@junobuild/core 0.0.48 → 0.0.49
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.
- package/declarations/satellite/satellite.did.d.ts +17 -3
- package/declarations/satellite/satellite.factory.did.js +23 -6
- package/declarations/satellite/satellite.factory.did.mjs +23 -6
- package/dist/browser/canisterStatus-TBLYKI2M.js +2 -0
- package/dist/browser/{chunk-DAMIJKS3.js → chunk-JAXPYESO.js} +8 -8
- package/dist/browser/{chunk-DAMIJKS3.js.map → chunk-JAXPYESO.js.map} +3 -3
- package/dist/browser/index.js +27 -27
- package/dist/browser/index.js.map +4 -4
- package/dist/declarations/satellite/satellite.did.d.ts +17 -3
- package/dist/declarations/satellite/satellite.factory.did.js +23 -6
- package/dist/declarations/satellite/satellite.factory.did.mjs +23 -6
- package/dist/node/index.mjs +36 -36
- package/dist/node/index.mjs.map +4 -4
- package/dist/types/api/doc.api.d.ts +1 -1
- package/dist/types/api/storage.api.d.ts +3 -3
- package/dist/types/services/doc.services.d.ts +9 -9
- package/dist/types/services/storage.services.d.ts +9 -9
- package/dist/types/types/doc.types.d.ts +1 -0
- package/dist/types/utils/actor.utils.d.ts +1 -1
- package/dist/workers/auth.worker.js +17 -12
- package/dist/workers/auth.worker.js.map +4 -4
- package/package.json +5 -5
- package/declarations/satellite/index.d.ts +0 -45
- package/declarations/satellite/index.js +0 -37
- package/dist/browser/canisterStatus-XBZ7P3SA.js +0 -2
- package/dist/declarations/satellite/index.d.ts +0 -45
- package/dist/declarations/satellite/index.js +0 -37
- /package/dist/browser/{canisterStatus-XBZ7P3SA.js.map → canisterStatus-TBLYKI2M.js.map} +0 -0
package/dist/node/index.mjs
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
import { createRequire as topLevelCreateRequire } from 'module';
|
|
2
2
|
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
-
var Qp=Object.create;var ts=Object.defineProperty;var ey=Object.getOwnPropertyDescriptor;var ty=Object.getOwnPropertyNames;var ry=Object.getPrototypeOf,ny=Object.prototype.hasOwnProperty;var Un=(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 ml=(t,e)=>()=>(t&&(e=t(t=0)),e);var L=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),iy=(t,e)=>{for(var r in e)ts(t,r,{get:e[r],enumerable:!0})},_l=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ty(e))!ny.call(t,i)&&i!==r&&ts(t,i,{get:()=>e[i],enumerable:!(n=ey(e,i))||n.enumerable});return t};var li=(t,e,r)=>(r=t!=null?Qp(ry(t)):{},_l(e||!t||!t.__esModule?ts(r,"default",{value:t,enumerable:!0}):r,t)),sy=t=>_l(ts({},"__esModule",{value:!0}),t);var wl=L(Mn=>{"use strict";Object.defineProperty(Mn,"__esModule",{value:!0});Mn.decode=Mn.encode=void 0;var rs="abcdefghijklmnopqrstuvwxyz234567",Fn=Object.create(null);for(let t=0;t<rs.length;t++)Fn[rs[t]]=t;Fn[0]=Fn.o;Fn[1]=Fn.i;function oy(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+=rs[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?rs[r>>3]:"")}Mn.encode=oy;function ay(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=Fn[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)}Mn.decode=ay});var xl=L(ns=>{"use strict";Object.defineProperty(ns,"__esModule",{value:!0});ns.getCrc32=void 0;var cy=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 uy(t){let e=new Uint8Array(t),r=-1;for(let n=0;n<e.length;n++){let s=(e[n]^r)&255;r=cy[s]^r>>>8}return(r^-1)>>>0}ns.getCrc32=uy});var ca=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 is(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}mt.number=is;function El(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}mt.bool=El;function vl(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}mt.isBytes=vl;function aa(t,...e){if(!vl(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=aa;function Bl(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");is(t.outputLen),is(t.blockLen)}mt.hash=Bl;function Tl(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=Tl;function Sl(t,e){aa(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}mt.output=Sl;var ly={number:is,bool:El,bytes:aa,hash:Bl,exists:Tl,output:Sl};mt.default=ly});var Al=L(os=>{"use strict";Object.defineProperty(os,"__esModule",{value:!0});os.crypto=void 0;var ss=Un("node:crypto");os.crypto=ss&&typeof ss=="object"&&"webcrypto"in ss?ss.webcrypto:void 0});var yn=L(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});pe.randomBytes=pe.wrapXOFConstructorWithOpts=pe.wrapConstructorWithOpts=pe.wrapConstructor=pe.checkOpts=pe.Hash=pe.concatBytes=pe.toBytes=pe.utf8ToBytes=pe.asyncLoop=pe.nextTick=pe.hexToBytes=pe.bytesToHex=pe.byteSwap32=pe.byteSwapIfBE=pe.byteSwap=pe.isLE=pe.rotl=pe.rotr=pe.createView=pe.u32=pe.u8=pe.isBytes=void 0;var ua=Al(),fa=ca();function fy(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}pe.isBytes=fy;var dy=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);pe.u8=dy;var hy=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));pe.u32=hy;var py=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);pe.createView=py;var yy=(t,e)=>t<<32-e|t>>>e;pe.rotr=yy;var by=(t,e)=>t<<e|t>>>32-e>>>0;pe.rotl=by;pe.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var gy=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;pe.byteSwap=gy;pe.byteSwapIfBE=pe.isLE?t=>t:t=>(0,pe.byteSwap)(t);function my(t){for(let e=0;e<t.length;e++)t[e]=(0,pe.byteSwap)(t[e])}pe.byteSwap32=my;var _y=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function wy(t){(0,fa.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=_y[t[r]];return e}pe.bytesToHex=wy;var Nr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Ol(t){if(t>=Nr._0&&t<=Nr._9)return t-Nr._0;if(t>=Nr._A&&t<=Nr._F)return t-(Nr._A-10);if(t>=Nr._a&&t<=Nr._f)return t-(Nr._a-10)}function xy(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=Ol(t.charCodeAt(s)),a=Ol(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}pe.hexToBytes=xy;var Ey=async()=>{};pe.nextTick=Ey;async function vy(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,pe.nextTick)(),n+=s)}}pe.asyncLoop=vy;function Nl(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}pe.utf8ToBytes=Nl;function as(t){return typeof t=="string"&&(t=Nl(t)),(0,fa.bytes)(t),t}pe.toBytes=as;function By(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];(0,fa.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}pe.concatBytes=By;var la=class{clone(){return this._cloneInto()}};pe.Hash=la;var Ty={}.toString;function Sy(t,e){if(e!==void 0&&Ty.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}pe.checkOpts=Sy;function Ay(t){let e=n=>t().update(as(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}pe.wrapConstructor=Ay;function Oy(t){let e=(n,i)=>t(i).update(as(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}pe.wrapConstructorWithOpts=Oy;function Ny(t){let e=(n,i)=>t(i).update(as(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}pe.wrapXOFConstructorWithOpts=Ny;function Py(t=32){if(ua.crypto&&typeof ua.crypto.getRandomValues=="function")return ua.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}pe.randomBytes=Py});var pa=L(Vr=>{"use strict";Object.defineProperty(Vr,"__esModule",{value:!0});Vr.HashMD=Vr.Maj=Vr.Chi=void 0;var da=ca(),fi=yn();function Ry(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,l=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+l,a,n)}var Iy=(t,e,r)=>t&e^~t&r;Vr.Chi=Iy;var Uy=(t,e,r)=>t&e^t&r^e&r;Vr.Maj=Uy;var ha=class extends fi.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,fi.createView)(this.buffer)}update(e){(0,da.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,fi.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,fi.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,da.exists)(this),(0,da.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 d=o;d<i;d++)r[d]=0;Ry(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=(0,fi.createView)(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)a.setUint32(4*d,f[d],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%r&&e.buffer.set(n),e}};Vr.HashMD=ha});var us=L(Cn=>{"use strict";Object.defineProperty(Cn,"__esModule",{value:!0});Cn.sha224=Cn.sha256=void 0;var ya=pa(),zt=yn(),Fy=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Hr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),$r=new Uint32Array(64),cs=class extends ya.HashMD{constructor(){super(64,32,8,!1),this.A=Hr[0]|0,this.B=Hr[1]|0,this.C=Hr[2]|0,this.D=Hr[3]|0,this.E=Hr[4]|0,this.F=Hr[5]|0,this.G=Hr[6]|0,this.H=Hr[7]|0}get(){let{A:e,B:r,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[e,r,n,i,s,o,a,c]}set(e,r,n,i,s,o,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let d=0;d<16;d++,r+=4)$r[d]=e.getUint32(r,!1);for(let d=16;d<64;d++){let v=$r[d-15],m=$r[d-2],x=(0,zt.rotr)(v,7)^(0,zt.rotr)(v,18)^v>>>3,w=(0,zt.rotr)(m,17)^(0,zt.rotr)(m,19)^m>>>10;$r[d]=w+$r[d-7]+x+$r[d-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:l,H:f}=this;for(let d=0;d<64;d++){let v=(0,zt.rotr)(a,6)^(0,zt.rotr)(a,11)^(0,zt.rotr)(a,25),m=f+v+(0,ya.Chi)(a,c,l)+Fy[d]+$r[d]|0,w=((0,zt.rotr)(n,2)^(0,zt.rotr)(n,13)^(0,zt.rotr)(n,22))+(0,ya.Maj)(n,i,s)|0;f=l,l=c,c=a,a=o+m|0,o=s,s=i,i=n,n=m+w|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,f=f+this.H|0,this.set(n,i,s,o,a,c,l,f)}roundClean(){$r.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},ba=class extends cs{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}};Cn.sha256=(0,zt.wrapConstructor)(()=>new cs);Cn.sha224=(0,zt.wrapConstructor)(()=>new ba)});var Pl=L(ls=>{"use strict";Object.defineProperty(ls,"__esModule",{value:!0});ls.sha224=void 0;var My=us();function Cy(t){return My.sha224.create().update(new Uint8Array(t)).digest()}ls.sha224=Cy});var Mt=L(fr=>{"use strict";Object.defineProperty(fr,"__esModule",{value:!0});fr.Principal=fr.JSON_KEY_PRINCIPAL=void 0;var Rl=wl(),qy=xl(),jy=Pl();fr.JSON_KEY_PRINCIPAL="__principal__";var ky=2,Il=4,Vy="aaaaa-aa",Hy=t=>{var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))},$y=t=>t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""),ga=class t{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Il]))}static managementCanister(){return this.fromHex(Vy)}static selfAuthenticating(e){let r=(0,jy.sha224)(e);return new this(new Uint8Array([...r,ky]))}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(Hy(e))}static fromText(e){let r=e;if(e.includes(fr.JSON_KEY_PRINCIPAL)){let o=JSON.parse(e);fr.JSON_KEY_PRINCIPAL in o&&(r=o[fr.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,Rl.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]===Il}toUint8Array(){return this._arr}toHex(){return $y(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,(0,qy.getCrc32)(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),a=(0,Rl.encode)(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}toJSON(){return{[fr.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"}};fr.Principal=ga});var Gl=L(ps=>{"use strict";ps.byteLength=Wy;ps.toByteArray=Zy;ps.fromByteArray=Ly;var hr=[],Zt=[],Dy=typeof Uint8Array<"u"?Uint8Array:Array,Ba="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(bn=0,$l=Ba.length;bn<$l;++bn)hr[bn]=Ba[bn],Zt[Ba.charCodeAt(bn)]=bn;var bn,$l;Zt[45]=62;Zt[95]=63;function Kl(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 Wy(t){var e=Kl(t),r=e[0],n=e[1];return(r+n)*3/4-n}function zy(t,e,r){return(e+r)*3/4-r}function Zy(t){var e,r=Kl(t),n=r[0],i=r[1],s=new Dy(zy(t,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=Zt[t.charCodeAt(c)]<<18|Zt[t.charCodeAt(c+1)]<<12|Zt[t.charCodeAt(c+2)]<<6|Zt[t.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=Zt[t.charCodeAt(c)]<<2|Zt[t.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=Zt[t.charCodeAt(c)]<<10|Zt[t.charCodeAt(c+1)]<<4|Zt[t.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function Xy(t){return hr[t>>18&63]+hr[t>>12&63]+hr[t>>6&63]+hr[t&63]}function Jy(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(Xy(n));return i.join("")}function Ly(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(Jy(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(hr[e>>2]+hr[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(hr[e>>10]+hr[e>>4&63]+hr[e<<2&63]+"=")),i.join("")}});var Sa=L(Ta=>{Ta.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,l=c>>1,f=-7,d=r?i-1:0,v=r?-1:1,m=t[e+d];for(d+=v,s=m&(1<<-f)-1,m>>=-f,f+=a;f>0;s=s*256+t[e+d],d+=v,f-=8);for(o=s&(1<<-f)-1,s>>=-f,f+=n;f>0;o=o*256+t[e+d],d+=v,f-=8);if(s===0)s=1-l;else{if(s===c)return o?NaN:(m?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-l}return(m?-1:1)*o*Math.pow(2,s-n)};Ta.write=function(t,e,r,n,i,s){var o,a,c,l=s*8-i-1,f=(1<<l)-1,d=f>>1,v=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,m=n?0:s-1,x=n?1:-1,w=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=f):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+d>=1?e+=v/c:e+=v*Math.pow(2,1-d),e*c>=2&&(o++,c/=2),o+d>=f?(a=0,o=f):o+d>=1?(a=(e*c-1)*Math.pow(2,i),o=o+d):(a=e*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;t[r+m]=a&255,m+=x,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;t[r+m]=o&255,m+=x,o/=256,l-=8);t[r+m-x]|=w*128}});var cf=L($n=>{"use strict";var Aa=Gl(),Vn=Sa(),Yl=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;$n.Buffer=V;$n.SlowBuffer=ib;$n.INSPECT_MAX_BYTES=50;var ys=2147483647;$n.kMaxLength=ys;V.TYPED_ARRAY_SUPPORT=Qy();!V.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 Qy(){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(V.prototype,"parent",{enumerable:!0,get:function(){if(V.isBuffer(this))return this.buffer}});Object.defineProperty(V.prototype,"offset",{enumerable:!0,get:function(){if(V.isBuffer(this))return this.byteOffset}});function Rr(t){if(t>ys)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,V.prototype),e}function V(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 Ra(t)}return Zl(t,e,r)}V.poolSize=8192;function Zl(t,e,r){if(typeof t=="string")return tb(t,e);if(ArrayBuffer.isView(t))return rb(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(pr(t,ArrayBuffer)||t&&pr(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(pr(t,SharedArrayBuffer)||t&&pr(t.buffer,SharedArrayBuffer)))return Na(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 V.from(n,e,r);let i=nb(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return V.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)}V.from=function(t,e,r){return Zl(t,e,r)};Object.setPrototypeOf(V.prototype,Uint8Array.prototype);Object.setPrototypeOf(V,Uint8Array);function Xl(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 eb(t,e,r){return Xl(t),t<=0?Rr(t):e!==void 0?typeof r=="string"?Rr(t).fill(e,r):Rr(t).fill(e):Rr(t)}V.alloc=function(t,e,r){return eb(t,e,r)};function Ra(t){return Xl(t),Rr(t<0?0:Ia(t)|0)}V.allocUnsafe=function(t){return Ra(t)};V.allocUnsafeSlow=function(t){return Ra(t)};function tb(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!V.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=Jl(t,e)|0,n=Rr(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Oa(t){let e=t.length<0?0:Ia(t.length)|0,r=Rr(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function rb(t){if(pr(t,Uint8Array)){let e=new Uint8Array(t);return Na(e.buffer,e.byteOffset,e.byteLength)}return Oa(t)}function Na(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,V.prototype),n}function nb(t){if(V.isBuffer(t)){let e=Ia(t.length)|0,r=Rr(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Fa(t.length)?Rr(0):Oa(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Oa(t.data)}function Ia(t){if(t>=ys)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ys.toString(16)+" bytes");return t|0}function ib(t){return+t!=t&&(t=0),V.alloc(+t)}V.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==V.prototype};V.compare=function(e,r){if(pr(e,Uint8Array)&&(e=V.from(e,e.offset,e.byteLength)),pr(r,Uint8Array)&&(r=V.from(r,r.offset,r.byteLength)),!V.isBuffer(e)||!V.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};V.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}};V.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return V.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=V.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(pr(o,Uint8Array))s+o.length>i.length?(V.isBuffer(o)||(o=V.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(V.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function Jl(t,e){if(V.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||pr(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 Pa(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return af(t).length;default:if(i)return n?-1:Pa(t).length;e=(""+e).toLowerCase(),i=!0}}V.byteLength=Jl;function sb(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 yb(this,e,r);case"utf8":case"utf-8":return Ql(this,e,r);case"ascii":return hb(this,e,r);case"latin1":case"binary":return pb(this,e,r);case"base64":return fb(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return bb(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}V.prototype._isBuffer=!0;function gn(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}V.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)gn(this,r,r+1);return this};V.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)gn(this,r,r+3),gn(this,r+1,r+2);return this};V.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)gn(this,r,r+7),gn(this,r+1,r+6),gn(this,r+2,r+5),gn(this,r+3,r+4);return this};V.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Ql(this,0,e):sb.apply(this,arguments)};V.prototype.toLocaleString=V.prototype.toString;V.prototype.equals=function(e){if(!V.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:V.compare(this,e)===0};V.prototype.inspect=function(){let e="",r=$n.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};Yl&&(V.prototype[Yl]=V.prototype.inspect);V.prototype.compare=function(e,r,n,i,s){if(pr(e,Uint8Array)&&(e=V.from(e,e.offset,e.byteLength)),!V.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),l=this.slice(i,s),f=e.slice(r,n);for(let d=0;d<c;++d)if(l[d]!==f[d]){o=l[d],a=f[d];break}return o<a?-1:a<o?1:0};function Ll(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,Fa(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=V.from(e,n)),V.isBuffer(e))return e.length===0?-1:Dl(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):Dl(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Dl(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(f,d){return s===1?f[d]:f.readUInt16BE(d*s)}let l;if(i){let f=-1;for(l=r;l<o;l++)if(c(t,l)===c(e,f===-1?0:l-f)){if(f===-1&&(f=l),l-f+1===a)return f*s}else f!==-1&&(l-=l-f),f=-1}else for(r+a>o&&(r=o-a),l=r;l>=0;l--){let f=!0;for(let d=0;d<a;d++)if(c(t,l+d)!==c(e,d)){f=!1;break}if(f)return l}return-1}V.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};V.prototype.indexOf=function(e,r,n){return Ll(this,e,r,n,!0)};V.prototype.lastIndexOf=function(e,r,n){return Ll(this,e,r,n,!1)};function ob(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(Fa(a))return o;t[r+o]=a}return o}function ab(t,e,r,n){return bs(Pa(e,t.length-r),t,r,n)}function cb(t,e,r,n){return bs(wb(e),t,r,n)}function ub(t,e,r,n){return bs(af(e),t,r,n)}function lb(t,e,r,n){return bs(xb(e,t.length-r),t,r,n)}V.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 ob(this,e,r,n);case"utf8":case"utf-8":return ab(this,e,r,n);case"ascii":case"latin1":case"binary":return cb(this,e,r,n);case"base64":return ub(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return lb(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};V.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function fb(t,e,r){return e===0&&r===t.length?Aa.fromByteArray(t):Aa.fromByteArray(t.slice(e,r))}function Ql(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,l,f,d;switch(a){case 1:s<128&&(o=s);break;case 2:c=t[i+1],(c&192)===128&&(d=(s&31)<<6|c&63,d>127&&(o=d));break;case 3:c=t[i+1],l=t[i+2],(c&192)===128&&(l&192)===128&&(d=(s&15)<<12|(c&63)<<6|l&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:c=t[i+1],l=t[i+2],f=t[i+3],(c&192)===128&&(l&192)===128&&(f&192)===128&&(d=(s&15)<<18|(c&63)<<12|(l&63)<<6|f&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return db(n)}var Wl=4096;function db(t){let e=t.length;if(e<=Wl)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Wl));return r}function hb(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 pb(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 yb(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+=Eb[t[s]];return i}function bb(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}V.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,V.prototype),i};function pt(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")}V.prototype.readUintLE=V.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||pt(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};V.prototype.readUintBE=V.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||pt(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};V.prototype.readUint8=V.prototype.readUInt8=function(e,r){return e=e>>>0,r||pt(e,1,this.length),this[e]};V.prototype.readUint16LE=V.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||pt(e,2,this.length),this[e]|this[e+1]<<8};V.prototype.readUint16BE=V.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||pt(e,2,this.length),this[e]<<8|this[e+1]};V.prototype.readUint32LE=V.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||pt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};V.prototype.readUint32BE=V.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||pt(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};V.prototype.readBigUInt64LE=Kr(function(e){e=e>>>0,Hn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&di(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))});V.prototype.readBigUInt64BE=Kr(function(e){e=e>>>0,Hn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&di(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)});V.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||pt(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};V.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||pt(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};V.prototype.readInt8=function(e,r){return e=e>>>0,r||pt(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};V.prototype.readInt16LE=function(e,r){e=e>>>0,r||pt(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};V.prototype.readInt16BE=function(e,r){e=e>>>0,r||pt(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};V.prototype.readInt32LE=function(e,r){return e=e>>>0,r||pt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};V.prototype.readInt32BE=function(e,r){return e=e>>>0,r||pt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};V.prototype.readBigInt64LE=Kr(function(e){e=e>>>0,Hn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&di(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)});V.prototype.readBigInt64BE=Kr(function(e){e=e>>>0,Hn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&di(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)});V.prototype.readFloatLE=function(e,r){return e=e>>>0,r||pt(e,4,this.length),Vn.read(this,e,!0,23,4)};V.prototype.readFloatBE=function(e,r){return e=e>>>0,r||pt(e,4,this.length),Vn.read(this,e,!1,23,4)};V.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||pt(e,8,this.length),Vn.read(this,e,!0,52,8)};V.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||pt(e,8,this.length),Vn.read(this,e,!1,52,8)};function Ct(t,e,r,n,i,s){if(!V.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")}V.prototype.writeUintLE=V.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;Ct(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};V.prototype.writeUintBE=V.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;Ct(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};V.prototype.writeUint8=V.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||Ct(this,e,r,1,255,0),this[r]=e&255,r+1};V.prototype.writeUint16LE=V.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Ct(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};V.prototype.writeUint16BE=V.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Ct(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};V.prototype.writeUint32LE=V.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Ct(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};V.prototype.writeUint32BE=V.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Ct(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 ef(t,e,r,n,i){of(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 tf(t,e,r,n,i){of(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}V.prototype.writeBigUInt64LE=Kr(function(e,r=0){return ef(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});V.prototype.writeBigUInt64BE=Kr(function(e,r=0){return tf(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});V.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Ct(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};V.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Ct(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};V.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||Ct(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};V.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Ct(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};V.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Ct(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};V.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Ct(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};V.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Ct(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};V.prototype.writeBigInt64LE=Kr(function(e,r=0){return ef(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});V.prototype.writeBigInt64BE=Kr(function(e,r=0){return tf(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function rf(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 nf(t,e,r,n,i){return e=+e,r=r>>>0,i||rf(t,e,r,4,34028234663852886e22,-34028234663852886e22),Vn.write(t,e,r,n,23,4),r+4}V.prototype.writeFloatLE=function(e,r,n){return nf(this,e,r,!0,n)};V.prototype.writeFloatBE=function(e,r,n){return nf(this,e,r,!1,n)};function sf(t,e,r,n,i){return e=+e,r=r>>>0,i||rf(t,e,r,8,17976931348623157e292,-17976931348623157e292),Vn.write(t,e,r,n,52,8),r+8}V.prototype.writeDoubleLE=function(e,r,n){return sf(this,e,r,!0,n)};V.prototype.writeDoubleBE=function(e,r,n){return sf(this,e,r,!1,n)};V.prototype.copy=function(e,r,n,i){if(!V.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};V.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"&&!V.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=V.isBuffer(e)?e:V.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 kn={};function Ua(t,e,r){kn[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}`}}}Ua("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Ua("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Ua("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=zl(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=zl(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function zl(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 gb(t,e,r){Hn(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&di(e,t.length-(r+1))}function of(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 kn.ERR_OUT_OF_RANGE("value",a,t)}gb(n,i,s)}function Hn(t,e){if(typeof t!="number")throw new kn.ERR_INVALID_ARG_TYPE(e,"number",t)}function di(t,e,r){throw Math.floor(t)!==t?(Hn(t,r),new kn.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new kn.ERR_BUFFER_OUT_OF_BOUNDS:new kn.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var mb=/[^+/0-9A-Za-z-_]/g;function _b(t){if(t=t.split("=")[0],t=t.trim().replace(mb,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Pa(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 wb(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function xb(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 af(t){return Aa.toByteArray(_b(t))}function bs(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 pr(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Fa(t){return t!==t}var Eb=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 Kr(t){return typeof BigInt>"u"?vb:t}function vb(){throw new Error("BigInt not supported")}});var uf=L(hi=>{"use strict";Object.defineProperty(hi,"__esModule",{value:!0});hi.ReplicaRejectCode=void 0;var Bb;(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"})(Bb=hi.ReplicaRejectCode||(hi.ReplicaRejectCode={}))});var Kn=L(gs=>{"use strict";Object.defineProperty(gs,"__esModule",{value:!0});gs.AgentError=void 0;var Ma=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};gs.AgentError=Ma});var ws=L(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.bufFromBufLike=qt.uint8ToBuf=qt.PipeArrayBuffer=qt.fromHexString=qt.toHexString=qt.concat=void 0;function Tb(...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}qt.concat=Tb;function Sb(t){return new Uint8Array(t).reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}qt.toHexString=Sb;function Ab(t){var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))}qt.fromHexString=Ab;var Ca=class{constructor(e,r=e?.byteLength||0){this._buffer=_s(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return _s(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}};qt.PipeArrayBuffer=Ca;function ms(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}qt.uint8ToBuf=ms;function _s(t){return t instanceof Uint8Array?ms(t):t instanceof ArrayBuffer?t:Array.isArray(t)?ms(new Uint8Array(t)):"buffer"in t?_s(t.buffer):ms(new Uint8Array(t))}qt.bufFromBufLike=_s});var qa=L(xs=>{"use strict";Object.defineProperty(xs,"__esModule",{value:!0});xs.idlLabelToId=void 0;function Ob(t){let r=new TextEncoder().encode(t),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function Nb(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 Ob(t)}xs.idlLabelToId=Nb});var ka=L(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.readIntLE=Ze.readUIntLE=Ze.writeIntLE=Ze.writeUIntLE=Ze.slebDecode=Ze.slebEncode=Ze.lebDecode=Ze.lebEncode=Ze.safeReadUint8=Ze.safeRead=void 0;var ja=ws();function lf(){throw new Error("unexpected end of buffer")}function ff(t,e){return t.byteLength<e&&lf(),t.read(e)}Ze.safeRead=ff;function Es(t){let e=t.readUint8();return e===void 0&&lf(),e}Ze.safeReadUint8=Es;function Pb(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 ja.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}Ze.lebEncode=Pb;function df(t){let e=BigInt(1),r=BigInt(0),n;do n=Es(t),r+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return r}Ze.lebDecode=df;function Rb(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 ja.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}Ze.slebEncode=Rb;function Ib(t){let e=new Uint8Array(t.buffer),r=0;for(;r<e.byteLength;r++)if(e[r]<128){if(!(e[r]&64))return df(t);break}let n=new Uint8Array(ff(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)}Ze.slebDecode=Ib;function Ub(t,e){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return hf(t,e)}Ze.writeUIntLE=Ub;function hf(t,e){t=BigInt(t);let r=new ja.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}Ze.writeIntLE=hf;function pf(t,e){let r=BigInt(Es(t)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(Es(t));r=r+n*s}return r}Ze.readUIntLE=pf;function Fb(t,e){let r=pf(t,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}Ze.readIntLE=Fb});var yf=L(Gn=>{"use strict";Object.defineProperty(Gn,"__esModule",{value:!0});Gn.iexp2=Gn.ilog2=void 0;function Mb(t){let e=BigInt(t);if(t<=0)throw new RangeError("Input must be positive");return e.toString(2).length-1}Gn.ilog2=Mb;function Cb(t){let e=BigInt(t);if(t<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}Gn.iexp2=Cb});var Ga=L(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.Variant=H.Record=H.Opt=H.Vec=H.Tuple=H.Principal=H.Nat64=H.Nat32=H.Nat16=H.Nat8=H.Int64=H.Int32=H.Int16=H.Int8=H.Float64=H.Float32=H.Nat=H.Int=H.Text=H.Null=H.Bool=H.Unknown=H.Reserved=H.Empty=H.decode=H.encode=H.ServiceClass=H.FuncClass=H.PrincipalClass=H.RecClass=H.VariantClass=H.TupleClass=H.RecordClass=H.OptClass=H.VecClass=H.FixedNatClass=H.FixedIntClass=H.FloatClass=H.NatClass=H.IntClass=H.TextClass=H.ReservedClass=H.NullClass=H.BoolClass=H.UnknownClass=H.EmptyClass=H.ConstructType=H.PrimitiveType=H.Type=H.Visitor=void 0;H.Service=H.Func=H.Rec=void 0;var qb=Mt(),Pe=ws(),yr=qa(),ne=ka(),Va=yf(),vs="DIDL",bf=400;function pi(t,e,r){return t.map((n,i)=>r(n,e[i]))}var Ha=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,ne.lebEncode)(this._typs.length),r=(0,Pe.concat)(...this._typs);return(0,Pe.concat)(e,r)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return(0,ne.slebEncode)(this._idx.get(e)||0)}},$a=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)}};H.Visitor=$a;var Yn=class{display(){return this.name}valueToString(e){return et(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}};H.Type=Yn;var jt=class extends Yn{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){}};H.PrimitiveType=jt;var gr=class extends Yn{checkType(e){if(e instanceof Gr){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)}};H.ConstructType=gr;var Bs=class extends jt{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,ne.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};H.EmptyClass=Bs;var Ts=class extends Yn{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 Gr?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"}};H.UnknownClass=Ts;var Ss=class extends jt{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,ne.slebEncode)(-2)}decodeValue(e,r){switch(this.checkType(r),(0,ne.safeReadUint8)(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};H.BoolClass=Ss;var As=class extends jt{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,ne.slebEncode)(-1)}decodeValue(e,r){return this.checkType(r),null}get name(){return"null"}};H.NullClass=As;var Dn=class extends jt{accept(e,r){return e.visitReserved(this,r)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ne.slebEncode)(-16)}decodeValue(e,r){return r.name!==this.name&&r.decodeValue(e,r),null}get name(){return"reserved"}};H.ReservedClass=Dn;var Os=class extends jt{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,ne.lebEncode)(r.byteLength);return(0,Pe.concat)(n,r)}encodeType(){return(0,ne.slebEncode)(-15)}decodeValue(e,r){this.checkType(r);let n=(0,ne.lebDecode)(e),i=(0,ne.safeRead)(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}};H.TextClass=Os;var Ns=class extends jt{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,ne.slebEncode)(e)}encodeType(){return(0,ne.slebEncode)(-4)}decodeValue(e,r){return this.checkType(r),(0,ne.slebDecode)(e)}get name(){return"int"}valueToString(e){return e.toString()}};H.IntClass=Ns;var Ps=class extends jt{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,ne.lebEncode)(e)}encodeType(){return(0,ne.slebEncode)(-3)}decodeValue(e,r){return this.checkType(r),(0,ne.lebDecode)(e)}get name(){return"nat"}valueToString(e){return e.toString()}};H.NatClass=Ps;var yi=class extends jt{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,ne.slebEncode)(e)}decodeValue(e,r){this.checkType(r);let n=(0,ne.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()}};H.FloatClass=yi;var Ir=class extends jt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedInt(this,r)}covariant(e){let r=(0,Va.iexp2)(this._bits-1)*BigInt(-1),n=(0,Va.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,ne.writeIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,ne.slebEncode)(-9-e)}decodeValue(e,r){this.checkType(r);let n=(0,ne.readIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}};H.FixedIntClass=Ir;var br=class extends jt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedNat(this,r)}covariant(e){let r=(0,Va.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,ne.writeUIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,ne.slebEncode)(-5-e)}decodeValue(e,r){this.checkType(r);let n=(0,ne.readUIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}};H.FixedNatClass=br;var Rs=class t extends gr{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof br&&e._bits===8&&(this._blobOptimization=!0)}accept(e,r){return e.visitVec(this,this._type,r)}covariant(e){let r=this._type instanceof br?this._type._bits:this._type instanceof Ir?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 Ey=Object.create;var fs=Object.defineProperty;var vy=Object.getOwnPropertyDescriptor;var By=Object.getOwnPropertyNames;var Ty=Object.getPrototypeOf,Sy=Object.prototype.hasOwnProperty;var Vn=(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 Cf=(t,e)=>()=>(t&&(e=t(t=0)),e);var J=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ay=(t,e)=>{for(var r in e)fs(t,r,{get:e[r],enumerable:!0})},qf=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of By(e))!Sy.call(t,i)&&i!==r&&fs(t,i,{get:()=>e[i],enumerable:!(n=vy(e,i))||n.enumerable});return t};var wi=(t,e,r)=>(r=t!=null?Ey(Ty(t)):{},qf(e||!t||!t.__esModule?fs(r,"default",{value:t,enumerable:!0}):r,t)),Oy=t=>qf(fs({},"__esModule",{value:!0}),t);var jf=J($n=>{"use strict";Object.defineProperty($n,"__esModule",{value:!0});$n.decode=$n.encode=void 0;var ls="abcdefghijklmnopqrstuvwxyz234567",Hn=Object.create(null);for(let t=0;t<ls.length;t++)Hn[ls[t]]=t;Hn[0]=Hn.o;Hn[1]=Hn.i;function Ny(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+=ls[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?ls[r>>3]:"")}$n.encode=Ny;function Py(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=Hn[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)}$n.decode=Py});var kf=J(ds=>{"use strict";Object.defineProperty(ds,"__esModule",{value:!0});ds.getCrc32=void 0;var Ry=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 Iy(t){let e=new Uint8Array(t),r=-1;for(let n=0;n<e.length;n++){let s=(e[n]^r)&255;r=Ry[s]^r>>>8}return(r^-1)>>>0}ds.getCrc32=Iy});var Sa=J(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.output=_t.exists=_t.hash=_t.bytes=_t.bool=_t.number=_t.isBytes=void 0;function hs(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}_t.number=hs;function Vf(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}_t.bool=Vf;function Hf(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}_t.isBytes=Hf;function Ta(t,...e){if(!Hf(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}`)}_t.bytes=Ta;function $f(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");hs(t.outputLen),hs(t.blockLen)}_t.hash=$f;function Kf(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")}_t.exists=Kf;function Gf(t,e){Ta(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}_t.output=Gf;var Uy={number:hs,bool:Vf,bytes:Ta,hash:$f,exists:Kf,output:Gf};_t.default=Uy});var Yf=J(ys=>{"use strict";Object.defineProperty(ys,"__esModule",{value:!0});ys.crypto=void 0;var ps=Vn("node:crypto");ys.crypto=ps&&typeof ps=="object"&&"webcrypto"in ps?ps.webcrypto:void 0});var xn=J(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});pe.randomBytes=pe.wrapXOFConstructorWithOpts=pe.wrapConstructorWithOpts=pe.wrapConstructor=pe.checkOpts=pe.Hash=pe.concatBytes=pe.toBytes=pe.utf8ToBytes=pe.asyncLoop=pe.nextTick=pe.hexToBytes=pe.bytesToHex=pe.byteSwap32=pe.byteSwapIfBE=pe.byteSwap=pe.isLE=pe.rotl=pe.rotr=pe.createView=pe.u32=pe.u8=pe.isBytes=void 0;var Aa=Yf(),Na=Sa();function Fy(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}pe.isBytes=Fy;var My=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);pe.u8=My;var Cy=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));pe.u32=Cy;var qy=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);pe.createView=qy;var jy=(t,e)=>t<<32-e|t>>>e;pe.rotr=jy;var ky=(t,e)=>t<<e|t>>>32-e>>>0;pe.rotl=ky;pe.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var Vy=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;pe.byteSwap=Vy;pe.byteSwapIfBE=pe.isLE?t=>t:t=>(0,pe.byteSwap)(t);function Hy(t){for(let e=0;e<t.length;e++)t[e]=(0,pe.byteSwap)(t[e])}pe.byteSwap32=Hy;var $y=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ky(t){(0,Na.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=$y[t[r]];return e}pe.bytesToHex=Ky;var Mr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Wf(t){if(t>=Mr._0&&t<=Mr._9)return t-Mr._0;if(t>=Mr._A&&t<=Mr._F)return t-(Mr._A-10);if(t>=Mr._a&&t<=Mr._f)return t-(Mr._a-10)}function Gy(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=Wf(t.charCodeAt(s)),a=Wf(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}pe.hexToBytes=Gy;var Yy=async()=>{};pe.nextTick=Yy;async function Wy(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,pe.nextTick)(),n+=s)}}pe.asyncLoop=Wy;function zf(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}pe.utf8ToBytes=zf;function bs(t){return typeof t=="string"&&(t=zf(t)),(0,Na.bytes)(t),t}pe.toBytes=bs;function zy(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];(0,Na.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}pe.concatBytes=zy;var Oa=class{clone(){return this._cloneInto()}};pe.Hash=Oa;var Dy={}.toString;function Zy(t,e){if(e!==void 0&&Dy.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}pe.checkOpts=Zy;function Xy(t){let e=n=>t().update(bs(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}pe.wrapConstructor=Xy;function Jy(t){let e=(n,i)=>t(i).update(bs(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}pe.wrapConstructorWithOpts=Jy;function Ly(t){let e=(n,i)=>t(i).update(bs(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}pe.wrapXOFConstructorWithOpts=Ly;function Qy(t=32){if(Aa.crypto&&typeof Aa.crypto.getRandomValues=="function")return Aa.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}pe.randomBytes=Qy});var Ia=J(Wr=>{"use strict";Object.defineProperty(Wr,"__esModule",{value:!0});Wr.HashMD=Wr.Maj=Wr.Chi=void 0;var Pa=Sa(),xi=xn();function eb(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 tb=(t,e,r)=>t&e^~t&r;Wr.Chi=tb;var rb=(t,e,r)=>t&e^t&r^e&r;Wr.Maj=rb;var Ra=class extends xi.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,xi.createView)(this.buffer)}update(e){(0,Pa.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,xi.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,xi.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,Pa.exists)(this),(0,Pa.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 d=o;d<i;d++)r[d]=0;eb(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=(0,xi.createView)(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,l=this.get();if(f>l.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,l[d],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%r&&e.buffer.set(n),e}};Wr.HashMD=Ra});var ms=J(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});Kn.sha224=Kn.sha256=void 0;var Ua=Ia(),Zt=xn(),nb=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]),zr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Dr=new Uint32Array(64),gs=class extends Ua.HashMD{constructor(){super(64,32,8,!1),this.A=zr[0]|0,this.B=zr[1]|0,this.C=zr[2]|0,this.D=zr[3]|0,this.E=zr[4]|0,this.F=zr[5]|0,this.G=zr[6]|0,this.H=zr[7]|0}get(){let{A:e,B:r,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[e,r,n,i,s,o,a,c]}set(e,r,n,i,s,o,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let d=0;d<16;d++,r+=4)Dr[d]=e.getUint32(r,!1);for(let d=16;d<64;d++){let v=Dr[d-15],w=Dr[d-2],g=(0,Zt.rotr)(v,7)^(0,Zt.rotr)(v,18)^v>>>3,x=(0,Zt.rotr)(w,17)^(0,Zt.rotr)(w,19)^w>>>10;Dr[d]=x+Dr[d-7]+g+Dr[d-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:f,H:l}=this;for(let d=0;d<64;d++){let v=(0,Zt.rotr)(a,6)^(0,Zt.rotr)(a,11)^(0,Zt.rotr)(a,25),w=l+v+(0,Ua.Chi)(a,c,f)+nb[d]+Dr[d]|0,x=((0,Zt.rotr)(n,2)^(0,Zt.rotr)(n,13)^(0,Zt.rotr)(n,22))+(0,Ua.Maj)(n,i,s)|0;l=f,f=c,c=a,a=o+w|0,o=s,s=i,i=n,n=w+x|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,l=l+this.H|0,this.set(n,i,s,o,a,c,f,l)}roundClean(){Dr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Fa=class extends gs{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}};Kn.sha256=(0,Zt.wrapConstructor)(()=>new gs);Kn.sha224=(0,Zt.wrapConstructor)(()=>new Fa)});var Df=J(_s=>{"use strict";Object.defineProperty(_s,"__esModule",{value:!0});_s.sha224=void 0;var ib=ms();function sb(t){return ib.sha224.create().update(new Uint8Array(t)).digest()}_s.sha224=sb});var Ct=J(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.Principal=hr.JSON_KEY_PRINCIPAL=void 0;var Zf=jf(),ob=kf(),ab=Df();hr.JSON_KEY_PRINCIPAL="__principal__";var cb=2,Xf=4,ub="aaaaa-aa",fb=t=>{var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))},lb=t=>t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""),Ma=class t{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Xf]))}static managementCanister(){return this.fromHex(ub)}static selfAuthenticating(e){let r=(0,ab.sha224)(e);return new this(new Uint8Array([...r,cb]))}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(fb(e))}static fromText(e){let r=e;if(e.includes(hr.JSON_KEY_PRINCIPAL)){let o=JSON.parse(e);hr.JSON_KEY_PRINCIPAL in o&&(r=o[hr.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,Zf.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]===Xf}toUint8Array(){return this._arr}toHex(){return lb(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,(0,ob.getCrc32)(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),a=(0,Zf.encode)(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}toJSON(){return{[hr.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"}};hr.Principal=Ma});var cl=J(vs=>{"use strict";vs.byteLength=bb;vs.toByteArray=mb;vs.fromByteArray=xb;var yr=[],Xt=[],yb=typeof Uint8Array<"u"?Uint8Array:Array,$a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(En=0,ol=$a.length;En<ol;++En)yr[En]=$a[En],Xt[$a.charCodeAt(En)]=En;var En,ol;Xt[45]=62;Xt[95]=63;function al(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 bb(t){var e=al(t),r=e[0],n=e[1];return(r+n)*3/4-n}function gb(t,e,r){return(e+r)*3/4-r}function mb(t){var e,r=al(t),n=r[0],i=r[1],s=new yb(gb(t,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=Xt[t.charCodeAt(c)]<<18|Xt[t.charCodeAt(c+1)]<<12|Xt[t.charCodeAt(c+2)]<<6|Xt[t.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=Xt[t.charCodeAt(c)]<<2|Xt[t.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=Xt[t.charCodeAt(c)]<<10|Xt[t.charCodeAt(c+1)]<<4|Xt[t.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function _b(t){return yr[t>>18&63]+yr[t>>12&63]+yr[t>>6&63]+yr[t&63]}function wb(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(_b(n));return i.join("")}function xb(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(wb(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(yr[e>>2]+yr[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(yr[e>>10]+yr[e>>4&63]+yr[e<<2&63]+"=")),i.join("")}});var Ga=J(Ka=>{Ka.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,f=c>>1,l=-7,d=r?i-1:0,v=r?-1:1,w=t[e+d];for(d+=v,s=w&(1<<-l)-1,w>>=-l,l+=a;l>0;s=s*256+t[e+d],d+=v,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=o*256+t[e+d],d+=v,l-=8);if(s===0)s=1-f;else{if(s===c)return o?NaN:(w?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-f}return(w?-1:1)*o*Math.pow(2,s-n)};Ka.write=function(t,e,r,n,i,s){var o,a,c,f=s*8-i-1,l=(1<<f)-1,d=l>>1,v=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=n?0:s-1,g=n?1:-1,x=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+d>=1?e+=v/c:e+=v*Math.pow(2,1-d),e*c>=2&&(o++,c/=2),o+d>=l?(a=0,o=l):o+d>=1?(a=(e*c-1)*Math.pow(2,i),o=o+d):(a=e*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;t[r+w]=a&255,w+=g,a/=256,i-=8);for(o=o<<i|a,f+=i;f>0;t[r+w]=o&255,w+=g,o/=256,f-=8);t[r+w-g]|=x*128}});var Tl=J(Zn=>{"use strict";var Ya=cl(),zn=Ga(),ul=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Zn.Buffer=V;Zn.SlowBuffer=Ab;Zn.INSPECT_MAX_BYTES=50;var Bs=2147483647;Zn.kMaxLength=Bs;V.TYPED_ARRAY_SUPPORT=Eb();!V.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 Eb(){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(V.prototype,"parent",{enumerable:!0,get:function(){if(V.isBuffer(this))return this.buffer}});Object.defineProperty(V.prototype,"offset",{enumerable:!0,get:function(){if(V.isBuffer(this))return this.byteOffset}});function qr(t){if(t>Bs)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,V.prototype),e}function V(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 Za(t)}return hl(t,e,r)}V.poolSize=8192;function hl(t,e,r){if(typeof t=="string")return Bb(t,e);if(ArrayBuffer.isView(t))return Tb(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(br(t,ArrayBuffer)||t&&br(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(br(t,SharedArrayBuffer)||t&&br(t.buffer,SharedArrayBuffer)))return za(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 V.from(n,e,r);let i=Sb(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return V.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)}V.from=function(t,e,r){return hl(t,e,r)};Object.setPrototypeOf(V.prototype,Uint8Array.prototype);Object.setPrototypeOf(V,Uint8Array);function pl(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 vb(t,e,r){return pl(t),t<=0?qr(t):e!==void 0?typeof r=="string"?qr(t).fill(e,r):qr(t).fill(e):qr(t)}V.alloc=function(t,e,r){return vb(t,e,r)};function Za(t){return pl(t),qr(t<0?0:Xa(t)|0)}V.allocUnsafe=function(t){return Za(t)};V.allocUnsafeSlow=function(t){return Za(t)};function Bb(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!V.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=yl(t,e)|0,n=qr(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Wa(t){let e=t.length<0?0:Xa(t.length)|0,r=qr(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function Tb(t){if(br(t,Uint8Array)){let e=new Uint8Array(t);return za(e.buffer,e.byteOffset,e.byteLength)}return Wa(t)}function za(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,V.prototype),n}function Sb(t){if(V.isBuffer(t)){let e=Xa(t.length)|0,r=qr(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||La(t.length)?qr(0):Wa(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Wa(t.data)}function Xa(t){if(t>=Bs)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Bs.toString(16)+" bytes");return t|0}function Ab(t){return+t!=t&&(t=0),V.alloc(+t)}V.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==V.prototype};V.compare=function(e,r){if(br(e,Uint8Array)&&(e=V.from(e,e.offset,e.byteLength)),br(r,Uint8Array)&&(r=V.from(r,r.offset,r.byteLength)),!V.isBuffer(e)||!V.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};V.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}};V.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return V.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=V.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(br(o,Uint8Array))s+o.length>i.length?(V.isBuffer(o)||(o=V.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(V.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function yl(t,e){if(V.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||br(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 Da(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Bl(t).length;default:if(i)return n?-1:Da(t).length;e=(""+e).toLowerCase(),i=!0}}V.byteLength=yl;function Ob(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 jb(this,e,r);case"utf8":case"utf-8":return gl(this,e,r);case"ascii":return Cb(this,e,r);case"latin1":case"binary":return qb(this,e,r);case"base64":return Fb(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return kb(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}V.prototype._isBuffer=!0;function vn(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}V.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)vn(this,r,r+1);return this};V.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)vn(this,r,r+3),vn(this,r+1,r+2);return this};V.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)vn(this,r,r+7),vn(this,r+1,r+6),vn(this,r+2,r+5),vn(this,r+3,r+4);return this};V.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?gl(this,0,e):Ob.apply(this,arguments)};V.prototype.toLocaleString=V.prototype.toString;V.prototype.equals=function(e){if(!V.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:V.compare(this,e)===0};V.prototype.inspect=function(){let e="",r=Zn.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};ul&&(V.prototype[ul]=V.prototype.inspect);V.prototype.compare=function(e,r,n,i,s){if(br(e,Uint8Array)&&(e=V.from(e,e.offset,e.byteLength)),!V.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,a=n-r,c=Math.min(o,a),f=this.slice(i,s),l=e.slice(r,n);for(let d=0;d<c;++d)if(f[d]!==l[d]){o=f[d],a=l[d];break}return o<a?-1:a<o?1:0};function bl(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,La(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=V.from(e,n)),V.isBuffer(e))return e.length===0?-1:fl(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):fl(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function fl(t,e,r,n,i){let s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(l,d){return s===1?l[d]:l.readUInt16BE(d*s)}let f;if(i){let l=-1;for(f=r;f<o;f++)if(c(t,f)===c(e,l===-1?0:f-l)){if(l===-1&&(l=f),f-l+1===a)return l*s}else l!==-1&&(f-=f-l),l=-1}else for(r+a>o&&(r=o-a),f=r;f>=0;f--){let l=!0;for(let d=0;d<a;d++)if(c(t,f+d)!==c(e,d)){l=!1;break}if(l)return f}return-1}V.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};V.prototype.indexOf=function(e,r,n){return bl(this,e,r,n,!0)};V.prototype.lastIndexOf=function(e,r,n){return bl(this,e,r,n,!1)};function Nb(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(La(a))return o;t[r+o]=a}return o}function Pb(t,e,r,n){return Ts(Da(e,t.length-r),t,r,n)}function Rb(t,e,r,n){return Ts(Kb(e),t,r,n)}function Ib(t,e,r,n){return Ts(Bl(e),t,r,n)}function Ub(t,e,r,n){return Ts(Gb(e,t.length-r),t,r,n)}V.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 Nb(this,e,r,n);case"utf8":case"utf-8":return Pb(this,e,r,n);case"ascii":case"latin1":case"binary":return Rb(this,e,r,n);case"base64":return Ib(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ub(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};V.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Fb(t,e,r){return e===0&&r===t.length?Ya.fromByteArray(t):Ya.fromByteArray(t.slice(e,r))}function gl(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let c,f,l,d;switch(a){case 1:s<128&&(o=s);break;case 2:c=t[i+1],(c&192)===128&&(d=(s&31)<<6|c&63,d>127&&(o=d));break;case 3:c=t[i+1],f=t[i+2],(c&192)===128&&(f&192)===128&&(d=(s&15)<<12|(c&63)<<6|f&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:c=t[i+1],f=t[i+2],l=t[i+3],(c&192)===128&&(f&192)===128&&(l&192)===128&&(d=(s&15)<<18|(c&63)<<12|(f&63)<<6|l&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return Mb(n)}var ll=4096;function Mb(t){let e=t.length;if(e<=ll)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=ll));return r}function Cb(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 qb(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 jb(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+=Yb[t[s]];return i}function kb(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}V.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,V.prototype),i};function yt(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")}V.prototype.readUintLE=V.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||yt(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};V.prototype.readUintBE=V.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||yt(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};V.prototype.readUint8=V.prototype.readUInt8=function(e,r){return e=e>>>0,r||yt(e,1,this.length),this[e]};V.prototype.readUint16LE=V.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||yt(e,2,this.length),this[e]|this[e+1]<<8};V.prototype.readUint16BE=V.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||yt(e,2,this.length),this[e]<<8|this[e+1]};V.prototype.readUint32LE=V.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||yt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};V.prototype.readUint32BE=V.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||yt(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};V.prototype.readBigUInt64LE=Zr(function(e){e=e>>>0,Dn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ei(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))});V.prototype.readBigUInt64BE=Zr(function(e){e=e>>>0,Dn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ei(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)});V.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||yt(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};V.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||yt(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};V.prototype.readInt8=function(e,r){return e=e>>>0,r||yt(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};V.prototype.readInt16LE=function(e,r){e=e>>>0,r||yt(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};V.prototype.readInt16BE=function(e,r){e=e>>>0,r||yt(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};V.prototype.readInt32LE=function(e,r){return e=e>>>0,r||yt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};V.prototype.readInt32BE=function(e,r){return e=e>>>0,r||yt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};V.prototype.readBigInt64LE=Zr(function(e){e=e>>>0,Dn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ei(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)});V.prototype.readBigInt64BE=Zr(function(e){e=e>>>0,Dn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ei(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)});V.prototype.readFloatLE=function(e,r){return e=e>>>0,r||yt(e,4,this.length),zn.read(this,e,!0,23,4)};V.prototype.readFloatBE=function(e,r){return e=e>>>0,r||yt(e,4,this.length),zn.read(this,e,!1,23,4)};V.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||yt(e,8,this.length),zn.read(this,e,!0,52,8)};V.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||yt(e,8,this.length),zn.read(this,e,!1,52,8)};function qt(t,e,r,n,i,s){if(!V.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")}V.prototype.writeUintLE=V.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};V.prototype.writeUintBE=V.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};V.prototype.writeUint8=V.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};V.prototype.writeUint16LE=V.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};V.prototype.writeUint16BE=V.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};V.prototype.writeUint32LE=V.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};V.prototype.writeUint32BE=V.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 ml(t,e,r,n,i){vl(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 _l(t,e,r,n,i){vl(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}V.prototype.writeBigUInt64LE=Zr(function(e,r=0){return ml(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});V.prototype.writeBigUInt64BE=Zr(function(e,r=0){return _l(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});V.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};V.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};V.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};V.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};V.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};V.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};V.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};V.prototype.writeBigInt64LE=Zr(function(e,r=0){return ml(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});V.prototype.writeBigInt64BE=Zr(function(e,r=0){return _l(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function wl(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 xl(t,e,r,n,i){return e=+e,r=r>>>0,i||wl(t,e,r,4,34028234663852886e22,-34028234663852886e22),zn.write(t,e,r,n,23,4),r+4}V.prototype.writeFloatLE=function(e,r,n){return xl(this,e,r,!0,n)};V.prototype.writeFloatBE=function(e,r,n){return xl(this,e,r,!1,n)};function El(t,e,r,n,i){return e=+e,r=r>>>0,i||wl(t,e,r,8,17976931348623157e292,-17976931348623157e292),zn.write(t,e,r,n,52,8),r+8}V.prototype.writeDoubleLE=function(e,r,n){return El(this,e,r,!0,n)};V.prototype.writeDoubleBE=function(e,r,n){return El(this,e,r,!1,n)};V.prototype.copy=function(e,r,n,i){if(!V.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};V.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"&&!V.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=V.isBuffer(e)?e:V.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 Wn={};function Ja(t,e,r){Wn[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}`}}}Ja("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Ja("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Ja("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=dl(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=dl(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function dl(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 Vb(t,e,r){Dn(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Ei(e,t.length-(r+1))}function vl(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 Wn.ERR_OUT_OF_RANGE("value",a,t)}Vb(n,i,s)}function Dn(t,e){if(typeof t!="number")throw new Wn.ERR_INVALID_ARG_TYPE(e,"number",t)}function Ei(t,e,r){throw Math.floor(t)!==t?(Dn(t,r),new Wn.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new Wn.ERR_BUFFER_OUT_OF_BOUNDS:new Wn.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Hb=/[^+/0-9A-Za-z-_]/g;function $b(t){if(t=t.split("=")[0],t=t.trim().replace(Hb,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Da(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 Kb(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Gb(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 Bl(t){return Ya.toByteArray($b(t))}function Ts(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 br(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function La(t){return t!==t}var Yb=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 Zr(t){return typeof BigInt>"u"?Wb:t}function Wb(){throw new Error("BigInt not supported")}});var Sl=J(vi=>{"use strict";Object.defineProperty(vi,"__esModule",{value:!0});vi.ReplicaRejectCode=void 0;var zb;(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"})(zb=vi.ReplicaRejectCode||(vi.ReplicaRejectCode={}))});var Xn=J(Ss=>{"use strict";Object.defineProperty(Ss,"__esModule",{value:!0});Ss.AgentError=void 0;var Qa=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};Ss.AgentError=Qa});var Ns=J(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.bufFromBufLike=jt.uint8ToBuf=jt.PipeArrayBuffer=jt.fromHexString=jt.toHexString=jt.concat=void 0;function Db(...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=Db;function Zb(t){return new Uint8Array(t).reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}jt.toHexString=Zb;function Xb(t){var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))}jt.fromHexString=Xb;var ec=class{constructor(e,r=e?.byteLength||0){this._buffer=Os(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return Os(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=ec;function As(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}jt.uint8ToBuf=As;function Os(t){return t instanceof Uint8Array?As(t):t instanceof ArrayBuffer?t:Array.isArray(t)?As(new Uint8Array(t)):"buffer"in t?Os(t.buffer):As(new Uint8Array(t))}jt.bufFromBufLike=Os});var tc=J(Ps=>{"use strict";Object.defineProperty(Ps,"__esModule",{value:!0});Ps.idlLabelToId=void 0;function Jb(t){let r=new TextEncoder().encode(t),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function Lb(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 Jb(t)}Ps.idlLabelToId=Lb});var nc=J(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.readIntLE=Ze.readUIntLE=Ze.writeIntLE=Ze.writeUIntLE=Ze.slebDecode=Ze.slebEncode=Ze.lebDecode=Ze.lebEncode=Ze.safeReadUint8=Ze.safeRead=void 0;var rc=Ns();function Al(){throw new Error("unexpected end of buffer")}function Ol(t,e){return t.byteLength<e&&Al(),t.read(e)}Ze.safeRead=Ol;function Rs(t){let e=t.readUint8();return e===void 0&&Al(),e}Ze.safeReadUint8=Rs;function Qb(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 rc.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}Ze.lebEncode=Qb;function Nl(t){let e=BigInt(1),r=BigInt(0),n;do n=Rs(t),r+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return r}Ze.lebDecode=Nl;function eg(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 rc.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}Ze.slebEncode=eg;function tg(t){let e=new Uint8Array(t.buffer),r=0;for(;r<e.byteLength;r++)if(e[r]<128){if(!(e[r]&64))return Nl(t);break}let n=new Uint8Array(Ol(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)}Ze.slebDecode=tg;function rg(t,e){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return Pl(t,e)}Ze.writeUIntLE=rg;function Pl(t,e){t=BigInt(t);let r=new rc.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}Ze.writeIntLE=Pl;function Rl(t,e){let r=BigInt(Rs(t)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(Rs(t));r=r+n*s}return r}Ze.readUIntLE=Rl;function ng(t,e){let r=Rl(t,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}Ze.readIntLE=ng});var Il=J(Jn=>{"use strict";Object.defineProperty(Jn,"__esModule",{value:!0});Jn.iexp2=Jn.ilog2=void 0;function ig(t){let e=BigInt(t);if(t<=0)throw new RangeError("Input must be positive");return e.toString(2).length-1}Jn.ilog2=ig;function sg(t){let e=BigInt(t);if(t<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}Jn.iexp2=sg});var cc=J(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.Variant=H.Record=H.Opt=H.Vec=H.Tuple=H.Principal=H.Nat64=H.Nat32=H.Nat16=H.Nat8=H.Int64=H.Int32=H.Int16=H.Int8=H.Float64=H.Float32=H.Nat=H.Int=H.Text=H.Null=H.Bool=H.Unknown=H.Reserved=H.Empty=H.decode=H.encode=H.ServiceClass=H.FuncClass=H.PrincipalClass=H.RecClass=H.VariantClass=H.TupleClass=H.RecordClass=H.OptClass=H.VecClass=H.FixedNatClass=H.FixedIntClass=H.FloatClass=H.NatClass=H.IntClass=H.TextClass=H.ReservedClass=H.NullClass=H.BoolClass=H.UnknownClass=H.EmptyClass=H.ConstructType=H.PrimitiveType=H.Type=H.Visitor=void 0;H.Service=H.Func=H.Rec=void 0;var og=Ct(),Re=Ns(),gr=tc(),ne=nc(),ic=Il(),Is="DIDL",Ul=400;function Bi(t,e,r){return t.map((n,i)=>r(n,e[i]))}var sc=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,ne.lebEncode)(this._typs.length),r=(0,Re.concat)(...this._typs);return(0,Re.concat)(e,r)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return(0,ne.slebEncode)(this._idx.get(e)||0)}},oc=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)}};H.Visitor=oc;var Ln=class{display(){return this.name}valueToString(e){return et(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}};H.Type=Ln;var kt=class extends Ln{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){}};H.PrimitiveType=kt;var _r=class extends Ln{checkType(e){if(e instanceof Xr){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)}};H.ConstructType=_r;var Us=class extends kt{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,ne.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};H.EmptyClass=Us;var Fs=class extends Ln{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 Xr?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"}};H.UnknownClass=Fs;var Ms=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: ${et(e)}`)}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return(0,ne.slebEncode)(-2)}decodeValue(e,r){switch(this.checkType(r),(0,ne.safeReadUint8)(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};H.BoolClass=Ms;var Cs=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: ${et(e)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ne.slebEncode)(-1)}decodeValue(e,r){return this.checkType(r),null}get name(){return"null"}};H.NullClass=Cs;var Qn=class extends kt{accept(e,r){return e.visitReserved(this,r)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ne.slebEncode)(-16)}decodeValue(e,r){return r.name!==this.name&&r.decodeValue(e,r),null}get name(){return"reserved"}};H.ReservedClass=Qn;var qs=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: ${et(e)}`)}encodeValue(e){let r=new TextEncoder().encode(e),n=(0,ne.lebEncode)(r.byteLength);return(0,Re.concat)(n,r)}encodeType(){return(0,ne.slebEncode)(-15)}decodeValue(e,r){this.checkType(r);let n=(0,ne.lebDecode)(e),i=(0,ne.safeRead)(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}};H.TextClass=qs;var js=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: ${et(e)}`)}encodeValue(e){return(0,ne.slebEncode)(e)}encodeType(){return(0,ne.slebEncode)(-4)}decodeValue(e,r){return this.checkType(r),(0,ne.slebDecode)(e)}get name(){return"int"}valueToString(e){return e.toString()}};H.IntClass=js;var ks=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: ${et(e)}`)}encodeValue(e){return(0,ne.lebEncode)(e)}encodeType(){return(0,ne.slebEncode)(-3)}decodeValue(e,r){return this.checkType(r),(0,ne.lebDecode)(e)}get name(){return"nat"}valueToString(e){return e.toString()}};H.NatClass=ks;var Ti=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: ${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,ne.slebEncode)(e)}decodeValue(e,r){this.checkType(r);let n=(0,ne.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()}};H.FloatClass=Ti;var jr=class extends kt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedInt(this,r)}covariant(e){let r=(0,ic.iexp2)(this._bits-1)*BigInt(-1),n=(0,ic.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,ne.writeIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,ne.slebEncode)(-9-e)}decodeValue(e,r){this.checkType(r);let n=(0,ne.readIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}};H.FixedIntClass=jr;var mr=class extends kt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedNat(this,r)}covariant(e){let r=(0,ic.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,ne.writeUIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,ne.slebEncode)(-5-e)}decodeValue(e,r){this.checkType(r);let n=(0,ne.readUIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}};H.FixedNatClass=mr;var Vs=class t extends _r{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof mr&&e._bits===8&&(this._blobOptimization=!0)}accept(e,r){return e.visitVec(this,this._type,r)}covariant(e){let r=this._type instanceof mr?this._type._bits:this._type instanceof jr?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
4
|
|
|
5
|
-
index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${et(e)}`)}encodeValue(e){let r=(0,ne.lebEncode)(e.length);if(this._blobOptimization)return(0,
|
|
5
|
+
index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${et(e)}`)}encodeValue(e){let r=(0,ne.lebEncode)(e.length);if(this._blobOptimization)return(0,Re.concat)(r,new Uint8Array(e));if(ArrayBuffer.isView(e))return(0,Re.concat)(r,new Uint8Array(e.buffer));let n=new Re.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,ne.slebEncode)(-19),n=this._type.encodeType(e);e.add(this,(0,Re.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,ne.lebDecode)(e));if(this._type instanceof mr){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 jr){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("; ")+"}"}};H.VecClass=Vs;var ei=class t extends _r{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
6
|
|
|
7
|
-
-> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${et(e)}`)}encodeValue(e){return e.length===0?new Uint8Array([0]):(0,
|
|
7
|
+
-> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${et(e)}`)}encodeValue(e){return e.length===0?new Uint8Array([0]):(0,Re.concat)(new Uint8Array([1]),this._type.encodeValue(e[0]))}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=(0,ne.slebEncode)(-18),n=this._type.encodeType(e);e.add(this,(0,Re.concat)(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not an option type");switch((0,ne.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])}`}};H.OptClass=ei;var Si=class t extends _r{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>(0,gr.idlLabelToId)(r[0])-(0,gr.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
8
|
|
|
9
|
-
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=
|
|
9
|
+
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=Bi(this._fields,r,([,i],s)=>i.encodeValue(s));return(0,Re.concat)(...n)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=(0,ne.slebEncode)(-20),n=(0,ne.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Re.concat)((0,ne.lebEncode)((0,gr.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Re.concat)(r,n,(0,Re.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,l]=this._fields[s],d=(0,gr.idlLabelToId)(this._fields[s][0]),v=(0,gr.idlLabelToId)(a);if(d===v)i[f]=l.decodeValue(e,c),s++,o++;else if(v>d)if(l instanceof ei||l instanceof Qn)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 ei||c instanceof Qn)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 {${Bi(this._fields,r,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}};H.RecordClass=Si;var Hs=class t extends Si{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
10
|
|
|
11
|
-
index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${et(e)}`)}encodeValue(e){let r=
|
|
11
|
+
index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${et(e)}`)}encodeValue(e){let r=Bi(this._components,e,(n,i)=>n.encodeValue(i));return(0,Re.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 {${Bi(this._components,e,(n,i)=>n.valueToString(i)).join("; ")}}`}};H.TupleClass=Hs;var $s=class t extends _r{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>(0,gr.idlLabelToId)(r[0])-(0,gr.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
12
|
|
|
13
|
-
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,ne.lebEncode)(r),o=i.encodeValue(e[n]);return(0,
|
|
13
|
+
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,ne.lebEncode)(r),o=i.encodeValue(e[n]);return(0,Re.concat)(s,o)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,s])=>{s.buildTypeTable(e)});let r=(0,ne.slebEncode)(-21),n=(0,ne.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Re.concat)((0,ne.lebEncode)((0,gr.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Re.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,ne.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,gr.idlLabelToId)(s)===(0,gr.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)}};H.VariantClass=$s;var Xr=class t extends _r{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)}};H.RecClass=Xr;Xr._counter=0;function ac(t){if((0,ne.safeReadUint8)(t)!==1)throw new Error("Cannot decode principal");let r=Number((0,ne.lebDecode)(t));return og.Principal.fromUint8Array(new Uint8Array((0,ne.safeRead)(t,r)))}var Ks=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: ${et(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=(0,ne.lebEncode)(r.byteLength);return(0,Re.concat)(new Uint8Array([1]),n,r)}encodeType(){return(0,ne.slebEncode)(-24)}decodeValue(e,r){return this.checkType(r),ac(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}};H.PrincipalClass=Ks;var Ai=class extends _r{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,ne.lebEncode)(n.byteLength),s=(0,Re.concat)(new Uint8Array([1]),i,n),o=new TextEncoder().encode(r),a=(0,ne.lebEncode)(o.byteLength);return(0,Re.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,ne.slebEncode)(-22),n=(0,ne.lebEncode)(this.argTypes.length),i=(0,Re.concat)(...this.argTypes.map(f=>f.encodeType(e))),s=(0,ne.lebEncode)(this.retTypes.length),o=(0,Re.concat)(...this.retTypes.map(f=>f.encodeType(e))),a=(0,ne.lebEncode)(this.annotations.length),c=(0,Re.concat)(...this.annotations.map(f=>this.encodeAnnotation(f)));e.add(this,(0,Re.concat)(r,n,i,s,o,a,c))}decodeValue(e){if((0,ne.safeReadUint8)(e)!==1)throw new Error("Cannot decode function reference");let n=ac(e),i=Number((0,ne.lebDecode)(e)),s=(0,ne.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")}};H.FuncClass=Ai;var Gs=class extends _r{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,ne.lebEncode)(r.length);return(0,Re.concat)(new Uint8Array([1]),n,r)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=(0,ne.slebEncode)(-23),n=(0,ne.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>{let a=new TextEncoder().encode(s),c=(0,ne.lebEncode)(a.length);return(0,Re.concat)(c,a,o.encodeType(e))});e.add(this,(0,Re.concat)(r,n,...i))}decodeValue(e){return ac(e)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};H.ServiceClass=Gs;function et(t){let e=JSON.stringify(t,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>Ul?e.substring(0,Ul-3)+"...":e}function ag(t,e){if(e.length<t.length)throw Error("Wrong number of message arguments");let r=new sc;t.forEach(c=>c.buildTypeTable(r));let n=new TextEncoder().encode(Is),i=r.encode(),s=(0,ne.lebEncode)(e.length),o=(0,Re.concat)(...t.map(c=>c.encodeType(r))),a=(0,Re.concat)(...Bi(t,e,(c,f)=>{try{c.covariant(f)}catch(l){throw new Error(l.message+`
|
|
14
14
|
|
|
15
|
-
`)}return c.encodeValue(l)}));return(0,Pe.concat)(n,i,s,o,a)}H.encode=jb;function kb(t,e){let r=new Pe.PipeArrayBuffer(e);if(e.byteLength<vs.length)throw new Error("Message length smaller than magic number");let n=(0,ne.safeRead)(r,vs.length),i=new TextDecoder().decode(n);if(i!==vs)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(m){let x=[],w=Number((0,ne.lebDecode)(m));for(let q=0;q<w;q++){let O=Number((0,ne.slebDecode)(m));switch(O){case-18:case-19:{let $=Number((0,ne.slebDecode)(m));x.push([O,$]);break}case-20:case-21:{let $=[],I=Number((0,ne.lebDecode)(m)),k;for(;I--;){let z=Number((0,ne.lebDecode)(m));if(z>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof k=="number"&&k>=z)throw new Error("field id collision or not sorted");k=z;let W=Number((0,ne.slebDecode)(m));$.push([z,W])}x.push([O,$]);break}case-22:{let $=[],I=Number((0,ne.lebDecode)(m));for(;I--;)$.push(Number((0,ne.slebDecode)(m)));let k=[],z=Number((0,ne.lebDecode)(m));for(;z--;)k.push(Number((0,ne.slebDecode)(m)));let W=[],K=Number((0,ne.lebDecode)(m));for(;K--;)switch(Number((0,ne.lebDecode)(m))){case 1:{W.push("query");break}case 2:{W.push("oneway");break}case 3:{W.push("composite_query");break}default:throw new Error("unknown annotation")}x.push([O,[$,k,W]]);break}case-23:{let $=Number((0,ne.lebDecode)(m)),I=[];for(;$--;){let k=Number((0,ne.lebDecode)(m)),z=new TextDecoder().decode((0,ne.safeRead)(m,k)),W=(0,ne.slebDecode)(m);I.push([z,W])}x.push([O,I]);break}default:throw new Error("Illegal op_code: "+O)}}let N=[],A=Number((0,ne.lebDecode)(m));for(let q=0;q<A;q++)N.push(Number((0,ne.slebDecode)(m)));return[x,N]}let[o,a]=s(r);if(a.length<t.length)throw new Error("Wrong number of return values");let c=o.map(m=>Ef());function l(m){if(m<-24)throw new Error("future value not supported");if(m<0)switch(m){case-1:return H.Null;case-2:return H.Bool;case-3:return H.Nat;case-4:return H.Int;case-5:return H.Nat8;case-6:return H.Nat16;case-7:return H.Nat32;case-8:return H.Nat64;case-9:return H.Int8;case-10:return H.Int16;case-11:return H.Int32;case-12:return H.Int64;case-13:return H.Float32;case-14:return H.Float64;case-15:return H.Text;case-16:return H.Reserved;case-17:return H.Empty;case-24:return H.Principal;default:throw new Error("Illegal op_code: "+m)}if(m>=o.length)throw new Error("type index out of range");return c[m]}function f(m){switch(m[0]){case-19:{let x=l(m[1]);return mf(x)}case-18:{let x=l(m[1]);return _f(x)}case-20:{let x={};for(let[A,q]of m[1]){let O=`_${A}_`;x[O]=l(q)}let w=wf(x),N=w.tryAsTuple();return Array.isArray(N)?gf(...N):w}case-21:{let x={};for(let[w,N]of m[1]){let A=`_${w}_`;x[A]=l(N)}return xf(x)}case-22:{let[x,w,N]=m[1];return vf(x.map(A=>l(A)),w.map(A=>l(A)),N)}case-23:{let x={},w=m[1];for(let[N,A]of w){let q=l(A);if(q instanceof Gr&&(q=q.getType()),!(q instanceof gi))throw new Error("Illegal service definition: services can only contain functions");x[N]=q}return Bf(x)}default:throw new Error("Illegal op_code: "+m[0])}}o.forEach((m,x)=>{if(m[0]===-22){let w=f(m);c[x].fill(w)}}),o.forEach((m,x)=>{if(m[0]!==-22){let w=f(m);c[x].fill(w)}});let d=a.map(m=>l(m)),v=t.map((m,x)=>m.decodeValue(r,d[x]));for(let m=t.length;m<d.length;m++)d[m].decodeValue(r,d[m]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return v}H.decode=kb;H.Empty=new Bs;H.Reserved=new Dn;H.Unknown=new Ts;H.Bool=new Ss;H.Null=new As;H.Text=new Os;H.Int=new Ns;H.Nat=new Ps;H.Float32=new yi(32);H.Float64=new yi(64);H.Int8=new Ir(8);H.Int16=new Ir(16);H.Int32=new Ir(32);H.Int64=new Ir(64);H.Nat8=new br(8);H.Nat16=new br(16);H.Nat32=new br(32);H.Nat64=new br(64);H.Principal=new Fs;function gf(...t){return new Is(t)}H.Tuple=gf;function mf(t){return new Rs(t)}H.Vec=mf;function _f(t){return new Wn(t)}H.Opt=_f;function wf(t){return new bi(t)}H.Record=wf;function xf(t){return new Us(t)}H.Variant=xf;function Ef(){return new Gr}H.Rec=Ef;function vf(t,e,r=[]){return new gi(t,e,r)}H.Func=vf;function Bf(t){return new Ms(t)}H.Service=Bf});var Ja=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 Ya=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=Ya;var Yr=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=Yr;var Da=class extends Yr{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=Da;var Wa=class extends Yr{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=Wa;var za=class extends Yr{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=za;var Za=class extends Yr{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=Za;var Xa=class extends Yr{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=Xa});var Sf=L(Te=>{"use strict";var Vb=Te&&Te.__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]}),Hb=Te&&Te.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Tf=Te&&Te.__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)&&Vb(e,t,r);return Hb(e,t),e};Object.defineProperty(Te,"__esModule",{value:!0});Te.renderValue=Te.renderInput=Te.Render=Te.vecForm=Te.optForm=Te.variantForm=Te.tupleForm=Te.recordForm=Te.inputBox=void 0;var qs=Tf(Ga()),La=Mt(),zn=Tf(Ja()),$b={parse:Zb},mi={render:rc},Kb=(t,e)=>new zn.InputBox(t,Object.assign(Object.assign({},$b),e));Te.inputBox=Kb;var Gb=(t,e)=>new zn.RecordForm(t,Object.assign(Object.assign({},mi),e));Te.recordForm=Gb;var Yb=(t,e)=>new zn.TupleForm(t,Object.assign(Object.assign({},mi),e));Te.tupleForm=Yb;var Db=(t,e)=>new zn.VariantForm(t,Object.assign(Object.assign({},mi),e));Te.variantForm=Db;var Wb=(t,e)=>new zn.OptionForm(t,Object.assign(Object.assign({},mi),e));Te.optForm=Wb;var zb=(t,e)=>new zn.VecForm(t,Object.assign(Object.assign({},mi),e));Te.vecForm=zb;var Cs=class extends qs.Visitor{visitType(e,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=e.display(),(0,Te.inputBox)(e,{input:n})}visitNull(e,r){return(0,Te.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,Te.recordForm)(r,i);return(0,Te.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,Te.tupleForm)(r,i);return(0,Te.inputBox)(e,{form:s})}visitVariant(e,r,n){let i=document.createElement("select");for(let[a,c]of r){let l=new Option(a);i.add(l)}i.selectedIndex=-1,i.classList.add("open");let s={open:i,event:"change"},o=(0,Te.variantForm)(r,s);return(0,Te.inputBox)(e,{form:o})}visitOpt(e,r,n){let i=document.createElement("input");i.type="checkbox",i.classList.add("open");let s=(0,Te.optForm)(r,{open:i,event:"change"});return(0,Te.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,Te.vecForm)(r,{open:i,event:"change",container:s});return(0,Te.inputBox)(e,{form:o})}visitRec(e,r,n){return rc(r)}};Te.Render=Cs;var Qa=class extends qs.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 La.Principal.fromText(r)}visitService(e,r){return La.Principal.fromText(r)}visitFunc(e,r){let n=r.split(".",2);return[La.Principal.fromText(n[0]),n[1]]}},ec=class extends qs.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 Zb(t,e,r){return e.random&&r===""?t.accept(new ec,r):t.accept(new Qa,r)}function rc(t){return t.accept(new Cs,null)}Te.renderInput=rc;function mn(t,e,r){return t.accept(new tc,{input:e,value:r})}Te.renderValue=mn;var tc=class extends qs.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){mn(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)),mn(r,i.form[0],n.value[0])}}visitRecord(e,r,n){let i=n.input.ui.form;r.forEach(([s,o],a)=>{mn(o,i.form[a],n.value[s])})}visitTuple(e,r,n){let i=n.input.ui.form;r.forEach((s,o)=>{mn(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 l=i.ui.open;l.selectedIndex=c,l.dispatchEvent(new Event(i.ui.event)),mn(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)=>{mn(r,i.form[c],a)})}}});var Of=L(Af=>{"use strict";Object.defineProperty(Af,"__esModule",{value:!0})});var Xn=L(yt=>{"use strict";var Nf=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]}),Xb=yt&&yt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Zn=yt&&yt.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Nf(e,t,r)},Jb=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)&&Nf(e,t,r);return Xb(e,t),e};Object.defineProperty(yt,"__esModule",{value:!0});yt.IDL=void 0;Zn(Sf(),yt);Zn(Ja(),yt);yt.IDL=Jb(Ga());Zn(qa(),yt);Zn(ka(),yt);Zn(ws(),yt);Zn(Of(),yt)});var _i=L((Pf,js)=>{(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,l=9007199254740991,f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],d=1e7,v=1e9;function m(I){var k,z,W,K=R.prototype={constructor:R,toString:null,valueOf:null},se=new R(1),te=20,fe=4,ue=-7,Be=21,Z=-1e7,C=1e7,X=!1,j=1,U=0,D={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},J="0123456789abcdefghijklmnopqrstuvwxyz",ie=!0;function R(u,h){var p,B,E,T,F,g,S,M,P=this;if(!(P instanceof R))return new R(u,h);if(h==null){if(u&&u._isBigNumber===!0){P.s=u.s,!u.c||u.e>C?P.c=P.e=null:u.e<Z?P.c=[P.e=0]:(P.e=u.e,P.c=u.c.slice());return}if((g=typeof u=="number")&&u*0==0){if(P.s=1/u<0?(u=-u,-1):1,u===~~u){for(T=0,F=u;F>=10;F/=10,T++);T>C?P.c=P.e=null:(P.e=T,P.c=[u]);return}M=String(u)}else{if(!r.test(M=String(u)))return W(P,M,g);P.s=M.charCodeAt(0)==45?(M=M.slice(1),-1):1}(T=M.indexOf("."))>-1&&(M=M.replace(".","")),(F=M.search(/e/i))>0?(T<0&&(T=F),T+=+M.slice(F+1),M=M.substring(0,F)):T<0&&(T=M.length)}else{if(A(h,2,J.length,"Base"),h==10&&ie)return P=new R(u),ce(P,te+P.e+1,fe);if(M=String(u),g=typeof u=="number"){if(u*0!=0)return W(P,M,g,h);if(P.s=1/u<0?(M=M.slice(1),-1):1,R.DEBUG&&M.replace(/^0\.0*|\./,"").length>15)throw Error(o+u)}else P.s=M.charCodeAt(0)===45?(M=M.slice(1),-1):1;for(p=J.slice(0,h),T=F=0,S=M.length;F<S;F++)if(p.indexOf(B=M.charAt(F))<0){if(B=="."){if(F>T){T=S;continue}}else if(!E&&(M==M.toUpperCase()&&(M=M.toLowerCase())||M==M.toLowerCase()&&(M=M.toUpperCase()))){E=!0,F=-1,T=0;continue}return W(P,String(u),g,h)}g=!1,M=z(M,h,10,P.s),(T=M.indexOf("."))>-1?M=M.replace(".",""):T=M.length}for(F=0;M.charCodeAt(F)===48;F++);for(S=M.length;M.charCodeAt(--S)===48;);if(M=M.slice(F,++S)){if(S-=F,g&&R.DEBUG&&S>15&&(u>l||u!==i(u)))throw Error(o+P.s*u);if((T=T-F-1)>C)P.c=P.e=null;else if(T<Z)P.c=[P.e=0];else{if(P.e=T,P.c=[],F=(T+1)%c,T<0&&(F+=c),F<S){for(F&&P.c.push(+M.slice(0,F)),S-=c;F<S;)P.c.push(+M.slice(F,F+=c));F=c-(M=M.slice(F)).length}else F-=S;for(;F--;M+="0");P.c.push(+M)}}else P.c=[P.e=0]}R.clone=m,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(u){var h,p;if(u!=null)if(typeof u=="object"){if(u.hasOwnProperty(h="DECIMAL_PLACES")&&(p=u[h],A(p,0,v,h),te=p),u.hasOwnProperty(h="ROUNDING_MODE")&&(p=u[h],A(p,0,8,h),fe=p),u.hasOwnProperty(h="EXPONENTIAL_AT")&&(p=u[h],p&&p.pop?(A(p[0],-v,0,h),A(p[1],0,v,h),ue=p[0],Be=p[1]):(A(p,-v,v,h),ue=-(Be=p<0?-p:p))),u.hasOwnProperty(h="RANGE"))if(p=u[h],p&&p.pop)A(p[0],-v,-1,h),A(p[1],1,v,h),Z=p[0],C=p[1];else if(A(p,-v,v,h),p)Z=-(C=p<0?-p:p);else throw Error(s+h+" cannot be zero: "+p);if(u.hasOwnProperty(h="CRYPTO"))if(p=u[h],p===!!p)if(p)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))X=p;else throw X=!p,Error(s+"crypto unavailable");else X=p;else throw Error(s+h+" not true or false: "+p);if(u.hasOwnProperty(h="MODULO_MODE")&&(p=u[h],A(p,0,9,h),j=p),u.hasOwnProperty(h="POW_PRECISION")&&(p=u[h],A(p,0,v,h),U=p),u.hasOwnProperty(h="FORMAT"))if(p=u[h],typeof p=="object")D=p;else throw Error(s+h+" not an object: "+p);if(u.hasOwnProperty(h="ALPHABET"))if(p=u[h],typeof p=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(p))ie=p.slice(0,10)=="0123456789",J=p;else throw Error(s+h+" invalid: "+p)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:te,ROUNDING_MODE:fe,EXPONENTIAL_AT:[ue,Be],RANGE:[Z,C],CRYPTO:X,MODULO_MODE:j,POW_PRECISION:U,FORMAT:D,ALPHABET:J}},R.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!R.DEBUG)return!0;var h,p,B=u.c,E=u.e,T=u.s;e:if({}.toString.call(B)=="[object Array]"){if((T===1||T===-1)&&E>=-v&&E<=v&&E===i(E)){if(B[0]===0){if(E===0&&B.length===1)return!0;break e}if(h=(E+1)%c,h<1&&(h+=c),String(B[0]).length==h){for(h=0;h<B.length;h++)if(p=B[h],p<0||p>=a||p!==i(p))break e;if(p!==0)return!0}}}else if(B===null&&E===null&&(T===null||T===1||T===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},R.maximum=R.max=function(){return de(arguments,-1)},R.minimum=R.min=function(){return de(arguments,1)},R.random=function(){var u=9007199254740992,h=Math.random()*u&2097151?function(){return i(Math.random()*u)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(p){var B,E,T,F,g,S=0,M=[],P=new R(se);if(p==null?p=te:A(p,0,v),F=n(p/c),X)if(crypto.getRandomValues){for(B=crypto.getRandomValues(new Uint32Array(F*=2));S<F;)g=B[S]*131072+(B[S+1]>>>11),g>=9e15?(E=crypto.getRandomValues(new Uint32Array(2)),B[S]=E[0],B[S+1]=E[1]):(M.push(g%1e14),S+=2);S=F/2}else if(crypto.randomBytes){for(B=crypto.randomBytes(F*=7);S<F;)g=(B[S]&31)*281474976710656+B[S+1]*1099511627776+B[S+2]*4294967296+B[S+3]*16777216+(B[S+4]<<16)+(B[S+5]<<8)+B[S+6],g>=9e15?crypto.randomBytes(7).copy(B,S):(M.push(g%1e14),S+=7);S=F/7}else throw X=!1,Error(s+"crypto unavailable");if(!X)for(;S<F;)g=h(),g<9e15&&(M[S++]=g%1e14);for(F=M[--S],p%=c,F&&p&&(g=f[c-p],M[S]=i(F/g)*g);M[S]===0;M.pop(),S--);if(S<0)M=[T=0];else{for(T=-1;M[0]===0;M.splice(0,1),T-=c);for(S=1,g=M[0];g>=10;g/=10,S++);S<c&&(T-=c-S)}return P.e=T,P.c=M,P}}(),R.sum=function(){for(var u=1,h=arguments,p=new R(h[0]);u<h.length;)p=p.plus(h[u++]);return p},z=function(){var u="0123456789";function h(p,B,E,T){for(var F,g=[0],S,M=0,P=p.length;M<P;){for(S=g.length;S--;g[S]*=B);for(g[0]+=T.indexOf(p.charAt(M++)),F=0;F<g.length;F++)g[F]>E-1&&(g[F+1]==null&&(g[F+1]=0),g[F+1]+=g[F]/E|0,g[F]%=E)}return g.reverse()}return function(p,B,E,T,F){var g,S,M,P,Y,Q,le,ve,Re=p.indexOf("."),ke=te,xe=fe;for(Re>=0&&(P=U,U=0,p=p.replace(".",""),ve=new R(B),Q=ve.pow(p.length-Re),U=P,ve.c=h($(w(Q.c),Q.e,"0"),10,E,u),ve.e=ve.c.length),le=h(p,B,E,F?(g=J,u):(g=u,J)),M=P=le.length;le[--P]==0;le.pop());if(!le[0])return g.charAt(0);if(Re<0?--M:(Q.c=le,Q.e=M,Q.s=T,Q=k(Q,ve,ke,xe,E),le=Q.c,Y=Q.r,M=Q.e),S=M+ke+1,Re=le[S],P=E/2,Y=Y||S<0||le[S+1]!=null,Y=xe<4?(Re!=null||Y)&&(xe==0||xe==(Q.s<0?3:2)):Re>P||Re==P&&(xe==4||Y||xe==6&&le[S-1]&1||xe==(Q.s<0?8:7)),S<1||!le[0])p=Y?$(g.charAt(1),-ke,g.charAt(0)):g.charAt(0);else{if(le.length=S,Y)for(--E;++le[--S]>E;)le[S]=0,S||(++M,le=[1].concat(le));for(P=le.length;!le[--P];);for(Re=0,p="";Re<=P;p+=g.charAt(le[Re++]));p=$(p,M,g.charAt(0))}return p}}(),k=function(){function u(B,E,T){var F,g,S,M,P=0,Y=B.length,Q=E%d,le=E/d|0;for(B=B.slice();Y--;)S=B[Y]%d,M=B[Y]/d|0,F=le*S+M*Q,g=Q*S+F%d*d+P,P=(g/T|0)+(F/d|0)+le*M,B[Y]=g%T;return P&&(B=[P].concat(B)),B}function h(B,E,T,F){var g,S;if(T!=F)S=T>F?1:-1;else for(g=S=0;g<T;g++)if(B[g]!=E[g]){S=B[g]>E[g]?1:-1;break}return S}function p(B,E,T,F){for(var g=0;T--;)B[T]-=g,g=B[T]<E[T]?1:0,B[T]=g*F+B[T]-E[T];for(;!B[0]&&B.length>1;B.splice(0,1));}return function(B,E,T,F,g){var S,M,P,Y,Q,le,ve,Re,ke,xe,he,De,Or,hn,pn,Ut,Ne,Ft=B.s==E.s?1:-1,gt=B.c,Ke=E.c;if(!gt||!gt[0]||!Ke||!Ke[0])return new R(!B.s||!E.s||(gt?Ke&>[0]==Ke[0]:!Ke)?NaN:gt&>[0]==0||!Ke?Ft*0:Ft/0);for(Re=new R(Ft),ke=Re.c=[],M=B.e-E.e,Ft=T+M+1,g||(g=a,M=x(B.e/c)-x(E.e/c),Ft=Ft/c|0),P=0;Ke[P]==(gt[P]||0);P++);if(Ke[P]>(gt[P]||0)&&M--,Ft<0)ke.push(1),Y=!0;else{for(hn=gt.length,Ut=Ke.length,P=0,Ft+=2,Q=i(g/(Ke[0]+1)),Q>1&&(Ke=u(Ke,Q,g),gt=u(gt,Q,g),Ut=Ke.length,hn=gt.length),Or=Ut,xe=gt.slice(0,Ut),he=xe.length;he<Ut;xe[he++]=0);Ne=Ke.slice(),Ne=[0].concat(Ne),pn=Ke[0],Ke[1]>=g/2&&pn++;do{if(Q=0,S=h(Ke,xe,Ut,he),S<0){if(De=xe[0],Ut!=he&&(De=De*g+(xe[1]||0)),Q=i(De/pn),Q>1)for(Q>=g&&(Q=g-1),le=u(Ke,Q,g),ve=le.length,he=xe.length;h(le,xe,ve,he)==1;)Q--,p(le,Ut<ve?Ne:Ke,ve,g),ve=le.length,S=1;else Q==0&&(S=Q=1),le=Ke.slice(),ve=le.length;if(ve<he&&(le=[0].concat(le)),p(xe,le,he,g),he=xe.length,S==-1)for(;h(Ke,xe,Ut,he)<1;)Q++,p(xe,Ut<he?Ne:Ke,he,g),he=xe.length}else S===0&&(Q++,xe=[0]);ke[P++]=Q,xe[0]?xe[he++]=gt[Or]||0:(xe=[gt[Or]],he=1)}while((Or++<hn||xe[0]!=null)&&Ft--);Y=xe[0]!=null,ke[0]||ke.splice(0,1)}if(g==a){for(P=1,Ft=ke[0];Ft>=10;Ft/=10,P++);ce(Re,T+(Re.e=P+M*c-1)+1,F,Y)}else Re.e=M,Re.r=+Y;return Re}}();function y(u,h,p,B){var E,T,F,g,S;if(p==null?p=fe:A(p,0,8),!u.c)return u.toString();if(E=u.c[0],F=u.e,h==null)S=w(u.c),S=B==1||B==2&&(F<=ue||F>=Be)?O(S,F):$(S,F,"0");else if(u=ce(new R(u),h,p),T=u.e,S=w(u.c),g=S.length,B==1||B==2&&(h<=T||T<=ue)){for(;g<h;S+="0",g++);S=O(S,T)}else if(h-=F,S=$(S,T,"0"),T+1>g){if(--h>0)for(S+=".";h--;S+="0");}else if(h+=T-g,h>0)for(T+1==g&&(S+=".");h--;S+="0");return u.s<0&&E?"-"+S:S}function de(u,h){for(var p,B,E=1,T=new R(u[0]);E<u.length;E++)B=new R(u[E]),(!B.s||(p=N(T,B))===h||p===0&&T.s===h)&&(T=B);return T}function ae(u,h,p){for(var B=1,E=h.length;!h[--E];h.pop());for(E=h[0];E>=10;E/=10,B++);return(p=B+p*c-1)>C?u.c=u.e=null:p<Z?u.c=[u.e=0]:(u.e=p,u.c=h),u}W=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,h=/^([^.]+)\.$/,p=/^\.([^.]+)$/,B=/^-?(Infinity|NaN)$/,E=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(T,F,g,S){var M,P=g?F:F.replace(E,"");if(B.test(P))T.s=isNaN(P)?null:P<0?-1:1;else{if(!g&&(P=P.replace(u,function(Y,Q,le){return M=(le=le.toLowerCase())=="x"?16:le=="b"?2:8,!S||S==M?Q:Y}),S&&(M=S,P=P.replace(h,"$1").replace(p,"0.$1")),F!=P))return new R(P,M);if(R.DEBUG)throw Error(s+"Not a"+(S?" base "+S:"")+" number: "+F);T.s=null}T.c=T.e=null}}();function ce(u,h,p,B){var E,T,F,g,S,M,P,Y=u.c,Q=f;if(Y){e:{for(E=1,g=Y[0];g>=10;g/=10,E++);if(T=h-E,T<0)T+=c,F=h,S=Y[M=0],P=i(S/Q[E-F-1]%10);else if(M=n((T+1)/c),M>=Y.length)if(B){for(;Y.length<=M;Y.push(0));S=P=0,E=1,T%=c,F=T-c+1}else break e;else{for(S=g=Y[M],E=1;g>=10;g/=10,E++);T%=c,F=T-c+E,P=F<0?0:i(S/Q[E-F-1]%10)}if(B=B||h<0||Y[M+1]!=null||(F<0?S:S%Q[E-F-1]),B=p<4?(P||B)&&(p==0||p==(u.s<0?3:2)):P>5||P==5&&(p==4||B||p==6&&(T>0?F>0?S/Q[E-F]:0:Y[M-1])%10&1||p==(u.s<0?8:7)),h<1||!Y[0])return Y.length=0,B?(h-=u.e+1,Y[0]=Q[(c-h%c)%c],u.e=-h||0):Y[0]=u.e=0,u;if(T==0?(Y.length=M,g=1,M--):(Y.length=M+1,g=Q[c-T],Y[M]=F>0?i(S/Q[E-F]%Q[F])*g:0),B)for(;;)if(M==0){for(T=1,F=Y[0];F>=10;F/=10,T++);for(F=Y[0]+=g,g=1;F>=10;F/=10,g++);T!=g&&(u.e++,Y[0]==a&&(Y[0]=1));break}else{if(Y[M]+=g,Y[M]!=a)break;Y[M--]=0,g=1}for(T=Y.length;Y[--T]===0;Y.pop());}u.e>C?u.c=u.e=null:u.e<Z&&(u.c=[u.e=0])}return u}function ee(u){var h,p=u.e;return p===null?u.toString():(h=w(u.c),h=p<=ue||p>=Be?O(h,p):$(h,p,"0"),u.s<0?"-"+h:h)}return K.absoluteValue=K.abs=function(){var u=new R(this);return u.s<0&&(u.s=1),u},K.comparedTo=function(u,h){return N(this,new R(u,h))},K.decimalPlaces=K.dp=function(u,h){var p,B,E,T=this;if(u!=null)return A(u,0,v),h==null?h=fe:A(h,0,8),ce(new R(T),u+T.e+1,h);if(!(p=T.c))return null;if(B=((E=p.length-1)-x(this.e/c))*c,E=p[E])for(;E%10==0;E/=10,B--);return B<0&&(B=0),B},K.dividedBy=K.div=function(u,h){return k(this,new R(u,h),te,fe)},K.dividedToIntegerBy=K.idiv=function(u,h){return k(this,new R(u,h),0,1)},K.exponentiatedBy=K.pow=function(u,h){var p,B,E,T,F,g,S,M,P,Y=this;if(u=new R(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+ee(u));if(h!=null&&(h=new R(h)),g=u.e>14,!Y.c||!Y.c[0]||Y.c[0]==1&&!Y.e&&Y.c.length==1||!u.c||!u.c[0])return P=new R(Math.pow(+ee(Y),g?u.s*(2-q(u)):+ee(u))),h?P.mod(h):P;if(S=u.s<0,h){if(h.c?!h.c[0]:!h.s)return new R(NaN);B=!S&&Y.isInteger()&&h.isInteger(),B&&(Y=Y.mod(h))}else{if(u.e>9&&(Y.e>0||Y.e<-1||(Y.e==0?Y.c[0]>1||g&&Y.c[1]>=24e7:Y.c[0]<8e13||g&&Y.c[0]<=9999975e7)))return T=Y.s<0&&q(u)?-0:0,Y.e>-1&&(T=1/T),new R(S?1/T:T);U&&(T=n(U/c+2))}for(g?(p=new R(.5),S&&(u.s=1),M=q(u)):(E=Math.abs(+ee(u)),M=E%2),P=new R(se);;){if(M){if(P=P.times(Y),!P.c)break;T?P.c.length>T&&(P.c.length=T):B&&(P=P.mod(h))}if(E){if(E=i(E/2),E===0)break;M=E%2}else if(u=u.times(p),ce(u,u.e+1,1),u.e>14)M=q(u);else{if(E=+ee(u),E===0)break;M=E%2}Y=Y.times(Y),T?Y.c&&Y.c.length>T&&(Y.c.length=T):B&&(Y=Y.mod(h))}return B?P:(S&&(P=se.div(P)),h?P.mod(h):T?ce(P,U,fe,F):P)},K.integerValue=function(u){var h=new R(this);return u==null?u=fe:A(u,0,8),ce(h,h.e+1,u)},K.isEqualTo=K.eq=function(u,h){return N(this,new R(u,h))===0},K.isFinite=function(){return!!this.c},K.isGreaterThan=K.gt=function(u,h){return N(this,new R(u,h))>0},K.isGreaterThanOrEqualTo=K.gte=function(u,h){return(h=N(this,new R(u,h)))===1||h===0},K.isInteger=function(){return!!this.c&&x(this.e/c)>this.c.length-2},K.isLessThan=K.lt=function(u,h){return N(this,new R(u,h))<0},K.isLessThanOrEqualTo=K.lte=function(u,h){return(h=N(this,new R(u,h)))===-1||h===0},K.isNaN=function(){return!this.s},K.isNegative=function(){return this.s<0},K.isPositive=function(){return this.s>0},K.isZero=function(){return!!this.c&&this.c[0]==0},K.minus=function(u,h){var p,B,E,T,F=this,g=F.s;if(u=new R(u,h),h=u.s,!g||!h)return new R(NaN);if(g!=h)return u.s=-h,F.plus(u);var S=F.e/c,M=u.e/c,P=F.c,Y=u.c;if(!S||!M){if(!P||!Y)return P?(u.s=-h,u):new R(Y?F:NaN);if(!P[0]||!Y[0])return Y[0]?(u.s=-h,u):new R(P[0]?F:fe==3?-0:0)}if(S=x(S),M=x(M),P=P.slice(),g=S-M){for((T=g<0)?(g=-g,E=P):(M=S,E=Y),E.reverse(),h=g;h--;E.push(0));E.reverse()}else for(B=(T=(g=P.length)<(h=Y.length))?g:h,g=h=0;h<B;h++)if(P[h]!=Y[h]){T=P[h]<Y[h];break}if(T&&(E=P,P=Y,Y=E,u.s=-u.s),h=(B=Y.length)-(p=P.length),h>0)for(;h--;P[p++]=0);for(h=a-1;B>g;){if(P[--B]<Y[B]){for(p=B;p&&!P[--p];P[p]=h);--P[p],P[B]+=a}P[B]-=Y[B]}for(;P[0]==0;P.splice(0,1),--M);return P[0]?ae(u,P,M):(u.s=fe==3?-1:1,u.c=[u.e=0],u)},K.modulo=K.mod=function(u,h){var p,B,E=this;return u=new R(u,h),!E.c||!u.s||u.c&&!u.c[0]?new R(NaN):!u.c||E.c&&!E.c[0]?new R(E):(j==9?(B=u.s,u.s=1,p=k(E,u,0,3),u.s=B,p.s*=B):p=k(E,u,0,j),u=E.minus(p.times(u)),!u.c[0]&&j==1&&(u.s=E.s),u)},K.multipliedBy=K.times=function(u,h){var p,B,E,T,F,g,S,M,P,Y,Q,le,ve,Re,ke,xe=this,he=xe.c,De=(u=new R(u,h)).c;if(!he||!De||!he[0]||!De[0])return!xe.s||!u.s||he&&!he[0]&&!De||De&&!De[0]&&!he?u.c=u.e=u.s=null:(u.s*=xe.s,!he||!De?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(B=x(xe.e/c)+x(u.e/c),u.s*=xe.s,S=he.length,Y=De.length,S<Y&&(ve=he,he=De,De=ve,E=S,S=Y,Y=E),E=S+Y,ve=[];E--;ve.push(0));for(Re=a,ke=d,E=Y;--E>=0;){for(p=0,Q=De[E]%ke,le=De[E]/ke|0,F=S,T=E+F;T>E;)M=he[--F]%ke,P=he[F]/ke|0,g=le*M+P*Q,M=Q*M+g%ke*ke+ve[T]+p,p=(M/Re|0)+(g/ke|0)+le*P,ve[T--]=M%Re;ve[T]=p}return p?++B:ve.splice(0,1),ae(u,ve,B)},K.negated=function(){var u=new R(this);return u.s=-u.s||null,u},K.plus=function(u,h){var p,B=this,E=B.s;if(u=new R(u,h),h=u.s,!E||!h)return new R(NaN);if(E!=h)return u.s=-h,B.minus(u);var T=B.e/c,F=u.e/c,g=B.c,S=u.c;if(!T||!F){if(!g||!S)return new R(E/0);if(!g[0]||!S[0])return S[0]?u:new R(g[0]?B:E*0)}if(T=x(T),F=x(F),g=g.slice(),E=T-F){for(E>0?(F=T,p=S):(E=-E,p=g),p.reverse();E--;p.push(0));p.reverse()}for(E=g.length,h=S.length,E-h<0&&(p=S,S=g,g=p,h=E),E=0;h;)E=(g[--h]=g[h]+S[h]+E)/a|0,g[h]=a===g[h]?0:g[h]%a;return E&&(g=[E].concat(g),++F),ae(u,g,F)},K.precision=K.sd=function(u,h){var p,B,E,T=this;if(u!=null&&u!==!!u)return A(u,1,v),h==null?h=fe:A(h,0,8),ce(new R(T),u,h);if(!(p=T.c))return null;if(E=p.length-1,B=E*c+1,E=p[E]){for(;E%10==0;E/=10,B--);for(E=p[0];E>=10;E/=10,B++);}return u&&T.e+1>B&&(B=T.e+1),B},K.shiftedBy=function(u){return A(u,-l,l),this.times("1e"+u)},K.squareRoot=K.sqrt=function(){var u,h,p,B,E,T=this,F=T.c,g=T.s,S=T.e,M=te+4,P=new R("0.5");if(g!==1||!F||!F[0])return new R(!g||g<0&&(!F||F[0])?NaN:F?T:1/0);if(g=Math.sqrt(+ee(T)),g==0||g==1/0?(h=w(F),(h.length+S)%2==0&&(h+="0"),g=Math.sqrt(+h),S=x((S+1)/2)-(S<0||S%2),g==1/0?h="5e"+S:(h=g.toExponential(),h=h.slice(0,h.indexOf("e")+1)+S),p=new R(h)):p=new R(g+""),p.c[0]){for(S=p.e,g=S+M,g<3&&(g=0);;)if(E=p,p=P.times(E.plus(k(T,E,M,1))),w(E.c).slice(0,g)===(h=w(p.c)).slice(0,g))if(p.e<S&&--g,h=h.slice(g-3,g+1),h=="9999"||!B&&h=="4999"){if(!B&&(ce(E,E.e+te+2,0),E.times(E).eq(T))){p=E;break}M+=4,g+=4,B=1}else{(!+h||!+h.slice(1)&&h.charAt(0)=="5")&&(ce(p,p.e+te+2,1),u=!p.times(p).eq(T));break}}return ce(p,p.e+te+1,fe,u)},K.toExponential=function(u,h){return u!=null&&(A(u,0,v),u++),y(this,u,h,1)},K.toFixed=function(u,h){return u!=null&&(A(u,0,v),u=u+this.e+1),y(this,u,h)},K.toFormat=function(u,h,p){var B,E=this;if(p==null)u!=null&&h&&typeof h=="object"?(p=h,h=null):u&&typeof u=="object"?(p=u,u=h=null):p=D;else if(typeof p!="object")throw Error(s+"Argument not an object: "+p);if(B=E.toFixed(u,h),E.c){var T,F=B.split("."),g=+p.groupSize,S=+p.secondaryGroupSize,M=p.groupSeparator||"",P=F[0],Y=F[1],Q=E.s<0,le=Q?P.slice(1):P,ve=le.length;if(S&&(T=g,g=S,S=T,ve-=T),g>0&&ve>0){for(T=ve%g||g,P=le.substr(0,T);T<ve;T+=g)P+=M+le.substr(T,g);S>0&&(P+=M+le.slice(T)),Q&&(P="-"+P)}B=Y?P+(p.decimalSeparator||"")+((S=+p.fractionGroupSize)?Y.replace(new RegExp("\\d{"+S+"}\\B","g"),"$&"+(p.fractionGroupSeparator||"")):Y):P}return(p.prefix||"")+B+(p.suffix||"")},K.toFraction=function(u){var h,p,B,E,T,F,g,S,M,P,Y,Q,le=this,ve=le.c;if(u!=null&&(g=new R(u),!g.isInteger()&&(g.c||g.s!==1)||g.lt(se)))throw Error(s+"Argument "+(g.isInteger()?"out of range: ":"not an integer: ")+ee(g));if(!ve)return new R(le);for(h=new R(se),M=p=new R(se),B=S=new R(se),Q=w(ve),T=h.e=Q.length-le.e-1,h.c[0]=f[(F=T%c)<0?c+F:F],u=!u||g.comparedTo(h)>0?T>0?h:M:g,F=C,C=1/0,g=new R(Q),S.c[0]=0;P=k(g,h,0,1),E=p.plus(P.times(B)),E.comparedTo(u)!=1;)p=B,B=E,M=S.plus(P.times(E=M)),S=E,h=g.minus(P.times(E=h)),g=E;return E=k(u.minus(p),B,0,1),S=S.plus(E.times(M)),p=p.plus(E.times(B)),S.s=M.s=le.s,T=T*2,Y=k(M,B,T,fe).minus(le).abs().comparedTo(k(S,p,T,fe).minus(le).abs())<1?[M,B]:[S,p],C=F,Y},K.toNumber=function(){return+ee(this)},K.toPrecision=function(u,h){return u!=null&&A(u,1,v),y(this,u,h,2)},K.toString=function(u){var h,p=this,B=p.s,E=p.e;return E===null?B?(h="Infinity",B<0&&(h="-"+h)):h="NaN":(u==null?h=E<=ue||E>=Be?O(w(p.c),E):$(w(p.c),E,"0"):u===10&&ie?(p=ce(new R(p),te+E+1,fe),h=$(w(p.c),p.e,"0")):(A(u,2,J.length,"Base"),h=z($(w(p.c),E,"0"),10,u,B,!0)),B<0&&p.c[0]&&(h="-"+h)),h},K.valueOf=K.toJSON=function(){return ee(this)},K._isBigNumber=!0,I!=null&&R.set(I),R}function x(I){var k=I|0;return I>0||I===k?k:k-1}function w(I){for(var k,z,W=1,K=I.length,se=I[0]+"";W<K;){for(k=I[W++]+"",z=c-k.length;z--;k="0"+k);se+=k}for(K=se.length;se.charCodeAt(--K)===48;);return se.slice(0,K+1||1)}function N(I,k){var z,W,K=I.c,se=k.c,te=I.s,fe=k.s,ue=I.e,Be=k.e;if(!te||!fe)return null;if(z=K&&!K[0],W=se&&!se[0],z||W)return z?W?0:-fe:te;if(te!=fe)return te;if(z=te<0,W=ue==Be,!K||!se)return W?0:!K^z?1:-1;if(!W)return ue>Be^z?1:-1;for(fe=(ue=K.length)<(Be=se.length)?ue:Be,te=0;te<fe;te++)if(K[te]!=se[te])return K[te]>se[te]^z?1:-1;return ue==Be?0:ue>Be^z?1:-1}function A(I,k,z,W){if(I<k||I>z||I!==i(I))throw Error(s+(W||"Argument")+(typeof I=="number"?I<k||I>z?" out of range: ":" not an integer: ":" not a primitive number: ")+String(I))}function q(I){var k=I.c.length-1;return x(I.e/c)==k&&I.c[k]%2!=0}function O(I,k){return(I.length>1?I.charAt(0)+"."+I.slice(1):I)+(k<0?"e":"e+")+k}function $(I,k,z){var W,K;if(k<0){for(K=z+".";++k;K+=z);I=K+I}else if(W=I.length,++k>W){for(K=z,k-=W;--k;K+=z);I+=K}else k<W&&(I=I.slice(0,k)+"."+I.slice(k));return I}e=m(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof js<"u"&&js.exports?js.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(Pf)});var If=L((qx,Rf)=>{Rf.exports=function(e,r,n){var i=new e.Uint8Array(n),s=r.pushInt,o=r.pushInt32,a=r.pushInt32Neg,c=r.pushInt64,l=r.pushInt64Neg,f=r.pushFloat,d=r.pushFloatSingle,v=r.pushFloatDouble,m=r.pushTrue,x=r.pushFalse,w=r.pushUndefined,N=r.pushNull,A=r.pushInfinity,q=r.pushInfinityNeg,O=r.pushNaN,$=r.pushNaNNeg,I=r.pushArrayStart,k=r.pushArrayStartFixed,z=r.pushArrayStartFixed32,W=r.pushArrayStartFixed64,K=r.pushObjectStart,se=r.pushObjectStartFixed,te=r.pushObjectStartFixed32,fe=r.pushObjectStartFixed64,ue=r.pushByteString,Be=r.pushByteStringStart,Z=r.pushUtf8String,C=r.pushUtf8StringStart,X=r.pushSimpleUnassigned,j=r.pushTagStart,U=r.pushTagStart4,D=r.pushTagStart8,J=r.pushTagUnassigned,ie=r.pushBreak,R=e.Math.pow,y=0,de=0,ae=0;function ce(_){for(_=_|0,y=0,de=_;(y|0)<(de|0)&&(ae=Lp[i[y]&255](i[y]|0)|0,!((ae|0)>0)););return ae|0}function ee(_){return _=_|0,((y|0)+(_|0)|0)<(de|0)?0:1}function u(_){return _=_|0,i[_|0]<<8|i[_+1|0]|0}function h(_){return _=_|0,i[_|0]<<24|i[_+1|0]<<16|i[_+2|0]<<8|i[_+3|0]|0}function p(_){return _=_|0,s(_|0),y=y+1|0,0}function B(_){return _=_|0,ee(1)|0?1:(s(i[y+1|0]|0),y=y+2|0,0)}function E(_){return _=_|0,ee(2)|0?1:(s(u(y+1|0)|0),y=y+3|0,0)}function T(_){return _=_|0,ee(4)|0?1:(o(u(y+1|0)|0,u(y+3|0)|0),y=y+5|0,0)}function F(_){return _=_|0,ee(8)|0?1:(c(u(y+1|0)|0,u(y+3|0)|0,u(y+5|0)|0,u(y+7|0)|0),y=y+9|0,0)}function g(_){return _=_|0,s(-1-(_-32|0)|0),y=y+1|0,0}function S(_){return _=_|0,ee(1)|0?1:(s(-1-(i[y+1|0]|0)|0),y=y+2|0,0)}function M(_){_=_|0;var Ae=0;return ee(2)|0?1:(Ae=u(y+1|0)|0,s(-1-(Ae|0)|0),y=y+3|0,0)}function P(_){return _=_|0,ee(4)|0?1:(a(u(y+1|0)|0,u(y+3|0)|0),y=y+5|0,0)}function Y(_){return _=_|0,ee(8)|0?1:(l(u(y+1|0)|0,u(y+3|0)|0,u(y+5|0)|0,u(y+7|0)|0),y=y+9|0,0)}function Q(_){_=_|0;var Ae=0,Oe=0,Se=0;return Se=_-64|0,ee(Se|0)|0?1:(Ae=y+1|0,Oe=(y+1|0)+(Se|0)|0,ue(Ae|0,Oe|0),y=Oe|0,0)}function le(_){_=_|0;var Ae=0,Oe=0,Se=0;return ee(1)|0||(Se=i[y+1|0]|0,Ae=y+2|0,Oe=(y+2|0)+(Se|0)|0,ee(Se+1|0)|0)?1:(ue(Ae|0,Oe|0),y=Oe|0,0)}function ve(_){_=_|0;var Ae=0,Oe=0,Se=0;return ee(2)|0||(Se=u(y+1|0)|0,Ae=y+3|0,Oe=(y+3|0)+(Se|0)|0,ee(Se+2|0)|0)?1:(ue(Ae|0,Oe|0),y=Oe|0,0)}function Re(_){_=_|0;var Ae=0,Oe=0,Se=0;return ee(4)|0||(Se=h(y+1|0)|0,Ae=y+5|0,Oe=(y+5|0)+(Se|0)|0,ee(Se+4|0)|0)?1:(ue(Ae|0,Oe|0),y=Oe|0,0)}function ke(_){return _=_|0,1}function xe(_){return _=_|0,Be(),y=y+1|0,0}function he(_){_=_|0;var Ae=0,Oe=0,Se=0;return Se=_-96|0,ee(Se|0)|0?1:(Ae=y+1|0,Oe=(y+1|0)+(Se|0)|0,Z(Ae|0,Oe|0),y=Oe|0,0)}function De(_){_=_|0;var Ae=0,Oe=0,Se=0;return ee(1)|0||(Se=i[y+1|0]|0,Ae=y+2|0,Oe=(y+2|0)+(Se|0)|0,ee(Se+1|0)|0)?1:(Z(Ae|0,Oe|0),y=Oe|0,0)}function Or(_){_=_|0;var Ae=0,Oe=0,Se=0;return ee(2)|0||(Se=u(y+1|0)|0,Ae=y+3|0,Oe=(y+3|0)+(Se|0)|0,ee(Se+2|0)|0)?1:(Z(Ae|0,Oe|0),y=Oe|0,0)}function hn(_){_=_|0;var Ae=0,Oe=0,Se=0;return ee(4)|0||(Se=h(y+1|0)|0,Ae=y+5|0,Oe=(y+5|0)+(Se|0)|0,ee(Se+4|0)|0)?1:(Z(Ae|0,Oe|0),y=Oe|0,0)}function pn(_){return _=_|0,1}function Ut(_){return _=_|0,C(),y=y+1|0,0}function Ne(_){return _=_|0,k(_-128|0),y=y+1|0,0}function Ft(_){return _=_|0,ee(1)|0?1:(k(i[y+1|0]|0),y=y+2|0,0)}function gt(_){return _=_|0,ee(2)|0?1:(k(u(y+1|0)|0),y=y+3|0,0)}function Ke(_){return _=_|0,ee(4)|0?1:(z(u(y+1|0)|0,u(y+3|0)|0),y=y+5|0,0)}function Ip(_){return _=_|0,ee(8)|0?1:(W(u(y+1|0)|0,u(y+3|0)|0,u(y+5|0)|0,u(y+7|0)|0),y=y+9|0,0)}function Up(_){return _=_|0,I(),y=y+1|0,0}function Ge(_){_=_|0;var Ae=0;return Ae=_-160|0,ee(Ae|0)|0?1:(se(Ae|0),y=y+1|0,0)}function Fp(_){return _=_|0,ee(1)|0?1:(se(i[y+1|0]|0),y=y+2|0,0)}function Mp(_){return _=_|0,ee(2)|0?1:(se(u(y+1|0)|0),y=y+3|0,0)}function Cp(_){return _=_|0,ee(4)|0?1:(te(u(y+1|0)|0,u(y+3|0)|0),y=y+5|0,0)}function qp(_){return _=_|0,ee(8)|0?1:(fe(u(y+1|0)|0,u(y+3|0)|0,u(y+5|0)|0,u(y+7|0)|0),y=y+9|0,0)}function jp(_){return _=_|0,K(),y=y+1|0,0}function In(_){return _=_|0,j(_-192|0|0),y=y+1|0,0}function V2(_){return _=_|0,j(_|0),y=y+1|0,0}function H2(_){return _=_|0,j(_|0),y=y+1|0,0}function $2(_){return _=_|0,j(_|0),y=y+1|0,0}function K2(_){return _=_|0,j(_|0),y=y+1|0,0}function dt(_){return _=_|0,j(_-192|0|0),y=y+1|0,0}function G2(_){return _=_|0,j(_|0),y=y+1|0,0}function Y2(_){return _=_|0,j(_|0),y=y+1|0,0}function D2(_){return _=_|0,j(_|0),y=y+1|0,0}function kp(_){return _=_|0,ee(1)|0?1:(j(i[y+1|0]|0),y=y+2|0,0)}function Vp(_){return _=_|0,ee(2)|0?1:(j(u(y+1|0)|0),y=y+3|0,0)}function Hp(_){return _=_|0,ee(4)|0?1:(U(u(y+1|0)|0,u(y+3|0)|0),y=y+5|0,0)}function $p(_){return _=_|0,ee(8)|0?1:(D(u(y+1|0)|0,u(y+3|0)|0,u(y+5|0)|0,u(y+7|0)|0),y=y+9|0,0)}function tt(_){return _=_|0,X((_|0)-224|0),y=y+1|0,0}function Kp(_){return _=_|0,x(),y=y+1|0,0}function Gp(_){return _=_|0,m(),y=y+1|0,0}function Yp(_){return _=_|0,N(),y=y+1|0,0}function Dp(_){return _=_|0,w(),y=y+1|0,0}function Wp(_){return _=_|0,ee(1)|0?1:(X(i[y+1|0]|0),y=y+2|0,0)}function zp(_){_=_|0;var Ae=0,Oe=0,Se=1,es=0,ui=0,W2=0;return ee(2)|0?1:(Ae=i[y+1|0]|0,Oe=i[y+2|0]|0,(Ae|0)&128&&(Se=-1),es=+(((Ae|0)&124)>>2),ui=+(((Ae|0)&3)<<8|Oe),+es==0?f(+(+Se*5960464477539063e-23*+ui)):+es==31?+Se==1?+ui>0?O():A():+ui>0?$():q():f(+(+Se*R(2,+(+es-25))*+(1024+ui))),y=y+3|0,0)}function Zp(_){return _=_|0,ee(4)|0?1:(d(i[y+1|0]|0,i[y+2|0]|0,i[y+3|0]|0,i[y+4|0]|0),y=y+5|0,0)}function Xp(_){return _=_|0,ee(8)|0?1:(v(i[y+1|0]|0,i[y+2|0]|0,i[y+3|0]|0,i[y+4|0]|0,i[y+5|0]|0,i[y+6|0]|0,i[y+7|0]|0,i[y+8|0]|0),y=y+9|0,0)}function qe(_){return _=_|0,1}function Jp(_){return _=_|0,ie(),y=y+1|0,0}var Lp=[p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,B,E,T,F,qe,qe,qe,qe,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,S,M,P,Y,qe,qe,qe,qe,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,le,ve,Re,ke,qe,qe,qe,xe,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,De,Or,hn,pn,qe,qe,qe,Ut,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ft,gt,Ke,Ip,qe,qe,qe,Up,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Fp,Mp,Cp,qp,qe,qe,qe,jp,In,In,In,In,In,In,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,kp,Vp,Hp,$p,qe,qe,qe,qe,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,Kp,Gp,Yp,Dp,Wp,zp,Zp,Xp,qe,qe,qe,Jp];return{parse:ce}}});var wi=L(Ht=>{"use strict";var nc=_i().BigNumber;Ht.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Ht.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36};Ht.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Ht.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Ht.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Ht.SHIFT32=Math.pow(2,32);Ht.SHIFT16=Math.pow(2,16);Ht.MAX_SAFE_HIGH=2097151;Ht.NEG_ONE=new nc(-1);Ht.TEN=new nc(10);Ht.TWO=new nc(2);Ht.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var ks=L(Xt=>{"use strict";var{Buffer:Lb}=Un("buffer"),Ff=_i().BigNumber,Mf=wi(),Uf=Mf.SHIFT32,Qb=Mf.SHIFT16,eg=2097151;Xt.parseHalf=function(e){var r,n,i;return i=e[0]&128?-1:1,r=(e[0]&124)>>2,n=(e[0]&3)<<8|e[1],r?r===31?i*(n?NaN:1/0):i*Math.pow(2,r-25)*(1024+n):i*5960464477539063e-23*n};function tg(t){return t<16?"0"+t.toString(16):t.toString(16)}Xt.arrayBufferToBignumber=function(t){let e=t.byteLength,r="";for(let n=0;n<e;n++)r+=tg(t[n]);return new Ff(r,16)};Xt.buildMap=t=>{let e=new Map,r=Object.keys(t),n=r.length;for(let i=0;i<n;i++)e.set(r[i],t[r[i]]);return e};Xt.buildInt32=(t,e)=>t*Qb+e;Xt.buildInt64=(t,e,r,n)=>{let i=Xt.buildInt32(t,e),s=Xt.buildInt32(r,n);return i>eg?new Ff(i).times(Uf).plus(s):i*Uf+s};Xt.writeHalf=function(e,r){let n=Lb.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};Xt.keySorter=function(t,e){var r=t[0].byteLength,n=e[0].byteLength;return r>n?1:n>r?-1:t[0].compare(e[0])};Xt.isNegativeZero=t=>t===0&&1/t<0;Xt.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,e+=1;return 1<<e}});var ac=L((Vx,Cf)=>{"use strict";var oc=wi(),rg=oc.MT,Vs=oc.SIMPLE,ic=oc.SYMS,sc=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,rg.SIMPLE_FLOAT)}static isSimple(e){return e instanceof t}static decode(e,r){switch(r==null&&(r=!0),e){case Vs.FALSE:return!1;case Vs.TRUE:return!0;case Vs.NULL:return r?null:ic.NULL;case Vs.UNDEFINED:return r?void 0:ic.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return ic.BREAK;default:return new t(e)}}};Cf.exports=sc});var uc=L((Hx,qf)=>{"use strict";var cc=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}}};qf.exports=cc});var fc=L(($x,kf)=>{"use strict";var{URL:ng,URLSearchParams:ig,format:sg}=Un("url"),jf="http://localhost",lc=class extends ng{constructor(e="",r=jf){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()}};kf.exports={URLWithLegacySupport:lc,URLSearchParams:ig,format:sg,defaultBase:jf}});var $f=L((Kx,Hf)=>{"use strict";var{URLWithLegacySupport:Vf,format:og}=fc();Hf.exports=(t,e={},r={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new Vf(t)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new Vf(t,og(o)).toString()}});var dc=L((Gx,Kf)=>{"use strict";var{URLWithLegacySupport:ag,format:cg,URLSearchParams:ug,defaultBase:lg}=fc(),fg=$f();Kf.exports={URL:ag,URLSearchParams:ug,format:cg,relative:fg,defaultBase:lg}});var hc=L((Yx,Yf)=>{"use strict";var{Buffer:Jn}=Un("buffer"),Gf=Sa(),dg=_i().BigNumber,hg=If(),Nt=ks(),Me=wi(),pg=ac(),yg=uc(),{URL:bg}=dc(),xi=class t{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=Nt.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=Jn.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>Nt.arrayBufferToBignumber(r),3:r=>Me.NEG_ONE.minus(Nt.arrayBufferToBignumber(r)),4:r=>Me.TEN.pow(r[0]).times(r[1]),5:r=>Me.TWO.pow(r[0]).times(r[1]),32:r=>new bg(r),35:r=>new RegExp(r)},e.tags),this.parser=hg(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 Me.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case Me.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case Me.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case Me.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 Me.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 Me.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===Me.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 Me.PARENT.ARRAY:case Me.PARENT.BYTE_STRING:case Me.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case Me.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=Me.PARENT.MAP,n.ref=Nt.buildMap(n.ref)));break;case Me.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case Me.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:Me.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,r){let n=this._knownTags[e];return n?n(r):new yg(e,r)}createMap(e,r){return e}createObject(e,r){return e}createArray(e,r){return e}createByteString(e,r){return Jn.concat(e)}createByteStringFromHeap(e,r){return e===r?Jn.alloc(0):Jn.from(this._heap.slice(e,r))}createInt(e){return e}createInt32(e,r){return Nt.buildInt32(e,r)}createInt64(e,r,n,i){return Nt.buildInt64(e,r,n,i)}createFloat(e){return e}createFloatSingle(e,r,n,i){return Gf.read([e,r,n,i],0,!1,23,4)}createFloatDouble(e,r,n,i,s,o,a,c){return Gf.read([e,r,n,i,s,o,a,c],0,!1,52,8)}createInt32Neg(e,r){return-1-Nt.buildInt32(e,r)}createInt64Neg(e,r,n,i){let s=Nt.buildInt32(e,r),o=Nt.buildInt32(n,i);return s>Me.MAX_SAFE_HIGH?Me.NEG_ONE.minus(new dg(s).times(Me.SHIFT32).plus(o)):-1-(s*Me.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 pg(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([],Me.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,r){let n=Nt.buildInt32(e,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,r,n,i){let s=Nt.buildInt64(e,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,r){let n=Nt.buildInt32(e,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,r,n,i){let s=Nt.buildInt64(e,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:Me.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:Me.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:Me.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,r){this.pushTagStart(Nt.buildInt32(e,r))}pushTagStart8(e,r,n,i){this.pushTagStart(Nt.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({},Me.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),Me.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=Jn.from(e,r||"hex")),new t({size:e.length}).decodeFirst(e)}static decodeAll(e,r){return typeof e=="string"&&(e=Jn.from(e,r||"hex")),new t({size:e.length}).decodeAll(e)}};xi.decodeFirst=xi.decode;Yf.exports=xi});var zf=L((Dx,Wf)=>{"use strict";var{Buffer:pc}=Un("buffer"),gg=hc(),mg=ks(),yc=class t extends gg{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 mg.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'${pc.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(Df(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(e,r){let n=super.createObject(e),i=Object.keys(n).reduce(Df(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,r){return`"${pc.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return typeof e=="string"&&(e=pc.from(e,r||"hex")),new t().decodeFirst(e)}};Wf.exports=yc;function Df(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}});var Qf=L((Wx,Lf)=>{"use strict";var{Buffer:mr}=Un("buffer"),{URL:_g}=dc(),gc=_i().BigNumber,bc=ks(),ot=wi(),sr=ot.MT,Hs=ot.NUMBYTES,Zf=ot.SHIFT32,Xf=ot.SYMS,Ln=ot.TAG,wg=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.TWO,xg=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.FOUR,Eg=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.EIGHT,vg=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.TRUE,Bg=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.FALSE,Tg=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.UNDEFINED,Jf=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.NULL,Sg=new gc("0x20000000000000"),Ag=mr.from("f97e00","hex"),Og=mr.from("f9fc00","hex"),Ng=mr.from("f97c00","hex");function Pg(t){return{}.toString.call(t).slice(8,-1)}var mc=class t{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[_g,this._pushUrl],[gc,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(Ag)}_pushInfinity(e){let r=e<0?Og:Ng;return this.push(r)}_pushFloat(e){let r=mr.allocUnsafe(2);if(bc.writeHalf(r,e)&&bc.parseHalf(r)===e)return this._pushUInt8(wg)&&this.push(r);let n=mr.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(xg)&&this.push(n):this._pushUInt8(Eg)&&this._pushDoubleBE(e)}_pushInt(e,r,n){let i=r<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|Hs.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|Hs.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|Hs.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|Hs.EIGHT)&&this._pushUInt32BE(Math.floor(e/Zf))&&this._pushUInt32BE(e%Zf):r===sr.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,sr.NEG_INT,e):this._pushInt(e,sr.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=mr.byteLength(e,"utf8");return this._pushInt(r,sr.UTF8_STRING)&&this.pushWrite(e,5,r)}_pushBoolean(e){return this._pushUInt8(e?vg:Bg)}_pushUndefined(e){return this._pushUInt8(Tg)}_pushArray(e,r){let n=r.length;if(!e._pushInt(n,sr.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,sr.TAG)}_pushDate(e,r){return e._pushTag(Ln.DATE_EPOCH)&&e.pushAny(Math.round(r/1e3))}_pushBuffer(e,r){return e._pushInt(r.length,sr.BYTE_STRING)&&e.push(r)}_pushNoFilter(e,r){return e._pushBuffer(e,r.slice())}_pushRegexp(e,r){return e._pushTag(Ln.REGEXP)&&e.pushAny(r.source)}_pushSet(e,r){if(!e._pushInt(r.size,sr.ARRAY))return!1;for(let n of r)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,r){return e._pushTag(Ln.URI)&&e.pushAny(r.format())}_pushBigint(e){let r=Ln.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),r=Ln.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=mr.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(Ln.DECIMAL_FRAC)&&e._pushInt(2,sr.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new gc(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(Sg)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,r){return e._pushInt(r.size,sr.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(e){if(!e)return this._pushUInt8(Jf);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,sr.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(bc.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=Pg(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,mr.isBuffer(e)?e:mr.from(e));case"Null":return this._pushUInt8(Jf);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 Xf.NULL:return this._pushObject(null);case Xf.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=mr.allocUnsafe(s),c=0,l=0;for(o=0;o<i;o++){switch(l=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,l,"utf8");break;default:throw new Error("unkown method")}c+=l}var f=a;return this._reset(),f}_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()}};Lf.exports=mc});var $s=L(at=>{"use strict";at.Diagnose=zf();at.Decoder=hc();at.Encoder=Qf();at.Simple=ac();at.Tagged=uc();at.decodeAll=at.Decoder.decodeAll;at.decodeFirst=at.Decoder.decodeFirst;at.diagnose=at.Diagnose.diagnose;at.encode=at.Encoder.encode;at.decode=at.Decoder.decode;at.leveldb={decode:at.Decoder.decodeAll,encode:at.Encoder.encode,buffer:!0,name:"cbor"}});var $t=L(Bt=>{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});Bt.bufFromBufLike=Bt.uint8ToBuf=Bt.bufEquals=Bt.compare=Bt.fromHex=Bt.toHex=Bt.concat=void 0;function Rg(...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}Bt.concat=Rg;function Ig(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}Bt.toHex=Ig;var Ug=new RegExp(/^[0-9a-fA-F]+$/);function Fg(t){if(!Ug.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}Bt.fromHex=Fg;function ed(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}Bt.compare=ed;function Mg(t,e){return ed(t,e)===0}Bt.bufEquals=Mg;function Ks(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}Bt.uint8ToBuf=Ks;function td(t){return t instanceof Uint8Array?Ks(t):t instanceof ArrayBuffer?t:Array.isArray(t)?Ks(new Uint8Array(t)):"buffer"in t?td(t.buffer):Ks(new Uint8Array(t))}Bt.bufFromBufLike=td});var Bi=L(Jt=>{"use strict";var Cg=Jt&&Jt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Jt,"__esModule",{value:!0});Jt.hashOfMap=Jt.requestIdOf=Jt.hashValue=Jt.hash=void 0;var rd=Xn(),qg=Cg($s()),jg=us(),Ei=$t();function Dr(t){return(0,Ei.uint8ToBuf)(jg.sha256.create().update(new Uint8Array(t)).digest())}Jt.hash=Dr;function vi(t){if(t instanceof qg.default.Tagged)return vi(t.value);if(typeof t=="string")return nd(t);if(typeof t=="number")return Dr((0,rd.lebEncode)(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return Dr(t);if(Array.isArray(t)){let e=t.map(vi);return Dr((0,Ei.concat)(...e))}else{if(t&&typeof t=="object"&&t._isPrincipal)return Dr(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return vi(t.toHash());if(typeof t=="object")return _c(t);if(typeof t=="bigint")return Dr((0,rd.lebEncode)(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}Jt.hashValue=vi;var nd=t=>{let e=new TextEncoder().encode(t);return Dr(e)};function kg(t){return _c(t)}Jt.requestIdOf=kg;function _c(t){let n=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=nd(o),l=vi(a);return[c,l]}).sort(([o],[a])=>(0,Ei.compare)(o,a)),i=(0,Ei.concat)(...n.map(o=>(0,Ei.concat)(...o)));return Dr(i)}Jt.hashOfMap=_c});var Ec=L(_r=>{"use strict";var Vg=_r&&_r.__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(_r,"__esModule",{value:!0});_r.createIdentityDescriptor=_r.AnonymousIdentity=_r.SignIdentity=void 0;var id=Mt(),Hg=Bi(),sd=$t(),$g=new TextEncoder().encode(`
|
|
16
|
-
ic-request`),wc=class{getPrincipal(){return this._principal||(this._principal=id.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=Vg(e,["body"]),i=await(0,Hg.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,sd.concat)($g,i))}})}};_r.SignIdentity=wc;var xc=class{getPrincipal(){return id.Principal.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};_r.AnonymousIdentity=xc;function Kg(t){return"getPublicKey"in t?{type:"PublicKeyIdentity",publicKey:(0,sd.toHex)(t.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}_r.createIdentityDescriptor=Kg});var Tc=L(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});var Gg=9007199254740992;function Ur(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 or(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 Gs(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 or(t,r,e.toString(16))}}function od(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 Ur(new Uint8Array(Gs(3,t.length)),new Uint8Array(e))}function Yg(t,e){if(t==14277111)return Ur(new Uint8Array([217,217,247]),e);if(t<24)return Ur(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}}Ve.tagged=Yg;function Ti(t){return new Uint8Array(t).buffer}Ve.raw=Ti;function vc(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}Ve.uSmall=vc;function ad(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),or(0,24,t)}Ve.u8=ad;function cd(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),or(0,25,t)}Ve.u16=cd;function ud(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),or(0,26,t)}Ve.u32=ud;function Bc(t,e){if(typeof t=="string"&&e==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return or(0,27,t)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),Gg),t=t.toString(16),or(0,27,t)}Ve.u64=Bc;function ld(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return vc(0);t=Math.min(Math.max(0,-t),24)-1;let e=[32+t];return new Uint8Array(e).buffer}Ve.iSmall=ld;function fd(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),or(1,24,t)}Ve.i8=fd;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),65535),t=t.toString(16),or(1,25,t)}Ve.i16=dd;function hd(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),or(1,26,t)}Ve.i32=hd;function pd(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?or(1,27,n):Bc(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),or(1,27,t)}Ve.i64=pd;function Dg(t){return t>=0?t<24?vc(t):t<=255?ad(t):t<=65535?cd(t):t<=4294967295?ud(t):Bc(t):t>=-24?ld(t):t>=-255?fd(t):t>=-65535?dd(t):t>=-4294967295?hd(t):pd(t)}Ve.number=Dg;function Wg(t){return Ur(Gs(2,t.byteLength),t)}Ve.bytes=Wg;function zg(t){return od(t)}Ve.string=zg;function Zg(t){return Ur(Gs(4,t.length),...t)}Ve.array=Zg;function Xg(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))),Ur(Gs(5,t.size),...r.map(([n,i])=>Ur(od(n),i)))}Ve.map=Xg;function Jg(t){let e=new Float32Array([t]);return Ur(new Uint8Array([250]),new Uint8Array(e.buffer))}Ve.singleFloat=Jg;function Lg(t){let e=new Float64Array([t]);return Ur(new Uint8Array([251]),new Uint8Array(e.buffer))}Ve.doubleFloat=Lg;function Qg(t){return t?yd():bd()}Ve.bool=Qg;function yd(){return Ti(new Uint8Array([245]))}Ve.true_=yd;function bd(){return Ti(new Uint8Array([244]))}Ve.false_=bd;function e1(){return Ti(new Uint8Array([246]))}Ve.null_=e1;function t1(){return Ti(new Uint8Array([247]))}Ve.undefined_=t1});var gd=L(Wr=>{"use strict";var r1=Wr&&Wr.__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(Wr,"__esModule",{value:!0});var ar=r1(Tc()),n1=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],Ys=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 ar.undefined_();case"boolean":return ar.bool(e);case"number":return Math.floor(e)===e?ar.number(e):ar.doubleFloat(e);case"string":return ar.string(e);case"object":if(e===null)return ar.null_();if(Array.isArray(e))return ar.array(e.map(r=>this._serializer.serializeValue(r)));if(n1.find(r=>e instanceof r))return ar.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 ar.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 ar.map(r,this._stable)}default:throw new Error("Invalid value.")}}};Wr.JsonDefaultCborEncoder=Ys;var Ds=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};Wr.ToCborEncoder=Ds;var Ws=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let r=new this;return r.addEncoder(new Ys(r,e)),r.addEncoder(new Ds),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)}};Wr.CborSerializer=Ws;var Sc=class extends Ws{serialize(e){return ar.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};Wr.SelfDescribeCborSerializer=Sc});var Si=L(_n=>{"use strict";function i1(t){for(var e in t)_n.hasOwnProperty(e)||(_n[e]=t[e])}var s1=_n&&_n.__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(_n,"__esModule",{value:!0});i1(gd());var o1=s1(Tc());_n.value=o1});var Ai=L(wt=>{"use strict";var a1=wt&&wt.__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]}),c1=wt&&wt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),u1=wt&&wt.__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)&&a1(e,t,r);return c1(e,t),e},l1=wt&&wt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(wt,"__esModule",{value:!0});wt.decode=wt.encode=wt.CborTag=void 0;var f1=l1($s()),Qn=u1(Si()),d1=Si(),Ac=$t(),Oc=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return Qn.value.bytes(e.toUint8Array())}},Nc=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return Qn.value.bytes(new Uint8Array(e))}},Pc=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?Qn.value.tagged(2,Qn.value.bytes((0,Ac.fromHex)(e.toString(16)))):Qn.value.tagged(3,Qn.value.bytes((0,Ac.fromHex)((BigInt("-1")*e).toString(16))))}},zs=d1.SelfDescribeCborSerializer.withDefaultEncoders(!0);zs.addEncoder(new Oc);zs.addEncoder(new Nc);zs.addEncoder(new Pc);var _d;(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(_d=wt.CborTag||(wt.CborTag={}));function h1(t){return zs.serialize(t)}wt.encode=h1;function md(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 Rc=class extends f1.default.Decoder{createByteString(e){return(0,Ac.concat)(...e)}createByteStringFromHeap(e,r){return e===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,r))}};function p1(t){let e=new Uint8Array(t);return new Rc({size:e.byteLength,tags:{2:n=>md(n),3:n=>-md(n),[_d.Semantic]:n=>n}}).decodeFirst(e)}wt.decode=p1});var Ic=L(Zs=>{"use strict";Object.defineProperty(Zs,"__esModule",{value:!0});Zs.randomNumber=void 0;var y1=()=>{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)};Zs.randomNumber=y1});var Oi=L(wn=>{"use strict";Object.defineProperty(wn,"__esModule",{value:!0});wn.makeNonce=wn.SubmitRequestType=void 0;var Xs=Ic(),b1;(function(t){t.Call="call"})(b1=wn.SubmitRequestType||(wn.SubmitRequestType={}));function g1(){let t=new ArrayBuffer(16),e=new DataView(t),r=(0,Xs.randomNumber)(),n=(0,Xs.randomNumber)(),i=(0,Xs.randomNumber)(),s=(0,Xs.randomNumber)();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),t}wn.makeNonce=g1});var Ls=L(Tt=>{"use strict";var m1=Tt&&Tt.__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]}),_1=Tt&&Tt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),w1=Tt&&Tt.__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)&&m1(e,t,r);return _1(e,t),e};Object.defineProperty(Tt,"__esModule",{value:!0});Tt.httpHeadersTransform=Tt.makeExpiryTransform=Tt.makeNonceTransform=Tt.Expiry=void 0;var x1=Xn(),E1=w1(Si()),v1=Oi(),B1=BigInt(1e6),T1=60*1e3,Js=class{constructor(e){let s=BigInt(Math.floor(Date.now()+e-T1))*B1/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return E1.value.u64(this._value.toString(16),16)}toHash(){return(0,x1.lebEncode)(this._value)}};Tt.Expiry=Js;function S1(t=v1.makeNonce){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}Tt.makeNonceTransform=S1;function A1(t){return async e=>{e.body.ingress_expiry=new Js(t)}}Tt.makeExpiryTransform=A1;function O1(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}Tt.httpHeadersTransform=O1});var Fc=L(Qs=>{"use strict";Object.defineProperty(Qs,"__esModule",{value:!0});Qs.AgentHTTPResponseError=void 0;var N1=Kn(),Uc=class extends N1.AgentError{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Qs.AgentHTTPResponseError=Uc});var Lt=L(me=>{"use strict";Object.defineProperty(me,"__esModule",{value:!0});me.validateObject=me.createHmacDrbg=me.bitMask=me.bitSet=me.bitGet=me.bitLen=me.utf8ToBytes=me.equalBytes=me.concatBytes=me.ensureBytes=me.numberToVarBytesBE=me.numberToBytesLE=me.numberToBytesBE=me.bytesToNumberLE=me.bytesToNumberBE=me.hexToBytes=me.hexToNumber=me.numberToHexUnpadded=me.bytesToHex=me.abytes=me.isBytes=void 0;var Ed=BigInt(0),eo=BigInt(1),P1=BigInt(2);function to(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}me.isBytes=to;function ro(t){if(!to(t))throw new Error("Uint8Array expected")}me.abytes=ro;var R1=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Cc(t){ro(t);let e="";for(let r=0;r<t.length;r++)e+=R1[t[r]];return e}me.bytesToHex=Cc;function vd(t){let e=t.toString(16);return e.length&1?`0${e}`:e}me.numberToHexUnpadded=vd;function qc(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}me.hexToNumber=qc;var Fr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function wd(t){if(t>=Fr._0&&t<=Fr._9)return t-Fr._0;if(t>=Fr._A&&t<=Fr._F)return t-(Fr._A-10);if(t>=Fr._a&&t<=Fr._f)return t-(Fr._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=wd(t.charCodeAt(s)),a=wd(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}me.hexToBytes=no;function I1(t){return qc(Cc(t))}me.bytesToNumberBE=I1;function U1(t){return ro(t),qc(Cc(Uint8Array.from(t).reverse()))}me.bytesToNumberLE=U1;function Bd(t,e){return no(t.toString(16).padStart(e*2,"0"))}me.numberToBytesBE=Bd;function F1(t,e){return Bd(t,e).reverse()}me.numberToBytesLE=F1;function M1(t){return no(vd(t))}me.numberToVarBytesBE=M1;function C1(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(to(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}me.ensureBytes=C1;function Td(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];ro(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}me.concatBytes=Td;function q1(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}me.equalBytes=q1;function j1(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}me.utf8ToBytes=j1;function k1(t){let e;for(e=0;t>Ed;t>>=eo,e+=1);return e}me.bitLen=k1;function V1(t,e){return t>>BigInt(e)&eo}me.bitGet=V1;function H1(t,e,r){return t|(r?eo:Ed)<<BigInt(e)}me.bitSet=H1;var $1=t=>(P1<<BigInt(t-1))-eo;me.bitMask=$1;var Mc=t=>new Uint8Array(t),xd=t=>Uint8Array.from(t);function K1(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=Mc(t),i=Mc(t),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...d)=>r(i,n,...d),c=(d=Mc())=>{i=a(xd([0]),d),n=a(),d.length!==0&&(i=a(xd([1]),d),n=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let d=0,v=[];for(;d<e;){n=a();let m=n.slice();v.push(m),d+=n.length}return Td(...v)};return(d,v)=>{o(),c(d);let m;for(;!(m=v(l()));)c();return o(),m}}me.createHmacDrbg=K1;var G1={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"||to(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 Y1(t,e,r={}){let n=(i,s,o)=>{let a=G1[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}me.validateObject=Y1});var Mr=L(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.mapHashToField=we.getMinHashLength=we.getFieldBytesLength=we.hashToPrivateScalar=we.FpSqrtEven=we.FpSqrtOdd=we.Field=we.nLength=we.FpIsSquare=we.FpDiv=we.FpInvertBatch=we.FpPow=we.validateField=we.isNegativeLE=we.FpSqrt=we.tonelliShanks=we.invert=we.pow2=we.pow=we.mod=void 0;var Gt=Lt(),ct=BigInt(0),je=BigInt(1),zr=BigInt(2),D1=BigInt(3),jc=BigInt(4),Sd=BigInt(5),Ad=BigInt(8),W1=BigInt(9),z1=BigInt(16);function Kt(t,e){let r=t%e;return r>=ct?r:e+r}we.mod=Kt;function Od(t,e,r){if(r<=ct||e<ct)throw new Error("Expected power/modulo > 0");if(r===je)return ct;let n=je;for(;e>ct;)e&je&&(n=n*t%r),t=t*t%r,e>>=je;return n}we.pow=Od;function Z1(t,e,r){let n=t;for(;e-- >ct;)n*=n,n%=r;return n}we.pow2=Z1;function io(t,e){if(t===ct||e<=ct)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Kt(t,e),n=e,i=ct,s=je,o=je,a=ct;for(;r!==ct;){let l=n/r,f=n%r,d=i-o*l,v=s-a*l;n=r,r=f,i=o,s=a,o=d,a=v}if(n!==je)throw new Error("invert: does not exist");return Kt(i,e)}we.invert=io;function Nd(t){let e=(t-je)/zr,r,n,i;for(r=t-je,n=0;r%zr===ct;r/=zr,n++);for(i=zr;i<t&&Od(i,e,t)!==t-je;i++);if(n===1){let o=(t+je)/jc;return function(c,l){let f=c.pow(l,o);if(!c.eql(c.sqr(f),l))throw new Error("Cannot find square root");return f}}let s=(r+je)/zr;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,f=a.pow(a.mul(a.ONE,i),r),d=a.pow(c,s),v=a.pow(c,r);for(;!a.eql(v,a.ONE);){if(a.eql(v,a.ZERO))return a.ZERO;let m=1;for(let w=a.sqr(v);m<l&&!a.eql(w,a.ONE);m++)w=a.sqr(w);let x=a.pow(f,je<<BigInt(l-m-1));f=a.sqr(x),d=a.mul(d,x),v=a.mul(v,f),l=m}return d}}we.tonelliShanks=Nd;function Pd(t){if(t%jc===D1){let e=(t+je)/jc;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%Ad===Sd){let e=(t-Sd)/Ad;return function(n,i){let s=n.mul(i,zr),o=n.pow(s,e),a=n.mul(i,o),c=n.mul(n.mul(a,zr),o),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),i))throw new Error("Cannot find square root");return l}}return t%z1,Nd(t)}we.FpSqrt=Pd;var X1=(t,e)=>(Kt(t,e)&je)===je;we.isNegativeLE=X1;var J1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function L1(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=J1.reduce((n,i)=>(n[i]="function",n),e);return(0,Gt.validateObject)(t,r)}we.validateField=L1;function Rd(t,e,r){if(r<ct)throw new Error("Expected power > 0");if(r===ct)return t.ONE;if(r===je)return e;let n=t.ONE,i=e;for(;r>ct;)r&je&&(n=t.mul(n,i)),i=t.sqr(i),r>>=je;return n}we.FpPow=Rd;function Id(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}we.FpInvertBatch=Id;function Q1(t,e,r){return t.mul(e,typeof r=="bigint"?io(r,t.ORDER):t.inv(r))}we.FpDiv=Q1;function em(t){let e=(t.ORDER-je)/zr;return r=>{let n=t.pow(r,e);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}}we.FpIsSquare=em;function kc(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}we.nLength=kc;function tm(t,e,r=!1,n={}){if(t<=ct)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:s}=kc(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=Pd(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:(0,Gt.bitMask)(i),ZERO:ct,ONE:je,create:c=>Kt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ct<=c&&c<t},is0:c=>c===ct,isOdd:c=>(c&je)===je,neg:c=>Kt(-c,t),eql:(c,l)=>c===l,sqr:c=>Kt(c*c,t),add:(c,l)=>Kt(c+l,t),sub:(c,l)=>Kt(c-l,t),mul:(c,l)=>Kt(c*l,t),pow:(c,l)=>Rd(a,c,l),div:(c,l)=>Kt(c*io(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>io(c,t),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>Id(a,c),cmov:(c,l,f)=>f?l:c,toBytes:c=>r?(0,Gt.numberToBytesLE)(c,s):(0,Gt.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?(0,Gt.bytesToNumberLE)(c):(0,Gt.bytesToNumberBE)(c)}});return Object.freeze(a)}we.Field=tm;function rm(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)}we.FpSqrtOdd=rm;function nm(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}we.FpSqrtEven=nm;function im(t,e,r=!1){t=(0,Gt.ensureBytes)("privateHash",t);let n=t.length,i=kc(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,Gt.bytesToNumberLE)(t):(0,Gt.bytesToNumberBE)(t);return Kt(s,e-je)+je}we.hashToPrivateScalar=im;function Vc(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}we.getFieldBytesLength=Vc;function Ud(t){let e=Vc(t);return e+Math.ceil(e/2)}we.getMinHashLength=Ud;function sm(t,e,r=!1){let n=t.length,i=Vc(e),s=Ud(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?(0,Gt.bytesToNumberBE)(t):(0,Gt.bytesToNumberLE)(t),a=Kt(o,e-je)+je;return r?(0,Gt.numberToBytesLE)(a,i):(0,Gt.numberToBytesBE)(a,i)}we.mapHashToField=sm});var so=L(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.createHasher=Qt.isogenyMap=Qt.hash_to_field=Qt.expand_message_xof=Qt.expand_message_xmd=void 0;var om=Mr(),St=Lt(),am=St.bytesToNumberBE;function Zr(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 cm(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 $c(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function Fd(t,e,r,n){(0,St.abytes)(t),(0,St.abytes)(e),$c(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,Zr(e.length,1)),c=Zr(0,s),l=Zr(r,2),f=new Array(o),d=n((0,St.concatBytes)(c,t,l,Zr(0,1),a));f[0]=n((0,St.concatBytes)(d,Zr(1,1),a));for(let m=1;m<=o;m++){let x=[cm(d,f[m-1]),Zr(m+1,1),a];f[m]=n((0,St.concatBytes)(...x))}return(0,St.concatBytes)(...f).slice(0,r)}Qt.expand_message_xmd=Fd;function Md(t,e,r,n,i){if((0,St.abytes)(t),(0,St.abytes)(e),$c(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(Zr(r,2)).update(e).update(Zr(e.length,1)).digest()}Qt.expand_message_xof=Md;function Hc(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),$c(e);let l=typeof c=="string"?(0,St.utf8ToBytes)(c):c,f=n.toString(2).length,d=Math.ceil((f+i)/8),v=e*s*d,m;if(a==="xmd")m=Fd(t,l,v,o);else if(a==="xof")m=Md(t,l,v,i,o);else if(a==="_internal_pass")m=t;else throw new Error('expand must be "xmd" or "xof"');let x=new Array(e);for(let w=0;w<e;w++){let N=new Array(s);for(let A=0;A<s;A++){let q=d*(A+w*s),O=m.subarray(q,q+d);N[A]=(0,om.mod)(am(O),n)}x[w]=N}return x}Qt.hash_to_field=Hc;function um(t,e){let r=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,a,c]=r.map(l=>l.reduce((f,d)=>t.add(t.mul(f,n),d)));return n=t.div(s,o),i=t.mul(i,t.div(a,c)),{x:n,y:i}}}Qt.isogenyMap=um;function lm(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=Hc(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=Hc(n,1,{...r,DST:r.encodeDST,...i}),o=t.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o}}}Qt.createHasher=lm});var Gc=L(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0});ei.validateBasic=ei.wNAF=void 0;var Cd=Mr(),fm=Lt(),dm=BigInt(0),Kc=BigInt(1);function hm(t,e){let r=(i,s)=>{let o=s.negate();return i?o:s},n=i=>{let s=Math.ceil(e/i)+1,o=2**(i-1);return{windows:s,windowSize:o}};return{constTimeNegate:r,unsafeLadder(i,s){let o=t.ZERO,a=i;for(;s>dm;)s&Kc&&(o=o.add(a)),a=a.double(),s>>=Kc;return o},precomputeWindow(i,s){let{windows:o,windowSize:a}=n(s),c=[],l=i,f=l;for(let d=0;d<o;d++){f=l,c.push(f);for(let v=1;v<a;v++)f=f.add(l),c.push(f);l=f.double()}return c},wNAF(i,s,o){let{windows:a,windowSize:c}=n(i),l=t.ZERO,f=t.BASE,d=BigInt(2**i-1),v=2**i,m=BigInt(i);for(let x=0;x<a;x++){let w=x*c,N=Number(o&d);o>>=m,N>c&&(N-=v,o+=Kc);let A=w,q=w+Math.abs(N)-1,O=x%2!==0,$=N<0;N===0?f=f.add(r(O,s[A])):l=l.add(r($,s[q]))}return{p:l,f}},wNAFCached(i,s,o,a){let c=i._WINDOW_SIZE||1,l=s.get(i);return l||(l=this.precomputeWindow(i,c),c!==1&&s.set(i,a(l))),this.wNAF(c,l,o)}}}ei.wNAF=hm;function pm(t){return(0,Cd.validateField)(t.Fp),(0,fm.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,Cd.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}ei.validateBasic=pm});var Dc=L(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.mapToCurveSimpleSWU=ut.SWUFpSqrtRatio=ut.weierstrass=ut.weierstrassPoints=ut.DER=void 0;var ti=Mr(),We=Lt(),wr=Lt(),Yc=Gc();function ym(t){let e=(0,Yc.validateBasic)(t);We.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:bm,hexToBytes:gm}=We;ut.DER={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=ut.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:bm(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=ut.DER,r=typeof t=="string"?gm(t):t;We.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}=ut.DER._parseInt(r.subarray(2)),{d:o,l:a}=ut.DER._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(t){let e=l=>Number.parseInt(l[0],16)&8?"00"+l:l,r=l=>{let f=l.toString(16);return f.length&1?`0${f}`:f},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 cr=BigInt(0),Xe=BigInt(1),Xr=BigInt(2),oo=BigInt(3),qd=BigInt(4);function jd(t){let e=ym(t),{Fp:r}=e,n=e.toBytes||((x,w,N)=>{let A=w.toAffine();return We.concatBytes(Uint8Array.from([4]),r.toBytes(A.x),r.toBytes(A.y))}),i=e.fromBytes||(x=>{let w=x.subarray(1),N=r.fromBytes(w.subarray(0,r.BYTES)),A=r.fromBytes(w.subarray(r.BYTES,2*r.BYTES));return{x:N,y:A}});function s(x){let{a:w,b:N}=e,A=r.sqr(x),q=r.mul(A,x);return r.add(r.add(q,r.mul(x,w)),N)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(x){return typeof x=="bigint"&&cr<x&&x<e.n}function a(x){if(!o(x))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(x){let{allowedPrivateKeyLengths:w,nByteLength:N,wrapPrivateKey:A,n:q}=e;if(w&&typeof x!="bigint"){if(We.isBytes(x)&&(x=We.bytesToHex(x)),typeof x!="string"||!w.includes(x.length))throw new Error("Invalid key");x=x.padStart(N*2,"0")}let O;try{O=typeof x=="bigint"?x:We.bytesToNumberBE((0,wr.ensureBytes)("private key",x,N))}catch{throw new Error(`private key must be ${N} bytes, hex or bigint, not ${typeof x}`)}return A&&(O=ti.mod(O,q)),a(O),O}let l=new Map;function f(x){if(!(x instanceof d))throw new Error("ProjectivePoint expected")}class d{constructor(w,N,A){if(this.px=w,this.py=N,this.pz=A,w==null||!r.isValid(w))throw new Error("x required");if(N==null||!r.isValid(N))throw new Error("y required");if(A==null||!r.isValid(A))throw new Error("z required")}static fromAffine(w){let{x:N,y:A}=w||{};if(!w||!r.isValid(N)||!r.isValid(A))throw new Error("invalid affine point");if(w instanceof d)throw new Error("projective point not allowed");let q=O=>r.eql(O,r.ZERO);return q(N)&&q(A)?d.ZERO:new d(N,A,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(w){let N=r.invertBatch(w.map(A=>A.pz));return w.map((A,q)=>A.toAffine(N[q])).map(d.fromAffine)}static fromHex(w){let N=d.fromAffine(i((0,wr.ensureBytes)("pointHex",w)));return N.assertValidity(),N}static fromPrivateKey(w){return d.BASE.multiply(c(w))}_setWindowSize(w){this._WINDOW_SIZE=w,l.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:w,y:N}=this.toAffine();if(!r.isValid(w)||!r.isValid(N))throw new Error("bad point: x or y not FE");let A=r.sqr(N),q=s(w);if(!r.eql(A,q))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:w}=this.toAffine();if(r.isOdd)return!r.isOdd(w);throw new Error("Field doesn't support isOdd")}equals(w){f(w);let{px:N,py:A,pz:q}=this,{px:O,py:$,pz:I}=w,k=r.eql(r.mul(N,I),r.mul(O,q)),z=r.eql(r.mul(A,I),r.mul($,q));return k&&z}negate(){return new d(this.px,r.neg(this.py),this.pz)}double(){let{a:w,b:N}=e,A=r.mul(N,oo),{px:q,py:O,pz:$}=this,I=r.ZERO,k=r.ZERO,z=r.ZERO,W=r.mul(q,q),K=r.mul(O,O),se=r.mul($,$),te=r.mul(q,O);return te=r.add(te,te),z=r.mul(q,$),z=r.add(z,z),I=r.mul(w,z),k=r.mul(A,se),k=r.add(I,k),I=r.sub(K,k),k=r.add(K,k),k=r.mul(I,k),I=r.mul(te,I),z=r.mul(A,z),se=r.mul(w,se),te=r.sub(W,se),te=r.mul(w,te),te=r.add(te,z),z=r.add(W,W),W=r.add(z,W),W=r.add(W,se),W=r.mul(W,te),k=r.add(k,W),se=r.mul(O,$),se=r.add(se,se),W=r.mul(se,te),I=r.sub(I,W),z=r.mul(se,K),z=r.add(z,z),z=r.add(z,z),new d(I,k,z)}add(w){f(w);let{px:N,py:A,pz:q}=this,{px:O,py:$,pz:I}=w,k=r.ZERO,z=r.ZERO,W=r.ZERO,K=e.a,se=r.mul(e.b,oo),te=r.mul(N,O),fe=r.mul(A,$),ue=r.mul(q,I),Be=r.add(N,A),Z=r.add(O,$);Be=r.mul(Be,Z),Z=r.add(te,fe),Be=r.sub(Be,Z),Z=r.add(N,q);let C=r.add(O,I);return Z=r.mul(Z,C),C=r.add(te,ue),Z=r.sub(Z,C),C=r.add(A,q),k=r.add($,I),C=r.mul(C,k),k=r.add(fe,ue),C=r.sub(C,k),W=r.mul(K,Z),k=r.mul(se,ue),W=r.add(k,W),k=r.sub(fe,W),W=r.add(fe,W),z=r.mul(k,W),fe=r.add(te,te),fe=r.add(fe,te),ue=r.mul(K,ue),Z=r.mul(se,Z),fe=r.add(fe,ue),ue=r.sub(te,ue),ue=r.mul(K,ue),Z=r.add(Z,ue),te=r.mul(fe,Z),z=r.add(z,te),te=r.mul(C,Z),k=r.mul(Be,k),k=r.sub(k,te),te=r.mul(Be,fe),W=r.mul(C,W),W=r.add(W,te),new d(k,z,W)}subtract(w){return this.add(w.negate())}is0(){return this.equals(d.ZERO)}wNAF(w){return m.wNAFCached(this,l,w,N=>{let A=r.invertBatch(N.map(q=>q.pz));return N.map((q,O)=>q.toAffine(A[O])).map(d.fromAffine)})}multiplyUnsafe(w){let N=d.ZERO;if(w===cr)return N;if(a(w),w===Xe)return this;let{endo:A}=e;if(!A)return m.unsafeLadder(this,w);let{k1neg:q,k1:O,k2neg:$,k2:I}=A.splitScalar(w),k=N,z=N,W=this;for(;O>cr||I>cr;)O&Xe&&(k=k.add(W)),I&Xe&&(z=z.add(W)),W=W.double(),O>>=Xe,I>>=Xe;return q&&(k=k.negate()),$&&(z=z.negate()),z=new d(r.mul(z.px,A.beta),z.py,z.pz),k.add(z)}multiply(w){a(w);let N=w,A,q,{endo:O}=e;if(O){let{k1neg:$,k1:I,k2neg:k,k2:z}=O.splitScalar(N),{p:W,f:K}=this.wNAF(I),{p:se,f:te}=this.wNAF(z);W=m.constTimeNegate($,W),se=m.constTimeNegate(k,se),se=new d(r.mul(se.px,O.beta),se.py,se.pz),A=W.add(se),q=K.add(te)}else{let{p:$,f:I}=this.wNAF(N);A=$,q=I}return d.normalizeZ([A,q])[0]}multiplyAndAddUnsafe(w,N,A){let q=d.BASE,O=(I,k)=>k===cr||k===Xe||!I.equals(q)?I.multiplyUnsafe(k):I.multiply(k),$=O(this,N).add(O(w,A));return $.is0()?void 0:$}toAffine(w){let{px:N,py:A,pz:q}=this,O=this.is0();w==null&&(w=O?r.ONE:r.inv(q));let $=r.mul(N,w),I=r.mul(A,w),k=r.mul(q,w);if(O)return{x:r.ZERO,y:r.ZERO};if(!r.eql(k,r.ONE))throw new Error("invZ was invalid");return{x:$,y:I}}isTorsionFree(){let{h:w,isTorsionFree:N}=e;if(w===Xe)return!0;if(N)return N(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:w,clearCofactor:N}=e;return w===Xe?this:N?N(d,this):this.multiplyUnsafe(e.h)}toRawBytes(w=!0){return this.assertValidity(),n(d,this,w)}toHex(w=!0){return We.bytesToHex(this.toRawBytes(w))}}d.BASE=new d(e.Gx,e.Gy,r.ONE),d.ZERO=new d(r.ZERO,r.ONE,r.ZERO);let v=e.nBitLength,m=(0,Yc.wNAF)(d,e.endo?Math.ceil(v/2):v);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:o}}ut.weierstrassPoints=jd;function mm(t){let e=(0,Yc.validateBasic)(t);return We.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function _m(t){let e=mm(t),{Fp:r,n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function o(Z){return cr<Z&&Z<r.ORDER}function a(Z){return ti.mod(Z,n)}function c(Z){return ti.invert(Z,n)}let{ProjectivePoint:l,normPrivateKeyToScalar:f,weierstrassEquation:d,isWithinCurveOrder:v}=jd({...e,toBytes(Z,C,X){let j=C.toAffine(),U=r.toBytes(j.x),D=We.concatBytes;return X?D(Uint8Array.from([C.hasEvenY()?2:3]),U):D(Uint8Array.from([4]),U,r.toBytes(j.y))},fromBytes(Z){let C=Z.length,X=Z[0],j=Z.subarray(1);if(C===i&&(X===2||X===3)){let U=We.bytesToNumberBE(j);if(!o(U))throw new Error("Point is not on curve");let D=d(U),J;try{J=r.sqrt(D)}catch(y){let de=y instanceof Error?": "+y.message:"";throw new Error("Point is not on curve"+de)}let ie=(J&Xe)===Xe;return(X&1)===1!==ie&&(J=r.neg(J)),{x:U,y:J}}else if(C===s&&X===4){let U=r.fromBytes(j.subarray(0,r.BYTES)),D=r.fromBytes(j.subarray(r.BYTES,2*r.BYTES));return{x:U,y:D}}else throw new Error(`Point of length ${C} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),m=Z=>We.bytesToHex(We.numberToBytesBE(Z,e.nByteLength));function x(Z){let C=n>>Xe;return Z>C}function w(Z){return x(Z)?a(-Z):Z}let N=(Z,C,X)=>We.bytesToNumberBE(Z.slice(C,X));class A{constructor(C,X,j){this.r=C,this.s=X,this.recovery=j,this.assertValidity()}static fromCompact(C){let X=e.nByteLength;return C=(0,wr.ensureBytes)("compactSignature",C,X*2),new A(N(C,0,X),N(C,X,2*X))}static fromDER(C){let{r:X,s:j}=ut.DER.toSig((0,wr.ensureBytes)("DER",C));return new A(X,j)}assertValidity(){if(!v(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!v(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(C){return new A(this.r,this.s,C)}recoverPublicKey(C){let{r:X,s:j,recovery:U}=this,D=z((0,wr.ensureBytes)("msgHash",C));if(U==null||![0,1,2,3].includes(U))throw new Error("recovery id invalid");let J=U===2||U===3?X+e.n:X;if(J>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let ie=U&1?"03":"02",R=l.fromHex(ie+m(J)),y=c(J),de=a(-D*y),ae=a(j*y),ce=l.BASE.multiplyAndAddUnsafe(R,de,ae);if(!ce)throw new Error("point at infinify");return ce.assertValidity(),ce}hasHighS(){return x(this.s)}normalizeS(){return this.hasHighS()?new A(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return We.hexToBytes(this.toDERHex())}toDERHex(){return ut.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return We.hexToBytes(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let q={isValidPrivateKey(Z){try{return f(Z),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let Z=ti.getMinHashLength(e.n);return ti.mapHashToField(e.randomBytes(Z),e.n)},precompute(Z=8,C=l.BASE){return C._setWindowSize(Z),C.multiply(BigInt(3)),C}};function O(Z,C=!0){return l.fromPrivateKey(Z).toRawBytes(C)}function $(Z){let C=We.isBytes(Z),X=typeof Z=="string",j=(C||X)&&Z.length;return C?j===i||j===s:X?j===2*i||j===2*s:Z instanceof l}function I(Z,C,X=!0){if($(Z))throw new Error("first arg must be private key");if(!$(C))throw new Error("second arg must be public key");return l.fromHex(C).multiply(f(Z)).toRawBytes(X)}let k=e.bits2int||function(Z){let C=We.bytesToNumberBE(Z),X=Z.length*8-e.nBitLength;return X>0?C>>BigInt(X):C},z=e.bits2int_modN||function(Z){return a(k(Z))},W=We.bitMask(e.nBitLength);function K(Z){if(typeof Z!="bigint")throw new Error("bigint expected");if(!(cr<=Z&&Z<W))throw new Error(`bigint expected < 2^${e.nBitLength}`);return We.numberToBytesBE(Z,e.nByteLength)}function se(Z,C,X=te){if(["recovered","canonical"].some(u=>u in X))throw new Error("sign() legacy options not supported");let{hash:j,randomBytes:U}=e,{lowS:D,prehash:J,extraEntropy:ie}=X;D==null&&(D=!0),Z=(0,wr.ensureBytes)("msgHash",Z),J&&(Z=(0,wr.ensureBytes)("prehashed msgHash",j(Z)));let R=z(Z),y=f(C),de=[K(y),K(R)];if(ie!=null&&ie!==!1){let u=ie===!0?U(r.BYTES):ie;de.push((0,wr.ensureBytes)("extraEntropy",u))}let ae=We.concatBytes(...de),ce=R;function ee(u){let h=k(u);if(!v(h))return;let p=c(h),B=l.BASE.multiply(h).toAffine(),E=a(B.x);if(E===cr)return;let T=a(p*a(ce+E*y));if(T===cr)return;let F=(B.x===E?0:2)|Number(B.y&Xe),g=T;return D&&x(T)&&(g=w(T),F^=1),new A(E,g,F)}return{seed:ae,k2sig:ee}}let te={lowS:e.lowS,prehash:!1},fe={lowS:e.lowS,prehash:!1};function ue(Z,C,X=te){let{seed:j,k2sig:U}=se(Z,C,X),D=e;return We.createHmacDrbg(D.hash.outputLen,D.nByteLength,D.hmac)(j,U)}l.BASE._setWindowSize(8);function Be(Z,C,X,j=fe){let U=Z;if(C=(0,wr.ensureBytes)("msgHash",C),X=(0,wr.ensureBytes)("publicKey",X),"strict"in j)throw new Error("options.strict was renamed to lowS");let{lowS:D,prehash:J}=j,ie,R;try{if(typeof U=="string"||We.isBytes(U))try{ie=A.fromDER(U)}catch(B){if(!(B instanceof ut.DER.Err))throw B;ie=A.fromCompact(U)}else if(typeof U=="object"&&typeof U.r=="bigint"&&typeof U.s=="bigint"){let{r:B,s:E}=U;ie=new A(B,E)}else throw new Error("PARSE");R=l.fromHex(X)}catch(B){if(B.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(D&&ie.hasHighS())return!1;J&&(C=e.hash(C));let{r:y,s:de}=ie,ae=z(C),ce=c(de),ee=a(ae*ce),u=a(y*ce),h=l.BASE.multiplyAndAddUnsafe(R,ee,u)?.toAffine();return h?a(h.x)===y:!1}return{CURVE:e,getPublicKey:O,getSharedSecret:I,sign:ue,verify:Be,ProjectivePoint:l,Signature:A,utils:q}}ut.weierstrass=_m;function kd(t,e){let r=t.ORDER,n=cr;for(let x=r-Xe;x%Xr===cr;x/=Xr)n+=Xe;let i=n,s=Xr<<i-Xe-Xe,o=s*Xr,a=(r-Xe)/o,c=(a-Xe)/Xr,l=o-Xe,f=s,d=t.pow(e,a),v=t.pow(e,(a+Xe)/Xr),m=(x,w)=>{let N=d,A=t.pow(w,l),q=t.sqr(A);q=t.mul(q,w);let O=t.mul(x,q);O=t.pow(O,c),O=t.mul(O,A),A=t.mul(O,w),q=t.mul(O,x);let $=t.mul(q,A);O=t.pow($,f);let I=t.eql(O,t.ONE);A=t.mul(q,v),O=t.mul($,N),q=t.cmov(A,q,I),$=t.cmov(O,$,I);for(let k=i;k>Xe;k--){let z=k-Xr;z=Xr<<z-Xe;let W=t.pow($,z),K=t.eql(W,t.ONE);A=t.mul(q,N),N=t.mul(N,N),W=t.mul($,N),q=t.cmov(A,q,K),$=t.cmov(W,$,K)}return{isValid:I,value:q}};if(t.ORDER%qd===oo){let x=(t.ORDER-oo)/qd,w=t.sqrt(t.neg(e));m=(N,A)=>{let q=t.sqr(A),O=t.mul(N,A);q=t.mul(q,O);let $=t.pow(q,x);$=t.mul($,O);let I=t.mul($,w),k=t.mul(t.sqr($),A),z=t.eql(k,N),W=t.cmov(I,$,z);return{isValid:z,value:W}}}return m}ut.SWUFpSqrtRatio=kd;function wm(t,e){if(ti.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=kd(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,a,c,l,f,d;i=t.sqr(n),i=t.mul(i,e.Z),s=t.sqr(i),s=t.add(s,i),o=t.add(s,t.ONE),o=t.mul(o,e.B),a=t.cmov(e.Z,t.neg(s),!t.eql(s,t.ZERO)),a=t.mul(a,e.A),s=t.sqr(o),l=t.sqr(a),c=t.mul(l,e.A),s=t.add(s,c),s=t.mul(s,o),l=t.mul(l,a),c=t.mul(l,e.B),s=t.add(s,c),f=t.mul(i,o);let{isValid:v,value:m}=r(s,l);d=t.mul(i,n),d=t.mul(d,m),f=t.cmov(f,o,v),d=t.cmov(d,m,v);let x=t.isOdd(n)===t.isOdd(d);return d=t.cmov(t.neg(d),d,x),f=t.div(f,a),{x:f,y:d}}}ut.mapToCurveSimpleSWU=wm});var Kd=L(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0});co.bls=void 0;var Vd=Mr(),Ni=Lt(),Hd=so(),$d=Dc(),Wc=BigInt(2),ao=BigInt(3);function xm(t){let{Fp:e,Fr:r,Fp2:n,Fp6:i,Fp12:s}=t.fields,o=(0,Ni.bitLen)(t.params.x);function a(C){let{x:X,y:j}=C,U=X,D=j,J=n.ONE,ie=U,R=D,y=J,de=[];for(let ae=o-2;ae>=0;ae--){let ce=n.sqr(R),ee=n.sqr(y),u=n.multiplyByB(n.mul(ee,ao)),h=n.mul(u,ao),p=n.sub(n.sub(n.sqr(n.add(R,y)),ee),ce);if(de.push([n.sub(u,ce),n.mul(n.sqr(ie),ao),n.neg(p)]),ie=n.div(n.mul(n.mul(n.sub(ce,h),ie),R),Wc),R=n.sub(n.sqr(n.div(n.add(ce,h),Wc)),n.mul(n.sqr(u),ao)),y=n.mul(ce,p),(0,Ni.bitGet)(t.params.x,ae)){let B=n.sub(R,n.mul(D,y)),E=n.sub(ie,n.mul(U,y));de.push([n.sub(n.mul(B,U),n.mul(E,D)),n.neg(B),E]);let T=n.sqr(E),F=n.mul(T,E),g=n.mul(T,ie),S=n.add(n.sub(F,n.mul(g,Wc)),n.mul(n.sqr(B),y));ie=n.mul(E,S),R=n.sub(n.mul(n.sub(g,S),B),n.mul(F,R)),y=n.mul(y,F)}}return de}function c(C,X){let{x:j}=t.params,U=X[0],D=X[1],J=s.ONE;for(let ie=0,R=o-2;R>=0;R--,ie++){let y=C[ie];if(J=s.multiplyBy014(J,y[0],n.mul(y[1],U),n.mul(y[2],D)),(0,Ni.bitGet)(j,R)){ie+=1;let de=C[ie];J=s.multiplyBy014(J,de[0],n.mul(de[1],U),n.mul(de[2],D))}R!==0&&(J=s.sqr(J))}return s.conjugate(J)}let l={randomPrivateKey:()=>{let C=(0,Vd.getMinHashLength)(r.ORDER);return(0,Vd.mapHashToField)(t.randomBytes(C),r.ORDER)},calcPairingPrecomputes:a},f=(0,$d.weierstrassPoints)({n:r.ORDER,...t.G1}),d=Object.assign(f,(0,Hd.createHasher)(f.ProjectivePoint,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults}));function v(C){let X=C;return X._PPRECOMPUTES||(X._PPRECOMPUTES=a(C.toAffine())),X._PPRECOMPUTES}let m=(0,$d.weierstrassPoints)({n:r.ORDER,...t.G2}),x=Object.assign(m,(0,Hd.createHasher)(m.ProjectivePoint,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),{ShortSignature:w}=t.G1,{Signature:N}=t.G2;function A(C,X,j=!0){if(C.equals(d.ProjectivePoint.ZERO)||X.equals(x.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");C.assertValidity(),X.assertValidity();let U=C.toAffine(),D=c(v(X),[U.x,U.y]);return j?s.finalExponentiate(D):D}function q(C){return C instanceof d.ProjectivePoint?C:d.ProjectivePoint.fromHex(C)}function O(C,X){return C instanceof d.ProjectivePoint?C:d.hashToCurve((0,Ni.ensureBytes)("point",C),X)}function $(C){return C instanceof x.ProjectivePoint?C:N.fromHex(C)}function I(C,X){return C instanceof x.ProjectivePoint?C:x.hashToCurve((0,Ni.ensureBytes)("point",C),X)}function k(C){return d.ProjectivePoint.fromPrivateKey(C).toRawBytes(!0)}function z(C){return x.ProjectivePoint.fromPrivateKey(C).toRawBytes(!0)}function W(C,X,j){let U=I(C,j);U.assertValidity();let D=U.multiply(d.normPrivateKeyToScalar(X));return C instanceof x.ProjectivePoint?D:N.toRawBytes(D)}function K(C,X,j){let U=O(C,j);U.assertValidity();let D=U.multiply(d.normPrivateKeyToScalar(X));return C instanceof d.ProjectivePoint?D:w.toRawBytes(D)}function se(C,X,j,U){let D=q(j),J=I(X,U),ie=d.ProjectivePoint.BASE,R=$(C),y=A(D.negate(),J,!1),de=A(ie,R,!1),ae=s.finalExponentiate(s.mul(de,y));return s.eql(ae,s.ONE)}function te(C,X,j,U){let D=$(j),J=O(X,U),ie=x.ProjectivePoint.BASE,R=q(C),y=A(J,D,!1),de=A(R,ie.negate(),!1),ae=s.finalExponentiate(s.mul(de,y));return s.eql(ae,s.ONE)}function fe(C){if(!C.length)throw new Error("Expected non-empty array");let j=C.map(q).reduce((U,D)=>U.add(D),d.ProjectivePoint.ZERO);return C[0]instanceof d.ProjectivePoint?(j.assertValidity(),j):j.toRawBytes(!0)}function ue(C){if(!C.length)throw new Error("Expected non-empty array");let j=C.map($).reduce((U,D)=>U.add(D),x.ProjectivePoint.ZERO);return C[0]instanceof x.ProjectivePoint?(j.assertValidity(),j):N.toRawBytes(j)}function Be(C){if(!C.length)throw new Error("Expected non-empty array");let j=C.map(q).reduce((U,D)=>U.add(D),d.ProjectivePoint.ZERO);return C[0]instanceof d.ProjectivePoint?(j.assertValidity(),j):w.toRawBytes(j)}function Z(C,X,j,U){if(!X.length)throw new Error("Expected non-empty messages array");if(j.length!==X.length)throw new Error("Pubkey count should equal msg count");let D=$(C),J=X.map(R=>I(R,U)),ie=j.map(q);try{let R=[];for(let ae of new Set(J)){let ce=J.reduce((ee,u,h)=>u===ae?ee.add(ie[h]):ee,d.ProjectivePoint.ZERO);R.push(A(ce,ae,!1))}R.push(A(d.ProjectivePoint.BASE.negate(),D,!1));let y=R.reduce((ae,ce)=>s.mul(ae,ce),s.ONE),de=s.finalExponentiate(y);return s.eql(de,s.ONE)}catch{return!1}}return d.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:k,getPublicKeyForShortSignatures:z,sign:W,signShortSignature:K,verify:se,verifyBatch:Z,verifyShortSignature:te,aggregatePublicKeys:fe,aggregateSignatures:ue,aggregateShortSignatures:Be,millerLoop:c,pairing:A,G1:d,G2:x,Signature:N,ShortSignature:w,fields:{Fr:r,Fp:e,Fp2:n,Fp6:i,Fp12:s},params:{x:t.params.x,r:t.params.r,G1b:t.G1.b,G2b:t.G2.b},utils:l}}co.bls=xm});var d0=L(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.bls12_381=void 0;var o0=us(),Em=yn(),vm=Kd(),Lr=Mr(),_e=Lt(),a0=Dc(),c0=so(),it=BigInt(0),xn=BigInt(1),Je=BigInt(2),uo=BigInt(3),Pi=BigInt(4),Bm=BigInt(8),Tm=BigInt(16),Xc=BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),G=Lr.Field(Xc),Gd=Lr.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),Yd=({c0:t,c1:e},{c0:r,c1:n})=>({c0:G.add(t,r),c1:G.add(e,n)}),Dd=({c0:t,c1:e},{c0:r,c1:n})=>({c0:G.sub(t,r),c1:G.sub(e,n)}),Wd=({c0:t,c1:e},r)=>{if(typeof r=="bigint")return{c0:G.mul(t,r),c1:G.mul(e,r)};let{c0:n,c1:i}=r,s=G.mul(t,n),o=G.mul(e,i),a=G.sub(s,o),c=G.sub(G.mul(G.add(t,e),G.add(n,i)),G.add(s,o));return{c0:a,c1:c}},zd=({c0:t,c1:e})=>{let r=G.add(t,e),n=G.sub(t,e),i=G.add(t,t);return{c0:G.mul(r,n),c1:G.mul(i,e)}},lo=Xc*Xc,b={ORDER:lo,BITS:(0,_e.bitLen)(lo),BYTES:Math.ceil((0,_e.bitLen)(lo)/8),MASK:(0,_e.bitMask)((0,_e.bitLen)(lo)),ZERO:{c0:G.ZERO,c1:G.ZERO},ONE:{c0:G.ONE,c1:G.ZERO},create:t=>t,isValid:({c0:t,c1:e})=>typeof t=="bigint"&&typeof e=="bigint",is0:({c0:t,c1:e})=>G.is0(t)&&G.is0(e),eql:({c0:t,c1:e},{c0:r,c1:n})=>G.eql(t,r)&&G.eql(e,n),neg:({c0:t,c1:e})=>({c0:G.neg(t),c1:G.neg(e)}),pow:(t,e)=>Lr.FpPow(b,t,e),invertBatch:t=>Lr.FpInvertBatch(b,t),add:Yd,sub:Dd,mul:Wd,sqr:zd,addN:Yd,subN:Dd,mulN:Wd,sqrN:zd,div:(t,e)=>b.mul(t,typeof e=="bigint"?G.inv(G.create(e)):b.inv(e)),inv:({c0:t,c1:e})=>{let r=G.inv(G.create(t*t+e*e));return{c0:G.mul(r,G.create(t)),c1:G.mul(r,G.create(-e))}},sqrt:t=>{if(b.eql(t,b.ZERO))return b.ZERO;let e=b.pow(t,(b.ORDER+Bm)/Tm),r=b.div(b.sqr(e),t),n=Am,i=[n[0],n[2],n[4],n[6]].find(m=>b.eql(m,r));if(!i)throw new Error("No root");let s=n.indexOf(i),o=n[s/2];if(!o)throw new Error("Invalid root");let a=b.div(e,o),c=b.neg(a),{re:l,im:f}=b.reim(a),{re:d,im:v}=b.reim(c);return f>v||f===v&&l>d?a:c},isOdd:t=>{let{re:e,im:r}=b.reim(t),n=e%Je,i=e===it,s=r%Je;return BigInt(n||i&&s)==xn},fromBytes(t){if(t.length!==b.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:G.fromBytes(t.subarray(0,G.BYTES)),c1:G.fromBytes(t.subarray(G.BYTES))}},toBytes:({c0:t,c1:e})=>(0,_e.concatBytes)(G.toBytes(t),G.toBytes(e)),cmov:({c0:t,c1:e},{c0:r,c1:n},i)=>({c0:G.cmov(t,r,i),c1:G.cmov(e,n,i)}),reim:({c0:t,c1:e})=>({re:t,im:e}),mulByNonresidue:({c0:t,c1:e})=>({c0:G.sub(t,e),c1:G.add(t,e)}),multiplyByB:({c0:t,c1:e})=>{let r=G.mul(t,Pi),n=G.mul(e,Pi);return{c0:G.sub(r,n),c1:G.add(r,n)}},fromBigTuple:t=>{if(t.length!==2)throw new Error("Invalid tuple");let e=t.map(r=>G.create(r));return{c0:e[0],c1:e[1]}},frobeniusMap:({c0:t,c1:e},r)=>({c0:t,c1:G.mul(e,Sm[r%2])})},Sm=[BigInt("0x1"),BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa")].map(t=>G.create(t)),Jr=BigInt("0x6af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09"),Am=[[xn,it],[Jr,-Jr],[it,xn],[Jr,Jr],[-xn,it],[-Jr,Jr],[it,-xn],[-Jr,-Jr]].map(t=>b.fromBigTuple(t)),Zd=({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s})=>({c0:b.add(t,n),c1:b.add(e,i),c2:b.add(r,s)}),Xd=({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s})=>({c0:b.sub(t,n),c1:b.sub(e,i),c2:b.sub(r,s)}),Jd=({c0:t,c1:e,c2:r},n)=>{if(typeof n=="bigint")return{c0:b.mul(t,n),c1:b.mul(e,n),c2:b.mul(r,n)};let{c0:i,c1:s,c2:o}=n,a=b.mul(t,i),c=b.mul(e,s),l=b.mul(r,o);return{c0:b.add(a,b.mulByNonresidue(b.sub(b.mul(b.add(e,r),b.add(s,o)),b.add(c,l)))),c1:b.add(b.sub(b.mul(b.add(t,e),b.add(i,s)),b.add(a,c)),b.mulByNonresidue(l)),c2:b.sub(b.add(c,b.mul(b.add(t,r),b.add(i,o))),b.add(a,l))}},Ld=({c0:t,c1:e,c2:r})=>{let n=b.sqr(t),i=b.mul(b.mul(t,e),Je),s=b.mul(b.mul(e,r),Je),o=b.sqr(r);return{c0:b.add(b.mulByNonresidue(s),n),c1:b.add(b.mulByNonresidue(o),i),c2:b.sub(b.sub(b.add(b.add(i,b.sqr(b.add(b.sub(t,e),r))),s),n),o)}},re={ORDER:b.ORDER,BITS:3*b.BITS,BYTES:3*b.BYTES,MASK:(0,_e.bitMask)(3*b.BITS),ZERO:{c0:b.ZERO,c1:b.ZERO,c2:b.ZERO},ONE:{c0:b.ONE,c1:b.ZERO,c2:b.ZERO},create:t=>t,isValid:({c0:t,c1:e,c2:r})=>b.isValid(t)&&b.isValid(e)&&b.isValid(r),is0:({c0:t,c1:e,c2:r})=>b.is0(t)&&b.is0(e)&&b.is0(r),neg:({c0:t,c1:e,c2:r})=>({c0:b.neg(t),c1:b.neg(e),c2:b.neg(r)}),eql:({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s})=>b.eql(t,n)&&b.eql(e,i)&&b.eql(r,s),sqrt:()=>{throw new Error("Not implemented")},div:(t,e)=>re.mul(t,typeof e=="bigint"?G.inv(G.create(e)):re.inv(e)),pow:(t,e)=>Lr.FpPow(re,t,e),invertBatch:t=>Lr.FpInvertBatch(re,t),add:Zd,sub:Xd,mul:Jd,sqr:Ld,addN:Zd,subN:Xd,mulN:Jd,sqrN:Ld,inv:({c0:t,c1:e,c2:r})=>{let n=b.sub(b.sqr(t),b.mulByNonresidue(b.mul(r,e))),i=b.sub(b.mulByNonresidue(b.sqr(r)),b.mul(t,e)),s=b.sub(b.sqr(e),b.mul(t,r)),o=b.inv(b.add(b.mulByNonresidue(b.add(b.mul(r,i),b.mul(e,s))),b.mul(t,n)));return{c0:b.mul(o,n),c1:b.mul(o,i),c2:b.mul(o,s)}},fromBytes:t=>{if(t.length!==re.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:b.fromBytes(t.subarray(0,b.BYTES)),c1:b.fromBytes(t.subarray(b.BYTES,2*b.BYTES)),c2:b.fromBytes(t.subarray(2*b.BYTES))}},toBytes:({c0:t,c1:e,c2:r})=>(0,_e.concatBytes)(b.toBytes(t),b.toBytes(e),b.toBytes(r)),cmov:({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s},o)=>({c0:b.cmov(t,n,o),c1:b.cmov(e,i,o),c2:b.cmov(r,s,o)}),fromBigSix:t=>{if(!Array.isArray(t)||t.length!==6)throw new Error("Invalid Fp6 usage");return{c0:b.fromBigTuple(t.slice(0,2)),c1:b.fromBigTuple(t.slice(2,4)),c2:b.fromBigTuple(t.slice(4,6))}},frobeniusMap:({c0:t,c1:e,c2:r},n)=>({c0:b.frobeniusMap(t,n),c1:b.mul(b.frobeniusMap(e,n),Om[n%6]),c2:b.mul(b.frobeniusMap(r,n),Nm[n%6])}),mulByNonresidue:({c0:t,c1:e,c2:r})=>({c0:b.mulByNonresidue(r),c1:t,c2:e}),multiplyBy1:({c0:t,c1:e,c2:r},n)=>({c0:b.mulByNonresidue(b.mul(r,n)),c1:b.mul(t,n),c2:b.mul(e,n)}),multiplyBy01({c0:t,c1:e,c2:r},n,i){let s=b.mul(t,n),o=b.mul(e,i);return{c0:b.add(b.mulByNonresidue(b.sub(b.mul(b.add(e,r),i),o)),s),c1:b.sub(b.sub(b.mul(b.add(n,i),b.add(t,e)),s),o),c2:b.add(b.sub(b.mul(b.add(t,r),n),s),o)}},multiplyByFp2:({c0:t,c1:e,c2:r},n)=>({c0:b.mul(t,n),c1:b.mul(e,n),c2:b.mul(r,n)})},Om=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x1")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe")]].map(t=>b.fromBigTuple(t)),Nm=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad"),BigInt("0x0")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa"),BigInt("0x0")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff"),BigInt("0x0")]].map(t=>b.fromBigTuple(t)),Jc=BigInt("0xd201000000010000"),Pm=(0,_e.bitLen)(Jc),Qd=({c0:t,c1:e},{c0:r,c1:n})=>({c0:re.add(t,r),c1:re.add(e,n)}),e0=({c0:t,c1:e},{c0:r,c1:n})=>({c0:re.sub(t,r),c1:re.sub(e,n)}),t0=({c0:t,c1:e},r)=>{if(typeof r=="bigint")return{c0:re.mul(t,r),c1:re.mul(e,r)};let{c0:n,c1:i}=r,s=re.mul(t,n),o=re.mul(e,i);return{c0:re.add(s,re.mulByNonresidue(o)),c1:re.sub(re.mul(re.add(t,e),re.add(n,i)),re.add(s,o))}},r0=({c0:t,c1:e})=>{let r=re.mul(t,e);return{c0:re.sub(re.sub(re.mul(re.add(re.mulByNonresidue(e),t),re.add(t,e)),r),re.mulByNonresidue(r)),c1:re.add(r,r)}};function zc(t,e){let r=b.sqr(t),n=b.sqr(e);return{first:b.add(b.mulByNonresidue(n),r),second:b.sub(b.sub(b.sqr(b.add(t,e)),r),n)}}var ye={ORDER:b.ORDER,BITS:2*b.BITS,BYTES:2*b.BYTES,MASK:(0,_e.bitMask)(2*b.BITS),ZERO:{c0:re.ZERO,c1:re.ZERO},ONE:{c0:re.ONE,c1:re.ZERO},create:t=>t,isValid:({c0:t,c1:e})=>re.isValid(t)&&re.isValid(e),is0:({c0:t,c1:e})=>re.is0(t)&&re.is0(e),neg:({c0:t,c1:e})=>({c0:re.neg(t),c1:re.neg(e)}),eql:({c0:t,c1:e},{c0:r,c1:n})=>re.eql(t,r)&&re.eql(e,n),sqrt:()=>{throw new Error("Not implemented")},inv:({c0:t,c1:e})=>{let r=re.inv(re.sub(re.sqr(t),re.mulByNonresidue(re.sqr(e))));return{c0:re.mul(t,r),c1:re.neg(re.mul(e,r))}},div:(t,e)=>ye.mul(t,typeof e=="bigint"?G.inv(G.create(e)):ye.inv(e)),pow:(t,e)=>Lr.FpPow(ye,t,e),invertBatch:t=>Lr.FpInvertBatch(ye,t),add:Qd,sub:e0,mul:t0,sqr:r0,addN:Qd,subN:e0,mulN:t0,sqrN:r0,fromBytes:t=>{if(t.length!==ye.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:re.fromBytes(t.subarray(0,re.BYTES)),c1:re.fromBytes(t.subarray(re.BYTES))}},toBytes:({c0:t,c1:e})=>(0,_e.concatBytes)(re.toBytes(t),re.toBytes(e)),cmov:({c0:t,c1:e},{c0:r,c1:n},i)=>({c0:re.cmov(t,r,i),c1:re.cmov(e,n,i)}),fromBigTwelve:t=>({c0:re.fromBigSix(t.slice(0,6)),c1:re.fromBigSix(t.slice(6,12))}),frobeniusMap(t,e){let r=re.frobeniusMap(t.c0,e),{c0:n,c1:i,c2:s}=re.frobeniusMap(t.c1,e),o=Rm[e%12];return{c0:r,c1:re.create({c0:b.mul(n,o),c1:b.mul(i,o),c2:b.mul(s,o)})}},multiplyBy014:({c0:t,c1:e},r,n,i)=>{let s=re.multiplyBy01(t,r,n),o=re.multiplyBy1(e,i);return{c0:re.add(re.mulByNonresidue(o),s),c1:re.sub(re.sub(re.multiplyBy01(re.add(e,t),r,b.add(n,i)),s),o)}},multiplyByFp2:({c0:t,c1:e},r)=>({c0:re.multiplyByFp2(t,r),c1:re.multiplyByFp2(e,r)}),conjugate:({c0:t,c1:e})=>({c0:t,c1:re.neg(e)}),_cyclotomicSquare:({c0:t,c1:e})=>{let{c0:r,c1:n,c2:i}=t,{c0:s,c1:o,c2:a}=e,{first:c,second:l}=zc(r,o),{first:f,second:d}=zc(s,i),{first:v,second:m}=zc(n,a),x=b.mulByNonresidue(m);return{c0:re.create({c0:b.add(b.mul(b.sub(c,r),Je),c),c1:b.add(b.mul(b.sub(f,n),Je),f),c2:b.add(b.mul(b.sub(v,i),Je),v)}),c1:re.create({c0:b.add(b.mul(b.add(x,s),Je),x),c1:b.add(b.mul(b.add(l,o),Je),l),c2:b.add(b.mul(b.add(d,a),Je),d)})}},_cyclotomicExp(t,e){let r=ye.ONE;for(let n=Pm-1;n>=0;n--)r=ye._cyclotomicSquare(r),(0,_e.bitGet)(e,n)&&(r=ye.mul(r,t));return r},finalExponentiate:t=>{let e=Jc,r=ye.div(ye.frobeniusMap(t,6),t),n=ye.mul(ye.frobeniusMap(r,2),r),i=ye.conjugate(ye._cyclotomicExp(n,e)),s=ye.mul(ye.conjugate(ye._cyclotomicSquare(n)),i),o=ye.conjugate(ye._cyclotomicExp(s,e)),a=ye.conjugate(ye._cyclotomicExp(o,e)),c=ye.mul(ye.conjugate(ye._cyclotomicExp(a,e)),ye._cyclotomicSquare(i)),l=ye.conjugate(ye._cyclotomicExp(c,e)),f=ye.frobeniusMap(ye.mul(i,a),2),d=ye.frobeniusMap(ye.mul(o,n),3),v=ye.frobeniusMap(ye.mul(c,ye.conjugate(n)),1),m=ye.mul(ye.mul(l,ye.conjugate(s)),n);return ye.mul(ye.mul(ye.mul(f,d),v),m)}},Rm=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8"),BigInt("0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff"),BigInt("0x0")],[BigInt("0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2"),BigInt("0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995"),BigInt("0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116")],[BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa"),BigInt("0x0")],[BigInt("0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3"),BigInt("0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09"),BigInt("0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad"),BigInt("0x0")],[BigInt("0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116"),BigInt("0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995")]].map(t=>b.fromBigTuple(t)),Im=(0,c0.isogenyMap)(b,[[["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=>b.fromBigTuple(e.map(BigInt))))),Um=(0,c0.isogenyMap)(G,[["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)))),Fm=(0,a0.mapToCurveSimpleSWU)(b,{A:b.create({c0:G.create(it),c1:G.create(BigInt(240))}),B:b.create({c0:G.create(BigInt(1012)),c1:G.create(BigInt(1012))}),Z:b.create({c0:G.create(BigInt(-2)),c1:G.create(BigInt(-1))})}),Mm=(0,a0.mapToCurveSimpleSWU)(G,{A:G.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:G.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:G.create(BigInt(11))}),u0=re.create({c0:b.ZERO,c1:b.ONE,c2:b.ZERO}),l0=ye.create({c0:u0,c1:re.ZERO}),f0=ye.create({c0:re.ZERO,c1:u0}),[Cm,qm]=ye.invertBatch([l0,f0]);function jm(t,e){let r=ye.mul(ye.frobeniusMap(ye.multiplyByFp2(Cm,t),1),l0).c0.c0,n=ye.mul(ye.frobeniusMap(ye.multiplyByFp2(qm,e),1),f0).c0.c0;return[r,n]}function n0(t,e){let r=e.toAffine(),n=jm(r.x,r.y);return new t(n[0],n[1],b.ONE)}var km=BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac");function Vm(t,e){return[b.mul(t,km),b.neg(e)]}function Hm(t,e){let r=e.toAffine(),n=Vm(r.x,r.y);return new t(n[0],n[1],b.ONE)}var Zc=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:G.ORDER,m:2,k:128,expand:"xmd",hash:o0.sha256}),ho=Ri(G.toBytes(it),{infinity:!0,compressed:!0});function fo(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 Ri(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 i0(t){t.assertValidity();let e=t.equals(nt.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=t.toAffine();if(e)return ho.slice();let i=G.ORDER,s=!!(n*Je/i);return Ri((0,_e.numberToBytesBE)(r,G.BYTES),{compressed:!0,sort:s})}function s0(t){t.assertValidity();let e=G.BYTES;if(t.equals(nt.bls12_381.G2.ProjectivePoint.ZERO))return(0,_e.concatBytes)(ho,(0,_e.numberToBytesBE)(it,e));let{x:r,y:n}=t.toAffine(),{re:i,im:s}=b.reim(r),{re:o,im:a}=b.reim(n),l=!!((a>it?a*Je:o*Je)/G.ORDER&xn),f=i;return(0,_e.concatBytes)(Ri((0,_e.numberToBytesBE)(s,e),{sort:l,compressed:!0}),(0,_e.numberToBytesBE)(f,e))}nt.bls12_381=(0,vm.bls)({fields:{Fp:G,Fp2:b,Fp6:re,Fp12:ye,Fr:Gd},G1:{Fp:G,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:G.ZERO,b:Pi,htfDefaults:{...Zc,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(G.mul(e.px,r),e.py,e.pz);return e.multiplyUnsafe(nt.bls12_381.params.x).negate().multiplyUnsafe(nt.bls12_381.params.x).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(nt.bls12_381.params.x).add(e),mapToCurve:t=>{let{x:e,y:r}=Mm(G.create(t[0]));return Um(e,r)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=fo(t);if(i.length===48&&e){let s=G.ORDER,o=(0,_e.bytesToNumberBE)(i),a=G.create(o&G.MASK);if(r){if(a!==it)throw new Error("G1: non-empty compressed point at infinity");return{x:it,y:it}}let c=G.add(G.pow(a,uo),G.create(nt.bls12_381.params.G1b)),l=G.sqrt(c);if(!l)throw new Error("Invalid compressed G1 point");return l*Je/s!==BigInt(n)&&(l=G.neg(l)),{x:G.create(a),y:G.create(l)}}else if(i.length===96&&!e){let s=(0,_e.bytesToNumberBE)(i.subarray(0,G.BYTES)),o=(0,_e.bytesToNumberBE)(i.subarray(G.BYTES));if(r){if(s!==it||o!==it)throw new Error("G1: non-empty point at infinity");return nt.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:G.create(s),y:G.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 ho.slice();let o=G.ORDER,a=!!(s*Je/o);return Ri((0,_e.numberToBytesBE)(i,G.BYTES),{compressed:!0,sort:a})}else return n?(0,_e.concatBytes)(new Uint8Array([64]),new Uint8Array(2*G.BYTES-1)):(0,_e.concatBytes)((0,_e.numberToBytesBE)(i,G.BYTES),(0,_e.numberToBytesBE)(s,G.BYTES))},ShortSignature:{fromHex(t){let{infinity:e,sort:r,value:n}=fo((0,_e.ensureBytes)("signatureHex",t,48)),i=G.ORDER,s=(0,_e.bytesToNumberBE)(n);if(e)return nt.bls12_381.G1.ProjectivePoint.ZERO;let o=G.create(s&G.MASK),a=G.add(G.pow(o,uo),G.create(nt.bls12_381.params.G1b)),c=G.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let l=BigInt(r);c*Je/i!==l&&(c=G.neg(c));let f=nt.bls12_381.G1.ProjectivePoint.fromAffine({x:o,y:c});return f.assertValidity(),f},toRawBytes(t){return i0(t)},toHex(t){return(0,_e.bytesToHex)(i0(t))}}},G2:{Fp:b,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:b.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:b.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:b.ZERO,b:b.fromBigTuple([Pi,Pi]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...Zc},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:t=>{let{x:e,y:r}=Fm(b.fromBigTuple(t));return Im(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(nt.bls12_381.params.x).negate().equals(n0(t,e)),clearCofactor:(t,e)=>{let r=nt.bls12_381.params.x,n=e.multiplyUnsafe(r).negate(),i=n0(t,e),s=e.double();return s=Hm(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}=fo(t);if(!e&&!r&&n||!e&&r&&n||n&&r&&e)throw new Error("Invalid encoding flag: "+(t[0]&224));let s=G.BYTES,o=(a,c,l)=>(0,_e.bytesToNumberBE)(a.slice(c,l));if(i.length===96&&e){let a=nt.bls12_381.params.G2b,c=G.ORDER;if(r){if(i.reduce((w,N)=>w!==0?N+1:N,0)>0)throw new Error("Invalid compressed G2 point");return{x:b.ZERO,y:b.ZERO}}let l=o(i,0,s),f=o(i,s,2*s),d=b.create({c0:G.create(f),c1:G.create(l)}),v=b.add(b.pow(d,uo),a),m=b.sqrt(v),x=m.c1===it?m.c0*Je/c:m.c1*Je/c?xn:it;return m=n&&x>0?m:b.neg(m),{x:d,y:m}}else if(i.length===192&&!e){if(r){if(i.reduce((d,v)=>d!==0?v+1:v,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:b.ZERO,y:b.ZERO}}let a=o(i,0,s),c=o(i,s,2*s),l=o(i,2*s,3*s),f=o(i,3*s,4*s);return{x:b.fromBigTuple([c,a]),y:b.fromBigTuple([f,l])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(t,e,r)=>{let{BYTES:n,ORDER:i}=G,s=e.equals(t.ZERO),{x:o,y:a}=e.toAffine();if(r){if(s)return(0,_e.concatBytes)(ho,(0,_e.numberToBytesBE)(it,n));let c=!!(a.c1===it?a.c0*Je/i:a.c1*Je/i);return(0,_e.concatBytes)(Ri((0,_e.numberToBytesBE)(o.c1,n),{compressed:!0,sort:c}),(0,_e.numberToBytesBE)(o.c0,n))}else{if(s)return(0,_e.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:l}=b.reim(o),{re:f,im:d}=b.reim(a);return(0,_e.concatBytes)((0,_e.numberToBytesBE)(l,n),(0,_e.numberToBytesBE)(c,n),(0,_e.numberToBytesBE)(d,n),(0,_e.numberToBytesBE)(f,n))}},Signature:{fromHex(t){let{infinity:e,sort:r,value:n}=fo((0,_e.ensureBytes)("signatureHex",t)),i=G.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,_e.bytesToNumberBE)(n.slice(0,s)),a=(0,_e.bytesToNumberBE)(n.slice(s));if(e)return nt.bls12_381.G2.ProjectivePoint.ZERO;let c=G.create(o&G.MASK),l=G.create(a),f=b.create({c0:l,c1:c}),d=b.add(b.pow(f,uo),nt.bls12_381.params.G2b),v=b.sqrt(d);if(!v)throw new Error("Failed to find a square root");let{re:m,im:x}=b.reim(v),w=BigInt(r),N=x>it&&x*Je/i!==w,A=x===it&&m*Je/i!==w;(N||A)&&(v=b.neg(v));let q=nt.bls12_381.G2.ProjectivePoint.fromAffine({x:f,y:v});return q.assertValidity(),q},toRawBytes(t){return s0(t)},toHex(t){return(0,_e.bytesToHex)(s0(t))}}},params:{x:Jc,r:Gd.ORDER},htfDefaults:Zc,hash:o0.sha256,randomBytes:Em.randomBytes})});var Qc=L(Ii=>{"use strict";Object.defineProperty(Ii,"__esModule",{value:!0});Ii.blsVerify=Ii.verify=void 0;var $m=d0(),Lc=$t();function Km(t,e,r){let n=typeof t=="string"?t:(0,Lc.toHex)(t),i=typeof e=="string"?e:(0,Lc.toHex)(e),s=typeof r=="string"?r:(0,Lc.toHex)(r);return $m.bls12_381.verifyShortSignature(i,s,n)}Ii.blsVerify=Km});var po=L(En=>{"use strict";Object.defineProperty(En,"__esModule",{value:!0});En.decodeTime=En.decodeLeb128=void 0;var h0=Xn(),Gm=t=>(0,h0.lebDecode)(new h0.PipeArrayBuffer(t));En.decodeLeb128=Gm;var Ym=t=>{let e=(0,En.decodeLeb128)(t);return new Date(Number(e)/1e6)};En.decodeTime=Ym});var Ci=L(He=>{"use strict";var Dm=He&&He.__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]}),Wm=He&&He.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),p0=He&&He.__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)&&Dm(e,t,r);return Wm(e,t),e};Object.defineProperty(He,"__esModule",{value:!0});He.check_canister_ranges=He.flatten_forks=He.lookup_path=He.reconstruct=He.lookupResultToBuffer=He.Certificate=He.hashTreeToString=He.NodeId=He.CertificateVerificationError=void 0;var y0=p0(Ai()),zm=Kn(),yo=Bi(),qr=$t(),eu=Mt(),Zm=p0(Qc()),Xm=po(),Cr=class extends zm.AgentError{constructor(e){super(`Invalid certificate: ${e}`)}};He.CertificateVerificationError=Cr;var At={Empty:0,Fork:1,Labeled:2,Leaf:3,Pruned:4};He.NodeId=At;function bo(t){let e=n=>n.split(`
|
|
15
|
+
`)}return c.encodeValue(f)}));return(0,Re.concat)(n,i,s,o,a)}H.encode=ag;function cg(t,e){let r=new Re.PipeArrayBuffer(e);if(e.byteLength<Is.length)throw new Error("Message length smaller than magic number");let n=(0,ne.safeRead)(r,Is.length),i=new TextDecoder().decode(n);if(i!==Is)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(w){let g=[],x=Number((0,ne.lebDecode)(w));for(let q=0;q<x;q++){let O=Number((0,ne.slebDecode)(w));switch(O){case-18:case-19:{let $=Number((0,ne.slebDecode)(w));g.push([O,$]);break}case-20:case-21:{let $=[],P=Number((0,ne.lebDecode)(w)),k;for(;P--;){let Z=Number((0,ne.lebDecode)(w));if(Z>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof k=="number"&&k>=Z)throw new Error("field id collision or not sorted");k=Z;let z=Number((0,ne.slebDecode)(w));$.push([Z,z])}g.push([O,$]);break}case-22:{let $=[],P=Number((0,ne.lebDecode)(w));for(;P--;)$.push(Number((0,ne.slebDecode)(w)));let k=[],Z=Number((0,ne.lebDecode)(w));for(;Z--;)k.push(Number((0,ne.slebDecode)(w)));let z=[],K=Number((0,ne.lebDecode)(w));for(;K--;)switch(Number((0,ne.lebDecode)(w))){case 1:{z.push("query");break}case 2:{z.push("oneway");break}case 3:{z.push("composite_query");break}default:throw new Error("unknown annotation")}g.push([O,[$,k,z]]);break}case-23:{let $=Number((0,ne.lebDecode)(w)),P=[];for(;$--;){let k=Number((0,ne.lebDecode)(w)),Z=new TextDecoder().decode((0,ne.safeRead)(w,k)),z=(0,ne.slebDecode)(w);P.push([Z,z])}g.push([O,P]);break}default:throw new Error("Illegal op_code: "+O)}}let N=[],T=Number((0,ne.lebDecode)(w));for(let q=0;q<T;q++)N.push(Number((0,ne.slebDecode)(w)));return[g,N]}let[o,a]=s(r);if(a.length<t.length)throw new Error("Wrong number of return values");let c=o.map(w=>kl());function f(w){if(w<-24)throw new Error("future value not supported");if(w<0)switch(w){case-1:return H.Null;case-2:return H.Bool;case-3:return H.Nat;case-4:return H.Int;case-5:return H.Nat8;case-6:return H.Nat16;case-7:return H.Nat32;case-8:return H.Nat64;case-9:return H.Int8;case-10:return H.Int16;case-11:return H.Int32;case-12:return H.Int64;case-13:return H.Float32;case-14:return H.Float64;case-15:return H.Text;case-16:return H.Reserved;case-17:return H.Empty;case-24:return H.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 l(w){switch(w[0]){case-19:{let g=f(w[1]);return Ml(g)}case-18:{let g=f(w[1]);return Cl(g)}case-20:{let g={};for(let[T,q]of w[1]){let O=`_${T}_`;g[O]=f(q)}let x=ql(g),N=x.tryAsTuple();return Array.isArray(N)?Fl(...N):x}case-21:{let g={};for(let[x,N]of w[1]){let T=`_${x}_`;g[T]=f(N)}return jl(g)}case-22:{let[g,x,N]=w[1];return Vl(g.map(T=>f(T)),x.map(T=>f(T)),N)}case-23:{let g={},x=w[1];for(let[N,T]of x){let q=f(T);if(q instanceof Xr&&(q=q.getType()),!(q instanceof Ai))throw new Error("Illegal service definition: services can only contain functions");g[N]=q}return Hl(g)}default:throw new Error("Illegal op_code: "+w[0])}}o.forEach((w,g)=>{if(w[0]===-22){let x=l(w);c[g].fill(x)}}),o.forEach((w,g)=>{if(w[0]!==-22){let x=l(w);c[g].fill(x)}});let d=a.map(w=>f(w)),v=t.map((w,g)=>w.decodeValue(r,d[g]));for(let w=t.length;w<d.length;w++)d[w].decodeValue(r,d[w]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return v}H.decode=cg;H.Empty=new Us;H.Reserved=new Qn;H.Unknown=new Fs;H.Bool=new Ms;H.Null=new Cs;H.Text=new qs;H.Int=new js;H.Nat=new ks;H.Float32=new Ti(32);H.Float64=new Ti(64);H.Int8=new jr(8);H.Int16=new jr(16);H.Int32=new jr(32);H.Int64=new jr(64);H.Nat8=new mr(8);H.Nat16=new mr(16);H.Nat32=new mr(32);H.Nat64=new mr(64);H.Principal=new Ks;function Fl(...t){return new Hs(t)}H.Tuple=Fl;function Ml(t){return new Vs(t)}H.Vec=Ml;function Cl(t){return new ei(t)}H.Opt=Cl;function ql(t){return new Si(t)}H.Record=ql;function jl(t){return new $s(t)}H.Variant=jl;function kl(){return new Xr}H.Rec=kl;function Vl(t,e,r=[]){return new Ai(t,e,r)}H.Func=Vl;function Hl(t){return new Gs(t)}H.Service=Hl});var yc=J(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 uc=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=uc;var Jr=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=Jr;var fc=class extends Jr{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=fc;var lc=class extends Jr{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=lc;var dc=class extends Jr{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=dc;var hc=class extends Jr{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=hc;var pc=class extends Jr{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=pc});var Kl=J(Se=>{"use strict";var ug=Se&&Se.__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=Se&&Se.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),$l=Se&&Se.__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)&&ug(e,t,r);return fg(e,t),e};Object.defineProperty(Se,"__esModule",{value:!0});Se.renderValue=Se.renderInput=Se.Render=Se.vecForm=Se.optForm=Se.variantForm=Se.tupleForm=Se.recordForm=Se.inputBox=void 0;var Ws=$l(cc()),bc=Ct(),ti=$l(yc()),lg={parse:mg},Oi={render:wc},dg=(t,e)=>new ti.InputBox(t,Object.assign(Object.assign({},lg),e));Se.inputBox=dg;var hg=(t,e)=>new ti.RecordForm(t,Object.assign(Object.assign({},Oi),e));Se.recordForm=hg;var pg=(t,e)=>new ti.TupleForm(t,Object.assign(Object.assign({},Oi),e));Se.tupleForm=pg;var yg=(t,e)=>new ti.VariantForm(t,Object.assign(Object.assign({},Oi),e));Se.variantForm=yg;var bg=(t,e)=>new ti.OptionForm(t,Object.assign(Object.assign({},Oi),e));Se.optForm=bg;var gg=(t,e)=>new ti.VecForm(t,Object.assign(Object.assign({},Oi),e));Se.vecForm=gg;var Ys=class extends Ws.Visitor{visitType(e,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=e.display(),(0,Se.inputBox)(e,{input:n})}visitNull(e,r){return(0,Se.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,Se.recordForm)(r,i);return(0,Se.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,Se.tupleForm)(r,i);return(0,Se.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,Se.variantForm)(r,s);return(0,Se.inputBox)(e,{form:o})}visitOpt(e,r,n){let i=document.createElement("input");i.type="checkbox",i.classList.add("open");let s=(0,Se.optForm)(r,{open:i,event:"change"});return(0,Se.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,Se.vecForm)(r,{open:i,event:"change",container:s});return(0,Se.inputBox)(e,{form:o})}visitRec(e,r,n){return wc(r)}};Se.Render=Ys;var gc=class extends Ws.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]]}},mc=class extends Ws.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 mg(t,e,r){return e.random&&r===""?t.accept(new mc,r):t.accept(new gc,r)}function wc(t){return t.accept(new Ys,null)}Se.renderInput=wc;function Bn(t,e,r){return t.accept(new _c,{input:e,value:r})}Se.renderValue=Bn;var _c=class extends Ws.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){Bn(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)),Bn(r,i.form[0],n.value[0])}}visitRecord(e,r,n){let i=n.input.ui.form;r.forEach(([s,o],a)=>{Bn(o,i.form[a],n.value[s])})}visitTuple(e,r,n){let i=n.input.ui.form;r.forEach((s,o)=>{Bn(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)),Bn(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)=>{Bn(r,i.form[c],a)})}}});var Yl=J(Gl=>{"use strict";Object.defineProperty(Gl,"__esModule",{value:!0})});var ni=J(bt=>{"use strict";var Wl=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}),ri=bt&&bt.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Wl(e,t,r)},wg=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)&&Wl(e,t,r);return _g(e,t),e};Object.defineProperty(bt,"__esModule",{value:!0});bt.IDL=void 0;ri(Kl(),bt);ri(yc(),bt);bt.IDL=wg(cc());ri(tc(),bt);ri(nc(),bt);ri(Ns(),bt);ri(Yl(),bt)});var Ni=J((zl,zs)=>{(function(t){"use strict";var e,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",a=1e14,c=14,f=9007199254740991,l=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],d=1e7,v=1e9;function w(P){var k,Z,z,K=U.prototype={constructor:U,toString:null,valueOf:null},se=new U(1),te=20,de=4,ue=-7,Te=21,D=-1e7,C=1e7,X=!1,j=1,I=0,W={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},L="0123456789abcdefghijklmnopqrstuvwxyz",ie=!0;function U(u,h){var p,B,E,S,F,m,A,M,R=this;if(!(R instanceof U))return new U(u,h);if(h==null){if(u&&u._isBigNumber===!0){R.s=u.s,!u.c||u.e>C?R.c=R.e=null:u.e<D?R.c=[R.e=0]:(R.e=u.e,R.c=u.c.slice());return}if((m=typeof u=="number")&&u*0==0){if(R.s=1/u<0?(u=-u,-1):1,u===~~u){for(S=0,F=u;F>=10;F/=10,S++);S>C?R.c=R.e=null:(R.e=S,R.c=[u]);return}M=String(u)}else{if(!r.test(M=String(u)))return z(R,M,m);R.s=M.charCodeAt(0)==45?(M=M.slice(1),-1):1}(S=M.indexOf("."))>-1&&(M=M.replace(".","")),(F=M.search(/e/i))>0?(S<0&&(S=F),S+=+M.slice(F+1),M=M.substring(0,F)):S<0&&(S=M.length)}else{if(T(h,2,L.length,"Base"),h==10&&ie)return R=new U(u),ce(R,te+R.e+1,de);if(M=String(u),m=typeof u=="number"){if(u*0!=0)return z(R,M,m,h);if(R.s=1/u<0?(M=M.slice(1),-1):1,U.DEBUG&&M.replace(/^0\.0*|\./,"").length>15)throw Error(o+u)}else R.s=M.charCodeAt(0)===45?(M=M.slice(1),-1):1;for(p=L.slice(0,h),S=F=0,A=M.length;F<A;F++)if(p.indexOf(B=M.charAt(F))<0){if(B=="."){if(F>S){S=A;continue}}else if(!E&&(M==M.toUpperCase()&&(M=M.toLowerCase())||M==M.toLowerCase()&&(M=M.toUpperCase()))){E=!0,F=-1,S=0;continue}return z(R,String(u),m,h)}m=!1,M=Z(M,h,10,R.s),(S=M.indexOf("."))>-1?M=M.replace(".",""):S=M.length}for(F=0;M.charCodeAt(F)===48;F++);for(A=M.length;M.charCodeAt(--A)===48;);if(M=M.slice(F,++A)){if(A-=F,m&&U.DEBUG&&A>15&&(u>f||u!==i(u)))throw Error(o+R.s*u);if((S=S-F-1)>C)R.c=R.e=null;else if(S<D)R.c=[R.e=0];else{if(R.e=S,R.c=[],F=(S+1)%c,S<0&&(F+=c),F<A){for(F&&R.c.push(+M.slice(0,F)),A-=c;F<A;)R.c.push(+M.slice(F,F+=c));F=c-(M=M.slice(F)).length}else F-=A;for(;F--;M+="0");R.c.push(+M)}}else R.c=[R.e=0]}U.clone=w,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(u){var h,p;if(u!=null)if(typeof u=="object"){if(u.hasOwnProperty(h="DECIMAL_PLACES")&&(p=u[h],T(p,0,v,h),te=p),u.hasOwnProperty(h="ROUNDING_MODE")&&(p=u[h],T(p,0,8,h),de=p),u.hasOwnProperty(h="EXPONENTIAL_AT")&&(p=u[h],p&&p.pop?(T(p[0],-v,0,h),T(p[1],0,v,h),ue=p[0],Te=p[1]):(T(p,-v,v,h),ue=-(Te=p<0?-p:p))),u.hasOwnProperty(h="RANGE"))if(p=u[h],p&&p.pop)T(p[0],-v,-1,h),T(p[1],1,v,h),D=p[0],C=p[1];else if(T(p,-v,v,h),p)D=-(C=p<0?-p:p);else throw Error(s+h+" cannot be zero: "+p);if(u.hasOwnProperty(h="CRYPTO"))if(p=u[h],p===!!p)if(p)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))X=p;else throw X=!p,Error(s+"crypto unavailable");else X=p;else throw Error(s+h+" not true or false: "+p);if(u.hasOwnProperty(h="MODULO_MODE")&&(p=u[h],T(p,0,9,h),j=p),u.hasOwnProperty(h="POW_PRECISION")&&(p=u[h],T(p,0,v,h),I=p),u.hasOwnProperty(h="FORMAT"))if(p=u[h],typeof p=="object")W=p;else throw Error(s+h+" not an object: "+p);if(u.hasOwnProperty(h="ALPHABET"))if(p=u[h],typeof p=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(p))ie=p.slice(0,10)=="0123456789",L=p;else throw Error(s+h+" invalid: "+p)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:te,ROUNDING_MODE:de,EXPONENTIAL_AT:[ue,Te],RANGE:[D,C],CRYPTO:X,MODULO_MODE:j,POW_PRECISION:I,FORMAT:W,ALPHABET:L}},U.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!U.DEBUG)return!0;var h,p,B=u.c,E=u.e,S=u.s;e:if({}.toString.call(B)=="[object Array]"){if((S===1||S===-1)&&E>=-v&&E<=v&&E===i(E)){if(B[0]===0){if(E===0&&B.length===1)return!0;break e}if(h=(E+1)%c,h<1&&(h+=c),String(B[0]).length==h){for(h=0;h<B.length;h++)if(p=B[h],p<0||p>=a||p!==i(p))break e;if(p!==0)return!0}}}else if(B===null&&E===null&&(S===null||S===1||S===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},U.maximum=U.max=function(){return fe(arguments,-1)},U.minimum=U.min=function(){return fe(arguments,1)},U.random=function(){var u=9007199254740992,h=Math.random()*u&2097151?function(){return i(Math.random()*u)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(p){var B,E,S,F,m,A=0,M=[],R=new U(se);if(p==null?p=te:T(p,0,v),F=n(p/c),X)if(crypto.getRandomValues){for(B=crypto.getRandomValues(new Uint32Array(F*=2));A<F;)m=B[A]*131072+(B[A+1]>>>11),m>=9e15?(E=crypto.getRandomValues(new Uint32Array(2)),B[A]=E[0],B[A+1]=E[1]):(M.push(m%1e14),A+=2);A=F/2}else if(crypto.randomBytes){for(B=crypto.randomBytes(F*=7);A<F;)m=(B[A]&31)*281474976710656+B[A+1]*1099511627776+B[A+2]*4294967296+B[A+3]*16777216+(B[A+4]<<16)+(B[A+5]<<8)+B[A+6],m>=9e15?crypto.randomBytes(7).copy(B,A):(M.push(m%1e14),A+=7);A=F/7}else throw X=!1,Error(s+"crypto unavailable");if(!X)for(;A<F;)m=h(),m<9e15&&(M[A++]=m%1e14);for(F=M[--A],p%=c,F&&p&&(m=l[c-p],M[A]=i(F/m)*m);M[A]===0;M.pop(),A--);if(A<0)M=[S=0];else{for(S=-1;M[0]===0;M.splice(0,1),S-=c);for(A=1,m=M[0];m>=10;m/=10,A++);A<c&&(S-=c-A)}return R.e=S,R.c=M,R}}(),U.sum=function(){for(var u=1,h=arguments,p=new U(h[0]);u<h.length;)p=p.plus(h[u++]);return p},Z=function(){var u="0123456789";function h(p,B,E,S){for(var F,m=[0],A,M=0,R=p.length;M<R;){for(A=m.length;A--;m[A]*=B);for(m[0]+=S.indexOf(p.charAt(M++)),F=0;F<m.length;F++)m[F]>E-1&&(m[F+1]==null&&(m[F+1]=0),m[F+1]+=m[F]/E|0,m[F]%=E)}return m.reverse()}return function(p,B,E,S,F){var m,A,M,R,Y,Q,le,Be,Ie=p.indexOf("."),Ve=te,xe=de;for(Ie>=0&&(R=I,I=0,p=p.replace(".",""),Be=new U(B),Q=Be.pow(p.length-Ie),I=R,Be.c=h($(x(Q.c),Q.e,"0"),10,E,u),Be.e=Be.c.length),le=h(p,B,E,F?(m=L,u):(m=u,L)),M=R=le.length;le[--R]==0;le.pop());if(!le[0])return m.charAt(0);if(Ie<0?--M:(Q.c=le,Q.e=M,Q.s=S,Q=k(Q,Be,Ve,xe,E),le=Q.c,Y=Q.r,M=Q.e),A=M+Ve+1,Ie=le[A],R=E/2,Y=Y||A<0||le[A+1]!=null,Y=xe<4?(Ie!=null||Y)&&(xe==0||xe==(Q.s<0?3:2)):Ie>R||Ie==R&&(xe==4||Y||xe==6&&le[A-1]&1||xe==(Q.s<0?8:7)),A<1||!le[0])p=Y?$(m.charAt(1),-Ve,m.charAt(0)):m.charAt(0);else{if(le.length=A,Y)for(--E;++le[--A]>E;)le[A]=0,A||(++M,le=[1].concat(le));for(R=le.length;!le[--R];);for(Ie=0,p="";Ie<=R;p+=m.charAt(le[Ie++]));p=$(p,M,m.charAt(0))}return p}}(),k=function(){function u(B,E,S){var F,m,A,M,R=0,Y=B.length,Q=E%d,le=E/d|0;for(B=B.slice();Y--;)A=B[Y]%d,M=B[Y]/d|0,F=le*A+M*Q,m=Q*A+F%d*d+R,R=(m/S|0)+(F/d|0)+le*M,B[Y]=m%S;return R&&(B=[R].concat(B)),B}function h(B,E,S,F){var m,A;if(S!=F)A=S>F?1:-1;else for(m=A=0;m<S;m++)if(B[m]!=E[m]){A=B[m]>E[m]?1:-1;break}return A}function p(B,E,S,F){for(var m=0;S--;)B[S]-=m,m=B[S]<E[S]?1:0,B[S]=m*F+B[S]-E[S];for(;!B[0]&&B.length>1;B.splice(0,1));}return function(B,E,S,F,m){var A,M,R,Y,Q,le,Be,Ie,Ve,xe,he,ze,Fr,_n,wn,Ft,Pe,Mt=B.s==E.s?1:-1,mt=B.c,Ge=E.c;if(!mt||!mt[0]||!Ge||!Ge[0])return new U(!B.s||!E.s||(mt?Ge&&mt[0]==Ge[0]:!Ge)?NaN:mt&&mt[0]==0||!Ge?Mt*0:Mt/0);for(Ie=new U(Mt),Ve=Ie.c=[],M=B.e-E.e,Mt=S+M+1,m||(m=a,M=g(B.e/c)-g(E.e/c),Mt=Mt/c|0),R=0;Ge[R]==(mt[R]||0);R++);if(Ge[R]>(mt[R]||0)&&M--,Mt<0)Ve.push(1),Y=!0;else{for(_n=mt.length,Ft=Ge.length,R=0,Mt+=2,Q=i(m/(Ge[0]+1)),Q>1&&(Ge=u(Ge,Q,m),mt=u(mt,Q,m),Ft=Ge.length,_n=mt.length),Fr=Ft,xe=mt.slice(0,Ft),he=xe.length;he<Ft;xe[he++]=0);Pe=Ge.slice(),Pe=[0].concat(Pe),wn=Ge[0],Ge[1]>=m/2&&wn++;do{if(Q=0,A=h(Ge,xe,Ft,he),A<0){if(ze=xe[0],Ft!=he&&(ze=ze*m+(xe[1]||0)),Q=i(ze/wn),Q>1)for(Q>=m&&(Q=m-1),le=u(Ge,Q,m),Be=le.length,he=xe.length;h(le,xe,Be,he)==1;)Q--,p(le,Ft<Be?Pe:Ge,Be,m),Be=le.length,A=1;else Q==0&&(A=Q=1),le=Ge.slice(),Be=le.length;if(Be<he&&(le=[0].concat(le)),p(xe,le,he,m),he=xe.length,A==-1)for(;h(Ge,xe,Ft,he)<1;)Q++,p(xe,Ft<he?Pe:Ge,he,m),he=xe.length}else A===0&&(Q++,xe=[0]);Ve[R++]=Q,xe[0]?xe[he++]=mt[Fr]||0:(xe=[mt[Fr]],he=1)}while((Fr++<_n||xe[0]!=null)&&Mt--);Y=xe[0]!=null,Ve[0]||Ve.splice(0,1)}if(m==a){for(R=1,Mt=Ve[0];Mt>=10;Mt/=10,R++);ce(Ie,S+(Ie.e=R+M*c-1)+1,F,Y)}else Ie.e=M,Ie.r=+Y;return Ie}}();function y(u,h,p,B){var E,S,F,m,A;if(p==null?p=de:T(p,0,8),!u.c)return u.toString();if(E=u.c[0],F=u.e,h==null)A=x(u.c),A=B==1||B==2&&(F<=ue||F>=Te)?O(A,F):$(A,F,"0");else if(u=ce(new U(u),h,p),S=u.e,A=x(u.c),m=A.length,B==1||B==2&&(h<=S||S<=ue)){for(;m<h;A+="0",m++);A=O(A,S)}else if(h-=F,A=$(A,S,"0"),S+1>m){if(--h>0)for(A+=".";h--;A+="0");}else if(h+=S-m,h>0)for(S+1==m&&(A+=".");h--;A+="0");return u.s<0&&E?"-"+A:A}function fe(u,h){for(var p,B,E=1,S=new U(u[0]);E<u.length;E++)B=new U(u[E]),(!B.s||(p=N(S,B))===h||p===0&&S.s===h)&&(S=B);return S}function ae(u,h,p){for(var B=1,E=h.length;!h[--E];h.pop());for(E=h[0];E>=10;E/=10,B++);return(p=B+p*c-1)>C?u.c=u.e=null:p<D?u.c=[u.e=0]:(u.e=p,u.c=h),u}z=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,h=/^([^.]+)\.$/,p=/^\.([^.]+)$/,B=/^-?(Infinity|NaN)$/,E=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(S,F,m,A){var M,R=m?F:F.replace(E,"");if(B.test(R))S.s=isNaN(R)?null:R<0?-1:1;else{if(!m&&(R=R.replace(u,function(Y,Q,le){return M=(le=le.toLowerCase())=="x"?16:le=="b"?2:8,!A||A==M?Q:Y}),A&&(M=A,R=R.replace(h,"$1").replace(p,"0.$1")),F!=R))return new U(R,M);if(U.DEBUG)throw Error(s+"Not a"+(A?" base "+A:"")+" number: "+F);S.s=null}S.c=S.e=null}}();function ce(u,h,p,B){var E,S,F,m,A,M,R,Y=u.c,Q=l;if(Y){e:{for(E=1,m=Y[0];m>=10;m/=10,E++);if(S=h-E,S<0)S+=c,F=h,A=Y[M=0],R=i(A/Q[E-F-1]%10);else if(M=n((S+1)/c),M>=Y.length)if(B){for(;Y.length<=M;Y.push(0));A=R=0,E=1,S%=c,F=S-c+1}else break e;else{for(A=m=Y[M],E=1;m>=10;m/=10,E++);S%=c,F=S-c+E,R=F<0?0:i(A/Q[E-F-1]%10)}if(B=B||h<0||Y[M+1]!=null||(F<0?A:A%Q[E-F-1]),B=p<4?(R||B)&&(p==0||p==(u.s<0?3:2)):R>5||R==5&&(p==4||B||p==6&&(S>0?F>0?A/Q[E-F]:0:Y[M-1])%10&1||p==(u.s<0?8:7)),h<1||!Y[0])return Y.length=0,B?(h-=u.e+1,Y[0]=Q[(c-h%c)%c],u.e=-h||0):Y[0]=u.e=0,u;if(S==0?(Y.length=M,m=1,M--):(Y.length=M+1,m=Q[c-S],Y[M]=F>0?i(A/Q[E-F]%Q[F])*m:0),B)for(;;)if(M==0){for(S=1,F=Y[0];F>=10;F/=10,S++);for(F=Y[0]+=m,m=1;F>=10;F/=10,m++);S!=m&&(u.e++,Y[0]==a&&(Y[0]=1));break}else{if(Y[M]+=m,Y[M]!=a)break;Y[M--]=0,m=1}for(S=Y.length;Y[--S]===0;Y.pop());}u.e>C?u.c=u.e=null:u.e<D&&(u.c=[u.e=0])}return u}function ee(u){var h,p=u.e;return p===null?u.toString():(h=x(u.c),h=p<=ue||p>=Te?O(h,p):$(h,p,"0"),u.s<0?"-"+h:h)}return K.absoluteValue=K.abs=function(){var u=new U(this);return u.s<0&&(u.s=1),u},K.comparedTo=function(u,h){return N(this,new U(u,h))},K.decimalPlaces=K.dp=function(u,h){var p,B,E,S=this;if(u!=null)return T(u,0,v),h==null?h=de:T(h,0,8),ce(new U(S),u+S.e+1,h);if(!(p=S.c))return null;if(B=((E=p.length-1)-g(this.e/c))*c,E=p[E])for(;E%10==0;E/=10,B--);return B<0&&(B=0),B},K.dividedBy=K.div=function(u,h){return k(this,new U(u,h),te,de)},K.dividedToIntegerBy=K.idiv=function(u,h){return k(this,new U(u,h),0,1)},K.exponentiatedBy=K.pow=function(u,h){var p,B,E,S,F,m,A,M,R,Y=this;if(u=new U(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+ee(u));if(h!=null&&(h=new U(h)),m=u.e>14,!Y.c||!Y.c[0]||Y.c[0]==1&&!Y.e&&Y.c.length==1||!u.c||!u.c[0])return R=new U(Math.pow(+ee(Y),m?u.s*(2-q(u)):+ee(u))),h?R.mod(h):R;if(A=u.s<0,h){if(h.c?!h.c[0]:!h.s)return new U(NaN);B=!A&&Y.isInteger()&&h.isInteger(),B&&(Y=Y.mod(h))}else{if(u.e>9&&(Y.e>0||Y.e<-1||(Y.e==0?Y.c[0]>1||m&&Y.c[1]>=24e7:Y.c[0]<8e13||m&&Y.c[0]<=9999975e7)))return S=Y.s<0&&q(u)?-0:0,Y.e>-1&&(S=1/S),new U(A?1/S:S);I&&(S=n(I/c+2))}for(m?(p=new U(.5),A&&(u.s=1),M=q(u)):(E=Math.abs(+ee(u)),M=E%2),R=new U(se);;){if(M){if(R=R.times(Y),!R.c)break;S?R.c.length>S&&(R.c.length=S):B&&(R=R.mod(h))}if(E){if(E=i(E/2),E===0)break;M=E%2}else if(u=u.times(p),ce(u,u.e+1,1),u.e>14)M=q(u);else{if(E=+ee(u),E===0)break;M=E%2}Y=Y.times(Y),S?Y.c&&Y.c.length>S&&(Y.c.length=S):B&&(Y=Y.mod(h))}return B?R:(A&&(R=se.div(R)),h?R.mod(h):S?ce(R,I,de,F):R)},K.integerValue=function(u){var h=new U(this);return u==null?u=de:T(u,0,8),ce(h,h.e+1,u)},K.isEqualTo=K.eq=function(u,h){return N(this,new U(u,h))===0},K.isFinite=function(){return!!this.c},K.isGreaterThan=K.gt=function(u,h){return N(this,new U(u,h))>0},K.isGreaterThanOrEqualTo=K.gte=function(u,h){return(h=N(this,new U(u,h)))===1||h===0},K.isInteger=function(){return!!this.c&&g(this.e/c)>this.c.length-2},K.isLessThan=K.lt=function(u,h){return N(this,new U(u,h))<0},K.isLessThanOrEqualTo=K.lte=function(u,h){return(h=N(this,new U(u,h)))===-1||h===0},K.isNaN=function(){return!this.s},K.isNegative=function(){return this.s<0},K.isPositive=function(){return this.s>0},K.isZero=function(){return!!this.c&&this.c[0]==0},K.minus=function(u,h){var p,B,E,S,F=this,m=F.s;if(u=new U(u,h),h=u.s,!m||!h)return new U(NaN);if(m!=h)return u.s=-h,F.plus(u);var A=F.e/c,M=u.e/c,R=F.c,Y=u.c;if(!A||!M){if(!R||!Y)return R?(u.s=-h,u):new U(Y?F:NaN);if(!R[0]||!Y[0])return Y[0]?(u.s=-h,u):new U(R[0]?F:de==3?-0:0)}if(A=g(A),M=g(M),R=R.slice(),m=A-M){for((S=m<0)?(m=-m,E=R):(M=A,E=Y),E.reverse(),h=m;h--;E.push(0));E.reverse()}else for(B=(S=(m=R.length)<(h=Y.length))?m:h,m=h=0;h<B;h++)if(R[h]!=Y[h]){S=R[h]<Y[h];break}if(S&&(E=R,R=Y,Y=E,u.s=-u.s),h=(B=Y.length)-(p=R.length),h>0)for(;h--;R[p++]=0);for(h=a-1;B>m;){if(R[--B]<Y[B]){for(p=B;p&&!R[--p];R[p]=h);--R[p],R[B]+=a}R[B]-=Y[B]}for(;R[0]==0;R.splice(0,1),--M);return R[0]?ae(u,R,M):(u.s=de==3?-1:1,u.c=[u.e=0],u)},K.modulo=K.mod=function(u,h){var p,B,E=this;return u=new U(u,h),!E.c||!u.s||u.c&&!u.c[0]?new U(NaN):!u.c||E.c&&!E.c[0]?new U(E):(j==9?(B=u.s,u.s=1,p=k(E,u,0,3),u.s=B,p.s*=B):p=k(E,u,0,j),u=E.minus(p.times(u)),!u.c[0]&&j==1&&(u.s=E.s),u)},K.multipliedBy=K.times=function(u,h){var p,B,E,S,F,m,A,M,R,Y,Q,le,Be,Ie,Ve,xe=this,he=xe.c,ze=(u=new U(u,h)).c;if(!he||!ze||!he[0]||!ze[0])return!xe.s||!u.s||he&&!he[0]&&!ze||ze&&!ze[0]&&!he?u.c=u.e=u.s=null:(u.s*=xe.s,!he||!ze?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(B=g(xe.e/c)+g(u.e/c),u.s*=xe.s,A=he.length,Y=ze.length,A<Y&&(Be=he,he=ze,ze=Be,E=A,A=Y,Y=E),E=A+Y,Be=[];E--;Be.push(0));for(Ie=a,Ve=d,E=Y;--E>=0;){for(p=0,Q=ze[E]%Ve,le=ze[E]/Ve|0,F=A,S=E+F;S>E;)M=he[--F]%Ve,R=he[F]/Ve|0,m=le*M+R*Q,M=Q*M+m%Ve*Ve+Be[S]+p,p=(M/Ie|0)+(m/Ve|0)+le*R,Be[S--]=M%Ie;Be[S]=p}return p?++B:Be.splice(0,1),ae(u,Be,B)},K.negated=function(){var u=new U(this);return u.s=-u.s||null,u},K.plus=function(u,h){var p,B=this,E=B.s;if(u=new U(u,h),h=u.s,!E||!h)return new U(NaN);if(E!=h)return u.s=-h,B.minus(u);var S=B.e/c,F=u.e/c,m=B.c,A=u.c;if(!S||!F){if(!m||!A)return new U(E/0);if(!m[0]||!A[0])return A[0]?u:new U(m[0]?B:E*0)}if(S=g(S),F=g(F),m=m.slice(),E=S-F){for(E>0?(F=S,p=A):(E=-E,p=m),p.reverse();E--;p.push(0));p.reverse()}for(E=m.length,h=A.length,E-h<0&&(p=A,A=m,m=p,h=E),E=0;h;)E=(m[--h]=m[h]+A[h]+E)/a|0,m[h]=a===m[h]?0:m[h]%a;return E&&(m=[E].concat(m),++F),ae(u,m,F)},K.precision=K.sd=function(u,h){var p,B,E,S=this;if(u!=null&&u!==!!u)return T(u,1,v),h==null?h=de:T(h,0,8),ce(new U(S),u,h);if(!(p=S.c))return null;if(E=p.length-1,B=E*c+1,E=p[E]){for(;E%10==0;E/=10,B--);for(E=p[0];E>=10;E/=10,B++);}return u&&S.e+1>B&&(B=S.e+1),B},K.shiftedBy=function(u){return T(u,-f,f),this.times("1e"+u)},K.squareRoot=K.sqrt=function(){var u,h,p,B,E,S=this,F=S.c,m=S.s,A=S.e,M=te+4,R=new U("0.5");if(m!==1||!F||!F[0])return new U(!m||m<0&&(!F||F[0])?NaN:F?S:1/0);if(m=Math.sqrt(+ee(S)),m==0||m==1/0?(h=x(F),(h.length+A)%2==0&&(h+="0"),m=Math.sqrt(+h),A=g((A+1)/2)-(A<0||A%2),m==1/0?h="5e"+A:(h=m.toExponential(),h=h.slice(0,h.indexOf("e")+1)+A),p=new U(h)):p=new U(m+""),p.c[0]){for(A=p.e,m=A+M,m<3&&(m=0);;)if(E=p,p=R.times(E.plus(k(S,E,M,1))),x(E.c).slice(0,m)===(h=x(p.c)).slice(0,m))if(p.e<A&&--m,h=h.slice(m-3,m+1),h=="9999"||!B&&h=="4999"){if(!B&&(ce(E,E.e+te+2,0),E.times(E).eq(S))){p=E;break}M+=4,m+=4,B=1}else{(!+h||!+h.slice(1)&&h.charAt(0)=="5")&&(ce(p,p.e+te+2,1),u=!p.times(p).eq(S));break}}return ce(p,p.e+te+1,de,u)},K.toExponential=function(u,h){return u!=null&&(T(u,0,v),u++),y(this,u,h,1)},K.toFixed=function(u,h){return u!=null&&(T(u,0,v),u=u+this.e+1),y(this,u,h)},K.toFormat=function(u,h,p){var B,E=this;if(p==null)u!=null&&h&&typeof h=="object"?(p=h,h=null):u&&typeof u=="object"?(p=u,u=h=null):p=W;else if(typeof p!="object")throw Error(s+"Argument not an object: "+p);if(B=E.toFixed(u,h),E.c){var S,F=B.split("."),m=+p.groupSize,A=+p.secondaryGroupSize,M=p.groupSeparator||"",R=F[0],Y=F[1],Q=E.s<0,le=Q?R.slice(1):R,Be=le.length;if(A&&(S=m,m=A,A=S,Be-=S),m>0&&Be>0){for(S=Be%m||m,R=le.substr(0,S);S<Be;S+=m)R+=M+le.substr(S,m);A>0&&(R+=M+le.slice(S)),Q&&(R="-"+R)}B=Y?R+(p.decimalSeparator||"")+((A=+p.fractionGroupSize)?Y.replace(new RegExp("\\d{"+A+"}\\B","g"),"$&"+(p.fractionGroupSeparator||"")):Y):R}return(p.prefix||"")+B+(p.suffix||"")},K.toFraction=function(u){var h,p,B,E,S,F,m,A,M,R,Y,Q,le=this,Be=le.c;if(u!=null&&(m=new U(u),!m.isInteger()&&(m.c||m.s!==1)||m.lt(se)))throw Error(s+"Argument "+(m.isInteger()?"out of range: ":"not an integer: ")+ee(m));if(!Be)return new U(le);for(h=new U(se),M=p=new U(se),B=A=new U(se),Q=x(Be),S=h.e=Q.length-le.e-1,h.c[0]=l[(F=S%c)<0?c+F:F],u=!u||m.comparedTo(h)>0?S>0?h:M:m,F=C,C=1/0,m=new U(Q),A.c[0]=0;R=k(m,h,0,1),E=p.plus(R.times(B)),E.comparedTo(u)!=1;)p=B,B=E,M=A.plus(R.times(E=M)),A=E,h=m.minus(R.times(E=h)),m=E;return E=k(u.minus(p),B,0,1),A=A.plus(E.times(M)),p=p.plus(E.times(B)),A.s=M.s=le.s,S=S*2,Y=k(M,B,S,de).minus(le).abs().comparedTo(k(A,p,S,de).minus(le).abs())<1?[M,B]:[A,p],C=F,Y},K.toNumber=function(){return+ee(this)},K.toPrecision=function(u,h){return u!=null&&T(u,1,v),y(this,u,h,2)},K.toString=function(u){var h,p=this,B=p.s,E=p.e;return E===null?B?(h="Infinity",B<0&&(h="-"+h)):h="NaN":(u==null?h=E<=ue||E>=Te?O(x(p.c),E):$(x(p.c),E,"0"):u===10&&ie?(p=ce(new U(p),te+E+1,de),h=$(x(p.c),p.e,"0")):(T(u,2,L.length,"Base"),h=Z($(x(p.c),E,"0"),10,u,B,!0)),B<0&&p.c[0]&&(h="-"+h)),h},K.valueOf=K.toJSON=function(){return ee(this)},K._isBigNumber=!0,P!=null&&U.set(P),U}function g(P){var k=P|0;return P>0||P===k?k:k-1}function x(P){for(var k,Z,z=1,K=P.length,se=P[0]+"";z<K;){for(k=P[z++]+"",Z=c-k.length;Z--;k="0"+k);se+=k}for(K=se.length;se.charCodeAt(--K)===48;);return se.slice(0,K+1||1)}function N(P,k){var Z,z,K=P.c,se=k.c,te=P.s,de=k.s,ue=P.e,Te=k.e;if(!te||!de)return null;if(Z=K&&!K[0],z=se&&!se[0],Z||z)return Z?z?0:-de:te;if(te!=de)return te;if(Z=te<0,z=ue==Te,!K||!se)return z?0:!K^Z?1:-1;if(!z)return ue>Te^Z?1:-1;for(de=(ue=K.length)<(Te=se.length)?ue:Te,te=0;te<de;te++)if(K[te]!=se[te])return K[te]>se[te]^Z?1:-1;return ue==Te?0:ue>Te^Z?1:-1}function T(P,k,Z,z){if(P<k||P>Z||P!==i(P))throw Error(s+(z||"Argument")+(typeof P=="number"?P<k||P>Z?" out of range: ":" not an integer: ":" not a primitive number: ")+String(P))}function q(P){var k=P.c.length-1;return g(P.e/c)==k&&P.c[k]%2!=0}function O(P,k){return(P.length>1?P.charAt(0)+"."+P.slice(1):P)+(k<0?"e":"e+")+k}function $(P,k,Z){var z,K;if(k<0){for(K=Z+".";++k;K+=Z);P=K+P}else if(z=P.length,++k>z){for(K=Z,k-=z;--k;K+=Z);P+=K}else k<z&&(P=P.slice(0,k)+"."+P.slice(k));return P}e=w(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof zs<"u"&&zs.exports?zs.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(zl)});var Zl=J((cE,Dl)=>{Dl.exports=function(e,r,n){var i=new e.Uint8Array(n),s=r.pushInt,o=r.pushInt32,a=r.pushInt32Neg,c=r.pushInt64,f=r.pushInt64Neg,l=r.pushFloat,d=r.pushFloatSingle,v=r.pushFloatDouble,w=r.pushTrue,g=r.pushFalse,x=r.pushUndefined,N=r.pushNull,T=r.pushInfinity,q=r.pushInfinityNeg,O=r.pushNaN,$=r.pushNaNNeg,P=r.pushArrayStart,k=r.pushArrayStartFixed,Z=r.pushArrayStartFixed32,z=r.pushArrayStartFixed64,K=r.pushObjectStart,se=r.pushObjectStartFixed,te=r.pushObjectStartFixed32,de=r.pushObjectStartFixed64,ue=r.pushByteString,Te=r.pushByteStringStart,D=r.pushUtf8String,C=r.pushUtf8StringStart,X=r.pushSimpleUnassigned,j=r.pushTagStart,I=r.pushTagStart4,W=r.pushTagStart8,L=r.pushTagUnassigned,ie=r.pushBreak,U=e.Math.pow,y=0,fe=0,ae=0;function ce(_){for(_=_|0,y=0,fe=_;(y|0)<(fe|0)&&(ae=xy[i[y]&255](i[y]|0)|0,!((ae|0)>0)););return ae|0}function ee(_){return _=_|0,((y|0)+(_|0)|0)<(fe|0)?0:1}function u(_){return _=_|0,i[_|0]<<8|i[_+1|0]|0}function h(_){return _=_|0,i[_|0]<<24|i[_+1|0]<<16|i[_+2|0]<<8|i[_+3|0]|0}function p(_){return _=_|0,s(_|0),y=y+1|0,0}function B(_){return _=_|0,ee(1)|0?1:(s(i[y+1|0]|0),y=y+2|0,0)}function E(_){return _=_|0,ee(2)|0?1:(s(u(y+1|0)|0),y=y+3|0,0)}function S(_){return _=_|0,ee(4)|0?1:(o(u(y+1|0)|0,u(y+3|0)|0),y=y+5|0,0)}function F(_){return _=_|0,ee(8)|0?1:(c(u(y+1|0)|0,u(y+3|0)|0,u(y+5|0)|0,u(y+7|0)|0),y=y+9|0,0)}function m(_){return _=_|0,s(-1-(_-32|0)|0),y=y+1|0,0}function A(_){return _=_|0,ee(1)|0?1:(s(-1-(i[y+1|0]|0)|0),y=y+2|0,0)}function M(_){_=_|0;var Oe=0;return ee(2)|0?1:(Oe=u(y+1|0)|0,s(-1-(Oe|0)|0),y=y+3|0,0)}function R(_){return _=_|0,ee(4)|0?1:(a(u(y+1|0)|0,u(y+3|0)|0),y=y+5|0,0)}function Y(_){return _=_|0,ee(8)|0?1:(f(u(y+1|0)|0,u(y+3|0)|0,u(y+5|0)|0,u(y+7|0)|0),y=y+9|0,0)}function Q(_){_=_|0;var Oe=0,Ne=0,Ae=0;return Ae=_-64|0,ee(Ae|0)|0?1:(Oe=y+1|0,Ne=(y+1|0)+(Ae|0)|0,ue(Oe|0,Ne|0),y=Ne|0,0)}function le(_){_=_|0;var Oe=0,Ne=0,Ae=0;return ee(1)|0||(Ae=i[y+1|0]|0,Oe=y+2|0,Ne=(y+2|0)+(Ae|0)|0,ee(Ae+1|0)|0)?1:(ue(Oe|0,Ne|0),y=Ne|0,0)}function Be(_){_=_|0;var Oe=0,Ne=0,Ae=0;return ee(2)|0||(Ae=u(y+1|0)|0,Oe=y+3|0,Ne=(y+3|0)+(Ae|0)|0,ee(Ae+2|0)|0)?1:(ue(Oe|0,Ne|0),y=Ne|0,0)}function Ie(_){_=_|0;var Oe=0,Ne=0,Ae=0;return ee(4)|0||(Ae=h(y+1|0)|0,Oe=y+5|0,Ne=(y+5|0)+(Ae|0)|0,ee(Ae+4|0)|0)?1:(ue(Oe|0,Ne|0),y=Ne|0,0)}function Ve(_){return _=_|0,1}function xe(_){return _=_|0,Te(),y=y+1|0,0}function he(_){_=_|0;var Oe=0,Ne=0,Ae=0;return Ae=_-96|0,ee(Ae|0)|0?1:(Oe=y+1|0,Ne=(y+1|0)+(Ae|0)|0,D(Oe|0,Ne|0),y=Ne|0,0)}function ze(_){_=_|0;var Oe=0,Ne=0,Ae=0;return ee(1)|0||(Ae=i[y+1|0]|0,Oe=y+2|0,Ne=(y+2|0)+(Ae|0)|0,ee(Ae+1|0)|0)?1:(D(Oe|0,Ne|0),y=Ne|0,0)}function Fr(_){_=_|0;var Oe=0,Ne=0,Ae=0;return ee(2)|0||(Ae=u(y+1|0)|0,Oe=y+3|0,Ne=(y+3|0)+(Ae|0)|0,ee(Ae+2|0)|0)?1:(D(Oe|0,Ne|0),y=Ne|0,0)}function _n(_){_=_|0;var Oe=0,Ne=0,Ae=0;return ee(4)|0||(Ae=h(y+1|0)|0,Oe=y+5|0,Ne=(y+5|0)+(Ae|0)|0,ee(Ae+4|0)|0)?1:(D(Oe|0,Ne|0),y=Ne|0,0)}function wn(_){return _=_|0,1}function Ft(_){return _=_|0,C(),y=y+1|0,0}function Pe(_){return _=_|0,k(_-128|0),y=y+1|0,0}function Mt(_){return _=_|0,ee(1)|0?1:(k(i[y+1|0]|0),y=y+2|0,0)}function mt(_){return _=_|0,ee(2)|0?1:(k(u(y+1|0)|0),y=y+3|0,0)}function Ge(_){return _=_|0,ee(4)|0?1:(Z(u(y+1|0)|0,u(y+3|0)|0),y=y+5|0,0)}function ty(_){return _=_|0,ee(8)|0?1:(z(u(y+1|0)|0,u(y+3|0)|0,u(y+5|0)|0,u(y+7|0)|0),y=y+9|0,0)}function ry(_){return _=_|0,P(),y=y+1|0,0}function Ye(_){_=_|0;var Oe=0;return Oe=_-160|0,ee(Oe|0)|0?1:(se(Oe|0),y=y+1|0,0)}function ny(_){return _=_|0,ee(1)|0?1:(se(i[y+1|0]|0),y=y+2|0,0)}function iy(_){return _=_|0,ee(2)|0?1:(se(u(y+1|0)|0),y=y+3|0,0)}function sy(_){return _=_|0,ee(4)|0?1:(te(u(y+1|0)|0,u(y+3|0)|0),y=y+5|0,0)}function oy(_){return _=_|0,ee(8)|0?1:(de(u(y+1|0)|0,u(y+3|0)|0,u(y+5|0)|0,u(y+7|0)|0),y=y+9|0,0)}function ay(_){return _=_|0,K(),y=y+1|0,0}function kn(_){return _=_|0,j(_-192|0|0),y=y+1|0,0}function lx(_){return _=_|0,j(_|0),y=y+1|0,0}function dx(_){return _=_|0,j(_|0),y=y+1|0,0}function hx(_){return _=_|0,j(_|0),y=y+1|0,0}function px(_){return _=_|0,j(_|0),y=y+1|0,0}function dt(_){return _=_|0,j(_-192|0|0),y=y+1|0,0}function yx(_){return _=_|0,j(_|0),y=y+1|0,0}function bx(_){return _=_|0,j(_|0),y=y+1|0,0}function gx(_){return _=_|0,j(_|0),y=y+1|0,0}function cy(_){return _=_|0,ee(1)|0?1:(j(i[y+1|0]|0),y=y+2|0,0)}function uy(_){return _=_|0,ee(2)|0?1:(j(u(y+1|0)|0),y=y+3|0,0)}function fy(_){return _=_|0,ee(4)|0?1:(I(u(y+1|0)|0,u(y+3|0)|0),y=y+5|0,0)}function ly(_){return _=_|0,ee(8)|0?1:(W(u(y+1|0)|0,u(y+3|0)|0,u(y+5|0)|0,u(y+7|0)|0),y=y+9|0,0)}function tt(_){return _=_|0,X((_|0)-224|0),y=y+1|0,0}function dy(_){return _=_|0,g(),y=y+1|0,0}function hy(_){return _=_|0,w(),y=y+1|0,0}function py(_){return _=_|0,N(),y=y+1|0,0}function yy(_){return _=_|0,x(),y=y+1|0,0}function by(_){return _=_|0,ee(1)|0?1:(X(i[y+1|0]|0),y=y+2|0,0)}function gy(_){_=_|0;var Oe=0,Ne=0,Ae=1,us=0,_i=0,mx=0;return ee(2)|0?1:(Oe=i[y+1|0]|0,Ne=i[y+2|0]|0,(Oe|0)&128&&(Ae=-1),us=+(((Oe|0)&124)>>2),_i=+(((Oe|0)&3)<<8|Ne),+us==0?l(+(+Ae*5960464477539063e-23*+_i)):+us==31?+Ae==1?+_i>0?O():T():+_i>0?$():q():l(+(+Ae*U(2,+(+us-25))*+(1024+_i))),y=y+3|0,0)}function my(_){return _=_|0,ee(4)|0?1:(d(i[y+1|0]|0,i[y+2|0]|0,i[y+3|0]|0,i[y+4|0]|0),y=y+5|0,0)}function _y(_){return _=_|0,ee(8)|0?1:(v(i[y+1|0]|0,i[y+2|0]|0,i[y+3|0]|0,i[y+4|0]|0,i[y+5|0]|0,i[y+6|0]|0,i[y+7|0]|0,i[y+8|0]|0),y=y+9|0,0)}function je(_){return _=_|0,1}function wy(_){return _=_|0,ie(),y=y+1|0,0}var xy=[p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,B,E,S,F,je,je,je,je,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,A,M,R,Y,je,je,je,je,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,le,Be,Ie,Ve,je,je,je,xe,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,ze,Fr,_n,wn,je,je,je,Ft,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Mt,mt,Ge,ty,je,je,je,ry,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,ny,iy,sy,oy,je,je,je,ay,kn,kn,kn,kn,kn,kn,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,cy,uy,fy,ly,je,je,je,je,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,dy,hy,py,yy,by,gy,my,_y,je,je,je,wy];return{parse:ce}}});var Pi=J($t=>{"use strict";var xc=Ni().BigNumber;$t.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};$t.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};$t.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};$t.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};$t.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};$t.SHIFT32=Math.pow(2,32);$t.SHIFT16=Math.pow(2,16);$t.MAX_SAFE_HIGH=2097151;$t.NEG_ONE=new xc(-1);$t.TEN=new xc(10);$t.TWO=new xc(2);$t.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var Ds=J(Jt=>{"use strict";var{Buffer:xg}=Vn("buffer"),Jl=Ni().BigNumber,Ll=Pi(),Xl=Ll.SHIFT32,Eg=Ll.SHIFT16,vg=2097151;Jt.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 Bg(t){return t<16?"0"+t.toString(16):t.toString(16)}Jt.arrayBufferToBignumber=function(t){let e=t.byteLength,r="";for(let n=0;n<e;n++)r+=Bg(t[n]);return new Jl(r,16)};Jt.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};Jt.buildInt32=(t,e)=>t*Eg+e;Jt.buildInt64=(t,e,r,n)=>{let i=Jt.buildInt32(t,e),s=Jt.buildInt32(r,n);return i>vg?new Jl(i).times(Xl).plus(s):i*Xl+s};Jt.writeHalf=function(e,r){let n=xg.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};Jt.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])};Jt.isNegativeZero=t=>t===0&&1/t<0;Jt.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,e+=1;return 1<<e}});var Tc=J((lE,Ql)=>{"use strict";var Bc=Pi(),Tg=Bc.MT,Zs=Bc.SIMPLE,Ec=Bc.SYMS,vc=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,Tg.SIMPLE_FLOAT)}static isSimple(e){return e instanceof t}static decode(e,r){switch(r==null&&(r=!0),e){case Zs.FALSE:return!1;case Zs.TRUE:return!0;case Zs.NULL:return r?null:Ec.NULL;case Zs.UNDEFINED:return r?void 0:Ec.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return Ec.BREAK;default:return new t(e)}}};Ql.exports=vc});var Ac=J((dE,ed)=>{"use strict";var Sc=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}}};ed.exports=Sc});var Nc=J((hE,rd)=>{"use strict";var{URL:Sg,URLSearchParams:Ag,format:Og}=Vn("url"),td="http://localhost",Oc=class extends Sg{constructor(e="",r=td){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()}};rd.exports={URLWithLegacySupport:Oc,URLSearchParams:Ag,format:Og,defaultBase:td}});var sd=J((pE,id)=>{"use strict";var{URLWithLegacySupport:nd,format:Ng}=Nc();id.exports=(t,e={},r={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new nd(t)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new nd(t,Ng(o)).toString()}});var Pc=J((yE,od)=>{"use strict";var{URLWithLegacySupport:Pg,format:Rg,URLSearchParams:Ig,defaultBase:Ug}=Nc(),Fg=sd();od.exports={URL:Pg,URLSearchParams:Ig,format:Rg,relative:Fg,defaultBase:Ug}});var Rc=J((bE,cd)=>{"use strict";var{Buffer:ii}=Vn("buffer"),ad=Ga(),Mg=Ni().BigNumber,Cg=Zl(),Pt=Ds(),Ce=Pi(),qg=Tc(),jg=Ac(),{URL:kg}=Pc(),Ri=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=ii.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 kg(r),35:r=>new RegExp(r)},e.tags),this.parser=Cg(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 jg(e,r)}createMap(e,r){return e}createObject(e,r){return e}createArray(e,r){return e}createByteString(e,r){return ii.concat(e)}createByteStringFromHeap(e,r){return e===r?ii.alloc(0):ii.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>Ce.MAX_SAFE_HIGH?Ce.NEG_ONE.minus(new Mg(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 qg(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=ii.from(e,r||"hex")),new t({size:e.length}).decodeFirst(e)}static decodeAll(e,r){return typeof e=="string"&&(e=ii.from(e,r||"hex")),new t({size:e.length}).decodeAll(e)}};Ri.decodeFirst=Ri.decode;cd.exports=Ri});var ld=J((gE,fd)=>{"use strict";var{Buffer:Ic}=Vn("buffer"),Vg=Rc(),Hg=Ds(),Uc=class t extends Vg{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 Hg.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'${Ic.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(ud(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(e,r){let n=super.createObject(e),i=Object.keys(n).reduce(ud(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,r){return`"${Ic.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return typeof e=="string"&&(e=Ic.from(e,r||"hex")),new t().decodeFirst(e)}};fd.exports=Uc;function ud(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}});var bd=J((mE,yd)=>{"use strict";var{Buffer:wr}=Vn("buffer"),{URL:$g}=Pc(),Mc=Ni().BigNumber,Fc=Ds(),ot=Pi(),or=ot.MT,Xs=ot.NUMBYTES,dd=ot.SHIFT32,hd=ot.SYMS,si=ot.TAG,Kg=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.TWO,Gg=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.FOUR,Yg=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.EIGHT,Wg=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.TRUE,zg=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.FALSE,Dg=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.UNDEFINED,pd=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.NULL,Zg=new Mc("0x20000000000000"),Xg=wr.from("f97e00","hex"),Jg=wr.from("f9fc00","hex"),Lg=wr.from("f97c00","hex");function Qg(t){return{}.toString.call(t).slice(8,-1)}var Cc=class t{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[$g,this._pushUrl],[Mc,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(Xg)}_pushInfinity(e){let r=e<0?Jg:Lg;return this.push(r)}_pushFloat(e){let r=wr.allocUnsafe(2);if(Fc.writeHalf(r,e)&&Fc.parseHalf(r)===e)return this._pushUInt8(Kg)&&this.push(r);let n=wr.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(Gg)&&this.push(n):this._pushUInt8(Yg)&&this._pushDoubleBE(e)}_pushInt(e,r,n){let i=r<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|Xs.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|Xs.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|Xs.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|Xs.EIGHT)&&this._pushUInt32BE(Math.floor(e/dd))&&this._pushUInt32BE(e%dd):r===or.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,or.NEG_INT,e):this._pushInt(e,or.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=wr.byteLength(e,"utf8");return this._pushInt(r,or.UTF8_STRING)&&this.pushWrite(e,5,r)}_pushBoolean(e){return this._pushUInt8(e?Wg:zg)}_pushUndefined(e){return this._pushUInt8(Dg)}_pushArray(e,r){let n=r.length;if(!e._pushInt(n,or.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,or.TAG)}_pushDate(e,r){return e._pushTag(si.DATE_EPOCH)&&e.pushAny(Math.round(r/1e3))}_pushBuffer(e,r){return e._pushInt(r.length,or.BYTE_STRING)&&e.push(r)}_pushNoFilter(e,r){return e._pushBuffer(e,r.slice())}_pushRegexp(e,r){return e._pushTag(si.REGEXP)&&e.pushAny(r.source)}_pushSet(e,r){if(!e._pushInt(r.size,or.ARRAY))return!1;for(let n of r)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,r){return e._pushTag(si.URI)&&e.pushAny(r.format())}_pushBigint(e){let r=si.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),r=si.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=wr.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(si.DECIMAL_FRAC)&&e._pushInt(2,or.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new Mc(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(Zg)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,r){return e._pushInt(r.size,or.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(e){if(!e)return this._pushUInt8(pd);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,or.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(Fc.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=Qg(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,wr.isBuffer(e)?e:wr.from(e));case"Null":return this._pushUInt8(pd);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 hd.NULL:return this._pushObject(null);case hd.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=wr.allocUnsafe(s),c=0,f=0;for(o=0;o<i;o++){switch(f=r[o],n[o]){case 0:e[o].copy(a,c);break;case 1:a.writeUInt8(e[o],c,!0);break;case 2:a.writeUInt16BE(e[o],c,!0);break;case 3:a.writeUInt32BE(e[o],c,!0);break;case 4:a.writeDoubleBE(e[o],c,!0);break;case 5:a.write(e[o],c,f,"utf8");break;default:throw new Error("unkown method")}c+=f}var l=a;return this._reset(),l}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(e){let r=new t;if(!r.pushAny(e))throw new Error("Failed to encode input");return r.finalize()}};yd.exports=Cc});var Js=J(at=>{"use strict";at.Diagnose=ld();at.Decoder=Rc();at.Encoder=bd();at.Simple=Tc();at.Tagged=Ac();at.decodeAll=at.Decoder.decodeAll;at.decodeFirst=at.Decoder.decodeFirst;at.diagnose=at.Diagnose.diagnose;at.encode=at.Encoder.encode;at.decode=at.Decoder.decode;at.leveldb={decode:at.Decoder.decodeAll,encode:at.Encoder.encode,buffer:!0,name:"cbor"}});var Kt=J(Bt=>{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});Bt.bufFromBufLike=Bt.uint8ToBuf=Bt.bufEquals=Bt.compare=Bt.fromHex=Bt.toHex=Bt.concat=void 0;function em(...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}Bt.concat=em;function tm(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}Bt.toHex=tm;var rm=new RegExp(/^[0-9a-fA-F]+$/);function nm(t){if(!rm.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}Bt.fromHex=nm;function gd(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}Bt.compare=gd;function im(t,e){return gd(t,e)===0}Bt.bufEquals=im;function Ls(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}Bt.uint8ToBuf=Ls;function md(t){return t instanceof Uint8Array?Ls(t):t instanceof ArrayBuffer?t:Array.isArray(t)?Ls(new Uint8Array(t)):"buffer"in t?md(t.buffer):Ls(new Uint8Array(t))}Bt.bufFromBufLike=md});var Fi=J(Lt=>{"use strict";var sm=Lt&&Lt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Lt,"__esModule",{value:!0});Lt.hashOfMap=Lt.requestIdOf=Lt.hashValue=Lt.hash=void 0;var _d=ni(),om=sm(Js()),am=ms(),Ii=Kt();function Lr(t){return(0,Ii.uint8ToBuf)(am.sha256.create().update(new Uint8Array(t)).digest())}Lt.hash=Lr;function Ui(t){if(t instanceof om.default.Tagged)return Ui(t.value);if(typeof t=="string")return wd(t);if(typeof t=="number")return Lr((0,_d.lebEncode)(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return Lr(t);if(Array.isArray(t)){let e=t.map(Ui);return Lr((0,Ii.concat)(...e))}else{if(t&&typeof t=="object"&&t._isPrincipal)return Lr(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return Ui(t.toHash());if(typeof t=="object")return qc(t);if(typeof t=="bigint")return Lr((0,_d.lebEncode)(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}Lt.hashValue=Ui;var wd=t=>{let e=new TextEncoder().encode(t);return Lr(e)};function cm(t){return qc(t)}Lt.requestIdOf=cm;function qc(t){let n=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=wd(o),f=Ui(a);return[c,f]}).sort(([o],[a])=>(0,Ii.compare)(o,a)),i=(0,Ii.concat)(...n.map(o=>(0,Ii.concat)(...o)));return Lr(i)}Lt.hashOfMap=qc});var Vc=J(xr=>{"use strict";var um=xr&&xr.__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(xr,"__esModule",{value:!0});xr.createIdentityDescriptor=xr.AnonymousIdentity=xr.SignIdentity=void 0;var xd=Ct(),fm=Fi(),Ed=Kt(),lm=new TextEncoder().encode(`
|
|
16
|
+
ic-request`),jc=class{getPrincipal(){return this._principal||(this._principal=xd.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=um(e,["body"]),i=await(0,fm.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,Ed.concat)(lm,i))}})}};xr.SignIdentity=jc;var kc=class{getPrincipal(){return xd.Principal.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};xr.AnonymousIdentity=kc;function dm(t){return"getPublicKey"in t?{type:"PublicKeyIdentity",publicKey:(0,Ed.toHex)(t.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}xr.createIdentityDescriptor=dm});var Kc=J(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});var hm=9007199254740992;function kr(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 ar(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 Qs(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 ar(t,r,e.toString(16))}}function vd(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 kr(new Uint8Array(Qs(3,t.length)),new Uint8Array(e))}function pm(t,e){if(t==14277111)return kr(new Uint8Array([217,217,247]),e);if(t<24)return kr(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}}He.tagged=pm;function Mi(t){return new Uint8Array(t).buffer}He.raw=Mi;function Hc(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}He.uSmall=Hc;function Bd(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),ar(0,24,t)}He.u8=Bd;function Td(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),ar(0,25,t)}He.u16=Td;function Sd(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),ar(0,26,t)}He.u32=Sd;function $c(t,e){if(typeof t=="string"&&e==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return ar(0,27,t)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),hm),t=t.toString(16),ar(0,27,t)}He.u64=$c;function Ad(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return Hc(0);t=Math.min(Math.max(0,-t),24)-1;let e=[32+t];return new Uint8Array(e).buffer}He.iSmall=Ad;function Od(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),ar(1,24,t)}He.i8=Od;function Nd(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),ar(1,25,t)}He.i16=Nd;function Pd(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),ar(1,26,t)}He.i32=Pd;function Rd(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?ar(1,27,n):$c(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),ar(1,27,t)}He.i64=Rd;function ym(t){return t>=0?t<24?Hc(t):t<=255?Bd(t):t<=65535?Td(t):t<=4294967295?Sd(t):$c(t):t>=-24?Ad(t):t>=-255?Od(t):t>=-65535?Nd(t):t>=-4294967295?Pd(t):Rd(t)}He.number=ym;function bm(t){return kr(Qs(2,t.byteLength),t)}He.bytes=bm;function gm(t){return vd(t)}He.string=gm;function mm(t){return kr(Qs(4,t.length),...t)}He.array=mm;function _m(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))),kr(Qs(5,t.size),...r.map(([n,i])=>kr(vd(n),i)))}He.map=_m;function wm(t){let e=new Float32Array([t]);return kr(new Uint8Array([250]),new Uint8Array(e.buffer))}He.singleFloat=wm;function xm(t){let e=new Float64Array([t]);return kr(new Uint8Array([251]),new Uint8Array(e.buffer))}He.doubleFloat=xm;function Em(t){return t?Id():Ud()}He.bool=Em;function Id(){return Mi(new Uint8Array([245]))}He.true_=Id;function Ud(){return Mi(new Uint8Array([244]))}He.false_=Ud;function vm(){return Mi(new Uint8Array([246]))}He.null_=vm;function Bm(){return Mi(new Uint8Array([247]))}He.undefined_=Bm});var Fd=J(Qr=>{"use strict";var Tm=Qr&&Qr.__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(Qr,"__esModule",{value:!0});var cr=Tm(Kc()),Sm=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],eo=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 cr.undefined_();case"boolean":return cr.bool(e);case"number":return Math.floor(e)===e?cr.number(e):cr.doubleFloat(e);case"string":return cr.string(e);case"object":if(e===null)return cr.null_();if(Array.isArray(e))return cr.array(e.map(r=>this._serializer.serializeValue(r)));if(Sm.find(r=>e instanceof r))return cr.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 cr.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 cr.map(r,this._stable)}default:throw new Error("Invalid value.")}}};Qr.JsonDefaultCborEncoder=eo;var to=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};Qr.ToCborEncoder=to;var ro=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let r=new this;return r.addEncoder(new eo(r,e)),r.addEncoder(new to),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)}};Qr.CborSerializer=ro;var Gc=class extends ro{serialize(e){return cr.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};Qr.SelfDescribeCborSerializer=Gc});var Ci=J(Tn=>{"use strict";function Am(t){for(var e in t)Tn.hasOwnProperty(e)||(Tn[e]=t[e])}var Om=Tn&&Tn.__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(Tn,"__esModule",{value:!0});Am(Fd());var Nm=Om(Kc());Tn.value=Nm});var qi=J(xt=>{"use strict";var Pm=xt&&xt.__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]}),Rm=xt&&xt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Im=xt&&xt.__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)&&Pm(e,t,r);return Rm(e,t),e},Um=xt&&xt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(xt,"__esModule",{value:!0});xt.decode=xt.encode=xt.CborTag=void 0;var Fm=Um(Js()),oi=Im(Ci()),Mm=Ci(),no=Kt(),Yc=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return oi.value.bytes(e.toUint8Array())}},Wc=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return oi.value.bytes(new Uint8Array(e))}},zc=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?oi.value.tagged(2,oi.value.bytes((0,no.fromHex)(e.toString(16)))):oi.value.tagged(3,oi.value.bytes((0,no.fromHex)((BigInt("-1")*e).toString(16))))}},io=Mm.SelfDescribeCborSerializer.withDefaultEncoders(!0);io.addEncoder(new Yc);io.addEncoder(new Wc);io.addEncoder(new zc);var Cd;(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(Cd=xt.CborTag||(xt.CborTag={}));function Cm(t){return io.serialize(t)}xt.encode=Cm;function Md(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 Dc=class extends Fm.default.Decoder{createByteString(e){return(0,no.concat)(...e)}createByteStringFromHeap(e,r){return e===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,r))}};function qm(t){let e=new Uint8Array(t),r=new Dc({size:e.byteLength,tags:{2:n=>Md(n),3:n=>-Md(n),[Cd.Semantic]:n=>n}});try{return r.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${(0,no.toHex)(e)}`)}}xt.decode=qm});var Zc=J(so=>{"use strict";Object.defineProperty(so,"__esModule",{value:!0});so.randomNumber=void 0;var jm=()=>{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)};so.randomNumber=jm});var ji=J(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.makeNonce=Sn.SubmitRequestType=void 0;var oo=Zc(),km;(function(t){t.Call="call"})(km=Sn.SubmitRequestType||(Sn.SubmitRequestType={}));function Vm(){let t=new ArrayBuffer(16),e=new DataView(t),r=(0,oo.randomNumber)(),n=(0,oo.randomNumber)(),i=(0,oo.randomNumber)(),s=(0,oo.randomNumber)();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),t}Sn.makeNonce=Vm});var co=J(Tt=>{"use strict";var Hm=Tt&&Tt.__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]}),$m=Tt&&Tt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Km=Tt&&Tt.__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)&&Hm(e,t,r);return $m(e,t),e};Object.defineProperty(Tt,"__esModule",{value:!0});Tt.httpHeadersTransform=Tt.makeExpiryTransform=Tt.makeNonceTransform=Tt.Expiry=void 0;var Gm=ni(),Ym=Km(Ci()),Wm=ji(),zm=BigInt(1e6),Dm=60*1e3,ao=class{constructor(e){let s=BigInt(Math.floor(Date.now()+e-Dm))*zm/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return Ym.value.u64(this._value.toString(16),16)}toHash(){return(0,Gm.lebEncode)(this._value)}};Tt.Expiry=ao;function Zm(t=Wm.makeNonce){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}Tt.makeNonceTransform=Zm;function Xm(t){return async e=>{e.body.ingress_expiry=new ao(t)}}Tt.makeExpiryTransform=Xm;function Jm(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}Tt.httpHeadersTransform=Jm});var Jc=J(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.AgentHTTPResponseError=void 0;var Lm=Xn(),Xc=class extends Lm.AgentError{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};uo.AgentHTTPResponseError=Xc});var Qt=J(me=>{"use strict";Object.defineProperty(me,"__esModule",{value:!0});me.validateObject=me.createHmacDrbg=me.bitMask=me.bitSet=me.bitGet=me.bitLen=me.utf8ToBytes=me.equalBytes=me.concatBytes=me.ensureBytes=me.numberToVarBytesBE=me.numberToBytesLE=me.numberToBytesBE=me.bytesToNumberLE=me.bytesToNumberBE=me.hexToBytes=me.hexToNumber=me.numberToHexUnpadded=me.bytesToHex=me.abytes=me.isBytes=void 0;var kd=BigInt(0),fo=BigInt(1),Qm=BigInt(2);function lo(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}me.isBytes=lo;function ho(t){if(!lo(t))throw new Error("Uint8Array expected")}me.abytes=ho;var e1=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Qc(t){ho(t);let e="";for(let r=0;r<t.length;r++)e+=e1[t[r]];return e}me.bytesToHex=Qc;function Vd(t){let e=t.toString(16);return e.length&1?`0${e}`:e}me.numberToHexUnpadded=Vd;function eu(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}me.hexToNumber=eu;var Vr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function qd(t){if(t>=Vr._0&&t<=Vr._9)return t-Vr._0;if(t>=Vr._A&&t<=Vr._F)return t-(Vr._A-10);if(t>=Vr._a&&t<=Vr._f)return t-(Vr._a-10)}function po(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=qd(t.charCodeAt(s)),a=qd(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}me.hexToBytes=po;function t1(t){return eu(Qc(t))}me.bytesToNumberBE=t1;function r1(t){return ho(t),eu(Qc(Uint8Array.from(t).reverse()))}me.bytesToNumberLE=r1;function Hd(t,e){return po(t.toString(16).padStart(e*2,"0"))}me.numberToBytesBE=Hd;function n1(t,e){return Hd(t,e).reverse()}me.numberToBytesLE=n1;function i1(t){return po(Vd(t))}me.numberToVarBytesBE=i1;function s1(t,e,r){let n;if(typeof e=="string")try{n=po(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(lo(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}me.ensureBytes=s1;function $d(...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}me.concatBytes=$d;function o1(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}me.equalBytes=o1;function a1(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}me.utf8ToBytes=a1;function c1(t){let e;for(e=0;t>kd;t>>=fo,e+=1);return e}me.bitLen=c1;function u1(t,e){return t>>BigInt(e)&fo}me.bitGet=u1;function f1(t,e,r){return t|(r?fo:kd)<<BigInt(e)}me.bitSet=f1;var l1=t=>(Qm<<BigInt(t-1))-fo;me.bitMask=l1;var Lc=t=>new Uint8Array(t),jd=t=>Uint8Array.from(t);function d1(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=Lc(t),i=Lc(t),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...d)=>r(i,n,...d),c=(d=Lc())=>{i=a(jd([0]),d),n=a(),d.length!==0&&(i=a(jd([1]),d),n=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let d=0,v=[];for(;d<e;){n=a();let w=n.slice();v.push(w),d+=n.length}return $d(...v)};return(d,v)=>{o(),c(d);let w;for(;!(w=v(f()));)c();return o(),w}}me.createHmacDrbg=d1;var h1={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"||lo(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 p1(t,e,r={}){let n=(i,s,o)=>{let a=h1[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}me.validateObject=p1});var Hr=J(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.mapHashToField=we.getMinHashLength=we.getFieldBytesLength=we.hashToPrivateScalar=we.FpSqrtEven=we.FpSqrtOdd=we.Field=we.nLength=we.FpIsSquare=we.FpDiv=we.FpInvertBatch=we.FpPow=we.validateField=we.isNegativeLE=we.FpSqrt=we.tonelliShanks=we.invert=we.pow2=we.pow=we.mod=void 0;var Yt=Qt(),ct=BigInt(0),ke=BigInt(1),en=BigInt(2),y1=BigInt(3),tu=BigInt(4),Kd=BigInt(5),Gd=BigInt(8),b1=BigInt(9),g1=BigInt(16);function Gt(t,e){let r=t%e;return r>=ct?r:e+r}we.mod=Gt;function Yd(t,e,r){if(r<=ct||e<ct)throw new Error("Expected power/modulo > 0");if(r===ke)return ct;let n=ke;for(;e>ct;)e&ke&&(n=n*t%r),t=t*t%r,e>>=ke;return n}we.pow=Yd;function m1(t,e,r){let n=t;for(;e-- >ct;)n*=n,n%=r;return n}we.pow2=m1;function yo(t,e){if(t===ct||e<=ct)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Gt(t,e),n=e,i=ct,s=ke,o=ke,a=ct;for(;r!==ct;){let f=n/r,l=n%r,d=i-o*f,v=s-a*f;n=r,r=l,i=o,s=a,o=d,a=v}if(n!==ke)throw new Error("invert: does not exist");return Gt(i,e)}we.invert=yo;function Wd(t){let e=(t-ke)/en,r,n,i;for(r=t-ke,n=0;r%en===ct;r/=en,n++);for(i=en;i<t&&Yd(i,e,t)!==t-ke;i++);if(n===1){let o=(t+ke)/tu;return function(c,f){let l=c.pow(f,o);if(!c.eql(c.sqr(l),f))throw new Error("Cannot find square root");return l}}let s=(r+ke)/en;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,l=a.pow(a.mul(a.ONE,i),r),d=a.pow(c,s),v=a.pow(c,r);for(;!a.eql(v,a.ONE);){if(a.eql(v,a.ZERO))return a.ZERO;let w=1;for(let x=a.sqr(v);w<f&&!a.eql(x,a.ONE);w++)x=a.sqr(x);let g=a.pow(l,ke<<BigInt(f-w-1));l=a.sqr(g),d=a.mul(d,g),v=a.mul(v,l),f=w}return d}}we.tonelliShanks=Wd;function zd(t){if(t%tu===y1){let e=(t+ke)/tu;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%Gd===Kd){let e=(t-Kd)/Gd;return function(n,i){let s=n.mul(i,en),o=n.pow(s,e),a=n.mul(i,o),c=n.mul(n.mul(a,en),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%g1,Wd(t)}we.FpSqrt=zd;var _1=(t,e)=>(Gt(t,e)&ke)===ke;we.isNegativeLE=_1;var w1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function x1(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=w1.reduce((n,i)=>(n[i]="function",n),e);return(0,Yt.validateObject)(t,r)}we.validateField=x1;function Dd(t,e,r){if(r<ct)throw new Error("Expected power > 0");if(r===ct)return t.ONE;if(r===ke)return e;let n=t.ONE,i=e;for(;r>ct;)r&ke&&(n=t.mul(n,i)),i=t.sqr(i),r>>=ke;return n}we.FpPow=Dd;function Zd(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}we.FpInvertBatch=Zd;function E1(t,e,r){return t.mul(e,typeof r=="bigint"?yo(r,t.ORDER):t.inv(r))}we.FpDiv=E1;function v1(t){let e=(t.ORDER-ke)/en;return r=>{let n=t.pow(r,e);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}}we.FpIsSquare=v1;function ru(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}we.nLength=ru;function B1(t,e,r=!1,n={}){if(t<=ct)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:s}=ru(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=zd(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:(0,Yt.bitMask)(i),ZERO:ct,ONE:ke,create:c=>Gt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ct<=c&&c<t},is0:c=>c===ct,isOdd:c=>(c&ke)===ke,neg:c=>Gt(-c,t),eql:(c,f)=>c===f,sqr:c=>Gt(c*c,t),add:(c,f)=>Gt(c+f,t),sub:(c,f)=>Gt(c-f,t),mul:(c,f)=>Gt(c*f,t),pow:(c,f)=>Dd(a,c,f),div:(c,f)=>Gt(c*yo(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>yo(c,t),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>Zd(a,c),cmov:(c,f,l)=>l?f:c,toBytes:c=>r?(0,Yt.numberToBytesLE)(c,s):(0,Yt.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?(0,Yt.bytesToNumberLE)(c):(0,Yt.bytesToNumberBE)(c)}});return Object.freeze(a)}we.Field=B1;function T1(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)}we.FpSqrtOdd=T1;function S1(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}we.FpSqrtEven=S1;function A1(t,e,r=!1){t=(0,Yt.ensureBytes)("privateHash",t);let n=t.length,i=ru(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,Yt.bytesToNumberLE)(t):(0,Yt.bytesToNumberBE)(t);return Gt(s,e-ke)+ke}we.hashToPrivateScalar=A1;function nu(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}we.getFieldBytesLength=nu;function Xd(t){let e=nu(t);return e+Math.ceil(e/2)}we.getMinHashLength=Xd;function O1(t,e,r=!1){let n=t.length,i=nu(e),s=Xd(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?(0,Yt.bytesToNumberBE)(t):(0,Yt.bytesToNumberLE)(t),a=Gt(o,e-ke)+ke;return r?(0,Yt.numberToBytesLE)(a,i):(0,Yt.numberToBytesBE)(a,i)}we.mapHashToField=O1});var bo=J(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});er.createHasher=er.isogenyMap=er.hash_to_field=er.expand_message_xof=er.expand_message_xmd=void 0;var N1=Hr(),St=Qt(),P1=St.bytesToNumberBE;function tn(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 R1(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 su(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function Jd(t,e,r,n){(0,St.abytes)(t),(0,St.abytes)(e),su(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,tn(e.length,1)),c=tn(0,s),f=tn(r,2),l=new Array(o),d=n((0,St.concatBytes)(c,t,f,tn(0,1),a));l[0]=n((0,St.concatBytes)(d,tn(1,1),a));for(let w=1;w<=o;w++){let g=[R1(d,l[w-1]),tn(w+1,1),a];l[w]=n((0,St.concatBytes)(...g))}return(0,St.concatBytes)(...l).slice(0,r)}er.expand_message_xmd=Jd;function Ld(t,e,r,n,i){if((0,St.abytes)(t),(0,St.abytes)(e),su(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(tn(r,2)).update(e).update(tn(e.length,1)).digest()}er.expand_message_xof=Ld;function iu(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),su(e);let f=typeof c=="string"?(0,St.utf8ToBytes)(c):c,l=n.toString(2).length,d=Math.ceil((l+i)/8),v=e*s*d,w;if(a==="xmd")w=Jd(t,f,v,o);else if(a==="xof")w=Ld(t,f,v,i,o);else if(a==="_internal_pass")w=t;else throw new Error('expand must be "xmd" or "xof"');let g=new Array(e);for(let x=0;x<e;x++){let N=new Array(s);for(let T=0;T<s;T++){let q=d*(T+x*s),O=w.subarray(q,q+d);N[T]=(0,N1.mod)(P1(O),n)}g[x]=N}return g}er.hash_to_field=iu;function I1(t,e){let r=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,a,c]=r.map(f=>f.reduce((l,d)=>t.add(t.mul(l,n),d)));return n=t.div(s,o),i=t.mul(i,t.div(a,c)),{x:n,y:i}}}er.isogenyMap=I1;function U1(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=iu(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=iu(n,1,{...r,DST:r.encodeDST,...i}),o=t.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o}}}er.createHasher=U1});var au=J(ai=>{"use strict";Object.defineProperty(ai,"__esModule",{value:!0});ai.validateBasic=ai.wNAF=void 0;var Qd=Hr(),F1=Qt(),M1=BigInt(0),ou=BigInt(1);function C1(t,e){let r=(i,s)=>{let o=s.negate();return i?o:s},n=i=>{let s=Math.ceil(e/i)+1,o=2**(i-1);return{windows:s,windowSize:o}};return{constTimeNegate:r,unsafeLadder(i,s){let o=t.ZERO,a=i;for(;s>M1;)s&ou&&(o=o.add(a)),a=a.double(),s>>=ou;return o},precomputeWindow(i,s){let{windows:o,windowSize:a}=n(s),c=[],f=i,l=f;for(let d=0;d<o;d++){l=f,c.push(l);for(let v=1;v<a;v++)l=l.add(f),c.push(l);f=l.double()}return c},wNAF(i,s,o){let{windows:a,windowSize:c}=n(i),f=t.ZERO,l=t.BASE,d=BigInt(2**i-1),v=2**i,w=BigInt(i);for(let g=0;g<a;g++){let x=g*c,N=Number(o&d);o>>=w,N>c&&(N-=v,o+=ou);let T=x,q=x+Math.abs(N)-1,O=g%2!==0,$=N<0;N===0?l=l.add(r(O,s[T])):f=f.add(r($,s[q]))}return{p:f,f:l}},wNAFCached(i,s,o,a){let c=i._WINDOW_SIZE||1,f=s.get(i);return f||(f=this.precomputeWindow(i,c),c!==1&&s.set(i,a(f))),this.wNAF(c,f,o)}}}ai.wNAF=C1;function q1(t){return(0,Qd.validateField)(t.Fp),(0,F1.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,Qd.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}ai.validateBasic=q1});var uu=J(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.mapToCurveSimpleSWU=ut.SWUFpSqrtRatio=ut.weierstrass=ut.weierstrassPoints=ut.DER=void 0;var ci=Hr(),De=Qt(),Er=Qt(),cu=au();function j1(t){let e=(0,cu.validateBasic)(t);De.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:k1,hexToBytes:V1}=De;ut.DER={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=ut.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:k1(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=ut.DER,r=typeof t=="string"?V1(t):t;De.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}=ut.DER._parseInt(r.subarray(2)),{d:o,l:a}=ut.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 l=f.toString(16);return l.length&1?`0${l}`:l},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 ur=BigInt(0),Xe=BigInt(1),rn=BigInt(2),go=BigInt(3),e0=BigInt(4);function t0(t){let e=j1(t),{Fp:r}=e,n=e.toBytes||((g,x,N)=>{let T=x.toAffine();return De.concatBytes(Uint8Array.from([4]),r.toBytes(T.x),r.toBytes(T.y))}),i=e.fromBytes||(g=>{let x=g.subarray(1),N=r.fromBytes(x.subarray(0,r.BYTES)),T=r.fromBytes(x.subarray(r.BYTES,2*r.BYTES));return{x:N,y:T}});function s(g){let{a:x,b:N}=e,T=r.sqr(g),q=r.mul(T,g);return r.add(r.add(q,r.mul(g,x)),N)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(g){return typeof g=="bigint"&&ur<g&&g<e.n}function a(g){if(!o(g))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(g){let{allowedPrivateKeyLengths:x,nByteLength:N,wrapPrivateKey:T,n:q}=e;if(x&&typeof g!="bigint"){if(De.isBytes(g)&&(g=De.bytesToHex(g)),typeof g!="string"||!x.includes(g.length))throw new Error("Invalid key");g=g.padStart(N*2,"0")}let O;try{O=typeof g=="bigint"?g:De.bytesToNumberBE((0,Er.ensureBytes)("private key",g,N))}catch{throw new Error(`private key must be ${N} bytes, hex or bigint, not ${typeof g}`)}return T&&(O=ci.mod(O,q)),a(O),O}let f=new Map;function l(g){if(!(g instanceof d))throw new Error("ProjectivePoint expected")}class d{constructor(x,N,T){if(this.px=x,this.py=N,this.pz=T,x==null||!r.isValid(x))throw new Error("x required");if(N==null||!r.isValid(N))throw new Error("y required");if(T==null||!r.isValid(T))throw new Error("z required")}static fromAffine(x){let{x:N,y:T}=x||{};if(!x||!r.isValid(N)||!r.isValid(T))throw new Error("invalid affine point");if(x instanceof d)throw new Error("projective point not allowed");let q=O=>r.eql(O,r.ZERO);return q(N)&&q(T)?d.ZERO:new d(N,T,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(x){let N=r.invertBatch(x.map(T=>T.pz));return x.map((T,q)=>T.toAffine(N[q])).map(d.fromAffine)}static fromHex(x){let N=d.fromAffine(i((0,Er.ensureBytes)("pointHex",x)));return N.assertValidity(),N}static fromPrivateKey(x){return d.BASE.multiply(c(x))}_setWindowSize(x){this._WINDOW_SIZE=x,f.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x,y:N}=this.toAffine();if(!r.isValid(x)||!r.isValid(N))throw new Error("bad point: x or y not FE");let T=r.sqr(N),q=s(x);if(!r.eql(T,q))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:x}=this.toAffine();if(r.isOdd)return!r.isOdd(x);throw new Error("Field doesn't support isOdd")}equals(x){l(x);let{px:N,py:T,pz:q}=this,{px:O,py:$,pz:P}=x,k=r.eql(r.mul(N,P),r.mul(O,q)),Z=r.eql(r.mul(T,P),r.mul($,q));return k&&Z}negate(){return new d(this.px,r.neg(this.py),this.pz)}double(){let{a:x,b:N}=e,T=r.mul(N,go),{px:q,py:O,pz:$}=this,P=r.ZERO,k=r.ZERO,Z=r.ZERO,z=r.mul(q,q),K=r.mul(O,O),se=r.mul($,$),te=r.mul(q,O);return te=r.add(te,te),Z=r.mul(q,$),Z=r.add(Z,Z),P=r.mul(x,Z),k=r.mul(T,se),k=r.add(P,k),P=r.sub(K,k),k=r.add(K,k),k=r.mul(P,k),P=r.mul(te,P),Z=r.mul(T,Z),se=r.mul(x,se),te=r.sub(z,se),te=r.mul(x,te),te=r.add(te,Z),Z=r.add(z,z),z=r.add(Z,z),z=r.add(z,se),z=r.mul(z,te),k=r.add(k,z),se=r.mul(O,$),se=r.add(se,se),z=r.mul(se,te),P=r.sub(P,z),Z=r.mul(se,K),Z=r.add(Z,Z),Z=r.add(Z,Z),new d(P,k,Z)}add(x){l(x);let{px:N,py:T,pz:q}=this,{px:O,py:$,pz:P}=x,k=r.ZERO,Z=r.ZERO,z=r.ZERO,K=e.a,se=r.mul(e.b,go),te=r.mul(N,O),de=r.mul(T,$),ue=r.mul(q,P),Te=r.add(N,T),D=r.add(O,$);Te=r.mul(Te,D),D=r.add(te,de),Te=r.sub(Te,D),D=r.add(N,q);let C=r.add(O,P);return D=r.mul(D,C),C=r.add(te,ue),D=r.sub(D,C),C=r.add(T,q),k=r.add($,P),C=r.mul(C,k),k=r.add(de,ue),C=r.sub(C,k),z=r.mul(K,D),k=r.mul(se,ue),z=r.add(k,z),k=r.sub(de,z),z=r.add(de,z),Z=r.mul(k,z),de=r.add(te,te),de=r.add(de,te),ue=r.mul(K,ue),D=r.mul(se,D),de=r.add(de,ue),ue=r.sub(te,ue),ue=r.mul(K,ue),D=r.add(D,ue),te=r.mul(de,D),Z=r.add(Z,te),te=r.mul(C,D),k=r.mul(Te,k),k=r.sub(k,te),te=r.mul(Te,de),z=r.mul(C,z),z=r.add(z,te),new d(k,Z,z)}subtract(x){return this.add(x.negate())}is0(){return this.equals(d.ZERO)}wNAF(x){return w.wNAFCached(this,f,x,N=>{let T=r.invertBatch(N.map(q=>q.pz));return N.map((q,O)=>q.toAffine(T[O])).map(d.fromAffine)})}multiplyUnsafe(x){let N=d.ZERO;if(x===ur)return N;if(a(x),x===Xe)return this;let{endo:T}=e;if(!T)return w.unsafeLadder(this,x);let{k1neg:q,k1:O,k2neg:$,k2:P}=T.splitScalar(x),k=N,Z=N,z=this;for(;O>ur||P>ur;)O&Xe&&(k=k.add(z)),P&Xe&&(Z=Z.add(z)),z=z.double(),O>>=Xe,P>>=Xe;return q&&(k=k.negate()),$&&(Z=Z.negate()),Z=new d(r.mul(Z.px,T.beta),Z.py,Z.pz),k.add(Z)}multiply(x){a(x);let N=x,T,q,{endo:O}=e;if(O){let{k1neg:$,k1:P,k2neg:k,k2:Z}=O.splitScalar(N),{p:z,f:K}=this.wNAF(P),{p:se,f:te}=this.wNAF(Z);z=w.constTimeNegate($,z),se=w.constTimeNegate(k,se),se=new d(r.mul(se.px,O.beta),se.py,se.pz),T=z.add(se),q=K.add(te)}else{let{p:$,f:P}=this.wNAF(N);T=$,q=P}return d.normalizeZ([T,q])[0]}multiplyAndAddUnsafe(x,N,T){let q=d.BASE,O=(P,k)=>k===ur||k===Xe||!P.equals(q)?P.multiplyUnsafe(k):P.multiply(k),$=O(this,N).add(O(x,T));return $.is0()?void 0:$}toAffine(x){let{px:N,py:T,pz:q}=this,O=this.is0();x==null&&(x=O?r.ONE:r.inv(q));let $=r.mul(N,x),P=r.mul(T,x),k=r.mul(q,x);if(O)return{x:r.ZERO,y:r.ZERO};if(!r.eql(k,r.ONE))throw new Error("invZ was invalid");return{x:$,y:P}}isTorsionFree(){let{h:x,isTorsionFree:N}=e;if(x===Xe)return!0;if(N)return N(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:x,clearCofactor:N}=e;return x===Xe?this:N?N(d,this):this.multiplyUnsafe(e.h)}toRawBytes(x=!0){return this.assertValidity(),n(d,this,x)}toHex(x=!0){return De.bytesToHex(this.toRawBytes(x))}}d.BASE=new d(e.Gx,e.Gy,r.ONE),d.ZERO=new d(r.ZERO,r.ONE,r.ZERO);let v=e.nBitLength,w=(0,cu.wNAF)(d,e.endo?Math.ceil(v/2):v);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:o}}ut.weierstrassPoints=t0;function H1(t){let e=(0,cu.validateBasic)(t);return De.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=H1(t),{Fp:r,n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function o(D){return ur<D&&D<r.ORDER}function a(D){return ci.mod(D,n)}function c(D){return ci.invert(D,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:l,weierstrassEquation:d,isWithinCurveOrder:v}=t0({...e,toBytes(D,C,X){let j=C.toAffine(),I=r.toBytes(j.x),W=De.concatBytes;return X?W(Uint8Array.from([C.hasEvenY()?2:3]),I):W(Uint8Array.from([4]),I,r.toBytes(j.y))},fromBytes(D){let C=D.length,X=D[0],j=D.subarray(1);if(C===i&&(X===2||X===3)){let I=De.bytesToNumberBE(j);if(!o(I))throw new Error("Point is not on curve");let W=d(I),L;try{L=r.sqrt(W)}catch(y){let fe=y instanceof Error?": "+y.message:"";throw new Error("Point is not on curve"+fe)}let ie=(L&Xe)===Xe;return(X&1)===1!==ie&&(L=r.neg(L)),{x:I,y:L}}else if(C===s&&X===4){let I=r.fromBytes(j.subarray(0,r.BYTES)),W=r.fromBytes(j.subarray(r.BYTES,2*r.BYTES));return{x:I,y:W}}else throw new Error(`Point of length ${C} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),w=D=>De.bytesToHex(De.numberToBytesBE(D,e.nByteLength));function g(D){let C=n>>Xe;return D>C}function x(D){return g(D)?a(-D):D}let N=(D,C,X)=>De.bytesToNumberBE(D.slice(C,X));class T{constructor(C,X,j){this.r=C,this.s=X,this.recovery=j,this.assertValidity()}static fromCompact(C){let X=e.nByteLength;return C=(0,Er.ensureBytes)("compactSignature",C,X*2),new T(N(C,0,X),N(C,X,2*X))}static fromDER(C){let{r:X,s:j}=ut.DER.toSig((0,Er.ensureBytes)("DER",C));return new T(X,j)}assertValidity(){if(!v(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!v(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(C){return new T(this.r,this.s,C)}recoverPublicKey(C){let{r:X,s:j,recovery:I}=this,W=Z((0,Er.ensureBytes)("msgHash",C));if(I==null||![0,1,2,3].includes(I))throw new Error("recovery id invalid");let L=I===2||I===3?X+e.n:X;if(L>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let ie=I&1?"03":"02",U=f.fromHex(ie+w(L)),y=c(L),fe=a(-W*y),ae=a(j*y),ce=f.BASE.multiplyAndAddUnsafe(U,fe,ae);if(!ce)throw new Error("point at infinify");return ce.assertValidity(),ce}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new T(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return De.hexToBytes(this.toDERHex())}toDERHex(){return ut.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return De.hexToBytes(this.toCompactHex())}toCompactHex(){return w(this.r)+w(this.s)}}let q={isValidPrivateKey(D){try{return l(D),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let D=ci.getMinHashLength(e.n);return ci.mapHashToField(e.randomBytes(D),e.n)},precompute(D=8,C=f.BASE){return C._setWindowSize(D),C.multiply(BigInt(3)),C}};function O(D,C=!0){return f.fromPrivateKey(D).toRawBytes(C)}function $(D){let C=De.isBytes(D),X=typeof D=="string",j=(C||X)&&D.length;return C?j===i||j===s:X?j===2*i||j===2*s:D instanceof f}function P(D,C,X=!0){if($(D))throw new Error("first arg must be private key");if(!$(C))throw new Error("second arg must be public key");return f.fromHex(C).multiply(l(D)).toRawBytes(X)}let k=e.bits2int||function(D){let C=De.bytesToNumberBE(D),X=D.length*8-e.nBitLength;return X>0?C>>BigInt(X):C},Z=e.bits2int_modN||function(D){return a(k(D))},z=De.bitMask(e.nBitLength);function K(D){if(typeof D!="bigint")throw new Error("bigint expected");if(!(ur<=D&&D<z))throw new Error(`bigint expected < 2^${e.nBitLength}`);return De.numberToBytesBE(D,e.nByteLength)}function se(D,C,X=te){if(["recovered","canonical"].some(u=>u in X))throw new Error("sign() legacy options not supported");let{hash:j,randomBytes:I}=e,{lowS:W,prehash:L,extraEntropy:ie}=X;W==null&&(W=!0),D=(0,Er.ensureBytes)("msgHash",D),L&&(D=(0,Er.ensureBytes)("prehashed msgHash",j(D)));let U=Z(D),y=l(C),fe=[K(y),K(U)];if(ie!=null&&ie!==!1){let u=ie===!0?I(r.BYTES):ie;fe.push((0,Er.ensureBytes)("extraEntropy",u))}let ae=De.concatBytes(...fe),ce=U;function ee(u){let h=k(u);if(!v(h))return;let p=c(h),B=f.BASE.multiply(h).toAffine(),E=a(B.x);if(E===ur)return;let S=a(p*a(ce+E*y));if(S===ur)return;let F=(B.x===E?0:2)|Number(B.y&Xe),m=S;return W&&g(S)&&(m=x(S),F^=1),new T(E,m,F)}return{seed:ae,k2sig:ee}}let te={lowS:e.lowS,prehash:!1},de={lowS:e.lowS,prehash:!1};function ue(D,C,X=te){let{seed:j,k2sig:I}=se(D,C,X),W=e;return De.createHmacDrbg(W.hash.outputLen,W.nByteLength,W.hmac)(j,I)}f.BASE._setWindowSize(8);function Te(D,C,X,j=de){let I=D;if(C=(0,Er.ensureBytes)("msgHash",C),X=(0,Er.ensureBytes)("publicKey",X),"strict"in j)throw new Error("options.strict was renamed to lowS");let{lowS:W,prehash:L}=j,ie,U;try{if(typeof I=="string"||De.isBytes(I))try{ie=T.fromDER(I)}catch(B){if(!(B instanceof ut.DER.Err))throw B;ie=T.fromCompact(I)}else if(typeof I=="object"&&typeof I.r=="bigint"&&typeof I.s=="bigint"){let{r:B,s:E}=I;ie=new T(B,E)}else throw new Error("PARSE");U=f.fromHex(X)}catch(B){if(B.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(W&&ie.hasHighS())return!1;L&&(C=e.hash(C));let{r:y,s:fe}=ie,ae=Z(C),ce=c(fe),ee=a(ae*ce),u=a(y*ce),h=f.BASE.multiplyAndAddUnsafe(U,ee,u)?.toAffine();return h?a(h.x)===y:!1}return{CURVE:e,getPublicKey:O,getSharedSecret:P,sign:ue,verify:Te,ProjectivePoint:f,Signature:T,utils:q}}ut.weierstrass=$1;function r0(t,e){let r=t.ORDER,n=ur;for(let g=r-Xe;g%rn===ur;g/=rn)n+=Xe;let i=n,s=rn<<i-Xe-Xe,o=s*rn,a=(r-Xe)/o,c=(a-Xe)/rn,f=o-Xe,l=s,d=t.pow(e,a),v=t.pow(e,(a+Xe)/rn),w=(g,x)=>{let N=d,T=t.pow(x,f),q=t.sqr(T);q=t.mul(q,x);let O=t.mul(g,q);O=t.pow(O,c),O=t.mul(O,T),T=t.mul(O,x),q=t.mul(O,g);let $=t.mul(q,T);O=t.pow($,l);let P=t.eql(O,t.ONE);T=t.mul(q,v),O=t.mul($,N),q=t.cmov(T,q,P),$=t.cmov(O,$,P);for(let k=i;k>Xe;k--){let Z=k-rn;Z=rn<<Z-Xe;let z=t.pow($,Z),K=t.eql(z,t.ONE);T=t.mul(q,N),N=t.mul(N,N),z=t.mul($,N),q=t.cmov(T,q,K),$=t.cmov(z,$,K)}return{isValid:P,value:q}};if(t.ORDER%e0===go){let g=(t.ORDER-go)/e0,x=t.sqrt(t.neg(e));w=(N,T)=>{let q=t.sqr(T),O=t.mul(N,T);q=t.mul(q,O);let $=t.pow(q,g);$=t.mul($,O);let P=t.mul($,x),k=t.mul(t.sqr($),T),Z=t.eql(k,N),z=t.cmov(P,$,Z);return{isValid:Z,value:z}}}return w}ut.SWUFpSqrtRatio=r0;function K1(t,e){if(ci.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=r0(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,a,c,f,l,d;i=t.sqr(n),i=t.mul(i,e.Z),s=t.sqr(i),s=t.add(s,i),o=t.add(s,t.ONE),o=t.mul(o,e.B),a=t.cmov(e.Z,t.neg(s),!t.eql(s,t.ZERO)),a=t.mul(a,e.A),s=t.sqr(o),f=t.sqr(a),c=t.mul(f,e.A),s=t.add(s,c),s=t.mul(s,o),f=t.mul(f,a),c=t.mul(f,e.B),s=t.add(s,c),l=t.mul(i,o);let{isValid:v,value:w}=r(s,f);d=t.mul(i,n),d=t.mul(d,w),l=t.cmov(l,o,v),d=t.cmov(d,w,v);let g=t.isOdd(n)===t.isOdd(d);return d=t.cmov(t.neg(d),d,g),l=t.div(l,a),{x:l,y:d}}}ut.mapToCurveSimpleSWU=K1});var o0=J(_o=>{"use strict";Object.defineProperty(_o,"__esModule",{value:!0});_o.bls=void 0;var n0=Hr(),ki=Qt(),i0=bo(),s0=uu(),fu=BigInt(2),mo=BigInt(3);function G1(t){let{Fp:e,Fr:r,Fp2:n,Fp6:i,Fp12:s}=t.fields,o=(0,ki.bitLen)(t.params.x);function a(C){let{x:X,y:j}=C,I=X,W=j,L=n.ONE,ie=I,U=W,y=L,fe=[];for(let ae=o-2;ae>=0;ae--){let ce=n.sqr(U),ee=n.sqr(y),u=n.multiplyByB(n.mul(ee,mo)),h=n.mul(u,mo),p=n.sub(n.sub(n.sqr(n.add(U,y)),ee),ce);if(fe.push([n.sub(u,ce),n.mul(n.sqr(ie),mo),n.neg(p)]),ie=n.div(n.mul(n.mul(n.sub(ce,h),ie),U),fu),U=n.sub(n.sqr(n.div(n.add(ce,h),fu)),n.mul(n.sqr(u),mo)),y=n.mul(ce,p),(0,ki.bitGet)(t.params.x,ae)){let B=n.sub(U,n.mul(W,y)),E=n.sub(ie,n.mul(I,y));fe.push([n.sub(n.mul(B,I),n.mul(E,W)),n.neg(B),E]);let S=n.sqr(E),F=n.mul(S,E),m=n.mul(S,ie),A=n.add(n.sub(F,n.mul(m,fu)),n.mul(n.sqr(B),y));ie=n.mul(E,A),U=n.sub(n.mul(n.sub(m,A),B),n.mul(F,U)),y=n.mul(y,F)}}return fe}function c(C,X){let{x:j}=t.params,I=X[0],W=X[1],L=s.ONE;for(let ie=0,U=o-2;U>=0;U--,ie++){let y=C[ie];if(L=s.multiplyBy014(L,y[0],n.mul(y[1],I),n.mul(y[2],W)),(0,ki.bitGet)(j,U)){ie+=1;let fe=C[ie];L=s.multiplyBy014(L,fe[0],n.mul(fe[1],I),n.mul(fe[2],W))}U!==0&&(L=s.sqr(L))}return s.conjugate(L)}let f={randomPrivateKey:()=>{let C=(0,n0.getMinHashLength)(r.ORDER);return(0,n0.mapHashToField)(t.randomBytes(C),r.ORDER)},calcPairingPrecomputes:a},l=(0,s0.weierstrassPoints)({n:r.ORDER,...t.G1}),d=Object.assign(l,(0,i0.createHasher)(l.ProjectivePoint,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults}));function v(C){let X=C;return X._PPRECOMPUTES||(X._PPRECOMPUTES=a(C.toAffine())),X._PPRECOMPUTES}let w=(0,s0.weierstrassPoints)({n:r.ORDER,...t.G2}),g=Object.assign(w,(0,i0.createHasher)(w.ProjectivePoint,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),{ShortSignature:x}=t.G1,{Signature:N}=t.G2;function T(C,X,j=!0){if(C.equals(d.ProjectivePoint.ZERO)||X.equals(g.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");C.assertValidity(),X.assertValidity();let I=C.toAffine(),W=c(v(X),[I.x,I.y]);return j?s.finalExponentiate(W):W}function q(C){return C instanceof d.ProjectivePoint?C:d.ProjectivePoint.fromHex(C)}function O(C,X){return C instanceof d.ProjectivePoint?C:d.hashToCurve((0,ki.ensureBytes)("point",C),X)}function $(C){return C instanceof g.ProjectivePoint?C:N.fromHex(C)}function P(C,X){return C instanceof g.ProjectivePoint?C:g.hashToCurve((0,ki.ensureBytes)("point",C),X)}function k(C){return d.ProjectivePoint.fromPrivateKey(C).toRawBytes(!0)}function Z(C){return g.ProjectivePoint.fromPrivateKey(C).toRawBytes(!0)}function z(C,X,j){let I=P(C,j);I.assertValidity();let W=I.multiply(d.normPrivateKeyToScalar(X));return C instanceof g.ProjectivePoint?W:N.toRawBytes(W)}function K(C,X,j){let I=O(C,j);I.assertValidity();let W=I.multiply(d.normPrivateKeyToScalar(X));return C instanceof d.ProjectivePoint?W:x.toRawBytes(W)}function se(C,X,j,I){let W=q(j),L=P(X,I),ie=d.ProjectivePoint.BASE,U=$(C),y=T(W.negate(),L,!1),fe=T(ie,U,!1),ae=s.finalExponentiate(s.mul(fe,y));return s.eql(ae,s.ONE)}function te(C,X,j,I){let W=$(j),L=O(X,I),ie=g.ProjectivePoint.BASE,U=q(C),y=T(L,W,!1),fe=T(U,ie.negate(),!1),ae=s.finalExponentiate(s.mul(fe,y));return s.eql(ae,s.ONE)}function de(C){if(!C.length)throw new Error("Expected non-empty array");let j=C.map(q).reduce((I,W)=>I.add(W),d.ProjectivePoint.ZERO);return C[0]instanceof d.ProjectivePoint?(j.assertValidity(),j):j.toRawBytes(!0)}function ue(C){if(!C.length)throw new Error("Expected non-empty array");let j=C.map($).reduce((I,W)=>I.add(W),g.ProjectivePoint.ZERO);return C[0]instanceof g.ProjectivePoint?(j.assertValidity(),j):N.toRawBytes(j)}function Te(C){if(!C.length)throw new Error("Expected non-empty array");let j=C.map(q).reduce((I,W)=>I.add(W),d.ProjectivePoint.ZERO);return C[0]instanceof d.ProjectivePoint?(j.assertValidity(),j):x.toRawBytes(j)}function D(C,X,j,I){if(!X.length)throw new Error("Expected non-empty messages array");if(j.length!==X.length)throw new Error("Pubkey count should equal msg count");let W=$(C),L=X.map(U=>P(U,I)),ie=j.map(q);try{let U=[];for(let ae of new Set(L)){let ce=L.reduce((ee,u,h)=>u===ae?ee.add(ie[h]):ee,d.ProjectivePoint.ZERO);U.push(T(ce,ae,!1))}U.push(T(d.ProjectivePoint.BASE.negate(),W,!1));let y=U.reduce((ae,ce)=>s.mul(ae,ce),s.ONE),fe=s.finalExponentiate(y);return s.eql(fe,s.ONE)}catch{return!1}}return d.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:k,getPublicKeyForShortSignatures:Z,sign:z,signShortSignature:K,verify:se,verifyBatch:D,verifyShortSignature:te,aggregatePublicKeys:de,aggregateSignatures:ue,aggregateShortSignatures:Te,millerLoop:c,pairing:T,G1:d,G2:g,Signature:N,ShortSignature:x,fields:{Fr:r,Fp:e,Fp2:n,Fp6:i,Fp12:s},params:{x:t.params.x,r:t.params.r,G1b:t.G1.b,G2b:t.G2.b},utils:f}}_o.bls=G1});var N0=J(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.bls12_381=void 0;var v0=ms(),Y1=xn(),W1=o0(),sn=Hr(),_e=Qt(),B0=uu(),T0=bo(),it=BigInt(0),An=BigInt(1),Je=BigInt(2),wo=BigInt(3),Vi=BigInt(4),z1=BigInt(8),D1=BigInt(16),hu=BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),G=sn.Field(hu),a0=sn.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),c0=({c0:t,c1:e},{c0:r,c1:n})=>({c0:G.add(t,r),c1:G.add(e,n)}),u0=({c0:t,c1:e},{c0:r,c1:n})=>({c0:G.sub(t,r),c1:G.sub(e,n)}),f0=({c0:t,c1:e},r)=>{if(typeof r=="bigint")return{c0:G.mul(t,r),c1:G.mul(e,r)};let{c0:n,c1:i}=r,s=G.mul(t,n),o=G.mul(e,i),a=G.sub(s,o),c=G.sub(G.mul(G.add(t,e),G.add(n,i)),G.add(s,o));return{c0:a,c1:c}},l0=({c0:t,c1:e})=>{let r=G.add(t,e),n=G.sub(t,e),i=G.add(t,t);return{c0:G.mul(r,n),c1:G.mul(i,e)}},xo=hu*hu,b={ORDER:xo,BITS:(0,_e.bitLen)(xo),BYTES:Math.ceil((0,_e.bitLen)(xo)/8),MASK:(0,_e.bitMask)((0,_e.bitLen)(xo)),ZERO:{c0:G.ZERO,c1:G.ZERO},ONE:{c0:G.ONE,c1:G.ZERO},create:t=>t,isValid:({c0:t,c1:e})=>typeof t=="bigint"&&typeof e=="bigint",is0:({c0:t,c1:e})=>G.is0(t)&&G.is0(e),eql:({c0:t,c1:e},{c0:r,c1:n})=>G.eql(t,r)&&G.eql(e,n),neg:({c0:t,c1:e})=>({c0:G.neg(t),c1:G.neg(e)}),pow:(t,e)=>sn.FpPow(b,t,e),invertBatch:t=>sn.FpInvertBatch(b,t),add:c0,sub:u0,mul:f0,sqr:l0,addN:c0,subN:u0,mulN:f0,sqrN:l0,div:(t,e)=>b.mul(t,typeof e=="bigint"?G.inv(G.create(e)):b.inv(e)),inv:({c0:t,c1:e})=>{let r=G.inv(G.create(t*t+e*e));return{c0:G.mul(r,G.create(t)),c1:G.mul(r,G.create(-e))}},sqrt:t=>{if(b.eql(t,b.ZERO))return b.ZERO;let e=b.pow(t,(b.ORDER+z1)/D1),r=b.div(b.sqr(e),t),n=X1,i=[n[0],n[2],n[4],n[6]].find(w=>b.eql(w,r));if(!i)throw new Error("No root");let s=n.indexOf(i),o=n[s/2];if(!o)throw new Error("Invalid root");let a=b.div(e,o),c=b.neg(a),{re:f,im:l}=b.reim(a),{re:d,im:v}=b.reim(c);return l>v||l===v&&f>d?a:c},isOdd:t=>{let{re:e,im:r}=b.reim(t),n=e%Je,i=e===it,s=r%Je;return BigInt(n||i&&s)==An},fromBytes(t){if(t.length!==b.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:G.fromBytes(t.subarray(0,G.BYTES)),c1:G.fromBytes(t.subarray(G.BYTES))}},toBytes:({c0:t,c1:e})=>(0,_e.concatBytes)(G.toBytes(t),G.toBytes(e)),cmov:({c0:t,c1:e},{c0:r,c1:n},i)=>({c0:G.cmov(t,r,i),c1:G.cmov(e,n,i)}),reim:({c0:t,c1:e})=>({re:t,im:e}),mulByNonresidue:({c0:t,c1:e})=>({c0:G.sub(t,e),c1:G.add(t,e)}),multiplyByB:({c0:t,c1:e})=>{let r=G.mul(t,Vi),n=G.mul(e,Vi);return{c0:G.sub(r,n),c1:G.add(r,n)}},fromBigTuple:t=>{if(t.length!==2)throw new Error("Invalid tuple");let e=t.map(r=>G.create(r));return{c0:e[0],c1:e[1]}},frobeniusMap:({c0:t,c1:e},r)=>({c0:t,c1:G.mul(e,Z1[r%2])})},Z1=[BigInt("0x1"),BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa")].map(t=>G.create(t)),nn=BigInt("0x6af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09"),X1=[[An,it],[nn,-nn],[it,An],[nn,nn],[-An,it],[-nn,nn],[it,-An],[-nn,-nn]].map(t=>b.fromBigTuple(t)),d0=({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s})=>({c0:b.add(t,n),c1:b.add(e,i),c2:b.add(r,s)}),h0=({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s})=>({c0:b.sub(t,n),c1:b.sub(e,i),c2:b.sub(r,s)}),p0=({c0:t,c1:e,c2:r},n)=>{if(typeof n=="bigint")return{c0:b.mul(t,n),c1:b.mul(e,n),c2:b.mul(r,n)};let{c0:i,c1:s,c2:o}=n,a=b.mul(t,i),c=b.mul(e,s),f=b.mul(r,o);return{c0:b.add(a,b.mulByNonresidue(b.sub(b.mul(b.add(e,r),b.add(s,o)),b.add(c,f)))),c1:b.add(b.sub(b.mul(b.add(t,e),b.add(i,s)),b.add(a,c)),b.mulByNonresidue(f)),c2:b.sub(b.add(c,b.mul(b.add(t,r),b.add(i,o))),b.add(a,f))}},y0=({c0:t,c1:e,c2:r})=>{let n=b.sqr(t),i=b.mul(b.mul(t,e),Je),s=b.mul(b.mul(e,r),Je),o=b.sqr(r);return{c0:b.add(b.mulByNonresidue(s),n),c1:b.add(b.mulByNonresidue(o),i),c2:b.sub(b.sub(b.add(b.add(i,b.sqr(b.add(b.sub(t,e),r))),s),n),o)}},re={ORDER:b.ORDER,BITS:3*b.BITS,BYTES:3*b.BYTES,MASK:(0,_e.bitMask)(3*b.BITS),ZERO:{c0:b.ZERO,c1:b.ZERO,c2:b.ZERO},ONE:{c0:b.ONE,c1:b.ZERO,c2:b.ZERO},create:t=>t,isValid:({c0:t,c1:e,c2:r})=>b.isValid(t)&&b.isValid(e)&&b.isValid(r),is0:({c0:t,c1:e,c2:r})=>b.is0(t)&&b.is0(e)&&b.is0(r),neg:({c0:t,c1:e,c2:r})=>({c0:b.neg(t),c1:b.neg(e),c2:b.neg(r)}),eql:({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s})=>b.eql(t,n)&&b.eql(e,i)&&b.eql(r,s),sqrt:()=>{throw new Error("Not implemented")},div:(t,e)=>re.mul(t,typeof e=="bigint"?G.inv(G.create(e)):re.inv(e)),pow:(t,e)=>sn.FpPow(re,t,e),invertBatch:t=>sn.FpInvertBatch(re,t),add:d0,sub:h0,mul:p0,sqr:y0,addN:d0,subN:h0,mulN:p0,sqrN:y0,inv:({c0:t,c1:e,c2:r})=>{let n=b.sub(b.sqr(t),b.mulByNonresidue(b.mul(r,e))),i=b.sub(b.mulByNonresidue(b.sqr(r)),b.mul(t,e)),s=b.sub(b.sqr(e),b.mul(t,r)),o=b.inv(b.add(b.mulByNonresidue(b.add(b.mul(r,i),b.mul(e,s))),b.mul(t,n)));return{c0:b.mul(o,n),c1:b.mul(o,i),c2:b.mul(o,s)}},fromBytes:t=>{if(t.length!==re.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:b.fromBytes(t.subarray(0,b.BYTES)),c1:b.fromBytes(t.subarray(b.BYTES,2*b.BYTES)),c2:b.fromBytes(t.subarray(2*b.BYTES))}},toBytes:({c0:t,c1:e,c2:r})=>(0,_e.concatBytes)(b.toBytes(t),b.toBytes(e),b.toBytes(r)),cmov:({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s},o)=>({c0:b.cmov(t,n,o),c1:b.cmov(e,i,o),c2:b.cmov(r,s,o)}),fromBigSix:t=>{if(!Array.isArray(t)||t.length!==6)throw new Error("Invalid Fp6 usage");return{c0:b.fromBigTuple(t.slice(0,2)),c1:b.fromBigTuple(t.slice(2,4)),c2:b.fromBigTuple(t.slice(4,6))}},frobeniusMap:({c0:t,c1:e,c2:r},n)=>({c0:b.frobeniusMap(t,n),c1:b.mul(b.frobeniusMap(e,n),J1[n%6]),c2:b.mul(b.frobeniusMap(r,n),L1[n%6])}),mulByNonresidue:({c0:t,c1:e,c2:r})=>({c0:b.mulByNonresidue(r),c1:t,c2:e}),multiplyBy1:({c0:t,c1:e,c2:r},n)=>({c0:b.mulByNonresidue(b.mul(r,n)),c1:b.mul(t,n),c2:b.mul(e,n)}),multiplyBy01({c0:t,c1:e,c2:r},n,i){let s=b.mul(t,n),o=b.mul(e,i);return{c0:b.add(b.mulByNonresidue(b.sub(b.mul(b.add(e,r),i),o)),s),c1:b.sub(b.sub(b.mul(b.add(n,i),b.add(t,e)),s),o),c2:b.add(b.sub(b.mul(b.add(t,r),n),s),o)}},multiplyByFp2:({c0:t,c1:e,c2:r},n)=>({c0:b.mul(t,n),c1:b.mul(e,n),c2:b.mul(r,n)})},J1=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x1")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe")]].map(t=>b.fromBigTuple(t)),L1=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad"),BigInt("0x0")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa"),BigInt("0x0")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff"),BigInt("0x0")]].map(t=>b.fromBigTuple(t)),pu=BigInt("0xd201000000010000"),Q1=(0,_e.bitLen)(pu),b0=({c0:t,c1:e},{c0:r,c1:n})=>({c0:re.add(t,r),c1:re.add(e,n)}),g0=({c0:t,c1:e},{c0:r,c1:n})=>({c0:re.sub(t,r),c1:re.sub(e,n)}),m0=({c0:t,c1:e},r)=>{if(typeof r=="bigint")return{c0:re.mul(t,r),c1:re.mul(e,r)};let{c0:n,c1:i}=r,s=re.mul(t,n),o=re.mul(e,i);return{c0:re.add(s,re.mulByNonresidue(o)),c1:re.sub(re.mul(re.add(t,e),re.add(n,i)),re.add(s,o))}},_0=({c0:t,c1:e})=>{let r=re.mul(t,e);return{c0:re.sub(re.sub(re.mul(re.add(re.mulByNonresidue(e),t),re.add(t,e)),r),re.mulByNonresidue(r)),c1:re.add(r,r)}};function lu(t,e){let r=b.sqr(t),n=b.sqr(e);return{first:b.add(b.mulByNonresidue(n),r),second:b.sub(b.sub(b.sqr(b.add(t,e)),r),n)}}var ye={ORDER:b.ORDER,BITS:2*b.BITS,BYTES:2*b.BYTES,MASK:(0,_e.bitMask)(2*b.BITS),ZERO:{c0:re.ZERO,c1:re.ZERO},ONE:{c0:re.ONE,c1:re.ZERO},create:t=>t,isValid:({c0:t,c1:e})=>re.isValid(t)&&re.isValid(e),is0:({c0:t,c1:e})=>re.is0(t)&&re.is0(e),neg:({c0:t,c1:e})=>({c0:re.neg(t),c1:re.neg(e)}),eql:({c0:t,c1:e},{c0:r,c1:n})=>re.eql(t,r)&&re.eql(e,n),sqrt:()=>{throw new Error("Not implemented")},inv:({c0:t,c1:e})=>{let r=re.inv(re.sub(re.sqr(t),re.mulByNonresidue(re.sqr(e))));return{c0:re.mul(t,r),c1:re.neg(re.mul(e,r))}},div:(t,e)=>ye.mul(t,typeof e=="bigint"?G.inv(G.create(e)):ye.inv(e)),pow:(t,e)=>sn.FpPow(ye,t,e),invertBatch:t=>sn.FpInvertBatch(ye,t),add:b0,sub:g0,mul:m0,sqr:_0,addN:b0,subN:g0,mulN:m0,sqrN:_0,fromBytes:t=>{if(t.length!==ye.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:re.fromBytes(t.subarray(0,re.BYTES)),c1:re.fromBytes(t.subarray(re.BYTES))}},toBytes:({c0:t,c1:e})=>(0,_e.concatBytes)(re.toBytes(t),re.toBytes(e)),cmov:({c0:t,c1:e},{c0:r,c1:n},i)=>({c0:re.cmov(t,r,i),c1:re.cmov(e,n,i)}),fromBigTwelve:t=>({c0:re.fromBigSix(t.slice(0,6)),c1:re.fromBigSix(t.slice(6,12))}),frobeniusMap(t,e){let r=re.frobeniusMap(t.c0,e),{c0:n,c1:i,c2:s}=re.frobeniusMap(t.c1,e),o=e_[e%12];return{c0:r,c1:re.create({c0:b.mul(n,o),c1:b.mul(i,o),c2:b.mul(s,o)})}},multiplyBy014:({c0:t,c1:e},r,n,i)=>{let s=re.multiplyBy01(t,r,n),o=re.multiplyBy1(e,i);return{c0:re.add(re.mulByNonresidue(o),s),c1:re.sub(re.sub(re.multiplyBy01(re.add(e,t),r,b.add(n,i)),s),o)}},multiplyByFp2:({c0:t,c1:e},r)=>({c0:re.multiplyByFp2(t,r),c1:re.multiplyByFp2(e,r)}),conjugate:({c0:t,c1:e})=>({c0:t,c1:re.neg(e)}),_cyclotomicSquare:({c0:t,c1:e})=>{let{c0:r,c1:n,c2:i}=t,{c0:s,c1:o,c2:a}=e,{first:c,second:f}=lu(r,o),{first:l,second:d}=lu(s,i),{first:v,second:w}=lu(n,a),g=b.mulByNonresidue(w);return{c0:re.create({c0:b.add(b.mul(b.sub(c,r),Je),c),c1:b.add(b.mul(b.sub(l,n),Je),l),c2:b.add(b.mul(b.sub(v,i),Je),v)}),c1:re.create({c0:b.add(b.mul(b.add(g,s),Je),g),c1:b.add(b.mul(b.add(f,o),Je),f),c2:b.add(b.mul(b.add(d,a),Je),d)})}},_cyclotomicExp(t,e){let r=ye.ONE;for(let n=Q1-1;n>=0;n--)r=ye._cyclotomicSquare(r),(0,_e.bitGet)(e,n)&&(r=ye.mul(r,t));return r},finalExponentiate:t=>{let e=pu,r=ye.div(ye.frobeniusMap(t,6),t),n=ye.mul(ye.frobeniusMap(r,2),r),i=ye.conjugate(ye._cyclotomicExp(n,e)),s=ye.mul(ye.conjugate(ye._cyclotomicSquare(n)),i),o=ye.conjugate(ye._cyclotomicExp(s,e)),a=ye.conjugate(ye._cyclotomicExp(o,e)),c=ye.mul(ye.conjugate(ye._cyclotomicExp(a,e)),ye._cyclotomicSquare(i)),f=ye.conjugate(ye._cyclotomicExp(c,e)),l=ye.frobeniusMap(ye.mul(i,a),2),d=ye.frobeniusMap(ye.mul(o,n),3),v=ye.frobeniusMap(ye.mul(c,ye.conjugate(n)),1),w=ye.mul(ye.mul(f,ye.conjugate(s)),n);return ye.mul(ye.mul(ye.mul(l,d),v),w)}},e_=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8"),BigInt("0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff"),BigInt("0x0")],[BigInt("0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2"),BigInt("0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995"),BigInt("0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116")],[BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa"),BigInt("0x0")],[BigInt("0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3"),BigInt("0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09"),BigInt("0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad"),BigInt("0x0")],[BigInt("0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116"),BigInt("0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995")]].map(t=>b.fromBigTuple(t)),t_=(0,T0.isogenyMap)(b,[[["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=>b.fromBigTuple(e.map(BigInt))))),r_=(0,T0.isogenyMap)(G,[["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)))),n_=(0,B0.mapToCurveSimpleSWU)(b,{A:b.create({c0:G.create(it),c1:G.create(BigInt(240))}),B:b.create({c0:G.create(BigInt(1012)),c1:G.create(BigInt(1012))}),Z:b.create({c0:G.create(BigInt(-2)),c1:G.create(BigInt(-1))})}),i_=(0,B0.mapToCurveSimpleSWU)(G,{A:G.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:G.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:G.create(BigInt(11))}),S0=re.create({c0:b.ZERO,c1:b.ONE,c2:b.ZERO}),A0=ye.create({c0:S0,c1:re.ZERO}),O0=ye.create({c0:re.ZERO,c1:S0}),[s_,o_]=ye.invertBatch([A0,O0]);function a_(t,e){let r=ye.mul(ye.frobeniusMap(ye.multiplyByFp2(s_,t),1),A0).c0.c0,n=ye.mul(ye.frobeniusMap(ye.multiplyByFp2(o_,e),1),O0).c0.c0;return[r,n]}function w0(t,e){let r=e.toAffine(),n=a_(r.x,r.y);return new t(n[0],n[1],b.ONE)}var c_=BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac");function u_(t,e){return[b.mul(t,c_),b.neg(e)]}function f_(t,e){let r=e.toAffine(),n=u_(r.x,r.y);return new t(n[0],n[1],b.ONE)}var du=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:G.ORDER,m:2,k:128,expand:"xmd",hash:v0.sha256}),vo=Hi(G.toBytes(it),{infinity:!0,compressed:!0});function Eo(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 Hi(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 x0(t){t.assertValidity();let e=t.equals(nt.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=t.toAffine();if(e)return vo.slice();let i=G.ORDER,s=!!(n*Je/i);return Hi((0,_e.numberToBytesBE)(r,G.BYTES),{compressed:!0,sort:s})}function E0(t){t.assertValidity();let e=G.BYTES;if(t.equals(nt.bls12_381.G2.ProjectivePoint.ZERO))return(0,_e.concatBytes)(vo,(0,_e.numberToBytesBE)(it,e));let{x:r,y:n}=t.toAffine(),{re:i,im:s}=b.reim(r),{re:o,im:a}=b.reim(n),f=!!((a>it?a*Je:o*Je)/G.ORDER&An),l=i;return(0,_e.concatBytes)(Hi((0,_e.numberToBytesBE)(s,e),{sort:f,compressed:!0}),(0,_e.numberToBytesBE)(l,e))}nt.bls12_381=(0,W1.bls)({fields:{Fp:G,Fp2:b,Fp6:re,Fp12:ye,Fr:a0},G1:{Fp:G,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:G.ZERO,b:Vi,htfDefaults:{...du,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(G.mul(e.px,r),e.py,e.pz);return e.multiplyUnsafe(nt.bls12_381.params.x).negate().multiplyUnsafe(nt.bls12_381.params.x).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(nt.bls12_381.params.x).add(e),mapToCurve:t=>{let{x:e,y:r}=i_(G.create(t[0]));return r_(e,r)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=Eo(t);if(i.length===48&&e){let s=G.ORDER,o=(0,_e.bytesToNumberBE)(i),a=G.create(o&G.MASK);if(r){if(a!==it)throw new Error("G1: non-empty compressed point at infinity");return{x:it,y:it}}let c=G.add(G.pow(a,wo),G.create(nt.bls12_381.params.G1b)),f=G.sqrt(c);if(!f)throw new Error("Invalid compressed G1 point");return f*Je/s!==BigInt(n)&&(f=G.neg(f)),{x:G.create(a),y:G.create(f)}}else if(i.length===96&&!e){let s=(0,_e.bytesToNumberBE)(i.subarray(0,G.BYTES)),o=(0,_e.bytesToNumberBE)(i.subarray(G.BYTES));if(r){if(s!==it||o!==it)throw new Error("G1: non-empty point at infinity");return nt.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:G.create(s),y:G.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 vo.slice();let o=G.ORDER,a=!!(s*Je/o);return Hi((0,_e.numberToBytesBE)(i,G.BYTES),{compressed:!0,sort:a})}else return n?(0,_e.concatBytes)(new Uint8Array([64]),new Uint8Array(2*G.BYTES-1)):(0,_e.concatBytes)((0,_e.numberToBytesBE)(i,G.BYTES),(0,_e.numberToBytesBE)(s,G.BYTES))},ShortSignature:{fromHex(t){let{infinity:e,sort:r,value:n}=Eo((0,_e.ensureBytes)("signatureHex",t,48)),i=G.ORDER,s=(0,_e.bytesToNumberBE)(n);if(e)return nt.bls12_381.G1.ProjectivePoint.ZERO;let o=G.create(s&G.MASK),a=G.add(G.pow(o,wo),G.create(nt.bls12_381.params.G1b)),c=G.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let f=BigInt(r);c*Je/i!==f&&(c=G.neg(c));let l=nt.bls12_381.G1.ProjectivePoint.fromAffine({x:o,y:c});return l.assertValidity(),l},toRawBytes(t){return x0(t)},toHex(t){return(0,_e.bytesToHex)(x0(t))}}},G2:{Fp:b,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:b.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:b.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:b.ZERO,b:b.fromBigTuple([Vi,Vi]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...du},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:t=>{let{x:e,y:r}=n_(b.fromBigTuple(t));return t_(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(nt.bls12_381.params.x).negate().equals(w0(t,e)),clearCofactor:(t,e)=>{let r=nt.bls12_381.params.x,n=e.multiplyUnsafe(r).negate(),i=w0(t,e),s=e.double();return s=f_(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}=Eo(t);if(!e&&!r&&n||!e&&r&&n||n&&r&&e)throw new Error("Invalid encoding flag: "+(t[0]&224));let s=G.BYTES,o=(a,c,f)=>(0,_e.bytesToNumberBE)(a.slice(c,f));if(i.length===96&&e){let a=nt.bls12_381.params.G2b,c=G.ORDER;if(r){if(i.reduce((x,N)=>x!==0?N+1:N,0)>0)throw new Error("Invalid compressed G2 point");return{x:b.ZERO,y:b.ZERO}}let f=o(i,0,s),l=o(i,s,2*s),d=b.create({c0:G.create(l),c1:G.create(f)}),v=b.add(b.pow(d,wo),a),w=b.sqrt(v),g=w.c1===it?w.c0*Je/c:w.c1*Je/c?An:it;return w=n&&g>0?w:b.neg(w),{x:d,y:w}}else if(i.length===192&&!e){if(r){if(i.reduce((d,v)=>d!==0?v+1:v,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:b.ZERO,y:b.ZERO}}let a=o(i,0,s),c=o(i,s,2*s),f=o(i,2*s,3*s),l=o(i,3*s,4*s);return{x:b.fromBigTuple([c,a]),y:b.fromBigTuple([l,f])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(t,e,r)=>{let{BYTES:n,ORDER:i}=G,s=e.equals(t.ZERO),{x:o,y:a}=e.toAffine();if(r){if(s)return(0,_e.concatBytes)(vo,(0,_e.numberToBytesBE)(it,n));let c=!!(a.c1===it?a.c0*Je/i:a.c1*Je/i);return(0,_e.concatBytes)(Hi((0,_e.numberToBytesBE)(o.c1,n),{compressed:!0,sort:c}),(0,_e.numberToBytesBE)(o.c0,n))}else{if(s)return(0,_e.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:f}=b.reim(o),{re:l,im:d}=b.reim(a);return(0,_e.concatBytes)((0,_e.numberToBytesBE)(f,n),(0,_e.numberToBytesBE)(c,n),(0,_e.numberToBytesBE)(d,n),(0,_e.numberToBytesBE)(l,n))}},Signature:{fromHex(t){let{infinity:e,sort:r,value:n}=Eo((0,_e.ensureBytes)("signatureHex",t)),i=G.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,_e.bytesToNumberBE)(n.slice(0,s)),a=(0,_e.bytesToNumberBE)(n.slice(s));if(e)return nt.bls12_381.G2.ProjectivePoint.ZERO;let c=G.create(o&G.MASK),f=G.create(a),l=b.create({c0:f,c1:c}),d=b.add(b.pow(l,wo),nt.bls12_381.params.G2b),v=b.sqrt(d);if(!v)throw new Error("Failed to find a square root");let{re:w,im:g}=b.reim(v),x=BigInt(r),N=g>it&&g*Je/i!==x,T=g===it&&w*Je/i!==x;(N||T)&&(v=b.neg(v));let q=nt.bls12_381.G2.ProjectivePoint.fromAffine({x:l,y:v});return q.assertValidity(),q},toRawBytes(t){return E0(t)},toHex(t){return(0,_e.bytesToHex)(E0(t))}}},params:{x:pu,r:a0.ORDER},htfDefaults:du,hash:v0.sha256,randomBytes:Y1.randomBytes})});var bu=J($i=>{"use strict";Object.defineProperty($i,"__esModule",{value:!0});$i.blsVerify=$i.verify=void 0;var l_=N0(),yu=Kt();function d_(t,e,r){let n=typeof t=="string"?t:(0,yu.toHex)(t),i=typeof e=="string"?e:(0,yu.toHex)(e),s=typeof r=="string"?r:(0,yu.toHex)(r);return l_.bls12_381.verifyShortSignature(i,s,n)}$i.blsVerify=d_});var Bo=J(On=>{"use strict";Object.defineProperty(On,"__esModule",{value:!0});On.decodeTime=On.decodeLeb128=void 0;var P0=ni(),h_=t=>(0,P0.lebDecode)(new P0.PipeArrayBuffer(t));On.decodeLeb128=h_;var p_=t=>{let e=(0,On.decodeLeb128)(t);return new Date(Number(e)/1e6)};On.decodeTime=p_});var Wi=J($e=>{"use strict";var y_=$e&&$e.__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]}),b_=$e&&$e.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),R0=$e&&$e.__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 b_(e,t),e};Object.defineProperty($e,"__esModule",{value:!0});$e.check_canister_ranges=$e.flatten_forks=$e.lookup_path=$e.reconstruct=$e.lookupResultToBuffer=$e.Certificate=$e.hashTreeToString=$e.NodeId=$e.CertificateVerificationError=void 0;var I0=R0(qi()),g_=Xn(),To=Fi(),Kr=Kt(),gu=Ct(),m_=R0(bu()),__=Bo(),$r=class extends g_.AgentError{constructor(e){super(`Invalid certificate: ${e}`)}};$e.CertificateVerificationError=$r;var At={Empty:0,Fork:1,Labeled:2,Leaf:3,Pruned:4};$e.NodeId=At;function So(t){let e=n=>n.split(`
|
|
17
17
|
`).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 At.Empty:return"()";case At.Fork:if(t[1]instanceof Array&&t[2]instanceof ArrayBuffer){let n=
|
|
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 At.Empty:return"()";case At.Fork:if(t[1]instanceof Array&&t[2]instanceof ArrayBuffer){let n=So(t[1]),i=So(t[2]);return`sub(
|
|
19
19
|
left:
|
|
20
20
|
${e(n)}
|
|
21
21
|
---
|
|
22
22
|
right:
|
|
23
23
|
${e(i)}
|
|
24
|
-
)`}else throw new Error("Invalid tree structure for fork");case At.Labeled:if(t[1]instanceof ArrayBuffer&&t[2]instanceof ArrayBuffer){let n=r(t[1]),i=
|
|
24
|
+
)`}else throw new Error("Invalid tree structure for fork");case At.Labeled:if(t[1]instanceof ArrayBuffer&&t[2]instanceof ArrayBuffer){let n=r(t[1]),i=So(t[2]);return`label(
|
|
25
25
|
label:
|
|
26
26
|
${e(n)}
|
|
27
27
|
sub:
|
|
28
28
|
${e(i)}
|
|
29
|
-
)`}else throw new Error("Invalid tree structure for labeled");case At.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 At.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,qr.toHex)(new Uint8Array(t[1]))}`}default:return`unknown(${JSON.stringify(t[0])})`}}He.hashTreeToString=bo;function b0(t,e){if(t.byteLength!==e.byteLength)return!1;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return!1;return!0}var tu=class t{constructor(e,r,n,i,s=5){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,this.cert=y0.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=Zm.blsVerify),new t(e.certificate,e.rootKey,e.canisterId,r,e.maxAgeInMinutes)}lookup(e){return g0(mo(e,this.cert.tree))}lookup_label(e){return this.lookup([e])}async verify(){let e=await Mi(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=Lm(r),s=(0,qr.concat)(Fi("ic-state-root"),e),o=!1,a=this.lookup(["time"]);if(!a)throw new Cr("Certificate does not contain a time");let c=5*60*1e3,l=this._maxAgeInMinutes*60*1e3,f=Date.now(),d=f-l,v=f+c,m=(0,Xm.decodeTime)(a);if(m.getTime()<d)throw new Cr(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+m.toISOString()+" Current time: "+new Date(f).toISOString());if(m.getTime()>v)throw new Cr("Certificate is signed more than 5 minutes in the future. Certificate time: "+m.toISOString()+" Current time: "+new Date(f).toISOString());try{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)throw new Cr("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 Cr("Delegation certificates cannot be nested");if(await r.verify(),!m0({canisterId:this._canisterId,subnetId:eu.Principal.fromUint8Array(new Uint8Array(e.subnet_id)),tree:r.cert.tree}))throw new Cr(`Canister ${this._canisterId} not in range of delegations for subnet 0x${(0,qr.toHex)(e.subnet_id)}`);let i=r.lookup(["subnet",e.subnet_id,"public_key"]);if(!i)throw new Error(`Could not find subnet key for subnet 0x${(0,qr.toHex)(e.subnet_id)}`);return i}};He.Certificate=tu;var Ui=(0,qr.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Jm=96;function Lm(t){let e=Ui.byteLength+Jm;if(t.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let r=t.slice(0,Ui.byteLength);if(!b0(r,Ui))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${Ui}, but get ${r}`);return t.slice(Ui.byteLength)}function g0(t){if(t instanceof ArrayBuffer)return t;if(t instanceof Uint8Array)return t.buffer}He.lookupResultToBuffer=g0;async function Mi(t){switch(t[0]){case At.Empty:return(0,yo.hash)(Fi("ic-hashtree-empty"));case At.Pruned:return t[1];case At.Leaf:return(0,yo.hash)((0,qr.concat)(Fi("ic-hashtree-leaf"),t[1]));case At.Labeled:return(0,yo.hash)((0,qr.concat)(Fi("ic-hashtree-labeled"),t[1],await Mi(t[2])));case At.Fork:return(0,yo.hash)((0,qr.concat)(Fi("ic-hashtree-fork"),await Mi(t[1]),await Mi(t[2])));default:throw new Error("unreachable")}}He.reconstruct=Mi;function Fi(t){let e=new Uint8Array([t.length]),r=new TextEncoder().encode(t);return(0,qr.concat)(e,r)}function mo(t,e){if(t.length===0)switch(e[0]){case At.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?e[1]:e[1]instanceof Uint8Array?e[1].buffer:e[1]}case At.Fork:return e;default:return e}let r=typeof t[0]=="string"?new TextEncoder().encode(t[0]):t[0],n=Qm(r,go(e));if(n)return mo(t.slice(1),n)}He.lookup_path=mo;function go(t){switch(t[0]){case At.Empty:return[];case At.Fork:return go(t[1]).concat(go(t[2]));default:return[t]}}He.flatten_forks=go;function Qm(t,e){if(e.length!==0){for(let r of e)if(r[0]===At.Labeled){let n=r[1];if(b0(t,n))return r[2]}}}function m0(t){let{canisterId:e,subnetId:r,tree:n}=t,i=mo(["subnet",r.toUint8Array(),"canister_ranges"],n);if(!i||!(i instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return y0.decode(i).map(c=>[eu.Principal.fromUint8Array(c[0]),eu.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(e)&&c[1].gtEq(e))}He.check_canister_ranges=m0});var qi=L(lt=>{"use strict";var e_=lt&<.__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]}),t_=lt&<.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r_=lt&<.__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)&&e_(e,t,r);return t_(e,t),e};Object.defineProperty(lt,"__esModule",{value:!0});lt.encodePath=lt.fetchNodeKeys=lt.request=lt.CustomPath=void 0;var Qr=Mt(),n_=Kn(),ri=Ci(),i_=$t(),x0=r_(Ai()),_0=po(),ru=class{constructor(e,r,n){this.key=e,this.path=r,this.decodeStrategy=n}};lt.CustomPath=ru;var s_=async t=>{let{agent:e,paths:r}=t,n=Qr.Principal.from(t.canisterId),i=[...new Set(r)],s=i.map(c=>(0,lt.encodePath)(c,n)),o=new Map,a=i.map((c,l)=>(async()=>{var f;try{let d=await e.readState(n,{paths:[s[l]]}),v=await ri.Certificate.create({certificate:d.certificate,rootKey:e.rootKey,canisterId:n}),m=(N,A)=>{if(A==="subnet"){let q=(0,lt.fetchNodeKeys)(d.certificate,n,e.rootKey);return{path:A,data:q}}else return{path:A,data:(0,ri.lookupResultToBuffer)(N.lookup((0,lt.encodePath)(A,n)))}},{path:x,data:w}=m(v,i[l]);if(!w)console.warn(`Expected to find result for path ${x}, but instead found nothing.`),typeof x=="string"?o.set(x,null):o.set(x.key,null);else switch(x){case"time":{o.set(x,(0,_0.decodeTime)(w));break}case"controllers":{o.set(x,u_(w));break}case"module_hash":{o.set(x,w0(w));break}case"subnet":{o.set(x,w);break}case"candid":{o.set(x,new TextDecoder().decode(w));break}default:if(typeof x!="string"&&"key"in x&&"path"in x)switch(x.decodeStrategy){case"raw":o.set(x.key,w);break;case"leb128":{o.set(x.key,(0,_0.decodeLeb128)(w));break}case"cbor":{o.set(x.key,E0(w));break}case"hex":{o.set(x.key,w0(w));break}case"utf-8":o.set(x.key,c_(w))}}}catch(d){if(!((f=d?.message)===null||f===void 0)&&f.includes("Invalid certificate"))throw new n_.AgentError(d.message);typeof c!="string"&&"key"in c&&"path"in c?o.set(c.key,null):o.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(d),console.groupEnd()}})());return await Promise.all(a),o};lt.request=s_;var o_=(t,e,r)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=x0.decode(new Uint8Array(t)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=Qr.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=Qr.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=Qr.Principal.selfAuthenticating(Qr.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,ri.check_canister_ranges)({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=(0,ri.lookup_path)(["subnet",s?.subnet_id,"node"],i),l=(0,ri.flatten_forks)(c);l.length;let f=new Map;return l.forEach(d=>{Object.getPrototypeOf(new Uint8Array(d[1]));let v=Qr.Principal.from(new Uint8Array(d[1])).toText(),m=(0,ri.lookup_path)(["public_key"],d[2]);if(m.byteLength!==44)throw new Error("Invalid public key length");f.set(v,m)}),{subnetId:Qr.Principal.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:f}};lt.fetchNodeKeys=o_;var a_=(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.`)};lt.encodePath=a_;var w0=t=>(0,i_.toHex)(t),E0=t=>x0.decode(t),c_=t=>new TextDecoder().decode(t),u_=t=>E0(t).map(r=>Qr.Principal.fromUint8Array(new Uint8Array(r)))});var G0=L(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.add5L=be.add5H=be.add4H=be.add4L=be.add3H=be.add3L=be.add=be.rotlBL=be.rotlBH=be.rotlSL=be.rotlSH=be.rotr32L=be.rotr32H=be.rotrBL=be.rotrBH=be.rotrSL=be.rotrSH=be.shrSL=be.shrSH=be.toBig=be.split=be.fromBig=void 0;var _o=BigInt(2**32-1),nu=BigInt(32);function iu(t,e=!1){return e?{h:Number(t&_o),l:Number(t>>nu&_o)}:{h:Number(t>>nu&_o)|0,l:Number(t&_o)|0}}be.fromBig=iu;function v0(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}=iu(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}be.split=v0;var B0=(t,e)=>BigInt(t>>>0)<<nu|BigInt(e>>>0);be.toBig=B0;var T0=(t,e,r)=>t>>>r;be.shrSH=T0;var S0=(t,e,r)=>t<<32-r|e>>>r;be.shrSL=S0;var A0=(t,e,r)=>t>>>r|e<<32-r;be.rotrSH=A0;var O0=(t,e,r)=>t<<32-r|e>>>r;be.rotrSL=O0;var N0=(t,e,r)=>t<<64-r|e>>>r-32;be.rotrBH=N0;var P0=(t,e,r)=>t>>>r-32|e<<64-r;be.rotrBL=P0;var R0=(t,e)=>e;be.rotr32H=R0;var I0=(t,e)=>t;be.rotr32L=I0;var U0=(t,e,r)=>t<<r|e>>>32-r;be.rotlSH=U0;var F0=(t,e,r)=>e<<r|t>>>32-r;be.rotlSL=F0;var M0=(t,e,r)=>e<<r-32|t>>>64-r;be.rotlBH=M0;var C0=(t,e,r)=>t<<r-32|e>>>64-r;be.rotlBL=C0;function q0(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}be.add=q0;var j0=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);be.add3L=j0;var k0=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;be.add3H=k0;var V0=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);be.add4L=V0;var H0=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;be.add4H=H0;var $0=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);be.add5L=$0;var K0=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0;be.add5H=K0;var l_={fromBig:iu,split:v0,toBig:B0,shrSH:T0,shrSL:S0,rotrSH:A0,rotrSL:O0,rotrBH:N0,rotrBL:P0,rotr32H:R0,rotr32L:I0,rotlSH:U0,rotlSL:F0,rotlBH:M0,rotlBL:C0,add:q0,add3L:j0,add3H:k0,add4L:V0,add4H:H0,add5H:K0,add5L:$0};be.default=l_});var Y0=L(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});er.sha384=er.sha512_256=er.sha512_224=er.sha512=er.SHA512=void 0;var f_=pa(),Ee=G0(),wo=yn(),[d_,h_]=Ee.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))),en=new Uint32Array(80),tn=new Uint32Array(80),vn=class extends f_.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:l,El:f,Fh:d,Fl:v,Gh:m,Gl:x,Hh:w,Hl:N}=this;return[e,r,n,i,s,o,a,c,l,f,d,v,m,x,w,N]}set(e,r,n,i,s,o,a,c,l,f,d,v,m,x,w,N){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=l|0,this.El=f|0,this.Fh=d|0,this.Fl=v|0,this.Gh=m|0,this.Gl=x|0,this.Hh=w|0,this.Hl=N|0}process(e,r){for(let O=0;O<16;O++,r+=4)en[O]=e.getUint32(r),tn[O]=e.getUint32(r+=4);for(let O=16;O<80;O++){let $=en[O-15]|0,I=tn[O-15]|0,k=Ee.default.rotrSH($,I,1)^Ee.default.rotrSH($,I,8)^Ee.default.shrSH($,I,7),z=Ee.default.rotrSL($,I,1)^Ee.default.rotrSL($,I,8)^Ee.default.shrSL($,I,7),W=en[O-2]|0,K=tn[O-2]|0,se=Ee.default.rotrSH(W,K,19)^Ee.default.rotrBH(W,K,61)^Ee.default.shrSH(W,K,6),te=Ee.default.rotrSL(W,K,19)^Ee.default.rotrBL(W,K,61)^Ee.default.shrSL(W,K,6),fe=Ee.default.add4L(z,te,tn[O-7],tn[O-16]),ue=Ee.default.add4H(fe,k,se,en[O-7],en[O-16]);en[O]=ue|0,tn[O]=fe|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:l,Dl:f,Eh:d,El:v,Fh:m,Fl:x,Gh:w,Gl:N,Hh:A,Hl:q}=this;for(let O=0;O<80;O++){let $=Ee.default.rotrSH(d,v,14)^Ee.default.rotrSH(d,v,18)^Ee.default.rotrBH(d,v,41),I=Ee.default.rotrSL(d,v,14)^Ee.default.rotrSL(d,v,18)^Ee.default.rotrBL(d,v,41),k=d&m^~d&w,z=v&x^~v&N,W=Ee.default.add5L(q,I,z,h_[O],tn[O]),K=Ee.default.add5H(W,A,$,k,d_[O],en[O]),se=W|0,te=Ee.default.rotrSH(n,i,28)^Ee.default.rotrBH(n,i,34)^Ee.default.rotrBH(n,i,39),fe=Ee.default.rotrSL(n,i,28)^Ee.default.rotrBL(n,i,34)^Ee.default.rotrBL(n,i,39),ue=n&s^n&a^s&a,Be=i&o^i&c^o&c;A=w|0,q=N|0,w=m|0,N=x|0,m=d|0,x=v|0,{h:d,l:v}=Ee.default.add(l|0,f|0,K|0,se|0),l=a|0,f=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let Z=Ee.default.add3L(se,fe,Be);n=Ee.default.add3H(Z,K,te,ue),i=Z|0}({h:n,l:i}=Ee.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=Ee.default.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=Ee.default.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:f}=Ee.default.add(this.Dh|0,this.Dl|0,l|0,f|0),{h:d,l:v}=Ee.default.add(this.Eh|0,this.El|0,d|0,v|0),{h:m,l:x}=Ee.default.add(this.Fh|0,this.Fl|0,m|0,x|0),{h:w,l:N}=Ee.default.add(this.Gh|0,this.Gl|0,w|0,N|0),{h:A,l:q}=Ee.default.add(this.Hh|0,this.Hl|0,A|0,q|0),this.set(n,i,s,o,a,c,l,f,d,v,m,x,w,N,A,q)}roundClean(){en.fill(0),tn.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)}};er.SHA512=vn;var su=class extends vn{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}},ou=class extends vn{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}},au=class extends vn{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}};er.sha512=(0,wo.wrapConstructor)(()=>new vn);er.sha512_224=(0,wo.wrapConstructor)(()=>new su);er.sha512_256=(0,wo.wrapConstructor)(()=>new ou);er.sha384=(0,wo.wrapConstructor)(()=>new au)});var W0=L(Eo=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});Eo.twistedEdwards=void 0;var p_=Mr(),jr=Lt(),rn=Lt(),D0=Gc(),ur=BigInt(0),Yt=BigInt(1),xo=BigInt(2),y_=BigInt(8),b_={zip215:!0};function g_(t){let e=(0,D0.validateBasic)(t);return jr.validateObject(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function m_(t){let e=g_(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,l=xo<<BigInt(a*8)-Yt,f=r.create,d=e.uvRatio||((j,U)=>{try{return{isValid:!0,value:r.sqrt(j*r.inv(U))}}catch{return{isValid:!1,value:ur}}}),v=e.adjustScalarBytes||(j=>j),m=e.domain||((j,U,D)=>{if(U.length||D)throw new Error("Contexts/pre-hash are not supported");return j}),x=j=>typeof j=="bigint"&&ur<j,w=(j,U)=>x(j)&&x(U)&&j<U,N=j=>j===ur||w(j,l);function A(j,U){if(w(j,U))return j;throw new Error(`Expected valid scalar < ${U}, got ${typeof j} ${j}`)}function q(j){return j===ur?j:A(j,n)}let O=new Map;function $(j){if(!(j instanceof I))throw new Error("ExtendedPoint expected")}class I{constructor(U,D,J,ie){if(this.ex=U,this.ey=D,this.ez=J,this.et=ie,!N(U))throw new Error("x required");if(!N(D))throw new Error("y required");if(!N(J))throw new Error("z required");if(!N(ie))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(U){if(U instanceof I)throw new Error("extended point not allowed");let{x:D,y:J}=U||{};if(!N(D)||!N(J))throw new Error("invalid affine point");return new I(D,J,Yt,f(D*J))}static normalizeZ(U){let D=r.invertBatch(U.map(J=>J.ez));return U.map((J,ie)=>J.toAffine(D[ie])).map(I.fromAffine)}_setWindowSize(U){this._WINDOW_SIZE=U,O.delete(this)}assertValidity(){let{a:U,d:D}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:J,ey:ie,ez:R,et:y}=this,de=f(J*J),ae=f(ie*ie),ce=f(R*R),ee=f(ce*ce),u=f(de*U),h=f(ce*f(u+ae)),p=f(ee+f(D*f(de*ae)));if(h!==p)throw new Error("bad point: equation left != right (1)");let B=f(J*ie),E=f(R*y);if(B!==E)throw new Error("bad point: equation left != right (2)")}equals(U){$(U);let{ex:D,ey:J,ez:ie}=this,{ex:R,ey:y,ez:de}=U,ae=f(D*de),ce=f(R*ie),ee=f(J*de),u=f(y*ie);return ae===ce&&ee===u}is0(){return this.equals(I.ZERO)}negate(){return new I(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:U}=e,{ex:D,ey:J,ez:ie}=this,R=f(D*D),y=f(J*J),de=f(xo*f(ie*ie)),ae=f(U*R),ce=D+J,ee=f(f(ce*ce)-R-y),u=ae+y,h=u-de,p=ae-y,B=f(ee*h),E=f(u*p),T=f(ee*p),F=f(h*u);return new I(B,E,F,T)}add(U){$(U);let{a:D,d:J}=e,{ex:ie,ey:R,ez:y,et:de}=this,{ex:ae,ey:ce,ez:ee,et:u}=U;if(D===BigInt(-1)){let le=f((R-ie)*(ce+ae)),ve=f((R+ie)*(ce-ae)),Re=f(ve-le);if(Re===ur)return this.double();let ke=f(y*xo*u),xe=f(de*xo*ee),he=xe+ke,De=ve+le,Or=xe-ke,hn=f(he*Re),pn=f(De*Or),Ut=f(he*Or),Ne=f(Re*De);return new I(hn,pn,Ne,Ut)}let h=f(ie*ae),p=f(R*ce),B=f(de*J*u),E=f(y*ee),T=f((ie+R)*(ae+ce)-h-p),F=E-B,g=E+B,S=f(p-D*h),M=f(T*F),P=f(g*S),Y=f(T*S),Q=f(F*g);return new I(M,P,Q,Y)}subtract(U){return this.add(U.negate())}wNAF(U){return W.wNAFCached(this,O,U,I.normalizeZ)}multiply(U){let{p:D,f:J}=this.wNAF(A(U,n));return I.normalizeZ([D,J])[0]}multiplyUnsafe(U){let D=q(U);return D===ur?z:this.equals(z)||D===Yt?this:this.equals(k)?this.wNAF(D).p:W.unsafeLadder(this,D)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return W.unsafeLadder(this,n).is0()}toAffine(U){let{ex:D,ey:J,ez:ie}=this,R=this.is0();U==null&&(U=R?y_:r.inv(ie));let y=f(D*U),de=f(J*U),ae=f(ie*U);if(R)return{x:ur,y:Yt};if(ae!==Yt)throw new Error("invZ was invalid");return{x:y,y:de}}clearCofactor(){let{h:U}=e;return U===Yt?this:this.multiplyUnsafe(U)}static fromHex(U,D=!1){let{d:J,a:ie}=e,R=r.BYTES;U=(0,rn.ensureBytes)("pointHex",U,R);let y=U.slice(),de=U[R-1];y[R-1]=de&-129;let ae=jr.bytesToNumberLE(y);ae===ur||(D?A(ae,l):A(ae,r.ORDER));let ce=f(ae*ae),ee=f(ce-Yt),u=f(J*ce-ie),{isValid:h,value:p}=d(ee,u);if(!h)throw new Error("Point.fromHex: invalid y coordinate");let B=(p&Yt)===Yt,E=(de&128)!==0;if(!D&&p===ur&&E)throw new Error("Point.fromHex: x=0 and x_0=1");return E!==B&&(p=f(-p)),I.fromAffine({x:p,y:ae})}static fromPrivateKey(U){return te(U).point}toRawBytes(){let{x:U,y:D}=this.toAffine(),J=jr.numberToBytesLE(D,r.BYTES);return J[J.length-1]|=U&Yt?128:0,J}toHex(){return jr.bytesToHex(this.toRawBytes())}}I.BASE=new I(e.Gx,e.Gy,Yt,f(e.Gx*e.Gy)),I.ZERO=new I(ur,Yt,Yt,ur);let{BASE:k,ZERO:z}=I,W=(0,D0.wNAF)(I,a*8);function K(j){return(0,p_.mod)(j,n)}function se(j){return K(jr.bytesToNumberLE(j))}function te(j){let U=a;j=(0,rn.ensureBytes)("private key",j,U);let D=(0,rn.ensureBytes)("hashed private key",s(j),2*U),J=v(D.slice(0,U)),ie=D.slice(U,2*U),R=se(J),y=k.multiply(R),de=y.toRawBytes();return{head:J,prefix:ie,scalar:R,point:y,pointBytes:de}}function fe(j){return te(j).pointBytes}function ue(j=new Uint8Array,...U){let D=jr.concatBytes(...U);return se(s(m(D,(0,rn.ensureBytes)("context",j),!!i)))}function Be(j,U,D={}){j=(0,rn.ensureBytes)("message",j),i&&(j=i(j));let{prefix:J,scalar:ie,pointBytes:R}=te(U),y=ue(D.context,J,j),de=k.multiply(y).toRawBytes(),ae=ue(D.context,de,R,j),ce=K(y+ae*ie);q(ce);let ee=jr.concatBytes(de,jr.numberToBytesLE(ce,r.BYTES));return(0,rn.ensureBytes)("result",ee,a*2)}let Z=b_;function C(j,U,D,J=Z){let{context:ie,zip215:R}=J,y=r.BYTES;j=(0,rn.ensureBytes)("signature",j,2*y),U=(0,rn.ensureBytes)("message",U),i&&(U=i(U));let de=jr.bytesToNumberLE(j.slice(y,2*y)),ae,ce,ee;try{ae=I.fromHex(D,R),ce=I.fromHex(j.slice(0,y),R),ee=k.multiplyUnsafe(de)}catch{return!1}if(!R&&ae.isSmallOrder())return!1;let u=ue(ie,ce.toRawBytes(),ae.toRawBytes(),U);return ce.add(ae.multiplyUnsafe(u)).subtract(ee).clearCofactor().equals(I.ZERO)}return k._setWindowSize(8),{CURVE:e,getPublicKey:fe,sign:Be,verify:C,ExtendedPoint:I,utils:{getExtendedPublicKey:te,randomPrivateKey:()=>o(r.BYTES),precompute(j=8,U=I.BASE){return U._setWindowSize(j),U.multiply(BigInt(3)),U}}}}Eo.twistedEdwards=m_});var Z0=L(vo=>{"use strict";Object.defineProperty(vo,"__esModule",{value:!0});vo.montgomery=void 0;var z0=Mr(),ni=Lt(),ji=BigInt(0),cu=BigInt(1);function __(t){return(0,ni.validateObject)(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function w_(t){let e=__(t),{P:r}=e,n=O=>(0,z0.mod)(O,r),i=e.montgomeryBits,s=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(O=>O),c=e.powPminus2||(O=>(0,z0.pow)(O,r-BigInt(2),r));function l(O,$,I){let k=n(O*($-I));return $=n($-k),I=n(I+k),[$,I]}function f(O){if(typeof O=="bigint"&&ji<=O&&O<r)return O;throw new Error("Expected valid scalar 0 < scalar < CURVE.P")}let d=(e.a-BigInt(2))/BigInt(4);function v(O,$){let I=f(O),k=f($),z=I,W=cu,K=ji,se=I,te=cu,fe=ji,ue;for(let Z=BigInt(i-1);Z>=ji;Z--){let C=k>>Z&cu;fe^=C,ue=l(fe,W,se),W=ue[0],se=ue[1],ue=l(fe,K,te),K=ue[0],te=ue[1],fe=C;let X=W+K,j=n(X*X),U=W-K,D=n(U*U),J=j-D,ie=se+te,R=se-te,y=n(R*X),de=n(ie*U),ae=y+de,ce=y-de;se=n(ae*ae),te=n(z*n(ce*ce)),W=n(j*D),K=n(J*(j+n(d*J)))}ue=l(fe,W,se),W=ue[0],se=ue[1],ue=l(fe,K,te),K=ue[0],te=ue[1];let Be=c(K);return n(W*Be)}function m(O){return(0,ni.numberToBytesLE)(n(O),s)}function x(O){let $=(0,ni.ensureBytes)("u coordinate",O,s);return o===32&&($[31]&=127),(0,ni.bytesToNumberLE)($)}function w(O){let $=(0,ni.ensureBytes)("scalar",O),I=$.length;if(I!==s&&I!==o)throw new Error(`Expected ${s} or ${o} bytes, got ${I}`);return(0,ni.bytesToNumberLE)(a($))}function N(O,$){let I=x($),k=w(O),z=v(I,k);if(z===ji)throw new Error("Invalid private or public key received");return m(z)}let A=m(e.Gu);function q(O){return N(O,A)}return{scalarMult:N,scalarMultBase:q,getSharedSecret:(O,$)=>N(O,$),getPublicKey:O=>q(O),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:A}}vo.montgomery=w_});var yu=L(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.hash_to_ristretto255=ge.hashToRistretto255=ge.RistrettoPoint=ge.encodeToCurve=ge.hashToCurve=ge.edwardsToMontgomeryPriv=ge.edwardsToMontgomery=ge.edwardsToMontgomeryPub=ge.x25519=ge.ed25519ph=ge.ed25519ctx=ge.ed25519=ge.ED25519_TORSION_SUBGROUP=void 0;var To=Y0(),ki=yn(),hu=W0(),x_=Z0(),Ie=Mr(),Bn=Lt(),rh=so(),Vi=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),fu=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),E_=BigInt(0),xr=BigInt(1),Bo=BigInt(2),v_=BigInt(5),X0=BigInt(10),B_=BigInt(20),T_=BigInt(40),J0=BigInt(80);function nh(t){let e=Vi,n=t*t%e*t%e,i=(0,Ie.pow2)(n,Bo,e)*n%e,s=(0,Ie.pow2)(i,xr,e)*t%e,o=(0,Ie.pow2)(s,v_,e)*s%e,a=(0,Ie.pow2)(o,X0,e)*o%e,c=(0,Ie.pow2)(a,B_,e)*a%e,l=(0,Ie.pow2)(c,T_,e)*c%e,f=(0,Ie.pow2)(l,J0,e)*l%e,d=(0,Ie.pow2)(f,J0,e)*l%e,v=(0,Ie.pow2)(d,X0,e)*o%e;return{pow_p_5_8:(0,Ie.pow2)(v,Bo,e)*t%e,b2:n}}function ih(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function pu(t,e){let r=Vi,n=(0,Ie.mod)(e*e*e,r),i=(0,Ie.mod)(n*n*e,r),s=nh(t*i).pow_p_5_8,o=(0,Ie.mod)(t*n*s,r),a=(0,Ie.mod)(e*o*o,r),c=o,l=(0,Ie.mod)(o*fu,r),f=a===t,d=a===(0,Ie.mod)(-t,r),v=a===(0,Ie.mod)(-t*fu,r);return f&&(o=c),(d||v)&&(o=l),(0,Ie.isNegativeLE)(o,r)&&(o=(0,Ie.mod)(-o,r)),{isValid:f||d,value:o}}ge.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var oe=(0,Ie.Field)(Vi,void 0,!0),Hi={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:oe,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:To.sha512,randomBytes:ki.randomBytes,adjustScalarBytes:ih,uvRatio:pu};ge.ed25519=(0,hu.twistedEdwards)(Hi);function sh(t,e,r){if(e.length>255)throw new Error("Context is too big");return(0,ki.concatBytes)((0,ki.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}ge.ed25519ctx=(0,hu.twistedEdwards)({...Hi,domain:sh});ge.ed25519ph=(0,hu.twistedEdwards)({...Hi,domain:sh,prehash:To.sha512});ge.x25519=(0,x_.montgomery)({P:Vi,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=Vi,{pow_p_5_8:r,b2:n}=nh(t);return(0,Ie.mod)((0,Ie.pow2)(r,BigInt(3),e)*n,e)},adjustScalarBytes:ih,randomBytes:ki.randomBytes});function oh(t){let{y:e}=ge.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return oe.toBytes(oe.create((r+e)*oe.inv(r-e)))}ge.edwardsToMontgomeryPub=oh;ge.edwardsToMontgomery=oh;function S_(t){let e=Hi.hash(t.subarray(0,32));return Hi.adjustScalarBytes(e).subarray(0,32)}ge.edwardsToMontgomeryPriv=S_;var A_=(oe.ORDER+BigInt(3))/BigInt(8),O_=oe.pow(Bo,A_),L0=oe.sqrt(oe.neg(oe.ONE)),N_=(oe.ORDER-BigInt(5))/BigInt(8),Q0=BigInt(486662);function P_(t){let e=oe.sqr(t);e=oe.mul(e,Bo);let r=oe.add(e,oe.ONE),n=oe.neg(Q0),i=oe.sqr(r),s=oe.mul(i,r),o=oe.mul(e,Q0);o=oe.mul(o,n),o=oe.add(o,i),o=oe.mul(o,n);let a=oe.sqr(s);i=oe.sqr(a),a=oe.mul(a,s),a=oe.mul(a,o),i=oe.mul(i,a);let c=oe.pow(i,N_);c=oe.mul(c,a);let l=oe.mul(c,L0);i=oe.sqr(c),i=oe.mul(i,s);let f=oe.eql(i,o),d=oe.cmov(l,c,f),v=oe.mul(n,e),m=oe.mul(c,t);m=oe.mul(m,O_);let x=oe.mul(m,L0),w=oe.mul(o,e);i=oe.sqr(m),i=oe.mul(i,s);let N=oe.eql(i,w),A=oe.cmov(x,m,N);i=oe.sqr(d),i=oe.mul(i,s);let q=oe.eql(i,o),O=oe.cmov(v,n,q),$=oe.cmov(A,d,q),I=oe.isOdd($);return $=oe.cmov($,oe.neg($),q!==I),{xMn:O,xMd:r,yMn:$,yMd:xr}}var R_=(0,Ie.FpSqrtEven)(oe,oe.neg(BigInt(486664)));function I_(t){let{xMn:e,xMd:r,yMn:n,yMd:i}=P_(t),s=oe.mul(e,i);s=oe.mul(s,R_);let o=oe.mul(r,n),a=oe.sub(e,r),c=oe.add(e,r),l=oe.mul(o,c),f=oe.eql(l,oe.ZERO);s=oe.cmov(s,oe.ZERO,f),o=oe.cmov(o,oe.ONE,f),a=oe.cmov(a,oe.ONE,f),c=oe.cmov(c,oe.ONE,f);let d=oe.invertBatch([o,c]);return{x:oe.mul(s,d[0]),y:oe.mul(a,d[1])}}var ah=(0,rh.createHasher)(ge.ed25519.ExtendedPoint,t=>I_(t[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:oe.ORDER,m:1,k:128,expand:"xmd",hash:To.sha512});ge.hashToCurve=ah.hashToCurve;ge.encodeToCurve=ah.encodeToCurve;function uu(t){if(!(t instanceof lr))throw new Error("RistrettoPoint expected")}var du=fu,U_=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),F_=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),M_=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),C_=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),eh=t=>pu(xr,t),q_=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),lu=t=>ge.ed25519.CURVE.Fp.create((0,Bn.bytesToNumberLE)(t)&q_);function th(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+xr)*M_),o=BigInt(-1),a=n((o-e*i)*n(i+e)),{isValid:c,value:l}=pu(s,a),f=n(l*t);(0,Ie.isNegativeLE)(f,r)||(f=n(-f)),c||(l=f),c||(o=i);let d=n(o*(i-xr)*C_-a),v=l*l,m=n((l+l)*a),x=n(d*U_),w=n(xr-v),N=n(xr+v);return new ge.ed25519.ExtendedPoint(n(m*N),n(w*x),n(x*N),n(m*w))}var lr=class t{constructor(e){this.ep=e}static fromAffine(e){return new t(ge.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,Bn.ensureBytes)("ristrettoHash",e,64);let r=lu(e.slice(0,32)),n=th(r),i=lu(e.slice(32,64)),s=th(i);return new t(n.add(s))}static fromHex(e){e=(0,Bn.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=lu(e);if(!(0,Bn.equalBytes)((0,Bn.numberToBytesLE)(a,32),e)||(0,Ie.isNegativeLE)(a,i))throw new Error(o);let c=s(a*a),l=s(xr+r*c),f=s(xr-r*c),d=s(l*l),v=s(f*f),m=s(r*n*d-v),{isValid:x,value:w}=eh(s(m*v)),N=s(w*f),A=s(w*N*m),q=s((a+a)*N);(0,Ie.isNegativeLE)(q,i)&&(q=s(-q));let O=s(l*A),$=s(q*O);if(!x||(0,Ie.isNegativeLE)($,i)||O===E_)throw new Error(o);return new t(new ge.ed25519.ExtendedPoint(q,O,xr,$))}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),l=o(c*c),{value:f}=eh(o(a*l)),d=o(f*a),v=o(f*c),m=o(d*v*i),x;if((0,Ie.isNegativeLE)(i*m,s)){let N=o(r*du),A=o(e*du);e=N,r=A,x=o(d*F_)}else x=v;(0,Ie.isNegativeLE)(e*m,s)&&(r=o(-r));let w=o((n-r)*x);return(0,Ie.isNegativeLE)(w,s)&&(w=o(-w)),(0,Bn.numberToBytesLE)(w,32)}toHex(){return(0,Bn.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){uu(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 uu(e),new t(this.ep.add(e.ep))}subtract(e){return uu(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=(lr.BASE||(lr.BASE=new lr(ge.ed25519.ExtendedPoint.BASE)),lr.ZERO||(lr.ZERO=new lr(ge.ed25519.ExtendedPoint.ZERO)),lr);var j_=(t,e)=>{let r=e.DST,n=typeof r=="string"?(0,ki.utf8ToBytes)(r):r,i=(0,rh.expand_message_xmd)(t,n,64,To.sha512);return lr.hashToCurve(i)};ge.hashToRistretto255=j_;ge.hash_to_ristretto255=ge.hashToRistretto255});var fh=L(nn=>{"use strict";var ch=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},Pt=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)},Ot,$i,uh,lh;Object.defineProperty(nn,"__esModule",{value:!0});nn.ExpirableMap=void 0;var bu=class{constructor(e={}){Ot.set(this,void 0),$i.set(this,void 0),this[uh]=this.entries.bind(this),this[lh]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();ch(this,Ot,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),ch(this,$i,n,"f")}prune(){let e=Date.now();for(let[r,n]of Pt(this,Ot,"f").entries())e-n.timestamp>Pt(this,$i,"f")&&Pt(this,Ot,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return Pt(this,Ot,"f").set(e,n),this}get(e){let r=Pt(this,Ot,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>Pt(this,$i,"f")){Pt(this,Ot,"f").delete(e);return}return r.value}}clear(){Pt(this,Ot,"f").clear()}entries(){let e=Pt(this,Ot,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=Pt(this,Ot,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return Pt(this,Ot,"f").keys()}forEach(e,r){for(let[n,i]of Pt(this,Ot,"f").entries())e.call(r,i.value,n,this)}has(e){return Pt(this,Ot,"f").has(e)}delete(e){return Pt(this,Ot,"f").delete(e)}get size(){return Pt(this,Ot,"f").size}};nn.ExpirableMap=bu;Ot=new WeakMap,$i=new WeakMap,uh=Symbol.iterator,lh=Symbol.toStringTag});var gu=L(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});Ce.unwrapDER=Ce.wrapDER=Ce.SECP256K1_OID=Ce.ED25519_OID=Ce.DER_COSE_OID=Ce.decodeLen=Ce.decodeLenBytes=Ce.encodeLen=Ce.encodeLenBytes=void 0;var k_=$t(),V_=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)")};Ce.encodeLenBytes=V_;var H_=(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)")};Ce.encodeLen=H_;var $_=(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)")};Ce.decodeLenBytes=$_;var K_=(t,e)=>{let r=(0,Ce.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)")};Ce.decodeLen=K_;Ce.DER_COSE_OID=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]);Ce.ED25519_OID=Uint8Array.from([48,5,6,3,43,101,112]);Ce.SECP256K1_OID=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function G_(t,e){let r=2+(0,Ce.encodeLenBytes)(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,s=new Uint8Array(1+(0,Ce.encodeLenBytes)(n)+n);return s[i++]=48,i+=(0,Ce.encodeLen)(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=(0,Ce.encodeLen)(s,i,t.byteLength+1),s[i++]=0,s.set(new Uint8Array(t),i),s}Ce.wrapDER=G_;var Y_=(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,Ce.decodeLenBytes)(i,r),!(0,k_.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,Ce.decodeLen)(i,r)-1;r+=(0,Ce.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};Ce.unwrapDER=Y_});var mu=L(sn=>{"use strict";var dh=sn&&sn.__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},hh=sn&&sn.__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)},Ao,Oo;Object.defineProperty(sn,"__esModule",{value:!0});sn.Ed25519PublicKey=void 0;var So=gu(),No=class t{constructor(e){if(Ao.set(this,void 0),Oo.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");dh(this,Ao,e,"f"),dh(this,Oo,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,So.wrapDER)(e,So.ED25519_OID).buffer}static derDecode(e){let r=(0,So.unwrapDER)(e,So.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 hh(this,Ao,"f")}get derKey(){return hh(this,Oo,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};sn.Ed25519PublicKey=No;Ao=new WeakMap,Oo=new WeakMap;No.RAW_KEY_LENGTH=32});var gh=L(on=>{"use strict";var ph=on&&on.__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)},_u,yh,wu,bh;Object.defineProperty(on,"__esModule",{value:!0});on.ObservableLog=on.Observable=void 0;var Po=class extends Function{constructor(){return super(),_u.add(this),this.observers=[],new Proxy(this,{apply:(e,r,n)=>ph(e,_u,"m",yh).call(e,n[0],...n.slice(1))})}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(r=>r!==e)}notify(e,...r){this.observers.forEach(n=>n(e,...r))}};on.Observable=Po;_u=new WeakSet,yh=function(e,...r){this.notify(e,...r)};var xu=class extends Po{constructor(){return super(),wu.add(this),new Proxy(this,{apply:(e,r,n)=>ph(e,wu,"m",bh).call(e,n[0],...n.slice(1))})}log(e,...r){this.notify({message:e,level:"info"},...r)}warn(e,...r){this.notify({message:e,level:"warn"},...r)}error(e,r,...n){this.notify({message:e,level:"error",error:r},...n)}};on.ObservableLog=xu;wu=new WeakSet,bh=function(e,...r){this.log(e,...r)}});var Tu=L(Fe=>{"use strict";var _h=Fe&&Fe.__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]}),D_=Fe&&Fe.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),wh=Fe&&Fe.__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)&&_h(e,t,r);return D_(e,t),e},W_=Fe&&Fe.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&_h(e,t,r)},mh=Fe&&Fe.__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},ze=Fe&&Fe.__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)},Gi,Uo,ii,si,Tn,Sn,xh,Fo;Object.defineProperty(Fe,"__esModule",{value:!0});Fe.HttpAgent=Fe.IdentityInvalidError=Fe.MANAGEMENT_CANISTER_ID=Fe.IC_ROOT_KEY=Fe.RequestStatusResponseStatus=Fe.makeNonce=void 0;var tr=Mt(),Mo=Kn(),z_=Ec(),an=wh(Ai()),Ro=Bi(),Eu=$t(),Er=Ls(),vu=Oi(),Eh=Fc(),Z_=qi(),Ki=Ci(),X_=yu(),J_=fh(),L_=mu(),Q_=po(),ew=gh();W_(Ls(),Fe);var tw=Oi();Object.defineProperty(Fe,"makeNonce",{enumerable:!0,get:function(){return tw.makeNonce}});var rw;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(rw=Fe.RequestStatusResponseStatus||(Fe.RequestStatusResponseStatus={}));var Io=5*60*1e3;Fe.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";Fe.MANAGEMENT_CANISTER_ID="aaaaa-aa";var nw="ic0.app",iw=".ic0.app",sw="icp0.io",ow=".icp0.io",aw="icp-api.io",cw=".icp-api.io",Yi=class extends Mo.AgentError{constructor(e){super(e),this.message=e}},An=class extends Mo.AgentError{constructor(e){super(e),this.message=e}};Fe.IdentityInvalidError=An;function uw(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new Yi("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 Yi("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 Yi("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}var Bu=class t{constructor(e={}){var r;if(Gi.add(this),this.rootKey=(0,Eu.fromHex)(Fe.IC_ROOT_KEY),this._timeDiffMsecs=0,this._rootKeyFetched=!1,this._isAgent=!0,Uo.set(this,0),this.log=new ew.ObservableLog,ii.set(this,[]),si.set(this,[]),Tn.set(this,new J_.ExpirableMap({expirationTime:5*60*1e3})),Sn.set(this,!0),Fo.set(this,(n,i)=>{if(ze(this,Sn,"f")===!1)return n;if(!i)throw new Ki.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:s,signatures:o=[],requestId:a}=n,c=new TextEncoder().encode("\vic-response");for(let l of o){let{timestamp:f,identity:d}=l,v=tr.Principal.fromUint8Array(d).toText(),m;if(s==="replied"){let{reply:q}=n;m=(0,Ro.hashOfMap)({status:s,reply:q,timestamp:BigInt(f),request_id:a})}else if(s==="rejected"){let{reject_code:q,reject_message:O,error_code:$}=n;m=(0,Ro.hashOfMap)({status:s,reject_code:q,reject_message:O,error_code:$,timestamp:BigInt(f),request_id:a})}else throw new Error(`Unknown status: ${s}`);let x=(0,Eu.concat)(c,new Uint8Array(m)),w=i?.nodeKeys.get(v);if(!w)throw new Ki.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let N=L_.Ed25519PublicKey.fromDer(w).rawKey;if(X_.ed25519.verify(l.signature,new Uint8Array(x),new Uint8Array(N)))return n;throw new Ki.CertificateVerificationError(`Invalid signature from replica ${v} signed query.`)}return n}),e.source){if(!(e.source instanceof t))throw new Error("An Agent's source can only be another HttpAgent");this._identity=e.source._identity,this._fetch=e.source._fetch,this._host=e.source._host,this._credentials=e.source._credentials}else this._fetch=e.fetch||uw()||fetch.bind(global),this._fetchOptions=e.fetchOptions,this._callOptions=e.callOptions;if(e.host!==void 0)!e.host.match(/^[a-z]+:/)&&typeof window<"u"?this._host=new URL(window.location.protocol+"//"+e.host):this._host=new URL(e.host);else if(e.source!==void 0)this._host=e.source._host;else{let n=typeof window<"u"?window.location:void 0;n||(this._host=new URL("https://icp-api.io"),this.log.warn("Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning."));let i=["ic0.app","icp0.io","127.0.0.1","localhost"],s=[".github.dev",".gitpod.io"],o=n?.hostname,a;o&&typeof o=="string"&&(s.some(c=>o.endsWith(c))?a=o:a=i.find(c=>o.endsWith(c))),n&&a?this._host=new URL(`${n.protocol}//${a}${n.port?":"+n.port:""}`):(this._host=new URL("https://icp-api.io"),this.log.warn("Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning."))}if(e.verifyQuerySignatures!==void 0&&mh(this,Sn,e.verifyQuerySignatures,"f"),this._retryTimes=(r=e.retryTimes)!==null&&r!==void 0?r:3,this._host.hostname.endsWith(iw)?this._host.hostname=nw:this._host.hostname.endsWith(ow)?this._host.hostname=sw:this._host.hostname.endsWith(cw)&&(this._host.hostname=aw),e.credentials){let{name:n,password:i}=e.credentials;this._credentials=`${n}${i?":"+i:""}`}this._identity=Promise.resolve(e.identity||new z_.AnonymousIdentity),this.addTransform("update",(0,Er.makeNonceTransform)(vu.makeNonce)),e.useQueryNonces&&this.addTransform("query",(0,Er.makeNonceTransform)(vu.makeNonce)),e.logToConsole&&this.log.subscribe(n=>{n.level==="error"?console.error(n.message):n.level==="warn"?console.warn(n.message):console.log(n.message)})}get waterMark(){return ze(this,Uo,"f")}isLocal(){let e=this._host.hostname;return e==="127.0.0.1"||e.endsWith("127.0.0.1")}addTransform(e,r,n=r.priority||0){if(e==="update"){let i=ze(this,si,"f").findIndex(s=>(s.priority||0)<n);ze(this,si,"f").splice(i>=0?i:ze(this,si,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=ze(this,ii,"f").findIndex(s=>(s.priority||0)<n);ze(this,ii,"f").splice(i>=0?i:ze(this,ii,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!this._identity)throw new An("This identity has expired due this application's security policy. Please refresh your authentication.");return(await this._identity).getPrincipal()}async call(e,r,n){let i=await(n!==void 0?await n:await this._identity);if(!i)throw new An("This identity has expired due this application's security policy. Please refresh your authentication.");let s=tr.Principal.from(e),o=r.effectiveCanisterId?tr.Principal.from(r.effectiveCanisterId):s,a=i.getPrincipal()||tr.Principal.anonymous(),c=new Er.Expiry(Io);Math.abs(this._timeDiffMsecs)>1e3*30&&(c=new Er.Expiry(Io+this._timeDiffMsecs));let l={request_type:vu.SubmitRequestType.Call,canister_id:s,method_name:r.methodName,arg:r.arg,sender:a,ingress_expiry:c},f=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"call",body:l});f=await i.transformRequest(f);let d=an.encode(f.body);this.log(`fetching "/api/v2/canister/${o.toText()}/call" with request:`,f);let v=this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${o.toText()}/call`,this._host),Object.assign(Object.assign(Object.assign({},this._callOptions),f.request),{body:d}))),[m,x]=await Promise.all([v,(0,Ro.requestIdOf)(l)]),w=await m.arrayBuffer(),N=m.status===200&&w.byteLength>0?an.decode(w):null;return{requestId:x,response:{ok:m.ok,status:m.status,statusText:m.statusText,body:N,headers:(0,Er.httpHeadersTransform)(m.headers)}}}async _requestAndRetry(e,r=0){let n;try{n=await e()}catch(o){if(this._retryTimes>r)return this.log.warn(`Caught exception while attempting to make request:
|
|
30
|
-
${
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
${
|
|
42
|
-
|
|
43
|
-
Request ID: ${(0,
|
|
29
|
+
)`}else throw new Error("Invalid tree structure for labeled");case At.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 At.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,Kr.toHex)(new Uint8Array(t[1]))}`}default:return`unknown(${JSON.stringify(t[0])})`}}$e.hashTreeToString=So;function U0(t,e){if(t.byteLength!==e.byteLength)return!1;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return!1;return!0}var mu=class t{constructor(e,r,n,i,s=5){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,this.cert=I0.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=m_.blsVerify),new t(e.certificate,e.rootKey,e.canisterId,r,e.maxAgeInMinutes)}lookup(e){return F0(Oo(e,this.cert.tree))}lookup_label(e){return this.lookup([e])}async verify(){let e=await Yi(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=x_(r),s=(0,Kr.concat)(Gi("ic-state-root"),e),o=!1,a=this.lookup(["time"]);if(!a)throw new $r("Certificate does not contain a time");let c=5*60*1e3,f=this._maxAgeInMinutes*60*1e3,l=Date.now(),d=l-f,v=l+c,w=(0,__.decodeTime)(a);if(w.getTime()<d)throw new $r(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+w.toISOString()+" Current time: "+new Date(l).toISOString());if(w.getTime()>v)throw new $r("Certificate is signed more than 5 minutes in the future. Certificate time: "+w.toISOString()+" Current time: "+new Date(l).toISOString());try{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)throw new $r("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 $r("Delegation certificates cannot be nested");if(await r.verify(),!M0({canisterId:this._canisterId,subnetId:gu.Principal.fromUint8Array(new Uint8Array(e.subnet_id)),tree:r.cert.tree}))throw new $r(`Canister ${this._canisterId} not in range of delegations for subnet 0x${(0,Kr.toHex)(e.subnet_id)}`);let i=r.lookup(["subnet",e.subnet_id,"public_key"]);if(!i)throw new Error(`Could not find subnet key for subnet 0x${(0,Kr.toHex)(e.subnet_id)}`);return i}};$e.Certificate=mu;var Ki=(0,Kr.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),w_=96;function x_(t){let e=Ki.byteLength+w_;if(t.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let r=t.slice(0,Ki.byteLength);if(!U0(r,Ki))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${Ki}, but get ${r}`);return t.slice(Ki.byteLength)}function F0(t){if(t instanceof ArrayBuffer)return t;if(t instanceof Uint8Array)return t.buffer}$e.lookupResultToBuffer=F0;async function Yi(t){switch(t[0]){case At.Empty:return(0,To.hash)(Gi("ic-hashtree-empty"));case At.Pruned:return t[1];case At.Leaf:return(0,To.hash)((0,Kr.concat)(Gi("ic-hashtree-leaf"),t[1]));case At.Labeled:return(0,To.hash)((0,Kr.concat)(Gi("ic-hashtree-labeled"),t[1],await Yi(t[2])));case At.Fork:return(0,To.hash)((0,Kr.concat)(Gi("ic-hashtree-fork"),await Yi(t[1]),await Yi(t[2])));default:throw new Error("unreachable")}}$e.reconstruct=Yi;function Gi(t){let e=new Uint8Array([t.length]),r=new TextEncoder().encode(t);return(0,Kr.concat)(e,r)}function Oo(t,e){if(t.length===0)switch(e[0]){case At.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?e[1]:e[1]instanceof Uint8Array?e[1].buffer:e[1]}case At.Fork:return e;default:return e}let r=typeof t[0]=="string"?new TextEncoder().encode(t[0]):t[0],n=E_(r,Ao(e));if(n)return Oo(t.slice(1),n)}$e.lookup_path=Oo;function Ao(t){switch(t[0]){case At.Empty:return[];case At.Fork:return Ao(t[1]).concat(Ao(t[2]));default:return[t]}}$e.flatten_forks=Ao;function E_(t,e){if(e.length!==0){for(let r of e)if(r[0]===At.Labeled){let n=r[1];if(U0(t,n))return r[2]}}}function M0(t){let{canisterId:e,subnetId:r,tree:n}=t,i=Oo(["subnet",r.toUint8Array(),"canister_ranges"],n);if(!i||!(i instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return I0.decode(i).map(c=>[gu.Principal.fromUint8Array(c[0]),gu.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(e)&&c[1].gtEq(e))}$e.check_canister_ranges=M0});var zi=J(ft=>{"use strict";var v_=ft&&ft.__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]}),B_=ft&&ft.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),T_=ft&&ft.__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)&&v_(e,t,r);return B_(e,t),e};Object.defineProperty(ft,"__esModule",{value:!0});ft.encodePath=ft.fetchNodeKeys=ft.request=ft.CustomPath=void 0;var on=Ct(),S_=Xn(),ui=Wi(),A_=Kt(),j0=T_(qi()),C0=Bo(),_u=class{constructor(e,r,n){this.key=e,this.path=r,this.decodeStrategy=n}};ft.CustomPath=_u;var O_=async t=>{let{agent:e,paths:r}=t,n=on.Principal.from(t.canisterId),i=[...new Set(r)],s=i.map(c=>(0,ft.encodePath)(c,n)),o=new Map,a=i.map((c,f)=>(async()=>{var l;try{let d=await e.readState(n,{paths:[s[f]]}),v=await ui.Certificate.create({certificate:d.certificate,rootKey:e.rootKey,canisterId:n}),w=(N,T)=>{if(T==="subnet"){let q=(0,ft.fetchNodeKeys)(d.certificate,n,e.rootKey);return{path:T,data:q}}else return{path:T,data:(0,ui.lookupResultToBuffer)(N.lookup((0,ft.encodePath)(T,n)))}},{path:g,data:x}=w(v,i[f]);if(!x)console.warn(`Expected to find result for path ${g}, but instead found nothing.`),typeof g=="string"?o.set(g,null):o.set(g.key,null);else switch(g){case"time":{o.set(g,(0,C0.decodeTime)(x));break}case"controllers":{o.set(g,I_(x));break}case"module_hash":{o.set(g,q0(x));break}case"subnet":{o.set(g,x);break}case"candid":{o.set(g,new TextDecoder().decode(x));break}default:if(typeof g!="string"&&"key"in g&&"path"in g)switch(g.decodeStrategy){case"raw":o.set(g.key,x);break;case"leb128":{o.set(g.key,(0,C0.decodeLeb128)(x));break}case"cbor":{o.set(g.key,k0(x));break}case"hex":{o.set(g.key,q0(x));break}case"utf-8":o.set(g.key,R_(x))}}}catch(d){if(!((l=d?.message)===null||l===void 0)&&l.includes("Invalid certificate"))throw new S_.AgentError(d.message);typeof c!="string"&&"key"in c&&"path"in c?o.set(c.key,null):o.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(d),console.groupEnd()}})());return await Promise.all(a),o};ft.request=O_;var N_=(t,e,r)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=j0.decode(new Uint8Array(t)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=on.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=on.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=on.Principal.selfAuthenticating(on.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,ui.check_canister_ranges)({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=(0,ui.lookup_path)(["subnet",s?.subnet_id,"node"],i),f=(0,ui.flatten_forks)(c);f.length;let l=new Map;return f.forEach(d=>{Object.getPrototypeOf(new Uint8Array(d[1]));let v=on.Principal.from(new Uint8Array(d[1])).toText(),w=(0,ui.lookup_path)(["public_key"],d[2]);if(w.byteLength!==44)throw new Error("Invalid public key length");l.set(v,w)}),{subnetId:on.Principal.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:l}};ft.fetchNodeKeys=N_;var P_=(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.`)};ft.encodePath=P_;var q0=t=>(0,A_.toHex)(t),k0=t=>j0.decode(t),R_=t=>new TextDecoder().decode(t),I_=t=>k0(t).map(r=>on.Principal.fromUint8Array(new Uint8Array(r)))});var ah=J(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.add5L=be.add5H=be.add4H=be.add4L=be.add3H=be.add3L=be.add=be.rotlBL=be.rotlBH=be.rotlSL=be.rotlSH=be.rotr32L=be.rotr32H=be.rotrBL=be.rotrBH=be.rotrSL=be.rotrSH=be.shrSL=be.shrSH=be.toBig=be.split=be.fromBig=void 0;var No=BigInt(2**32-1),wu=BigInt(32);function xu(t,e=!1){return e?{h:Number(t&No),l:Number(t>>wu&No)}:{h:Number(t>>wu&No)|0,l:Number(t&No)|0}}be.fromBig=xu;function V0(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}=xu(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}be.split=V0;var H0=(t,e)=>BigInt(t>>>0)<<wu|BigInt(e>>>0);be.toBig=H0;var $0=(t,e,r)=>t>>>r;be.shrSH=$0;var K0=(t,e,r)=>t<<32-r|e>>>r;be.shrSL=K0;var G0=(t,e,r)=>t>>>r|e<<32-r;be.rotrSH=G0;var Y0=(t,e,r)=>t<<32-r|e>>>r;be.rotrSL=Y0;var W0=(t,e,r)=>t<<64-r|e>>>r-32;be.rotrBH=W0;var z0=(t,e,r)=>t>>>r-32|e<<64-r;be.rotrBL=z0;var D0=(t,e)=>e;be.rotr32H=D0;var Z0=(t,e)=>t;be.rotr32L=Z0;var X0=(t,e,r)=>t<<r|e>>>32-r;be.rotlSH=X0;var J0=(t,e,r)=>e<<r|t>>>32-r;be.rotlSL=J0;var L0=(t,e,r)=>e<<r-32|t>>>64-r;be.rotlBH=L0;var Q0=(t,e,r)=>t<<r-32|e>>>64-r;be.rotlBL=Q0;function eh(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}be.add=eh;var th=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);be.add3L=th;var rh=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;be.add3H=rh;var nh=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);be.add4L=nh;var ih=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;be.add4H=ih;var sh=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);be.add5L=sh;var oh=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0;be.add5H=oh;var U_={fromBig:xu,split:V0,toBig:H0,shrSH:$0,shrSL:K0,rotrSH:G0,rotrSL:Y0,rotrBH:W0,rotrBL:z0,rotr32H:D0,rotr32L:Z0,rotlSH:X0,rotlSL:J0,rotlBH:L0,rotlBL:Q0,add:eh,add3L:th,add3H:rh,add4L:nh,add4H:ih,add5H:oh,add5L:sh};be.default=U_});var ch=J(tr=>{"use strict";Object.defineProperty(tr,"__esModule",{value:!0});tr.sha384=tr.sha512_256=tr.sha512_224=tr.sha512=tr.SHA512=void 0;var F_=Ia(),Ee=ah(),Po=xn(),[M_,C_]=Ee.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))),an=new Uint32Array(80),cn=new Uint32Array(80),Nn=class extends F_.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:l,Fh:d,Fl:v,Gh:w,Gl:g,Hh:x,Hl:N}=this;return[e,r,n,i,s,o,a,c,f,l,d,v,w,g,x,N]}set(e,r,n,i,s,o,a,c,f,l,d,v,w,g,x,N){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=l|0,this.Fh=d|0,this.Fl=v|0,this.Gh=w|0,this.Gl=g|0,this.Hh=x|0,this.Hl=N|0}process(e,r){for(let O=0;O<16;O++,r+=4)an[O]=e.getUint32(r),cn[O]=e.getUint32(r+=4);for(let O=16;O<80;O++){let $=an[O-15]|0,P=cn[O-15]|0,k=Ee.default.rotrSH($,P,1)^Ee.default.rotrSH($,P,8)^Ee.default.shrSH($,P,7),Z=Ee.default.rotrSL($,P,1)^Ee.default.rotrSL($,P,8)^Ee.default.shrSL($,P,7),z=an[O-2]|0,K=cn[O-2]|0,se=Ee.default.rotrSH(z,K,19)^Ee.default.rotrBH(z,K,61)^Ee.default.shrSH(z,K,6),te=Ee.default.rotrSL(z,K,19)^Ee.default.rotrBL(z,K,61)^Ee.default.shrSL(z,K,6),de=Ee.default.add4L(Z,te,cn[O-7],cn[O-16]),ue=Ee.default.add4H(de,k,se,an[O-7],an[O-16]);an[O]=ue|0,cn[O]=de|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:f,Dl:l,Eh:d,El:v,Fh:w,Fl:g,Gh:x,Gl:N,Hh:T,Hl:q}=this;for(let O=0;O<80;O++){let $=Ee.default.rotrSH(d,v,14)^Ee.default.rotrSH(d,v,18)^Ee.default.rotrBH(d,v,41),P=Ee.default.rotrSL(d,v,14)^Ee.default.rotrSL(d,v,18)^Ee.default.rotrBL(d,v,41),k=d&w^~d&x,Z=v&g^~v&N,z=Ee.default.add5L(q,P,Z,C_[O],cn[O]),K=Ee.default.add5H(z,T,$,k,M_[O],an[O]),se=z|0,te=Ee.default.rotrSH(n,i,28)^Ee.default.rotrBH(n,i,34)^Ee.default.rotrBH(n,i,39),de=Ee.default.rotrSL(n,i,28)^Ee.default.rotrBL(n,i,34)^Ee.default.rotrBL(n,i,39),ue=n&s^n&a^s&a,Te=i&o^i&c^o&c;T=x|0,q=N|0,x=w|0,N=g|0,w=d|0,g=v|0,{h:d,l:v}=Ee.default.add(f|0,l|0,K|0,se|0),f=a|0,l=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let D=Ee.default.add3L(se,de,Te);n=Ee.default.add3H(D,K,te,ue),i=D|0}({h:n,l:i}=Ee.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=Ee.default.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=Ee.default.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l}=Ee.default.add(this.Dh|0,this.Dl|0,f|0,l|0),{h:d,l:v}=Ee.default.add(this.Eh|0,this.El|0,d|0,v|0),{h:w,l:g}=Ee.default.add(this.Fh|0,this.Fl|0,w|0,g|0),{h:x,l:N}=Ee.default.add(this.Gh|0,this.Gl|0,x|0,N|0),{h:T,l:q}=Ee.default.add(this.Hh|0,this.Hl|0,T|0,q|0),this.set(n,i,s,o,a,c,f,l,d,v,w,g,x,N,T,q)}roundClean(){an.fill(0),cn.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)}};tr.SHA512=Nn;var Eu=class extends Nn{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 Nn{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}},Bu=class extends Nn{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}};tr.sha512=(0,Po.wrapConstructor)(()=>new Nn);tr.sha512_224=(0,Po.wrapConstructor)(()=>new Eu);tr.sha512_256=(0,Po.wrapConstructor)(()=>new vu);tr.sha384=(0,Po.wrapConstructor)(()=>new Bu)});var fh=J(Io=>{"use strict";Object.defineProperty(Io,"__esModule",{value:!0});Io.twistedEdwards=void 0;var q_=Hr(),Gr=Qt(),un=Qt(),uh=au(),fr=BigInt(0),Wt=BigInt(1),Ro=BigInt(2),j_=BigInt(8),k_={zip215:!0};function V_(t){let e=(0,uh.validateBasic)(t);return Gr.validateObject(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function H_(t){let e=V_(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,f=Ro<<BigInt(a*8)-Wt,l=r.create,d=e.uvRatio||((j,I)=>{try{return{isValid:!0,value:r.sqrt(j*r.inv(I))}}catch{return{isValid:!1,value:fr}}}),v=e.adjustScalarBytes||(j=>j),w=e.domain||((j,I,W)=>{if(I.length||W)throw new Error("Contexts/pre-hash are not supported");return j}),g=j=>typeof j=="bigint"&&fr<j,x=(j,I)=>g(j)&&g(I)&&j<I,N=j=>j===fr||x(j,f);function T(j,I){if(x(j,I))return j;throw new Error(`Expected valid scalar < ${I}, got ${typeof j} ${j}`)}function q(j){return j===fr?j:T(j,n)}let O=new Map;function $(j){if(!(j instanceof P))throw new Error("ExtendedPoint expected")}class P{constructor(I,W,L,ie){if(this.ex=I,this.ey=W,this.ez=L,this.et=ie,!N(I))throw new Error("x required");if(!N(W))throw new Error("y required");if(!N(L))throw new Error("z required");if(!N(ie))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(I){if(I instanceof P)throw new Error("extended point not allowed");let{x:W,y:L}=I||{};if(!N(W)||!N(L))throw new Error("invalid affine point");return new P(W,L,Wt,l(W*L))}static normalizeZ(I){let W=r.invertBatch(I.map(L=>L.ez));return I.map((L,ie)=>L.toAffine(W[ie])).map(P.fromAffine)}_setWindowSize(I){this._WINDOW_SIZE=I,O.delete(this)}assertValidity(){let{a:I,d:W}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:L,ey:ie,ez:U,et:y}=this,fe=l(L*L),ae=l(ie*ie),ce=l(U*U),ee=l(ce*ce),u=l(fe*I),h=l(ce*l(u+ae)),p=l(ee+l(W*l(fe*ae)));if(h!==p)throw new Error("bad point: equation left != right (1)");let B=l(L*ie),E=l(U*y);if(B!==E)throw new Error("bad point: equation left != right (2)")}equals(I){$(I);let{ex:W,ey:L,ez:ie}=this,{ex:U,ey:y,ez:fe}=I,ae=l(W*fe),ce=l(U*ie),ee=l(L*fe),u=l(y*ie);return ae===ce&&ee===u}is0(){return this.equals(P.ZERO)}negate(){return new P(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){let{a:I}=e,{ex:W,ey:L,ez:ie}=this,U=l(W*W),y=l(L*L),fe=l(Ro*l(ie*ie)),ae=l(I*U),ce=W+L,ee=l(l(ce*ce)-U-y),u=ae+y,h=u-fe,p=ae-y,B=l(ee*h),E=l(u*p),S=l(ee*p),F=l(h*u);return new P(B,E,F,S)}add(I){$(I);let{a:W,d:L}=e,{ex:ie,ey:U,ez:y,et:fe}=this,{ex:ae,ey:ce,ez:ee,et:u}=I;if(W===BigInt(-1)){let le=l((U-ie)*(ce+ae)),Be=l((U+ie)*(ce-ae)),Ie=l(Be-le);if(Ie===fr)return this.double();let Ve=l(y*Ro*u),xe=l(fe*Ro*ee),he=xe+Ve,ze=Be+le,Fr=xe-Ve,_n=l(he*Ie),wn=l(ze*Fr),Ft=l(he*Fr),Pe=l(Ie*ze);return new P(_n,wn,Pe,Ft)}let h=l(ie*ae),p=l(U*ce),B=l(fe*L*u),E=l(y*ee),S=l((ie+U)*(ae+ce)-h-p),F=E-B,m=E+B,A=l(p-W*h),M=l(S*F),R=l(m*A),Y=l(S*A),Q=l(F*m);return new P(M,R,Q,Y)}subtract(I){return this.add(I.negate())}wNAF(I){return z.wNAFCached(this,O,I,P.normalizeZ)}multiply(I){let{p:W,f:L}=this.wNAF(T(I,n));return P.normalizeZ([W,L])[0]}multiplyUnsafe(I){let W=q(I);return W===fr?Z:this.equals(Z)||W===Wt?this:this.equals(k)?this.wNAF(W).p:z.unsafeLadder(this,W)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return z.unsafeLadder(this,n).is0()}toAffine(I){let{ex:W,ey:L,ez:ie}=this,U=this.is0();I==null&&(I=U?j_:r.inv(ie));let y=l(W*I),fe=l(L*I),ae=l(ie*I);if(U)return{x:fr,y:Wt};if(ae!==Wt)throw new Error("invZ was invalid");return{x:y,y:fe}}clearCofactor(){let{h:I}=e;return I===Wt?this:this.multiplyUnsafe(I)}static fromHex(I,W=!1){let{d:L,a:ie}=e,U=r.BYTES;I=(0,un.ensureBytes)("pointHex",I,U);let y=I.slice(),fe=I[U-1];y[U-1]=fe&-129;let ae=Gr.bytesToNumberLE(y);ae===fr||(W?T(ae,f):T(ae,r.ORDER));let ce=l(ae*ae),ee=l(ce-Wt),u=l(L*ce-ie),{isValid:h,value:p}=d(ee,u);if(!h)throw new Error("Point.fromHex: invalid y coordinate");let B=(p&Wt)===Wt,E=(fe&128)!==0;if(!W&&p===fr&&E)throw new Error("Point.fromHex: x=0 and x_0=1");return E!==B&&(p=l(-p)),P.fromAffine({x:p,y:ae})}static fromPrivateKey(I){return te(I).point}toRawBytes(){let{x:I,y:W}=this.toAffine(),L=Gr.numberToBytesLE(W,r.BYTES);return L[L.length-1]|=I&Wt?128:0,L}toHex(){return Gr.bytesToHex(this.toRawBytes())}}P.BASE=new P(e.Gx,e.Gy,Wt,l(e.Gx*e.Gy)),P.ZERO=new P(fr,Wt,Wt,fr);let{BASE:k,ZERO:Z}=P,z=(0,uh.wNAF)(P,a*8);function K(j){return(0,q_.mod)(j,n)}function se(j){return K(Gr.bytesToNumberLE(j))}function te(j){let I=a;j=(0,un.ensureBytes)("private key",j,I);let W=(0,un.ensureBytes)("hashed private key",s(j),2*I),L=v(W.slice(0,I)),ie=W.slice(I,2*I),U=se(L),y=k.multiply(U),fe=y.toRawBytes();return{head:L,prefix:ie,scalar:U,point:y,pointBytes:fe}}function de(j){return te(j).pointBytes}function ue(j=new Uint8Array,...I){let W=Gr.concatBytes(...I);return se(s(w(W,(0,un.ensureBytes)("context",j),!!i)))}function Te(j,I,W={}){j=(0,un.ensureBytes)("message",j),i&&(j=i(j));let{prefix:L,scalar:ie,pointBytes:U}=te(I),y=ue(W.context,L,j),fe=k.multiply(y).toRawBytes(),ae=ue(W.context,fe,U,j),ce=K(y+ae*ie);q(ce);let ee=Gr.concatBytes(fe,Gr.numberToBytesLE(ce,r.BYTES));return(0,un.ensureBytes)("result",ee,a*2)}let D=k_;function C(j,I,W,L=D){let{context:ie,zip215:U}=L,y=r.BYTES;j=(0,un.ensureBytes)("signature",j,2*y),I=(0,un.ensureBytes)("message",I),i&&(I=i(I));let fe=Gr.bytesToNumberLE(j.slice(y,2*y)),ae,ce,ee;try{ae=P.fromHex(W,U),ce=P.fromHex(j.slice(0,y),U),ee=k.multiplyUnsafe(fe)}catch{return!1}if(!U&&ae.isSmallOrder())return!1;let u=ue(ie,ce.toRawBytes(),ae.toRawBytes(),I);return ce.add(ae.multiplyUnsafe(u)).subtract(ee).clearCofactor().equals(P.ZERO)}return k._setWindowSize(8),{CURVE:e,getPublicKey:de,sign:Te,verify:C,ExtendedPoint:P,utils:{getExtendedPublicKey:te,randomPrivateKey:()=>o(r.BYTES),precompute(j=8,I=P.BASE){return I._setWindowSize(j),I.multiply(BigInt(3)),I}}}}Io.twistedEdwards=H_});var dh=J(Uo=>{"use strict";Object.defineProperty(Uo,"__esModule",{value:!0});Uo.montgomery=void 0;var lh=Hr(),fi=Qt(),Di=BigInt(0),Tu=BigInt(1);function $_(t){return(0,fi.validateObject)(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function K_(t){let e=$_(t),{P:r}=e,n=O=>(0,lh.mod)(O,r),i=e.montgomeryBits,s=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(O=>O),c=e.powPminus2||(O=>(0,lh.pow)(O,r-BigInt(2),r));function f(O,$,P){let k=n(O*($-P));return $=n($-k),P=n(P+k),[$,P]}function l(O){if(typeof O=="bigint"&&Di<=O&&O<r)return O;throw new Error("Expected valid scalar 0 < scalar < CURVE.P")}let d=(e.a-BigInt(2))/BigInt(4);function v(O,$){let P=l(O),k=l($),Z=P,z=Tu,K=Di,se=P,te=Tu,de=Di,ue;for(let D=BigInt(i-1);D>=Di;D--){let C=k>>D&Tu;de^=C,ue=f(de,z,se),z=ue[0],se=ue[1],ue=f(de,K,te),K=ue[0],te=ue[1],de=C;let X=z+K,j=n(X*X),I=z-K,W=n(I*I),L=j-W,ie=se+te,U=se-te,y=n(U*X),fe=n(ie*I),ae=y+fe,ce=y-fe;se=n(ae*ae),te=n(Z*n(ce*ce)),z=n(j*W),K=n(L*(j+n(d*L)))}ue=f(de,z,se),z=ue[0],se=ue[1],ue=f(de,K,te),K=ue[0],te=ue[1];let Te=c(K);return n(z*Te)}function w(O){return(0,fi.numberToBytesLE)(n(O),s)}function g(O){let $=(0,fi.ensureBytes)("u coordinate",O,s);return o===32&&($[31]&=127),(0,fi.bytesToNumberLE)($)}function x(O){let $=(0,fi.ensureBytes)("scalar",O),P=$.length;if(P!==s&&P!==o)throw new Error(`Expected ${s} or ${o} bytes, got ${P}`);return(0,fi.bytesToNumberLE)(a($))}function N(O,$){let P=g($),k=x(O),Z=v(P,k);if(Z===Di)throw new Error("Invalid private or public key received");return w(Z)}let T=w(e.Gu);function q(O){return N(O,T)}return{scalarMult:N,scalarMultBase:q,getSharedSecret:(O,$)=>N(O,$),getPublicKey:O=>q(O),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:T}}Uo.montgomery=K_});var Iu=J(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.hash_to_ristretto255=ge.hashToRistretto255=ge.RistrettoPoint=ge.encodeToCurve=ge.hashToCurve=ge.edwardsToMontgomeryPriv=ge.edwardsToMontgomery=ge.edwardsToMontgomeryPub=ge.x25519=ge.ed25519ph=ge.ed25519ctx=ge.ed25519=ge.ED25519_TORSION_SUBGROUP=void 0;var Mo=ch(),Zi=xn(),Pu=fh(),G_=dh(),Ue=Hr(),Pn=Qt(),_h=bo(),Xi=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ou=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Y_=BigInt(0),vr=BigInt(1),Fo=BigInt(2),W_=BigInt(5),hh=BigInt(10),z_=BigInt(20),D_=BigInt(40),ph=BigInt(80);function wh(t){let e=Xi,n=t*t%e*t%e,i=(0,Ue.pow2)(n,Fo,e)*n%e,s=(0,Ue.pow2)(i,vr,e)*t%e,o=(0,Ue.pow2)(s,W_,e)*s%e,a=(0,Ue.pow2)(o,hh,e)*o%e,c=(0,Ue.pow2)(a,z_,e)*a%e,f=(0,Ue.pow2)(c,D_,e)*c%e,l=(0,Ue.pow2)(f,ph,e)*f%e,d=(0,Ue.pow2)(l,ph,e)*f%e,v=(0,Ue.pow2)(d,hh,e)*o%e;return{pow_p_5_8:(0,Ue.pow2)(v,Fo,e)*t%e,b2:n}}function xh(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function Ru(t,e){let r=Xi,n=(0,Ue.mod)(e*e*e,r),i=(0,Ue.mod)(n*n*e,r),s=wh(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*Ou,r),l=a===t,d=a===(0,Ue.mod)(-t,r),v=a===(0,Ue.mod)(-t*Ou,r);return l&&(o=c),(d||v)&&(o=f),(0,Ue.isNegativeLE)(o,r)&&(o=(0,Ue.mod)(-o,r)),{isValid:l||d,value:o}}ge.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var oe=(0,Ue.Field)(Xi,void 0,!0),Ji={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:oe,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Mo.sha512,randomBytes:Zi.randomBytes,adjustScalarBytes:xh,uvRatio:Ru};ge.ed25519=(0,Pu.twistedEdwards)(Ji);function Eh(t,e,r){if(e.length>255)throw new Error("Context is too big");return(0,Zi.concatBytes)((0,Zi.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}ge.ed25519ctx=(0,Pu.twistedEdwards)({...Ji,domain:Eh});ge.ed25519ph=(0,Pu.twistedEdwards)({...Ji,domain:Eh,prehash:Mo.sha512});ge.x25519=(0,G_.montgomery)({P:Xi,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=Xi,{pow_p_5_8:r,b2:n}=wh(t);return(0,Ue.mod)((0,Ue.pow2)(r,BigInt(3),e)*n,e)},adjustScalarBytes:xh,randomBytes:Zi.randomBytes});function vh(t){let{y:e}=ge.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return oe.toBytes(oe.create((r+e)*oe.inv(r-e)))}ge.edwardsToMontgomeryPub=vh;ge.edwardsToMontgomery=vh;function Z_(t){let e=Ji.hash(t.subarray(0,32));return Ji.adjustScalarBytes(e).subarray(0,32)}ge.edwardsToMontgomeryPriv=Z_;var X_=(oe.ORDER+BigInt(3))/BigInt(8),J_=oe.pow(Fo,X_),yh=oe.sqrt(oe.neg(oe.ONE)),L_=(oe.ORDER-BigInt(5))/BigInt(8),bh=BigInt(486662);function Q_(t){let e=oe.sqr(t);e=oe.mul(e,Fo);let r=oe.add(e,oe.ONE),n=oe.neg(bh),i=oe.sqr(r),s=oe.mul(i,r),o=oe.mul(e,bh);o=oe.mul(o,n),o=oe.add(o,i),o=oe.mul(o,n);let a=oe.sqr(s);i=oe.sqr(a),a=oe.mul(a,s),a=oe.mul(a,o),i=oe.mul(i,a);let c=oe.pow(i,L_);c=oe.mul(c,a);let f=oe.mul(c,yh);i=oe.sqr(c),i=oe.mul(i,s);let l=oe.eql(i,o),d=oe.cmov(f,c,l),v=oe.mul(n,e),w=oe.mul(c,t);w=oe.mul(w,J_);let g=oe.mul(w,yh),x=oe.mul(o,e);i=oe.sqr(w),i=oe.mul(i,s);let N=oe.eql(i,x),T=oe.cmov(g,w,N);i=oe.sqr(d),i=oe.mul(i,s);let q=oe.eql(i,o),O=oe.cmov(v,n,q),$=oe.cmov(T,d,q),P=oe.isOdd($);return $=oe.cmov($,oe.neg($),q!==P),{xMn:O,xMd:r,yMn:$,yMd:vr}}var ew=(0,Ue.FpSqrtEven)(oe,oe.neg(BigInt(486664)));function tw(t){let{xMn:e,xMd:r,yMn:n,yMd:i}=Q_(t),s=oe.mul(e,i);s=oe.mul(s,ew);let o=oe.mul(r,n),a=oe.sub(e,r),c=oe.add(e,r),f=oe.mul(o,c),l=oe.eql(f,oe.ZERO);s=oe.cmov(s,oe.ZERO,l),o=oe.cmov(o,oe.ONE,l),a=oe.cmov(a,oe.ONE,l),c=oe.cmov(c,oe.ONE,l);let d=oe.invertBatch([o,c]);return{x:oe.mul(s,d[0]),y:oe.mul(a,d[1])}}var Bh=(0,_h.createHasher)(ge.ed25519.ExtendedPoint,t=>tw(t[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:oe.ORDER,m:1,k:128,expand:"xmd",hash:Mo.sha512});ge.hashToCurve=Bh.hashToCurve;ge.encodeToCurve=Bh.encodeToCurve;function Su(t){if(!(t instanceof lr))throw new Error("RistrettoPoint expected")}var Nu=Ou,rw=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),nw=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),iw=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),sw=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),gh=t=>Ru(vr,t),ow=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Au=t=>ge.ed25519.CURVE.Fp.create((0,Pn.bytesToNumberLE)(t)&ow);function mh(t){let{d:e}=ge.ed25519.CURVE,r=ge.ed25519.CURVE.Fp.ORDER,n=ge.ed25519.CURVE.Fp.create,i=n(Nu*t*t),s=n((i+vr)*iw),o=BigInt(-1),a=n((o-e*i)*n(i+e)),{isValid:c,value:f}=Ru(s,a),l=n(f*t);(0,Ue.isNegativeLE)(l,r)||(l=n(-l)),c||(f=l),c||(o=i);let d=n(o*(i-vr)*sw-a),v=f*f,w=n((f+f)*a),g=n(d*rw),x=n(vr-v),N=n(vr+v);return new ge.ed25519.ExtendedPoint(n(w*N),n(x*g),n(g*N),n(w*x))}var lr=class t{constructor(e){this.ep=e}static fromAffine(e){return new t(ge.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,Pn.ensureBytes)("ristrettoHash",e,64);let r=Au(e.slice(0,32)),n=mh(r),i=Au(e.slice(32,64)),s=mh(i);return new t(n.add(s))}static fromHex(e){e=(0,Pn.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=Au(e);if(!(0,Pn.equalBytes)((0,Pn.numberToBytesLE)(a,32),e)||(0,Ue.isNegativeLE)(a,i))throw new Error(o);let c=s(a*a),f=s(vr+r*c),l=s(vr-r*c),d=s(f*f),v=s(l*l),w=s(r*n*d-v),{isValid:g,value:x}=gh(s(w*v)),N=s(x*l),T=s(x*N*w),q=s((a+a)*N);(0,Ue.isNegativeLE)(q,i)&&(q=s(-q));let O=s(f*T),$=s(q*O);if(!g||(0,Ue.isNegativeLE)($,i)||O===Y_)throw new Error(o);return new t(new ge.ed25519.ExtendedPoint(q,O,vr,$))}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:l}=gh(o(a*f)),d=o(l*a),v=o(l*c),w=o(d*v*i),g;if((0,Ue.isNegativeLE)(i*w,s)){let N=o(r*Nu),T=o(e*Nu);e=N,r=T,g=o(d*nw)}else g=v;(0,Ue.isNegativeLE)(e*w,s)&&(r=o(-r));let x=o((n-r)*g);return(0,Ue.isNegativeLE)(x,s)&&(x=o(-x)),(0,Pn.numberToBytesLE)(x,32)}toHex(){return(0,Pn.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){Su(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 Su(e),new t(this.ep.add(e.ep))}subtract(e){return Su(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=(lr.BASE||(lr.BASE=new lr(ge.ed25519.ExtendedPoint.BASE)),lr.ZERO||(lr.ZERO=new lr(ge.ed25519.ExtendedPoint.ZERO)),lr);var aw=(t,e)=>{let r=e.DST,n=typeof r=="string"?(0,Zi.utf8ToBytes)(r):r,i=(0,_h.expand_message_xmd)(t,n,64,Mo.sha512);return lr.hashToCurve(i)};ge.hashToRistretto255=aw;ge.hash_to_ristretto255=ge.hashToRistretto255});var Oh=J(fn=>{"use strict";var Th=fn&&fn.__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=fn&&fn.__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)},Ot,Li,Sh,Ah;Object.defineProperty(fn,"__esModule",{value:!0});fn.ExpirableMap=void 0;var Uu=class{constructor(e={}){Ot.set(this,void 0),Li.set(this,void 0),this[Sh]=this.entries.bind(this),this[Ah]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();Th(this,Ot,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),Th(this,Li,n,"f")}prune(){let e=Date.now();for(let[r,n]of Rt(this,Ot,"f").entries())e-n.timestamp>Rt(this,Li,"f")&&Rt(this,Ot,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return Rt(this,Ot,"f").set(e,n),this}get(e){let r=Rt(this,Ot,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>Rt(this,Li,"f")){Rt(this,Ot,"f").delete(e);return}return r.value}}clear(){Rt(this,Ot,"f").clear()}entries(){let e=Rt(this,Ot,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=Rt(this,Ot,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return Rt(this,Ot,"f").keys()}forEach(e,r){for(let[n,i]of Rt(this,Ot,"f").entries())e.call(r,i.value,n,this)}has(e){return Rt(this,Ot,"f").has(e)}delete(e){return Rt(this,Ot,"f").delete(e)}get size(){return Rt(this,Ot,"f").size}};fn.ExpirableMap=Uu;Ot=new WeakMap,Li=new WeakMap,Sh=Symbol.iterator,Ah=Symbol.toStringTag});var Fu=J(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});qe.unwrapDER=qe.wrapDER=qe.SECP256K1_OID=qe.ED25519_OID=qe.DER_COSE_OID=qe.decodeLen=qe.decodeLenBytes=qe.encodeLen=qe.encodeLenBytes=void 0;var cw=Kt(),uw=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)")};qe.encodeLenBytes=uw;var fw=(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)")};qe.encodeLen=fw;var lw=(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)")};qe.decodeLenBytes=lw;var dw=(t,e)=>{let r=(0,qe.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)")};qe.decodeLen=dw;qe.DER_COSE_OID=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]);qe.ED25519_OID=Uint8Array.from([48,5,6,3,43,101,112]);qe.SECP256K1_OID=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function hw(t,e){let r=2+(0,qe.encodeLenBytes)(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,s=new Uint8Array(1+(0,qe.encodeLenBytes)(n)+n);return s[i++]=48,i+=(0,qe.encodeLen)(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=(0,qe.encodeLen)(s,i,t.byteLength+1),s[i++]=0,s.set(new Uint8Array(t),i),s}qe.wrapDER=hw;var pw=(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,qe.decodeLenBytes)(i,r),!(0,cw.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,qe.decodeLen)(i,r)-1;r+=(0,qe.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};qe.unwrapDER=pw});var Mu=J(ln=>{"use strict";var Nh=ln&&ln.__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},Ph=ln&&ln.__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)},qo,jo;Object.defineProperty(ln,"__esModule",{value:!0});ln.Ed25519PublicKey=void 0;var Co=Fu(),ko=class t{constructor(e){if(qo.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");Nh(this,qo,e,"f"),Nh(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,Co.wrapDER)(e,Co.ED25519_OID).buffer}static derDecode(e){let r=(0,Co.unwrapDER)(e,Co.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 Ph(this,qo,"f")}get derKey(){return Ph(this,jo,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};ln.Ed25519PublicKey=ko;qo=new WeakMap,jo=new WeakMap;ko.RAW_KEY_LENGTH=32});var Fh=J(dn=>{"use strict";var Rh=dn&&dn.__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)},Cu,Ih,qu,Uh;Object.defineProperty(dn,"__esModule",{value:!0});dn.ObservableLog=dn.Observable=void 0;var Vo=class extends Function{constructor(){return super(),Cu.add(this),this.observers=[],new Proxy(this,{apply:(e,r,n)=>Rh(e,Cu,"m",Ih).call(e,n[0],...n.slice(1))})}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(r=>r!==e)}notify(e,...r){this.observers.forEach(n=>n(e,...r))}};dn.Observable=Vo;Cu=new WeakSet,Ih=function(e,...r){this.notify(e,...r)};var ju=class extends Vo{constructor(){return super(),qu.add(this),new Proxy(this,{apply:(e,r,n)=>Rh(e,qu,"m",Uh).call(e,n[0],...n.slice(1))})}log(e,...r){this.notify({message:e,level:"info"},...r)}warn(e,...r){this.notify({message:e,level:"warn"},...r)}error(e,r,...n){this.notify({message:e,level:"error",error:r},...n)}};dn.ObservableLog=ju;qu=new WeakSet,Uh=function(e,...r){this.log(e,...r)}});var Hh=J(Sr=>{"use strict";var Br=Sr&&Sr.__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},Nt=Sr&&Sr.__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)},Tr,Ho,$o,Ko,Go,Yo,Wo,zo,li;Object.defineProperty(Sr,"__esModule",{value:!0});Sr.exponentialBackoff=Sr.ExponentialBackoff=void 0;var Mh=.5,Ch=1.5,qh=500,jh=6e4,kh=9e5,Vh=10,di=class t{constructor(e=t.default){Tr.set(this,void 0),Ho.set(this,void 0),$o.set(this,void 0),Ko.set(this,void 0),Go.set(this,void 0),Yo.set(this,void 0),Wo.set(this,void 0),zo.set(this,void 0),li.set(this,0);let{initialInterval:r=qh,randomizationFactor:n=Mh,multiplier:i=Ch,maxInterval:s=jh,maxElapsedTime:o=kh,maxIterations:a=Vh,date:c=Date}=e;Br(this,Tr,r,"f"),Br(this,Ho,n,"f"),Br(this,$o,i,"f"),Br(this,Ko,s,"f"),Br(this,zo,c,"f"),Br(this,Go,c.now(),"f"),Br(this,Yo,o,"f"),Br(this,Wo,a,"f")}get ellapsedTimeInMsec(){return Nt(this,zo,"f").now()-Nt(this,Go,"f")}get currentInterval(){return Nt(this,Tr,"f")}get count(){return Nt(this,li,"f")}get randomValueFromInterval(){let e=Nt(this,Ho,"f")*Nt(this,Tr,"f"),r=Nt(this,Tr,"f")-e,n=Nt(this,Tr,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return Br(this,Tr,Math.min(Nt(this,Tr,"f")*Nt(this,$o,"f"),Nt(this,Ko,"f")),"f"),Br(this,li,(e=Nt(this,li,"f"),e++,e),"f"),Nt(this,Tr,"f")}next(){return this.ellapsedTimeInMsec>=Nt(this,Yo,"f")||Nt(this,li,"f")>=Nt(this,Wo,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Sr.ExponentialBackoff=di;Tr=new WeakMap,Ho=new WeakMap,$o=new WeakMap,Ko=new WeakMap,Go=new WeakMap,Yo=new WeakMap,Wo=new WeakMap,zo=new WeakMap,li=new WeakMap;di.default={initialInterval:qh,randomizationFactor:Mh,multiplier:Ch,maxInterval:jh,maxElapsedTime:kh,maxIterations:Vh,date:Date};function*yw(t=di.default){let e=new di(t),r=e.next();for(;r;)yield r,r=e.next()}Sr.exponentialBackoff=yw});var $u=J(Me=>{"use strict";var Kh=Me&&Me.__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]}),bw=Me&&Me.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Gh=Me&&Me.__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)&&Kh(e,t,r);return bw(e,t),e},gw=Me&&Me.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Kh(e,t,r)},Do=Me&&Me.__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},ve=Me&&Me.__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)},Or,dr,Rn,Jo,hi,pi,In,Un,Yh,Lo,Qo;Object.defineProperty(Me,"__esModule",{value:!0});Me.HttpAgent=Me.IdentityInvalidError=Me.MANAGEMENT_CANISTER_ID=Me.IC_ROOT_KEY=Me.RequestStatusResponseStatus=Me.makeNonce=void 0;var rr=Ct(),yi=Xn(),mw=Vc(),hn=Gh(qi()),Zo=Fi(),ku=Kt(),Ar=co(),Vu=ji(),$h=Jc(),_w=zi(),Qi=Wi(),ww=Iu(),xw=Oh(),Ew=Mu(),vw=Bo(),Bw=Fh(),Tw=Hh();gw(co(),Me);var Sw=ji();Object.defineProperty(Me,"makeNonce",{enumerable:!0,get:function(){return Sw.makeNonce}});var Aw;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(Aw=Me.RequestStatusResponseStatus||(Me.RequestStatusResponseStatus={}));var Xo=5*60*1e3;Me.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";Me.MANAGEMENT_CANISTER_ID="aaaaa-aa";var Ow="ic0.app",Nw=".ic0.app",Pw="icp0.io",Rw=".icp0.io",Iw="icp-api.io",Uw=".icp-api.io",es=class extends yi.AgentError{constructor(e){super(e),this.message=e}},Fn=class extends yi.AgentError{constructor(e){super(e),this.message=e}};Me.IdentityInvalidError=Fn;function Fw(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new es("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 es("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 es("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}var Hu=class t{constructor(e={}){var r;if(Or.add(this),this.rootKey=(0,ku.fromHex)(Me.IC_ROOT_KEY),this._timeDiffMsecs=0,this._rootKeyFetched=!1,dr.set(this,void 0),Rn.set(this,void 0),this._isAgent=!0,Jo.set(this,0),this.log=new Bw.ObservableLog,hi.set(this,[]),pi.set(this,[]),In.set(this,new xw.ExpirableMap({expirationTime:5*60*1e3})),Un.set(this,!0),Qo.set(this,(i,s)=>{if(ve(this,Un,"f")===!1)return i;if(!s)throw new Qi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:o,signatures:a=[],requestId:c}=i,f=new TextEncoder().encode("\vic-response");for(let l of a){let{timestamp:d,identity:v}=l,w=rr.Principal.fromUint8Array(v).toText(),g;if(o==="replied"){let{reply:O}=i;g=(0,Zo.hashOfMap)({status:o,reply:O,timestamp:BigInt(d),request_id:c})}else if(o==="rejected"){let{reject_code:O,reject_message:$,error_code:P}=i;g=(0,Zo.hashOfMap)({status:o,reject_code:O,reject_message:$,error_code:P,timestamp:BigInt(d),request_id:c})}else throw new Error(`Unknown status: ${o}`);let x=(0,ku.concat)(f,new Uint8Array(g)),N=s?.nodeKeys.get(w);if(!N)throw new Qi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let T=Ew.Ed25519PublicKey.fromDer(N).rawKey;if(ww.ed25519.verify(l.signature,new Uint8Array(x),new Uint8Array(T)))return i;throw new Qi.CertificateVerificationError(`Invalid signature from replica ${w} signed query.`)}return i}),e.source){if(!(e.source instanceof t))throw new Error("An Agent's source can only be another HttpAgent");this._identity=e.source._identity,this._fetch=e.source._fetch,this._host=e.source._host,this._credentials=e.source._credentials}else this._fetch=e.fetch||Fw()||fetch.bind(global),this._fetchOptions=e.fetchOptions,this._callOptions=e.callOptions;if(e.host!==void 0)!e.host.match(/^[a-z]+:/)&&typeof window<"u"?this._host=new URL(window.location.protocol+"//"+e.host):this._host=new URL(e.host);else if(e.source!==void 0)this._host=e.source._host;else{let i=typeof window<"u"?window.location:void 0;i||(this._host=new URL("https://icp-api.io"),this.log.warn("Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning."));let s=["ic0.app","icp0.io","127.0.0.1","localhost"],o=[".github.dev",".gitpod.io"],a=i?.hostname,c;a&&typeof a=="string"&&(o.some(f=>a.endsWith(f))?c=a:c=s.find(f=>a.endsWith(f))),i&&c?this._host=new URL(`${i.protocol}//${c}${i.port?":"+i.port:""}`):(this._host=new URL("https://icp-api.io"),this.log.warn("Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning."))}e.verifyQuerySignatures!==void 0&&Do(this,Un,e.verifyQuerySignatures,"f"),Do(this,dr,(r=e.retryTimes)!==null&&r!==void 0?r:3,"f");let n=()=>new Tw.ExponentialBackoff({maxIterations:ve(this,dr,"f")});if(Do(this,Rn,e.backoffStrategy||n,"f"),this._host.hostname.endsWith(Nw)?this._host.hostname=Ow:this._host.hostname.endsWith(Rw)?this._host.hostname=Pw:this._host.hostname.endsWith(Uw)&&(this._host.hostname=Iw),e.credentials){let{name:i,password:s}=e.credentials;this._credentials=`${i}${s?":"+s:""}`}this._identity=Promise.resolve(e.identity||new mw.AnonymousIdentity),this.addTransform("update",(0,Ar.makeNonceTransform)(Vu.makeNonce)),e.useQueryNonces&&this.addTransform("query",(0,Ar.makeNonceTransform)(Vu.makeNonce)),e.logToConsole&&this.log.subscribe(i=>{i.level==="error"?console.error(i.message):i.level==="warn"?console.warn(i.message):console.log(i.message)})}get waterMark(){return ve(this,Jo,"f")}isLocal(){let e=this._host.hostname;return e==="127.0.0.1"||e.endsWith("127.0.0.1")}addTransform(e,r,n=r.priority||0){if(e==="update"){let i=ve(this,pi,"f").findIndex(s=>(s.priority||0)<n);ve(this,pi,"f").splice(i>=0?i:ve(this,pi,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=ve(this,hi,"f").findIndex(s=>(s.priority||0)<n);ve(this,hi,"f").splice(i>=0?i:ve(this,hi,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!this._identity)throw new Fn("This identity has expired due this application's security policy. Please refresh your authentication.");return(await this._identity).getPrincipal()}async call(e,r,n){let i=await(n!==void 0?await n:await this._identity);if(!i)throw new Fn("This identity has expired due this application's security policy. Please refresh your authentication.");let s=rr.Principal.from(e),o=r.effectiveCanisterId?rr.Principal.from(r.effectiveCanisterId):s,a=i.getPrincipal()||rr.Principal.anonymous(),c=new Ar.Expiry(Xo);Math.abs(this._timeDiffMsecs)>1e3*30&&(c=new Ar.Expiry(Xo+this._timeDiffMsecs));let f={request_type:Vu.SubmitRequestType.Call,canister_id:s,method_name:r.methodName,arg:r.arg,sender:a,ingress_expiry:c},l=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"call",body:f});l=await i.transformRequest(l);let d=hn.encode(l.body);this.log(`fetching "/api/v2/canister/${o.toText()}/call" with request:`,l);let v=ve(this,Rn,"f").call(this),w=ve(this,Or,"m",Lo).call(this,{request:()=>this._fetch(""+new URL(`/api/v2/canister/${o.toText()}/call`,this._host),Object.assign(Object.assign(Object.assign({},this._callOptions),l.request),{body:d})),backoff:v,tries:0}),[g,x]=await Promise.all([w,(0,Zo.requestIdOf)(f)]),N=await g.arrayBuffer(),T=g.status===200&&N.byteLength>0?hn.decode(N):null;return{requestId:x,response:{ok:g.ok,status:g.status,statusText:g.statusText,body:T,headers:(0,Ar.httpHeadersTransform)(g.headers)}}}async query(e,r,n){let i=ve(this,Rn,"f").call(this),s=r.effectiveCanisterId?rr.Principal.from(r.effectiveCanisterId):rr.Principal.from(e);this.log(`ecid ${s.toString()}`),this.log(`canisterId ${e.toString()}`);let o=async()=>{let l=await(n!==void 0?await n:await this._identity);if(!l)throw new Fn("This identity has expired due this application's security policy. Please refresh your authentication.");let d=rr.Principal.from(e),v=l?.getPrincipal()||rr.Principal.anonymous(),w={request_type:"query",canister_id:d,method_name:r.methodName,arg:r.arg,sender:v,ingress_expiry:new Ar.Expiry(Xo)},g=await(0,Zo.requestIdOf)(w),x=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read",body:w});x=await l?.transformRequest(x);let N=hn.encode(x.body),T={canister:d.toText(),ecid:s,transformedRequest:x,body:N,requestId:g,backoff:i,tries:0};return await ve(this,Or,"m",Yh).call(this,T)},a=async()=>{if(!ve(this,Un,"f"))return;let l=ve(this,In,"f").get(s.toString());return l||(await this.fetchSubnetKeys(s.toString()),ve(this,In,"f").get(s.toString()))},[c,f]=await Promise.all([o(),a()]);if(this.log("Query response:",c),!ve(this,Un,"f"))return c;try{return ve(this,Qo,"f").call(this,c,f)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ve(this,In,"f").delete(e.toString()),await this.fetchSubnetKeys(s.toString());let d=ve(this,In,"f").get(e.toString());if(!d)throw new Qi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");return ve(this,Qo,"f").call(this,c,d)}}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await this._identity);if(!n)throw new Fn("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||rr.Principal.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new Ar.Expiry(Xo)}});return n?.transformRequest(s)}async readState(e,r,n,i){let s=typeof e=="string"?rr.Principal.fromText(e):e,o=i??await this.createReadStateRequest(r,n),a=hn.encode(o.body);this.log(`fetching "/api/v2/canister/${s}/read_state" with request:`,o);let c=ve(this,Rn,"f").call(this),f=await ve(this,Or,"m",Lo).call(this,{request:()=>this._fetch(""+new URL(`/api/v2/canister/${s.toString()}/read_state`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),o.request),{body: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 l=hn.decode(await f.arrayBuffer());this.log("Read state response:",l);let d=await this.parseTimeFromResponse(l);return d>0&&(this.log("Read state response time:",d),Do(this,Jo,d,"f")),l}async parseTimeFromResponse(e){let r;if(e.certificate){let n=hn.decode(e.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=(0,Qi.lookup_path)(["time"],r);if(!i)throw new Error("Time was not found in the response or was not in its expected format.");if(!(i instanceof ArrayBuffer)&&!ArrayBuffer.isView(i))throw new Error("Time was not found in the response or was not in its expected format.");let s=(0,vw.decodeTime)((0,ku.bufFromBufLike)(i));return this.log("Time from response:",s),this.log("Time from response in milliseconds:",Number(s)),Number(s)}else this.log.warn("No certificate found in response");return 0}async syncTime(e){let r=await Promise.resolve().then(()=>Gh(zi())),n=Date.now();try{e||this.log("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let s=(await r.request({canisterId:e??rr.Principal.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");s&&(this._timeDiffMsecs=Number(s)-Number(n))}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{};this.log('fetching "/api/v2/status"');let r=ve(this,Rn,"f").call(this),n=await ve(this,Or,"m",Lo).call(this,{backoff:r,request:()=>this._fetch(""+new URL("/api/v2/status",this._host),Object.assign({headers:e},this._fetchOptions)),tries:0});return hn.decode(await n.arrayBuffer())}async fetchRootKey(){return this._rootKeyFetched||(this.rootKey=(await this.status()).root_key,this._rootKeyFetched=!0),this.rootKey}invalidateIdentity(){this._identity=null}replaceIdentity(e){this._identity=Promise.resolve(e)}async fetchSubnetKeys(e){let r=rr.Principal.from(e),i=(await(0,_w.request)({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return ve(this,In,"f").set(r.toText(),i),i}_transform(e){let r=Promise.resolve(e);if(e.endpoint==="call")for(let n of ve(this,pi,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of ve(this,hi,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};Me.HttpAgent=Hu;dr=new WeakMap,Rn=new WeakMap,Jo=new WeakMap,hi=new WeakMap,pi=new WeakMap,In=new WeakMap,Un=new WeakMap,Qo=new WeakMap,Or=new WeakSet,Yh=async function t(e){var r,n;let{ecid:i,transformedRequest:s,body:o,requestId:a,backoff:c,tries:f}=e,l=f===0?0:c.next();if(this.log(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:f,backoff:c,delay:l}),l===null)throw new yi.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ve(this,dr,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);l>0&&await new Promise(g=>setTimeout(g,l));let d;try{this.log(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let g=await this._fetch(""+new URL(`/api/v2/canister/${i.toString()}/query`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),s.request),{body:o}));if(g.status===200){let x=hn.decode(await g.arrayBuffer());d=Object.assign(Object.assign({},x),{httpDetails:{ok:g.ok,status:g.status,statusText:g.statusText,headers:(0,Ar.httpHeadersTransform)(g.headers)},requestId:a})}else throw new $h.AgentHTTPResponseError(`Server returned an error:
|
|
33
|
+
Code: ${g.status} (${g.statusText})
|
|
34
|
+
Body: ${await g.text()}
|
|
35
|
+
`,{ok:g.ok,status:g.status,statusText:g.statusText,headers:(0,Ar.httpHeadersTransform)(g.headers)})}catch(g){if(f<ve(this,dr,"f"))return this.log.warn(`Caught exception while attempting to make query:
|
|
36
|
+
${g}
|
|
37
|
+
Retrying query.`),await ve(this,Or,"m",t).call(this,Object.assign(Object.assign({},e),{tries:f+1}));throw g}let v=(n=(r=d.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!ve(this,Un,"f"))return d;if(!v)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let w=Number(BigInt(v)/BigInt(1e6));if(this.log("watermark and timestamp",{waterMark:this.waterMark,timestamp:w}),Number(this.waterMark)>w){let g=new yi.AgentError("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",g,{timestamp:v,waterMark:this.waterMark}),f<ve(this,dr,"f"))return await ve(this,Or,"m",t).call(this,Object.assign(Object.assign({},e),{tries:f+1}));throw new yi.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ve(this,dr,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return d},Lo=async function t(e){let{request:r,backoff:n,tries:i}=e,s=i===0?0:n.next();if(s===null)throw new yi.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ve(this,dr,"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(ve(this,dr,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
|
|
38
|
+
${f}
|
|
39
|
+
Retrying request.`),await ve(this,Or,"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
|
+
Code: ${o.status} (${o.statusText})
|
|
41
|
+
Body: ${a}
|
|
42
|
+
`;if(i<ve(this,dr,"f"))return await ve(this,Or,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw new $h.AgentHTTPResponseError(c,{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,Ar.httpHeadersTransform)(o.headers)})}});var Wh=J(Yr=>{"use strict";Object.defineProperty(Yr,"__esModule",{value:!0});Yr.ProxyAgent=Yr.ProxyStubAgent=Yr.ProxyMessageKind=void 0;var Mw=Ct(),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=Yr.ProxyMessageKind||(Yr.ProxyMessageKind={}));var Ku=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)}`)}}};Yr.ProxyStubAgent=Ku;var Gu=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 Mw.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}};Yr.ProxyAgent=Gu});var ta=J(nr=>{"use strict";var Cw=nr&&nr.__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]}),ea=nr&&nr.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Cw(e,t,r)};Object.defineProperty(nr,"__esModule",{value:!0});nr.getDefaultAgent=void 0;ea(Sl(),nr);ea($u(),nr);ea(Jc(),nr);ea(Wh(),nr);function qw(){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}nr.getDefaultAgent=qw});var Yu=J(gt=>{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.chain=gt.backoff=gt.timeout=gt.throttle=gt.maxAttempts=gt.conditionalDelay=gt.once=gt.defaultStrategy=void 0;var zh=Kt(),jw=5*60*1e3;function kw(){return Lh(Zh(Dh(),1e3),Jh(1e3,1.2),Xh(jw))}gt.defaultStrategy=kw;function Dh(){let t=!0;return async()=>t?(t=!1,!0):!1}gt.once=Dh;function Zh(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(s=>setTimeout(s,e))}}gt.conditionalDelay=Zh;function Vw(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,zh.toHex)(n)}
|
|
44
44
|
Request status: ${i}
|
|
45
|
-
`)}}
|
|
46
|
-
Request ID: ${(0,
|
|
45
|
+
`)}}gt.maxAttempts=Vw;function Hw(t){return()=>new Promise(e=>setTimeout(e,t))}gt.throttle=Hw;function Xh(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,zh.toHex)(n)}
|
|
47
47
|
Request status: ${i}
|
|
48
|
-
`)}}
|
|
49
|
-
Request ID: ${(0,
|
|
50
|
-
Reject code: ${
|
|
51
|
-
Reject text: ${
|
|
52
|
-
`)}case
|
|
53
|
-
Request ID: ${(0,
|
|
54
|
-
`)}throw new Error("unreachable")}
|
|
55
|
-
`)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}};ft.ActorCallError=Di;var Vo=class extends Di{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=Ru.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};ft.QueryCallRejectedError=Vo;var Ho=class extends Di{constructor(e,r,n,i){super(e,r,"update",Object.assign({"Request ID":(0,Bw.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}};ft.UpdateCallRejectedError=Ho;var nr=Symbol.for("ic-agent-metadata"),$o=class t{constructor(e){this[nr]=Object.freeze(e)}static agentOf(e){return e[nr].config.agent}static interfaceOf(e){return e[nr].service}static canisterIdOf(e){return vr.Principal.from(e[nr].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"?vr.Principal.fromText(r.canisterId):r.canisterId;await Uu(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,sender_canister_version:[]})}static async createCanister(e,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[]}]}let{canister_id:i}=await Uu(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:ko.IDL});class i extends t{constructor(o){if(!o.canisterId)throw new Iu.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"?vr.Principal.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Fh),o),{canisterId:a}),service:n});for(let[c,l]of n._fields)r?.httpDetails&&l.annotations.push(ft.ACTOR_METHOD_WITH_HTTP_DETAILS),this[c]=Sw(this,c,l,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Iu.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)}};ft.Actor=$o;function jo(t,e){let r=ko.IDL.decode(t,vw.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var Fh={pollingStrategyFactory:Uh.strategy.defaultStrategy};ft.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";function Sw(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,l;o=Object.assign(Object.assign({},o),(l=(c=t[nr].config).queryTransform)===null||l===void 0?void 0:l.call(c,e,a,Object.assign(Object.assign({},t[nr].config),o)));let f=o.agent||t[nr].config.agent||(0,Ru.getDefaultAgent)(),d=vr.Principal.from(o.canisterId||t[nr].config.canisterId),v=ko.IDL.encode(r.argTypes,a),m=await f.query(d,{methodName:e,arg:v,effectiveCanisterId:o.effectiveCanisterId});switch(m.status){case"rejected":throw new Vo(d,e,m);case"replied":return r.annotations.includes(ft.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:m.httpDetails,result:jo(r.retTypes,m.reply.arg)}:jo(r.retTypes,m.reply.arg)}}:i=async(o,...a)=>{var c,l;o=Object.assign(Object.assign({},o),(l=(c=t[nr].config).callTransform)===null||l===void 0?void 0:l.call(c,e,a,Object.assign(Object.assign({},t[nr].config),o)));let f=o.agent||t[nr].config.agent||(0,Ru.getDefaultAgent)(),{canisterId:d,effectiveCanisterId:v,pollingStrategyFactory:m}=Object.assign(Object.assign(Object.assign({},Fh),t[nr].config),o),x=vr.Principal.from(d),w=v!==void 0?vr.Principal.from(v):x,N=ko.IDL.encode(r.argTypes,a),{requestId:A,response:q}=await f.call(x,{methodName:e,arg:N,effectiveCanisterId:w});if(!q.ok||q.body)throw new Ho(x,e,A,q);let O=m(),$=await(0,Uh.pollForResponse)(f,w,A,O,n),I=r.annotations.includes(ft.ACTOR_METHOD_WITH_HTTP_DETAILS);if($!==void 0)return I?{httpDetails:q,result:jo(r.retTypes,$)}:jo(r.retTypes,$);if(r.retTypes.length===0)return I?{httpDetails:q,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 Uu(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:vr.Principal.from(t.effectiveCanisterId)};let i=n[0],s=vr.Principal.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(s=vr.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return $o.createActor(Tw.default,Object.assign(Object.assign(Object.assign({},t),{canisterId:vr.Principal.fromHex("")}),{callTransform:e,queryTransform:e}))}ft.getManagementCanister=Uu});var Mh=L(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});Fu.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 Ch=L(oi=>{"use strict";var Aw=oi&&oi.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(oi,"__esModule",{value:!0});oi.createAssetCanisterActor=void 0;var Ow=Ko(),Nw=Aw(Mh());function Pw(t){return Ow.Actor.createActor(Nw.default,t)}oi.createAssetCanisterActor=Pw});var qh=L(Br=>{"use strict";var Rw=Br&&Br.__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]}),Iw=Br&&Br.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Uw=Br&&Br.__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)&&Rw(e,t,r);return Iw(e,t),e};Object.defineProperty(Br,"__esModule",{value:!0});Br.fetchCandid=void 0;var Fw=Mt(),Mw=Uw(qi()),Cw=Tu(),qw=Ko();async function jw(t,e){e||(e=new Cw.HttpAgent,e.isLocal()&&e.fetchRootKey());let n=(await Mw.request({agent:e,canisterId:Fw.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 qw.Actor.createActor(i,{agent:e,canisterId:t}).__get_candid_interface_tmp_hack()}Br.fetchCandid=jw});var Tr=L(Ue=>{"use strict";var jh=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]}),kw=Ue&&Ue.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Vt=Ue&&Ue.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&jh(e,t,r)},Mu=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)&&jh(e,t,r);return kw(e,t),e};Object.defineProperty(Ue,"__esModule",{value:!0});Ue.Cbor=Ue.CanisterStatus=Ue.polling=void 0;Vt(Ko(),Ue);Vt(qo(),Ue);Vt(Ls(),Ue);Vt(Oi(),Ue);Vt(Ec(),Ue);Vt(Ch(),Ue);Vt(Ci(),Ue);Vt(gu(),Ue);Vt(qh(),Ue);Vt(mu(),Ue);Vt(Bi(),Ue);Vt(Qc(),Ue);Vt($t(),Ue);Vt(Ic(),Ue);Ue.polling=Mu(Nu());Ue.CanisterStatus=Mu(qi());Ue.Cbor=Mu(Ai())});var Vh=L(Sr=>{"use strict";var Do=Sr&&Sr.__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},cn=Sr&&Sr.__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)},Go,Yo,ai,ci;Object.defineProperty(Sr,"__esModule",{value:!0});Sr.Ed25519KeyIdentity=Sr.Ed25519PublicKey=void 0;var Vw=Tr(),Dt=Tr(),Wi=yu();function kh(t){return t!==null&&typeof t=="object"}var Nn=class t{constructor(e){if(Go.set(this,void 0),Yo.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Do(this,Go,e,"f"),Do(this,Yo,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=(0,Dt.fromHex)(e);return this.fromRaw(r)}else if(kh(e)){let r=e;if(kh(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw((0,Dt.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,Dt.wrapDER)(e,Dt.ED25519_OID).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=(0,Dt.unwrapDER)(e,Dt.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 cn(this,Go,"f")}get derKey(){return cn(this,Yo,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Sr.Ed25519PublicKey=Nn;Go=new WeakMap,Yo=new WeakMap;Nn.RAW_KEY_LENGTH=32;var Cu=class t extends Dt.SignIdentity{constructor(e,r){super(),ai.set(this,void 0),ci.set(this,void 0),Do(this,ai,Nn.from(e),"f"),Do(this,ci,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=Wi.ed25519.utils.randomPrivateKey()),(0,Vw.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=Wi.ed25519.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(Nn.fromDer((0,Dt.fromHex)(r)),(0,Dt.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(Nn.fromRaw(e),r)}static fromSecretKey(e){let r=Wi.ed25519.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[(0,Dt.toHex)(cn(this,ai,"f").toDer()),(0,Dt.toHex)(cn(this,ci,"f"))]}getKeyPair(){return{secretKey:cn(this,ci,"f"),publicKey:cn(this,ai,"f")}}getPublicKey(){return cn(this,ai,"f")}async sign(e){let r=new Uint8Array(e),n=(0,Dt.uint8ToBuf)(Wi.ed25519.sign(r,cn(this,ci,"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,Dt.fromHex)(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return Wi.ed25519.verify(s,i,o)}};Sr.Ed25519KeyIdentity=Cu;ai=new WeakMap,ci=new WeakMap});var $h=L(Pn=>{"use strict";Object.defineProperty(Pn,"__esModule",{value:!0});Pn.ECDSAKeyIdentity=Pn.CryptoError=void 0;var Hw=Tr(),Wo=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};Pn.CryptoError=Wo;function Hh(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 Wo("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 zo=class t extends Hw.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=Hh(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=Hh(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)}};Pn.ECDSAKeyIdentity=zo;Pn.default=zo});var ju=L(ln=>{"use strict";var $w=ln&&ln.__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},zi=ln&&ln.__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)},un;Object.defineProperty(ln,"__esModule",{value:!0});ln.PartialIdentity=void 0;var Kw=Mt(),qu=class{constructor(e){un.set(this,void 0),$w(this,un,e,"f")}get rawKey(){return zi(this,un,"f").rawKey}get derKey(){return zi(this,un,"f").derKey}toDer(){return zi(this,un,"f").toDer()}getPublicKey(){return zi(this,un,"f")}getPrincipal(){return Kw.Principal.from(zi(this,un,"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.")}};ln.PartialIdentity=qu;un=new WeakMap});var Kh=L(Ye=>{"use strict";var Gw=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]}),Yw=Ye&&Ye.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Dw=Ye&&Ye.__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)&&Gw(e,t,r);return Yw(e,t),e},Ww=Ye&&Ye.__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},zw=Ye&&Ye.__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)},Zw=Ye&&Ye.__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},Zo;Object.defineProperty(Ye,"__esModule",{value:!0});Ye.isDelegationValid=Ye.PartialDelegationIdentity=Ye.DelegationIdentity=Ye.DelegationChain=Ye.Delegation=void 0;var fn=Tr(),Vu=Mt(),Zi=Dw(Si()),Xw=ju(),Jw=new TextEncoder().encode("ic-request-auth-delegation"),Lw=new TextEncoder().encode(`
|
|
56
|
-
ic-request`);function ku(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return(0,fn.fromHex)(t)}var Xi=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return Zi.value.map(Object.assign({pubkey:Zi.value.bytes(this.pubkey),expiration:Zi.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Zi.value.array(this.targets.map(e=>Zi.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,fn.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};Ye.Delegation=Xi;async function Qw(t,e,r,n){let i=new Xi(e.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...Jw,...new Uint8Array((0,fn.requestIdOf)(i))]),o=await t.sign(s);return{delegation:i,signature:o}}var Hu=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 Qw(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:l,targets:f}=o;if(f!==void 0&&!Array.isArray(f))throw new Error("Invalid targets.");return{delegation:new Xi(ku(c),BigInt("0x"+l),f&&f.map(d=>{if(typeof d!="string")throw new Error("Invalid target.");return Vu.Principal.fromHex(d)})),signature:ku(a)}});return new this(i,ku(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,fn.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,fn.toHex)(n)}}),publicKey:(0,fn.toHex)(this.publicKey)}}};Ye.DelegationChain=Hu;var $u=class extends fn.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=Zw(e,["body"]),i=await(0,fn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...Lw,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};Ye.DelegationIdentity=$u;var Ku=class t extends Xw.PartialIdentity{constructor(e,r){super(e),Zo.set(this,void 0),Ww(this,Zo,r,"f")}get delegation(){return zw(this,Zo,"f")}static fromDelegation(e,r){return new t(e,r)}};Ye.PartialDelegationIdentity=Ku;Zo=new WeakMap;function e2(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"?Vu.Principal.fromText(i):i)):r.push(typeof n=="string"?Vu.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}Ye.isDelegationValid=e2});var Gh=L(dn=>{"use strict";var t2=dn&&dn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(dn,"__esModule",{value:!0});dn.WebAuthnIdentity=dn.CosePublicKey=void 0;var Rn=Tr(),Gu=t2($s()),r2=yn(),n2=Xn();function i2(t){return(0,Rn.wrapDER)(t,Rn.DER_COSE_OID).buffer}function s2(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 Xo=class{constructor(e){this._cose=e,this._encodedKey=i2(e)}toDer(){return this._encodedKey}getCose(){return this._cose}};dn.CosePublicKey=Xo;function o2(t="<ic0.app>"){return typeof t=="string"?Uint8Array.from(t,e=>e.charCodeAt(0)):t}async function a2(t){let e=await navigator.credentials.create(t??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:o2(),pubKeyCredParams:[{type:"public-key",alg:Yu.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,r2.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,n2.bufFromBufLike)(e.rawId)}}var Yu;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(Yu||(Yu={}));var Du=class extends Rn.SignIdentity{constructor(e,r,n){super(),this.rawId=e,this.authenticatorAttachment=n,this._publicKey=new Xo(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,Rn.fromHex)(n),(0,Rn.fromHex)(r),void 0)}static async create(e){var r;let n=await a2(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=Gu.default.decodeFirst(new Uint8Array(i.attestationObject));return new this(n.rawId,s2(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=Gu.default.encode(new Gu.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,Rn.toHex)(this._publicKey.getCose()),rawId:(0,Rn.toHex)(this.rawId)}}};dn.WebAuthnIdentity=Du});var Dh=L($e=>{"use strict";var c2=$e&&$e.__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]}),zu=$e&&$e.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&c2(e,t,r)};Object.defineProperty($e,"__esModule",{value:!0});$e.Secp256k1KeyIdentity=$e.ED25519_OID=$e.DER_COSE_OID=$e.unwrapDER=$e.wrapDER=$e.WebAuthnIdentity=$e.Ed25519PublicKey=$e.Ed25519KeyIdentity=void 0;var Yh=Vh();Object.defineProperty($e,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return Yh.Ed25519KeyIdentity}});Object.defineProperty($e,"Ed25519PublicKey",{enumerable:!0,get:function(){return Yh.Ed25519PublicKey}});zu($h(),$e);zu(Kh(),$e);zu(ju(),$e);var u2=Gh();Object.defineProperty($e,"WebAuthnIdentity",{enumerable:!0,get:function(){return u2.WebAuthnIdentity}});var Jo=Tr();Object.defineProperty($e,"wrapDER",{enumerable:!0,get:function(){return Jo.wrapDER}});Object.defineProperty($e,"unwrapDER",{enumerable:!0,get:function(){return Jo.unwrapDER}});Object.defineProperty($e,"DER_COSE_OID",{enumerable:!0,get:function(){return Jo.DER_COSE_OID}});Object.defineProperty($e,"ED25519_OID",{enumerable:!0,get:function(){return Jo.ED25519_OID}});var Wu=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};$e.Secp256k1KeyIdentity=Wu});var Xu=L(Lo=>{"use strict";Object.defineProperty(Lo,"__esModule",{value:!0});Lo.IdleManager=void 0;var Wh=["mousedown","mousemove","keydown","touchstart","wheel"],Zu=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),Wh.forEach(function(a){document.addEventListener(a,s,!0)});let o=(a,c)=>{let l;return(...f)=>{let d=this,v=function(){l=void 0,a.apply(d,f)};clearTimeout(l),l=window.setTimeout(v,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);Wh.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)}};Lo.IdleManager=Zu});function f2(){return zh||(zh=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function d2(){return Zh||(Zh=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function h2(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o)},s=()=>{r(ir(t.result)),i()},o=()=>{n(t.error),i()};t.addEventListener("success",s),t.addEventListener("error",o)});return e.then(r=>{r instanceof IDBCursor&&Xh.set(r,t)}).catch(()=>{}),el.set(e,t),e}function p2(t){if(Lu.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)});Lu.set(t,e)}function Lh(t){Qu=t(Qu)}function y2(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Ji(this),e,...r);return Jh.set(n,e.sort?e.sort():[e]),ir(n)}:d2().includes(t)?function(...e){return t.apply(Ji(this),e),ir(Xh.get(this))}:function(...e){return ir(t.apply(Ji(this),e))}}function b2(t){return typeof t=="function"?y2(t):(t instanceof IDBTransaction&&p2(t),l2(t,f2())?new Proxy(t,Qu):t)}function ir(t){if(t instanceof IDBRequest)return h2(t);if(Ju.has(t))return Ju.get(t);let e=b2(t);return e!==t&&(Ju.set(t,e),el.set(e,t)),e}var l2,zh,Zh,Xh,Lu,Jh,Ju,el,Qu,Ji,tl=ml(()=>{l2=(t,e)=>e.some(r=>t instanceof r);Xh=new WeakMap,Lu=new WeakMap,Jh=new WeakMap,Ju=new WeakMap,el=new WeakMap;Qu={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return Lu.get(t);if(e==="objectStoreNames")return t.objectStoreNames||Jh.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return ir(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}};Ji=t=>el.get(t)});var ep={};iy(ep,{deleteDB:()=>m2,openDB:()=>g2,unwrap:()=>Ji,wrap:()=>ir});function g2(t,e,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(t,e),a=ir(o);return n&&o.addEventListener("upgradeneeded",c=>{n(ir(o.result),c.oldVersion,c.newVersion,ir(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",l=>i(l.oldVersion,l.newVersion,l))}).catch(()=>{}),a}function m2(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),ir(r).then(()=>{})}function Qh(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(rl.get(e))return rl.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=w2.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||_2.includes(r)))return;let s=async function(o,...a){let c=this.transaction(o,i?"readwrite":"readonly"),l=c.store;return n&&(l=l.index(a.shift())),(await Promise.all([l[r](...a),i&&c.done]))[0]};return rl.set(e,s),s}var _2,w2,rl,tp=ml(()=>{tl();tl();_2=["get","getKey","getAll","getAllKeys","count"],w2=["put","add","delete","clear"],rl=new Map;Lh(t=>({...t,get:(e,r,n)=>Qh(e,r)||t.get(e,r,n),has:(e,r)=>!!Qh(e,r)||t.has(e,r)}))});var il=L(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});Qo.IdbKeyVal=void 0;var x2=(tp(),sy(ep)),Li=ea(),rp="auth-client-db",np="ic-keyval",E2=async(t=rp,e=np,r)=>(Li.isBrowser&&(localStorage!=null&&localStorage.getItem(Li.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(Li.KEY_STORAGE_DELEGATION),localStorage.removeItem(Li.KEY_STORAGE_KEY)),await(0,x2.openDB)(t,r,{upgrade:n=>{n.objectStoreNames,n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function v2(t,e,r){return await t.get(e,r)}async function B2(t,e,r,n){return await t.put(e,n,r)}async function T2(t,e,r){return await t.delete(e,r)}var nl=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=rp,storeName:n=np,version:i=Li.DB_VERSION}=e??{},s=await E2(r,n,i);return new t(s,n)}async set(e,r){return await B2(this._db,this._storeName,e,r)}async get(e){var r;return(r=await v2(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await T2(this._db,this._storeName,e)}};Qo.IdbKeyVal=nl});var ea=L(st=>{"use strict";var S2=st&&st.__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},A2=st&&st.__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)},ta;Object.defineProperty(st,"__esModule",{value:!0});st.IdbStorage=st.LocalStorage=st.isBrowser=st.DB_VERSION=st.KEY_VECTOR=st.KEY_STORAGE_DELEGATION=st.KEY_STORAGE_KEY=void 0;var O2=il();st.KEY_STORAGE_KEY="identity";st.KEY_STORAGE_DELEGATION="delegation";st.KEY_VECTOR="iv";st.DB_VERSION=1;st.isBrowser=typeof window<"u";var sl=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}};st.LocalStorage=sl;var ol=class{constructor(e){ta.set(this,void 0),S2(this,ta,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}O2.IdbKeyVal.create(A2(this,ta,"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)}};st.IdbStorage=ol;ta=new WeakMap});var op=L(Qe=>{"use strict";var N2=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]}),P2=Qe&&Qe.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&N2(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 ip=Tr(),Wt=Dh(),sp=Xu(),xt=ea(),ra=ea();Object.defineProperty(Qe,"IdbStorage",{enumerable:!0,get:function(){return ra.IdbStorage}});Object.defineProperty(Qe,"LocalStorage",{enumerable:!0,get:function(){return ra.LocalStorage}});Object.defineProperty(Qe,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return ra.KEY_STORAGE_DELEGATION}});Object.defineProperty(Qe,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return ra.KEY_STORAGE_KEY}});var R2=il();Object.defineProperty(Qe,"IdbKeyVal",{enumerable:!0,get:function(){return R2.IdbKeyVal}});var I2="https://identity.ic0.app",U2="#authorize",al="ECDSA",cl="Ed25519",F2=500;Qe.ERROR_USER_INTERRUPT="UserInterrupt";P2(Xu(),Qe);var ll=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:al,a=null;if(e.identity)a=e.identity;else{let d=await s.get(xt.KEY_STORAGE_KEY);if(!d&&xt.isBrowser)try{let v=new xt.LocalStorage,m=await v.get(xt.KEY_STORAGE_DELEGATION),x=await v.get(xt.KEY_STORAGE_KEY);m&&x&&o===al&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(xt.KEY_STORAGE_DELEGATION,m),await s.set(xt.KEY_STORAGE_KEY,x),d=m,await v.remove(xt.KEY_STORAGE_DELEGATION),await v.remove(xt.KEY_STORAGE_KEY))}catch(v){console.error("error while attempting to recover localstorage: "+v)}if(d)try{typeof d=="object"?o===cl&&typeof d=="string"?a=await Wt.Ed25519KeyIdentity.fromJSON(d):a=await Wt.ECDSAKeyIdentity.fromKeyPair(d):typeof d=="string"&&(a=Wt.Ed25519KeyIdentity.fromJSON(d))}catch{}}let c=new ip.AnonymousIdentity,l=null;if(a)try{let d=await s.get(xt.KEY_STORAGE_DELEGATION);if(typeof d=="object"&&d!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");e.identity?c=e.identity:d&&(l=Wt.DelegationChain.fromJSON(d),(0,Wt.isDelegationValid)(l)?"toDer"in a?c=Wt.PartialDelegationIdentity.fromDelegation(a,l):c=Wt.DelegationIdentity.fromDelegation(a,l):(await ul(s),a=null))}catch(d){console.error(d),await ul(s),a=null}let f;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?f=void 0:(l||e.identity)&&(f=sp.IdleManager.create(e.idleOptions)),a||(o===cl?(a=await Wt.Ed25519KeyIdentity.generate(),await s.set(xt.KEY_STORAGE_KEY,JSON.stringify(a.toJSON()))):(e.storage&&o===al&&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 '${cl}' as the key type, as it can serialize to a string`),a=await Wt.ECDSAKeyIdentity.generate(),await s.set(xt.KEY_STORAGE_KEY,a.getKeyPair()))),new this(c,a,l,s,f,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(l=>({delegation:new Wt.Delegation(l.delegation.pubkey,l.delegation.expiration,l.delegation.targets),signature:l.signature.buffer})),o=Wt.DelegationChain.fromDelegations(s,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=o,"toDer"in a?this._identity=Wt.PartialDelegationIdentity.fromDelegation(a,this._chain):this._identity=Wt.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=sp.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())||I2);a.hash=U2,(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,F2))};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 ul(this._storage),this._identity=new ip.AnonymousIdentity,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};Qe.AuthClient=ll;async function ul(t){await t.remove(xt.KEY_STORAGE_KEY),await t.remove(xt.KEY_STORAGE_DELEGATION),await t.remove(xt.KEY_VECTOR)}});var xa=li(Mt(),1);var rt=t=>t==null,ht=t=>!rt(t),Ky=class extends Error{},Ul=(t,e)=>{if(rt(t))throw new Ky(e)},ma="__bigint__",_a="__principal__",wa="__uint8array__",Gy=(t,e)=>typeof e=="bigint"?{[ma]:`${e}`}:ht(e)&&e instanceof xa.Principal?{[_a]:e.toText()}:ht(e)&&e instanceof Uint8Array?{[wa]:Array.from(e)}:e,Yy=(t,e)=>{let r=n=>e[n];return ht(e)&&typeof e=="object"&&ma in e?BigInt(r(ma)):ht(e)&&typeof e=="object"&&_a in e?xa.Principal.fromText(r(_a)):ht(e)&&typeof e=="object"&&wa in e?Uint8Array.from(r(wa)):e},_t=t=>ht(t)?[t]:[],Et=t=>t?.[0],Fl=async t=>{let e=new Blob([JSON.stringify(t,Gy)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},fs=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(),Yy)},ds=()=>typeof window<"u";var qn=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 Pr=class t extends qn{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 Ea=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var Ml=BigInt(144e11),Cl=!1,ql={width:576,height:576},jl={width:505,height:705},kl="internetcomputer.org";var jn="http://127.0.0.1:5987",Vl="rdmx6-jaaaa-aaaaa-aaadq-cai";var dr=class t extends qn{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 va=({width:t,height:e})=>{if(!ds()||rt(window)||rt(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 hs=class{#e;constructor({domain:e}){this.#e=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=dr.getInstance().get()?.container;if(rt(n)||n===!1)return`https://identity.${this.#e??kl}`;let i=dr.getInstance().get(),s=ht(i)&&ht(i?.internetIdentityId)?i.internetIdentityId:Vl,{host:o,protocol:a}=new URL(n===!0?jn:n);return/apple/i.test(navigator?.vendor)?`${a}//${o}?canisterId=${s}`:`${a}//${s}.${o.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:va(ql)},identityProvider:r()}}},Hl=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:va(jl)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var ap=li(op(),1),na=()=>ap.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var cp=async({data:t})=>{try{return await fs(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var fl=async t=>{let{data:e,updated_at:r,description:n}=t;return{description:_t(n),data:await Fl(e),updated_at:_t(r)}},dl=t=>{let{updated_at:e}=t;return{updated_at:_t(e)}},Qi=async({doc:t,key:e})=>{let{owner:r,description:n,data:i,...s}=t;return{key:e,description:Et(n),owner:r.toText(),data:await fs(i),...s}};var up=li(Mt(),1);var ia=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:rt(t)?[]:[{key:_t(t.key),description:_t(t.description)}],paginate:_t(rt(e)?void 0:{start_after:_t(e.startAfter),limit:_t(rt(e.limit)?void 0:BigInt(e.limit))}),order:_t(rt(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:_t(rt(n)?void 0:typeof n=="string"?up.Principal.fromText(n):n)});var lp=({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.Record({controllers:t.Vec(t.Principal)}),n=t.Variant({Write:t.Null,Admin:t.Null}),i=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:n,expires_at:t.Opt(t.Nat64)}),s=t.Record({updated_at:t.Opt(t.Nat64)}),o=t.Variant({Db:t.Null,Storage:t.Null}),a=t.Record({cycles:t.Nat,destination_id:t.Principal}),c=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}),l=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),f=t.Record({key:c,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,l)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64}),d=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),v=t.Record({status_code:t.Nat16,location:t.Text}),m=t.Record({iframe:t.Opt(d),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),redirects:t.Opt(t.Vec(t.Tuple(t.Text,v)))}),x=t.Record({storage:m}),w=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64}),N=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)}),A=t.Variant({Heap:t.Null,Stable:t.Null}),q=t.Record({memory:A,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}),O=t.Variant({Callback:t.Record({token:q,callback:t.Func([],[],["query"])})}),$=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(O),status_code:t.Nat16}),I=t.Record({token:t.Opt(q),body:t.Vec(t.Nat8)}),k=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}),W=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),K=t.Record({field:W,desc:t.Bool}),se=t.Record({key:t.Opt(t.Text),description:t.Opt(t.Text)}),te=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),fe=t.Record({order:t.Opt(K),owner:t.Opt(t.Principal),matcher:t.Opt(se),paginate:t.Opt(te)}),ue=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}),Be=t.Record({updated_at:t.Nat64,created_at: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,w)),items_length:t.Nat64}),C=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),X=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(A),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:C,created_at:t.Nat64,mutable_permissions:t.Opt(t.Bool),write:C}),j=t.Record({stable:t.Nat64,heap:t.Nat64}),U=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:n,expires_at:t.Opt(t.Nat64)}),D=t.Record({controller:U,controllers:t.Vec(t.Principal)}),J=t.Record({updated_at:t.Opt(t.Nat64),data:t.Vec(t.Nat8),description:t.Opt(t.Text)}),ie=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(A),updated_at:t.Opt(t.Nat64),max_size:t.Opt(t.Nat),read:C,mutable_permissions:t.Opt(t.Bool),write:C}),R=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),y=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],[t.Nat64],["query"]),count_docs:t.Func([t.Text],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([r],[t.Vec(t.Tuple(t.Principal,i))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,s],[],[]),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,s))],[],[]),del_rule:t.Func([o,t.Text,s],[],[]),deposit_cycles:t.Func([a],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(f)],["query"]),get_config:t.Func([],[x],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(w)],["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(w)))],["query"]),http_request:t.Func([N],[$],["query"]),http_request_streaming_callback:t.Func([q],[I],["query"]),init_asset_upload:t.Func([k],[z],[]),list_assets:t.Func([t.Text,fe],[ue],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,i))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,Be))],["query"]),list_docs:t.Func([t.Text,fe],[Z],["query"]),list_rules:t.Func([o],[t.Vec(t.Tuple(t.Text,X))],["query"]),memory_size:t.Func([],[j],["query"]),set_config:t.Func([x],[],[]),set_controllers:t.Func([D],[t.Vec(t.Tuple(t.Principal,i))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_doc:t.Func([t.Text,t.Text,J],[w],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,J))],[t.Vec(t.Tuple(t.Text,w))],[]),set_rule:t.Func([o,t.Text,ie],[],[]),upload_asset_chunk:t.Func([R],[y],[]),version:t.Func([],[t.Text],["query"])})};var sa=li(Tr(),1);var fp=async({satelliteId:t,idlFactory:e,identity:r,fetch:n,container:i})=>{let o=ht(i)&&i!==!1?i===!0?jn:i:"https://icp-api.io",a=new sa.HttpAgent({identity:r,host:o,...n&&{fetch:n}});return ht(i)&&await a.fetchRootKey(),sa.Actor.createActor(e,{agent:a,canisterId:t})};var hl=({satelliteId:t,container:e})=>{let{satelliteId:r}=pl({satelliteId:t}),{container:n}=yl({container:e});if(ht(n)&&n!==!1){let{host:i,protocol:s}=new URL(n===!0?jn:n);return`${s}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},pl=({satelliteId:t})=>ht(t)?{satelliteId:t}:dr.getInstance().get()??{satelliteId:void 0},yl=({container:t})=>ht(t)?{container:t}:dr.getInstance().get()??{container:void 0};var Rt=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=pl({satelliteId:t});Ul(n,"No satellite principal defined.");let{container:i}=yl({container:e});return fp({satelliteId:n,container:i,idlFactory:lp,...r})};var dp=async({collection:t,key:e,satellite:r})=>{let n=await Rt(r),i=Et(await n.get_doc(t,e));if(!rt(i))return Qi({doc:i,key:e})},hp=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await Rt(e),n=t.map(({collection:o,key:a})=>[o,a]),i=await r(n),s=[];for(let[o,a]of i){let c=Et(a);s.push(ht(c)?await Qi({key:o,doc:c}):void 0)}return s},pp=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await Rt(r),{key:i}=e,s=await fl(e),o=await n(t,i,s);return await Qi({key:i,doc:o})},yp=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await Rt(e),n=[];for(let{collection:o,doc:a}of t){let{key:c}=a;n.push([o,c,await fl(a)])}let i=await r(n),s=[];for(let[o,a]of i)s.push(await Qi({key:o,doc:a}));return s},bp=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await Rt(r),{key:i}=e;return n(t,i,dl(e))},gp=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await Rt(e),n=t.map(({collection:i,doc:s})=>[i,s.key,dl(s)]);await r(n)},mp=async({collection:t,filter:e,satellite:r})=>{let n=await Rt(r),{items:i,items_page:s,items_length:o,matches_length:a,matches_pages:c}=await n.list_docs(t,ia(e)),l=[];for(let[f,d]of i){let{data:v,owner:m,description:x,...w}=d;l.push({key:f,description:Et(x),owner:m.toText(),data:await cp({data:v}),...w})}return{items:l,items_length:o,items_page:Et(s),matches_length:a,matches_pages:Et(c)}};var _p=li(Tr(),1);var It=t=>t!==void 0?t:oa()??new _p.AnonymousIdentity;var wp=async({satellite:t,...e})=>{let r=It(t?.identity);return dp({...e,satellite:{...t,identity:r}})},A8=async({satellite:t,...e})=>{let r=It(t?.identity);return hp({...e,satellite:{...t,identity:r}})},xp=async({satellite:t,...e})=>{let r=It(t?.identity);return pp({...e,satellite:{...t,identity:r}})},O8=async({satellite:t,...e})=>{let r=It(t?.identity);return yp({...e,satellite:{...t,identity:r}})},N8=async({satellite:t,...e})=>{let r=It(t?.identity);return bp({...e,satellite:{...t,identity:r}})},P8=async({satellite:t,...e})=>{let r=It(t?.identity);return gp({...e,satellite:{...t,identity:r}})},R8=async({satellite:t,filter:e,...r})=>{let n=It(t?.identity);return mp({...r,filter:e??{},satellite:{...t,identity:n}})};var Ep=async t=>{let e=oa();if(rt(e))throw new Error("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=await wp({collection:"#user",key:r});return rt(n)?await M2({userId:r,provider:t}):n},M2=async({userId:t,...e})=>xp({collection:"#user",doc:{key:t,data:e}});var Ar,bl=async t=>{if(Ar=Ar??await na(),!(await Ar?.isAuthenticated()??!1))return;let r=await Ep(t);Pr.getInstance().set(r)},C2=async t=>new Promise(async(e,r)=>{Ar=Ar??await na();let n=t?.provider??new hs({});await Ar.login({onSuccess:async()=>{await bl(n.id),e()},onError:i=>r(i),maxTimeToLive:t?.maxTimeToLive??Ml,allowPinAuthentication:t?.allowPin??Cl,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),gl=async()=>{await Ar?.logout(),Ar=void 0,Pr.getInstance().reset()},oa=()=>Ar?.getIdentity(),q2=async()=>(Ar??await na()).getIdentity();var vp=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{Ea({message:"junoSignOutAuthTimer"}),await gl()};return r.onmessage=async({data:i})=>{let{msg:s,data:o}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":Ea({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},Pr.getInstance().subscribe(i=>{if(rt(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var Bp=async({data:t,filename:e,collection:r,headers:n,token:i,fullPath:s,encoding:o,description:a,satellite:c})=>{let l=await Rt(c),{batch_id:f}=await l.init_asset_upload({collection:r,full_path:s,name:e,token:_t(i),encoding_type:_t(o),description:_t(a)}),d=19e5,v=[],m=ds()?new Blob([await t.arrayBuffer()]):t,x=0n;for(let A=0;A<m.size;A+=d){let q=m.slice(A,A+d);v.push({batchId:f,chunk:q,actor:l,orderId:x}),x++}let w=[];for await(let A of j2({uploadChunks:v}))w=[...w,...A];let N=n.find(([A,q])=>A.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await l.commit_asset_upload({batch_id:f,chunk_ids:w.map(({chunk_id:A})=>A),headers:[...n,...N||[]]})};async function*j2({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(s=>k2(s)))}}var k2=async({batchId:t,chunk:e,actor:r,orderId:n})=>r.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:_t(n)}),Tp=async({collection:t,satellite:e,filter:r})=>{let n=await Rt(e),{items:i,items_length:s,items_page:o,matches_length:a,matches_pages:c}=await n.list_assets(t,ia(r));return{items:i.map(([l,f])=>f),items_length:s,items_page:Et(o),matches_length:a,matches_pages:Et(c)}},Sp=async({collection:t,fullPath:e,satellite:r})=>(await Rt(r)).del_asset(t,e),Ap=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await Rt(e),n=t.map(({collection:i,fullPath:s})=>[i,s]);await r(n)},Op=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await Rt(r);return Et(await n(t,e))},Np=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await Rt(e),n=t.map(({collection:s,fullPath:o})=>[s,o]);return(await r(n)).map(([s,o])=>Et(o))};var Pp=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var i6=async t=>Rp(t),s6=async t=>Rp({filename:t.data.name,...t}),Rp=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:s,satellite:o,encoding:a,description:c})=>{let l=It(o?.identity),f=decodeURI(t),d=i??`/${r}/${f}`,v={...o,identity:l};return await Bp({data:e,filename:f,collection:r,token:s,headers:n,fullPath:d,encoding:a,satellite:v,description:c}),{downloadUrl:`${hl(v)}${d}${s!==void 0?`?token=${s}`:""}`,fullPath:d,name:f}},o6=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:It(e?.identity)},{items:i,...s}=await Tp({collection:t,satellite:n,filter:r??{}}),o=hl(n);return{assets:i.map(({key:{full_path:a,token:c,name:l,owner:f,description:d},headers:v,encodings:m,created_at:x,updated_at:w})=>{let N=Et(c);return{fullPath:a,description:Et(d),name:l,downloadUrl:`${o}${a}${N!==void 0?`?token=${N}`:""}`,token:N,headers:v,encodings:m.reduce((A,[q,{modified:O,sha256:$,total_length:I}])=>({...A,[q]:{modified:O,sha256:Pp($),total_length:I}}),{}),owner:f.toText(),created_at:x,updated_at:w}}),...s}},a6=async({collection:t,fullPath:e,satellite:r})=>Sp({collection:t,fullPath:e,satellite:{...r,identity:It(r?.identity)}}),c6=async({assets:t,satellite:e})=>Ap({assets:t,satellite:{...e,identity:It(e?.identity)}}),u6=async({satellite:t,...e})=>{let r=It(t?.identity);return Op({...e,satellite:{...t,identity:r}})},l6=async({satellite:t,...e})=>{let r=It(t?.identity);return Np({...e,satellite:{...t,identity:r}})};var b6=async t=>{dr.getInstance().set(t),await bl();let e=t.workers?.auth!==void 0?vp(t.workers.auth):void 0;return[...e?[e]:[]]},g6=t=>Pr.getInstance().subscribe(t);export{hs as InternetIdentityProvider,Hl as NFIDProvider,g6 as authSubscribe,a6 as deleteAsset,N8 as deleteDoc,c6 as deleteManyAssets,P8 as deleteManyDocs,u6 as getAsset,wp as getDoc,l6 as getManyAssets,A8 as getManyDocs,b6 as initJuno,o6 as listAssets,R8 as listDocs,xp as setDoc,O8 as setManyDocs,C2 as signIn,gl as signOut,q2 as unsafeIdentity,i6 as uploadBlob,s6 as uploadFile};
|
|
48
|
+
`)}}gt.timeout=Xh;function Jh(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}gt.backoff=Jh;function Lh(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}gt.chain=Lh});var Wu=J(Vt=>{"use strict";var $w=Vt&&Vt.__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]}),Kw=Vt&&Vt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Gw=Vt&&Vt.__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)&&$w(e,t,r);return Kw(e,t),e};Object.defineProperty(Vt,"__esModule",{value:!0});Vt.pollForResponse=Vt.defaultStrategy=Vt.strategy=void 0;var Mn=ta(),Yw=Wi(),Qh=Kt();Vt.strategy=Gw(Yu());var Ww=Yu();Object.defineProperty(Vt,"defaultStrategy",{enumerable:!0,get:function(){return Ww.defaultStrategy}});async function ep(t,e,r,n,i,s){var o;let a=[new TextEncoder().encode("request_status"),r],c=i??await((o=t.createReadStateRequest)===null||o===void 0?void 0:o.call(t,{paths:[a]})),f=await t.readState(e,{paths:[a]},void 0,c);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let l=await Yw.Certificate.create({certificate:f.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:s}),d=l.lookup([...a,new TextEncoder().encode("status")]),v;switch(typeof d>"u"?v=Mn.RequestStatusResponseStatus.Unknown:v=new TextDecoder().decode(d),v){case Mn.RequestStatusResponseStatus.Replied:return l.lookup([...a,"reply"]);case Mn.RequestStatusResponseStatus.Received:case Mn.RequestStatusResponseStatus.Unknown:case Mn.RequestStatusResponseStatus.Processing:return await n(e,r,v),ep(t,e,r,n,c);case Mn.RequestStatusResponseStatus.Rejected:{let w=new Uint8Array(l.lookup([...a,"reject_code"]))[0],g=new TextDecoder().decode(l.lookup([...a,"reject_message"]));throw new Error(`Call was rejected:
|
|
49
|
+
Request ID: ${(0,Qh.toHex)(r)}
|
|
50
|
+
Reject code: ${w}
|
|
51
|
+
Reject text: ${g}
|
|
52
|
+
`)}case Mn.RequestStatusResponseStatus.Done:throw new Error(`Call was marked as done but we never saw the reply:
|
|
53
|
+
Request ID: ${(0,Qh.toHex)(r)}
|
|
54
|
+
`)}throw new Error("unreachable")}Vt.pollForResponse=ep});var tp=J(zu=>{"use strict";Object.defineProperty(zu,"__esModule",{value:!0});zu.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,address:r,min_confirmations:t.Opt(t.Nat32)}),a=i,c=t.Record({network:e}),f=t.Nat64,l=t.Vec(f),d=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),v=t.Vec(t.Nat8),w=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),g=t.Record({height:t.Nat32,value:i,outpoint:w}),x=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:v,utxos:t.Vec(g)}),N=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),T=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:v,utxos:t.Vec(g)}),q=t.Record({transaction:t.Vec(t.Nat8),network:e}),O=t.Principal,$=t.Record({canister_id:O,num_requested_changes:t.Opt(t.Nat64)}),P=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),k=t.Variant({creation:t.Record({controllers:t.Vec(t.Principal)}),code_deployment:t.Record({mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),module_hash:t.Vec(t.Nat8)}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),Z=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:P,details:k}),z=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(Z),total_num_changes:t.Nat64}),K=t.Record({canister_id:O}),se=t.Variant({controllers:t.Null,public:t.Null}),te=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:se,memory_allocation:t.Nat,compute_allocation:t.Nat}),de=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:te,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),ue=t.Record({canister_id:O}),Te=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(se),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),D=t.Record({settings:t.Opt(Te),sender_canister_version:t.Opt(t.Nat64)}),C=t.Record({canister_id:O}),X=t.Record({canister_id:O}),j=t.Record({canister_id:O}),I=t.Variant({secp256k1:t.Null}),W=t.Record({key_id:t.Record({name:t.Text,curve:I}),canister_id:t.Opt(O),derivation_path:t.Vec(t.Vec(t.Nat8))}),L=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),ie=t.Record({canister_id:O}),U=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),y=t.Record({canister_log_records:t.Vec(U)}),fe=t.Record({value:t.Text,name:t.Text}),ae=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(fe)}),ce=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:ae})],[ae],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(fe)}),ee=t.Vec(t.Nat8),u=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),chunk_hashes_list:t.Vec(ee),target_canister:O,sender_canister_version:t.Opt(t.Nat64),storage_canister:t.Opt(O)}),h=t.Vec(t.Nat8),p=t.Record({arg:t.Vec(t.Nat8),wasm_module:h,mode:t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),canister_id:O,sender_canister_version:t.Opt(t.Nat64)}),B=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),E=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_total:t.Nat64}),S=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(E)})),F=t.Record({settings:t.Opt(Te),specified_id:t.Opt(O),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),m=t.Record({canister_id:O}),A=t.Record({canister_id:O,amount:t.Nat}),M=t.Vec(t.Nat8),R=t.Record({key_id:t.Record({name:t.Text,curve:I}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),Y=t.Record({signature:t.Vec(t.Nat8)}),Q=t.Record({canister_id:O}),le=t.Record({canister_id:O}),Be=t.Record({canister_id:O}),Ie=t.Vec(ee),Ve=t.Record({canister_id:O,sender_canister_version:t.Opt(t.Nat64)}),xe=t.Record({canister_id:t.Principal,settings:Te,sender_canister_version:t.Opt(t.Nat64)}),he=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),ze=ee;return t.Service({bitcoin_get_balance:t.Func([n],[s],[]),bitcoin_get_balance_query:t.Func([o],[a],["query"]),bitcoin_get_current_fee_percentiles:t.Func([c],[l],[]),bitcoin_get_utxos:t.Func([d],[x],[]),bitcoin_get_utxos_query:t.Func([N],[T],["query"]),bitcoin_send_transaction:t.Func([q],[],[]),canister_info:t.Func([$],[z],[]),canister_status:t.Func([K],[de],[]),clear_chunk_store:t.Func([ue],[],[]),create_canister:t.Func([D],[C],[]),delete_canister:t.Func([X],[],[]),deposit_cycles:t.Func([j],[],[]),ecdsa_public_key:t.Func([W],[L],[]),fetch_canister_logs:t.Func([ie],[y],["query"]),http_request:t.Func([ce],[ae],[]),install_chunked_code:t.Func([u],[],[]),install_code:t.Func([p],[],[]),node_metrics_history:t.Func([B],[S],[]),provisional_create_canister_with_cycles:t.Func([F],[m],[]),provisional_top_up_canister:t.Func([A],[],[]),raw_rand:t.Func([],[M],[]),sign_with_ecdsa:t.Func([R],[Y],[]),start_canister:t.Func([Q],[],[]),stop_canister:t.Func([le],[],[]),stored_chunks:t.Func([Be],[Ie],[]),uninstall_code:t.Func([Ve],[],[]),update_settings:t.Func([xe],[],[]),upload_chunk:t.Func([he],[ze],[])})}});var aa=J(lt=>{"use strict";var zw=lt&<.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(lt,"__esModule",{value:!0});lt.getManagementCanister=lt.ACTOR_METHOD_WITH_HTTP_DETAILS=lt.Actor=lt.UpdateCallRejectedError=lt.QueryCallRejectedError=lt.ActorCallError=void 0;var Dw=Tl(),Du=ta(),Zu=Xn(),na=ni(),rp=Wu(),Nr=Ct(),Zw=Kt(),Xw=zw(tp()),ts=class extends Zu.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}};lt.ActorCallError=ts;var ia=class extends ts{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=Du.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};lt.QueryCallRejectedError=ia;var sa=class extends ts{constructor(e,r,n,i){super(e,r,"update",Object.assign({"Request ID":(0,Zw.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}};lt.UpdateCallRejectedError=sa;var ir=Symbol.for("ic-agent-metadata"),oa=class t{constructor(e){this[ir]=Object.freeze(e)}static agentOf(e){return e[ir].config.agent}static interfaceOf(e){return e[ir].service}static canisterIdOf(e){return Nr.Principal.from(e[ir].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"?Nr.Principal.fromText(r.canisterId):r.canisterId;await Xu(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,sender_canister_version:[]})}static async createCanister(e,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[]}]}let{canister_id:i}=await Xu(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:na.IDL});class i extends t{constructor(o){if(!o.canisterId)throw new Zu.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"?Nr.Principal.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},np),o),{canisterId:a}),service:n});for(let[c,f]of n._fields)r?.httpDetails&&f.annotations.push(lt.ACTOR_METHOD_WITH_HTTP_DETAILS),this[c]=Jw(this,c,f,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Zu.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)}};lt.Actor=oa;function ra(t,e){let r=na.IDL.decode(t,Dw.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var np={pollingStrategyFactory:rp.strategy.defaultStrategy};lt.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";function Jw(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[ir].config).queryTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ir].config),o)));let l=o.agent||t[ir].config.agent||(0,Du.getDefaultAgent)(),d=Nr.Principal.from(o.canisterId||t[ir].config.canisterId),v=na.IDL.encode(r.argTypes,a),w=await l.query(d,{methodName:e,arg:v,effectiveCanisterId:o.effectiveCanisterId});switch(w.status){case"rejected":throw new ia(d,e,w);case"replied":return r.annotations.includes(lt.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:w.httpDetails,result:ra(r.retTypes,w.reply.arg)}:ra(r.retTypes,w.reply.arg)}}:i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ir].config).callTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ir].config),o)));let l=o.agent||t[ir].config.agent||(0,Du.getDefaultAgent)(),{canisterId:d,effectiveCanisterId:v,pollingStrategyFactory:w}=Object.assign(Object.assign(Object.assign({},np),t[ir].config),o),g=Nr.Principal.from(d),x=v!==void 0?Nr.Principal.from(v):g,N=na.IDL.encode(r.argTypes,a),{requestId:T,response:q}=await l.call(g,{methodName:e,arg:N,effectiveCanisterId:x});if(!q.ok||q.body)throw new sa(g,e,T,q);let O=w(),$=await(0,rp.pollForResponse)(l,x,T,O,n),P=r.annotations.includes(lt.ACTOR_METHOD_WITH_HTTP_DETAILS);if($!==void 0)return P?{httpDetails:q,result:ra(r.retTypes,$)}:ra(r.retTypes,$);if(r.retTypes.length===0)return P?{httpDetails:q,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 Xu(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:Nr.Principal.from(t.effectiveCanisterId)};let i=n[0],s=Nr.Principal.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(s=Nr.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return oa.createActor(Xw.default,Object.assign(Object.assign(Object.assign({},t),{canisterId:Nr.Principal.fromHex("")}),{callTransform:e,queryTransform:e}))}lt.getManagementCanister=Xu});var ip=J(Ju=>{"use strict";Object.defineProperty(Ju,"__esModule",{value:!0});Ju.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 sp=J(bi=>{"use strict";var Lw=bi&&bi.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(bi,"__esModule",{value:!0});bi.createAssetCanisterActor=void 0;var Qw=aa(),e2=Lw(ip());function t2(t){return Qw.Actor.createActor(e2.default,t)}bi.createAssetCanisterActor=t2});var op=J(Pr=>{"use strict";var r2=Pr&&Pr.__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]}),n2=Pr&&Pr.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i2=Pr&&Pr.__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)&&r2(e,t,r);return n2(e,t),e};Object.defineProperty(Pr,"__esModule",{value:!0});Pr.fetchCandid=void 0;var s2=Ct(),o2=i2(zi()),a2=$u(),c2=aa();async function u2(t,e){e||(e=new a2.HttpAgent,e.isLocal()&&e.fetchRootKey());let n=(await o2.request({agent:e,canisterId:s2.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 c2.Actor.createActor(i,{agent:e,canisterId:t}).__get_candid_interface_tmp_hack()}Pr.fetchCandid=u2});var Rr=J(Fe=>{"use strict";var ap=Fe&&Fe.__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=Fe&&Fe.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Ht=Fe&&Fe.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&ap(e,t,r)},Lu=Fe&&Fe.__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)&&ap(e,t,r);return f2(e,t),e};Object.defineProperty(Fe,"__esModule",{value:!0});Fe.Cbor=Fe.CanisterStatus=Fe.polling=void 0;Ht(aa(),Fe);Ht(ta(),Fe);Ht(co(),Fe);Ht(ji(),Fe);Ht(Vc(),Fe);Ht(sp(),Fe);Ht(Wi(),Fe);Ht(Fu(),Fe);Ht(op(),Fe);Ht(Mu(),Fe);Ht(Fi(),Fe);Ht(bu(),Fe);Ht(Kt(),Fe);Ht(Zc(),Fe);Fe.polling=Lu(Wu());Fe.CanisterStatus=Lu(zi());Fe.Cbor=Lu(qi())});var up=J(Ir=>{"use strict";var fa=Ir&&Ir.__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},pn=Ir&&Ir.__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)},ca,ua,gi,mi;Object.defineProperty(Ir,"__esModule",{value:!0});Ir.Ed25519KeyIdentity=Ir.Ed25519PublicKey=void 0;var l2=Rr(),zt=Rr(),rs=Iu();function cp(t){return t!==null&&typeof t=="object"}var Cn=class t{constructor(e){if(ca.set(this,void 0),ua.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");fa(this,ca,e,"f"),fa(this,ua,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=(0,zt.fromHex)(e);return this.fromRaw(r)}else if(cp(e)){let r=e;if(cp(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw((0,zt.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,zt.wrapDER)(e,zt.ED25519_OID).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=(0,zt.unwrapDER)(e,zt.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 pn(this,ca,"f")}get derKey(){return pn(this,ua,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Ir.Ed25519PublicKey=Cn;ca=new WeakMap,ua=new WeakMap;Cn.RAW_KEY_LENGTH=32;var Qu=class t extends zt.SignIdentity{constructor(e,r){super(),gi.set(this,void 0),mi.set(this,void 0),fa(this,gi,Cn.from(e),"f"),fa(this,mi,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=rs.ed25519.utils.randomPrivateKey()),(0,l2.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=rs.ed25519.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(Cn.fromDer((0,zt.fromHex)(r)),(0,zt.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(Cn.fromRaw(e),r)}static fromSecretKey(e){let r=rs.ed25519.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[(0,zt.toHex)(pn(this,gi,"f").toDer()),(0,zt.toHex)(pn(this,mi,"f"))]}getKeyPair(){return{secretKey:pn(this,mi,"f"),publicKey:pn(this,gi,"f")}}getPublicKey(){return pn(this,gi,"f")}async sign(e){let r=new Uint8Array(e),n=(0,zt.uint8ToBuf)(rs.ed25519.sign(r,pn(this,mi,"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,zt.fromHex)(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return rs.ed25519.verify(s,i,o)}};Ir.Ed25519KeyIdentity=Qu;gi=new WeakMap,mi=new WeakMap});var lp=J(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.ECDSAKeyIdentity=qn.CryptoError=void 0;var d2=Rr(),la=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};qn.CryptoError=la;function fp(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 la("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 da=class t extends d2.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=fp(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=fp(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)}};qn.ECDSAKeyIdentity=da;qn.default=da});var tf=J(bn=>{"use strict";var h2=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},ns=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)},yn;Object.defineProperty(bn,"__esModule",{value:!0});bn.PartialIdentity=void 0;var p2=Ct(),ef=class{constructor(e){yn.set(this,void 0),h2(this,yn,e,"f")}get rawKey(){return ns(this,yn,"f").rawKey}get derKey(){return ns(this,yn,"f").derKey}toDer(){return ns(this,yn,"f").toDer()}getPublicKey(){return ns(this,yn,"f")}getPrincipal(){return p2.Principal.from(ns(this,yn,"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.")}};bn.PartialIdentity=ef;yn=new WeakMap});var dp=J(We=>{"use strict";var y2=We&&We.__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=We&&We.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),g2=We&&We.__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)&&y2(e,t,r);return b2(e,t),e},m2=We&&We.__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},_2=We&&We.__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)},w2=We&&We.__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},ha;Object.defineProperty(We,"__esModule",{value:!0});We.isDelegationValid=We.PartialDelegationIdentity=We.DelegationIdentity=We.DelegationChain=We.Delegation=void 0;var gn=Rr(),nf=Ct(),is=g2(Ci()),x2=tf(),E2=new TextEncoder().encode("ic-request-auth-delegation"),v2=new TextEncoder().encode(`
|
|
56
|
+
ic-request`);function rf(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return(0,gn.fromHex)(t)}var ss=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return is.value.map(Object.assign({pubkey:is.value.bytes(this.pubkey),expiration:is.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:is.value.array(this.targets.map(e=>is.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,gn.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};We.Delegation=ss;async function B2(t,e,r,n){let i=new ss(e.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...E2,...new Uint8Array((0,gn.requestIdOf)(i))]),o=await t.sign(s);return{delegation:i,signature:o}}var sf=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 B2(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:l}=o;if(l!==void 0&&!Array.isArray(l))throw new Error("Invalid targets.");return{delegation:new ss(rf(c),BigInt("0x"+f),l&&l.map(d=>{if(typeof d!="string")throw new Error("Invalid target.");return nf.Principal.fromHex(d)})),signature:rf(a)}});return new this(i,rf(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,gn.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,gn.toHex)(n)}}),publicKey:(0,gn.toHex)(this.publicKey)}}};We.DelegationChain=sf;var of=class extends gn.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=w2(e,["body"]),i=await(0,gn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...v2,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};We.DelegationIdentity=of;var af=class t extends x2.PartialIdentity{constructor(e,r){super(e),ha.set(this,void 0),m2(this,ha,r,"f")}get delegation(){return _2(this,ha,"f")}static fromDelegation(e,r){return new t(e,r)}};We.PartialDelegationIdentity=af;ha=new WeakMap;function T2(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"?nf.Principal.fromText(i):i)):r.push(typeof n=="string"?nf.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}We.isDelegationValid=T2});var hp=J(mn=>{"use strict";var S2=mn&&mn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(mn,"__esModule",{value:!0});mn.WebAuthnIdentity=mn.CosePublicKey=void 0;var jn=Rr(),cf=S2(Js()),A2=xn(),O2=ni();function N2(t){return(0,jn.wrapDER)(t,jn.DER_COSE_OID).buffer}function P2(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 pa=class{constructor(e){this._cose=e,this._encodedKey=N2(e)}toDer(){return this._encodedKey}getCose(){return this._cose}};mn.CosePublicKey=pa;function R2(t="<ic0.app>"){return typeof t=="string"?Uint8Array.from(t,e=>e.charCodeAt(0)):t}async function I2(t){let e=await navigator.credentials.create(t??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:R2(),pubKeyCredParams:[{type:"public-key",alg:uf.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,A2.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,O2.bufFromBufLike)(e.rawId)}}var uf;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(uf||(uf={}));var ff=class extends jn.SignIdentity{constructor(e,r,n){super(),this.rawId=e,this.authenticatorAttachment=n,this._publicKey=new pa(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,jn.fromHex)(n),(0,jn.fromHex)(r),void 0)}static async create(e){var r;let n=await I2(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=cf.default.decodeFirst(new Uint8Array(i.attestationObject));return new this(n.rawId,P2(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=cf.default.encode(new cf.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,jn.toHex)(this._publicKey.getCose()),rawId:(0,jn.toHex)(this.rawId)}}};mn.WebAuthnIdentity=ff});var yp=J(Ke=>{"use strict";var U2=Ke&&Ke.__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]}),df=Ke&&Ke.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&U2(e,t,r)};Object.defineProperty(Ke,"__esModule",{value:!0});Ke.Secp256k1KeyIdentity=Ke.ED25519_OID=Ke.DER_COSE_OID=Ke.unwrapDER=Ke.wrapDER=Ke.WebAuthnIdentity=Ke.Ed25519PublicKey=Ke.Ed25519KeyIdentity=void 0;var pp=up();Object.defineProperty(Ke,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return pp.Ed25519KeyIdentity}});Object.defineProperty(Ke,"Ed25519PublicKey",{enumerable:!0,get:function(){return pp.Ed25519PublicKey}});df(lp(),Ke);df(dp(),Ke);df(tf(),Ke);var F2=hp();Object.defineProperty(Ke,"WebAuthnIdentity",{enumerable:!0,get:function(){return F2.WebAuthnIdentity}});var ya=Rr();Object.defineProperty(Ke,"wrapDER",{enumerable:!0,get:function(){return ya.wrapDER}});Object.defineProperty(Ke,"unwrapDER",{enumerable:!0,get:function(){return ya.unwrapDER}});Object.defineProperty(Ke,"DER_COSE_OID",{enumerable:!0,get:function(){return ya.DER_COSE_OID}});Object.defineProperty(Ke,"ED25519_OID",{enumerable:!0,get:function(){return ya.ED25519_OID}});var lf=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};Ke.Secp256k1KeyIdentity=lf});var pf=J(ba=>{"use strict";Object.defineProperty(ba,"__esModule",{value:!0});ba.IdleManager=void 0;var bp=["mousedown","mousemove","keydown","touchstart","wheel"],hf=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),bp.forEach(function(a){document.addEventListener(a,s,!0)});let o=(a,c)=>{let f;return(...l)=>{let d=this,v=function(){f=void 0,a.apply(d,l)};clearTimeout(f),f=window.setTimeout(v,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);bp.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)}};ba.IdleManager=hf});function C2(){return gp||(gp=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function q2(){return mp||(mp=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function j2(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o)},s=()=>{r(sr(t.result)),i()},o=()=>{n(t.error),i()};t.addEventListener("success",s),t.addEventListener("error",o)});return e.then(r=>{r instanceof IDBCursor&&_p.set(r,t)}).catch(()=>{}),mf.set(e,t),e}function k2(t){if(bf.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)});bf.set(t,e)}function xp(t){gf=t(gf)}function V2(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(os(this),e,...r);return wp.set(n,e.sort?e.sort():[e]),sr(n)}:q2().includes(t)?function(...e){return t.apply(os(this),e),sr(_p.get(this))}:function(...e){return sr(t.apply(os(this),e))}}function H2(t){return typeof t=="function"?V2(t):(t instanceof IDBTransaction&&k2(t),M2(t,C2())?new Proxy(t,gf):t)}function sr(t){if(t instanceof IDBRequest)return j2(t);if(yf.has(t))return yf.get(t);let e=H2(t);return e!==t&&(yf.set(t,e),mf.set(e,t)),e}var M2,gp,mp,_p,bf,wp,yf,mf,gf,os,_f=Cf(()=>{M2=(t,e)=>e.some(r=>t instanceof r);_p=new WeakMap,bf=new WeakMap,wp=new WeakMap,yf=new WeakMap,mf=new WeakMap;gf={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return bf.get(t);if(e==="objectStoreNames")return t.objectStoreNames||wp.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return sr(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}};os=t=>mf.get(t)});var vp={};Ay(vp,{deleteDB:()=>K2,openDB:()=>$2,unwrap:()=>os,wrap:()=>sr});function $2(t,e,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(t,e),a=sr(o);return n&&o.addEventListener("upgradeneeded",c=>{n(sr(o.result),c.oldVersion,c.newVersion,sr(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 K2(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),sr(r).then(()=>{})}function Ep(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(wf.get(e))return wf.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=Y2.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||G2.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 wf.set(e,s),s}var G2,Y2,wf,Bp=Cf(()=>{_f();_f();G2=["get","getKey","getAll","getAllKeys","count"],Y2=["put","add","delete","clear"],wf=new Map;xp(t=>({...t,get:(e,r,n)=>Ep(e,r)||t.get(e,r,n),has:(e,r)=>!!Ep(e,r)||t.has(e,r)}))});var Ef=J(ga=>{"use strict";Object.defineProperty(ga,"__esModule",{value:!0});ga.IdbKeyVal=void 0;var W2=(Bp(),Oy(vp)),as=ma(),Tp="auth-client-db",Sp="ic-keyval",z2=async(t=Tp,e=Sp,r)=>(as.isBrowser&&(localStorage!=null&&localStorage.getItem(as.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(as.KEY_STORAGE_DELEGATION),localStorage.removeItem(as.KEY_STORAGE_KEY)),await(0,W2.openDB)(t,r,{upgrade:n=>{n.objectStoreNames,n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function D2(t,e,r){return await t.get(e,r)}async function Z2(t,e,r,n){return await t.put(e,n,r)}async function X2(t,e,r){return await t.delete(e,r)}var xf=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=Tp,storeName:n=Sp,version:i=as.DB_VERSION}=e??{},s=await z2(r,n,i);return new t(s,n)}async set(e,r){return await Z2(this._db,this._storeName,e,r)}async get(e){var r;return(r=await D2(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await X2(this._db,this._storeName,e)}};ga.IdbKeyVal=xf});var ma=J(st=>{"use strict";var J2=st&&st.__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},L2=st&&st.__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)},_a;Object.defineProperty(st,"__esModule",{value:!0});st.IdbStorage=st.LocalStorage=st.isBrowser=st.DB_VERSION=st.KEY_VECTOR=st.KEY_STORAGE_DELEGATION=st.KEY_STORAGE_KEY=void 0;var Q2=Ef();st.KEY_STORAGE_KEY="identity";st.KEY_STORAGE_DELEGATION="delegation";st.KEY_VECTOR="iv";st.DB_VERSION=1;st.isBrowser=typeof window<"u";var vf=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}};st.LocalStorage=vf;var Bf=class{constructor(e){_a.set(this,void 0),J2(this,_a,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}Q2.IdbKeyVal.create(L2(this,_a,"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)}};st.IdbStorage=Bf;_a=new WeakMap});var Np=J(Qe=>{"use strict";var ex=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]}),tx=Qe&&Qe.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&ex(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 Ap=Rr(),Dt=yp(),Op=pf(),Et=ma(),wa=ma();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 rx=Ef();Object.defineProperty(Qe,"IdbKeyVal",{enumerable:!0,get:function(){return rx.IdbKeyVal}});var nx="https://identity.ic0.app",ix="#authorize",Tf="ECDSA",Sf="Ed25519",sx=500;Qe.ERROR_USER_INTERRUPT="UserInterrupt";tx(pf(),Qe);var Of=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:Tf,a=null;if(e.identity)a=e.identity;else{let d=await s.get(Et.KEY_STORAGE_KEY);if(!d&&Et.isBrowser)try{let v=new Et.LocalStorage,w=await v.get(Et.KEY_STORAGE_DELEGATION),g=await v.get(Et.KEY_STORAGE_KEY);w&&g&&o===Tf&&(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,g),d=w,await v.remove(Et.KEY_STORAGE_DELEGATION),await v.remove(Et.KEY_STORAGE_KEY))}catch(v){console.error("error while attempting to recover localstorage: "+v)}if(d)try{typeof d=="object"?o===Sf&&typeof d=="string"?a=await Dt.Ed25519KeyIdentity.fromJSON(d):a=await Dt.ECDSAKeyIdentity.fromKeyPair(d):typeof d=="string"&&(a=Dt.Ed25519KeyIdentity.fromJSON(d))}catch{}}let c=new Ap.AnonymousIdentity,f=null;if(a)try{let d=await s.get(Et.KEY_STORAGE_DELEGATION);if(typeof d=="object"&&d!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");e.identity?c=e.identity:d&&(f=Dt.DelegationChain.fromJSON(d),(0,Dt.isDelegationValid)(f)?"toDer"in a?c=Dt.PartialDelegationIdentity.fromDelegation(a,f):c=Dt.DelegationIdentity.fromDelegation(a,f):(await Af(s),a=null))}catch(d){console.error(d),await Af(s),a=null}let l;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?l=void 0:(f||e.identity)&&(l=Op.IdleManager.create(e.idleOptions)),a||(o===Sf?(a=await Dt.Ed25519KeyIdentity.generate(),await s.set(Et.KEY_STORAGE_KEY,JSON.stringify(a.toJSON()))):(e.storage&&o===Tf&&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 '${Sf}' as the key type, as it can serialize to a string`),a=await Dt.ECDSAKeyIdentity.generate(),await s.set(Et.KEY_STORAGE_KEY,a.getKeyPair()))),new this(c,a,f,s,l,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 Dt.Delegation(f.delegation.pubkey,f.delegation.expiration,f.delegation.targets),signature:f.signature.buffer})),o=Dt.DelegationChain.fromDelegations(s,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=o,"toDer"in a?this._identity=Dt.PartialDelegationIdentity.fromDelegation(a,this._chain):this._identity=Dt.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=Op.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())||nx);a.hash=ix,(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,sx))};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 Af(this._storage),this._identity=new Ap.AnonymousIdentity,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};Qe.AuthClient=Of;async function Af(t){await t.remove(Et.KEY_STORAGE_KEY),await t.remove(Et.KEY_STORAGE_DELEGATION),await t.remove(Et.KEY_VECTOR)}});var ka=wi(Ct(),1);var rt=t=>t==null,ht=t=>!rt(t),db=class extends Error{},Jf=(t,e)=>{if(rt(t))throw new db(e)},Ca="__bigint__",qa="__principal__",ja="__uint8array__",hb=(t,e)=>typeof e=="bigint"?{[Ca]:`${e}`}:ht(e)&&e instanceof ka.Principal?{[qa]:e.toText()}:ht(e)&&e instanceof Uint8Array?{[ja]:Array.from(e)}:e,pb=(t,e)=>{let r=n=>e[n];return ht(e)&&typeof e=="object"&&Ca in e?BigInt(r(Ca)):ht(e)&&typeof e=="object"&&qa in e?ka.Principal.fromText(r(qa)):ht(e)&&typeof e=="object"&&ja in e?Uint8Array.from(r(ja)):e},wt=t=>ht(t)?[t]:[],pt=t=>t?.[0],Lf=async t=>{let e=new Blob([JSON.stringify(t,hb)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},ws=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(),pb)},xs=()=>typeof window<"u";var Gn=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 Cr=class t extends Gn{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 Va=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var Qf=BigInt(144e11),el=!1,tl={width:576,height:576},rl={width:505,height:705},nl="internetcomputer.org";var Yn="http://127.0.0.1:5987",il="rdmx6-jaaaa-aaaaa-aaadq-cai";var pr=class t extends Gn{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 Ha=({width:t,height:e})=>{if(!xs()||rt(window)||rt(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 Es=class{#e;constructor({domain:e}){this.#e=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=pr.getInstance().get()?.container;if(rt(n)||n===!1)return`https://identity.${this.#e??nl}`;let i=pr.getInstance().get(),s=ht(i)&&ht(i?.internetIdentityId)?i.internetIdentityId:il,{host:o,protocol:a}=new URL(n===!0?Yn:n);return/apple/i.test(navigator?.vendor)?`${a}//${o}?canisterId=${s}`:`${a}//${s}.${o.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:Ha(tl)},identityProvider:r()}}},sl=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:Ha(rl)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var Pp=wi(Np(),1),xa=()=>Pp.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Rp=async({data:t})=>{try{return await ws(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var Nf=async t=>{let{data:e,version:r,description:n}=t;return{description:wt(n),data:await Lf(e),version:wt(r)}},Pf=t=>{let{version:e}=t;return{version:wt(e)}},cs=async({doc:t,key:e})=>{let{owner:r,version:n,description:i,data:s,...o}=t;return{key:e,description:pt(i),owner:r.toText(),data:await ws(s),version:pt(n),...o}};var Ip=wi(Ct(),1);var Ea=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:rt(t)?[]:[{key:wt(t.key),description:wt(t.description)}],paginate:wt(rt(e)?void 0:{start_after:wt(e.startAfter),limit:wt(rt(e.limit)?void 0:BigInt(e.limit))}),order:wt(rt(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:wt(rt(n)?void 0:typeof n=="string"?Ip.Principal.fromText(n):n)});var Up=({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.Record({controllers:t.Vec(t.Principal)}),n=t.Variant({Write:t.Null,Admin:t.Null}),i=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:n,expires_at:t.Opt(t.Nat64)}),s=t.Record({version:t.Opt(t.Nat64)}),o=t.Variant({Db:t.Null,Storage:t.Null}),a=t.Record({cycles:t.Nat,destination_id:t.Principal}),c=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}),f=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),l=t.Record({key:c,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,f)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),d=t.Record({derivation_origin:t.Opt(t.Text)}),v=t.Record({internet_identity:t.Opt(d)}),w=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),g=t.Variant({Deny:t.Null,Allow:t.Null}),x=t.Record({status_code:t.Nat16,location:t.Text}),N=t.Record({iframe:t.Opt(w),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),raw_access:t.Opt(g),redirects:t.Opt(t.Vec(t.Tuple(t.Text,x)))}),T=t.Record({storage:N}),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)}),O=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)}),$=t.Variant({Heap:t.Null,Stable:t.Null}),P=t.Record({memory:$,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}),k=t.Variant({Callback:t.Record({token:P,callback:t.Func([],[],["query"])})}),Z=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(k),status_code:t.Nat16}),z=t.Record({token:t.Opt(P),body:t.Vec(t.Nat8)}),K=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}),se=t.Record({batch_id:t.Nat}),te=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),de=t.Record({field:te,desc:t.Bool}),ue=t.Record({key:t.Opt(t.Text),description:t.Opt(t.Text)}),Te=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),D=t.Record({order:t.Opt(de),owner:t.Opt(t.Principal),matcher:t.Opt(ue),paginate:t.Opt(Te)}),C=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,l)),items_length:t.Nat64}),X=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),j=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}),I=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),W=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt($),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:I,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:I}),L=t.Record({stable:t.Nat64,heap:t.Nat64}),ie=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:n,expires_at:t.Opt(t.Nat64)}),U=t.Record({controller:ie,controllers:t.Vec(t.Principal)}),y=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),fe=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt($),max_size:t.Opt(t.Nat),read:I,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:I}),ae=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),ce=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],[t.Nat64],["query"]),count_docs:t.Func([t.Text],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([r],[t.Vec(t.Tuple(t.Principal,i))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,s],[],[]),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,s))],[],[]),del_rule:t.Func([o,t.Text,s],[],[]),deposit_cycles:t.Func([a],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(l)],["query"]),get_auth_config:t.Func([],[t.Opt(v)],["query"]),get_config:t.Func([],[T],[]),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(l)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(q)))],["query"]),http_request:t.Func([O],[Z],["query"]),http_request_streaming_callback:t.Func([P],[z],["query"]),init_asset_upload:t.Func([K],[se],[]),list_assets:t.Func([t.Text,D],[C],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,i))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,X))],["query"]),list_docs:t.Func([t.Text,D],[j],["query"]),list_rules:t.Func([o],[t.Vec(t.Tuple(t.Text,W))],["query"]),memory_size:t.Func([],[L],["query"]),set_auth_config:t.Func([v],[],[]),set_config:t.Func([T],[],[]),set_controllers:t.Func([U],[t.Vec(t.Tuple(t.Principal,i))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_doc:t.Func([t.Text,t.Text,y],[q],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,y))],[t.Vec(t.Tuple(t.Text,q))],[]),set_rule:t.Func([o,t.Text,fe],[],[]),upload_asset_chunk:t.Func([ae],[ce],[]),version:t.Func([],[t.Text],["query"])})};var va=wi(Rr(),1);var Fp=async({satelliteId:t,idlFactory:e,identity:r,fetch:n,container:i})=>{let o=ht(i)&&i!==!1?i===!0?Yn:i:"https://icp-api.io",a=new va.HttpAgent({identity:r,host:o,...n&&{fetch:n}});return ht(i)&&await a.fetchRootKey(),va.Actor.createActor(e,{agent:a,canisterId:t})};var Rf=({satelliteId:t,container:e})=>{let{satelliteId:r}=If({satelliteId:t}),{container:n}=Uf({container:e});if(ht(n)&&n!==!1){let{host:i,protocol:s}=new URL(n===!0?Yn:n);return`${s}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},If=({satelliteId:t})=>ht(t)?{satelliteId:t}:pr.getInstance().get()??{satelliteId:void 0},Uf=({container:t})=>ht(t)?{container:t}:pr.getInstance().get()??{container:void 0};var It=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=If({satelliteId:t});Jf(n,"No satellite principal defined.");let{container:i}=Uf({container:e});return Fp({satelliteId:n,container:i,idlFactory:Up,...r})};var Mp=async({collection:t,key:e,satellite:r})=>{let n=await It(r),i=pt(await n.get_doc(t,e));if(!rt(i))return cs({doc:i,key:e})},Cp=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await It(e),n=t.map(({collection:o,key:a})=>[o,a]),i=await r(n),s=[];for(let[o,a]of i){let c=pt(a);s.push(ht(c)?await cs({key:o,doc:c}):void 0)}return s},qp=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await It(r),{key:i}=e,s=await Nf(e),o=await n(t,i,s);return await cs({key:i,doc:o})},jp=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await It(e),n=[];for(let{collection:o,doc:a}of t){let{key:c}=a;n.push([o,c,await Nf(a)])}let i=await r(n),s=[];for(let[o,a]of i)s.push(await cs({key:o,doc:a}));return s},kp=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await It(r),{key:i}=e;return n(t,i,Pf(e))},Vp=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await It(e),n=t.map(({collection:i,doc:s})=>[i,s.key,Pf(s)]);await r(n)},Hp=async({collection:t,filter:e,satellite:r})=>{let n=await It(r),{items:i,items_page:s,items_length:o,matches_length:a,matches_pages:c}=await n.list_docs(t,Ea(e)),f=[];for(let[l,d]of i){let{data:v,owner:w,description:g,version:x,...N}=d;f.push({key:l,description:pt(g),owner:w.toText(),data:await Rp({data:v}),version:pt(x),...N})}return{items:f,items_length:o,items_page:pt(s),matches_length:a,matches_pages:pt(c)}};var $p=wi(Rr(),1);var Ut=t=>t!==void 0?t:Ba()??new $p.AnonymousIdentity;var Kp=async({satellite:t,...e})=>{let r=Ut(t?.identity);return Mp({...e,satellite:{...t,identity:r}})},Q8=async({satellite:t,...e})=>{let r=Ut(t?.identity);return Cp({...e,satellite:{...t,identity:r}})},Gp=async({satellite:t,...e})=>{let r=Ut(t?.identity);return qp({...e,satellite:{...t,identity:r}})},ev=async({satellite:t,...e})=>{let r=Ut(t?.identity);return jp({...e,satellite:{...t,identity:r}})},tv=async({satellite:t,...e})=>{let r=Ut(t?.identity);return kp({...e,satellite:{...t,identity:r}})},rv=async({satellite:t,...e})=>{let r=Ut(t?.identity);return Vp({...e,satellite:{...t,identity:r}})},nv=async({satellite:t,filter:e,...r})=>{let n=Ut(t?.identity);return Hp({...r,filter:e??{},satellite:{...t,identity:n}})};var Yp=async t=>{let e=Ba();if(rt(e))throw new Error("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=await Kp({collection:"#user",key:r});return rt(n)?await ox({userId:r,provider:t}):n},ox=async({userId:t,...e})=>Gp({collection:"#user",doc:{key:t,data:e}});var Ur,Ff=async t=>{if(Ur=Ur??await xa(),!(await Ur?.isAuthenticated()??!1))return;let r=await Yp(t);Cr.getInstance().set(r)},ax=async t=>new Promise(async(e,r)=>{Ur=Ur??await xa();let n=t?.provider??new Es({});await Ur.login({onSuccess:async()=>{await Ff(n.id),e()},onError:i=>r(i),maxTimeToLive:t?.maxTimeToLive??Qf,allowPinAuthentication:t?.allowPin??el,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),Mf=async()=>{await Ur?.logout(),Ur=void 0,Cr.getInstance().reset()},Ba=()=>Ur?.getIdentity(),cx=async()=>(Ur??await xa()).getIdentity();var Wp=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{Va({message:"junoSignOutAuthTimer"}),await Mf()};return r.onmessage=async({data:i})=>{let{msg:s,data:o}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":Va({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},Cr.getInstance().subscribe(i=>{if(rt(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var zp=async({data:t,filename:e,collection:r,headers:n,token:i,fullPath:s,encoding:o,description:a,satellite:c})=>{let f=await It(c),{batch_id:l}=await f.init_asset_upload({collection:r,full_path:s,name:e,token:wt(i),encoding_type:wt(o),description:wt(a)}),d=19e5,v=[],w=xs()?new Blob([await t.arrayBuffer()]):t,g=0n;for(let T=0;T<w.size;T+=d){let q=w.slice(T,T+d);v.push({batchId:l,chunk:q,actor:f,orderId:g}),g++}let x=[];for await(let T of ux({uploadChunks:v}))x=[...x,...T];let N=n.find(([T,q])=>T.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await f.commit_asset_upload({batch_id:l,chunk_ids:x.map(({chunk_id:T})=>T),headers:[...n,...N||[]]})};async function*ux({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(s=>fx(s)))}}var fx=async({batchId:t,chunk:e,actor:r,orderId:n})=>r.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:wt(n)}),Dp=async({collection:t,satellite:e,filter:r})=>{let n=await It(e),{items:i,items_length:s,items_page:o,matches_length:a,matches_pages:c}=await n.list_assets(t,Ea(r));return{items:i.map(([f,l])=>l),items_length:s,items_page:pt(o),matches_length:a,matches_pages:pt(c)}},Zp=async({collection:t,fullPath:e,satellite:r})=>(await It(r)).del_asset(t,e),Xp=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await It(e),n=t.map(({collection:i,fullPath:s})=>[i,s]);await r(n)},Jp=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await It(r);return pt(await n(t,e))},Lp=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await It(e),n=t.map(({collection:s,fullPath:o})=>[s,o]);return(await r(n)).map(([s,o])=>pt(o))};var Qp=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var Pv=async t=>ey(t),Rv=async t=>ey({filename:t.data.name,...t}),ey=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:s,satellite:o,encoding:a,description:c})=>{let f=Ut(o?.identity),l=decodeURI(t),d=i??`/${r}/${l}`,v={...o,identity:f};return await zp({data:e,filename:l,collection:r,token:s,headers:n,fullPath:d,encoding:a,satellite:v,description:c}),{downloadUrl:`${Rf(v)}${d}${s!==void 0?`?token=${s}`:""}`,fullPath:d,name:l}},Iv=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:Ut(e?.identity)},{items:i,...s}=await Dp({collection:t,satellite:n,filter:r??{}}),o=Rf(n);return{assets:i.map(({key:{full_path:a,token:c,name:f,owner:l,description:d},headers:v,encodings:w,created_at:g,updated_at:x})=>{let N=pt(c);return{fullPath:a,description:pt(d),name:f,downloadUrl:`${o}${a}${N!==void 0?`?token=${N}`:""}`,token:N,headers:v,encodings:w.reduce((T,[q,{modified:O,sha256:$,total_length:P}])=>({...T,[q]:{modified:O,sha256:Qp($),total_length:P}}),{}),owner:l.toText(),created_at:g,updated_at:x}}),...s}},Uv=async({collection:t,fullPath:e,satellite:r})=>Zp({collection:t,fullPath:e,satellite:{...r,identity:Ut(r?.identity)}}),Fv=async({assets:t,satellite:e})=>Xp({assets:t,satellite:{...e,identity:Ut(e?.identity)}}),Mv=async({satellite:t,...e})=>{let r=Ut(t?.identity);return Jp({...e,satellite:{...t,identity:r}})},Cv=async({satellite:t,...e})=>{let r=Ut(t?.identity);return Lp({...e,satellite:{...t,identity:r}})};var $v=async t=>{pr.getInstance().set(t),await Ff();let e=t.workers?.auth!==void 0?Wp(t.workers.auth):void 0;return[...e?[e]:[]]},Kv=t=>Cr.getInstance().subscribe(t);export{Es as InternetIdentityProvider,sl as NFIDProvider,Kv as authSubscribe,Uv as deleteAsset,tv as deleteDoc,Fv as deleteManyAssets,rv as deleteManyDocs,Mv as getAsset,Kp as getDoc,Cv as getManyAssets,Q8 as getManyDocs,$v as initJuno,Iv as listAssets,nv as listDocs,Gp as setDoc,ev as setManyDocs,ax as signIn,Mf as signOut,cx as unsafeIdentity,Pv as uploadBlob,Rv as uploadFile};
|
|
57
57
|
/*! Bundled license information:
|
|
58
58
|
|
|
59
59
|
@noble/hashes/utils.js:
|