@junobuild/analytics 0.0.31 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,43 +1,43 @@
1
- "use strict";(()=>{var jl=Object.create;var Ti=Object.defineProperty;var Hl=Object.getOwnPropertyDescriptor;var Gl=Object.getOwnPropertyNames;var Yl=Object.getPrototypeOf,zl=Object.prototype.hasOwnProperty;var he=(t,e)=>()=>(t&&(e=t(t=0)),e);var He=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Un=(t,e)=>{for(var r in e)Ti(t,r,{get:e[r],enumerable:!0})},Bc=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Gl(e))!zl.call(t,i)&&i!==r&&Ti(t,i,{get:()=>e[i],enumerable:!(n=Hl(e,i))||n.enumerable});return t};var tn=(t,e,r)=>(r=t!=null?jl(Yl(t)):{},Bc(e||!t||!t.__esModule?Ti(r,"default",{value:t,enumerable:!0}):r,t)),Kl=t=>Bc(Ti({},"__esModule",{value:!0}),t);function Ac(t){let e=0,r=0,n="";function i(s){return e<0?r|=s>>-e:r=s<<e&248,e>3?(e-=8,1):(e<4&&(n+=Si[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?Si[r>>3]:"")}function Tc(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=rn[o.toLowerCase()];if(a===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);a<<=3,r|=a>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=a<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}var Si,rn,Sc=he(()=>{Si="abcdefghijklmnopqrstuvwxyz234567",rn=Object.create(null);for(let t=0;t<Si.length;t++)rn[Si[t]]=t;rn[0]=rn.o;rn[1]=rn.i});function Nc(t){let e=new Uint8Array(t),r=-1;for(let n=0;n<e.length;n++){let s=(e[n]^r)&255;r=Wl[s]^r>>>8}return(r^-1)>>>0}var Wl,Rc=he(()=>{Wl=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117])});function Zl(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function po(t,...e){if(!Zl(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function mo(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Oc(t,e){po(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var yo=he(()=>{});var qr,Fc=he(()=>{qr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});function Uc(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function go(t){return typeof t=="string"&&(t=Uc(t)),po(t),t}function In(t){let e=n=>t().update(go(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Oi(t=32){if(qr&&typeof qr.getRandomValues=="function")return qr.getRandomValues(new Uint8Array(t));if(qr&&typeof qr.randomBytes=="function")return qr.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}var Ri,Nt,w1,Ni,b1,nn=he(()=>{Fc();yo();Ri=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Nt=(t,e)=>t<<32-e|t>>>e,w1=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;Ni=class{clone(){return this._cloneInto()}},b1={}.toString});function Xl(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,l=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+l,a,n)}var Ic,Pc,sn,wo=he(()=>{yo();nn();Ic=(t,e,r)=>t&e^~t&r,Pc=(t,e,r)=>t&e^t&r^e&r,sn=class extends Ni{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Ri(this.buffer)}update(e){mo(this);let{view:r,buffer:n,blockLen:i}=this;e=go(e);let s=e.length;for(let o=0;o<s;){let a=Math.min(i-this.pos,s-o);if(a===i){let c=Ri(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){mo(this),Oc(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let d=o;d<i;d++)r[d]=0;Xl(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=Ri(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)a.setUint32(4*d,h[d],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%r&&e.buffer.set(n),e}}});var Jl,yr,gr,Fi,bo,Pn,kc,Ui=he(()=>{wo();nn();Jl=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),yr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),gr=new Uint32Array(64),Fi=class extends sn{constructor(){super(64,32,8,!1),this.A=yr[0]|0,this.B=yr[1]|0,this.C=yr[2]|0,this.D=yr[3]|0,this.E=yr[4]|0,this.F=yr[5]|0,this.G=yr[6]|0,this.H=yr[7]|0}get(){let{A:e,B:r,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[e,r,n,i,s,o,a,c]}set(e,r,n,i,s,o,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let d=0;d<16;d++,r+=4)gr[d]=e.getUint32(r,!1);for(let d=16;d<64;d++){let w=gr[d-15],b=gr[d-2],f=Nt(w,7)^Nt(w,18)^w>>>3,S=Nt(b,17)^Nt(b,19)^b>>>10;gr[d]=S+gr[d-7]+f+gr[d-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:l,H:h}=this;for(let d=0;d<64;d++){let w=Nt(a,6)^Nt(a,11)^Nt(a,25),b=h+w+Ic(a,c,l)+Jl[d]+gr[d]|0,S=(Nt(n,2)^Nt(n,13)^Nt(n,22))+Pc(n,i,s)|0;h=l,l=c,c=a,a=o+b|0,o=s,s=i,i=n,n=b+S|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,i,s,o,a,c,l,h)}roundClean(){gr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},bo=class extends Fi{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}},Pn=In(()=>new Fi),kc=In(()=>new bo)});function Mc(t){return kc.create().update(new Uint8Array(t)).digest()}var Cc=he(()=>{Ui()});var Ii,Ql,qc,Ll,Dl,eh,de,yt=he(()=>{Sc();Rc();Cc();Ii="__principal__",Ql=2,qc=4,Ll="aaaaa-aa",Dl=t=>{var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))},eh=t=>t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""),de=class t{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([qc]))}static managementCanister(){return this.fromHex(Ll)}static selfAuthenticating(e){let r=Mc(e);return new this(new Uint8Array([...r,Ql]))}static from(e){if(typeof e=="string")return t.fromText(e);if(Object.getPrototypeOf(e)===Uint8Array.prototype)return new t(e);if(typeof e=="object"&&e!==null&&e._isPrincipal===!0)return new t(e._arr);throw new Error(`Impossible to convert ${JSON.stringify(e)} to Principal.`)}static fromHex(e){return new this(Dl(e))}static fromText(e){let r=e;if(e.includes(Ii)){let o=JSON.parse(e);Ii in o&&(r=o[Ii])}let n=r.toLowerCase().replace(/-/g,""),i=Tc(n);i=i.slice(4,i.length);let s=new this(i);if(s.toText()!==r)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${r}" may not be a valid Principal ID).`);return s}static fromUint8Array(e){return new this(e)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===qc}toUint8Array(){return this._arr}toHex(){return eh(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,Nc(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),a=Ac(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}toJSON(){return{[Ii]:this.toText()}}compareTo(e){for(let r=0;r<Math.min(this._arr.length,e._arr.length);r++){if(this._arr[r]<e._arr[r])return"lt";if(this._arr[r]>e._arr[r])return"gt"}return this._arr.length<e._arr.length?"lt":this._arr.length>e._arr.length?"gt":"eq"}ltEq(e){let r=this.compareTo(e);return r=="lt"||r=="eq"}gtEq(e){let r=this.compareTo(e);return r=="gt"||r=="eq"}}});var Gc=He(Pi=>{"use strict";Pi.byteLength=oh;Pi.toByteArray=ch;Pi.fromByteArray=lh;var Yt=[],Et=[],sh=typeof Uint8Array<"u"?Uint8Array:Array,Eo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Vr=0,jc=Eo.length;Vr<jc;++Vr)Yt[Vr]=Eo[Vr],Et[Eo.charCodeAt(Vr)]=Vr;var Vr,jc;Et[45]=62;Et[95]=63;function Hc(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function oh(t){var e=Hc(t),r=e[0],n=e[1];return(r+n)*3/4-n}function ah(t,e,r){return(e+r)*3/4-r}function ch(t){var e,r=Hc(t),n=r[0],i=r[1],s=new sh(ah(t,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=Et[t.charCodeAt(c)]<<18|Et[t.charCodeAt(c+1)]<<12|Et[t.charCodeAt(c+2)]<<6|Et[t.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=Et[t.charCodeAt(c)]<<2|Et[t.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=Et[t.charCodeAt(c)]<<10|Et[t.charCodeAt(c+1)]<<4|Et[t.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function uh(t){return Yt[t>>18&63]+Yt[t>>12&63]+Yt[t>>6&63]+Yt[t&63]}function fh(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),i.push(uh(n));return i.join("")}function lh(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(fh(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(Yt[e>>2]+Yt[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(Yt[e>>10]+Yt[e>>4&63]+Yt[e<<2&63]+"=")),i.join("")}});var Bo=He(vo=>{vo.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,l=c>>1,h=-7,d=r?i-1:0,w=r?-1:1,b=t[e+d];for(d+=w,s=b&(1<<-h)-1,b>>=-h,h+=a;h>0;s=s*256+t[e+d],d+=w,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=o*256+t[e+d],d+=w,h-=8);if(s===0)s=1-l;else{if(s===c)return o?NaN:(b?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-l}return(b?-1:1)*o*Math.pow(2,s-n)};vo.write=function(t,e,r,n,i,s){var o,a,c,l=s*8-i-1,h=(1<<l)-1,d=h>>1,w=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=n?0:s-1,f=n?1:-1,S=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+d>=1?e+=w/c:e+=w*Math.pow(2,1-d),e*c>=2&&(o++,c/=2),o+d>=h?(a=0,o=h):o+d>=1?(a=(e*c-1)*Math.pow(2,i),o=o+d):(a=e*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;t[r+b]=a&255,b+=f,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;t[r+b]=o&255,b+=f,o/=256,l-=8);t[r+b-f]|=S*128}});var ou=He(un=>{"use strict";var Ao=Gc(),an=Bo(),Yc=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;un.Buffer=j;un.SlowBuffer=gh;un.INSPECT_MAX_BYTES=50;var ki=2147483647;un.kMaxLength=ki;j.TYPED_ARRAY_SUPPORT=hh();!j.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function hh(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(j.prototype,"parent",{enumerable:!0,get:function(){if(j.isBuffer(this))return this.buffer}});Object.defineProperty(j.prototype,"offset",{enumerable:!0,get:function(){if(j.isBuffer(this))return this.byteOffset}});function sr(t){if(t>ki)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,j.prototype),e}function j(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Ro(t)}return Zc(t,e,r)}j.poolSize=8192;function Zc(t,e,r){if(typeof t=="string")return ph(t,e);if(ArrayBuffer.isView(t))return mh(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(zt(t,ArrayBuffer)||t&&zt(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(zt(t,SharedArrayBuffer)||t&&zt(t.buffer,SharedArrayBuffer)))return So(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return j.from(n,e,r);let i=yh(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return j.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}j.from=function(t,e,r){return Zc(t,e,r)};Object.setPrototypeOf(j.prototype,Uint8Array.prototype);Object.setPrototypeOf(j,Uint8Array);function Xc(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function dh(t,e,r){return Xc(t),t<=0?sr(t):e!==void 0?typeof r=="string"?sr(t).fill(e,r):sr(t).fill(e):sr(t)}j.alloc=function(t,e,r){return dh(t,e,r)};function Ro(t){return Xc(t),sr(t<0?0:Oo(t)|0)}j.allocUnsafe=function(t){return Ro(t)};j.allocUnsafeSlow=function(t){return Ro(t)};function ph(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!j.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=Jc(t,e)|0,n=sr(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function To(t){let e=t.length<0?0:Oo(t.length)|0,r=sr(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function mh(t){if(zt(t,Uint8Array)){let e=new Uint8Array(t);return So(e.buffer,e.byteOffset,e.byteLength)}return To(t)}function So(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,j.prototype),n}function yh(t){if(j.isBuffer(t)){let e=Oo(t.length)|0,r=sr(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Uo(t.length)?sr(0):To(t);if(t.type==="Buffer"&&Array.isArray(t.data))return To(t.data)}function Oo(t){if(t>=ki)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ki.toString(16)+" bytes");return t|0}function gh(t){return+t!=t&&(t=0),j.alloc(+t)}j.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==j.prototype};j.compare=function(e,r){if(zt(e,Uint8Array)&&(e=j.from(e,e.offset,e.byteLength)),zt(r,Uint8Array)&&(r=j.from(r,r.offset,r.byteLength)),!j.isBuffer(e)||!j.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==r[s]){n=e[s],i=r[s];break}return n<i?-1:i<n?1:0};j.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};j.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return j.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=j.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(zt(o,Uint8Array))s+o.length>i.length?(j.isBuffer(o)||(o=j.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(j.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function Jc(t,e){if(j.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||zt(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return No(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return su(t).length;default:if(i)return n?-1:No(t).length;e=(""+e).toLowerCase(),i=!0}}j.byteLength=Jc;function wh(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Nh(this,e,r);case"utf8":case"utf-8":return Lc(this,e,r);case"ascii":return Th(this,e,r);case"latin1":case"binary":return Sh(this,e,r);case"base64":return Bh(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rh(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}j.prototype._isBuffer=!0;function jr(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}j.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)jr(this,r,r+1);return this};j.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)jr(this,r,r+3),jr(this,r+1,r+2);return this};j.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)jr(this,r,r+7),jr(this,r+1,r+6),jr(this,r+2,r+5),jr(this,r+3,r+4);return this};j.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Lc(this,0,e):wh.apply(this,arguments)};j.prototype.toLocaleString=j.prototype.toString;j.prototype.equals=function(e){if(!j.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:j.compare(this,e)===0};j.prototype.inspect=function(){let e="",r=un.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};Yc&&(j.prototype[Yc]=j.prototype.inspect);j.prototype.compare=function(e,r,n,i,s){if(zt(e,Uint8Array)&&(e=j.from(e,e.offset,e.byteLength)),!j.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,a=n-r,c=Math.min(o,a),l=this.slice(i,s),h=e.slice(r,n);for(let d=0;d<c;++d)if(l[d]!==h[d]){o=l[d],a=h[d];break}return o<a?-1:a<o?1:0};function Qc(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Uo(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=j.from(e,n)),j.isBuffer(e))return e.length===0?-1:zc(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):zc(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function zc(t,e,r,n,i){let s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(h,d){return s===1?h[d]:h.readUInt16BE(d*s)}let l;if(i){let h=-1;for(l=r;l<o;l++)if(c(t,l)===c(e,h===-1?0:l-h)){if(h===-1&&(h=l),l-h+1===a)return h*s}else h!==-1&&(l-=l-h),h=-1}else for(r+a>o&&(r=o-a),l=r;l>=0;l--){let h=!0;for(let d=0;d<a;d++)if(c(t,l+d)!==c(e,d)){h=!1;break}if(h)return l}return-1}j.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};j.prototype.indexOf=function(e,r,n){return Qc(this,e,r,n,!0)};j.prototype.lastIndexOf=function(e,r,n){return Qc(this,e,r,n,!1)};function bh(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let a=parseInt(e.substr(o*2,2),16);if(Uo(a))return o;t[r+o]=a}return o}function xh(t,e,r,n){return Mi(No(e,t.length-r),t,r,n)}function _h(t,e,r,n){return Mi(Ih(e),t,r,n)}function Eh(t,e,r,n){return Mi(su(e),t,r,n)}function vh(t,e,r,n){return Mi(Ph(e,t.length-r),t,r,n)}j.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-r;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return bh(this,e,r,n);case"utf8":case"utf-8":return xh(this,e,r,n);case"ascii":case"latin1":case"binary":return _h(this,e,r,n);case"base64":return Eh(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return vh(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};j.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Bh(t,e,r){return e===0&&r===t.length?Ao.fromByteArray(t):Ao.fromByteArray(t.slice(e,r))}function Lc(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let c,l,h,d;switch(a){case 1:s<128&&(o=s);break;case 2:c=t[i+1],(c&192)===128&&(d=(s&31)<<6|c&63,d>127&&(o=d));break;case 3:c=t[i+1],l=t[i+2],(c&192)===128&&(l&192)===128&&(d=(s&15)<<12|(c&63)<<6|l&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:c=t[i+1],l=t[i+2],h=t[i+3],(c&192)===128&&(l&192)===128&&(h&192)===128&&(d=(s&15)<<18|(c&63)<<12|(l&63)<<6|h&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return Ah(n)}var Kc=4096;function Ah(t){let e=t.length;if(e<=Kc)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Kc));return r}function Th(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function Sh(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Nh(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let s=e;s<r;++s)i+=kh[t[s]];return i}function Rh(t,e,r){let n=t.slice(e,r),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}j.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,j.prototype),i};function Je(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}j.prototype.readUintLE=j.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Je(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};j.prototype.readUintBE=j.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||Je(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};j.prototype.readUint8=j.prototype.readUInt8=function(e,r){return e=e>>>0,r||Je(e,1,this.length),this[e]};j.prototype.readUint16LE=j.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||Je(e,2,this.length),this[e]|this[e+1]<<8};j.prototype.readUint16BE=j.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||Je(e,2,this.length),this[e]<<8|this[e+1]};j.prototype.readUint32LE=j.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||Je(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};j.prototype.readUint32BE=j.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||Je(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};j.prototype.readBigUInt64LE=br(function(e){e=e>>>0,cn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Mn(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});j.prototype.readBigUInt64BE=br(function(e){e=e>>>0,cn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Mn(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});j.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Je(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};j.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||Je(e,r,this.length);let i=r,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};j.prototype.readInt8=function(e,r){return e=e>>>0,r||Je(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};j.prototype.readInt16LE=function(e,r){e=e>>>0,r||Je(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};j.prototype.readInt16BE=function(e,r){e=e>>>0,r||Je(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};j.prototype.readInt32LE=function(e,r){return e=e>>>0,r||Je(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};j.prototype.readInt32BE=function(e,r){return e=e>>>0,r||Je(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};j.prototype.readBigInt64LE=br(function(e){e=e>>>0,cn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Mn(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});j.prototype.readBigInt64BE=br(function(e){e=e>>>0,cn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Mn(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});j.prototype.readFloatLE=function(e,r){return e=e>>>0,r||Je(e,4,this.length),an.read(this,e,!0,23,4)};j.prototype.readFloatBE=function(e,r){return e=e>>>0,r||Je(e,4,this.length),an.read(this,e,!1,23,4)};j.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||Je(e,8,this.length),an.read(this,e,!0,52,8)};j.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||Je(e,8,this.length),an.read(this,e,!1,52,8)};function ft(t,e,r,n,i,s){if(!j.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}j.prototype.writeUintLE=j.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;ft(this,e,r,n,a,0)}let s=1,o=0;for(this[r]=e&255;++o<n&&(s*=256);)this[r+o]=e/s&255;return r+n};j.prototype.writeUintBE=j.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;ft(this,e,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=e&255;--s>=0&&(o*=256);)this[r+s]=e/o&255;return r+n};j.prototype.writeUint8=j.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,1,255,0),this[r]=e&255,r+1};j.prototype.writeUint16LE=j.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};j.prototype.writeUint16BE=j.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};j.prototype.writeUint32LE=j.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};j.prototype.writeUint32BE=j.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function Dc(t,e,r,n,i){iu(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,r}function eu(t,e,r,n,i){iu(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s=s>>8,t[r+6]=s,s=s>>8,t[r+5]=s,s=s>>8,t[r+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o=o>>8,t[r+2]=o,o=o>>8,t[r+1]=o,o=o>>8,t[r]=o,r+8}j.prototype.writeBigUInt64LE=br(function(e,r=0){return Dc(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});j.prototype.writeBigUInt64BE=br(function(e,r=0){return eu(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});j.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);ft(this,e,r,n,c-1,-c)}let s=0,o=1,a=0;for(this[r]=e&255;++s<n&&(o*=256);)e<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};j.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);ft(this,e,r,n,c-1,-c)}let s=n-1,o=1,a=0;for(this[r+s]=e&255;--s>=0&&(o*=256);)e<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};j.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};j.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};j.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};j.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};j.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};j.prototype.writeBigInt64LE=br(function(e,r=0){return Dc(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});j.prototype.writeBigInt64BE=br(function(e,r=0){return eu(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function tu(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ru(t,e,r,n,i){return e=+e,r=r>>>0,i||tu(t,e,r,4,34028234663852886e22,-34028234663852886e22),an.write(t,e,r,n,23,4),r+4}j.prototype.writeFloatLE=function(e,r,n){return ru(this,e,r,!0,n)};j.prototype.writeFloatBE=function(e,r,n){return ru(this,e,r,!1,n)};function nu(t,e,r,n,i){return e=+e,r=r>>>0,i||tu(t,e,r,8,17976931348623157e292,-17976931348623157e292),an.write(t,e,r,n,52,8),r+8}j.prototype.writeDoubleLE=function(e,r,n){return nu(this,e,r,!0,n)};j.prototype.writeDoubleBE=function(e,r,n){return nu(this,e,r,!1,n)};j.prototype.copy=function(e,r,n,i){if(!j.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let s=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),s};j.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!j.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=r;s<n;++s)this[s]=e;else{let o=j.isBuffer(e)?e:j.from(e,i),a=o.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var on={};function Fo(t,e,r){on[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}Fo("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Fo("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Fo("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=Wc(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Wc(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Wc(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function Oh(t,e,r){cn(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Mn(e,t.length-(r+1))}function iu(t,e,r,n,i,s){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",a;throw s>3?e===0||e===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${e}${o} and <= ${r}${o}`,new on.ERR_OUT_OF_RANGE("value",a,t)}Oh(n,i,s)}function cn(t,e){if(typeof t!="number")throw new on.ERR_INVALID_ARG_TYPE(e,"number",t)}function Mn(t,e,r){throw Math.floor(t)!==t?(cn(t,r),new on.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new on.ERR_BUFFER_OUT_OF_BOUNDS:new on.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Fh=/[^+/0-9A-Za-z-_]/g;function Uh(t){if(t=t.split("=")[0],t=t.trim().replace(Fh,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function No(t,e){e=e||1/0;let r,n=t.length,i=null,s=[];for(let o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function Ih(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Ph(t,e){let r,n,i,s=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function su(t){return Ao.toByteArray(Uh(t))}function Mi(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function zt(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Uo(t){return t!==t}var kh=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function br(t){return typeof BigInt>"u"?Mh:t}function Mh(){throw new Error("BigInt not supported")}});var Cn,Io=he(()=>{(function(t){t[t.SysFatal=1]="SysFatal",t[t.SysTransient=2]="SysTransient",t[t.DestinationInvalid=3]="DestinationInvalid",t[t.CanisterReject=4]="CanisterReject",t[t.CanisterError=5]="CanisterError"})(Cn||(Cn={}))});function nt(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e.buffer}function Me(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}function Hr(t){if(!Ch.test(t))throw new Error("Invalid hexadecimal string.");let e=[...t].reduce((r,n,i)=>(r[i/2|0]=(r[i/2|0]||"")+n,r),[]).map(r=>Number.parseInt(r,16));return new Uint8Array(e).buffer}function Po(t,e){if(t.byteLength!==e.byteLength)return t.byteLength-e.byteLength;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return r[i]-n[i];return 0}function $n(t,e){return Po(t,e)===0}function qn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}function ko(t){return t instanceof Uint8Array?qn(t):t instanceof ArrayBuffer?t:Array.isArray(t)?qn(new Uint8Array(t)):"buffer"in t?ko(t.buffer):qn(new Uint8Array(t))}var Ch,lt=he(()=>{Ch=new RegExp(/^[0-9a-fA-F]+$/)});var Pe,fn=he(()=>{yt();Io();lt();Pe=class t extends Error{constructor(e){super(e),this.message=e,this.name="AgentError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}}});function Ee(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e}function Mo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}function Vn(t){return t instanceof Uint8Array?Mo(t):t instanceof ArrayBuffer?t:Array.isArray(t)?Mo(new Uint8Array(t)):"buffer"in t?Vn(t.buffer):Mo(new Uint8Array(t))}var Rt,Ci=he(()=>{Rt=class{constructor(e,r=e?.byteLength||0){this._buffer=Vn(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return Vn(this._view.slice())}get byteLength(){return this._view.byteLength}read(e){let r=this._view.subarray(0,e);return this._view=this._view.subarray(e),r.slice().buffer}readUint8(){let e=this._view[0];return this._view=this._view.subarray(1),e}write(e){let r=new Uint8Array(e),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+r.byteLength>=this._buffer.byteLength?this.alloc(r.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+r.byteLength),this._view.set(r,n)}get end(){return this._view.byteLength===0}alloc(e){let r=new ArrayBuffer((this._buffer.byteLength+e)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+e);n.set(this._view),this._buffer=r,this._view=n}}});function qh(t){let r=new TextEncoder().encode(t),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function Ot(t){if(/^_\d+_$/.test(t)||/^_0x[0-9a-fA-F]+_$/.test(t)){let e=+t.slice(1,-1);if(Number.isSafeInteger(e)&&e>=0&&e<2**32)return e}return qh(t)}var Co=he(()=>{});function au(){throw new Error("unexpected end of buffer")}function _r(t,e){return t.byteLength<e&&au(),t.read(e)}function xr(t){let e=t.readUint8();return e===void 0&&au(),e}function Oe(t){if(typeof t=="number"&&(t=BigInt(t)),t<BigInt(0))throw new Error("Cannot leb encode negative values.");let e=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,r=new Rt(new ArrayBuffer(e),0);for(;;){let n=Number(t&BigInt(127));if(t/=BigInt(128),t===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}function Ge(t){let e=BigInt(1),r=BigInt(0),n;do n=xr(t),r+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return r}function Ye(t){typeof t=="number"&&(t=BigInt(t));let e=t<BigInt(0);e&&(t=-t-BigInt(1));let r=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,n=new Rt(new ArrayBuffer(r),0);for(;;){let s=i(t);if(t/=BigInt(128),e&&t===BigInt(0)&&s&64||!e&&t===BigInt(0)&&!(s&64)){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let o=s%BigInt(128);return Number(e?BigInt(128)-o-BigInt(1):o)}return n.buffer}function or(t){let e=new Uint8Array(t.buffer),r=0;for(;r<e.byteLength;r++)if(e[r]<128){if(!(e[r]&64))return Ge(t);break}let n=new Uint8Array(_r(t,r+1)),i=BigInt(0);for(let s=n.byteLength-1;s>=0;s--)i=i*BigInt(128)+BigInt(128-(n[s]&127)-1);return-i-BigInt(1)}function cu(t,e){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return qo(t,e)}function qo(t,e){t=BigInt(t);let r=new Rt(new ArrayBuffer(Math.min(1,e)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(t%i);for(r.write(new Uint8Array([o]));++n<e;)t<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((t/i-s)%BigInt(256)),r.write(new Uint8Array([o])),i*=BigInt(256);return r.buffer}function $o(t,e){let r=BigInt(xr(t)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(xr(t));r=r+n*s}return r}function uu(t,e){let r=$o(t,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}var Vo=he(()=>{Ci()});function qi(t){let e=BigInt(t);if(t<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}var fu=he(()=>{});var vr={};Un(vr,{Bool:()=>pu,BoolClass:()=>Gi,ConstructType:()=>Wt,Empty:()=>hu,EmptyClass:()=>ji,FixedIntClass:()=>ar,FixedNatClass:()=>Kt,Float32:()=>bu,Float64:()=>xu,FloatClass:()=>Hn,Func:()=>Mu,FuncClass:()=>Yn,Int:()=>gu,Int16:()=>Eu,Int32:()=>vu,Int64:()=>Bu,Int8:()=>_u,IntClass:()=>Ki,Nat:()=>wu,Nat16:()=>Tu,Nat32:()=>Su,Nat64:()=>Nu,Nat8:()=>Au,NatClass:()=>Wi,Null:()=>mu,NullClass:()=>Yi,Opt:()=>Uu,OptClass:()=>dn,PrimitiveType:()=>ht,Principal:()=>Ru,PrincipalClass:()=>Qi,Rec:()=>ku,RecClass:()=>Er,Record:()=>Iu,RecordClass:()=>Gn,Reserved:()=>du,ReservedClass:()=>hn,Service:()=>Cu,ServiceClass:()=>Li,Text:()=>yu,TextClass:()=>zi,Tuple:()=>Ou,TupleClass:()=>Xi,Type:()=>ln,Unknown:()=>jh,UnknownClass:()=>Hi,Variant:()=>Pu,VariantClass:()=>Ji,Vec:()=>Fu,VecClass:()=>Zi,Visitor:()=>Vi,decode:()=>Vh,encode:()=>$h});function jn(t,e,r){return t.map((n,i)=>r(n,e[i]))}function Ho(t){if(xr(t)!==1)throw new Error("Cannot decode principal");let r=Number(Ge(t));return de.fromUint8Array(new Uint8Array(_r(t,r)))}function Ce(t){let e=JSON.stringify(t,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>lu?e.substring(0,lu-3)+"...":e}function $h(t,e){if(e.length<t.length)throw Error("Wrong number of message arguments");let r=new jo;t.forEach(c=>c.buildTypeTable(r));let n=new TextEncoder().encode($i),i=r.encode(),s=Oe(e.length),o=Ee(...t.map(c=>c.encodeType(r))),a=Ee(...jn(t,e,(c,l)=>{try{c.covariant(l)}catch(h){throw new Error(h.message+`
1
+ "use strict";(()=>{var Gl=Object.create;var Si=Object.defineProperty;var zl=Object.getOwnPropertyDescriptor;var Yl=Object.getOwnPropertyNames;var Kl=Object.getPrototypeOf,Wl=Object.prototype.hasOwnProperty;var he=(t,e)=>()=>(t&&(e=t(t=0)),e);var He=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),In=(t,e)=>{for(var r in e)Si(t,r,{get:e[r],enumerable:!0})},Ac=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Yl(e))!Wl.call(t,i)&&i!==r&&Si(t,i,{get:()=>e[i],enumerable:!(n=zl(e,i))||n.enumerable});return t};var tn=(t,e,r)=>(r=t!=null?Gl(Kl(t)):{},Ac(e||!t||!t.__esModule?Si(r,"default",{value:t,enumerable:!0}):r,t)),Zl=t=>Ac(Si({},"__esModule",{value:!0}),t);function Tc(t){let e=0,r=0,n="";function i(s){return e<0?r|=s>>-e:r=s<<e&248,e>3?(e-=8,1):(e<4&&(n+=Ni[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?Ni[r>>3]:"")}function Sc(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=rn[o.toLowerCase()];if(a===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);a<<=3,r|=a>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=a<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}var Ni,rn,Nc=he(()=>{Ni="abcdefghijklmnopqrstuvwxyz234567",rn=Object.create(null);for(let t=0;t<Ni.length;t++)rn[Ni[t]]=t;rn[0]=rn.o;rn[1]=rn.i});function Rc(t){let e=new Uint8Array(t),r=-1;for(let n=0;n<e.length;n++){let s=(e[n]^r)&255;r=Xl[s]^r>>>8}return(r^-1)>>>0}var Xl,Oc=he(()=>{Xl=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117])});function Jl(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function mo(t,...e){if(!Jl(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function yo(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Fc(t,e){mo(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var go=he(()=>{});var $r,Uc=he(()=>{$r=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});function Ic(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function wo(t){return typeof t=="string"&&(t=Ic(t)),mo(t),t}function Pn(t){let e=n=>t().update(wo(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Fi(t=32){if($r&&typeof $r.getRandomValues=="function")return $r.getRandomValues(new Uint8Array(t));if($r&&typeof $r.randomBytes=="function")return $r.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}var Oi,Nt,_m,Ri,Em,nn=he(()=>{Uc();go();Oi=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Nt=(t,e)=>t<<32-e|t>>>e,_m=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;Ri=class{clone(){return this._cloneInto()}},Em={}.toString});function Ql(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,l=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+l,a,n)}var Pc,kc,sn,bo=he(()=>{go();nn();Pc=(t,e,r)=>t&e^~t&r,kc=(t,e,r)=>t&e^t&r^e&r,sn=class extends Ri{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Oi(this.buffer)}update(e){yo(this);let{view:r,buffer:n,blockLen:i}=this;e=wo(e);let s=e.length;for(let o=0;o<s;){let a=Math.min(i-this.pos,s-o);if(a===i){let c=Oi(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){yo(this),Fc(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let d=o;d<i;d++)r[d]=0;Ql(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=Oi(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)a.setUint32(4*d,h[d],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%r&&e.buffer.set(n),e}}});var Ll,yr,gr,Ui,xo,kn,Mc,Ii=he(()=>{bo();nn();Ll=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),yr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),gr=new Uint32Array(64),Ui=class extends sn{constructor(){super(64,32,8,!1),this.A=yr[0]|0,this.B=yr[1]|0,this.C=yr[2]|0,this.D=yr[3]|0,this.E=yr[4]|0,this.F=yr[5]|0,this.G=yr[6]|0,this.H=yr[7]|0}get(){let{A:e,B:r,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[e,r,n,i,s,o,a,c]}set(e,r,n,i,s,o,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let d=0;d<16;d++,r+=4)gr[d]=e.getUint32(r,!1);for(let d=16;d<64;d++){let w=gr[d-15],b=gr[d-2],f=Nt(w,7)^Nt(w,18)^w>>>3,S=Nt(b,17)^Nt(b,19)^b>>>10;gr[d]=S+gr[d-7]+f+gr[d-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:l,H:h}=this;for(let d=0;d<64;d++){let w=Nt(a,6)^Nt(a,11)^Nt(a,25),b=h+w+Pc(a,c,l)+Ll[d]+gr[d]|0,S=(Nt(n,2)^Nt(n,13)^Nt(n,22))+kc(n,i,s)|0;h=l,l=c,c=a,a=o+b|0,o=s,s=i,i=n,n=b+S|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,i,s,o,a,c,l,h)}roundClean(){gr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},xo=class extends Ui{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}},kn=Pn(()=>new Ui),Mc=Pn(()=>new xo)});function Cc(t){return Mc.create().update(new Uint8Array(t)).digest()}var qc=he(()=>{Ii()});var Pi,Dl,$c,eh,th,rh,de,yt=he(()=>{Nc();Oc();qc();Pi="__principal__",Dl=2,$c=4,eh="aaaaa-aa",th=t=>{var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))},rh=t=>t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""),de=class t{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([$c]))}static managementCanister(){return this.fromHex(eh)}static selfAuthenticating(e){let r=Cc(e);return new this(new Uint8Array([...r,Dl]))}static from(e){if(typeof e=="string")return t.fromText(e);if(Object.getPrototypeOf(e)===Uint8Array.prototype)return new t(e);if(typeof e=="object"&&e!==null&&e._isPrincipal===!0)return new t(e._arr);throw new Error(`Impossible to convert ${JSON.stringify(e)} to Principal.`)}static fromHex(e){return new this(th(e))}static fromText(e){let r=e;if(e.includes(Pi)){let o=JSON.parse(e);Pi in o&&(r=o[Pi])}let n=r.toLowerCase().replace(/-/g,""),i=Sc(n);i=i.slice(4,i.length);let s=new this(i);if(s.toText()!==r)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${r}" may not be a valid Principal ID).`);return s}static fromUint8Array(e){return new this(e)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===$c}toUint8Array(){return this._arr}toHex(){return rh(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,Rc(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),a=Tc(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}toJSON(){return{[Pi]:this.toText()}}compareTo(e){for(let r=0;r<Math.min(this._arr.length,e._arr.length);r++){if(this._arr[r]<e._arr[r])return"lt";if(this._arr[r]>e._arr[r])return"gt"}return this._arr.length<e._arr.length?"lt":this._arr.length>e._arr.length?"gt":"eq"}ltEq(e){let r=this.compareTo(e);return r=="lt"||r=="eq"}gtEq(e){let r=this.compareTo(e);return r=="gt"||r=="eq"}}});var Hc=He(ki=>{"use strict";ki.byteLength=ih;ki.toByteArray=oh;ki.fromByteArray=uh;var zt=[],Et=[],nh=typeof Uint8Array<"u"?Uint8Array:Array,_o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Vr=0,Vc=_o.length;Vr<Vc;++Vr)zt[Vr]=_o[Vr],Et[_o.charCodeAt(Vr)]=Vr;var Vr,Vc;Et[45]=62;Et[95]=63;function jc(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function ih(t){var e=jc(t),r=e[0],n=e[1];return(r+n)*3/4-n}function sh(t,e,r){return(e+r)*3/4-r}function oh(t){var e,r=jc(t),n=r[0],i=r[1],s=new nh(sh(t,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=Et[t.charCodeAt(c)]<<18|Et[t.charCodeAt(c+1)]<<12|Et[t.charCodeAt(c+2)]<<6|Et[t.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=Et[t.charCodeAt(c)]<<2|Et[t.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=Et[t.charCodeAt(c)]<<10|Et[t.charCodeAt(c+1)]<<4|Et[t.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function ah(t){return zt[t>>18&63]+zt[t>>12&63]+zt[t>>6&63]+zt[t&63]}function ch(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),i.push(ah(n));return i.join("")}function uh(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(ch(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(zt[e>>2]+zt[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(zt[e>>10]+zt[e>>4&63]+zt[e<<2&63]+"=")),i.join("")}});var vo=He(Eo=>{Eo.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,l=c>>1,h=-7,d=r?i-1:0,w=r?-1:1,b=t[e+d];for(d+=w,s=b&(1<<-h)-1,b>>=-h,h+=a;h>0;s=s*256+t[e+d],d+=w,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=o*256+t[e+d],d+=w,h-=8);if(s===0)s=1-l;else{if(s===c)return o?NaN:(b?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-l}return(b?-1:1)*o*Math.pow(2,s-n)};Eo.write=function(t,e,r,n,i,s){var o,a,c,l=s*8-i-1,h=(1<<l)-1,d=h>>1,w=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=n?0:s-1,f=n?1:-1,S=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+d>=1?e+=w/c:e+=w*Math.pow(2,1-d),e*c>=2&&(o++,c/=2),o+d>=h?(a=0,o=h):o+d>=1?(a=(e*c-1)*Math.pow(2,i),o=o+d):(a=e*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;t[r+b]=a&255,b+=f,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;t[r+b]=o&255,b+=f,o/=256,l-=8);t[r+b-f]|=S*128}});var su=He(un=>{"use strict";var Bo=Hc(),an=vo(),Gc=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;un.Buffer=j;un.SlowBuffer=mh;un.INSPECT_MAX_BYTES=50;var Mi=2147483647;un.kMaxLength=Mi;j.TYPED_ARRAY_SUPPORT=fh();!j.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function fh(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(j.prototype,"parent",{enumerable:!0,get:function(){if(j.isBuffer(this))return this.buffer}});Object.defineProperty(j.prototype,"offset",{enumerable:!0,get:function(){if(j.isBuffer(this))return this.byteOffset}});function sr(t){if(t>Mi)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,j.prototype),e}function j(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return No(t)}return Wc(t,e,r)}j.poolSize=8192;function Wc(t,e,r){if(typeof t=="string")return hh(t,e);if(ArrayBuffer.isView(t))return dh(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Yt(t,ArrayBuffer)||t&&Yt(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Yt(t,SharedArrayBuffer)||t&&Yt(t.buffer,SharedArrayBuffer)))return To(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return j.from(n,e,r);let i=ph(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return j.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}j.from=function(t,e,r){return Wc(t,e,r)};Object.setPrototypeOf(j.prototype,Uint8Array.prototype);Object.setPrototypeOf(j,Uint8Array);function Zc(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function lh(t,e,r){return Zc(t),t<=0?sr(t):e!==void 0?typeof r=="string"?sr(t).fill(e,r):sr(t).fill(e):sr(t)}j.alloc=function(t,e,r){return lh(t,e,r)};function No(t){return Zc(t),sr(t<0?0:Ro(t)|0)}j.allocUnsafe=function(t){return No(t)};j.allocUnsafeSlow=function(t){return No(t)};function hh(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!j.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=Xc(t,e)|0,n=sr(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Ao(t){let e=t.length<0?0:Ro(t.length)|0,r=sr(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function dh(t){if(Yt(t,Uint8Array)){let e=new Uint8Array(t);return To(e.buffer,e.byteOffset,e.byteLength)}return Ao(t)}function To(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,j.prototype),n}function ph(t){if(j.isBuffer(t)){let e=Ro(t.length)|0,r=sr(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Fo(t.length)?sr(0):Ao(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Ao(t.data)}function Ro(t){if(t>=Mi)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Mi.toString(16)+" bytes");return t|0}function mh(t){return+t!=t&&(t=0),j.alloc(+t)}j.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==j.prototype};j.compare=function(e,r){if(Yt(e,Uint8Array)&&(e=j.from(e,e.offset,e.byteLength)),Yt(r,Uint8Array)&&(r=j.from(r,r.offset,r.byteLength)),!j.isBuffer(e)||!j.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==r[s]){n=e[s],i=r[s];break}return n<i?-1:i<n?1:0};j.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};j.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return j.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=j.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(Yt(o,Uint8Array))s+o.length>i.length?(j.isBuffer(o)||(o=j.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(j.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function Xc(t,e){if(j.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Yt(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return So(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return iu(t).length;default:if(i)return n?-1:So(t).length;e=(""+e).toLowerCase(),i=!0}}j.byteLength=Xc;function yh(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Th(this,e,r);case"utf8":case"utf-8":return Qc(this,e,r);case"ascii":return Bh(this,e,r);case"latin1":case"binary":return Ah(this,e,r);case"base64":return Eh(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Sh(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}j.prototype._isBuffer=!0;function jr(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}j.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)jr(this,r,r+1);return this};j.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)jr(this,r,r+3),jr(this,r+1,r+2);return this};j.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)jr(this,r,r+7),jr(this,r+1,r+6),jr(this,r+2,r+5),jr(this,r+3,r+4);return this};j.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Qc(this,0,e):yh.apply(this,arguments)};j.prototype.toLocaleString=j.prototype.toString;j.prototype.equals=function(e){if(!j.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:j.compare(this,e)===0};j.prototype.inspect=function(){let e="",r=un.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};Gc&&(j.prototype[Gc]=j.prototype.inspect);j.prototype.compare=function(e,r,n,i,s){if(Yt(e,Uint8Array)&&(e=j.from(e,e.offset,e.byteLength)),!j.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,a=n-r,c=Math.min(o,a),l=this.slice(i,s),h=e.slice(r,n);for(let d=0;d<c;++d)if(l[d]!==h[d]){o=l[d],a=h[d];break}return o<a?-1:a<o?1:0};function Jc(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Fo(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=j.from(e,n)),j.isBuffer(e))return e.length===0?-1:zc(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):zc(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function zc(t,e,r,n,i){let s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(h,d){return s===1?h[d]:h.readUInt16BE(d*s)}let l;if(i){let h=-1;for(l=r;l<o;l++)if(c(t,l)===c(e,h===-1?0:l-h)){if(h===-1&&(h=l),l-h+1===a)return h*s}else h!==-1&&(l-=l-h),h=-1}else for(r+a>o&&(r=o-a),l=r;l>=0;l--){let h=!0;for(let d=0;d<a;d++)if(c(t,l+d)!==c(e,d)){h=!1;break}if(h)return l}return-1}j.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};j.prototype.indexOf=function(e,r,n){return Jc(this,e,r,n,!0)};j.prototype.lastIndexOf=function(e,r,n){return Jc(this,e,r,n,!1)};function gh(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let a=parseInt(e.substr(o*2,2),16);if(Fo(a))return o;t[r+o]=a}return o}function wh(t,e,r,n){return Ci(So(e,t.length-r),t,r,n)}function bh(t,e,r,n){return Ci(Fh(e),t,r,n)}function xh(t,e,r,n){return Ci(iu(e),t,r,n)}function _h(t,e,r,n){return Ci(Uh(e,t.length-r),t,r,n)}j.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-r;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return gh(this,e,r,n);case"utf8":case"utf-8":return wh(this,e,r,n);case"ascii":case"latin1":case"binary":return bh(this,e,r,n);case"base64":return xh(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _h(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};j.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Eh(t,e,r){return e===0&&r===t.length?Bo.fromByteArray(t):Bo.fromByteArray(t.slice(e,r))}function Qc(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let c,l,h,d;switch(a){case 1:s<128&&(o=s);break;case 2:c=t[i+1],(c&192)===128&&(d=(s&31)<<6|c&63,d>127&&(o=d));break;case 3:c=t[i+1],l=t[i+2],(c&192)===128&&(l&192)===128&&(d=(s&15)<<12|(c&63)<<6|l&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:c=t[i+1],l=t[i+2],h=t[i+3],(c&192)===128&&(l&192)===128&&(h&192)===128&&(d=(s&15)<<18|(c&63)<<12|(l&63)<<6|h&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return vh(n)}var Yc=4096;function vh(t){let e=t.length;if(e<=Yc)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Yc));return r}function Bh(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function Ah(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Th(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let s=e;s<r;++s)i+=Ih[t[s]];return i}function Sh(t,e,r){let n=t.slice(e,r),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}j.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,j.prototype),i};function Je(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}j.prototype.readUintLE=j.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Je(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};j.prototype.readUintBE=j.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||Je(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};j.prototype.readUint8=j.prototype.readUInt8=function(e,r){return e=e>>>0,r||Je(e,1,this.length),this[e]};j.prototype.readUint16LE=j.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||Je(e,2,this.length),this[e]|this[e+1]<<8};j.prototype.readUint16BE=j.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||Je(e,2,this.length),this[e]<<8|this[e+1]};j.prototype.readUint32LE=j.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||Je(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};j.prototype.readUint32BE=j.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||Je(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};j.prototype.readBigUInt64LE=wr(function(e){e=e>>>0,cn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Mn(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});j.prototype.readBigUInt64BE=wr(function(e){e=e>>>0,cn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Mn(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});j.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Je(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};j.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||Je(e,r,this.length);let i=r,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};j.prototype.readInt8=function(e,r){return e=e>>>0,r||Je(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};j.prototype.readInt16LE=function(e,r){e=e>>>0,r||Je(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};j.prototype.readInt16BE=function(e,r){e=e>>>0,r||Je(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};j.prototype.readInt32LE=function(e,r){return e=e>>>0,r||Je(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};j.prototype.readInt32BE=function(e,r){return e=e>>>0,r||Je(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};j.prototype.readBigInt64LE=wr(function(e){e=e>>>0,cn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Mn(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});j.prototype.readBigInt64BE=wr(function(e){e=e>>>0,cn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Mn(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});j.prototype.readFloatLE=function(e,r){return e=e>>>0,r||Je(e,4,this.length),an.read(this,e,!0,23,4)};j.prototype.readFloatBE=function(e,r){return e=e>>>0,r||Je(e,4,this.length),an.read(this,e,!1,23,4)};j.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||Je(e,8,this.length),an.read(this,e,!0,52,8)};j.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||Je(e,8,this.length),an.read(this,e,!1,52,8)};function ft(t,e,r,n,i,s){if(!j.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}j.prototype.writeUintLE=j.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;ft(this,e,r,n,a,0)}let s=1,o=0;for(this[r]=e&255;++o<n&&(s*=256);)this[r+o]=e/s&255;return r+n};j.prototype.writeUintBE=j.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;ft(this,e,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=e&255;--s>=0&&(o*=256);)this[r+s]=e/o&255;return r+n};j.prototype.writeUint8=j.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,1,255,0),this[r]=e&255,r+1};j.prototype.writeUint16LE=j.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};j.prototype.writeUint16BE=j.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};j.prototype.writeUint32LE=j.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};j.prototype.writeUint32BE=j.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function Lc(t,e,r,n,i){nu(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,r}function Dc(t,e,r,n,i){nu(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s=s>>8,t[r+6]=s,s=s>>8,t[r+5]=s,s=s>>8,t[r+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o=o>>8,t[r+2]=o,o=o>>8,t[r+1]=o,o=o>>8,t[r]=o,r+8}j.prototype.writeBigUInt64LE=wr(function(e,r=0){return Lc(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});j.prototype.writeBigUInt64BE=wr(function(e,r=0){return Dc(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});j.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);ft(this,e,r,n,c-1,-c)}let s=0,o=1,a=0;for(this[r]=e&255;++s<n&&(o*=256);)e<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};j.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);ft(this,e,r,n,c-1,-c)}let s=n-1,o=1,a=0;for(this[r+s]=e&255;--s>=0&&(o*=256);)e<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};j.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};j.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};j.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};j.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};j.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};j.prototype.writeBigInt64LE=wr(function(e,r=0){return Lc(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});j.prototype.writeBigInt64BE=wr(function(e,r=0){return Dc(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function eu(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function tu(t,e,r,n,i){return e=+e,r=r>>>0,i||eu(t,e,r,4,34028234663852886e22,-34028234663852886e22),an.write(t,e,r,n,23,4),r+4}j.prototype.writeFloatLE=function(e,r,n){return tu(this,e,r,!0,n)};j.prototype.writeFloatBE=function(e,r,n){return tu(this,e,r,!1,n)};function ru(t,e,r,n,i){return e=+e,r=r>>>0,i||eu(t,e,r,8,17976931348623157e292,-17976931348623157e292),an.write(t,e,r,n,52,8),r+8}j.prototype.writeDoubleLE=function(e,r,n){return ru(this,e,r,!0,n)};j.prototype.writeDoubleBE=function(e,r,n){return ru(this,e,r,!1,n)};j.prototype.copy=function(e,r,n,i){if(!j.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let s=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),s};j.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!j.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=r;s<n;++s)this[s]=e;else{let o=j.isBuffer(e)?e:j.from(e,i),a=o.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var on={};function Oo(t,e,r){on[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}Oo("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Oo("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Oo("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=Kc(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Kc(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Kc(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function Nh(t,e,r){cn(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Mn(e,t.length-(r+1))}function nu(t,e,r,n,i,s){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",a;throw s>3?e===0||e===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${e}${o} and <= ${r}${o}`,new on.ERR_OUT_OF_RANGE("value",a,t)}Nh(n,i,s)}function cn(t,e){if(typeof t!="number")throw new on.ERR_INVALID_ARG_TYPE(e,"number",t)}function Mn(t,e,r){throw Math.floor(t)!==t?(cn(t,r),new on.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new on.ERR_BUFFER_OUT_OF_BOUNDS:new on.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Rh=/[^+/0-9A-Za-z-_]/g;function Oh(t){if(t=t.split("=")[0],t=t.trim().replace(Rh,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function So(t,e){e=e||1/0;let r,n=t.length,i=null,s=[];for(let o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function Fh(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Uh(t,e){let r,n,i,s=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function iu(t){return Bo.toByteArray(Oh(t))}function Ci(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Yt(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Fo(t){return t!==t}var Ih=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function wr(t){return typeof BigInt>"u"?Ph:t}function Ph(){throw new Error("BigInt not supported")}});var Cn,Uo=he(()=>{(function(t){t[t.SysFatal=1]="SysFatal",t[t.SysTransient=2]="SysTransient",t[t.DestinationInvalid=3]="DestinationInvalid",t[t.CanisterReject=4]="CanisterReject",t[t.CanisterError=5]="CanisterError"})(Cn||(Cn={}))});function nt(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e.buffer}function Me(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}function Hr(t){if(!kh.test(t))throw new Error("Invalid hexadecimal string.");let e=[...t].reduce((r,n,i)=>(r[i/2|0]=(r[i/2|0]||"")+n,r),[]).map(r=>Number.parseInt(r,16));return new Uint8Array(e).buffer}function Io(t,e){if(t.byteLength!==e.byteLength)return t.byteLength-e.byteLength;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return r[i]-n[i];return 0}function $n(t,e){return Io(t,e)===0}function qn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}function Po(t){return t instanceof Uint8Array?qn(t):t instanceof ArrayBuffer?t:Array.isArray(t)?qn(new Uint8Array(t)):"buffer"in t?Po(t.buffer):qn(new Uint8Array(t))}var kh,lt=he(()=>{kh=new RegExp(/^[0-9a-fA-F]+$/)});var Pe,fn=he(()=>{yt();Uo();lt();Pe=class t extends Error{constructor(e){super(e),this.message=e,this.name="AgentError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}}});function Ee(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e}function ko(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}function Vn(t){return t instanceof Uint8Array?ko(t):t instanceof ArrayBuffer?t:Array.isArray(t)?ko(new Uint8Array(t)):"buffer"in t?Vn(t.buffer):ko(new Uint8Array(t))}var Rt,qi=he(()=>{Rt=class{constructor(e,r=e?.byteLength||0){this._buffer=Vn(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return Vn(this._view.slice())}get byteLength(){return this._view.byteLength}read(e){let r=this._view.subarray(0,e);return this._view=this._view.subarray(e),r.slice().buffer}readUint8(){let e=this._view[0];return this._view=this._view.subarray(1),e}write(e){let r=new Uint8Array(e),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+r.byteLength>=this._buffer.byteLength?this.alloc(r.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+r.byteLength),this._view.set(r,n)}get end(){return this._view.byteLength===0}alloc(e){let r=new ArrayBuffer((this._buffer.byteLength+e)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+e);n.set(this._view),this._buffer=r,this._view=n}}});function Mh(t){let r=new TextEncoder().encode(t),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function Ot(t){if(/^_\d+_$/.test(t)||/^_0x[0-9a-fA-F]+_$/.test(t)){let e=+t.slice(1,-1);if(Number.isSafeInteger(e)&&e>=0&&e<2**32)return e}return Mh(t)}var Mo=he(()=>{});function ou(){throw new Error("unexpected end of buffer")}function xr(t,e){return t.byteLength<e&&ou(),t.read(e)}function br(t){let e=t.readUint8();return e===void 0&&ou(),e}function Oe(t){if(typeof t=="number"&&(t=BigInt(t)),t<BigInt(0))throw new Error("Cannot leb encode negative values.");let e=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,r=new Rt(new ArrayBuffer(e),0);for(;;){let n=Number(t&BigInt(127));if(t/=BigInt(128),t===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}function Ge(t){let e=BigInt(1),r=BigInt(0),n;do n=br(t),r+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return r}function ze(t){typeof t=="number"&&(t=BigInt(t));let e=t<BigInt(0);e&&(t=-t-BigInt(1));let r=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,n=new Rt(new ArrayBuffer(r),0);for(;;){let s=i(t);if(t/=BigInt(128),e&&t===BigInt(0)&&s&64||!e&&t===BigInt(0)&&!(s&64)){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let o=s%BigInt(128);return Number(e?BigInt(128)-o-BigInt(1):o)}return n.buffer}function or(t){let e=new Uint8Array(t.buffer),r=0;for(;r<e.byteLength;r++)if(e[r]<128){if(!(e[r]&64))return Ge(t);break}let n=new Uint8Array(xr(t,r+1)),i=BigInt(0);for(let s=n.byteLength-1;s>=0;s--)i=i*BigInt(128)+BigInt(128-(n[s]&127)-1);return-i-BigInt(1)}function au(t,e){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return Co(t,e)}function Co(t,e){t=BigInt(t);let r=new Rt(new ArrayBuffer(Math.min(1,e)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(t%i);for(r.write(new Uint8Array([o]));++n<e;)t<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((t/i-s)%BigInt(256)),r.write(new Uint8Array([o])),i*=BigInt(256);return r.buffer}function qo(t,e){let r=BigInt(br(t)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(br(t));r=r+n*s}return r}function cu(t,e){let r=qo(t,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}var $o=he(()=>{qi()});function $i(t){let e=BigInt(t);if(t<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}var uu=he(()=>{});var Er={};In(Er,{Bool:()=>du,BoolClass:()=>zi,ConstructType:()=>Wt,Empty:()=>lu,EmptyClass:()=>Hi,FixedIntClass:()=>ar,FixedNatClass:()=>Kt,Float32:()=>wu,Float64:()=>bu,FloatClass:()=>Hn,Func:()=>ku,FuncClass:()=>zn,Int:()=>yu,Int16:()=>_u,Int32:()=>Eu,Int64:()=>vu,Int8:()=>xu,IntClass:()=>Wi,Nat:()=>gu,Nat16:()=>Au,Nat32:()=>Tu,Nat64:()=>Su,Nat8:()=>Bu,NatClass:()=>Zi,Null:()=>pu,NullClass:()=>Yi,Opt:()=>Fu,OptClass:()=>dn,PrimitiveType:()=>ht,Principal:()=>Nu,PrincipalClass:()=>Li,Rec:()=>Pu,RecClass:()=>_r,Record:()=>Uu,RecordClass:()=>Gn,Reserved:()=>hu,ReservedClass:()=>hn,Service:()=>Mu,ServiceClass:()=>Di,Text:()=>mu,TextClass:()=>Ki,Tuple:()=>Ru,TupleClass:()=>Ji,Type:()=>ln,Unknown:()=>$h,UnknownClass:()=>Gi,Variant:()=>Iu,VariantClass:()=>Qi,Vec:()=>Ou,VecClass:()=>Xi,Visitor:()=>ji,decode:()=>qh,encode:()=>Ch});function jn(t,e,r){return t.map((n,i)=>r(n,e[i]))}function jo(t){if(br(t)!==1)throw new Error("Cannot decode principal");let r=Number(Ge(t));return de.fromUint8Array(new Uint8Array(xr(t,r)))}function Ce(t){let e=JSON.stringify(t,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>fu?e.substring(0,fu-3)+"...":e}function Ch(t,e){if(e.length<t.length)throw Error("Wrong number of message arguments");let r=new Vo;t.forEach(c=>c.buildTypeTable(r));let n=new TextEncoder().encode(Vi),i=r.encode(),s=Oe(e.length),o=Ee(...t.map(c=>c.encodeType(r))),a=Ee(...jn(t,e,(c,l)=>{try{c.covariant(l)}catch(h){throw new Error(h.message+`
2
2
 
3
- `)}return c.encodeValue(l)}));return Ee(n,i,s,o,a)}function Vh(t,e){let r=new Rt(e);if(e.byteLength<$i.length)throw new Error("Message length smaller than magic number");let n=_r(r,$i.length),i=new TextDecoder().decode(n);if(i!==$i)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(b){let f=[],S=Number(Ge(b));for(let V=0;V<S;V++){let q=Number(or(b));switch(q){case-18:case-19:{let Y=Number(or(b));f.push([q,Y]);break}case-20:case-21:{let Y=[],E=Number(Ge(b)),H;for(;E--;){let z=Number(Ge(b));if(z>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof H=="number"&&H>=z)throw new Error("field id collision or not sorted");H=z;let Z=Number(or(b));Y.push([z,Z])}f.push([q,Y]);break}case-22:{let Y=[],E=Number(Ge(b));for(;E--;)Y.push(Number(or(b)));let H=[],z=Number(Ge(b));for(;z--;)H.push(Number(or(b)));let Z=[],C=Number(Ge(b));for(;C--;)switch(Number(Ge(b))){case 1:{Z.push("query");break}case 2:{Z.push("oneway");break}case 3:{Z.push("composite_query");break}default:throw new Error("unknown annotation")}f.push([q,[Y,H,Z]]);break}case-23:{let Y=Number(Ge(b)),E=[];for(;Y--;){let H=Number(Ge(b)),z=new TextDecoder().decode(_r(b,H)),Z=or(b);E.push([z,Z])}f.push([q,E]);break}default:throw new Error("Illegal op_code: "+q)}}let R=[],O=Number(Ge(b));for(let V=0;V<O;V++)R.push(Number(or(b)));return[f,R]}let[o,a]=s(r);if(a.length<t.length)throw new Error("Wrong number of return values");let c=o.map(b=>ku());function l(b){if(b<-24)throw new Error("future value not supported");if(b<0)switch(b){case-1:return mu;case-2:return pu;case-3:return wu;case-4:return gu;case-5:return Au;case-6:return Tu;case-7:return Su;case-8:return Nu;case-9:return _u;case-10:return Eu;case-11:return vu;case-12:return Bu;case-13:return bu;case-14:return xu;case-15:return yu;case-16:return du;case-17:return hu;case-24:return Ru;default:throw new Error("Illegal op_code: "+b)}if(b>=o.length)throw new Error("type index out of range");return c[b]}function h(b){switch(b[0]){case-19:{let f=l(b[1]);return Fu(f)}case-18:{let f=l(b[1]);return Uu(f)}case-20:{let f={};for(let[O,V]of b[1]){let q=`_${O}_`;f[q]=l(V)}let S=Iu(f),R=S.tryAsTuple();return Array.isArray(R)?Ou(...R):S}case-21:{let f={};for(let[S,R]of b[1]){let O=`_${S}_`;f[O]=l(R)}return Pu(f)}case-22:{let[f,S,R]=b[1];return Mu(f.map(O=>l(O)),S.map(O=>l(O)),R)}case-23:{let f={},S=b[1];for(let[R,O]of S){let V=l(O);if(V instanceof Er&&(V=V.getType()),!(V instanceof Yn))throw new Error("Illegal service definition: services can only contain functions");f[R]=V}return Cu(f)}default:throw new Error("Illegal op_code: "+b[0])}}o.forEach((b,f)=>{if(b[0]===-22){let S=h(b);c[f].fill(S)}}),o.forEach((b,f)=>{if(b[0]!==-22){let S=h(b);c[f].fill(S)}});let d=a.map(b=>l(b)),w=t.map((b,f)=>b.decodeValue(r,d[f]));for(let b=t.length;b<d.length;b++)d[b].decodeValue(r,d[b]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return w}function Ou(...t){return new Xi(t)}function Fu(t){return new Zi(t)}function Uu(t){return new dn(t)}function Iu(t){return new Gn(t)}function Pu(t){return new Ji(t)}function ku(){return new Er}function Mu(t,e,r=[]){return new Yn(t,e,r)}function Cu(t){return new Li(t)}var $i,lu,jo,Vi,ln,ht,Wt,ji,Hi,Gi,Yi,hn,zi,Ki,Wi,Hn,ar,Kt,Zi,dn,Gn,Xi,Ji,Er,Qi,Yn,Li,hu,du,jh,pu,mu,yu,gu,wu,bu,xu,_u,Eu,vu,Bu,Au,Tu,Su,Nu,Ru,Go=he(()=>{yt();Ci();Co();Vo();fu();$i="DIDL",lu=400;jo=class{constructor(){this._typs=[],this._idx=new Map}has(e){return this._idx.has(e.name)}add(e,r){let n=this._typs.length;this._idx.set(e.name,n),this._typs.push(r)}merge(e,r){let n=this._idx.get(e.name),i=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+e);if(i===void 0)throw new Error("Missing type index for "+r);this._typs[n]=this._typs[i],this._typs.splice(i,1),this._idx.delete(r)}encode(){let e=Oe(this._typs.length),r=Ee(...this._typs);return Ee(e,r)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return Ye(this._idx.get(e)||0)}},Vi=class{visitType(e,r){throw new Error("Not implemented")}visitPrimitive(e,r){return this.visitType(e,r)}visitEmpty(e,r){return this.visitPrimitive(e,r)}visitBool(e,r){return this.visitPrimitive(e,r)}visitNull(e,r){return this.visitPrimitive(e,r)}visitReserved(e,r){return this.visitPrimitive(e,r)}visitText(e,r){return this.visitPrimitive(e,r)}visitNumber(e,r){return this.visitPrimitive(e,r)}visitInt(e,r){return this.visitNumber(e,r)}visitNat(e,r){return this.visitNumber(e,r)}visitFloat(e,r){return this.visitPrimitive(e,r)}visitFixedInt(e,r){return this.visitNumber(e,r)}visitFixedNat(e,r){return this.visitNumber(e,r)}visitPrincipal(e,r){return this.visitPrimitive(e,r)}visitConstruct(e,r){return this.visitType(e,r)}visitVec(e,r,n){return this.visitConstruct(e,n)}visitOpt(e,r,n){return this.visitConstruct(e,n)}visitRecord(e,r,n){return this.visitConstruct(e,n)}visitTuple(e,r,n){let i=r.map((s,o)=>[`_${o}_`,s]);return this.visitRecord(e,i,n)}visitVariant(e,r,n){return this.visitConstruct(e,n)}visitRec(e,r,n){return this.visitConstruct(r,n)}visitFunc(e,r){return this.visitConstruct(e,r)}visitService(e,r){return this.visitConstruct(e,r)}},ln=class{display(){return this.name}valueToString(e){return Ce(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}},ht=class extends ln{checkType(e){if(this.name!==e.name)throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`);return e}_buildTypeTableImpl(e){}},Wt=class extends ln{checkType(e){if(e instanceof Er){let r=e.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`)}encodeType(e){return e.indexOf(this.name)}},ji=class extends ht{accept(e,r){return e.visitEmpty(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return Ye(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},Hi=class extends ln{checkType(e){throw new Error("Method not implemented for unknown.")}accept(e,r){throw e.visitType(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(e,r){let n=r.decodeValue(e,r);Object(n)!==n&&(n=Object(n));let i;return r instanceof Er?i=()=>r.getType():i=()=>r,Object.defineProperty(n,"type",{value:i,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}},Gi=class extends ht{accept(e,r){return e.visitBool(this,r)}covariant(e){if(typeof e=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return Ye(-2)}decodeValue(e,r){switch(this.checkType(r),xr(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},Yi=class extends ht{accept(e,r){return e.visitNull(this,r)}covariant(e){if(e===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return Ye(-1)}decodeValue(e,r){return this.checkType(r),null}get name(){return"null"}},hn=class extends ht{accept(e,r){return e.visitReserved(this,r)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return Ye(-16)}decodeValue(e,r){return r.name!==this.name&&r.decodeValue(e,r),null}get name(){return"reserved"}},zi=class extends ht{accept(e,r){return e.visitText(this,r)}covariant(e){if(typeof e=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=new TextEncoder().encode(e),n=Oe(r.byteLength);return Ee(n,r)}encodeType(){return Ye(-15)}decodeValue(e,r){this.checkType(r);let n=Ge(e),i=_r(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}},Ki=class extends ht{accept(e,r){return e.visitInt(this,r)}covariant(e){if(typeof e=="bigint"||Number.isInteger(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return Ye(e)}encodeType(){return Ye(-4)}decodeValue(e,r){return this.checkType(r),or(e)}get name(){return"int"}valueToString(e){return e.toString()}},Wi=class extends ht{accept(e,r){return e.visitNat(this,r)}covariant(e){if(typeof e=="bigint"&&e>=BigInt(0)||Number.isInteger(e)&&e>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return Oe(e)}encodeType(){return Ye(-3)}decodeValue(e,r){return this.checkType(r),Ge(e)}get name(){return"nat"}valueToString(e){return e.toString()}},Hn=class extends ht{constructor(e){if(super(),this._bits=e,e!==32&&e!==64)throw new Error("not a valid float type")}accept(e,r){return e.visitFloat(this,r)}covariant(e){if(typeof e=="number"||e instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,e,!0):n.setFloat64(0,e,!0),r}encodeType(){let e=this._bits===32?-13:-14;return Ye(e)}decodeValue(e,r){this.checkType(r);let n=_r(e,this._bits/8),i=new DataView(n);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(e){return e.toString()}},ar=class extends ht{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedInt(this,r)}covariant(e){let r=qi(this._bits-1)*BigInt(-1),n=qi(this._bits-1)-BigInt(1),i=!1;if(typeof e=="bigint")i=e>=r&&e<=n;else if(Number.isInteger(e)){let s=BigInt(e);i=s>=r&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return qo(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return Ye(-9-e)}decodeValue(e,r){this.checkType(r);let n=uu(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}},Kt=class extends ht{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedNat(this,r)}covariant(e){let r=qi(this._bits),n=!1;if(typeof e=="bigint"&&e>=BigInt(0)?n=e<r:Number.isInteger(e)&&e>=0?n=BigInt(e)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return cu(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return Ye(-5-e)}decodeValue(e,r){this.checkType(r);let n=$o(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}},Zi=class t extends Wt{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof Kt&&e._bits===8&&(this._blobOptimization=!0)}accept(e,r){return e.visitVec(this,this._type,r)}covariant(e){let r=this._type instanceof Kt?this._type._bits:this._type instanceof ar?this._type._bits:0;if(ArrayBuffer.isView(e)&&r==e.BYTES_PER_ELEMENT*8||Array.isArray(e)&&e.every((n,i)=>{try{return this._type.covariant(n)}catch(s){throw new Error(`Invalid ${this.display()} argument:
3
+ `)}return c.encodeValue(l)}));return Ee(n,i,s,o,a)}function qh(t,e){let r=new Rt(e);if(e.byteLength<Vi.length)throw new Error("Message length smaller than magic number");let n=xr(r,Vi.length),i=new TextDecoder().decode(n);if(i!==Vi)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(b){let f=[],S=Number(Ge(b));for(let V=0;V<S;V++){let q=Number(or(b));switch(q){case-18:case-19:{let z=Number(or(b));f.push([q,z]);break}case-20:case-21:{let z=[],E=Number(Ge(b)),H;for(;E--;){let Y=Number(Ge(b));if(Y>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof H=="number"&&H>=Y)throw new Error("field id collision or not sorted");H=Y;let Z=Number(or(b));z.push([Y,Z])}f.push([q,z]);break}case-22:{let z=[],E=Number(Ge(b));for(;E--;)z.push(Number(or(b)));let H=[],Y=Number(Ge(b));for(;Y--;)H.push(Number(or(b)));let Z=[],C=Number(Ge(b));for(;C--;)switch(Number(Ge(b))){case 1:{Z.push("query");break}case 2:{Z.push("oneway");break}case 3:{Z.push("composite_query");break}default:throw new Error("unknown annotation")}f.push([q,[z,H,Z]]);break}case-23:{let z=Number(Ge(b)),E=[];for(;z--;){let H=Number(Ge(b)),Y=new TextDecoder().decode(xr(b,H)),Z=or(b);E.push([Y,Z])}f.push([q,E]);break}default:throw new Error("Illegal op_code: "+q)}}let R=[],O=Number(Ge(b));for(let V=0;V<O;V++)R.push(Number(or(b)));return[f,R]}let[o,a]=s(r);if(a.length<t.length)throw new Error("Wrong number of return values");let c=o.map(b=>Pu());function l(b){if(b<-24)throw new Error("future value not supported");if(b<0)switch(b){case-1:return pu;case-2:return du;case-3:return gu;case-4:return yu;case-5:return Bu;case-6:return Au;case-7:return Tu;case-8:return Su;case-9:return xu;case-10:return _u;case-11:return Eu;case-12:return vu;case-13:return wu;case-14:return bu;case-15:return mu;case-16:return hu;case-17:return lu;case-24:return Nu;default:throw new Error("Illegal op_code: "+b)}if(b>=o.length)throw new Error("type index out of range");return c[b]}function h(b){switch(b[0]){case-19:{let f=l(b[1]);return Ou(f)}case-18:{let f=l(b[1]);return Fu(f)}case-20:{let f={};for(let[O,V]of b[1]){let q=`_${O}_`;f[q]=l(V)}let S=Uu(f),R=S.tryAsTuple();return Array.isArray(R)?Ru(...R):S}case-21:{let f={};for(let[S,R]of b[1]){let O=`_${S}_`;f[O]=l(R)}return Iu(f)}case-22:{let[f,S,R]=b[1];return ku(f.map(O=>l(O)),S.map(O=>l(O)),R)}case-23:{let f={},S=b[1];for(let[R,O]of S){let V=l(O);if(V instanceof _r&&(V=V.getType()),!(V instanceof zn))throw new Error("Illegal service definition: services can only contain functions");f[R]=V}return Mu(f)}default:throw new Error("Illegal op_code: "+b[0])}}o.forEach((b,f)=>{if(b[0]===-22){let S=h(b);c[f].fill(S)}}),o.forEach((b,f)=>{if(b[0]!==-22){let S=h(b);c[f].fill(S)}});let d=a.map(b=>l(b)),w=t.map((b,f)=>b.decodeValue(r,d[f]));for(let b=t.length;b<d.length;b++)d[b].decodeValue(r,d[b]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return w}function Ru(...t){return new Ji(t)}function Ou(t){return new Xi(t)}function Fu(t){return new dn(t)}function Uu(t){return new Gn(t)}function Iu(t){return new Qi(t)}function Pu(){return new _r}function ku(t,e,r=[]){return new zn(t,e,r)}function Mu(t){return new Di(t)}var Vi,fu,Vo,ji,ln,ht,Wt,Hi,Gi,zi,Yi,hn,Ki,Wi,Zi,Hn,ar,Kt,Xi,dn,Gn,Ji,Qi,_r,Li,zn,Di,lu,hu,$h,du,pu,mu,yu,gu,wu,bu,xu,_u,Eu,vu,Bu,Au,Tu,Su,Nu,Ho=he(()=>{yt();qi();Mo();$o();uu();Vi="DIDL",fu=400;Vo=class{constructor(){this._typs=[],this._idx=new Map}has(e){return this._idx.has(e.name)}add(e,r){let n=this._typs.length;this._idx.set(e.name,n),this._typs.push(r)}merge(e,r){let n=this._idx.get(e.name),i=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+e);if(i===void 0)throw new Error("Missing type index for "+r);this._typs[n]=this._typs[i],this._typs.splice(i,1),this._idx.delete(r)}encode(){let e=Oe(this._typs.length),r=Ee(...this._typs);return Ee(e,r)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return ze(this._idx.get(e)||0)}},ji=class{visitType(e,r){throw new Error("Not implemented")}visitPrimitive(e,r){return this.visitType(e,r)}visitEmpty(e,r){return this.visitPrimitive(e,r)}visitBool(e,r){return this.visitPrimitive(e,r)}visitNull(e,r){return this.visitPrimitive(e,r)}visitReserved(e,r){return this.visitPrimitive(e,r)}visitText(e,r){return this.visitPrimitive(e,r)}visitNumber(e,r){return this.visitPrimitive(e,r)}visitInt(e,r){return this.visitNumber(e,r)}visitNat(e,r){return this.visitNumber(e,r)}visitFloat(e,r){return this.visitPrimitive(e,r)}visitFixedInt(e,r){return this.visitNumber(e,r)}visitFixedNat(e,r){return this.visitNumber(e,r)}visitPrincipal(e,r){return this.visitPrimitive(e,r)}visitConstruct(e,r){return this.visitType(e,r)}visitVec(e,r,n){return this.visitConstruct(e,n)}visitOpt(e,r,n){return this.visitConstruct(e,n)}visitRecord(e,r,n){return this.visitConstruct(e,n)}visitTuple(e,r,n){let i=r.map((s,o)=>[`_${o}_`,s]);return this.visitRecord(e,i,n)}visitVariant(e,r,n){return this.visitConstruct(e,n)}visitRec(e,r,n){return this.visitConstruct(r,n)}visitFunc(e,r){return this.visitConstruct(e,r)}visitService(e,r){return this.visitConstruct(e,r)}},ln=class{display(){return this.name}valueToString(e){return Ce(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}},ht=class extends ln{checkType(e){if(this.name!==e.name)throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`);return e}_buildTypeTableImpl(e){}},Wt=class extends ln{checkType(e){if(e instanceof _r){let r=e.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`)}encodeType(e){return e.indexOf(this.name)}},Hi=class extends ht{accept(e,r){return e.visitEmpty(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return ze(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},Gi=class extends ln{checkType(e){throw new Error("Method not implemented for unknown.")}accept(e,r){throw e.visitType(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(e,r){let n=r.decodeValue(e,r);Object(n)!==n&&(n=Object(n));let i;return r instanceof _r?i=()=>r.getType():i=()=>r,Object.defineProperty(n,"type",{value:i,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}},zi=class extends ht{accept(e,r){return e.visitBool(this,r)}covariant(e){if(typeof e=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return ze(-2)}decodeValue(e,r){switch(this.checkType(r),br(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},Yi=class extends ht{accept(e,r){return e.visitNull(this,r)}covariant(e){if(e===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return ze(-1)}decodeValue(e,r){return this.checkType(r),null}get name(){return"null"}},hn=class extends ht{accept(e,r){return e.visitReserved(this,r)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return ze(-16)}decodeValue(e,r){return r.name!==this.name&&r.decodeValue(e,r),null}get name(){return"reserved"}},Ki=class extends ht{accept(e,r){return e.visitText(this,r)}covariant(e){if(typeof e=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=new TextEncoder().encode(e),n=Oe(r.byteLength);return Ee(n,r)}encodeType(){return ze(-15)}decodeValue(e,r){this.checkType(r);let n=Ge(e),i=xr(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}},Wi=class extends ht{accept(e,r){return e.visitInt(this,r)}covariant(e){if(typeof e=="bigint"||Number.isInteger(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return ze(e)}encodeType(){return ze(-4)}decodeValue(e,r){return this.checkType(r),or(e)}get name(){return"int"}valueToString(e){return e.toString()}},Zi=class extends ht{accept(e,r){return e.visitNat(this,r)}covariant(e){if(typeof e=="bigint"&&e>=BigInt(0)||Number.isInteger(e)&&e>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return Oe(e)}encodeType(){return ze(-3)}decodeValue(e,r){return this.checkType(r),Ge(e)}get name(){return"nat"}valueToString(e){return e.toString()}},Hn=class extends ht{constructor(e){if(super(),this._bits=e,e!==32&&e!==64)throw new Error("not a valid float type")}accept(e,r){return e.visitFloat(this,r)}covariant(e){if(typeof e=="number"||e instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,e,!0):n.setFloat64(0,e,!0),r}encodeType(){let e=this._bits===32?-13:-14;return ze(e)}decodeValue(e,r){this.checkType(r);let n=xr(e,this._bits/8),i=new DataView(n);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(e){return e.toString()}},ar=class extends ht{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedInt(this,r)}covariant(e){let r=$i(this._bits-1)*BigInt(-1),n=$i(this._bits-1)-BigInt(1),i=!1;if(typeof e=="bigint")i=e>=r&&e<=n;else if(Number.isInteger(e)){let s=BigInt(e);i=s>=r&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return Co(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return ze(-9-e)}decodeValue(e,r){this.checkType(r);let n=cu(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}},Kt=class extends ht{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedNat(this,r)}covariant(e){let r=$i(this._bits),n=!1;if(typeof e=="bigint"&&e>=BigInt(0)?n=e<r:Number.isInteger(e)&&e>=0?n=BigInt(e)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return au(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return ze(-5-e)}decodeValue(e,r){this.checkType(r);let n=qo(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}},Xi=class t extends Wt{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof Kt&&e._bits===8&&(this._blobOptimization=!0)}accept(e,r){return e.visitVec(this,this._type,r)}covariant(e){let r=this._type instanceof Kt?this._type._bits:this._type instanceof ar?this._type._bits:0;if(ArrayBuffer.isView(e)&&r==e.BYTES_PER_ELEMENT*8||Array.isArray(e)&&e.every((n,i)=>{try{return this._type.covariant(n)}catch(s){throw new Error(`Invalid ${this.display()} argument:
4
4
 
5
- index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=Oe(e.length);if(this._blobOptimization)return Ee(r,new Uint8Array(e));if(ArrayBuffer.isView(e))return Ee(r,new Uint8Array(e.buffer));let n=new Rt(new ArrayBuffer(r.byteLength+e.length),0);n.write(r);for(let i of e){let s=this._type.encodeValue(i);n.write(new Uint8Array(s))}return n.buffer}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=Ye(-19),n=this._type.encodeType(e);e.add(this,Ee(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a vector type");let i=Number(Ge(e));if(this._type instanceof Kt){if(this._type._bits==8)return new Uint8Array(e.read(i));if(this._type._bits==16)return new Uint16Array(e.read(i*2));if(this._type._bits==32)return new Uint32Array(e.read(i*4));if(this._type._bits==64)return new BigUint64Array(e.read(i*8))}if(this._type instanceof ar){if(this._type._bits==8)return new Int8Array(e.read(i));if(this._type._bits==16)return new Int16Array(e.read(i*2));if(this._type._bits==32)return new Int32Array(e.read(i*4));if(this._type._bits==64)return new BigInt64Array(e.read(i*8))}let s=[];for(let o=0;o<i;o++)s.push(this._type.decodeValue(e,n._type));return s}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(e){return"vec {"+e.map(n=>this._type.valueToString(n)).join("; ")+"}"}},dn=class t extends Wt{constructor(e){super(),this._type=e}accept(e,r){return e.visitOpt(this,this._type,r)}covariant(e){try{if(Array.isArray(e)&&(e.length===0||e.length===1&&this._type.covariant(e[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}
5
+ index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=Oe(e.length);if(this._blobOptimization)return Ee(r,new Uint8Array(e));if(ArrayBuffer.isView(e))return Ee(r,new Uint8Array(e.buffer));let n=new Rt(new ArrayBuffer(r.byteLength+e.length),0);n.write(r);for(let i of e){let s=this._type.encodeValue(i);n.write(new Uint8Array(s))}return n.buffer}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=ze(-19),n=this._type.encodeType(e);e.add(this,Ee(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a vector type");let i=Number(Ge(e));if(this._type instanceof Kt){if(this._type._bits==8)return new Uint8Array(e.read(i));if(this._type._bits==16)return new Uint16Array(e.read(i*2));if(this._type._bits==32)return new Uint32Array(e.read(i*4));if(this._type._bits==64)return new BigUint64Array(e.read(i*8))}if(this._type instanceof ar){if(this._type._bits==8)return new Int8Array(e.read(i));if(this._type._bits==16)return new Int16Array(e.read(i*2));if(this._type._bits==32)return new Int32Array(e.read(i*4));if(this._type._bits==64)return new BigInt64Array(e.read(i*8))}let s=[];for(let o=0;o<i;o++)s.push(this._type.decodeValue(e,n._type));return s}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(e){return"vec {"+e.map(n=>this._type.valueToString(n)).join("; ")+"}"}},dn=class t extends Wt{constructor(e){super(),this._type=e}accept(e,r){return e.visitOpt(this,this._type,r)}covariant(e){try{if(Array.isArray(e)&&(e.length===0||e.length===1&&this._type.covariant(e[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}
6
6
 
7
- -> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return e.length===0?new Uint8Array([0]):Ee(new Uint8Array([1]),this._type.encodeValue(e[0]))}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=Ye(-18),n=this._type.encodeType(e);e.add(this,Ee(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not an option type");switch(xr(e)){case 0:return[];case 1:return[this._type.decodeValue(e,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(e){return e.length===0?"null":`opt ${this._type.valueToString(e[0])}`}},Gn=class t extends Wt{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>Ot(r[0])-Ot(n[0]))}accept(e,r){return e.visitRecord(this,this._fields,r)}tryAsTuple(){let e=[];for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(n!==`_${r}_`)return null;e.push(i)}return e}covariant(e){if(typeof e=="object"&&this._fields.every(([r,n])=>{if(!e.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
7
+ -> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return e.length===0?new Uint8Array([0]):Ee(new Uint8Array([1]),this._type.encodeValue(e[0]))}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=ze(-18),n=this._type.encodeType(e);e.add(this,Ee(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not an option type");switch(br(e)){case 0:return[];case 1:return[this._type.decodeValue(e,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(e){return e.length===0?"null":`opt ${this._type.valueToString(e[0])}`}},Gn=class t extends Wt{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>Ot(r[0])-Ot(n[0]))}accept(e,r){return e.visitRecord(this,this._fields,r)}tryAsTuple(){let e=[];for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(n!==`_${r}_`)return null;e.push(i)}return e}covariant(e){if(typeof e=="object"&&this._fields.every(([r,n])=>{if(!e.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
8
8
 
9
- field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=this._fields.map(([i])=>e[i]),n=jn(this._fields,r,([,i],s)=>i.encodeValue(s));return Ee(...n)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=Ye(-20),n=Oe(this._fields.length),i=this._fields.map(([s,o])=>Ee(Oe(Ot(s)),o.encodeType(e)));e.add(this,Ee(r,n,Ee(...i)))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a record type");let i={},s=0,o=0;for(;o<n._fields.length;){let[a,c]=n._fields[o];if(s>=this._fields.length){c.decodeValue(e,c),o++;continue}let[l,h]=this._fields[s],d=Ot(this._fields[s][0]),w=Ot(a);if(d===w)i[l]=h.decodeValue(e,c),s++,o++;else if(w>d)if(h instanceof dn||h instanceof hn)i[l]=[],s++;else throw new Error("Cannot find required field "+l);else c.decodeValue(e,c),o++}for(let[a,c]of this._fields.slice(s))if(c instanceof dn||c instanceof hn)i[a]=[];else throw new Error("Cannot find required field "+a);return i}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(e){let r=this._fields.map(([i])=>e[i]);return`record {${jn(this._fields,r,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}},Xi=class t extends Gn{constructor(e){let r={};e.forEach((n,i)=>r["_"+i+"_"]=n),super(r),this._components=e}accept(e,r){return e.visitTuple(this,this._components,r)}covariant(e){if(Array.isArray(e)&&e.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(e[n])}catch(i){throw new Error(`Invalid ${this.display()} argument:
9
+ field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=this._fields.map(([i])=>e[i]),n=jn(this._fields,r,([,i],s)=>i.encodeValue(s));return Ee(...n)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=ze(-20),n=Oe(this._fields.length),i=this._fields.map(([s,o])=>Ee(Oe(Ot(s)),o.encodeType(e)));e.add(this,Ee(r,n,Ee(...i)))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a record type");let i={},s=0,o=0;for(;o<n._fields.length;){let[a,c]=n._fields[o];if(s>=this._fields.length){c.decodeValue(e,c),o++;continue}let[l,h]=this._fields[s],d=Ot(this._fields[s][0]),w=Ot(a);if(d===w)i[l]=h.decodeValue(e,c),s++,o++;else if(w>d)if(h instanceof dn||h instanceof hn)i[l]=[],s++;else throw new Error("Cannot find required field "+l);else c.decodeValue(e,c),o++}for(let[a,c]of this._fields.slice(s))if(c instanceof dn||c instanceof hn)i[a]=[];else throw new Error("Cannot find required field "+a);return i}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(e){let r=this._fields.map(([i])=>e[i]);return`record {${jn(this._fields,r,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}},Ji=class t extends Gn{constructor(e){let r={};e.forEach((n,i)=>r["_"+i+"_"]=n),super(r),this._components=e}accept(e,r){return e.visitTuple(this,this._components,r)}covariant(e){if(Array.isArray(e)&&e.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(e[n])}catch(i){throw new Error(`Invalid ${this.display()} argument:
10
10
 
11
- index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=jn(this._components,e,(n,i)=>n.encodeValue(i));return Ee(...r)}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let i=[];for(let[s,o]of n._components.entries())s>=this._components.length?o.decodeValue(e,o):i.push(this._components[s].decodeValue(e,o));return i}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(e){return`record {${jn(this._components,e,(n,i)=>n.valueToString(i)).join("; ")}}`}},Ji=class t extends Wt{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>Ot(r[0])-Ot(n[0]))}accept(e,r){return e.visitVariant(this,this._fields,r)}covariant(e){if(typeof e=="object"&&Object.entries(e).length===1&&this._fields.every(([r,n])=>{try{return!e.hasOwnProperty(r)||n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
11
+ index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=jn(this._components,e,(n,i)=>n.encodeValue(i));return Ee(...r)}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let i=[];for(let[s,o]of n._components.entries())s>=this._components.length?o.decodeValue(e,o):i.push(this._components[s].decodeValue(e,o));return i}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(e){return`record {${jn(this._components,e,(n,i)=>n.valueToString(i)).join("; ")}}`}},Qi=class t extends Wt{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>Ot(r[0])-Ot(n[0]))}accept(e,r){return e.visitVariant(this,this._fields,r)}covariant(e){if(typeof e=="object"&&Object.entries(e).length===1&&this._fields.every(([r,n])=>{try{return!e.hasOwnProperty(r)||n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
12
12
 
13
- variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(e.hasOwnProperty(n)){let s=Oe(r),o=i.encodeValue(e[n]);return Ee(s,o)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,s])=>{s.buildTypeTable(e)});let r=Ye(-21),n=Oe(this._fields.length),i=this._fields.map(([s,o])=>Ee(Oe(Ot(s)),o.encodeType(e)));e.add(this,Ee(r,n,...i))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a variant type");let i=Number(Ge(e));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,o]=n._fields[i];for(let[a,c]of this._fields)if(Ot(s)===Ot(a)){let l=c.decodeValue(e,o);return{[a]:l}}throw new Error("Cannot find field hash "+s)}get name(){return`variant {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([r,n])=>r+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(e){for(let[r,n]of this._fields)if(e.hasOwnProperty(r)){let i=n.valueToString(e[r]);return i==="null"?`variant {${r}}`:`variant {${r}=${i}}`}throw new Error("Variant has no data: "+e)}},Er=class t extends Wt{constructor(){super(...arguments),this._id=t._counter++,this._type=void 0}accept(e,r){if(!this._type)throw Error("Recursive type uninitialized.");return e.visitRec(this,this._type,r)}fill(e){this._type=e}getType(){return this._type}covariant(e){if(this._type&&this._type.covariant(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(e)}_buildTypeTableImpl(e){if(!this._type)throw Error("Recursive type uninitialized.");e.add(this,new Uint8Array([])),this._type.buildTypeTable(e),e.merge(this,this._type.name)}decodeValue(e,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(e,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(e)}};Er._counter=0;Qi=class extends ht{accept(e,r){return e.visitPrincipal(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=Oe(r.byteLength);return Ee(new Uint8Array([1]),n,r)}encodeType(){return Ye(-24)}decodeValue(e,r){return this.checkType(r),Ho(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}},Yn=class extends Wt{constructor(e,r,n=[]){super(),this.argTypes=e,this.retTypes=r,this.annotations=n}static argsToString(e,r){if(e.length!==r.length)throw new Error("arity mismatch");return"("+e.map((n,i)=>n.valueToString(r[i])).join(", ")+")"}accept(e,r){return e.visitFunc(this,r)}covariant(e){if(Array.isArray(e)&&e.length===2&&e[0]&&e[0]._isPrincipal&&typeof e[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue([e,r]){let n=e.toUint8Array(),i=Oe(n.byteLength),s=Ee(new Uint8Array([1]),i,n),o=new TextEncoder().encode(r),a=Oe(o.byteLength);return Ee(new Uint8Array([1]),s,a,o)}_buildTypeTableImpl(e){this.argTypes.forEach(l=>l.buildTypeTable(e)),this.retTypes.forEach(l=>l.buildTypeTable(e));let r=Ye(-22),n=Oe(this.argTypes.length),i=Ee(...this.argTypes.map(l=>l.encodeType(e))),s=Oe(this.retTypes.length),o=Ee(...this.retTypes.map(l=>l.encodeType(e))),a=Oe(this.annotations.length),c=Ee(...this.annotations.map(l=>this.encodeAnnotation(l)));e.add(this,Ee(r,n,i,s,o,a,c))}decodeValue(e){if(xr(e)!==1)throw new Error("Cannot decode function reference");let n=Ho(e),i=Number(Ge(e)),s=_r(e,i),a=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,a]}get name(){let e=this.argTypes.map(i=>i.name).join(", "),r=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${e}) -> (${r})${n}`}valueToString([e,r]){return`func "${e.toText()}".${r}`}display(){let e=this.argTypes.map(i=>i.display()).join(", "),r=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${e}) \u2192 (${r})${n}`}encodeAnnotation(e){if(e==="query")return new Uint8Array([1]);if(e==="oneway")return new Uint8Array([2]);if(e==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}},Li=class extends Wt{constructor(e){super(),this._fields=Object.entries(e).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(e,r){return e.visitService(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=Oe(r.length);return Ee(new Uint8Array([1]),n,r)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=Ye(-23),n=Oe(this._fields.length),i=this._fields.map(([s,o])=>{let a=new TextEncoder().encode(s),c=Oe(a.length);return Ee(c,a,o.encodeType(e))});e.add(this,Ee(r,n,...i))}decodeValue(e){return Ho(e)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};hu=new ji,du=new hn,jh=new Hi,pu=new Gi,mu=new Yi,yu=new zi,gu=new Ki,wu=new Wi,bu=new Hn(32),xu=new Hn(64),_u=new ar(8),Eu=new ar(16),vu=new ar(32),Bu=new ar(64),Au=new Kt(8),Tu=new Kt(16),Su=new Kt(32),Nu=new Kt(64),Ru=new Qi});var Yo=he(()=>{});var qu=he(()=>{Go();yt();Yo()});var $u=he(()=>{});var zn=he(()=>{qu();Yo();Go();Co();Vo();Ci();$u()});var of={};Un(of,{Buffer:()=>X,INSPECT_MAX_BYTES:()=>Ku,SlowBuffer:()=>Dh,isBuffer:()=>nf,kMaxLength:()=>Zh});function Gu(){Ko=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,r=t.length;e<r;++e)Zt[e]=t[e],vt[t.charCodeAt(e)]=e;vt[45]=62,vt[95]=63}function Yh(t){Ko||Gu();var e,r,n,i,s,o,a=t.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s=t[a-2]==="="?2:t[a-1]==="="?1:0,o=new Gh(a*3/4-s),n=s>0?a-4:a;var c=0;for(e=0,r=0;e<n;e+=4,r+=3)i=vt[t.charCodeAt(e)]<<18|vt[t.charCodeAt(e+1)]<<12|vt[t.charCodeAt(e+2)]<<6|vt[t.charCodeAt(e+3)],o[c++]=i>>16&255,o[c++]=i>>8&255,o[c++]=i&255;return s===2?(i=vt[t.charCodeAt(e)]<<2|vt[t.charCodeAt(e+1)]>>4,o[c++]=i&255):s===1&&(i=vt[t.charCodeAt(e)]<<10|vt[t.charCodeAt(e+1)]<<4|vt[t.charCodeAt(e+2)]>>2,o[c++]=i>>8&255,o[c++]=i&255),o}function zh(t){return Zt[t>>18&63]+Zt[t>>12&63]+Zt[t>>6&63]+Zt[t&63]}function Kh(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16)+(t[s+1]<<8)+t[s+2],i.push(zh(n));return i.join("")}function Vu(t){Ko||Gu();for(var e,r=t.length,n=r%3,i="",s=[],o=16383,a=0,c=r-n;a<c;a+=o)s.push(Kh(t,a,a+o>c?c:a+o));return n===1?(e=t[r-1],i+=Zt[e>>2],i+=Zt[e<<4&63],i+="=="):n===2&&(e=(t[r-2]<<8)+t[r-1],i+=Zt[e>>10],i+=Zt[e>>4&63],i+=Zt[e<<2&63],i+="="),s.push(i),s.join("")}function ts(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,l=c>>1,h=-7,d=r?i-1:0,w=r?-1:1,b=t[e+d];for(d+=w,s=b&(1<<-h)-1,b>>=-h,h+=a;h>0;s=s*256+t[e+d],d+=w,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=o*256+t[e+d],d+=w,h-=8);if(s===0)s=1-l;else{if(s===c)return o?NaN:(b?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-l}return(b?-1:1)*o*Math.pow(2,s-n)}function Yu(t,e,r,n,i,s){var o,a,c,l=s*8-i-1,h=(1<<l)-1,d=h>>1,w=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=n?0:s-1,f=n?1:-1,S=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+d>=1?e+=w/c:e+=w*Math.pow(2,1-d),e*c>=2&&(o++,c/=2),o+d>=h?(a=0,o=h):o+d>=1?(a=(e*c-1)*Math.pow(2,i),o=o+d):(a=e*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;t[r+b]=a&255,b+=f,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;t[r+b]=o&255,b+=f,o/=256,l-=8);t[r+b-f]|=S*128}function Di(){return X.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function cr(t,e){if(Di()<e)throw new RangeError("Invalid typed array length");return X.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=X.prototype):(t===null&&(t=new X(e)),t.length=e),t}function X(t,e,r){if(!X.TYPED_ARRAY_SUPPORT&&!(this instanceof X))return new X(t,e,r);if(typeof t=="number"){if(typeof e=="string")throw new Error("If encoding is specified then the first argument must be a string");return Wo(this,t)}return Wu(this,t,e,r)}function Wu(t,e,r,n){if(typeof e=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer?Qh(t,e,r,n):typeof e=="string"?Jh(t,e,r):Lh(t,e)}function Zu(t){if(typeof t!="number")throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function Xh(t,e,r,n){return Zu(e),e<=0?cr(t,e):r!==void 0?typeof n=="string"?cr(t,e).fill(r,n):cr(t,e).fill(r):cr(t,e)}function Wo(t,e){if(Zu(e),t=cr(t,e<0?0:Zo(e)|0),!X.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function Jh(t,e,r){if((typeof r!="string"||r==="")&&(r="utf8"),!X.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=Xu(e,r)|0;t=cr(t,n);var i=t.write(e,r);return i!==n&&(t=t.slice(0,i)),t}function zo(t,e){var r=e.length<0?0:Zo(e.length)|0;t=cr(t,r);for(var n=0;n<r;n+=1)t[n]=e[n]&255;return t}function Qh(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return r===void 0&&n===void 0?e=new Uint8Array(e):n===void 0?e=new Uint8Array(e,r):e=new Uint8Array(e,r,n),X.TYPED_ARRAY_SUPPORT?(t=e,t.__proto__=X.prototype):t=zo(t,e),t}function Lh(t,e){if(Xt(e)){var r=Zo(e.length)|0;return t=cr(t,r),t.length===0||e.copy(t,0,0,r),t}if(e){if(typeof ArrayBuffer<"u"&&e.buffer instanceof ArrayBuffer||"length"in e)return typeof e.length!="number"||wd(e.length)?cr(t,0):zo(t,e);if(e.type==="Buffer"&&zu(e.data))return zo(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Zo(t){if(t>=Di())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Di().toString(16)+" bytes");return t|0}function Dh(t){return+t!=t&&(t=0),X.alloc(+t)}function Xt(t){return!!(t!=null&&t._isBuffer)}function Xu(t,e){if(Xt(t))return t.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;typeof t!="string"&&(t=""+t);var r=t.length;if(r===0)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return es(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return rf(t).length;default:if(n)return es(t).length;e=(""+e).toLowerCase(),n=!0}}function ed(t,e,r){var n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return fd(this,e,r);case"utf8":case"utf-8":return Lu(this,e,r);case"ascii":return cd(this,e,r);case"latin1":case"binary":return ud(this,e,r);case"base64":return od(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ld(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function Gr(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function Ju(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=X.from(e,n)),Xt(e))return e.length===0?-1:ju(t,e,r,n,i);if(typeof e=="number")return e=e&255,X.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):ju(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ju(t,e,r,n,i){var s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(b,f){return s===1?b[f]:b.readUInt16BE(f*s)}var l;if(i){var h=-1;for(l=r;l<o;l++)if(c(t,l)===c(e,h===-1?0:l-h)){if(h===-1&&(h=l),l-h+1===a)return h*s}else h!==-1&&(l-=l-h),h=-1}else for(r+a>o&&(r=o-a),l=r;l>=0;l--){for(var d=!0,w=0;w<a;w++)if(c(t,l+w)!==c(e,w)){d=!1;break}if(d)return l}return-1}function td(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var s=e.length;if(s%2!==0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o<n;++o){var a=parseInt(e.substr(o*2,2),16);if(isNaN(a))return o;t[r+o]=a}return o}function rd(t,e,r,n){return is(es(e,t.length-r),t,r,n)}function Qu(t,e,r,n){return is(yd(e),t,r,n)}function nd(t,e,r,n){return Qu(t,e,r,n)}function id(t,e,r,n){return is(rf(e),t,r,n)}function sd(t,e,r,n){return is(gd(e,t.length-r),t,r,n)}function od(t,e,r){return e===0&&r===t.length?Vu(t):Vu(t.slice(e,r))}function Lu(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){var c,l,h,d;switch(a){case 1:s<128&&(o=s);break;case 2:c=t[i+1],(c&192)===128&&(d=(s&31)<<6|c&63,d>127&&(o=d));break;case 3:c=t[i+1],l=t[i+2],(c&192)===128&&(l&192)===128&&(d=(s&15)<<12|(c&63)<<6|l&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:c=t[i+1],l=t[i+2],h=t[i+3],(c&192)===128&&(l&192)===128&&(h&192)===128&&(d=(s&15)<<18|(c&63)<<12|(l&63)<<6|h&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return ad(n)}function ad(t){var e=t.length;if(e<=Hu)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Hu));return r}function cd(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function ud(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function fd(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",s=e;s<r;++s)i+=md(t[s]);return i}function ld(t,e,r){for(var n=t.slice(e,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}function Qe(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function dt(t,e,r,n,i,s){if(!Xt(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function rs(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,s=Math.min(t.length-r,2);i<s;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}function ns(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,s=Math.min(t.length-r,4);i<s;++i)t[r+i]=e>>>(n?i:3-i)*8&255}function Du(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ef(t,e,r,n,i){return i||Du(t,e,r,4),Yu(t,e,r,n,23,4),r+4}function tf(t,e,r,n,i){return i||Du(t,e,r,8),Yu(t,e,r,n,52,8),r+8}function dd(t){if(t=pd(t).replace(hd,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function pd(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function md(t){return t<16?"0"+t.toString(16):t.toString(16)}function es(t,e){e=e||1/0;for(var r,n=t.length,i=null,s=[],o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function yd(t){for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function gd(t,e){for(var r,n,i,s=[],o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function rf(t){return Yh(dd(t))}function is(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function wd(t){return t!==t}function nf(t){return t!=null&&(!!t._isBuffer||sf(t)||bd(t))}function sf(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function bd(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&sf(t.slice(0,0))}var Zt,vt,Gh,Ko,Wh,zu,Ku,Zh,Hu,hd,af=he(()=>{Zt=[],vt=[],Gh=typeof Uint8Array<"u"?Uint8Array:Array,Ko=!1;Wh={}.toString,zu=Array.isArray||function(t){return Wh.call(t)=="[object Array]"};Ku=50;X.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;Zh=Di();X.poolSize=8192;X._augment=function(t){return t.__proto__=X.prototype,t};X.from=function(t,e,r){return Wu(null,t,e,r)};X.TYPED_ARRAY_SUPPORT&&(X.prototype.__proto__=Uint8Array.prototype,X.__proto__=Uint8Array);X.alloc=function(t,e,r){return Xh(null,t,e,r)};X.allocUnsafe=function(t){return Wo(null,t)};X.allocUnsafeSlow=function(t){return Wo(null,t)};X.isBuffer=nf;X.compare=function(e,r){if(!Xt(e)||!Xt(r))throw new TypeError("Arguments must be Buffers");if(e===r)return 0;for(var n=e.length,i=r.length,s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==r[s]){n=e[s],i=r[s];break}return n<i?-1:i<n?1:0};X.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};X.concat=function(e,r){if(!zu(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return X.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;var i=X.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){var o=e[n];if(!Xt(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,s),s+=o.length}return i};X.byteLength=Xu;X.prototype._isBuffer=!0;X.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<e;r+=2)Gr(this,r,r+1);return this};X.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<e;r+=4)Gr(this,r,r+3),Gr(this,r+1,r+2);return this};X.prototype.swap64=function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<e;r+=8)Gr(this,r,r+7),Gr(this,r+1,r+6),Gr(this,r+2,r+5),Gr(this,r+3,r+4);return this};X.prototype.toString=function(){var e=this.length|0;return e===0?"":arguments.length===0?Lu(this,0,e):ed.apply(this,arguments)};X.prototype.equals=function(e){if(!Xt(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:X.compare(this,e)===0};X.prototype.inspect=function(){var e="",r=Ku;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"};X.prototype.compare=function(e,r,n,i,s){if(!Xt(e))throw new TypeError("Argument must be a Buffer");if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;for(var o=s-i,a=n-r,c=Math.min(o,a),l=this.slice(i,s),h=e.slice(r,n),d=0;d<c;++d)if(l[d]!==h[d]){o=l[d],a=h[d];break}return o<a?-1:a<o?1:0};X.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};X.prototype.indexOf=function(e,r,n){return Ju(this,e,r,n,!0)};X.prototype.lastIndexOf=function(e,r,n){return Ju(this,e,r,n,!1)};X.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r|0,isFinite(n)?(n=n|0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s=this.length-r;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return td(this,e,r,n);case"utf8":case"utf-8":return rd(this,e,r,n);case"ascii":return Qu(this,e,r,n);case"latin1":case"binary":return nd(this,e,r,n);case"base64":return id(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return sd(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};X.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};Hu=4096;X.prototype.slice=function(e,r){var n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);var i;if(X.TYPED_ARRAY_SUPPORT)i=this.subarray(e,r),i.__proto__=X.prototype;else{var s=r-e;i=new X(s,void 0);for(var o=0;o<s;++o)i[o]=this[o+e]}return i};X.prototype.readUIntLE=function(e,r,n){e=e|0,r=r|0,n||Qe(e,r,this.length);for(var i=this[e],s=1,o=0;++o<r&&(s*=256);)i+=this[e+o]*s;return i};X.prototype.readUIntBE=function(e,r,n){e=e|0,r=r|0,n||Qe(e,r,this.length);for(var i=this[e+--r],s=1;r>0&&(s*=256);)i+=this[e+--r]*s;return i};X.prototype.readUInt8=function(e,r){return r||Qe(e,1,this.length),this[e]};X.prototype.readUInt16LE=function(e,r){return r||Qe(e,2,this.length),this[e]|this[e+1]<<8};X.prototype.readUInt16BE=function(e,r){return r||Qe(e,2,this.length),this[e]<<8|this[e+1]};X.prototype.readUInt32LE=function(e,r){return r||Qe(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};X.prototype.readUInt32BE=function(e,r){return r||Qe(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};X.prototype.readIntLE=function(e,r,n){e=e|0,r=r|0,n||Qe(e,r,this.length);for(var i=this[e],s=1,o=0;++o<r&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};X.prototype.readIntBE=function(e,r,n){e=e|0,r=r|0,n||Qe(e,r,this.length);for(var i=r,s=1,o=this[e+--i];i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};X.prototype.readInt8=function(e,r){return r||Qe(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};X.prototype.readInt16LE=function(e,r){r||Qe(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};X.prototype.readInt16BE=function(e,r){r||Qe(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};X.prototype.readInt32LE=function(e,r){return r||Qe(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};X.prototype.readInt32BE=function(e,r){return r||Qe(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};X.prototype.readFloatLE=function(e,r){return r||Qe(e,4,this.length),ts(this,e,!0,23,4)};X.prototype.readFloatBE=function(e,r){return r||Qe(e,4,this.length),ts(this,e,!1,23,4)};X.prototype.readDoubleLE=function(e,r){return r||Qe(e,8,this.length),ts(this,e,!0,52,8)};X.prototype.readDoubleBE=function(e,r){return r||Qe(e,8,this.length),ts(this,e,!1,52,8)};X.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r|0,n=n|0,!i){var s=Math.pow(2,8*n)-1;dt(this,e,r,n,s,0)}var o=1,a=0;for(this[r]=e&255;++a<n&&(o*=256);)this[r+a]=e/o&255;return r+n};X.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r|0,n=n|0,!i){var s=Math.pow(2,8*n)-1;dt(this,e,r,n,s,0)}var o=n-1,a=1;for(this[r+o]=e&255;--o>=0&&(a*=256);)this[r+o]=e/a&255;return r+n};X.prototype.writeUInt8=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,1,255,0),X.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[r]=e&255,r+1};X.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,2,65535,0),X.TYPED_ARRAY_SUPPORT?(this[r]=e&255,this[r+1]=e>>>8):rs(this,e,r,!0),r+2};X.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,2,65535,0),X.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=e&255):rs(this,e,r,!1),r+2};X.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,4,4294967295,0),X.TYPED_ARRAY_SUPPORT?(this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255):ns(this,e,r,!0),r+4};X.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,4,4294967295,0),X.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255):ns(this,e,r,!1),r+4};X.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r|0,!i){var s=Math.pow(2,8*n-1);dt(this,e,r,n,s-1,-s)}var o=0,a=1,c=0;for(this[r]=e&255;++o<n&&(a*=256);)e<0&&c===0&&this[r+o-1]!==0&&(c=1),this[r+o]=(e/a>>0)-c&255;return r+n};X.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r|0,!i){var s=Math.pow(2,8*n-1);dt(this,e,r,n,s-1,-s)}var o=n-1,a=1,c=0;for(this[r+o]=e&255;--o>=0&&(a*=256);)e<0&&c===0&&this[r+o+1]!==0&&(c=1),this[r+o]=(e/a>>0)-c&255;return r+n};X.prototype.writeInt8=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,1,127,-128),X.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[r]=e&255,r+1};X.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,2,32767,-32768),X.TYPED_ARRAY_SUPPORT?(this[r]=e&255,this[r+1]=e>>>8):rs(this,e,r,!0),r+2};X.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,2,32767,-32768),X.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=e&255):rs(this,e,r,!1),r+2};X.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,4,2147483647,-2147483648),X.TYPED_ARRAY_SUPPORT?(this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24):ns(this,e,r,!0),r+4};X.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),X.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255):ns(this,e,r,!1),r+4};X.prototype.writeFloatLE=function(e,r,n){return ef(this,e,r,!0,n)};X.prototype.writeFloatBE=function(e,r,n){return ef(this,e,r,!1,n)};X.prototype.writeDoubleLE=function(e,r,n){return tf(this,e,r,!0,n)};X.prototype.writeDoubleBE=function(e,r,n){return tf(this,e,r,!1,n)};X.prototype.copy=function(e,r,n,i){if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);var s=i-n,o;if(this===e&&n<r&&r<i)for(o=s-1;o>=0;--o)e[o+r]=this[o+n];else if(s<1e3||!X.TYPED_ARRAY_SUPPORT)for(o=0;o<s;++o)e[o+r]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+s),r);return s};X.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),e.length===1){var s=e.charCodeAt(0);s<256&&(e=s)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!X.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof e=="number"&&(e=e&255);if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);var o;if(typeof e=="number")for(o=r;o<n;++o)this[o]=e;else{var a=Xt(e)?e:es(new X(e,i).toString()),c=a.length;for(o=0;o<n-r;++o)this[o+r]=a[o%c]}return this};hd=/[^+\/0-9A-Za-z-_]/g});var Kn=He((by,ss)=>{var Yr=(af(),Kl(of));if(Yr&&Yr.default){ss.exports=Yr.default;for(let t in Yr)ss.exports[t]=Yr[t]}else Yr&&(ss.exports=Yr)});var Wn=He((cf,os)=>{(function(t){"use strict";var e,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",a=1e14,c=14,l=9007199254740991,h=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],d=1e7,w=1e9;function b(E){var H,z,Z,C=P.prototype={constructor:P,toString:null,valueOf:null},ie=new P(1),re=20,ee=4,g=-7,B=21,$=-1e7,F=1e7,U=!1,G=1,J=0,fe={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},ce="0123456789abcdefghijklmnopqrstuvwxyz",W=!0;function P(u,p){var y,T,v,A,M,x,N,k,I=this;if(!(I instanceof P))return new P(u,p);if(p==null){if(u&&u._isBigNumber===!0){I.s=u.s,!u.c||u.e>F?I.c=I.e=null:u.e<$?I.c=[I.e=0]:(I.e=u.e,I.c=u.c.slice());return}if((x=typeof u=="number")&&u*0==0){if(I.s=1/u<0?(u=-u,-1):1,u===~~u){for(A=0,M=u;M>=10;M/=10,A++);A>F?I.c=I.e=null:(I.e=A,I.c=[u]);return}k=String(u)}else{if(!r.test(k=String(u)))return Z(I,k,x);I.s=k.charCodeAt(0)==45?(k=k.slice(1),-1):1}(A=k.indexOf("."))>-1&&(k=k.replace(".","")),(M=k.search(/e/i))>0?(A<0&&(A=M),A+=+k.slice(M+1),k=k.substring(0,M)):A<0&&(A=k.length)}else{if(O(p,2,ce.length,"Base"),p==10&&W)return I=new P(u),le(I,re+I.e+1,ee);if(k=String(u),x=typeof u=="number"){if(u*0!=0)return Z(I,k,x,p);if(I.s=1/u<0?(k=k.slice(1),-1):1,P.DEBUG&&k.replace(/^0\.0*|\./,"").length>15)throw Error(o+u)}else I.s=k.charCodeAt(0)===45?(k=k.slice(1),-1):1;for(y=ce.slice(0,p),A=M=0,N=k.length;M<N;M++)if(y.indexOf(T=k.charAt(M))<0){if(T=="."){if(M>A){A=N;continue}}else if(!v&&(k==k.toUpperCase()&&(k=k.toLowerCase())||k==k.toLowerCase()&&(k=k.toUpperCase()))){v=!0,M=-1,A=0;continue}return Z(I,String(u),x,p)}x=!1,k=z(k,p,10,I.s),(A=k.indexOf("."))>-1?k=k.replace(".",""):A=k.length}for(M=0;k.charCodeAt(M)===48;M++);for(N=k.length;k.charCodeAt(--N)===48;);if(k=k.slice(M,++N)){if(N-=M,x&&P.DEBUG&&N>15&&(u>l||u!==i(u)))throw Error(o+I.s*u);if((A=A-M-1)>F)I.c=I.e=null;else if(A<$)I.c=[I.e=0];else{if(I.e=A,I.c=[],M=(A+1)%c,A<0&&(M+=c),M<N){for(M&&I.c.push(+k.slice(0,M)),N-=c;M<N;)I.c.push(+k.slice(M,M+=c));M=c-(k=k.slice(M)).length}else M-=N;for(;M--;k+="0");I.c.push(+k)}}else I.c=[I.e=0]}P.clone=b,P.ROUND_UP=0,P.ROUND_DOWN=1,P.ROUND_CEIL=2,P.ROUND_FLOOR=3,P.ROUND_HALF_UP=4,P.ROUND_HALF_DOWN=5,P.ROUND_HALF_EVEN=6,P.ROUND_HALF_CEIL=7,P.ROUND_HALF_FLOOR=8,P.EUCLID=9,P.config=P.set=function(u){var p,y;if(u!=null)if(typeof u=="object"){if(u.hasOwnProperty(p="DECIMAL_PLACES")&&(y=u[p],O(y,0,w,p),re=y),u.hasOwnProperty(p="ROUNDING_MODE")&&(y=u[p],O(y,0,8,p),ee=y),u.hasOwnProperty(p="EXPONENTIAL_AT")&&(y=u[p],y&&y.pop?(O(y[0],-w,0,p),O(y[1],0,w,p),g=y[0],B=y[1]):(O(y,-w,w,p),g=-(B=y<0?-y:y))),u.hasOwnProperty(p="RANGE"))if(y=u[p],y&&y.pop)O(y[0],-w,-1,p),O(y[1],1,w,p),$=y[0],F=y[1];else if(O(y,-w,w,p),y)$=-(F=y<0?-y:y);else throw Error(s+p+" cannot be zero: "+y);if(u.hasOwnProperty(p="CRYPTO"))if(y=u[p],y===!!y)if(y)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))U=y;else throw U=!y,Error(s+"crypto unavailable");else U=y;else throw Error(s+p+" not true or false: "+y);if(u.hasOwnProperty(p="MODULO_MODE")&&(y=u[p],O(y,0,9,p),G=y),u.hasOwnProperty(p="POW_PRECISION")&&(y=u[p],O(y,0,w,p),J=y),u.hasOwnProperty(p="FORMAT"))if(y=u[p],typeof y=="object")fe=y;else throw Error(s+p+" not an object: "+y);if(u.hasOwnProperty(p="ALPHABET"))if(y=u[p],typeof y=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(y))W=y.slice(0,10)=="0123456789",ce=y;else throw Error(s+p+" invalid: "+y)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:re,ROUNDING_MODE:ee,EXPONENTIAL_AT:[g,B],RANGE:[$,F],CRYPTO:U,MODULO_MODE:G,POW_PRECISION:J,FORMAT:fe,ALPHABET:ce}},P.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!P.DEBUG)return!0;var p,y,T=u.c,v=u.e,A=u.s;e:if({}.toString.call(T)=="[object Array]"){if((A===1||A===-1)&&v>=-w&&v<=w&&v===i(v)){if(T[0]===0){if(v===0&&T.length===1)return!0;break e}if(p=(v+1)%c,p<1&&(p+=c),String(T[0]).length==p){for(p=0;p<T.length;p++)if(y=T[p],y<0||y>=a||y!==i(y))break e;if(y!==0)return!0}}}else if(T===null&&v===null&&(A===null||A===1||A===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},P.maximum=P.max=function(){return L(arguments,-1)},P.minimum=P.min=function(){return L(arguments,1)},P.random=function(){var u=9007199254740992,p=Math.random()*u&2097151?function(){return i(Math.random()*u)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(y){var T,v,A,M,x,N=0,k=[],I=new P(ie);if(y==null?y=re:O(y,0,w),M=n(y/c),U)if(crypto.getRandomValues){for(T=crypto.getRandomValues(new Uint32Array(M*=2));N<M;)x=T[N]*131072+(T[N+1]>>>11),x>=9e15?(v=crypto.getRandomValues(new Uint32Array(2)),T[N]=v[0],T[N+1]=v[1]):(k.push(x%1e14),N+=2);N=M/2}else if(crypto.randomBytes){for(T=crypto.randomBytes(M*=7);N<M;)x=(T[N]&31)*281474976710656+T[N+1]*1099511627776+T[N+2]*4294967296+T[N+3]*16777216+(T[N+4]<<16)+(T[N+5]<<8)+T[N+6],x>=9e15?crypto.randomBytes(7).copy(T,N):(k.push(x%1e14),N+=7);N=M/7}else throw U=!1,Error(s+"crypto unavailable");if(!U)for(;N<M;)x=p(),x<9e15&&(k[N++]=x%1e14);for(M=k[--N],y%=c,M&&y&&(x=h[c-y],k[N]=i(M/x)*x);k[N]===0;k.pop(),N--);if(N<0)k=[A=0];else{for(A=-1;k[0]===0;k.splice(0,1),A-=c);for(N=1,x=k[0];x>=10;x/=10,N++);N<c&&(A-=c-N)}return I.e=A,I.c=k,I}}(),P.sum=function(){for(var u=1,p=arguments,y=new P(p[0]);u<p.length;)y=y.plus(p[u++]);return y},z=function(){var u="0123456789";function p(y,T,v,A){for(var M,x=[0],N,k=0,I=y.length;k<I;){for(N=x.length;N--;x[N]*=T);for(x[0]+=A.indexOf(y.charAt(k++)),M=0;M<x.length;M++)x[M]>v-1&&(x[M+1]==null&&(x[M+1]=0),x[M+1]+=x[M]/v|0,x[M]%=v)}return x.reverse()}return function(y,T,v,A,M){var x,N,k,I,K,Q,oe,ye,ve=y.indexOf("."),Se=re,me=ee;for(ve>=0&&(I=J,J=0,y=y.replace(".",""),ye=new P(T),Q=ye.pow(y.length-ve),J=I,ye.c=p(Y(S(Q.c),Q.e,"0"),10,v,u),ye.e=ye.c.length),oe=p(y,T,v,M?(x=ce,u):(x=u,ce)),k=I=oe.length;oe[--I]==0;oe.pop());if(!oe[0])return x.charAt(0);if(ve<0?--k:(Q.c=oe,Q.e=k,Q.s=A,Q=H(Q,ye,Se,me,v),oe=Q.c,K=Q.r,k=Q.e),N=k+Se+1,ve=oe[N],I=v/2,K=K||N<0||oe[N+1]!=null,K=me<4?(ve!=null||K)&&(me==0||me==(Q.s<0?3:2)):ve>I||ve==I&&(me==4||K||me==6&&oe[N-1]&1||me==(Q.s<0?8:7)),N<1||!oe[0])y=K?Y(x.charAt(1),-Se,x.charAt(0)):x.charAt(0);else{if(oe.length=N,K)for(--v;++oe[--N]>v;)oe[N]=0,N||(++k,oe=[1].concat(oe));for(I=oe.length;!oe[--I];);for(ve=0,y="";ve<=I;y+=x.charAt(oe[ve++]));y=Y(y,k,x.charAt(0))}return y}}(),H=function(){function u(T,v,A){var M,x,N,k,I=0,K=T.length,Q=v%d,oe=v/d|0;for(T=T.slice();K--;)N=T[K]%d,k=T[K]/d|0,M=oe*N+k*Q,x=Q*N+M%d*d+I,I=(x/A|0)+(M/d|0)+oe*k,T[K]=x%A;return I&&(T=[I].concat(T)),T}function p(T,v,A,M){var x,N;if(A!=M)N=A>M?1:-1;else for(x=N=0;x<A;x++)if(T[x]!=v[x]){N=T[x]>v[x]?1:-1;break}return N}function y(T,v,A,M){for(var x=0;A--;)T[A]-=x,x=T[A]<v[A]?1:0,T[A]=x*M+T[A]-v[A];for(;!T[0]&&T.length>1;T.splice(0,1));}return function(T,v,A,M,x){var N,k,I,K,Q,oe,ye,ve,Se,me,ae,ke,Gt,ir,Cr,_t,_e,ut=T.s==v.s?1:-1,De=T.c,Ue=v.c;if(!De||!De[0]||!Ue||!Ue[0])return new P(!T.s||!v.s||(De?Ue&&De[0]==Ue[0]:!Ue)?NaN:De&&De[0]==0||!Ue?ut*0:ut/0);for(ve=new P(ut),Se=ve.c=[],k=T.e-v.e,ut=A+k+1,x||(x=a,k=f(T.e/c)-f(v.e/c),ut=ut/c|0),I=0;Ue[I]==(De[I]||0);I++);if(Ue[I]>(De[I]||0)&&k--,ut<0)Se.push(1),K=!0;else{for(ir=De.length,_t=Ue.length,I=0,ut+=2,Q=i(x/(Ue[0]+1)),Q>1&&(Ue=u(Ue,Q,x),De=u(De,Q,x),_t=Ue.length,ir=De.length),Gt=_t,me=De.slice(0,_t),ae=me.length;ae<_t;me[ae++]=0);_e=Ue.slice(),_e=[0].concat(_e),Cr=Ue[0],Ue[1]>=x/2&&Cr++;do{if(Q=0,N=p(Ue,me,_t,ae),N<0){if(ke=me[0],_t!=ae&&(ke=ke*x+(me[1]||0)),Q=i(ke/Cr),Q>1)for(Q>=x&&(Q=x-1),oe=u(Ue,Q,x),ye=oe.length,ae=me.length;p(oe,me,ye,ae)==1;)Q--,y(oe,_t<ye?_e:Ue,ye,x),ye=oe.length,N=1;else Q==0&&(N=Q=1),oe=Ue.slice(),ye=oe.length;if(ye<ae&&(oe=[0].concat(oe)),y(me,oe,ae,x),ae=me.length,N==-1)for(;p(Ue,me,_t,ae)<1;)Q++,y(me,_t<ae?_e:Ue,ae,x),ae=me.length}else N===0&&(Q++,me=[0]);Se[I++]=Q,me[0]?me[ae++]=De[Gt]||0:(me=[De[Gt]],ae=1)}while((Gt++<ir||me[0]!=null)&&ut--);K=me[0]!=null,Se[0]||Se.splice(0,1)}if(x==a){for(I=1,ut=Se[0];ut>=10;ut/=10,I++);le(ve,A+(ve.e=I+k*c-1)+1,M,K)}else ve.e=k,ve.r=+K;return ve}}();function m(u,p,y,T){var v,A,M,x,N;if(y==null?y=ee:O(y,0,8),!u.c)return u.toString();if(v=u.c[0],M=u.e,p==null)N=S(u.c),N=T==1||T==2&&(M<=g||M>=B)?q(N,M):Y(N,M,"0");else if(u=le(new P(u),p,y),A=u.e,N=S(u.c),x=N.length,T==1||T==2&&(p<=A||A<=g)){for(;x<p;N+="0",x++);N=q(N,A)}else if(p-=M,N=Y(N,A,"0"),A+1>x){if(--p>0)for(N+=".";p--;N+="0");}else if(p+=A-x,p>0)for(A+1==x&&(N+=".");p--;N+="0");return u.s<0&&v?"-"+N:N}function L(u,p){for(var y,T,v=1,A=new P(u[0]);v<u.length;v++)T=new P(u[v]),(!T.s||(y=R(A,T))===p||y===0&&A.s===p)&&(A=T);return A}function te(u,p,y){for(var T=1,v=p.length;!p[--v];p.pop());for(v=p[0];v>=10;v/=10,T++);return(y=T+y*c-1)>F?u.c=u.e=null:y<$?u.c=[u.e=0]:(u.e=y,u.c=p),u}Z=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,p=/^([^.]+)\.$/,y=/^\.([^.]+)$/,T=/^-?(Infinity|NaN)$/,v=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(A,M,x,N){var k,I=x?M:M.replace(v,"");if(T.test(I))A.s=isNaN(I)?null:I<0?-1:1;else{if(!x&&(I=I.replace(u,function(K,Q,oe){return k=(oe=oe.toLowerCase())=="x"?16:oe=="b"?2:8,!N||N==k?Q:K}),N&&(k=N,I=I.replace(p,"$1").replace(y,"0.$1")),M!=I))return new P(I,k);if(P.DEBUG)throw Error(s+"Not a"+(N?" base "+N:"")+" number: "+M);A.s=null}A.c=A.e=null}}();function le(u,p,y,T){var v,A,M,x,N,k,I,K=u.c,Q=h;if(K){e:{for(v=1,x=K[0];x>=10;x/=10,v++);if(A=p-v,A<0)A+=c,M=p,N=K[k=0],I=i(N/Q[v-M-1]%10);else if(k=n((A+1)/c),k>=K.length)if(T){for(;K.length<=k;K.push(0));N=I=0,v=1,A%=c,M=A-c+1}else break e;else{for(N=x=K[k],v=1;x>=10;x/=10,v++);A%=c,M=A-c+v,I=M<0?0:i(N/Q[v-M-1]%10)}if(T=T||p<0||K[k+1]!=null||(M<0?N:N%Q[v-M-1]),T=y<4?(I||T)&&(y==0||y==(u.s<0?3:2)):I>5||I==5&&(y==4||T||y==6&&(A>0?M>0?N/Q[v-M]:0:K[k-1])%10&1||y==(u.s<0?8:7)),p<1||!K[0])return K.length=0,T?(p-=u.e+1,K[0]=Q[(c-p%c)%c],u.e=-p||0):K[0]=u.e=0,u;if(A==0?(K.length=k,x=1,k--):(K.length=k+1,x=Q[c-A],K[k]=M>0?i(N/Q[v-M]%Q[M])*x:0),T)for(;;)if(k==0){for(A=1,M=K[0];M>=10;M/=10,A++);for(M=K[0]+=x,x=1;M>=10;M/=10,x++);A!=x&&(u.e++,K[0]==a&&(K[0]=1));break}else{if(K[k]+=x,K[k]!=a)break;K[k--]=0,x=1}for(A=K.length;K[--A]===0;K.pop());}u.e>F?u.c=u.e=null:u.e<$&&(u.c=[u.e=0])}return u}function D(u){var p,y=u.e;return y===null?u.toString():(p=S(u.c),p=y<=g||y>=B?q(p,y):Y(p,y,"0"),u.s<0?"-"+p:p)}return C.absoluteValue=C.abs=function(){var u=new P(this);return u.s<0&&(u.s=1),u},C.comparedTo=function(u,p){return R(this,new P(u,p))},C.decimalPlaces=C.dp=function(u,p){var y,T,v,A=this;if(u!=null)return O(u,0,w),p==null?p=ee:O(p,0,8),le(new P(A),u+A.e+1,p);if(!(y=A.c))return null;if(T=((v=y.length-1)-f(this.e/c))*c,v=y[v])for(;v%10==0;v/=10,T--);return T<0&&(T=0),T},C.dividedBy=C.div=function(u,p){return H(this,new P(u,p),re,ee)},C.dividedToIntegerBy=C.idiv=function(u,p){return H(this,new P(u,p),0,1)},C.exponentiatedBy=C.pow=function(u,p){var y,T,v,A,M,x,N,k,I,K=this;if(u=new P(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+D(u));if(p!=null&&(p=new P(p)),x=u.e>14,!K.c||!K.c[0]||K.c[0]==1&&!K.e&&K.c.length==1||!u.c||!u.c[0])return I=new P(Math.pow(+D(K),x?u.s*(2-V(u)):+D(u))),p?I.mod(p):I;if(N=u.s<0,p){if(p.c?!p.c[0]:!p.s)return new P(NaN);T=!N&&K.isInteger()&&p.isInteger(),T&&(K=K.mod(p))}else{if(u.e>9&&(K.e>0||K.e<-1||(K.e==0?K.c[0]>1||x&&K.c[1]>=24e7:K.c[0]<8e13||x&&K.c[0]<=9999975e7)))return A=K.s<0&&V(u)?-0:0,K.e>-1&&(A=1/A),new P(N?1/A:A);J&&(A=n(J/c+2))}for(x?(y=new P(.5),N&&(u.s=1),k=V(u)):(v=Math.abs(+D(u)),k=v%2),I=new P(ie);;){if(k){if(I=I.times(K),!I.c)break;A?I.c.length>A&&(I.c.length=A):T&&(I=I.mod(p))}if(v){if(v=i(v/2),v===0)break;k=v%2}else if(u=u.times(y),le(u,u.e+1,1),u.e>14)k=V(u);else{if(v=+D(u),v===0)break;k=v%2}K=K.times(K),A?K.c&&K.c.length>A&&(K.c.length=A):T&&(K=K.mod(p))}return T?I:(N&&(I=ie.div(I)),p?I.mod(p):A?le(I,J,ee,M):I)},C.integerValue=function(u){var p=new P(this);return u==null?u=ee:O(u,0,8),le(p,p.e+1,u)},C.isEqualTo=C.eq=function(u,p){return R(this,new P(u,p))===0},C.isFinite=function(){return!!this.c},C.isGreaterThan=C.gt=function(u,p){return R(this,new P(u,p))>0},C.isGreaterThanOrEqualTo=C.gte=function(u,p){return(p=R(this,new P(u,p)))===1||p===0},C.isInteger=function(){return!!this.c&&f(this.e/c)>this.c.length-2},C.isLessThan=C.lt=function(u,p){return R(this,new P(u,p))<0},C.isLessThanOrEqualTo=C.lte=function(u,p){return(p=R(this,new P(u,p)))===-1||p===0},C.isNaN=function(){return!this.s},C.isNegative=function(){return this.s<0},C.isPositive=function(){return this.s>0},C.isZero=function(){return!!this.c&&this.c[0]==0},C.minus=function(u,p){var y,T,v,A,M=this,x=M.s;if(u=new P(u,p),p=u.s,!x||!p)return new P(NaN);if(x!=p)return u.s=-p,M.plus(u);var N=M.e/c,k=u.e/c,I=M.c,K=u.c;if(!N||!k){if(!I||!K)return I?(u.s=-p,u):new P(K?M:NaN);if(!I[0]||!K[0])return K[0]?(u.s=-p,u):new P(I[0]?M:ee==3?-0:0)}if(N=f(N),k=f(k),I=I.slice(),x=N-k){for((A=x<0)?(x=-x,v=I):(k=N,v=K),v.reverse(),p=x;p--;v.push(0));v.reverse()}else for(T=(A=(x=I.length)<(p=K.length))?x:p,x=p=0;p<T;p++)if(I[p]!=K[p]){A=I[p]<K[p];break}if(A&&(v=I,I=K,K=v,u.s=-u.s),p=(T=K.length)-(y=I.length),p>0)for(;p--;I[y++]=0);for(p=a-1;T>x;){if(I[--T]<K[T]){for(y=T;y&&!I[--y];I[y]=p);--I[y],I[T]+=a}I[T]-=K[T]}for(;I[0]==0;I.splice(0,1),--k);return I[0]?te(u,I,k):(u.s=ee==3?-1:1,u.c=[u.e=0],u)},C.modulo=C.mod=function(u,p){var y,T,v=this;return u=new P(u,p),!v.c||!u.s||u.c&&!u.c[0]?new P(NaN):!u.c||v.c&&!v.c[0]?new P(v):(G==9?(T=u.s,u.s=1,y=H(v,u,0,3),u.s=T,y.s*=T):y=H(v,u,0,G),u=v.minus(y.times(u)),!u.c[0]&&G==1&&(u.s=v.s),u)},C.multipliedBy=C.times=function(u,p){var y,T,v,A,M,x,N,k,I,K,Q,oe,ye,ve,Se,me=this,ae=me.c,ke=(u=new P(u,p)).c;if(!ae||!ke||!ae[0]||!ke[0])return!me.s||!u.s||ae&&!ae[0]&&!ke||ke&&!ke[0]&&!ae?u.c=u.e=u.s=null:(u.s*=me.s,!ae||!ke?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(T=f(me.e/c)+f(u.e/c),u.s*=me.s,N=ae.length,K=ke.length,N<K&&(ye=ae,ae=ke,ke=ye,v=N,N=K,K=v),v=N+K,ye=[];v--;ye.push(0));for(ve=a,Se=d,v=K;--v>=0;){for(y=0,Q=ke[v]%Se,oe=ke[v]/Se|0,M=N,A=v+M;A>v;)k=ae[--M]%Se,I=ae[M]/Se|0,x=oe*k+I*Q,k=Q*k+x%Se*Se+ye[A]+y,y=(k/ve|0)+(x/Se|0)+oe*I,ye[A--]=k%ve;ye[A]=y}return y?++T:ye.splice(0,1),te(u,ye,T)},C.negated=function(){var u=new P(this);return u.s=-u.s||null,u},C.plus=function(u,p){var y,T=this,v=T.s;if(u=new P(u,p),p=u.s,!v||!p)return new P(NaN);if(v!=p)return u.s=-p,T.minus(u);var A=T.e/c,M=u.e/c,x=T.c,N=u.c;if(!A||!M){if(!x||!N)return new P(v/0);if(!x[0]||!N[0])return N[0]?u:new P(x[0]?T:v*0)}if(A=f(A),M=f(M),x=x.slice(),v=A-M){for(v>0?(M=A,y=N):(v=-v,y=x),y.reverse();v--;y.push(0));y.reverse()}for(v=x.length,p=N.length,v-p<0&&(y=N,N=x,x=y,p=v),v=0;p;)v=(x[--p]=x[p]+N[p]+v)/a|0,x[p]=a===x[p]?0:x[p]%a;return v&&(x=[v].concat(x),++M),te(u,x,M)},C.precision=C.sd=function(u,p){var y,T,v,A=this;if(u!=null&&u!==!!u)return O(u,1,w),p==null?p=ee:O(p,0,8),le(new P(A),u,p);if(!(y=A.c))return null;if(v=y.length-1,T=v*c+1,v=y[v]){for(;v%10==0;v/=10,T--);for(v=y[0];v>=10;v/=10,T++);}return u&&A.e+1>T&&(T=A.e+1),T},C.shiftedBy=function(u){return O(u,-l,l),this.times("1e"+u)},C.squareRoot=C.sqrt=function(){var u,p,y,T,v,A=this,M=A.c,x=A.s,N=A.e,k=re+4,I=new P("0.5");if(x!==1||!M||!M[0])return new P(!x||x<0&&(!M||M[0])?NaN:M?A:1/0);if(x=Math.sqrt(+D(A)),x==0||x==1/0?(p=S(M),(p.length+N)%2==0&&(p+="0"),x=Math.sqrt(+p),N=f((N+1)/2)-(N<0||N%2),x==1/0?p="5e"+N:(p=x.toExponential(),p=p.slice(0,p.indexOf("e")+1)+N),y=new P(p)):y=new P(x+""),y.c[0]){for(N=y.e,x=N+k,x<3&&(x=0);;)if(v=y,y=I.times(v.plus(H(A,v,k,1))),S(v.c).slice(0,x)===(p=S(y.c)).slice(0,x))if(y.e<N&&--x,p=p.slice(x-3,x+1),p=="9999"||!T&&p=="4999"){if(!T&&(le(v,v.e+re+2,0),v.times(v).eq(A))){y=v;break}k+=4,x+=4,T=1}else{(!+p||!+p.slice(1)&&p.charAt(0)=="5")&&(le(y,y.e+re+2,1),u=!y.times(y).eq(A));break}}return le(y,y.e+re+1,ee,u)},C.toExponential=function(u,p){return u!=null&&(O(u,0,w),u++),m(this,u,p,1)},C.toFixed=function(u,p){return u!=null&&(O(u,0,w),u=u+this.e+1),m(this,u,p)},C.toFormat=function(u,p,y){var T,v=this;if(y==null)u!=null&&p&&typeof p=="object"?(y=p,p=null):u&&typeof u=="object"?(y=u,u=p=null):y=fe;else if(typeof y!="object")throw Error(s+"Argument not an object: "+y);if(T=v.toFixed(u,p),v.c){var A,M=T.split("."),x=+y.groupSize,N=+y.secondaryGroupSize,k=y.groupSeparator||"",I=M[0],K=M[1],Q=v.s<0,oe=Q?I.slice(1):I,ye=oe.length;if(N&&(A=x,x=N,N=A,ye-=A),x>0&&ye>0){for(A=ye%x||x,I=oe.substr(0,A);A<ye;A+=x)I+=k+oe.substr(A,x);N>0&&(I+=k+oe.slice(A)),Q&&(I="-"+I)}T=K?I+(y.decimalSeparator||"")+((N=+y.fractionGroupSize)?K.replace(new RegExp("\\d{"+N+"}\\B","g"),"$&"+(y.fractionGroupSeparator||"")):K):I}return(y.prefix||"")+T+(y.suffix||"")},C.toFraction=function(u){var p,y,T,v,A,M,x,N,k,I,K,Q,oe=this,ye=oe.c;if(u!=null&&(x=new P(u),!x.isInteger()&&(x.c||x.s!==1)||x.lt(ie)))throw Error(s+"Argument "+(x.isInteger()?"out of range: ":"not an integer: ")+D(x));if(!ye)return new P(oe);for(p=new P(ie),k=y=new P(ie),T=N=new P(ie),Q=S(ye),A=p.e=Q.length-oe.e-1,p.c[0]=h[(M=A%c)<0?c+M:M],u=!u||x.comparedTo(p)>0?A>0?p:k:x,M=F,F=1/0,x=new P(Q),N.c[0]=0;I=H(x,p,0,1),v=y.plus(I.times(T)),v.comparedTo(u)!=1;)y=T,T=v,k=N.plus(I.times(v=k)),N=v,p=x.minus(I.times(v=p)),x=v;return v=H(u.minus(y),T,0,1),N=N.plus(v.times(k)),y=y.plus(v.times(T)),N.s=k.s=oe.s,A=A*2,K=H(k,T,A,ee).minus(oe).abs().comparedTo(H(N,y,A,ee).minus(oe).abs())<1?[k,T]:[N,y],F=M,K},C.toNumber=function(){return+D(this)},C.toPrecision=function(u,p){return u!=null&&O(u,1,w),m(this,u,p,2)},C.toString=function(u){var p,y=this,T=y.s,v=y.e;return v===null?T?(p="Infinity",T<0&&(p="-"+p)):p="NaN":(u==null?p=v<=g||v>=B?q(S(y.c),v):Y(S(y.c),v,"0"):u===10&&W?(y=le(new P(y),re+v+1,ee),p=Y(S(y.c),y.e,"0")):(O(u,2,ce.length,"Base"),p=z(Y(S(y.c),v,"0"),10,u,T,!0)),T<0&&y.c[0]&&(p="-"+p)),p},C.valueOf=C.toJSON=function(){return D(this)},C._isBigNumber=!0,E!=null&&P.set(E),P}function f(E){var H=E|0;return E>0||E===H?H:H-1}function S(E){for(var H,z,Z=1,C=E.length,ie=E[0]+"";Z<C;){for(H=E[Z++]+"",z=c-H.length;z--;H="0"+H);ie+=H}for(C=ie.length;ie.charCodeAt(--C)===48;);return ie.slice(0,C+1||1)}function R(E,H){var z,Z,C=E.c,ie=H.c,re=E.s,ee=H.s,g=E.e,B=H.e;if(!re||!ee)return null;if(z=C&&!C[0],Z=ie&&!ie[0],z||Z)return z?Z?0:-ee:re;if(re!=ee)return re;if(z=re<0,Z=g==B,!C||!ie)return Z?0:!C^z?1:-1;if(!Z)return g>B^z?1:-1;for(ee=(g=C.length)<(B=ie.length)?g:B,re=0;re<ee;re++)if(C[re]!=ie[re])return C[re]>ie[re]^z?1:-1;return g==B?0:g>B^z?1:-1}function O(E,H,z,Z){if(E<H||E>z||E!==i(E))throw Error(s+(Z||"Argument")+(typeof E=="number"?E<H||E>z?" out of range: ":" not an integer: ":" not a primitive number: ")+String(E))}function V(E){var H=E.c.length-1;return f(E.e/c)==H&&E.c[H]%2!=0}function q(E,H){return(E.length>1?E.charAt(0)+"."+E.slice(1):E)+(H<0?"e":"e+")+H}function Y(E,H,z){var Z,C;if(H<0){for(C=z+".";++H;C+=z);E=C+E}else if(Z=E.length,++H>Z){for(C=z,H-=Z;--H;C+=z);E+=C}else H<Z&&(E=E.slice(0,H)+"."+E.slice(H));return E}e=b(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof os<"u"&&os.exports?os.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(cf)});var ff=He((xy,uf)=>{uf.exports=function(e,r,n){var i=new e.Uint8Array(n),s=r.pushInt,o=r.pushInt32,a=r.pushInt32Neg,c=r.pushInt64,l=r.pushInt64Neg,h=r.pushFloat,d=r.pushFloatSingle,w=r.pushFloatDouble,b=r.pushTrue,f=r.pushFalse,S=r.pushUndefined,R=r.pushNull,O=r.pushInfinity,V=r.pushInfinityNeg,q=r.pushNaN,Y=r.pushNaNNeg,E=r.pushArrayStart,H=r.pushArrayStartFixed,z=r.pushArrayStartFixed32,Z=r.pushArrayStartFixed64,C=r.pushObjectStart,ie=r.pushObjectStartFixed,re=r.pushObjectStartFixed32,ee=r.pushObjectStartFixed64,g=r.pushByteString,B=r.pushByteStringStart,$=r.pushUtf8String,F=r.pushUtf8StringStart,U=r.pushSimpleUnassigned,G=r.pushTagStart,J=r.pushTagStart4,fe=r.pushTagStart8,ce=r.pushTagUnassigned,W=r.pushBreak,P=e.Math.pow,m=0,L=0,te=0;function le(_){for(_=_|0,m=0,L=_;(m|0)<(L|0)&&(te=Vl[i[m]&255](i[m]|0)|0,!((te|0)>0)););return te|0}function D(_){return _=_|0,((m|0)+(_|0)|0)<(L|0)?0:1}function u(_){return _=_|0,i[_|0]<<8|i[_+1|0]|0}function p(_){return _=_|0,i[_|0]<<24|i[_+1|0]<<16|i[_+2|0]<<8|i[_+3|0]|0}function y(_){return _=_|0,s(_|0),m=m+1|0,0}function T(_){return _=_|0,D(1)|0?1:(s(i[m+1|0]|0),m=m+2|0,0)}function v(_){return _=_|0,D(2)|0?1:(s(u(m+1|0)|0),m=m+3|0,0)}function A(_){return _=_|0,D(4)|0?1:(o(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function M(_){return _=_|0,D(8)|0?1:(c(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function x(_){return _=_|0,s(-1-(_-32|0)|0),m=m+1|0,0}function N(_){return _=_|0,D(1)|0?1:(s(-1-(i[m+1|0]|0)|0),m=m+2|0,0)}function k(_){_=_|0;var be=0;return D(2)|0?1:(be=u(m+1|0)|0,s(-1-(be|0)|0),m=m+3|0,0)}function I(_){return _=_|0,D(4)|0?1:(a(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function K(_){return _=_|0,D(8)|0?1:(l(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function Q(_){_=_|0;var be=0,xe=0,ge=0;return ge=_-64|0,D(ge|0)|0?1:(be=m+1|0,xe=(m+1|0)+(ge|0)|0,g(be|0,xe|0),m=xe|0,0)}function oe(_){_=_|0;var be=0,xe=0,ge=0;return D(1)|0||(ge=i[m+1|0]|0,be=m+2|0,xe=(m+2|0)+(ge|0)|0,D(ge+1|0)|0)?1:(g(be|0,xe|0),m=xe|0,0)}function ye(_){_=_|0;var be=0,xe=0,ge=0;return D(2)|0||(ge=u(m+1|0)|0,be=m+3|0,xe=(m+3|0)+(ge|0)|0,D(ge+2|0)|0)?1:(g(be|0,xe|0),m=xe|0,0)}function ve(_){_=_|0;var be=0,xe=0,ge=0;return D(4)|0||(ge=p(m+1|0)|0,be=m+5|0,xe=(m+5|0)+(ge|0)|0,D(ge+4|0)|0)?1:(g(be|0,xe|0),m=xe|0,0)}function Se(_){return _=_|0,1}function me(_){return _=_|0,B(),m=m+1|0,0}function ae(_){_=_|0;var be=0,xe=0,ge=0;return ge=_-96|0,D(ge|0)|0?1:(be=m+1|0,xe=(m+1|0)+(ge|0)|0,$(be|0,xe|0),m=xe|0,0)}function ke(_){_=_|0;var be=0,xe=0,ge=0;return D(1)|0||(ge=i[m+1|0]|0,be=m+2|0,xe=(m+2|0)+(ge|0)|0,D(ge+1|0)|0)?1:($(be|0,xe|0),m=xe|0,0)}function Gt(_){_=_|0;var be=0,xe=0,ge=0;return D(2)|0||(ge=u(m+1|0)|0,be=m+3|0,xe=(m+3|0)+(ge|0)|0,D(ge+2|0)|0)?1:($(be|0,xe|0),m=xe|0,0)}function ir(_){_=_|0;var be=0,xe=0,ge=0;return D(4)|0||(ge=p(m+1|0)|0,be=m+5|0,xe=(m+5|0)+(ge|0)|0,D(ge+4|0)|0)?1:($(be|0,xe|0),m=xe|0,0)}function Cr(_){return _=_|0,1}function _t(_){return _=_|0,F(),m=m+1|0,0}function _e(_){return _=_|0,H(_-128|0),m=m+1|0,0}function ut(_){return _=_|0,D(1)|0?1:(H(i[m+1|0]|0),m=m+2|0,0)}function De(_){return _=_|0,D(2)|0?1:(H(u(m+1|0)|0),m=m+3|0,0)}function Ue(_){return _=_|0,D(4)|0?1:(z(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function xl(_){return _=_|0,D(8)|0?1:(Z(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function _l(_){return _=_|0,E(),m=m+1|0,0}function Ie(_){_=_|0;var be=0;return be=_-160|0,D(be|0)|0?1:(ie(be|0),m=m+1|0,0)}function El(_){return _=_|0,D(1)|0?1:(ie(i[m+1|0]|0),m=m+2|0,0)}function vl(_){return _=_|0,D(2)|0?1:(ie(u(m+1|0)|0),m=m+3|0,0)}function Bl(_){return _=_|0,D(4)|0?1:(re(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function Al(_){return _=_|0,D(8)|0?1:(ee(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function Tl(_){return _=_|0,C(),m=m+1|0,0}function en(_){return _=_|0,G(_-192|0|0),m=m+1|0,0}function n1(_){return _=_|0,G(_|0),m=m+1|0,0}function i1(_){return _=_|0,G(_|0),m=m+1|0,0}function s1(_){return _=_|0,G(_|0),m=m+1|0,0}function o1(_){return _=_|0,G(_|0),m=m+1|0,0}function Xe(_){return _=_|0,G(_-192|0|0),m=m+1|0,0}function a1(_){return _=_|0,G(_|0),m=m+1|0,0}function c1(_){return _=_|0,G(_|0),m=m+1|0,0}function u1(_){return _=_|0,G(_|0),m=m+1|0,0}function Sl(_){return _=_|0,D(1)|0?1:(G(i[m+1|0]|0),m=m+2|0,0)}function Nl(_){return _=_|0,D(2)|0?1:(G(u(m+1|0)|0),m=m+3|0,0)}function Rl(_){return _=_|0,D(4)|0?1:(J(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function Ol(_){return _=_|0,D(8)|0?1:(fe(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function je(_){return _=_|0,U((_|0)-224|0),m=m+1|0,0}function Fl(_){return _=_|0,f(),m=m+1|0,0}function Ul(_){return _=_|0,b(),m=m+1|0,0}function Il(_){return _=_|0,R(),m=m+1|0,0}function Pl(_){return _=_|0,S(),m=m+1|0,0}function kl(_){return _=_|0,D(1)|0?1:(U(i[m+1|0]|0),m=m+2|0,0)}function Ml(_){_=_|0;var be=0,xe=0,ge=1,Ai=0,Fn=0,f1=0;return D(2)|0?1:(be=i[m+1|0]|0,xe=i[m+2|0]|0,(be|0)&128&&(ge=-1),Ai=+(((be|0)&124)>>2),Fn=+(((be|0)&3)<<8|xe),+Ai==0?h(+(+ge*5960464477539063e-23*+Fn)):+Ai==31?+ge==1?+Fn>0?q():O():+Fn>0?Y():V():h(+(+ge*P(2,+(+Ai-25))*+(1024+Fn))),m=m+3|0,0)}function Cl(_){return _=_|0,D(4)|0?1:(d(i[m+1|0]|0,i[m+2|0]|0,i[m+3|0]|0,i[m+4|0]|0),m=m+5|0,0)}function ql(_){return _=_|0,D(8)|0?1:(w(i[m+1|0]|0,i[m+2|0]|0,i[m+3|0]|0,i[m+4|0]|0,i[m+5|0]|0,i[m+6|0]|0,i[m+7|0]|0,i[m+8|0]|0),m=m+9|0,0)}function Ae(_){return _=_|0,1}function $l(_){return _=_|0,W(),m=m+1|0,0}var Vl=[y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,T,v,A,M,Ae,Ae,Ae,Ae,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,N,k,I,K,Ae,Ae,Ae,Ae,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,oe,ye,ve,Se,Ae,Ae,Ae,me,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ke,Gt,ir,Cr,Ae,Ae,Ae,_t,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,ut,De,Ue,xl,Ae,Ae,Ae,_l,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,El,vl,Bl,Al,Ae,Ae,Ae,Tl,en,en,en,en,en,en,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Sl,Nl,Rl,Ol,Ae,Ae,Ae,Ae,je,je,je,je,je,je,je,je,je,je,je,je,je,je,je,je,je,je,je,je,Fl,Ul,Il,Pl,kl,Ml,Cl,ql,Ae,Ae,Ae,$l];return{parse:le}}});var Zn=He(gt=>{"use strict";var Xo=Wn().BigNumber;gt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};gt.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36};gt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};gt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};gt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};gt.SHIFT32=Math.pow(2,32);gt.SHIFT16=Math.pow(2,16);gt.MAX_SAFE_HIGH=2097151;gt.NEG_ONE=new Xo(-1);gt.TEN=new Xo(10);gt.TWO=new Xo(2);gt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var as=He(Bt=>{"use strict";var{Buffer:xd}=Kn(),hf=Wn().BigNumber,df=Zn(),lf=df.SHIFT32,_d=df.SHIFT16,Ed=2097151;Bt.parseHalf=function(e){var r,n,i;return i=e[0]&128?-1:1,r=(e[0]&124)>>2,n=(e[0]&3)<<8|e[1],r?r===31?i*(n?NaN:1/0):i*Math.pow(2,r-25)*(1024+n):i*5960464477539063e-23*n};function vd(t){return t<16?"0"+t.toString(16):t.toString(16)}Bt.arrayBufferToBignumber=function(t){let e=t.byteLength,r="";for(let n=0;n<e;n++)r+=vd(t[n]);return new hf(r,16)};Bt.buildMap=t=>{let e=new Map,r=Object.keys(t),n=r.length;for(let i=0;i<n;i++)e.set(r[i],t[r[i]]);return e};Bt.buildInt32=(t,e)=>t*_d+e;Bt.buildInt64=(t,e,r,n)=>{let i=Bt.buildInt32(t,e),s=Bt.buildInt32(r,n);return i>Ed?new hf(i).times(lf).plus(s):i*lf+s};Bt.writeHalf=function(e,r){let n=xd.allocUnsafe(4);n.writeFloatBE(r,0);let i=n.readUInt32BE(0);if(i&8191)return!1;var s=i>>16&32768;let o=i>>23&255,a=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(a>>13);else if(o>=103&&o<113){if(a&(1<<126-o)-1)return!1;s+=a+8388608>>126-o}else return!1;return e.writeUInt16BE(s,0),!0};Bt.keySorter=function(t,e){var r=t[0].byteLength,n=e[0].byteLength;return r>n?1:n>r?-1:t[0].compare(e[0])};Bt.isNegativeZero=t=>t===0&&1/t<0;Bt.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,e+=1;return 1<<e}});var Do=He((vy,pf)=>{"use strict";var Lo=Zn(),Bd=Lo.MT,cs=Lo.SIMPLE,Jo=Lo.SYMS,Qo=class t{constructor(e){if(typeof e!="number")throw new Error("Invalid Simple type: "+typeof e);if(e<0||e>255||(e|0)!==e)throw new Error("value must be a small positive integer: "+e);this.value=e}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(e){return e._pushInt(this.value,Bd.SIMPLE_FLOAT)}static isSimple(e){return e instanceof t}static decode(e,r){switch(r==null&&(r=!0),e){case cs.FALSE:return!1;case cs.TRUE:return!0;case cs.NULL:return r?null:Jo.NULL;case cs.UNDEFINED:return r?void 0:Jo.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return Jo.BREAK;default:return new t(e)}}};pf.exports=Qo});var ta=He((By,mf)=>{"use strict";var ea=class t{constructor(e,r,n){if(this.tag=e,this.value=r,this.err=n,typeof this.tag!="number")throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(this.tag|0)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(e){return e._pushTag(this.tag),e.pushAny(this.value)}convert(e){var r,n;if(n=e?.[this.tag],typeof n!="function"&&(n=t["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(t,this.value)}catch(i){return r=i,this.err=r,this}}};mf.exports=ea});var ia=He((Ay,gf)=>{"use strict";var yf=self.location?self.location.protocol+"//"+self.location.host:"",ra=self.URL,na=class{constructor(e="",r=yf){this.super=new ra(e,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(e){this.super.hash=e}set host(e){this.super.host=e}set hostname(e){this.super.hostname=e}set href(e){this.super.href=e}set origin(e){this.super.origin=e}set password(e){this.super.password=e}set pathname(e){this.super.pathname=e}set port(e){this.super.port=e}set protocol(e){this.super.protocol=e}set search(e){this.super.search=e}set searchParams(e){this.super.searchParams=e}set username(e){this.super.username=e}createObjectURL(e){return this.super.createObjectURL(e)}revokeObjectURL(e){this.super.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function Ad(t){if(typeof t=="string")return new ra(t).toString();if(!(t instanceof ra)){let e=t.username&&t.password?`${t.username}:${t.password}@`:"",r=t.auth?t.auth+"@":"",n=t.port?":"+t.port:"",i=t.protocol?t.protocol+"//":"",s=t.host||"",o=t.hostname||"",a=t.search||(t.query?"?"+t.query:""),c=t.hash||"",l=t.pathname||"",h=t.path||l+a;return`${i}${e||r}${s||o+n}${h}${c}`}}gf.exports={URLWithLegacySupport:na,URLSearchParams:self.URLSearchParams,defaultBase:yf,format:Ad}});var xf=He((Ty,bf)=>{"use strict";var{URLWithLegacySupport:wf,format:Td}=ia();bf.exports=(t,e={},r={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new wf(t)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new wf(t,Td(o)).toString()}});var sa=He((Sy,_f)=>{"use strict";var{URLWithLegacySupport:Sd,format:Nd,URLSearchParams:Rd,defaultBase:Od}=ia(),Fd=xf();_f.exports={URL:Sd,URLSearchParams:Rd,format:Nd,relative:Fd,defaultBase:Od}});var oa=He((Ny,vf)=>{"use strict";var{Buffer:pn}=Kn(),Ef=Bo(),Ud=Wn().BigNumber,Id=ff(),it=as(),Be=Zn(),Pd=Do(),kd=ta(),{URL:Md}=sa(),Xn=class t{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=it.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=pn.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>it.arrayBufferToBignumber(r),3:r=>Be.NEG_ONE.minus(it.arrayBufferToBignumber(r)),4:r=>Be.TEN.pow(r[0]).times(r[1]),5:r=>Be.TWO.pow(r[0]).times(r[1]),32:r=>new Md(r),35:r=>new RegExp(r)},e.tags),this.parser=Id(globalThis,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var e=this._parents.pop();if(e.length>0)throw new Error(`Missing ${e.length} elements`);switch(e.type){case Be.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case Be.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case Be.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case Be.PARENT.MAP:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(e.ref,e.length));break;case Be.PARENT.OBJECT:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(e.ref,e.length));break;case Be.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===Be.PARENT.TAG&&this._dec()}_dec(){let e=this._currentParent;e.length<0||(e.length--,e.length===0&&this._closeParent())}_push(e,r){let n=this._currentParent;switch(n.values++,n.type){case Be.PARENT.ARRAY:case Be.PARENT.BYTE_STRING:case Be.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case Be.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=Be.PARENT.MAP,n.ref=it.buildMap(n.ref)));break;case Be.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case Be.PARENT.TAG:this._ref.push(e),r||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(e,r,n){this._parents[this._depth]={type:r,length:n,ref:e,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:Be.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,r){let n=this._knownTags[e];return n?n(r):new kd(e,r)}createMap(e,r){return e}createObject(e,r){return e}createArray(e,r){return e}createByteString(e,r){return pn.concat(e)}createByteStringFromHeap(e,r){return e===r?pn.alloc(0):pn.from(this._heap.slice(e,r))}createInt(e){return e}createInt32(e,r){return it.buildInt32(e,r)}createInt64(e,r,n,i){return it.buildInt64(e,r,n,i)}createFloat(e){return e}createFloatSingle(e,r,n,i){return Ef.read([e,r,n,i],0,!1,23,4)}createFloatDouble(e,r,n,i,s,o,a,c){return Ef.read([e,r,n,i,s,o,a,c],0,!1,52,8)}createInt32Neg(e,r){return-1-it.buildInt32(e,r)}createInt64Neg(e,r,n,i){let s=it.buildInt32(e,r),o=it.buildInt32(n,i);return s>Be.MAX_SAFE_HIGH?Be.NEG_ONE.minus(new Ud(s).times(Be.SHIFT32).plus(o)):-1-(s*Be.SHIFT32+o)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(e,r){return e.join("")}createUtf8StringFromHeap(e,r){return e===r?"":this._buffer.toString("utf8",e,r)}createSimpleUnassigned(e){return new Pd(e)}pushInt(e){this._push(this.createInt(e))}pushInt32(e,r){this._push(this.createInt32(e,r))}pushInt64(e,r,n,i){this._push(this.createInt64(e,r,n,i))}pushFloat(e){this._push(this.createFloat(e))}pushFloatSingle(e,r,n,i){this._push(this.createFloatSingle(e,r,n,i))}pushFloatDouble(e,r,n,i,s,o,a,c){this._push(this.createFloatDouble(e,r,n,i,s,o,a,c))}pushInt32Neg(e,r){this._push(this.createInt32Neg(e,r))}pushInt64Neg(e,r,n,i){this._push(this.createInt64Neg(e,r,n,i))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],Be.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,r){let n=it.buildInt32(e,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,r,n,i){let s=it.buildInt64(e,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,r){let n=it.buildInt32(e,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,r,n,i){let s=it.buildInt64(e,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:Be.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(e,r){this._push(this.createByteStringFromHeap(e,r))}pushUtf8StringStart(){this._parents[this._depth]={type:Be.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(e,r){this._push(this.createUtf8StringFromHeap(e,r))}pushSimpleUnassigned(e){this._push(this.createSimpleUnassigned(e))}pushTagStart(e){this._parents[this._depth]={type:Be.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,r){this.pushTagStart(it.buildInt32(e,r))}pushTagStart8(e,r,n,i){this.pushTagStart(it.buildInt64(e,r,n,i))}pushTagUnassigned(e){this._push(this.createTag(e))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(e){if(e===0){this._push(this.createObject({}));return}this._createParent({},Be.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),Be.PARENT.ARRAY,e)}_decode(e){if(e.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(e);let r=this.parser.parse(e.byteLength);if(this._depth>1){for(;this._currentParent.length===0;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(r>0)throw new Error("Failed to parse");if(this._res.length===0)throw new Error("No valid result")}decodeFirst(e){return this._decode(e),this._res[0]}decodeAll(e){return this._decode(e),this._res}static decode(e,r){return typeof e=="string"&&(e=pn.from(e,r||"hex")),new t({size:e.length}).decodeFirst(e)}static decodeAll(e,r){return typeof e=="string"&&(e=pn.from(e,r||"hex")),new t({size:e.length}).decodeAll(e)}};Xn.decodeFirst=Xn.decode;vf.exports=Xn});var Tf=He((Ry,Af)=>{"use strict";var{Buffer:aa}=Kn(),Cd=oa(),qd=as(),ca=class t extends Cd{createTag(e,r){return`${e}(${r})`}createInt(e){return super.createInt(e).toString()}createInt32(e,r){return super.createInt32(e,r).toString()}createInt64(e,r,n,i){return super.createInt64(e,r,n,i).toString()}createInt32Neg(e,r){return super.createInt32Neg(e,r).toString()}createInt64Neg(e,r,n,i){return super.createInt64Neg(e,r,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(e){let r=super.createFloat(e);return qd.isNegativeZero(e)?"-0_1":`${r}_1`}createFloatSingle(e,r,n,i){return`${super.createFloatSingle(e,r,n,i)}_2`}createFloatDouble(e,r,n,i,s,o,a,c){return`${super.createFloatDouble(e,r,n,i,s,o,a,c)}_3`}createByteString(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(e,r){return`h'${aa.from(super.createByteStringFromHeap(e,r)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(e){return`simple(${e})`}createArray(e,r){let n=super.createArray(e,r);return r===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(e,r){let n=super.createMap(e),i=Array.from(n.keys()).reduce(Bf(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(e,r){let n=super.createObject(e),i=Object.keys(n).reduce(Bf(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,r){return`"${aa.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return typeof e=="string"&&(e=aa.from(e,r||"hex")),new t().decodeFirst(e)}};Af.exports=ca;function Bf(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}});var Ff=He((Oy,Of)=>{"use strict";var{Buffer:Jt}=Kn(),{URL:$d}=sa(),fa=Wn().BigNumber,ua=as(),Ke=Zn(),Ft=Ke.MT,us=Ke.NUMBYTES,Sf=Ke.SHIFT32,Nf=Ke.SYMS,mn=Ke.TAG,Vd=Ke.MT.SIMPLE_FLOAT<<5|Ke.NUMBYTES.TWO,jd=Ke.MT.SIMPLE_FLOAT<<5|Ke.NUMBYTES.FOUR,Hd=Ke.MT.SIMPLE_FLOAT<<5|Ke.NUMBYTES.EIGHT,Gd=Ke.MT.SIMPLE_FLOAT<<5|Ke.SIMPLE.TRUE,Yd=Ke.MT.SIMPLE_FLOAT<<5|Ke.SIMPLE.FALSE,zd=Ke.MT.SIMPLE_FLOAT<<5|Ke.SIMPLE.UNDEFINED,Rf=Ke.MT.SIMPLE_FLOAT<<5|Ke.SIMPLE.NULL,Kd=new fa("0x20000000000000"),Wd=Jt.from("f97e00","hex"),Zd=Jt.from("f9fc00","hex"),Xd=Jt.from("f97c00","hex");function Jd(t){return{}.toString.call(t).slice(8,-1)}var la=class t{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[$d,this._pushUrl],[fa,this._pushBigNumber]];let r=e.genTypes||[],n=r.length;for(let i=0;i<n;i++)this.addSemanticType(r[i][0],r[i][1]);this._reset()}addSemanticType(e,r){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===e){let o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=r,o}return this.semanticTypes.push([e,r]),null}push(e){return e&&(this.result[this.offset]=e,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=e.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(e,r,n){return this.result[this.offset]=e,this.resultMethod[this.offset]=r,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(e){return this.pushWrite(e,1,1)}_pushUInt16BE(e){return this.pushWrite(e,2,2)}_pushUInt32BE(e){return this.pushWrite(e,3,4)}_pushDoubleBE(e){return this.pushWrite(e,4,8)}_pushNaN(){return this.push(Wd)}_pushInfinity(e){let r=e<0?Zd:Xd;return this.push(r)}_pushFloat(e){let r=Jt.allocUnsafe(2);if(ua.writeHalf(r,e)&&ua.parseHalf(r)===e)return this._pushUInt8(Vd)&&this.push(r);let n=Jt.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(jd)&&this.push(n):this._pushUInt8(Hd)&&this._pushDoubleBE(e)}_pushInt(e,r,n){let i=r<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|us.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|us.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|us.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|us.EIGHT)&&this._pushUInt32BE(Math.floor(e/Sf))&&this._pushUInt32BE(e%Sf):r===Ft.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,Ft.NEG_INT,e):this._pushInt(e,Ft.POS_INT)}_pushNumber(e){switch(!1){case e===e:return this._pushNaN(e);case isFinite(e):return this._pushInfinity(e);case e%1!==0:return this._pushIntNum(e);default:return this._pushFloat(e)}}_pushString(e){let r=Jt.byteLength(e,"utf8");return this._pushInt(r,Ft.UTF8_STRING)&&this.pushWrite(e,5,r)}_pushBoolean(e){return this._pushUInt8(e?Gd:Yd)}_pushUndefined(e){return this._pushUInt8(zd)}_pushArray(e,r){let n=r.length;if(!e._pushInt(n,Ft.ARRAY))return!1;for(let i=0;i<n;i++)if(!e.pushAny(r[i]))return!1;return!0}_pushTag(e){return this._pushInt(e,Ft.TAG)}_pushDate(e,r){return e._pushTag(mn.DATE_EPOCH)&&e.pushAny(Math.round(r/1e3))}_pushBuffer(e,r){return e._pushInt(r.length,Ft.BYTE_STRING)&&e.push(r)}_pushNoFilter(e,r){return e._pushBuffer(e,r.slice())}_pushRegexp(e,r){return e._pushTag(mn.REGEXP)&&e.pushAny(r.source)}_pushSet(e,r){if(!e._pushInt(r.size,Ft.ARRAY))return!1;for(let n of r)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,r){return e._pushTag(mn.URI)&&e.pushAny(r.format())}_pushBigint(e){let r=mn.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),r=mn.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=Jt.from(n,"hex");return this._pushTag(r)&&this._pushBuffer(this,i)}_pushBigNumber(e,r){if(r.isNaN())return e._pushNaN();if(!r.isFinite())return e._pushInfinity(r.isNegative()?-1/0:1/0);if(r.isInteger())return e._pushBigint(r);if(!(e._pushTag(mn.DECIMAL_FRAC)&&e._pushInt(2,Ft.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new fa(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(Kd)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,r){return e._pushInt(r.size,Ft.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(e){if(!e)return this._pushUInt8(Rf);for(var r=this.semanticTypes.length,n=0;n<r;n++)if(e instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(e,this,e);var i=e.encodeCBOR;if(typeof i=="function")return i.call(e,this);var s=Object.keys(e),o=s.length;return this._pushInt(o,Ft.MAP)?this._pushRawMap(o,s.map(a=>[a,e[a]])):!1}_pushRawMap(e,r){r=r.map(function(i){return i[0]=t.encode(i[0]),i}).sort(ua.keySorter);for(var n=0;n<e;n++)if(!this.push(r[n][0])||!this.pushAny(r[n][1]))return!1;return!0}write(e){return this.pushAny(e)}pushAny(e){var r=Jd(e);switch(r){case"Number":return this._pushNumber(e);case"String":return this._pushString(e);case"Boolean":return this._pushBoolean(e);case"Object":return this._pushObject(e);case"Array":return this._pushArray(this,e);case"Uint8Array":return this._pushBuffer(this,Jt.isBuffer(e)?e:Jt.from(e));case"Null":return this._pushUInt8(Rf);case"Undefined":return this._pushUndefined(e);case"Map":return this._pushMap(this,e);case"Set":return this._pushSet(this,e);case"URL":return this._pushUrl(this,e);case"BigNumber":return this._pushBigNumber(this,e);case"Date":return this._pushDate(this,e);case"RegExp":return this._pushRegexp(this,e);case"Symbol":switch(e){case Nf.NULL:return this._pushObject(null);case Nf.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+e.toString())}default:throw new Error("Unknown type: "+typeof e+", "+(e?e.toString():""))}}finalize(){if(this.offset===0)return null;for(var e=this.result,r=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=r[o];var a=Jt.allocUnsafe(s),c=0,l=0;for(o=0;o<i;o++){switch(l=r[o],n[o]){case 0:e[o].copy(a,c);break;case 1:a.writeUInt8(e[o],c,!0);break;case 2:a.writeUInt16BE(e[o],c,!0);break;case 3:a.writeUInt32BE(e[o],c,!0);break;case 4:a.writeDoubleBE(e[o],c,!0);break;case 5:a.write(e[o],c,l,"utf8");break;default:throw new Error("unkown method")}c+=l}var h=a;return this._reset(),h}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(e){let r=new t;if(!r.pushAny(e))throw new Error("Failed to encode input");return r.finalize()}};Of.exports=la});var ha=He(We=>{"use strict";We.Diagnose=Tf();We.Decoder=oa();We.Encoder=Ff();We.Simple=Do();We.Tagged=ta();We.decodeAll=We.Decoder.decodeAll;We.decodeFirst=We.Decoder.decodeFirst;We.diagnose=We.Diagnose.diagnose;We.encode=We.Encoder.encode;We.decode=We.Decoder.decode;We.leveldb={decode:We.Decoder.decodeAll,encode:We.Encoder.encode,buffer:!0,name:"cbor"}});function At(t){return qn(Pn.create().update(new Uint8Array(t)).digest())}function fs(t){if(t instanceof Uf.default.Tagged)return fs(t.value);if(typeof t=="string")return If(t);if(typeof t=="number")return At(Oe(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return At(t);if(Array.isArray(t)){let e=t.map(fs);return At(nt(...e))}else{if(t&&typeof t=="object"&&t._isPrincipal)return At(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return fs(t.toHash());if(typeof t=="object")return Jn(t);if(typeof t=="bigint")return At(Oe(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}function ls(t){return Jn(t)}function Jn(t){let n=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=If(o),l=fs(a);return[c,l]}).sort(([o],[a])=>Po(o,a)),i=nt(...n.map(o=>nt(...o)));return At(i)}var Uf,If,Qn=he(()=>{zn();Uf=tn(ha());Ui();lt();If=t=>{let e=new TextEncoder().encode(t);return At(e)}});var $y,yn,da=he(()=>{yt();Qn();lt();$y=new TextEncoder().encode(`
14
- ic-request`),yn=class{getPrincipal(){return de.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}}});var ya=He(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});var Qd=9007199254740992;function ur(t,...e){let r=new Uint8Array(t.byteLength+e.reduce((i,s)=>i+s.byteLength,0));r.set(new Uint8Array(t),0);let n=t.byteLength;for(let i of e)r.set(new Uint8Array(i),n),n+=i.byteLength;return r.buffer}function Ut(t,e,r){r=r.replace(/[^0-9a-fA-F]/g,"");let n=2**(e-24);r=r.slice(-n*2).padStart(n*2,"0");let i=[(t<<5)+e].concat(r.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function hs(t,e){if(e<24)return new Uint8Array([(t<<5)+e]).buffer;{let r=e<=255?24:e<=65535?25:e<=4294967295?26:27;return Ut(t,r,e.toString(16))}}function Pf(t){let e=[];for(let r=0;r<t.length;r++){let n=t.charCodeAt(r);n<128?e.push(n):n<2048?e.push(192|n>>6,128|n&63):n<55296||n>=57344?e.push(224|n>>12,128|n>>6&63,128|n&63):(r++,n=(n&1023)<<10|t.charCodeAt(r)&1023,e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return ur(new Uint8Array(hs(3,t.length)),new Uint8Array(e))}function Ld(t,e){if(t==14277111)return ur(new Uint8Array([217,217,247]),e);if(t<24)return ur(new Uint8Array([192+t]),e);{let r=t<=255?24:t<=65535?25:t<=4294967295?26:27,n=2**(r-24),i=t.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+r].concat(i.match(/../g).map(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}Ne.tagged=Ld;function Ln(t){return new Uint8Array(t).buffer}Ne.raw=Ln;function pa(t){if(isNaN(t))throw new RangeError("Invalid number.");t=Math.min(Math.max(0,t),23);let e=[0+t];return new Uint8Array(e).buffer}Ne.uSmall=pa;function kf(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),255),t=t.toString(16),Ut(0,24,t)}Ne.u8=kf;function Mf(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),65535),t=t.toString(16),Ut(0,25,t)}Ne.u16=Mf;function Cf(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),4294967295),t=t.toString(16),Ut(0,26,t)}Ne.u32=Cf;function ma(t,e){if(typeof t=="string"&&e==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return Ut(0,27,t)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),Qd),t=t.toString(16),Ut(0,27,t)}Ne.u64=ma;function qf(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return pa(0);t=Math.min(Math.max(0,-t),24)-1;let e=[32+t];return new Uint8Array(e).buffer}Ne.iSmall=qf;function $f(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),255),t=t.toString(16),Ut(1,24,t)}Ne.i8=$f;function Vf(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),65535),t=t.toString(16),Ut(1,25,t)}Ne.i16=Vf;function jf(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),4294967295),t=t.toString(16),Ut(1,26,t)}Ne.i32=jf;function Hf(t,e){if(typeof t=="string"&&e==16){if(t.startsWith("-")?t=t.slice(1):t="0",t.match(/[^0-9a-fA-F]/)||t.length>16)throw new RangeError("Invalid number.");let r=!1,n=t.split("").reduceRight((i,s)=>{if(r)return s+i;let o=parseInt(s,16)-1;return o>=0?(r=!0,o.toString(16)+i):"f"+i},"");return r?Ut(1,27,n):ma(0)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),9007199254740992),t=t.toString(16),Ut(1,27,t)}Ne.i64=Hf;function Dd(t){return t>=0?t<24?pa(t):t<=255?kf(t):t<=65535?Mf(t):t<=4294967295?Cf(t):ma(t):t>=-24?qf(t):t>=-255?$f(t):t>=-65535?Vf(t):t>=-4294967295?jf(t):Hf(t)}Ne.number=Dd;function ep(t){return ur(hs(2,t.byteLength),t)}Ne.bytes=ep;function tp(t){return Pf(t)}Ne.string=tp;function rp(t){return ur(hs(4,t.length),...t)}Ne.array=rp;function np(t,e=!1){t instanceof Map||(t=new Map(Object.entries(t)));let r=Array.from(t.entries());return e&&(r=r.sort(([n],[i])=>n.localeCompare(i))),ur(hs(5,t.size),...r.map(([n,i])=>ur(Pf(n),i)))}Ne.map=np;function ip(t){let e=new Float32Array([t]);return ur(new Uint8Array([250]),new Uint8Array(e.buffer))}Ne.singleFloat=ip;function sp(t){let e=new Float64Array([t]);return ur(new Uint8Array([251]),new Uint8Array(e.buffer))}Ne.doubleFloat=sp;function op(t){return t?Gf():Yf()}Ne.bool=op;function Gf(){return Ln(new Uint8Array([245]))}Ne.true_=Gf;function Yf(){return Ln(new Uint8Array([244]))}Ne.false_=Yf;function ap(){return Ln(new Uint8Array([246]))}Ne.null_=ap;function cp(){return Ln(new Uint8Array([247]))}Ne.undefined_=cp});var zf=He(Br=>{"use strict";var up=Br&&Br.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(Br,"__esModule",{value:!0});var It=up(ya()),fp=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],ds=class{constructor(e,r=!1){this._serializer=e,this._stable=r,this.name="jsonDefault",this.priority=-100}match(e){return["undefined","boolean","number","string","object"].indexOf(typeof e)!=-1}encode(e){switch(typeof e){case"undefined":return It.undefined_();case"boolean":return It.bool(e);case"number":return Math.floor(e)===e?It.number(e):It.doubleFloat(e);case"string":return It.string(e);case"object":if(e===null)return It.null_();if(Array.isArray(e))return It.array(e.map(r=>this._serializer.serializeValue(r)));if(fp.find(r=>e instanceof r))return It.bytes(e.buffer);if(Object.getOwnPropertyNames(e).indexOf("toJSON")!==-1)return this.encode(e.toJSON());if(e instanceof Map){let r=new Map;for(let[n,i]of e.entries())r.set(n,this._serializer.serializeValue(i));return It.map(r,this._stable)}else{let r=new Map;for(let[n,i]of Object.entries(e))r.set(n,this._serializer.serializeValue(i));return It.map(r,this._stable)}default:throw new Error("Invalid value.")}}};Br.JsonDefaultCborEncoder=ds;var ps=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};Br.ToCborEncoder=ps;var ms=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let r=new this;return r.addEncoder(new ds(r,e)),r.addEncoder(new ps),r}removeEncoder(e){for(let r of this._encoders.values())r.name==e&&this._encoders.delete(r)}addEncoder(e){this._encoders.add(e)}getEncoderFor(e){let r=null;for(let n of this._encoders)(!r||n.priority>r.priority)&&n.match(e)&&(r=n);if(r===null)throw new Error("Could not find an encoder for value.");return r}serializeValue(e){return this.getEncoderFor(e).encode(e)}serialize(e){return this.serializeValue(e)}};Br.CborSerializer=ms;var ga=class extends ms{serialize(e){return It.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};Br.SelfDescribeCborSerializer=ga});var ys=He(zr=>{"use strict";function lp(t){for(var e in t)zr.hasOwnProperty(e)||(zr[e]=t[e])}var hp=zr&&zr.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(zr,"__esModule",{value:!0});lp(zf());var dp=hp(ya());zr.value=dp});function ws(t){return gs.serialize(t)}function Kf(t){let e=t.byteLength,r=BigInt(0);for(let n=0;n<e;n++)r=r*BigInt(256)+BigInt(t[n]);return r}function Tt(t){let e=new Uint8Array(t),r=new Ea({size:e.byteLength,tags:{2:n=>Kf(n),3:n=>-Kf(n),[_a.Semantic]:n=>n}});try{return r.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${Me(e)}`)}}var Wf,Kr,Zf,wa,ba,xa,gs,_a,Ea,Dn=he(()=>{Wf=tn(ha()),Kr=tn(ys()),Zf=tn(ys());lt();wa=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return Kr.value.bytes(e.toUint8Array())}},ba=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return Kr.value.bytes(new Uint8Array(e))}},xa=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?Kr.value.tagged(2,Kr.value.bytes(Hr(e.toString(16)))):Kr.value.tagged(3,Kr.value.bytes(Hr((BigInt("-1")*e).toString(16))))}},gs=Zf.SelfDescribeCborSerializer.withDefaultEncoders(!0);gs.addEncoder(new wa);gs.addEncoder(new ba);gs.addEncoder(new xa);(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(_a||(_a={}));Ea=class extends Wf.default.Decoder{createByteString(e){return nt(...e)}createByteStringFromHeap(e,r){return e===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,r))}}});var ei,va=he(()=>{ei=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let t=new Uint32Array(1);return window.crypto.getRandomValues(t),t[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let t=new Uint32Array(1);return crypto.getRandomValues(t),t[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)}});function gn(){let t=new ArrayBuffer(16),e=new DataView(t),r=ei(),n=ei(),i=ei(),s=ei();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),t}var xs,ti=he(()=>{va();(function(t){t.Call="call"})(xs||(xs={}))});function Ba(t=gn){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}function wn(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}var Jf,Xf,pp,Qt,_s=he(()=>{zn();Jf=tn(ys());ti();Xf=BigInt(1e6),pp=60*1e3,Qt=class{constructor(e){if(e<90*1e3){let a=BigInt(Date.now()+e)*Xf/BigInt(1e9);this._value=a*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+e-pp))*Xf/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return Jf.value.u64(this._value.toString(16),16)}toHash(){return Oe(this._value)}}});var bn,Aa=he(()=>{fn();bn=class extends Pe{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}}});var As={};Un(As,{aInRange:()=>Mt,abool:()=>Ar,abytes:()=>Pt,bitGet:()=>Fa,bitLen:()=>lr,bitMask:()=>Sr,bitSet:()=>bp,bytesToHex:()=>kt,bytesToNumberBE:()=>et,bytesToNumberLE:()=>Tr,concatBytes:()=>Te,createHmacDrbg:()=>Df,ensureBytes:()=>ze,equalBytes:()=>wp,hexToBytes:()=>ri,hexToNumber:()=>Oa,inRange:()=>vs,isBytes:()=>xn,memoized:()=>hr,notImplemented:()=>Bs,numberToBytesBE:()=>qe,numberToBytesLE:()=>Wr,numberToHexUnpadded:()=>Ra,numberToVarBytesBE:()=>gp,utf8ToBytes:()=>ni,validateObject:()=>Ct});function xn(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Pt(t){if(!xn(t))throw new Error("Uint8Array expected")}function Ar(t,e){if(typeof e!="boolean")throw new Error(`${t} must be valid boolean, got "${e}".`)}function kt(t){Pt(t);let e="";for(let r=0;r<t.length;r++)e+=yp[t[r]];return e}function Ra(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function Oa(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function Qf(t){if(t>=fr._0&&t<=fr._9)return t-fr._0;if(t>=fr._A&&t<=fr._F)return t-(fr._A-10);if(t>=fr._a&&t<=fr._f)return t-(fr._a-10)}function ri(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=Qf(t.charCodeAt(s)),a=Qf(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function et(t){return Oa(kt(t))}function Tr(t){return Pt(t),Oa(kt(Uint8Array.from(t).reverse()))}function qe(t,e){return ri(t.toString(16).padStart(e*2,"0"))}function Wr(t,e){return qe(t,e).reverse()}function gp(t){return ri(Ra(t))}function ze(t,e,r){let n;if(typeof e=="string")try{n=ri(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(xn(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function Te(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];Pt(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}function wp(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function ni(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function vs(t,e,r){return Ta(t)&&Ta(e)&&Ta(r)&&e<=t&&t<r}function Mt(t,e,r,n){if(!vs(e,r,n))throw new Error(`expected valid ${t}: ${r} <= n < ${n}, got ${typeof e} ${e}`)}function lr(t){let e;for(e=0;t>Na;t>>=Es,e+=1);return e}function Fa(t,e){return t>>BigInt(e)&Es}function bp(t,e,r){return t|(r?Es:Na)<<BigInt(e)}function Df(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=Sa(t),i=Sa(t),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...d)=>r(i,n,...d),c=(d=Sa())=>{i=a(Lf([0]),d),n=a(),d.length!==0&&(i=a(Lf([1]),d),n=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let d=0,w=[];for(;d<e;){n=a();let b=n.slice();w.push(b),d+=n.length}return Te(...w)};return(d,w)=>{o(),c(d);let b;for(;!(b=w(l()));)c();return o(),b}}function Ct(t,e,r={}){let n=(i,s,o)=>{let a=xp[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(r))n(i,s,!0);return t}function hr(t){let e=new WeakMap;return(r,...n)=>{let i=e.get(r);if(i!==void 0)return i;let s=t(r,...n);return e.set(r,s),s}}var Na,Es,mp,yp,fr,Ta,Sr,Sa,Lf,xp,Bs,qt=he(()=>{Na=BigInt(0),Es=BigInt(1),mp=BigInt(2);yp=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));fr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};Ta=t=>typeof t=="bigint"&&Na<=t;Sr=t=>(mp<<BigInt(t-1))-Es,Sa=t=>new Uint8Array(t),Lf=t=>Uint8Array.from(t);xp={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||xn(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};Bs=()=>{throw new Error("not implemented")}});function Re(t,e){let r=t%e;return r>=Ze?r:e+r}function Bp(t,e,r){if(r<=Ze||e<Ze)throw new Error("Expected power/modulo > 0");if(r===Fe)return Ze;let n=Fe;for(;e>Ze;)e&Fe&&(n=n*t%r),t=t*t%r,e>>=Fe;return n}function $t(t,e,r){let n=t;for(;e-- >Ze;)n*=n,n%=r;return n}function Ia(t,e){if(t===Ze||e<=Ze)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Re(t,e),n=e,i=Ze,s=Fe,o=Fe,a=Ze;for(;r!==Ze;){let l=n/r,h=n%r,d=i-o*l,w=s-a*l;n=r,r=h,i=o,s=a,o=d,a=w}if(n!==Fe)throw new Error("invert: does not exist");return Re(i,e)}function Ap(t){let e=(t-Fe)/Nr,r,n,i;for(r=t-Fe,n=0;r%Nr===Ze;r/=Nr,n++);for(i=Nr;i<t&&Bp(i,e,t)!==t-Fe;i++);if(n===1){let o=(t+Fe)/Ua;return function(c,l){let h=c.pow(l,o);if(!c.eql(c.sqr(h),l))throw new Error("Cannot find square root");return h}}let s=(r+Fe)/Nr;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,h=a.pow(a.mul(a.ONE,i),r),d=a.pow(c,s),w=a.pow(c,r);for(;!a.eql(w,a.ONE);){if(a.eql(w,a.ZERO))return a.ZERO;let b=1;for(let S=a.sqr(w);b<l&&!a.eql(S,a.ONE);b++)S=a.sqr(S);let f=a.pow(h,Fe<<BigInt(l-b-1));h=a.sqr(f),d=a.mul(d,f),w=a.mul(w,h),l=b}return d}}function Tp(t){if(t%Ua===_p){let e=(t+Fe)/Ua;return function(n,i){let s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(t%t0===e0){let e=(t-e0)/t0;return function(n,i){let s=n.mul(i,Nr),o=n.pow(s,e),a=n.mul(i,o),c=n.mul(n.mul(a,Nr),o),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),i))throw new Error("Cannot find square root");return l}}return t%vp,Ap(t)}function Ts(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Sp.reduce((n,i)=>(n[i]="function",n),e);return Ct(t,r)}function ii(t,e,r){if(r<Ze)throw new Error("Expected power > 0");if(r===Ze)return t.ONE;if(r===Fe)return e;let n=t.ONE,i=e;for(;r>Ze;)r&Fe&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Fe;return n}function si(t,e){let r=new Array(e.length),n=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),i=t.inv(n);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),i),r}function n0(t){let e=(t-Fe)/Nr;return(r,n)=>r.pow(n,e)}function Pa(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Lt(t,e,r=!1,n={}){if(t<=Ze)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:s}=Pa(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=Tp(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:Sr(i),ZERO:Ze,ONE:Fe,create:c=>Re(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return Ze<=c&&c<t},is0:c=>c===Ze,isOdd:c=>(c&Fe)===Fe,neg:c=>Re(-c,t),eql:(c,l)=>c===l,sqr:c=>Re(c*c,t),add:(c,l)=>Re(c+l,t),sub:(c,l)=>Re(c-l,t),mul:(c,l)=>Re(c*l,t),pow:(c,l)=>ii(a,c,l),div:(c,l)=>Re(c*Ia(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Ia(c,t),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>si(a,c),cmov:(c,l,h)=>h?l:c,toBytes:c=>r?Wr(c,s):qe(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?Tr(c):et(c)}});return Object.freeze(a)}function i0(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function Ss(t){let e=i0(t);return e+Math.ceil(e/2)}function ka(t,e,r=!1){let n=t.length,i=i0(e),s=Ss(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?et(t):Tr(t),a=Re(o,e-Fe)+Fe;return r?Wr(a,i):qe(a,i)}var Ze,Fe,Nr,_p,Ua,e0,t0,Ep,vp,r0,Sp,dr=he(()=>{qt();Ze=BigInt(0),Fe=BigInt(1),Nr=BigInt(2),_p=BigInt(3),Ua=BigInt(4),e0=BigInt(5),t0=BigInt(8),Ep=BigInt(9),vp=BigInt(16);r0=(t,e)=>(Re(t,e)&Fe)===Fe,Sp=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"]});function Rr(t,e){if(oi(t),oi(e),t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);let r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=t&255,t>>>=8;return new Uint8Array(r)}function Rp(t,e){let r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function oi(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function Op(t,e,r,n){Pt(t),Pt(e),oi(r),e.length>255&&(e=n(Te(ni("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(r/i);if(r>65535||o>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=Te(e,Rr(e.length,1)),c=Rr(0,s),l=Rr(r,2),h=new Array(o),d=n(Te(c,t,l,Rr(0,1),a));h[0]=n(Te(d,Rr(1,1),a));for(let b=1;b<=o;b++){let f=[Rp(d,h[b-1]),Rr(b+1,1),a];h[b]=n(Te(...f))}return Te(...h).slice(0,r)}function Fp(t,e,r,n,i){if(Pt(t),Pt(e),oi(r),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update(ni("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(t).update(Rr(r,2)).update(e).update(Rr(e.length,1)).digest()}function s0(t,e,r){Ct(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:o,expand:a,DST:c}=r;Pt(t),oi(e);let l=typeof c=="string"?ni(c):c,h=n.toString(2).length,d=Math.ceil((h+i)/8),w=e*s*d,b;if(a==="xmd")b=Op(t,l,w,o);else if(a==="xof")b=Fp(t,l,w,i,o);else if(a==="_internal_pass")b=t;else throw new Error('expand must be "xmd" or "xof"');let f=new Array(e);for(let S=0;S<e;S++){let R=new Array(s);for(let O=0;O<s;O++){let V=d*(O+S*s),q=b.subarray(V,V+d);R[O]=Re(Np(q),n)}f[S]=R}return f}function Ca(t,e){let r=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,a,c]=r.map(l=>l.reduce((h,d)=>t.add(t.mul(h,n),d)));return n=t.div(s,o),i=t.mul(i,t.div(a,c)),{x:n,y:i}}}function qa(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=s0(n,2,{...r,DST:r.DST,...i}),o=t.fromAffine(e(s[0])),a=t.fromAffine(e(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=s0(n,1,{...r,DST:r.encodeDST,...i}),o=t.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(let s of n)if(typeof s!="bigint")throw new Error(`mapToCurve: expected array of bigints, got ${s} in array`);let i=t.fromAffine(e(n)).clearCofactor();return i.assertValidity(),i}}}var Np,$a=he(()=>{dr();qt();Np=et});function Ns(t,e){let r=(s,o)=>{let a=o.negate();return s?a:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>e)throw new Error(`Wrong window size=${s}, should be [1..${e}]`)},i=s=>{n(s);let o=Math.ceil(e/s)+1,a=2**(s-1);return{windows:o,windowSize:a}};return{constTimeNegate:r,unsafeLadder(s,o){let a=t.ZERO,c=s;for(;o>Up;)o&Va&&(a=a.add(c)),c=c.double(),o>>=Va;return a},precomputeWindow(s,o){let{windows:a,windowSize:c}=i(o),l=[],h=s,d=h;for(let w=0;w<a;w++){d=h,l.push(d);for(let b=1;b<c;b++)d=d.add(h),l.push(d);h=d.double()}return l},wNAF(s,o,a){let{windows:c,windowSize:l}=i(s),h=t.ZERO,d=t.BASE,w=BigInt(2**s-1),b=2**s,f=BigInt(s);for(let S=0;S<c;S++){let R=S*l,O=Number(a&w);a>>=f,O>l&&(O-=b,a+=Va);let V=R,q=R+Math.abs(O)-1,Y=S%2!==0,E=O<0;O===0?d=d.add(r(Y,o[V])):h=h.add(r(E,o[q]))}return{p:h,f:d}},wNAFCached(s,o,a){let c=o0.get(s)||1,l=ja.get(s);return l||(l=this.precomputeWindow(s,c),c!==1&&ja.set(s,a(l))),this.wNAF(c,l,o)},setWindowSize(s,o){n(o),o0.set(s,o),ja.delete(s)}}}function Rs(t,e,r,n){if(!Array.isArray(r)||!Array.isArray(n)||n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((h,d)=>{if(!e.isValid(h))throw new Error(`wrong scalar at index ${d}`)}),r.forEach((h,d)=>{if(!(h instanceof t))throw new Error(`wrong point at index ${d}`)});let i=lr(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,o=(1<<s)-1,a=new Array(o+1).fill(t.ZERO),c=Math.floor((e.BITS-1)/s)*s,l=t.ZERO;for(let h=c;h>=0;h-=s){a.fill(t.ZERO);for(let w=0;w<n.length;w++){let b=n[w],f=Number(b>>BigInt(h)&BigInt(o));a[f]=a[f].add(r[w])}let d=t.ZERO;for(let w=a.length-1,b=t.ZERO;w>0;w--)b=b.add(a[w]),d=d.add(b);if(l=l.add(d),h!==0)for(let w=0;w<s;w++)l=l.double()}return l}function Os(t){return Ts(t.Fp),Ct(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Pa(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}var Up,Va,ja,o0,Ha=he(()=>{dr();qt();Up=BigInt(0),Va=BigInt(1),ja=new WeakMap,o0=new WeakMap});function Ip(t){let e=Os(t);Ct(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}function Ga(t){let e=Ip(t),{Fp:r}=e,n=Lt(e.n,e.nBitLength),i=e.toBytes||((S,R,O)=>{let V=R.toAffine();return Te(Uint8Array.from([4]),r.toBytes(V.x),r.toBytes(V.y))}),s=e.fromBytes||(S=>{let R=S.subarray(1),O=r.fromBytes(R.subarray(0,r.BYTES)),V=r.fromBytes(R.subarray(r.BYTES,2*r.BYTES));return{x:O,y:V}});function o(S){let{a:R,b:O}=e,V=r.sqr(S),q=r.mul(V,S);return r.add(r.add(q,r.mul(S,R)),O)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(S){return vs(S,$e,e.n)}function c(S){let{allowedPrivateKeyLengths:R,nByteLength:O,wrapPrivateKey:V,n:q}=e;if(R&&typeof S!="bigint"){if(xn(S)&&(S=kt(S)),typeof S!="string"||!R.includes(S.length))throw new Error("Invalid key");S=S.padStart(O*2,"0")}let Y;try{Y=typeof S=="bigint"?S:et(ze("private key",S,O))}catch{throw new Error(`private key must be ${O} bytes, hex or bigint, not ${typeof S}`)}return V&&(Y=Re(Y,q)),Mt("private key",Y,$e,q),Y}function l(S){if(!(S instanceof w))throw new Error("ProjectivePoint expected")}let h=hr((S,R)=>{let{px:O,py:V,pz:q}=S;if(r.eql(q,r.ONE))return{x:O,y:V};let Y=S.is0();R==null&&(R=Y?r.ONE:r.inv(q));let E=r.mul(O,R),H=r.mul(V,R),z=r.mul(q,R);if(Y)return{x:r.ZERO,y:r.ZERO};if(!r.eql(z,r.ONE))throw new Error("invZ was invalid");return{x:E,y:H}}),d=hr(S=>{if(S.is0()){if(e.allowInfinityPoint&&!r.is0(S.py))return;throw new Error("bad point: ZERO")}let{x:R,y:O}=S.toAffine();if(!r.isValid(R)||!r.isValid(O))throw new Error("bad point: x or y not FE");let V=r.sqr(O),q=o(R);if(!r.eql(V,q))throw new Error("bad point: equation left != right");if(!S.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class w{constructor(R,O,V){if(this.px=R,this.py=O,this.pz=V,R==null||!r.isValid(R))throw new Error("x required");if(O==null||!r.isValid(O))throw new Error("y required");if(V==null||!r.isValid(V))throw new Error("z required");Object.freeze(this)}static fromAffine(R){let{x:O,y:V}=R||{};if(!R||!r.isValid(O)||!r.isValid(V))throw new Error("invalid affine point");if(R instanceof w)throw new Error("projective point not allowed");let q=Y=>r.eql(Y,r.ZERO);return q(O)&&q(V)?w.ZERO:new w(O,V,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(R){let O=r.invertBatch(R.map(V=>V.pz));return R.map((V,q)=>V.toAffine(O[q])).map(w.fromAffine)}static fromHex(R){let O=w.fromAffine(s(ze("pointHex",R)));return O.assertValidity(),O}static fromPrivateKey(R){return w.BASE.multiply(c(R))}static msm(R,O){return Rs(w,n,R,O)}_setWindowSize(R){f.setWindowSize(this,R)}assertValidity(){d(this)}hasEvenY(){let{y:R}=this.toAffine();if(r.isOdd)return!r.isOdd(R);throw new Error("Field doesn't support isOdd")}equals(R){l(R);let{px:O,py:V,pz:q}=this,{px:Y,py:E,pz:H}=R,z=r.eql(r.mul(O,H),r.mul(Y,q)),Z=r.eql(r.mul(V,H),r.mul(E,q));return z&&Z}negate(){return new w(this.px,r.neg(this.py),this.pz)}double(){let{a:R,b:O}=e,V=r.mul(O,Fs),{px:q,py:Y,pz:E}=this,H=r.ZERO,z=r.ZERO,Z=r.ZERO,C=r.mul(q,q),ie=r.mul(Y,Y),re=r.mul(E,E),ee=r.mul(q,Y);return ee=r.add(ee,ee),Z=r.mul(q,E),Z=r.add(Z,Z),H=r.mul(R,Z),z=r.mul(V,re),z=r.add(H,z),H=r.sub(ie,z),z=r.add(ie,z),z=r.mul(H,z),H=r.mul(ee,H),Z=r.mul(V,Z),re=r.mul(R,re),ee=r.sub(C,re),ee=r.mul(R,ee),ee=r.add(ee,Z),Z=r.add(C,C),C=r.add(Z,C),C=r.add(C,re),C=r.mul(C,ee),z=r.add(z,C),re=r.mul(Y,E),re=r.add(re,re),C=r.mul(re,ee),H=r.sub(H,C),Z=r.mul(re,ie),Z=r.add(Z,Z),Z=r.add(Z,Z),new w(H,z,Z)}add(R){l(R);let{px:O,py:V,pz:q}=this,{px:Y,py:E,pz:H}=R,z=r.ZERO,Z=r.ZERO,C=r.ZERO,ie=e.a,re=r.mul(e.b,Fs),ee=r.mul(O,Y),g=r.mul(V,E),B=r.mul(q,H),$=r.add(O,V),F=r.add(Y,E);$=r.mul($,F),F=r.add(ee,g),$=r.sub($,F),F=r.add(O,q);let U=r.add(Y,H);return F=r.mul(F,U),U=r.add(ee,B),F=r.sub(F,U),U=r.add(V,q),z=r.add(E,H),U=r.mul(U,z),z=r.add(g,B),U=r.sub(U,z),C=r.mul(ie,F),z=r.mul(re,B),C=r.add(z,C),z=r.sub(g,C),C=r.add(g,C),Z=r.mul(z,C),g=r.add(ee,ee),g=r.add(g,ee),B=r.mul(ie,B),F=r.mul(re,F),g=r.add(g,B),B=r.sub(ee,B),B=r.mul(ie,B),F=r.add(F,B),ee=r.mul(g,F),Z=r.add(Z,ee),ee=r.mul(U,F),z=r.mul($,z),z=r.sub(z,ee),ee=r.mul($,g),C=r.mul(U,C),C=r.add(C,ee),new w(z,Z,C)}subtract(R){return this.add(R.negate())}is0(){return this.equals(w.ZERO)}wNAF(R){return f.wNAFCached(this,R,w.normalizeZ)}multiplyUnsafe(R){Mt("scalar",R,Zr,e.n);let O=w.ZERO;if(R===Zr)return O;if(R===$e)return this;let{endo:V}=e;if(!V)return f.unsafeLadder(this,R);let{k1neg:q,k1:Y,k2neg:E,k2:H}=V.splitScalar(R),z=O,Z=O,C=this;for(;Y>Zr||H>Zr;)Y&$e&&(z=z.add(C)),H&$e&&(Z=Z.add(C)),C=C.double(),Y>>=$e,H>>=$e;return q&&(z=z.negate()),E&&(Z=Z.negate()),Z=new w(r.mul(Z.px,V.beta),Z.py,Z.pz),z.add(Z)}multiply(R){let{endo:O,n:V}=e;Mt("scalar",R,$e,V);let q,Y;if(O){let{k1neg:E,k1:H,k2neg:z,k2:Z}=O.splitScalar(R),{p:C,f:ie}=this.wNAF(H),{p:re,f:ee}=this.wNAF(Z);C=f.constTimeNegate(E,C),re=f.constTimeNegate(z,re),re=new w(r.mul(re.px,O.beta),re.py,re.pz),q=C.add(re),Y=ie.add(ee)}else{let{p:E,f:H}=this.wNAF(R);q=E,Y=H}return w.normalizeZ([q,Y])[0]}multiplyAndAddUnsafe(R,O,V){let q=w.BASE,Y=(H,z)=>z===Zr||z===$e||!H.equals(q)?H.multiplyUnsafe(z):H.multiply(z),E=Y(this,O).add(Y(R,V));return E.is0()?void 0:E}toAffine(R){return h(this,R)}isTorsionFree(){let{h:R,isTorsionFree:O}=e;if(R===$e)return!0;if(O)return O(w,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:R,clearCofactor:O}=e;return R===$e?this:O?O(w,this):this.multiplyUnsafe(e.h)}toRawBytes(R=!0){return Ar("isCompressed",R),this.assertValidity(),i(w,this,R)}toHex(R=!0){return Ar("isCompressed",R),kt(this.toRawBytes(R))}}w.BASE=new w(e.Gx,e.Gy,r.ONE),w.ZERO=new w(r.ZERO,r.ONE,r.ZERO);let b=e.nBitLength,f=Ns(w,e.endo?Math.ceil(b/2):b);return{CURVE:e,ProjectivePoint:w,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function Pp(t,e){let r=t.ORDER,n=Zr;for(let f=r-$e;f%Or===Zr;f/=Or)n+=$e;let i=n,s=Or<<i-$e-$e,o=s*Or,a=(r-$e)/o,c=(a-$e)/Or,l=o-$e,h=s,d=t.pow(e,a),w=t.pow(e,(a+$e)/Or),b=(f,S)=>{let R=d,O=t.pow(S,l),V=t.sqr(O);V=t.mul(V,S);let q=t.mul(f,V);q=t.pow(q,c),q=t.mul(q,O),O=t.mul(q,S),V=t.mul(q,f);let Y=t.mul(V,O);q=t.pow(Y,h);let E=t.eql(q,t.ONE);O=t.mul(V,w),q=t.mul(Y,R),V=t.cmov(O,V,E),Y=t.cmov(q,Y,E);for(let H=i;H>$e;H--){let z=H-Or;z=Or<<z-$e;let Z=t.pow(Y,z),C=t.eql(Z,t.ONE);O=t.mul(V,R),R=t.mul(R,R),Z=t.mul(Y,R),V=t.cmov(O,V,C),Y=t.cmov(Z,Y,C)}return{isValid:E,value:V}};if(t.ORDER%a0===Fs){let f=(t.ORDER-Fs)/a0,S=t.sqrt(t.neg(e));b=(R,O)=>{let V=t.sqr(O),q=t.mul(R,O);V=t.mul(V,q);let Y=t.pow(V,f);Y=t.mul(Y,q);let E=t.mul(Y,S),H=t.mul(t.sqr(Y),O),z=t.eql(H,R),Z=t.cmov(E,Y,z);return{isValid:z,value:Z}}}return b}function Ya(t,e){if(Ts(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=Pp(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,a,c,l,h,d;i=t.sqr(n),i=t.mul(i,e.Z),s=t.sqr(i),s=t.add(s,i),o=t.add(s,t.ONE),o=t.mul(o,e.B),a=t.cmov(e.Z,t.neg(s),!t.eql(s,t.ZERO)),a=t.mul(a,e.A),s=t.sqr(o),l=t.sqr(a),c=t.mul(l,e.A),s=t.add(s,c),s=t.mul(s,o),l=t.mul(l,a),c=t.mul(l,e.B),s=t.add(s,c),h=t.mul(i,o);let{isValid:w,value:b}=r(s,l);d=t.mul(i,n),d=t.mul(d,b),h=t.cmov(h,o,w),d=t.cmov(d,b,w);let f=t.isOdd(n)===t.isOdd(d);return d=t.cmov(t.neg(d),d,f),h=t.div(h,a),{x:h,y:d}}}var cg,ug,Zr,$e,Or,Fs,a0,za=he(()=>{Ha();dr();qt();qt();({bytesToNumberBE:cg,hexToBytes:ug}=As),Zr=BigInt(0),$e=BigInt(1),Or=BigInt(2),Fs=BigInt(3),a0=BigInt(4)});function Mp(t){let e=[];for(;t>Us;t>>=Us)(t&Us)===kp?e.unshift(0):(t&_n)===_n?(e.unshift(-1),t+=Us):e.unshift(1);return e}function u0(t){let{Fp:e,Fr:r,Fp2:n,Fp6:i,Fp12:s}=t.fields,o=t.params.xNegative,a=t.params.twistType,c=Ga({n:r.ORDER,...t.G1}),l=Object.assign(c,qa(c.ProjectivePoint,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults})),h=Ga({n:r.ORDER,...t.G2}),d=Object.assign(h,qa(h.ProjectivePoint,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),w;if(a==="multiplicative")w=(W,P,m,L,te,le)=>s.mul014(L,W,n.mul(P,te),n.mul(m,le));else if(a==="divisive")w=(W,P,m,L,te,le)=>s.mul034(L,n.mul(m,le),n.mul(P,te),W);else throw new Error("bls: unknown twist type");let b=n.div(n.ONE,n.mul(n.ONE,c0));function f(W,P,m,L){let te=n.sqr(m),le=n.sqr(L),D=n.mulByB(n.mul(le,_n)),u=n.mul(D,_n),p=n.sub(n.sub(n.sqr(n.add(m,L)),le),te),y=n.sub(D,te),T=n.mul(n.sqr(P),_n),v=n.neg(p);return W.push([y,T,v]),P=n.mul(n.mul(n.mul(n.sub(te,u),P),m),b),m=n.sub(n.sqr(n.mul(n.add(te,u),b)),n.mul(n.sqr(D),_n)),L=n.mul(te,p),{Rx:P,Ry:m,Rz:L}}function S(W,P,m,L,te,le){let D=n.sub(m,n.mul(le,L)),u=n.sub(P,n.mul(te,L)),p=n.sub(n.mul(D,te),n.mul(u,le)),y=n.neg(D),T=u;W.push([p,y,T]);let v=n.sqr(u),A=n.mul(v,u),M=n.mul(v,P),x=n.add(n.sub(A,n.mul(M,c0)),n.mul(n.sqr(D),L));return P=n.mul(u,x),m=n.sub(n.mul(n.sub(M,x),D),n.mul(A,m)),L=n.mul(L,A),{Rx:P,Ry:m,Rz:L}}let R=Mp(t.params.ateLoopSize),O=hr(W=>{let P=W,{x:m,y:L}=P.toAffine(),te=m,le=L,D=n.neg(L),u=te,p=le,y=n.ONE,T=[];for(let v of R){let A=[];({Rx:u,Ry:p,Rz:y}=f(A,u,p,y)),v&&({Rx:u,Ry:p,Rz:y}=S(A,u,p,y,te,v===-1?D:le)),T.push(A)}if(t.postPrecompute){let v=T[T.length-1];t.postPrecompute(u,p,y,te,le,S.bind(null,v))}return T});function V(W,P=!1){let m=s.ONE;if(W.length){let L=W[0][0].length;for(let te=0;te<L;te++){m=s.sqr(m);for(let[le,D,u]of W)for(let[p,y,T]of le[te])m=w(p,y,T,m,D,u)}}return o&&(m=s.conjugate(m)),P?s.finalExponentiate(m):m}function q(W,P=!0){let m=[];l.ProjectivePoint.normalizeZ(W.map(({g1:L})=>L)),d.ProjectivePoint.normalizeZ(W.map(({g2:L})=>L));for(let{g1:L,g2:te}of W){if(L.equals(l.ProjectivePoint.ZERO)||te.equals(d.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");L.assertValidity(),te.assertValidity();let le=L.toAffine();m.push([O(te),le.x,le.y])}return V(m,P)}function Y(W,P,m=!0){return q([{g1:W,g2:P}],m)}let E={randomPrivateKey:()=>{let W=Ss(r.ORDER);return ka(t.randomBytes(W),r.ORDER)},calcPairingPrecomputes:O},{ShortSignature:H}=t.G1,{Signature:z}=t.G2;function Z(W){return W instanceof l.ProjectivePoint?W:l.ProjectivePoint.fromHex(W)}function C(W,P){return W instanceof l.ProjectivePoint?W:l.hashToCurve(ze("point",W),P)}function ie(W){return W instanceof d.ProjectivePoint?W:z.fromHex(W)}function re(W,P){return W instanceof d.ProjectivePoint?W:d.hashToCurve(ze("point",W),P)}function ee(W){return l.ProjectivePoint.fromPrivateKey(W).toRawBytes(!0)}function g(W){return d.ProjectivePoint.fromPrivateKey(W).toRawBytes(!0)}function B(W,P,m){let L=re(W,m);L.assertValidity();let te=L.multiply(l.normPrivateKeyToScalar(P));return W instanceof d.ProjectivePoint?te:z.toRawBytes(te)}function $(W,P,m){let L=C(W,m);L.assertValidity();let te=L.multiply(l.normPrivateKeyToScalar(P));return W instanceof l.ProjectivePoint?te:H.toRawBytes(te)}function F(W,P,m,L){let te=Z(m),le=re(P,L),D=l.ProjectivePoint.BASE,u=ie(W),p=q([{g1:te.negate(),g2:le},{g1:D,g2:u}]);return s.eql(p,s.ONE)}function U(W,P,m,L){let te=ie(m),le=C(P,L),D=d.ProjectivePoint.BASE,u=Z(W),p=q([{g1:le,g2:te},{g1:u,g2:D.negate()}]);return s.eql(p,s.ONE)}function G(W){if(!W.length)throw new Error("Expected non-empty array");let m=W.map(Z).reduce((L,te)=>L.add(te),l.ProjectivePoint.ZERO);return W[0]instanceof l.ProjectivePoint?(m.assertValidity(),m):m.toRawBytes(!0)}function J(W){if(!W.length)throw new Error("Expected non-empty array");let m=W.map(ie).reduce((L,te)=>L.add(te),d.ProjectivePoint.ZERO);return W[0]instanceof d.ProjectivePoint?(m.assertValidity(),m):z.toRawBytes(m)}function fe(W){if(!W.length)throw new Error("Expected non-empty array");let m=W.map(Z).reduce((L,te)=>L.add(te),l.ProjectivePoint.ZERO);return W[0]instanceof l.ProjectivePoint?(m.assertValidity(),m):H.toRawBytes(m)}function ce(W,P,m,L){if(!P.length)throw new Error("Expected non-empty messages array");if(m.length!==P.length)throw new Error("Pubkey count should equal msg count");let te=ie(W),le=P.map(y=>re(y,L)),D=m.map(Z),u=new Map;for(let y=0;y<D.length;y++){let T=D[y],v=le[y],A=u.get(v);A===void 0&&(A=[],u.set(v,A)),A.push(T)}let p=[];try{for(let[y,T]of u){let v=T.reduce((A,M)=>A.add(M));p.push({g1:v,g2:y})}return p.push({g1:l.ProjectivePoint.BASE.negate(),g2:te}),s.eql(q(p),s.ONE)}catch{return!1}}return l.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:ee,getPublicKeyForShortSignatures:g,sign:B,signShortSignature:$,verify:F,verifyBatch:ce,verifyShortSignature:U,aggregatePublicKeys:G,aggregateSignatures:J,aggregateShortSignatures:fe,millerLoopBatch:V,pairing:Y,pairingBatch:q,G1:l,G2:d,Signature:z,ShortSignature:H,fields:{Fr:r,Fp:e,Fp2:n,Fp6:i,Fp12:s},params:{ateLoopSize:t.params.ateLoopSize,r:t.params.r,G1b:t.G1.b,G2b:t.G2.b},utils:E}}var kp,Us,c0,_n,f0=he(()=>{dr();qt();$a();za();kp=BigInt(0),Us=BigInt(1),c0=BigInt(2),_n=BigInt(3)});function Ka(t,e,r,n,i=1,s){let o=BigInt(s===void 0?n:s),a=r**BigInt(n),c=[];for(let l=0;l<i;l++){let h=BigInt(l+1),d=[];for(let w=0,b=En;w<n;w++){let f=(h*b-h)/o%a;d.push(t.pow(e,f)),b*=r}c.push(d)}return c}function h0(t,e,r){let n=e.pow(r,(t.ORDER-En)/l0),i=e.pow(r,(t.ORDER-En)/pr);function s(w,b){let f=e.mul(e.frobeniusMap(w,1),n),S=e.mul(e.frobeniusMap(b,1),i);return[f,S]}let o=e.pow(r,(t.ORDER**pr-En)/l0),a=e.pow(r,(t.ORDER**pr-En)/pr);if(!e.eql(a,e.neg(e.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(w,b){return[e.mul(w,o),e.neg(b)]}let l=w=>(b,f)=>{let S=f.toAffine(),R=w(S.x,S.y);return b.fromAffine({x:R[0],y:R[1]})},h=l(s),d=l(c);return{psi:s,psi2:c,G2psi:h,G2psi2:d,PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:a}}function d0(t){let{ORDER:e}=t,r=Lt(e),n=r.create(t.NONRESIDUE||BigInt(-1)),i=n0(e),s=r.div(r.ONE,pr),o=Ka(r,n,r.ORDER,2)[0],a=({c0:g,c1:B},{c0:$,c1:F})=>({c0:r.add(g,$),c1:r.add(B,F)}),c=({c0:g,c1:B},{c0:$,c1:F})=>({c0:r.sub(g,$),c1:r.sub(B,F)}),l=({c0:g,c1:B},$)=>{if(typeof $=="bigint")return{c0:r.mul(g,$),c1:r.mul(B,$)};let{c0:F,c1:U}=$,G=r.mul(g,F),J=r.mul(B,U),fe=r.sub(G,J),ce=r.sub(r.mul(r.add(g,B),r.add(F,U)),r.add(G,J));return{c0:fe,c1:ce}},h=({c0:g,c1:B})=>{let $=r.add(g,B),F=r.sub(g,B),U=r.add(g,g);return{c0:r.mul($,F),c1:r.mul(U,B)}},d=g=>{if(g.length!==2)throw new Error("Invalid tuple");let B=g.map($=>r.create($));return{c0:B[0],c1:B[1]}},w=e*e,b=d(t.FP2_NONRESIDUE),f={ORDER:w,NONRESIDUE:b,BITS:lr(w),BYTES:Math.ceil(lr(w)/8),MASK:Sr(lr(w)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:g=>g,isValid:({c0:g,c1:B})=>typeof g=="bigint"&&typeof B=="bigint",is0:({c0:g,c1:B})=>r.is0(g)&&r.is0(B),eql:({c0:g,c1:B},{c0:$,c1:F})=>r.eql(g,$)&&r.eql(B,F),neg:({c0:g,c1:B})=>({c0:r.neg(g),c1:r.neg(B)}),pow:(g,B)=>ii(f,g,B),invertBatch:g=>si(f,g),add:a,sub:c,mul:l,sqr:h,addN:a,subN:c,mulN:l,sqrN:h,div:(g,B)=>f.mul(g,typeof B=="bigint"?r.inv(r.create(B)):f.inv(B)),inv:({c0:g,c1:B})=>{let $=r.inv(r.create(g*g+B*B));return{c0:r.mul($,r.create(g)),c1:r.mul($,r.create(-B))}},sqrt:g=>{if(t.Fp2sqrt)return t.Fp2sqrt(g);let{c0:B,c1:$}=g;if(r.is0($))return r.eql(i(r,B),r.ONE)?f.create({c0:r.sqrt(B),c1:r.ZERO}):f.create({c0:r.ZERO,c1:r.sqrt(r.div(B,n))});let F=r.sqrt(r.sub(r.sqr(B),r.mul(r.sqr($),n))),U=r.mul(r.add(F,B),s),G=i(r,U);!r.is0(G)&&!r.eql(G,r.ONE)&&(U=r.sub(U,F));let J=r.sqrt(U),fe=f.create({c0:J,c1:r.div(r.mul($,s),J)});if(!f.eql(f.sqr(fe),g))throw new Error("Cannot find square root");let ce=fe,W=f.neg(ce),{re:P,im:m}=f.reim(ce),{re:L,im:te}=f.reim(W);return m>te||m===te&&P>L?ce:W},isOdd:g=>{let{re:B,im:$}=f.reim(g),F=B%pr,U=B===Cp,G=$%pr;return BigInt(F||U&&G)==En},fromBytes(g){if(g.length!==f.BYTES)throw new Error(`fromBytes wrong length=${g.length}`);return{c0:r.fromBytes(g.subarray(0,r.BYTES)),c1:r.fromBytes(g.subarray(r.BYTES))}},toBytes:({c0:g,c1:B})=>Te(r.toBytes(g),r.toBytes(B)),cmov:({c0:g,c1:B},{c0:$,c1:F},U)=>({c0:r.cmov(g,$,U),c1:r.cmov(B,F,U)}),reim:({c0:g,c1:B})=>({re:g,im:B}),mulByNonresidue:({c0:g,c1:B})=>f.mul({c0:g,c1:B},b),mulByB:t.Fp2mulByB,fromBigTuple:d,frobeniusMap:({c0:g,c1:B},$)=>({c0:g,c1:r.mul(B,o[$%2])})},S=({c0:g,c1:B,c2:$},{c0:F,c1:U,c2:G})=>({c0:f.add(g,F),c1:f.add(B,U),c2:f.add($,G)}),R=({c0:g,c1:B,c2:$},{c0:F,c1:U,c2:G})=>({c0:f.sub(g,F),c1:f.sub(B,U),c2:f.sub($,G)}),O=({c0:g,c1:B,c2:$},F)=>{if(typeof F=="bigint")return{c0:f.mul(g,F),c1:f.mul(B,F),c2:f.mul($,F)};let{c0:U,c1:G,c2:J}=F,fe=f.mul(g,U),ce=f.mul(B,G),W=f.mul($,J);return{c0:f.add(fe,f.mulByNonresidue(f.sub(f.mul(f.add(B,$),f.add(G,J)),f.add(ce,W)))),c1:f.add(f.sub(f.mul(f.add(g,B),f.add(U,G)),f.add(fe,ce)),f.mulByNonresidue(W)),c2:f.sub(f.add(ce,f.mul(f.add(g,$),f.add(U,J))),f.add(fe,W))}},V=({c0:g,c1:B,c2:$})=>{let F=f.sqr(g),U=f.mul(f.mul(g,B),pr),G=f.mul(f.mul(B,$),pr),J=f.sqr($);return{c0:f.add(f.mulByNonresidue(G),F),c1:f.add(f.mulByNonresidue(J),U),c2:f.sub(f.sub(f.add(f.add(U,f.sqr(f.add(f.sub(g,B),$))),G),F),J)}},[q,Y]=Ka(f,b,r.ORDER,6,2,3),E={ORDER:f.ORDER,BITS:3*f.BITS,BYTES:3*f.BYTES,MASK:Sr(3*f.BITS),ZERO:{c0:f.ZERO,c1:f.ZERO,c2:f.ZERO},ONE:{c0:f.ONE,c1:f.ZERO,c2:f.ZERO},create:g=>g,isValid:({c0:g,c1:B,c2:$})=>f.isValid(g)&&f.isValid(B)&&f.isValid($),is0:({c0:g,c1:B,c2:$})=>f.is0(g)&&f.is0(B)&&f.is0($),neg:({c0:g,c1:B,c2:$})=>({c0:f.neg(g),c1:f.neg(B),c2:f.neg($)}),eql:({c0:g,c1:B,c2:$},{c0:F,c1:U,c2:G})=>f.eql(g,F)&&f.eql(B,U)&&f.eql($,G),sqrt:Bs,div:(g,B)=>E.mul(g,typeof B=="bigint"?r.inv(r.create(B)):E.inv(B)),pow:(g,B)=>ii(E,g,B),invertBatch:g=>si(E,g),add:S,sub:R,mul:O,sqr:V,addN:S,subN:R,mulN:O,sqrN:V,inv:({c0:g,c1:B,c2:$})=>{let F=f.sub(f.sqr(g),f.mulByNonresidue(f.mul($,B))),U=f.sub(f.mulByNonresidue(f.sqr($)),f.mul(g,B)),G=f.sub(f.sqr(B),f.mul(g,$)),J=f.inv(f.add(f.mulByNonresidue(f.add(f.mul($,U),f.mul(B,G))),f.mul(g,F)));return{c0:f.mul(J,F),c1:f.mul(J,U),c2:f.mul(J,G)}},fromBytes:g=>{if(g.length!==E.BYTES)throw new Error(`fromBytes wrong length=${g.length}`);return{c0:f.fromBytes(g.subarray(0,f.BYTES)),c1:f.fromBytes(g.subarray(f.BYTES,2*f.BYTES)),c2:f.fromBytes(g.subarray(2*f.BYTES))}},toBytes:({c0:g,c1:B,c2:$})=>Te(f.toBytes(g),f.toBytes(B),f.toBytes($)),cmov:({c0:g,c1:B,c2:$},{c0:F,c1:U,c2:G},J)=>({c0:f.cmov(g,F,J),c1:f.cmov(B,U,J),c2:f.cmov($,G,J)}),fromBigSix:g=>{if(!Array.isArray(g)||g.length!==6)throw new Error("Invalid Fp6 usage");return{c0:f.fromBigTuple(g.slice(0,2)),c1:f.fromBigTuple(g.slice(2,4)),c2:f.fromBigTuple(g.slice(4,6))}},frobeniusMap:({c0:g,c1:B,c2:$},F)=>({c0:f.frobeniusMap(g,F),c1:f.mul(f.frobeniusMap(B,F),q[F%6]),c2:f.mul(f.frobeniusMap($,F),Y[F%6])}),mulByFp2:({c0:g,c1:B,c2:$},F)=>({c0:f.mul(g,F),c1:f.mul(B,F),c2:f.mul($,F)}),mulByNonresidue:({c0:g,c1:B,c2:$})=>({c0:f.mulByNonresidue($),c1:g,c2:B}),mul1:({c0:g,c1:B,c2:$},F)=>({c0:f.mulByNonresidue(f.mul($,F)),c1:f.mul(g,F),c2:f.mul(B,F)}),mul01({c0:g,c1:B,c2:$},F,U){let G=f.mul(g,F),J=f.mul(B,U);return{c0:f.add(f.mulByNonresidue(f.sub(f.mul(f.add(B,$),U),J)),G),c1:f.sub(f.sub(f.mul(f.add(F,U),f.add(g,B)),G),J),c2:f.add(f.sub(f.mul(f.add(g,$),F),G),J)}}},H=Ka(f,b,r.ORDER,12,1,6)[0],z=({c0:g,c1:B},{c0:$,c1:F})=>({c0:E.add(g,$),c1:E.add(B,F)}),Z=({c0:g,c1:B},{c0:$,c1:F})=>({c0:E.sub(g,$),c1:E.sub(B,F)}),C=({c0:g,c1:B},$)=>{if(typeof $=="bigint")return{c0:E.mul(g,$),c1:E.mul(B,$)};let{c0:F,c1:U}=$,G=E.mul(g,F),J=E.mul(B,U);return{c0:E.add(G,E.mulByNonresidue(J)),c1:E.sub(E.mul(E.add(g,B),E.add(F,U)),E.add(G,J))}},ie=({c0:g,c1:B})=>{let $=E.mul(g,B);return{c0:E.sub(E.sub(E.mul(E.add(E.mulByNonresidue(B),g),E.add(g,B)),$),E.mulByNonresidue($)),c1:E.add($,$)}};function re(g,B){let $=f.sqr(g),F=f.sqr(B);return{first:f.add(f.mulByNonresidue(F),$),second:f.sub(f.sub(f.sqr(f.add(g,B)),$),F)}}let ee={ORDER:f.ORDER,BITS:2*f.BITS,BYTES:2*f.BYTES,MASK:Sr(2*f.BITS),ZERO:{c0:E.ZERO,c1:E.ZERO},ONE:{c0:E.ONE,c1:E.ZERO},create:g=>g,isValid:({c0:g,c1:B})=>E.isValid(g)&&E.isValid(B),is0:({c0:g,c1:B})=>E.is0(g)&&E.is0(B),neg:({c0:g,c1:B})=>({c0:E.neg(g),c1:E.neg(B)}),eql:({c0:g,c1:B},{c0:$,c1:F})=>E.eql(g,$)&&E.eql(B,F),sqrt:Bs,inv:({c0:g,c1:B})=>{let $=E.inv(E.sub(E.sqr(g),E.mulByNonresidue(E.sqr(B))));return{c0:E.mul(g,$),c1:E.neg(E.mul(B,$))}},div:(g,B)=>ee.mul(g,typeof B=="bigint"?r.inv(r.create(B)):ee.inv(B)),pow:(g,B)=>ii(ee,g,B),invertBatch:g=>si(ee,g),add:z,sub:Z,mul:C,sqr:ie,addN:z,subN:Z,mulN:C,sqrN:ie,fromBytes:g=>{if(g.length!==ee.BYTES)throw new Error(`fromBytes wrong length=${g.length}`);return{c0:E.fromBytes(g.subarray(0,E.BYTES)),c1:E.fromBytes(g.subarray(E.BYTES))}},toBytes:({c0:g,c1:B})=>Te(E.toBytes(g),E.toBytes(B)),cmov:({c0:g,c1:B},{c0:$,c1:F},U)=>({c0:E.cmov(g,$,U),c1:E.cmov(B,F,U)}),fromBigTwelve:g=>({c0:E.fromBigSix(g.slice(0,6)),c1:E.fromBigSix(g.slice(6,12))}),frobeniusMap(g,B){let{c0:$,c1:F,c2:U}=E.frobeniusMap(g.c1,B),G=H[B%12];return{c0:E.frobeniusMap(g.c0,B),c1:E.create({c0:f.mul($,G),c1:f.mul(F,G),c2:f.mul(U,G)})}},mulByFp2:({c0:g,c1:B},$)=>({c0:E.mulByFp2(g,$),c1:E.mulByFp2(B,$)}),conjugate:({c0:g,c1:B})=>({c0:g,c1:E.neg(B)}),mul014:({c0:g,c1:B},$,F,U)=>{let G=E.mul01(g,$,F),J=E.mul1(B,U);return{c0:E.add(E.mulByNonresidue(J),G),c1:E.sub(E.sub(E.mul01(E.add(B,g),$,f.add(F,U)),G),J)}},mul034:({c0:g,c1:B},$,F,U)=>{let G=E.create({c0:f.mul(g.c0,$),c1:f.mul(g.c1,$),c2:f.mul(g.c2,$)}),J=E.mul01(B,F,U),fe=E.mul01(E.add(g,B),f.add($,F),U);return{c0:E.add(E.mulByNonresidue(J),G),c1:E.sub(fe,E.add(G,J))}},_cyclotomicSquare:t.Fp12cyclotomicSquare,_cyclotomicExp:t.Fp12cyclotomicExp,finalExponentiate:t.Fp12finalExponentiate};return{Fp:r,Fp2:f,Fp6:E,Fp4Square:re,Fp12:ee}}var Cp,En,pr,l0,p0=he(()=>{dr();qt();Cp=BigInt(0),En=BigInt(1),pr=BigInt(2),l0=BigInt(3)});function Ps(t){t=t.slice();let e=t[0]&224,r=!!(e>>7&1),n=!!(e>>6&1),i=!!(e>>5&1);return t[0]&=31,{compressed:r,infinity:n,sort:i,value:t}}function ci(t,e){if(t[0]&224)throw new Error("setMask: non-empty mask");return e.compressed&&(t[0]|=128),e.infinity&&(t[0]|=64),e.sort&&(t[0]|=32),t}function g0(t){t.assertValidity();let e=t.equals(wt.G1.ProjectivePoint.ZERO),{x:r,y:n}=t.toAffine();if(e)return Ms.slice();let i=se.ORDER,s=!!(n*Le/i);return ci(qe(r,se.BYTES),{compressed:!0,sort:s})}function w0(t){t.assertValidity();let e=se.BYTES;if(t.equals(wt.G2.ProjectivePoint.ZERO))return Te(Ms,qe(st,e));let{x:r,y:n}=t.toAffine(),{re:i,im:s}=ue.reim(r),{re:o,im:a}=ue.reim(n),l=!!((a>st?a*Le:o*Le)/se.ORDER&ks),h=i;return Te(ci(qe(s,e),{sort:l,compressed:!0}),qe(h,e))}var st,ks,Le,Is,ai,Fr,qp,se,ue,Xa,Wa,we,m0,$p,Vp,jp,Hp,y0,Gp,Za,Ms,wt,b0=he(()=>{Ui();nn();f0();dr();qt();$a();za();p0();st=BigInt(0),ks=BigInt(1),Le=BigInt(2),Is=BigInt(3),ai=BigInt(4),Fr=BigInt("0xd201000000010000"),qp=lr(Fr),{Fp:se,Fp2:ue,Fp6:Xa,Fp4Square:Wa,Fp12:we}=d0({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[ks,ks],Fp2mulByB:({c0:t,c1:e})=>{let r=se.mul(t,ai),n=se.mul(e,ai);return{c0:se.sub(r,n),c1:se.add(r,n)}},Fp12cyclotomicSquare:({c0:t,c1:e})=>{let{c0:r,c1:n,c2:i}=t,{c0:s,c1:o,c2:a}=e,{first:c,second:l}=Wa(r,o),{first:h,second:d}=Wa(s,i),{first:w,second:b}=Wa(n,a),f=ue.mulByNonresidue(b);return{c0:Xa.create({c0:ue.add(ue.mul(ue.sub(c,r),Le),c),c1:ue.add(ue.mul(ue.sub(h,n),Le),h),c2:ue.add(ue.mul(ue.sub(w,i),Le),w)}),c1:Xa.create({c0:ue.add(ue.mul(ue.add(f,s),Le),f),c1:ue.add(ue.mul(ue.add(l,o),Le),l),c2:ue.add(ue.mul(ue.add(d,a),Le),d)})}},Fp12cyclotomicExp(t,e){let r=we.ONE;for(let n=qp-1;n>=0;n--)r=we._cyclotomicSquare(r),Fa(e,n)&&(r=we.mul(r,t));return r},Fp12finalExponentiate:t=>{let e=Fr,r=we.div(we.frobeniusMap(t,6),t),n=we.mul(we.frobeniusMap(r,2),r),i=we.conjugate(we._cyclotomicExp(n,e)),s=we.mul(we.conjugate(we._cyclotomicSquare(n)),i),o=we.conjugate(we._cyclotomicExp(s,e)),a=we.conjugate(we._cyclotomicExp(o,e)),c=we.mul(we.conjugate(we._cyclotomicExp(a,e)),we._cyclotomicSquare(i)),l=we.conjugate(we._cyclotomicExp(c,e)),h=we.frobeniusMap(we.mul(i,a),2),d=we.frobeniusMap(we.mul(o,n),3),w=we.frobeniusMap(we.mul(c,we.conjugate(n)),1),b=we.mul(we.mul(l,we.conjugate(s)),n);return we.mul(we.mul(we.mul(h,d),w),b)}}),m0=Lt(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),$p=Ca(ue,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(t=>t.map(e=>ue.fromBigTuple(e.map(BigInt))))),Vp=Ca(se,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(e=>BigInt(e)))),jp=Ya(ue,{A:ue.create({c0:se.create(st),c1:se.create(BigInt(240))}),B:ue.create({c0:se.create(BigInt(1012)),c1:se.create(BigInt(1012))}),Z:ue.create({c0:se.create(BigInt(-2)),c1:se.create(BigInt(-1))})}),Hp=Ya(se,{A:se.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:se.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:se.create(BigInt(11))}),{G2psi:y0,G2psi2:Gp}=h0(se,ue,ue.div(ue.ONE,ue.NONRESIDUE)),Za=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:se.ORDER,m:2,k:128,expand:"xmd",hash:Pn}),Ms=ci(se.toBytes(st),{infinity:!0,compressed:!0});wt=u0({fields:{Fp:se,Fp2:ue,Fp6:Xa,Fp12:we,Fr:m0},G1:{Fp:se,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:se.ZERO,b:ai,htfDefaults:{...Za,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(t,e)=>{let r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new t(se.mul(e.px,r),e.py,e.pz);return e.multiplyUnsafe(Fr).negate().multiplyUnsafe(Fr).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(Fr).add(e),mapToCurve:t=>{let{x:e,y:r}=Hp(se.create(t[0]));return Vp(e,r)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=Ps(t);if(i.length===48&&e){let s=se.ORDER,o=et(i),a=se.create(o&se.MASK);if(r){if(a!==st)throw new Error("G1: non-empty compressed point at infinity");return{x:st,y:st}}let c=se.add(se.pow(a,Is),se.create(wt.params.G1b)),l=se.sqrt(c);if(!l)throw new Error("Invalid compressed G1 point");return l*Le/s!==BigInt(n)&&(l=se.neg(l)),{x:se.create(a),y:se.create(l)}}else if(i.length===96&&!e){let s=et(i.subarray(0,se.BYTES)),o=et(i.subarray(se.BYTES));if(r){if(s!==st||o!==st)throw new Error("G1: non-empty point at infinity");return wt.G1.ProjectivePoint.ZERO.toAffine()}return{x:se.create(s),y:se.create(o)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(t,e,r)=>{let n=e.equals(t.ZERO),{x:i,y:s}=e.toAffine();if(r){if(n)return Ms.slice();let o=se.ORDER,a=!!(s*Le/o);return ci(qe(i,se.BYTES),{compressed:!0,sort:a})}else return n?Te(new Uint8Array([64]),new Uint8Array(2*se.BYTES-1)):Te(qe(i,se.BYTES),qe(s,se.BYTES))},ShortSignature:{fromHex(t){let{infinity:e,sort:r,value:n}=Ps(ze("signatureHex",t,48)),i=se.ORDER,s=et(n);if(e)return wt.G1.ProjectivePoint.ZERO;let o=se.create(s&se.MASK),a=se.add(se.pow(o,Is),se.create(wt.params.G1b)),c=se.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let l=BigInt(r);c*Le/i!==l&&(c=se.neg(c));let h=wt.G1.ProjectivePoint.fromAffine({x:o,y:c});return h.assertValidity(),h},toRawBytes(t){return g0(t)},toHex(t){return kt(g0(t))}}},G2:{Fp:ue,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:ue.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:ue.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:ue.ZERO,b:ue.fromBigTuple([ai,ai]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...Za},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:t=>{let{x:e,y:r}=jp(ue.fromBigTuple(t));return $p(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(Fr).negate().equals(y0(t,e)),clearCofactor:(t,e)=>{let r=Fr,n=e.multiplyUnsafe(r).negate(),i=y0(t,e),s=e.double();return s=Gp(t,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(r).negate(),s=s.add(i),s=s.subtract(n),s.subtract(e)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=Ps(t);if(!e&&!r&&n||!e&&r&&n||n&&r&&e)throw new Error("Invalid encoding flag: "+(t[0]&224));let s=se.BYTES,o=(a,c,l)=>et(a.slice(c,l));if(i.length===96&&e){let a=wt.params.G2b,c=se.ORDER;if(r){if(i.reduce((S,R)=>S!==0?R+1:R,0)>0)throw new Error("Invalid compressed G2 point");return{x:ue.ZERO,y:ue.ZERO}}let l=o(i,0,s),h=o(i,s,2*s),d=ue.create({c0:se.create(h),c1:se.create(l)}),w=ue.add(ue.pow(d,Is),a),b=ue.sqrt(w),f=b.c1===st?b.c0*Le/c:b.c1*Le/c?ks:st;return b=n&&f>0?b:ue.neg(b),{x:d,y:b}}else if(i.length===192&&!e){if(r){if(i.reduce((d,w)=>d!==0?w+1:w,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:ue.ZERO,y:ue.ZERO}}let a=o(i,0,s),c=o(i,s,2*s),l=o(i,2*s,3*s),h=o(i,3*s,4*s);return{x:ue.fromBigTuple([c,a]),y:ue.fromBigTuple([h,l])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(t,e,r)=>{let{BYTES:n,ORDER:i}=se,s=e.equals(t.ZERO),{x:o,y:a}=e.toAffine();if(r){if(s)return Te(Ms,qe(st,n));let c=!!(a.c1===st?a.c0*Le/i:a.c1*Le/i);return Te(ci(qe(o.c1,n),{compressed:!0,sort:c}),qe(o.c0,n))}else{if(s)return Te(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:l}=ue.reim(o),{re:h,im:d}=ue.reim(a);return Te(qe(l,n),qe(c,n),qe(d,n),qe(h,n))}},Signature:{fromHex(t){let{infinity:e,sort:r,value:n}=Ps(ze("signatureHex",t)),i=se.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=et(n.slice(0,s)),a=et(n.slice(s));if(e)return wt.G2.ProjectivePoint.ZERO;let c=se.create(o&se.MASK),l=se.create(a),h=ue.create({c0:l,c1:c}),d=ue.add(ue.pow(h,Is),wt.params.G2b),w=ue.sqrt(d);if(!w)throw new Error("Failed to find a square root");let{re:b,im:f}=ue.reim(w),S=BigInt(r),R=f>st&&f*Le/i!==S,O=f===st&&b*Le/i!==S;(R||O)&&(w=ue.neg(w));let V=wt.G2.ProjectivePoint.fromAffine({x:h,y:w});return V.assertValidity(),V},toRawBytes(t){return w0(t)},toHex(t){return kt(w0(t))}}},params:{ateLoopSize:Fr,r:m0.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:Za,hash:Pn,randomBytes:Oi})});function x0(t,e,r){let n=typeof t=="string"?t:Me(t),i=typeof e=="string"?e:Me(e),s=typeof r=="string"?r:Me(r);return wt.verifyShortSignature(i,s,n)}var Ja=he(()=>{b0();lt()});var Qa,vn,Cs=he(()=>{zn();Qa=t=>Ge(new Rt(t)),vn=t=>{let e=Qa(t);return new Date(Number(e)/1e6)}});function zp(t,e){let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]>n[i])return!0;return!1}function Wp(t){let e=ui.byteLength+Kp;if(t.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let r=t.slice(0,ui.byteLength);if(!$n(r,ui))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${ui}, but get ${r}`);return t.slice(ui.byteLength)}function ot(t){if(t.status===Ve.Found){if(t.value instanceof ArrayBuffer)return t.value;if(t.value instanceof Uint8Array)return t.value.buffer}}async function qs(t){switch(t[0]){case xt.Empty:return At(fi("ic-hashtree-empty"));case xt.Pruned:return t[1];case xt.Leaf:return At(nt(fi("ic-hashtree-leaf"),t[1]));case xt.Labeled:return At(nt(fi("ic-hashtree-labeled"),t[1],await qs(t[2])));case xt.Fork:return At(nt(fi("ic-hashtree-fork"),await qs(t[1]),await qs(t[2])));default:throw new Error("unreachable")}}function fi(t){let e=new Uint8Array([t.length]),r=new TextEncoder().encode(t);return nt(e,r)}function Ir(t,e){if(t.length===0)switch(e[0]){case xt.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?{status:Ve.Found,value:e[1]}:e[1]instanceof Uint8Array?{status:Ve.Found,value:e[1].buffer}:{status:Ve.Found,value:e[1]}}default:return{status:Ve.Found,value:e}}let r=typeof t[0]=="string"?new TextEncoder().encode(t[0]):t[0],n=$s(r,e);switch(n.status){case Ve.Found:return Ir(t.slice(1),n.value);case mr.Greater:case mr.Less:return{status:Ve.Absent};default:return n}}function Vs(t){switch(t[0]){case xt.Empty:return[];case xt.Fork:return Vs(t[1]).concat(Vs(t[2]));default:return[t]}}function $s(t,e){switch(e[0]){case xt.Labeled:return zp(t,e[1])?{status:mr.Greater}:$n(t,e[1])?{status:Ve.Found,value:e[2]}:{status:mr.Less};case xt.Fork:let r=$s(t,e[1]);switch(r.status){case mr.Greater:{let n=$s(t,e[2]);return n.status===mr.Less?{status:Ve.Absent}:n}case Ve.Unknown:{let n=$s(t,e[2]);return n.status===mr.Less?{status:Ve.Unknown}:n}default:return r}case xt.Pruned:return{status:Ve.Unknown};default:return{status:Ve.Absent}}}function La(t){let{canisterId:e,subnetId:r,tree:n}=t,i=Ir(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==Ve.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return Tt(i.value).map(c=>[de.fromUint8Array(c[0]),de.fromUint8Array(c[1])]).some(c=>c[0].ltEq(e)&&c[1].gtEq(e))}var bt,xt,Ur,ui,Kp,Ve,mr,Bn=he(()=>{Dn();fn();Qn();lt();yt();Ja();Cs();li();bt=class extends Pe{constructor(e){super(`Invalid certificate: ${e}`)}};(function(t){t[t.Empty=0]="Empty",t[t.Fork=1]="Fork",t[t.Labeled=2]="Labeled",t[t.Leaf=3]="Leaf",t[t.Pruned=4]="Pruned"})(xt||(xt={}));Ur=class t{constructor(e,r,n,i,s=5){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,this.cert=Tt(new Uint8Array(e))}static async create(e){let r=t.createUnverified(e);return await r.verify(),r}static createUnverified(e){let r=e.blsVerify;return r||(r=x0),new t(e.certificate,e.rootKey,e.canisterId,r,e.maxAgeInMinutes)}lookup(e){return Ir(e,this.cert.tree)}lookup_label(e){return this.lookup([e])}async verify(){let e=await qs(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=Wp(r),s=nt(fi("ic-state-root"),e),o=!1,a=ot(this.lookup(["time"]));if(!a)throw new bt("Certificate does not contain a time");let c=5*60*1e3,l=this._maxAgeInMinutes*60*1e3,h=Date.now(),d=h-l,w=h+c,b=vn(a);if(b.getTime()<d)throw new bt(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+b.toISOString()+" Current time: "+new Date(h).toISOString());if(b.getTime()>w)throw new bt("Certificate is signed more than 5 minutes in the future. Certificate time: "+b.toISOString()+" Current time: "+new Date(h).toISOString());try{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)throw new bt("Signature verification failed")}async _checkDelegationAndGetKey(e){if(!e)return this._rootKey;let r=await t.createUnverified({certificate:e.certificate,rootKey:this._rootKey,canisterId:this._canisterId,blsVerify:this._blsVerify,maxAgeInMinutes:1/0});if(r.cert.delegation)throw new bt("Delegation certificates cannot be nested");if(await r.verify(),this._canisterId.toString()!==_0&&!La({canisterId:this._canisterId,subnetId:de.fromUint8Array(new Uint8Array(e.subnet_id)),tree:r.cert.tree}))throw new bt(`Canister ${this._canisterId} not in range of delegations for subnet 0x${Me(e.subnet_id)}`);let n=ot(r.lookup(["subnet",e.subnet_id,"public_key"]));if(!n)throw new Error(`Could not find subnet key for subnet 0x${Me(e.subnet_id)}`);return n}},ui=Hr("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Kp=96;(function(t){t.Unknown="unknown",t.Absent="absent",t.Found="found"})(Ve||(Ve={}));(function(t){t.Less="less",t.Greater="greater"})(mr||(mr={}))});var Hs={};Un(Hs,{CustomPath:()=>Da,encodePath:()=>ec,fetchNodeKeys:()=>v0,request:()=>js});var Da,js,v0,ec,E0,B0,Zp,Xp,hi=he(()=>{yt();fn();Bn();lt();Dn();Cs();Da=class{constructor(e,r,n){this.key=e,this.path=r,this.decodeStrategy=n}},js=async t=>{let{agent:e,paths:r}=t,n=de.from(t.canisterId),i=[...new Set(r)],s=i.map(c=>ec(c,n)),o=new Map,a=i.map((c,l)=>(async()=>{var h;try{let d=await e.readState(n,{paths:[s[l]]}),w=await Ur.create({certificate:d.certificate,rootKey:e.rootKey,canisterId:n}),b=(R,O)=>{if(O==="subnet"){let V=v0(d.certificate,n,e.rootKey);return{path:O,data:V}}else return{path:O,data:ot(R.lookup(ec(O,n)))}},{path:f,data:S}=b(w,i[l]);if(!S)console.warn(`Expected to find result for path ${f}, but instead found nothing.`),typeof f=="string"?o.set(f,null):o.set(f.key,null);else switch(f){case"time":{o.set(f,vn(S));break}case"controllers":{o.set(f,Xp(S));break}case"module_hash":{o.set(f,E0(S));break}case"subnet":{o.set(f,S);break}case"candid":{o.set(f,new TextDecoder().decode(S));break}default:if(typeof f!="string"&&"key"in f&&"path"in f)switch(f.decodeStrategy){case"raw":o.set(f.key,S);break;case"leb128":{o.set(f.key,Qa(S));break}case"cbor":{o.set(f.key,B0(S));break}case"hex":{o.set(f.key,E0(S));break}case"utf-8":o.set(f.key,Zp(S))}}}catch(d){if(!((h=d?.message)===null||h===void 0)&&h.includes("Invalid certificate"))throw new Pe(d.message);typeof c!="string"&&"key"in c&&"path"in c?o.set(c.key,null):o.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(d),console.groupEnd()}})());return await Promise.all(a),o},v0=(t,e,r)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=Tt(new Uint8Array(t)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=de.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=de.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=de.selfAuthenticating(de.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!La({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=Ir(["subnet",s.subnet_id,"node"],i);if(c.status!==Ve.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let l=Vs(c.value),h=new Map;return l.forEach(d=>{let w=de.from(new Uint8Array(d[1])).toText(),b=Ir(["public_key"],d[2]);if(b.status!==Ve.Found)throw new Error("Public key not found");let f=b.value;if(f.byteLength!==44)throw new Error("Invalid public key length");h.set(w,f)}),{subnetId:de.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:h}},ec=(t,e)=>{let r=new TextEncoder,n=s=>new DataView(r.encode(s).buffer).buffer,i=new DataView(e.toUint8Array().buffer).buffer;switch(t){case"time":return[n("time")];case"controllers":return[n("canister"),i,n("controllers")];case"module_hash":return[n("canister"),i,n("module_hash")];case"subnet":return[n("subnet")];case"candid":return[n("canister"),i,n("metadata"),n("candid:service")];default:if("key"in t&&"path"in t)if(typeof t.path=="string"||t.path instanceof ArrayBuffer){let s=t.path,o=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),o]}else return t.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${t} was formatted correctly.`)},E0=t=>Me(t),B0=t=>Tt(t),Zp=t=>new TextDecoder().decode(t),Xp=t=>B0(t).map(r=>de.fromUint8Array(new Uint8Array(r)))});function A0(t,e=!1){return e?{h:Number(t&Gs),l:Number(t>>tc&Gs)}:{h:Number(t>>tc&Gs)|0,l:Number(t&Gs)|0}}function Jp(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:s,l:o}=A0(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}function fm(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var Gs,tc,Qp,Lp,Dp,em,tm,rm,nm,im,sm,om,am,cm,um,lm,hm,dm,pm,mm,ym,gm,pe,T0=he(()=>{Gs=BigInt(4294967295),tc=BigInt(32);Qp=(t,e)=>BigInt(t>>>0)<<tc|BigInt(e>>>0),Lp=(t,e,r)=>t>>>r,Dp=(t,e,r)=>t<<32-r|e>>>r,em=(t,e,r)=>t>>>r|e<<32-r,tm=(t,e,r)=>t<<32-r|e>>>r,rm=(t,e,r)=>t<<64-r|e>>>r-32,nm=(t,e,r)=>t>>>r-32|e<<64-r,im=(t,e)=>e,sm=(t,e)=>t,om=(t,e,r)=>t<<r|e>>>32-r,am=(t,e,r)=>e<<r|t>>>32-r,cm=(t,e,r)=>e<<r-32|t>>>64-r,um=(t,e,r)=>t<<r-32|e>>>64-r;lm=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),hm=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,dm=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),pm=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,mm=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),ym=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0,gm={fromBig:A0,split:Jp,toBig:Qp,shrSH:Lp,shrSL:Dp,rotrSH:em,rotrSL:tm,rotrBH:rm,rotrBL:nm,rotr32H:im,rotr32L:sm,rotlSH:om,rotlSL:am,rotlBH:cm,rotlBL:um,add:fm,add3L:lm,add3H:hm,add4L:dm,add4H:pm,add5H:ym,add5L:mm},pe=gm});var wm,bm,Pr,kr,rc,S0,N0=he(()=>{wo();T0();nn();[wm,bm]=pe.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Pr=new Uint32Array(80),kr=new Uint32Array(80),rc=class extends sn{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:l,El:h,Fh:d,Fl:w,Gh:b,Gl:f,Hh:S,Hl:R}=this;return[e,r,n,i,s,o,a,c,l,h,d,w,b,f,S,R]}set(e,r,n,i,s,o,a,c,l,h,d,w,b,f,S,R){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=h|0,this.Fh=d|0,this.Fl=w|0,this.Gh=b|0,this.Gl=f|0,this.Hh=S|0,this.Hl=R|0}process(e,r){for(let q=0;q<16;q++,r+=4)Pr[q]=e.getUint32(r),kr[q]=e.getUint32(r+=4);for(let q=16;q<80;q++){let Y=Pr[q-15]|0,E=kr[q-15]|0,H=pe.rotrSH(Y,E,1)^pe.rotrSH(Y,E,8)^pe.shrSH(Y,E,7),z=pe.rotrSL(Y,E,1)^pe.rotrSL(Y,E,8)^pe.shrSL(Y,E,7),Z=Pr[q-2]|0,C=kr[q-2]|0,ie=pe.rotrSH(Z,C,19)^pe.rotrBH(Z,C,61)^pe.shrSH(Z,C,6),re=pe.rotrSL(Z,C,19)^pe.rotrBL(Z,C,61)^pe.shrSL(Z,C,6),ee=pe.add4L(z,re,kr[q-7],kr[q-16]),g=pe.add4H(ee,H,ie,Pr[q-7],Pr[q-16]);Pr[q]=g|0,kr[q]=ee|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:l,Dl:h,Eh:d,El:w,Fh:b,Fl:f,Gh:S,Gl:R,Hh:O,Hl:V}=this;for(let q=0;q<80;q++){let Y=pe.rotrSH(d,w,14)^pe.rotrSH(d,w,18)^pe.rotrBH(d,w,41),E=pe.rotrSL(d,w,14)^pe.rotrSL(d,w,18)^pe.rotrBL(d,w,41),H=d&b^~d&S,z=w&f^~w&R,Z=pe.add5L(V,E,z,bm[q],kr[q]),C=pe.add5H(Z,O,Y,H,wm[q],Pr[q]),ie=Z|0,re=pe.rotrSH(n,i,28)^pe.rotrBH(n,i,34)^pe.rotrBH(n,i,39),ee=pe.rotrSL(n,i,28)^pe.rotrBL(n,i,34)^pe.rotrBL(n,i,39),g=n&s^n&a^s&a,B=i&o^i&c^o&c;O=S|0,V=R|0,S=b|0,R=f|0,b=d|0,f=w|0,{h:d,l:w}=pe.add(l|0,h|0,C|0,ie|0),l=a|0,h=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let $=pe.add3L(ie,ee,B);n=pe.add3H($,C,re,g),i=$|0}({h:n,l:i}=pe.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=pe.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=pe.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:h}=pe.add(this.Dh|0,this.Dl|0,l|0,h|0),{h:d,l:w}=pe.add(this.Eh|0,this.El|0,d|0,w|0),{h:b,l:f}=pe.add(this.Fh|0,this.Fl|0,b|0,f|0),{h:S,l:R}=pe.add(this.Gh|0,this.Gl|0,S|0,R|0),{h:O,l:V}=pe.add(this.Hh|0,this.Hl|0,O|0,V|0),this.set(n,i,s,o,a,c,l,h,d,w,b,f,S,R,O,V)}roundClean(){Pr.fill(0),kr.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)}},S0=In(()=>new rc)});function Em(t){let e=Os(t);return Ct(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function R0(t){let e=Em(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,l=Ys<<BigInt(a*8)-pt,h=r.create,d=Lt(e.n,e.nBitLength),w=e.uvRatio||((F,U)=>{try{return{isValid:!0,value:r.sqrt(F*r.inv(U))}}catch{return{isValid:!1,value:Vt}}}),b=e.adjustScalarBytes||(F=>F),f=e.domain||((F,U,G)=>{if(Ar("phflag",G),U.length||G)throw new Error("Contexts/pre-hash are not supported");return F});function S(F,U){Mt("coordinate "+F,U,Vt,l)}function R(F){if(!(F instanceof q))throw new Error("ExtendedPoint expected")}let O=hr((F,U)=>{let{ex:G,ey:J,ez:fe}=F,ce=F.is0();U==null&&(U=ce?xm:r.inv(fe));let W=h(G*U),P=h(J*U),m=h(fe*U);if(ce)return{x:Vt,y:pt};if(m!==pt)throw new Error("invZ was invalid");return{x:W,y:P}}),V=hr(F=>{let{a:U,d:G}=e;if(F.is0())throw new Error("bad point: ZERO");let{ex:J,ey:fe,ez:ce,et:W}=F,P=h(J*J),m=h(fe*fe),L=h(ce*ce),te=h(L*L),le=h(P*U),D=h(L*h(le+m)),u=h(te+h(G*h(P*m)));if(D!==u)throw new Error("bad point: equation left != right (1)");let p=h(J*fe),y=h(ce*W);if(p!==y)throw new Error("bad point: equation left != right (2)");return!0});class q{constructor(U,G,J,fe){this.ex=U,this.ey=G,this.ez=J,this.et=fe,S("x",U),S("y",G),S("z",J),S("t",fe),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(U){if(U instanceof q)throw new Error("extended point not allowed");let{x:G,y:J}=U||{};return S("x",G),S("y",J),new q(G,J,pt,h(G*J))}static normalizeZ(U){let G=r.invertBatch(U.map(J=>J.ez));return U.map((J,fe)=>J.toAffine(G[fe])).map(q.fromAffine)}static msm(U,G){return Rs(q,d,U,G)}_setWindowSize(U){H.setWindowSize(this,U)}assertValidity(){V(this)}equals(U){R(U);let{ex:G,ey:J,ez:fe}=this,{ex:ce,ey:W,ez:P}=U,m=h(G*P),L=h(ce*fe),te=h(J*P),le=h(W*fe);return m===L&&te===le}is0(){return this.equals(q.ZERO)}negate(){return new q(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){let{a:U}=e,{ex:G,ey:J,ez:fe}=this,ce=h(G*G),W=h(J*J),P=h(Ys*h(fe*fe)),m=h(U*ce),L=G+J,te=h(h(L*L)-ce-W),le=m+W,D=le-P,u=m-W,p=h(te*D),y=h(le*u),T=h(te*u),v=h(D*le);return new q(p,y,v,T)}add(U){R(U);let{a:G,d:J}=e,{ex:fe,ey:ce,ez:W,et:P}=this,{ex:m,ey:L,ez:te,et:le}=U;if(G===BigInt(-1)){let K=h((ce-fe)*(L+m)),Q=h((ce+fe)*(L-m)),oe=h(Q-K);if(oe===Vt)return this.double();let ye=h(W*Ys*le),ve=h(P*Ys*te),Se=ve+ye,me=Q+K,ae=ve-ye,ke=h(Se*oe),Gt=h(me*ae),ir=h(Se*ae),Cr=h(oe*me);return new q(ke,Gt,Cr,ir)}let D=h(fe*m),u=h(ce*L),p=h(P*J*le),y=h(W*te),T=h((fe+ce)*(m+L)-D-u),v=y-p,A=y+p,M=h(u-G*D),x=h(T*v),N=h(A*M),k=h(T*M),I=h(v*A);return new q(x,N,I,k)}subtract(U){return this.add(U.negate())}wNAF(U){return H.wNAFCached(this,U,q.normalizeZ)}multiply(U){let G=U;Mt("scalar",G,pt,n);let{p:J,f:fe}=this.wNAF(G);return q.normalizeZ([J,fe])[0]}multiplyUnsafe(U){let G=U;return Mt("scalar",G,Vt,n),G===Vt?E:this.equals(E)||G===pt?this:this.equals(Y)?this.wNAF(G).p:H.unsafeLadder(this,G)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return H.unsafeLadder(this,n).is0()}toAffine(U){return O(this,U)}clearCofactor(){let{h:U}=e;return U===pt?this:this.multiplyUnsafe(U)}static fromHex(U,G=!1){let{d:J,a:fe}=e,ce=r.BYTES;U=ze("pointHex",U,ce),Ar("zip215",G);let W=U.slice(),P=U[ce-1];W[ce-1]=P&-129;let m=Tr(W),L=G?l:r.ORDER;Mt("pointHex.y",m,Vt,L);let te=h(m*m),le=h(te-pt),D=h(J*te-fe),{isValid:u,value:p}=w(le,D);if(!u)throw new Error("Point.fromHex: invalid y coordinate");let y=(p&pt)===pt,T=(P&128)!==0;if(!G&&p===Vt&&T)throw new Error("Point.fromHex: x=0 and x_0=1");return T!==y&&(p=h(-p)),q.fromAffine({x:p,y:m})}static fromPrivateKey(U){return C(U).point}toRawBytes(){let{x:U,y:G}=this.toAffine(),J=Wr(G,r.BYTES);return J[J.length-1]|=U&pt?128:0,J}toHex(){return kt(this.toRawBytes())}}q.BASE=new q(e.Gx,e.Gy,pt,h(e.Gx*e.Gy)),q.ZERO=new q(Vt,pt,pt,Vt);let{BASE:Y,ZERO:E}=q,H=Ns(q,a*8);function z(F){return Re(F,n)}function Z(F){return z(Tr(F))}function C(F){let U=a;F=ze("private key",F,U);let G=ze("hashed private key",s(F),2*U),J=b(G.slice(0,U)),fe=G.slice(U,2*U),ce=Z(J),W=Y.multiply(ce),P=W.toRawBytes();return{head:J,prefix:fe,scalar:ce,point:W,pointBytes:P}}function ie(F){return C(F).pointBytes}function re(F=new Uint8Array,...U){let G=Te(...U);return Z(s(f(G,ze("context",F),!!i)))}function ee(F,U,G={}){F=ze("message",F),i&&(F=i(F));let{prefix:J,scalar:fe,pointBytes:ce}=C(U),W=re(G.context,J,F),P=Y.multiply(W).toRawBytes(),m=re(G.context,P,ce,F),L=z(W+m*fe);Mt("signature.s",L,Vt,n);let te=Te(P,Wr(L,r.BYTES));return ze("result",te,a*2)}let g=_m;function B(F,U,G,J=g){let{context:fe,zip215:ce}=J,W=r.BYTES;F=ze("signature",F,2*W),U=ze("message",U),ce!==void 0&&Ar("zip215",ce),i&&(U=i(U));let P=Tr(F.slice(W,2*W)),m,L,te;try{m=q.fromHex(G,ce),L=q.fromHex(F.slice(0,W),ce),te=Y.multiplyUnsafe(P)}catch{return!1}if(!ce&&m.isSmallOrder())return!1;let le=re(fe,L.toRawBytes(),m.toRawBytes(),U);return L.add(m.multiplyUnsafe(le)).subtract(te).clearCofactor().equals(q.ZERO)}return Y._setWindowSize(8),{CURVE:e,getPublicKey:ie,sign:ee,verify:B,ExtendedPoint:q,utils:{getExtendedPublicKey:C,randomPrivateKey:()=>o(r.BYTES),precompute(F=8,U=q.BASE){return U._setWindowSize(F),U.multiply(BigInt(3)),U}}}}var Vt,pt,Ys,xm,_m,O0=he(()=>{Ha();dr();qt();qt();Vt=BigInt(0),pt=BigInt(1),Ys=BigInt(2),xm=BigInt(8),_m={zip215:!0}});function Tm(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=nc,a=t*t%s*t%s,c=$t(a,U0,s)*a%s,l=$t(c,vm,s)*t%s,h=$t(l,Bm,s)*l%s,d=$t(h,e,s)*h%s,w=$t(d,r,s)*d%s,b=$t(w,n,s)*w%s,f=$t(b,i,s)*b%s,S=$t(f,i,s)*b%s,R=$t(S,e,s)*h%s;return{pow_p_5_8:$t(R,U0,s)*t%s,b2:a}}function Sm(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function Nm(t,e){let r=nc,n=Re(e*e*e,r),i=Re(n*n*e,r),s=Tm(t*i).pow_p_5_8,o=Re(t*n*s,r),a=Re(e*o*o,r),c=o,l=Re(o*F0,r),h=a===t,d=a===Re(-t,r),w=a===Re(-t*F0,r);return h&&(o=c),(d||w)&&(o=l),r0(o,r)&&(o=Re(-o,r)),{isValid:h||d,value:o}}var nc,F0,nw,vm,U0,iw,Bm,Am,Rm,Om,I0,P0=he(()=>{N0();nn();O0();dr();nc=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),F0=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),nw=BigInt(0),vm=BigInt(1),U0=BigInt(2),iw=BigInt(3),Bm=BigInt(5),Am=BigInt(8);Rm=Lt(nc,void 0,!0),Om={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Rm,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Am,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:S0,randomBytes:Oi,adjustScalarBytes:Sm,uvRatio:Nm},I0=R0(Om)});var k0,at,tt,di,M0,C0,zs,q0=he(()=>{k0=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},at=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},zs=class{constructor(e={}){tt.set(this,void 0),di.set(this,void 0),this[M0]=this.entries.bind(this),this[C0]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();k0(this,tt,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),k0(this,di,n,"f")}prune(){let e=Date.now();for(let[r,n]of at(this,tt,"f").entries())e-n.timestamp>at(this,di,"f")&&at(this,tt,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return at(this,tt,"f").set(e,n),this}get(e){let r=at(this,tt,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>at(this,di,"f")){at(this,tt,"f").delete(e);return}return r.value}}clear(){at(this,tt,"f").clear()}entries(){let e=at(this,tt,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=at(this,tt,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return at(this,tt,"f").keys()}forEach(e,r){for(let[n,i]of at(this,tt,"f").entries())e.call(r,i.value,n,this)}has(e){return at(this,tt,"f").has(e)}delete(e){return at(this,tt,"f").delete(e)}get size(){return at(this,tt,"f").size}};tt=new WeakMap,di=new WeakMap,M0=Symbol.iterator,C0=Symbol.toStringTag});function j0(t,e){let r=2+$0(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,s=new Uint8Array(1+$0(n)+n);return s[i++]=48,i+=V0(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=V0(s,i,t.byteLength+1),s[i++]=0,s.set(new Uint8Array(t),i),s}var $0,V0,ic,Fm,cw,sc,uw,H0,oc=he(()=>{lt();$0=t=>{if(t<=127)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},V0=(t,e,r)=>{if(r<=127)return t[e]=r,1;if(r<=255)return t[e]=129,t[e+1]=r,2;if(r<=65535)return t[e]=130,t[e+1]=r>>8,t[e+2]=r,3;if(r<=16777215)return t[e]=131,t[e+1]=r>>16,t[e+2]=r>>8,t[e+3]=r,4;throw new Error("Length too long (> 4 bytes)")},ic=(t,e)=>{if(t[e]<128)return 1;if(t[e]===128)throw new Error("Invalid length 0");if(t[e]===129)return 2;if(t[e]===130)return 3;if(t[e]===131)return 4;throw new Error("Length too long (> 4 bytes)")},Fm=(t,e)=>{let r=ic(t,e);if(r===1)return t[e];if(r===2)return t[e+1];if(r===3)return(t[e+1]<<8)+t[e+2];if(r===4)return(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];throw new Error("Length too long (> 4 bytes)")},cw=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),sc=Uint8Array.from([48,5,6,3,43,101,112]),uw=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);H0=(t,e)=>{let r=0,n=(a,c)=>{if(i[r++]!==a)throw new Error("Expected: "+c)},i=new Uint8Array(t);if(n(48,"sequence"),r+=ic(i,r),!$n(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let s=Fm(i,r)-1;r+=ic(i,r),n(0,"0 padding");let o=i.slice(r);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o}});var G0,Y0,Ks,Ws,pi,ac=he(()=>{oc();G0=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Y0=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},pi=class t{constructor(e){if(Ks.set(this,void 0),Ws.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");G0(this,Ks,e,"f"),G0(this,Ws,t.derEncode(e),"f")}static from(e){return this.fromDer(e.toDer())}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){return j0(e,sc).buffer}static derDecode(e){let r=H0(e,sc);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Y0(this,Ks,"f")}get derKey(){return Y0(this,Ws,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Ks=new WeakMap,Ws=new WeakMap;pi.RAW_KEY_LENGTH=32});var cc,Zs,z0=he(()=>{cc=class{constructor(){this.observers=[]}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(r=>r!==e)}notify(e,...r){this.observers.forEach(n=>n(e,...r))}},Zs=class extends cc{constructor(){super()}print(e,...r){this.notify({message:e,level:"info"},...r)}warn(e,...r){this.notify({message:e,level:"warn"},...r)}error(e,r,...n){this.notify({message:e,level:"error",error:r},...n)}}});var Dt,rt,er,Xs,Js,Qs,Ls,Ds,eo,to,An,mi,K0=he(()=>{Dt=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},rt=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},mi=class t{constructor(e=t.default){er.set(this,void 0),Xs.set(this,void 0),Js.set(this,void 0),Qs.set(this,void 0),Ls.set(this,void 0),Ds.set(this,void 0),eo.set(this,void 0),to.set(this,void 0),An.set(this,0);let{initialInterval:r=500,randomizationFactor:n=.5,multiplier:i=1.5,maxInterval:s=6e4,maxElapsedTime:o=9e5,maxIterations:a=10,date:c=Date}=e;Dt(this,er,r,"f"),Dt(this,Xs,n,"f"),Dt(this,Js,i,"f"),Dt(this,Qs,s,"f"),Dt(this,to,c,"f"),Dt(this,Ls,c.now(),"f"),Dt(this,Ds,o,"f"),Dt(this,eo,a,"f")}get ellapsedTimeInMsec(){return rt(this,to,"f").now()-rt(this,Ls,"f")}get currentInterval(){return rt(this,er,"f")}get count(){return rt(this,An,"f")}get randomValueFromInterval(){let e=rt(this,Xs,"f")*rt(this,er,"f"),r=rt(this,er,"f")-e,n=rt(this,er,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return Dt(this,er,Math.min(rt(this,er,"f")*rt(this,Js,"f"),rt(this,Qs,"f")),"f"),Dt(this,An,(e=rt(this,An,"f"),e++,e),"f"),rt(this,er,"f")}next(){return this.ellapsedTimeInMsec>=rt(this,Ds,"f")||rt(this,An,"f")>=rt(this,eo,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};er=new WeakMap,Xs=new WeakMap,Js=new WeakMap,Qs=new WeakMap,Ls=new WeakMap,Ds=new WeakMap,eo=new WeakMap,to=new WeakMap,An=new WeakMap;mi.default={initialInterval:500,randomizationFactor:.5,multiplier:1.5,maxInterval:6e4,maxElapsedTime:9e5,maxIterations:10,date:Date}});var uc=he(()=>{});function $m(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new bi("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof globalThis<"u")if(globalThis.fetch)t=globalThis.fetch.bind(globalThis);else throw new bi("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(t=self.fetch.bind(self));if(t)return t;throw new bi("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function Vm(t){let e;if(t!==void 0)!t.match(/^[a-z]+:/)&&typeof window<"u"?e=new URL(window.location.protocol+"//"+t):e=new URL(t);else{let r=["ic0.app","icp0.io","127.0.0.1","localhost"],n=[".github.dev",".gitpod.io"],i=typeof window<"u"?window.location:void 0,s=i?.hostname,o;s&&typeof s=="string"&&(n.some(a=>s.endsWith(a))?o=s:o=r.find(a=>s.endsWith(a))),i&&o?e=new URL(`${i.protocol}//${o}${i.port?":"+i.port:""}`):e=new URL("https://icp-api.io")}return e.toString()}var ct,ne,rr,tr,Mr,Nn,yi,gi,jt,no,Ht,Xr,Jr,wi,Tn,Sn,Qr,Lr,W0,io,so,nr,ro,Um,_0,Im,Pm,km,Mm,Cm,qm,bi,Rn,xi,lc=he(()=>{yt();fn();da();Dn();Qn();lt();_s();ti();Aa();hi();Bn();P0();q0();ac();Cs();z0();K0();uc();_s();ti();ct=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},ne=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)};(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(nr||(nr={}));ro=60*1e3,Um="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae",_0="aaaaa-aa",Im="ic0.app",Pm=".ic0.app",km="icp0.io",Mm=".icp0.io",Cm="icp-api.io",qm=".icp-api.io",bi=class extends Pe{constructor(e){super(e),this.message=e}},Rn=class extends Pe{constructor(e){super(e),this.message=e}};xi=class t{constructor(e={}){var r;rr.add(this),tr.set(this,void 0),Mr.set(this,void 0),Nn.set(this,void 0),yi.set(this,void 0),gi.set(this,0),jt.set(this,void 0),no.set(this,!1),Ht.set(this,void 0),Xr.set(this,void 0),Jr.set(this,void 0),this._isAgent=!0,this.config={},wi.set(this,0),this.log=new Zs,Tn.set(this,[]),Sn.set(this,[]),Qr.set(this,new zs({expirationTime:5*60*1e3})),Lr.set(this,!0),so.set(this,(s,o)=>{if(ne(this,Lr,"f")===!1)return s;if(!o)throw new bt("Invalid signature from replica signed query: no matching node key found.");let{status:a,signatures:c=[],requestId:l}=s,h=new TextEncoder().encode("\vic-response");for(let d of c){let{timestamp:w,identity:b}=d,f=de.fromUint8Array(b).toText(),S;if(a==="replied"){let{reply:Y}=s;S=Jn({status:a,reply:Y,timestamp:BigInt(w),request_id:l})}else if(a==="rejected"){let{reject_code:Y,reject_message:E,error_code:H}=s;S=Jn({status:a,reject_code:Y,reject_message:E,error_code:H,timestamp:BigInt(w),request_id:l})}else throw new Error(`Unknown status: ${a}`);let R=nt(h,new Uint8Array(S)),O=o?.nodeKeys.get(f);if(!O)throw new bt("Invalid signature from replica signed query: no matching node key found.");let V=pi.fromDer(O).rawKey;if(I0.verify(d.signature,new Uint8Array(R),new Uint8Array(V)))return s;throw new bt(`Invalid signature from replica ${f} signed query.`)}return s}),this.config=e,ct(this,Mr,e.fetch||$m()||fetch.bind(globalThis),"f"),ct(this,Nn,e.fetchOptions,"f"),ct(this,yi,e.callOptions,"f"),this.rootKey=e.rootKey?e.rootKey:Hr(Um);let n=Vm(e.host);this.host=new URL(n),e.verifyQuerySignatures!==void 0&&ct(this,Lr,e.verifyQuerySignatures,"f"),ct(this,Ht,(r=e.retryTimes)!==null&&r!==void 0?r:3,"f");let i=()=>new mi({maxIterations:ne(this,Ht,"f")});if(ct(this,Xr,e.backoffStrategy||i,"f"),this.host.hostname.endsWith(Pm)?this.host.hostname=Im:this.host.hostname.endsWith(Mm)?this.host.hostname=km:this.host.hostname.endsWith(qm)&&(this.host.hostname=Cm),e.credentials){let{name:s,password:o}=e.credentials;ct(this,jt,`${s}${o?":"+o:""}`,"f")}if(ct(this,tr,Promise.resolve(e.identity||new yn),"f"),e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes>5)throw new Pe(`The maximum ingress expiry time is 5 minutes. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);if(e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes<=0)throw new Pe(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);ct(this,Jr,e.ingressExpiryInMinutes||5,"f"),this.addTransform("update",Ba(gn)),e.useQueryNonces&&this.addTransform("query",Ba(gn)),e.logToConsole&&this.log.subscribe(s=>{s.level==="error"?console.error(s.message):s.level==="warn"?console.warn(s.message):console.log(s.message)})}get waterMark(){return ne(this,wi,"f")}static createSync(e={}){return new this(Object.assign({},e))}static async create(e={shouldFetchRootKey:!1}){let r=t.createSync(e),n=[r.syncTime()];return r.host.toString()!=="https://icp-api.io"&&e.shouldFetchRootKey&&n.push(r.fetchRootKey()),await Promise.all(n),r}static async from(e){var r;try{return"config"in e?await t.create(e.config):await t.create({fetch:e._fetch,fetchOptions:e._fetchOptions,callOptions:e._callOptions,host:e._host.toString(),identity:(r=e._identity)!==null&&r!==void 0?r:void 0})}catch{throw new Pe("Failed to create agent from provided agent")}}isLocal(){let e=this.host.hostname;return e==="127.0.0.1"||e.endsWith("127.0.0.1")}addTransform(e,r,n=r.priority||0){if(e==="update"){let i=ne(this,Sn,"f").findIndex(s=>(s.priority||0)<n);ne(this,Sn,"f").splice(i>=0?i:ne(this,Sn,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=ne(this,Tn,"f").findIndex(s=>(s.priority||0)<n);ne(this,Tn,"f").splice(i>=0?i:ne(this,Tn,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!ne(this,tr,"f"))throw new Rn("This identity has expired due this application's security policy. Please refresh your authentication.");return(await ne(this,tr,"f")).getPrincipal()}async call(e,r,n){var i;let s=(i=r.callSync)!==null&&i!==void 0?i:!0,o=await(n!==void 0?await n:await ne(this,tr,"f"));if(!o)throw new Rn("This identity has expired due this application's security policy. Please refresh your authentication.");let a=de.from(e),c=r.effectiveCanisterId?de.from(r.effectiveCanisterId):a,l=o.getPrincipal()||de.anonymous(),h=new Qt(ne(this,Jr,"f")*ro);Math.abs(ne(this,gi,"f"))>1e3*30&&(h=new Qt(ne(this,Jr,"f")*ro+ne(this,gi,"f")));let d={request_type:xs.Call,canister_id:a,method_name:r.methodName,arg:r.arg,sender:l,ingress_expiry:h},w=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,jt,"f")?{Authorization:"Basic "+btoa(ne(this,jt,"f"))}:{})},endpoint:"call",body:d}),b=w.body.nonce?f(w.body.nonce):void 0;d.nonce=b;function f(O){return new Uint8Array(O)}w=await o.transformRequest(w);let S=ws(w.body),R=ne(this,Xr,"f").call(this);try{let O=()=>(this.log.print(`fetching "/api/v3/canister/${c.toText()}/call" with request:`,w),ne(this,Mr,"f").call(this,""+new URL(`/api/v3/canister/${c.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,yi,"f")),w.request),{body:S}))),V=()=>(this.log.print(`fetching "/api/v2/canister/${c.toText()}/call" with request:`,w),ne(this,Mr,"f").call(this,""+new URL(`/api/v2/canister/${c.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,yi,"f")),w.request),{body:S}))),q=ne(this,rr,"m",io).call(this,{request:s?O:V,backoff:R,tries:0}),[Y,E]=await Promise.all([q,ls(d)]),H=await Y.arrayBuffer(),z=Y.status===200&&H.byteLength>0?Tt(H):null;if(z&&"certificate"in z){let Z=await this.parseTimeFromResponse({certificate:z.certificate});ct(this,wi,Z,"f")}return{requestId:E,response:{ok:Y.ok,status:Y.status,statusText:Y.statusText,body:z,headers:wn(Y.headers)},requestDetails:d}}catch(O){if(O.message.includes("v3 api not supported."))return this.log.warn("v3 api not supported. Fall back to v2"),this.call(e,Object.assign(Object.assign({},r),{callSync:!1}),n);throw this.log.error("Error while making call:",O),O}}async query(e,r,n){let i=ne(this,Xr,"f").call(this),s=r.effectiveCanisterId?de.from(r.effectiveCanisterId):de.from(e);this.log.print(`ecid ${s.toString()}`),this.log.print(`canisterId ${e.toString()}`);let o=async()=>{let b=await(n!==void 0?n:ne(this,tr,"f"));if(!b)throw new Rn("This identity has expired due this application's security policy. Please refresh your authentication.");let f=de.from(e),S=b?.getPrincipal()||de.anonymous(),R={request_type:"query",canister_id:f,method_name:r.methodName,arg:r.arg,sender:S,ingress_expiry:new Qt(ne(this,Jr,"f")*ro)},O=await ls(R),V=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,jt,"f")?{Authorization:"Basic "+btoa(ne(this,jt,"f"))}:{})},endpoint:"read",body:R});V=await b?.transformRequest(V);let q=ws(V.body),Y={canister:f.toText(),ecid:s,transformedRequest:V,body:q,requestId:O,backoff:i,tries:0};return{requestDetails:R,query:await ne(this,rr,"m",W0).call(this,Y)}},a=async()=>{if(!ne(this,Lr,"f"))return;let b=ne(this,Qr,"f").get(s.toString());return b||(await this.fetchSubnetKeys(s.toString()),ne(this,Qr,"f").get(s.toString()))},[c,l]=await Promise.all([o(),a()]),{requestDetails:h,query:d}=c,w=Object.assign(Object.assign({},d),{requestDetails:h});if(this.log.print("Query response:",w),!ne(this,Lr,"f"))return w;try{return ne(this,so,"f").call(this,w,l)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ne(this,Qr,"f").delete(e.toString()),await this.fetchSubnetKeys(s.toString());let f=ne(this,Qr,"f").get(e.toString());if(!f)throw new bt("Invalid signature from replica signed query: no matching node key found.");return ne(this,so,"f").call(this,w,f)}}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await ne(this,tr,"f"));if(!n)throw new Rn("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||de.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,jt,"f")?{Authorization:"Basic "+btoa(ne(this,jt,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new Qt(ne(this,Jr,"f")*ro)}});return n?.transformRequest(s)}async readState(e,r,n,i){let s=typeof e=="string"?de.fromText(e):e,o=i??await this.createReadStateRequest(r,n),a=Object.assign(Object.assign({},o.body),{ingress_expiry:new Qt(3e5)}),c=ws(a);this.log.print(`fetching "/api/v2/canister/${s}/read_state" with request:`,o);let l=ne(this,Xr,"f").call(this);try{let h=await ne(this,rr,"m",io).call(this,{request:()=>ne(this,Mr,"f").call(this,""+new URL(`/api/v2/canister/${s.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,Nn,"f")),o.request),{body:c})),backoff:l,tries:0});if(!h.ok)throw new Error(`Server returned an error:
13
+ variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(e.hasOwnProperty(n)){let s=Oe(r),o=i.encodeValue(e[n]);return Ee(s,o)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,s])=>{s.buildTypeTable(e)});let r=ze(-21),n=Oe(this._fields.length),i=this._fields.map(([s,o])=>Ee(Oe(Ot(s)),o.encodeType(e)));e.add(this,Ee(r,n,...i))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a variant type");let i=Number(Ge(e));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,o]=n._fields[i];for(let[a,c]of this._fields)if(Ot(s)===Ot(a)){let l=c.decodeValue(e,o);return{[a]:l}}throw new Error("Cannot find field hash "+s)}get name(){return`variant {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([r,n])=>r+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(e){for(let[r,n]of this._fields)if(e.hasOwnProperty(r)){let i=n.valueToString(e[r]);return i==="null"?`variant {${r}}`:`variant {${r}=${i}}`}throw new Error("Variant has no data: "+e)}},_r=class t extends Wt{constructor(){super(...arguments),this._id=t._counter++,this._type=void 0}accept(e,r){if(!this._type)throw Error("Recursive type uninitialized.");return e.visitRec(this,this._type,r)}fill(e){this._type=e}getType(){return this._type}covariant(e){if(this._type&&this._type.covariant(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(e)}_buildTypeTableImpl(e){if(!this._type)throw Error("Recursive type uninitialized.");e.add(this,new Uint8Array([])),this._type.buildTypeTable(e),e.merge(this,this._type.name)}decodeValue(e,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(e,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(e)}};_r._counter=0;Li=class extends ht{accept(e,r){return e.visitPrincipal(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=Oe(r.byteLength);return Ee(new Uint8Array([1]),n,r)}encodeType(){return ze(-24)}decodeValue(e,r){return this.checkType(r),jo(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}},zn=class extends Wt{constructor(e,r,n=[]){super(),this.argTypes=e,this.retTypes=r,this.annotations=n}static argsToString(e,r){if(e.length!==r.length)throw new Error("arity mismatch");return"("+e.map((n,i)=>n.valueToString(r[i])).join(", ")+")"}accept(e,r){return e.visitFunc(this,r)}covariant(e){if(Array.isArray(e)&&e.length===2&&e[0]&&e[0]._isPrincipal&&typeof e[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue([e,r]){let n=e.toUint8Array(),i=Oe(n.byteLength),s=Ee(new Uint8Array([1]),i,n),o=new TextEncoder().encode(r),a=Oe(o.byteLength);return Ee(new Uint8Array([1]),s,a,o)}_buildTypeTableImpl(e){this.argTypes.forEach(l=>l.buildTypeTable(e)),this.retTypes.forEach(l=>l.buildTypeTable(e));let r=ze(-22),n=Oe(this.argTypes.length),i=Ee(...this.argTypes.map(l=>l.encodeType(e))),s=Oe(this.retTypes.length),o=Ee(...this.retTypes.map(l=>l.encodeType(e))),a=Oe(this.annotations.length),c=Ee(...this.annotations.map(l=>this.encodeAnnotation(l)));e.add(this,Ee(r,n,i,s,o,a,c))}decodeValue(e){if(br(e)!==1)throw new Error("Cannot decode function reference");let n=jo(e),i=Number(Ge(e)),s=xr(e,i),a=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,a]}get name(){let e=this.argTypes.map(i=>i.name).join(", "),r=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${e}) -> (${r})${n}`}valueToString([e,r]){return`func "${e.toText()}".${r}`}display(){let e=this.argTypes.map(i=>i.display()).join(", "),r=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${e}) \u2192 (${r})${n}`}encodeAnnotation(e){if(e==="query")return new Uint8Array([1]);if(e==="oneway")return new Uint8Array([2]);if(e==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}},Di=class extends Wt{constructor(e){super(),this._fields=Object.entries(e).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(e,r){return e.visitService(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=Oe(r.length);return Ee(new Uint8Array([1]),n,r)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=ze(-23),n=Oe(this._fields.length),i=this._fields.map(([s,o])=>{let a=new TextEncoder().encode(s),c=Oe(a.length);return Ee(c,a,o.encodeType(e))});e.add(this,Ee(r,n,...i))}decodeValue(e){return jo(e)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};lu=new Hi,hu=new hn,$h=new Gi,du=new zi,pu=new Yi,mu=new Ki,yu=new Wi,gu=new Zi,wu=new Hn(32),bu=new Hn(64),xu=new ar(8),_u=new ar(16),Eu=new ar(32),vu=new ar(64),Bu=new Kt(8),Au=new Kt(16),Tu=new Kt(32),Su=new Kt(64),Nu=new Li});var Go=he(()=>{});var Cu=he(()=>{Ho();yt();Go()});var qu=he(()=>{});var Yn=he(()=>{Cu();Go();Ho();Mo();$o();qi();qu()});var sf={};In(sf,{Buffer:()=>X,INSPECT_MAX_BYTES:()=>Yu,SlowBuffer:()=>Qh,isBuffer:()=>rf,kMaxLength:()=>Kh});function Hu(){Yo=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,r=t.length;e<r;++e)Zt[e]=t[e],vt[t.charCodeAt(e)]=e;vt[45]=62,vt[95]=63}function Hh(t){Yo||Hu();var e,r,n,i,s,o,a=t.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s=t[a-2]==="="?2:t[a-1]==="="?1:0,o=new jh(a*3/4-s),n=s>0?a-4:a;var c=0;for(e=0,r=0;e<n;e+=4,r+=3)i=vt[t.charCodeAt(e)]<<18|vt[t.charCodeAt(e+1)]<<12|vt[t.charCodeAt(e+2)]<<6|vt[t.charCodeAt(e+3)],o[c++]=i>>16&255,o[c++]=i>>8&255,o[c++]=i&255;return s===2?(i=vt[t.charCodeAt(e)]<<2|vt[t.charCodeAt(e+1)]>>4,o[c++]=i&255):s===1&&(i=vt[t.charCodeAt(e)]<<10|vt[t.charCodeAt(e+1)]<<4|vt[t.charCodeAt(e+2)]>>2,o[c++]=i>>8&255,o[c++]=i&255),o}function Gh(t){return Zt[t>>18&63]+Zt[t>>12&63]+Zt[t>>6&63]+Zt[t&63]}function zh(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16)+(t[s+1]<<8)+t[s+2],i.push(Gh(n));return i.join("")}function $u(t){Yo||Hu();for(var e,r=t.length,n=r%3,i="",s=[],o=16383,a=0,c=r-n;a<c;a+=o)s.push(zh(t,a,a+o>c?c:a+o));return n===1?(e=t[r-1],i+=Zt[e>>2],i+=Zt[e<<4&63],i+="=="):n===2&&(e=(t[r-2]<<8)+t[r-1],i+=Zt[e>>10],i+=Zt[e>>4&63],i+=Zt[e<<2&63],i+="="),s.push(i),s.join("")}function rs(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,l=c>>1,h=-7,d=r?i-1:0,w=r?-1:1,b=t[e+d];for(d+=w,s=b&(1<<-h)-1,b>>=-h,h+=a;h>0;s=s*256+t[e+d],d+=w,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=o*256+t[e+d],d+=w,h-=8);if(s===0)s=1-l;else{if(s===c)return o?NaN:(b?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-l}return(b?-1:1)*o*Math.pow(2,s-n)}function Gu(t,e,r,n,i,s){var o,a,c,l=s*8-i-1,h=(1<<l)-1,d=h>>1,w=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=n?0:s-1,f=n?1:-1,S=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+d>=1?e+=w/c:e+=w*Math.pow(2,1-d),e*c>=2&&(o++,c/=2),o+d>=h?(a=0,o=h):o+d>=1?(a=(e*c-1)*Math.pow(2,i),o=o+d):(a=e*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;t[r+b]=a&255,b+=f,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;t[r+b]=o&255,b+=f,o/=256,l-=8);t[r+b-f]|=S*128}function es(){return X.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function cr(t,e){if(es()<e)throw new RangeError("Invalid typed array length");return X.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=X.prototype):(t===null&&(t=new X(e)),t.length=e),t}function X(t,e,r){if(!X.TYPED_ARRAY_SUPPORT&&!(this instanceof X))return new X(t,e,r);if(typeof t=="number"){if(typeof e=="string")throw new Error("If encoding is specified then the first argument must be a string");return Ko(this,t)}return Ku(this,t,e,r)}function Ku(t,e,r,n){if(typeof e=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer?Xh(t,e,r,n):typeof e=="string"?Zh(t,e,r):Jh(t,e)}function Wu(t){if(typeof t!="number")throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function Wh(t,e,r,n){return Wu(e),e<=0?cr(t,e):r!==void 0?typeof n=="string"?cr(t,e).fill(r,n):cr(t,e).fill(r):cr(t,e)}function Ko(t,e){if(Wu(e),t=cr(t,e<0?0:Wo(e)|0),!X.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function Zh(t,e,r){if((typeof r!="string"||r==="")&&(r="utf8"),!X.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=Zu(e,r)|0;t=cr(t,n);var i=t.write(e,r);return i!==n&&(t=t.slice(0,i)),t}function zo(t,e){var r=e.length<0?0:Wo(e.length)|0;t=cr(t,r);for(var n=0;n<r;n+=1)t[n]=e[n]&255;return t}function Xh(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return r===void 0&&n===void 0?e=new Uint8Array(e):n===void 0?e=new Uint8Array(e,r):e=new Uint8Array(e,r,n),X.TYPED_ARRAY_SUPPORT?(t=e,t.__proto__=X.prototype):t=zo(t,e),t}function Jh(t,e){if(Xt(e)){var r=Wo(e.length)|0;return t=cr(t,r),t.length===0||e.copy(t,0,0,r),t}if(e){if(typeof ArrayBuffer<"u"&&e.buffer instanceof ArrayBuffer||"length"in e)return typeof e.length!="number"||yd(e.length)?cr(t,0):zo(t,e);if(e.type==="Buffer"&&zu(e.data))return zo(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Wo(t){if(t>=es())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+es().toString(16)+" bytes");return t|0}function Qh(t){return+t!=t&&(t=0),X.alloc(+t)}function Xt(t){return!!(t!=null&&t._isBuffer)}function Zu(t,e){if(Xt(t))return t.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;typeof t!="string"&&(t=""+t);var r=t.length;if(r===0)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return ts(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return tf(t).length;default:if(n)return ts(t).length;e=(""+e).toLowerCase(),n=!0}}function Lh(t,e,r){var n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return cd(this,e,r);case"utf8":case"utf-8":return Qu(this,e,r);case"ascii":return od(this,e,r);case"latin1":case"binary":return ad(this,e,r);case"base64":return id(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ud(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function Gr(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function Xu(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=X.from(e,n)),Xt(e))return e.length===0?-1:Vu(t,e,r,n,i);if(typeof e=="number")return e=e&255,X.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):Vu(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Vu(t,e,r,n,i){var s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(b,f){return s===1?b[f]:b.readUInt16BE(f*s)}var l;if(i){var h=-1;for(l=r;l<o;l++)if(c(t,l)===c(e,h===-1?0:l-h)){if(h===-1&&(h=l),l-h+1===a)return h*s}else h!==-1&&(l-=l-h),h=-1}else for(r+a>o&&(r=o-a),l=r;l>=0;l--){for(var d=!0,w=0;w<a;w++)if(c(t,l+w)!==c(e,w)){d=!1;break}if(d)return l}return-1}function Dh(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var s=e.length;if(s%2!==0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o<n;++o){var a=parseInt(e.substr(o*2,2),16);if(isNaN(a))return o;t[r+o]=a}return o}function ed(t,e,r,n){return ss(ts(e,t.length-r),t,r,n)}function Ju(t,e,r,n){return ss(pd(e),t,r,n)}function td(t,e,r,n){return Ju(t,e,r,n)}function rd(t,e,r,n){return ss(tf(e),t,r,n)}function nd(t,e,r,n){return ss(md(e,t.length-r),t,r,n)}function id(t,e,r){return e===0&&r===t.length?$u(t):$u(t.slice(e,r))}function Qu(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){var c,l,h,d;switch(a){case 1:s<128&&(o=s);break;case 2:c=t[i+1],(c&192)===128&&(d=(s&31)<<6|c&63,d>127&&(o=d));break;case 3:c=t[i+1],l=t[i+2],(c&192)===128&&(l&192)===128&&(d=(s&15)<<12|(c&63)<<6|l&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:c=t[i+1],l=t[i+2],h=t[i+3],(c&192)===128&&(l&192)===128&&(h&192)===128&&(d=(s&15)<<18|(c&63)<<12|(l&63)<<6|h&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return sd(n)}function sd(t){var e=t.length;if(e<=ju)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=ju));return r}function od(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function ad(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function cd(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",s=e;s<r;++s)i+=dd(t[s]);return i}function ud(t,e,r){for(var n=t.slice(e,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}function Qe(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function dt(t,e,r,n,i,s){if(!Xt(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function ns(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,s=Math.min(t.length-r,2);i<s;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}function is(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,s=Math.min(t.length-r,4);i<s;++i)t[r+i]=e>>>(n?i:3-i)*8&255}function Lu(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Du(t,e,r,n,i){return i||Lu(t,e,r,4),Gu(t,e,r,n,23,4),r+4}function ef(t,e,r,n,i){return i||Lu(t,e,r,8),Gu(t,e,r,n,52,8),r+8}function ld(t){if(t=hd(t).replace(fd,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function hd(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function dd(t){return t<16?"0"+t.toString(16):t.toString(16)}function ts(t,e){e=e||1/0;for(var r,n=t.length,i=null,s=[],o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function pd(t){for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function md(t,e){for(var r,n,i,s=[],o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function tf(t){return Hh(ld(t))}function ss(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function yd(t){return t!==t}function rf(t){return t!=null&&(!!t._isBuffer||nf(t)||gd(t))}function nf(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function gd(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&nf(t.slice(0,0))}var Zt,vt,jh,Yo,Yh,zu,Yu,Kh,ju,fd,of=he(()=>{Zt=[],vt=[],jh=typeof Uint8Array<"u"?Uint8Array:Array,Yo=!1;Yh={}.toString,zu=Array.isArray||function(t){return Yh.call(t)=="[object Array]"};Yu=50;X.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;Kh=es();X.poolSize=8192;X._augment=function(t){return t.__proto__=X.prototype,t};X.from=function(t,e,r){return Ku(null,t,e,r)};X.TYPED_ARRAY_SUPPORT&&(X.prototype.__proto__=Uint8Array.prototype,X.__proto__=Uint8Array);X.alloc=function(t,e,r){return Wh(null,t,e,r)};X.allocUnsafe=function(t){return Ko(null,t)};X.allocUnsafeSlow=function(t){return Ko(null,t)};X.isBuffer=rf;X.compare=function(e,r){if(!Xt(e)||!Xt(r))throw new TypeError("Arguments must be Buffers");if(e===r)return 0;for(var n=e.length,i=r.length,s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==r[s]){n=e[s],i=r[s];break}return n<i?-1:i<n?1:0};X.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};X.concat=function(e,r){if(!zu(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return X.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;var i=X.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){var o=e[n];if(!Xt(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,s),s+=o.length}return i};X.byteLength=Zu;X.prototype._isBuffer=!0;X.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<e;r+=2)Gr(this,r,r+1);return this};X.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<e;r+=4)Gr(this,r,r+3),Gr(this,r+1,r+2);return this};X.prototype.swap64=function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<e;r+=8)Gr(this,r,r+7),Gr(this,r+1,r+6),Gr(this,r+2,r+5),Gr(this,r+3,r+4);return this};X.prototype.toString=function(){var e=this.length|0;return e===0?"":arguments.length===0?Qu(this,0,e):Lh.apply(this,arguments)};X.prototype.equals=function(e){if(!Xt(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:X.compare(this,e)===0};X.prototype.inspect=function(){var e="",r=Yu;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"};X.prototype.compare=function(e,r,n,i,s){if(!Xt(e))throw new TypeError("Argument must be a Buffer");if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;for(var o=s-i,a=n-r,c=Math.min(o,a),l=this.slice(i,s),h=e.slice(r,n),d=0;d<c;++d)if(l[d]!==h[d]){o=l[d],a=h[d];break}return o<a?-1:a<o?1:0};X.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};X.prototype.indexOf=function(e,r,n){return Xu(this,e,r,n,!0)};X.prototype.lastIndexOf=function(e,r,n){return Xu(this,e,r,n,!1)};X.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r|0,isFinite(n)?(n=n|0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s=this.length-r;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return Dh(this,e,r,n);case"utf8":case"utf-8":return ed(this,e,r,n);case"ascii":return Ju(this,e,r,n);case"latin1":case"binary":return td(this,e,r,n);case"base64":return rd(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return nd(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};X.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};ju=4096;X.prototype.slice=function(e,r){var n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);var i;if(X.TYPED_ARRAY_SUPPORT)i=this.subarray(e,r),i.__proto__=X.prototype;else{var s=r-e;i=new X(s,void 0);for(var o=0;o<s;++o)i[o]=this[o+e]}return i};X.prototype.readUIntLE=function(e,r,n){e=e|0,r=r|0,n||Qe(e,r,this.length);for(var i=this[e],s=1,o=0;++o<r&&(s*=256);)i+=this[e+o]*s;return i};X.prototype.readUIntBE=function(e,r,n){e=e|0,r=r|0,n||Qe(e,r,this.length);for(var i=this[e+--r],s=1;r>0&&(s*=256);)i+=this[e+--r]*s;return i};X.prototype.readUInt8=function(e,r){return r||Qe(e,1,this.length),this[e]};X.prototype.readUInt16LE=function(e,r){return r||Qe(e,2,this.length),this[e]|this[e+1]<<8};X.prototype.readUInt16BE=function(e,r){return r||Qe(e,2,this.length),this[e]<<8|this[e+1]};X.prototype.readUInt32LE=function(e,r){return r||Qe(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};X.prototype.readUInt32BE=function(e,r){return r||Qe(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};X.prototype.readIntLE=function(e,r,n){e=e|0,r=r|0,n||Qe(e,r,this.length);for(var i=this[e],s=1,o=0;++o<r&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};X.prototype.readIntBE=function(e,r,n){e=e|0,r=r|0,n||Qe(e,r,this.length);for(var i=r,s=1,o=this[e+--i];i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};X.prototype.readInt8=function(e,r){return r||Qe(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};X.prototype.readInt16LE=function(e,r){r||Qe(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};X.prototype.readInt16BE=function(e,r){r||Qe(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};X.prototype.readInt32LE=function(e,r){return r||Qe(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};X.prototype.readInt32BE=function(e,r){return r||Qe(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};X.prototype.readFloatLE=function(e,r){return r||Qe(e,4,this.length),rs(this,e,!0,23,4)};X.prototype.readFloatBE=function(e,r){return r||Qe(e,4,this.length),rs(this,e,!1,23,4)};X.prototype.readDoubleLE=function(e,r){return r||Qe(e,8,this.length),rs(this,e,!0,52,8)};X.prototype.readDoubleBE=function(e,r){return r||Qe(e,8,this.length),rs(this,e,!1,52,8)};X.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r|0,n=n|0,!i){var s=Math.pow(2,8*n)-1;dt(this,e,r,n,s,0)}var o=1,a=0;for(this[r]=e&255;++a<n&&(o*=256);)this[r+a]=e/o&255;return r+n};X.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r|0,n=n|0,!i){var s=Math.pow(2,8*n)-1;dt(this,e,r,n,s,0)}var o=n-1,a=1;for(this[r+o]=e&255;--o>=0&&(a*=256);)this[r+o]=e/a&255;return r+n};X.prototype.writeUInt8=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,1,255,0),X.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[r]=e&255,r+1};X.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,2,65535,0),X.TYPED_ARRAY_SUPPORT?(this[r]=e&255,this[r+1]=e>>>8):ns(this,e,r,!0),r+2};X.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,2,65535,0),X.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=e&255):ns(this,e,r,!1),r+2};X.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,4,4294967295,0),X.TYPED_ARRAY_SUPPORT?(this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255):is(this,e,r,!0),r+4};X.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,4,4294967295,0),X.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255):is(this,e,r,!1),r+4};X.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r|0,!i){var s=Math.pow(2,8*n-1);dt(this,e,r,n,s-1,-s)}var o=0,a=1,c=0;for(this[r]=e&255;++o<n&&(a*=256);)e<0&&c===0&&this[r+o-1]!==0&&(c=1),this[r+o]=(e/a>>0)-c&255;return r+n};X.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r|0,!i){var s=Math.pow(2,8*n-1);dt(this,e,r,n,s-1,-s)}var o=n-1,a=1,c=0;for(this[r+o]=e&255;--o>=0&&(a*=256);)e<0&&c===0&&this[r+o+1]!==0&&(c=1),this[r+o]=(e/a>>0)-c&255;return r+n};X.prototype.writeInt8=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,1,127,-128),X.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[r]=e&255,r+1};X.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,2,32767,-32768),X.TYPED_ARRAY_SUPPORT?(this[r]=e&255,this[r+1]=e>>>8):ns(this,e,r,!0),r+2};X.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,2,32767,-32768),X.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=e&255):ns(this,e,r,!1),r+2};X.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,4,2147483647,-2147483648),X.TYPED_ARRAY_SUPPORT?(this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24):is(this,e,r,!0),r+4};X.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),X.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255):is(this,e,r,!1),r+4};X.prototype.writeFloatLE=function(e,r,n){return Du(this,e,r,!0,n)};X.prototype.writeFloatBE=function(e,r,n){return Du(this,e,r,!1,n)};X.prototype.writeDoubleLE=function(e,r,n){return ef(this,e,r,!0,n)};X.prototype.writeDoubleBE=function(e,r,n){return ef(this,e,r,!1,n)};X.prototype.copy=function(e,r,n,i){if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);var s=i-n,o;if(this===e&&n<r&&r<i)for(o=s-1;o>=0;--o)e[o+r]=this[o+n];else if(s<1e3||!X.TYPED_ARRAY_SUPPORT)for(o=0;o<s;++o)e[o+r]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+s),r);return s};X.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),e.length===1){var s=e.charCodeAt(0);s<256&&(e=s)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!X.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof e=="number"&&(e=e&255);if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);var o;if(typeof e=="number")for(o=r;o<n;++o)this[o]=e;else{var a=Xt(e)?e:ts(new X(e,i).toString()),c=a.length;for(o=0;o<n-r;++o)this[o+r]=a[o%c]}return this};fd=/[^+\/0-9A-Za-z-_]/g});var Kn=He((gy,os)=>{var zr=(of(),Zl(sf));if(zr&&zr.default){os.exports=zr.default;for(let t in zr)os.exports[t]=zr[t]}else zr&&(os.exports=zr)});var Wn=He((af,as)=>{(function(t){"use strict";var e,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",a=1e14,c=14,l=9007199254740991,h=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],d=1e7,w=1e9;function b(E){var H,Y,Z,C=P.prototype={constructor:P,toString:null,valueOf:null},ie=new P(1),re=20,ee=4,g=-7,B=21,$=-1e7,F=1e7,U=!1,G=1,J=0,fe={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},ce="0123456789abcdefghijklmnopqrstuvwxyz",W=!0;function P(u,p){var y,T,v,A,M,x,N,k,I=this;if(!(I instanceof P))return new P(u,p);if(p==null){if(u&&u._isBigNumber===!0){I.s=u.s,!u.c||u.e>F?I.c=I.e=null:u.e<$?I.c=[I.e=0]:(I.e=u.e,I.c=u.c.slice());return}if((x=typeof u=="number")&&u*0==0){if(I.s=1/u<0?(u=-u,-1):1,u===~~u){for(A=0,M=u;M>=10;M/=10,A++);A>F?I.c=I.e=null:(I.e=A,I.c=[u]);return}k=String(u)}else{if(!r.test(k=String(u)))return Z(I,k,x);I.s=k.charCodeAt(0)==45?(k=k.slice(1),-1):1}(A=k.indexOf("."))>-1&&(k=k.replace(".","")),(M=k.search(/e/i))>0?(A<0&&(A=M),A+=+k.slice(M+1),k=k.substring(0,M)):A<0&&(A=k.length)}else{if(O(p,2,ce.length,"Base"),p==10&&W)return I=new P(u),le(I,re+I.e+1,ee);if(k=String(u),x=typeof u=="number"){if(u*0!=0)return Z(I,k,x,p);if(I.s=1/u<0?(k=k.slice(1),-1):1,P.DEBUG&&k.replace(/^0\.0*|\./,"").length>15)throw Error(o+u)}else I.s=k.charCodeAt(0)===45?(k=k.slice(1),-1):1;for(y=ce.slice(0,p),A=M=0,N=k.length;M<N;M++)if(y.indexOf(T=k.charAt(M))<0){if(T=="."){if(M>A){A=N;continue}}else if(!v&&(k==k.toUpperCase()&&(k=k.toLowerCase())||k==k.toLowerCase()&&(k=k.toUpperCase()))){v=!0,M=-1,A=0;continue}return Z(I,String(u),x,p)}x=!1,k=Y(k,p,10,I.s),(A=k.indexOf("."))>-1?k=k.replace(".",""):A=k.length}for(M=0;k.charCodeAt(M)===48;M++);for(N=k.length;k.charCodeAt(--N)===48;);if(k=k.slice(M,++N)){if(N-=M,x&&P.DEBUG&&N>15&&(u>l||u!==i(u)))throw Error(o+I.s*u);if((A=A-M-1)>F)I.c=I.e=null;else if(A<$)I.c=[I.e=0];else{if(I.e=A,I.c=[],M=(A+1)%c,A<0&&(M+=c),M<N){for(M&&I.c.push(+k.slice(0,M)),N-=c;M<N;)I.c.push(+k.slice(M,M+=c));M=c-(k=k.slice(M)).length}else M-=N;for(;M--;k+="0");I.c.push(+k)}}else I.c=[I.e=0]}P.clone=b,P.ROUND_UP=0,P.ROUND_DOWN=1,P.ROUND_CEIL=2,P.ROUND_FLOOR=3,P.ROUND_HALF_UP=4,P.ROUND_HALF_DOWN=5,P.ROUND_HALF_EVEN=6,P.ROUND_HALF_CEIL=7,P.ROUND_HALF_FLOOR=8,P.EUCLID=9,P.config=P.set=function(u){var p,y;if(u!=null)if(typeof u=="object"){if(u.hasOwnProperty(p="DECIMAL_PLACES")&&(y=u[p],O(y,0,w,p),re=y),u.hasOwnProperty(p="ROUNDING_MODE")&&(y=u[p],O(y,0,8,p),ee=y),u.hasOwnProperty(p="EXPONENTIAL_AT")&&(y=u[p],y&&y.pop?(O(y[0],-w,0,p),O(y[1],0,w,p),g=y[0],B=y[1]):(O(y,-w,w,p),g=-(B=y<0?-y:y))),u.hasOwnProperty(p="RANGE"))if(y=u[p],y&&y.pop)O(y[0],-w,-1,p),O(y[1],1,w,p),$=y[0],F=y[1];else if(O(y,-w,w,p),y)$=-(F=y<0?-y:y);else throw Error(s+p+" cannot be zero: "+y);if(u.hasOwnProperty(p="CRYPTO"))if(y=u[p],y===!!y)if(y)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))U=y;else throw U=!y,Error(s+"crypto unavailable");else U=y;else throw Error(s+p+" not true or false: "+y);if(u.hasOwnProperty(p="MODULO_MODE")&&(y=u[p],O(y,0,9,p),G=y),u.hasOwnProperty(p="POW_PRECISION")&&(y=u[p],O(y,0,w,p),J=y),u.hasOwnProperty(p="FORMAT"))if(y=u[p],typeof y=="object")fe=y;else throw Error(s+p+" not an object: "+y);if(u.hasOwnProperty(p="ALPHABET"))if(y=u[p],typeof y=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(y))W=y.slice(0,10)=="0123456789",ce=y;else throw Error(s+p+" invalid: "+y)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:re,ROUNDING_MODE:ee,EXPONENTIAL_AT:[g,B],RANGE:[$,F],CRYPTO:U,MODULO_MODE:G,POW_PRECISION:J,FORMAT:fe,ALPHABET:ce}},P.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!P.DEBUG)return!0;var p,y,T=u.c,v=u.e,A=u.s;e:if({}.toString.call(T)=="[object Array]"){if((A===1||A===-1)&&v>=-w&&v<=w&&v===i(v)){if(T[0]===0){if(v===0&&T.length===1)return!0;break e}if(p=(v+1)%c,p<1&&(p+=c),String(T[0]).length==p){for(p=0;p<T.length;p++)if(y=T[p],y<0||y>=a||y!==i(y))break e;if(y!==0)return!0}}}else if(T===null&&v===null&&(A===null||A===1||A===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},P.maximum=P.max=function(){return L(arguments,-1)},P.minimum=P.min=function(){return L(arguments,1)},P.random=function(){var u=9007199254740992,p=Math.random()*u&2097151?function(){return i(Math.random()*u)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(y){var T,v,A,M,x,N=0,k=[],I=new P(ie);if(y==null?y=re:O(y,0,w),M=n(y/c),U)if(crypto.getRandomValues){for(T=crypto.getRandomValues(new Uint32Array(M*=2));N<M;)x=T[N]*131072+(T[N+1]>>>11),x>=9e15?(v=crypto.getRandomValues(new Uint32Array(2)),T[N]=v[0],T[N+1]=v[1]):(k.push(x%1e14),N+=2);N=M/2}else if(crypto.randomBytes){for(T=crypto.randomBytes(M*=7);N<M;)x=(T[N]&31)*281474976710656+T[N+1]*1099511627776+T[N+2]*4294967296+T[N+3]*16777216+(T[N+4]<<16)+(T[N+5]<<8)+T[N+6],x>=9e15?crypto.randomBytes(7).copy(T,N):(k.push(x%1e14),N+=7);N=M/7}else throw U=!1,Error(s+"crypto unavailable");if(!U)for(;N<M;)x=p(),x<9e15&&(k[N++]=x%1e14);for(M=k[--N],y%=c,M&&y&&(x=h[c-y],k[N]=i(M/x)*x);k[N]===0;k.pop(),N--);if(N<0)k=[A=0];else{for(A=-1;k[0]===0;k.splice(0,1),A-=c);for(N=1,x=k[0];x>=10;x/=10,N++);N<c&&(A-=c-N)}return I.e=A,I.c=k,I}}(),P.sum=function(){for(var u=1,p=arguments,y=new P(p[0]);u<p.length;)y=y.plus(p[u++]);return y},Y=function(){var u="0123456789";function p(y,T,v,A){for(var M,x=[0],N,k=0,I=y.length;k<I;){for(N=x.length;N--;x[N]*=T);for(x[0]+=A.indexOf(y.charAt(k++)),M=0;M<x.length;M++)x[M]>v-1&&(x[M+1]==null&&(x[M+1]=0),x[M+1]+=x[M]/v|0,x[M]%=v)}return x.reverse()}return function(y,T,v,A,M){var x,N,k,I,K,Q,oe,ye,ve=y.indexOf("."),Se=re,me=ee;for(ve>=0&&(I=J,J=0,y=y.replace(".",""),ye=new P(T),Q=ye.pow(y.length-ve),J=I,ye.c=p(z(S(Q.c),Q.e,"0"),10,v,u),ye.e=ye.c.length),oe=p(y,T,v,M?(x=ce,u):(x=u,ce)),k=I=oe.length;oe[--I]==0;oe.pop());if(!oe[0])return x.charAt(0);if(ve<0?--k:(Q.c=oe,Q.e=k,Q.s=A,Q=H(Q,ye,Se,me,v),oe=Q.c,K=Q.r,k=Q.e),N=k+Se+1,ve=oe[N],I=v/2,K=K||N<0||oe[N+1]!=null,K=me<4?(ve!=null||K)&&(me==0||me==(Q.s<0?3:2)):ve>I||ve==I&&(me==4||K||me==6&&oe[N-1]&1||me==(Q.s<0?8:7)),N<1||!oe[0])y=K?z(x.charAt(1),-Se,x.charAt(0)):x.charAt(0);else{if(oe.length=N,K)for(--v;++oe[--N]>v;)oe[N]=0,N||(++k,oe=[1].concat(oe));for(I=oe.length;!oe[--I];);for(ve=0,y="";ve<=I;y+=x.charAt(oe[ve++]));y=z(y,k,x.charAt(0))}return y}}(),H=function(){function u(T,v,A){var M,x,N,k,I=0,K=T.length,Q=v%d,oe=v/d|0;for(T=T.slice();K--;)N=T[K]%d,k=T[K]/d|0,M=oe*N+k*Q,x=Q*N+M%d*d+I,I=(x/A|0)+(M/d|0)+oe*k,T[K]=x%A;return I&&(T=[I].concat(T)),T}function p(T,v,A,M){var x,N;if(A!=M)N=A>M?1:-1;else for(x=N=0;x<A;x++)if(T[x]!=v[x]){N=T[x]>v[x]?1:-1;break}return N}function y(T,v,A,M){for(var x=0;A--;)T[A]-=x,x=T[A]<v[A]?1:0,T[A]=x*M+T[A]-v[A];for(;!T[0]&&T.length>1;T.splice(0,1));}return function(T,v,A,M,x){var N,k,I,K,Q,oe,ye,ve,Se,me,ae,ke,Gt,ir,qr,_t,_e,ut=T.s==v.s?1:-1,De=T.c,Ue=v.c;if(!De||!De[0]||!Ue||!Ue[0])return new P(!T.s||!v.s||(De?Ue&&De[0]==Ue[0]:!Ue)?NaN:De&&De[0]==0||!Ue?ut*0:ut/0);for(ve=new P(ut),Se=ve.c=[],k=T.e-v.e,ut=A+k+1,x||(x=a,k=f(T.e/c)-f(v.e/c),ut=ut/c|0),I=0;Ue[I]==(De[I]||0);I++);if(Ue[I]>(De[I]||0)&&k--,ut<0)Se.push(1),K=!0;else{for(ir=De.length,_t=Ue.length,I=0,ut+=2,Q=i(x/(Ue[0]+1)),Q>1&&(Ue=u(Ue,Q,x),De=u(De,Q,x),_t=Ue.length,ir=De.length),Gt=_t,me=De.slice(0,_t),ae=me.length;ae<_t;me[ae++]=0);_e=Ue.slice(),_e=[0].concat(_e),qr=Ue[0],Ue[1]>=x/2&&qr++;do{if(Q=0,N=p(Ue,me,_t,ae),N<0){if(ke=me[0],_t!=ae&&(ke=ke*x+(me[1]||0)),Q=i(ke/qr),Q>1)for(Q>=x&&(Q=x-1),oe=u(Ue,Q,x),ye=oe.length,ae=me.length;p(oe,me,ye,ae)==1;)Q--,y(oe,_t<ye?_e:Ue,ye,x),ye=oe.length,N=1;else Q==0&&(N=Q=1),oe=Ue.slice(),ye=oe.length;if(ye<ae&&(oe=[0].concat(oe)),y(me,oe,ae,x),ae=me.length,N==-1)for(;p(Ue,me,_t,ae)<1;)Q++,y(me,_t<ae?_e:Ue,ae,x),ae=me.length}else N===0&&(Q++,me=[0]);Se[I++]=Q,me[0]?me[ae++]=De[Gt]||0:(me=[De[Gt]],ae=1)}while((Gt++<ir||me[0]!=null)&&ut--);K=me[0]!=null,Se[0]||Se.splice(0,1)}if(x==a){for(I=1,ut=Se[0];ut>=10;ut/=10,I++);le(ve,A+(ve.e=I+k*c-1)+1,M,K)}else ve.e=k,ve.r=+K;return ve}}();function m(u,p,y,T){var v,A,M,x,N;if(y==null?y=ee:O(y,0,8),!u.c)return u.toString();if(v=u.c[0],M=u.e,p==null)N=S(u.c),N=T==1||T==2&&(M<=g||M>=B)?q(N,M):z(N,M,"0");else if(u=le(new P(u),p,y),A=u.e,N=S(u.c),x=N.length,T==1||T==2&&(p<=A||A<=g)){for(;x<p;N+="0",x++);N=q(N,A)}else if(p-=M,N=z(N,A,"0"),A+1>x){if(--p>0)for(N+=".";p--;N+="0");}else if(p+=A-x,p>0)for(A+1==x&&(N+=".");p--;N+="0");return u.s<0&&v?"-"+N:N}function L(u,p){for(var y,T,v=1,A=new P(u[0]);v<u.length;v++)T=new P(u[v]),(!T.s||(y=R(A,T))===p||y===0&&A.s===p)&&(A=T);return A}function te(u,p,y){for(var T=1,v=p.length;!p[--v];p.pop());for(v=p[0];v>=10;v/=10,T++);return(y=T+y*c-1)>F?u.c=u.e=null:y<$?u.c=[u.e=0]:(u.e=y,u.c=p),u}Z=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,p=/^([^.]+)\.$/,y=/^\.([^.]+)$/,T=/^-?(Infinity|NaN)$/,v=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(A,M,x,N){var k,I=x?M:M.replace(v,"");if(T.test(I))A.s=isNaN(I)?null:I<0?-1:1;else{if(!x&&(I=I.replace(u,function(K,Q,oe){return k=(oe=oe.toLowerCase())=="x"?16:oe=="b"?2:8,!N||N==k?Q:K}),N&&(k=N,I=I.replace(p,"$1").replace(y,"0.$1")),M!=I))return new P(I,k);if(P.DEBUG)throw Error(s+"Not a"+(N?" base "+N:"")+" number: "+M);A.s=null}A.c=A.e=null}}();function le(u,p,y,T){var v,A,M,x,N,k,I,K=u.c,Q=h;if(K){e:{for(v=1,x=K[0];x>=10;x/=10,v++);if(A=p-v,A<0)A+=c,M=p,N=K[k=0],I=i(N/Q[v-M-1]%10);else if(k=n((A+1)/c),k>=K.length)if(T){for(;K.length<=k;K.push(0));N=I=0,v=1,A%=c,M=A-c+1}else break e;else{for(N=x=K[k],v=1;x>=10;x/=10,v++);A%=c,M=A-c+v,I=M<0?0:i(N/Q[v-M-1]%10)}if(T=T||p<0||K[k+1]!=null||(M<0?N:N%Q[v-M-1]),T=y<4?(I||T)&&(y==0||y==(u.s<0?3:2)):I>5||I==5&&(y==4||T||y==6&&(A>0?M>0?N/Q[v-M]:0:K[k-1])%10&1||y==(u.s<0?8:7)),p<1||!K[0])return K.length=0,T?(p-=u.e+1,K[0]=Q[(c-p%c)%c],u.e=-p||0):K[0]=u.e=0,u;if(A==0?(K.length=k,x=1,k--):(K.length=k+1,x=Q[c-A],K[k]=M>0?i(N/Q[v-M]%Q[M])*x:0),T)for(;;)if(k==0){for(A=1,M=K[0];M>=10;M/=10,A++);for(M=K[0]+=x,x=1;M>=10;M/=10,x++);A!=x&&(u.e++,K[0]==a&&(K[0]=1));break}else{if(K[k]+=x,K[k]!=a)break;K[k--]=0,x=1}for(A=K.length;K[--A]===0;K.pop());}u.e>F?u.c=u.e=null:u.e<$&&(u.c=[u.e=0])}return u}function D(u){var p,y=u.e;return y===null?u.toString():(p=S(u.c),p=y<=g||y>=B?q(p,y):z(p,y,"0"),u.s<0?"-"+p:p)}return C.absoluteValue=C.abs=function(){var u=new P(this);return u.s<0&&(u.s=1),u},C.comparedTo=function(u,p){return R(this,new P(u,p))},C.decimalPlaces=C.dp=function(u,p){var y,T,v,A=this;if(u!=null)return O(u,0,w),p==null?p=ee:O(p,0,8),le(new P(A),u+A.e+1,p);if(!(y=A.c))return null;if(T=((v=y.length-1)-f(this.e/c))*c,v=y[v])for(;v%10==0;v/=10,T--);return T<0&&(T=0),T},C.dividedBy=C.div=function(u,p){return H(this,new P(u,p),re,ee)},C.dividedToIntegerBy=C.idiv=function(u,p){return H(this,new P(u,p),0,1)},C.exponentiatedBy=C.pow=function(u,p){var y,T,v,A,M,x,N,k,I,K=this;if(u=new P(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+D(u));if(p!=null&&(p=new P(p)),x=u.e>14,!K.c||!K.c[0]||K.c[0]==1&&!K.e&&K.c.length==1||!u.c||!u.c[0])return I=new P(Math.pow(+D(K),x?u.s*(2-V(u)):+D(u))),p?I.mod(p):I;if(N=u.s<0,p){if(p.c?!p.c[0]:!p.s)return new P(NaN);T=!N&&K.isInteger()&&p.isInteger(),T&&(K=K.mod(p))}else{if(u.e>9&&(K.e>0||K.e<-1||(K.e==0?K.c[0]>1||x&&K.c[1]>=24e7:K.c[0]<8e13||x&&K.c[0]<=9999975e7)))return A=K.s<0&&V(u)?-0:0,K.e>-1&&(A=1/A),new P(N?1/A:A);J&&(A=n(J/c+2))}for(x?(y=new P(.5),N&&(u.s=1),k=V(u)):(v=Math.abs(+D(u)),k=v%2),I=new P(ie);;){if(k){if(I=I.times(K),!I.c)break;A?I.c.length>A&&(I.c.length=A):T&&(I=I.mod(p))}if(v){if(v=i(v/2),v===0)break;k=v%2}else if(u=u.times(y),le(u,u.e+1,1),u.e>14)k=V(u);else{if(v=+D(u),v===0)break;k=v%2}K=K.times(K),A?K.c&&K.c.length>A&&(K.c.length=A):T&&(K=K.mod(p))}return T?I:(N&&(I=ie.div(I)),p?I.mod(p):A?le(I,J,ee,M):I)},C.integerValue=function(u){var p=new P(this);return u==null?u=ee:O(u,0,8),le(p,p.e+1,u)},C.isEqualTo=C.eq=function(u,p){return R(this,new P(u,p))===0},C.isFinite=function(){return!!this.c},C.isGreaterThan=C.gt=function(u,p){return R(this,new P(u,p))>0},C.isGreaterThanOrEqualTo=C.gte=function(u,p){return(p=R(this,new P(u,p)))===1||p===0},C.isInteger=function(){return!!this.c&&f(this.e/c)>this.c.length-2},C.isLessThan=C.lt=function(u,p){return R(this,new P(u,p))<0},C.isLessThanOrEqualTo=C.lte=function(u,p){return(p=R(this,new P(u,p)))===-1||p===0},C.isNaN=function(){return!this.s},C.isNegative=function(){return this.s<0},C.isPositive=function(){return this.s>0},C.isZero=function(){return!!this.c&&this.c[0]==0},C.minus=function(u,p){var y,T,v,A,M=this,x=M.s;if(u=new P(u,p),p=u.s,!x||!p)return new P(NaN);if(x!=p)return u.s=-p,M.plus(u);var N=M.e/c,k=u.e/c,I=M.c,K=u.c;if(!N||!k){if(!I||!K)return I?(u.s=-p,u):new P(K?M:NaN);if(!I[0]||!K[0])return K[0]?(u.s=-p,u):new P(I[0]?M:ee==3?-0:0)}if(N=f(N),k=f(k),I=I.slice(),x=N-k){for((A=x<0)?(x=-x,v=I):(k=N,v=K),v.reverse(),p=x;p--;v.push(0));v.reverse()}else for(T=(A=(x=I.length)<(p=K.length))?x:p,x=p=0;p<T;p++)if(I[p]!=K[p]){A=I[p]<K[p];break}if(A&&(v=I,I=K,K=v,u.s=-u.s),p=(T=K.length)-(y=I.length),p>0)for(;p--;I[y++]=0);for(p=a-1;T>x;){if(I[--T]<K[T]){for(y=T;y&&!I[--y];I[y]=p);--I[y],I[T]+=a}I[T]-=K[T]}for(;I[0]==0;I.splice(0,1),--k);return I[0]?te(u,I,k):(u.s=ee==3?-1:1,u.c=[u.e=0],u)},C.modulo=C.mod=function(u,p){var y,T,v=this;return u=new P(u,p),!v.c||!u.s||u.c&&!u.c[0]?new P(NaN):!u.c||v.c&&!v.c[0]?new P(v):(G==9?(T=u.s,u.s=1,y=H(v,u,0,3),u.s=T,y.s*=T):y=H(v,u,0,G),u=v.minus(y.times(u)),!u.c[0]&&G==1&&(u.s=v.s),u)},C.multipliedBy=C.times=function(u,p){var y,T,v,A,M,x,N,k,I,K,Q,oe,ye,ve,Se,me=this,ae=me.c,ke=(u=new P(u,p)).c;if(!ae||!ke||!ae[0]||!ke[0])return!me.s||!u.s||ae&&!ae[0]&&!ke||ke&&!ke[0]&&!ae?u.c=u.e=u.s=null:(u.s*=me.s,!ae||!ke?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(T=f(me.e/c)+f(u.e/c),u.s*=me.s,N=ae.length,K=ke.length,N<K&&(ye=ae,ae=ke,ke=ye,v=N,N=K,K=v),v=N+K,ye=[];v--;ye.push(0));for(ve=a,Se=d,v=K;--v>=0;){for(y=0,Q=ke[v]%Se,oe=ke[v]/Se|0,M=N,A=v+M;A>v;)k=ae[--M]%Se,I=ae[M]/Se|0,x=oe*k+I*Q,k=Q*k+x%Se*Se+ye[A]+y,y=(k/ve|0)+(x/Se|0)+oe*I,ye[A--]=k%ve;ye[A]=y}return y?++T:ye.splice(0,1),te(u,ye,T)},C.negated=function(){var u=new P(this);return u.s=-u.s||null,u},C.plus=function(u,p){var y,T=this,v=T.s;if(u=new P(u,p),p=u.s,!v||!p)return new P(NaN);if(v!=p)return u.s=-p,T.minus(u);var A=T.e/c,M=u.e/c,x=T.c,N=u.c;if(!A||!M){if(!x||!N)return new P(v/0);if(!x[0]||!N[0])return N[0]?u:new P(x[0]?T:v*0)}if(A=f(A),M=f(M),x=x.slice(),v=A-M){for(v>0?(M=A,y=N):(v=-v,y=x),y.reverse();v--;y.push(0));y.reverse()}for(v=x.length,p=N.length,v-p<0&&(y=N,N=x,x=y,p=v),v=0;p;)v=(x[--p]=x[p]+N[p]+v)/a|0,x[p]=a===x[p]?0:x[p]%a;return v&&(x=[v].concat(x),++M),te(u,x,M)},C.precision=C.sd=function(u,p){var y,T,v,A=this;if(u!=null&&u!==!!u)return O(u,1,w),p==null?p=ee:O(p,0,8),le(new P(A),u,p);if(!(y=A.c))return null;if(v=y.length-1,T=v*c+1,v=y[v]){for(;v%10==0;v/=10,T--);for(v=y[0];v>=10;v/=10,T++);}return u&&A.e+1>T&&(T=A.e+1),T},C.shiftedBy=function(u){return O(u,-l,l),this.times("1e"+u)},C.squareRoot=C.sqrt=function(){var u,p,y,T,v,A=this,M=A.c,x=A.s,N=A.e,k=re+4,I=new P("0.5");if(x!==1||!M||!M[0])return new P(!x||x<0&&(!M||M[0])?NaN:M?A:1/0);if(x=Math.sqrt(+D(A)),x==0||x==1/0?(p=S(M),(p.length+N)%2==0&&(p+="0"),x=Math.sqrt(+p),N=f((N+1)/2)-(N<0||N%2),x==1/0?p="5e"+N:(p=x.toExponential(),p=p.slice(0,p.indexOf("e")+1)+N),y=new P(p)):y=new P(x+""),y.c[0]){for(N=y.e,x=N+k,x<3&&(x=0);;)if(v=y,y=I.times(v.plus(H(A,v,k,1))),S(v.c).slice(0,x)===(p=S(y.c)).slice(0,x))if(y.e<N&&--x,p=p.slice(x-3,x+1),p=="9999"||!T&&p=="4999"){if(!T&&(le(v,v.e+re+2,0),v.times(v).eq(A))){y=v;break}k+=4,x+=4,T=1}else{(!+p||!+p.slice(1)&&p.charAt(0)=="5")&&(le(y,y.e+re+2,1),u=!y.times(y).eq(A));break}}return le(y,y.e+re+1,ee,u)},C.toExponential=function(u,p){return u!=null&&(O(u,0,w),u++),m(this,u,p,1)},C.toFixed=function(u,p){return u!=null&&(O(u,0,w),u=u+this.e+1),m(this,u,p)},C.toFormat=function(u,p,y){var T,v=this;if(y==null)u!=null&&p&&typeof p=="object"?(y=p,p=null):u&&typeof u=="object"?(y=u,u=p=null):y=fe;else if(typeof y!="object")throw Error(s+"Argument not an object: "+y);if(T=v.toFixed(u,p),v.c){var A,M=T.split("."),x=+y.groupSize,N=+y.secondaryGroupSize,k=y.groupSeparator||"",I=M[0],K=M[1],Q=v.s<0,oe=Q?I.slice(1):I,ye=oe.length;if(N&&(A=x,x=N,N=A,ye-=A),x>0&&ye>0){for(A=ye%x||x,I=oe.substr(0,A);A<ye;A+=x)I+=k+oe.substr(A,x);N>0&&(I+=k+oe.slice(A)),Q&&(I="-"+I)}T=K?I+(y.decimalSeparator||"")+((N=+y.fractionGroupSize)?K.replace(new RegExp("\\d{"+N+"}\\B","g"),"$&"+(y.fractionGroupSeparator||"")):K):I}return(y.prefix||"")+T+(y.suffix||"")},C.toFraction=function(u){var p,y,T,v,A,M,x,N,k,I,K,Q,oe=this,ye=oe.c;if(u!=null&&(x=new P(u),!x.isInteger()&&(x.c||x.s!==1)||x.lt(ie)))throw Error(s+"Argument "+(x.isInteger()?"out of range: ":"not an integer: ")+D(x));if(!ye)return new P(oe);for(p=new P(ie),k=y=new P(ie),T=N=new P(ie),Q=S(ye),A=p.e=Q.length-oe.e-1,p.c[0]=h[(M=A%c)<0?c+M:M],u=!u||x.comparedTo(p)>0?A>0?p:k:x,M=F,F=1/0,x=new P(Q),N.c[0]=0;I=H(x,p,0,1),v=y.plus(I.times(T)),v.comparedTo(u)!=1;)y=T,T=v,k=N.plus(I.times(v=k)),N=v,p=x.minus(I.times(v=p)),x=v;return v=H(u.minus(y),T,0,1),N=N.plus(v.times(k)),y=y.plus(v.times(T)),N.s=k.s=oe.s,A=A*2,K=H(k,T,A,ee).minus(oe).abs().comparedTo(H(N,y,A,ee).minus(oe).abs())<1?[k,T]:[N,y],F=M,K},C.toNumber=function(){return+D(this)},C.toPrecision=function(u,p){return u!=null&&O(u,1,w),m(this,u,p,2)},C.toString=function(u){var p,y=this,T=y.s,v=y.e;return v===null?T?(p="Infinity",T<0&&(p="-"+p)):p="NaN":(u==null?p=v<=g||v>=B?q(S(y.c),v):z(S(y.c),v,"0"):u===10&&W?(y=le(new P(y),re+v+1,ee),p=z(S(y.c),y.e,"0")):(O(u,2,ce.length,"Base"),p=Y(z(S(y.c),v,"0"),10,u,T,!0)),T<0&&y.c[0]&&(p="-"+p)),p},C.valueOf=C.toJSON=function(){return D(this)},C._isBigNumber=!0,E!=null&&P.set(E),P}function f(E){var H=E|0;return E>0||E===H?H:H-1}function S(E){for(var H,Y,Z=1,C=E.length,ie=E[0]+"";Z<C;){for(H=E[Z++]+"",Y=c-H.length;Y--;H="0"+H);ie+=H}for(C=ie.length;ie.charCodeAt(--C)===48;);return ie.slice(0,C+1||1)}function R(E,H){var Y,Z,C=E.c,ie=H.c,re=E.s,ee=H.s,g=E.e,B=H.e;if(!re||!ee)return null;if(Y=C&&!C[0],Z=ie&&!ie[0],Y||Z)return Y?Z?0:-ee:re;if(re!=ee)return re;if(Y=re<0,Z=g==B,!C||!ie)return Z?0:!C^Y?1:-1;if(!Z)return g>B^Y?1:-1;for(ee=(g=C.length)<(B=ie.length)?g:B,re=0;re<ee;re++)if(C[re]!=ie[re])return C[re]>ie[re]^Y?1:-1;return g==B?0:g>B^Y?1:-1}function O(E,H,Y,Z){if(E<H||E>Y||E!==i(E))throw Error(s+(Z||"Argument")+(typeof E=="number"?E<H||E>Y?" out of range: ":" not an integer: ":" not a primitive number: ")+String(E))}function V(E){var H=E.c.length-1;return f(E.e/c)==H&&E.c[H]%2!=0}function q(E,H){return(E.length>1?E.charAt(0)+"."+E.slice(1):E)+(H<0?"e":"e+")+H}function z(E,H,Y){var Z,C;if(H<0){for(C=Y+".";++H;C+=Y);E=C+E}else if(Z=E.length,++H>Z){for(C=Y,H-=Z;--H;C+=Y);E+=C}else H<Z&&(E=E.slice(0,H)+"."+E.slice(H));return E}e=b(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof as<"u"&&as.exports?as.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(af)});var uf=He((wy,cf)=>{cf.exports=function(e,r,n){var i=new e.Uint8Array(n),s=r.pushInt,o=r.pushInt32,a=r.pushInt32Neg,c=r.pushInt64,l=r.pushInt64Neg,h=r.pushFloat,d=r.pushFloatSingle,w=r.pushFloatDouble,b=r.pushTrue,f=r.pushFalse,S=r.pushUndefined,R=r.pushNull,O=r.pushInfinity,V=r.pushInfinityNeg,q=r.pushNaN,z=r.pushNaNNeg,E=r.pushArrayStart,H=r.pushArrayStartFixed,Y=r.pushArrayStartFixed32,Z=r.pushArrayStartFixed64,C=r.pushObjectStart,ie=r.pushObjectStartFixed,re=r.pushObjectStartFixed32,ee=r.pushObjectStartFixed64,g=r.pushByteString,B=r.pushByteStringStart,$=r.pushUtf8String,F=r.pushUtf8StringStart,U=r.pushSimpleUnassigned,G=r.pushTagStart,J=r.pushTagStart4,fe=r.pushTagStart8,ce=r.pushTagUnassigned,W=r.pushBreak,P=e.Math.pow,m=0,L=0,te=0;function le(_){for(_=_|0,m=0,L=_;(m|0)<(L|0)&&(te=Hl[i[m]&255](i[m]|0)|0,!((te|0)>0)););return te|0}function D(_){return _=_|0,((m|0)+(_|0)|0)<(L|0)?0:1}function u(_){return _=_|0,i[_|0]<<8|i[_+1|0]|0}function p(_){return _=_|0,i[_|0]<<24|i[_+1|0]<<16|i[_+2|0]<<8|i[_+3|0]|0}function y(_){return _=_|0,s(_|0),m=m+1|0,0}function T(_){return _=_|0,D(1)|0?1:(s(i[m+1|0]|0),m=m+2|0,0)}function v(_){return _=_|0,D(2)|0?1:(s(u(m+1|0)|0),m=m+3|0,0)}function A(_){return _=_|0,D(4)|0?1:(o(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function M(_){return _=_|0,D(8)|0?1:(c(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function x(_){return _=_|0,s(-1-(_-32|0)|0),m=m+1|0,0}function N(_){return _=_|0,D(1)|0?1:(s(-1-(i[m+1|0]|0)|0),m=m+2|0,0)}function k(_){_=_|0;var be=0;return D(2)|0?1:(be=u(m+1|0)|0,s(-1-(be|0)|0),m=m+3|0,0)}function I(_){return _=_|0,D(4)|0?1:(a(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function K(_){return _=_|0,D(8)|0?1:(l(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function Q(_){_=_|0;var be=0,xe=0,ge=0;return ge=_-64|0,D(ge|0)|0?1:(be=m+1|0,xe=(m+1|0)+(ge|0)|0,g(be|0,xe|0),m=xe|0,0)}function oe(_){_=_|0;var be=0,xe=0,ge=0;return D(1)|0||(ge=i[m+1|0]|0,be=m+2|0,xe=(m+2|0)+(ge|0)|0,D(ge+1|0)|0)?1:(g(be|0,xe|0),m=xe|0,0)}function ye(_){_=_|0;var be=0,xe=0,ge=0;return D(2)|0||(ge=u(m+1|0)|0,be=m+3|0,xe=(m+3|0)+(ge|0)|0,D(ge+2|0)|0)?1:(g(be|0,xe|0),m=xe|0,0)}function ve(_){_=_|0;var be=0,xe=0,ge=0;return D(4)|0||(ge=p(m+1|0)|0,be=m+5|0,xe=(m+5|0)+(ge|0)|0,D(ge+4|0)|0)?1:(g(be|0,xe|0),m=xe|0,0)}function Se(_){return _=_|0,1}function me(_){return _=_|0,B(),m=m+1|0,0}function ae(_){_=_|0;var be=0,xe=0,ge=0;return ge=_-96|0,D(ge|0)|0?1:(be=m+1|0,xe=(m+1|0)+(ge|0)|0,$(be|0,xe|0),m=xe|0,0)}function ke(_){_=_|0;var be=0,xe=0,ge=0;return D(1)|0||(ge=i[m+1|0]|0,be=m+2|0,xe=(m+2|0)+(ge|0)|0,D(ge+1|0)|0)?1:($(be|0,xe|0),m=xe|0,0)}function Gt(_){_=_|0;var be=0,xe=0,ge=0;return D(2)|0||(ge=u(m+1|0)|0,be=m+3|0,xe=(m+3|0)+(ge|0)|0,D(ge+2|0)|0)?1:($(be|0,xe|0),m=xe|0,0)}function ir(_){_=_|0;var be=0,xe=0,ge=0;return D(4)|0||(ge=p(m+1|0)|0,be=m+5|0,xe=(m+5|0)+(ge|0)|0,D(ge+4|0)|0)?1:($(be|0,xe|0),m=xe|0,0)}function qr(_){return _=_|0,1}function _t(_){return _=_|0,F(),m=m+1|0,0}function _e(_){return _=_|0,H(_-128|0),m=m+1|0,0}function ut(_){return _=_|0,D(1)|0?1:(H(i[m+1|0]|0),m=m+2|0,0)}function De(_){return _=_|0,D(2)|0?1:(H(u(m+1|0)|0),m=m+3|0,0)}function Ue(_){return _=_|0,D(4)|0?1:(Y(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function El(_){return _=_|0,D(8)|0?1:(Z(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function vl(_){return _=_|0,E(),m=m+1|0,0}function Ie(_){_=_|0;var be=0;return be=_-160|0,D(be|0)|0?1:(ie(be|0),m=m+1|0,0)}function Bl(_){return _=_|0,D(1)|0?1:(ie(i[m+1|0]|0),m=m+2|0,0)}function Al(_){return _=_|0,D(2)|0?1:(ie(u(m+1|0)|0),m=m+3|0,0)}function Tl(_){return _=_|0,D(4)|0?1:(re(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function Sl(_){return _=_|0,D(8)|0?1:(ee(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function Nl(_){return _=_|0,C(),m=m+1|0,0}function en(_){return _=_|0,G(_-192|0|0),m=m+1|0,0}function om(_){return _=_|0,G(_|0),m=m+1|0,0}function am(_){return _=_|0,G(_|0),m=m+1|0,0}function cm(_){return _=_|0,G(_|0),m=m+1|0,0}function um(_){return _=_|0,G(_|0),m=m+1|0,0}function Xe(_){return _=_|0,G(_-192|0|0),m=m+1|0,0}function fm(_){return _=_|0,G(_|0),m=m+1|0,0}function lm(_){return _=_|0,G(_|0),m=m+1|0,0}function hm(_){return _=_|0,G(_|0),m=m+1|0,0}function Rl(_){return _=_|0,D(1)|0?1:(G(i[m+1|0]|0),m=m+2|0,0)}function Ol(_){return _=_|0,D(2)|0?1:(G(u(m+1|0)|0),m=m+3|0,0)}function Fl(_){return _=_|0,D(4)|0?1:(J(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function Ul(_){return _=_|0,D(8)|0?1:(fe(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function je(_){return _=_|0,U((_|0)-224|0),m=m+1|0,0}function Il(_){return _=_|0,f(),m=m+1|0,0}function Pl(_){return _=_|0,b(),m=m+1|0,0}function kl(_){return _=_|0,R(),m=m+1|0,0}function Ml(_){return _=_|0,S(),m=m+1|0,0}function Cl(_){return _=_|0,D(1)|0?1:(U(i[m+1|0]|0),m=m+2|0,0)}function ql(_){_=_|0;var be=0,xe=0,ge=1,Ti=0,Un=0,dm=0;return D(2)|0?1:(be=i[m+1|0]|0,xe=i[m+2|0]|0,(be|0)&128&&(ge=-1),Ti=+(((be|0)&124)>>2),Un=+(((be|0)&3)<<8|xe),+Ti==0?h(+(+ge*5960464477539063e-23*+Un)):+Ti==31?+ge==1?+Un>0?q():O():+Un>0?z():V():h(+(+ge*P(2,+(+Ti-25))*+(1024+Un))),m=m+3|0,0)}function $l(_){return _=_|0,D(4)|0?1:(d(i[m+1|0]|0,i[m+2|0]|0,i[m+3|0]|0,i[m+4|0]|0),m=m+5|0,0)}function Vl(_){return _=_|0,D(8)|0?1:(w(i[m+1|0]|0,i[m+2|0]|0,i[m+3|0]|0,i[m+4|0]|0,i[m+5|0]|0,i[m+6|0]|0,i[m+7|0]|0,i[m+8|0]|0),m=m+9|0,0)}function Ae(_){return _=_|0,1}function jl(_){return _=_|0,W(),m=m+1|0,0}var Hl=[y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,T,v,A,M,Ae,Ae,Ae,Ae,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,N,k,I,K,Ae,Ae,Ae,Ae,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,oe,ye,ve,Se,Ae,Ae,Ae,me,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ae,ke,Gt,ir,qr,Ae,Ae,Ae,_t,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,ut,De,Ue,El,Ae,Ae,Ae,vl,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Ie,Bl,Al,Tl,Sl,Ae,Ae,Ae,Nl,en,en,en,en,en,en,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Rl,Ol,Fl,Ul,Ae,Ae,Ae,Ae,je,je,je,je,je,je,je,je,je,je,je,je,je,je,je,je,je,je,je,je,Il,Pl,kl,Ml,Cl,ql,$l,Vl,Ae,Ae,Ae,jl];return{parse:le}}});var Zn=He(gt=>{"use strict";var Zo=Wn().BigNumber;gt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};gt.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36};gt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};gt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};gt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};gt.SHIFT32=Math.pow(2,32);gt.SHIFT16=Math.pow(2,16);gt.MAX_SAFE_HIGH=2097151;gt.NEG_ONE=new Zo(-1);gt.TEN=new Zo(10);gt.TWO=new Zo(2);gt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var cs=He(Bt=>{"use strict";var{Buffer:wd}=Kn(),lf=Wn().BigNumber,hf=Zn(),ff=hf.SHIFT32,bd=hf.SHIFT16,xd=2097151;Bt.parseHalf=function(e){var r,n,i;return i=e[0]&128?-1:1,r=(e[0]&124)>>2,n=(e[0]&3)<<8|e[1],r?r===31?i*(n?NaN:1/0):i*Math.pow(2,r-25)*(1024+n):i*5960464477539063e-23*n};function _d(t){return t<16?"0"+t.toString(16):t.toString(16)}Bt.arrayBufferToBignumber=function(t){let e=t.byteLength,r="";for(let n=0;n<e;n++)r+=_d(t[n]);return new lf(r,16)};Bt.buildMap=t=>{let e=new Map,r=Object.keys(t),n=r.length;for(let i=0;i<n;i++)e.set(r[i],t[r[i]]);return e};Bt.buildInt32=(t,e)=>t*bd+e;Bt.buildInt64=(t,e,r,n)=>{let i=Bt.buildInt32(t,e),s=Bt.buildInt32(r,n);return i>xd?new lf(i).times(ff).plus(s):i*ff+s};Bt.writeHalf=function(e,r){let n=wd.allocUnsafe(4);n.writeFloatBE(r,0);let i=n.readUInt32BE(0);if(i&8191)return!1;var s=i>>16&32768;let o=i>>23&255,a=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(a>>13);else if(o>=103&&o<113){if(a&(1<<126-o)-1)return!1;s+=a+8388608>>126-o}else return!1;return e.writeUInt16BE(s,0),!0};Bt.keySorter=function(t,e){var r=t[0].byteLength,n=e[0].byteLength;return r>n?1:n>r?-1:t[0].compare(e[0])};Bt.isNegativeZero=t=>t===0&&1/t<0;Bt.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,e+=1;return 1<<e}});var Lo=He((_y,df)=>{"use strict";var Qo=Zn(),Ed=Qo.MT,us=Qo.SIMPLE,Xo=Qo.SYMS,Jo=class t{constructor(e){if(typeof e!="number")throw new Error("Invalid Simple type: "+typeof e);if(e<0||e>255||(e|0)!==e)throw new Error("value must be a small positive integer: "+e);this.value=e}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(e){return e._pushInt(this.value,Ed.SIMPLE_FLOAT)}static isSimple(e){return e instanceof t}static decode(e,r){switch(r==null&&(r=!0),e){case us.FALSE:return!1;case us.TRUE:return!0;case us.NULL:return r?null:Xo.NULL;case us.UNDEFINED:return r?void 0:Xo.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return Xo.BREAK;default:return new t(e)}}};df.exports=Jo});var ea=He((Ey,pf)=>{"use strict";var Do=class t{constructor(e,r,n){if(this.tag=e,this.value=r,this.err=n,typeof this.tag!="number")throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(this.tag|0)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(e){return e._pushTag(this.tag),e.pushAny(this.value)}convert(e){var r,n;if(n=e?.[this.tag],typeof n!="function"&&(n=t["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(t,this.value)}catch(i){return r=i,this.err=r,this}}};pf.exports=Do});var na=He((vy,yf)=>{"use strict";var mf=self.location?self.location.protocol+"//"+self.location.host:"",ta=self.URL,ra=class{constructor(e="",r=mf){this.super=new ta(e,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(e){this.super.hash=e}set host(e){this.super.host=e}set hostname(e){this.super.hostname=e}set href(e){this.super.href=e}set origin(e){this.super.origin=e}set password(e){this.super.password=e}set pathname(e){this.super.pathname=e}set port(e){this.super.port=e}set protocol(e){this.super.protocol=e}set search(e){this.super.search=e}set searchParams(e){this.super.searchParams=e}set username(e){this.super.username=e}createObjectURL(e){return this.super.createObjectURL(e)}revokeObjectURL(e){this.super.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function vd(t){if(typeof t=="string")return new ta(t).toString();if(!(t instanceof ta)){let e=t.username&&t.password?`${t.username}:${t.password}@`:"",r=t.auth?t.auth+"@":"",n=t.port?":"+t.port:"",i=t.protocol?t.protocol+"//":"",s=t.host||"",o=t.hostname||"",a=t.search||(t.query?"?"+t.query:""),c=t.hash||"",l=t.pathname||"",h=t.path||l+a;return`${i}${e||r}${s||o+n}${h}${c}`}}yf.exports={URLWithLegacySupport:ra,URLSearchParams:self.URLSearchParams,defaultBase:mf,format:vd}});var bf=He((By,wf)=>{"use strict";var{URLWithLegacySupport:gf,format:Bd}=na();wf.exports=(t,e={},r={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new gf(t)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new gf(t,Bd(o)).toString()}});var ia=He((Ay,xf)=>{"use strict";var{URLWithLegacySupport:Ad,format:Td,URLSearchParams:Sd,defaultBase:Nd}=na(),Rd=bf();xf.exports={URL:Ad,URLSearchParams:Sd,format:Td,relative:Rd,defaultBase:Nd}});var sa=He((Ty,Ef)=>{"use strict";var{Buffer:pn}=Kn(),_f=vo(),Od=Wn().BigNumber,Fd=uf(),it=cs(),Be=Zn(),Ud=Lo(),Id=ea(),{URL:Pd}=ia(),Xn=class t{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=it.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=pn.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>it.arrayBufferToBignumber(r),3:r=>Be.NEG_ONE.minus(it.arrayBufferToBignumber(r)),4:r=>Be.TEN.pow(r[0]).times(r[1]),5:r=>Be.TWO.pow(r[0]).times(r[1]),32:r=>new Pd(r),35:r=>new RegExp(r)},e.tags),this.parser=Fd(globalThis,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var e=this._parents.pop();if(e.length>0)throw new Error(`Missing ${e.length} elements`);switch(e.type){case Be.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case Be.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case Be.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case Be.PARENT.MAP:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(e.ref,e.length));break;case Be.PARENT.OBJECT:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(e.ref,e.length));break;case Be.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===Be.PARENT.TAG&&this._dec()}_dec(){let e=this._currentParent;e.length<0||(e.length--,e.length===0&&this._closeParent())}_push(e,r){let n=this._currentParent;switch(n.values++,n.type){case Be.PARENT.ARRAY:case Be.PARENT.BYTE_STRING:case Be.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case Be.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=Be.PARENT.MAP,n.ref=it.buildMap(n.ref)));break;case Be.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case Be.PARENT.TAG:this._ref.push(e),r||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(e,r,n){this._parents[this._depth]={type:r,length:n,ref:e,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:Be.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,r){let n=this._knownTags[e];return n?n(r):new Id(e,r)}createMap(e,r){return e}createObject(e,r){return e}createArray(e,r){return e}createByteString(e,r){return pn.concat(e)}createByteStringFromHeap(e,r){return e===r?pn.alloc(0):pn.from(this._heap.slice(e,r))}createInt(e){return e}createInt32(e,r){return it.buildInt32(e,r)}createInt64(e,r,n,i){return it.buildInt64(e,r,n,i)}createFloat(e){return e}createFloatSingle(e,r,n,i){return _f.read([e,r,n,i],0,!1,23,4)}createFloatDouble(e,r,n,i,s,o,a,c){return _f.read([e,r,n,i,s,o,a,c],0,!1,52,8)}createInt32Neg(e,r){return-1-it.buildInt32(e,r)}createInt64Neg(e,r,n,i){let s=it.buildInt32(e,r),o=it.buildInt32(n,i);return s>Be.MAX_SAFE_HIGH?Be.NEG_ONE.minus(new Od(s).times(Be.SHIFT32).plus(o)):-1-(s*Be.SHIFT32+o)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(e,r){return e.join("")}createUtf8StringFromHeap(e,r){return e===r?"":this._buffer.toString("utf8",e,r)}createSimpleUnassigned(e){return new Ud(e)}pushInt(e){this._push(this.createInt(e))}pushInt32(e,r){this._push(this.createInt32(e,r))}pushInt64(e,r,n,i){this._push(this.createInt64(e,r,n,i))}pushFloat(e){this._push(this.createFloat(e))}pushFloatSingle(e,r,n,i){this._push(this.createFloatSingle(e,r,n,i))}pushFloatDouble(e,r,n,i,s,o,a,c){this._push(this.createFloatDouble(e,r,n,i,s,o,a,c))}pushInt32Neg(e,r){this._push(this.createInt32Neg(e,r))}pushInt64Neg(e,r,n,i){this._push(this.createInt64Neg(e,r,n,i))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],Be.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,r){let n=it.buildInt32(e,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,r,n,i){let s=it.buildInt64(e,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,r){let n=it.buildInt32(e,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,r,n,i){let s=it.buildInt64(e,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:Be.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(e,r){this._push(this.createByteStringFromHeap(e,r))}pushUtf8StringStart(){this._parents[this._depth]={type:Be.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(e,r){this._push(this.createUtf8StringFromHeap(e,r))}pushSimpleUnassigned(e){this._push(this.createSimpleUnassigned(e))}pushTagStart(e){this._parents[this._depth]={type:Be.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,r){this.pushTagStart(it.buildInt32(e,r))}pushTagStart8(e,r,n,i){this.pushTagStart(it.buildInt64(e,r,n,i))}pushTagUnassigned(e){this._push(this.createTag(e))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(e){if(e===0){this._push(this.createObject({}));return}this._createParent({},Be.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),Be.PARENT.ARRAY,e)}_decode(e){if(e.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(e);let r=this.parser.parse(e.byteLength);if(this._depth>1){for(;this._currentParent.length===0;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(r>0)throw new Error("Failed to parse");if(this._res.length===0)throw new Error("No valid result")}decodeFirst(e){return this._decode(e),this._res[0]}decodeAll(e){return this._decode(e),this._res}static decode(e,r){return typeof e=="string"&&(e=pn.from(e,r||"hex")),new t({size:e.length}).decodeFirst(e)}static decodeAll(e,r){return typeof e=="string"&&(e=pn.from(e,r||"hex")),new t({size:e.length}).decodeAll(e)}};Xn.decodeFirst=Xn.decode;Ef.exports=Xn});var Af=He((Sy,Bf)=>{"use strict";var{Buffer:oa}=Kn(),kd=sa(),Md=cs(),aa=class t extends kd{createTag(e,r){return`${e}(${r})`}createInt(e){return super.createInt(e).toString()}createInt32(e,r){return super.createInt32(e,r).toString()}createInt64(e,r,n,i){return super.createInt64(e,r,n,i).toString()}createInt32Neg(e,r){return super.createInt32Neg(e,r).toString()}createInt64Neg(e,r,n,i){return super.createInt64Neg(e,r,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(e){let r=super.createFloat(e);return Md.isNegativeZero(e)?"-0_1":`${r}_1`}createFloatSingle(e,r,n,i){return`${super.createFloatSingle(e,r,n,i)}_2`}createFloatDouble(e,r,n,i,s,o,a,c){return`${super.createFloatDouble(e,r,n,i,s,o,a,c)}_3`}createByteString(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(e,r){return`h'${oa.from(super.createByteStringFromHeap(e,r)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(e){return`simple(${e})`}createArray(e,r){let n=super.createArray(e,r);return r===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(e,r){let n=super.createMap(e),i=Array.from(n.keys()).reduce(vf(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(e,r){let n=super.createObject(e),i=Object.keys(n).reduce(vf(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,r){return`"${oa.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return typeof e=="string"&&(e=oa.from(e,r||"hex")),new t().decodeFirst(e)}};Bf.exports=aa;function vf(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}});var Of=He((Ny,Rf)=>{"use strict";var{Buffer:Jt}=Kn(),{URL:Cd}=ia(),ua=Wn().BigNumber,ca=cs(),Ke=Zn(),Ft=Ke.MT,fs=Ke.NUMBYTES,Tf=Ke.SHIFT32,Sf=Ke.SYMS,mn=Ke.TAG,qd=Ke.MT.SIMPLE_FLOAT<<5|Ke.NUMBYTES.TWO,$d=Ke.MT.SIMPLE_FLOAT<<5|Ke.NUMBYTES.FOUR,Vd=Ke.MT.SIMPLE_FLOAT<<5|Ke.NUMBYTES.EIGHT,jd=Ke.MT.SIMPLE_FLOAT<<5|Ke.SIMPLE.TRUE,Hd=Ke.MT.SIMPLE_FLOAT<<5|Ke.SIMPLE.FALSE,Gd=Ke.MT.SIMPLE_FLOAT<<5|Ke.SIMPLE.UNDEFINED,Nf=Ke.MT.SIMPLE_FLOAT<<5|Ke.SIMPLE.NULL,zd=new ua("0x20000000000000"),Yd=Jt.from("f97e00","hex"),Kd=Jt.from("f9fc00","hex"),Wd=Jt.from("f97c00","hex");function Zd(t){return{}.toString.call(t).slice(8,-1)}var fa=class t{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[Cd,this._pushUrl],[ua,this._pushBigNumber]];let r=e.genTypes||[],n=r.length;for(let i=0;i<n;i++)this.addSemanticType(r[i][0],r[i][1]);this._reset()}addSemanticType(e,r){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===e){let o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=r,o}return this.semanticTypes.push([e,r]),null}push(e){return e&&(this.result[this.offset]=e,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=e.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(e,r,n){return this.result[this.offset]=e,this.resultMethod[this.offset]=r,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(e){return this.pushWrite(e,1,1)}_pushUInt16BE(e){return this.pushWrite(e,2,2)}_pushUInt32BE(e){return this.pushWrite(e,3,4)}_pushDoubleBE(e){return this.pushWrite(e,4,8)}_pushNaN(){return this.push(Yd)}_pushInfinity(e){let r=e<0?Kd:Wd;return this.push(r)}_pushFloat(e){let r=Jt.allocUnsafe(2);if(ca.writeHalf(r,e)&&ca.parseHalf(r)===e)return this._pushUInt8(qd)&&this.push(r);let n=Jt.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8($d)&&this.push(n):this._pushUInt8(Vd)&&this._pushDoubleBE(e)}_pushInt(e,r,n){let i=r<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|fs.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|fs.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|fs.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|fs.EIGHT)&&this._pushUInt32BE(Math.floor(e/Tf))&&this._pushUInt32BE(e%Tf):r===Ft.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,Ft.NEG_INT,e):this._pushInt(e,Ft.POS_INT)}_pushNumber(e){switch(!1){case e===e:return this._pushNaN(e);case isFinite(e):return this._pushInfinity(e);case e%1!==0:return this._pushIntNum(e);default:return this._pushFloat(e)}}_pushString(e){let r=Jt.byteLength(e,"utf8");return this._pushInt(r,Ft.UTF8_STRING)&&this.pushWrite(e,5,r)}_pushBoolean(e){return this._pushUInt8(e?jd:Hd)}_pushUndefined(e){return this._pushUInt8(Gd)}_pushArray(e,r){let n=r.length;if(!e._pushInt(n,Ft.ARRAY))return!1;for(let i=0;i<n;i++)if(!e.pushAny(r[i]))return!1;return!0}_pushTag(e){return this._pushInt(e,Ft.TAG)}_pushDate(e,r){return e._pushTag(mn.DATE_EPOCH)&&e.pushAny(Math.round(r/1e3))}_pushBuffer(e,r){return e._pushInt(r.length,Ft.BYTE_STRING)&&e.push(r)}_pushNoFilter(e,r){return e._pushBuffer(e,r.slice())}_pushRegexp(e,r){return e._pushTag(mn.REGEXP)&&e.pushAny(r.source)}_pushSet(e,r){if(!e._pushInt(r.size,Ft.ARRAY))return!1;for(let n of r)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,r){return e._pushTag(mn.URI)&&e.pushAny(r.format())}_pushBigint(e){let r=mn.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),r=mn.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=Jt.from(n,"hex");return this._pushTag(r)&&this._pushBuffer(this,i)}_pushBigNumber(e,r){if(r.isNaN())return e._pushNaN();if(!r.isFinite())return e._pushInfinity(r.isNegative()?-1/0:1/0);if(r.isInteger())return e._pushBigint(r);if(!(e._pushTag(mn.DECIMAL_FRAC)&&e._pushInt(2,Ft.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new ua(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(zd)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,r){return e._pushInt(r.size,Ft.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(e){if(!e)return this._pushUInt8(Nf);for(var r=this.semanticTypes.length,n=0;n<r;n++)if(e instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(e,this,e);var i=e.encodeCBOR;if(typeof i=="function")return i.call(e,this);var s=Object.keys(e),o=s.length;return this._pushInt(o,Ft.MAP)?this._pushRawMap(o,s.map(a=>[a,e[a]])):!1}_pushRawMap(e,r){r=r.map(function(i){return i[0]=t.encode(i[0]),i}).sort(ca.keySorter);for(var n=0;n<e;n++)if(!this.push(r[n][0])||!this.pushAny(r[n][1]))return!1;return!0}write(e){return this.pushAny(e)}pushAny(e){var r=Zd(e);switch(r){case"Number":return this._pushNumber(e);case"String":return this._pushString(e);case"Boolean":return this._pushBoolean(e);case"Object":return this._pushObject(e);case"Array":return this._pushArray(this,e);case"Uint8Array":return this._pushBuffer(this,Jt.isBuffer(e)?e:Jt.from(e));case"Null":return this._pushUInt8(Nf);case"Undefined":return this._pushUndefined(e);case"Map":return this._pushMap(this,e);case"Set":return this._pushSet(this,e);case"URL":return this._pushUrl(this,e);case"BigNumber":return this._pushBigNumber(this,e);case"Date":return this._pushDate(this,e);case"RegExp":return this._pushRegexp(this,e);case"Symbol":switch(e){case Sf.NULL:return this._pushObject(null);case Sf.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+e.toString())}default:throw new Error("Unknown type: "+typeof e+", "+(e?e.toString():""))}}finalize(){if(this.offset===0)return null;for(var e=this.result,r=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=r[o];var a=Jt.allocUnsafe(s),c=0,l=0;for(o=0;o<i;o++){switch(l=r[o],n[o]){case 0:e[o].copy(a,c);break;case 1:a.writeUInt8(e[o],c,!0);break;case 2:a.writeUInt16BE(e[o],c,!0);break;case 3:a.writeUInt32BE(e[o],c,!0);break;case 4:a.writeDoubleBE(e[o],c,!0);break;case 5:a.write(e[o],c,l,"utf8");break;default:throw new Error("unkown method")}c+=l}var h=a;return this._reset(),h}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(e){let r=new t;if(!r.pushAny(e))throw new Error("Failed to encode input");return r.finalize()}};Rf.exports=fa});var la=He(We=>{"use strict";We.Diagnose=Af();We.Decoder=sa();We.Encoder=Of();We.Simple=Lo();We.Tagged=ea();We.decodeAll=We.Decoder.decodeAll;We.decodeFirst=We.Decoder.decodeFirst;We.diagnose=We.Diagnose.diagnose;We.encode=We.Encoder.encode;We.decode=We.Decoder.decode;We.leveldb={decode:We.Decoder.decodeAll,encode:We.Encoder.encode,buffer:!0,name:"cbor"}});function At(t){return qn(kn.create().update(new Uint8Array(t)).digest())}function ls(t){if(t instanceof Ff.default.Tagged)return ls(t.value);if(typeof t=="string")return Uf(t);if(typeof t=="number")return At(Oe(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return At(t);if(Array.isArray(t)){let e=t.map(ls);return At(nt(...e))}else{if(t&&typeof t=="object"&&t._isPrincipal)return At(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return ls(t.toHash());if(typeof t=="object")return Jn(t);if(typeof t=="bigint")return At(Oe(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}function hs(t){return Jn(t)}function Jn(t){let n=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=Uf(o),l=ls(a);return[c,l]}).sort(([o],[a])=>Io(o,a)),i=nt(...n.map(o=>nt(...o)));return At(i)}var Ff,Uf,Qn=he(()=>{Yn();Ff=tn(la());Ii();lt();Uf=t=>{let e=new TextEncoder().encode(t);return At(e)}});var Cy,Yr,ha=he(()=>{yt();Qn();lt();Cy=new TextEncoder().encode(`
14
+ ic-request`),Yr=class{getPrincipal(){return de.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}}});var ma=He(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});var Xd=9007199254740992;function ur(t,...e){let r=new Uint8Array(t.byteLength+e.reduce((i,s)=>i+s.byteLength,0));r.set(new Uint8Array(t),0);let n=t.byteLength;for(let i of e)r.set(new Uint8Array(i),n),n+=i.byteLength;return r.buffer}function Ut(t,e,r){r=r.replace(/[^0-9a-fA-F]/g,"");let n=2**(e-24);r=r.slice(-n*2).padStart(n*2,"0");let i=[(t<<5)+e].concat(r.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function ds(t,e){if(e<24)return new Uint8Array([(t<<5)+e]).buffer;{let r=e<=255?24:e<=65535?25:e<=4294967295?26:27;return Ut(t,r,e.toString(16))}}function If(t){let e=[];for(let r=0;r<t.length;r++){let n=t.charCodeAt(r);n<128?e.push(n):n<2048?e.push(192|n>>6,128|n&63):n<55296||n>=57344?e.push(224|n>>12,128|n>>6&63,128|n&63):(r++,n=(n&1023)<<10|t.charCodeAt(r)&1023,e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return ur(new Uint8Array(ds(3,t.length)),new Uint8Array(e))}function Jd(t,e){if(t==14277111)return ur(new Uint8Array([217,217,247]),e);if(t<24)return ur(new Uint8Array([192+t]),e);{let r=t<=255?24:t<=65535?25:t<=4294967295?26:27,n=2**(r-24),i=t.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+r].concat(i.match(/../g).map(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}Ne.tagged=Jd;function Ln(t){return new Uint8Array(t).buffer}Ne.raw=Ln;function da(t){if(isNaN(t))throw new RangeError("Invalid number.");t=Math.min(Math.max(0,t),23);let e=[0+t];return new Uint8Array(e).buffer}Ne.uSmall=da;function Pf(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),255),t=t.toString(16),Ut(0,24,t)}Ne.u8=Pf;function kf(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),65535),t=t.toString(16),Ut(0,25,t)}Ne.u16=kf;function Mf(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),4294967295),t=t.toString(16),Ut(0,26,t)}Ne.u32=Mf;function pa(t,e){if(typeof t=="string"&&e==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return Ut(0,27,t)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),Xd),t=t.toString(16),Ut(0,27,t)}Ne.u64=pa;function Cf(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return da(0);t=Math.min(Math.max(0,-t),24)-1;let e=[32+t];return new Uint8Array(e).buffer}Ne.iSmall=Cf;function qf(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),255),t=t.toString(16),Ut(1,24,t)}Ne.i8=qf;function $f(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),65535),t=t.toString(16),Ut(1,25,t)}Ne.i16=$f;function Vf(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),4294967295),t=t.toString(16),Ut(1,26,t)}Ne.i32=Vf;function jf(t,e){if(typeof t=="string"&&e==16){if(t.startsWith("-")?t=t.slice(1):t="0",t.match(/[^0-9a-fA-F]/)||t.length>16)throw new RangeError("Invalid number.");let r=!1,n=t.split("").reduceRight((i,s)=>{if(r)return s+i;let o=parseInt(s,16)-1;return o>=0?(r=!0,o.toString(16)+i):"f"+i},"");return r?Ut(1,27,n):pa(0)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),9007199254740992),t=t.toString(16),Ut(1,27,t)}Ne.i64=jf;function Qd(t){return t>=0?t<24?da(t):t<=255?Pf(t):t<=65535?kf(t):t<=4294967295?Mf(t):pa(t):t>=-24?Cf(t):t>=-255?qf(t):t>=-65535?$f(t):t>=-4294967295?Vf(t):jf(t)}Ne.number=Qd;function Ld(t){return ur(ds(2,t.byteLength),t)}Ne.bytes=Ld;function Dd(t){return If(t)}Ne.string=Dd;function ep(t){return ur(ds(4,t.length),...t)}Ne.array=ep;function tp(t,e=!1){t instanceof Map||(t=new Map(Object.entries(t)));let r=Array.from(t.entries());return e&&(r=r.sort(([n],[i])=>n.localeCompare(i))),ur(ds(5,t.size),...r.map(([n,i])=>ur(If(n),i)))}Ne.map=tp;function rp(t){let e=new Float32Array([t]);return ur(new Uint8Array([250]),new Uint8Array(e.buffer))}Ne.singleFloat=rp;function np(t){let e=new Float64Array([t]);return ur(new Uint8Array([251]),new Uint8Array(e.buffer))}Ne.doubleFloat=np;function ip(t){return t?Hf():Gf()}Ne.bool=ip;function Hf(){return Ln(new Uint8Array([245]))}Ne.true_=Hf;function Gf(){return Ln(new Uint8Array([244]))}Ne.false_=Gf;function sp(){return Ln(new Uint8Array([246]))}Ne.null_=sp;function op(){return Ln(new Uint8Array([247]))}Ne.undefined_=op});var zf=He(vr=>{"use strict";var ap=vr&&vr.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(vr,"__esModule",{value:!0});var It=ap(ma()),cp=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],ps=class{constructor(e,r=!1){this._serializer=e,this._stable=r,this.name="jsonDefault",this.priority=-100}match(e){return["undefined","boolean","number","string","object"].indexOf(typeof e)!=-1}encode(e){switch(typeof e){case"undefined":return It.undefined_();case"boolean":return It.bool(e);case"number":return Math.floor(e)===e?It.number(e):It.doubleFloat(e);case"string":return It.string(e);case"object":if(e===null)return It.null_();if(Array.isArray(e))return It.array(e.map(r=>this._serializer.serializeValue(r)));if(cp.find(r=>e instanceof r))return It.bytes(e.buffer);if(Object.getOwnPropertyNames(e).indexOf("toJSON")!==-1)return this.encode(e.toJSON());if(e instanceof Map){let r=new Map;for(let[n,i]of e.entries())r.set(n,this._serializer.serializeValue(i));return It.map(r,this._stable)}else{let r=new Map;for(let[n,i]of Object.entries(e))r.set(n,this._serializer.serializeValue(i));return It.map(r,this._stable)}default:throw new Error("Invalid value.")}}};vr.JsonDefaultCborEncoder=ps;var ms=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};vr.ToCborEncoder=ms;var ys=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let r=new this;return r.addEncoder(new ps(r,e)),r.addEncoder(new ms),r}removeEncoder(e){for(let r of this._encoders.values())r.name==e&&this._encoders.delete(r)}addEncoder(e){this._encoders.add(e)}getEncoderFor(e){let r=null;for(let n of this._encoders)(!r||n.priority>r.priority)&&n.match(e)&&(r=n);if(r===null)throw new Error("Could not find an encoder for value.");return r}serializeValue(e){return this.getEncoderFor(e).encode(e)}serialize(e){return this.serializeValue(e)}};vr.CborSerializer=ys;var ya=class extends ys{serialize(e){return It.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};vr.SelfDescribeCborSerializer=ya});var gs=He(Kr=>{"use strict";function up(t){for(var e in t)Kr.hasOwnProperty(e)||(Kr[e]=t[e])}var fp=Kr&&Kr.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(Kr,"__esModule",{value:!0});up(zf());var lp=fp(ma());Kr.value=lp});function bs(t){return ws.serialize(t)}function Yf(t){let e=t.byteLength,r=BigInt(0);for(let n=0;n<e;n++)r=r*BigInt(256)+BigInt(t[n]);return r}function Tt(t){let e=new Uint8Array(t),r=new _a({size:e.byteLength,tags:{2:n=>Yf(n),3:n=>-Yf(n),[xa.Semantic]:n=>n}});try{return r.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${Me(e)}`)}}var Kf,Wr,Wf,ga,wa,ba,ws,xa,_a,Dn=he(()=>{Kf=tn(la()),Wr=tn(gs()),Wf=tn(gs());lt();ga=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return Wr.value.bytes(e.toUint8Array())}},wa=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return Wr.value.bytes(new Uint8Array(e))}},ba=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?Wr.value.tagged(2,Wr.value.bytes(Hr(e.toString(16)))):Wr.value.tagged(3,Wr.value.bytes(Hr((BigInt("-1")*e).toString(16))))}},ws=Wf.SelfDescribeCborSerializer.withDefaultEncoders(!0);ws.addEncoder(new ga);ws.addEncoder(new wa);ws.addEncoder(new ba);(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(xa||(xa={}));_a=class extends Kf.default.Decoder{createByteString(e){return nt(...e)}createByteStringFromHeap(e,r){return e===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,r))}}});var ei,Ea=he(()=>{ei=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let t=new Uint32Array(1);return window.crypto.getRandomValues(t),t[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let t=new Uint32Array(1);return crypto.getRandomValues(t),t[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)}});function yn(){let t=new ArrayBuffer(16),e=new DataView(t),r=ei(),n=ei(),i=ei(),s=ei();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),t}var _s,ti=he(()=>{Ea();(function(t){t.Call="call"})(_s||(_s={}))});function va(t=yn){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}function gn(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}var Xf,Zf,hp,Qt,Es=he(()=>{Yn();Xf=tn(gs());ti();Zf=BigInt(1e6),hp=60*1e3,Qt=class{constructor(e){if(e<90*1e3){let a=BigInt(Date.now()+e)*Zf/BigInt(1e9);this._value=a*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+e-hp))*Zf/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return Xf.value.u64(this._value.toString(16),16)}toHash(){return Oe(this._value)}}});var wn,Ba=he(()=>{fn();wn=class extends Pe{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}}});var Ts={};In(Ts,{aInRange:()=>Mt,abool:()=>Br,abytes:()=>Pt,bitGet:()=>Oa,bitLen:()=>lr,bitMask:()=>Tr,bitSet:()=>gp,bytesToHex:()=>kt,bytesToNumberBE:()=>et,bytesToNumberLE:()=>Ar,concatBytes:()=>Te,createHmacDrbg:()=>Lf,ensureBytes:()=>Ye,equalBytes:()=>yp,hexToBytes:()=>ri,hexToNumber:()=>Ra,inRange:()=>Bs,isBytes:()=>bn,memoized:()=>hr,notImplemented:()=>As,numberToBytesBE:()=>qe,numberToBytesLE:()=>Zr,numberToHexUnpadded:()=>Na,numberToVarBytesBE:()=>mp,utf8ToBytes:()=>ni,validateObject:()=>Ct});function bn(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Pt(t){if(!bn(t))throw new Error("Uint8Array expected")}function Br(t,e){if(typeof e!="boolean")throw new Error(`${t} must be valid boolean, got "${e}".`)}function kt(t){Pt(t);let e="";for(let r=0;r<t.length;r++)e+=pp[t[r]];return e}function Na(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function Ra(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function Jf(t){if(t>=fr._0&&t<=fr._9)return t-fr._0;if(t>=fr._A&&t<=fr._F)return t-(fr._A-10);if(t>=fr._a&&t<=fr._f)return t-(fr._a-10)}function ri(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=Jf(t.charCodeAt(s)),a=Jf(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function et(t){return Ra(kt(t))}function Ar(t){return Pt(t),Ra(kt(Uint8Array.from(t).reverse()))}function qe(t,e){return ri(t.toString(16).padStart(e*2,"0"))}function Zr(t,e){return qe(t,e).reverse()}function mp(t){return ri(Na(t))}function Ye(t,e,r){let n;if(typeof e=="string")try{n=ri(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(bn(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function Te(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];Pt(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}function yp(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function ni(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Bs(t,e,r){return Aa(t)&&Aa(e)&&Aa(r)&&e<=t&&t<r}function Mt(t,e,r,n){if(!Bs(e,r,n))throw new Error(`expected valid ${t}: ${r} <= n < ${n}, got ${typeof e} ${e}`)}function lr(t){let e;for(e=0;t>Sa;t>>=vs,e+=1);return e}function Oa(t,e){return t>>BigInt(e)&vs}function gp(t,e,r){return t|(r?vs:Sa)<<BigInt(e)}function Lf(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=Ta(t),i=Ta(t),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...d)=>r(i,n,...d),c=(d=Ta())=>{i=a(Qf([0]),d),n=a(),d.length!==0&&(i=a(Qf([1]),d),n=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let d=0,w=[];for(;d<e;){n=a();let b=n.slice();w.push(b),d+=n.length}return Te(...w)};return(d,w)=>{o(),c(d);let b;for(;!(b=w(l()));)c();return o(),b}}function Ct(t,e,r={}){let n=(i,s,o)=>{let a=wp[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(r))n(i,s,!0);return t}function hr(t){let e=new WeakMap;return(r,...n)=>{let i=e.get(r);if(i!==void 0)return i;let s=t(r,...n);return e.set(r,s),s}}var Sa,vs,dp,pp,fr,Aa,Tr,Ta,Qf,wp,As,qt=he(()=>{Sa=BigInt(0),vs=BigInt(1),dp=BigInt(2);pp=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));fr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};Aa=t=>typeof t=="bigint"&&Sa<=t;Tr=t=>(dp<<BigInt(t-1))-vs,Ta=t=>new Uint8Array(t),Qf=t=>Uint8Array.from(t);wp={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||bn(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};As=()=>{throw new Error("not implemented")}});function Re(t,e){let r=t%e;return r>=Ze?r:e+r}function Ep(t,e,r){if(r<=Ze||e<Ze)throw new Error("Expected power/modulo > 0");if(r===Fe)return Ze;let n=Fe;for(;e>Ze;)e&Fe&&(n=n*t%r),t=t*t%r,e>>=Fe;return n}function $t(t,e,r){let n=t;for(;e-- >Ze;)n*=n,n%=r;return n}function Ua(t,e){if(t===Ze||e<=Ze)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Re(t,e),n=e,i=Ze,s=Fe,o=Fe,a=Ze;for(;r!==Ze;){let l=n/r,h=n%r,d=i-o*l,w=s-a*l;n=r,r=h,i=o,s=a,o=d,a=w}if(n!==Fe)throw new Error("invert: does not exist");return Re(i,e)}function vp(t){let e=(t-Fe)/Sr,r,n,i;for(r=t-Fe,n=0;r%Sr===Ze;r/=Sr,n++);for(i=Sr;i<t&&Ep(i,e,t)!==t-Fe;i++);if(n===1){let o=(t+Fe)/Fa;return function(c,l){let h=c.pow(l,o);if(!c.eql(c.sqr(h),l))throw new Error("Cannot find square root");return h}}let s=(r+Fe)/Sr;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,h=a.pow(a.mul(a.ONE,i),r),d=a.pow(c,s),w=a.pow(c,r);for(;!a.eql(w,a.ONE);){if(a.eql(w,a.ZERO))return a.ZERO;let b=1;for(let S=a.sqr(w);b<l&&!a.eql(S,a.ONE);b++)S=a.sqr(S);let f=a.pow(h,Fe<<BigInt(l-b-1));h=a.sqr(f),d=a.mul(d,f),w=a.mul(w,h),l=b}return d}}function Bp(t){if(t%Fa===bp){let e=(t+Fe)/Fa;return function(n,i){let s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(t%e0===Df){let e=(t-Df)/e0;return function(n,i){let s=n.mul(i,Sr),o=n.pow(s,e),a=n.mul(i,o),c=n.mul(n.mul(a,Sr),o),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),i))throw new Error("Cannot find square root");return l}}return t%_p,vp(t)}function Ss(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Ap.reduce((n,i)=>(n[i]="function",n),e);return Ct(t,r)}function ii(t,e,r){if(r<Ze)throw new Error("Expected power > 0");if(r===Ze)return t.ONE;if(r===Fe)return e;let n=t.ONE,i=e;for(;r>Ze;)r&Fe&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Fe;return n}function si(t,e){let r=new Array(e.length),n=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),i=t.inv(n);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),i),r}function r0(t){let e=(t-Fe)/Sr;return(r,n)=>r.pow(n,e)}function Ia(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Lt(t,e,r=!1,n={}){if(t<=Ze)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:s}=Ia(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=Bp(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:Tr(i),ZERO:Ze,ONE:Fe,create:c=>Re(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return Ze<=c&&c<t},is0:c=>c===Ze,isOdd:c=>(c&Fe)===Fe,neg:c=>Re(-c,t),eql:(c,l)=>c===l,sqr:c=>Re(c*c,t),add:(c,l)=>Re(c+l,t),sub:(c,l)=>Re(c-l,t),mul:(c,l)=>Re(c*l,t),pow:(c,l)=>ii(a,c,l),div:(c,l)=>Re(c*Ua(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Ua(c,t),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>si(a,c),cmov:(c,l,h)=>h?l:c,toBytes:c=>r?Zr(c,s):qe(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?Ar(c):et(c)}});return Object.freeze(a)}function n0(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function Ns(t){let e=n0(t);return e+Math.ceil(e/2)}function Pa(t,e,r=!1){let n=t.length,i=n0(e),s=Ns(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?et(t):Ar(t),a=Re(o,e-Fe)+Fe;return r?Zr(a,i):qe(a,i)}var Ze,Fe,Sr,bp,Fa,Df,e0,xp,_p,t0,Ap,dr=he(()=>{qt();Ze=BigInt(0),Fe=BigInt(1),Sr=BigInt(2),bp=BigInt(3),Fa=BigInt(4),Df=BigInt(5),e0=BigInt(8),xp=BigInt(9),_p=BigInt(16);t0=(t,e)=>(Re(t,e)&Fe)===Fe,Ap=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"]});function Nr(t,e){if(oi(t),oi(e),t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);let r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=t&255,t>>>=8;return new Uint8Array(r)}function Sp(t,e){let r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function oi(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function Np(t,e,r,n){Pt(t),Pt(e),oi(r),e.length>255&&(e=n(Te(ni("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(r/i);if(r>65535||o>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=Te(e,Nr(e.length,1)),c=Nr(0,s),l=Nr(r,2),h=new Array(o),d=n(Te(c,t,l,Nr(0,1),a));h[0]=n(Te(d,Nr(1,1),a));for(let b=1;b<=o;b++){let f=[Sp(d,h[b-1]),Nr(b+1,1),a];h[b]=n(Te(...f))}return Te(...h).slice(0,r)}function Rp(t,e,r,n,i){if(Pt(t),Pt(e),oi(r),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update(ni("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(t).update(Nr(r,2)).update(e).update(Nr(e.length,1)).digest()}function i0(t,e,r){Ct(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:o,expand:a,DST:c}=r;Pt(t),oi(e);let l=typeof c=="string"?ni(c):c,h=n.toString(2).length,d=Math.ceil((h+i)/8),w=e*s*d,b;if(a==="xmd")b=Np(t,l,w,o);else if(a==="xof")b=Rp(t,l,w,i,o);else if(a==="_internal_pass")b=t;else throw new Error('expand must be "xmd" or "xof"');let f=new Array(e);for(let S=0;S<e;S++){let R=new Array(s);for(let O=0;O<s;O++){let V=d*(O+S*s),q=b.subarray(V,V+d);R[O]=Re(Tp(q),n)}f[S]=R}return f}function Ma(t,e){let r=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,a,c]=r.map(l=>l.reduce((h,d)=>t.add(t.mul(h,n),d)));return n=t.div(s,o),i=t.mul(i,t.div(a,c)),{x:n,y:i}}}function Ca(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=i0(n,2,{...r,DST:r.DST,...i}),o=t.fromAffine(e(s[0])),a=t.fromAffine(e(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=i0(n,1,{...r,DST:r.encodeDST,...i}),o=t.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(let s of n)if(typeof s!="bigint")throw new Error(`mapToCurve: expected array of bigints, got ${s} in array`);let i=t.fromAffine(e(n)).clearCofactor();return i.assertValidity(),i}}}var Tp,qa=he(()=>{dr();qt();Tp=et});function Rs(t,e){let r=(s,o)=>{let a=o.negate();return s?a:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>e)throw new Error(`Wrong window size=${s}, should be [1..${e}]`)},i=s=>{n(s);let o=Math.ceil(e/s)+1,a=2**(s-1);return{windows:o,windowSize:a}};return{constTimeNegate:r,unsafeLadder(s,o){let a=t.ZERO,c=s;for(;o>Op;)o&$a&&(a=a.add(c)),c=c.double(),o>>=$a;return a},precomputeWindow(s,o){let{windows:a,windowSize:c}=i(o),l=[],h=s,d=h;for(let w=0;w<a;w++){d=h,l.push(d);for(let b=1;b<c;b++)d=d.add(h),l.push(d);h=d.double()}return l},wNAF(s,o,a){let{windows:c,windowSize:l}=i(s),h=t.ZERO,d=t.BASE,w=BigInt(2**s-1),b=2**s,f=BigInt(s);for(let S=0;S<c;S++){let R=S*l,O=Number(a&w);a>>=f,O>l&&(O-=b,a+=$a);let V=R,q=R+Math.abs(O)-1,z=S%2!==0,E=O<0;O===0?d=d.add(r(z,o[V])):h=h.add(r(E,o[q]))}return{p:h,f:d}},wNAFCached(s,o,a){let c=s0.get(s)||1,l=Va.get(s);return l||(l=this.precomputeWindow(s,c),c!==1&&Va.set(s,a(l))),this.wNAF(c,l,o)},setWindowSize(s,o){n(o),s0.set(s,o),Va.delete(s)}}}function Os(t,e,r,n){if(!Array.isArray(r)||!Array.isArray(n)||n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((h,d)=>{if(!e.isValid(h))throw new Error(`wrong scalar at index ${d}`)}),r.forEach((h,d)=>{if(!(h instanceof t))throw new Error(`wrong point at index ${d}`)});let i=lr(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,o=(1<<s)-1,a=new Array(o+1).fill(t.ZERO),c=Math.floor((e.BITS-1)/s)*s,l=t.ZERO;for(let h=c;h>=0;h-=s){a.fill(t.ZERO);for(let w=0;w<n.length;w++){let b=n[w],f=Number(b>>BigInt(h)&BigInt(o));a[f]=a[f].add(r[w])}let d=t.ZERO;for(let w=a.length-1,b=t.ZERO;w>0;w--)b=b.add(a[w]),d=d.add(b);if(l=l.add(d),h!==0)for(let w=0;w<s;w++)l=l.double()}return l}function Fs(t){return Ss(t.Fp),Ct(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ia(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}var Op,$a,Va,s0,ja=he(()=>{dr();qt();Op=BigInt(0),$a=BigInt(1),Va=new WeakMap,s0=new WeakMap});function Fp(t){let e=Fs(t);Ct(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}function Ha(t){let e=Fp(t),{Fp:r}=e,n=Lt(e.n,e.nBitLength),i=e.toBytes||((S,R,O)=>{let V=R.toAffine();return Te(Uint8Array.from([4]),r.toBytes(V.x),r.toBytes(V.y))}),s=e.fromBytes||(S=>{let R=S.subarray(1),O=r.fromBytes(R.subarray(0,r.BYTES)),V=r.fromBytes(R.subarray(r.BYTES,2*r.BYTES));return{x:O,y:V}});function o(S){let{a:R,b:O}=e,V=r.sqr(S),q=r.mul(V,S);return r.add(r.add(q,r.mul(S,R)),O)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(S){return Bs(S,$e,e.n)}function c(S){let{allowedPrivateKeyLengths:R,nByteLength:O,wrapPrivateKey:V,n:q}=e;if(R&&typeof S!="bigint"){if(bn(S)&&(S=kt(S)),typeof S!="string"||!R.includes(S.length))throw new Error("Invalid key");S=S.padStart(O*2,"0")}let z;try{z=typeof S=="bigint"?S:et(Ye("private key",S,O))}catch{throw new Error(`private key must be ${O} bytes, hex or bigint, not ${typeof S}`)}return V&&(z=Re(z,q)),Mt("private key",z,$e,q),z}function l(S){if(!(S instanceof w))throw new Error("ProjectivePoint expected")}let h=hr((S,R)=>{let{px:O,py:V,pz:q}=S;if(r.eql(q,r.ONE))return{x:O,y:V};let z=S.is0();R==null&&(R=z?r.ONE:r.inv(q));let E=r.mul(O,R),H=r.mul(V,R),Y=r.mul(q,R);if(z)return{x:r.ZERO,y:r.ZERO};if(!r.eql(Y,r.ONE))throw new Error("invZ was invalid");return{x:E,y:H}}),d=hr(S=>{if(S.is0()){if(e.allowInfinityPoint&&!r.is0(S.py))return;throw new Error("bad point: ZERO")}let{x:R,y:O}=S.toAffine();if(!r.isValid(R)||!r.isValid(O))throw new Error("bad point: x or y not FE");let V=r.sqr(O),q=o(R);if(!r.eql(V,q))throw new Error("bad point: equation left != right");if(!S.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class w{constructor(R,O,V){if(this.px=R,this.py=O,this.pz=V,R==null||!r.isValid(R))throw new Error("x required");if(O==null||!r.isValid(O))throw new Error("y required");if(V==null||!r.isValid(V))throw new Error("z required");Object.freeze(this)}static fromAffine(R){let{x:O,y:V}=R||{};if(!R||!r.isValid(O)||!r.isValid(V))throw new Error("invalid affine point");if(R instanceof w)throw new Error("projective point not allowed");let q=z=>r.eql(z,r.ZERO);return q(O)&&q(V)?w.ZERO:new w(O,V,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(R){let O=r.invertBatch(R.map(V=>V.pz));return R.map((V,q)=>V.toAffine(O[q])).map(w.fromAffine)}static fromHex(R){let O=w.fromAffine(s(Ye("pointHex",R)));return O.assertValidity(),O}static fromPrivateKey(R){return w.BASE.multiply(c(R))}static msm(R,O){return Os(w,n,R,O)}_setWindowSize(R){f.setWindowSize(this,R)}assertValidity(){d(this)}hasEvenY(){let{y:R}=this.toAffine();if(r.isOdd)return!r.isOdd(R);throw new Error("Field doesn't support isOdd")}equals(R){l(R);let{px:O,py:V,pz:q}=this,{px:z,py:E,pz:H}=R,Y=r.eql(r.mul(O,H),r.mul(z,q)),Z=r.eql(r.mul(V,H),r.mul(E,q));return Y&&Z}negate(){return new w(this.px,r.neg(this.py),this.pz)}double(){let{a:R,b:O}=e,V=r.mul(O,Us),{px:q,py:z,pz:E}=this,H=r.ZERO,Y=r.ZERO,Z=r.ZERO,C=r.mul(q,q),ie=r.mul(z,z),re=r.mul(E,E),ee=r.mul(q,z);return ee=r.add(ee,ee),Z=r.mul(q,E),Z=r.add(Z,Z),H=r.mul(R,Z),Y=r.mul(V,re),Y=r.add(H,Y),H=r.sub(ie,Y),Y=r.add(ie,Y),Y=r.mul(H,Y),H=r.mul(ee,H),Z=r.mul(V,Z),re=r.mul(R,re),ee=r.sub(C,re),ee=r.mul(R,ee),ee=r.add(ee,Z),Z=r.add(C,C),C=r.add(Z,C),C=r.add(C,re),C=r.mul(C,ee),Y=r.add(Y,C),re=r.mul(z,E),re=r.add(re,re),C=r.mul(re,ee),H=r.sub(H,C),Z=r.mul(re,ie),Z=r.add(Z,Z),Z=r.add(Z,Z),new w(H,Y,Z)}add(R){l(R);let{px:O,py:V,pz:q}=this,{px:z,py:E,pz:H}=R,Y=r.ZERO,Z=r.ZERO,C=r.ZERO,ie=e.a,re=r.mul(e.b,Us),ee=r.mul(O,z),g=r.mul(V,E),B=r.mul(q,H),$=r.add(O,V),F=r.add(z,E);$=r.mul($,F),F=r.add(ee,g),$=r.sub($,F),F=r.add(O,q);let U=r.add(z,H);return F=r.mul(F,U),U=r.add(ee,B),F=r.sub(F,U),U=r.add(V,q),Y=r.add(E,H),U=r.mul(U,Y),Y=r.add(g,B),U=r.sub(U,Y),C=r.mul(ie,F),Y=r.mul(re,B),C=r.add(Y,C),Y=r.sub(g,C),C=r.add(g,C),Z=r.mul(Y,C),g=r.add(ee,ee),g=r.add(g,ee),B=r.mul(ie,B),F=r.mul(re,F),g=r.add(g,B),B=r.sub(ee,B),B=r.mul(ie,B),F=r.add(F,B),ee=r.mul(g,F),Z=r.add(Z,ee),ee=r.mul(U,F),Y=r.mul($,Y),Y=r.sub(Y,ee),ee=r.mul($,g),C=r.mul(U,C),C=r.add(C,ee),new w(Y,Z,C)}subtract(R){return this.add(R.negate())}is0(){return this.equals(w.ZERO)}wNAF(R){return f.wNAFCached(this,R,w.normalizeZ)}multiplyUnsafe(R){Mt("scalar",R,Xr,e.n);let O=w.ZERO;if(R===Xr)return O;if(R===$e)return this;let{endo:V}=e;if(!V)return f.unsafeLadder(this,R);let{k1neg:q,k1:z,k2neg:E,k2:H}=V.splitScalar(R),Y=O,Z=O,C=this;for(;z>Xr||H>Xr;)z&$e&&(Y=Y.add(C)),H&$e&&(Z=Z.add(C)),C=C.double(),z>>=$e,H>>=$e;return q&&(Y=Y.negate()),E&&(Z=Z.negate()),Z=new w(r.mul(Z.px,V.beta),Z.py,Z.pz),Y.add(Z)}multiply(R){let{endo:O,n:V}=e;Mt("scalar",R,$e,V);let q,z;if(O){let{k1neg:E,k1:H,k2neg:Y,k2:Z}=O.splitScalar(R),{p:C,f:ie}=this.wNAF(H),{p:re,f:ee}=this.wNAF(Z);C=f.constTimeNegate(E,C),re=f.constTimeNegate(Y,re),re=new w(r.mul(re.px,O.beta),re.py,re.pz),q=C.add(re),z=ie.add(ee)}else{let{p:E,f:H}=this.wNAF(R);q=E,z=H}return w.normalizeZ([q,z])[0]}multiplyAndAddUnsafe(R,O,V){let q=w.BASE,z=(H,Y)=>Y===Xr||Y===$e||!H.equals(q)?H.multiplyUnsafe(Y):H.multiply(Y),E=z(this,O).add(z(R,V));return E.is0()?void 0:E}toAffine(R){return h(this,R)}isTorsionFree(){let{h:R,isTorsionFree:O}=e;if(R===$e)return!0;if(O)return O(w,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:R,clearCofactor:O}=e;return R===$e?this:O?O(w,this):this.multiplyUnsafe(e.h)}toRawBytes(R=!0){return Br("isCompressed",R),this.assertValidity(),i(w,this,R)}toHex(R=!0){return Br("isCompressed",R),kt(this.toRawBytes(R))}}w.BASE=new w(e.Gx,e.Gy,r.ONE),w.ZERO=new w(r.ZERO,r.ONE,r.ZERO);let b=e.nBitLength,f=Rs(w,e.endo?Math.ceil(b/2):b);return{CURVE:e,ProjectivePoint:w,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function Up(t,e){let r=t.ORDER,n=Xr;for(let f=r-$e;f%Rr===Xr;f/=Rr)n+=$e;let i=n,s=Rr<<i-$e-$e,o=s*Rr,a=(r-$e)/o,c=(a-$e)/Rr,l=o-$e,h=s,d=t.pow(e,a),w=t.pow(e,(a+$e)/Rr),b=(f,S)=>{let R=d,O=t.pow(S,l),V=t.sqr(O);V=t.mul(V,S);let q=t.mul(f,V);q=t.pow(q,c),q=t.mul(q,O),O=t.mul(q,S),V=t.mul(q,f);let z=t.mul(V,O);q=t.pow(z,h);let E=t.eql(q,t.ONE);O=t.mul(V,w),q=t.mul(z,R),V=t.cmov(O,V,E),z=t.cmov(q,z,E);for(let H=i;H>$e;H--){let Y=H-Rr;Y=Rr<<Y-$e;let Z=t.pow(z,Y),C=t.eql(Z,t.ONE);O=t.mul(V,R),R=t.mul(R,R),Z=t.mul(z,R),V=t.cmov(O,V,C),z=t.cmov(Z,z,C)}return{isValid:E,value:V}};if(t.ORDER%o0===Us){let f=(t.ORDER-Us)/o0,S=t.sqrt(t.neg(e));b=(R,O)=>{let V=t.sqr(O),q=t.mul(R,O);V=t.mul(V,q);let z=t.pow(V,f);z=t.mul(z,q);let E=t.mul(z,S),H=t.mul(t.sqr(z),O),Y=t.eql(H,R),Z=t.cmov(E,z,Y);return{isValid:Y,value:Z}}}return b}function Ga(t,e){if(Ss(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=Up(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,a,c,l,h,d;i=t.sqr(n),i=t.mul(i,e.Z),s=t.sqr(i),s=t.add(s,i),o=t.add(s,t.ONE),o=t.mul(o,e.B),a=t.cmov(e.Z,t.neg(s),!t.eql(s,t.ZERO)),a=t.mul(a,e.A),s=t.sqr(o),l=t.sqr(a),c=t.mul(l,e.A),s=t.add(s,c),s=t.mul(s,o),l=t.mul(l,a),c=t.mul(l,e.B),s=t.add(s,c),h=t.mul(i,o);let{isValid:w,value:b}=r(s,l);d=t.mul(i,n),d=t.mul(d,b),h=t.cmov(h,o,w),d=t.cmov(d,b,w);let f=t.isOdd(n)===t.isOdd(d);return d=t.cmov(t.neg(d),d,f),h=t.div(h,a),{x:h,y:d}}}var og,ag,Xr,$e,Rr,Us,o0,za=he(()=>{ja();dr();qt();qt();({bytesToNumberBE:og,hexToBytes:ag}=Ts),Xr=BigInt(0),$e=BigInt(1),Rr=BigInt(2),Us=BigInt(3),o0=BigInt(4)});function Pp(t){let e=[];for(;t>Is;t>>=Is)(t&Is)===Ip?e.unshift(0):(t&xn)===xn?(e.unshift(-1),t+=Is):e.unshift(1);return e}function c0(t){let{Fp:e,Fr:r,Fp2:n,Fp6:i,Fp12:s}=t.fields,o=t.params.xNegative,a=t.params.twistType,c=Ha({n:r.ORDER,...t.G1}),l=Object.assign(c,Ca(c.ProjectivePoint,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults})),h=Ha({n:r.ORDER,...t.G2}),d=Object.assign(h,Ca(h.ProjectivePoint,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),w;if(a==="multiplicative")w=(W,P,m,L,te,le)=>s.mul014(L,W,n.mul(P,te),n.mul(m,le));else if(a==="divisive")w=(W,P,m,L,te,le)=>s.mul034(L,n.mul(m,le),n.mul(P,te),W);else throw new Error("bls: unknown twist type");let b=n.div(n.ONE,n.mul(n.ONE,a0));function f(W,P,m,L){let te=n.sqr(m),le=n.sqr(L),D=n.mulByB(n.mul(le,xn)),u=n.mul(D,xn),p=n.sub(n.sub(n.sqr(n.add(m,L)),le),te),y=n.sub(D,te),T=n.mul(n.sqr(P),xn),v=n.neg(p);return W.push([y,T,v]),P=n.mul(n.mul(n.mul(n.sub(te,u),P),m),b),m=n.sub(n.sqr(n.mul(n.add(te,u),b)),n.mul(n.sqr(D),xn)),L=n.mul(te,p),{Rx:P,Ry:m,Rz:L}}function S(W,P,m,L,te,le){let D=n.sub(m,n.mul(le,L)),u=n.sub(P,n.mul(te,L)),p=n.sub(n.mul(D,te),n.mul(u,le)),y=n.neg(D),T=u;W.push([p,y,T]);let v=n.sqr(u),A=n.mul(v,u),M=n.mul(v,P),x=n.add(n.sub(A,n.mul(M,a0)),n.mul(n.sqr(D),L));return P=n.mul(u,x),m=n.sub(n.mul(n.sub(M,x),D),n.mul(A,m)),L=n.mul(L,A),{Rx:P,Ry:m,Rz:L}}let R=Pp(t.params.ateLoopSize),O=hr(W=>{let P=W,{x:m,y:L}=P.toAffine(),te=m,le=L,D=n.neg(L),u=te,p=le,y=n.ONE,T=[];for(let v of R){let A=[];({Rx:u,Ry:p,Rz:y}=f(A,u,p,y)),v&&({Rx:u,Ry:p,Rz:y}=S(A,u,p,y,te,v===-1?D:le)),T.push(A)}if(t.postPrecompute){let v=T[T.length-1];t.postPrecompute(u,p,y,te,le,S.bind(null,v))}return T});function V(W,P=!1){let m=s.ONE;if(W.length){let L=W[0][0].length;for(let te=0;te<L;te++){m=s.sqr(m);for(let[le,D,u]of W)for(let[p,y,T]of le[te])m=w(p,y,T,m,D,u)}}return o&&(m=s.conjugate(m)),P?s.finalExponentiate(m):m}function q(W,P=!0){let m=[];l.ProjectivePoint.normalizeZ(W.map(({g1:L})=>L)),d.ProjectivePoint.normalizeZ(W.map(({g2:L})=>L));for(let{g1:L,g2:te}of W){if(L.equals(l.ProjectivePoint.ZERO)||te.equals(d.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");L.assertValidity(),te.assertValidity();let le=L.toAffine();m.push([O(te),le.x,le.y])}return V(m,P)}function z(W,P,m=!0){return q([{g1:W,g2:P}],m)}let E={randomPrivateKey:()=>{let W=Ns(r.ORDER);return Pa(t.randomBytes(W),r.ORDER)},calcPairingPrecomputes:O},{ShortSignature:H}=t.G1,{Signature:Y}=t.G2;function Z(W){return W instanceof l.ProjectivePoint?W:l.ProjectivePoint.fromHex(W)}function C(W,P){return W instanceof l.ProjectivePoint?W:l.hashToCurve(Ye("point",W),P)}function ie(W){return W instanceof d.ProjectivePoint?W:Y.fromHex(W)}function re(W,P){return W instanceof d.ProjectivePoint?W:d.hashToCurve(Ye("point",W),P)}function ee(W){return l.ProjectivePoint.fromPrivateKey(W).toRawBytes(!0)}function g(W){return d.ProjectivePoint.fromPrivateKey(W).toRawBytes(!0)}function B(W,P,m){let L=re(W,m);L.assertValidity();let te=L.multiply(l.normPrivateKeyToScalar(P));return W instanceof d.ProjectivePoint?te:Y.toRawBytes(te)}function $(W,P,m){let L=C(W,m);L.assertValidity();let te=L.multiply(l.normPrivateKeyToScalar(P));return W instanceof l.ProjectivePoint?te:H.toRawBytes(te)}function F(W,P,m,L){let te=Z(m),le=re(P,L),D=l.ProjectivePoint.BASE,u=ie(W),p=q([{g1:te.negate(),g2:le},{g1:D,g2:u}]);return s.eql(p,s.ONE)}function U(W,P,m,L){let te=ie(m),le=C(P,L),D=d.ProjectivePoint.BASE,u=Z(W),p=q([{g1:le,g2:te},{g1:u,g2:D.negate()}]);return s.eql(p,s.ONE)}function G(W){if(!W.length)throw new Error("Expected non-empty array");let m=W.map(Z).reduce((L,te)=>L.add(te),l.ProjectivePoint.ZERO);return W[0]instanceof l.ProjectivePoint?(m.assertValidity(),m):m.toRawBytes(!0)}function J(W){if(!W.length)throw new Error("Expected non-empty array");let m=W.map(ie).reduce((L,te)=>L.add(te),d.ProjectivePoint.ZERO);return W[0]instanceof d.ProjectivePoint?(m.assertValidity(),m):Y.toRawBytes(m)}function fe(W){if(!W.length)throw new Error("Expected non-empty array");let m=W.map(Z).reduce((L,te)=>L.add(te),l.ProjectivePoint.ZERO);return W[0]instanceof l.ProjectivePoint?(m.assertValidity(),m):H.toRawBytes(m)}function ce(W,P,m,L){if(!P.length)throw new Error("Expected non-empty messages array");if(m.length!==P.length)throw new Error("Pubkey count should equal msg count");let te=ie(W),le=P.map(y=>re(y,L)),D=m.map(Z),u=new Map;for(let y=0;y<D.length;y++){let T=D[y],v=le[y],A=u.get(v);A===void 0&&(A=[],u.set(v,A)),A.push(T)}let p=[];try{for(let[y,T]of u){let v=T.reduce((A,M)=>A.add(M));p.push({g1:v,g2:y})}return p.push({g1:l.ProjectivePoint.BASE.negate(),g2:te}),s.eql(q(p),s.ONE)}catch{return!1}}return l.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:ee,getPublicKeyForShortSignatures:g,sign:B,signShortSignature:$,verify:F,verifyBatch:ce,verifyShortSignature:U,aggregatePublicKeys:G,aggregateSignatures:J,aggregateShortSignatures:fe,millerLoopBatch:V,pairing:z,pairingBatch:q,G1:l,G2:d,Signature:Y,ShortSignature:H,fields:{Fr:r,Fp:e,Fp2:n,Fp6:i,Fp12:s},params:{ateLoopSize:t.params.ateLoopSize,r:t.params.r,G1b:t.G1.b,G2b:t.G2.b},utils:E}}var Ip,Is,a0,xn,u0=he(()=>{dr();qt();qa();za();Ip=BigInt(0),Is=BigInt(1),a0=BigInt(2),xn=BigInt(3)});function Ya(t,e,r,n,i=1,s){let o=BigInt(s===void 0?n:s),a=r**BigInt(n),c=[];for(let l=0;l<i;l++){let h=BigInt(l+1),d=[];for(let w=0,b=_n;w<n;w++){let f=(h*b-h)/o%a;d.push(t.pow(e,f)),b*=r}c.push(d)}return c}function l0(t,e,r){let n=e.pow(r,(t.ORDER-_n)/f0),i=e.pow(r,(t.ORDER-_n)/pr);function s(w,b){let f=e.mul(e.frobeniusMap(w,1),n),S=e.mul(e.frobeniusMap(b,1),i);return[f,S]}let o=e.pow(r,(t.ORDER**pr-_n)/f0),a=e.pow(r,(t.ORDER**pr-_n)/pr);if(!e.eql(a,e.neg(e.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(w,b){return[e.mul(w,o),e.neg(b)]}let l=w=>(b,f)=>{let S=f.toAffine(),R=w(S.x,S.y);return b.fromAffine({x:R[0],y:R[1]})},h=l(s),d=l(c);return{psi:s,psi2:c,G2psi:h,G2psi2:d,PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:a}}function h0(t){let{ORDER:e}=t,r=Lt(e),n=r.create(t.NONRESIDUE||BigInt(-1)),i=r0(e),s=r.div(r.ONE,pr),o=Ya(r,n,r.ORDER,2)[0],a=({c0:g,c1:B},{c0:$,c1:F})=>({c0:r.add(g,$),c1:r.add(B,F)}),c=({c0:g,c1:B},{c0:$,c1:F})=>({c0:r.sub(g,$),c1:r.sub(B,F)}),l=({c0:g,c1:B},$)=>{if(typeof $=="bigint")return{c0:r.mul(g,$),c1:r.mul(B,$)};let{c0:F,c1:U}=$,G=r.mul(g,F),J=r.mul(B,U),fe=r.sub(G,J),ce=r.sub(r.mul(r.add(g,B),r.add(F,U)),r.add(G,J));return{c0:fe,c1:ce}},h=({c0:g,c1:B})=>{let $=r.add(g,B),F=r.sub(g,B),U=r.add(g,g);return{c0:r.mul($,F),c1:r.mul(U,B)}},d=g=>{if(g.length!==2)throw new Error("Invalid tuple");let B=g.map($=>r.create($));return{c0:B[0],c1:B[1]}},w=e*e,b=d(t.FP2_NONRESIDUE),f={ORDER:w,NONRESIDUE:b,BITS:lr(w),BYTES:Math.ceil(lr(w)/8),MASK:Tr(lr(w)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:g=>g,isValid:({c0:g,c1:B})=>typeof g=="bigint"&&typeof B=="bigint",is0:({c0:g,c1:B})=>r.is0(g)&&r.is0(B),eql:({c0:g,c1:B},{c0:$,c1:F})=>r.eql(g,$)&&r.eql(B,F),neg:({c0:g,c1:B})=>({c0:r.neg(g),c1:r.neg(B)}),pow:(g,B)=>ii(f,g,B),invertBatch:g=>si(f,g),add:a,sub:c,mul:l,sqr:h,addN:a,subN:c,mulN:l,sqrN:h,div:(g,B)=>f.mul(g,typeof B=="bigint"?r.inv(r.create(B)):f.inv(B)),inv:({c0:g,c1:B})=>{let $=r.inv(r.create(g*g+B*B));return{c0:r.mul($,r.create(g)),c1:r.mul($,r.create(-B))}},sqrt:g=>{if(t.Fp2sqrt)return t.Fp2sqrt(g);let{c0:B,c1:$}=g;if(r.is0($))return r.eql(i(r,B),r.ONE)?f.create({c0:r.sqrt(B),c1:r.ZERO}):f.create({c0:r.ZERO,c1:r.sqrt(r.div(B,n))});let F=r.sqrt(r.sub(r.sqr(B),r.mul(r.sqr($),n))),U=r.mul(r.add(F,B),s),G=i(r,U);!r.is0(G)&&!r.eql(G,r.ONE)&&(U=r.sub(U,F));let J=r.sqrt(U),fe=f.create({c0:J,c1:r.div(r.mul($,s),J)});if(!f.eql(f.sqr(fe),g))throw new Error("Cannot find square root");let ce=fe,W=f.neg(ce),{re:P,im:m}=f.reim(ce),{re:L,im:te}=f.reim(W);return m>te||m===te&&P>L?ce:W},isOdd:g=>{let{re:B,im:$}=f.reim(g),F=B%pr,U=B===kp,G=$%pr;return BigInt(F||U&&G)==_n},fromBytes(g){if(g.length!==f.BYTES)throw new Error(`fromBytes wrong length=${g.length}`);return{c0:r.fromBytes(g.subarray(0,r.BYTES)),c1:r.fromBytes(g.subarray(r.BYTES))}},toBytes:({c0:g,c1:B})=>Te(r.toBytes(g),r.toBytes(B)),cmov:({c0:g,c1:B},{c0:$,c1:F},U)=>({c0:r.cmov(g,$,U),c1:r.cmov(B,F,U)}),reim:({c0:g,c1:B})=>({re:g,im:B}),mulByNonresidue:({c0:g,c1:B})=>f.mul({c0:g,c1:B},b),mulByB:t.Fp2mulByB,fromBigTuple:d,frobeniusMap:({c0:g,c1:B},$)=>({c0:g,c1:r.mul(B,o[$%2])})},S=({c0:g,c1:B,c2:$},{c0:F,c1:U,c2:G})=>({c0:f.add(g,F),c1:f.add(B,U),c2:f.add($,G)}),R=({c0:g,c1:B,c2:$},{c0:F,c1:U,c2:G})=>({c0:f.sub(g,F),c1:f.sub(B,U),c2:f.sub($,G)}),O=({c0:g,c1:B,c2:$},F)=>{if(typeof F=="bigint")return{c0:f.mul(g,F),c1:f.mul(B,F),c2:f.mul($,F)};let{c0:U,c1:G,c2:J}=F,fe=f.mul(g,U),ce=f.mul(B,G),W=f.mul($,J);return{c0:f.add(fe,f.mulByNonresidue(f.sub(f.mul(f.add(B,$),f.add(G,J)),f.add(ce,W)))),c1:f.add(f.sub(f.mul(f.add(g,B),f.add(U,G)),f.add(fe,ce)),f.mulByNonresidue(W)),c2:f.sub(f.add(ce,f.mul(f.add(g,$),f.add(U,J))),f.add(fe,W))}},V=({c0:g,c1:B,c2:$})=>{let F=f.sqr(g),U=f.mul(f.mul(g,B),pr),G=f.mul(f.mul(B,$),pr),J=f.sqr($);return{c0:f.add(f.mulByNonresidue(G),F),c1:f.add(f.mulByNonresidue(J),U),c2:f.sub(f.sub(f.add(f.add(U,f.sqr(f.add(f.sub(g,B),$))),G),F),J)}},[q,z]=Ya(f,b,r.ORDER,6,2,3),E={ORDER:f.ORDER,BITS:3*f.BITS,BYTES:3*f.BYTES,MASK:Tr(3*f.BITS),ZERO:{c0:f.ZERO,c1:f.ZERO,c2:f.ZERO},ONE:{c0:f.ONE,c1:f.ZERO,c2:f.ZERO},create:g=>g,isValid:({c0:g,c1:B,c2:$})=>f.isValid(g)&&f.isValid(B)&&f.isValid($),is0:({c0:g,c1:B,c2:$})=>f.is0(g)&&f.is0(B)&&f.is0($),neg:({c0:g,c1:B,c2:$})=>({c0:f.neg(g),c1:f.neg(B),c2:f.neg($)}),eql:({c0:g,c1:B,c2:$},{c0:F,c1:U,c2:G})=>f.eql(g,F)&&f.eql(B,U)&&f.eql($,G),sqrt:As,div:(g,B)=>E.mul(g,typeof B=="bigint"?r.inv(r.create(B)):E.inv(B)),pow:(g,B)=>ii(E,g,B),invertBatch:g=>si(E,g),add:S,sub:R,mul:O,sqr:V,addN:S,subN:R,mulN:O,sqrN:V,inv:({c0:g,c1:B,c2:$})=>{let F=f.sub(f.sqr(g),f.mulByNonresidue(f.mul($,B))),U=f.sub(f.mulByNonresidue(f.sqr($)),f.mul(g,B)),G=f.sub(f.sqr(B),f.mul(g,$)),J=f.inv(f.add(f.mulByNonresidue(f.add(f.mul($,U),f.mul(B,G))),f.mul(g,F)));return{c0:f.mul(J,F),c1:f.mul(J,U),c2:f.mul(J,G)}},fromBytes:g=>{if(g.length!==E.BYTES)throw new Error(`fromBytes wrong length=${g.length}`);return{c0:f.fromBytes(g.subarray(0,f.BYTES)),c1:f.fromBytes(g.subarray(f.BYTES,2*f.BYTES)),c2:f.fromBytes(g.subarray(2*f.BYTES))}},toBytes:({c0:g,c1:B,c2:$})=>Te(f.toBytes(g),f.toBytes(B),f.toBytes($)),cmov:({c0:g,c1:B,c2:$},{c0:F,c1:U,c2:G},J)=>({c0:f.cmov(g,F,J),c1:f.cmov(B,U,J),c2:f.cmov($,G,J)}),fromBigSix:g=>{if(!Array.isArray(g)||g.length!==6)throw new Error("Invalid Fp6 usage");return{c0:f.fromBigTuple(g.slice(0,2)),c1:f.fromBigTuple(g.slice(2,4)),c2:f.fromBigTuple(g.slice(4,6))}},frobeniusMap:({c0:g,c1:B,c2:$},F)=>({c0:f.frobeniusMap(g,F),c1:f.mul(f.frobeniusMap(B,F),q[F%6]),c2:f.mul(f.frobeniusMap($,F),z[F%6])}),mulByFp2:({c0:g,c1:B,c2:$},F)=>({c0:f.mul(g,F),c1:f.mul(B,F),c2:f.mul($,F)}),mulByNonresidue:({c0:g,c1:B,c2:$})=>({c0:f.mulByNonresidue($),c1:g,c2:B}),mul1:({c0:g,c1:B,c2:$},F)=>({c0:f.mulByNonresidue(f.mul($,F)),c1:f.mul(g,F),c2:f.mul(B,F)}),mul01({c0:g,c1:B,c2:$},F,U){let G=f.mul(g,F),J=f.mul(B,U);return{c0:f.add(f.mulByNonresidue(f.sub(f.mul(f.add(B,$),U),J)),G),c1:f.sub(f.sub(f.mul(f.add(F,U),f.add(g,B)),G),J),c2:f.add(f.sub(f.mul(f.add(g,$),F),G),J)}}},H=Ya(f,b,r.ORDER,12,1,6)[0],Y=({c0:g,c1:B},{c0:$,c1:F})=>({c0:E.add(g,$),c1:E.add(B,F)}),Z=({c0:g,c1:B},{c0:$,c1:F})=>({c0:E.sub(g,$),c1:E.sub(B,F)}),C=({c0:g,c1:B},$)=>{if(typeof $=="bigint")return{c0:E.mul(g,$),c1:E.mul(B,$)};let{c0:F,c1:U}=$,G=E.mul(g,F),J=E.mul(B,U);return{c0:E.add(G,E.mulByNonresidue(J)),c1:E.sub(E.mul(E.add(g,B),E.add(F,U)),E.add(G,J))}},ie=({c0:g,c1:B})=>{let $=E.mul(g,B);return{c0:E.sub(E.sub(E.mul(E.add(E.mulByNonresidue(B),g),E.add(g,B)),$),E.mulByNonresidue($)),c1:E.add($,$)}};function re(g,B){let $=f.sqr(g),F=f.sqr(B);return{first:f.add(f.mulByNonresidue(F),$),second:f.sub(f.sub(f.sqr(f.add(g,B)),$),F)}}let ee={ORDER:f.ORDER,BITS:2*f.BITS,BYTES:2*f.BYTES,MASK:Tr(2*f.BITS),ZERO:{c0:E.ZERO,c1:E.ZERO},ONE:{c0:E.ONE,c1:E.ZERO},create:g=>g,isValid:({c0:g,c1:B})=>E.isValid(g)&&E.isValid(B),is0:({c0:g,c1:B})=>E.is0(g)&&E.is0(B),neg:({c0:g,c1:B})=>({c0:E.neg(g),c1:E.neg(B)}),eql:({c0:g,c1:B},{c0:$,c1:F})=>E.eql(g,$)&&E.eql(B,F),sqrt:As,inv:({c0:g,c1:B})=>{let $=E.inv(E.sub(E.sqr(g),E.mulByNonresidue(E.sqr(B))));return{c0:E.mul(g,$),c1:E.neg(E.mul(B,$))}},div:(g,B)=>ee.mul(g,typeof B=="bigint"?r.inv(r.create(B)):ee.inv(B)),pow:(g,B)=>ii(ee,g,B),invertBatch:g=>si(ee,g),add:Y,sub:Z,mul:C,sqr:ie,addN:Y,subN:Z,mulN:C,sqrN:ie,fromBytes:g=>{if(g.length!==ee.BYTES)throw new Error(`fromBytes wrong length=${g.length}`);return{c0:E.fromBytes(g.subarray(0,E.BYTES)),c1:E.fromBytes(g.subarray(E.BYTES))}},toBytes:({c0:g,c1:B})=>Te(E.toBytes(g),E.toBytes(B)),cmov:({c0:g,c1:B},{c0:$,c1:F},U)=>({c0:E.cmov(g,$,U),c1:E.cmov(B,F,U)}),fromBigTwelve:g=>({c0:E.fromBigSix(g.slice(0,6)),c1:E.fromBigSix(g.slice(6,12))}),frobeniusMap(g,B){let{c0:$,c1:F,c2:U}=E.frobeniusMap(g.c1,B),G=H[B%12];return{c0:E.frobeniusMap(g.c0,B),c1:E.create({c0:f.mul($,G),c1:f.mul(F,G),c2:f.mul(U,G)})}},mulByFp2:({c0:g,c1:B},$)=>({c0:E.mulByFp2(g,$),c1:E.mulByFp2(B,$)}),conjugate:({c0:g,c1:B})=>({c0:g,c1:E.neg(B)}),mul014:({c0:g,c1:B},$,F,U)=>{let G=E.mul01(g,$,F),J=E.mul1(B,U);return{c0:E.add(E.mulByNonresidue(J),G),c1:E.sub(E.sub(E.mul01(E.add(B,g),$,f.add(F,U)),G),J)}},mul034:({c0:g,c1:B},$,F,U)=>{let G=E.create({c0:f.mul(g.c0,$),c1:f.mul(g.c1,$),c2:f.mul(g.c2,$)}),J=E.mul01(B,F,U),fe=E.mul01(E.add(g,B),f.add($,F),U);return{c0:E.add(E.mulByNonresidue(J),G),c1:E.sub(fe,E.add(G,J))}},_cyclotomicSquare:t.Fp12cyclotomicSquare,_cyclotomicExp:t.Fp12cyclotomicExp,finalExponentiate:t.Fp12finalExponentiate};return{Fp:r,Fp2:f,Fp6:E,Fp4Square:re,Fp12:ee}}var kp,_n,pr,f0,d0=he(()=>{dr();qt();kp=BigInt(0),_n=BigInt(1),pr=BigInt(2),f0=BigInt(3)});function ks(t){t=t.slice();let e=t[0]&224,r=!!(e>>7&1),n=!!(e>>6&1),i=!!(e>>5&1);return t[0]&=31,{compressed:r,infinity:n,sort:i,value:t}}function ci(t,e){if(t[0]&224)throw new Error("setMask: non-empty mask");return e.compressed&&(t[0]|=128),e.infinity&&(t[0]|=64),e.sort&&(t[0]|=32),t}function y0(t){t.assertValidity();let e=t.equals(wt.G1.ProjectivePoint.ZERO),{x:r,y:n}=t.toAffine();if(e)return Cs.slice();let i=se.ORDER,s=!!(n*Le/i);return ci(qe(r,se.BYTES),{compressed:!0,sort:s})}function g0(t){t.assertValidity();let e=se.BYTES;if(t.equals(wt.G2.ProjectivePoint.ZERO))return Te(Cs,qe(st,e));let{x:r,y:n}=t.toAffine(),{re:i,im:s}=ue.reim(r),{re:o,im:a}=ue.reim(n),l=!!((a>st?a*Le:o*Le)/se.ORDER&Ms),h=i;return Te(ci(qe(s,e),{sort:l,compressed:!0}),qe(h,e))}var st,Ms,Le,Ps,ai,Or,Mp,se,ue,Za,Ka,we,p0,Cp,qp,$p,Vp,m0,jp,Wa,Cs,wt,w0=he(()=>{Ii();nn();u0();dr();qt();qa();za();d0();st=BigInt(0),Ms=BigInt(1),Le=BigInt(2),Ps=BigInt(3),ai=BigInt(4),Or=BigInt("0xd201000000010000"),Mp=lr(Or),{Fp:se,Fp2:ue,Fp6:Za,Fp4Square:Ka,Fp12:we}=h0({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[Ms,Ms],Fp2mulByB:({c0:t,c1:e})=>{let r=se.mul(t,ai),n=se.mul(e,ai);return{c0:se.sub(r,n),c1:se.add(r,n)}},Fp12cyclotomicSquare:({c0:t,c1:e})=>{let{c0:r,c1:n,c2:i}=t,{c0:s,c1:o,c2:a}=e,{first:c,second:l}=Ka(r,o),{first:h,second:d}=Ka(s,i),{first:w,second:b}=Ka(n,a),f=ue.mulByNonresidue(b);return{c0:Za.create({c0:ue.add(ue.mul(ue.sub(c,r),Le),c),c1:ue.add(ue.mul(ue.sub(h,n),Le),h),c2:ue.add(ue.mul(ue.sub(w,i),Le),w)}),c1:Za.create({c0:ue.add(ue.mul(ue.add(f,s),Le),f),c1:ue.add(ue.mul(ue.add(l,o),Le),l),c2:ue.add(ue.mul(ue.add(d,a),Le),d)})}},Fp12cyclotomicExp(t,e){let r=we.ONE;for(let n=Mp-1;n>=0;n--)r=we._cyclotomicSquare(r),Oa(e,n)&&(r=we.mul(r,t));return r},Fp12finalExponentiate:t=>{let e=Or,r=we.div(we.frobeniusMap(t,6),t),n=we.mul(we.frobeniusMap(r,2),r),i=we.conjugate(we._cyclotomicExp(n,e)),s=we.mul(we.conjugate(we._cyclotomicSquare(n)),i),o=we.conjugate(we._cyclotomicExp(s,e)),a=we.conjugate(we._cyclotomicExp(o,e)),c=we.mul(we.conjugate(we._cyclotomicExp(a,e)),we._cyclotomicSquare(i)),l=we.conjugate(we._cyclotomicExp(c,e)),h=we.frobeniusMap(we.mul(i,a),2),d=we.frobeniusMap(we.mul(o,n),3),w=we.frobeniusMap(we.mul(c,we.conjugate(n)),1),b=we.mul(we.mul(l,we.conjugate(s)),n);return we.mul(we.mul(we.mul(h,d),w),b)}}),p0=Lt(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),Cp=Ma(ue,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(t=>t.map(e=>ue.fromBigTuple(e.map(BigInt))))),qp=Ma(se,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(e=>BigInt(e)))),$p=Ga(ue,{A:ue.create({c0:se.create(st),c1:se.create(BigInt(240))}),B:ue.create({c0:se.create(BigInt(1012)),c1:se.create(BigInt(1012))}),Z:ue.create({c0:se.create(BigInt(-2)),c1:se.create(BigInt(-1))})}),Vp=Ga(se,{A:se.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:se.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:se.create(BigInt(11))}),{G2psi:m0,G2psi2:jp}=l0(se,ue,ue.div(ue.ONE,ue.NONRESIDUE)),Wa=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:se.ORDER,m:2,k:128,expand:"xmd",hash:kn}),Cs=ci(se.toBytes(st),{infinity:!0,compressed:!0});wt=c0({fields:{Fp:se,Fp2:ue,Fp6:Za,Fp12:we,Fr:p0},G1:{Fp:se,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:se.ZERO,b:ai,htfDefaults:{...Wa,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(t,e)=>{let r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new t(se.mul(e.px,r),e.py,e.pz);return e.multiplyUnsafe(Or).negate().multiplyUnsafe(Or).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(Or).add(e),mapToCurve:t=>{let{x:e,y:r}=Vp(se.create(t[0]));return qp(e,r)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=ks(t);if(i.length===48&&e){let s=se.ORDER,o=et(i),a=se.create(o&se.MASK);if(r){if(a!==st)throw new Error("G1: non-empty compressed point at infinity");return{x:st,y:st}}let c=se.add(se.pow(a,Ps),se.create(wt.params.G1b)),l=se.sqrt(c);if(!l)throw new Error("Invalid compressed G1 point");return l*Le/s!==BigInt(n)&&(l=se.neg(l)),{x:se.create(a),y:se.create(l)}}else if(i.length===96&&!e){let s=et(i.subarray(0,se.BYTES)),o=et(i.subarray(se.BYTES));if(r){if(s!==st||o!==st)throw new Error("G1: non-empty point at infinity");return wt.G1.ProjectivePoint.ZERO.toAffine()}return{x:se.create(s),y:se.create(o)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(t,e,r)=>{let n=e.equals(t.ZERO),{x:i,y:s}=e.toAffine();if(r){if(n)return Cs.slice();let o=se.ORDER,a=!!(s*Le/o);return ci(qe(i,se.BYTES),{compressed:!0,sort:a})}else return n?Te(new Uint8Array([64]),new Uint8Array(2*se.BYTES-1)):Te(qe(i,se.BYTES),qe(s,se.BYTES))},ShortSignature:{fromHex(t){let{infinity:e,sort:r,value:n}=ks(Ye("signatureHex",t,48)),i=se.ORDER,s=et(n);if(e)return wt.G1.ProjectivePoint.ZERO;let o=se.create(s&se.MASK),a=se.add(se.pow(o,Ps),se.create(wt.params.G1b)),c=se.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let l=BigInt(r);c*Le/i!==l&&(c=se.neg(c));let h=wt.G1.ProjectivePoint.fromAffine({x:o,y:c});return h.assertValidity(),h},toRawBytes(t){return y0(t)},toHex(t){return kt(y0(t))}}},G2:{Fp:ue,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:ue.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:ue.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:ue.ZERO,b:ue.fromBigTuple([ai,ai]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...Wa},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:t=>{let{x:e,y:r}=$p(ue.fromBigTuple(t));return Cp(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(Or).negate().equals(m0(t,e)),clearCofactor:(t,e)=>{let r=Or,n=e.multiplyUnsafe(r).negate(),i=m0(t,e),s=e.double();return s=jp(t,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(r).negate(),s=s.add(i),s=s.subtract(n),s.subtract(e)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=ks(t);if(!e&&!r&&n||!e&&r&&n||n&&r&&e)throw new Error("Invalid encoding flag: "+(t[0]&224));let s=se.BYTES,o=(a,c,l)=>et(a.slice(c,l));if(i.length===96&&e){let a=wt.params.G2b,c=se.ORDER;if(r){if(i.reduce((S,R)=>S!==0?R+1:R,0)>0)throw new Error("Invalid compressed G2 point");return{x:ue.ZERO,y:ue.ZERO}}let l=o(i,0,s),h=o(i,s,2*s),d=ue.create({c0:se.create(h),c1:se.create(l)}),w=ue.add(ue.pow(d,Ps),a),b=ue.sqrt(w),f=b.c1===st?b.c0*Le/c:b.c1*Le/c?Ms:st;return b=n&&f>0?b:ue.neg(b),{x:d,y:b}}else if(i.length===192&&!e){if(r){if(i.reduce((d,w)=>d!==0?w+1:w,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:ue.ZERO,y:ue.ZERO}}let a=o(i,0,s),c=o(i,s,2*s),l=o(i,2*s,3*s),h=o(i,3*s,4*s);return{x:ue.fromBigTuple([c,a]),y:ue.fromBigTuple([h,l])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(t,e,r)=>{let{BYTES:n,ORDER:i}=se,s=e.equals(t.ZERO),{x:o,y:a}=e.toAffine();if(r){if(s)return Te(Cs,qe(st,n));let c=!!(a.c1===st?a.c0*Le/i:a.c1*Le/i);return Te(ci(qe(o.c1,n),{compressed:!0,sort:c}),qe(o.c0,n))}else{if(s)return Te(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:l}=ue.reim(o),{re:h,im:d}=ue.reim(a);return Te(qe(l,n),qe(c,n),qe(d,n),qe(h,n))}},Signature:{fromHex(t){let{infinity:e,sort:r,value:n}=ks(Ye("signatureHex",t)),i=se.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=et(n.slice(0,s)),a=et(n.slice(s));if(e)return wt.G2.ProjectivePoint.ZERO;let c=se.create(o&se.MASK),l=se.create(a),h=ue.create({c0:l,c1:c}),d=ue.add(ue.pow(h,Ps),wt.params.G2b),w=ue.sqrt(d);if(!w)throw new Error("Failed to find a square root");let{re:b,im:f}=ue.reim(w),S=BigInt(r),R=f>st&&f*Le/i!==S,O=f===st&&b*Le/i!==S;(R||O)&&(w=ue.neg(w));let V=wt.G2.ProjectivePoint.fromAffine({x:h,y:w});return V.assertValidity(),V},toRawBytes(t){return g0(t)},toHex(t){return kt(g0(t))}}},params:{ateLoopSize:Or,r:p0.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:Wa,hash:kn,randomBytes:Fi})});function b0(t,e,r){let n=typeof t=="string"?t:Me(t),i=typeof e=="string"?e:Me(e),s=typeof r=="string"?r:Me(r);return wt.verifyShortSignature(i,s,n)}var Xa=he(()=>{w0();lt()});var Ja,En,qs=he(()=>{Yn();Ja=t=>Ge(new Rt(t)),En=t=>{let e=Ja(t);return new Date(Number(e)/1e6)}});function Gp(t,e){let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]>n[i])return!0;return!1}function Yp(t){let e=ui.byteLength+zp;if(t.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let r=t.slice(0,ui.byteLength);if(!$n(r,ui))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${ui}, but get ${r}`);return t.slice(ui.byteLength)}function ot(t){if(t.status===Ve.Found){if(t.value instanceof ArrayBuffer)return t.value;if(t.value instanceof Uint8Array)return t.value.buffer}}async function $s(t){switch(t[0]){case xt.Empty:return At(fi("ic-hashtree-empty"));case xt.Pruned:return t[1];case xt.Leaf:return At(nt(fi("ic-hashtree-leaf"),t[1]));case xt.Labeled:return At(nt(fi("ic-hashtree-labeled"),t[1],await $s(t[2])));case xt.Fork:return At(nt(fi("ic-hashtree-fork"),await $s(t[1]),await $s(t[2])));default:throw new Error("unreachable")}}function fi(t){let e=new Uint8Array([t.length]),r=new TextEncoder().encode(t);return nt(e,r)}function Ur(t,e){if(t.length===0)switch(e[0]){case xt.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?{status:Ve.Found,value:e[1]}:e[1]instanceof Uint8Array?{status:Ve.Found,value:e[1].buffer}:{status:Ve.Found,value:e[1]}}default:return{status:Ve.Found,value:e}}let r=typeof t[0]=="string"?new TextEncoder().encode(t[0]):t[0],n=Vs(r,e);switch(n.status){case Ve.Found:return Ur(t.slice(1),n.value);case mr.Greater:case mr.Less:return{status:Ve.Absent};default:return n}}function js(t){switch(t[0]){case xt.Empty:return[];case xt.Fork:return js(t[1]).concat(js(t[2]));default:return[t]}}function Vs(t,e){switch(e[0]){case xt.Labeled:return Gp(t,e[1])?{status:mr.Greater}:$n(t,e[1])?{status:Ve.Found,value:e[2]}:{status:mr.Less};case xt.Fork:let r=Vs(t,e[1]);switch(r.status){case mr.Greater:{let n=Vs(t,e[2]);return n.status===mr.Less?{status:Ve.Absent}:n}case Ve.Unknown:{let n=Vs(t,e[2]);return n.status===mr.Less?{status:Ve.Unknown}:n}default:return r}case xt.Pruned:return{status:Ve.Unknown};default:return{status:Ve.Absent}}}function Qa(t){let{canisterId:e,subnetId:r,tree:n}=t,i=Ur(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==Ve.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return Tt(i.value).map(c=>[de.fromUint8Array(c[0]),de.fromUint8Array(c[1])]).some(c=>c[0].ltEq(e)&&c[1].gtEq(e))}var bt,xt,Fr,ui,zp,Ve,mr,vn=he(()=>{Dn();fn();Qn();lt();yt();Xa();qs();li();bt=class extends Pe{constructor(e){super(`Invalid certificate: ${e}`)}};(function(t){t[t.Empty=0]="Empty",t[t.Fork=1]="Fork",t[t.Labeled=2]="Labeled",t[t.Leaf=3]="Leaf",t[t.Pruned=4]="Pruned"})(xt||(xt={}));Fr=class t{constructor(e,r,n,i,s=5){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,this.cert=Tt(new Uint8Array(e))}static async create(e){let r=t.createUnverified(e);return await r.verify(),r}static createUnverified(e){let r=e.blsVerify;return r||(r=b0),new t(e.certificate,e.rootKey,e.canisterId,r,e.maxAgeInMinutes)}lookup(e){return Ur(e,this.cert.tree)}lookup_label(e){return this.lookup([e])}async verify(){let e=await $s(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=Yp(r),s=nt(fi("ic-state-root"),e),o=!1,a=ot(this.lookup(["time"]));if(!a)throw new bt("Certificate does not contain a time");let c=5*60*1e3,l=this._maxAgeInMinutes*60*1e3,h=Date.now(),d=h-l,w=h+c,b=En(a);if(b.getTime()<d)throw new bt(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+b.toISOString()+" Current time: "+new Date(h).toISOString());if(b.getTime()>w)throw new bt("Certificate is signed more than 5 minutes in the future. Certificate time: "+b.toISOString()+" Current time: "+new Date(h).toISOString());try{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)throw new bt("Signature verification failed")}async _checkDelegationAndGetKey(e){if(!e)return this._rootKey;let r=await t.createUnverified({certificate:e.certificate,rootKey:this._rootKey,canisterId:this._canisterId,blsVerify:this._blsVerify,maxAgeInMinutes:1/0});if(r.cert.delegation)throw new bt("Delegation certificates cannot be nested");if(await r.verify(),this._canisterId.toString()!==x0&&!Qa({canisterId:this._canisterId,subnetId:de.fromUint8Array(new Uint8Array(e.subnet_id)),tree:r.cert.tree}))throw new bt(`Canister ${this._canisterId} not in range of delegations for subnet 0x${Me(e.subnet_id)}`);let n=ot(r.lookup(["subnet",e.subnet_id,"public_key"]));if(!n)throw new Error(`Could not find subnet key for subnet 0x${Me(e.subnet_id)}`);return n}},ui=Hr("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),zp=96;(function(t){t.Unknown="unknown",t.Absent="absent",t.Found="found"})(Ve||(Ve={}));(function(t){t.Less="less",t.Greater="greater"})(mr||(mr={}))});var Gs={};In(Gs,{CustomPath:()=>La,encodePath:()=>Da,fetchNodeKeys:()=>E0,request:()=>Hs});var La,Hs,E0,Da,_0,v0,Kp,Wp,hi=he(()=>{yt();fn();vn();lt();Dn();qs();La=class{constructor(e,r,n){this.key=e,this.path=r,this.decodeStrategy=n}},Hs=async t=>{let{agent:e,paths:r}=t,n=de.from(t.canisterId),i=[...new Set(r)],s=i.map(c=>Da(c,n)),o=new Map,a=i.map((c,l)=>(async()=>{var h;try{let d=await e.readState(n,{paths:[s[l]]}),w=await Fr.create({certificate:d.certificate,rootKey:e.rootKey,canisterId:n}),b=(R,O)=>{if(O==="subnet"){let V=E0(d.certificate,n,e.rootKey);return{path:O,data:V}}else return{path:O,data:ot(R.lookup(Da(O,n)))}},{path:f,data:S}=b(w,i[l]);if(!S)console.warn(`Expected to find result for path ${f}, but instead found nothing.`),typeof f=="string"?o.set(f,null):o.set(f.key,null);else switch(f){case"time":{o.set(f,En(S));break}case"controllers":{o.set(f,Wp(S));break}case"module_hash":{o.set(f,_0(S));break}case"subnet":{o.set(f,S);break}case"candid":{o.set(f,new TextDecoder().decode(S));break}default:if(typeof f!="string"&&"key"in f&&"path"in f)switch(f.decodeStrategy){case"raw":o.set(f.key,S);break;case"leb128":{o.set(f.key,Ja(S));break}case"cbor":{o.set(f.key,v0(S));break}case"hex":{o.set(f.key,_0(S));break}case"utf-8":o.set(f.key,Kp(S))}}}catch(d){if(!((h=d?.message)===null||h===void 0)&&h.includes("Invalid certificate"))throw new Pe(d.message);typeof c!="string"&&"key"in c&&"path"in c?o.set(c.key,null):o.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(d),console.groupEnd()}})());return await Promise.all(a),o},E0=(t,e,r)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=Tt(new Uint8Array(t)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=de.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=de.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=de.selfAuthenticating(de.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!Qa({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=Ur(["subnet",s.subnet_id,"node"],i);if(c.status!==Ve.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let l=js(c.value),h=new Map;return l.forEach(d=>{let w=de.from(new Uint8Array(d[1])).toText(),b=Ur(["public_key"],d[2]);if(b.status!==Ve.Found)throw new Error("Public key not found");let f=b.value;if(f.byteLength!==44)throw new Error("Invalid public key length");h.set(w,f)}),{subnetId:de.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:h}},Da=(t,e)=>{let r=new TextEncoder,n=s=>new DataView(r.encode(s).buffer).buffer,i=new DataView(e.toUint8Array().buffer).buffer;switch(t){case"time":return[n("time")];case"controllers":return[n("canister"),i,n("controllers")];case"module_hash":return[n("canister"),i,n("module_hash")];case"subnet":return[n("subnet")];case"candid":return[n("canister"),i,n("metadata"),n("candid:service")];default:if("key"in t&&"path"in t)if(typeof t.path=="string"||t.path instanceof ArrayBuffer){let s=t.path,o=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),o]}else return t.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${t} was formatted correctly.`)},_0=t=>Me(t),v0=t=>Tt(t),Kp=t=>new TextDecoder().decode(t),Wp=t=>v0(t).map(r=>de.fromUint8Array(new Uint8Array(r)))});function B0(t,e=!1){return e?{h:Number(t&zs),l:Number(t>>ec&zs)}:{h:Number(t>>ec&zs)|0,l:Number(t&zs)|0}}function Zp(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:s,l:o}=B0(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}function c1(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var zs,ec,Xp,Jp,Qp,Lp,Dp,e1,t1,r1,n1,i1,s1,o1,a1,u1,f1,l1,h1,d1,p1,m1,pe,A0=he(()=>{zs=BigInt(4294967295),ec=BigInt(32);Xp=(t,e)=>BigInt(t>>>0)<<ec|BigInt(e>>>0),Jp=(t,e,r)=>t>>>r,Qp=(t,e,r)=>t<<32-r|e>>>r,Lp=(t,e,r)=>t>>>r|e<<32-r,Dp=(t,e,r)=>t<<32-r|e>>>r,e1=(t,e,r)=>t<<64-r|e>>>r-32,t1=(t,e,r)=>t>>>r-32|e<<64-r,r1=(t,e)=>e,n1=(t,e)=>t,i1=(t,e,r)=>t<<r|e>>>32-r,s1=(t,e,r)=>e<<r|t>>>32-r,o1=(t,e,r)=>e<<r-32|t>>>64-r,a1=(t,e,r)=>t<<r-32|e>>>64-r;u1=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),f1=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,l1=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),h1=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,d1=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),p1=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0,m1={fromBig:B0,split:Zp,toBig:Xp,shrSH:Jp,shrSL:Qp,rotrSH:Lp,rotrSL:Dp,rotrBH:e1,rotrBL:t1,rotr32H:r1,rotr32L:n1,rotlSH:i1,rotlSL:s1,rotlBH:o1,rotlBL:a1,add:c1,add3L:u1,add3H:f1,add4L:l1,add4H:h1,add5H:p1,add5L:d1},pe=m1});var y1,g1,Ir,Pr,tc,T0,S0=he(()=>{bo();A0();nn();[y1,g1]=pe.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Ir=new Uint32Array(80),Pr=new Uint32Array(80),tc=class extends sn{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:l,El:h,Fh:d,Fl:w,Gh:b,Gl:f,Hh:S,Hl:R}=this;return[e,r,n,i,s,o,a,c,l,h,d,w,b,f,S,R]}set(e,r,n,i,s,o,a,c,l,h,d,w,b,f,S,R){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=h|0,this.Fh=d|0,this.Fl=w|0,this.Gh=b|0,this.Gl=f|0,this.Hh=S|0,this.Hl=R|0}process(e,r){for(let q=0;q<16;q++,r+=4)Ir[q]=e.getUint32(r),Pr[q]=e.getUint32(r+=4);for(let q=16;q<80;q++){let z=Ir[q-15]|0,E=Pr[q-15]|0,H=pe.rotrSH(z,E,1)^pe.rotrSH(z,E,8)^pe.shrSH(z,E,7),Y=pe.rotrSL(z,E,1)^pe.rotrSL(z,E,8)^pe.shrSL(z,E,7),Z=Ir[q-2]|0,C=Pr[q-2]|0,ie=pe.rotrSH(Z,C,19)^pe.rotrBH(Z,C,61)^pe.shrSH(Z,C,6),re=pe.rotrSL(Z,C,19)^pe.rotrBL(Z,C,61)^pe.shrSL(Z,C,6),ee=pe.add4L(Y,re,Pr[q-7],Pr[q-16]),g=pe.add4H(ee,H,ie,Ir[q-7],Ir[q-16]);Ir[q]=g|0,Pr[q]=ee|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:l,Dl:h,Eh:d,El:w,Fh:b,Fl:f,Gh:S,Gl:R,Hh:O,Hl:V}=this;for(let q=0;q<80;q++){let z=pe.rotrSH(d,w,14)^pe.rotrSH(d,w,18)^pe.rotrBH(d,w,41),E=pe.rotrSL(d,w,14)^pe.rotrSL(d,w,18)^pe.rotrBL(d,w,41),H=d&b^~d&S,Y=w&f^~w&R,Z=pe.add5L(V,E,Y,g1[q],Pr[q]),C=pe.add5H(Z,O,z,H,y1[q],Ir[q]),ie=Z|0,re=pe.rotrSH(n,i,28)^pe.rotrBH(n,i,34)^pe.rotrBH(n,i,39),ee=pe.rotrSL(n,i,28)^pe.rotrBL(n,i,34)^pe.rotrBL(n,i,39),g=n&s^n&a^s&a,B=i&o^i&c^o&c;O=S|0,V=R|0,S=b|0,R=f|0,b=d|0,f=w|0,{h:d,l:w}=pe.add(l|0,h|0,C|0,ie|0),l=a|0,h=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let $=pe.add3L(ie,ee,B);n=pe.add3H($,C,re,g),i=$|0}({h:n,l:i}=pe.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=pe.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=pe.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:h}=pe.add(this.Dh|0,this.Dl|0,l|0,h|0),{h:d,l:w}=pe.add(this.Eh|0,this.El|0,d|0,w|0),{h:b,l:f}=pe.add(this.Fh|0,this.Fl|0,b|0,f|0),{h:S,l:R}=pe.add(this.Gh|0,this.Gl|0,S|0,R|0),{h:O,l:V}=pe.add(this.Hh|0,this.Hl|0,O|0,V|0),this.set(n,i,s,o,a,c,l,h,d,w,b,f,S,R,O,V)}roundClean(){Ir.fill(0),Pr.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)}},T0=Pn(()=>new tc)});function x1(t){let e=Fs(t);return Ct(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function N0(t){let e=x1(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,l=Ys<<BigInt(a*8)-pt,h=r.create,d=Lt(e.n,e.nBitLength),w=e.uvRatio||((F,U)=>{try{return{isValid:!0,value:r.sqrt(F*r.inv(U))}}catch{return{isValid:!1,value:Vt}}}),b=e.adjustScalarBytes||(F=>F),f=e.domain||((F,U,G)=>{if(Br("phflag",G),U.length||G)throw new Error("Contexts/pre-hash are not supported");return F});function S(F,U){Mt("coordinate "+F,U,Vt,l)}function R(F){if(!(F instanceof q))throw new Error("ExtendedPoint expected")}let O=hr((F,U)=>{let{ex:G,ey:J,ez:fe}=F,ce=F.is0();U==null&&(U=ce?w1:r.inv(fe));let W=h(G*U),P=h(J*U),m=h(fe*U);if(ce)return{x:Vt,y:pt};if(m!==pt)throw new Error("invZ was invalid");return{x:W,y:P}}),V=hr(F=>{let{a:U,d:G}=e;if(F.is0())throw new Error("bad point: ZERO");let{ex:J,ey:fe,ez:ce,et:W}=F,P=h(J*J),m=h(fe*fe),L=h(ce*ce),te=h(L*L),le=h(P*U),D=h(L*h(le+m)),u=h(te+h(G*h(P*m)));if(D!==u)throw new Error("bad point: equation left != right (1)");let p=h(J*fe),y=h(ce*W);if(p!==y)throw new Error("bad point: equation left != right (2)");return!0});class q{constructor(U,G,J,fe){this.ex=U,this.ey=G,this.ez=J,this.et=fe,S("x",U),S("y",G),S("z",J),S("t",fe),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(U){if(U instanceof q)throw new Error("extended point not allowed");let{x:G,y:J}=U||{};return S("x",G),S("y",J),new q(G,J,pt,h(G*J))}static normalizeZ(U){let G=r.invertBatch(U.map(J=>J.ez));return U.map((J,fe)=>J.toAffine(G[fe])).map(q.fromAffine)}static msm(U,G){return Os(q,d,U,G)}_setWindowSize(U){H.setWindowSize(this,U)}assertValidity(){V(this)}equals(U){R(U);let{ex:G,ey:J,ez:fe}=this,{ex:ce,ey:W,ez:P}=U,m=h(G*P),L=h(ce*fe),te=h(J*P),le=h(W*fe);return m===L&&te===le}is0(){return this.equals(q.ZERO)}negate(){return new q(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){let{a:U}=e,{ex:G,ey:J,ez:fe}=this,ce=h(G*G),W=h(J*J),P=h(Ys*h(fe*fe)),m=h(U*ce),L=G+J,te=h(h(L*L)-ce-W),le=m+W,D=le-P,u=m-W,p=h(te*D),y=h(le*u),T=h(te*u),v=h(D*le);return new q(p,y,v,T)}add(U){R(U);let{a:G,d:J}=e,{ex:fe,ey:ce,ez:W,et:P}=this,{ex:m,ey:L,ez:te,et:le}=U;if(G===BigInt(-1)){let K=h((ce-fe)*(L+m)),Q=h((ce+fe)*(L-m)),oe=h(Q-K);if(oe===Vt)return this.double();let ye=h(W*Ys*le),ve=h(P*Ys*te),Se=ve+ye,me=Q+K,ae=ve-ye,ke=h(Se*oe),Gt=h(me*ae),ir=h(Se*ae),qr=h(oe*me);return new q(ke,Gt,qr,ir)}let D=h(fe*m),u=h(ce*L),p=h(P*J*le),y=h(W*te),T=h((fe+ce)*(m+L)-D-u),v=y-p,A=y+p,M=h(u-G*D),x=h(T*v),N=h(A*M),k=h(T*M),I=h(v*A);return new q(x,N,I,k)}subtract(U){return this.add(U.negate())}wNAF(U){return H.wNAFCached(this,U,q.normalizeZ)}multiply(U){let G=U;Mt("scalar",G,pt,n);let{p:J,f:fe}=this.wNAF(G);return q.normalizeZ([J,fe])[0]}multiplyUnsafe(U){let G=U;return Mt("scalar",G,Vt,n),G===Vt?E:this.equals(E)||G===pt?this:this.equals(z)?this.wNAF(G).p:H.unsafeLadder(this,G)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return H.unsafeLadder(this,n).is0()}toAffine(U){return O(this,U)}clearCofactor(){let{h:U}=e;return U===pt?this:this.multiplyUnsafe(U)}static fromHex(U,G=!1){let{d:J,a:fe}=e,ce=r.BYTES;U=Ye("pointHex",U,ce),Br("zip215",G);let W=U.slice(),P=U[ce-1];W[ce-1]=P&-129;let m=Ar(W),L=G?l:r.ORDER;Mt("pointHex.y",m,Vt,L);let te=h(m*m),le=h(te-pt),D=h(J*te-fe),{isValid:u,value:p}=w(le,D);if(!u)throw new Error("Point.fromHex: invalid y coordinate");let y=(p&pt)===pt,T=(P&128)!==0;if(!G&&p===Vt&&T)throw new Error("Point.fromHex: x=0 and x_0=1");return T!==y&&(p=h(-p)),q.fromAffine({x:p,y:m})}static fromPrivateKey(U){return C(U).point}toRawBytes(){let{x:U,y:G}=this.toAffine(),J=Zr(G,r.BYTES);return J[J.length-1]|=U&pt?128:0,J}toHex(){return kt(this.toRawBytes())}}q.BASE=new q(e.Gx,e.Gy,pt,h(e.Gx*e.Gy)),q.ZERO=new q(Vt,pt,pt,Vt);let{BASE:z,ZERO:E}=q,H=Rs(q,a*8);function Y(F){return Re(F,n)}function Z(F){return Y(Ar(F))}function C(F){let U=a;F=Ye("private key",F,U);let G=Ye("hashed private key",s(F),2*U),J=b(G.slice(0,U)),fe=G.slice(U,2*U),ce=Z(J),W=z.multiply(ce),P=W.toRawBytes();return{head:J,prefix:fe,scalar:ce,point:W,pointBytes:P}}function ie(F){return C(F).pointBytes}function re(F=new Uint8Array,...U){let G=Te(...U);return Z(s(f(G,Ye("context",F),!!i)))}function ee(F,U,G={}){F=Ye("message",F),i&&(F=i(F));let{prefix:J,scalar:fe,pointBytes:ce}=C(U),W=re(G.context,J,F),P=z.multiply(W).toRawBytes(),m=re(G.context,P,ce,F),L=Y(W+m*fe);Mt("signature.s",L,Vt,n);let te=Te(P,Zr(L,r.BYTES));return Ye("result",te,a*2)}let g=b1;function B(F,U,G,J=g){let{context:fe,zip215:ce}=J,W=r.BYTES;F=Ye("signature",F,2*W),U=Ye("message",U),ce!==void 0&&Br("zip215",ce),i&&(U=i(U));let P=Ar(F.slice(W,2*W)),m,L,te;try{m=q.fromHex(G,ce),L=q.fromHex(F.slice(0,W),ce),te=z.multiplyUnsafe(P)}catch{return!1}if(!ce&&m.isSmallOrder())return!1;let le=re(fe,L.toRawBytes(),m.toRawBytes(),U);return L.add(m.multiplyUnsafe(le)).subtract(te).clearCofactor().equals(q.ZERO)}return z._setWindowSize(8),{CURVE:e,getPublicKey:ie,sign:ee,verify:B,ExtendedPoint:q,utils:{getExtendedPublicKey:C,randomPrivateKey:()=>o(r.BYTES),precompute(F=8,U=q.BASE){return U._setWindowSize(F),U.multiply(BigInt(3)),U}}}}var Vt,pt,Ys,w1,b1,R0=he(()=>{ja();dr();qt();qt();Vt=BigInt(0),pt=BigInt(1),Ys=BigInt(2),w1=BigInt(8),b1={zip215:!0}});function B1(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=rc,a=t*t%s*t%s,c=$t(a,F0,s)*a%s,l=$t(c,_1,s)*t%s,h=$t(l,E1,s)*l%s,d=$t(h,e,s)*h%s,w=$t(d,r,s)*d%s,b=$t(w,n,s)*w%s,f=$t(b,i,s)*b%s,S=$t(f,i,s)*b%s,R=$t(S,e,s)*h%s;return{pow_p_5_8:$t(R,F0,s)*t%s,b2:a}}function A1(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function T1(t,e){let r=rc,n=Re(e*e*e,r),i=Re(n*n*e,r),s=B1(t*i).pow_p_5_8,o=Re(t*n*s,r),a=Re(e*o*o,r),c=o,l=Re(o*O0,r),h=a===t,d=a===Re(-t,r),w=a===Re(-t*O0,r);return h&&(o=c),(d||w)&&(o=l),t0(o,r)&&(o=Re(-o,r)),{isValid:h||d,value:o}}var rc,O0,tw,_1,F0,rw,E1,v1,S1,N1,U0,I0=he(()=>{S0();nn();R0();dr();rc=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),O0=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),tw=BigInt(0),_1=BigInt(1),F0=BigInt(2),rw=BigInt(3),E1=BigInt(5),v1=BigInt(8);S1=Lt(rc,void 0,!0),N1={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:S1,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:v1,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:T0,randomBytes:Fi,adjustScalarBytes:A1,uvRatio:T1},U0=N0(N1)});var P0,at,tt,di,k0,M0,Ks,C0=he(()=>{P0=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},at=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Ks=class{constructor(e={}){tt.set(this,void 0),di.set(this,void 0),this[k0]=this.entries.bind(this),this[M0]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();P0(this,tt,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),P0(this,di,n,"f")}prune(){let e=Date.now();for(let[r,n]of at(this,tt,"f").entries())e-n.timestamp>at(this,di,"f")&&at(this,tt,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return at(this,tt,"f").set(e,n),this}get(e){let r=at(this,tt,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>at(this,di,"f")){at(this,tt,"f").delete(e);return}return r.value}}clear(){at(this,tt,"f").clear()}entries(){let e=at(this,tt,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=at(this,tt,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return at(this,tt,"f").keys()}forEach(e,r){for(let[n,i]of at(this,tt,"f").entries())e.call(r,i.value,n,this)}has(e){return at(this,tt,"f").has(e)}delete(e){return at(this,tt,"f").delete(e)}get size(){return at(this,tt,"f").size}};tt=new WeakMap,di=new WeakMap,k0=Symbol.iterator,M0=Symbol.toStringTag});function V0(t,e){let r=2+q0(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,s=new Uint8Array(1+q0(n)+n);return s[i++]=48,i+=$0(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=$0(s,i,t.byteLength+1),s[i++]=0,s.set(new Uint8Array(t),i),s}var q0,$0,nc,R1,ow,ic,aw,j0,sc=he(()=>{lt();q0=t=>{if(t<=127)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},$0=(t,e,r)=>{if(r<=127)return t[e]=r,1;if(r<=255)return t[e]=129,t[e+1]=r,2;if(r<=65535)return t[e]=130,t[e+1]=r>>8,t[e+2]=r,3;if(r<=16777215)return t[e]=131,t[e+1]=r>>16,t[e+2]=r>>8,t[e+3]=r,4;throw new Error("Length too long (> 4 bytes)")},nc=(t,e)=>{if(t[e]<128)return 1;if(t[e]===128)throw new Error("Invalid length 0");if(t[e]===129)return 2;if(t[e]===130)return 3;if(t[e]===131)return 4;throw new Error("Length too long (> 4 bytes)")},R1=(t,e)=>{let r=nc(t,e);if(r===1)return t[e];if(r===2)return t[e+1];if(r===3)return(t[e+1]<<8)+t[e+2];if(r===4)return(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];throw new Error("Length too long (> 4 bytes)")},ow=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),ic=Uint8Array.from([48,5,6,3,43,101,112]),aw=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);j0=(t,e)=>{let r=0,n=(a,c)=>{if(i[r++]!==a)throw new Error("Expected: "+c)},i=new Uint8Array(t);if(n(48,"sequence"),r+=nc(i,r),!$n(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let s=R1(i,r)-1;r+=nc(i,r),n(0,"0 padding");let o=i.slice(r);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o}});var H0,G0,Ws,Zs,pi,oc=he(()=>{sc();H0=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},G0=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},pi=class t{constructor(e){if(Ws.set(this,void 0),Zs.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");H0(this,Ws,e,"f"),H0(this,Zs,t.derEncode(e),"f")}static from(e){return this.fromDer(e.toDer())}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){return V0(e,ic).buffer}static derDecode(e){let r=j0(e,ic);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return G0(this,Ws,"f")}get derKey(){return G0(this,Zs,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Ws=new WeakMap,Zs=new WeakMap;pi.RAW_KEY_LENGTH=32});var ac,Xs,z0=he(()=>{ac=class{constructor(){this.observers=[]}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(r=>r!==e)}notify(e,...r){this.observers.forEach(n=>n(e,...r))}},Xs=class extends ac{constructor(){super()}print(e,...r){this.notify({message:e,level:"info"},...r)}warn(e,...r){this.notify({message:e,level:"warn"},...r)}error(e,r,...n){this.notify({message:e,level:"error",error:r},...n)}}});var Dt,rt,er,Js,Qs,Ls,Ds,eo,to,ro,Bn,mi,Y0=he(()=>{Dt=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},rt=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},mi=class t{constructor(e=t.default){er.set(this,void 0),Js.set(this,void 0),Qs.set(this,void 0),Ls.set(this,void 0),Ds.set(this,void 0),eo.set(this,void 0),to.set(this,void 0),ro.set(this,void 0),Bn.set(this,0);let{initialInterval:r=500,randomizationFactor:n=.5,multiplier:i=1.5,maxInterval:s=6e4,maxElapsedTime:o=9e5,maxIterations:a=10,date:c=Date}=e;Dt(this,er,r,"f"),Dt(this,Js,n,"f"),Dt(this,Qs,i,"f"),Dt(this,Ls,s,"f"),Dt(this,ro,c,"f"),Dt(this,Ds,c.now(),"f"),Dt(this,eo,o,"f"),Dt(this,to,a,"f")}get ellapsedTimeInMsec(){return rt(this,ro,"f").now()-rt(this,Ds,"f")}get currentInterval(){return rt(this,er,"f")}get count(){return rt(this,Bn,"f")}get randomValueFromInterval(){let e=rt(this,Js,"f")*rt(this,er,"f"),r=rt(this,er,"f")-e,n=rt(this,er,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return Dt(this,er,Math.min(rt(this,er,"f")*rt(this,Qs,"f"),rt(this,Ls,"f")),"f"),Dt(this,Bn,(e=rt(this,Bn,"f"),e++,e),"f"),rt(this,er,"f")}next(){return this.ellapsedTimeInMsec>=rt(this,eo,"f")||rt(this,Bn,"f")>=rt(this,to,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};er=new WeakMap,Js=new WeakMap,Qs=new WeakMap,Ls=new WeakMap,Ds=new WeakMap,eo=new WeakMap,to=new WeakMap,ro=new WeakMap,Bn=new WeakMap;mi.default={initialInterval:500,randomizationFactor:.5,multiplier:1.5,maxInterval:6e4,maxElapsedTime:9e5,maxIterations:10,date:Date}});var cc=he(()=>{});function C1(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new bi("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof globalThis<"u")if(globalThis.fetch)t=globalThis.fetch.bind(globalThis);else throw new bi("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(t=self.fetch.bind(self));if(t)return t;throw new bi("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function q1(t){let e;if(t!==void 0)!t.match(/^[a-z]+:/)&&typeof window<"u"?e=new URL(window.location.protocol+"//"+t):e=new URL(t);else{let r=["ic0.app","icp0.io","127.0.0.1","localhost"],n=[".github.dev",".gitpod.io"],i=typeof window<"u"?window.location:void 0,s=i?.hostname,o;s&&typeof s=="string"&&(n.some(a=>s.endsWith(a))?o=s:o=r.find(a=>s.endsWith(a))),i&&o?e=new URL(`${i.protocol}//${o}${i.port?":"+i.port:""}`):e=new URL("https://icp-api.io")}return e.toString()}var ct,ne,rr,tr,kr,Sn,yi,gi,jt,io,Ht,Jr,Qr,wi,An,Tn,Lr,Dr,K0,so,oo,nr,no,O1,x0,F1,U1,I1,P1,k1,M1,bi,Nn,Rn,fc=he(()=>{yt();fn();ha();Dn();Qn();lt();Es();ti();Ba();hi();vn();I0();C0();oc();qs();z0();Y0();cc();Es();ti();ct=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},ne=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)};(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(nr||(nr={}));no=60*1e3,O1="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae",x0="aaaaa-aa",F1="ic0.app",U1=".ic0.app",I1="icp0.io",P1=".icp0.io",k1="icp-api.io",M1=".icp-api.io",bi=class extends Pe{constructor(e){super(e),this.message=e}},Nn=class extends Pe{constructor(e){super(e),this.message=e}};Rn=class t{constructor(e={}){var r;rr.add(this),tr.set(this,void 0),kr.set(this,void 0),Sn.set(this,void 0),yi.set(this,void 0),gi.set(this,0),jt.set(this,void 0),io.set(this,!1),Ht.set(this,void 0),Jr.set(this,void 0),Qr.set(this,void 0),this._isAgent=!0,this.config={},wi.set(this,0),this.log=new Xs,An.set(this,[]),Tn.set(this,[]),Lr.set(this,new Ks({expirationTime:5*60*1e3})),Dr.set(this,!0),oo.set(this,(s,o)=>{if(ne(this,Dr,"f")===!1)return s;if(!o)throw new bt("Invalid signature from replica signed query: no matching node key found.");let{status:a,signatures:c=[],requestId:l}=s,h=new TextEncoder().encode("\vic-response");for(let d of c){let{timestamp:w,identity:b}=d,f=de.fromUint8Array(b).toText(),S;if(a==="replied"){let{reply:z}=s;S=Jn({status:a,reply:z,timestamp:BigInt(w),request_id:l})}else if(a==="rejected"){let{reject_code:z,reject_message:E,error_code:H}=s;S=Jn({status:a,reject_code:z,reject_message:E,error_code:H,timestamp:BigInt(w),request_id:l})}else throw new Error(`Unknown status: ${a}`);let R=nt(h,new Uint8Array(S)),O=o?.nodeKeys.get(f);if(!O)throw new bt("Invalid signature from replica signed query: no matching node key found.");let V=pi.fromDer(O).rawKey;if(U0.verify(d.signature,new Uint8Array(R),new Uint8Array(V)))return s;throw new bt(`Invalid signature from replica ${f} signed query.`)}return s}),this.config=e,ct(this,kr,e.fetch||C1()||fetch.bind(globalThis),"f"),ct(this,Sn,e.fetchOptions,"f"),ct(this,yi,e.callOptions,"f"),this.rootKey=e.rootKey?e.rootKey:Hr(O1);let n=q1(e.host);this.host=new URL(n),e.verifyQuerySignatures!==void 0&&ct(this,Dr,e.verifyQuerySignatures,"f"),ct(this,Ht,(r=e.retryTimes)!==null&&r!==void 0?r:3,"f");let i=()=>new mi({maxIterations:ne(this,Ht,"f")});if(ct(this,Jr,e.backoffStrategy||i,"f"),this.host.hostname.endsWith(U1)?this.host.hostname=F1:this.host.hostname.endsWith(P1)?this.host.hostname=I1:this.host.hostname.endsWith(M1)&&(this.host.hostname=k1),e.credentials){let{name:s,password:o}=e.credentials;ct(this,jt,`${s}${o?":"+o:""}`,"f")}if(ct(this,tr,Promise.resolve(e.identity||new Yr),"f"),e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes>5)throw new Pe(`The maximum ingress expiry time is 5 minutes. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);if(e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes<=0)throw new Pe(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);ct(this,Qr,e.ingressExpiryInMinutes||5,"f"),this.addTransform("update",va(yn)),e.useQueryNonces&&this.addTransform("query",va(yn)),e.logToConsole&&this.log.subscribe(s=>{s.level==="error"?console.error(s.message):s.level==="warn"?console.warn(s.message):console.log(s.message)})}get waterMark(){return ne(this,wi,"f")}static createSync(e={}){return new this(Object.assign({},e))}static async create(e={shouldFetchRootKey:!1}){let r=t.createSync(e),n=[r.syncTime()];return r.host.toString()!=="https://icp-api.io"&&e.shouldFetchRootKey&&n.push(r.fetchRootKey()),await Promise.all(n),r}static async from(e){var r;try{return"config"in e?await t.create(e.config):await t.create({fetch:e._fetch,fetchOptions:e._fetchOptions,callOptions:e._callOptions,host:e._host.toString(),identity:(r=e._identity)!==null&&r!==void 0?r:void 0})}catch{throw new Pe("Failed to create agent from provided agent")}}isLocal(){let e=this.host.hostname;return e==="127.0.0.1"||e.endsWith("127.0.0.1")}addTransform(e,r,n=r.priority||0){if(e==="update"){let i=ne(this,Tn,"f").findIndex(s=>(s.priority||0)<n);ne(this,Tn,"f").splice(i>=0?i:ne(this,Tn,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=ne(this,An,"f").findIndex(s=>(s.priority||0)<n);ne(this,An,"f").splice(i>=0?i:ne(this,An,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!ne(this,tr,"f"))throw new Nn("This identity has expired due this application's security policy. Please refresh your authentication.");return(await ne(this,tr,"f")).getPrincipal()}async call(e,r,n){var i;let s=(i=r.callSync)!==null&&i!==void 0?i:!0,o=await(n!==void 0?await n:await ne(this,tr,"f"));if(!o)throw new Nn("This identity has expired due this application's security policy. Please refresh your authentication.");let a=de.from(e),c=r.effectiveCanisterId?de.from(r.effectiveCanisterId):a,l=o.getPrincipal()||de.anonymous(),h=new Qt(ne(this,Qr,"f")*no);Math.abs(ne(this,gi,"f"))>1e3*30&&(h=new Qt(ne(this,Qr,"f")*no+ne(this,gi,"f")));let d={request_type:_s.Call,canister_id:a,method_name:r.methodName,arg:r.arg,sender:l,ingress_expiry:h},w=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,jt,"f")?{Authorization:"Basic "+btoa(ne(this,jt,"f"))}:{})},endpoint:"call",body:d}),b=w.body.nonce?f(w.body.nonce):void 0;d.nonce=b;function f(O){return new Uint8Array(O)}w=await o.transformRequest(w);let S=bs(w.body),R=ne(this,Jr,"f").call(this);try{let O=()=>(this.log.print(`fetching "/api/v3/canister/${c.toText()}/call" with request:`,w),ne(this,kr,"f").call(this,""+new URL(`/api/v3/canister/${c.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,yi,"f")),w.request),{body:S}))),V=()=>(this.log.print(`fetching "/api/v2/canister/${c.toText()}/call" with request:`,w),ne(this,kr,"f").call(this,""+new URL(`/api/v2/canister/${c.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,yi,"f")),w.request),{body:S}))),q=ne(this,rr,"m",so).call(this,{request:s?O:V,backoff:R,tries:0}),[z,E]=await Promise.all([q,hs(d)]),H=await z.arrayBuffer(),Y=z.status===200&&H.byteLength>0?Tt(H):null;if(Y&&"certificate"in Y){let Z=await this.parseTimeFromResponse({certificate:Y.certificate});ct(this,wi,Z,"f")}return{requestId:E,response:{ok:z.ok,status:z.status,statusText:z.statusText,body:Y,headers:gn(z.headers)},requestDetails:d}}catch(O){if(O.message.includes("v3 api not supported."))return this.log.warn("v3 api not supported. Fall back to v2"),this.call(e,Object.assign(Object.assign({},r),{callSync:!1}),n);throw this.log.error("Error while making call:",O),O}}async query(e,r,n){let i=ne(this,Jr,"f").call(this),s=r.effectiveCanisterId?de.from(r.effectiveCanisterId):de.from(e);this.log.print(`ecid ${s.toString()}`),this.log.print(`canisterId ${e.toString()}`);let o=async()=>{let b=await(n!==void 0?n:ne(this,tr,"f"));if(!b)throw new Nn("This identity has expired due this application's security policy. Please refresh your authentication.");let f=de.from(e),S=b?.getPrincipal()||de.anonymous(),R={request_type:"query",canister_id:f,method_name:r.methodName,arg:r.arg,sender:S,ingress_expiry:new Qt(ne(this,Qr,"f")*no)},O=await hs(R),V=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,jt,"f")?{Authorization:"Basic "+btoa(ne(this,jt,"f"))}:{})},endpoint:"read",body:R});V=await b?.transformRequest(V);let q=bs(V.body),z={canister:f.toText(),ecid:s,transformedRequest:V,body:q,requestId:O,backoff:i,tries:0};return{requestDetails:R,query:await ne(this,rr,"m",K0).call(this,z)}},a=async()=>{if(!ne(this,Dr,"f"))return;let b=ne(this,Lr,"f").get(s.toString());return b||(await this.fetchSubnetKeys(s.toString()),ne(this,Lr,"f").get(s.toString()))},[c,l]=await Promise.all([o(),a()]),{requestDetails:h,query:d}=c,w=Object.assign(Object.assign({},d),{requestDetails:h});if(this.log.print("Query response:",w),!ne(this,Dr,"f"))return w;try{return ne(this,oo,"f").call(this,w,l)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ne(this,Lr,"f").delete(e.toString()),await this.fetchSubnetKeys(s.toString());let f=ne(this,Lr,"f").get(e.toString());if(!f)throw new bt("Invalid signature from replica signed query: no matching node key found.");return ne(this,oo,"f").call(this,w,f)}}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await ne(this,tr,"f"));if(!n)throw new Nn("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||de.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,jt,"f")?{Authorization:"Basic "+btoa(ne(this,jt,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new Qt(ne(this,Qr,"f")*no)}});return n?.transformRequest(s)}async readState(e,r,n,i){let s=typeof e=="string"?de.fromText(e):e,o=i??await this.createReadStateRequest(r,n),a=Object.assign(Object.assign({},o.body),{ingress_expiry:new Qt(3e5)}),c=bs(a);this.log.print(`fetching "/api/v2/canister/${s}/read_state" with request:`,o);let l=ne(this,Jr,"f").call(this);try{let h=await ne(this,rr,"m",so).call(this,{request:()=>ne(this,kr,"f").call(this,""+new URL(`/api/v2/canister/${s.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,Sn,"f")),o.request),{body:c})),backoff:l,tries:0});if(!h.ok)throw new Error(`Server returned an error:
15
15
  Code: ${h.status} (${h.statusText})
16
16
  Body: ${await h.text()}
17
- `);let d=Tt(await h.arrayBuffer());this.log.print("Read state response:",d);let w=await this.parseTimeFromResponse(d);return w>0&&(this.log.print("Read state response time:",w),ct(this,wi,w,"f")),d}catch(h){throw this.log.error("Caught exception while attempting to read state",h),h}}async parseTimeFromResponse(e){let r;if(e.certificate){let n=Tt(e.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=Ir(["time"],r);if(i.status!==Ve.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=vn(ko(i.value));return this.log.print("Time from response:",s),this.log.print("Time from response in milliseconds:",Number(s)),Number(s)}else this.log.warn("No certificate found in response");return 0}async syncTime(e){let r=await Promise.resolve().then(()=>(hi(),Hs)),n=Date.now();try{e||this.log.print("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let s=(await r.request({canisterId:e??de.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");s&&ct(this,gi,Number(s)-Number(n),"f")}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=ne(this,jt,"f")?{Authorization:"Basic "+btoa(ne(this,jt,"f"))}:{};this.log.print('fetching "/api/v2/status"');let r=ne(this,Xr,"f").call(this),n=await ne(this,rr,"m",io).call(this,{backoff:r,request:()=>ne(this,Mr,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:e},ne(this,Nn,"f"))),tries:0});return Tt(await n.arrayBuffer())}async fetchRootKey(){if(!ne(this,no,"f")){let e=await this.status();this.rootKey=e.root_key,ct(this,no,!0,"f")}return this.rootKey}invalidateIdentity(){ct(this,tr,null,"f")}replaceIdentity(e){ct(this,tr,Promise.resolve(e),"f")}async fetchSubnetKeys(e){let r=de.from(e),i=(await js({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return ne(this,Qr,"f").set(r.toText(),i),i}_transform(e){let r=Promise.resolve(e);if(e.endpoint==="call")for(let n of ne(this,Sn,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of ne(this,Tn,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};tr=new WeakMap,Mr=new WeakMap,Nn=new WeakMap,yi=new WeakMap,gi=new WeakMap,jt=new WeakMap,no=new WeakMap,Ht=new WeakMap,Xr=new WeakMap,Jr=new WeakMap,wi=new WeakMap,Tn=new WeakMap,Sn=new WeakMap,Qr=new WeakMap,Lr=new WeakMap,so=new WeakMap,rr=new WeakSet,W0=async function t(e){var r,n;let{ecid:i,transformedRequest:s,body:o,requestId:a,backoff:c,tries:l}=e,h=l===0?0:c.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:l,backoff:c,delay:h}),h===null)throw new Pe(`Timestamp failed to pass the watermark after retrying the configured ${ne(this,Ht,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);h>0&&await new Promise(f=>setTimeout(f,h));let d;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let f=await ne(this,Mr,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,Nn,"f")),s.request),{body:o}));if(f.status===200){let S=Tt(await f.arrayBuffer());d=Object.assign(Object.assign({},S),{httpDetails:{ok:f.ok,status:f.status,statusText:f.statusText,headers:wn(f.headers)},requestId:a})}else throw new bn(`Gateway returned an error:
17
+ `);let d=Tt(await h.arrayBuffer());this.log.print("Read state response:",d);let w=await this.parseTimeFromResponse(d);return w>0&&(this.log.print("Read state response time:",w),ct(this,wi,w,"f")),d}catch(h){throw this.log.error("Caught exception while attempting to read state",h),h}}async parseTimeFromResponse(e){let r;if(e.certificate){let n=Tt(e.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=Ur(["time"],r);if(i.status!==Ve.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=En(Po(i.value));return this.log.print("Time from response:",s),this.log.print("Time from response in milliseconds:",Number(s)),Number(s)}else this.log.warn("No certificate found in response");return 0}async syncTime(e){let r=await Promise.resolve().then(()=>(hi(),Gs)),n=Date.now();try{e||this.log.print("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let s=(await r.request({canisterId:e??de.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");s&&ct(this,gi,Number(s)-Number(n),"f")}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=ne(this,jt,"f")?{Authorization:"Basic "+btoa(ne(this,jt,"f"))}:{};this.log.print('fetching "/api/v2/status"');let r=ne(this,Jr,"f").call(this),n=await ne(this,rr,"m",so).call(this,{backoff:r,request:()=>ne(this,kr,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:e},ne(this,Sn,"f"))),tries:0});return Tt(await n.arrayBuffer())}async fetchRootKey(){if(!ne(this,io,"f")){let e=await this.status();this.rootKey=e.root_key,ct(this,io,!0,"f")}return this.rootKey}invalidateIdentity(){ct(this,tr,null,"f")}replaceIdentity(e){ct(this,tr,Promise.resolve(e),"f")}async fetchSubnetKeys(e){let r=de.from(e),i=(await Hs({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return ne(this,Lr,"f").set(r.toText(),i),i}_transform(e){let r=Promise.resolve(e);if(e.endpoint==="call")for(let n of ne(this,Tn,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of ne(this,An,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};tr=new WeakMap,kr=new WeakMap,Sn=new WeakMap,yi=new WeakMap,gi=new WeakMap,jt=new WeakMap,io=new WeakMap,Ht=new WeakMap,Jr=new WeakMap,Qr=new WeakMap,wi=new WeakMap,An=new WeakMap,Tn=new WeakMap,Lr=new WeakMap,Dr=new WeakMap,oo=new WeakMap,rr=new WeakSet,K0=async function t(e){var r,n;let{ecid:i,transformedRequest:s,body:o,requestId:a,backoff:c,tries:l}=e,h=l===0?0:c.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:l,backoff:c,delay:h}),h===null)throw new Pe(`Timestamp failed to pass the watermark after retrying the configured ${ne(this,Ht,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);h>0&&await new Promise(f=>setTimeout(f,h));let d;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let f=await ne(this,kr,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,Sn,"f")),s.request),{body:o}));if(f.status===200){let S=Tt(await f.arrayBuffer());d=Object.assign(Object.assign({},S),{httpDetails:{ok:f.ok,status:f.status,statusText:f.statusText,headers:gn(f.headers)},requestId:a})}else throw new wn(`Gateway returned an error:
18
18
  Code: ${f.status} (${f.statusText})
19
19
  Body: ${await f.text()}
20
- `,{ok:f.ok,status:f.status,statusText:f.statusText,headers:wn(f.headers)})}catch(f){if(l<ne(this,Ht,"f"))return this.log.warn(`Caught exception while attempting to make query:
20
+ `,{ok:f.ok,status:f.status,statusText:f.statusText,headers:gn(f.headers)})}catch(f){if(l<ne(this,Ht,"f"))return this.log.warn(`Caught exception while attempting to make query:
21
21
  ${f}
22
- Retrying query.`),await ne(this,rr,"m",t).call(this,Object.assign(Object.assign({},e),{tries:l+1}));throw f}let w=(n=(r=d.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!ne(this,Lr,"f"))return d;if(!w)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let b=Number(BigInt(w)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:b}),Number(this.waterMark)>b){let f=new Pe("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",f,{timestamp:w,waterMark:this.waterMark}),l<ne(this,Ht,"f"))return await ne(this,rr,"m",t).call(this,Object.assign(Object.assign({},e),{tries:l+1}));throw new Pe(`Timestamp failed to pass the watermark after retrying the configured ${ne(this,Ht,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return d},io=async function t(e){let{request:r,backoff:n,tries:i}=e,s=i===0?0:n.next();if(s===null)throw new Pe(`Timestamp failed to pass the watermark after retrying the configured ${ne(this,Ht,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(l=>setTimeout(l,s));let o;try{o=await r()}catch(l){if(ne(this,Ht,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
22
+ Retrying query.`),await ne(this,rr,"m",t).call(this,Object.assign(Object.assign({},e),{tries:l+1}));throw f}let w=(n=(r=d.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!ne(this,Dr,"f"))return d;if(!w)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let b=Number(BigInt(w)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:b}),Number(this.waterMark)>b){let f=new Pe("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",f,{timestamp:w,waterMark:this.waterMark}),l<ne(this,Ht,"f"))return await ne(this,rr,"m",t).call(this,Object.assign(Object.assign({},e),{tries:l+1}));throw new Pe(`Timestamp failed to pass the watermark after retrying the configured ${ne(this,Ht,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return d},so=async function t(e){let{request:r,backoff:n,tries:i}=e,s=i===0?0:n.next();if(s===null)throw new Pe(`Timestamp failed to pass the watermark after retrying the configured ${ne(this,Ht,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(l=>setTimeout(l,s));let o;try{o=await r()}catch(l){if(ne(this,Ht,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
23
23
  ${l}
24
24
  Retrying request.`),await ne(this,rr,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw l}if(o.ok)return o;let a=await o.clone().text(),c=`Server returned an error:
25
25
  Code: ${o.status} (${o.statusText})
26
26
  Body: ${a}
27
- `;if(o.status===404&&o.url.includes("api/v3"))throw new bn("v3 api not supported. Fall back to v2",{ok:o.ok,status:o.status,statusText:o.statusText,headers:wn(o.headers)});if(i<ne(this,Ht,"f"))return await ne(this,rr,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw new bn(c,{ok:o.ok,status:o.status,statusText:o.statusText,headers:wn(o.headers)})}});var Z0,X0=he(()=>{yt();(function(t){t.Error="err",t.GetPrincipal="gp",t.GetPrincipalResponse="gpr",t.Query="q",t.QueryResponse="qr",t.Call="c",t.CallResponse="cr",t.ReadState="rs",t.ReadStateResponse="rsr",t.Status="s",t.StatusResponse="sr"})(Z0||(Z0={}))});function hc(){let t=typeof window>"u"?typeof globalThis>"u"?typeof self>"u"?void 0:self.ic.agent:globalThis.ic.agent:window.ic.agent;if(!t)throw new Error("No Agent could be found.");return t}var li=he(()=>{Io();lc();Aa();X0()});yt();yt();var xo=(t,e)=>{let r;return(...n)=>{let i=()=>t(...n);r&&clearTimeout(r),r=setTimeout(i,e!==void 0&&e>0?e:300)}},$r=t=>t==null,wr=t=>!$r(t),th=class extends Error{},_o=(t,e)=>{if($r(t))throw new th(e)};var rh=" daum[ /]| deusu/| yadirectfetcher|(?:^|[^g])news|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bot(?:[^\\w]|_|$)|(?<!(?: ya| yandex|^job|inapp;) ?)search|(?<!(?:lib))http|(?<![hg]m)score|(?<!android|ios)@|\\(\\)|\\.com|^12345|^<|^[\\w \\.\\-\\(?:\\):]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[^ ]{50,}$|^\\w+/[\\w\\(\\)]*$|^active|^ad muncher|^amaya|^avsdevicesdk/|^biglotron|^bot|^bw/|^clamav[ /]|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d \\(compatible;?\\)$|^mozilla/\\d\\.\\d \\w*$|^navermailapp|^netsurf|^offline explorer|^postman|^python|^rank|^read|^reed|^rest|^serf|^snapchat|^space bison|^svn|^swcd |^taringa|^thumbor/|^track|^valid|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|^{{.*}}$|analyzer|archive|ask jeeves/teoma|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check|chrome-lighthouse|chromeframe|classifier|cloud|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|feed|firephp|gomezagent|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|images|insight|inspect|iplabel|ips-agent|java(?!;)|library|mail\\.ru/|manager|measure|neustar wpm|node|nutch|offbyone|optimize|pageburst|parser|perl|phantomjs|pingdom|powermarks|preview|proxy|ptst[ /]\\d|reputation|resolver|retriever|rexx;|rigor|robot|rss|scan|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|trace|transcoder|url|virtuoso|wappalyzer|watch|webglance|webkit2png|whatcms/|zgrab",nh=/bot|spider|crawl|http|lighthouse/i,kn;function ih(){if(kn instanceof RegExp)return kn;try{kn=new RegExp(rh,"i")}catch{kn=nh}return kn}function $c(t){return!!t&&ih().test(t)}var Vc=({IDL:t})=>{let e=t.Record({controllers:t.Vec(t.Principal)}),r=t.Variant({Write:t.Null,Admin:t.Null}),n=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:r,expires_at:t.Opt(t.Nat64)}),i=t.Record({version:t.Opt(t.Nat64)}),s=t.Record({cycles:t.Nat,destination_id:t.Principal}),o=t.Record({to:t.Opt(t.Nat64),from:t.Opt(t.Nat64),satellite_id:t.Opt(t.Principal)}),a=t.Record({key:t.Text,collected_at:t.Nat64}),c=t.Record({inner_height:t.Nat16,inner_width:t.Nat16}),l=t.Record({title:t.Text,updated_at:t.Nat64,referrer:t.Opt(t.Text),time_zone:t.Text,session_id:t.Text,href:t.Text,created_at:t.Nat64,satellite_id:t.Principal,device:c,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),h=t.Record({safari:t.Float64,opera:t.Float64,others:t.Float64,firefox:t.Float64,chrome:t.Float64}),d=t.Record({desktop:t.Float64,others:t.Float64,mobile:t.Float64}),w=t.Record({browsers:h,devices:d}),b=t.Record({day:t.Nat8,month:t.Nat8,year:t.Int32}),f=t.Record({bounce_rate:t.Float64,average_page_views_per_session:t.Float64,daily_total_page_views:t.Vec(t.Tuple(b,t.Nat32)),total_page_views:t.Nat32,unique_page_views:t.Nat64,unique_sessions:t.Nat64}),S=t.Record({referrers:t.Vec(t.Tuple(t.Text,t.Nat32)),pages:t.Vec(t.Tuple(t.Text,t.Nat32))}),R=t.Variant({Navigate:t.Null,Restore:t.Null,Reload:t.Null,BackForward:t.Null,BackForwardCache:t.Null,Prerender:t.Null}),O=t.Record({id:t.Text,value:t.Float64,navigation_type:t.Opt(R),delta:t.Float64}),V=t.Variant({WebVitalsMetric:O}),q=t.Variant({CLS:t.Null,FCP:t.Null,INP:t.Null,LCP:t.Null,TTFB:t.Null}),Y=t.Record({updated_at:t.Nat64,session_id:t.Text,data:V,href:t.Text,metric_name:q,created_at:t.Nat64,satellite_id:t.Principal,version:t.Opt(t.Nat64)}),E=t.Record({cls:t.Opt(t.Float64),fcp:t.Opt(t.Float64),inp:t.Opt(t.Float64),lcp:t.Opt(t.Float64),ttfb:t.Opt(t.Float64)}),H=t.Record({overall:E,pages:t.Vec(t.Tuple(t.Text,E))}),z=t.Record({updated_at:t.Nat64,session_id:t.Text,metadata:t.Opt(t.Vec(t.Tuple(t.Text,t.Text))),name:t.Text,created_at:t.Nat64,satellite_id:t.Principal,version:t.Opt(t.Nat64)}),Z=t.Record({total:t.Vec(t.Tuple(t.Text,t.Nat32))}),C=t.Record({performance_metrics:t.Bool,track_events:t.Bool,page_views:t.Bool}),ie=t.Record({updated_at:t.Nat64,features:t.Opt(C),created_at:t.Nat64,version:t.Opt(t.Nat64)}),re=t.Record({stable:t.Nat64,heap:t.Nat64}),ee=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:r,expires_at:t.Opt(t.Nat64)}),g=t.Record({controller:ee,controllers:t.Vec(t.Principal)}),B=t.Record({title:t.Text,updated_at:t.Opt(t.Nat64),referrer:t.Opt(t.Text),time_zone:t.Text,session_id:t.Text,href:t.Text,satellite_id:t.Principal,device:c,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),$=t.Variant({Ok:l,Err:t.Text}),F=t.Variant({Ok:t.Null,Err:t.Vec(t.Tuple(a,t.Text))}),U=t.Record({session_id:t.Text,data:V,href:t.Text,metric_name:q,satellite_id:t.Principal,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),G=t.Variant({Ok:Y,Err:t.Text}),J=t.Record({features:t.Opt(C),version:t.Opt(t.Nat64)}),fe=t.Record({updated_at:t.Opt(t.Nat64),session_id:t.Text,metadata:t.Opt(t.Vec(t.Tuple(t.Text,t.Text))),name:t.Text,satellite_id:t.Principal,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),ce=t.Variant({Ok:z,Err:t.Text});return t.Service({del_controllers:t.Func([e],[t.Vec(t.Tuple(t.Principal,n))],[]),del_satellite_config:t.Func([t.Principal,i],[],[]),deposit_cycles:t.Func([s],[],[]),get_page_views:t.Func([o],[t.Vec(t.Tuple(a,l))],["query"]),get_page_views_analytics_clients:t.Func([o],[w],["query"]),get_page_views_analytics_metrics:t.Func([o],[f],["query"]),get_page_views_analytics_top_10:t.Func([o],[S],["query"]),get_performance_metrics:t.Func([o],[t.Vec(t.Tuple(a,Y))],["query"]),get_performance_metrics_analytics_web_vitals:t.Func([o],[H],["query"]),get_track_events:t.Func([o],[t.Vec(t.Tuple(a,z))],["query"]),get_track_events_analytics:t.Func([o],[Z],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,n))],["query"]),list_satellite_configs:t.Func([],[t.Vec(t.Tuple(t.Principal,ie))],["query"]),memory_size:t.Func([],[re],["query"]),set_controllers:t.Func([g],[t.Vec(t.Tuple(t.Principal,n))],[]),set_page_view:t.Func([a,B],[$],[]),set_page_views:t.Func([t.Vec(t.Tuple(a,B))],[F],[]),set_performance_metric:t.Func([a,U],[G],[]),set_performance_metrics:t.Func([t.Vec(t.Tuple(a,U))],[F],[]),set_satellite_configs:t.Func([t.Vec(t.Tuple(t.Principal,J))],[t.Vec(t.Tuple(t.Principal,ie))],[]),set_track_event:t.Func([a,fe],[ce],[]),set_track_events:t.Func([t.Vec(t.Tuple(a,fe))],[F],[]),version:t.Func([],[t.Text],["query"])})};var nl=tn(ou());li();fn();zn();li();Bn();lt();var ao={};Un(ao,{backoff:()=>D0,chain:()=>el,conditionalDelay:()=>Q0,defaultStrategy:()=>oo,maxAttempts:()=>Hm,once:()=>J0,throttle:()=>Gm,timeout:()=>L0});lt();var jm=5*60*1e3;function oo(){return el(Q0(J0(),1e3),D0(1e3,1.2),L0(jm))}function J0(){let t=!0;return async()=>t?(t=!1,!0):!1}function Q0(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(s=>setTimeout(s,e))}}function Hm(t){let e=t;return async(r,n,i)=>{if(--e<=0)throw new Error(`Failed to retrieve a reply for request after ${t} attempts:
27
+ `;if(o.status===404&&o.url.includes("api/v3"))throw new wn("v3 api not supported. Fall back to v2",{ok:o.ok,status:o.status,statusText:o.statusText,headers:gn(o.headers)});if(i<ne(this,Ht,"f"))return await ne(this,rr,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw new wn(c,{ok:o.ok,status:o.status,statusText:o.statusText,headers:gn(o.headers)})}});var W0,Z0=he(()=>{yt();(function(t){t.Error="err",t.GetPrincipal="gp",t.GetPrincipalResponse="gpr",t.Query="q",t.QueryResponse="qr",t.Call="c",t.CallResponse="cr",t.ReadState="rs",t.ReadStateResponse="rsr",t.Status="s",t.StatusResponse="sr"})(W0||(W0={}))});function lc(){let t=typeof window>"u"?typeof globalThis>"u"?typeof self>"u"?void 0:self.ic.agent:globalThis.ic.agent:window.ic.agent;if(!t)throw new Error("No Agent could be found.");return t}var li=he(()=>{Uo();fc();Ba();Z0()});yt();var rl=tn(su());li();fn();Yn();li();vn();lt();var co={};In(co,{backoff:()=>L0,chain:()=>D0,conditionalDelay:()=>J0,defaultStrategy:()=>ao,maxAttempts:()=>V1,once:()=>X0,throttle:()=>j1,timeout:()=>Q0});lt();var $1=5*60*1e3;function ao(){return D0(J0(X0(),1e3),L0(1e3,1.2),Q0($1))}function X0(){let t=!0;return async()=>t?(t=!1,!0):!1}function J0(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(s=>setTimeout(s,e))}}function V1(t){let e=t;return async(r,n,i)=>{if(--e<=0)throw new Error(`Failed to retrieve a reply for request after ${t} attempts:
28
28
  Request ID: ${Me(n)}
29
29
  Request status: ${i}
30
- `)}}function Gm(t){return()=>new Promise(e=>setTimeout(e,t))}function L0(t){let e=Date.now()+t;return async(r,n,i)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
30
+ `)}}function j1(t){return()=>new Promise(e=>setTimeout(e,t))}function Q0(t){let e=Date.now()+t;return async(r,n,i)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
31
31
  Request ID: ${Me(n)}
32
32
  Request status: ${i}
33
- `)}}function D0(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}function el(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}uc();async function dc(t,e,r,n=oo(),i,s){var o;let a=[new TextEncoder().encode("request_status"),r],c=i??await((o=t.createReadStateRequest)===null||o===void 0?void 0:o.call(t,{paths:[a]}));c.body.content.ingress_expiry=new Qt(3e5);let l=await t.readState(e,{paths:[a]},void 0,c);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let h=await Ur.create({certificate:l.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:s}),d=ot(h.lookup([...a,new TextEncoder().encode("status")])),w;switch(typeof d>"u"?w=nr.Unknown:w=new TextDecoder().decode(d),w){case nr.Replied:return{reply:ot(h.lookup([...a,"reply"])),certificate:h};case nr.Received:case nr.Unknown:case nr.Processing:return await n(e,r,w),dc(t,e,r,n,c,s);case nr.Rejected:{let b=new Uint8Array(ot(h.lookup([...a,"reject_code"])))[0],f=new TextDecoder().decode(ot(h.lookup([...a,"reject_message"])));throw new Error(`Call was rejected:
33
+ `)}}function L0(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}function D0(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}cc();async function hc(t,e,r,n=ao(),i,s){var o;let a=[new TextEncoder().encode("request_status"),r],c=i??await((o=t.createReadStateRequest)===null||o===void 0?void 0:o.call(t,{paths:[a]}));c.body.content.ingress_expiry=new Qt(3e5);let l=await t.readState(e,{paths:[a]},void 0,c);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let h=await Fr.create({certificate:l.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:s}),d=ot(h.lookup([...a,new TextEncoder().encode("status")])),w;switch(typeof d>"u"?w=nr.Unknown:w=new TextDecoder().decode(d),w){case nr.Replied:return{reply:ot(h.lookup([...a,"reply"])),certificate:h};case nr.Received:case nr.Unknown:case nr.Processing:return await n(e,r,w),hc(t,e,r,n,c,s);case nr.Rejected:{let b=new Uint8Array(ot(h.lookup([...a,"reject_code"])))[0],f=new TextDecoder().decode(ot(h.lookup([...a,"reject_message"])));throw new Error(`Call was rejected:
34
34
  Request ID: ${Me(r)}
35
35
  Reject code: ${b}
36
36
  Reject text: ${f}
37
37
  `)}case nr.Done:throw new Error(`Call was marked as done but we never saw the reply:
38
38
  Request ID: ${Me(r)}
39
- `)}throw new Error("unreachable")}yt();lt();Bn();var tl=({IDL:t})=>{let e=t.Variant({mainnet:t.Null,testnet:t.Null}),r=t.Text,n=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,s=i,o=t.Record({network:e}),a=t.Nat64,c=t.Vec(a),l=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),h=t.Vec(t.Nat8),d=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),w=t.Record({height:t.Nat32,value:i,outpoint:d}),b=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:h,utxos:t.Vec(w)}),f=t.Record({transaction:t.Vec(t.Nat8),network:e}),S=t.Principal,R=t.Record({canister_id:S,num_requested_changes:t.Opt(t.Nat64)}),O=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),V=t.Variant({creation:t.Record({controllers:t.Vec(t.Principal)}),code_deployment:t.Record({mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),module_hash:t.Vec(t.Nat8)}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),q=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:O,details:V}),Y=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(q),total_num_changes:t.Nat64}),E=t.Record({canister_id:S}),H=t.Variant({controllers:t.Null,public:t.Null}),z=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:H,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),Z=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:z,query_stats:t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),C=t.Record({canister_id:S}),ie=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt(H),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),re=t.Record({settings:t.Opt(ie),sender_canister_version:t.Opt(t.Nat64)}),ee=t.Record({canister_id:S}),g=t.Record({canister_id:S}),B=t.Record({canister_id:S}),$=t.Variant({secp256k1:t.Null}),F=t.Record({key_id:t.Record({name:t.Text,curve:$}),canister_id:t.Opt(S),derivation_path:t.Vec(t.Vec(t.Nat8))}),U=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),G=t.Record({canister_id:S}),J=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),fe=t.Record({canister_log_records:t.Vec(J)}),ce=t.Record({value:t.Text,name:t.Text}),W=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(ce)}),P=t.Record({url:t.Text,method:t.Variant({get:t.Null,head:t.Null,post:t.Null}),max_response_bytes:t.Opt(t.Nat64),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Record({function:t.Func([t.Record({context:t.Vec(t.Nat8),response:W})],[W],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(ce)}),m=t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({wasm_memory_persistence:t.Opt(t.Variant({keep:t.Null,replace:t.Null})),skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),L=t.Record({hash:t.Vec(t.Nat8)}),te=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:m,chunk_hashes_list:t.Vec(L),target_canister:S,store_canister:t.Opt(S),sender_canister_version:t.Opt(t.Nat64)}),le=t.Vec(t.Nat8),D=t.Record({arg:t.Vec(t.Nat8),wasm_module:le,mode:m,canister_id:S,sender_canister_version:t.Opt(t.Nat64)}),u=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),p=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_proposed_total:t.Nat64}),y=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(p)})),T=t.Record({settings:t.Opt(ie),specified_id:t.Opt(S),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),v=t.Record({canister_id:S}),A=t.Record({canister_id:S,amount:t.Nat}),M=t.Vec(t.Nat8),x=t.Variant({ed25519:t.Null,bip340secp256k1:t.Null}),N=t.Record({key_id:t.Record({algorithm:x,name:t.Text}),canister_id:t.Opt(S),derivation_path:t.Vec(t.Vec(t.Nat8))}),k=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),I=t.Record({key_id:t.Record({name:t.Text,curve:$}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),K=t.Record({signature:t.Vec(t.Nat8)}),Q=t.Record({key_id:t.Record({algorithm:x,name:t.Text}),derivation_path:t.Vec(t.Vec(t.Nat8)),message:t.Vec(t.Nat8)}),oe=t.Record({signature:t.Vec(t.Nat8)}),ye=t.Record({canister_id:S}),ve=t.Record({canister_id:S}),Se=t.Record({canister_id:S}),me=t.Vec(L),ae=t.Record({canister_id:S,sender_canister_version:t.Opt(t.Nat64)}),ke=t.Record({canister_id:t.Principal,settings:ie,sender_canister_version:t.Opt(t.Nat64)}),Gt=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),ir=L;return t.Service({bitcoin_get_balance:t.Func([n],[s],[]),bitcoin_get_current_fee_percentiles:t.Func([o],[c],[]),bitcoin_get_utxos:t.Func([l],[b],[]),bitcoin_send_transaction:t.Func([f],[],[]),canister_info:t.Func([R],[Y],[]),canister_status:t.Func([E],[Z],[]),clear_chunk_store:t.Func([C],[],[]),create_canister:t.Func([re],[ee],[]),delete_canister:t.Func([g],[],[]),deposit_cycles:t.Func([B],[],[]),ecdsa_public_key:t.Func([F],[U],[]),fetch_canister_logs:t.Func([G],[fe],["query"]),http_request:t.Func([P],[W],[]),install_chunked_code:t.Func([te],[],[]),install_code:t.Func([D],[],[]),node_metrics_history:t.Func([u],[y],[]),provisional_create_canister_with_cycles:t.Func([T],[v],[]),provisional_top_up_canister:t.Func([A],[],[]),raw_rand:t.Func([],[M],[]),schnorr_public_key:t.Func([N],[k],[]),sign_with_ecdsa:t.Func([I],[K],[]),sign_with_schnorr:t.Func([Q],[oe],[]),start_canister:t.Func([ye],[],[]),stop_canister:t.Func([ve],[],[]),stored_chunks:t.Func([Se],[me],[]),uninstall_code:t.Func([ae],[],[]),update_settings:t.Func([ke],[],[]),upload_chunk:t.Func([Gt],[ir],[])})};var co=class extends Pe{constructor(e,r,n,i){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(s=>` "${s}": ${JSON.stringify(i[s])}`)].join(`
40
- `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}},pc=class extends co{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=Cn[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},uo=class extends co{constructor(e,r,n,i,s,o,a){super(e,r,"update",Object.assign({"Request ID":Me(n)},i.body?Object.assign(Object.assign({},a?{"Error code":a}:{}),{"Reject code":String(s),"Reject message":o}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.reject_code=s,this.reject_message=o,this.error_code=a}},St=Symbol.for("ic-agent-metadata"),Dr=class t{constructor(e){this[St]=Object.freeze(e)}static agentOf(e){return e[St].config.agent}static interfaceOf(e){return e[St].service}static canisterIdOf(e){return de.from(e[St].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],s=[...new Uint8Array(e.module)],o=typeof r.canisterId=="string"?de.fromText(r.canisterId):r.canisterId;await rl(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,sender_canister_version:[]})}static async createCanister(e,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await rl(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:vr});class i extends t{constructor(o){if(!o.canisterId)throw new Pe(`Canister ID is required, but received ${typeof o.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof o.canisterId=="string"?de.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},il),o),{canisterId:a}),service:n});for(let[c,l]of n._fields)r?.httpDetails&&l.annotations.push(mc),r?.certificate&&l.annotations.push(sl),this[c]=zm(this,c,l,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Pe(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}static createActorWithExtendedDetails(e,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(e,n))(r)}};function On(t,e){let r=vr.decode(t,nl.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var il={pollingStrategyFactory:ao.defaultStrategy},mc="http-details",sl="certificate";function zm(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,l;o=Object.assign(Object.assign({},o),(l=(c=t[St].config).queryTransform)===null||l===void 0?void 0:l.call(c,e,a,Object.assign(Object.assign({},t[St].config),o)));let h=o.agent||t[St].config.agent||hc(),d=de.from(o.canisterId||t[St].config.canisterId),w=vr.encode(r.argTypes,a),b=await h.query(d,{methodName:e,arg:w,effectiveCanisterId:o.effectiveCanisterId}),f=Object.assign(Object.assign({},b.httpDetails),{requestDetails:b.requestDetails});switch(b.status){case"rejected":throw new pc(d,e,b);case"replied":return r.annotations.includes(mc)?{httpDetails:f,result:On(r.retTypes,b.reply.arg)}:On(r.retTypes,b.reply.arg)}}:i=async(o,...a)=>{var c,l;o=Object.assign(Object.assign({},o),(l=(c=t[St].config).callTransform)===null||l===void 0?void 0:l.call(c,e,a,Object.assign(Object.assign({},t[St].config),o)));let h=o.agent||t[St].config.agent||hc(),{canisterId:d,effectiveCanisterId:w,pollingStrategyFactory:b}=Object.assign(Object.assign(Object.assign({},il),t[St].config),o),f=de.from(d),S=w!==void 0?de.from(w):f,R=vr.encode(r.argTypes,a);if(h.rootKey==null)throw new Pe("Agent root key not initialized before making call");let{requestId:O,response:V,requestDetails:q}=await h.call(f,{methodName:e,arg:R,effectiveCanisterId:S}),Y,E;if(V.body&&V.body.certificate){let C=V.body.certificate;E=await Ur.create({certificate:Vn(C),rootKey:h.rootKey,canisterId:de.from(d),blsVerify:n});let ie=[new TextEncoder().encode("request_status"),O];switch(new TextDecoder().decode(ot(E.lookup([...ie,"status"])))){case"replied":Y=ot(E.lookup([...ie,"reply"]));break;case"rejected":{let ee=new Uint8Array(ot(E.lookup([...ie,"reject_code"])))[0],g=new TextDecoder().decode(ot(E.lookup([...ie,"reject_message"]))),B=ot(E.lookup([...ie,"error_code"])),$=B?new TextDecoder().decode(B):void 0;throw new uo(f,e,O,V,ee,g,$)}}}else if(V.body&&"reject_message"in V.body){let{reject_code:C,reject_message:ie,error_code:re}=V.body;throw new uo(f,e,O,V,C,ie,re)}if(V.status===202){let C=b(),ie=await dc(h,S,O,C,n);E=ie.certificate,Y=ie.reply}let H=r.annotations.includes(mc),z=r.annotations.includes(sl),Z=Object.assign(Object.assign({},V),{requestDetails:q});if(Y!==void 0)return H&&z?{httpDetails:Z,certificate:E,result:On(r.retTypes,Y)}:z?{certificate:E,result:On(r.retTypes,Y)}:H?{httpDetails:Z,result:On(r.retTypes,Y)}:On(r.retTypes,Y);if(r.retTypes.length===0)return H?{httpDetails:V,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let s=(...o)=>i({},...o);return s.withOptions=o=>(...a)=>i(o,...a),s}function rl(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:de.from(t.effectiveCanisterId)};let i=n[0],s=de.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(s=de.from(i.canister_id)),{effectiveCanisterId:s}}return Dr.createActor(tl,Object.assign(Object.assign(Object.assign({},t),{canisterId:de.fromHex("")}),{callTransform:e,queryTransform:e}))}li();_s();ti();da();Bn();oc();yt();hi();lc();ac();Qn();Ja();lt();va();hi();Dn();var ol=async({orbiterId:t,idlFactory:e,container:r})=>{let n=wr(r)&&r!==!1,i=n?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io",s=await xi.create({identity:new yn,host:i,shouldFetchRootKey:n});return Dr.createActor(e,{agent:s,canisterId:t})};var fo=t=>ol({idlFactory:Vc,...t});function _i(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function Ei(t,e){let r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);let n=_i(r);return(i,s)=>n.then(o=>s(o.transaction(e,i).objectStore(e)))}var yc;function al(){return yc||(yc=Ei("keyval-store","keyval")),yc}function lo(t,e=al()){return e("readwrite",r=>(t.forEach(n=>r.delete(n)),_i(r.transaction)))}function Km(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},_i(t.transaction)}function ho(t=al()){return t("readonly",e=>{if(e.getAll&&e.getAllKeys)return Promise.all([_i(e.getAllKeys()),_i(e.getAll())]).then(([n,i])=>n.map((s,o)=>[s,i[o]]));let r=[];return t("readonly",n=>Km(n,i=>r.push([i.key,i.value])).then(()=>r))})}var cl=Ei("juno-views","views"),ul=Ei("juno-events","events"),fl=Ei("juno-metrics","metrics");var ll=()=>ho(cl),hl=t=>lo(t,cl);var dl=()=>ho(ul),pl=t=>lo(t,ul);var ml=()=>ho(fl),yl=t=>lo(t,fl);onmessage=async({data:t})=>{let{msg:e,data:r}=t;switch(e){case"junoInitEnvironment":Xm(r);return;case"junoTrackPageView":t1();return;case"junoTrackEvent":r1();return;case"junoStartTrackTimer":await Qm();return;case"junoStopTracker":await Jm();return}};var Wm="Analytics worker not initialized. Did you set `satelliteId`?",Zm="Analytics worker not initialized. Did you set `orbiterId`?",mt,Xm=t=>{let{orbiterId:e,satelliteId:r}=t;_o(e,Zm),_o(r,Wm),mt=t},vi,xc=async()=>await Promise.all([gl(),wl(),e1()]),Jm=async()=>{await xc(),wr(vi)&&(clearInterval(vi),vi=void 0),self.close()},Qm=async()=>{wr(vi)||(await xc(),vi=setInterval(xc,mt?.worker?.timerInterval??1e3))},gc=!1,wc=!1,bc=!1,gl=async()=>{if(!Bi(mt)||gc)return;let t=await ll();if(!($r(t)||t.length===0)){gc=!0;try{let r=await(await fo(mt)).set_page_views(t.map(([n,{collected_at:i,...s}])=>[_c({key:n,collected_at:i}),{...s,...Ec(mt)}]));await hl(t.map(([n,i])=>n)),vc(r)}catch(e){console.error(e)}gc=!1}},Lm=xo(async()=>await gl(),100),wl=async()=>{if(!Bi(mt)||wc)return;let t=await dl();if(!($r(t)||t.length===0)){wc=!0;try{let e=await fo(mt),r=({metadata:i,...s})=>({metadata:$r(i)?[]:[Object.entries(i??{})],...s,...Ec(mt)}),n=await e.set_track_events(t.map(([i,{collected_at:s,...o}])=>[_c({key:i,collected_at:s}),r(o)]));await pl(t.map(([i,s])=>i)),vc(n)}catch(e){console.error(e)}wc=!1}},Dm=xo(async()=>await wl(),250),e1=async()=>{if(!Bi(mt)||mt?.options?.performance===!1||bc)return;let t=await ml();if(!($r(t)||t.length===0)){bc=!0;try{let r=await(await fo(mt)).set_performance_metrics(t.map(([n,{collected_at:i,...s}])=>[_c({key:n,collected_at:i}),{...s,...Ec(mt)}]));await yl(t.map(([n,i])=>n)),vc(r)}catch(e){console.error(e)}bc=!1}},t1=()=>{Bi(mt)&&(bl()||Lm())},r1=()=>{Bi(mt)&&(bl()||Dm())},_c=({key:t,collected_at:e})=>({collected_at:e,key:t}),Ec=t=>({satellite_id:de.fromText(t.satelliteId)}),bl=()=>{let{userAgent:t}=navigator;return wr(t)?$c(t):!1},Bi=t=>t!=null&&wr(t.orbiterId)&&wr(t.satelliteId),vc=t=>{"Ok"in t||t.Err.forEach(([e,r])=>console.warn(`${r} [Key: ${e.key}]`))};})();
39
+ `)}throw new Error("unreachable")}yt();lt();vn();var el=({IDL:t})=>{let e=t.Variant({mainnet:t.Null,testnet:t.Null}),r=t.Text,n=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,s=i,o=t.Record({network:e}),a=t.Nat64,c=t.Vec(a),l=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),h=t.Vec(t.Nat8),d=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),w=t.Record({height:t.Nat32,value:i,outpoint:d}),b=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:h,utxos:t.Vec(w)}),f=t.Record({transaction:t.Vec(t.Nat8),network:e}),S=t.Principal,R=t.Record({canister_id:S,num_requested_changes:t.Opt(t.Nat64)}),O=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),V=t.Variant({creation:t.Record({controllers:t.Vec(t.Principal)}),code_deployment:t.Record({mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),module_hash:t.Vec(t.Nat8)}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),q=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:O,details:V}),z=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(q),total_num_changes:t.Nat64}),E=t.Record({canister_id:S}),H=t.Variant({controllers:t.Null,public:t.Null}),Y=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:H,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),Z=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:Y,query_stats:t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),C=t.Record({canister_id:S}),ie=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt(H),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),re=t.Record({settings:t.Opt(ie),sender_canister_version:t.Opt(t.Nat64)}),ee=t.Record({canister_id:S}),g=t.Record({canister_id:S}),B=t.Record({canister_id:S}),$=t.Variant({secp256k1:t.Null}),F=t.Record({key_id:t.Record({name:t.Text,curve:$}),canister_id:t.Opt(S),derivation_path:t.Vec(t.Vec(t.Nat8))}),U=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),G=t.Record({canister_id:S}),J=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),fe=t.Record({canister_log_records:t.Vec(J)}),ce=t.Record({value:t.Text,name:t.Text}),W=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(ce)}),P=t.Record({url:t.Text,method:t.Variant({get:t.Null,head:t.Null,post:t.Null}),max_response_bytes:t.Opt(t.Nat64),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Record({function:t.Func([t.Record({context:t.Vec(t.Nat8),response:W})],[W],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(ce)}),m=t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({wasm_memory_persistence:t.Opt(t.Variant({keep:t.Null,replace:t.Null})),skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),L=t.Record({hash:t.Vec(t.Nat8)}),te=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:m,chunk_hashes_list:t.Vec(L),target_canister:S,store_canister:t.Opt(S),sender_canister_version:t.Opt(t.Nat64)}),le=t.Vec(t.Nat8),D=t.Record({arg:t.Vec(t.Nat8),wasm_module:le,mode:m,canister_id:S,sender_canister_version:t.Opt(t.Nat64)}),u=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),p=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_proposed_total:t.Nat64}),y=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(p)})),T=t.Record({settings:t.Opt(ie),specified_id:t.Opt(S),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),v=t.Record({canister_id:S}),A=t.Record({canister_id:S,amount:t.Nat}),M=t.Vec(t.Nat8),x=t.Variant({ed25519:t.Null,bip340secp256k1:t.Null}),N=t.Record({key_id:t.Record({algorithm:x,name:t.Text}),canister_id:t.Opt(S),derivation_path:t.Vec(t.Vec(t.Nat8))}),k=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),I=t.Record({key_id:t.Record({name:t.Text,curve:$}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),K=t.Record({signature:t.Vec(t.Nat8)}),Q=t.Record({key_id:t.Record({algorithm:x,name:t.Text}),derivation_path:t.Vec(t.Vec(t.Nat8)),message:t.Vec(t.Nat8)}),oe=t.Record({signature:t.Vec(t.Nat8)}),ye=t.Record({canister_id:S}),ve=t.Record({canister_id:S}),Se=t.Record({canister_id:S}),me=t.Vec(L),ae=t.Record({canister_id:S,sender_canister_version:t.Opt(t.Nat64)}),ke=t.Record({canister_id:t.Principal,settings:ie,sender_canister_version:t.Opt(t.Nat64)}),Gt=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),ir=L;return t.Service({bitcoin_get_balance:t.Func([n],[s],[]),bitcoin_get_current_fee_percentiles:t.Func([o],[c],[]),bitcoin_get_utxos:t.Func([l],[b],[]),bitcoin_send_transaction:t.Func([f],[],[]),canister_info:t.Func([R],[z],[]),canister_status:t.Func([E],[Z],[]),clear_chunk_store:t.Func([C],[],[]),create_canister:t.Func([re],[ee],[]),delete_canister:t.Func([g],[],[]),deposit_cycles:t.Func([B],[],[]),ecdsa_public_key:t.Func([F],[U],[]),fetch_canister_logs:t.Func([G],[fe],["query"]),http_request:t.Func([P],[W],[]),install_chunked_code:t.Func([te],[],[]),install_code:t.Func([D],[],[]),node_metrics_history:t.Func([u],[y],[]),provisional_create_canister_with_cycles:t.Func([T],[v],[]),provisional_top_up_canister:t.Func([A],[],[]),raw_rand:t.Func([],[M],[]),schnorr_public_key:t.Func([N],[k],[]),sign_with_ecdsa:t.Func([I],[K],[]),sign_with_schnorr:t.Func([Q],[oe],[]),start_canister:t.Func([ye],[],[]),stop_canister:t.Func([ve],[],[]),stored_chunks:t.Func([Se],[me],[]),uninstall_code:t.Func([ae],[],[]),update_settings:t.Func([ke],[],[]),upload_chunk:t.Func([Gt],[ir],[])})};var uo=class extends Pe{constructor(e,r,n,i){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(s=>` "${s}": ${JSON.stringify(i[s])}`)].join(`
40
+ `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}},dc=class extends uo{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=Cn[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},fo=class extends uo{constructor(e,r,n,i,s,o,a){super(e,r,"update",Object.assign({"Request ID":Me(n)},i.body?Object.assign(Object.assign({},a?{"Error code":a}:{}),{"Reject code":String(s),"Reject message":o}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.reject_code=s,this.reject_message=o,this.error_code=a}},St=Symbol.for("ic-agent-metadata"),Mr=class t{constructor(e){this[St]=Object.freeze(e)}static agentOf(e){return e[St].config.agent}static interfaceOf(e){return e[St].service}static canisterIdOf(e){return de.from(e[St].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],s=[...new Uint8Array(e.module)],o=typeof r.canisterId=="string"?de.fromText(r.canisterId):r.canisterId;await tl(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,sender_canister_version:[]})}static async createCanister(e,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await tl(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:Er});class i extends t{constructor(o){if(!o.canisterId)throw new Pe(`Canister ID is required, but received ${typeof o.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof o.canisterId=="string"?de.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},nl),o),{canisterId:a}),service:n});for(let[c,l]of n._fields)r?.httpDetails&&l.annotations.push(pc),r?.certificate&&l.annotations.push(il),this[c]=G1(this,c,l,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Pe(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}static createActorWithExtendedDetails(e,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(e,n))(r)}};function On(t,e){let r=Er.decode(t,rl.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var nl={pollingStrategyFactory:co.defaultStrategy},pc="http-details",il="certificate";function G1(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,l;o=Object.assign(Object.assign({},o),(l=(c=t[St].config).queryTransform)===null||l===void 0?void 0:l.call(c,e,a,Object.assign(Object.assign({},t[St].config),o)));let h=o.agent||t[St].config.agent||lc(),d=de.from(o.canisterId||t[St].config.canisterId),w=Er.encode(r.argTypes,a),b=await h.query(d,{methodName:e,arg:w,effectiveCanisterId:o.effectiveCanisterId}),f=Object.assign(Object.assign({},b.httpDetails),{requestDetails:b.requestDetails});switch(b.status){case"rejected":throw new dc(d,e,b);case"replied":return r.annotations.includes(pc)?{httpDetails:f,result:On(r.retTypes,b.reply.arg)}:On(r.retTypes,b.reply.arg)}}:i=async(o,...a)=>{var c,l;o=Object.assign(Object.assign({},o),(l=(c=t[St].config).callTransform)===null||l===void 0?void 0:l.call(c,e,a,Object.assign(Object.assign({},t[St].config),o)));let h=o.agent||t[St].config.agent||lc(),{canisterId:d,effectiveCanisterId:w,pollingStrategyFactory:b}=Object.assign(Object.assign(Object.assign({},nl),t[St].config),o),f=de.from(d),S=w!==void 0?de.from(w):f,R=Er.encode(r.argTypes,a);if(h.rootKey==null)throw new Pe("Agent root key not initialized before making call");let{requestId:O,response:V,requestDetails:q}=await h.call(f,{methodName:e,arg:R,effectiveCanisterId:S}),z,E;if(V.body&&V.body.certificate){let C=V.body.certificate;E=await Fr.create({certificate:Vn(C),rootKey:h.rootKey,canisterId:de.from(d),blsVerify:n});let ie=[new TextEncoder().encode("request_status"),O];switch(new TextDecoder().decode(ot(E.lookup([...ie,"status"])))){case"replied":z=ot(E.lookup([...ie,"reply"]));break;case"rejected":{let ee=new Uint8Array(ot(E.lookup([...ie,"reject_code"])))[0],g=new TextDecoder().decode(ot(E.lookup([...ie,"reject_message"]))),B=ot(E.lookup([...ie,"error_code"])),$=B?new TextDecoder().decode(B):void 0;throw new fo(f,e,O,V,ee,g,$)}}}else if(V.body&&"reject_message"in V.body){let{reject_code:C,reject_message:ie,error_code:re}=V.body;throw new fo(f,e,O,V,C,ie,re)}if(V.status===202){let C=b(),ie=await hc(h,S,O,C,n);E=ie.certificate,z=ie.reply}let H=r.annotations.includes(pc),Y=r.annotations.includes(il),Z=Object.assign(Object.assign({},V),{requestDetails:q});if(z!==void 0)return H&&Y?{httpDetails:Z,certificate:E,result:On(r.retTypes,z)}:Y?{certificate:E,result:On(r.retTypes,z)}:H?{httpDetails:Z,result:On(r.retTypes,z)}:On(r.retTypes,z);if(r.retTypes.length===0)return H?{httpDetails:V,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let s=(...o)=>i({},...o);return s.withOptions=o=>(...a)=>i(o,...a),s}function tl(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:de.from(t.effectiveCanisterId)};let i=n[0],s=de.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(s=de.from(i.canister_id)),{effectiveCanisterId:s}}return Mr.createActor(el,Object.assign(Object.assign(Object.assign({},t),{canisterId:de.fromHex("")}),{callTransform:e,queryTransform:e}))}li();Es();ti();ha();vn();sc();yt();hi();fc();oc();Qn();Xa();lt();Ea();hi();Dn();yt();var z1=(t=>(t[t.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",t[t.InvalidFormat=1]="InvalidFormat",t[t.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",t))(z1||{}),R2=BigInt(1e8);var Fn=t=>t==null,Cr=t=>!Fn(t);var Y1=class extends Error{},mc=(t,e)=>{if(t==null)throw new Y1(e)};var sl="abcdefghijklmnopqrstuvwxyz234567",xi=Object.create(null);for(let t=0;t<sl.length;t++)xi[sl[t]]=t;xi[0]=xi.o;xi[1]=xi.i;var U2=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);var yc=(t,e)=>{let r;return(...n)=>{let i=()=>t(...n);r&&clearTimeout(r),r=setTimeout(i,e!==void 0&&e>0?e:300)}};var K1=" daum[ /]| deusu/| yadirectfetcher|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?:lib))http|(?<![hg]m)score|@[a-z][\\w-]+\\.|\\(\\)|\\.com\\b|\\btime/|^<|^[\\w \\.\\-\\(?:\\):]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[^ ]{50,}$|^\\d+\\b|^\\w*search\\b|^\\w+/[\\w\\(\\)]*$|^active|^ad muncher|^amaya|^avsdevicesdk/|^biglotron|^bot|^bw/|^clamav[ /]|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^email|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^igetter/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/5\\.0\\s[a-z\\.-]+$|^mozilla/\\d\\.\\d \\(compatible;?\\)$|^mozilla/\\d\\.\\d \\w*$|^navermailapp|^netsurf|^offline|^openai/|^owler|^php|^postman|^python|^rank|^read|^reed|^rest|^rss|^snapchat|^space bison|^svn|^swcd |^taringa|^thumbor/|^track|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|^{{.*}}$|adscanner/|analyzer|archive|ask jeeves/teoma|audit|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|convertify|cookiehubscan|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|exaleadcloudview|feed|firephp|functionize|gomezagent|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|images|infrawatch|insight|inspect|iplabel|ips-agent|java(?!;)|jsjcw_scanner|library|linkcheck|mail\\.ru/|manager|measure|neustar wpm|node|nutch|offbyone|optimize|pageburst|pagespeed|parser|perl|phantomjs|pingdom|powermarks|preview|proxy|ptst[ /]\\d|reputation|resolver|retriever|rexx;|rigor|rss\\b|scanner\\.|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|trace|transcoder|url|validator|virtuoso|wappalyzer|webglance|webkit2png|whatcms/|zgrab",W1=/bot|crawl|http|lighthouse|scan|search|spider/i,_i;function Z1(){if(_i instanceof RegExp)return _i;try{_i=new RegExp(K1,"i")}catch{_i=W1}return _i}function ol(t){return!!t&&Z1().test(t)}var al=({IDL:t})=>{let e=t.Record({controllers:t.Vec(t.Principal)}),r=t.Variant({Write:t.Null,Admin:t.Null}),n=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:r,expires_at:t.Opt(t.Nat64)}),i=t.Record({version:t.Opt(t.Nat64)}),s=t.Record({cycles:t.Nat,destination_id:t.Principal}),o=t.Record({to:t.Opt(t.Nat64),from:t.Opt(t.Nat64),satellite_id:t.Opt(t.Principal)}),a=t.Record({key:t.Text,collected_at:t.Nat64}),c=t.Record({inner_height:t.Nat16,inner_width:t.Nat16}),l=t.Record({title:t.Text,updated_at:t.Nat64,referrer:t.Opt(t.Text),time_zone:t.Text,session_id:t.Text,href:t.Text,created_at:t.Nat64,satellite_id:t.Principal,device:c,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),h=t.Record({safari:t.Float64,opera:t.Float64,others:t.Float64,firefox:t.Float64,chrome:t.Float64}),d=t.Record({desktop:t.Float64,others:t.Float64,mobile:t.Float64}),w=t.Record({browsers:h,devices:d}),b=t.Record({day:t.Nat8,month:t.Nat8,year:t.Int32}),f=t.Record({bounce_rate:t.Float64,average_page_views_per_session:t.Float64,daily_total_page_views:t.Vec(t.Tuple(b,t.Nat32)),total_page_views:t.Nat32,unique_page_views:t.Nat64,unique_sessions:t.Nat64}),S=t.Record({referrers:t.Vec(t.Tuple(t.Text,t.Nat32)),pages:t.Vec(t.Tuple(t.Text,t.Nat32))}),R=t.Variant({Navigate:t.Null,Restore:t.Null,Reload:t.Null,BackForward:t.Null,BackForwardCache:t.Null,Prerender:t.Null}),O=t.Record({id:t.Text,value:t.Float64,navigation_type:t.Opt(R),delta:t.Float64}),V=t.Variant({WebVitalsMetric:O}),q=t.Variant({CLS:t.Null,FCP:t.Null,INP:t.Null,LCP:t.Null,TTFB:t.Null}),z=t.Record({updated_at:t.Nat64,session_id:t.Text,data:V,href:t.Text,metric_name:q,created_at:t.Nat64,satellite_id:t.Principal,version:t.Opt(t.Nat64)}),E=t.Record({cls:t.Opt(t.Float64),fcp:t.Opt(t.Float64),inp:t.Opt(t.Float64),lcp:t.Opt(t.Float64),ttfb:t.Opt(t.Float64)}),H=t.Record({overall:E,pages:t.Vec(t.Tuple(t.Text,E))}),Y=t.Record({updated_at:t.Nat64,session_id:t.Text,metadata:t.Opt(t.Vec(t.Tuple(t.Text,t.Text))),name:t.Text,created_at:t.Nat64,satellite_id:t.Principal,version:t.Opt(t.Nat64)}),Z=t.Record({total:t.Vec(t.Tuple(t.Text,t.Nat32))}),C=t.Record({performance_metrics:t.Bool,track_events:t.Bool,page_views:t.Bool}),ie=t.Record({updated_at:t.Nat64,features:t.Opt(C),created_at:t.Nat64,version:t.Opt(t.Nat64)}),re=t.Record({stable:t.Nat64,heap:t.Nat64}),ee=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:r,expires_at:t.Opt(t.Nat64)}),g=t.Record({controller:ee,controllers:t.Vec(t.Principal)}),B=t.Record({title:t.Text,updated_at:t.Opt(t.Nat64),referrer:t.Opt(t.Text),time_zone:t.Text,session_id:t.Text,href:t.Text,satellite_id:t.Principal,device:c,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),$=t.Variant({Ok:l,Err:t.Text}),F=t.Variant({Ok:t.Null,Err:t.Vec(t.Tuple(a,t.Text))}),U=t.Record({session_id:t.Text,data:V,href:t.Text,metric_name:q,satellite_id:t.Principal,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),G=t.Variant({Ok:z,Err:t.Text}),J=t.Record({features:t.Opt(C),version:t.Opt(t.Nat64)}),fe=t.Record({updated_at:t.Opt(t.Nat64),session_id:t.Text,metadata:t.Opt(t.Vec(t.Tuple(t.Text,t.Text))),name:t.Text,satellite_id:t.Principal,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),ce=t.Variant({Ok:Y,Err:t.Text});return t.Service({del_controllers:t.Func([e],[t.Vec(t.Tuple(t.Principal,n))],[]),del_satellite_config:t.Func([t.Principal,i],[],[]),deposit_cycles:t.Func([s],[],[]),get_page_views:t.Func([o],[t.Vec(t.Tuple(a,l))],["query"]),get_page_views_analytics_clients:t.Func([o],[w],["query"]),get_page_views_analytics_metrics:t.Func([o],[f],["query"]),get_page_views_analytics_top_10:t.Func([o],[S],["query"]),get_performance_metrics:t.Func([o],[t.Vec(t.Tuple(a,z))],["query"]),get_performance_metrics_analytics_web_vitals:t.Func([o],[H],["query"]),get_track_events:t.Func([o],[t.Vec(t.Tuple(a,Y))],["query"]),get_track_events_analytics:t.Func([o],[Z],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,n))],["query"]),list_satellite_configs:t.Func([],[t.Vec(t.Tuple(t.Principal,ie))],["query"]),memory_size:t.Func([],[re],["query"]),set_controllers:t.Func([g],[t.Vec(t.Tuple(t.Principal,n))],[]),set_page_view:t.Func([a,B],[$],[]),set_page_views:t.Func([t.Vec(t.Tuple(a,B))],[F],[]),set_performance_metric:t.Func([a,U],[G],[]),set_performance_metrics:t.Func([t.Vec(t.Tuple(a,U))],[F],[]),set_satellite_configs:t.Func([t.Vec(t.Tuple(t.Principal,J))],[t.Vec(t.Tuple(t.Principal,ie))],[]),set_track_event:t.Func([a,fe],[ce],[]),set_track_events:t.Func([t.Vec(t.Tuple(a,fe))],[F],[]),version:t.Func([],[t.Text],["query"])})};var cl=async({orbiterId:t,idlFactory:e,container:r})=>{let n=Cr(r)&&r!==!1,i=n?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io",s=await Rn.create({identity:new Yr,host:i,shouldFetchRootKey:n});return Mr.createActor(e,{agent:s,canisterId:t})};var lo=t=>cl({idlFactory:al,...t});function Ei(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function vi(t,e){let r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);let n=Ei(r);return(i,s)=>n.then(o=>s(o.transaction(e,i).objectStore(e)))}var gc;function ul(){return gc||(gc=vi("keyval-store","keyval")),gc}function ho(t,e=ul()){return e("readwrite",r=>(t.forEach(n=>r.delete(n)),Ei(r.transaction)))}function X1(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Ei(t.transaction)}function po(t=ul()){return t("readonly",e=>{if(e.getAll&&e.getAllKeys)return Promise.all([Ei(e.getAllKeys()),Ei(e.getAll())]).then(([n,i])=>n.map((s,o)=>[s,i[o]]));let r=[];return t("readonly",n=>X1(n,i=>r.push([i.key,i.value])).then(()=>r))})}var fl=vi("juno-views","views"),ll=vi("juno-events","events"),hl=vi("juno-metrics","metrics");var dl=()=>po(fl),pl=t=>ho(t,fl);var ml=()=>po(ll),yl=t=>ho(t,ll);var gl=()=>po(hl),wl=t=>ho(t,hl);onmessage=async({data:t})=>{let{msg:e,data:r}=t;switch(e){case"junoInitEnvironment":L1(r);return;case"junoTrackPageView":im();return;case"junoTrackEvent":sm();return;case"junoStartTrackTimer":await em();return;case"junoStopTracker":await D1();return}};var J1="Analytics worker not initialized. Did you set `satelliteId`?",Q1="Analytics worker not initialized. Did you set `orbiterId`?",mt,L1=t=>{let{orbiterId:e,satelliteId:r}=t;mc(e,Q1),mc(r,J1),mt=t},Bi,_c=async()=>await Promise.all([bl(),xl(),nm()]),D1=async()=>{await _c(),Cr(Bi)&&(clearInterval(Bi),Bi=void 0),self.close()},em=async()=>{Cr(Bi)||(await _c(),Bi=setInterval(_c,mt?.worker?.timerInterval??1e3))},wc=!1,bc=!1,xc=!1,bl=async()=>{if(!Ai(mt)||wc)return;let t=await dl();if(!(Fn(t)||t.length===0)){wc=!0;try{let r=await(await lo(mt)).set_page_views(t.map(([n,{collected_at:i,...s}])=>[Ec({key:n,collected_at:i}),{...s,...vc(mt)}]));await pl(t.map(([n,i])=>n)),Bc(r)}catch(e){console.error(e)}wc=!1}},tm=yc(async()=>await bl(),100),xl=async()=>{if(!Ai(mt)||bc)return;let t=await ml();if(!(Fn(t)||t.length===0)){bc=!0;try{let e=await lo(mt),r=({metadata:i,...s})=>({metadata:Fn(i)?[]:[Object.entries(i??{})],...s,...vc(mt)}),n=await e.set_track_events(t.map(([i,{collected_at:s,...o}])=>[Ec({key:i,collected_at:s}),r(o)]));await yl(t.map(([i,s])=>i)),Bc(n)}catch(e){console.error(e)}bc=!1}},rm=yc(async()=>await xl(),250),nm=async()=>{if(!Ai(mt)||mt?.options?.performance===!1||xc)return;let t=await gl();if(!(Fn(t)||t.length===0)){xc=!0;try{let r=await(await lo(mt)).set_performance_metrics(t.map(([n,{collected_at:i,...s}])=>[Ec({key:n,collected_at:i}),{...s,...vc(mt)}]));await wl(t.map(([n,i])=>n)),Bc(r)}catch(e){console.error(e)}xc=!1}},im=()=>{Ai(mt)&&(_l()||tm())},sm=()=>{Ai(mt)&&(_l()||rm())},Ec=({key:t,collected_at:e})=>({collected_at:e,key:t}),vc=t=>({satellite_id:de.fromText(t.satelliteId)}),_l=()=>{let{userAgent:t}=navigator;return Cr(t)?ol(t):!1},Ai=t=>t!=null&&Cr(t.orbiterId)&&Cr(t.satelliteId),Bc=t=>{"Ok"in t||t.Err.forEach(([e,r])=>console.warn(`${r} [Key: ${e.key}]`))};})();
41
41
  /*!
42
42
  * The buffer module from node.js, for the browser.
43
43
  *