@junobuild/core-standalone 1.0.0 → 1.0.1
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/dist/browser/canisterStatus-72I5GDMD.js +2 -0
- package/dist/browser/{chunk-DCSQJUQP.js → chunk-EMF4NSTU.js} +3 -3
- package/dist/browser/{chunk-DCSQJUQP.js.map → chunk-EMF4NSTU.js.map} +1 -1
- package/dist/browser/index.js +6 -6
- package/dist/browser/index.js.map +3 -3
- package/dist/node/index.mjs +12 -12
- package/dist/node/index.mjs.map +3 -3
- package/dist/workers/_auth.worker.handler.js +2 -2
- package/dist/workers/_auth.worker.handler.js.map +1 -1
- package/dist/workers/auth.worker.js +2 -2
- package/dist/workers/auth.worker.js.map +1 -1
- package/package.json +1 -1
- package/dist/browser/canisterStatus-OWQH6ZT5.js +0 -2
- /package/dist/browser/{canisterStatus-OWQH6ZT5.js.map → canisterStatus-72I5GDMD.js.map} +0 -0
|
@@ -11,10 +11,10 @@ index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display
|
|
|
11
11
|
variant ${t} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(e){for(let t=0;t<this._fields.length;t++){let[n,i]=this._fields[t];if(e.hasOwnProperty(n)){let s=Be(t),o=i.encodeValue(e[n]);return xe(s,o)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,s])=>{s.buildTypeTable(e)});let t=$e(-21),n=Be(this._fields.length),i=this._fields.map(([s,o])=>xe(Be(It(s)),o.encodeType(e)));e.add(this,xe(t,n,...i))}decodeValue(e,t){let n=this.checkType(t);if(!(n instanceof r))throw new Error("Not a variant type");let i=Number(Ce(e));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,o]=n._fields[i];for(let[c,a]of this._fields)if(It(s)===It(c)){let h=a.decodeValue(e,o);return{[c]:h}}throw new Error("Cannot find field hash "+s)}get name(){return`variant {${this._fields.map(([t,n])=>t+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([t,n])=>t+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(e){for(let[t,n]of this._fields)if(e.hasOwnProperty(t)){let i=n.valueToString(e[t]);return i==="null"?`variant {${t}}`:`variant {${t}=${i}}`}throw new Error("Variant has no data: "+e)}},ir=class r extends Dt{constructor(){super(...arguments),this._id=r._counter++,this._type=void 0}accept(e,t){if(!this._type)throw Error("Recursive type uninitialized.");return e.visitRec(this,this._type,t)}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: ${Pe(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,t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(e,t)}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)}};ir._counter=0;function ro(r){if(rr(r)!==1)throw new Error("Cannot decode principal");let t=Number(Ce(r));return me.fromUint8Array(new Uint8Array(nr(r,t)))}var xi=class extends ct{accept(e,t){return e.visitPrincipal(this,t)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(e){let t=e.toUint8Array(),n=Be(t.byteLength);return xe(new Uint8Array([1]),n,t)}encodeType(){return $e(-24)}decodeValue(e,t){return this.checkType(t),ro(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}},mn=class extends Dt{constructor(e,t,n=[]){super(),this.argTypes=e,this.retTypes=t,this.annotations=n}static argsToString(e,t){if(e.length!==t.length)throw new Error("arity mismatch");return"("+e.map((n,i)=>n.valueToString(t[i])).join(", ")+")"}accept(e,t){return e.visitFunc(this,t)}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: ${Pe(e)}`)}encodeValue([e,t]){let n=e.toUint8Array(),i=Be(n.byteLength),s=xe(new Uint8Array([1]),i,n),o=new TextEncoder().encode(t),c=Be(o.byteLength);return xe(new Uint8Array([1]),s,c,o)}_buildTypeTableImpl(e){this.argTypes.forEach(h=>h.buildTypeTable(e)),this.retTypes.forEach(h=>h.buildTypeTable(e));let t=$e(-22),n=Be(this.argTypes.length),i=xe(...this.argTypes.map(h=>h.encodeType(e))),s=Be(this.retTypes.length),o=xe(...this.retTypes.map(h=>h.encodeType(e))),c=Be(this.annotations.length),a=xe(...this.annotations.map(h=>this.encodeAnnotation(h)));e.add(this,xe(t,n,i,s,o,c,a))}decodeValue(e){if(rr(e)!==1)throw new Error("Cannot decode function reference");let n=ro(e),i=Number(Ce(e)),s=nr(e,i),c=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,c]}get name(){let e=this.argTypes.map(i=>i.name).join(", "),t=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${e}) -> (${t})${n}`}valueToString([e,t]){return`func "${e.toText()}".${t}`}display(){let e=this.argTypes.map(i=>i.display()).join(", "),t=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${e}) \u2192 (${t})${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")}},_i=class extends Dt{constructor(e){super(),this._fields=Object.entries(e).sort((t,n)=>t[0]<n[0]?-1:t[0]>n[0]?1:0)}accept(e,t){return e.visitService(this,t)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(e){let t=e.toUint8Array(),n=Be(t.length);return xe(new Uint8Array([1]),n,t)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let t=$e(-23),n=Be(this._fields.length),i=this._fields.map(([s,o])=>{let c=new TextEncoder().encode(s),a=Be(c.length);return xe(a,c,o.encodeType(e))});e.add(this,xe(t,n,...i))}decodeValue(e){return ro(e)}get name(){return`service {${this._fields.map(([t,n])=>t+":"+n.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};function Pe(r){let e=JSON.stringify(r,(t,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>rc?e.substring(0,rc-3)+"...":e}function M0(r,e){if(e.length<r.length)throw Error("Wrong number of message arguments");let t=new to;r.forEach(a=>a.buildTypeTable(t));let n=new TextEncoder().encode(ci),i=t.encode(),s=Be(e.length),o=xe(...r.map(a=>a.encodeType(t))),c=xe(...hn(r,e,(a,h)=>{try{a.covariant(h)}catch(p){throw new Error(p.message+`
|
|
12
12
|
|
|
13
13
|
`)}return a.encodeValue(h)}));return xe(n,i,s,o,c)}function D0(r,e){let t=new vt(e);if(e.byteLength<ci.length)throw new Error("Message length smaller than magic number");let n=nr(t,ci.length),i=new TextDecoder().decode(n);if(i!==ci)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(x){let f=[],N=Number(Ce(x));for(let H=0;H<N;H++){let D=Number(Vt(x));switch(D){case-18:case-19:{let K=Number(Vt(x));f.push([D,K]);break}case-20:case-21:{let K=[],E=Number(Ce(x)),C;for(;E--;){let G=Number(Ce(x));if(G>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof C=="number"&&C>=G)throw new Error("field id collision or not sorted");C=G;let j=Number(Vt(x));K.push([G,j])}f.push([D,K]);break}case-22:{let K=[],E=Number(Ce(x));for(;E--;)K.push(Number(Vt(x)));let C=[],G=Number(Ce(x));for(;G--;)C.push(Number(Vt(x)));let j=[],k=Number(Ce(x));for(;k--;)switch(Number(Ce(x))){case 1:{j.push("query");break}case 2:{j.push("oneway");break}case 3:{j.push("composite_query");break}default:throw new Error("unknown annotation")}f.push([D,[K,C,j]]);break}case-23:{let K=Number(Ce(x)),E=[];for(;K--;){let C=Number(Ce(x)),G=new TextDecoder().decode(nr(x,C)),j=Vt(x);E.push([G,j])}f.push([D,E]);break}default:throw new Error("Illegal op_code: "+D)}}let T=[],O=Number(Ce(x));for(let H=0;H<O;H++)T.push(Number(Vt(x)));return[f,T]}let[o,c]=s(t);if(c.length<r.length)throw new Error("Wrong number of return values");let a=o.map(x=>Sc());function h(x){if(x<-24)throw new Error("future value not supported");if(x<0)switch(x){case-1:return oc;case-2:return sc;case-3:return uc;case-4:return cc;case-5:return gc;case-6:return yc;case-7:return wc;case-8:return bc;case-9:return hc;case-10:return dc;case-11:return pc;case-12:return mc;case-13:return fc;case-14:return lc;case-15:return ac;case-16:return ic;case-17:return nc;case-24:return xc;default:throw new Error("Illegal op_code: "+x)}if(x>=o.length)throw new Error("type index out of range");return a[x]}function p(x){switch(x[0]){case-19:{let f=h(x[1]);return Ec(f)}case-18:{let f=h(x[1]);return vc(f)}case-20:{let f={};for(let[O,H]of x[1]){let D=`_${O}_`;f[D]=h(H)}let N=Ic(f),T=N.tryAsTuple();return Array.isArray(T)?_c(...T):N}case-21:{let f={};for(let[N,T]of x[1]){let O=`_${N}_`;f[O]=h(T)}return Ac(f)}case-22:{let[f,N,T]=x[1];return Bc(f.map(O=>h(O)),N.map(O=>h(O)),T)}case-23:{let f={},N=x[1];for(let[T,O]of N){let H=h(O);if(H instanceof ir&&(H=H.getType()),!(H instanceof mn))throw new Error("Illegal service definition: services can only contain functions");f[T]=H}return Tc(f)}default:throw new Error("Illegal op_code: "+x[0])}}o.forEach((x,f)=>{if(x[0]===-22){let N=p(x);a[f].fill(N)}}),o.forEach((x,f)=>{if(x[0]!==-22){let N=p(x);a[f].fill(N)}});let g=c.map(x=>h(x)),w=r.map((x,f)=>x.decodeValue(t,g[f]));for(let x=r.length;x<g.length;x++)g[x].decodeValue(t,g[x]);if(t.byteLength>0)throw new Error("decode: Left-over bytes");return w}var nc=new fi,ic=new qr,k0=new li,sc=new hi,oc=new di,ac=new pi,cc=new mi,uc=new gi,fc=new dn(32),lc=new dn(64),hc=new jt(8),dc=new jt(16),pc=new jt(32),mc=new jt(64),gc=new Mt(8),yc=new Mt(16),wc=new Mt(32),bc=new Mt(64),xc=new xi;function _c(...r){return new wi(r)}function Ec(r){return new yi(r)}function vc(r){return new Cr(r)}function Ic(r){return new pn(r)}function Ac(r){return new bi(r)}function Sc(){return new ir}function Bc(r,e,t=[]){return new mn(r,e,t)}function Tc(r){return new _i(r)}var Nc=rn(Cs());function wt(r){return on(sn.create().update(new Uint8Array(r)).digest())}function Ei(r){if(r instanceof Nc.default.Tagged)return Ei(r.value);if(typeof r=="string")return Rc(r);if(typeof r=="number")return wt(Be(r));if(r instanceof ArrayBuffer||ArrayBuffer.isView(r))return wt(r);if(Array.isArray(r)){let e=r.map(Ei);return wt(Qe(...e))}else{if(r&&typeof r=="object"&&r._isPrincipal)return wt(r.toUint8Array());if(typeof r=="object"&&r!==null&&typeof r.toHash=="function")return Ei(r.toHash());if(typeof r=="object")return yn(r);if(typeof r=="bigint")return wt(Be(r))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${r}`),{value:r})}var Rc=r=>{let e=new TextEncoder().encode(r);return wt(e)};function gn(r){return yn(r)}function yn(r){let n=Object.entries(r).filter(([,o])=>o!==void 0).map(([o,c])=>{let a=Rc(o),h=Ei(c);return[a,h]}).sort(([o],[c])=>gs(o,c)),i=Qe(...n.map(o=>Qe(...o)));return wt(i)}var Si={};fs(Si,{aInRange:()=>Bt,abool:()=>sr,abytes:()=>At,bitGet:()=>uo,bitLen:()=>zt,bitMask:()=>ar,bitSet:()=>V0,bytesToHex:()=>St,bytesToNumberBE:()=>Je,bytesToNumberLE:()=>or,concatBytes:()=>Ie,createHmacDrbg:()=>Fc,ensureBytes:()=>He,equalBytes:()=>G0,hexToBytes:()=>wn,hexToNumber:()=>co,inRange:()=>Ii,isBytes:()=>$r,memoized:()=>Kt,notImplemented:()=>Ai,numberToBytesBE:()=>Le,numberToBytesLE:()=>Ir,numberToHexUnpadded:()=>ao,numberToVarBytesBE:()=>H0,utf8ToBytes:()=>bn,validateObject:()=>Tt});var oo=BigInt(0),vi=BigInt(1),C0=BigInt(2);function $r(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function At(r){if(!$r(r))throw new Error("Uint8Array expected")}function sr(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var $0=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function St(r){At(r);let e="";for(let t=0;t<r.length;t++)e+=$0[r[t]];return e}function ao(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function co(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var Yt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Oc(r){if(r>=Yt._0&&r<=Yt._9)return r-Yt._0;if(r>=Yt._A&&r<=Yt._F)return r-(Yt._A-10);if(r>=Yt._a&&r<=Yt._f)return r-(Yt._a-10)}function wn(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let i=0,s=0;i<t;i++,s+=2){let o=Oc(r.charCodeAt(s)),c=Oc(r.charCodeAt(s+1));if(o===void 0||c===void 0){let a=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[i]=o*16+c}return n}function Je(r){return co(St(r))}function or(r){return At(r),co(St(Uint8Array.from(r).reverse()))}function Le(r,e){return wn(r.toString(16).padStart(e*2,"0"))}function Ir(r,e){return Le(r,e).reverse()}function H0(r){return wn(ao(r))}function He(r,e,t){let n;if(typeof e=="string")try{n=wn(e)}catch(s){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${s}`)}else if($r(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let i=n.length;if(typeof t=="number"&&i!==t)throw new Error(`${r} expected ${t} bytes, got ${i}`);return n}function Ie(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];At(i),e+=i.length}let t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let s=r[n];t.set(s,i),i+=s.length}return t}function G0(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function bn(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var io=r=>typeof r=="bigint"&&oo<=r;function Ii(r,e,t){return io(r)&&io(e)&&io(t)&&e<=r&&r<t}function Bt(r,e,t,n){if(!Ii(e,t,n))throw new Error(`expected valid ${r}: ${t} <= n < ${n}, got ${typeof e} ${e}`)}function zt(r){let e;for(e=0;r>oo;r>>=vi,e+=1);return e}function uo(r,e){return r>>BigInt(e)&vi}function V0(r,e,t){return r|(t?vi:oo)<<BigInt(e)}var ar=r=>(C0<<BigInt(r-1))-vi,so=r=>new Uint8Array(r),Uc=r=>Uint8Array.from(r);function Fc(r,e,t){if(typeof r!="number"||r<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 t!="function")throw new Error("hmacFn must be a function");let n=so(r),i=so(r),s=0,o=()=>{n.fill(1),i.fill(0),s=0},c=(...g)=>t(i,n,...g),a=(g=so())=>{i=c(Uc([0]),g),n=c(),g.length!==0&&(i=c(Uc([1]),g),n=c())},h=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let g=0,w=[];for(;g<e;){n=c();let x=n.slice();w.push(x),g+=n.length}return Ie(...w)};return(g,w)=>{o(),a(g);let x;for(;!(x=w(h()));)a();return o(),x}}var j0={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||$r(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Tt(r,e,t={}){let n=(i,s,o)=>{let c=j0[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);let a=r[i];if(!(o&&a===void 0)&&!c(a,r))throw new Error(`Invalid param ${String(i)}=${a} (${typeof a}), expected ${s}`)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(t))n(i,s,!0);return r}var Ai=()=>{throw new Error("not implemented")};function Kt(r){let e=new WeakMap;return(t,...n)=>{let i=e.get(t);if(i!==void 0)return i;let s=r(t,...n);return e.set(t,s),s}}var je=BigInt(0),Te=BigInt(1),cr=BigInt(2),Y0=BigInt(3),fo=BigInt(4),Pc=BigInt(5),Lc=BigInt(8),z0=BigInt(9),K0=BigInt(16);function Se(r,e){let t=r%e;return t>=je?t:e+t}function Z0(r,e,t){if(t<=je||e<je)throw new Error("Expected power/modulo > 0");if(t===Te)return je;let n=Te;for(;e>je;)e&Te&&(n=n*r%t),r=r*r%t,e>>=Te;return n}function Nt(r,e,t){let n=r;for(;e-- >je;)n*=n,n%=t;return n}function lo(r,e){if(r===je||e<=je)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Se(r,e),n=e,i=je,s=Te,o=Te,c=je;for(;t!==je;){let h=n/t,p=n%t,g=i-o*h,w=s-c*h;n=t,t=p,i=o,s=c,o=g,c=w}if(n!==Te)throw new Error("invert: does not exist");return Se(i,e)}function W0(r){let e=(r-Te)/cr,t,n,i;for(t=r-Te,n=0;t%cr===je;t/=cr,n++);for(i=cr;i<r&&Z0(i,e,r)!==r-Te;i++);if(n===1){let o=(r+Te)/fo;return function(a,h){let p=a.pow(h,o);if(!a.eql(a.sqr(p),h))throw new Error("Cannot find square root");return p}}let s=(t+Te)/cr;return function(c,a){if(c.pow(a,e)===c.neg(c.ONE))throw new Error("Cannot find square root");let h=n,p=c.pow(c.mul(c.ONE,i),t),g=c.pow(a,s),w=c.pow(a,t);for(;!c.eql(w,c.ONE);){if(c.eql(w,c.ZERO))return c.ZERO;let x=1;for(let N=c.sqr(w);x<h&&!c.eql(N,c.ONE);x++)N=c.sqr(N);let f=c.pow(p,Te<<BigInt(h-x-1));p=c.sqr(f),g=c.mul(g,f),w=c.mul(w,p),h=x}return g}}function X0(r){if(r%fo===Y0){let e=(r+Te)/fo;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(r%Lc===Pc){let e=(r-Pc)/Lc;return function(n,i){let s=n.mul(i,cr),o=n.pow(s,e),c=n.mul(i,o),a=n.mul(n.mul(c,cr),o),h=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(h),i))throw new Error("Cannot find square root");return h}}return r%K0,W0(r)}var Mc=(r,e)=>(Se(r,e)&Te)===Te,Q0=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Bi(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Q0.reduce((n,i)=>(n[i]="function",n),e);return Tt(r,t)}function xn(r,e,t){if(t<je)throw new Error("Expected power > 0");if(t===je)return r.ONE;if(t===Te)return e;let n=r.ONE,i=e;for(;t>je;)t&Te&&(n=r.mul(n,i)),i=r.sqr(i),t>>=Te;return n}function _n(r,e){let t=new Array(e.length),n=e.reduce((s,o,c)=>r.is0(o)?s:(t[c]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return e.reduceRight((s,o,c)=>r.is0(o)?s:(t[c]=r.mul(s,t[c]),r.mul(s,o)),i),t}function Dc(r){let e=(r-Te)/cr;return(t,n)=>t.pow(n,e)}function ho(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function kt(r,e,t=!1,n={}){if(r<=je)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:i,nByteLength:s}=ho(r,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=X0(r),c=Object.freeze({ORDER:r,BITS:i,BYTES:s,MASK:ar(i),ZERO:je,ONE:Te,create:a=>Se(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return je<=a&&a<r},is0:a=>a===je,isOdd:a=>(a&Te)===Te,neg:a=>Se(-a,r),eql:(a,h)=>a===h,sqr:a=>Se(a*a,r),add:(a,h)=>Se(a+h,r),sub:(a,h)=>Se(a-h,r),mul:(a,h)=>Se(a*h,r),pow:(a,h)=>xn(c,a,h),div:(a,h)=>Se(a*lo(h,r),r),sqrN:a=>a*a,addN:(a,h)=>a+h,subN:(a,h)=>a-h,mulN:(a,h)=>a*h,inv:a=>lo(a,r),sqrt:n.sqrt||(a=>o(c,a)),invertBatch:a=>_n(c,a),cmov:(a,h,p)=>p?h:a,toBytes:a=>t?Ir(a,s):Le(a,s),fromBytes:a=>{if(a.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${a.length}`);return t?or(a):Je(a)}});return Object.freeze(c)}function kc(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function Ti(r){let e=kc(r);return e+Math.ceil(e/2)}function po(r,e,t=!1){let n=r.length,i=kc(e),s=Ti(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=t?Je(r):or(r),c=Se(o,e-Te)+Te;return t?Ir(c,i):Le(c,i)}var J0=Je;function ur(r,e){if(En(r),En(e),r<0||r>=1<<8*e)throw new Error(`bad I2OSP call: value=${r} length=${e}`);let t=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)t[n]=r&255,r>>>=8;return new Uint8Array(t)}function el(r,e){let t=new Uint8Array(r.length);for(let n=0;n<r.length;n++)t[n]=r[n]^e[n];return t}function En(r){if(!Number.isSafeInteger(r))throw new Error("number expected")}function tl(r,e,t,n){At(r),At(e),En(t),e.length>255&&(e=n(Ie(bn("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(t/i);if(t>65535||o>255)throw new Error("expand_message_xmd: invalid lenInBytes");let c=Ie(e,ur(e.length,1)),a=ur(0,s),h=ur(t,2),p=new Array(o),g=n(Ie(a,r,h,ur(0,1),c));p[0]=n(Ie(g,ur(1,1),c));for(let x=1;x<=o;x++){let f=[el(g,p[x-1]),ur(x+1,1),c];p[x]=n(Ie(...f))}return Ie(...p).slice(0,t)}function rl(r,e,t,n,i){if(At(r),At(e),En(t),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update(bn("H2C-OVERSIZE-DST-")).update(e).digest()}if(t>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:t}).update(r).update(ur(t,2)).update(e).update(ur(e.length,1)).digest()}function qc(r,e,t){Tt(t,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:o,expand:c,DST:a}=t;At(r),En(e);let h=typeof a=="string"?bn(a):a,p=n.toString(2).length,g=Math.ceil((p+i)/8),w=e*s*g,x;if(c==="xmd")x=tl(r,h,w,o);else if(c==="xof")x=rl(r,h,w,i,o);else if(c==="_internal_pass")x=r;else throw new Error('expand must be "xmd" or "xof"');let f=new Array(e);for(let N=0;N<e;N++){let T=new Array(s);for(let O=0;O<s;O++){let H=g*(O+N*s),D=x.subarray(H,H+g);T[O]=Se(J0(D),n)}f[N]=T}return f}function go(r,e){let t=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,c,a]=t.map(h=>h.reduce((p,g)=>r.add(r.mul(p,n),g)));return n=r.div(s,o),i=r.mul(i,r.div(c,a)),{x:n,y:i}}}function yo(r,e,t){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=qc(n,2,{...t,DST:t.DST,...i}),o=r.fromAffine(e(s[0])),c=r.fromAffine(e(s[1])),a=o.add(c).clearCofactor();return a.assertValidity(),a},encodeToCurve(n,i){let s=qc(n,1,{...t,DST:t.encodeDST,...i}),o=r.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(let s of n)if(typeof s!="bigint")throw new Error(`mapToCurve: expected array of bigints, got ${s} in array`);let i=r.fromAffine(e(n)).clearCofactor();return i.assertValidity(),i}}}var nl=BigInt(0),wo=BigInt(1),bo=new WeakMap,Cc=new WeakMap;function Ni(r,e){let t=(s,o)=>{let c=o.negate();return s?c:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>e)throw new Error(`Wrong window size=${s}, should be [1..${e}]`)},i=s=>{n(s);let o=Math.ceil(e/s)+1,c=2**(s-1);return{windows:o,windowSize:c}};return{constTimeNegate:t,unsafeLadder(s,o){let c=r.ZERO,a=s;for(;o>nl;)o&wo&&(c=c.add(a)),a=a.double(),o>>=wo;return c},precomputeWindow(s,o){let{windows:c,windowSize:a}=i(o),h=[],p=s,g=p;for(let w=0;w<c;w++){g=p,h.push(g);for(let x=1;x<a;x++)g=g.add(p),h.push(g);p=g.double()}return h},wNAF(s,o,c){let{windows:a,windowSize:h}=i(s),p=r.ZERO,g=r.BASE,w=BigInt(2**s-1),x=2**s,f=BigInt(s);for(let N=0;N<a;N++){let T=N*h,O=Number(c&w);c>>=f,O>h&&(O-=x,c+=wo);let H=T,D=T+Math.abs(O)-1,K=N%2!==0,E=O<0;O===0?g=g.add(t(K,o[H])):p=p.add(t(E,o[D]))}return{p,f:g}},wNAFCached(s,o,c){let a=Cc.get(s)||1,h=bo.get(s);return h||(h=this.precomputeWindow(s,a),a!==1&&bo.set(s,c(h))),this.wNAF(a,h,o)},setWindowSize(s,o){n(o),Cc.set(s,o),bo.delete(s)}}}function Ri(r,e,t,n){if(!Array.isArray(t)||!Array.isArray(n)||n.length!==t.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((p,g)=>{if(!e.isValid(p))throw new Error(`wrong scalar at index ${g}`)}),t.forEach((p,g)=>{if(!(p instanceof r))throw new Error(`wrong point at index ${g}`)});let i=zt(BigInt(t.length)),s=i>12?i-3:i>4?i-2:i?2:1,o=(1<<s)-1,c=new Array(o+1).fill(r.ZERO),a=Math.floor((e.BITS-1)/s)*s,h=r.ZERO;for(let p=a;p>=0;p-=s){c.fill(r.ZERO);for(let w=0;w<n.length;w++){let x=n[w],f=Number(x>>BigInt(p)&BigInt(o));c[f]=c[f].add(t[w])}let g=r.ZERO;for(let w=c.length-1,x=r.ZERO;w>0;w--)x=x.add(c[w]),g=g.add(x);if(h=h.add(g),p!==0)for(let w=0;w<s;w++)h=h.double()}return h}function Oi(r){return Bi(r.Fp),Tt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ho(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}function il(r){let e=Oi(r);Tt(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:i}=e;if(t){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:rp,hexToBytes:np}=Si;var Ar=BigInt(0),Me=BigInt(1),fr=BigInt(2),Ui=BigInt(3),$c=BigInt(4);function xo(r){let e=il(r),{Fp:t}=e,n=kt(e.n,e.nBitLength),i=e.toBytes||((N,T,O)=>{let H=T.toAffine();return Ie(Uint8Array.from([4]),t.toBytes(H.x),t.toBytes(H.y))}),s=e.fromBytes||(N=>{let T=N.subarray(1),O=t.fromBytes(T.subarray(0,t.BYTES)),H=t.fromBytes(T.subarray(t.BYTES,2*t.BYTES));return{x:O,y:H}});function o(N){let{a:T,b:O}=e,H=t.sqr(N),D=t.mul(H,N);return t.add(t.add(D,t.mul(N,T)),O)}if(!t.eql(t.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function c(N){return Ii(N,Me,e.n)}function a(N){let{allowedPrivateKeyLengths:T,nByteLength:O,wrapPrivateKey:H,n:D}=e;if(T&&typeof N!="bigint"){if($r(N)&&(N=St(N)),typeof N!="string"||!T.includes(N.length))throw new Error("Invalid key");N=N.padStart(O*2,"0")}let K;try{K=typeof N=="bigint"?N:Je(He("private key",N,O))}catch{throw new Error(`private key must be ${O} bytes, hex or bigint, not ${typeof N}`)}return H&&(K=Se(K,D)),Bt("private key",K,Me,D),K}function h(N){if(!(N instanceof w))throw new Error("ProjectivePoint expected")}let p=Kt((N,T)=>{let{px:O,py:H,pz:D}=N;if(t.eql(D,t.ONE))return{x:O,y:H};let K=N.is0();T==null&&(T=K?t.ONE:t.inv(D));let E=t.mul(O,T),C=t.mul(H,T),G=t.mul(D,T);if(K)return{x:t.ZERO,y:t.ZERO};if(!t.eql(G,t.ONE))throw new Error("invZ was invalid");return{x:E,y:C}}),g=Kt(N=>{if(N.is0()){if(e.allowInfinityPoint&&!t.is0(N.py))return;throw new Error("bad point: ZERO")}let{x:T,y:O}=N.toAffine();if(!t.isValid(T)||!t.isValid(O))throw new Error("bad point: x or y not FE");let H=t.sqr(O),D=o(T);if(!t.eql(H,D))throw new Error("bad point: equation left != right");if(!N.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class w{constructor(T,O,H){if(this.px=T,this.py=O,this.pz=H,T==null||!t.isValid(T))throw new Error("x required");if(O==null||!t.isValid(O))throw new Error("y required");if(H==null||!t.isValid(H))throw new Error("z required");Object.freeze(this)}static fromAffine(T){let{x:O,y:H}=T||{};if(!T||!t.isValid(O)||!t.isValid(H))throw new Error("invalid affine point");if(T instanceof w)throw new Error("projective point not allowed");let D=K=>t.eql(K,t.ZERO);return D(O)&&D(H)?w.ZERO:new w(O,H,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(T){let O=t.invertBatch(T.map(H=>H.pz));return T.map((H,D)=>H.toAffine(O[D])).map(w.fromAffine)}static fromHex(T){let O=w.fromAffine(s(He("pointHex",T)));return O.assertValidity(),O}static fromPrivateKey(T){return w.BASE.multiply(a(T))}static msm(T,O){return Ri(w,n,T,O)}_setWindowSize(T){f.setWindowSize(this,T)}assertValidity(){g(this)}hasEvenY(){let{y:T}=this.toAffine();if(t.isOdd)return!t.isOdd(T);throw new Error("Field doesn't support isOdd")}equals(T){h(T);let{px:O,py:H,pz:D}=this,{px:K,py:E,pz:C}=T,G=t.eql(t.mul(O,C),t.mul(K,D)),j=t.eql(t.mul(H,C),t.mul(E,D));return G&&j}negate(){return new w(this.px,t.neg(this.py),this.pz)}double(){let{a:T,b:O}=e,H=t.mul(O,Ui),{px:D,py:K,pz:E}=this,C=t.ZERO,G=t.ZERO,j=t.ZERO,k=t.mul(D,D),fe=t.mul(K,K),re=t.mul(E,E),te=t.mul(D,K);return te=t.add(te,te),j=t.mul(D,E),j=t.add(j,j),C=t.mul(T,j),G=t.mul(H,re),G=t.add(C,G),C=t.sub(fe,G),G=t.add(fe,G),G=t.mul(C,G),C=t.mul(te,C),j=t.mul(H,j),re=t.mul(T,re),te=t.sub(k,re),te=t.mul(T,te),te=t.add(te,j),j=t.add(k,k),k=t.add(j,k),k=t.add(k,re),k=t.mul(k,te),G=t.add(G,k),re=t.mul(K,E),re=t.add(re,re),k=t.mul(re,te),C=t.sub(C,k),j=t.mul(re,fe),j=t.add(j,j),j=t.add(j,j),new w(C,G,j)}add(T){h(T);let{px:O,py:H,pz:D}=this,{px:K,py:E,pz:C}=T,G=t.ZERO,j=t.ZERO,k=t.ZERO,fe=e.a,re=t.mul(e.b,Ui),te=t.mul(O,K),y=t.mul(H,E),I=t.mul(D,C),q=t.add(O,H),F=t.add(K,E);q=t.mul(q,F),F=t.add(te,y),q=t.sub(q,F),F=t.add(O,D);let P=t.add(K,C);return F=t.mul(F,P),P=t.add(te,I),F=t.sub(F,P),P=t.add(H,D),G=t.add(E,C),P=t.mul(P,G),G=t.add(y,I),P=t.sub(P,G),k=t.mul(fe,F),G=t.mul(re,I),k=t.add(G,k),G=t.sub(y,k),k=t.add(y,k),j=t.mul(G,k),y=t.add(te,te),y=t.add(y,te),I=t.mul(fe,I),F=t.mul(re,F),y=t.add(y,I),I=t.sub(te,I),I=t.mul(fe,I),F=t.add(F,I),te=t.mul(y,F),j=t.add(j,te),te=t.mul(P,F),G=t.mul(q,G),G=t.sub(G,te),te=t.mul(q,y),k=t.mul(P,k),k=t.add(k,te),new w(G,j,k)}subtract(T){return this.add(T.negate())}is0(){return this.equals(w.ZERO)}wNAF(T){return f.wNAFCached(this,T,w.normalizeZ)}multiplyUnsafe(T){Bt("scalar",T,Ar,e.n);let O=w.ZERO;if(T===Ar)return O;if(T===Me)return this;let{endo:H}=e;if(!H)return f.unsafeLadder(this,T);let{k1neg:D,k1:K,k2neg:E,k2:C}=H.splitScalar(T),G=O,j=O,k=this;for(;K>Ar||C>Ar;)K&Me&&(G=G.add(k)),C&Me&&(j=j.add(k)),k=k.double(),K>>=Me,C>>=Me;return D&&(G=G.negate()),E&&(j=j.negate()),j=new w(t.mul(j.px,H.beta),j.py,j.pz),G.add(j)}multiply(T){let{endo:O,n:H}=e;Bt("scalar",T,Me,H);let D,K;if(O){let{k1neg:E,k1:C,k2neg:G,k2:j}=O.splitScalar(T),{p:k,f:fe}=this.wNAF(C),{p:re,f:te}=this.wNAF(j);k=f.constTimeNegate(E,k),re=f.constTimeNegate(G,re),re=new w(t.mul(re.px,O.beta),re.py,re.pz),D=k.add(re),K=fe.add(te)}else{let{p:E,f:C}=this.wNAF(T);D=E,K=C}return w.normalizeZ([D,K])[0]}multiplyAndAddUnsafe(T,O,H){let D=w.BASE,K=(C,G)=>G===Ar||G===Me||!C.equals(D)?C.multiplyUnsafe(G):C.multiply(G),E=K(this,O).add(K(T,H));return E.is0()?void 0:E}toAffine(T){return p(this,T)}isTorsionFree(){let{h:T,isTorsionFree:O}=e;if(T===Me)return!0;if(O)return O(w,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:T,clearCofactor:O}=e;return T===Me?this:O?O(w,this):this.multiplyUnsafe(e.h)}toRawBytes(T=!0){return sr("isCompressed",T),this.assertValidity(),i(w,this,T)}toHex(T=!0){return sr("isCompressed",T),St(this.toRawBytes(T))}}w.BASE=new w(e.Gx,e.Gy,t.ONE),w.ZERO=new w(t.ZERO,t.ONE,t.ZERO);let x=e.nBitLength,f=Ni(w,e.endo?Math.ceil(x/2):x);return{CURVE:e,ProjectivePoint:w,normPrivateKeyToScalar:a,weierstrassEquation:o,isWithinCurveOrder:c}}function sl(r,e){let t=r.ORDER,n=Ar;for(let f=t-Me;f%fr===Ar;f/=fr)n+=Me;let i=n,s=fr<<i-Me-Me,o=s*fr,c=(t-Me)/o,a=(c-Me)/fr,h=o-Me,p=s,g=r.pow(e,c),w=r.pow(e,(c+Me)/fr),x=(f,N)=>{let T=g,O=r.pow(N,h),H=r.sqr(O);H=r.mul(H,N);let D=r.mul(f,H);D=r.pow(D,a),D=r.mul(D,O),O=r.mul(D,N),H=r.mul(D,f);let K=r.mul(H,O);D=r.pow(K,p);let E=r.eql(D,r.ONE);O=r.mul(H,w),D=r.mul(K,T),H=r.cmov(O,H,E),K=r.cmov(D,K,E);for(let C=i;C>Me;C--){let G=C-fr;G=fr<<G-Me;let j=r.pow(K,G),k=r.eql(j,r.ONE);O=r.mul(H,T),T=r.mul(T,T),j=r.mul(K,T),H=r.cmov(O,H,k),K=r.cmov(j,K,k)}return{isValid:E,value:H}};if(r.ORDER%$c===Ui){let f=(r.ORDER-Ui)/$c,N=r.sqrt(r.neg(e));x=(T,O)=>{let H=r.sqr(O),D=r.mul(T,O);H=r.mul(H,D);let K=r.pow(H,f);K=r.mul(K,D);let E=r.mul(K,N),C=r.mul(r.sqr(K),O),G=r.eql(C,T),j=r.cmov(E,K,G);return{isValid:G,value:j}}}return x}function _o(r,e){if(Bi(r),!r.isValid(e.A)||!r.isValid(e.B)||!r.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let t=sl(r,e.Z);if(!r.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,c,a,h,p,g;i=r.sqr(n),i=r.mul(i,e.Z),s=r.sqr(i),s=r.add(s,i),o=r.add(s,r.ONE),o=r.mul(o,e.B),c=r.cmov(e.Z,r.neg(s),!r.eql(s,r.ZERO)),c=r.mul(c,e.A),s=r.sqr(o),h=r.sqr(c),a=r.mul(h,e.A),s=r.add(s,a),s=r.mul(s,o),h=r.mul(h,c),a=r.mul(h,e.B),s=r.add(s,a),p=r.mul(i,o);let{isValid:w,value:x}=t(s,h);g=r.mul(i,n),g=r.mul(g,x),p=r.cmov(p,o,w),g=r.cmov(g,x,w);let f=r.isOdd(n)===r.isOdd(g);return g=r.cmov(r.neg(g),g,f),p=r.div(p,c),{x:p,y:g}}}var ol=BigInt(0),Fi=BigInt(1),Hc=BigInt(2),Hr=BigInt(3);function al(r){let e=[];for(;r>Fi;r>>=Fi)(r&Fi)===ol?e.unshift(0):(r&Hr)===Hr?(e.unshift(-1),r+=Fi):e.unshift(1);return e}function Gc(r){let{Fp:e,Fr:t,Fp2:n,Fp6:i,Fp12:s}=r.fields,o=r.params.xNegative,c=r.params.twistType,a=xo({n:t.ORDER,...r.G1}),h=Object.assign(a,yo(a.ProjectivePoint,r.G1.mapToCurve,{...r.htfDefaults,...r.G1.htfDefaults})),p=xo({n:t.ORDER,...r.G2}),g=Object.assign(p,yo(p.ProjectivePoint,r.G2.mapToCurve,{...r.htfDefaults,...r.G2.htfDefaults})),w;if(c==="multiplicative")w=(Y,U,d,J,ee,ae)=>s.mul014(J,Y,n.mul(U,ee),n.mul(d,ae));else if(c==="divisive")w=(Y,U,d,J,ee,ae)=>s.mul034(J,n.mul(d,ae),n.mul(U,ee),Y);else throw new Error("bls: unknown twist type");let x=n.div(n.ONE,n.mul(n.ONE,Hc));function f(Y,U,d,J){let ee=n.sqr(d),ae=n.sqr(J),Q=n.mulByB(n.mul(ae,Hr)),u=n.mul(Q,Hr),l=n.sub(n.sub(n.sqr(n.add(d,J)),ae),ee),m=n.sub(Q,ee),S=n.mul(n.sqr(U),Hr),v=n.neg(l);return Y.push([m,S,v]),U=n.mul(n.mul(n.mul(n.sub(ee,u),U),d),x),d=n.sub(n.sqr(n.mul(n.add(ee,u),x)),n.mul(n.sqr(Q),Hr)),J=n.mul(ee,l),{Rx:U,Ry:d,Rz:J}}function N(Y,U,d,J,ee,ae){let Q=n.sub(d,n.mul(ae,J)),u=n.sub(U,n.mul(ee,J)),l=n.sub(n.mul(Q,ee),n.mul(u,ae)),m=n.neg(Q),S=u;Y.push([l,m,S]);let v=n.sqr(u),A=n.mul(v,u),M=n.mul(v,U),b=n.add(n.sub(A,n.mul(M,Hc)),n.mul(n.sqr(Q),J));return U=n.mul(u,b),d=n.sub(n.mul(n.sub(M,b),Q),n.mul(A,d)),J=n.mul(J,A),{Rx:U,Ry:d,Rz:J}}let T=al(r.params.ateLoopSize),O=Kt(Y=>{let U=Y,{x:d,y:J}=U.toAffine(),ee=d,ae=J,Q=n.neg(J),u=ee,l=ae,m=n.ONE,S=[];for(let v of T){let A=[];({Rx:u,Ry:l,Rz:m}=f(A,u,l,m)),v&&({Rx:u,Ry:l,Rz:m}=N(A,u,l,m,ee,v===-1?Q:ae)),S.push(A)}if(r.postPrecompute){let v=S[S.length-1];r.postPrecompute(u,l,m,ee,ae,N.bind(null,v))}return S});function H(Y,U=!1){let d=s.ONE;if(Y.length){let J=Y[0][0].length;for(let ee=0;ee<J;ee++){d=s.sqr(d);for(let[ae,Q,u]of Y)for(let[l,m,S]of ae[ee])d=w(l,m,S,d,Q,u)}}return o&&(d=s.conjugate(d)),U?s.finalExponentiate(d):d}function D(Y,U=!0){let d=[];h.ProjectivePoint.normalizeZ(Y.map(({g1:J})=>J)),g.ProjectivePoint.normalizeZ(Y.map(({g2:J})=>J));for(let{g1:J,g2:ee}of Y){if(J.equals(h.ProjectivePoint.ZERO)||ee.equals(g.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");J.assertValidity(),ee.assertValidity();let ae=J.toAffine();d.push([O(ee),ae.x,ae.y])}return H(d,U)}function K(Y,U,d=!0){return D([{g1:Y,g2:U}],d)}let E={randomPrivateKey:()=>{let Y=Ti(t.ORDER);return po(r.randomBytes(Y),t.ORDER)},calcPairingPrecomputes:O},{ShortSignature:C}=r.G1,{Signature:G}=r.G2;function j(Y){return Y instanceof h.ProjectivePoint?Y:h.ProjectivePoint.fromHex(Y)}function k(Y,U){return Y instanceof h.ProjectivePoint?Y:h.hashToCurve(He("point",Y),U)}function fe(Y){return Y instanceof g.ProjectivePoint?Y:G.fromHex(Y)}function re(Y,U){return Y instanceof g.ProjectivePoint?Y:g.hashToCurve(He("point",Y),U)}function te(Y){return h.ProjectivePoint.fromPrivateKey(Y).toRawBytes(!0)}function y(Y){return g.ProjectivePoint.fromPrivateKey(Y).toRawBytes(!0)}function I(Y,U,d){let J=re(Y,d);J.assertValidity();let ee=J.multiply(h.normPrivateKeyToScalar(U));return Y instanceof g.ProjectivePoint?ee:G.toRawBytes(ee)}function q(Y,U,d){let J=k(Y,d);J.assertValidity();let ee=J.multiply(h.normPrivateKeyToScalar(U));return Y instanceof h.ProjectivePoint?ee:C.toRawBytes(ee)}function F(Y,U,d,J){let ee=j(d),ae=re(U,J),Q=h.ProjectivePoint.BASE,u=fe(Y),l=D([{g1:ee.negate(),g2:ae},{g1:Q,g2:u}]);return s.eql(l,s.ONE)}function P(Y,U,d,J){let ee=fe(d),ae=k(U,J),Q=g.ProjectivePoint.BASE,u=j(Y),l=D([{g1:ae,g2:ee},{g1:u,g2:Q.negate()}]);return s.eql(l,s.ONE)}function $(Y){if(!Y.length)throw new Error("Expected non-empty array");let d=Y.map(j).reduce((J,ee)=>J.add(ee),h.ProjectivePoint.ZERO);return Y[0]instanceof h.ProjectivePoint?(d.assertValidity(),d):d.toRawBytes(!0)}function Z(Y){if(!Y.length)throw new Error("Expected non-empty array");let d=Y.map(fe).reduce((J,ee)=>J.add(ee),g.ProjectivePoint.ZERO);return Y[0]instanceof g.ProjectivePoint?(d.assertValidity(),d):G.toRawBytes(d)}function ue(Y){if(!Y.length)throw new Error("Expected non-empty array");let d=Y.map(j).reduce((J,ee)=>J.add(ee),h.ProjectivePoint.ZERO);return Y[0]instanceof h.ProjectivePoint?(d.assertValidity(),d):C.toRawBytes(d)}function ce(Y,U,d,J){if(!U.length)throw new Error("Expected non-empty messages array");if(d.length!==U.length)throw new Error("Pubkey count should equal msg count");let ee=fe(Y),ae=U.map(m=>re(m,J)),Q=d.map(j),u=new Map;for(let m=0;m<Q.length;m++){let S=Q[m],v=ae[m],A=u.get(v);A===void 0&&(A=[],u.set(v,A)),A.push(S)}let l=[];try{for(let[m,S]of u){let v=S.reduce((A,M)=>A.add(M));l.push({g1:v,g2:m})}return l.push({g1:h.ProjectivePoint.BASE.negate(),g2:ee}),s.eql(D(l),s.ONE)}catch{return!1}}return h.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:te,getPublicKeyForShortSignatures:y,sign:I,signShortSignature:q,verify:F,verifyBatch:ce,verifyShortSignature:P,aggregatePublicKeys:$,aggregateSignatures:Z,aggregateShortSignatures:ue,millerLoopBatch:H,pairing:K,pairingBatch:D,G1:h,G2:g,Signature:G,ShortSignature:C,fields:{Fr:t,Fp:e,Fp2:n,Fp6:i,Fp12:s},params:{ateLoopSize:r.params.ateLoopSize,r:r.params.r,G1b:r.G1.b,G2b:r.G2.b},utils:E}}var cl=BigInt(0),Gr=BigInt(1),Zt=BigInt(2),Vc=BigInt(3);function Eo(r,e,t,n,i=1,s){let o=BigInt(s===void 0?n:s),c=t**BigInt(n),a=[];for(let h=0;h<i;h++){let p=BigInt(h+1),g=[];for(let w=0,x=Gr;w<n;w++){let f=(p*x-p)/o%c;g.push(r.pow(e,f)),x*=t}a.push(g)}return a}function jc(r,e,t){let n=e.pow(t,(r.ORDER-Gr)/Vc),i=e.pow(t,(r.ORDER-Gr)/Zt);function s(w,x){let f=e.mul(e.frobeniusMap(w,1),n),N=e.mul(e.frobeniusMap(x,1),i);return[f,N]}let o=e.pow(t,(r.ORDER**Zt-Gr)/Vc),c=e.pow(t,(r.ORDER**Zt-Gr)/Zt);if(!e.eql(c,e.neg(e.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function a(w,x){return[e.mul(w,o),e.neg(x)]}let h=w=>(x,f)=>{let N=f.toAffine(),T=w(N.x,N.y);return x.fromAffine({x:T[0],y:T[1]})},p=h(s),g=h(a);return{psi:s,psi2:a,G2psi:p,G2psi2:g,PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:c}}function Yc(r){let{ORDER:e}=r,t=kt(e),n=t.create(r.NONRESIDUE||BigInt(-1)),i=Dc(e),s=t.div(t.ONE,Zt),o=Eo(t,n,t.ORDER,2)[0],c=({c0:y,c1:I},{c0:q,c1:F})=>({c0:t.add(y,q),c1:t.add(I,F)}),a=({c0:y,c1:I},{c0:q,c1:F})=>({c0:t.sub(y,q),c1:t.sub(I,F)}),h=({c0:y,c1:I},q)=>{if(typeof q=="bigint")return{c0:t.mul(y,q),c1:t.mul(I,q)};let{c0:F,c1:P}=q,$=t.mul(y,F),Z=t.mul(I,P),ue=t.sub($,Z),ce=t.sub(t.mul(t.add(y,I),t.add(F,P)),t.add($,Z));return{c0:ue,c1:ce}},p=({c0:y,c1:I})=>{let q=t.add(y,I),F=t.sub(y,I),P=t.add(y,y);return{c0:t.mul(q,F),c1:t.mul(P,I)}},g=y=>{if(y.length!==2)throw new Error("Invalid tuple");let I=y.map(q=>t.create(q));return{c0:I[0],c1:I[1]}},w=e*e,x=g(r.FP2_NONRESIDUE),f={ORDER:w,NONRESIDUE:x,BITS:zt(w),BYTES:Math.ceil(zt(w)/8),MASK:ar(zt(w)),ZERO:{c0:t.ZERO,c1:t.ZERO},ONE:{c0:t.ONE,c1:t.ZERO},create:y=>y,isValid:({c0:y,c1:I})=>typeof y=="bigint"&&typeof I=="bigint",is0:({c0:y,c1:I})=>t.is0(y)&&t.is0(I),eql:({c0:y,c1:I},{c0:q,c1:F})=>t.eql(y,q)&&t.eql(I,F),neg:({c0:y,c1:I})=>({c0:t.neg(y),c1:t.neg(I)}),pow:(y,I)=>xn(f,y,I),invertBatch:y=>_n(f,y),add:c,sub:a,mul:h,sqr:p,addN:c,subN:a,mulN:h,sqrN:p,div:(y,I)=>f.mul(y,typeof I=="bigint"?t.inv(t.create(I)):f.inv(I)),inv:({c0:y,c1:I})=>{let q=t.inv(t.create(y*y+I*I));return{c0:t.mul(q,t.create(y)),c1:t.mul(q,t.create(-I))}},sqrt:y=>{if(r.Fp2sqrt)return r.Fp2sqrt(y);let{c0:I,c1:q}=y;if(t.is0(q))return t.eql(i(t,I),t.ONE)?f.create({c0:t.sqrt(I),c1:t.ZERO}):f.create({c0:t.ZERO,c1:t.sqrt(t.div(I,n))});let F=t.sqrt(t.sub(t.sqr(I),t.mul(t.sqr(q),n))),P=t.mul(t.add(F,I),s),$=i(t,P);!t.is0($)&&!t.eql($,t.ONE)&&(P=t.sub(P,F));let Z=t.sqrt(P),ue=f.create({c0:Z,c1:t.div(t.mul(q,s),Z)});if(!f.eql(f.sqr(ue),y))throw new Error("Cannot find square root");let ce=ue,Y=f.neg(ce),{re:U,im:d}=f.reim(ce),{re:J,im:ee}=f.reim(Y);return d>ee||d===ee&&U>J?ce:Y},isOdd:y=>{let{re:I,im:q}=f.reim(y),F=I%Zt,P=I===cl,$=q%Zt;return BigInt(F||P&&$)==Gr},fromBytes(y){if(y.length!==f.BYTES)throw new Error(`fromBytes wrong length=${y.length}`);return{c0:t.fromBytes(y.subarray(0,t.BYTES)),c1:t.fromBytes(y.subarray(t.BYTES))}},toBytes:({c0:y,c1:I})=>Ie(t.toBytes(y),t.toBytes(I)),cmov:({c0:y,c1:I},{c0:q,c1:F},P)=>({c0:t.cmov(y,q,P),c1:t.cmov(I,F,P)}),reim:({c0:y,c1:I})=>({re:y,im:I}),mulByNonresidue:({c0:y,c1:I})=>f.mul({c0:y,c1:I},x),mulByB:r.Fp2mulByB,fromBigTuple:g,frobeniusMap:({c0:y,c1:I},q)=>({c0:y,c1:t.mul(I,o[q%2])})},N=({c0:y,c1:I,c2:q},{c0:F,c1:P,c2:$})=>({c0:f.add(y,F),c1:f.add(I,P),c2:f.add(q,$)}),T=({c0:y,c1:I,c2:q},{c0:F,c1:P,c2:$})=>({c0:f.sub(y,F),c1:f.sub(I,P),c2:f.sub(q,$)}),O=({c0:y,c1:I,c2:q},F)=>{if(typeof F=="bigint")return{c0:f.mul(y,F),c1:f.mul(I,F),c2:f.mul(q,F)};let{c0:P,c1:$,c2:Z}=F,ue=f.mul(y,P),ce=f.mul(I,$),Y=f.mul(q,Z);return{c0:f.add(ue,f.mulByNonresidue(f.sub(f.mul(f.add(I,q),f.add($,Z)),f.add(ce,Y)))),c1:f.add(f.sub(f.mul(f.add(y,I),f.add(P,$)),f.add(ue,ce)),f.mulByNonresidue(Y)),c2:f.sub(f.add(ce,f.mul(f.add(y,q),f.add(P,Z))),f.add(ue,Y))}},H=({c0:y,c1:I,c2:q})=>{let F=f.sqr(y),P=f.mul(f.mul(y,I),Zt),$=f.mul(f.mul(I,q),Zt),Z=f.sqr(q);return{c0:f.add(f.mulByNonresidue($),F),c1:f.add(f.mulByNonresidue(Z),P),c2:f.sub(f.sub(f.add(f.add(P,f.sqr(f.add(f.sub(y,I),q))),$),F),Z)}},[D,K]=Eo(f,x,t.ORDER,6,2,3),E={ORDER:f.ORDER,BITS:3*f.BITS,BYTES:3*f.BYTES,MASK:ar(3*f.BITS),ZERO:{c0:f.ZERO,c1:f.ZERO,c2:f.ZERO},ONE:{c0:f.ONE,c1:f.ZERO,c2:f.ZERO},create:y=>y,isValid:({c0:y,c1:I,c2:q})=>f.isValid(y)&&f.isValid(I)&&f.isValid(q),is0:({c0:y,c1:I,c2:q})=>f.is0(y)&&f.is0(I)&&f.is0(q),neg:({c0:y,c1:I,c2:q})=>({c0:f.neg(y),c1:f.neg(I),c2:f.neg(q)}),eql:({c0:y,c1:I,c2:q},{c0:F,c1:P,c2:$})=>f.eql(y,F)&&f.eql(I,P)&&f.eql(q,$),sqrt:Ai,div:(y,I)=>E.mul(y,typeof I=="bigint"?t.inv(t.create(I)):E.inv(I)),pow:(y,I)=>xn(E,y,I),invertBatch:y=>_n(E,y),add:N,sub:T,mul:O,sqr:H,addN:N,subN:T,mulN:O,sqrN:H,inv:({c0:y,c1:I,c2:q})=>{let F=f.sub(f.sqr(y),f.mulByNonresidue(f.mul(q,I))),P=f.sub(f.mulByNonresidue(f.sqr(q)),f.mul(y,I)),$=f.sub(f.sqr(I),f.mul(y,q)),Z=f.inv(f.add(f.mulByNonresidue(f.add(f.mul(q,P),f.mul(I,$))),f.mul(y,F)));return{c0:f.mul(Z,F),c1:f.mul(Z,P),c2:f.mul(Z,$)}},fromBytes:y=>{if(y.length!==E.BYTES)throw new Error(`fromBytes wrong length=${y.length}`);return{c0:f.fromBytes(y.subarray(0,f.BYTES)),c1:f.fromBytes(y.subarray(f.BYTES,2*f.BYTES)),c2:f.fromBytes(y.subarray(2*f.BYTES))}},toBytes:({c0:y,c1:I,c2:q})=>Ie(f.toBytes(y),f.toBytes(I),f.toBytes(q)),cmov:({c0:y,c1:I,c2:q},{c0:F,c1:P,c2:$},Z)=>({c0:f.cmov(y,F,Z),c1:f.cmov(I,P,Z),c2:f.cmov(q,$,Z)}),fromBigSix:y=>{if(!Array.isArray(y)||y.length!==6)throw new Error("Invalid Fp6 usage");return{c0:f.fromBigTuple(y.slice(0,2)),c1:f.fromBigTuple(y.slice(2,4)),c2:f.fromBigTuple(y.slice(4,6))}},frobeniusMap:({c0:y,c1:I,c2:q},F)=>({c0:f.frobeniusMap(y,F),c1:f.mul(f.frobeniusMap(I,F),D[F%6]),c2:f.mul(f.frobeniusMap(q,F),K[F%6])}),mulByFp2:({c0:y,c1:I,c2:q},F)=>({c0:f.mul(y,F),c1:f.mul(I,F),c2:f.mul(q,F)}),mulByNonresidue:({c0:y,c1:I,c2:q})=>({c0:f.mulByNonresidue(q),c1:y,c2:I}),mul1:({c0:y,c1:I,c2:q},F)=>({c0:f.mulByNonresidue(f.mul(q,F)),c1:f.mul(y,F),c2:f.mul(I,F)}),mul01({c0:y,c1:I,c2:q},F,P){let $=f.mul(y,F),Z=f.mul(I,P);return{c0:f.add(f.mulByNonresidue(f.sub(f.mul(f.add(I,q),P),Z)),$),c1:f.sub(f.sub(f.mul(f.add(F,P),f.add(y,I)),$),Z),c2:f.add(f.sub(f.mul(f.add(y,q),F),$),Z)}}},C=Eo(f,x,t.ORDER,12,1,6)[0],G=({c0:y,c1:I},{c0:q,c1:F})=>({c0:E.add(y,q),c1:E.add(I,F)}),j=({c0:y,c1:I},{c0:q,c1:F})=>({c0:E.sub(y,q),c1:E.sub(I,F)}),k=({c0:y,c1:I},q)=>{if(typeof q=="bigint")return{c0:E.mul(y,q),c1:E.mul(I,q)};let{c0:F,c1:P}=q,$=E.mul(y,F),Z=E.mul(I,P);return{c0:E.add($,E.mulByNonresidue(Z)),c1:E.sub(E.mul(E.add(y,I),E.add(F,P)),E.add($,Z))}},fe=({c0:y,c1:I})=>{let q=E.mul(y,I);return{c0:E.sub(E.sub(E.mul(E.add(E.mulByNonresidue(I),y),E.add(y,I)),q),E.mulByNonresidue(q)),c1:E.add(q,q)}};function re(y,I){let q=f.sqr(y),F=f.sqr(I);return{first:f.add(f.mulByNonresidue(F),q),second:f.sub(f.sub(f.sqr(f.add(y,I)),q),F)}}let te={ORDER:f.ORDER,BITS:2*f.BITS,BYTES:2*f.BYTES,MASK:ar(2*f.BITS),ZERO:{c0:E.ZERO,c1:E.ZERO},ONE:{c0:E.ONE,c1:E.ZERO},create:y=>y,isValid:({c0:y,c1:I})=>E.isValid(y)&&E.isValid(I),is0:({c0:y,c1:I})=>E.is0(y)&&E.is0(I),neg:({c0:y,c1:I})=>({c0:E.neg(y),c1:E.neg(I)}),eql:({c0:y,c1:I},{c0:q,c1:F})=>E.eql(y,q)&&E.eql(I,F),sqrt:Ai,inv:({c0:y,c1:I})=>{let q=E.inv(E.sub(E.sqr(y),E.mulByNonresidue(E.sqr(I))));return{c0:E.mul(y,q),c1:E.neg(E.mul(I,q))}},div:(y,I)=>te.mul(y,typeof I=="bigint"?t.inv(t.create(I)):te.inv(I)),pow:(y,I)=>xn(te,y,I),invertBatch:y=>_n(te,y),add:G,sub:j,mul:k,sqr:fe,addN:G,subN:j,mulN:k,sqrN:fe,fromBytes:y=>{if(y.length!==te.BYTES)throw new Error(`fromBytes wrong length=${y.length}`);return{c0:E.fromBytes(y.subarray(0,E.BYTES)),c1:E.fromBytes(y.subarray(E.BYTES))}},toBytes:({c0:y,c1:I})=>Ie(E.toBytes(y),E.toBytes(I)),cmov:({c0:y,c1:I},{c0:q,c1:F},P)=>({c0:E.cmov(y,q,P),c1:E.cmov(I,F,P)}),fromBigTwelve:y=>({c0:E.fromBigSix(y.slice(0,6)),c1:E.fromBigSix(y.slice(6,12))}),frobeniusMap(y,I){let{c0:q,c1:F,c2:P}=E.frobeniusMap(y.c1,I),$=C[I%12];return{c0:E.frobeniusMap(y.c0,I),c1:E.create({c0:f.mul(q,$),c1:f.mul(F,$),c2:f.mul(P,$)})}},mulByFp2:({c0:y,c1:I},q)=>({c0:E.mulByFp2(y,q),c1:E.mulByFp2(I,q)}),conjugate:({c0:y,c1:I})=>({c0:y,c1:E.neg(I)}),mul014:({c0:y,c1:I},q,F,P)=>{let $=E.mul01(y,q,F),Z=E.mul1(I,P);return{c0:E.add(E.mulByNonresidue(Z),$),c1:E.sub(E.sub(E.mul01(E.add(I,y),q,f.add(F,P)),$),Z)}},mul034:({c0:y,c1:I},q,F,P)=>{let $=E.create({c0:f.mul(y.c0,q),c1:f.mul(y.c1,q),c2:f.mul(y.c2,q)}),Z=E.mul01(I,F,P),ue=E.mul01(E.add(y,I),f.add(q,F),P);return{c0:E.add(E.mulByNonresidue(Z),$),c1:E.sub(ue,E.add($,Z))}},_cyclotomicSquare:r.Fp12cyclotomicSquare,_cyclotomicExp:r.Fp12cyclotomicExp,finalExponentiate:r.Fp12finalExponentiate};return{Fp:t,Fp2:f,Fp6:E,Fp4Square:re,Fp12:te}}var it=BigInt(0),Mi=BigInt(1),Ze=BigInt(2),Pi=BigInt(3),vn=BigInt(4),lr=BigInt("0xd201000000010000"),ul=zt(lr),{Fp:ne,Fp2:se,Fp6:Ao,Fp4Square:vo,Fp12:ge}=Yc({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[Mi,Mi],Fp2mulByB:({c0:r,c1:e})=>{let t=ne.mul(r,vn),n=ne.mul(e,vn);return{c0:ne.sub(t,n),c1:ne.add(t,n)}},Fp12cyclotomicSquare:({c0:r,c1:e})=>{let{c0:t,c1:n,c2:i}=r,{c0:s,c1:o,c2:c}=e,{first:a,second:h}=vo(t,o),{first:p,second:g}=vo(s,i),{first:w,second:x}=vo(n,c),f=se.mulByNonresidue(x);return{c0:Ao.create({c0:se.add(se.mul(se.sub(a,t),Ze),a),c1:se.add(se.mul(se.sub(p,n),Ze),p),c2:se.add(se.mul(se.sub(w,i),Ze),w)}),c1:Ao.create({c0:se.add(se.mul(se.add(f,s),Ze),f),c1:se.add(se.mul(se.add(h,o),Ze),h),c2:se.add(se.mul(se.add(g,c),Ze),g)})}},Fp12cyclotomicExp(r,e){let t=ge.ONE;for(let n=ul-1;n>=0;n--)t=ge._cyclotomicSquare(t),uo(e,n)&&(t=ge.mul(t,r));return t},Fp12finalExponentiate:r=>{let e=lr,t=ge.div(ge.frobeniusMap(r,6),r),n=ge.mul(ge.frobeniusMap(t,2),t),i=ge.conjugate(ge._cyclotomicExp(n,e)),s=ge.mul(ge.conjugate(ge._cyclotomicSquare(n)),i),o=ge.conjugate(ge._cyclotomicExp(s,e)),c=ge.conjugate(ge._cyclotomicExp(o,e)),a=ge.mul(ge.conjugate(ge._cyclotomicExp(c,e)),ge._cyclotomicSquare(i)),h=ge.conjugate(ge._cyclotomicExp(a,e)),p=ge.frobeniusMap(ge.mul(i,c),2),g=ge.frobeniusMap(ge.mul(o,n),3),w=ge.frobeniusMap(ge.mul(a,ge.conjugate(n)),1),x=ge.mul(ge.mul(h,ge.conjugate(s)),n);return ge.mul(ge.mul(ge.mul(p,g),w),x)}}),zc=kt(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),fl=go(se,[[["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(r=>r.map(e=>se.fromBigTuple(e.map(BigInt))))),ll=go(ne,[["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(r=>r.map(e=>BigInt(e)))),hl=_o(se,{A:se.create({c0:ne.create(it),c1:ne.create(BigInt(240))}),B:se.create({c0:ne.create(BigInt(1012)),c1:ne.create(BigInt(1012))}),Z:se.create({c0:ne.create(BigInt(-2)),c1:ne.create(BigInt(-1))})}),dl=_o(ne,{A:ne.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:ne.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:ne.create(BigInt(11))}),{G2psi:Kc,G2psi2:pl}=jc(ne,se,se.div(se.ONE,se.NONRESIDUE)),Io=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:ne.ORDER,m:2,k:128,expand:"xmd",hash:sn}),Di=In(ne.toBytes(it),{infinity:!0,compressed:!0});function Li(r){r=r.slice();let e=r[0]&224,t=!!(e>>7&1),n=!!(e>>6&1),i=!!(e>>5&1);return r[0]&=31,{compressed:t,infinity:n,sort:i,value:r}}function In(r,e){if(r[0]&224)throw new Error("setMask: non-empty mask");return e.compressed&&(r[0]|=128),e.infinity&&(r[0]|=64),e.sort&&(r[0]|=32),r}function Zc(r){r.assertValidity();let e=r.equals(lt.G1.ProjectivePoint.ZERO),{x:t,y:n}=r.toAffine();if(e)return Di.slice();let i=ne.ORDER,s=!!(n*Ze/i);return In(Le(t,ne.BYTES),{compressed:!0,sort:s})}function Wc(r){r.assertValidity();let e=ne.BYTES;if(r.equals(lt.G2.ProjectivePoint.ZERO))return Ie(Di,Le(it,e));let{x:t,y:n}=r.toAffine(),{re:i,im:s}=se.reim(t),{re:o,im:c}=se.reim(n),h=!!((c>it?c*Ze:o*Ze)/ne.ORDER&Mi),p=i;return Ie(In(Le(s,e),{sort:h,compressed:!0}),Le(p,e))}var lt=Gc({fields:{Fp:ne,Fp2:se,Fp6:Ao,Fp12:ge,Fr:zc},G1:{Fp:ne,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:ne.ZERO,b:vn,htfDefaults:{...Io,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(r,e)=>{let t=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new r(ne.mul(e.px,t),e.py,e.pz);return e.multiplyUnsafe(lr).negate().multiplyUnsafe(lr).equals(n)},clearCofactor:(r,e)=>e.multiplyUnsafe(lr).add(e),mapToCurve:r=>{let{x:e,y:t}=dl(ne.create(r[0]));return ll(e,t)},fromBytes:r=>{let{compressed:e,infinity:t,sort:n,value:i}=Li(r);if(i.length===48&&e){let s=ne.ORDER,o=Je(i),c=ne.create(o&ne.MASK);if(t){if(c!==it)throw new Error("G1: non-empty compressed point at infinity");return{x:it,y:it}}let a=ne.add(ne.pow(c,Pi),ne.create(lt.params.G1b)),h=ne.sqrt(a);if(!h)throw new Error("Invalid compressed G1 point");return h*Ze/s!==BigInt(n)&&(h=ne.neg(h)),{x:ne.create(c),y:ne.create(h)}}else if(i.length===96&&!e){let s=Je(i.subarray(0,ne.BYTES)),o=Je(i.subarray(ne.BYTES));if(t){if(s!==it||o!==it)throw new Error("G1: non-empty point at infinity");return lt.G1.ProjectivePoint.ZERO.toAffine()}return{x:ne.create(s),y:ne.create(o)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(r,e,t)=>{let n=e.equals(r.ZERO),{x:i,y:s}=e.toAffine();if(t){if(n)return Di.slice();let o=ne.ORDER,c=!!(s*Ze/o);return In(Le(i,ne.BYTES),{compressed:!0,sort:c})}else return n?Ie(new Uint8Array([64]),new Uint8Array(2*ne.BYTES-1)):Ie(Le(i,ne.BYTES),Le(s,ne.BYTES))},ShortSignature:{fromHex(r){let{infinity:e,sort:t,value:n}=Li(He("signatureHex",r,48)),i=ne.ORDER,s=Je(n);if(e)return lt.G1.ProjectivePoint.ZERO;let o=ne.create(s&ne.MASK),c=ne.add(ne.pow(o,Pi),ne.create(lt.params.G1b)),a=ne.sqrt(c);if(!a)throw new Error("Invalid compressed G1 point");let h=BigInt(t);a*Ze/i!==h&&(a=ne.neg(a));let p=lt.G1.ProjectivePoint.fromAffine({x:o,y:a});return p.assertValidity(),p},toRawBytes(r){return Zc(r)},toHex(r){return St(Zc(r))}}},G2:{Fp:se,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:se.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:se.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:se.ZERO,b:se.fromBigTuple([vn,vn]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...Io},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:r=>{let{x:e,y:t}=hl(se.fromBigTuple(r));return fl(e,t)},isTorsionFree:(r,e)=>e.multiplyUnsafe(lr).negate().equals(Kc(r,e)),clearCofactor:(r,e)=>{let t=lr,n=e.multiplyUnsafe(t).negate(),i=Kc(r,e),s=e.double();return s=pl(r,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(t).negate(),s=s.add(i),s=s.subtract(n),s.subtract(e)},fromBytes:r=>{let{compressed:e,infinity:t,sort:n,value:i}=Li(r);if(!e&&!t&&n||!e&&t&&n||n&&t&&e)throw new Error("Invalid encoding flag: "+(r[0]&224));let s=ne.BYTES,o=(c,a,h)=>Je(c.slice(a,h));if(i.length===96&&e){let c=lt.params.G2b,a=ne.ORDER;if(t){if(i.reduce((N,T)=>N!==0?T+1:T,0)>0)throw new Error("Invalid compressed G2 point");return{x:se.ZERO,y:se.ZERO}}let h=o(i,0,s),p=o(i,s,2*s),g=se.create({c0:ne.create(p),c1:ne.create(h)}),w=se.add(se.pow(g,Pi),c),x=se.sqrt(w),f=x.c1===it?x.c0*Ze/a:x.c1*Ze/a?Mi:it;return x=n&&f>0?x:se.neg(x),{x:g,y:x}}else if(i.length===192&&!e){if(t){if(i.reduce((g,w)=>g!==0?w+1:w,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:se.ZERO,y:se.ZERO}}let c=o(i,0,s),a=o(i,s,2*s),h=o(i,2*s,3*s),p=o(i,3*s,4*s);return{x:se.fromBigTuple([a,c]),y:se.fromBigTuple([p,h])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(r,e,t)=>{let{BYTES:n,ORDER:i}=ne,s=e.equals(r.ZERO),{x:o,y:c}=e.toAffine();if(t){if(s)return Ie(Di,Le(it,n));let a=!!(c.c1===it?c.c0*Ze/i:c.c1*Ze/i);return Ie(In(Le(o.c1,n),{compressed:!0,sort:a}),Le(o.c0,n))}else{if(s)return Ie(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:a,im:h}=se.reim(o),{re:p,im:g}=se.reim(c);return Ie(Le(h,n),Le(a,n),Le(g,n),Le(p,n))}},Signature:{fromHex(r){let{infinity:e,sort:t,value:n}=Li(He("signatureHex",r)),i=ne.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=Je(n.slice(0,s)),c=Je(n.slice(s));if(e)return lt.G2.ProjectivePoint.ZERO;let a=ne.create(o&ne.MASK),h=ne.create(c),p=se.create({c0:h,c1:a}),g=se.add(se.pow(p,Pi),lt.params.G2b),w=se.sqrt(g);if(!w)throw new Error("Failed to find a square root");let{re:x,im:f}=se.reim(w),N=BigInt(t),T=f>it&&f*Ze/i!==N,O=f===it&&x*Ze/i!==N;(T||O)&&(w=se.neg(w));let H=lt.G2.ProjectivePoint.fromAffine({x:p,y:w});return H.assertValidity(),H},toRawBytes(r){return Wc(r)},toHex(r){return St(Wc(r))}}},params:{ateLoopSize:lr,r:zc.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:Io,hash:sn,randomBytes:Cn});function Xc(r,e,t){let n=typeof r=="string"?r:Fe(r),i=typeof e=="string"?e:Fe(e),s=typeof t=="string"?t:Fe(t);return lt.verifyShortSignature(i,s,n)}var So=r=>Ce(new vt(r)),Vr=r=>{let e=So(r);return new Date(Number(e)/1e6)};var gl=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t},yl=new TextEncoder().encode(`
|
|
14
|
-
ic-request`),Qc=class{getPrincipal(){return this._principal||(this._principal=me.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:t}=e,n=gl(e,["body"]),i=gn(t);return Object.assign(Object.assign({},n),{body:{content:t,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign(Qe(yl,i))}})}},An=class{getPrincipal(){return me.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};var eu=rn(ii());var Sn=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let r=new Uint32Array(1);return window.crypto.getRandomValues(r),r[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let r=new Uint32Array(1);return crypto.getRandomValues(r),r[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)};var ki;(function(r){r.Call="call"})(ki||(ki={}));function jr(){let r=new ArrayBuffer(16),e=new DataView(r),t=Sn(),n=Sn(),i=Sn(),s=Sn();return e.setUint32(0,t),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),r}var Jc=BigInt(1e6),wl=60*1e3,Sr=class{constructor(e){if(e<90*1e3){let c=BigInt(Date.now()+e)*Jc/BigInt(1e9);this._value=c*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+e-wl))*Jc/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return eu.value.u64(this._value.toString(16),16)}toHash(){return Be(this._value)}};function Bo(r=jr){return async e=>{let t=e.request.headers;e.request.headers=t,e.endpoint==="call"&&(e.body.nonce=r())}}function Yr(r){let e=[];return r.forEach((t,n)=>{e.push([n,t])}),e}var zr=class extends Ue{constructor(e,t){super(e),this.response=t,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}},qi=class extends Ue{constructor(e,t,n,i,s,o){super(e),this.response=t,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentCallError",Object.setPrototypeOf(this,new.target.prototype)}},Ci=class extends Ue{constructor(e,t,n,i,s,o){super(e),this.response=t,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentQueryError",Object.setPrototypeOf(this,new.target.prototype)}},$i=class extends Ue{constructor(e,t,n,i,s,o){super(e),this.response=t,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentReadStateError",Object.setPrototypeOf(this,new.target.prototype)}};var Hi=BigInt(4294967295),To=BigInt(32);function tu(r,e=!1){return e?{h:Number(r&Hi),l:Number(r>>To&Hi)}:{h:Number(r>>To&Hi)|0,l:Number(r&Hi)|0}}function bl(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){let{h:s,l:o}=tu(r[i],e);[t[i],n[i]]=[s,o]}return[t,n]}var xl=(r,e)=>BigInt(r>>>0)<<To|BigInt(e>>>0),_l=(r,e,t)=>r>>>t,El=(r,e,t)=>r<<32-t|e>>>t,vl=(r,e,t)=>r>>>t|e<<32-t,Il=(r,e,t)=>r<<32-t|e>>>t,Al=(r,e,t)=>r<<64-t|e>>>t-32,Sl=(r,e,t)=>r>>>t-32|e<<64-t,Bl=(r,e)=>e,Tl=(r,e)=>r,Nl=(r,e,t)=>r<<t|e>>>32-t,Rl=(r,e,t)=>e<<t|r>>>32-t,Ol=(r,e,t)=>e<<t-32|r>>>64-t,Ul=(r,e,t)=>r<<t-32|e>>>64-t;function Fl(r,e,t,n){let i=(e>>>0)+(n>>>0);return{h:r+t+(i/2**32|0)|0,l:i|0}}var Pl=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),Ll=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,Ml=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),Dl=(r,e,t,n,i)=>e+t+n+i+(r/2**32|0)|0,kl=(r,e,t,n,i)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(i>>>0),ql=(r,e,t,n,i,s)=>e+t+n+i+s+(r/2**32|0)|0;var Cl={fromBig:tu,split:bl,toBig:xl,shrSH:_l,shrSL:El,rotrSH:vl,rotrSL:Il,rotrBH:Al,rotrBL:Sl,rotr32H:Bl,rotr32L:Tl,rotlSH:Nl,rotlSL:Rl,rotlBH:Ol,rotlBL:Ul,add:Fl,add3L:Pl,add3H:Ll,add4L:Ml,add4H:Dl,add5H:ql,add5L:kl},le=Cl;var[$l,Hl]=le.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(r=>BigInt(r))),hr=new Uint32Array(80),dr=new Uint32Array(80),No=class extends Lr{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:t,Bh:n,Bl:i,Ch:s,Cl:o,Dh:c,Dl:a,Eh:h,El:p,Fh:g,Fl:w,Gh:x,Gl:f,Hh:N,Hl:T}=this;return[e,t,n,i,s,o,c,a,h,p,g,w,x,f,N,T]}set(e,t,n,i,s,o,c,a,h,p,g,w,x,f,N,T){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=c|0,this.Dl=a|0,this.Eh=h|0,this.El=p|0,this.Fh=g|0,this.Fl=w|0,this.Gh=x|0,this.Gl=f|0,this.Hh=N|0,this.Hl=T|0}process(e,t){for(let D=0;D<16;D++,t+=4)hr[D]=e.getUint32(t),dr[D]=e.getUint32(t+=4);for(let D=16;D<80;D++){let K=hr[D-15]|0,E=dr[D-15]|0,C=le.rotrSH(K,E,1)^le.rotrSH(K,E,8)^le.shrSH(K,E,7),G=le.rotrSL(K,E,1)^le.rotrSL(K,E,8)^le.shrSL(K,E,7),j=hr[D-2]|0,k=dr[D-2]|0,fe=le.rotrSH(j,k,19)^le.rotrBH(j,k,61)^le.shrSH(j,k,6),re=le.rotrSL(j,k,19)^le.rotrBL(j,k,61)^le.shrSL(j,k,6),te=le.add4L(G,re,dr[D-7],dr[D-16]),y=le.add4H(te,C,fe,hr[D-7],hr[D-16]);hr[D]=y|0,dr[D]=te|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:c,Cl:a,Dh:h,Dl:p,Eh:g,El:w,Fh:x,Fl:f,Gh:N,Gl:T,Hh:O,Hl:H}=this;for(let D=0;D<80;D++){let K=le.rotrSH(g,w,14)^le.rotrSH(g,w,18)^le.rotrBH(g,w,41),E=le.rotrSL(g,w,14)^le.rotrSL(g,w,18)^le.rotrBL(g,w,41),C=g&x^~g&N,G=w&f^~w&T,j=le.add5L(H,E,G,Hl[D],dr[D]),k=le.add5H(j,O,K,C,$l[D],hr[D]),fe=j|0,re=le.rotrSH(n,i,28)^le.rotrBH(n,i,34)^le.rotrBH(n,i,39),te=le.rotrSL(n,i,28)^le.rotrBL(n,i,34)^le.rotrBL(n,i,39),y=n&s^n&c^s&c,I=i&o^i&a^o&a;O=N|0,H=T|0,N=x|0,T=f|0,x=g|0,f=w|0,{h:g,l:w}=le.add(h|0,p|0,k|0,fe|0),h=c|0,p=a|0,c=s|0,a=o|0,s=n|0,o=i|0;let q=le.add3L(fe,te,I);n=le.add3H(q,k,re,y),i=q|0}({h:n,l:i}=le.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=le.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:c,l:a}=le.add(this.Ch|0,this.Cl|0,c|0,a|0),{h,l:p}=le.add(this.Dh|0,this.Dl|0,h|0,p|0),{h:g,l:w}=le.add(this.Eh|0,this.El|0,g|0,w|0),{h:x,l:f}=le.add(this.Fh|0,this.Fl|0,x|0,f|0),{h:N,l:T}=le.add(this.Gh|0,this.Gl|0,N|0,T|0),{h:O,l:H}=le.add(this.Hh|0,this.Hl|0,O|0,H|0),this.set(n,i,s,o,c,a,h,p,g,w,x,f,N,T,O,H)}roundClean(){hr.fill(0),dr.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var ru=nn(()=>new No);var Rt=BigInt(0),ut=BigInt(1),Gi=BigInt(2),Gl=BigInt(8),Vl={zip215:!0};function jl(r){let e=Oi(r);return Tt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function nu(r){let e=jl(r),{Fp:t,n,prehash:i,hash:s,randomBytes:o,nByteLength:c,h:a}=e,h=Gi<<BigInt(c*8)-ut,p=t.create,g=kt(e.n,e.nBitLength),w=e.uvRatio||((F,P)=>{try{return{isValid:!0,value:t.sqrt(F*t.inv(P))}}catch{return{isValid:!1,value:Rt}}}),x=e.adjustScalarBytes||(F=>F),f=e.domain||((F,P,$)=>{if(sr("phflag",$),P.length||$)throw new Error("Contexts/pre-hash are not supported");return F});function N(F,P){Bt("coordinate "+F,P,Rt,h)}function T(F){if(!(F instanceof D))throw new Error("ExtendedPoint expected")}let O=Kt((F,P)=>{let{ex:$,ey:Z,ez:ue}=F,ce=F.is0();P==null&&(P=ce?Gl:t.inv(ue));let Y=p($*P),U=p(Z*P),d=p(ue*P);if(ce)return{x:Rt,y:ut};if(d!==ut)throw new Error("invZ was invalid");return{x:Y,y:U}}),H=Kt(F=>{let{a:P,d:$}=e;if(F.is0())throw new Error("bad point: ZERO");let{ex:Z,ey:ue,ez:ce,et:Y}=F,U=p(Z*Z),d=p(ue*ue),J=p(ce*ce),ee=p(J*J),ae=p(U*P),Q=p(J*p(ae+d)),u=p(ee+p($*p(U*d)));if(Q!==u)throw new Error("bad point: equation left != right (1)");let l=p(Z*ue),m=p(ce*Y);if(l!==m)throw new Error("bad point: equation left != right (2)");return!0});class D{constructor(P,$,Z,ue){this.ex=P,this.ey=$,this.ez=Z,this.et=ue,N("x",P),N("y",$),N("z",Z),N("t",ue),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(P){if(P instanceof D)throw new Error("extended point not allowed");let{x:$,y:Z}=P||{};return N("x",$),N("y",Z),new D($,Z,ut,p($*Z))}static normalizeZ(P){let $=t.invertBatch(P.map(Z=>Z.ez));return P.map((Z,ue)=>Z.toAffine($[ue])).map(D.fromAffine)}static msm(P,$){return Ri(D,g,P,$)}_setWindowSize(P){C.setWindowSize(this,P)}assertValidity(){H(this)}equals(P){T(P);let{ex:$,ey:Z,ez:ue}=this,{ex:ce,ey:Y,ez:U}=P,d=p($*U),J=p(ce*ue),ee=p(Z*U),ae=p(Y*ue);return d===J&&ee===ae}is0(){return this.equals(D.ZERO)}negate(){return new D(p(-this.ex),this.ey,this.ez,p(-this.et))}double(){let{a:P}=e,{ex:$,ey:Z,ez:ue}=this,ce=p($*$),Y=p(Z*Z),U=p(Gi*p(ue*ue)),d=p(P*ce),J=$+Z,ee=p(p(J*J)-ce-Y),ae=d+Y,Q=ae-U,u=d-Y,l=p(ee*Q),m=p(ae*u),S=p(ee*u),v=p(Q*ae);return new D(l,m,v,S)}add(P){T(P);let{a:$,d:Z}=e,{ex:ue,ey:ce,ez:Y,et:U}=this,{ex:d,ey:J,ez:ee,et:ae}=P;if($===BigInt(-1)){let V=p((ce-ue)*(J+d)),W=p((ce+ue)*(J-d)),ie=p(W-V);if(ie===Rt)return this.double();let de=p(Y*Gi*ae),Ee=p(U*Gi*ee),Ne=Ee+de,he=W+V,oe=Ee-de,ke=p(Ne*ie),Qt=p(he*oe),mr=p(Ne*oe),gr=p(ie*he);return new D(ke,Qt,gr,mr)}let Q=p(ue*d),u=p(ce*J),l=p(U*Z*ae),m=p(Y*ee),S=p((ue+ce)*(d+J)-Q-u),v=m-l,A=m+l,M=p(u-$*Q),b=p(S*v),B=p(A*M),L=p(S*M),R=p(v*A);return new D(b,B,R,L)}subtract(P){return this.add(P.negate())}wNAF(P){return C.wNAFCached(this,P,D.normalizeZ)}multiply(P){let $=P;Bt("scalar",$,ut,n);let{p:Z,f:ue}=this.wNAF($);return D.normalizeZ([Z,ue])[0]}multiplyUnsafe(P){let $=P;return Bt("scalar",$,Rt,n),$===Rt?E:this.equals(E)||$===ut?this:this.equals(K)?this.wNAF($).p:C.unsafeLadder(this,$)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return C.unsafeLadder(this,n).is0()}toAffine(P){return O(this,P)}clearCofactor(){let{h:P}=e;return P===ut?this:this.multiplyUnsafe(P)}static fromHex(P,$=!1){let{d:Z,a:ue}=e,ce=t.BYTES;P=He("pointHex",P,ce),sr("zip215",$);let Y=P.slice(),U=P[ce-1];Y[ce-1]=U&-129;let d=or(Y),J=$?h:t.ORDER;Bt("pointHex.y",d,Rt,J);let ee=p(d*d),ae=p(ee-ut),Q=p(Z*ee-ue),{isValid:u,value:l}=w(ae,Q);if(!u)throw new Error("Point.fromHex: invalid y coordinate");let m=(l&ut)===ut,S=(U&128)!==0;if(!$&&l===Rt&&S)throw new Error("Point.fromHex: x=0 and x_0=1");return S!==m&&(l=p(-l)),D.fromAffine({x:l,y:d})}static fromPrivateKey(P){return k(P).point}toRawBytes(){let{x:P,y:$}=this.toAffine(),Z=Ir($,t.BYTES);return Z[Z.length-1]|=P&ut?128:0,Z}toHex(){return St(this.toRawBytes())}}D.BASE=new D(e.Gx,e.Gy,ut,p(e.Gx*e.Gy)),D.ZERO=new D(Rt,ut,ut,Rt);let{BASE:K,ZERO:E}=D,C=Ni(D,c*8);function G(F){return Se(F,n)}function j(F){return G(or(F))}function k(F){let P=c;F=He("private key",F,P);let $=He("hashed private key",s(F),2*P),Z=x($.slice(0,P)),ue=$.slice(P,2*P),ce=j(Z),Y=K.multiply(ce),U=Y.toRawBytes();return{head:Z,prefix:ue,scalar:ce,point:Y,pointBytes:U}}function fe(F){return k(F).pointBytes}function re(F=new Uint8Array,...P){let $=Ie(...P);return j(s(f($,He("context",F),!!i)))}function te(F,P,$={}){F=He("message",F),i&&(F=i(F));let{prefix:Z,scalar:ue,pointBytes:ce}=k(P),Y=re($.context,Z,F),U=K.multiply(Y).toRawBytes(),d=re($.context,U,ce,F),J=G(Y+d*ue);Bt("signature.s",J,Rt,n);let ee=Ie(U,Ir(J,t.BYTES));return He("result",ee,c*2)}let y=Vl;function I(F,P,$,Z=y){let{context:ue,zip215:ce}=Z,Y=t.BYTES;F=He("signature",F,2*Y),P=He("message",P),ce!==void 0&&sr("zip215",ce),i&&(P=i(P));let U=or(F.slice(Y,2*Y)),d,J,ee;try{d=D.fromHex($,ce),J=D.fromHex(F.slice(0,Y),ce),ee=K.multiplyUnsafe(U)}catch{return!1}if(!ce&&d.isSmallOrder())return!1;let ae=re(ue,J.toRawBytes(),d.toRawBytes(),P);return J.add(d.multiplyUnsafe(ae)).subtract(ee).clearCofactor().equals(D.ZERO)}return K._setWindowSize(8),{CURVE:e,getPublicKey:fe,sign:te,verify:I,ExtendedPoint:D,utils:{getExtendedPublicKey:k,randomPrivateKey:()=>o(t.BYTES),precompute(F=8,P=D.BASE){return P._setWindowSize(F),P.multiply(BigInt(3)),P}}}}var Ro=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),iu=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Xp=BigInt(0),Yl=BigInt(1),su=BigInt(2),Qp=BigInt(3),zl=BigInt(5),Kl=BigInt(8);function Zl(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),i=BigInt(80),s=Ro,c=r*r%s*r%s,a=Nt(c,su,s)*c%s,h=Nt(a,Yl,s)*r%s,p=Nt(h,zl,s)*h%s,g=Nt(p,e,s)*p%s,w=Nt(g,t,s)*g%s,x=Nt(w,n,s)*w%s,f=Nt(x,i,s)*x%s,N=Nt(f,i,s)*x%s,T=Nt(N,e,s)*p%s;return{pow_p_5_8:Nt(T,su,s)*r%s,b2:c}}function Wl(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Xl(r,e){let t=Ro,n=Se(e*e*e,t),i=Se(n*n*e,t),s=Zl(r*i).pow_p_5_8,o=Se(r*n*s,t),c=Se(e*o*o,t),a=o,h=Se(o*iu,t),p=c===r,g=c===Se(-r,t),w=c===Se(-r*iu,t);return p&&(o=a),(g||w)&&(o=h),Mc(o,t)&&(o=Se(-o,t)),{isValid:p||g,value:o}}var Ql=kt(Ro,void 0,!0),Jl={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ql,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Kl,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ru,randomBytes:Cn,adjustScalarBytes:Wl,uvRatio:Xl},ou=nu(Jl);var au=function(r,e,t,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"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},st=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},et,Bn,cu,uu,Vi=class{constructor(e={}){et.set(this,void 0),Bn.set(this,void 0),this[cu]=this.entries.bind(this),this[uu]="ExpirableMap";let{source:t=[],expirationTime:n=10*60*1e3}=e,i=Date.now();au(this,et,new Map([...t].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),au(this,Bn,n,"f")}prune(){let e=Date.now();for(let[t,n]of st(this,et,"f").entries())e-n.timestamp>st(this,Bn,"f")&&st(this,et,"f").delete(t);return this}set(e,t){this.prune();let n={value:t,timestamp:Date.now()};return st(this,et,"f").set(e,n),this}get(e){let t=st(this,et,"f").get(e);if(t!==void 0){if(Date.now()-t.timestamp>st(this,Bn,"f")){st(this,et,"f").delete(e);return}return t.value}}clear(){st(this,et,"f").clear()}entries(){let e=st(this,et,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=st(this,et,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return st(this,et,"f").keys()}forEach(e,t){for(let[n,i]of st(this,et,"f").entries())e.call(t,i.value,n,this)}has(e){return st(this,et,"f").has(e)}delete(e){return st(this,et,"f").delete(e)}get size(){return st(this,et,"f").size}};et=new WeakMap,Bn=new WeakMap,cu=Symbol.iterator,uu=Symbol.toStringTag;var fu=r=>{if(r<=127)return 1;if(r<=255)return 2;if(r<=65535)return 3;if(r<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},lu=(r,e,t)=>{if(t<=127)return r[e]=t,1;if(t<=255)return r[e]=129,r[e+1]=t,2;if(t<=65535)return r[e]=130,r[e+1]=t>>8,r[e+2]=t,3;if(t<=16777215)return r[e]=131,r[e+1]=t>>16,r[e+2]=t>>8,r[e+3]=t,4;throw new Error("Length too long (> 4 bytes)")},Oo=(r,e)=>{if(r[e]<128)return 1;if(r[e]===128)throw new Error("Invalid length 0");if(r[e]===129)return 2;if(r[e]===130)return 3;if(r[e]===131)return 4;throw new Error("Length too long (> 4 bytes)")},eh=(r,e)=>{let t=Oo(r,e);if(t===1)return r[e];if(t===2)return r[e+1];if(t===3)return(r[e+1]<<8)+r[e+2];if(t===4)return(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];throw new Error("Length too long (> 4 bytes)")},r1=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),Uo=Uint8Array.from([48,5,6,3,43,101,112]),n1=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function hu(r,e){let t=2+fu(r.byteLength+1),n=e.byteLength+t+r.byteLength,i=0,s=new Uint8Array(1+fu(n)+n);return s[i++]=48,i+=lu(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=lu(s,i,r.byteLength+1),s[i++]=0,s.set(new Uint8Array(r),i),s}var du=(r,e)=>{let t=0,n=(c,a)=>{if(i[t++]!==c)throw new Error("Expected: "+a)},i=new Uint8Array(r);if(n(48,"sequence"),t+=Oo(i,t),!br(i.slice(t,t+e.byteLength),e))throw new Error("Not the expected OID.");t+=e.byteLength,n(3,"bit string");let s=eh(i,t)-1;t+=Oo(i,t),n(0,"0 padding");let o=i.slice(t);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o};var pu=function(r,e,t,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"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},mu=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},ji,Yi,Tn=class r{constructor(e){if(ji.set(this,void 0),Yi.set(this,void 0),e.byteLength!==r.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");pu(this,ji,e,"f"),pu(this,Yi,r.derEncode(e),"f")}static from(e){return this.fromDer(e.toDer())}static fromRaw(e){return new r(e)}static fromDer(e){return new r(this.derDecode(e))}static derEncode(e){return hu(e,Uo).buffer}static derDecode(e){let t=du(e,Uo);if(t.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return t}get rawKey(){return mu(this,ji,"f")}get derKey(){return mu(this,Yi,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};ji=new WeakMap,Yi=new WeakMap;Tn.RAW_KEY_LENGTH=32;var Fo=class{constructor(){this.observers=[]}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(t=>t!==e)}notify(e,...t){this.observers.forEach(n=>n(e,...t))}},zi=class extends Fo{constructor(){super()}print(e,...t){this.notify({message:e,level:"info"},...t)}warn(e,...t){this.notify({message:e,level:"warn"},...t)}error(e,t,...n){this.notify({message:e,level:"error",error:t},...n)}};var qt=function(r,e,t,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"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},tt=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Ct,Ki,Zi,Wi,Xi,Qi,Ji,es,Kr;var Nn=class r{constructor(e=r.default){Ct.set(this,void 0),Ki.set(this,void 0),Zi.set(this,void 0),Wi.set(this,void 0),Xi.set(this,void 0),Qi.set(this,void 0),Ji.set(this,void 0),es.set(this,void 0),Kr.set(this,0);let{initialInterval:t=500,randomizationFactor:n=.5,multiplier:i=1.5,maxInterval:s=6e4,maxElapsedTime:o=9e5,maxIterations:c=10,date:a=Date}=e;qt(this,Ct,t,"f"),qt(this,Ki,n,"f"),qt(this,Zi,i,"f"),qt(this,Wi,s,"f"),qt(this,es,a,"f"),qt(this,Xi,a.now(),"f"),qt(this,Qi,o,"f"),qt(this,Ji,c,"f")}get ellapsedTimeInMsec(){return tt(this,es,"f").now()-tt(this,Xi,"f")}get currentInterval(){return tt(this,Ct,"f")}get count(){return tt(this,Kr,"f")}get randomValueFromInterval(){let e=tt(this,Ki,"f")*tt(this,Ct,"f"),t=tt(this,Ct,"f")-e,n=tt(this,Ct,"f")+e;return Math.random()*(n-t)+t}incrementCurrentInterval(){var e;return qt(this,Ct,Math.min(tt(this,Ct,"f")*tt(this,Zi,"f"),tt(this,Wi,"f")),"f"),qt(this,Kr,(e=tt(this,Kr,"f"),e++,e),"f"),tt(this,Ct,"f")}next(){return this.ellapsedTimeInMsec>=tt(this,Qi,"f")||tt(this,Kr,"f")>=tt(this,Ji,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Ct=new WeakMap,Ki=new WeakMap,Zi=new WeakMap,Wi=new WeakMap,Xi=new WeakMap,Qi=new WeakMap,Ji=new WeakMap,es=new WeakMap,Kr=new WeakMap;Nn.default={initialInterval:500,randomizationFactor:.5,multiplier:1.5,maxInterval:6e4,maxElapsedTime:9e5,maxIterations:10,date:Date};var Xe=function(r,e,t,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"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},X=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},rt,Br,en,$t,Wt,Qr,Rn,Zr,Ot,Ut,Tr,Nr,On,Wr,Xr,Rr,Ur,bu,rs,ns,Or,gu;(function(r){r.Received="received",r.Processing="processing",r.Replied="replied",r.Rejected="rejected",r.Unknown="unknown",r.Done="done"})(gu||(gu={}));var ts=60*1e3,th="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae",xu="aaaaa-aa",rh="ic0.app",nh=".ic0.app",ih="icp0.io",sh=".icp0.io",oh="icp-api.io",ah=".icp-api.io",Un=class extends Ue{constructor(e){super(e),this.message=e}},Jr=class extends Ue{constructor(e){super(e),this.message=e}};function ch(){let r;if(typeof window<"u")if(window.fetch)r=window.fetch.bind(window);else throw new Un("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof globalThis<"u")if(globalThis.fetch)r=globalThis.fetch.bind(globalThis);else throw new Un("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&&(r=self.fetch.bind(self));if(r)return r;throw new Un("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function uh(r){let e;if(r!==void 0)!r.match(/^[a-z]+:/)&&typeof window<"u"?e=new URL(window.location.protocol+"//"+r):e=new URL(r);else{let t=["ic0.app","icp0.io","127.0.0.1","localhost"],n=[".github.dev",".gitpod.io"],i=typeof window<"u"?window.location:void 0,s=i?.hostname,o;s&&typeof s=="string"&&(n.some(c=>s.endsWith(c))?o=s:o=t.find(c=>s.endsWith(c))),i&&o?e=new URL(`${i.protocol}//${o}${i.port?":"+i.port:""}`):e=new URL("https://icp-api.io")}return e.toString()}var yu=class r{constructor(e={}){var t,n;rt.add(this),Br.set(this,null),en.set(this,!1),$t.set(this,void 0),Wt.set(this,void 0),Qr.set(this,void 0),Rn.set(this,void 0),Zr.set(this,0),Ot.set(this,void 0),Ut.set(this,void 0),Tr.set(this,void 0),Nr.set(this,void 0),this._isAgent=!0,this.config={},On.set(this,0),this.log=new zi,Wr.set(this,[]),Xr.set(this,[]),Rr.set(this,new Vi({expirationTime:5*60*1e3})),Ur.set(this,!0),ns.set(this,(o,c)=>{if(X(this,Ur,"f")===!1)return o;if(!c)throw new ht("Invalid signature from replica signed query: no matching node key found.");let{status:a,signatures:h=[],requestId:p}=o,g=new TextEncoder().encode("\vic-response");for(let w of h){let{timestamp:x,identity:f}=w,N=me.fromUint8Array(f).toText(),T;if(a==="replied"){let{reply:E}=o;T=yn({status:a,reply:E,timestamp:BigInt(x),request_id:p})}else if(a==="rejected"){let{reject_code:E,reject_message:C,error_code:G}=o;T=yn({status:a,reject_code:E,reject_message:C,error_code:G,timestamp:BigInt(x),request_id:p})}else throw new Error(`Unknown status: ${a}`);let O=Qe(g,new Uint8Array(T)),H=c?.nodeKeys.get(N);if(!H)throw new ht("Invalid signature from replica signed query: no matching node key found.");let D=Tn.fromDer(H).rawKey;if(ou.verify(w.signature,new Uint8Array(O),new Uint8Array(D)))return o;throw new ht(`Invalid signature from replica ${N} signed query.`)}return o}),this.config=e,Xe(this,Wt,e.fetch||ch()||fetch.bind(globalThis),"f"),Xe(this,Qr,e.fetchOptions,"f"),Xe(this,Rn,e.callOptions,"f"),Xe(this,en,(t=e.shouldFetchRootKey)!==null&&t!==void 0?t:!1,"f"),e.rootKey?this.rootKey=e.rootKey:X(this,en,"f")?this.rootKey=null:this.rootKey=wr(th);let i=uh(e.host);this.host=new URL(i),e.verifyQuerySignatures!==void 0&&Xe(this,Ur,e.verifyQuerySignatures,"f"),Xe(this,Ut,(n=e.retryTimes)!==null&&n!==void 0?n:3,"f");let s=()=>new Nn({maxIterations:X(this,Ut,"f")});if(Xe(this,Tr,e.backoffStrategy||s,"f"),this.host.hostname.endsWith(nh)?this.host.hostname=rh:this.host.hostname.endsWith(sh)?this.host.hostname=ih:this.host.hostname.endsWith(ah)&&(this.host.hostname=oh),e.credentials){let{name:o,password:c}=e.credentials;Xe(this,Ot,`${o}${c?":"+c:""}`,"f")}if(Xe(this,$t,Promise.resolve(e.identity||new An),"f"),e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes>5)throw new Ue(`The maximum ingress expiry time is 5 minutes. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);if(e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes<=0)throw new Ue(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);Xe(this,Nr,e.ingressExpiryInMinutes||5,"f"),this.addTransform("update",Bo(jr)),e.useQueryNonces&&this.addTransform("query",Bo(jr)),e.logToConsole&&this.log.subscribe(o=>{o.level==="error"?console.error(o.message):o.level==="warn"?console.warn(o.message):console.log(o.message)})}get waterMark(){return X(this,On,"f")}static createSync(e={}){return new this(Object.assign({},e))}static async create(e={shouldFetchRootKey:!1}){let t=r.createSync(e),n=[t.syncTime()];return t.host.toString()!=="https://icp-api.io"&&e.shouldFetchRootKey&&n.push(t.fetchRootKey()),await Promise.all(n),t}static async from(e){var t;try{return"config"in e?await r.create(e.config):await r.create({fetch:e._fetch,fetchOptions:e._fetchOptions,callOptions:e._callOptions,host:e._host.toString(),identity:(t=e._identity)!==null&&t!==void 0?t:void 0})}catch{throw new Ue("Failed to create agent from provided agent")}}isLocal(){let e=this.host.hostname;return e==="127.0.0.1"||e.endsWith("127.0.0.1")}addTransform(e,t,n=t.priority||0){if(e==="update"){let i=X(this,Xr,"f").findIndex(s=>(s.priority||0)<n);X(this,Xr,"f").splice(i>=0?i:X(this,Xr,"f").length,0,Object.assign(t,{priority:n}))}else if(e==="query"){let i=X(this,Wr,"f").findIndex(s=>(s.priority||0)<n);X(this,Wr,"f").splice(i>=0?i:X(this,Wr,"f").length,0,Object.assign(t,{priority:n}))}}async getPrincipal(){if(!X(this,$t,"f"))throw new Jr("This identity has expired due this application's security policy. Please refresh your authentication.");return(await X(this,$t,"f")).getPrincipal()}async call(e,t,n){var i,s;await X(this,rt,"m",Or).call(this);let o=(i=t.callSync)!==null&&i!==void 0?i:!0,c=await(n!==void 0?await n:await X(this,$t,"f"));if(!c)throw new Jr("This identity has expired due this application's security policy. Please refresh your authentication.");let a=me.from(e),h=t.effectiveCanisterId?me.from(t.effectiveCanisterId):a,p=c.getPrincipal()||me.anonymous(),g=new Sr(X(this,Nr,"f")*ts);Math.abs(X(this,Zr,"f"))>1e3*30&&(g=new Sr(X(this,Nr,"f")*ts+X(this,Zr,"f")));let w={request_type:ki.Call,canister_id:a,method_name:t.methodName,arg:t.arg,sender:p,ingress_expiry:g},x=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},X(this,Ot,"f")?{Authorization:"Basic "+btoa(X(this,Ot,"f"))}:{})},endpoint:"call",body:w}),f=x.body.nonce?N(x.body.nonce):void 0;w.nonce=f;function N(D){return new Uint8Array(D)}x=await c.transformRequest(x);let T=oi(x.body),O=X(this,Tr,"f").call(this),H=gn(w);try{let D=()=>(this.log.print(`fetching "/api/v3/canister/${h.toText()}/call" with request:`,x),X(this,Wt,"f").call(this,""+new URL(`/api/v3/canister/${h.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},X(this,Rn,"f")),x.request),{body:T}))),K=()=>(this.log.print(`fetching "/api/v2/canister/${h.toText()}/call" with request:`,x),X(this,Wt,"f").call(this,""+new URL(`/api/v2/canister/${h.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},X(this,Rn,"f")),x.request),{body:T}))),C=await X(this,rt,"m",rs).call(this,{request:o?D:K,backoff:O,tries:0}),G=await C.arrayBuffer(),j=C.status===200&&G.byteLength>0?yt(G):null;if(j&&"certificate"in j){let k=await this.parseTimeFromResponse({certificate:j.certificate});Xe(this,On,k,"f")}return{requestId:H,response:{ok:C.ok,status:C.status,statusText:C.statusText,body:j,headers:Yr(C.headers)},requestDetails:w}}catch(D){if(D.message.includes("v3 api not supported."))return this.log.warn("v3 api not supported. Fall back to v2"),this.call(e,Object.assign(Object.assign({},t),{callSync:!1}),n);let K=`Error while making call: ${(s=D.message)!==null&&s!==void 0?s:String(D)}`,E=new qi(K,D,Fe(H),Fe(x.body.sender_pubkey),Fe(x.body.sender_sig),String(x.body.content.ingress_expiry._value));throw this.log.error(K,E),E}}async query(e,t,n){var i,s,o,c;await X(this,rt,"m",Or).call(this);let a=X(this,Tr,"f").call(this),h=t.effectiveCanisterId?me.from(t.effectiveCanisterId):me.from(e);this.log.print(`ecid ${h.toString()}`),this.log.print(`canisterId ${e.toString()}`);let p,g,w=await(n!==void 0?n:X(this,$t,"f"));if(!w)throw new Jr("This identity has expired due this application's security policy. Please refresh your authentication.");let x=me.from(e),f=w?.getPrincipal()||me.anonymous(),N={request_type:"query",canister_id:x,method_name:t.methodName,arg:t.arg,sender:f,ingress_expiry:new Sr(X(this,Nr,"f")*ts)},T=gn(N);p=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},X(this,Ot,"f")?{Authorization:"Basic "+btoa(X(this,Ot,"f"))}:{})},endpoint:"read",body:N}),p=await w?.transformRequest(p);let O=oi(p.body),H={canister:x.toText(),ecid:h,transformedRequest:p,body:O,requestId:T,backoff:a,tries:0},D=async()=>({requestDetails:N,query:await X(this,rt,"m",bu).call(this,H)}),K=async()=>{if(!X(this,Ur,"f"))return;let E=X(this,Rr,"f").get(h.toString());return E||(await this.fetchSubnetKeys(h.toString()),X(this,Rr,"f").get(h.toString()))};try{let[E,C]=await Promise.all([D(),K()]);g=E;let{requestDetails:G,query:j}=g,k=Object.assign(Object.assign({},j),{requestDetails:G});if(this.log.print("Query response:",k),!X(this,Ur,"f"))return k;try{return X(this,ns,"f").call(this,k,C)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),X(this,Rr,"f").delete(e.toString()),await this.fetchSubnetKeys(h.toString());let re=X(this,Rr,"f").get(e.toString());if(!re)throw new ht("Invalid signature from replica signed query: no matching node key found.");return X(this,ns,"f").call(this,k,re)}}catch(E){let C=`Error while making call: ${(i=E.message)!==null&&i!==void 0?i:String(E)}`,G=new Ci(C,E,String(T),Fe((s=p?.body)===null||s===void 0?void 0:s.sender_pubkey),Fe((o=p?.body)===null||o===void 0?void 0:o.sender_sig),String((c=p?.body)===null||c===void 0?void 0:c.content.ingress_expiry._value));throw this.log.error(C,G),G}}async createReadStateRequest(e,t){await X(this,rt,"m",Or).call(this);let n=await(t!==void 0?await t:await X(this,$t,"f"));if(!n)throw new Jr("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||me.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},X(this,Ot,"f")?{Authorization:"Basic "+btoa(X(this,Ot,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new Sr(X(this,Nr,"f")*ts)}});return n?.transformRequest(s)}async readState(e,t,n,i){var s,o,c,a;function h(N){for(let T of N.paths){let[O,H]=T,D=new TextEncoder().encode("request_status");if(br(O,D))return H}}let p=h(t);await X(this,rt,"m",Or).call(this);let g=typeof e=="string"?me.fromText(e):e,w=i??await this.createReadStateRequest(t,n),x=oi(w.body);this.log.print(`fetching "/api/v2/canister/${g}/read_state" with request:`,w);let f=X(this,Tr,"f").call(this);try{let N=await X(this,rt,"m",rs).call(this,{request:()=>X(this,Wt,"f").call(this,""+new URL(`/api/v2/canister/${g.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},X(this,Qr,"f")),w.request),{body:x})),backoff:f,tries:0});if(!N.ok)throw new Error(`Server returned an error:
|
|
14
|
+
ic-request`),Qc=class{getPrincipal(){return this._principal||(this._principal=me.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:t}=e,n=gl(e,["body"]),i=gn(t);return Object.assign(Object.assign({},n),{body:{content:t,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign(Qe(yl,i))}})}},An=class{getPrincipal(){return me.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};var eu=rn(ii());var Sn=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let r=new Uint32Array(1);return window.crypto.getRandomValues(r),r[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let r=new Uint32Array(1);return crypto.getRandomValues(r),r[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)};var ki;(function(r){r.Call="call"})(ki||(ki={}));function jr(){let r=new ArrayBuffer(16),e=new DataView(r),t=Sn(),n=Sn(),i=Sn(),s=Sn();return e.setUint32(0,t),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),r}var Jc=BigInt(1e6),wl=60*1e3,Sr=class{constructor(e){if(e<90*1e3){let c=BigInt(Date.now()+e)*Jc/BigInt(1e9);this._value=c*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+e-wl))*Jc/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return eu.value.u64(this._value.toString(16),16)}toHash(){return Be(this._value)}};function Bo(r=jr){return async e=>{let t=e.request.headers;e.request.headers=t,e.endpoint==="call"&&(e.body.nonce=r())}}function Yr(r){let e=[];return r.forEach((t,n)=>{e.push([n,t])}),e}var zr=class extends Ue{constructor(e,t){super(e),this.response=t,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}},qi=class extends Ue{constructor(e,t,n,i,s,o){super(e),this.response=t,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentCallError",Object.setPrototypeOf(this,new.target.prototype)}},Ci=class extends Ue{constructor(e,t,n,i,s,o){super(e),this.response=t,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentQueryError",Object.setPrototypeOf(this,new.target.prototype)}},$i=class extends Ue{constructor(e,t,n,i,s,o){super(e),this.response=t,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentReadStateError",Object.setPrototypeOf(this,new.target.prototype)}};var Hi=BigInt(4294967295),To=BigInt(32);function tu(r,e=!1){return e?{h:Number(r&Hi),l:Number(r>>To&Hi)}:{h:Number(r>>To&Hi)|0,l:Number(r&Hi)|0}}function bl(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){let{h:s,l:o}=tu(r[i],e);[t[i],n[i]]=[s,o]}return[t,n]}var xl=(r,e)=>BigInt(r>>>0)<<To|BigInt(e>>>0),_l=(r,e,t)=>r>>>t,El=(r,e,t)=>r<<32-t|e>>>t,vl=(r,e,t)=>r>>>t|e<<32-t,Il=(r,e,t)=>r<<32-t|e>>>t,Al=(r,e,t)=>r<<64-t|e>>>t-32,Sl=(r,e,t)=>r>>>t-32|e<<64-t,Bl=(r,e)=>e,Tl=(r,e)=>r,Nl=(r,e,t)=>r<<t|e>>>32-t,Rl=(r,e,t)=>e<<t|r>>>32-t,Ol=(r,e,t)=>e<<t-32|r>>>64-t,Ul=(r,e,t)=>r<<t-32|e>>>64-t;function Fl(r,e,t,n){let i=(e>>>0)+(n>>>0);return{h:r+t+(i/2**32|0)|0,l:i|0}}var Pl=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),Ll=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,Ml=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),Dl=(r,e,t,n,i)=>e+t+n+i+(r/2**32|0)|0,kl=(r,e,t,n,i)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(i>>>0),ql=(r,e,t,n,i,s)=>e+t+n+i+s+(r/2**32|0)|0;var Cl={fromBig:tu,split:bl,toBig:xl,shrSH:_l,shrSL:El,rotrSH:vl,rotrSL:Il,rotrBH:Al,rotrBL:Sl,rotr32H:Bl,rotr32L:Tl,rotlSH:Nl,rotlSL:Rl,rotlBH:Ol,rotlBL:Ul,add:Fl,add3L:Pl,add3H:Ll,add4L:Ml,add4H:Dl,add5H:ql,add5L:kl},le=Cl;var[$l,Hl]=le.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(r=>BigInt(r))),hr=new Uint32Array(80),dr=new Uint32Array(80),No=class extends Lr{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:t,Bh:n,Bl:i,Ch:s,Cl:o,Dh:c,Dl:a,Eh:h,El:p,Fh:g,Fl:w,Gh:x,Gl:f,Hh:N,Hl:T}=this;return[e,t,n,i,s,o,c,a,h,p,g,w,x,f,N,T]}set(e,t,n,i,s,o,c,a,h,p,g,w,x,f,N,T){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=c|0,this.Dl=a|0,this.Eh=h|0,this.El=p|0,this.Fh=g|0,this.Fl=w|0,this.Gh=x|0,this.Gl=f|0,this.Hh=N|0,this.Hl=T|0}process(e,t){for(let D=0;D<16;D++,t+=4)hr[D]=e.getUint32(t),dr[D]=e.getUint32(t+=4);for(let D=16;D<80;D++){let K=hr[D-15]|0,E=dr[D-15]|0,C=le.rotrSH(K,E,1)^le.rotrSH(K,E,8)^le.shrSH(K,E,7),G=le.rotrSL(K,E,1)^le.rotrSL(K,E,8)^le.shrSL(K,E,7),j=hr[D-2]|0,k=dr[D-2]|0,fe=le.rotrSH(j,k,19)^le.rotrBH(j,k,61)^le.shrSH(j,k,6),re=le.rotrSL(j,k,19)^le.rotrBL(j,k,61)^le.shrSL(j,k,6),te=le.add4L(G,re,dr[D-7],dr[D-16]),y=le.add4H(te,C,fe,hr[D-7],hr[D-16]);hr[D]=y|0,dr[D]=te|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:c,Cl:a,Dh:h,Dl:p,Eh:g,El:w,Fh:x,Fl:f,Gh:N,Gl:T,Hh:O,Hl:H}=this;for(let D=0;D<80;D++){let K=le.rotrSH(g,w,14)^le.rotrSH(g,w,18)^le.rotrBH(g,w,41),E=le.rotrSL(g,w,14)^le.rotrSL(g,w,18)^le.rotrBL(g,w,41),C=g&x^~g&N,G=w&f^~w&T,j=le.add5L(H,E,G,Hl[D],dr[D]),k=le.add5H(j,O,K,C,$l[D],hr[D]),fe=j|0,re=le.rotrSH(n,i,28)^le.rotrBH(n,i,34)^le.rotrBH(n,i,39),te=le.rotrSL(n,i,28)^le.rotrBL(n,i,34)^le.rotrBL(n,i,39),y=n&s^n&c^s&c,I=i&o^i&a^o&a;O=N|0,H=T|0,N=x|0,T=f|0,x=g|0,f=w|0,{h:g,l:w}=le.add(h|0,p|0,k|0,fe|0),h=c|0,p=a|0,c=s|0,a=o|0,s=n|0,o=i|0;let q=le.add3L(fe,te,I);n=le.add3H(q,k,re,y),i=q|0}({h:n,l:i}=le.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=le.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:c,l:a}=le.add(this.Ch|0,this.Cl|0,c|0,a|0),{h,l:p}=le.add(this.Dh|0,this.Dl|0,h|0,p|0),{h:g,l:w}=le.add(this.Eh|0,this.El|0,g|0,w|0),{h:x,l:f}=le.add(this.Fh|0,this.Fl|0,x|0,f|0),{h:N,l:T}=le.add(this.Gh|0,this.Gl|0,N|0,T|0),{h:O,l:H}=le.add(this.Hh|0,this.Hl|0,O|0,H|0),this.set(n,i,s,o,c,a,h,p,g,w,x,f,N,T,O,H)}roundClean(){hr.fill(0),dr.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var ru=nn(()=>new No);var Rt=BigInt(0),ut=BigInt(1),Gi=BigInt(2),Gl=BigInt(8),Vl={zip215:!0};function jl(r){let e=Oi(r);return Tt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function nu(r){let e=jl(r),{Fp:t,n,prehash:i,hash:s,randomBytes:o,nByteLength:c,h:a}=e,h=Gi<<BigInt(c*8)-ut,p=t.create,g=kt(e.n,e.nBitLength),w=e.uvRatio||((F,P)=>{try{return{isValid:!0,value:t.sqrt(F*t.inv(P))}}catch{return{isValid:!1,value:Rt}}}),x=e.adjustScalarBytes||(F=>F),f=e.domain||((F,P,$)=>{if(sr("phflag",$),P.length||$)throw new Error("Contexts/pre-hash are not supported");return F});function N(F,P){Bt("coordinate "+F,P,Rt,h)}function T(F){if(!(F instanceof D))throw new Error("ExtendedPoint expected")}let O=Kt((F,P)=>{let{ex:$,ey:Z,ez:ue}=F,ce=F.is0();P==null&&(P=ce?Gl:t.inv(ue));let Y=p($*P),U=p(Z*P),d=p(ue*P);if(ce)return{x:Rt,y:ut};if(d!==ut)throw new Error("invZ was invalid");return{x:Y,y:U}}),H=Kt(F=>{let{a:P,d:$}=e;if(F.is0())throw new Error("bad point: ZERO");let{ex:Z,ey:ue,ez:ce,et:Y}=F,U=p(Z*Z),d=p(ue*ue),J=p(ce*ce),ee=p(J*J),ae=p(U*P),Q=p(J*p(ae+d)),u=p(ee+p($*p(U*d)));if(Q!==u)throw new Error("bad point: equation left != right (1)");let l=p(Z*ue),m=p(ce*Y);if(l!==m)throw new Error("bad point: equation left != right (2)");return!0});class D{constructor(P,$,Z,ue){this.ex=P,this.ey=$,this.ez=Z,this.et=ue,N("x",P),N("y",$),N("z",Z),N("t",ue),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(P){if(P instanceof D)throw new Error("extended point not allowed");let{x:$,y:Z}=P||{};return N("x",$),N("y",Z),new D($,Z,ut,p($*Z))}static normalizeZ(P){let $=t.invertBatch(P.map(Z=>Z.ez));return P.map((Z,ue)=>Z.toAffine($[ue])).map(D.fromAffine)}static msm(P,$){return Ri(D,g,P,$)}_setWindowSize(P){C.setWindowSize(this,P)}assertValidity(){H(this)}equals(P){T(P);let{ex:$,ey:Z,ez:ue}=this,{ex:ce,ey:Y,ez:U}=P,d=p($*U),J=p(ce*ue),ee=p(Z*U),ae=p(Y*ue);return d===J&&ee===ae}is0(){return this.equals(D.ZERO)}negate(){return new D(p(-this.ex),this.ey,this.ez,p(-this.et))}double(){let{a:P}=e,{ex:$,ey:Z,ez:ue}=this,ce=p($*$),Y=p(Z*Z),U=p(Gi*p(ue*ue)),d=p(P*ce),J=$+Z,ee=p(p(J*J)-ce-Y),ae=d+Y,Q=ae-U,u=d-Y,l=p(ee*Q),m=p(ae*u),S=p(ee*u),v=p(Q*ae);return new D(l,m,v,S)}add(P){T(P);let{a:$,d:Z}=e,{ex:ue,ey:ce,ez:Y,et:U}=this,{ex:d,ey:J,ez:ee,et:ae}=P;if($===BigInt(-1)){let V=p((ce-ue)*(J+d)),W=p((ce+ue)*(J-d)),ie=p(W-V);if(ie===Rt)return this.double();let de=p(Y*Gi*ae),Ee=p(U*Gi*ee),Ne=Ee+de,he=W+V,oe=Ee-de,ke=p(Ne*ie),Qt=p(he*oe),mr=p(Ne*oe),gr=p(ie*he);return new D(ke,Qt,gr,mr)}let Q=p(ue*d),u=p(ce*J),l=p(U*Z*ae),m=p(Y*ee),S=p((ue+ce)*(d+J)-Q-u),v=m-l,A=m+l,M=p(u-$*Q),b=p(S*v),B=p(A*M),L=p(S*M),R=p(v*A);return new D(b,B,R,L)}subtract(P){return this.add(P.negate())}wNAF(P){return C.wNAFCached(this,P,D.normalizeZ)}multiply(P){let $=P;Bt("scalar",$,ut,n);let{p:Z,f:ue}=this.wNAF($);return D.normalizeZ([Z,ue])[0]}multiplyUnsafe(P){let $=P;return Bt("scalar",$,Rt,n),$===Rt?E:this.equals(E)||$===ut?this:this.equals(K)?this.wNAF($).p:C.unsafeLadder(this,$)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return C.unsafeLadder(this,n).is0()}toAffine(P){return O(this,P)}clearCofactor(){let{h:P}=e;return P===ut?this:this.multiplyUnsafe(P)}static fromHex(P,$=!1){let{d:Z,a:ue}=e,ce=t.BYTES;P=He("pointHex",P,ce),sr("zip215",$);let Y=P.slice(),U=P[ce-1];Y[ce-1]=U&-129;let d=or(Y),J=$?h:t.ORDER;Bt("pointHex.y",d,Rt,J);let ee=p(d*d),ae=p(ee-ut),Q=p(Z*ee-ue),{isValid:u,value:l}=w(ae,Q);if(!u)throw new Error("Point.fromHex: invalid y coordinate");let m=(l&ut)===ut,S=(U&128)!==0;if(!$&&l===Rt&&S)throw new Error("Point.fromHex: x=0 and x_0=1");return S!==m&&(l=p(-l)),D.fromAffine({x:l,y:d})}static fromPrivateKey(P){return k(P).point}toRawBytes(){let{x:P,y:$}=this.toAffine(),Z=Ir($,t.BYTES);return Z[Z.length-1]|=P&ut?128:0,Z}toHex(){return St(this.toRawBytes())}}D.BASE=new D(e.Gx,e.Gy,ut,p(e.Gx*e.Gy)),D.ZERO=new D(Rt,ut,ut,Rt);let{BASE:K,ZERO:E}=D,C=Ni(D,c*8);function G(F){return Se(F,n)}function j(F){return G(or(F))}function k(F){let P=c;F=He("private key",F,P);let $=He("hashed private key",s(F),2*P),Z=x($.slice(0,P)),ue=$.slice(P,2*P),ce=j(Z),Y=K.multiply(ce),U=Y.toRawBytes();return{head:Z,prefix:ue,scalar:ce,point:Y,pointBytes:U}}function fe(F){return k(F).pointBytes}function re(F=new Uint8Array,...P){let $=Ie(...P);return j(s(f($,He("context",F),!!i)))}function te(F,P,$={}){F=He("message",F),i&&(F=i(F));let{prefix:Z,scalar:ue,pointBytes:ce}=k(P),Y=re($.context,Z,F),U=K.multiply(Y).toRawBytes(),d=re($.context,U,ce,F),J=G(Y+d*ue);Bt("signature.s",J,Rt,n);let ee=Ie(U,Ir(J,t.BYTES));return He("result",ee,c*2)}let y=Vl;function I(F,P,$,Z=y){let{context:ue,zip215:ce}=Z,Y=t.BYTES;F=He("signature",F,2*Y),P=He("message",P),ce!==void 0&&sr("zip215",ce),i&&(P=i(P));let U=or(F.slice(Y,2*Y)),d,J,ee;try{d=D.fromHex($,ce),J=D.fromHex(F.slice(0,Y),ce),ee=K.multiplyUnsafe(U)}catch{return!1}if(!ce&&d.isSmallOrder())return!1;let ae=re(ue,J.toRawBytes(),d.toRawBytes(),P);return J.add(d.multiplyUnsafe(ae)).subtract(ee).clearCofactor().equals(D.ZERO)}return K._setWindowSize(8),{CURVE:e,getPublicKey:fe,sign:te,verify:I,ExtendedPoint:D,utils:{getExtendedPublicKey:k,randomPrivateKey:()=>o(t.BYTES),precompute(F=8,P=D.BASE){return P._setWindowSize(F),P.multiply(BigInt(3)),P}}}}var Ro=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),iu=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Xp=BigInt(0),Yl=BigInt(1),su=BigInt(2),Qp=BigInt(3),zl=BigInt(5),Kl=BigInt(8);function Zl(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),i=BigInt(80),s=Ro,c=r*r%s*r%s,a=Nt(c,su,s)*c%s,h=Nt(a,Yl,s)*r%s,p=Nt(h,zl,s)*h%s,g=Nt(p,e,s)*p%s,w=Nt(g,t,s)*g%s,x=Nt(w,n,s)*w%s,f=Nt(x,i,s)*x%s,N=Nt(f,i,s)*x%s,T=Nt(N,e,s)*p%s;return{pow_p_5_8:Nt(T,su,s)*r%s,b2:c}}function Wl(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Xl(r,e){let t=Ro,n=Se(e*e*e,t),i=Se(n*n*e,t),s=Zl(r*i).pow_p_5_8,o=Se(r*n*s,t),c=Se(e*o*o,t),a=o,h=Se(o*iu,t),p=c===r,g=c===Se(-r,t),w=c===Se(-r*iu,t);return p&&(o=a),(g||w)&&(o=h),Mc(o,t)&&(o=Se(-o,t)),{isValid:p||g,value:o}}var Ql=kt(Ro,void 0,!0),Jl={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ql,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Kl,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ru,randomBytes:Cn,adjustScalarBytes:Wl,uvRatio:Xl},ou=nu(Jl);var au=function(r,e,t,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"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},st=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},et,Bn,cu,uu,Vi=class{constructor(e={}){et.set(this,void 0),Bn.set(this,void 0),this[cu]=this.entries.bind(this),this[uu]="ExpirableMap";let{source:t=[],expirationTime:n=600*1e3}=e,i=Date.now();au(this,et,new Map([...t].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),au(this,Bn,n,"f")}prune(){let e=Date.now();for(let[t,n]of st(this,et,"f").entries())e-n.timestamp>st(this,Bn,"f")&&st(this,et,"f").delete(t);return this}set(e,t){this.prune();let n={value:t,timestamp:Date.now()};return st(this,et,"f").set(e,n),this}get(e){let t=st(this,et,"f").get(e);if(t!==void 0){if(Date.now()-t.timestamp>st(this,Bn,"f")){st(this,et,"f").delete(e);return}return t.value}}clear(){st(this,et,"f").clear()}entries(){let e=st(this,et,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=st(this,et,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return st(this,et,"f").keys()}forEach(e,t){for(let[n,i]of st(this,et,"f").entries())e.call(t,i.value,n,this)}has(e){return st(this,et,"f").has(e)}delete(e){return st(this,et,"f").delete(e)}get size(){return st(this,et,"f").size}};et=new WeakMap,Bn=new WeakMap,cu=Symbol.iterator,uu=Symbol.toStringTag;var fu=r=>{if(r<=127)return 1;if(r<=255)return 2;if(r<=65535)return 3;if(r<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},lu=(r,e,t)=>{if(t<=127)return r[e]=t,1;if(t<=255)return r[e]=129,r[e+1]=t,2;if(t<=65535)return r[e]=130,r[e+1]=t>>8,r[e+2]=t,3;if(t<=16777215)return r[e]=131,r[e+1]=t>>16,r[e+2]=t>>8,r[e+3]=t,4;throw new Error("Length too long (> 4 bytes)")},Oo=(r,e)=>{if(r[e]<128)return 1;if(r[e]===128)throw new Error("Invalid length 0");if(r[e]===129)return 2;if(r[e]===130)return 3;if(r[e]===131)return 4;throw new Error("Length too long (> 4 bytes)")},eh=(r,e)=>{let t=Oo(r,e);if(t===1)return r[e];if(t===2)return r[e+1];if(t===3)return(r[e+1]<<8)+r[e+2];if(t===4)return(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];throw new Error("Length too long (> 4 bytes)")},r1=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),Uo=Uint8Array.from([48,5,6,3,43,101,112]),n1=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function hu(r,e){let t=2+fu(r.byteLength+1),n=e.byteLength+t+r.byteLength,i=0,s=new Uint8Array(1+fu(n)+n);return s[i++]=48,i+=lu(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=lu(s,i,r.byteLength+1),s[i++]=0,s.set(new Uint8Array(r),i),s}var du=(r,e)=>{let t=0,n=(c,a)=>{if(i[t++]!==c)throw new Error("Expected: "+a)},i=new Uint8Array(r);if(n(48,"sequence"),t+=Oo(i,t),!br(i.slice(t,t+e.byteLength),e))throw new Error("Not the expected OID.");t+=e.byteLength,n(3,"bit string");let s=eh(i,t)-1;t+=Oo(i,t),n(0,"0 padding");let o=i.slice(t);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o};var pu=function(r,e,t,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"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},mu=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},ji,Yi,Tn=class r{constructor(e){if(ji.set(this,void 0),Yi.set(this,void 0),e.byteLength!==r.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");pu(this,ji,e,"f"),pu(this,Yi,r.derEncode(e),"f")}static from(e){return this.fromDer(e.toDer())}static fromRaw(e){return new r(e)}static fromDer(e){return new r(this.derDecode(e))}static derEncode(e){return hu(e,Uo).buffer}static derDecode(e){let t=du(e,Uo);if(t.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return t}get rawKey(){return mu(this,ji,"f")}get derKey(){return mu(this,Yi,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};ji=new WeakMap,Yi=new WeakMap;Tn.RAW_KEY_LENGTH=32;var Fo=class{constructor(){this.observers=[]}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(t=>t!==e)}notify(e,...t){this.observers.forEach(n=>n(e,...t))}},zi=class extends Fo{constructor(){super()}print(e,...t){this.notify({message:e,level:"info"},...t)}warn(e,...t){this.notify({message:e,level:"warn"},...t)}error(e,t,...n){this.notify({message:e,level:"error",error:t},...n)}};var qt=function(r,e,t,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"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},tt=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Ct,Ki,Zi,Wi,Xi,Qi,Ji,es,Kr;var Nn=class r{constructor(e=r.default){Ct.set(this,void 0),Ki.set(this,void 0),Zi.set(this,void 0),Wi.set(this,void 0),Xi.set(this,void 0),Qi.set(this,void 0),Ji.set(this,void 0),es.set(this,void 0),Kr.set(this,0);let{initialInterval:t=500,randomizationFactor:n=.5,multiplier:i=1.5,maxInterval:s=6e4,maxElapsedTime:o=9e5,maxIterations:c=10,date:a=Date}=e;qt(this,Ct,t,"f"),qt(this,Ki,n,"f"),qt(this,Zi,i,"f"),qt(this,Wi,s,"f"),qt(this,es,a,"f"),qt(this,Xi,a.now(),"f"),qt(this,Qi,o,"f"),qt(this,Ji,c,"f")}get ellapsedTimeInMsec(){return tt(this,es,"f").now()-tt(this,Xi,"f")}get currentInterval(){return tt(this,Ct,"f")}get count(){return tt(this,Kr,"f")}get randomValueFromInterval(){let e=tt(this,Ki,"f")*tt(this,Ct,"f"),t=tt(this,Ct,"f")-e,n=tt(this,Ct,"f")+e;return Math.random()*(n-t)+t}incrementCurrentInterval(){var e;return qt(this,Ct,Math.min(tt(this,Ct,"f")*tt(this,Zi,"f"),tt(this,Wi,"f")),"f"),qt(this,Kr,(e=tt(this,Kr,"f"),e++,e),"f"),tt(this,Ct,"f")}next(){return this.ellapsedTimeInMsec>=tt(this,Qi,"f")||tt(this,Kr,"f")>=tt(this,Ji,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Ct=new WeakMap,Ki=new WeakMap,Zi=new WeakMap,Wi=new WeakMap,Xi=new WeakMap,Qi=new WeakMap,Ji=new WeakMap,es=new WeakMap,Kr=new WeakMap;Nn.default={initialInterval:500,randomizationFactor:.5,multiplier:1.5,maxInterval:6e4,maxElapsedTime:9e5,maxIterations:10,date:Date};var Xe=function(r,e,t,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"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},X=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},rt,Br,en,$t,Wt,Qr,Rn,Zr,Ot,Ut,Tr,Nr,On,Wr,Xr,Rr,Ur,bu,rs,ns,Or,gu;(function(r){r.Received="received",r.Processing="processing",r.Replied="replied",r.Rejected="rejected",r.Unknown="unknown",r.Done="done"})(gu||(gu={}));var ts=60*1e3,th="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae",xu="aaaaa-aa",rh="ic0.app",nh=".ic0.app",ih="icp0.io",sh=".icp0.io",oh="icp-api.io",ah=".icp-api.io",Un=class extends Ue{constructor(e){super(e),this.message=e}},Jr=class extends Ue{constructor(e){super(e),this.message=e}};function ch(){let r;if(typeof window<"u")if(window.fetch)r=window.fetch.bind(window);else throw new Un("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof globalThis<"u")if(globalThis.fetch)r=globalThis.fetch.bind(globalThis);else throw new Un("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&&(r=self.fetch.bind(self));if(r)return r;throw new Un("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function uh(r){let e;if(r!==void 0)!r.match(/^[a-z]+:/)&&typeof window<"u"?e=new URL(window.location.protocol+"//"+r):e=new URL(r);else{let t=["ic0.app","icp0.io","127.0.0.1","localhost"],n=[".github.dev",".gitpod.io"],i=typeof window<"u"?window.location:void 0,s=i?.hostname,o;s&&typeof s=="string"&&(n.some(c=>s.endsWith(c))?o=s:o=t.find(c=>s.endsWith(c))),i&&o?e=new URL(`${i.protocol}//${o}${i.port?":"+i.port:""}`):e=new URL("https://icp-api.io")}return e.toString()}var yu=class r{constructor(e={}){var t,n;rt.add(this),Br.set(this,null),en.set(this,!1),$t.set(this,void 0),Wt.set(this,void 0),Qr.set(this,void 0),Rn.set(this,void 0),Zr.set(this,0),Ot.set(this,void 0),Ut.set(this,void 0),Tr.set(this,void 0),Nr.set(this,void 0),this._isAgent=!0,this.config={},On.set(this,0),this.log=new zi,Wr.set(this,[]),Xr.set(this,[]),Rr.set(this,new Vi({expirationTime:300*1e3})),Ur.set(this,!0),ns.set(this,(o,c)=>{if(X(this,Ur,"f")===!1)return o;if(!c)throw new ht("Invalid signature from replica signed query: no matching node key found.");let{status:a,signatures:h=[],requestId:p}=o,g=new TextEncoder().encode("\vic-response");for(let w of h){let{timestamp:x,identity:f}=w,N=me.fromUint8Array(f).toText(),T;if(a==="replied"){let{reply:E}=o;T=yn({status:a,reply:E,timestamp:BigInt(x),request_id:p})}else if(a==="rejected"){let{reject_code:E,reject_message:C,error_code:G}=o;T=yn({status:a,reject_code:E,reject_message:C,error_code:G,timestamp:BigInt(x),request_id:p})}else throw new Error(`Unknown status: ${a}`);let O=Qe(g,new Uint8Array(T)),H=c?.nodeKeys.get(N);if(!H)throw new ht("Invalid signature from replica signed query: no matching node key found.");let D=Tn.fromDer(H).rawKey;if(ou.verify(w.signature,new Uint8Array(O),new Uint8Array(D)))return o;throw new ht(`Invalid signature from replica ${N} signed query.`)}return o}),this.config=e,Xe(this,Wt,e.fetch||ch()||fetch.bind(globalThis),"f"),Xe(this,Qr,e.fetchOptions,"f"),Xe(this,Rn,e.callOptions,"f"),Xe(this,en,(t=e.shouldFetchRootKey)!==null&&t!==void 0?t:!1,"f"),e.rootKey?this.rootKey=e.rootKey:X(this,en,"f")?this.rootKey=null:this.rootKey=wr(th);let i=uh(e.host);this.host=new URL(i),e.verifyQuerySignatures!==void 0&&Xe(this,Ur,e.verifyQuerySignatures,"f"),Xe(this,Ut,(n=e.retryTimes)!==null&&n!==void 0?n:3,"f");let s=()=>new Nn({maxIterations:X(this,Ut,"f")});if(Xe(this,Tr,e.backoffStrategy||s,"f"),this.host.hostname.endsWith(nh)?this.host.hostname=rh:this.host.hostname.endsWith(sh)?this.host.hostname=ih:this.host.hostname.endsWith(ah)&&(this.host.hostname=oh),e.credentials){let{name:o,password:c}=e.credentials;Xe(this,Ot,`${o}${c?":"+c:""}`,"f")}if(Xe(this,$t,Promise.resolve(e.identity||new An),"f"),e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes>5)throw new Ue(`The maximum ingress expiry time is 5 minutes. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);if(e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes<=0)throw new Ue(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);Xe(this,Nr,e.ingressExpiryInMinutes||5,"f"),this.addTransform("update",Bo(jr)),e.useQueryNonces&&this.addTransform("query",Bo(jr)),e.logToConsole&&this.log.subscribe(o=>{o.level==="error"?console.error(o.message):o.level==="warn"?console.warn(o.message):console.log(o.message)})}get waterMark(){return X(this,On,"f")}static createSync(e={}){return new this(Object.assign({},e))}static async create(e={shouldFetchRootKey:!1}){let t=r.createSync(e),n=[t.syncTime()];return t.host.toString()!=="https://icp-api.io"&&e.shouldFetchRootKey&&n.push(t.fetchRootKey()),await Promise.all(n),t}static async from(e){var t;try{return"config"in e?await r.create(e.config):await r.create({fetch:e._fetch,fetchOptions:e._fetchOptions,callOptions:e._callOptions,host:e._host.toString(),identity:(t=e._identity)!==null&&t!==void 0?t:void 0})}catch{throw new Ue("Failed to create agent from provided agent")}}isLocal(){let e=this.host.hostname;return e==="127.0.0.1"||e.endsWith("127.0.0.1")}addTransform(e,t,n=t.priority||0){if(e==="update"){let i=X(this,Xr,"f").findIndex(s=>(s.priority||0)<n);X(this,Xr,"f").splice(i>=0?i:X(this,Xr,"f").length,0,Object.assign(t,{priority:n}))}else if(e==="query"){let i=X(this,Wr,"f").findIndex(s=>(s.priority||0)<n);X(this,Wr,"f").splice(i>=0?i:X(this,Wr,"f").length,0,Object.assign(t,{priority:n}))}}async getPrincipal(){if(!X(this,$t,"f"))throw new Jr("This identity has expired due this application's security policy. Please refresh your authentication.");return(await X(this,$t,"f")).getPrincipal()}async call(e,t,n){var i,s;await X(this,rt,"m",Or).call(this);let o=(i=t.callSync)!==null&&i!==void 0?i:!0,c=await(n!==void 0?await n:await X(this,$t,"f"));if(!c)throw new Jr("This identity has expired due this application's security policy. Please refresh your authentication.");let a=me.from(e),h=t.effectiveCanisterId?me.from(t.effectiveCanisterId):a,p=c.getPrincipal()||me.anonymous(),g=new Sr(X(this,Nr,"f")*ts);Math.abs(X(this,Zr,"f"))>1e3*30&&(g=new Sr(X(this,Nr,"f")*ts+X(this,Zr,"f")));let w={request_type:ki.Call,canister_id:a,method_name:t.methodName,arg:t.arg,sender:p,ingress_expiry:g},x=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},X(this,Ot,"f")?{Authorization:"Basic "+btoa(X(this,Ot,"f"))}:{})},endpoint:"call",body:w}),f=x.body.nonce?N(x.body.nonce):void 0;w.nonce=f;function N(D){return new Uint8Array(D)}x=await c.transformRequest(x);let T=oi(x.body),O=X(this,Tr,"f").call(this),H=gn(w);try{let D=()=>(this.log.print(`fetching "/api/v3/canister/${h.toText()}/call" with request:`,x),X(this,Wt,"f").call(this,""+new URL(`/api/v3/canister/${h.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},X(this,Rn,"f")),x.request),{body:T}))),K=()=>(this.log.print(`fetching "/api/v2/canister/${h.toText()}/call" with request:`,x),X(this,Wt,"f").call(this,""+new URL(`/api/v2/canister/${h.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},X(this,Rn,"f")),x.request),{body:T}))),C=await X(this,rt,"m",rs).call(this,{request:o?D:K,backoff:O,tries:0}),G=await C.arrayBuffer(),j=C.status===200&&G.byteLength>0?yt(G):null;if(j&&"certificate"in j){let k=await this.parseTimeFromResponse({certificate:j.certificate});Xe(this,On,k,"f")}return{requestId:H,response:{ok:C.ok,status:C.status,statusText:C.statusText,body:j,headers:Yr(C.headers)},requestDetails:w}}catch(D){if(D.message.includes("v3 api not supported."))return this.log.warn("v3 api not supported. Fall back to v2"),this.call(e,Object.assign(Object.assign({},t),{callSync:!1}),n);let K=`Error while making call: ${(s=D.message)!==null&&s!==void 0?s:String(D)}`,E=new qi(K,D,Fe(H),Fe(x.body.sender_pubkey),Fe(x.body.sender_sig),String(x.body.content.ingress_expiry._value));throw this.log.error(K,E),E}}async query(e,t,n){var i,s,o,c;await X(this,rt,"m",Or).call(this);let a=X(this,Tr,"f").call(this),h=t.effectiveCanisterId?me.from(t.effectiveCanisterId):me.from(e);this.log.print(`ecid ${h.toString()}`),this.log.print(`canisterId ${e.toString()}`);let p,g,w=await(n!==void 0?n:X(this,$t,"f"));if(!w)throw new Jr("This identity has expired due this application's security policy. Please refresh your authentication.");let x=me.from(e),f=w?.getPrincipal()||me.anonymous(),N={request_type:"query",canister_id:x,method_name:t.methodName,arg:t.arg,sender:f,ingress_expiry:new Sr(X(this,Nr,"f")*ts)},T=gn(N);p=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},X(this,Ot,"f")?{Authorization:"Basic "+btoa(X(this,Ot,"f"))}:{})},endpoint:"read",body:N}),p=await w?.transformRequest(p);let O=oi(p.body),H={canister:x.toText(),ecid:h,transformedRequest:p,body:O,requestId:T,backoff:a,tries:0},D=async()=>({requestDetails:N,query:await X(this,rt,"m",bu).call(this,H)}),K=async()=>{if(!X(this,Ur,"f"))return;let E=X(this,Rr,"f").get(h.toString());return E||(await this.fetchSubnetKeys(h.toString()),X(this,Rr,"f").get(h.toString()))};try{let[E,C]=await Promise.all([D(),K()]);g=E;let{requestDetails:G,query:j}=g,k=Object.assign(Object.assign({},j),{requestDetails:G});if(this.log.print("Query response:",k),!X(this,Ur,"f"))return k;try{return X(this,ns,"f").call(this,k,C)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),X(this,Rr,"f").delete(e.toString()),await this.fetchSubnetKeys(h.toString());let re=X(this,Rr,"f").get(e.toString());if(!re)throw new ht("Invalid signature from replica signed query: no matching node key found.");return X(this,ns,"f").call(this,k,re)}}catch(E){let C=`Error while making call: ${(i=E.message)!==null&&i!==void 0?i:String(E)}`,G=new Ci(C,E,String(T),Fe((s=p?.body)===null||s===void 0?void 0:s.sender_pubkey),Fe((o=p?.body)===null||o===void 0?void 0:o.sender_sig),String((c=p?.body)===null||c===void 0?void 0:c.content.ingress_expiry._value));throw this.log.error(C,G),G}}async createReadStateRequest(e,t){await X(this,rt,"m",Or).call(this);let n=await(t!==void 0?await t:await X(this,$t,"f"));if(!n)throw new Jr("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||me.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},X(this,Ot,"f")?{Authorization:"Basic "+btoa(X(this,Ot,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new Sr(X(this,Nr,"f")*ts)}});return n?.transformRequest(s)}async readState(e,t,n,i){var s,o,c,a;function h(N){for(let T of N.paths){let[O,H]=T,D=new TextEncoder().encode("request_status");if(br(O,D))return H}}let p=h(t);await X(this,rt,"m",Or).call(this);let g=typeof e=="string"?me.fromText(e):e,w=i??await this.createReadStateRequest(t,n),x=oi(w.body);this.log.print(`fetching "/api/v2/canister/${g}/read_state" with request:`,w);let f=X(this,Tr,"f").call(this);try{let N=await X(this,rt,"m",rs).call(this,{request:()=>X(this,Wt,"f").call(this,""+new URL(`/api/v2/canister/${g.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},X(this,Qr,"f")),w.request),{body:x})),backoff:f,tries:0});if(!N.ok)throw new Error(`Server returned an error:
|
|
15
15
|
Code: ${N.status} (${N.statusText})
|
|
16
16
|
Body: ${await N.text()}
|
|
17
|
-
`);let T=yt(await N.arrayBuffer());this.log.print("Read state response:",T);let O=await this.parseTimeFromResponse(T);return O>0&&(this.log.print("Read state response time:",O),Xe(this,On,O,"f")),T}catch(N){let T=`Caught exception while attempting to read state: ${(s=N.message)!==null&&s!==void 0?s:String(N)}`,O=new $i(T,N,String(p),Fe((o=w?.body)===null||o===void 0?void 0:o.sender_pubkey),Fe((c=w?.body)===null||c===void 0?void 0:c.sender_sig),String((a=w?.body)===null||a===void 0?void 0:a.content.ingress_expiry._value));throw this.log.error(T,O),O}}async parseTimeFromResponse(e){let t;if(e.certificate){let n=yt(e.certificate);if(n&&"tree"in n)t=n.tree;else throw new Error("Could not decode time from response");let i=pr(["time"],t);if(i.status!==De.Found)throw new Error("Time was not found in the response or was not in its expected format.");if(!(i.value instanceof ArrayBuffer)&&!ArrayBuffer.isView(i))throw new Error("Time was not found in the response or was not in its expected format.");let s=Vr(ys(i.value));return this.log.print("Time from response:",s),this.log.print("Time from response in milliseconds:",Number(s)),Number(s)}else this.log.warn("No certificate found in response");return 0}async syncTime(e){await X(this,rt,"m",Or).call(this);let t=await import("./canisterStatus-
|
|
17
|
+
`);let T=yt(await N.arrayBuffer());this.log.print("Read state response:",T);let O=await this.parseTimeFromResponse(T);return O>0&&(this.log.print("Read state response time:",O),Xe(this,On,O,"f")),T}catch(N){let T=`Caught exception while attempting to read state: ${(s=N.message)!==null&&s!==void 0?s:String(N)}`,O=new $i(T,N,String(p),Fe((o=w?.body)===null||o===void 0?void 0:o.sender_pubkey),Fe((c=w?.body)===null||c===void 0?void 0:c.sender_sig),String((a=w?.body)===null||a===void 0?void 0:a.content.ingress_expiry._value));throw this.log.error(T,O),O}}async parseTimeFromResponse(e){let t;if(e.certificate){let n=yt(e.certificate);if(n&&"tree"in n)t=n.tree;else throw new Error("Could not decode time from response");let i=pr(["time"],t);if(i.status!==De.Found)throw new Error("Time was not found in the response or was not in its expected format.");if(!(i.value instanceof ArrayBuffer)&&!ArrayBuffer.isView(i))throw new Error("Time was not found in the response or was not in its expected format.");let s=Vr(ys(i.value));return this.log.print("Time from response:",s),this.log.print("Time from response in milliseconds:",Number(s)),Number(s)}else this.log.warn("No certificate found in response");return 0}async syncTime(e){await X(this,rt,"m",Or).call(this);let t=await import("./canisterStatus-72I5GDMD.js"),n=Date.now();try{e||this.log.print("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let i=r.createSync({identity:new An,host:this.host.toString(),fetch:X(this,Wt,"f"),retryTimes:0}),o=(await t.request({canisterId:e??me.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:i,paths:["time"]})).get("time");o&&(Xe(this,Zr,Number(o)-Number(n),"f"),this.log.notify({message:`Syncing time: offset of ${X(this,Zr,"f")}`,level:"info"}))}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=X(this,Ot,"f")?{Authorization:"Basic "+btoa(X(this,Ot,"f"))}:{};this.log.print('fetching "/api/v2/status"');let t=X(this,Tr,"f").call(this),n=await X(this,rt,"m",rs).call(this,{backoff:t,request:()=>X(this,Wt,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:e},X(this,Qr,"f"))),tries:0});return yt(await n.arrayBuffer())}async fetchRootKey(){let e;return X(this,Br,"f")?e=await X(this,Br,"f"):(Xe(this,Br,new Promise((t,n)=>{this.status().then(i=>{let s=i.root_key;this.rootKey=s,t(s)}).catch(n)}),"f"),e=await X(this,Br,"f")),Xe(this,Br,null,"f"),e}invalidateIdentity(){Xe(this,$t,null,"f")}replaceIdentity(e){Xe(this,$t,Promise.resolve(e),"f")}async fetchSubnetKeys(e){await X(this,rt,"m",Or).call(this);let t=me.from(e),i=(await wu({canisterId:t,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return X(this,Rr,"f").set(t.toText(),i),i}_transform(e){let t=Promise.resolve(e);if(e.endpoint==="call")for(let n of X(this,Xr,"f"))t=t.then(i=>n(i).then(s=>s||i));else for(let n of X(this,Wr,"f"))t=t.then(i=>n(i).then(s=>s||i));return t}};Br=new WeakMap,en=new WeakMap,$t=new WeakMap,Wt=new WeakMap,Qr=new WeakMap,Rn=new WeakMap,Zr=new WeakMap,Ot=new WeakMap,Ut=new WeakMap,Tr=new WeakMap,Nr=new WeakMap,On=new WeakMap,Wr=new WeakMap,Xr=new WeakMap,Rr=new WeakMap,Ur=new WeakMap,ns=new WeakMap,rt=new WeakSet,bu=async function r(e){var t,n;let{ecid:i,transformedRequest:s,body:o,requestId:c,backoff:a,tries:h}=e,p=h===0?0:a.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:h,backoff:a,delay:p}),p===null)throw new Ue(`Timestamp failed to pass the watermark after retrying the configured ${X(this,Ut,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);p>0&&await new Promise(f=>setTimeout(f,p));let g;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let f=await X(this,Wt,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},X(this,Qr,"f")),s.request),{body:o}));if(f.status===200){let N=yt(await f.arrayBuffer());g=Object.assign(Object.assign({},N),{httpDetails:{ok:f.ok,status:f.status,statusText:f.statusText,headers:Yr(f.headers)},requestId:c})}else throw new zr(`Gateway returned an error:
|
|
18
18
|
Code: ${f.status} (${f.statusText})
|
|
19
19
|
Body: ${await f.text()}
|
|
20
20
|
`,{ok:f.ok,status:f.status,statusText:f.statusText,headers:Yr(f.headers)})}catch(f){if(h<X(this,Ut,"f"))return this.log.warn(`Caught exception while attempting to make query:
|
|
@@ -50,4 +50,4 @@ ieee754/index.js:
|
|
|
50
50
|
@noble/curves/esm/ed25519.js:
|
|
51
51
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
52
52
|
*/
|
|
53
|
-
//# sourceMappingURL=chunk-
|
|
53
|
+
//# sourceMappingURL=chunk-EMF4NSTU.js.map
|