@libp2p/peer-collections 6.0.13 → 6.0.14-c90984ec7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PPeerCollections = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PPeerCollections=(()=>{var ks=Object.create;var ze=Object.defineProperty;var Ms=Object.getOwnPropertyDescriptor;var Ds=Object.getOwnPropertyNames;var Os=Object.getPrototypeOf,Ps=Object.prototype.hasOwnProperty;var qn=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),ct=(r,t)=>{for(var e in t)ze(r,e,{get:t[e],enumerable:!0})},Fn=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ds(t))!Ps.call(r,o)&&o!==e&&ze(r,o,{get:()=>t[o],enumerable:!(n=Ms(t,o))||n.enumerable});return r};var zs=(r,t,e)=>(e=r!=null?ks(Os(r)):{},Fn(t||!r||!r.__esModule?ze(e,"default",{value:r,enumerable:!0}):e,r)),Hs=r=>Fn(ze({},"__esModule",{value:!0}),r);var xs=qn((Me,wr)=>{(function(r,t){"use strict";var e={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function n(i){if(!Array.isArray(i)&&!ArrayBuffer.isView(i))return!1;for(var l=0;l<i.length;l++)if(!Number.isInteger(i[l])||i[l]<0||i[l]>255)return!1;return!0}function o(i,l){return(i&65535)*l+(((i>>>16)*l&65535)<<16)}function s(i,l){return i<<l|i>>>32-l}function c(i){return i^=i>>>16,i=o(i,2246822507),i^=i>>>13,i=o(i,3266489909),i^=i>>>16,i}function a(i,l){i=[i[0]>>>16,i[0]&65535,i[1]>>>16,i[1]&65535],l=[l[0]>>>16,l[0]&65535,l[1]>>>16,l[1]&65535];var d=[0,0,0,0];return d[3]+=i[3]+l[3],d[2]+=d[3]>>>16,d[3]&=65535,d[2]+=i[2]+l[2],d[1]+=d[2]>>>16,d[2]&=65535,d[1]+=i[1]+l[1],d[0]+=d[1]>>>16,d[1]&=65535,d[0]+=i[0]+l[0],d[0]&=65535,[d[0]<<16|d[1],d[2]<<16|d[3]]}function f(i,l){i=[i[0]>>>16,i[0]&65535,i[1]>>>16,i[1]&65535],l=[l[0]>>>16,l[0]&65535,l[1]>>>16,l[1]&65535];var d=[0,0,0,0];return d[3]+=i[3]*l[3],d[2]+=d[3]>>>16,d[3]&=65535,d[2]+=i[2]*l[3],d[1]+=d[2]>>>16,d[2]&=65535,d[2]+=i[3]*l[2],d[1]+=d[2]>>>16,d[2]&=65535,d[1]+=i[1]*l[3],d[0]+=d[1]>>>16,d[1]&=65535,d[1]+=i[2]*l[2],d[0]+=d[1]>>>16,d[1]&=65535,d[1]+=i[3]*l[1],d[0]+=d[1]>>>16,d[1]&=65535,d[0]+=i[0]*l[3]+i[1]*l[2]+i[2]*l[1]+i[3]*l[0],d[0]&=65535,[d[0]<<16|d[1],d[2]<<16|d[3]]}function y(i,l){return l%=64,l===32?[i[1],i[0]]:l<32?[i[0]<<l|i[1]>>>32-l,i[1]<<l|i[0]>>>32-l]:(l-=32,[i[1]<<l|i[0]>>>32-l,i[0]<<l|i[1]>>>32-l])}function h(i,l){return l%=64,l===0?i:l<32?[i[0]<<l|i[1]>>>32-l,i[1]<<l]:[i[1]<<l-32,0]}function g(i,l){return[i[0]^l[0],i[1]^l[1]]}function _(i){return i=g(i,[0,i[0]>>>1]),i=f(i,[4283543511,3981806797]),i=g(i,[0,i[0]>>>1]),i=f(i,[3301882366,444984403]),i=g(i,[0,i[0]>>>1]),i}e.x86.hash32=function(i,l){if(e.inputValidation&&!n(i))return t;l=l||0;for(var d=i.length%4,x=i.length-d,p=l,m=0,u=3432918353,E=461845907,B=0;B<x;B=B+4)m=i[B]|i[B+1]<<8|i[B+2]<<16|i[B+3]<<24,m=o(m,u),m=s(m,15),m=o(m,E),p^=m,p=s(p,13),p=o(p,5)+3864292196;switch(m=0,d){case 3:m^=i[B+2]<<16;case 2:m^=i[B+1]<<8;case 1:m^=i[B],m=o(m,u),m=s(m,15),m=o(m,E),p^=m}return p^=i.length,p=c(p),p>>>0},e.x86.hash128=function(i,l){if(e.inputValidation&&!n(i))return t;l=l||0;for(var d=i.length%16,x=i.length-d,p=l,m=l,u=l,E=l,B=0,A=0,b=0,I=0,R=597399067,K=2869860233,P=951274213,O=2716044179,N=0;N<x;N=N+16)B=i[N]|i[N+1]<<8|i[N+2]<<16|i[N+3]<<24,A=i[N+4]|i[N+5]<<8|i[N+6]<<16|i[N+7]<<24,b=i[N+8]|i[N+9]<<8|i[N+10]<<16|i[N+11]<<24,I=i[N+12]|i[N+13]<<8|i[N+14]<<16|i[N+15]<<24,B=o(B,R),B=s(B,15),B=o(B,K),p^=B,p=s(p,19),p+=m,p=o(p,5)+1444728091,A=o(A,K),A=s(A,16),A=o(A,P),m^=A,m=s(m,17),m+=u,m=o(m,5)+197830471,b=o(b,P),b=s(b,17),b=o(b,O),u^=b,u=s(u,15),u+=E,u=o(u,5)+2530024501,I=o(I,O),I=s(I,18),I=o(I,R),E^=I,E=s(E,13),E+=p,E=o(E,5)+850148119;switch(B=0,A=0,b=0,I=0,d){case 15:I^=i[N+14]<<16;case 14:I^=i[N+13]<<8;case 13:I^=i[N+12],I=o(I,O),I=s(I,18),I=o(I,R),E^=I;case 12:b^=i[N+11]<<24;case 11:b^=i[N+10]<<16;case 10:b^=i[N+9]<<8;case 9:b^=i[N+8],b=o(b,P),b=s(b,17),b=o(b,O),u^=b;case 8:A^=i[N+7]<<24;case 7:A^=i[N+6]<<16;case 6:A^=i[N+5]<<8;case 5:A^=i[N+4],A=o(A,K),A=s(A,16),A=o(A,P),m^=A;case 4:B^=i[N+3]<<24;case 3:B^=i[N+2]<<16;case 2:B^=i[N+1]<<8;case 1:B^=i[N],B=o(B,R),B=s(B,15),B=o(B,K),p^=B}return p^=i.length,m^=i.length,u^=i.length,E^=i.length,p+=m,p+=u,p+=E,m+=p,u+=p,E+=p,p=c(p),m=c(m),u=c(u),E=c(E),p+=m,p+=u,p+=E,m+=p,u+=p,E+=p,("00000000"+(p>>>0).toString(16)).slice(-8)+("00000000"+(m>>>0).toString(16)).slice(-8)+("00000000"+(u>>>0).toString(16)).slice(-8)+("00000000"+(E>>>0).toString(16)).slice(-8)},e.x64.hash128=function(i,l){if(e.inputValidation&&!n(i))return t;l=l||0;for(var d=i.length%16,x=i.length-d,p=[0,l],m=[0,l],u=[0,0],E=[0,0],B=[2277735313,289559509],A=[1291169091,658871167],b=0;b<x;b=b+16)u=[i[b+4]|i[b+5]<<8|i[b+6]<<16|i[b+7]<<24,i[b]|i[b+1]<<8|i[b+2]<<16|i[b+3]<<24],E=[i[b+12]|i[b+13]<<8|i[b+14]<<16|i[b+15]<<24,i[b+8]|i[b+9]<<8|i[b+10]<<16|i[b+11]<<24],u=f(u,B),u=y(u,31),u=f(u,A),p=g(p,u),p=y(p,27),p=a(p,m),p=a(f(p,[0,5]),[0,1390208809]),E=f(E,A),E=y(E,33),E=f(E,B),m=g(m,E),m=y(m,31),m=a(m,p),m=a(f(m,[0,5]),[0,944331445]);switch(u=[0,0],E=[0,0],d){case 15:E=g(E,h([0,i[b+14]],48));case 14:E=g(E,h([0,i[b+13]],40));case 13:E=g(E,h([0,i[b+12]],32));case 12:E=g(E,h([0,i[b+11]],24));case 11:E=g(E,h([0,i[b+10]],16));case 10:E=g(E,h([0,i[b+9]],8));case 9:E=g(E,[0,i[b+8]]),E=f(E,A),E=y(E,33),E=f(E,B),m=g(m,E);case 8:u=g(u,h([0,i[b+7]],56));case 7:u=g(u,h([0,i[b+6]],48));case 6:u=g(u,h([0,i[b+5]],40));case 5:u=g(u,h([0,i[b+4]],32));case 4:u=g(u,h([0,i[b+3]],24));case 3:u=g(u,h([0,i[b+2]],16));case 2:u=g(u,h([0,i[b+1]],8));case 1:u=g(u,[0,i[b]]),u=f(u,B),u=y(u,31),u=f(u,A),p=g(p,u)}return p=g(p,[0,i.length]),m=g(m,[0,i.length]),p=a(p,m),m=a(m,p),p=_(p),m=_(m),p=a(p,m),m=a(m,p),("00000000"+(p[0]>>>0).toString(16)).slice(-8)+("00000000"+(p[1]>>>0).toString(16)).slice(-8)+("00000000"+(m[0]>>>0).toString(16)).slice(-8)+("00000000"+(m[1]>>>0).toString(16)).slice(-8)},typeof Me<"u"?(typeof wr<"u"&&wr.exports&&(Me=wr.exports=e),Me.murmurHash3=e):typeof define=="function"&&define.amd?define([],function(){return e}):(e._murmurHash3=r.murmurHash3,e.noConflict=function(){return r.murmurHash3=e._murmurHash3,e._murmurHash3=t,e.noConflict=t,e},r.murmurHash3=e)})(Me)});var bs=qn((P0,gs)=>{gs.exports=xs()});var Ra={};ct(Ra,{PeerFilter:()=>Pe,PeerList:()=>Zt,PeerMap:()=>Ft,PeerSet:()=>Vt,peerFilter:()=>_s,peerList:()=>ms,peerMap:()=>ds,peerSet:()=>ps,trackedPeerList:()=>vs,trackedPeerMap:()=>Ss,trackedPeerSet:()=>Bs});var _r=Symbol.for("@libp2p/peer-id");var ge=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},He=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Ke=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var be=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Ir={};ct(Ir,{base58btc:()=>X,base58flickr:()=>Gs});var Ua=new Uint8Array(0);function Vn(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function _t(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Zn(r){return new TextEncoder().encode(r)}function Gn(r){return new TextDecoder().decode(r)}function Ks(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),c=s.charCodeAt(0);if(e[c]!==255)throw new TypeError(s+" is ambiguous");e[c]=o}var a=r.length,f=r.charAt(0),y=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function g(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var d=0,x=0,p=0,m=l.length;p!==m&&l[p]===0;)p++,d++;for(var u=(m-p)*h+1>>>0,E=new Uint8Array(u);p!==m;){for(var B=l[p],A=0,b=u-1;(B!==0||A<x)&&b!==-1;b--,A++)B+=256*E[b]>>>0,E[b]=B%a>>>0,B=B/a>>>0;if(B!==0)throw new Error("Non-zero carry");x=A,p++}for(var I=u-x;I!==u&&E[I]===0;)I++;for(var R=f.repeat(d);I<u;++I)R+=r.charAt(E[I]);return R}function _(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var d=0;if(l[d]!==" "){for(var x=0,p=0;l[d]===f;)x++,d++;for(var m=(l.length-d)*y+1>>>0,u=new Uint8Array(m);l[d];){var E=e[l.charCodeAt(d)];if(E===255)return;for(var B=0,A=m-1;(E!==0||B<p)&&A!==-1;A--,B++)E+=a*u[A]>>>0,u[A]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");p=B,d++}if(l[d]!==" "){for(var b=m-p;b!==m&&u[b]===0;)b++;for(var I=new Uint8Array(x+(m-b)),R=x;b!==m;)I[R++]=u[b++];return I}}}function i(l){var d=_(l);if(d)return d;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:_,decode:i}}var qs=Ks,Fs=qs,Yn=Fs;var Sr=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Br=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Xn(this,t)}},vr=class{decoders;constructor(t){this.decoders=t}or(t){return Xn(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Xn(r,t){return new vr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Ar=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Sr(t,e,n),this.decoder=new Br(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function se({name:r,prefix:t,encode:e,decode:n}){return new Ar(r,t,e,n)}function Nt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Yn(e,r);return se({prefix:t,name:r,encode:n,decode:s=>_t(o(s))})}function Vs(r,t,e,n){let o={};for(let h=0;h<t.length;++h)o[t[h]]=h;let s=r.length;for(;r[s-1]==="=";)--s;let c=new Uint8Array(s*e/8|0),a=0,f=0,y=0;for(let h=0;h<s;++h){let g=o[r[h]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<e|g,a+=e,a>=8&&(a-=8,c[y++]=255&f>>a)}if(a>=e||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return c}function Zs(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",c=0,a=0;for(let f=0;f<r.length;++f)for(a=a<<8|r[f],c+=8;c>e;)c-=e,s+=t[o&a>>c];if(c!==0&&(s+=t[o&a<<e-c]),n)for(;s.length*e&7;)s+="=";return s}function Y({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return se({prefix:t,name:r,encode(o){return Zs(o,n,e)},decode(o){return Vs(o,n,e,r)}})}var X=Nt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Gs=Nt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Tr={};ct(Tr,{base32:()=>ie,base32hex:()=>Ws,base32hexpad:()=>Qs,base32hexpadupper:()=>Js,base32hexupper:()=>$s,base32pad:()=>Ys,base32padupper:()=>Xs,base32upper:()=>js,base32z:()=>ti});var ie=Y({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),js=Y({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ys=Y({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Xs=Y({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ws=Y({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),$s=Y({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Qs=Y({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Js=Y({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ti=Y({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Rr={};ct(Rr,{base36:()=>we,base36upper:()=>ei});var we=Nt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ei=Nt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ri=Qn,Wn=128,ni=127,oi=~ni,si=Math.pow(2,31);function Qn(r,t,e){t=t||[],e=e||0;for(var n=e;r>=si;)t[e++]=r&255|Wn,r/=128;for(;r&oi;)t[e++]=r&255|Wn,r>>>=7;return t[e]=r|0,Qn.bytes=e-n+1,t}var ii=Cr,ci=128,$n=127;function Cr(r,n){var e=0,n=n||0,o=0,s=n,c,a=r.length;do{if(s>=a)throw Cr.bytes=0,new RangeError("Could not decode varint");c=r[s++],e+=o<28?(c&$n)<<o:(c&$n)*Math.pow(2,o),o+=7}while(c>=ci);return Cr.bytes=s-n,e}var ai=Math.pow(2,7),fi=Math.pow(2,14),ui=Math.pow(2,21),hi=Math.pow(2,28),li=Math.pow(2,35),di=Math.pow(2,42),pi=Math.pow(2,49),mi=Math.pow(2,56),xi=Math.pow(2,63),gi=function(r){return r<ai?1:r<fi?2:r<ui?3:r<hi?4:r<li?5:r<di?6:r<pi?7:r<mi?8:r<xi?9:10},bi={encode:ri,decode:ii,encodingLength:gi},wi=bi,ye=wi;function Ee(r,t=0){return[ye.decode(r,t),ye.decode.bytes]}function ce(r,t,e=0){return ye.encode(r,t,e),t}function ae(r){return ye.encodingLength(r)}function Gt(r,t){let e=t.byteLength,n=ae(r),o=n+ae(e),s=new Uint8Array(o+e);return ce(r,s,0),ce(e,s,n),s.set(t,o),new fe(r,e,t,s)}function _e(r){let t=_t(r),[e,n]=Ee(t),[o,s]=Ee(t.subarray(n)),c=t.subarray(n+s);if(c.byteLength!==o)throw new Error("Incorrect length");return new fe(e,o,c,t)}function Jn(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Vn(r.bytes,e.bytes)}}var fe=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function to(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Ei(e,Lr(r),t??X.encoder);default:return _i(e,Lr(r),t??ie.encoder)}}var eo=new WeakMap;function Lr(r){let t=eo.get(r);if(t==null){let e=new Map;return eo.set(r,e),e}return t}var lt=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Se)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Si)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Gt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Jn(t.multihash,n.multihash)}toString(t){return to(this,t)}toJSON(){return{"/":to(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:c}=e;return new r(n,o,s,c??ro(n,o,s.bytes))}else if(e[Bi]===!0){let{version:n,multihash:o,code:s}=e,c=_e(o);return r.create(n,s,c)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Se)throw new Error(`Version 0 CID must use dag-pb (code: ${Se}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=ro(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Se,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=_t(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),c=new fe(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(c):r.createV1(e.codec,c),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[g,_]=Ee(t.subarray(e));return e+=_,g},o=n(),s=Se;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let c=e,a=n(),f=n(),y=e+f,h=y-c;return{version:o,codec:s,multihashCode:a,digestSize:f,multihashSize:h,size:y}}static parse(t,e){let[n,o]=yi(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Lr(s).set(n,t),s}};function yi(r,t){switch(r[0]){case"Q":{let e=t??X;return[X.prefix,e.decode(`${X.prefix}${r}`)]}case X.prefix:{let e=t??X;return[X.prefix,e.decode(r)]}case ie.prefix:{let e=t??ie;return[ie.prefix,e.decode(r)]}case we.prefix:{let e=t??we;return[we.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Ei(r,t,e){let{prefix:n}=e;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function _i(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var Se=112,Si=18;function ro(r,t,e){let n=ae(r),o=n+ae(t),s=new Uint8Array(o+e.byteLength);return ce(r,s,0),ce(t,s,n),s.set(e,o),s}var Bi=Symbol.for("@ipld/js-cid/CID");var Nr={};ct(Nr,{identity:()=>St});var no=0,vi="identity",oo=_t;function Ai(r){return Gt(no,oo(r))}var St={code:no,name:vi,encode:oo,digest:Ai};function Bt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function so(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Ii(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ue(r,...t){if(!Ii(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function io(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");so(r.outputLen),so(r.blockLen)}function he(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function co(r,t){ue(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var Yt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Fe=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),dt=(r,t)=>r<<32-t|r>>>t;function ao(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Be(r){return typeof r=="string"&&(r=ao(r)),ue(r),r}function Ur(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];ue(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var le=class{clone(){return this._cloneInto()}};function Ve(r){let t=n=>r().update(Be(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Ze(r=32){if(Yt&&typeof Yt.getRandomValues=="function")return Yt.getRandomValues(new Uint8Array(r));if(Yt&&typeof Yt.randomBytes=="function")return Yt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Ti(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),c=Number(e>>o&s),a=Number(e&s),f=n?4:0,y=n?0:4;r.setUint32(t+f,c,n),r.setUint32(t+y,a,n)}var fo=(r,t,e)=>r&t^~r&e,uo=(r,t,e)=>r&t^r&e^t&e,de=class extends le{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Fe(this.buffer)}update(t){he(this);let{view:e,buffer:n,blockLen:o}=this;t=Be(t);let s=t.length;for(let c=0;c<s;){let a=Math.min(o-this.pos,s-c);if(a===o){let f=Fe(t);for(;o<=s-c;c+=o)this.process(f,c);continue}n.set(t.subarray(c,c+a),this.pos),this.pos+=a,c+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){he(this),co(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:c}=this;e[c++]=128,this.buffer.subarray(c).fill(0),this.padOffset>o-c&&(this.process(n,0),c=0);for(let g=c;g<o;g++)e[g]=0;Ti(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=Fe(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let y=f/4,h=this.get();if(y>h.length)throw new Error("_sha2: outputLen bigger than state");for(let g=0;g<y;g++)a.setUint32(4*g,h[g],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:c,pos:a}=this;return t.length=o,t.pos=a,t.finished=s,t.destroyed=c,o%e&&t.buffer.set(n),t}};var Ge=BigInt(4294967295),kr=BigInt(32);function ho(r,t=!1){return t?{h:Number(r&Ge),l:Number(r>>kr&Ge)}:{h:Number(r>>kr&Ge)|0,l:Number(r&Ge)|0}}function Ri(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:c}=ho(r[o],t);[e[o],n[o]]=[s,c]}return[e,n]}var Ci=(r,t)=>BigInt(r>>>0)<<kr|BigInt(t>>>0),Li=(r,t,e)=>r>>>e,Ni=(r,t,e)=>r<<32-e|t>>>e,Ui=(r,t,e)=>r>>>e|t<<32-e,ki=(r,t,e)=>r<<32-e|t>>>e,Mi=(r,t,e)=>r<<64-e|t>>>e-32,Di=(r,t,e)=>r>>>e-32|t<<64-e,Oi=(r,t)=>t,Pi=(r,t)=>r,zi=(r,t,e)=>r<<e|t>>>32-e,Hi=(r,t,e)=>t<<e|r>>>32-e,Ki=(r,t,e)=>t<<e-32|r>>>64-e,qi=(r,t,e)=>r<<e-32|t>>>64-e;function Fi(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var Vi=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Zi=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Gi=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),ji=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Yi=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Xi=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Wi={fromBig:ho,split:Ri,toBig:Ci,shrSH:Li,shrSL:Ni,rotrSH:Ui,rotrSL:ki,rotrBH:Mi,rotrBL:Di,rotr32H:Oi,rotr32L:Pi,rotlSH:zi,rotlSL:Hi,rotlBH:Ki,rotlBL:qi,add:Fi,add3L:Vi,add3H:Zi,add4L:Gi,add4H:ji,add5H:Xi,add5L:Yi},D=Wi;var[$i,Qi]=D.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Ut=new Uint32Array(80),kt=new Uint32Array(80),Mr=class extends de{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:c,Dh:a,Dl:f,Eh:y,El:h,Fh:g,Fl:_,Gh:i,Gl:l,Hh:d,Hl:x}=this;return[t,e,n,o,s,c,a,f,y,h,g,_,i,l,d,x]}set(t,e,n,o,s,c,a,f,y,h,g,_,i,l,d,x){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=c|0,this.Dh=a|0,this.Dl=f|0,this.Eh=y|0,this.El=h|0,this.Fh=g|0,this.Fl=_|0,this.Gh=i|0,this.Gl=l|0,this.Hh=d|0,this.Hl=x|0}process(t,e){for(let u=0;u<16;u++,e+=4)Ut[u]=t.getUint32(e),kt[u]=t.getUint32(e+=4);for(let u=16;u<80;u++){let E=Ut[u-15]|0,B=kt[u-15]|0,A=D.rotrSH(E,B,1)^D.rotrSH(E,B,8)^D.shrSH(E,B,7),b=D.rotrSL(E,B,1)^D.rotrSL(E,B,8)^D.shrSL(E,B,7),I=Ut[u-2]|0,R=kt[u-2]|0,K=D.rotrSH(I,R,19)^D.rotrBH(I,R,61)^D.shrSH(I,R,6),P=D.rotrSL(I,R,19)^D.rotrBL(I,R,61)^D.shrSL(I,R,6),O=D.add4L(b,P,kt[u-7],kt[u-16]),N=D.add4H(O,A,K,Ut[u-7],Ut[u-16]);Ut[u]=N|0,kt[u]=O|0}let{Ah:n,Al:o,Bh:s,Bl:c,Ch:a,Cl:f,Dh:y,Dl:h,Eh:g,El:_,Fh:i,Fl:l,Gh:d,Gl:x,Hh:p,Hl:m}=this;for(let u=0;u<80;u++){let E=D.rotrSH(g,_,14)^D.rotrSH(g,_,18)^D.rotrBH(g,_,41),B=D.rotrSL(g,_,14)^D.rotrSL(g,_,18)^D.rotrBL(g,_,41),A=g&i^~g&d,b=_&l^~_&x,I=D.add5L(m,B,b,Qi[u],kt[u]),R=D.add5H(I,p,E,A,$i[u],Ut[u]),K=I|0,P=D.rotrSH(n,o,28)^D.rotrBH(n,o,34)^D.rotrBH(n,o,39),O=D.rotrSL(n,o,28)^D.rotrBL(n,o,34)^D.rotrBL(n,o,39),N=n&s^n&a^s&a,T=o&c^o&f^c&f;p=d|0,m=x|0,d=i|0,x=l|0,i=g|0,l=_|0,{h:g,l:_}=D.add(y|0,h|0,R|0,K|0),y=a|0,h=f|0,a=s|0,f=c|0,s=n|0,c=o|0;let L=D.add3L(K,O,T);n=D.add3H(L,R,P,N),o=L|0}({h:n,l:o}=D.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:c}=D.add(this.Bh|0,this.Bl|0,s|0,c|0),{h:a,l:f}=D.add(this.Ch|0,this.Cl|0,a|0,f|0),{h:y,l:h}=D.add(this.Dh|0,this.Dl|0,y|0,h|0),{h:g,l:_}=D.add(this.Eh|0,this.El|0,g|0,_|0),{h:i,l}=D.add(this.Fh|0,this.Fl|0,i|0,l|0),{h:d,l:x}=D.add(this.Gh|0,this.Gl|0,d|0,x|0),{h:p,l:m}=D.add(this.Hh|0,this.Hl|0,p|0,m|0),this.set(n,o,s,c,a,f,y,h,g,_,i,l,d,x,p,m)}roundClean(){Ut.fill(0),kt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var lo=Ve(()=>new Mr);var Xe={};ct(Xe,{aInRange:()=>at,abool:()=>pt,abytes:()=>pe,bitGet:()=>oc,bitLen:()=>zr,bitMask:()=>Ae,bitSet:()=>sc,bytesToHex:()=>At,bytesToNumberBE:()=>It,bytesToNumberLE:()=>Dt,concatBytes:()=>Tt,createHmacDrbg:()=>Hr,ensureBytes:()=>j,equalBytes:()=>rc,hexToBytes:()=>Wt,hexToNumber:()=>Pr,inRange:()=>ve,isBytes:()=>Mt,memoized:()=>Qt,notImplemented:()=>cc,numberToBytesBE:()=>Ot,numberToBytesLE:()=>$t,numberToHexUnpadded:()=>Xt,numberToVarBytesBE:()=>ec,utf8ToBytes:()=>nc,validateObject:()=>wt});var je=BigInt(0),Ye=BigInt(1),Ji=BigInt(2);function Mt(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function pe(r){if(!Mt(r))throw new Error("Uint8Array expected")}function pt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var tc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function At(r){pe(r);let t="";for(let e=0;e<r.length;e++)t+=tc[r[e]];return t}function Xt(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Pr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?je:BigInt("0x"+r)}var vt={_0:48,_9:57,A:65,F:70,a:97,f:102};function po(r){if(r>=vt._0&&r<=vt._9)return r-vt._0;if(r>=vt.A&&r<=vt.F)return r-(vt.A-10);if(r>=vt.a&&r<=vt.f)return r-(vt.a-10)}function Wt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let c=po(r.charCodeAt(s)),a=po(r.charCodeAt(s+1));if(c===void 0||a===void 0){let f=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+s)}n[o]=c*16+a}return n}function It(r){return Pr(At(r))}function Dt(r){return pe(r),Pr(At(Uint8Array.from(r).reverse()))}function Ot(r,t){return Wt(r.toString(16).padStart(t*2,"0"))}function $t(r,t){return Ot(r,t).reverse()}function ec(r){return Wt(Xt(r))}function j(r,t,e){let n;if(typeof t=="string")try{n=Wt(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(Mt(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function Tt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];pe(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}function rc(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function nc(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var Dr=r=>typeof r=="bigint"&&je<=r;function ve(r,t,e){return Dr(r)&&Dr(t)&&Dr(e)&&t<=r&&r<e}function at(r,t,e,n){if(!ve(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function zr(r){let t;for(t=0;r>je;r>>=Ye,t+=1);return t}function oc(r,t){return r>>BigInt(t)&Ye}function sc(r,t,e){return r|(e?Ye:je)<<BigInt(t)}var Ae=r=>(Ji<<BigInt(r-1))-Ye,Or=r=>new Uint8Array(r),mo=r=>Uint8Array.from(r);function Hr(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=Or(r),o=Or(r),s=0,c=()=>{n.fill(1),o.fill(0),s=0},a=(...g)=>e(o,n,...g),f=(g=Or())=>{o=a(mo([0]),g),n=a(),g.length!==0&&(o=a(mo([1]),g),n=a())},y=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let g=0,_=[];for(;g<t;){n=a();let i=n.slice();_.push(i),g+=n.length}return Tt(..._)};return(g,_)=>{c(),f(g);let i;for(;!(i=_(y()));)f();return c(),i}}var ic={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Mt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function wt(r,t,e={}){let n=(o,s,c)=>{let a=ic[s];if(typeof a!="function")throw new Error("invalid validator function");let f=r[o];if(!(c&&f===void 0)&&!a(f,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+f)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}var cc=()=>{throw new Error("not implemented")};function Qt(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var W=BigInt(0),Z=BigInt(1),Jt=BigInt(2),ac=BigInt(3),Kr=BigInt(4),xo=BigInt(5),go=BigInt(8),fc=BigInt(9),uc=BigInt(16);function F(r,t){let e=r%t;return e>=W?e:t+e}function hc(r,t,e){if(t<W)throw new Error("invalid exponent, negatives unsupported");if(e<=W)throw new Error("invalid modulus");if(e===Z)return W;let n=Z;for(;t>W;)t&Z&&(n=n*r%e),r=r*r%e,t>>=Z;return n}function G(r,t,e){let n=r;for(;t-- >W;)n*=n,n%=e;return n}function We(r,t){if(r===W)throw new Error("invert: expected non-zero number");if(t<=W)throw new Error("invert: expected positive modulus, got "+t);let e=F(r,t),n=t,o=W,s=Z,c=Z,a=W;for(;e!==W;){let y=n/e,h=n%e,g=o-c*y,_=s-a*y;n=e,e=h,o=c,s=a,c=g,a=_}if(n!==Z)throw new Error("invert: does not exist");return F(o,t)}function lc(r){let t=(r-Z)/Jt,e,n,o;for(e=r-Z,n=0;e%Jt===W;e/=Jt,n++);for(o=Jt;o<r&&hc(o,t,r)!==r-Z;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let c=(r+Z)/Kr;return function(f,y){let h=f.pow(y,c);if(!f.eql(f.sqr(h),y))throw new Error("Cannot find square root");return h}}let s=(e+Z)/Jt;return function(a,f){if(a.pow(f,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let y=n,h=a.pow(a.mul(a.ONE,o),e),g=a.pow(f,s),_=a.pow(f,e);for(;!a.eql(_,a.ONE);){if(a.eql(_,a.ZERO))return a.ZERO;let i=1;for(let d=a.sqr(_);i<y&&!a.eql(d,a.ONE);i++)d=a.sqr(d);let l=a.pow(h,Z<<BigInt(y-i-1));h=a.sqr(l),g=a.mul(g,l),_=a.mul(_,h),y=i}return g}}function dc(r){if(r%Kr===ac){let t=(r+Z)/Kr;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%go===xo){let t=(r-xo)/go;return function(n,o){let s=n.mul(o,Jt),c=n.pow(s,t),a=n.mul(o,c),f=n.mul(n.mul(a,Jt),c),y=n.mul(a,n.sub(f,n.ONE));if(!n.eql(n.sqr(y),o))throw new Error("Cannot find square root");return y}}return r%uc,lc(r)}var bo=(r,t)=>(F(r,t)&Z)===Z,pc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function qr(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=pc.reduce((n,o)=>(n[o]="function",n),t);return wt(r,e)}function mc(r,t,e){if(e<W)throw new Error("invalid exponent, negatives unsupported");if(e===W)return r.ONE;if(e===Z)return t;let n=r.ONE,o=t;for(;e>W;)e&Z&&(n=r.mul(n,o)),o=r.sqr(o),e>>=Z;return n}function xc(r,t){let e=new Array(t.length),n=t.reduce((s,c,a)=>r.is0(c)?s:(e[a]=s,r.mul(s,c)),r.ONE),o=r.inv(n);return t.reduceRight((s,c,a)=>r.is0(c)?s:(e[a]=r.mul(s,e[a]),r.mul(s,c)),o),e}function Fr(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Pt(r,t,e=!1,n={}){if(r<=W)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=Fr(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c,a=Object.freeze({ORDER:r,BITS:o,BYTES:s,MASK:Ae(o),ZERO:W,ONE:Z,create:f=>F(f,r),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return W<=f&&f<r},is0:f=>f===W,isOdd:f=>(f&Z)===Z,neg:f=>F(-f,r),eql:(f,y)=>f===y,sqr:f=>F(f*f,r),add:(f,y)=>F(f+y,r),sub:(f,y)=>F(f-y,r),mul:(f,y)=>F(f*y,r),pow:(f,y)=>mc(a,f,y),div:(f,y)=>F(f*We(y,r),r),sqrN:f=>f*f,addN:(f,y)=>f+y,subN:(f,y)=>f-y,mulN:(f,y)=>f*y,inv:f=>We(f,r),sqrt:n.sqrt||(f=>(c||(c=dc(r)),c(a,f))),invertBatch:f=>xc(a,f),cmov:(f,y,h)=>h?y:f,toBytes:f=>e?$t(f,s):Ot(f,s),fromBytes:f=>{if(f.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+f.length);return e?Dt(f):It(f)}});return Object.freeze(a)}function wo(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Vr(r){let t=wo(r);return t+Math.ceil(t/2)}function yo(r,t,e=!1){let n=r.length,o=wo(t),s=Vr(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let c=e?It(r):Dt(r),a=F(c,t-Z)+Z;return e?$t(a,o):Ot(a,o)}var Eo=BigInt(0),$e=BigInt(1);function Zr(r,t){let e=t.negate();return r?e:t}function _o(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Gr(r,t){_o(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function bc(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function wc(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var jr=new WeakMap,So=new WeakMap;function Yr(r){return So.get(r)||1}function Qe(r,t){return{constTimeNegate:Zr,hasPrecomputes(e){return Yr(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Eo;)n&$e&&(o=o.add(s)),s=s.double(),n>>=$e;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=Gr(n,t),c=[],a=e,f=a;for(let y=0;y<o;y++){f=a,c.push(f);for(let h=1;h<s;h++)f=f.add(a),c.push(f);a=f.double()}return c},wNAF(e,n,o){let{windows:s,windowSize:c}=Gr(e,t),a=r.ZERO,f=r.BASE,y=BigInt(2**e-1),h=2**e,g=BigInt(e);for(let _=0;_<s;_++){let i=_*c,l=Number(o&y);o>>=g,l>c&&(l-=h,o+=$e);let d=i,x=i+Math.abs(l)-1,p=_%2!==0,m=l<0;l===0?f=f.add(Zr(p,n[d])):a=a.add(Zr(m,n[x]))}return{p:a,f}},wNAFUnsafe(e,n,o,s=r.ZERO){let{windows:c,windowSize:a}=Gr(e,t),f=BigInt(2**e-1),y=2**e,h=BigInt(e);for(let g=0;g<c;g++){let _=g*a;if(o===Eo)break;let i=Number(o&f);if(o>>=h,i>a&&(i-=y,o+=$e),i===0)continue;let l=n[_+Math.abs(i)-1];i<0&&(l=l.negate()),s=s.add(l)}return s},getPrecomputes(e,n,o){let s=jr.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&jr.set(n,o(s))),s},wNAFCached(e,n,o){let s=Yr(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let c=Yr(e);return c===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(c,this.getPrecomputes(c,e,o),n,s)},setWindowSize(e,n){_o(n,t),So.set(e,n),jr.delete(e)}}}function Je(r,t,e,n){if(bc(e,r),wc(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,s=zr(BigInt(e.length)),c=s>12?s-3:s>4?s-2:s?2:1,a=(1<<c)-1,f=new Array(a+1).fill(o),y=Math.floor((t.BITS-1)/c)*c,h=o;for(let g=y;g>=0;g-=c){f.fill(o);for(let i=0;i<n.length;i++){let l=n[i],d=Number(l>>BigInt(g)&BigInt(a));f[d]=f[d].add(e[i])}let _=o;for(let i=f.length-1,l=o;i>0;i--)l=l.add(f[i]),_=_.add(l);if(h=h.add(_),g!==0)for(let i=0;i<c;i++)h=h.double()}return h}function Ie(r){return qr(r.Fp),wt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Fr(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var mt=BigInt(0),ft=BigInt(1),tr=BigInt(2),yc=BigInt(8),Ec={zip215:!0};function _c(r){let t=Ie(r);return wt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Bo(r){let t=_c(r),{Fp:e,n,prehash:o,hash:s,randomBytes:c,nByteLength:a,h:f}=t,y=tr<<BigInt(a*8)-ft,h=e.create,g=Pt(t.n,t.nBitLength),_=t.uvRatio||((S,w)=>{try{return{isValid:!0,value:e.sqrt(S*e.inv(w))}}catch{return{isValid:!1,value:mt}}}),i=t.adjustScalarBytes||(S=>S),l=t.domain||((S,w,v)=>{if(pt("phflag",v),w.length||v)throw new Error("Contexts/pre-hash are not supported");return S});function d(S,w){at("coordinate "+S,w,mt,y)}function x(S){if(!(S instanceof u))throw new Error("ExtendedPoint expected")}let p=Qt((S,w)=>{let{ex:v,ey:C,ez:U}=S,k=S.is0();w==null&&(w=k?yc:e.inv(U));let z=h(v*w),H=h(C*w),M=h(U*w);if(k)return{x:mt,y:ft};if(M!==ft)throw new Error("invZ was invalid");return{x:z,y:H}}),m=Qt(S=>{let{a:w,d:v}=t;if(S.is0())throw new Error("bad point: ZERO");let{ex:C,ey:U,ez:k,et:z}=S,H=h(C*C),M=h(U*U),q=h(k*k),V=h(q*q),$=h(H*w),Q=h(q*h($+M)),tt=h(V+h(v*h(H*M)));if(Q!==tt)throw new Error("bad point: equation left != right (1)");let et=h(C*U),it=h(k*z);if(et!==it)throw new Error("bad point: equation left != right (2)");return!0});class u{constructor(w,v,C,U){this.ex=w,this.ey=v,this.ez=C,this.et=U,d("x",w),d("y",v),d("z",C),d("t",U),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(w){if(w instanceof u)throw new Error("extended point not allowed");let{x:v,y:C}=w||{};return d("x",v),d("y",C),new u(v,C,ft,h(v*C))}static normalizeZ(w){let v=e.invertBatch(w.map(C=>C.ez));return w.map((C,U)=>C.toAffine(v[U])).map(u.fromAffine)}static msm(w,v){return Je(u,g,w,v)}_setWindowSize(w){A.setWindowSize(this,w)}assertValidity(){m(this)}equals(w){x(w);let{ex:v,ey:C,ez:U}=this,{ex:k,ey:z,ez:H}=w,M=h(v*H),q=h(k*U),V=h(C*H),$=h(z*U);return M===q&&V===$}is0(){return this.equals(u.ZERO)}negate(){return new u(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){let{a:w}=t,{ex:v,ey:C,ez:U}=this,k=h(v*v),z=h(C*C),H=h(tr*h(U*U)),M=h(w*k),q=v+C,V=h(h(q*q)-k-z),$=M+z,Q=$-H,tt=M-z,et=h(V*Q),it=h($*tt),nt=h(V*tt),bt=h(Q*$);return new u(et,it,bt,nt)}add(w){x(w);let{a:v,d:C}=t,{ex:U,ey:k,ez:z,et:H}=this,{ex:M,ey:q,ez:V,et:$}=w;if(v===BigInt(-1)){let Mn=h((k-U)*(q+M)),Dn=h((k+U)*(q-M)),Er=h(Dn-Mn);if(Er===mt)return this.double();let On=h(z*tr*$),Pn=h(H*tr*V),zn=Pn+On,Hn=Dn+Mn,Kn=Pn-On,Cs=h(zn*Er),Ls=h(Hn*Kn),Ns=h(zn*Kn),Us=h(Er*Hn);return new u(Cs,Ls,Us,Ns)}let Q=h(U*M),tt=h(k*q),et=h(H*C*$),it=h(z*V),nt=h((U+k)*(M+q)-Q-tt),bt=it-et,Et=it+et,xe=h(tt-v*Q),As=h(nt*bt),Is=h(Et*xe),Ts=h(nt*xe),Rs=h(bt*Et);return new u(As,Is,Rs,Ts)}subtract(w){return this.add(w.negate())}wNAF(w){return A.wNAFCached(this,w,u.normalizeZ)}multiply(w){let v=w;at("scalar",v,ft,n);let{p:C,f:U}=this.wNAF(v);return u.normalizeZ([C,U])[0]}multiplyUnsafe(w,v=u.ZERO){let C=w;return at("scalar",C,mt,n),C===mt?B:this.is0()||C===ft?this:A.wNAFCachedUnsafe(this,C,u.normalizeZ,v)}isSmallOrder(){return this.multiplyUnsafe(f).is0()}isTorsionFree(){return A.unsafeLadder(this,n).is0()}toAffine(w){return p(this,w)}clearCofactor(){let{h:w}=t;return w===ft?this:this.multiplyUnsafe(w)}static fromHex(w,v=!1){let{d:C,a:U}=t,k=e.BYTES;w=j("pointHex",w,k),pt("zip215",v);let z=w.slice(),H=w[k-1];z[k-1]=H&-129;let M=Dt(z),q=v?y:e.ORDER;at("pointHex.y",M,mt,q);let V=h(M*M),$=h(V-ft),Q=h(C*V-U),{isValid:tt,value:et}=_($,Q);if(!tt)throw new Error("Point.fromHex: invalid y coordinate");let it=(et&ft)===ft,nt=(H&128)!==0;if(!v&&et===mt&&nt)throw new Error("Point.fromHex: x=0 and x_0=1");return nt!==it&&(et=h(-et)),u.fromAffine({x:et,y:M})}static fromPrivateKey(w){return R(w).point}toRawBytes(){let{x:w,y:v}=this.toAffine(),C=$t(v,e.BYTES);return C[C.length-1]|=w&ft?128:0,C}toHex(){return At(this.toRawBytes())}}u.BASE=new u(t.Gx,t.Gy,ft,h(t.Gx*t.Gy)),u.ZERO=new u(mt,ft,ft,mt);let{BASE:E,ZERO:B}=u,A=Qe(u,a*8);function b(S){return F(S,n)}function I(S){return b(Dt(S))}function R(S){let w=e.BYTES;S=j("private key",S,w);let v=j("hashed private key",s(S),2*w),C=i(v.slice(0,w)),U=v.slice(w,2*w),k=I(C),z=E.multiply(k),H=z.toRawBytes();return{head:C,prefix:U,scalar:k,point:z,pointBytes:H}}function K(S){return R(S).pointBytes}function P(S=new Uint8Array,...w){let v=Tt(...w);return I(s(l(v,j("context",S),!!o)))}function O(S,w,v={}){S=j("message",S),o&&(S=o(S));let{prefix:C,scalar:U,pointBytes:k}=R(w),z=P(v.context,C,S),H=E.multiply(z).toRawBytes(),M=P(v.context,H,k,S),q=b(z+M*U);at("signature.s",q,mt,n);let V=Tt(H,$t(q,e.BYTES));return j("result",V,e.BYTES*2)}let N=Ec;function T(S,w,v,C=N){let{context:U,zip215:k}=C,z=e.BYTES;S=j("signature",S,2*z),w=j("message",w),v=j("publicKey",v,z),k!==void 0&&pt("zip215",k),o&&(w=o(w));let H=Dt(S.slice(z,2*z)),M,q,V;try{M=u.fromHex(v,k),q=u.fromHex(S.slice(0,z),k),V=E.multiplyUnsafe(H)}catch{return!1}if(!k&&M.isSmallOrder())return!1;let $=P(U,q.toRawBytes(),M.toRawBytes(),w);return q.add(M.multiplyUnsafe($)).subtract(V).clearCofactor().equals(u.ZERO)}return E._setWindowSize(8),{CURVE:t,getPublicKey:K,sign:O,verify:T,ExtendedPoint:u,utils:{getExtendedPublicKey:R,randomPrivateKey:()=>c(e.BYTES),precompute(S=8,w=u.BASE){return w._setWindowSize(S),w.multiply(BigInt(3)),w}}}}var Xr=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),vo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),vf=BigInt(0),Sc=BigInt(1),Ao=BigInt(2),Af=BigInt(3),Bc=BigInt(5),vc=BigInt(8);function Ac(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=Xr,a=r*r%s*r%s,f=G(a,Ao,s)*a%s,y=G(f,Sc,s)*r%s,h=G(y,Bc,s)*y%s,g=G(h,t,s)*h%s,_=G(g,e,s)*g%s,i=G(_,n,s)*_%s,l=G(i,o,s)*i%s,d=G(l,o,s)*i%s,x=G(d,t,s)*h%s;return{pow_p_5_8:G(x,Ao,s)*r%s,b2:a}}function Ic(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Tc(r,t){let e=Xr,n=F(t*t*t,e),o=F(n*n*t,e),s=Ac(r*o).pow_p_5_8,c=F(r*n*s,e),a=F(t*c*c,e),f=c,y=F(c*vo,e),h=a===r,g=a===F(-r,e),_=a===F(-r*vo,e);return h&&(c=f),(g||_)&&(c=y),bo(c,e)&&(c=F(-c,e)),{isValid:h||g,value:c}}var Rc=Pt(Xr,void 0,!0),Cc={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Rc,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:vc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:lo,randomBytes:Ze,adjustScalarBytes:Ic,uvRatio:Tc},Io=Bo(Cc);var er=32;function To(r,t,e){return Io.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var rr=class{type="Ed25519";raw;constructor(t){this.raw=Wr(t,er)}toMultihash(){return St.digest(nr(this))}toCID(){return lt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Bt(this.raw,t.raw)}verify(t,e){return To(this.raw,e,t)}};function Co(r){return r=Wr(r,er),new rr(r)}function Wr(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new ge(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function Lo(r=0){return new Uint8Array(r)}function Rt(r=0){return new Uint8Array(r)}var Nc=Math.pow(2,7),Uc=Math.pow(2,14),kc=Math.pow(2,21),No=Math.pow(2,28),Uo=Math.pow(2,35),ko=Math.pow(2,42),Mo=Math.pow(2,49),ot=128,zt=127;function Te(r){if(r<Nc)return 1;if(r<Uc)return 2;if(r<kc)return 3;if(r<No)return 4;if(r<Uo)return 5;if(r<ko)return 6;if(r<Mo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Do(r,t,e=0){switch(Te(r)){case 8:t[e++]=r&255|ot,r/=128;case 7:t[e++]=r&255|ot,r/=128;case 6:t[e++]=r&255|ot,r/=128;case 5:t[e++]=r&255|ot,r/=128;case 4:t[e++]=r&255|ot,r>>>=7;case 3:t[e++]=r&255|ot,r>>>=7;case 2:t[e++]=r&255|ot,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Oo(r,t){let e=r[t],n=0;if(n+=e&zt,e<ot||(e=r[t+1],n+=(e&zt)<<7,e<ot)||(e=r[t+2],n+=(e&zt)<<14,e<ot)||(e=r[t+3],n+=(e&zt)<<21,e<ot)||(e=r[t+4],n+=(e&zt)*No,e<ot)||(e=r[t+5],n+=(e&zt)*Uo,e<ot)||(e=r[t+6],n+=(e&zt)*ko,e<ot)||(e=r[t+7],n+=(e&zt)*Mo,e<ot))return n;throw new RangeError("Could not decode varint")}var $r=new Float32Array([-0]),Ht=new Uint8Array($r.buffer);function Po(r,t,e){$r[0]=r,t[e]=Ht[0],t[e+1]=Ht[1],t[e+2]=Ht[2],t[e+3]=Ht[3]}function zo(r,t){return Ht[0]=r[t],Ht[1]=r[t+1],Ht[2]=r[t+2],Ht[3]=r[t+3],$r[0]}var Qr=new Float64Array([-0]),rt=new Uint8Array(Qr.buffer);function Ho(r,t,e){Qr[0]=r,t[e]=rt[0],t[e+1]=rt[1],t[e+2]=rt[2],t[e+3]=rt[3],t[e+4]=rt[4],t[e+5]=rt[5],t[e+6]=rt[6],t[e+7]=rt[7]}function Ko(r,t){return rt[0]=r[t],rt[1]=r[t+1],rt[2]=r[t+2],rt[3]=r[t+3],rt[4]=r[t+4],rt[5]=r[t+5],rt[6]=r[t+6],rt[7]=r[t+7],Qr[0]}var Mc=BigInt(Number.MAX_SAFE_INTEGER),Dc=BigInt(Number.MIN_SAFE_INTEGER),ut=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return te;if(t<Mc&&t>Dc)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>qo&&(o=0n,++n>qo&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return te;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):te}},te=new ut(0,0);te.toBigInt=function(){return 0n};te.zzEncode=te.zzDecode=function(){return this};te.length=function(){return 1};var qo=4294967296n;function Fo(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Vo(r,t,e){if(e-t<1)return"";let o,s=[],c=0,a;for(;t<e;)a=r[t++],a<128?s[c++]=a:a>191&&a<224?s[c++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[c++]=55296+(a>>10),s[c++]=56320+(a&1023)):s[c++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&63,c>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),c=0);return o!=null?(c>0&&o.push(String.fromCharCode.apply(String,s.slice(0,c))),o.join("")):String.fromCharCode.apply(String,s.slice(0,c))}function Jr(r,t,e){let n=e,o,s;for(let c=0;c<r.length;++c)o=r.charCodeAt(c),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(c+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++c,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function xt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function or(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var tn=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,xt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw xt(this,4);return or(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw xt(this,4);return or(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw xt(this,4);let t=zo(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw xt(this,4);let t=Ko(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw xt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Vo(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw xt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw xt(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new ut(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw xt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw xt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw xt(this,8);let t=or(this.buf,this.pos+=4),e=or(this.buf,this.pos+=4);return new ut(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Oo(this.buf,this.pos);return this.pos+=Te(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function en(r){return new tn(r instanceof Uint8Array?r:r.subarray())}function sr(r,t,e){let n=en(r);return t.decode(n,void 0,e)}var rn={};ct(rn,{base10:()=>Oc});var Oc=Nt({prefix:"9",name:"base10",alphabet:"0123456789"});var nn={};ct(nn,{base16:()=>Pc,base16upper:()=>zc});var Pc=Y({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),zc=Y({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var on={};ct(on,{base2:()=>Hc});var Hc=Y({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var sn={};ct(sn,{base256emoji:()=>Zc});var Go=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Kc=Go.reduce((r,t,e)=>(r[e]=t,r),[]),qc=Go.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Fc(r){return r.reduce((t,e)=>(t+=Kc[e],t),"")}function Vc(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=qc[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Zc=se({prefix:"\u{1F680}",name:"base256emoji",encode:Fc,decode:Vc});var cn={};ct(cn,{base64:()=>Gc,base64pad:()=>jc,base64url:()=>Yc,base64urlpad:()=>Xc});var Gc=Y({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),jc=Y({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Yc=Y({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Xc=Y({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var an={};ct(an,{base8:()=>Wc});var Wc=Y({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var fn={};ct(fn,{identity:()=>$c});var $c=se({prefix:"\0",name:"identity",encode:r=>Gn(r),decode:r=>Zn(r)});var fu=new TextEncoder,uu=new TextDecoder;var ln={};ct(ln,{sha256:()=>Re,sha512:()=>ta});function hn({name:r,code:t,encode:e}){return new un(r,t,e)}var un=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Gt(this.code,e):e.then(n=>Gt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Yo(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Re=hn({name:"sha2-256",code:18,encode:Yo("SHA-256")}),ta=hn({name:"sha2-512",code:19,encode:Yo("SHA-512")});var dn={...fn,...on,...an,...rn,...nn,...Tr,...Rr,...Ir,...cn,...sn},_u={...ln,...Nr};function Wo(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Xo=Wo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),pn=Wo("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=Rt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),ea={utf8:Xo,"utf-8":Xo,hex:dn.base16,latin1:pn,ascii:pn,binary:pn,...dn},ir=ea;function st(r,t="utf8"){let e=ir[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function mn(r){let t=r??8192,e=t>>>1,n,o=t;return function(c){if(c<1||c>e)return Rt(c);o+c>t&&(n=Rt(t),o=0);let a=n.subarray(o,o+=c);return o&7&&(o=(o|7)+1),a}}var ee=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function xn(){}var bn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},ra=mn();function na(r){return globalThis.Buffer!=null?Rt(r):ra(r)}var Le=class{len;head;tail;states;constructor(){this.len=0,this.head=new ee(xn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ee(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new wn((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(cr,10,ut.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=ut.fromBigInt(t);return this._push(cr,e.length(),e)}uint64Number(t){return this._push(Do,Te(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=ut.fromBigInt(t).zzEncode();return this._push(cr,e.length(),e)}sint64Number(t){let e=ut.fromNumber(t).zzEncode();return this._push(cr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(gn,1,t?1:0)}fixed32(t){return this._push(Ce,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=ut.fromBigInt(t);return this._push(Ce,4,e.lo)._push(Ce,4,e.hi)}fixed64Number(t){let e=ut.fromNumber(t);return this._push(Ce,4,e.lo)._push(Ce,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Po,4,t)}double(t){return this._push(Ho,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(gn,1,0):this.uint32(e)._push(sa,e,t)}string(t){let e=Fo(t);return e!==0?this.uint32(e)._push(Jr,e,t):this._push(gn,1,0)}fork(){return this.states=new bn(this),this.head=this.tail=new ee(xn,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new ee(xn,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=na(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function gn(r,t,e){t[e]=r&255}function oa(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var wn=class extends ee{next;constructor(t,e){super(oa,t,e),this.next=void 0}};function cr(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Ce(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function sa(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Le.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(ia,t,r),this},Le.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(ca,t,r),this});function ia(r,t,e){t.set(r,e)}function ca(r,t,e){r.length<40?Jr(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(st(r),e)}function yn(){return new Le}function ar(r,t){let e=yn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var me;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(me||(me={}));function fr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function En(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,c){let a=t(s);c.int32(a)},n=function(s){let c=s.int32();return t(c)};return fr("enum",me.VARINT,e,n)}function ur(r,t){return fr("message",me.LENGTH_DELIMITED,r,t)}var ht;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(ht||(ht={}));var _n;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(_n||(_n={}));(function(r){r.codec=()=>En(_n)})(ht||(ht={}));var Ne;(function(r){let t;r.codec=()=>(t==null&&(t=ur((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ht.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},c=n==null?e.len:e.pos+n;for(;e.pos<c;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=ht.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ar(e,r.codec()),r.decode=(e,n)=>sr(e,r.codec(),n)})(Ne||(Ne={}));var Sn;(function(r){let t;r.codec=()=>(t==null&&(t=ur((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ht.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},c=n==null?e.len:e.pos+n;for(;e.pos<c;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=ht.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ar(e,r.codec()),r.decode=(e,n)=>sr(e,r.codec(),n)})(Sn||(Sn={}));function hr(r,t="utf8"){let e=ir[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Ue=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var fa=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]),Kt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),qt=new Uint32Array(64),Bn=class extends de{constructor(){super(64,32,8,!1),this.A=Kt[0]|0,this.B=Kt[1]|0,this.C=Kt[2]|0,this.D=Kt[3]|0,this.E=Kt[4]|0,this.F=Kt[5]|0,this.G=Kt[6]|0,this.H=Kt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:c,G:a,H:f}=this;return[t,e,n,o,s,c,a,f]}set(t,e,n,o,s,c,a,f){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=c|0,this.G=a|0,this.H=f|0}process(t,e){for(let g=0;g<16;g++,e+=4)qt[g]=t.getUint32(e,!1);for(let g=16;g<64;g++){let _=qt[g-15],i=qt[g-2],l=dt(_,7)^dt(_,18)^_>>>3,d=dt(i,17)^dt(i,19)^i>>>10;qt[g]=d+qt[g-7]+l+qt[g-16]|0}let{A:n,B:o,C:s,D:c,E:a,F:f,G:y,H:h}=this;for(let g=0;g<64;g++){let _=dt(a,6)^dt(a,11)^dt(a,25),i=h+_+fo(a,f,y)+fa[g]+qt[g]|0,d=(dt(n,2)^dt(n,13)^dt(n,22))+uo(n,o,s)|0;h=y,y=f,f=a,a=c+i|0,c=s,s=o,o=n,n=i+d|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,c=c+this.D|0,a=a+this.E|0,f=f+this.F|0,y=y+this.G|0,h=h+this.H|0,this.set(n,o,s,c,a,f,y,h)}roundClean(){qt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var $o=Ve(()=>new Bn);var lr=class extends le{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,io(t);let n=Be(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let c=0;c<s.length;c++)s[c]^=54;this.iHash.update(s),this.oHash=t.create();for(let c=0;c<s.length;c++)s[c]^=106;this.oHash.update(s),s.fill(0)}update(t){return he(this),this.iHash.update(t),this}digestInto(t){he(this),ue(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:s,blockLen:c,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=c,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},vn=(r,t,e)=>new lr(r,t).update(e).digest();vn.create=(r,t)=>new lr(r,t);function Qo(r){r.lowS!==void 0&&pt("lowS",r.lowS),r.prehash!==void 0&&pt("prehash",r.prehash)}function ua(r){let t=Ie(r);wt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:ha,hexToBytes:la}=Xe,Ct={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(r,t)=>{let{Err:e}=Ct;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=Xt(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Xt(o.length/2|128):"";return Xt(r)+s+o+t},decode(r,t){let{Err:e}=Ct,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),c=0;if(!s)c=o;else{let f=o&127;if(!f)throw new e("tlv.decode(long): indefinite length not supported");if(f>4)throw new e("tlv.decode(long): byte length is too big");let y=t.subarray(n,n+f);if(y.length!==f)throw new e("tlv.decode: length bytes not complete");if(y[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let h of y)c=c<<8|h;if(n+=f,c<128)throw new e("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+c);if(a.length!==c)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+c)}}},_int:{encode(r){let{Err:t}=Ct;if(r<Lt)throw new t("integer: negative integers are not allowed");let e=Xt(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=Ct;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return ha(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Ct,o=typeof r=="string"?la(r):r;pe(o);let{v:s,l:c}=n.decode(48,o);if(c.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:f}=n.decode(2,s),{v:y,l:h}=n.decode(2,f);if(h.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(y)}},hexFromSig(r){let{_tlv:t,_int:e}=Ct,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},Lt=BigInt(0),J=BigInt(1),hh=BigInt(2),Jo=BigInt(3),lh=BigInt(4);function da(r){let t=ua(r),{Fp:e}=t,n=Pt(t.n,t.nBitLength),o=t.toBytes||((d,x,p)=>{let m=x.toAffine();return Tt(Uint8Array.from([4]),e.toBytes(m.x),e.toBytes(m.y))}),s=t.fromBytes||(d=>{let x=d.subarray(1),p=e.fromBytes(x.subarray(0,e.BYTES)),m=e.fromBytes(x.subarray(e.BYTES,2*e.BYTES));return{x:p,y:m}});function c(d){let{a:x,b:p}=t,m=e.sqr(d),u=e.mul(m,d);return e.add(e.add(u,e.mul(d,x)),p)}if(!e.eql(e.sqr(t.Gy),c(t.Gx)))throw new Error("bad generator point: equation left != right");function a(d){return ve(d,J,t.n)}function f(d){let{allowedPrivateKeyLengths:x,nByteLength:p,wrapPrivateKey:m,n:u}=t;if(x&&typeof d!="bigint"){if(Mt(d)&&(d=At(d)),typeof d!="string"||!x.includes(d.length))throw new Error("invalid private key");d=d.padStart(p*2,"0")}let E;try{E=typeof d=="bigint"?d:It(j("private key",d,p))}catch{throw new Error("invalid private key, expected hex or "+p+" bytes, got "+typeof d)}return m&&(E=F(E,u)),at("private key",E,J,u),E}function y(d){if(!(d instanceof _))throw new Error("ProjectivePoint expected")}let h=Qt((d,x)=>{let{px:p,py:m,pz:u}=d;if(e.eql(u,e.ONE))return{x:p,y:m};let E=d.is0();x==null&&(x=E?e.ONE:e.inv(u));let B=e.mul(p,x),A=e.mul(m,x),b=e.mul(u,x);if(E)return{x:e.ZERO,y:e.ZERO};if(!e.eql(b,e.ONE))throw new Error("invZ was invalid");return{x:B,y:A}}),g=Qt(d=>{if(d.is0()){if(t.allowInfinityPoint&&!e.is0(d.py))return;throw new Error("bad point: ZERO")}let{x,y:p}=d.toAffine();if(!e.isValid(x)||!e.isValid(p))throw new Error("bad point: x or y not FE");let m=e.sqr(p),u=c(x);if(!e.eql(m,u))throw new Error("bad point: equation left != right");if(!d.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class _{constructor(x,p,m){if(this.px=x,this.py=p,this.pz=m,x==null||!e.isValid(x))throw new Error("x required");if(p==null||!e.isValid(p))throw new Error("y required");if(m==null||!e.isValid(m))throw new Error("z required");Object.freeze(this)}static fromAffine(x){let{x:p,y:m}=x||{};if(!x||!e.isValid(p)||!e.isValid(m))throw new Error("invalid affine point");if(x instanceof _)throw new Error("projective point not allowed");let u=E=>e.eql(E,e.ZERO);return u(p)&&u(m)?_.ZERO:new _(p,m,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(x){let p=e.invertBatch(x.map(m=>m.pz));return x.map((m,u)=>m.toAffine(p[u])).map(_.fromAffine)}static fromHex(x){let p=_.fromAffine(s(j("pointHex",x)));return p.assertValidity(),p}static fromPrivateKey(x){return _.BASE.multiply(f(x))}static msm(x,p){return Je(_,n,x,p)}_setWindowSize(x){l.setWindowSize(this,x)}assertValidity(){g(this)}hasEvenY(){let{y:x}=this.toAffine();if(e.isOdd)return!e.isOdd(x);throw new Error("Field doesn't support isOdd")}equals(x){y(x);let{px:p,py:m,pz:u}=this,{px:E,py:B,pz:A}=x,b=e.eql(e.mul(p,A),e.mul(E,u)),I=e.eql(e.mul(m,A),e.mul(B,u));return b&&I}negate(){return new _(this.px,e.neg(this.py),this.pz)}double(){let{a:x,b:p}=t,m=e.mul(p,Jo),{px:u,py:E,pz:B}=this,A=e.ZERO,b=e.ZERO,I=e.ZERO,R=e.mul(u,u),K=e.mul(E,E),P=e.mul(B,B),O=e.mul(u,E);return O=e.add(O,O),I=e.mul(u,B),I=e.add(I,I),A=e.mul(x,I),b=e.mul(m,P),b=e.add(A,b),A=e.sub(K,b),b=e.add(K,b),b=e.mul(A,b),A=e.mul(O,A),I=e.mul(m,I),P=e.mul(x,P),O=e.sub(R,P),O=e.mul(x,O),O=e.add(O,I),I=e.add(R,R),R=e.add(I,R),R=e.add(R,P),R=e.mul(R,O),b=e.add(b,R),P=e.mul(E,B),P=e.add(P,P),R=e.mul(P,O),A=e.sub(A,R),I=e.mul(P,K),I=e.add(I,I),I=e.add(I,I),new _(A,b,I)}add(x){y(x);let{px:p,py:m,pz:u}=this,{px:E,py:B,pz:A}=x,b=e.ZERO,I=e.ZERO,R=e.ZERO,K=t.a,P=e.mul(t.b,Jo),O=e.mul(p,E),N=e.mul(m,B),T=e.mul(u,A),L=e.add(p,m),S=e.add(E,B);L=e.mul(L,S),S=e.add(O,N),L=e.sub(L,S),S=e.add(p,u);let w=e.add(E,A);return S=e.mul(S,w),w=e.add(O,T),S=e.sub(S,w),w=e.add(m,u),b=e.add(B,A),w=e.mul(w,b),b=e.add(N,T),w=e.sub(w,b),R=e.mul(K,S),b=e.mul(P,T),R=e.add(b,R),b=e.sub(N,R),R=e.add(N,R),I=e.mul(b,R),N=e.add(O,O),N=e.add(N,O),T=e.mul(K,T),S=e.mul(P,S),N=e.add(N,T),T=e.sub(O,T),T=e.mul(K,T),S=e.add(S,T),O=e.mul(N,S),I=e.add(I,O),O=e.mul(w,S),b=e.mul(L,b),b=e.sub(b,O),O=e.mul(L,N),R=e.mul(w,R),R=e.add(R,O),new _(b,I,R)}subtract(x){return this.add(x.negate())}is0(){return this.equals(_.ZERO)}wNAF(x){return l.wNAFCached(this,x,_.normalizeZ)}multiplyUnsafe(x){let{endo:p,n:m}=t;at("scalar",x,Lt,m);let u=_.ZERO;if(x===Lt)return u;if(this.is0()||x===J)return this;if(!p||l.hasPrecomputes(this))return l.wNAFCachedUnsafe(this,x,_.normalizeZ);let{k1neg:E,k1:B,k2neg:A,k2:b}=p.splitScalar(x),I=u,R=u,K=this;for(;B>Lt||b>Lt;)B&J&&(I=I.add(K)),b&J&&(R=R.add(K)),K=K.double(),B>>=J,b>>=J;return E&&(I=I.negate()),A&&(R=R.negate()),R=new _(e.mul(R.px,p.beta),R.py,R.pz),I.add(R)}multiply(x){let{endo:p,n:m}=t;at("scalar",x,J,m);let u,E;if(p){let{k1neg:B,k1:A,k2neg:b,k2:I}=p.splitScalar(x),{p:R,f:K}=this.wNAF(A),{p:P,f:O}=this.wNAF(I);R=l.constTimeNegate(B,R),P=l.constTimeNegate(b,P),P=new _(e.mul(P.px,p.beta),P.py,P.pz),u=R.add(P),E=K.add(O)}else{let{p:B,f:A}=this.wNAF(x);u=B,E=A}return _.normalizeZ([u,E])[0]}multiplyAndAddUnsafe(x,p,m){let u=_.BASE,E=(A,b)=>b===Lt||b===J||!A.equals(u)?A.multiplyUnsafe(b):A.multiply(b),B=E(this,p).add(E(x,m));return B.is0()?void 0:B}toAffine(x){return h(this,x)}isTorsionFree(){let{h:x,isTorsionFree:p}=t;if(x===J)return!0;if(p)return p(_,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:x,clearCofactor:p}=t;return x===J?this:p?p(_,this):this.multiplyUnsafe(t.h)}toRawBytes(x=!0){return pt("isCompressed",x),this.assertValidity(),o(_,this,x)}toHex(x=!0){return pt("isCompressed",x),At(this.toRawBytes(x))}}_.BASE=new _(t.Gx,t.Gy,e.ONE),_.ZERO=new _(e.ZERO,e.ONE,e.ZERO);let i=t.nBitLength,l=Qe(_,t.endo?Math.ceil(i/2):i);return{CURVE:t,ProjectivePoint:_,normPrivateKeyToScalar:f,weierstrassEquation:c,isWithinCurveOrder:a}}function pa(r){let t=Ie(r);return wt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function ts(r){let t=pa(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function c(T){return F(T,n)}function a(T){return We(T,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:y,weierstrassEquation:h,isWithinCurveOrder:g}=da({...t,toBytes(T,L,S){let w=L.toAffine(),v=e.toBytes(w.x),C=Tt;return pt("isCompressed",S),S?C(Uint8Array.from([L.hasEvenY()?2:3]),v):C(Uint8Array.from([4]),v,e.toBytes(w.y))},fromBytes(T){let L=T.length,S=T[0],w=T.subarray(1);if(L===o&&(S===2||S===3)){let v=It(w);if(!ve(v,J,e.ORDER))throw new Error("Point is not on curve");let C=h(v),U;try{U=e.sqrt(C)}catch(H){let M=H instanceof Error?": "+H.message:"";throw new Error("Point is not on curve"+M)}let k=(U&J)===J;return(S&1)===1!==k&&(U=e.neg(U)),{x:v,y:U}}else if(L===s&&S===4){let v=e.fromBytes(w.subarray(0,e.BYTES)),C=e.fromBytes(w.subarray(e.BYTES,2*e.BYTES));return{x:v,y:C}}else{let v=o,C=s;throw new Error("invalid Point, expected length of "+v+", or uncompressed "+C+", got "+L)}}}),_=T=>At(Ot(T,t.nByteLength));function i(T){let L=n>>J;return T>L}function l(T){return i(T)?c(-T):T}let d=(T,L,S)=>It(T.slice(L,S));class x{constructor(L,S,w){this.r=L,this.s=S,this.recovery=w,this.assertValidity()}static fromCompact(L){let S=t.nByteLength;return L=j("compactSignature",L,S*2),new x(d(L,0,S),d(L,S,2*S))}static fromDER(L){let{r:S,s:w}=Ct.toSig(j("DER",L));return new x(S,w)}assertValidity(){at("r",this.r,J,n),at("s",this.s,J,n)}addRecoveryBit(L){return new x(this.r,this.s,L)}recoverPublicKey(L){let{r:S,s:w,recovery:v}=this,C=A(j("msgHash",L));if(v==null||![0,1,2,3].includes(v))throw new Error("recovery id invalid");let U=v===2||v===3?S+t.n:S;if(U>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let k=v&1?"03":"02",z=f.fromHex(k+_(U)),H=a(U),M=c(-C*H),q=c(w*H),V=f.BASE.multiplyAndAddUnsafe(z,M,q);if(!V)throw new Error("point at infinify");return V.assertValidity(),V}hasHighS(){return i(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return Wt(this.toDERHex())}toDERHex(){return Ct.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Wt(this.toCompactHex())}toCompactHex(){return _(this.r)+_(this.s)}}let p={isValidPrivateKey(T){try{return y(T),!0}catch{return!1}},normPrivateKeyToScalar:y,randomPrivateKey:()=>{let T=Vr(t.n);return yo(t.randomBytes(T),t.n)},precompute(T=8,L=f.BASE){return L._setWindowSize(T),L.multiply(BigInt(3)),L}};function m(T,L=!0){return f.fromPrivateKey(T).toRawBytes(L)}function u(T){let L=Mt(T),S=typeof T=="string",w=(L||S)&&T.length;return L?w===o||w===s:S?w===2*o||w===2*s:T instanceof f}function E(T,L,S=!0){if(u(T))throw new Error("first arg must be private key");if(!u(L))throw new Error("second arg must be public key");return f.fromHex(L).multiply(y(T)).toRawBytes(S)}let B=t.bits2int||function(T){if(T.length>8192)throw new Error("input is too large");let L=It(T),S=T.length*8-t.nBitLength;return S>0?L>>BigInt(S):L},A=t.bits2int_modN||function(T){return c(B(T))},b=Ae(t.nBitLength);function I(T){return at("num < 2^"+t.nBitLength,T,Lt,b),Ot(T,t.nByteLength)}function R(T,L,S=K){if(["recovered","canonical"].some(Q=>Q in S))throw new Error("sign() legacy options not supported");let{hash:w,randomBytes:v}=t,{lowS:C,prehash:U,extraEntropy:k}=S;C==null&&(C=!0),T=j("msgHash",T),Qo(S),U&&(T=j("prehashed msgHash",w(T)));let z=A(T),H=y(L),M=[I(H),I(z)];if(k!=null&&k!==!1){let Q=k===!0?v(e.BYTES):k;M.push(j("extraEntropy",Q))}let q=Tt(...M),V=z;function $(Q){let tt=B(Q);if(!g(tt))return;let et=a(tt),it=f.BASE.multiply(tt).toAffine(),nt=c(it.x);if(nt===Lt)return;let bt=c(et*c(V+nt*H));if(bt===Lt)return;let Et=(it.x===nt?0:2)|Number(it.y&J),xe=bt;return C&&i(bt)&&(xe=l(bt),Et^=1),new x(nt,xe,Et)}return{seed:q,k2sig:$}}let K={lowS:t.lowS,prehash:!1},P={lowS:t.lowS,prehash:!1};function O(T,L,S=K){let{seed:w,k2sig:v}=R(T,L,S),C=t;return Hr(C.hash.outputLen,C.nByteLength,C.hmac)(w,v)}f.BASE._setWindowSize(8);function N(T,L,S,w=P){let v=T;L=j("msgHash",L),S=j("publicKey",S);let{lowS:C,prehash:U,format:k}=w;if(Qo(w),"strict"in w)throw new Error("options.strict was renamed to lowS");if(k!==void 0&&k!=="compact"&&k!=="der")throw new Error("format must be compact or der");let z=typeof v=="string"||Mt(v),H=!z&&!k&&typeof v=="object"&&v!==null&&typeof v.r=="bigint"&&typeof v.s=="bigint";if(!z&&!H)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let M,q;try{if(H&&(M=new x(v.r,v.s)),z){try{k!=="compact"&&(M=x.fromDER(v))}catch(Et){if(!(Et instanceof Ct.Err))throw Et}!M&&k!=="der"&&(M=x.fromCompact(v))}q=f.fromHex(S)}catch{return!1}if(!M||C&&M.hasHighS())return!1;U&&(L=t.hash(L));let{r:V,s:$}=M,Q=A(L),tt=a($),et=c(Q*tt),it=c(V*tt),nt=f.BASE.multiplyAndAddUnsafe(q,et,it)?.toAffine();return nt?c(nt.x)===V:!1}return{CURVE:t,getPublicKey:m,getSharedSecret:E,sign:O,verify:N,ProjectivePoint:f,Signature:x,utils:p}}function ma(r){return{hash:r,hmac:(t,...e)=>vn(r,t,Ur(...e)),randomBytes:Ze}}function es(r,t){let e=n=>ts({...r,...ma(n)});return Object.freeze({...e(t),create:e})}var os=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),rs=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),xa=BigInt(1),An=BigInt(2),ns=(r,t)=>(r+t/An)/t;function ga(r){let t=os,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),c=BigInt(23),a=BigInt(44),f=BigInt(88),y=r*r*r%t,h=y*y*r%t,g=G(h,e,t)*h%t,_=G(g,e,t)*h%t,i=G(_,An,t)*y%t,l=G(i,o,t)*i%t,d=G(l,s,t)*l%t,x=G(d,a,t)*d%t,p=G(x,f,t)*x%t,m=G(p,a,t)*d%t,u=G(m,e,t)*h%t,E=G(u,c,t)*l%t,B=G(E,n,t)*y%t,A=G(B,An,t);if(!In.eql(In.sqr(A),r))throw new Error("Cannot find square root");return A}var In=Pt(os,void 0,void 0,{sqrt:ga}),re=es({a:BigInt(0),b:BigInt(7),Fp:In,n:rs,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=rs,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-xa*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,c=BigInt("0x100000000000000000000000000000000"),a=ns(s*r,t),f=ns(-n*r,t),y=F(r-a*e-f*o,t),h=F(-a*n-f*s,t),g=y>c,_=h>c;if(g&&(y=t-y),_&&(h=t-h),y>c||h>c)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:g,k1:y,k2neg:_,k2:h}}}},$o),Eh=BigInt(0);var _h=re.ProjectivePoint;function ss(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function is(r,t,e){let n=Re.digest(e instanceof Uint8Array?e:e.subarray());if(ss(n))return n.then(({digest:o})=>re.verify(t,o,r)).catch(o=>{throw new Ue(String(o))});try{return re.verify(t,n.digest,r)}catch(o){throw new Ue(String(o))}}var dr=class{type="secp256k1";raw;_key;constructor(t){this._key=as(t),this.raw=cs(this._key)}toMultihash(){return St.digest(nr(this))}toCID(){return lt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Bt(this.raw,t.raw)}verify(t,e){return is(this._key,e,t)}};function fs(r){return new dr(r)}function cs(r){return re.ProjectivePoint.fromHex(r).toRawBytes(!0)}function as(r){try{return re.ProjectivePoint.fromHex(r),r}catch(t){throw new He(String(t))}}function us(r){let{Type:t,Data:e}=Ne.decode(r.digest),n=e??new Uint8Array;switch(t){case ht.Ed25519:return Co(n);case ht.secp256k1:return fs(n);default:throw new be}}function nr(r){return Ne.encode({Type:ht[r.type],Data:r.raw})}var hs=Symbol.for("nodejs.util.inspect.custom"),ba=114,ke=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[_r]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return lt.createV1(ba,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Bt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Bt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[hs](){return`PeerId(${this.toString()})`}},pr=class extends ke{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},mr=class extends ke{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},xr=class extends ke{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},wa=2336,gr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=St.digest(st(this.url))}[hs](){return`PeerId(${this.url})`}[_r]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return lt.createV1(wa,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=hr(t)),t.toString()===this.toString())}};function ls(r){if(Ea(r))return new pr({multihash:r});if(ya(r))try{let t=us(r);if(t.type==="Ed25519")return new mr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new xr({multihash:r,publicKey:t})}catch{let e=hr(r.digest);return new gr(new URL(e))}throw new Ke("Supplied PeerID Multihash is invalid")}function ya(r){return r.code===St.code}function Ea(r){return r.code===Re.code}function yt(r,t){let e={[Symbol.iterator]:()=>e,next:()=>{let n=r.next(),o=n.value;return n.done===!0||o==null?{done:!0,value:void 0}:{done:!1,value:t(o)}}};return e}function br(r){let t=_e(X.decode(`z${r}`));return ls(t)}var Ft=class{map;constructor(t){if(this.map=new Map,t!=null)for(let[e,n]of t.entries())this.map.set(e.toString(),{key:e,value:n})}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(t){return this.map.delete(t.toString())}entries(){return yt(this.map.entries(),t=>[t[1].key,t[1].value])}forEach(t){this.map.forEach((e,n)=>{t(e.value,e.key,this)})}get(t){return this.map.get(t.toString())?.value}has(t){return this.map.has(t.toString())}set(t,e){this.map.set(t.toString(),{key:t,value:e})}keys(){return yt(this.map.values(),t=>t.key)}values(){return yt(this.map.values(),t=>t.value)}get size(){return this.map.size}};function ds(){return new Ft}var Vt=class r{set;constructor(t){if(this.set=new Set,t!=null)for(let e of t)this.set.add(e.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(t){this.set.add(t.toString())}clear(){this.set.clear()}delete(t){this.set.delete(t.toString())}entries(){return yt(this.set.entries(),t=>{let e=br(t[0]);return[e,e]})}forEach(t){this.set.forEach(e=>{let n=br(e);t(n,n,this)})}has(t){return this.set.has(t.toString())}values(){return yt(this.set.values(),t=>br(t))}intersection(t){let e=new r;for(let n of t)this.has(n)&&e.add(n);return e}difference(t){let e=new r;for(let n of this)t.has(n)||e.add(n);return e}union(t){let e=new r;for(let n of t)e.add(n);for(let n of this)e.add(n);return e}};function ps(){return new Vt}var Zt=class r{list;constructor(t){if(this.list=[],t!=null)for(let e of t)this.list.push(e)}[Symbol.iterator](){return yt(this.list.entries(),t=>t[1])}concat(t){let e=new r(this);for(let n of t)e.push(n);return e}entries(){return yt(this.list.entries(),t=>[t[0],t[1]])}every(t){return this.list.every((e,n)=>t(e,n,this))}filter(t){let e=new r;return this.list.forEach((n,o)=>{t(n,o,this)&&e.push(n)}),e}find(t){let e=this.list.find((n,o)=>t(n,o,this));if(e!=null)return e}findIndex(t){return this.list.findIndex((e,n)=>t(e,n,this))}forEach(t){this.list.forEach((e,n)=>{t(e,n,this)})}includes(t){return this.includes(t)}indexOf(t){return this.list.findIndex(e=>e.equals(t))}pop(){let t=this.list.pop();if(t!=null)return t}push(...t){for(let e of t)this.list.push(e)}shift(){let t=this.list.shift();if(t!=null)return t}unshift(...t){let e=this.list.length;for(let n=t.length-1;n>-1;n--)e=this.list.unshift(t[n]);return e}clear(){this.list=[]}get length(){return this.list.length}};function ms(){return new Zt}var Tn=64,gt=class{fp;h;seed;constructor(t,e,n,o=2){if(o>Tn)throw new TypeError("Invalid Fingerprint Size");let s=e.hashV(t,n),c=Lo(o);for(let a=0;a<c.length;a++)c[a]=s[a];c.length===0&&(c[0]=7),this.fp=c,this.h=e,this.seed=n}hash(){return this.h.hash(this.fp,this.seed)}equals(t){return t?.fp instanceof Uint8Array?Bt(this.fp,t.fp):!1}};function ne(r,t){return Math.floor(Math.random()*(t-r))+r}var oe=class{contents;constructor(t){this.contents=new Array(t).fill(null)}has(t){if(!(t instanceof gt))throw new TypeError("Invalid Fingerprint");return this.contents.some(e=>t.equals(e))}add(t){if(!(t instanceof gt))throw new TypeError("Invalid Fingerprint");for(let e=0;e<this.contents.length;e++)if(this.contents[e]==null)return this.contents[e]=t,!0;return!0}swap(t){if(!(t instanceof gt))throw new TypeError("Invalid Fingerprint");let e=ne(0,this.contents.length-1),n=this.contents[e];return this.contents[e]=t,n}remove(t){if(!(t instanceof gt))throw new TypeError("Invalid Fingerprint");let e=this.contents.findIndex(n=>t.equals(n));return e>-1?(this.contents[e]=null,!0):!1}};var Rn={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},ws={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},ys=new globalThis.TextEncoder;function _a(r,t){let e=Rn[t],n=ws[t];for(let o=0;o<r.length;o++)n^=BigInt(r[o]),n=BigInt.asUintN(t,n*e);return n}function Sa(r,t,e){if(e.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");let n=Rn[t],o=ws[t],s=r;for(;s.length>0;){let c=ys.encodeInto(s,e);s=s.slice(c.read);for(let a=0;a<c.written;a++)o^=BigInt(e[a]),o=BigInt.asUintN(t,o*n)}return o}function Cn(r,{size:t=32,utf8Buffer:e}={}){if(!Rn[t])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if(typeof r=="string"){if(e)return Sa(r,t,e);r=ys.encode(r)}return _a(r,t)}var Ba=zs(bs(),1);var De={hash:r=>Number(Cn(r,{size:32})),hashV:(r,t)=>va(De.hash(r,t))};function va(r){let t=r.toString(16);return t.length%2===1&&(t=`0${t}`),st(t,"base16")}var Aa=500,Oe=class{bucketSize;filterSize;fingerprintSize;buckets;count;hash;seed;constructor(t){this.filterSize=t.filterSize,this.bucketSize=t.bucketSize??4,this.fingerprintSize=t.fingerprintSize??2,this.count=0,this.buckets=[],this.hash=t.hash??De,this.seed=t.seed??ne(0,Math.pow(2,10))}add(t){typeof t=="string"&&(t=st(t));let e=new gt(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=(n^e.hash())%this.filterSize;if(this.buckets[n]==null&&(this.buckets[n]=new oe(this.bucketSize)),this.buckets[o]==null&&(this.buckets[o]=new oe(this.bucketSize)),this.buckets[n].add(e)||this.buckets[o].add(e))return this.count++,!0;let s=[n,o],c=s[ne(0,s.length-1)];this.buckets[c]==null&&(this.buckets[c]=new oe(this.bucketSize));for(let a=0;a<Aa;a++){let f=this.buckets[c].swap(e);if(f!=null&&(c=(c^f.hash())%this.filterSize,this.buckets[c]==null&&(this.buckets[c]=new oe(this.bucketSize)),this.buckets[c].add(f)))return this.count++,!0}return!1}has(t){typeof t=="string"&&(t=st(t));let e=new gt(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.has(e)??!1;if(o)return o;let s=(n^e.hash())%this.filterSize;return this.buckets[s]?.has(e)??!1}remove(t){typeof t=="string"&&(t=st(t));let e=new gt(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.remove(e)??!1;if(o)return this.count--,o;let s=(n^e.hash())%this.filterSize,c=this.buckets[s]?.remove(e)??!1;return c&&this.count--,c}get reliable(){return Math.floor(100*(this.count/this.filterSize))<=90}},Ia={1:.5,2:.84,4:.95,8:.98};function Ta(r=.001){return r>.002?2:r>1e-5?4:8}function Es(r,t=.001){let e=Ta(t),n=Ia[e],o=Math.round(r/n),s=Math.min(Math.ceil(Math.log2(1/t)+Math.log2(2*e)),Tn);return{filterSize:o,bucketSize:e,fingerprintSize:s}}var yr=class{filterSize;bucketSize;fingerprintSize;scale;filterSeries;hash;seed;constructor(t){this.bucketSize=t.bucketSize??4,this.filterSize=t.filterSize??(1<<18)/this.bucketSize,this.fingerprintSize=t.fingerprintSize??2,this.scale=t.scale??2,this.hash=t.hash??De,this.seed=t.seed??ne(0,Math.pow(2,10)),this.filterSeries=[new Oe({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(t){if(typeof t=="string"&&(t=st(t)),this.has(t))return!0;let e=this.filterSeries.find(n=>n.reliable);if(e==null){let n=this.filterSize*Math.pow(this.scale,this.filterSeries.length);e=new Oe({filterSize:n,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(e)}return e.add(t)}has(t){typeof t=="string"&&(t=st(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].has(t))return!0;return!1}remove(t){typeof t=="string"&&(t=st(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].remove(t))return!0;return!1}get count(){return this.filterSeries.reduce((t,e)=>t+e.count,0)}};function Ln(r,t=.001,e){return new yr({...Es(r,t),...e??{}})}var Pe=class{filter;constructor(t,e){this.filter=Ln(t,e)}has(t){return this.filter.has(t.toMultihash().bytes)}add(t){this.filter.add(t.toMultihash().bytes)}remove(t){this.filter.remove?.(t.toMultihash().bytes)}};function _s(r,t=.001){return new Pe(r,t)}var Nn=class extends Ft{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}set(t,e){return super.set(t,e),this.updateComponentMetric(),this}delete(t){let e=super.delete(t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function Ss(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Nn({name:t,metrics:e}):n=new Ft,n}var Un=class extends Vt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}add(t){super.add(t),this.updateComponentMetric()}delete(t){super.delete(t),this.updateComponentMetric()}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function Bs(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Un({name:t,metrics:e}):n=new Vt,n}var kn=class extends Zt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}pop(){let t=super.pop();return this.updateComponentMetric(),t}push(...t){super.push(...t),this.updateComponentMetric()}shift(){let t=super.shift();return this.updateComponentMetric(),t}unshift(...t){let e=super.unshift(...t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.length)}};function vs(r){let{name:t,metrics:e}=r,n;return e!=null?n=new kn({name:t,metrics:e}):n=new Zt,n}return Hs(Ra);})();
2
+ "use strict";var Libp2PPeerCollections=(()=>{var Ms=Object.create;var ze=Object.defineProperty;var Ds=Object.getOwnPropertyDescriptor;var Os=Object.getOwnPropertyNames;var Ps=Object.getPrototypeOf,zs=Object.prototype.hasOwnProperty;var Fn=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),ct=(r,t)=>{for(var e in t)ze(r,e,{get:t[e],enumerable:!0})},Vn=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Os(t))!zs.call(r,o)&&o!==e&&ze(r,o,{get:()=>t[o],enumerable:!(n=Ds(t,o))||n.enumerable});return r};var Hs=(r,t,e)=>(e=r!=null?Ms(Ps(r)):{},Vn(t||!r||!r.__esModule?ze(e,"default",{value:r,enumerable:!0}):e,r)),Ks=r=>Vn(ze({},"__esModule",{value:!0}),r);var gs=Fn((Me,wr)=>{(function(r,t){"use strict";var e={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function n(i){if(!Array.isArray(i)&&!ArrayBuffer.isView(i))return!1;for(var l=0;l<i.length;l++)if(!Number.isInteger(i[l])||i[l]<0||i[l]>255)return!1;return!0}function o(i,l){return(i&65535)*l+(((i>>>16)*l&65535)<<16)}function s(i,l){return i<<l|i>>>32-l}function c(i){return i^=i>>>16,i=o(i,2246822507),i^=i>>>13,i=o(i,3266489909),i^=i>>>16,i}function a(i,l){i=[i[0]>>>16,i[0]&65535,i[1]>>>16,i[1]&65535],l=[l[0]>>>16,l[0]&65535,l[1]>>>16,l[1]&65535];var d=[0,0,0,0];return d[3]+=i[3]+l[3],d[2]+=d[3]>>>16,d[3]&=65535,d[2]+=i[2]+l[2],d[1]+=d[2]>>>16,d[2]&=65535,d[1]+=i[1]+l[1],d[0]+=d[1]>>>16,d[1]&=65535,d[0]+=i[0]+l[0],d[0]&=65535,[d[0]<<16|d[1],d[2]<<16|d[3]]}function f(i,l){i=[i[0]>>>16,i[0]&65535,i[1]>>>16,i[1]&65535],l=[l[0]>>>16,l[0]&65535,l[1]>>>16,l[1]&65535];var d=[0,0,0,0];return d[3]+=i[3]*l[3],d[2]+=d[3]>>>16,d[3]&=65535,d[2]+=i[2]*l[3],d[1]+=d[2]>>>16,d[2]&=65535,d[2]+=i[3]*l[2],d[1]+=d[2]>>>16,d[2]&=65535,d[1]+=i[1]*l[3],d[0]+=d[1]>>>16,d[1]&=65535,d[1]+=i[2]*l[2],d[0]+=d[1]>>>16,d[1]&=65535,d[1]+=i[3]*l[1],d[0]+=d[1]>>>16,d[1]&=65535,d[0]+=i[0]*l[3]+i[1]*l[2]+i[2]*l[1]+i[3]*l[0],d[0]&=65535,[d[0]<<16|d[1],d[2]<<16|d[3]]}function y(i,l){return l%=64,l===32?[i[1],i[0]]:l<32?[i[0]<<l|i[1]>>>32-l,i[1]<<l|i[0]>>>32-l]:(l-=32,[i[1]<<l|i[0]>>>32-l,i[0]<<l|i[1]>>>32-l])}function h(i,l){return l%=64,l===0?i:l<32?[i[0]<<l|i[1]>>>32-l,i[1]<<l]:[i[1]<<l-32,0]}function g(i,l){return[i[0]^l[0],i[1]^l[1]]}function _(i){return i=g(i,[0,i[0]>>>1]),i=f(i,[4283543511,3981806797]),i=g(i,[0,i[0]>>>1]),i=f(i,[3301882366,444984403]),i=g(i,[0,i[0]>>>1]),i}e.x86.hash32=function(i,l){if(e.inputValidation&&!n(i))return t;l=l||0;for(var d=i.length%4,x=i.length-d,p=l,m=0,u=3432918353,E=461845907,B=0;B<x;B=B+4)m=i[B]|i[B+1]<<8|i[B+2]<<16|i[B+3]<<24,m=o(m,u),m=s(m,15),m=o(m,E),p^=m,p=s(p,13),p=o(p,5)+3864292196;switch(m=0,d){case 3:m^=i[B+2]<<16;case 2:m^=i[B+1]<<8;case 1:m^=i[B],m=o(m,u),m=s(m,15),m=o(m,E),p^=m}return p^=i.length,p=c(p),p>>>0},e.x86.hash128=function(i,l){if(e.inputValidation&&!n(i))return t;l=l||0;for(var d=i.length%16,x=i.length-d,p=l,m=l,u=l,E=l,B=0,A=0,b=0,I=0,R=597399067,K=2869860233,P=951274213,O=2716044179,U=0;U<x;U=U+16)B=i[U]|i[U+1]<<8|i[U+2]<<16|i[U+3]<<24,A=i[U+4]|i[U+5]<<8|i[U+6]<<16|i[U+7]<<24,b=i[U+8]|i[U+9]<<8|i[U+10]<<16|i[U+11]<<24,I=i[U+12]|i[U+13]<<8|i[U+14]<<16|i[U+15]<<24,B=o(B,R),B=s(B,15),B=o(B,K),p^=B,p=s(p,19),p+=m,p=o(p,5)+1444728091,A=o(A,K),A=s(A,16),A=o(A,P),m^=A,m=s(m,17),m+=u,m=o(m,5)+197830471,b=o(b,P),b=s(b,17),b=o(b,O),u^=b,u=s(u,15),u+=E,u=o(u,5)+2530024501,I=o(I,O),I=s(I,18),I=o(I,R),E^=I,E=s(E,13),E+=p,E=o(E,5)+850148119;switch(B=0,A=0,b=0,I=0,d){case 15:I^=i[U+14]<<16;case 14:I^=i[U+13]<<8;case 13:I^=i[U+12],I=o(I,O),I=s(I,18),I=o(I,R),E^=I;case 12:b^=i[U+11]<<24;case 11:b^=i[U+10]<<16;case 10:b^=i[U+9]<<8;case 9:b^=i[U+8],b=o(b,P),b=s(b,17),b=o(b,O),u^=b;case 8:A^=i[U+7]<<24;case 7:A^=i[U+6]<<16;case 6:A^=i[U+5]<<8;case 5:A^=i[U+4],A=o(A,K),A=s(A,16),A=o(A,P),m^=A;case 4:B^=i[U+3]<<24;case 3:B^=i[U+2]<<16;case 2:B^=i[U+1]<<8;case 1:B^=i[U],B=o(B,R),B=s(B,15),B=o(B,K),p^=B}return p^=i.length,m^=i.length,u^=i.length,E^=i.length,p+=m,p+=u,p+=E,m+=p,u+=p,E+=p,p=c(p),m=c(m),u=c(u),E=c(E),p+=m,p+=u,p+=E,m+=p,u+=p,E+=p,("00000000"+(p>>>0).toString(16)).slice(-8)+("00000000"+(m>>>0).toString(16)).slice(-8)+("00000000"+(u>>>0).toString(16)).slice(-8)+("00000000"+(E>>>0).toString(16)).slice(-8)},e.x64.hash128=function(i,l){if(e.inputValidation&&!n(i))return t;l=l||0;for(var d=i.length%16,x=i.length-d,p=[0,l],m=[0,l],u=[0,0],E=[0,0],B=[2277735313,289559509],A=[1291169091,658871167],b=0;b<x;b=b+16)u=[i[b+4]|i[b+5]<<8|i[b+6]<<16|i[b+7]<<24,i[b]|i[b+1]<<8|i[b+2]<<16|i[b+3]<<24],E=[i[b+12]|i[b+13]<<8|i[b+14]<<16|i[b+15]<<24,i[b+8]|i[b+9]<<8|i[b+10]<<16|i[b+11]<<24],u=f(u,B),u=y(u,31),u=f(u,A),p=g(p,u),p=y(p,27),p=a(p,m),p=a(f(p,[0,5]),[0,1390208809]),E=f(E,A),E=y(E,33),E=f(E,B),m=g(m,E),m=y(m,31),m=a(m,p),m=a(f(m,[0,5]),[0,944331445]);switch(u=[0,0],E=[0,0],d){case 15:E=g(E,h([0,i[b+14]],48));case 14:E=g(E,h([0,i[b+13]],40));case 13:E=g(E,h([0,i[b+12]],32));case 12:E=g(E,h([0,i[b+11]],24));case 11:E=g(E,h([0,i[b+10]],16));case 10:E=g(E,h([0,i[b+9]],8));case 9:E=g(E,[0,i[b+8]]),E=f(E,A),E=y(E,33),E=f(E,B),m=g(m,E);case 8:u=g(u,h([0,i[b+7]],56));case 7:u=g(u,h([0,i[b+6]],48));case 6:u=g(u,h([0,i[b+5]],40));case 5:u=g(u,h([0,i[b+4]],32));case 4:u=g(u,h([0,i[b+3]],24));case 3:u=g(u,h([0,i[b+2]],16));case 2:u=g(u,h([0,i[b+1]],8));case 1:u=g(u,[0,i[b]]),u=f(u,B),u=y(u,31),u=f(u,A),p=g(p,u)}return p=g(p,[0,i.length]),m=g(m,[0,i.length]),p=a(p,m),m=a(m,p),p=_(p),m=_(m),p=a(p,m),m=a(m,p),("00000000"+(p[0]>>>0).toString(16)).slice(-8)+("00000000"+(p[1]>>>0).toString(16)).slice(-8)+("00000000"+(m[0]>>>0).toString(16)).slice(-8)+("00000000"+(m[1]>>>0).toString(16)).slice(-8)},typeof Me<"u"?(typeof wr<"u"&&wr.exports&&(Me=wr.exports=e),Me.murmurHash3=e):typeof define=="function"&&define.amd?define([],function(){return e}):(e._murmurHash3=r.murmurHash3,e.noConflict=function(){return r.murmurHash3=e._murmurHash3,e._murmurHash3=t,e.noConflict=t,e},r.murmurHash3=e)})(Me)});var ws=Fn((P0,bs)=>{bs.exports=gs()});var Ca={};ct(Ca,{PeerFilter:()=>Pe,PeerList:()=>Zt,PeerMap:()=>Ft,PeerSet:()=>Vt,peerFilter:()=>Ss,peerList:()=>xs,peerMap:()=>ps,peerSet:()=>ms,trackedPeerList:()=>As,trackedPeerMap:()=>Bs,trackedPeerSet:()=>vs});var _r=Symbol.for("@libp2p/peer-id");var ge=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},He=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Ke=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var be=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Ir={};ct(Ir,{base58btc:()=>X,base58flickr:()=>js});var ka=new Uint8Array(0);function Zn(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function _t(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Gn(r){return new TextEncoder().encode(r)}function jn(r){return new TextDecoder().decode(r)}function qs(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),c=s.charCodeAt(0);if(e[c]!==255)throw new TypeError(s+" is ambiguous");e[c]=o}var a=r.length,f=r.charAt(0),y=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function g(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var d=0,x=0,p=0,m=l.length;p!==m&&l[p]===0;)p++,d++;for(var u=(m-p)*h+1>>>0,E=new Uint8Array(u);p!==m;){for(var B=l[p],A=0,b=u-1;(B!==0||A<x)&&b!==-1;b--,A++)B+=256*E[b]>>>0,E[b]=B%a>>>0,B=B/a>>>0;if(B!==0)throw new Error("Non-zero carry");x=A,p++}for(var I=u-x;I!==u&&E[I]===0;)I++;for(var R=f.repeat(d);I<u;++I)R+=r.charAt(E[I]);return R}function _(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var d=0;if(l[d]!==" "){for(var x=0,p=0;l[d]===f;)x++,d++;for(var m=(l.length-d)*y+1>>>0,u=new Uint8Array(m);l[d];){var E=e[l.charCodeAt(d)];if(E===255)return;for(var B=0,A=m-1;(E!==0||B<p)&&A!==-1;A--,B++)E+=a*u[A]>>>0,u[A]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");p=B,d++}if(l[d]!==" "){for(var b=m-p;b!==m&&u[b]===0;)b++;for(var I=new Uint8Array(x+(m-b)),R=x;b!==m;)I[R++]=u[b++];return I}}}function i(l){var d=_(l);if(d)return d;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:_,decode:i}}var Fs=qs,Vs=Fs,Xn=Vs;var Sr=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Br=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Wn(this,t)}},vr=class{decoders;constructor(t){this.decoders=t}or(t){return Wn(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Wn(r,t){return new vr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Ar=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Sr(t,e,n),this.decoder=new Br(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function se({name:r,prefix:t,encode:e,decode:n}){return new Ar(r,t,e,n)}function Ut({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Xn(e,r);return se({prefix:t,name:r,encode:n,decode:s=>_t(o(s))})}function Zs(r,t,e,n){let o={};for(let h=0;h<t.length;++h)o[t[h]]=h;let s=r.length;for(;r[s-1]==="=";)--s;let c=new Uint8Array(s*e/8|0),a=0,f=0,y=0;for(let h=0;h<s;++h){let g=o[r[h]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<e|g,a+=e,a>=8&&(a-=8,c[y++]=255&f>>a)}if(a>=e||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return c}function Gs(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",c=0,a=0;for(let f=0;f<r.length;++f)for(a=a<<8|r[f],c+=8;c>e;)c-=e,s+=t[o&a>>c];if(c!==0&&(s+=t[o&a<<e-c]),n)for(;s.length*e&7;)s+="=";return s}function Y({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return se({prefix:t,name:r,encode(o){return Gs(o,n,e)},decode(o){return Zs(o,n,e,r)}})}var X=Ut({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),js=Ut({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Tr={};ct(Tr,{base32:()=>ie,base32hex:()=>$s,base32hexpad:()=>Js,base32hexpadupper:()=>ti,base32hexupper:()=>Qs,base32pad:()=>Xs,base32padupper:()=>Ws,base32upper:()=>Ys,base32z:()=>ei});var ie=Y({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ys=Y({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Xs=Y({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ws=Y({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),$s=Y({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Qs=Y({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Js=Y({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ti=Y({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ei=Y({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Rr={};ct(Rr,{base36:()=>we,base36upper:()=>ri});var we=Ut({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ri=Ut({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ni=Jn,$n=128,oi=127,si=~oi,ii=Math.pow(2,31);function Jn(r,t,e){t=t||[],e=e||0;for(var n=e;r>=ii;)t[e++]=r&255|$n,r/=128;for(;r&si;)t[e++]=r&255|$n,r>>>=7;return t[e]=r|0,Jn.bytes=e-n+1,t}var ci=Cr,ai=128,Qn=127;function Cr(r,n){var e=0,n=n||0,o=0,s=n,c,a=r.length;do{if(s>=a)throw Cr.bytes=0,new RangeError("Could not decode varint");c=r[s++],e+=o<28?(c&Qn)<<o:(c&Qn)*Math.pow(2,o),o+=7}while(c>=ai);return Cr.bytes=s-n,e}var fi=Math.pow(2,7),ui=Math.pow(2,14),hi=Math.pow(2,21),li=Math.pow(2,28),di=Math.pow(2,35),pi=Math.pow(2,42),mi=Math.pow(2,49),xi=Math.pow(2,56),gi=Math.pow(2,63),bi=function(r){return r<fi?1:r<ui?2:r<hi?3:r<li?4:r<di?5:r<pi?6:r<mi?7:r<xi?8:r<gi?9:10},wi={encode:ni,decode:ci,encodingLength:bi},yi=wi,ye=yi;function Ee(r,t=0){return[ye.decode(r,t),ye.decode.bytes]}function ce(r,t,e=0){return ye.encode(r,t,e),t}function ae(r){return ye.encodingLength(r)}function Gt(r,t){let e=t.byteLength,n=ae(r),o=n+ae(e),s=new Uint8Array(o+e);return ce(r,s,0),ce(e,s,n),s.set(t,o),new fe(r,e,t,s)}function _e(r){let t=_t(r),[e,n]=Ee(t),[o,s]=Ee(t.subarray(n)),c=t.subarray(n+s);if(c.byteLength!==o)throw new Error("Incorrect length");return new fe(e,o,c,t)}function to(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Zn(r.bytes,e.bytes)}}var fe=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function eo(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return _i(e,Lr(r),t??X.encoder);default:return Si(e,Lr(r),t??ie.encoder)}}var ro=new WeakMap;function Lr(r){let t=ro.get(r);if(t==null){let e=new Map;return ro.set(r,e),e}return t}var lt=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Se)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Bi)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Gt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&to(t.multihash,n.multihash)}toString(t){return eo(this,t)}toJSON(){return{"/":eo(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:c}=e;return new r(n,o,s,c??no(n,o,s.bytes))}else if(e[vi]===!0){let{version:n,multihash:o,code:s}=e,c=_e(o);return r.create(n,s,c)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Se)throw new Error(`Version 0 CID must use dag-pb (code: ${Se}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=no(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Se,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=_t(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),c=new fe(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(c):r.createV1(e.codec,c),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[g,_]=Ee(t.subarray(e));return e+=_,g},o=n(),s=Se;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let c=e,a=n(),f=n(),y=e+f,h=y-c;return{version:o,codec:s,multihashCode:a,digestSize:f,multihashSize:h,size:y}}static parse(t,e){let[n,o]=Ei(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Lr(s).set(n,t),s}};function Ei(r,t){switch(r[0]){case"Q":{let e=t??X;return[X.prefix,e.decode(`${X.prefix}${r}`)]}case X.prefix:{let e=t??X;return[X.prefix,e.decode(r)]}case ie.prefix:{let e=t??ie;return[ie.prefix,e.decode(r)]}case we.prefix:{let e=t??we;return[we.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function _i(r,t,e){let{prefix:n}=e;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function Si(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var Se=112,Bi=18;function no(r,t,e){let n=ae(r),o=n+ae(t),s=new Uint8Array(o+e.byteLength);return ce(r,s,0),ce(t,s,n),s.set(e,o),s}var vi=Symbol.for("@ipld/js-cid/CID");var Ur={};ct(Ur,{identity:()=>St});var oo=0,Ai="identity",so=_t;function Ii(r){return Gt(oo,so(r))}var St={code:oo,name:Ai,encode:so,digest:Ii};function Bt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function io(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Ti(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ue(r,...t){if(!Ti(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function co(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");io(r.outputLen),io(r.blockLen)}function he(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function ao(r,t){ue(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var Yt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Fe=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),dt=(r,t)=>r<<32-t|r>>>t;function fo(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Be(r){return typeof r=="string"&&(r=fo(r)),ue(r),r}function Nr(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];ue(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var le=class{clone(){return this._cloneInto()}};function Ve(r){let t=n=>r().update(Be(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Ze(r=32){if(Yt&&typeof Yt.getRandomValues=="function")return Yt.getRandomValues(new Uint8Array(r));if(Yt&&typeof Yt.randomBytes=="function")return Yt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Ri(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),c=Number(e>>o&s),a=Number(e&s),f=n?4:0,y=n?0:4;r.setUint32(t+f,c,n),r.setUint32(t+y,a,n)}var uo=(r,t,e)=>r&t^~r&e,ho=(r,t,e)=>r&t^r&e^t&e,de=class extends le{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Fe(this.buffer)}update(t){he(this);let{view:e,buffer:n,blockLen:o}=this;t=Be(t);let s=t.length;for(let c=0;c<s;){let a=Math.min(o-this.pos,s-c);if(a===o){let f=Fe(t);for(;o<=s-c;c+=o)this.process(f,c);continue}n.set(t.subarray(c,c+a),this.pos),this.pos+=a,c+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){he(this),ao(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:c}=this;e[c++]=128,this.buffer.subarray(c).fill(0),this.padOffset>o-c&&(this.process(n,0),c=0);for(let g=c;g<o;g++)e[g]=0;Ri(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=Fe(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let y=f/4,h=this.get();if(y>h.length)throw new Error("_sha2: outputLen bigger than state");for(let g=0;g<y;g++)a.setUint32(4*g,h[g],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:c,pos:a}=this;return t.length=o,t.pos=a,t.finished=s,t.destroyed=c,o%e&&t.buffer.set(n),t}};var Ge=BigInt(4294967295),kr=BigInt(32);function lo(r,t=!1){return t?{h:Number(r&Ge),l:Number(r>>kr&Ge)}:{h:Number(r>>kr&Ge)|0,l:Number(r&Ge)|0}}function Ci(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:c}=lo(r[o],t);[e[o],n[o]]=[s,c]}return[e,n]}var Li=(r,t)=>BigInt(r>>>0)<<kr|BigInt(t>>>0),Ui=(r,t,e)=>r>>>e,Ni=(r,t,e)=>r<<32-e|t>>>e,ki=(r,t,e)=>r>>>e|t<<32-e,Mi=(r,t,e)=>r<<32-e|t>>>e,Di=(r,t,e)=>r<<64-e|t>>>e-32,Oi=(r,t,e)=>r>>>e-32|t<<64-e,Pi=(r,t)=>t,zi=(r,t)=>r,Hi=(r,t,e)=>r<<e|t>>>32-e,Ki=(r,t,e)=>t<<e|r>>>32-e,qi=(r,t,e)=>t<<e-32|r>>>64-e,Fi=(r,t,e)=>r<<e-32|t>>>64-e;function Vi(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var Zi=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Gi=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,ji=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Yi=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Xi=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Wi=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var $i={fromBig:lo,split:Ci,toBig:Li,shrSH:Ui,shrSL:Ni,rotrSH:ki,rotrSL:Mi,rotrBH:Di,rotrBL:Oi,rotr32H:Pi,rotr32L:zi,rotlSH:Hi,rotlSL:Ki,rotlBH:qi,rotlBL:Fi,add:Vi,add3L:Zi,add3H:Gi,add4L:ji,add4H:Yi,add5H:Wi,add5L:Xi},D=$i;var[Qi,Ji]=D.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Nt=new Uint32Array(80),kt=new Uint32Array(80),Mr=class extends de{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:c,Dh:a,Dl:f,Eh:y,El:h,Fh:g,Fl:_,Gh:i,Gl:l,Hh:d,Hl:x}=this;return[t,e,n,o,s,c,a,f,y,h,g,_,i,l,d,x]}set(t,e,n,o,s,c,a,f,y,h,g,_,i,l,d,x){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=c|0,this.Dh=a|0,this.Dl=f|0,this.Eh=y|0,this.El=h|0,this.Fh=g|0,this.Fl=_|0,this.Gh=i|0,this.Gl=l|0,this.Hh=d|0,this.Hl=x|0}process(t,e){for(let u=0;u<16;u++,e+=4)Nt[u]=t.getUint32(e),kt[u]=t.getUint32(e+=4);for(let u=16;u<80;u++){let E=Nt[u-15]|0,B=kt[u-15]|0,A=D.rotrSH(E,B,1)^D.rotrSH(E,B,8)^D.shrSH(E,B,7),b=D.rotrSL(E,B,1)^D.rotrSL(E,B,8)^D.shrSL(E,B,7),I=Nt[u-2]|0,R=kt[u-2]|0,K=D.rotrSH(I,R,19)^D.rotrBH(I,R,61)^D.shrSH(I,R,6),P=D.rotrSL(I,R,19)^D.rotrBL(I,R,61)^D.shrSL(I,R,6),O=D.add4L(b,P,kt[u-7],kt[u-16]),U=D.add4H(O,A,K,Nt[u-7],Nt[u-16]);Nt[u]=U|0,kt[u]=O|0}let{Ah:n,Al:o,Bh:s,Bl:c,Ch:a,Cl:f,Dh:y,Dl:h,Eh:g,El:_,Fh:i,Fl:l,Gh:d,Gl:x,Hh:p,Hl:m}=this;for(let u=0;u<80;u++){let E=D.rotrSH(g,_,14)^D.rotrSH(g,_,18)^D.rotrBH(g,_,41),B=D.rotrSL(g,_,14)^D.rotrSL(g,_,18)^D.rotrBL(g,_,41),A=g&i^~g&d,b=_&l^~_&x,I=D.add5L(m,B,b,Ji[u],kt[u]),R=D.add5H(I,p,E,A,Qi[u],Nt[u]),K=I|0,P=D.rotrSH(n,o,28)^D.rotrBH(n,o,34)^D.rotrBH(n,o,39),O=D.rotrSL(n,o,28)^D.rotrBL(n,o,34)^D.rotrBL(n,o,39),U=n&s^n&a^s&a,T=o&c^o&f^c&f;p=d|0,m=x|0,d=i|0,x=l|0,i=g|0,l=_|0,{h:g,l:_}=D.add(y|0,h|0,R|0,K|0),y=a|0,h=f|0,a=s|0,f=c|0,s=n|0,c=o|0;let L=D.add3L(K,O,T);n=D.add3H(L,R,P,U),o=L|0}({h:n,l:o}=D.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:c}=D.add(this.Bh|0,this.Bl|0,s|0,c|0),{h:a,l:f}=D.add(this.Ch|0,this.Cl|0,a|0,f|0),{h:y,l:h}=D.add(this.Dh|0,this.Dl|0,y|0,h|0),{h:g,l:_}=D.add(this.Eh|0,this.El|0,g|0,_|0),{h:i,l}=D.add(this.Fh|0,this.Fl|0,i|0,l|0),{h:d,l:x}=D.add(this.Gh|0,this.Gl|0,d|0,x|0),{h:p,l:m}=D.add(this.Hh|0,this.Hl|0,p|0,m|0),this.set(n,o,s,c,a,f,y,h,g,_,i,l,d,x,p,m)}roundClean(){Nt.fill(0),kt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var po=Ve(()=>new Mr);var Xe={};ct(Xe,{aInRange:()=>at,abool:()=>pt,abytes:()=>pe,bitGet:()=>sc,bitLen:()=>zr,bitMask:()=>Ae,bitSet:()=>ic,bytesToHex:()=>At,bytesToNumberBE:()=>It,bytesToNumberLE:()=>Dt,concatBytes:()=>Tt,createHmacDrbg:()=>Hr,ensureBytes:()=>j,equalBytes:()=>nc,hexToBytes:()=>Wt,hexToNumber:()=>Pr,inRange:()=>ve,isBytes:()=>Mt,memoized:()=>Qt,notImplemented:()=>ac,numberToBytesBE:()=>Ot,numberToBytesLE:()=>$t,numberToHexUnpadded:()=>Xt,numberToVarBytesBE:()=>rc,utf8ToBytes:()=>oc,validateObject:()=>wt});var je=BigInt(0),Ye=BigInt(1),tc=BigInt(2);function Mt(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function pe(r){if(!Mt(r))throw new Error("Uint8Array expected")}function pt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var ec=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function At(r){pe(r);let t="";for(let e=0;e<r.length;e++)t+=ec[r[e]];return t}function Xt(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Pr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?je:BigInt("0x"+r)}var vt={_0:48,_9:57,A:65,F:70,a:97,f:102};function mo(r){if(r>=vt._0&&r<=vt._9)return r-vt._0;if(r>=vt.A&&r<=vt.F)return r-(vt.A-10);if(r>=vt.a&&r<=vt.f)return r-(vt.a-10)}function Wt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let c=mo(r.charCodeAt(s)),a=mo(r.charCodeAt(s+1));if(c===void 0||a===void 0){let f=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+s)}n[o]=c*16+a}return n}function It(r){return Pr(At(r))}function Dt(r){return pe(r),Pr(At(Uint8Array.from(r).reverse()))}function Ot(r,t){return Wt(r.toString(16).padStart(t*2,"0"))}function $t(r,t){return Ot(r,t).reverse()}function rc(r){return Wt(Xt(r))}function j(r,t,e){let n;if(typeof t=="string")try{n=Wt(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(Mt(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function Tt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];pe(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}function nc(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function oc(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var Dr=r=>typeof r=="bigint"&&je<=r;function ve(r,t,e){return Dr(r)&&Dr(t)&&Dr(e)&&t<=r&&r<e}function at(r,t,e,n){if(!ve(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function zr(r){let t;for(t=0;r>je;r>>=Ye,t+=1);return t}function sc(r,t){return r>>BigInt(t)&Ye}function ic(r,t,e){return r|(e?Ye:je)<<BigInt(t)}var Ae=r=>(tc<<BigInt(r-1))-Ye,Or=r=>new Uint8Array(r),xo=r=>Uint8Array.from(r);function Hr(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=Or(r),o=Or(r),s=0,c=()=>{n.fill(1),o.fill(0),s=0},a=(...g)=>e(o,n,...g),f=(g=Or())=>{o=a(xo([0]),g),n=a(),g.length!==0&&(o=a(xo([1]),g),n=a())},y=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let g=0,_=[];for(;g<t;){n=a();let i=n.slice();_.push(i),g+=n.length}return Tt(..._)};return(g,_)=>{c(),f(g);let i;for(;!(i=_(y()));)f();return c(),i}}var cc={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Mt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function wt(r,t,e={}){let n=(o,s,c)=>{let a=cc[s];if(typeof a!="function")throw new Error("invalid validator function");let f=r[o];if(!(c&&f===void 0)&&!a(f,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+f)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}var ac=()=>{throw new Error("not implemented")};function Qt(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var W=BigInt(0),Z=BigInt(1),Jt=BigInt(2),fc=BigInt(3),Kr=BigInt(4),go=BigInt(5),bo=BigInt(8),uc=BigInt(9),hc=BigInt(16);function F(r,t){let e=r%t;return e>=W?e:t+e}function lc(r,t,e){if(t<W)throw new Error("invalid exponent, negatives unsupported");if(e<=W)throw new Error("invalid modulus");if(e===Z)return W;let n=Z;for(;t>W;)t&Z&&(n=n*r%e),r=r*r%e,t>>=Z;return n}function G(r,t,e){let n=r;for(;t-- >W;)n*=n,n%=e;return n}function We(r,t){if(r===W)throw new Error("invert: expected non-zero number");if(t<=W)throw new Error("invert: expected positive modulus, got "+t);let e=F(r,t),n=t,o=W,s=Z,c=Z,a=W;for(;e!==W;){let y=n/e,h=n%e,g=o-c*y,_=s-a*y;n=e,e=h,o=c,s=a,c=g,a=_}if(n!==Z)throw new Error("invert: does not exist");return F(o,t)}function dc(r){let t=(r-Z)/Jt,e,n,o;for(e=r-Z,n=0;e%Jt===W;e/=Jt,n++);for(o=Jt;o<r&&lc(o,t,r)!==r-Z;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let c=(r+Z)/Kr;return function(f,y){let h=f.pow(y,c);if(!f.eql(f.sqr(h),y))throw new Error("Cannot find square root");return h}}let s=(e+Z)/Jt;return function(a,f){if(a.pow(f,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let y=n,h=a.pow(a.mul(a.ONE,o),e),g=a.pow(f,s),_=a.pow(f,e);for(;!a.eql(_,a.ONE);){if(a.eql(_,a.ZERO))return a.ZERO;let i=1;for(let d=a.sqr(_);i<y&&!a.eql(d,a.ONE);i++)d=a.sqr(d);let l=a.pow(h,Z<<BigInt(y-i-1));h=a.sqr(l),g=a.mul(g,l),_=a.mul(_,h),y=i}return g}}function pc(r){if(r%Kr===fc){let t=(r+Z)/Kr;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%bo===go){let t=(r-go)/bo;return function(n,o){let s=n.mul(o,Jt),c=n.pow(s,t),a=n.mul(o,c),f=n.mul(n.mul(a,Jt),c),y=n.mul(a,n.sub(f,n.ONE));if(!n.eql(n.sqr(y),o))throw new Error("Cannot find square root");return y}}return r%hc,dc(r)}var wo=(r,t)=>(F(r,t)&Z)===Z,mc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function qr(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=mc.reduce((n,o)=>(n[o]="function",n),t);return wt(r,e)}function xc(r,t,e){if(e<W)throw new Error("invalid exponent, negatives unsupported");if(e===W)return r.ONE;if(e===Z)return t;let n=r.ONE,o=t;for(;e>W;)e&Z&&(n=r.mul(n,o)),o=r.sqr(o),e>>=Z;return n}function gc(r,t){let e=new Array(t.length),n=t.reduce((s,c,a)=>r.is0(c)?s:(e[a]=s,r.mul(s,c)),r.ONE),o=r.inv(n);return t.reduceRight((s,c,a)=>r.is0(c)?s:(e[a]=r.mul(s,e[a]),r.mul(s,c)),o),e}function Fr(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Pt(r,t,e=!1,n={}){if(r<=W)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=Fr(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c,a=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:Ae(o),ZERO:W,ONE:Z,create:f=>F(f,r),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return W<=f&&f<r},is0:f=>f===W,isOdd:f=>(f&Z)===Z,neg:f=>F(-f,r),eql:(f,y)=>f===y,sqr:f=>F(f*f,r),add:(f,y)=>F(f+y,r),sub:(f,y)=>F(f-y,r),mul:(f,y)=>F(f*y,r),pow:(f,y)=>xc(a,f,y),div:(f,y)=>F(f*We(y,r),r),sqrN:f=>f*f,addN:(f,y)=>f+y,subN:(f,y)=>f-y,mulN:(f,y)=>f*y,inv:f=>We(f,r),sqrt:n.sqrt||(f=>(c||(c=pc(r)),c(a,f))),invertBatch:f=>gc(a,f),cmov:(f,y,h)=>h?y:f,toBytes:f=>e?$t(f,s):Ot(f,s),fromBytes:f=>{if(f.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+f.length);return e?Dt(f):It(f)}});return Object.freeze(a)}function yo(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Vr(r){let t=yo(r);return t+Math.ceil(t/2)}function Eo(r,t,e=!1){let n=r.length,o=yo(t),s=Vr(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let c=e?Dt(r):It(r),a=F(c,t-Z)+Z;return e?$t(a,o):Ot(a,o)}var _o=BigInt(0),$e=BigInt(1);function Zr(r,t){let e=t.negate();return r?e:t}function So(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Gr(r,t){So(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function wc(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function yc(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var jr=new WeakMap,Bo=new WeakMap;function Yr(r){return Bo.get(r)||1}function Qe(r,t){return{constTimeNegate:Zr,hasPrecomputes(e){return Yr(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>_o;)n&$e&&(o=o.add(s)),s=s.double(),n>>=$e;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=Gr(n,t),c=[],a=e,f=a;for(let y=0;y<o;y++){f=a,c.push(f);for(let h=1;h<s;h++)f=f.add(a),c.push(f);a=f.double()}return c},wNAF(e,n,o){let{windows:s,windowSize:c}=Gr(e,t),a=r.ZERO,f=r.BASE,y=BigInt(2**e-1),h=2**e,g=BigInt(e);for(let _=0;_<s;_++){let i=_*c,l=Number(o&y);o>>=g,l>c&&(l-=h,o+=$e);let d=i,x=i+Math.abs(l)-1,p=_%2!==0,m=l<0;l===0?f=f.add(Zr(p,n[d])):a=a.add(Zr(m,n[x]))}return{p:a,f}},wNAFUnsafe(e,n,o,s=r.ZERO){let{windows:c,windowSize:a}=Gr(e,t),f=BigInt(2**e-1),y=2**e,h=BigInt(e);for(let g=0;g<c;g++){let _=g*a;if(o===_o)break;let i=Number(o&f);if(o>>=h,i>a&&(i-=y,o+=$e),i===0)continue;let l=n[_+Math.abs(i)-1];i<0&&(l=l.negate()),s=s.add(l)}return s},getPrecomputes(e,n,o){let s=jr.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&jr.set(n,o(s))),s},wNAFCached(e,n,o){let s=Yr(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let c=Yr(e);return c===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(c,this.getPrecomputes(c,e,o),n,s)},setWindowSize(e,n){So(n,t),Bo.set(e,n),jr.delete(e)}}}function Je(r,t,e,n){if(wc(e,r),yc(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,s=zr(BigInt(e.length)),c=s>12?s-3:s>4?s-2:s?2:1,a=(1<<c)-1,f=new Array(a+1).fill(o),y=Math.floor((t.BITS-1)/c)*c,h=o;for(let g=y;g>=0;g-=c){f.fill(o);for(let i=0;i<n.length;i++){let l=n[i],d=Number(l>>BigInt(g)&BigInt(a));f[d]=f[d].add(e[i])}let _=o;for(let i=f.length-1,l=o;i>0;i--)l=l.add(f[i]),_=_.add(l);if(h=h.add(_),g!==0)for(let i=0;i<c;i++)h=h.double()}return h}function Ie(r){return qr(r.Fp),wt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Fr(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var mt=BigInt(0),ft=BigInt(1),tr=BigInt(2),Ec=BigInt(8),_c={zip215:!0};function Sc(r){let t=Ie(r);return wt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function vo(r){let t=Sc(r),{Fp:e,n,prehash:o,hash:s,randomBytes:c,nByteLength:a,h:f}=t,y=tr<<BigInt(a*8)-ft,h=e.create,g=Pt(t.n,t.nBitLength),_=t.uvRatio||((S,w)=>{try{return{isValid:!0,value:e.sqrt(S*e.inv(w))}}catch{return{isValid:!1,value:mt}}}),i=t.adjustScalarBytes||(S=>S),l=t.domain||((S,w,v)=>{if(pt("phflag",v),w.length||v)throw new Error("Contexts/pre-hash are not supported");return S});function d(S,w){at("coordinate "+S,w,mt,y)}function x(S){if(!(S instanceof u))throw new Error("ExtendedPoint expected")}let p=Qt((S,w)=>{let{ex:v,ey:C,ez:N}=S,k=S.is0();w==null&&(w=k?Ec:e.inv(N));let z=h(v*w),H=h(C*w),M=h(N*w);if(k)return{x:mt,y:ft};if(M!==ft)throw new Error("invZ was invalid");return{x:z,y:H}}),m=Qt(S=>{let{a:w,d:v}=t;if(S.is0())throw new Error("bad point: ZERO");let{ex:C,ey:N,ez:k,et:z}=S,H=h(C*C),M=h(N*N),q=h(k*k),V=h(q*q),$=h(H*w),Q=h(q*h($+M)),tt=h(V+h(v*h(H*M)));if(Q!==tt)throw new Error("bad point: equation left != right (1)");let et=h(C*N),it=h(k*z);if(et!==it)throw new Error("bad point: equation left != right (2)");return!0});class u{constructor(w,v,C,N){this.ex=w,this.ey=v,this.ez=C,this.et=N,d("x",w),d("y",v),d("z",C),d("t",N),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(w){if(w instanceof u)throw new Error("extended point not allowed");let{x:v,y:C}=w||{};return d("x",v),d("y",C),new u(v,C,ft,h(v*C))}static normalizeZ(w){let v=e.invertBatch(w.map(C=>C.ez));return w.map((C,N)=>C.toAffine(v[N])).map(u.fromAffine)}static msm(w,v){return Je(u,g,w,v)}_setWindowSize(w){A.setWindowSize(this,w)}assertValidity(){m(this)}equals(w){x(w);let{ex:v,ey:C,ez:N}=this,{ex:k,ey:z,ez:H}=w,M=h(v*H),q=h(k*N),V=h(C*H),$=h(z*N);return M===q&&V===$}is0(){return this.equals(u.ZERO)}negate(){return new u(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){let{a:w}=t,{ex:v,ey:C,ez:N}=this,k=h(v*v),z=h(C*C),H=h(tr*h(N*N)),M=h(w*k),q=v+C,V=h(h(q*q)-k-z),$=M+z,Q=$-H,tt=M-z,et=h(V*Q),it=h($*tt),nt=h(V*tt),bt=h(Q*$);return new u(et,it,bt,nt)}add(w){x(w);let{a:v,d:C}=t,{ex:N,ey:k,ez:z,et:H}=this,{ex:M,ey:q,ez:V,et:$}=w;if(v===BigInt(-1)){let Dn=h((k-N)*(q+M)),On=h((k+N)*(q-M)),Er=h(On-Dn);if(Er===mt)return this.double();let Pn=h(z*tr*$),zn=h(H*tr*V),Hn=zn+Pn,Kn=On+Dn,qn=zn-Pn,Ls=h(Hn*Er),Us=h(Kn*qn),Ns=h(Hn*qn),ks=h(Er*Kn);return new u(Ls,Us,ks,Ns)}let Q=h(N*M),tt=h(k*q),et=h(H*C*$),it=h(z*V),nt=h((N+k)*(M+q)-Q-tt),bt=it-et,Et=it+et,xe=h(tt-v*Q),Is=h(nt*bt),Ts=h(Et*xe),Rs=h(nt*xe),Cs=h(bt*Et);return new u(Is,Ts,Cs,Rs)}subtract(w){return this.add(w.negate())}wNAF(w){return A.wNAFCached(this,w,u.normalizeZ)}multiply(w){let v=w;at("scalar",v,ft,n);let{p:C,f:N}=this.wNAF(v);return u.normalizeZ([C,N])[0]}multiplyUnsafe(w,v=u.ZERO){let C=w;return at("scalar",C,mt,n),C===mt?B:this.is0()||C===ft?this:A.wNAFCachedUnsafe(this,C,u.normalizeZ,v)}isSmallOrder(){return this.multiplyUnsafe(f).is0()}isTorsionFree(){return A.unsafeLadder(this,n).is0()}toAffine(w){return p(this,w)}clearCofactor(){let{h:w}=t;return w===ft?this:this.multiplyUnsafe(w)}static fromHex(w,v=!1){let{d:C,a:N}=t,k=e.BYTES;w=j("pointHex",w,k),pt("zip215",v);let z=w.slice(),H=w[k-1];z[k-1]=H&-129;let M=Dt(z),q=v?y:e.ORDER;at("pointHex.y",M,mt,q);let V=h(M*M),$=h(V-ft),Q=h(C*V-N),{isValid:tt,value:et}=_($,Q);if(!tt)throw new Error("Point.fromHex: invalid y coordinate");let it=(et&ft)===ft,nt=(H&128)!==0;if(!v&&et===mt&&nt)throw new Error("Point.fromHex: x=0 and x_0=1");return nt!==it&&(et=h(-et)),u.fromAffine({x:et,y:M})}static fromPrivateKey(w){return R(w).point}toRawBytes(){let{x:w,y:v}=this.toAffine(),C=$t(v,e.BYTES);return C[C.length-1]|=w&ft?128:0,C}toHex(){return At(this.toRawBytes())}}u.BASE=new u(t.Gx,t.Gy,ft,h(t.Gx*t.Gy)),u.ZERO=new u(mt,ft,ft,mt);let{BASE:E,ZERO:B}=u,A=Qe(u,a*8);function b(S){return F(S,n)}function I(S){return b(Dt(S))}function R(S){let w=e.BYTES;S=j("private key",S,w);let v=j("hashed private key",s(S),2*w),C=i(v.slice(0,w)),N=v.slice(w,2*w),k=I(C),z=E.multiply(k),H=z.toRawBytes();return{head:C,prefix:N,scalar:k,point:z,pointBytes:H}}function K(S){return R(S).pointBytes}function P(S=new Uint8Array,...w){let v=Tt(...w);return I(s(l(v,j("context",S),!!o)))}function O(S,w,v={}){S=j("message",S),o&&(S=o(S));let{prefix:C,scalar:N,pointBytes:k}=R(w),z=P(v.context,C,S),H=E.multiply(z).toRawBytes(),M=P(v.context,H,k,S),q=b(z+M*N);at("signature.s",q,mt,n);let V=Tt(H,$t(q,e.BYTES));return j("result",V,e.BYTES*2)}let U=_c;function T(S,w,v,C=U){let{context:N,zip215:k}=C,z=e.BYTES;S=j("signature",S,2*z),w=j("message",w),v=j("publicKey",v,z),k!==void 0&&pt("zip215",k),o&&(w=o(w));let H=Dt(S.slice(z,2*z)),M,q,V;try{M=u.fromHex(v,k),q=u.fromHex(S.slice(0,z),k),V=E.multiplyUnsafe(H)}catch{return!1}if(!k&&M.isSmallOrder())return!1;let $=P(N,q.toRawBytes(),M.toRawBytes(),w);return q.add(M.multiplyUnsafe($)).subtract(V).clearCofactor().equals(u.ZERO)}return E._setWindowSize(8),{CURVE:t,getPublicKey:K,sign:O,verify:T,ExtendedPoint:u,utils:{getExtendedPublicKey:R,randomPrivateKey:()=>c(e.BYTES),precompute(S=8,w=u.BASE){return w._setWindowSize(S),w.multiply(BigInt(3)),w}}}}var Xr=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ao=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Af=BigInt(0),Bc=BigInt(1),Io=BigInt(2),If=BigInt(3),vc=BigInt(5),Ac=BigInt(8);function Ic(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=Xr,a=r*r%s*r%s,f=G(a,Io,s)*a%s,y=G(f,Bc,s)*r%s,h=G(y,vc,s)*y%s,g=G(h,t,s)*h%s,_=G(g,e,s)*g%s,i=G(_,n,s)*_%s,l=G(i,o,s)*i%s,d=G(l,o,s)*i%s,x=G(d,t,s)*h%s;return{pow_p_5_8:G(x,Io,s)*r%s,b2:a}}function Tc(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Rc(r,t){let e=Xr,n=F(t*t*t,e),o=F(n*n*t,e),s=Ic(r*o).pow_p_5_8,c=F(r*n*s,e),a=F(t*c*c,e),f=c,y=F(c*Ao,e),h=a===r,g=a===F(-r,e),_=a===F(-r*Ao,e);return h&&(c=f),(g||_)&&(c=y),wo(c,e)&&(c=F(-c,e)),{isValid:h||g,value:c}}var Cc=Pt(Xr,void 0,!0),Lc={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Cc,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Ac,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:po,randomBytes:Ze,adjustScalarBytes:Tc,uvRatio:Rc},To=vo(Lc);var er=32;function Ro(r,t,e){return To.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var rr=class{type="Ed25519";raw;constructor(t){this.raw=Wr(t,er)}toMultihash(){return St.digest(nr(this))}toCID(){return lt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Bt(this.raw,t.raw)}verify(t,e){return Ro(this.raw,e,t)}};function Lo(r){return r=Wr(r,er),new rr(r)}function Wr(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new ge(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function Uo(r=0){return new Uint8Array(r)}function Rt(r=0){return new Uint8Array(r)}var Nc=Math.pow(2,7),kc=Math.pow(2,14),Mc=Math.pow(2,21),No=Math.pow(2,28),ko=Math.pow(2,35),Mo=Math.pow(2,42),Do=Math.pow(2,49),ot=128,zt=127;function Te(r){if(r<Nc)return 1;if(r<kc)return 2;if(r<Mc)return 3;if(r<No)return 4;if(r<ko)return 5;if(r<Mo)return 6;if(r<Do)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Oo(r,t,e=0){switch(Te(r)){case 8:t[e++]=r&255|ot,r/=128;case 7:t[e++]=r&255|ot,r/=128;case 6:t[e++]=r&255|ot,r/=128;case 5:t[e++]=r&255|ot,r/=128;case 4:t[e++]=r&255|ot,r>>>=7;case 3:t[e++]=r&255|ot,r>>>=7;case 2:t[e++]=r&255|ot,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Po(r,t){let e=r[t],n=0;if(n+=e&zt,e<ot||(e=r[t+1],n+=(e&zt)<<7,e<ot)||(e=r[t+2],n+=(e&zt)<<14,e<ot)||(e=r[t+3],n+=(e&zt)<<21,e<ot)||(e=r[t+4],n+=(e&zt)*No,e<ot)||(e=r[t+5],n+=(e&zt)*ko,e<ot)||(e=r[t+6],n+=(e&zt)*Mo,e<ot)||(e=r[t+7],n+=(e&zt)*Do,e<ot))return n;throw new RangeError("Could not decode varint")}var $r=new Float32Array([-0]),Ht=new Uint8Array($r.buffer);function zo(r,t,e){$r[0]=r,t[e]=Ht[0],t[e+1]=Ht[1],t[e+2]=Ht[2],t[e+3]=Ht[3]}function Ho(r,t){return Ht[0]=r[t],Ht[1]=r[t+1],Ht[2]=r[t+2],Ht[3]=r[t+3],$r[0]}var Qr=new Float64Array([-0]),rt=new Uint8Array(Qr.buffer);function Ko(r,t,e){Qr[0]=r,t[e]=rt[0],t[e+1]=rt[1],t[e+2]=rt[2],t[e+3]=rt[3],t[e+4]=rt[4],t[e+5]=rt[5],t[e+6]=rt[6],t[e+7]=rt[7]}function qo(r,t){return rt[0]=r[t],rt[1]=r[t+1],rt[2]=r[t+2],rt[3]=r[t+3],rt[4]=r[t+4],rt[5]=r[t+5],rt[6]=r[t+6],rt[7]=r[t+7],Qr[0]}var Dc=BigInt(Number.MAX_SAFE_INTEGER),Oc=BigInt(Number.MIN_SAFE_INTEGER),ut=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return te;if(t<Dc&&t>Oc)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>Fo&&(o=0n,++n>Fo&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return te;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):te}},te=new ut(0,0);te.toBigInt=function(){return 0n};te.zzEncode=te.zzDecode=function(){return this};te.length=function(){return 1};var Fo=4294967296n;function Vo(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Zo(r,t,e){if(e-t<1)return"";let o,s=[],c=0,a;for(;t<e;)a=r[t++],a<128?s[c++]=a:a>191&&a<224?s[c++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[c++]=55296+(a>>10),s[c++]=56320+(a&1023)):s[c++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&63,c>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),c=0);return o!=null?(c>0&&o.push(String.fromCharCode.apply(String,s.slice(0,c))),o.join("")):String.fromCharCode.apply(String,s.slice(0,c))}function Jr(r,t,e){let n=e,o,s;for(let c=0;c<r.length;++c)o=r.charCodeAt(c),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(c+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++c,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function xt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function or(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var tn=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,xt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw xt(this,4);return or(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw xt(this,4);return or(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw xt(this,4);let t=Ho(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw xt(this,4);let t=qo(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw xt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Zo(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw xt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw xt(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new ut(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw xt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw xt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw xt(this,8);let t=or(this.buf,this.pos+=4),e=or(this.buf,this.pos+=4);return new ut(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Po(this.buf,this.pos);return this.pos+=Te(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function en(r){return new tn(r instanceof Uint8Array?r:r.subarray())}function sr(r,t,e){let n=en(r);return t.decode(n,void 0,e)}var rn={};ct(rn,{base10:()=>Pc});var Pc=Ut({prefix:"9",name:"base10",alphabet:"0123456789"});var nn={};ct(nn,{base16:()=>zc,base16upper:()=>Hc});var zc=Y({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Hc=Y({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var on={};ct(on,{base2:()=>Kc});var Kc=Y({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var sn={};ct(sn,{base256emoji:()=>Gc});var jo=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),qc=jo.reduce((r,t,e)=>(r[e]=t,r),[]),Fc=jo.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Vc(r){return r.reduce((t,e)=>(t+=qc[e],t),"")}function Zc(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Fc[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Gc=se({prefix:"\u{1F680}",name:"base256emoji",encode:Vc,decode:Zc});var cn={};ct(cn,{base64:()=>jc,base64pad:()=>Yc,base64url:()=>Xc,base64urlpad:()=>Wc});var jc=Y({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Yc=Y({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Xc=Y({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Wc=Y({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var an={};ct(an,{base8:()=>$c});var $c=Y({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var fn={};ct(fn,{identity:()=>Qc});var Qc=se({prefix:"\0",name:"identity",encode:r=>jn(r),decode:r=>Gn(r)});var uu=new TextEncoder,hu=new TextDecoder;var ln={};ct(ln,{sha256:()=>Re,sha512:()=>ea});function hn({name:r,code:t,encode:e}){return new un(r,t,e)}var un=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Gt(this.code,e):e.then(n=>Gt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Xo(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Re=hn({name:"sha2-256",code:18,encode:Xo("SHA-256")}),ea=hn({name:"sha2-512",code:19,encode:Xo("SHA-512")});var dn={...fn,...on,...an,...rn,...nn,...Tr,...Rr,...Ir,...cn,...sn},Su={...ln,...Ur};function $o(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Wo=$o("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),pn=$o("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=Rt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),ra={utf8:Wo,"utf-8":Wo,hex:dn.base16,latin1:pn,ascii:pn,binary:pn,...dn},ir=ra;function st(r,t="utf8"){let e=ir[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function mn(r){let t=r??8192,e=t>>>1,n,o=t;return function(c){if(c<1||c>e)return Rt(c);o+c>t&&(n=Rt(t),o=0);let a=n.subarray(o,o+=c);return o&7&&(o=(o|7)+1),a}}var ee=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function xn(){}var bn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},na=mn();function oa(r){return globalThis.Buffer!=null?Rt(r):na(r)}var Le=class{len;head;tail;states;constructor(){this.len=0,this.head=new ee(xn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ee(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new wn((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(cr,10,ut.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=ut.fromBigInt(t);return this._push(cr,e.length(),e)}uint64Number(t){return this._push(Oo,Te(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=ut.fromBigInt(t).zzEncode();return this._push(cr,e.length(),e)}sint64Number(t){let e=ut.fromNumber(t).zzEncode();return this._push(cr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(gn,1,t?1:0)}fixed32(t){return this._push(Ce,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=ut.fromBigInt(t);return this._push(Ce,4,e.lo)._push(Ce,4,e.hi)}fixed64Number(t){let e=ut.fromNumber(t);return this._push(Ce,4,e.lo)._push(Ce,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(zo,4,t)}double(t){return this._push(Ko,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(gn,1,0):this.uint32(e)._push(ia,e,t)}string(t){let e=Vo(t);return e!==0?this.uint32(e)._push(Jr,e,t):this._push(gn,1,0)}fork(){return this.states=new bn(this),this.head=this.tail=new ee(xn,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new ee(xn,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=oa(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function gn(r,t,e){t[e]=r&255}function sa(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var wn=class extends ee{next;constructor(t,e){super(sa,t,e),this.next=void 0}};function cr(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Ce(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function ia(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Le.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(ca,t,r),this},Le.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(aa,t,r),this});function ca(r,t,e){t.set(r,e)}function aa(r,t,e){r.length<40?Jr(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(st(r),e)}function yn(){return new Le}function ar(r,t){let e=yn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var me;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(me||(me={}));function fr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function En(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,c){let a=t(s);c.int32(a)},n=function(s){let c=s.int32();return t(c)};return fr("enum",me.VARINT,e,n)}function ur(r,t){return fr("message",me.LENGTH_DELIMITED,r,t)}var ht;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(ht||(ht={}));var _n;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(_n||(_n={}));(function(r){r.codec=()=>En(_n)})(ht||(ht={}));var Ue;(function(r){let t;r.codec=()=>(t==null&&(t=ur((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ht.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},c=n==null?e.len:e.pos+n;for(;e.pos<c;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=ht.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ar(e,r.codec()),r.decode=(e,n)=>sr(e,r.codec(),n)})(Ue||(Ue={}));var Sn;(function(r){let t;r.codec=()=>(t==null&&(t=ur((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ht.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},c=n==null?e.len:e.pos+n;for(;e.pos<c;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=ht.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ar(e,r.codec()),r.decode=(e,n)=>sr(e,r.codec(),n)})(Sn||(Sn={}));var ua=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]),Kt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),qt=new Uint32Array(64),Bn=class extends de{constructor(){super(64,32,8,!1),this.A=Kt[0]|0,this.B=Kt[1]|0,this.C=Kt[2]|0,this.D=Kt[3]|0,this.E=Kt[4]|0,this.F=Kt[5]|0,this.G=Kt[6]|0,this.H=Kt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:c,G:a,H:f}=this;return[t,e,n,o,s,c,a,f]}set(t,e,n,o,s,c,a,f){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=c|0,this.G=a|0,this.H=f|0}process(t,e){for(let g=0;g<16;g++,e+=4)qt[g]=t.getUint32(e,!1);for(let g=16;g<64;g++){let _=qt[g-15],i=qt[g-2],l=dt(_,7)^dt(_,18)^_>>>3,d=dt(i,17)^dt(i,19)^i>>>10;qt[g]=d+qt[g-7]+l+qt[g-16]|0}let{A:n,B:o,C:s,D:c,E:a,F:f,G:y,H:h}=this;for(let g=0;g<64;g++){let _=dt(a,6)^dt(a,11)^dt(a,25),i=h+_+uo(a,f,y)+ua[g]+qt[g]|0,d=(dt(n,2)^dt(n,13)^dt(n,22))+ho(n,o,s)|0;h=y,y=f,f=a,a=c+i|0,c=s,s=o,o=n,n=i+d|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,c=c+this.D|0,a=a+this.E|0,f=f+this.F|0,y=y+this.G|0,h=h+this.H|0,this.set(n,o,s,c,a,f,y,h)}roundClean(){qt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Qo=Ve(()=>new Bn);function hr(r,t="utf8"){let e=ir[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Ne=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var lr=class extends le{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,co(t);let n=Be(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let c=0;c<s.length;c++)s[c]^=54;this.iHash.update(s),this.oHash=t.create();for(let c=0;c<s.length;c++)s[c]^=106;this.oHash.update(s),s.fill(0)}update(t){return he(this),this.iHash.update(t),this}digestInto(t){he(this),ue(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:s,blockLen:c,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=c,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},vn=(r,t,e)=>new lr(r,t).update(e).digest();vn.create=(r,t)=>new lr(r,t);function Jo(r){r.lowS!==void 0&&pt("lowS",r.lowS),r.prehash!==void 0&&pt("prehash",r.prehash)}function ha(r){let t=Ie(r);wt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:la,hexToBytes:da}=Xe,An=class extends Error{constructor(t=""){super(t)}},Ct={Err:An,_tlv:{encode:(r,t)=>{let{Err:e}=Ct;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=Xt(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Xt(o.length/2|128):"";return Xt(r)+s+o+t},decode(r,t){let{Err:e}=Ct,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),c=0;if(!s)c=o;else{let f=o&127;if(!f)throw new e("tlv.decode(long): indefinite length not supported");if(f>4)throw new e("tlv.decode(long): byte length is too big");let y=t.subarray(n,n+f);if(y.length!==f)throw new e("tlv.decode: length bytes not complete");if(y[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let h of y)c=c<<8|h;if(n+=f,c<128)throw new e("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+c);if(a.length!==c)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+c)}}},_int:{encode(r){let{Err:t}=Ct;if(r<Lt)throw new t("integer: negative integers are not allowed");let e=Xt(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=Ct;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return la(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Ct,o=typeof r=="string"?da(r):r;pe(o);let{v:s,l:c}=n.decode(48,o);if(c.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:f}=n.decode(2,s),{v:y,l:h}=n.decode(2,f);if(h.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(y)}},hexFromSig(r){let{_tlv:t,_int:e}=Ct,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},Lt=BigInt(0),J=BigInt(1),hh=BigInt(2),ts=BigInt(3),lh=BigInt(4);function pa(r){let t=ha(r),{Fp:e}=t,n=Pt(t.n,t.nBitLength),o=t.toBytes||((d,x,p)=>{let m=x.toAffine();return Tt(Uint8Array.from([4]),e.toBytes(m.x),e.toBytes(m.y))}),s=t.fromBytes||(d=>{let x=d.subarray(1),p=e.fromBytes(x.subarray(0,e.BYTES)),m=e.fromBytes(x.subarray(e.BYTES,2*e.BYTES));return{x:p,y:m}});function c(d){let{a:x,b:p}=t,m=e.sqr(d),u=e.mul(m,d);return e.add(e.add(u,e.mul(d,x)),p)}if(!e.eql(e.sqr(t.Gy),c(t.Gx)))throw new Error("bad generator point: equation left != right");function a(d){return ve(d,J,t.n)}function f(d){let{allowedPrivateKeyLengths:x,nByteLength:p,wrapPrivateKey:m,n:u}=t;if(x&&typeof d!="bigint"){if(Mt(d)&&(d=At(d)),typeof d!="string"||!x.includes(d.length))throw new Error("invalid private key");d=d.padStart(p*2,"0")}let E;try{E=typeof d=="bigint"?d:It(j("private key",d,p))}catch{throw new Error("invalid private key, expected hex or "+p+" bytes, got "+typeof d)}return m&&(E=F(E,u)),at("private key",E,J,u),E}function y(d){if(!(d instanceof _))throw new Error("ProjectivePoint expected")}let h=Qt((d,x)=>{let{px:p,py:m,pz:u}=d;if(e.eql(u,e.ONE))return{x:p,y:m};let E=d.is0();x==null&&(x=E?e.ONE:e.inv(u));let B=e.mul(p,x),A=e.mul(m,x),b=e.mul(u,x);if(E)return{x:e.ZERO,y:e.ZERO};if(!e.eql(b,e.ONE))throw new Error("invZ was invalid");return{x:B,y:A}}),g=Qt(d=>{if(d.is0()){if(t.allowInfinityPoint&&!e.is0(d.py))return;throw new Error("bad point: ZERO")}let{x,y:p}=d.toAffine();if(!e.isValid(x)||!e.isValid(p))throw new Error("bad point: x or y not FE");let m=e.sqr(p),u=c(x);if(!e.eql(m,u))throw new Error("bad point: equation left != right");if(!d.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class _{constructor(x,p,m){if(this.px=x,this.py=p,this.pz=m,x==null||!e.isValid(x))throw new Error("x required");if(p==null||!e.isValid(p))throw new Error("y required");if(m==null||!e.isValid(m))throw new Error("z required");Object.freeze(this)}static fromAffine(x){let{x:p,y:m}=x||{};if(!x||!e.isValid(p)||!e.isValid(m))throw new Error("invalid affine point");if(x instanceof _)throw new Error("projective point not allowed");let u=E=>e.eql(E,e.ZERO);return u(p)&&u(m)?_.ZERO:new _(p,m,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(x){let p=e.invertBatch(x.map(m=>m.pz));return x.map((m,u)=>m.toAffine(p[u])).map(_.fromAffine)}static fromHex(x){let p=_.fromAffine(s(j("pointHex",x)));return p.assertValidity(),p}static fromPrivateKey(x){return _.BASE.multiply(f(x))}static msm(x,p){return Je(_,n,x,p)}_setWindowSize(x){l.setWindowSize(this,x)}assertValidity(){g(this)}hasEvenY(){let{y:x}=this.toAffine();if(e.isOdd)return!e.isOdd(x);throw new Error("Field doesn't support isOdd")}equals(x){y(x);let{px:p,py:m,pz:u}=this,{px:E,py:B,pz:A}=x,b=e.eql(e.mul(p,A),e.mul(E,u)),I=e.eql(e.mul(m,A),e.mul(B,u));return b&&I}negate(){return new _(this.px,e.neg(this.py),this.pz)}double(){let{a:x,b:p}=t,m=e.mul(p,ts),{px:u,py:E,pz:B}=this,A=e.ZERO,b=e.ZERO,I=e.ZERO,R=e.mul(u,u),K=e.mul(E,E),P=e.mul(B,B),O=e.mul(u,E);return O=e.add(O,O),I=e.mul(u,B),I=e.add(I,I),A=e.mul(x,I),b=e.mul(m,P),b=e.add(A,b),A=e.sub(K,b),b=e.add(K,b),b=e.mul(A,b),A=e.mul(O,A),I=e.mul(m,I),P=e.mul(x,P),O=e.sub(R,P),O=e.mul(x,O),O=e.add(O,I),I=e.add(R,R),R=e.add(I,R),R=e.add(R,P),R=e.mul(R,O),b=e.add(b,R),P=e.mul(E,B),P=e.add(P,P),R=e.mul(P,O),A=e.sub(A,R),I=e.mul(P,K),I=e.add(I,I),I=e.add(I,I),new _(A,b,I)}add(x){y(x);let{px:p,py:m,pz:u}=this,{px:E,py:B,pz:A}=x,b=e.ZERO,I=e.ZERO,R=e.ZERO,K=t.a,P=e.mul(t.b,ts),O=e.mul(p,E),U=e.mul(m,B),T=e.mul(u,A),L=e.add(p,m),S=e.add(E,B);L=e.mul(L,S),S=e.add(O,U),L=e.sub(L,S),S=e.add(p,u);let w=e.add(E,A);return S=e.mul(S,w),w=e.add(O,T),S=e.sub(S,w),w=e.add(m,u),b=e.add(B,A),w=e.mul(w,b),b=e.add(U,T),w=e.sub(w,b),R=e.mul(K,S),b=e.mul(P,T),R=e.add(b,R),b=e.sub(U,R),R=e.add(U,R),I=e.mul(b,R),U=e.add(O,O),U=e.add(U,O),T=e.mul(K,T),S=e.mul(P,S),U=e.add(U,T),T=e.sub(O,T),T=e.mul(K,T),S=e.add(S,T),O=e.mul(U,S),I=e.add(I,O),O=e.mul(w,S),b=e.mul(L,b),b=e.sub(b,O),O=e.mul(L,U),R=e.mul(w,R),R=e.add(R,O),new _(b,I,R)}subtract(x){return this.add(x.negate())}is0(){return this.equals(_.ZERO)}wNAF(x){return l.wNAFCached(this,x,_.normalizeZ)}multiplyUnsafe(x){let{endo:p,n:m}=t;at("scalar",x,Lt,m);let u=_.ZERO;if(x===Lt)return u;if(this.is0()||x===J)return this;if(!p||l.hasPrecomputes(this))return l.wNAFCachedUnsafe(this,x,_.normalizeZ);let{k1neg:E,k1:B,k2neg:A,k2:b}=p.splitScalar(x),I=u,R=u,K=this;for(;B>Lt||b>Lt;)B&J&&(I=I.add(K)),b&J&&(R=R.add(K)),K=K.double(),B>>=J,b>>=J;return E&&(I=I.negate()),A&&(R=R.negate()),R=new _(e.mul(R.px,p.beta),R.py,R.pz),I.add(R)}multiply(x){let{endo:p,n:m}=t;at("scalar",x,J,m);let u,E;if(p){let{k1neg:B,k1:A,k2neg:b,k2:I}=p.splitScalar(x),{p:R,f:K}=this.wNAF(A),{p:P,f:O}=this.wNAF(I);R=l.constTimeNegate(B,R),P=l.constTimeNegate(b,P),P=new _(e.mul(P.px,p.beta),P.py,P.pz),u=R.add(P),E=K.add(O)}else{let{p:B,f:A}=this.wNAF(x);u=B,E=A}return _.normalizeZ([u,E])[0]}multiplyAndAddUnsafe(x,p,m){let u=_.BASE,E=(A,b)=>b===Lt||b===J||!A.equals(u)?A.multiplyUnsafe(b):A.multiply(b),B=E(this,p).add(E(x,m));return B.is0()?void 0:B}toAffine(x){return h(this,x)}isTorsionFree(){let{h:x,isTorsionFree:p}=t;if(x===J)return!0;if(p)return p(_,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:x,clearCofactor:p}=t;return x===J?this:p?p(_,this):this.multiplyUnsafe(t.h)}toRawBytes(x=!0){return pt("isCompressed",x),this.assertValidity(),o(_,this,x)}toHex(x=!0){return pt("isCompressed",x),At(this.toRawBytes(x))}}_.BASE=new _(t.Gx,t.Gy,e.ONE),_.ZERO=new _(e.ZERO,e.ONE,e.ZERO);let i=t.nBitLength,l=Qe(_,t.endo?Math.ceil(i/2):i);return{CURVE:t,ProjectivePoint:_,normPrivateKeyToScalar:f,weierstrassEquation:c,isWithinCurveOrder:a}}function ma(r){let t=Ie(r);return wt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function es(r){let t=ma(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function c(T){return F(T,n)}function a(T){return We(T,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:y,weierstrassEquation:h,isWithinCurveOrder:g}=pa({...t,toBytes(T,L,S){let w=L.toAffine(),v=e.toBytes(w.x),C=Tt;return pt("isCompressed",S),S?C(Uint8Array.from([L.hasEvenY()?2:3]),v):C(Uint8Array.from([4]),v,e.toBytes(w.y))},fromBytes(T){let L=T.length,S=T[0],w=T.subarray(1);if(L===o&&(S===2||S===3)){let v=It(w);if(!ve(v,J,e.ORDER))throw new Error("Point is not on curve");let C=h(v),N;try{N=e.sqrt(C)}catch(H){let M=H instanceof Error?": "+H.message:"";throw new Error("Point is not on curve"+M)}let k=(N&J)===J;return(S&1)===1!==k&&(N=e.neg(N)),{x:v,y:N}}else if(L===s&&S===4){let v=e.fromBytes(w.subarray(0,e.BYTES)),C=e.fromBytes(w.subarray(e.BYTES,2*e.BYTES));return{x:v,y:C}}else{let v=o,C=s;throw new Error("invalid Point, expected length of "+v+", or uncompressed "+C+", got "+L)}}}),_=T=>At(Ot(T,t.nByteLength));function i(T){let L=n>>J;return T>L}function l(T){return i(T)?c(-T):T}let d=(T,L,S)=>It(T.slice(L,S));class x{constructor(L,S,w){this.r=L,this.s=S,this.recovery=w,this.assertValidity()}static fromCompact(L){let S=t.nByteLength;return L=j("compactSignature",L,S*2),new x(d(L,0,S),d(L,S,2*S))}static fromDER(L){let{r:S,s:w}=Ct.toSig(j("DER",L));return new x(S,w)}assertValidity(){at("r",this.r,J,n),at("s",this.s,J,n)}addRecoveryBit(L){return new x(this.r,this.s,L)}recoverPublicKey(L){let{r:S,s:w,recovery:v}=this,C=A(j("msgHash",L));if(v==null||![0,1,2,3].includes(v))throw new Error("recovery id invalid");let N=v===2||v===3?S+t.n:S;if(N>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let k=v&1?"03":"02",z=f.fromHex(k+_(N)),H=a(N),M=c(-C*H),q=c(w*H),V=f.BASE.multiplyAndAddUnsafe(z,M,q);if(!V)throw new Error("point at infinify");return V.assertValidity(),V}hasHighS(){return i(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return Wt(this.toDERHex())}toDERHex(){return Ct.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Wt(this.toCompactHex())}toCompactHex(){return _(this.r)+_(this.s)}}let p={isValidPrivateKey(T){try{return y(T),!0}catch{return!1}},normPrivateKeyToScalar:y,randomPrivateKey:()=>{let T=Vr(t.n);return Eo(t.randomBytes(T),t.n)},precompute(T=8,L=f.BASE){return L._setWindowSize(T),L.multiply(BigInt(3)),L}};function m(T,L=!0){return f.fromPrivateKey(T).toRawBytes(L)}function u(T){let L=Mt(T),S=typeof T=="string",w=(L||S)&&T.length;return L?w===o||w===s:S?w===2*o||w===2*s:T instanceof f}function E(T,L,S=!0){if(u(T))throw new Error("first arg must be private key");if(!u(L))throw new Error("second arg must be public key");return f.fromHex(L).multiply(y(T)).toRawBytes(S)}let B=t.bits2int||function(T){if(T.length>8192)throw new Error("input is too large");let L=It(T),S=T.length*8-t.nBitLength;return S>0?L>>BigInt(S):L},A=t.bits2int_modN||function(T){return c(B(T))},b=Ae(t.nBitLength);function I(T){return at("num < 2^"+t.nBitLength,T,Lt,b),Ot(T,t.nByteLength)}function R(T,L,S=K){if(["recovered","canonical"].some(Q=>Q in S))throw new Error("sign() legacy options not supported");let{hash:w,randomBytes:v}=t,{lowS:C,prehash:N,extraEntropy:k}=S;C==null&&(C=!0),T=j("msgHash",T),Jo(S),N&&(T=j("prehashed msgHash",w(T)));let z=A(T),H=y(L),M=[I(H),I(z)];if(k!=null&&k!==!1){let Q=k===!0?v(e.BYTES):k;M.push(j("extraEntropy",Q))}let q=Tt(...M),V=z;function $(Q){let tt=B(Q);if(!g(tt))return;let et=a(tt),it=f.BASE.multiply(tt).toAffine(),nt=c(it.x);if(nt===Lt)return;let bt=c(et*c(V+nt*H));if(bt===Lt)return;let Et=(it.x===nt?0:2)|Number(it.y&J),xe=bt;return C&&i(bt)&&(xe=l(bt),Et^=1),new x(nt,xe,Et)}return{seed:q,k2sig:$}}let K={lowS:t.lowS,prehash:!1},P={lowS:t.lowS,prehash:!1};function O(T,L,S=K){let{seed:w,k2sig:v}=R(T,L,S),C=t;return Hr(C.hash.outputLen,C.nByteLength,C.hmac)(w,v)}f.BASE._setWindowSize(8);function U(T,L,S,w=P){let v=T;L=j("msgHash",L),S=j("publicKey",S);let{lowS:C,prehash:N,format:k}=w;if(Jo(w),"strict"in w)throw new Error("options.strict was renamed to lowS");if(k!==void 0&&k!=="compact"&&k!=="der")throw new Error("format must be compact or der");let z=typeof v=="string"||Mt(v),H=!z&&!k&&typeof v=="object"&&v!==null&&typeof v.r=="bigint"&&typeof v.s=="bigint";if(!z&&!H)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let M,q;try{if(H&&(M=new x(v.r,v.s)),z){try{k!=="compact"&&(M=x.fromDER(v))}catch(Et){if(!(Et instanceof Ct.Err))throw Et}!M&&k!=="der"&&(M=x.fromCompact(v))}q=f.fromHex(S)}catch{return!1}if(!M||C&&M.hasHighS())return!1;N&&(L=t.hash(L));let{r:V,s:$}=M,Q=A(L),tt=a($),et=c(Q*tt),it=c(V*tt),nt=f.BASE.multiplyAndAddUnsafe(q,et,it)?.toAffine();return nt?c(nt.x)===V:!1}return{CURVE:t,getPublicKey:m,getSharedSecret:E,sign:O,verify:U,ProjectivePoint:f,Signature:x,utils:p}}function xa(r){return{hash:r,hmac:(t,...e)=>vn(r,t,Nr(...e)),randomBytes:Ze}}function rs(r,t){let e=n=>es({...r,...xa(n)});return{...e(t),create:e}}var ss=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ns=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ga=BigInt(1),In=BigInt(2),os=(r,t)=>(r+t/In)/t;function ba(r){let t=ss,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),c=BigInt(23),a=BigInt(44),f=BigInt(88),y=r*r*r%t,h=y*y*r%t,g=G(h,e,t)*h%t,_=G(g,e,t)*h%t,i=G(_,In,t)*y%t,l=G(i,o,t)*i%t,d=G(l,s,t)*l%t,x=G(d,a,t)*d%t,p=G(x,f,t)*x%t,m=G(p,a,t)*d%t,u=G(m,e,t)*h%t,E=G(u,c,t)*l%t,B=G(E,n,t)*y%t,A=G(B,In,t);if(!Tn.eql(Tn.sqr(A),r))throw new Error("Cannot find square root");return A}var Tn=Pt(ss,void 0,void 0,{sqrt:ba}),re=rs({a:BigInt(0),b:BigInt(7),Fp:Tn,n:ns,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=ns,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-ga*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,c=BigInt("0x100000000000000000000000000000000"),a=os(s*r,t),f=os(-n*r,t),y=F(r-a*e-f*o,t),h=F(-a*n-f*s,t),g=y>c,_=h>c;if(g&&(y=t-y),_&&(h=t-h),y>c||h>c)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:g,k1:y,k2neg:_,k2:h}}}},Qo),Eh=BigInt(0);var _h=re.ProjectivePoint;function is(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function cs(r,t,e){let n=Re.digest(e instanceof Uint8Array?e:e.subarray());if(is(n))return n.then(({digest:o})=>re.verify(t,o,r)).catch(o=>{throw new Ne(String(o))});try{return re.verify(t,n.digest,r)}catch(o){throw new Ne(String(o))}}var dr=class{type="secp256k1";raw;_key;constructor(t){this._key=fs(t),this.raw=as(this._key)}toMultihash(){return St.digest(nr(this))}toCID(){return lt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Bt(this.raw,t.raw)}verify(t,e){return cs(this._key,e,t)}};function us(r){return new dr(r)}function as(r){return re.ProjectivePoint.fromHex(r).toRawBytes(!0)}function fs(r){try{return re.ProjectivePoint.fromHex(r),r}catch(t){throw new He(String(t))}}function hs(r){let{Type:t,Data:e}=Ue.decode(r.digest),n=e??new Uint8Array;switch(t){case ht.Ed25519:return Lo(n);case ht.secp256k1:return us(n);default:throw new be}}function nr(r){return Ue.encode({Type:ht[r.type],Data:r.raw})}var ls=Symbol.for("nodejs.util.inspect.custom"),wa=114,ke=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[_r]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return lt.createV1(wa,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Bt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Bt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[ls](){return`PeerId(${this.toString()})`}},pr=class extends ke{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},mr=class extends ke{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},xr=class extends ke{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},ya=2336,gr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=St.digest(st(this.url))}[ls](){return`PeerId(${this.url})`}[_r]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return lt.createV1(ya,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=hr(t)),t.toString()===this.toString())}};function ds(r){if(_a(r))return new pr({multihash:r});if(Ea(r))try{let t=hs(r);if(t.type==="Ed25519")return new mr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new xr({multihash:r,publicKey:t})}catch{let e=hr(r.digest);return new gr(new URL(e))}throw new Ke("Supplied PeerID Multihash is invalid")}function Ea(r){return r.code===St.code}function _a(r){return r.code===Re.code}function yt(r,t){let e={[Symbol.iterator]:()=>e,next:()=>{let n=r.next(),o=n.value;return n.done===!0||o==null?{done:!0,value:void 0}:{done:!1,value:t(o)}}};return e}function br(r){let t=_e(X.decode(`z${r}`));return ds(t)}var Ft=class{map;constructor(t){if(this.map=new Map,t!=null)for(let[e,n]of t.entries())this.map.set(e.toString(),{key:e,value:n})}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(t){return this.map.delete(t.toString())}entries(){return yt(this.map.entries(),t=>[t[1].key,t[1].value])}forEach(t){this.map.forEach((e,n)=>{t(e.value,e.key,this)})}get(t){return this.map.get(t.toString())?.value}has(t){return this.map.has(t.toString())}set(t,e){this.map.set(t.toString(),{key:t,value:e})}keys(){return yt(this.map.values(),t=>t.key)}values(){return yt(this.map.values(),t=>t.value)}get size(){return this.map.size}};function ps(){return new Ft}var Vt=class r{set;constructor(t){if(this.set=new Set,t!=null)for(let e of t)this.set.add(e.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(t){this.set.add(t.toString())}clear(){this.set.clear()}delete(t){this.set.delete(t.toString())}entries(){return yt(this.set.entries(),t=>{let e=br(t[0]);return[e,e]})}forEach(t){this.set.forEach(e=>{let n=br(e);t(n,n,this)})}has(t){return this.set.has(t.toString())}values(){return yt(this.set.values(),t=>br(t))}intersection(t){let e=new r;for(let n of t)this.has(n)&&e.add(n);return e}difference(t){let e=new r;for(let n of this)t.has(n)||e.add(n);return e}union(t){let e=new r;for(let n of t)e.add(n);for(let n of this)e.add(n);return e}};function ms(){return new Vt}var Zt=class r{list;constructor(t){if(this.list=[],t!=null)for(let e of t)this.list.push(e)}[Symbol.iterator](){return yt(this.list.entries(),t=>t[1])}concat(t){let e=new r(this);for(let n of t)e.push(n);return e}entries(){return yt(this.list.entries(),t=>[t[0],t[1]])}every(t){return this.list.every((e,n)=>t(e,n,this))}filter(t){let e=new r;return this.list.forEach((n,o)=>{t(n,o,this)&&e.push(n)}),e}find(t){let e=this.list.find((n,o)=>t(n,o,this));if(e!=null)return e}findIndex(t){return this.list.findIndex((e,n)=>t(e,n,this))}forEach(t){this.list.forEach((e,n)=>{t(e,n,this)})}includes(t){return this.includes(t)}indexOf(t){return this.list.findIndex(e=>e.equals(t))}pop(){let t=this.list.pop();if(t!=null)return t}push(...t){for(let e of t)this.list.push(e)}shift(){let t=this.list.shift();if(t!=null)return t}unshift(...t){let e=this.list.length;for(let n=t.length-1;n>-1;n--)e=this.list.unshift(t[n]);return e}clear(){this.list=[]}get length(){return this.list.length}};function xs(){return new Zt}var Rn=64,gt=class{fp;h;seed;constructor(t,e,n,o=2){if(o>Rn)throw new TypeError("Invalid Fingerprint Size");let s=e.hashV(t,n),c=Uo(o);for(let a=0;a<c.length;a++)c[a]=s[a];c.length===0&&(c[0]=7),this.fp=c,this.h=e,this.seed=n}hash(){return this.h.hash(this.fp,this.seed)}equals(t){return t?.fp instanceof Uint8Array?Bt(this.fp,t.fp):!1}};function ne(r,t){return Math.floor(Math.random()*(t-r))+r}var oe=class{contents;constructor(t){this.contents=new Array(t).fill(null)}has(t){if(!(t instanceof gt))throw new TypeError("Invalid Fingerprint");return this.contents.some(e=>t.equals(e))}add(t){if(!(t instanceof gt))throw new TypeError("Invalid Fingerprint");for(let e=0;e<this.contents.length;e++)if(this.contents[e]==null)return this.contents[e]=t,!0;return!0}swap(t){if(!(t instanceof gt))throw new TypeError("Invalid Fingerprint");let e=ne(0,this.contents.length-1),n=this.contents[e];return this.contents[e]=t,n}remove(t){if(!(t instanceof gt))throw new TypeError("Invalid Fingerprint");let e=this.contents.findIndex(n=>t.equals(n));return e>-1?(this.contents[e]=null,!0):!1}};var Cn={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},ys={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},Es=new globalThis.TextEncoder;function Sa(r,t){let e=Cn[t],n=ys[t];for(let o=0;o<r.length;o++)n^=BigInt(r[o]),n=BigInt.asUintN(t,n*e);return n}function Ba(r,t,e){if(e.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");let n=Cn[t],o=ys[t],s=r;for(;s.length>0;){let c=Es.encodeInto(s,e);s=s.slice(c.read);for(let a=0;a<c.written;a++)o^=BigInt(e[a]),o=BigInt.asUintN(t,o*n)}return o}function Ln(r,{size:t=32,utf8Buffer:e}={}){if(!Cn[t])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if(typeof r=="string"){if(e)return Ba(r,t,e);r=Es.encode(r)}return Sa(r,t)}var va=Hs(ws(),1);var De={hash:r=>Number(Ln(r,{size:32})),hashV:(r,t)=>Aa(De.hash(r,t))};function Aa(r){let t=r.toString(16);return t.length%2===1&&(t=`0${t}`),st(t,"base16")}var Ia=500,Oe=class{bucketSize;filterSize;fingerprintSize;buckets;count;hash;seed;constructor(t){this.filterSize=t.filterSize,this.bucketSize=t.bucketSize??4,this.fingerprintSize=t.fingerprintSize??2,this.count=0,this.buckets=[],this.hash=t.hash??De,this.seed=t.seed??ne(0,Math.pow(2,10))}add(t){typeof t=="string"&&(t=st(t));let e=new gt(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=(n^e.hash())%this.filterSize;if(this.buckets[n]==null&&(this.buckets[n]=new oe(this.bucketSize)),this.buckets[o]==null&&(this.buckets[o]=new oe(this.bucketSize)),this.buckets[n].add(e)||this.buckets[o].add(e))return this.count++,!0;let s=[n,o],c=s[ne(0,s.length-1)];this.buckets[c]==null&&(this.buckets[c]=new oe(this.bucketSize));for(let a=0;a<Ia;a++){let f=this.buckets[c].swap(e);if(f!=null&&(c=(c^f.hash())%this.filterSize,this.buckets[c]==null&&(this.buckets[c]=new oe(this.bucketSize)),this.buckets[c].add(f)))return this.count++,!0}return!1}has(t){typeof t=="string"&&(t=st(t));let e=new gt(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.has(e)??!1;if(o)return o;let s=(n^e.hash())%this.filterSize;return this.buckets[s]?.has(e)??!1}remove(t){typeof t=="string"&&(t=st(t));let e=new gt(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.remove(e)??!1;if(o)return this.count--,o;let s=(n^e.hash())%this.filterSize,c=this.buckets[s]?.remove(e)??!1;return c&&this.count--,c}get reliable(){return Math.floor(100*(this.count/this.filterSize))<=90}},Ta={1:.5,2:.84,4:.95,8:.98};function Ra(r=.001){return r>.002?2:r>1e-5?4:8}function _s(r,t=.001){let e=Ra(t),n=Ta[e],o=Math.round(r/n),s=Math.min(Math.ceil(Math.log2(1/t)+Math.log2(2*e)),Rn);return{filterSize:o,bucketSize:e,fingerprintSize:s}}var yr=class{filterSize;bucketSize;fingerprintSize;scale;filterSeries;hash;seed;constructor(t){this.bucketSize=t.bucketSize??4,this.filterSize=t.filterSize??(1<<18)/this.bucketSize,this.fingerprintSize=t.fingerprintSize??2,this.scale=t.scale??2,this.hash=t.hash??De,this.seed=t.seed??ne(0,Math.pow(2,10)),this.filterSeries=[new Oe({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(t){if(typeof t=="string"&&(t=st(t)),this.has(t))return!0;let e=this.filterSeries.find(n=>n.reliable);if(e==null){let n=this.filterSize*Math.pow(this.scale,this.filterSeries.length);e=new Oe({filterSize:n,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(e)}return e.add(t)}has(t){typeof t=="string"&&(t=st(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].has(t))return!0;return!1}remove(t){typeof t=="string"&&(t=st(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].remove(t))return!0;return!1}get count(){return this.filterSeries.reduce((t,e)=>t+e.count,0)}};function Un(r,t=.001,e){return new yr({..._s(r,t),...e??{}})}var Pe=class{filter;constructor(t,e){this.filter=Un(t,e)}has(t){return this.filter.has(t.toMultihash().bytes)}add(t){this.filter.add(t.toMultihash().bytes)}remove(t){this.filter.remove?.(t.toMultihash().bytes)}};function Ss(r,t=.001){return new Pe(r,t)}var Nn=class extends Ft{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}set(t,e){return super.set(t,e),this.updateComponentMetric(),this}delete(t){let e=super.delete(t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function Bs(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Nn({name:t,metrics:e}):n=new Ft,n}var kn=class extends Vt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}add(t){super.add(t),this.updateComponentMetric()}delete(t){super.delete(t),this.updateComponentMetric()}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function vs(r){let{name:t,metrics:e}=r,n;return e!=null?n=new kn({name:t,metrics:e}):n=new Vt,n}var Mn=class extends Zt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}pop(){let t=super.pop();return this.updateComponentMetric(),t}push(...t){super.push(...t),this.updateComponentMetric()}shift(){let t=super.shift();return this.updateComponentMetric(),t}unshift(...t){let e=super.unshift(...t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.length)}};function As(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Mn({name:t,metrics:e}):n=new Zt,n}return Ks(Ca);})();
3
3
  /*! Bundled license information:
4
4
 
5
5
  @noble/hashes/esm/utils.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/peer-collections",
3
- "version": "6.0.13",
3
+ "version": "6.0.14-c90984ec7",
4
4
  "description": "Stores values against a peer id",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-collections#readme",
@@ -54,13 +54,13 @@
54
54
  "test:electron-main": "aegir test -t electron-main"
55
55
  },
56
56
  "dependencies": {
57
- "@libp2p/interface": "^2.3.0",
58
- "@libp2p/peer-id": "^5.0.9",
59
- "@libp2p/utils": "^6.3.0",
57
+ "@libp2p/interface": "2.4.0-c90984ec7",
58
+ "@libp2p/peer-id": "5.0.10-c90984ec7",
59
+ "@libp2p/utils": "6.3.1-c90984ec7",
60
60
  "multiformats": "^13.3.1"
61
61
  },
62
62
  "devDependencies": {
63
- "@libp2p/crypto": "^5.0.8",
63
+ "@libp2p/crypto": "5.0.9-c90984ec7",
64
64
  "@types/sinon": "^17.0.3",
65
65
  "aegir": "^45.0.5",
66
66
  "sinon": "^19.0.2",
@@ -1,16 +0,0 @@
1
- {
2
- "PeerFilter": "https://libp2p.github.io/js-libp2p/classes/_libp2p_peer_collections.PeerFilter.html",
3
- "PeerList": "https://libp2p.github.io/js-libp2p/classes/_libp2p_peer_collections.PeerList.html",
4
- "PeerMap": "https://libp2p.github.io/js-libp2p/classes/_libp2p_peer_collections.PeerMap.html",
5
- "PeerSet": "https://libp2p.github.io/js-libp2p/classes/_libp2p_peer_collections.PeerSet.html",
6
- "TrackedPeerListInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_peer_collections.TrackedPeerListInit.html",
7
- "TrackedPeerMapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_peer_collections.TrackedPeerMapInit.html",
8
- "TrackedPeerSetInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_peer_collections.TrackedPeerSetInit.html",
9
- "peerFilter": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.peerFilter-1.html",
10
- "peerList": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.peerList-1.html",
11
- "peerMap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.peerMap-1.html",
12
- "peerSet": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.peerSet-1.html",
13
- "trackedPeerList": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.trackedPeerList.html",
14
- "trackedPeerMap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.trackedPeerMap.html",
15
- "trackedPeerSet": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.trackedPeerSet.html"
16
- }