@libp2p/peer-collections 6.0.30 → 6.0.31

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 Lr=Object.defineProperty;var ci=Object.getOwnPropertyDescriptor;var ai=Object.getOwnPropertyNames;var fi=Object.prototype.hasOwnProperty;var ht=(r,t)=>{for(var e in t)Lr(r,e,{get:t[e],enumerable:!0})},ui=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ai(t))!fi.call(r,o)&&o!==e&&Lr(r,o,{get:()=>t[o],enumerable:!(n=ci(t,o))||n.enumerable});return r};var hi=r=>ui(Lr({},"__esModule",{value:!0}),r);var Ka={};ht(Ka,{PeerFilter:()=>Xe,PeerList:()=>Wt,PeerMap:()=>Zt,PeerSet:()=>Yt,peerFilter:()=>Qs,peerList:()=>Ws,peerMap:()=>Zs,peerSet:()=>Ys,trackedPeerList:()=>ri,trackedPeerMap:()=>ti,trackedPeerSet:()=>ei});var Cr=Symbol.for("@libp2p/peer-id");var Ct=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},$e=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Je=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 Rr={};ht(Rr,{base58btc:()=>Y,base58flickr:()=>bi});var za=new Uint8Array(0);function to(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 Ut(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 eo(r){return new TextEncoder().encode(r)}function ro(r){return new TextDecoder().decode(r)}function li(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),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,c=r.charAt(0),d=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(S){if(S instanceof Uint8Array||(ArrayBuffer.isView(S)?S=new Uint8Array(S.buffer,S.byteOffset,S.byteLength):Array.isArray(S)&&(S=Uint8Array.from(S))),!(S instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(S.length===0)return"";for(var x=0,P=0,R=0,z=S.length;R!==z&&S[R]===0;)R++,x++;for(var _=(z-R)*f+1>>>0,u=new Uint8Array(_);R!==z;){for(var m=S[R],A=0,v=_-1;(m!==0||A<P)&&v!==-1;v--,A++)m+=256*u[v]>>>0,u[v]=m%a>>>0,m=m/a>>>0;if(m!==0)throw new Error("Non-zero carry");P=A,R++}for(var B=_-P;B!==_&&u[B]===0;)B++;for(var D=c.repeat(x);B<_;++B)D+=r.charAt(u[B]);return D}function E(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var x=0;if(S[x]!==" "){for(var P=0,R=0;S[x]===c;)P++,x++;for(var z=(S.length-x)*d+1>>>0,_=new Uint8Array(z);S[x];){var u=e[S.charCodeAt(x)];if(u===255)return;for(var m=0,A=z-1;(u!==0||m<R)&&A!==-1;A--,m++)u+=a*_[A]>>>0,_[A]=u%256>>>0,u=u/256>>>0;if(u!==0)throw new Error("Non-zero carry");R=m,x++}if(S[x]!==" "){for(var v=z-R;v!==z&&_[v]===0;)v++;for(var B=new Uint8Array(P+(z-v)),D=P;v!==z;)B[D++]=_[v++];return B}}}function I(S){var x=E(S);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:E,decode:I}}var di=li,pi=di,oo=pi;var Ur=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")}},Tr=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 so(this,t)}},Dr=class{decoders;constructor(t){this.decoders=t}or(t){return so(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 so(r,t){return new Dr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Pr=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 Ur(t,e,n),this.decoder=new Tr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ue({name:r,prefix:t,encode:e,decode:n}){return new Pr(r,t,e,n)}function Mt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=oo(e,r);return ue({prefix:t,name:r,encode:n,decode:s=>Ut(o(s))})}function mi(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,a=0,c=0;for(let d=0;d<o;++d){let f=t[r[d]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|f,i+=e,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=e||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function xi(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function yi(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function G({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=yi(n);return ue({prefix:t,name:r,encode(s){return xi(s,n,e)},decode(s){return mi(s,o,e,r)}})}var Y=Mt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),bi=Mt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Nr={};ht(Nr,{base32:()=>he,base32hex:()=>_i,base32hexpad:()=>Ai,base32hexpadupper:()=>vi,base32hexupper:()=>Si,base32pad:()=>wi,base32padupper:()=>Ei,base32upper:()=>gi,base32z:()=>Bi});var he=G({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),gi=G({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),wi=G({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ei=G({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_i=G({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Si=G({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ai=G({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),vi=G({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Bi=G({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var kr={};ht(kr,{base36:()=>Ie,base36upper:()=>Ii});var Ie=Mt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ii=Mt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Li=ao,io=128,Ci=127,Ui=~Ci,Ti=Math.pow(2,31);function ao(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Ti;)t[e++]=r&255|io,r/=128;for(;r&Ui;)t[e++]=r&255|io,r>>>=7;return t[e]=r|0,ao.bytes=e-n+1,t}var Di=Kr,Pi=128,co=127;function Kr(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Kr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&co)<<o:(i&co)*Math.pow(2,o),o+=7}while(i>=Pi);return Kr.bytes=s-n,e}var Ri=Math.pow(2,7),Ni=Math.pow(2,14),ki=Math.pow(2,21),Ki=Math.pow(2,28),Oi=Math.pow(2,35),Mi=Math.pow(2,42),Hi=Math.pow(2,49),zi=Math.pow(2,56),qi=Math.pow(2,63),Vi=function(r){return r<Ri?1:r<Ni?2:r<ki?3:r<Ki?4:r<Oi?5:r<Mi?6:r<Hi?7:r<zi?8:r<qi?9:10},Fi={encode:Li,decode:Di,encodingLength:Vi},ji=Fi,Le=ji;function Ce(r,t=0){return[Le.decode(r,t),Le.decode.bytes]}function le(r,t,e=0){return Le.encode(r,t,e),t}function de(r){return Le.encodingLength(r)}function Xt(r,t){let e=t.byteLength,n=de(r),o=n+de(e),s=new Uint8Array(o+e);return le(r,s,0),le(e,s,n),s.set(t,o),new pe(r,e,t,s)}function Ue(r){let t=Ut(r),[e,n]=Ce(t),[o,s]=Ce(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new pe(e,o,i,t)}function fo(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&to(r.bytes,e.bytes)}}var pe=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function uo(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Zi(e,Or(r),t??Y.encoder);default:return Yi(e,Or(r),t??he.encoder)}}var ho=new WeakMap;function Or(r){let t=ho.get(r);if(t==null){let e=new Map;return ho.set(r,e),e}return t}var ft=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!==Te)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Wi)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=Xt(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&&fo(t.multihash,n.multihash)}toString(t){return uo(this,t)}toJSON(){return{"/":uo(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:i}=e;return new r(n,o,s,i??lo(n,o,s.bytes))}else if(e[Xi]===!0){let{version:n,multihash:o,code:s}=e,i=Ue(o);return r.create(n,s,i)}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!==Te)throw new Error(`Version 0 CID must use dag-pb (code: ${Te}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=lo(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Te,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=Ut(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new pe(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,E]=Ce(t.subarray(e));return e+=E,l},o=n(),s=Te;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),c=n(),d=e+c,f=d-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:f,size:d}}static parse(t,e){let[n,o]=Gi(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 Or(s).set(n,t),s}};function Gi(r,t){switch(r[0]){case"Q":{let e=t??Y;return[Y.prefix,e.decode(`${Y.prefix}${r}`)]}case Y.prefix:{let e=t??Y;return[Y.prefix,e.decode(r)]}case he.prefix:{let e=t??he;return[he.prefix,e.decode(r)]}case Ie.prefix:{let e=t??Ie;return[Ie.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 Zi(r,t,e){let{prefix:n}=e;if(n!==Y.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 Yi(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 Te=112,Wi=18;function lo(r,t,e){let n=de(r),o=n+de(t),s=new Uint8Array(o+e.byteLength);return le(r,s,0),le(t,s,n),s.set(e,o),s}var Xi=Symbol.for("@ipld/js-cid/CID");var Mr={};ht(Mr,{identity:()=>gt});var po=0,$i="identity",mo=Ut;function Ji(r){return Xt(po,mo(r))}var gt={code:po,name:$i,encode:mo,digest:Ji};function lt(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 wt(r=0){return new Uint8Array(r)}function dt(r=0){return new Uint8Array(r)}function tr(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=dt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var yo=Symbol.for("@achingbrain/uint8arraylist");function xo(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function er(r){return!!r?.[yo]}var pt=class r{bufs;length;[yo]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(er(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(er(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=xo(this.bufs,t);return e.buf[e.index]}set(t,e){let n=xo(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(er(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return tr(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:tr(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,c=a+i.byteLength;if(o=c,t>=c)continue;let d=t>=a&&t<c,f=e>a&&e<=c;if(d&&f){if(t===a&&e===c){n.push(i);break}let l=t-a;n.push(i.subarray(l,l+(e-t)));break}if(d){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(f){if(e===c){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!er(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let a=i,c=this.byteLength-n.byteLength,d=n.byteLength-1,f;for(let l=e;l<=c;l+=f){f=0;for(let E=d;E>=0;E--){let I=this.get(l+E);if(n[E]!==I){f=Math.max(1,E-a[I]);break}}if(f===0)return l}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=dt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=wt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=wt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=wt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=dt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=wt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=wt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=wt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=wt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=wt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!lt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var Hr={};ht(Hr,{base10:()=>Qi});var Qi=Mt({prefix:"9",name:"base10",alphabet:"0123456789"});var zr={};ht(zr,{base16:()=>tc,base16upper:()=>ec});var tc=G({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ec=G({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var qr={};ht(qr,{base2:()=>rc});var rc=G({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Vr={};ht(Vr,{base256emoji:()=>cc});var bo=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}"),nc=bo.reduce((r,t,e)=>(r[e]=t,r),[]),oc=bo.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function sc(r){return r.reduce((t,e)=>(t+=nc[e],t),"")}function ic(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=oc[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var cc=ue({prefix:"\u{1F680}",name:"base256emoji",encode:sc,decode:ic});var Fr={};ht(Fr,{base64:()=>ac,base64pad:()=>fc,base64url:()=>uc,base64urlpad:()=>hc});var ac=G({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),fc=G({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),uc=G({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),hc=G({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var jr={};ht(jr,{base8:()=>lc});var lc=G({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Gr={};ht(Gr,{identity:()=>dc});var dc=ue({prefix:"\0",name:"identity",encode:r=>ro(r),decode:r=>eo(r)});var vf=new TextEncoder,Bf=new TextDecoder;var Wr={};ht(Wr,{sha256:()=>De,sha512:()=>xc});function Yr({name:r,code:t,encode:e}){return new Zr(r,t,e)}var Zr=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?Xt(this.code,e):e.then(n=>Xt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function wo(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var De=Yr({name:"sha2-256",code:18,encode:wo("SHA-256")}),xc=Yr({name:"sha2-512",code:19,encode:wo("SHA-512")});var Xr={...Gr,...qr,...jr,...Hr,...zr,...Nr,...kr,...Rr,...Fr,...Vr},Of={...Wr,...Mr};function _o(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Eo=_o("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),$r=_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=dt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),yc={utf8:Eo,"utf-8":Eo,hex:Xr.base16,latin1:$r,ascii:$r,binary:$r,...Xr},rr=yc;function J(r,t="utf8"){let e=rr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Et(r,t="utf8"){let e=rr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var bc=parseInt("11111",2),Jr=parseInt("10000000",2),gc=parseInt("01111111",2),So={0:Pe,1:Pe,2:wc,3:Sc,4:Ac,5:_c,6:Ec,16:Pe,22:Pe,48:Pe};function Qr(r,t={offset:0}){let e=r[t.offset]&bc;if(t.offset++,So[e]!=null)return So[e](r,t);throw new Error("No decoder for tag "+e)}function Re(r,t){let e=0;if((r[t.offset]&Jr)===Jr){let n=r[t.offset]&gc,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function Pe(r,t){Re(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=Qr(r,t);if(n===null)break;e.push(n)}return e}function wc(r,t){let e=Re(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function Ec(r,t){let e=Re(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let a=`${s}.${i}`,c=[];for(;t.offset<n;){let d=r[t.offset];if(t.offset++,c.push(d&127),d<128){c.reverse();let f=0;for(let l=0;l<c.length;l++)f+=c[l]<<l*7;a+=`.${f}`,c=[]}}return a}function _c(r,t){return t.offset++,null}function Sc(r,t){let e=Re(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Ac(r,t){let e=Re(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function vc(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new pt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function tn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=vc(r.byteLength);return new pt(Uint8Array.from([t.byteLength|Jr]),t)}function Ao(r){let t=new pt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new pt(Uint8Array.from([2]),tn(t),t)}function vo(r){let t=Uint8Array.from([0]),e=new pt(t,r);return new pt(Uint8Array.from([3]),tn(e),e)}function nr(r,t=48){let e=new pt;for(let n of r)e.append(n);return new pt(Uint8Array.from([t]),tn(e),e)}async function Bo(r,t,e){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,e.subarray())}var Bc=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Ic=Uint8Array.from([6,5,43,129,4,0,34]),Lc=Uint8Array.from([6,5,43,129,4,0,35]),Cc={ext:!0,kty:"EC",crv:"P-256"},Uc={ext:!0,kty:"EC",crv:"P-384"},Tc={ext:!0,kty:"EC",crv:"P-521"},en=32,rn=48,nn=66;function Io(r){let t=Qr(r);return Lo(t)}function Lo(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===en*2+1)return n=Et(t.subarray(e,e+en),"base64url"),o=Et(t.subarray(e+en),"base64url"),new me({...Cc,key_ops:["verify"],x:n,y:o});if(t.byteLength===rn*2+1)return n=Et(t.subarray(e,e+rn),"base64url"),o=Et(t.subarray(e+rn),"base64url"),new me({...Uc,key_ops:["verify"],x:n,y:o});if(t.byteLength===nn*2+1)return n=Et(t.subarray(e,e+nn),"base64url"),o=Et(t.subarray(e+nn),"base64url"),new me({...Tc,key_ops:["verify"],x:n,y:o});throw new Ct(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Co(r){return nr([Ao(Uint8Array.from([1])),nr([Dc(r.crv)],160),nr([vo(new pt(Uint8Array.from([4]),J(r.x??"","base64url"),J(r.y??"","base64url")))],161)]).subarray()}function Dc(r){if(r==="P-256")return Bc;if(r==="P-384")return Ic;if(r==="P-521")return Lc;throw new Ct(`Invalid curve ${r}`)}var me=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Co(this.jwk)),this._raw}toMultihash(){return gt.digest(xe(this))}toCID(){return ft.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:lt(this.raw,t.raw)}async verify(t,e){return Bo(this.jwk,e,t)}};var Jt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Pc(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function or(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Qt(r,...t){if(!Pc(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 Uo(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");or(r.outputLen),or(r.blockLen)}function be(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 To(r,t){Qt(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function Tt(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function sr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function _t(r,t){return r<<32-t|r>>>t}function Do(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function Ne(r){return typeof r=="string"&&(r=Do(r)),Qt(r),r}function on(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Qt(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 ye=class{};function sn(r){let t=n=>r().update(Ne(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function ir(r=32){if(Jt&&typeof Jt.getRandomValues=="function")return Jt.getRandomValues(new Uint8Array(r));if(Jt&&typeof Jt.randomBytes=="function")return Uint8Array.from(Jt.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function Rc(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),a=Number(e&s),c=n?4:0,d=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+d,a,n)}function Po(r,t,e){return r&t^~r&e}function Ro(r,t,e){return r&t^r&e^t&e}var ke=class extends ye{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=sr(this.buffer)}update(t){be(this),t=Ne(t),Qt(t);let{view:e,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=sr(t);for(;o<=s-i;i+=o)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){be(this),To(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,Tt(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)e[l]=0;Rc(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=sr(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=c/4,f=this.get();if(d>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<d;l++)a.setUint32(4*l,f[l],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:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=a,o%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Dt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var rt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var cr=BigInt(4294967295),No=BigInt(32);function Nc(r,t=!1){return t?{h:Number(r&cr),l:Number(r>>No&cr)}:{h:Number(r>>No&cr)|0,l:Number(r&cr)|0}}function ko(r,t=!1){let e=r.length,n=new Uint32Array(e),o=new Uint32Array(e);for(let s=0;s<e;s++){let{h:i,l:a}=Nc(r[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var cn=(r,t,e)=>r>>>e,an=(r,t,e)=>r<<32-e|t>>>e,te=(r,t,e)=>r>>>e|t<<32-e,ee=(r,t,e)=>r<<32-e|t>>>e,Ke=(r,t,e)=>r<<64-e|t>>>e-32,Oe=(r,t,e)=>r>>>e-32|t<<64-e;function vt(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var Ko=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Oo=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Mo=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Ho=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,zo=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),qo=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Kc=Uint32Array.from([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]),Ht=new Uint32Array(64),fn=class extends ke{constructor(t=32){super(64,t,8,!1),this.A=Dt[0]|0,this.B=Dt[1]|0,this.C=Dt[2]|0,this.D=Dt[3]|0,this.E=Dt[4]|0,this.F=Dt[5]|0,this.G=Dt[6]|0,this.H=Dt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,e,n,o,s,i,a,c]}set(t,e,n,o,s,i,a,c){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,e){for(let l=0;l<16;l++,e+=4)Ht[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let E=Ht[l-15],I=Ht[l-2],S=_t(E,7)^_t(E,18)^E>>>3,x=_t(I,17)^_t(I,19)^I>>>10;Ht[l]=x+Ht[l-7]+S+Ht[l-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:d,H:f}=this;for(let l=0;l<64;l++){let E=_t(a,6)^_t(a,11)^_t(a,25),I=f+E+Po(a,c,d)+Kc[l]+Ht[l]|0,x=(_t(n,2)^_t(n,13)^_t(n,22))+Ro(n,o,s)|0;f=d,d=c,c=a,a=i+I|0,i=s,s=o,o=n,n=I+x|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(n,o,s,i,a,c,d,f)}roundClean(){Tt(Ht)}destroy(){this.set(0,0,0,0,0,0,0,0),Tt(this.buffer)}};var Vo=ko(["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))),Oc=Vo[0],Mc=Vo[1],zt=new Uint32Array(80),qt=new Uint32Array(80),un=class extends ke{constructor(t=64){super(128,t,16,!1),this.Ah=rt[0]|0,this.Al=rt[1]|0,this.Bh=rt[2]|0,this.Bl=rt[3]|0,this.Ch=rt[4]|0,this.Cl=rt[5]|0,this.Dh=rt[6]|0,this.Dl=rt[7]|0,this.Eh=rt[8]|0,this.El=rt[9]|0,this.Fh=rt[10]|0,this.Fl=rt[11]|0,this.Gh=rt[12]|0,this.Gl=rt[13]|0,this.Hh=rt[14]|0,this.Hl=rt[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:d,El:f,Fh:l,Fl:E,Gh:I,Gl:S,Hh:x,Hl:P}=this;return[t,e,n,o,s,i,a,c,d,f,l,E,I,S,x,P]}set(t,e,n,o,s,i,a,c,d,f,l,E,I,S,x,P){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=d|0,this.El=f|0,this.Fh=l|0,this.Fl=E|0,this.Gh=I|0,this.Gl=S|0,this.Hh=x|0,this.Hl=P|0}process(t,e){for(let _=0;_<16;_++,e+=4)zt[_]=t.getUint32(e),qt[_]=t.getUint32(e+=4);for(let _=16;_<80;_++){let u=zt[_-15]|0,m=qt[_-15]|0,A=te(u,m,1)^te(u,m,8)^cn(u,m,7),v=ee(u,m,1)^ee(u,m,8)^an(u,m,7),B=zt[_-2]|0,D=qt[_-2]|0,K=te(B,D,19)^Ke(B,D,61)^cn(B,D,6),C=ee(B,D,19)^Oe(B,D,61)^an(B,D,6),N=Mo(v,C,qt[_-7],qt[_-16]),T=Ho(N,A,K,zt[_-7],zt[_-16]);zt[_]=T|0,qt[_]=N|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:d,Dl:f,Eh:l,El:E,Fh:I,Fl:S,Gh:x,Gl:P,Hh:R,Hl:z}=this;for(let _=0;_<80;_++){let u=te(l,E,14)^te(l,E,18)^Ke(l,E,41),m=ee(l,E,14)^ee(l,E,18)^Oe(l,E,41),A=l&I^~l&x,v=E&S^~E&P,B=zo(z,m,v,Mc[_],qt[_]),D=qo(B,R,u,A,Oc[_],zt[_]),K=B|0,C=te(n,o,28)^Ke(n,o,34)^Ke(n,o,39),N=ee(n,o,28)^Oe(n,o,34)^Oe(n,o,39),T=n&s^n&a^s&a,W=o&i^o&c^i&c;R=x|0,z=P|0,x=I|0,P=S|0,I=l|0,S=E|0,{h:l,l:E}=vt(d|0,f|0,D|0,K|0),d=a|0,f=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let g=Ko(K,N,W);n=Oo(g,D,C,T),o=g|0}({h:n,l:o}=vt(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=vt(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=vt(this.Ch|0,this.Cl|0,a|0,c|0),{h:d,l:f}=vt(this.Dh|0,this.Dl|0,d|0,f|0),{h:l,l:E}=vt(this.Eh|0,this.El|0,l|0,E|0),{h:I,l:S}=vt(this.Fh|0,this.Fl|0,I|0,S|0),{h:x,l:P}=vt(this.Gh|0,this.Gl|0,x|0,P|0),{h:R,l:z}=vt(this.Hh|0,this.Hl|0,R|0,z|0),this.set(n,o,s,i,a,c,d,f,l,E,I,S,x,P,R,z)}roundClean(){Tt(zt,qt)}destroy(){Tt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Fo=sn(()=>new fn);var jo=sn(()=>new un);var pn=BigInt(0),dn=BigInt(1);function ge(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function mn(r){if(!ge(r))throw new Error("Uint8Array expected")}function Bt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function Me(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Yo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?pn:BigInt("0x"+r)}var Wo=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Hc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Vt(r){if(mn(r),Wo)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=Hc[r[e]];return t}var Pt={_0:48,_9:57,A:65,F:70,a:97,f:102};function Go(r){if(r>=Pt._0&&r<=Pt._9)return r-Pt._0;if(r>=Pt.A&&r<=Pt.F)return r-(Pt.A-10);if(r>=Pt.a&&r<=Pt.f)return r-(Pt.a-10)}function He(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(Wo)return Uint8Array.fromHex(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 i=Go(r.charCodeAt(s)),a=Go(r.charCodeAt(s+1));if(i===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function Rt(r){return Yo(Vt(r))}function re(r){return mn(r),Yo(Vt(Uint8Array.from(r).reverse()))}function ne(r,t){return He(r.toString(16).padStart(t*2,"0"))}function we(r,t){return ne(r,t).reverse()}function F(r,t,e){let n;if(typeof t=="string")try{n=He(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(ge(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 Ft(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];mn(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 hn=r=>typeof r=="bigint"&&pn<=r;function ar(r,t,e){return hn(r)&&hn(t)&&hn(e)&&t<=r&&r<e}function mt(r,t,e,n){if(!ar(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Xo(r){let t;for(t=0;r>pn;r>>=dn,t+=1);return t}var oe=r=>(dn<<BigInt(r))-dn,ln=r=>new Uint8Array(r),Zo=r=>Uint8Array.from(r);function $o(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=ln(r),o=ln(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},a=(...l)=>e(o,n,...l),c=(l=ln(0))=>{o=a(Zo([0]),l),n=a(),l.length!==0&&(o=a(Zo([1]),l),n=a())},d=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,E=[];for(;l<t;){n=a();let I=n.slice();E.push(I),l+=n.length}return Ft(...E)};return(l,E)=>{i(),c(l);let I;for(;!(I=E(d()));)c();return i(),I}}var zc={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"||ge(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 Nt(r,t,e={}){let n=(o,s,i)=>{let a=zc[s];if(typeof a!="function")throw new Error("invalid validator function");let c=r[o];if(!(i&&c===void 0)&&!a(c,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+c)};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}function Ee(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 st=BigInt(0),Q=BigInt(1),se=BigInt(2),qc=BigInt(3),Qo=BigInt(4),ts=BigInt(5),es=BigInt(8);function V(r,t){let e=r%t;return e>=st?e:t+e}function j(r,t,e){let n=r;for(;t-- >st;)n*=n,n%=e;return n}function fr(r,t){if(r===st)throw new Error("invert: expected non-zero number");if(t<=st)throw new Error("invert: expected positive modulus, got "+t);let e=V(r,t),n=t,o=st,s=Q,i=Q,a=st;for(;e!==st;){let d=n/e,f=n%e,l=o-i*d,E=s-a*d;n=e,e=f,o=i,s=a,i=l,a=E}if(n!==Q)throw new Error("invert: does not exist");return V(o,t)}function rs(r,t){let e=(r.ORDER+Q)/Qo,n=r.pow(t,e);if(!r.eql(r.sqr(n),t))throw new Error("Cannot find square root");return n}function Vc(r,t){let e=(r.ORDER-ts)/es,n=r.mul(t,se),o=r.pow(n,e),s=r.mul(t,o),i=r.mul(r.mul(s,se),o),a=r.mul(s,r.sub(i,r.ONE));if(!r.eql(r.sqr(a),t))throw new Error("Cannot find square root");return a}function Fc(r){if(r<BigInt(3))throw new Error("sqrt is not defined for small field");let t=r-Q,e=0;for(;t%se===st;)t/=se,e++;let n=se,o=kt(r);for(;Jo(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return rs;let s=o.pow(n,t),i=(t+Q)/se;return function(c,d){if(c.is0(d))return d;if(Jo(c,d)!==1)throw new Error("Cannot find square root");let f=e,l=c.mul(c.ONE,s),E=c.pow(d,t),I=c.pow(d,i);for(;!c.eql(E,c.ONE);){if(c.is0(E))return c.ZERO;let S=1,x=c.sqr(E);for(;!c.eql(x,c.ONE);)if(S++,x=c.sqr(x),S===f)throw new Error("Cannot find square root");let P=Q<<BigInt(f-S-1),R=c.pow(l,P);f=S,l=c.sqr(R),E=c.mul(E,l),I=c.mul(I,R)}return I}}function jc(r){return r%Qo===qc?rs:r%es===ts?Vc:Fc(r)}var ns=(r,t)=>(V(r,t)&Q)===Q,Gc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function xn(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Gc.reduce((n,o)=>(n[o]="function",n),t);return Nt(r,e)}function Zc(r,t,e){if(e<st)throw new Error("invalid exponent, negatives unsupported");if(e===st)return r.ONE;if(e===Q)return t;let n=r.ONE,o=t;for(;e>st;)e&Q&&(n=r.mul(n,o)),o=r.sqr(o),e>>=Q;return n}function _e(r,t,e=!1){let n=new Array(t.length).fill(e?r.ZERO:void 0),o=t.reduce((i,a,c)=>r.is0(a)?i:(n[c]=i,r.mul(i,a)),r.ONE),s=r.inv(o);return t.reduceRight((i,a,c)=>r.is0(a)?i:(n[c]=r.mul(i,n[c]),r.mul(i,a)),s),n}function Jo(r,t){let e=(r.ORDER-Q)/se,n=r.pow(t,e),o=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),i=r.eql(n,r.neg(r.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function yn(r,t){t!==void 0&&or(t);let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function kt(r,t,e=!1,n={}){if(r<=st)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=yn(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,a=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:oe(o),ZERO:st,ONE:Q,create:c=>V(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return st<=c&&c<r},is0:c=>c===st,isOdd:c=>(c&Q)===Q,neg:c=>V(-c,r),eql:(c,d)=>c===d,sqr:c=>V(c*c,r),add:(c,d)=>V(c+d,r),sub:(c,d)=>V(c-d,r),mul:(c,d)=>V(c*d,r),pow:(c,d)=>Zc(a,c,d),div:(c,d)=>V(c*fr(d,r),r),sqrN:c=>c*c,addN:(c,d)=>c+d,subN:(c,d)=>c-d,mulN:(c,d)=>c*d,inv:c=>fr(c,r),sqrt:n.sqrt||(c=>(i||(i=jc(r)),i(a,c))),toBytes:c=>e?we(c,s):ne(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return e?re(c):Rt(c)},invertBatch:c=>_e(a,c),cmov:(c,d,f)=>f?d:c});return Object.freeze(a)}function os(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 bn(r){let t=os(r);return t+Math.ceil(t/2)}function ss(r,t,e=!1){let n=r.length,o=os(t),s=bn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?re(r):Rt(r),a=V(i,t-Q)+Q;return e?we(a,o):ne(a,o)}var is=BigInt(0),Sn=BigInt(1);function gn(r,t){let e=t.negate();return r?e:t}function as(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function wn(r,t){as(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=oe(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function cs(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,a=Number(r&o),c=r>>i;a>n&&(a-=s,c+=Sn);let d=t*n,f=d+Math.abs(a)-1,l=a===0,E=a<0,I=t%2!==0;return{nextN:c,offset:f,isZero:l,isNeg:E,isNegF:I,offsetF:d}}function Yc(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 En=new WeakMap,fs=new WeakMap;function _n(r){return fs.get(r)||1}function ur(r,t){return{constTimeNegate:gn,hasPrecomputes(e){return _n(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>is;)n&Sn&&(o=o.add(s)),s=s.double(),n>>=Sn;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=wn(n,t),i=[],a=e,c=a;for(let d=0;d<o;d++){c=a,i.push(c);for(let f=1;f<s;f++)c=c.add(a),i.push(c);a=c.double()}return i},wNAF(e,n,o){let s=r.ZERO,i=r.BASE,a=wn(e,t);for(let c=0;c<a.windows;c++){let{nextN:d,offset:f,isZero:l,isNeg:E,isNegF:I,offsetF:S}=cs(o,c,a);o=d,l?i=i.add(gn(I,n[S])):s=s.add(gn(E,n[f]))}return{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=wn(e,t);for(let a=0;a<i.windows&&o!==is;a++){let{nextN:c,offset:d,isZero:f,isNeg:l}=cs(o,a,i);if(o=c,!f){let E=n[d];s=s.add(l?E.negate():E)}}return s},getPrecomputes(e,n,o){let s=En.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&En.set(n,o(s))),s},wNAFCached(e,n,o){let s=_n(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=_n(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){as(n,t),fs.set(e,n),En.delete(e)}}}function hr(r,t,e,n){Yc(e,r),Wc(n,t);let o=e.length,s=n.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");let i=r.ZERO,a=Xo(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let d=oe(c),f=new Array(Number(d)+1).fill(i),l=Math.floor((t.BITS-1)/c)*c,E=i;for(let I=l;I>=0;I-=c){f.fill(i);for(let x=0;x<s;x++){let P=n[x],R=Number(P>>BigInt(I)&d);f[R]=f[R].add(e[x])}let S=i;for(let x=f.length-1,P=i;x>0;x--)P=P.add(f[x]),S=S.add(P);if(E=E.add(S),I!==0)for(let x=0;x<c;x++)E=E.double()}return E}function ze(r){return xn(r.Fp),Nt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...yn(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var It=BigInt(0),it=BigInt(1),us=BigInt(2),Xc=BigInt(8),$c={zip215:!0};function Jc(r){let t=ze(r);return Nt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function hs(r){let t=Jc(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:a,h:c}=t,d=us<<BigInt(a*8)-it,f=e.create,l=kt(t.n,t.nBitLength);function E(y,h){let p=e.sqr(y),w=e.sqr(h),U=e.add(e.mul(t.a,p),w),k=e.add(e.ONE,e.mul(t.d,e.mul(p,w)));return e.eql(U,k)}if(!E(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let I=t.uvRatio||((y,h)=>{try{return{isValid:!0,value:e.sqrt(y*e.inv(h))}}catch{return{isValid:!1,value:It}}}),S=t.adjustScalarBytes||(y=>y),x=t.domain||((y,h,p)=>{if(Bt("phflag",p),h.length||p)throw new Error("Contexts/pre-hash are not supported");return y});function P(y,h,p=!1){let w=p?it:It;mt("coordinate "+y,h,w,d)}function R(y){if(!(y instanceof u))throw new Error("ExtendedPoint expected")}let z=Ee((y,h)=>{let{ex:p,ey:w,ez:U}=y,k=y.is0();h==null&&(h=k?Xc:e.inv(U));let O=f(p*h),M=f(w*h),H=f(U*h);if(k)return{x:It,y:it};if(H!==it)throw new Error("invZ was invalid");return{x:O,y:M}}),_=Ee(y=>{let{a:h,d:p}=t;if(y.is0())throw new Error("bad point: ZERO");let{ex:w,ey:U,ez:k,et:O}=y,M=f(w*w),H=f(U*U),q=f(k*k),X=f(q*q),Z=f(M*h),et=f(q*f(Z+H)),at=f(X+f(p*f(M*H)));if(et!==at)throw new Error("bad point: equation left != right (1)");let $=f(w*U),nt=f(k*O);if($!==nt)throw new Error("bad point: equation left != right (2)");return!0});class u{constructor(h,p,w,U){P("x",h),P("y",p),P("z",w,!0),P("t",U),this.ex=h,this.ey=p,this.ez=w,this.et=U,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(h){if(h instanceof u)throw new Error("extended point not allowed");let{x:p,y:w}=h||{};return P("x",p),P("y",w),new u(p,w,it,f(p*w))}static normalizeZ(h){let p=_e(e,h.map(w=>w.ez));return h.map((w,U)=>w.toAffine(p[U])).map(u.fromAffine)}static msm(h,p){return hr(u,l,h,p)}_setWindowSize(h){v.setWindowSize(this,h)}assertValidity(){_(this)}equals(h){R(h);let{ex:p,ey:w,ez:U}=this,{ex:k,ey:O,ez:M}=h,H=f(p*M),q=f(k*U),X=f(w*M),Z=f(O*U);return H===q&&X===Z}is0(){return this.equals(u.ZERO)}negate(){return new u(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:h}=t,{ex:p,ey:w,ez:U}=this,k=f(p*p),O=f(w*w),M=f(us*f(U*U)),H=f(h*k),q=p+w,X=f(f(q*q)-k-O),Z=H+O,et=Z-M,at=H-O,$=f(X*et),nt=f(Z*at),ut=f(X*at),bt=f(et*Z);return new u($,nt,bt,ut)}add(h){R(h);let{a:p,d:w}=t,{ex:U,ey:k,ez:O,et:M}=this,{ex:H,ey:q,ez:X,et:Z}=h,et=f(U*H),at=f(k*q),$=f(M*w*Z),nt=f(O*X),ut=f((U+k)*(H+q)-et-at),bt=nt-$,ve=nt+$,Qn=f(at-p*et),ni=f(ut*bt),oi=f(ve*Qn),si=f(ut*Qn),ii=f(bt*ve);return new u(ni,oi,ii,si)}subtract(h){return this.add(h.negate())}wNAF(h){return v.wNAFCached(this,h,u.normalizeZ)}multiply(h){let p=h;mt("scalar",p,it,n);let{p:w,f:U}=this.wNAF(p);return u.normalizeZ([w,U])[0]}multiplyUnsafe(h,p=u.ZERO){let w=h;return mt("scalar",w,It,n),w===It?A:this.is0()||w===it?this:v.wNAFCachedUnsafe(this,w,u.normalizeZ,p)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return v.unsafeLadder(this,n).is0()}toAffine(h){return z(this,h)}clearCofactor(){let{h}=t;return h===it?this:this.multiplyUnsafe(h)}static fromHex(h,p=!1){let{d:w,a:U}=t,k=e.BYTES;h=F("pointHex",h,k),Bt("zip215",p);let O=h.slice(),M=h[k-1];O[k-1]=M&-129;let H=re(O),q=p?d:e.ORDER;mt("pointHex.y",H,It,q);let X=f(H*H),Z=f(X-it),et=f(w*X-U),{isValid:at,value:$}=I(Z,et);if(!at)throw new Error("Point.fromHex: invalid y coordinate");let nt=($&it)===it,ut=(M&128)!==0;if(!p&&$===It&&ut)throw new Error("Point.fromHex: x=0 and x_0=1");return ut!==nt&&($=f(-$)),u.fromAffine({x:$,y:H})}static fromPrivateKey(h){let{scalar:p}=K(h);return m.multiply(p)}toRawBytes(){let{x:h,y:p}=this.toAffine(),w=we(p,e.BYTES);return w[w.length-1]|=h&it?128:0,w}toHex(){return Vt(this.toRawBytes())}}u.BASE=new u(t.Gx,t.Gy,it,f(t.Gx*t.Gy)),u.ZERO=new u(It,it,it,It);let{BASE:m,ZERO:A}=u,v=ur(u,a*8);function B(y){return V(y,n)}function D(y){return B(re(y))}function K(y){let h=e.BYTES;y=F("private key",y,h);let p=F("hashed private key",s(y),2*h),w=S(p.slice(0,h)),U=p.slice(h,2*h),k=D(w);return{head:w,prefix:U,scalar:k}}function C(y){let{head:h,prefix:p,scalar:w}=K(y),U=m.multiply(w),k=U.toRawBytes();return{head:h,prefix:p,scalar:w,point:U,pointBytes:k}}function N(y){return C(y).pointBytes}function T(y=Uint8Array.of(),...h){let p=Ft(...h);return D(s(x(p,F("context",y),!!o)))}function W(y,h,p={}){y=F("message",y),o&&(y=o(y));let{prefix:w,scalar:U,pointBytes:k}=C(h),O=T(p.context,w,y),M=m.multiply(O).toRawBytes(),H=T(p.context,M,k,y),q=B(O+H*U);mt("signature.s",q,It,n);let X=Ft(M,we(q,e.BYTES));return F("result",X,e.BYTES*2)}let g=$c;function b(y,h,p,w=g){let{context:U,zip215:k}=w,O=e.BYTES;y=F("signature",y,2*O),h=F("message",h),p=F("publicKey",p,O),k!==void 0&&Bt("zip215",k),o&&(h=o(h));let M=re(y.slice(O,2*O)),H,q,X;try{H=u.fromHex(p,k),q=u.fromHex(y.slice(0,O),k),X=m.multiplyUnsafe(M)}catch{return!1}if(!k&&H.isSmallOrder())return!1;let Z=T(U,q.toRawBytes(),H.toRawBytes(),h);return q.add(H.multiplyUnsafe(Z)).subtract(X).clearCofactor().equals(u.ZERO)}return m._setWindowSize(8),{CURVE:t,getPublicKey:N,sign:W,verify:b,ExtendedPoint:u,utils:{getExtendedPublicKey:C,randomPrivateKey:()=>i(e.BYTES),precompute(y=8,h=u.BASE){return h._setWindowSize(y),h.multiply(BigInt(3)),h}}}}var An=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ls=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),zu=BigInt(0),Qc=BigInt(1),ds=BigInt(2),qu=BigInt(3),ta=BigInt(5),ea=BigInt(8);function ra(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=An,a=r*r%s*r%s,c=j(a,ds,s)*a%s,d=j(c,Qc,s)*r%s,f=j(d,ta,s)*d%s,l=j(f,t,s)*f%s,E=j(l,e,s)*l%s,I=j(E,n,s)*E%s,S=j(I,o,s)*I%s,x=j(S,o,s)*I%s,P=j(x,t,s)*f%s;return{pow_p_5_8:j(P,ds,s)*r%s,b2:a}}function na(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function oa(r,t){let e=An,n=V(t*t*t,e),o=V(n*n*t,e),s=ra(r*o).pow_p_5_8,i=V(r*n*s,e),a=V(t*i*i,e),c=i,d=V(i*ls,e),f=a===r,l=a===V(-r,e),E=a===V(-r*ls,e);return f&&(i=c),(l||E)&&(i=d),ns(i,e)&&(i=V(-i,e)),{isValid:f||l,value:i}}var ps=kt(An,void 0,!0),sa={a:ps.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ps,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:ea,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:jo,randomBytes:ir,adjustScalarBytes:na,uvRatio:oa},ms=hs(sa);var lr=32;function xs(r,t,e){return ms.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var dr=class{type="Ed25519";raw;constructor(t){this.raw=vn(t,lr)}toMultihash(){return gt.digest(xe(this))}toCID(){return ft.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:lt(this.raw,t.raw)}verify(t,e){return xs(this.raw,e,t)}};function bs(r){return r=vn(r,lr),new dr(r)}function vn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new Ct(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var ca=Math.pow(2,7),aa=Math.pow(2,14),fa=Math.pow(2,21),gs=Math.pow(2,28),ws=Math.pow(2,35),Es=Math.pow(2,42),_s=Math.pow(2,49),ct=128,jt=127;function qe(r){if(r<ca)return 1;if(r<aa)return 2;if(r<fa)return 3;if(r<gs)return 4;if(r<ws)return 5;if(r<Es)return 6;if(r<_s)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Ss(r,t,e=0){switch(qe(r)){case 8:t[e++]=r&255|ct,r/=128;case 7:t[e++]=r&255|ct,r/=128;case 6:t[e++]=r&255|ct,r/=128;case 5:t[e++]=r&255|ct,r/=128;case 4:t[e++]=r&255|ct,r>>>=7;case 3:t[e++]=r&255|ct,r>>>=7;case 2:t[e++]=r&255|ct,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function As(r,t){let e=r[t],n=0;if(n+=e&jt,e<ct||(e=r[t+1],n+=(e&jt)<<7,e<ct)||(e=r[t+2],n+=(e&jt)<<14,e<ct)||(e=r[t+3],n+=(e&jt)<<21,e<ct)||(e=r[t+4],n+=(e&jt)*gs,e<ct)||(e=r[t+5],n+=(e&jt)*ws,e<ct)||(e=r[t+6],n+=(e&jt)*Es,e<ct)||(e=r[t+7],n+=(e&jt)*_s,e<ct))return n;throw new RangeError("Could not decode varint")}var Bn=new Float32Array([-0]),Gt=new Uint8Array(Bn.buffer);function vs(r,t,e){Bn[0]=r,t[e]=Gt[0],t[e+1]=Gt[1],t[e+2]=Gt[2],t[e+3]=Gt[3]}function Bs(r,t){return Gt[0]=r[t],Gt[1]=r[t+1],Gt[2]=r[t+2],Gt[3]=r[t+3],Bn[0]}var In=new Float64Array([-0]),ot=new Uint8Array(In.buffer);function Is(r,t,e){In[0]=r,t[e]=ot[0],t[e+1]=ot[1],t[e+2]=ot[2],t[e+3]=ot[3],t[e+4]=ot[4],t[e+5]=ot[5],t[e+6]=ot[6],t[e+7]=ot[7]}function Ls(r,t){return ot[0]=r[t],ot[1]=r[t+1],ot[2]=r[t+2],ot[3]=r[t+3],ot[4]=r[t+4],ot[5]=r[t+5],ot[6]=r[t+6],ot[7]=r[t+7],In[0]}var ua=BigInt(Number.MAX_SAFE_INTEGER),ha=BigInt(Number.MIN_SAFE_INTEGER),xt=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 ie;if(t<ua&&t>ha)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>Cs&&(o=0n,++n>Cs&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ie;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):ie}},ie=new xt(0,0);ie.toBigInt=function(){return 0n};ie.zzEncode=ie.zzDecode=function(){return this};ie.length=function(){return 1};var Cs=4294967296n;function Us(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 Ts(r,t,e){if(e-t<1)return"";let o,s=[],i=0,a;for(;t<e;)a=r[t++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(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[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function Ln(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,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 St(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function pr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Cn=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,St(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 St(this,4);return pr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw St(this,4);return pr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw St(this,4);let t=Bs(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw St(this,4);let t=Ls(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 St(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Ts(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw St(this,t);this.pos+=t}else do if(this.pos>=this.len)throw St(this);while((this.buf[this.pos++]&128)!==0);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 xt(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 St(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 St(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 St(this,8);let t=pr(this.buf,this.pos+=4),e=pr(this.buf,this.pos+=4);return new xt(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=As(this.buf,this.pos);return this.pos+=qe(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 Un(r){return new Cn(r instanceof Uint8Array?r:r.subarray())}function mr(r,t,e){let n=Un(r);return t.decode(n,void 0,e)}function Tn(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return dt(i);o+i>t&&(n=dt(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var ce=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Dn(){}var Rn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},la=Tn();function da(r){return globalThis.Buffer!=null?dt(r):la(r)}var Fe=class{len;head;tail;states;constructor(){this.len=0,this.head=new ce(Dn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ce(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Nn((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(xr,10,xt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=xt.fromBigInt(t);return this._push(xr,e.length(),e)}uint64Number(t){return this._push(Ss,qe(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=xt.fromBigInt(t).zzEncode();return this._push(xr,e.length(),e)}sint64Number(t){let e=xt.fromNumber(t).zzEncode();return this._push(xr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Pn,1,t?1:0)}fixed32(t){return this._push(Ve,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=xt.fromBigInt(t);return this._push(Ve,4,e.lo)._push(Ve,4,e.hi)}fixed64Number(t){let e=xt.fromNumber(t);return this._push(Ve,4,e.lo)._push(Ve,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(vs,4,t)}double(t){return this._push(Is,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Pn,1,0):this.uint32(e)._push(ma,e,t)}string(t){let e=Us(t);return e!==0?this.uint32(e)._push(Ln,e,t):this._push(Pn,1,0)}fork(){return this.states=new Rn(this),this.head=this.tail=new ce(Dn,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 ce(Dn,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=da(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Pn(r,t,e){t[e]=r&255}function pa(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Nn=class extends ce{next;constructor(t,e){super(pa,t,e),this.next=void 0}};function xr(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 Ve(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 ma(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Fe.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(xa,t,r),this},Fe.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(ya,t,r),this});function xa(r,t,e){t.set(r,e)}function ya(r,t,e){r.length<40?Ln(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(J(r),e)}function kn(){return new Fe}function yr(r,t){let e=kn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Se;(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"})(Se||(Se={}));function br(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Kn(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let a=t(s);i.int32(a)},n=function(s){let i=s.int32();return t(i)};return br("enum",Se.VARINT,e,n)}function gr(r,t){return br("message",Se.LENGTH_DELIMITED,r,t)}var yt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(yt||(yt={}));var On;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(On||(On={}));(function(r){r.codec=()=>Kn(On)})(yt||(yt={}));var je;(function(r){let t;r.codec=()=>(t==null&&(t=gr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),yt.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={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=yt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>yr(e,r.codec()),r.decode=(e,n)=>mr(e,r.codec(),n)})(je||(je={}));var Mn;(function(r){let t;r.codec=()=>(t==null&&(t=gr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),yt.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={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=yt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>yr(e,r.codec()),r.decode=(e,n)=>mr(e,r.codec(),n)})(Mn||(Mn={}));var Ge=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var wr=class extends ye{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Uo(t);let n=Ne(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 i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),Tt(s)}update(t){return be(this),this.iHash.update(t),this}digestInto(t){be(this),Qt(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:i,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Hn=(r,t,e)=>new wr(r,t).update(e).digest();Hn.create=(r,t)=>new wr(r,t);function Ps(r){r.lowS!==void 0&&Bt("lowS",r.lowS),r.prehash!==void 0&&Bt("prehash",r.prehash)}function ga(r){let t=ze(r);Nt(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}var Vn=class extends Error{constructor(t=""){super(t)}},Kt={Err:Vn,_tlv:{encode:(r,t)=>{let{Err:e}=Kt;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=Me(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Me(o.length/2|128):"";return Me(r)+s+o+t},decode(r,t){let{Err:e}=Kt,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),i=0;if(!s)i=o;else{let c=o&127;if(!c)throw new e("tlv.decode(long): indefinite length not supported");if(c>4)throw new e("tlv.decode(long): byte length is too big");let d=t.subarray(n,n+c);if(d.length!==c)throw new e("tlv.decode: length bytes not complete");if(d[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let f of d)i=i<<8|f;if(n+=c,i<128)throw new e("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+i);if(a.length!==i)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Kt;if(r<Ot)throw new t("integer: negative integers are not allowed");let e=Me(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}=Kt;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 Rt(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Kt,o=F("signature",r),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,s),{v:d,l:f}=n.decode(2,c);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(d)}},hexFromSig(r){let{_tlv:t,_int:e}=Kt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}};function zn(r,t){return Vt(ne(r,t))}var Ot=BigInt(0),tt=BigInt(1),jh=BigInt(2),qn=BigInt(3),wa=BigInt(4);function Ea(r){let t=ga(r),{Fp:e}=t,n=kt(t.n,t.nBitLength),o=t.toBytes||((_,u,m)=>{let A=u.toAffine();return Ft(Uint8Array.from([4]),e.toBytes(A.x),e.toBytes(A.y))}),s=t.fromBytes||(_=>{let u=_.subarray(1),m=e.fromBytes(u.subarray(0,e.BYTES)),A=e.fromBytes(u.subarray(e.BYTES,2*e.BYTES));return{x:m,y:A}});function i(_){let{a:u,b:m}=t,A=e.sqr(_),v=e.mul(A,_);return e.add(e.add(v,e.mul(_,u)),m)}function a(_,u){let m=e.sqr(u),A=i(_);return e.eql(m,A)}if(!a(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let c=e.mul(e.pow(t.a,qn),wa),d=e.mul(e.sqr(t.b),BigInt(27));if(e.is0(e.add(c,d)))throw new Error("bad curve params: a or b");function f(_){return ar(_,tt,t.n)}function l(_){let{allowedPrivateKeyLengths:u,nByteLength:m,wrapPrivateKey:A,n:v}=t;if(u&&typeof _!="bigint"){if(ge(_)&&(_=Vt(_)),typeof _!="string"||!u.includes(_.length))throw new Error("invalid private key");_=_.padStart(m*2,"0")}let B;try{B=typeof _=="bigint"?_:Rt(F("private key",_,m))}catch{throw new Error("invalid private key, expected hex or "+m+" bytes, got "+typeof _)}return A&&(B=V(B,v)),mt("private key",B,tt,v),B}function E(_){if(!(_ instanceof x))throw new Error("ProjectivePoint expected")}let I=Ee((_,u)=>{let{px:m,py:A,pz:v}=_;if(e.eql(v,e.ONE))return{x:m,y:A};let B=_.is0();u==null&&(u=B?e.ONE:e.inv(v));let D=e.mul(m,u),K=e.mul(A,u),C=e.mul(v,u);if(B)return{x:e.ZERO,y:e.ZERO};if(!e.eql(C,e.ONE))throw new Error("invZ was invalid");return{x:D,y:K}}),S=Ee(_=>{if(_.is0()){if(t.allowInfinityPoint&&!e.is0(_.py))return;throw new Error("bad point: ZERO")}let{x:u,y:m}=_.toAffine();if(!e.isValid(u)||!e.isValid(m))throw new Error("bad point: x or y not FE");if(!a(u,m))throw new Error("bad point: equation left != right");if(!_.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class x{constructor(u,m,A){if(u==null||!e.isValid(u))throw new Error("x required");if(m==null||!e.isValid(m)||e.is0(m))throw new Error("y required");if(A==null||!e.isValid(A))throw new Error("z required");this.px=u,this.py=m,this.pz=A,Object.freeze(this)}static fromAffine(u){let{x:m,y:A}=u||{};if(!u||!e.isValid(m)||!e.isValid(A))throw new Error("invalid affine point");if(u instanceof x)throw new Error("projective point not allowed");let v=B=>e.eql(B,e.ZERO);return v(m)&&v(A)?x.ZERO:new x(m,A,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(u){let m=_e(e,u.map(A=>A.pz));return u.map((A,v)=>A.toAffine(m[v])).map(x.fromAffine)}static fromHex(u){let m=x.fromAffine(s(F("pointHex",u)));return m.assertValidity(),m}static fromPrivateKey(u){return x.BASE.multiply(l(u))}static msm(u,m){return hr(x,n,u,m)}_setWindowSize(u){z.setWindowSize(this,u)}assertValidity(){S(this)}hasEvenY(){let{y:u}=this.toAffine();if(e.isOdd)return!e.isOdd(u);throw new Error("Field doesn't support isOdd")}equals(u){E(u);let{px:m,py:A,pz:v}=this,{px:B,py:D,pz:K}=u,C=e.eql(e.mul(m,K),e.mul(B,v)),N=e.eql(e.mul(A,K),e.mul(D,v));return C&&N}negate(){return new x(this.px,e.neg(this.py),this.pz)}double(){let{a:u,b:m}=t,A=e.mul(m,qn),{px:v,py:B,pz:D}=this,K=e.ZERO,C=e.ZERO,N=e.ZERO,T=e.mul(v,v),W=e.mul(B,B),g=e.mul(D,D),b=e.mul(v,B);return b=e.add(b,b),N=e.mul(v,D),N=e.add(N,N),K=e.mul(u,N),C=e.mul(A,g),C=e.add(K,C),K=e.sub(W,C),C=e.add(W,C),C=e.mul(K,C),K=e.mul(b,K),N=e.mul(A,N),g=e.mul(u,g),b=e.sub(T,g),b=e.mul(u,b),b=e.add(b,N),N=e.add(T,T),T=e.add(N,T),T=e.add(T,g),T=e.mul(T,b),C=e.add(C,T),g=e.mul(B,D),g=e.add(g,g),T=e.mul(g,b),K=e.sub(K,T),N=e.mul(g,W),N=e.add(N,N),N=e.add(N,N),new x(K,C,N)}add(u){E(u);let{px:m,py:A,pz:v}=this,{px:B,py:D,pz:K}=u,C=e.ZERO,N=e.ZERO,T=e.ZERO,W=t.a,g=e.mul(t.b,qn),b=e.mul(m,B),L=e.mul(A,D),y=e.mul(v,K),h=e.add(m,A),p=e.add(B,D);h=e.mul(h,p),p=e.add(b,L),h=e.sub(h,p),p=e.add(m,v);let w=e.add(B,K);return p=e.mul(p,w),w=e.add(b,y),p=e.sub(p,w),w=e.add(A,v),C=e.add(D,K),w=e.mul(w,C),C=e.add(L,y),w=e.sub(w,C),T=e.mul(W,p),C=e.mul(g,y),T=e.add(C,T),C=e.sub(L,T),T=e.add(L,T),N=e.mul(C,T),L=e.add(b,b),L=e.add(L,b),y=e.mul(W,y),p=e.mul(g,p),L=e.add(L,y),y=e.sub(b,y),y=e.mul(W,y),p=e.add(p,y),b=e.mul(L,p),N=e.add(N,b),b=e.mul(w,p),C=e.mul(h,C),C=e.sub(C,b),b=e.mul(h,L),T=e.mul(w,T),T=e.add(T,b),new x(C,N,T)}subtract(u){return this.add(u.negate())}is0(){return this.equals(x.ZERO)}wNAF(u){return z.wNAFCached(this,u,x.normalizeZ)}multiplyUnsafe(u){let{endo:m,n:A}=t;mt("scalar",u,Ot,A);let v=x.ZERO;if(u===Ot)return v;if(this.is0()||u===tt)return this;if(!m||z.hasPrecomputes(this))return z.wNAFCachedUnsafe(this,u,x.normalizeZ);let{k1neg:B,k1:D,k2neg:K,k2:C}=m.splitScalar(u),N=v,T=v,W=this;for(;D>Ot||C>Ot;)D&tt&&(N=N.add(W)),C&tt&&(T=T.add(W)),W=W.double(),D>>=tt,C>>=tt;return B&&(N=N.negate()),K&&(T=T.negate()),T=new x(e.mul(T.px,m.beta),T.py,T.pz),N.add(T)}multiply(u){let{endo:m,n:A}=t;mt("scalar",u,tt,A);let v,B;if(m){let{k1neg:D,k1:K,k2neg:C,k2:N}=m.splitScalar(u),{p:T,f:W}=this.wNAF(K),{p:g,f:b}=this.wNAF(N);T=z.constTimeNegate(D,T),g=z.constTimeNegate(C,g),g=new x(e.mul(g.px,m.beta),g.py,g.pz),v=T.add(g),B=W.add(b)}else{let{p:D,f:K}=this.wNAF(u);v=D,B=K}return x.normalizeZ([v,B])[0]}multiplyAndAddUnsafe(u,m,A){let v=x.BASE,B=(K,C)=>C===Ot||C===tt||!K.equals(v)?K.multiplyUnsafe(C):K.multiply(C),D=B(this,m).add(B(u,A));return D.is0()?void 0:D}toAffine(u){return I(this,u)}isTorsionFree(){let{h:u,isTorsionFree:m}=t;if(u===tt)return!0;if(m)return m(x,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:u,clearCofactor:m}=t;return u===tt?this:m?m(x,this):this.multiplyUnsafe(t.h)}toRawBytes(u=!0){return Bt("isCompressed",u),this.assertValidity(),o(x,this,u)}toHex(u=!0){return Bt("isCompressed",u),Vt(this.toRawBytes(u))}}x.BASE=new x(t.Gx,t.Gy,e.ONE),x.ZERO=new x(e.ZERO,e.ONE,e.ZERO);let{endo:P,nBitLength:R}=t,z=ur(x,P?Math.ceil(R/2):R);return{CURVE:t,ProjectivePoint:x,normPrivateKeyToScalar:l,weierstrassEquation:i,isWithinCurveOrder:f}}function _a(r){let t=ze(r);return Nt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Rs(r){let t=_a(r),{Fp:e,n,nByteLength:o,nBitLength:s}=t,i=e.BYTES+1,a=2*e.BYTES+1;function c(g){return V(g,n)}function d(g){return fr(g,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:l,weierstrassEquation:E,isWithinCurveOrder:I}=Ea({...t,toBytes(g,b,L){let y=b.toAffine(),h=e.toBytes(y.x),p=Ft;return Bt("isCompressed",L),L?p(Uint8Array.from([b.hasEvenY()?2:3]),h):p(Uint8Array.from([4]),h,e.toBytes(y.y))},fromBytes(g){let b=g.length,L=g[0],y=g.subarray(1);if(b===i&&(L===2||L===3)){let h=Rt(y);if(!ar(h,tt,e.ORDER))throw new Error("Point is not on curve");let p=E(h),w;try{w=e.sqrt(p)}catch(O){let M=O instanceof Error?": "+O.message:"";throw new Error("Point is not on curve"+M)}let U=(w&tt)===tt;return(L&1)===1!==U&&(w=e.neg(w)),{x:h,y:w}}else if(b===a&&L===4){let h=e.fromBytes(y.subarray(0,e.BYTES)),p=e.fromBytes(y.subarray(e.BYTES,2*e.BYTES));return{x:h,y:p}}else{let h=i,p=a;throw new Error("invalid Point, expected length of "+h+", or uncompressed "+p+", got "+b)}}});function S(g){let b=n>>tt;return g>b}function x(g){return S(g)?c(-g):g}let P=(g,b,L)=>Rt(g.slice(b,L));class R{constructor(b,L,y){mt("r",b,tt,n),mt("s",L,tt,n),this.r=b,this.s=L,y!=null&&(this.recovery=y),Object.freeze(this)}static fromCompact(b){let L=o;return b=F("compactSignature",b,L*2),new R(P(b,0,L),P(b,L,2*L))}static fromDER(b){let{r:L,s:y}=Kt.toSig(F("DER",b));return new R(L,y)}assertValidity(){}addRecoveryBit(b){return new R(this.r,this.s,b)}recoverPublicKey(b){let{r:L,s:y,recovery:h}=this,p=v(F("msgHash",b));if(h==null||![0,1,2,3].includes(h))throw new Error("recovery id invalid");let w=h===2||h===3?L+t.n:L;if(w>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let U=(h&1)===0?"02":"03",k=f.fromHex(U+zn(w,e.BYTES)),O=d(w),M=c(-p*O),H=c(y*O),q=f.BASE.multiplyAndAddUnsafe(k,M,H);if(!q)throw new Error("point at infinify");return q.assertValidity(),q}hasHighS(){return S(this.s)}normalizeS(){return this.hasHighS()?new R(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return He(this.toDERHex())}toDERHex(){return Kt.hexFromSig(this)}toCompactRawBytes(){return He(this.toCompactHex())}toCompactHex(){let b=o;return zn(this.r,b)+zn(this.s,b)}}let z={isValidPrivateKey(g){try{return l(g),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let g=bn(t.n);return ss(t.randomBytes(g),t.n)},precompute(g=8,b=f.BASE){return b._setWindowSize(g),b.multiply(BigInt(3)),b}};function _(g,b=!0){return f.fromPrivateKey(g).toRawBytes(b)}function u(g){if(typeof g=="bigint")return!1;if(g instanceof f)return!0;let L=F("key",g).length,y=e.BYTES,h=y+1,p=2*y+1;if(!(t.allowedPrivateKeyLengths||o===h))return L===h||L===p}function m(g,b,L=!0){if(u(g)===!0)throw new Error("first arg must be private key");if(u(b)===!1)throw new Error("second arg must be public key");return f.fromHex(b).multiply(l(g)).toRawBytes(L)}let A=t.bits2int||function(g){if(g.length>8192)throw new Error("input is too large");let b=Rt(g),L=g.length*8-s;return L>0?b>>BigInt(L):b},v=t.bits2int_modN||function(g){return c(A(g))},B=oe(s);function D(g){return mt("num < 2^"+s,g,Ot,B),ne(g,o)}function K(g,b,L=C){if(["recovered","canonical"].some(Z=>Z in L))throw new Error("sign() legacy options not supported");let{hash:y,randomBytes:h}=t,{lowS:p,prehash:w,extraEntropy:U}=L;p==null&&(p=!0),g=F("msgHash",g),Ps(L),w&&(g=F("prehashed msgHash",y(g)));let k=v(g),O=l(b),M=[D(O),D(k)];if(U!=null&&U!==!1){let Z=U===!0?h(e.BYTES):U;M.push(F("extraEntropy",Z))}let H=Ft(...M),q=k;function X(Z){let et=A(Z);if(!I(et))return;let at=d(et),$=f.BASE.multiply(et).toAffine(),nt=c($.x);if(nt===Ot)return;let ut=c(at*c(q+nt*O));if(ut===Ot)return;let bt=($.x===nt?0:2)|Number($.y&tt),ve=ut;return p&&S(ut)&&(ve=x(ut),bt^=1),new R(nt,ve,bt)}return{seed:H,k2sig:X}}let C={lowS:t.lowS,prehash:!1},N={lowS:t.lowS,prehash:!1};function T(g,b,L=C){let{seed:y,k2sig:h}=K(g,b,L),p=t;return $o(p.hash.outputLen,p.nByteLength,p.hmac)(y,h)}f.BASE._setWindowSize(8);function W(g,b,L,y=N){let h=g;b=F("msgHash",b),L=F("publicKey",L);let{lowS:p,prehash:w,format:U}=y;if(Ps(y),"strict"in y)throw new Error("options.strict was renamed to lowS");if(U!==void 0&&U!=="compact"&&U!=="der")throw new Error("format must be compact or der");let k=typeof h=="string"||ge(h),O=!k&&!U&&typeof h=="object"&&h!==null&&typeof h.r=="bigint"&&typeof h.s=="bigint";if(!k&&!O)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let M,H;try{if(O&&(M=new R(h.r,h.s)),k){try{U!=="compact"&&(M=R.fromDER(h))}catch(bt){if(!(bt instanceof Kt.Err))throw bt}!M&&U!=="der"&&(M=R.fromCompact(h))}H=f.fromHex(L)}catch{return!1}if(!M||p&&M.hasHighS())return!1;w&&(b=t.hash(b));let{r:q,s:X}=M,Z=v(b),et=d(X),at=c(Z*et),$=c(q*et),nt=f.BASE.multiplyAndAddUnsafe(H,at,$)?.toAffine();return nt?c(nt.x)===q:!1}return{CURVE:t,getPublicKey:_,getSharedSecret:m,sign:T,verify:W,ProjectivePoint:f,Signature:R,utils:z}}function Sa(r){return{hash:r,hmac:(t,...e)=>Hn(r,t,on(...e)),randomBytes:ir}}function Ns(r,t){let e=n=>Rs({...r,...Sa(n)});return{...e(t),create:e}}var Os=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ks=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Aa=BigInt(0),va=BigInt(1),Fn=BigInt(2),Ks=(r,t)=>(r+t/Fn)/t;function Ba(r){let t=Os,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),d=r*r*r%t,f=d*d*r%t,l=j(f,e,t)*f%t,E=j(l,e,t)*f%t,I=j(E,Fn,t)*d%t,S=j(I,o,t)*I%t,x=j(S,s,t)*S%t,P=j(x,a,t)*x%t,R=j(P,c,t)*P%t,z=j(R,a,t)*x%t,_=j(z,e,t)*f%t,u=j(_,i,t)*S%t,m=j(u,n,t)*d%t,A=j(m,Fn,t);if(!jn.eql(jn.sqr(A),r))throw new Error("Cannot find square root");return A}var jn=kt(Os,void 0,void 0,{sqrt:Ba}),Ae=Ns({a:Aa,b:BigInt(7),Fp:jn,n:ks,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=ks,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-va*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),a=Ks(s*r,t),c=Ks(-n*r,t),d=V(r-a*e-c*o,t),f=V(-a*n-c*s,t),l=d>i,E=f>i;if(l&&(d=t-d),E&&(f=t-f),d>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:d,k2neg:E,k2:f}}}},Fo);function Ms(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Hs(r,t,e){let n=De.digest(e instanceof Uint8Array?e:e.subarray());if(Ms(n))return n.then(({digest:o})=>Ae.verify(t,o,r)).catch(o=>{throw new Ge(String(o))});try{return Ae.verify(t,n.digest,r)}catch(o){throw new Ge(String(o))}}var Er=class{type="secp256k1";raw;_key;constructor(t){this._key=qs(t),this.raw=zs(this._key)}toMultihash(){return gt.digest(xe(this))}toCID(){return ft.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:lt(this.raw,t.raw)}verify(t,e){return Hs(this._key,e,t)}};function Vs(r){return new Er(r)}function zs(r){return Ae.ProjectivePoint.fromHex(r).toRawBytes(!0)}function qs(r){try{return Ae.ProjectivePoint.fromHex(r),r}catch(t){throw new $e(String(t))}}function Fs(r){let{Type:t,Data:e}=je.decode(r.digest),n=e??new Uint8Array;switch(t){case yt.Ed25519:return bs(n);case yt.secp256k1:return Vs(n);case yt.ECDSA:return Io(n);default:throw new Be}}function xe(r){return je.encode({Type:yt[r.type],Data:r.raw})}var js=Symbol.for("nodejs.util.inspect.custom"),Ia=114,Ze=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()})`}[Cr]=!0;toString(){return this.string==null&&(this.string=Y.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ft.createV1(Ia,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return lt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return lt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[js](){return`PeerId(${this.toString()})`}},_r=class extends Ze{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Sr=class extends Ze{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Ar=class extends Ze{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},La=2336,vr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=gt.digest(J(this.url))}[js](){return`PeerId(${this.url})`}[Cr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ft.createV1(La,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=Et(t)),t.toString()===this.toString())}};function Gs(r){if(Ua(r))return new _r({multihash:r});if(Ca(r))try{let t=Fs(r);if(t.type==="Ed25519")return new Sr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Ar({multihash:r,publicKey:t})}catch{let e=Et(r.digest);return new vr(new URL(e))}throw new Je("Supplied PeerID Multihash is invalid")}function Ca(r){return r.code===gt.code}function Ua(r){return r.code===De.code}function Lt(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=Ue(Y.decode(`z${r}`));return Gs(t)}var Zt=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 Lt(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 Lt(this.map.values(),t=>t.key)}values(){return Lt(this.map.values(),t=>t.value)}get size(){return this.map.size}};function Zs(){return new Zt}var Yt=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 Lt(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 Lt(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 Ys(){return new Yt}var Wt=class r{list;constructor(t){if(this.list=[],t!=null)for(let e of t)this.list.push(e)}[Symbol.iterator](){return Lt(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 Lt(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 Ws(){return new Wt}var Gn={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},Xs={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},$s=new globalThis.TextEncoder;function Ta(r,t){let e=Gn[t],n=Xs[t];for(let o=0;o<r.length;o++)n^=BigInt(r[o]),n=BigInt.asUintN(t,n*e);return n}function Da(r,t,e){if(e.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");let n=Gn[t],o=Xs[t],s=r;for(;s.length>0;){let i=$s.encodeInto(s,e);s=s.slice(i.read);for(let a=0;a<i.written;a++)o^=BigInt(e[a]),o=BigInt.asUintN(t,o*n)}return o}function Zn(r,{size:t=32,utf8Buffer:e}={}){if(!Gn[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 Da(r,t,e);r=$s.encode(r)}return Ta(r,t)}var Ye={hash:r=>Number(Zn(r,{size:32})),hashV:(r,t)=>Pa(Ye.hash(r,t))};function Pa(r){let t=r.toString(16);return t.length%2===1&&(t=`0${t}`),J(t,"base16")}var Yn=64,At=class{fp;h;seed;constructor(t,e,n,o=2){if(o>Yn)throw new TypeError("Invalid Fingerprint Size");let s=e.hashV(t,n),i=wt(o);for(let a=0;a<i.length;a++)i[a]=s[a];i.length===0&&(i[0]=7),this.fp=i,this.h=e,this.seed=n}hash(){return this.h.hash(this.fp,this.seed)}equals(t){return t?.fp instanceof Uint8Array?lt(this.fp,t.fp):!1}};function ae(r,t){return Math.floor(Math.random()*(t-r))+r}var fe=class{contents;constructor(t){this.contents=new Array(t).fill(null)}has(t){if(!(t instanceof At))throw new TypeError("Invalid Fingerprint");return this.contents.some(e=>t.equals(e))}add(t){if(!(t instanceof At))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 At))throw new TypeError("Invalid Fingerprint");let e=ae(0,this.contents.length-1),n=this.contents[e];return this.contents[e]=t,n}remove(t){if(!(t instanceof At))throw new TypeError("Invalid Fingerprint");let e=this.contents.findIndex(n=>t.equals(n));return e>-1?(this.contents[e]=null,!0):!1}};var Ra=500,We=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??Ye,this.seed=t.seed??ae(0,Math.pow(2,10))}add(t){typeof t=="string"&&(t=J(t));let e=new At(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 fe(this.bucketSize)),this.buckets[o]==null&&(this.buckets[o]=new fe(this.bucketSize)),this.buckets[n].add(e)||this.buckets[o].add(e))return this.count++,!0;let s=[n,o],i=s[ae(0,s.length-1)];this.buckets[i]==null&&(this.buckets[i]=new fe(this.bucketSize));for(let a=0;a<Ra;a++){let c=this.buckets[i].swap(e);if(c!=null&&(i=(i^c.hash())%this.filterSize,this.buckets[i]==null&&(this.buckets[i]=new fe(this.bucketSize)),this.buckets[i].add(c)))return this.count++,!0}return!1}has(t){typeof t=="string"&&(t=J(t));let e=new At(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=J(t));let e=new At(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,i=this.buckets[s]?.remove(e)??!1;return i&&this.count--,i}get reliable(){return Math.floor(100*(this.count/this.filterSize))<=90}},Na={1:.5,2:.84,4:.95,8:.98};function ka(r=.001){return r>.002?2:r>1e-5?4:8}function Js(r,t=.001){let e=ka(t),n=Na[e],o=Math.round(r/n),s=Math.min(Math.ceil(Math.log2(1/t)+Math.log2(2*e)),Yn);return{filterSize:o,bucketSize:e,fingerprintSize:s}}var Ir=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??Ye,this.seed=t.seed??ae(0,Math.pow(2,10)),this.filterSeries=[new We({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(t){if(typeof t=="string"&&(t=J(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 We({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=J(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=J(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 Wn(r,t=.001,e){return new Ir({...Js(r,t),...e??{}})}var Xe=class{filter;constructor(t,e){this.filter=Wn(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 Qs(r,t=.001){return new Xe(r,t)}var Xn=class extends Zt{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 ti(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Xn({name:t,metrics:e}):n=new Zt,n}var $n=class extends Yt{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 ei(r){let{name:t,metrics:e}=r,n;return e!=null?n=new $n({name:t,metrics:e}):n=new Yt,n}var Jn=class extends Wt{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 ri(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Jn({name:t,metrics:e}):n=new Wt,n}return hi(Ka);})();
2
+ "use strict";var Libp2PPeerCollections=(()=>{var Tr=Object.defineProperty;var hi=Object.getOwnPropertyDescriptor;var li=Object.getOwnPropertyNames;var di=Object.prototype.hasOwnProperty;var ht=(r,t)=>{for(var e in t)Tr(r,e,{get:t[e],enumerable:!0})},pi=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of li(t))!di.call(r,o)&&o!==e&&Tr(r,o,{get:()=>t[o],enumerable:!(n=hi(t,o))||n.enumerable});return r};var mi=r=>pi(Tr({},"__esModule",{value:!0}),r);var Fa={};ht(Fa,{PeerFilter:()=>Xe,PeerList:()=>Wt,PeerMap:()=>Zt,PeerSet:()=>Yt,peerFilter:()=>ni,peerList:()=>Qs,peerMap:()=>$s,peerSet:()=>Js,trackedPeerList:()=>ii,trackedPeerMap:()=>oi,trackedPeerSet:()=>si});var Dr=Symbol.for("@libp2p/peer-id");var Lt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},$e=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Je=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 Kr={};ht(Kr,{base58btc:()=>Y,base58flickr:()=>_i});var Ya=new Uint8Array(0);function oo(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 Ut(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 so(r){return new TextEncoder().encode(r)}function io(r){return new TextDecoder().decode(r)}function yi(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),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,c=r.charAt(0),d=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(S){if(S instanceof Uint8Array||(ArrayBuffer.isView(S)?S=new Uint8Array(S.buffer,S.byteOffset,S.byteLength):Array.isArray(S)&&(S=Uint8Array.from(S))),!(S instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(S.length===0)return"";for(var y=0,P=0,R=0,z=S.length;R!==z&&S[R]===0;)R++,y++;for(var _=(z-R)*f+1>>>0,u=new Uint8Array(_);R!==z;){for(var m=S[R],A=0,v=_-1;(m!==0||A<P)&&v!==-1;v--,A++)m+=256*u[v]>>>0,u[v]=m%a>>>0,m=m/a>>>0;if(m!==0)throw new Error("Non-zero carry");P=A,R++}for(var B=_-P;B!==_&&u[B]===0;)B++;for(var D=c.repeat(y);B<_;++B)D+=r.charAt(u[B]);return D}function E(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var y=0;if(S[y]!==" "){for(var P=0,R=0;S[y]===c;)P++,y++;for(var z=(S.length-y)*d+1>>>0,_=new Uint8Array(z);S[y];){var u=e[S.charCodeAt(y)];if(u===255)return;for(var m=0,A=z-1;(u!==0||m<R)&&A!==-1;A--,m++)u+=a*_[A]>>>0,_[A]=u%256>>>0,u=u/256>>>0;if(u!==0)throw new Error("Non-zero carry");R=m,y++}if(S[y]!==" "){for(var v=z-R;v!==z&&_[v]===0;)v++;for(var B=new Uint8Array(P+(z-v)),D=P;v!==z;)B[D++]=_[v++];return B}}}function I(S){var y=E(S);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:E,decode:I}}var bi=yi,xi=bi,ao=xi;var Pr=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")}},Rr=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 fo(this,t)}},kr=class{decoders;constructor(t){this.decoders=t}or(t){return fo(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 fo(r,t){return new kr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Nr=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 Pr(t,e,n),this.decoder=new Rr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ue({name:r,prefix:t,encode:e,decode:n}){return new Nr(r,t,e,n)}function Mt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=ao(e,r);return ue({prefix:t,name:r,encode:n,decode:s=>Ut(o(s))})}function gi(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,a=0,c=0;for(let d=0;d<o;++d){let f=t[r[d]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|f,i+=e,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=e||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function wi(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function Ei(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function G({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=Ei(n);return ue({prefix:t,name:r,encode(s){return wi(s,n,e)},decode(s){return gi(s,o,e,r)}})}var Y=Mt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),_i=Mt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Or={};ht(Or,{base32:()=>he,base32hex:()=>Bi,base32hexpad:()=>Ci,base32hexpadupper:()=>Li,base32hexupper:()=>Ii,base32pad:()=>Ai,base32padupper:()=>vi,base32upper:()=>Si,base32z:()=>Ui});var he=G({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Si=G({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ai=G({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vi=G({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Bi=G({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ii=G({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ci=G({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Li=G({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ui=G({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Mr={};ht(Mr,{base36:()=>Ie,base36upper:()=>Ti});var Ie=Mt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ti=Mt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Di=lo,uo=128,Pi=127,Ri=~Pi,ki=Math.pow(2,31);function lo(r,t,e){t=t||[],e=e||0;for(var n=e;r>=ki;)t[e++]=r&255|uo,r/=128;for(;r&Ri;)t[e++]=r&255|uo,r>>>=7;return t[e]=r|0,lo.bytes=e-n+1,t}var Ni=Hr,Ki=128,ho=127;function Hr(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Hr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&ho)<<o:(i&ho)*Math.pow(2,o),o+=7}while(i>=Ki);return Hr.bytes=s-n,e}var Oi=Math.pow(2,7),Mi=Math.pow(2,14),Hi=Math.pow(2,21),zi=Math.pow(2,28),qi=Math.pow(2,35),Vi=Math.pow(2,42),Fi=Math.pow(2,49),ji=Math.pow(2,56),Gi=Math.pow(2,63),Zi=function(r){return r<Oi?1:r<Mi?2:r<Hi?3:r<zi?4:r<qi?5:r<Vi?6:r<Fi?7:r<ji?8:r<Gi?9:10},Yi={encode:Di,decode:Ni,encodingLength:Zi},Wi=Yi,Ce=Wi;function Le(r,t=0){return[Ce.decode(r,t),Ce.decode.bytes]}function le(r,t,e=0){return Ce.encode(r,t,e),t}function de(r){return Ce.encodingLength(r)}function Xt(r,t){let e=t.byteLength,n=de(r),o=n+de(e),s=new Uint8Array(o+e);return le(r,s,0),le(e,s,n),s.set(t,o),new pe(r,e,t,s)}function Ue(r){let t=Ut(r),[e,n]=Le(t),[o,s]=Le(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new pe(e,o,i,t)}function po(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&oo(r.bytes,e.bytes)}}var pe=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function mo(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return $i(e,zr(r),t??Y.encoder);default:return Ji(e,zr(r),t??he.encoder)}}var yo=new WeakMap;function zr(r){let t=yo.get(r);if(t==null){let e=new Map;return yo.set(r,e),e}return t}var ft=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!==Te)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Qi)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=Xt(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&&po(t.multihash,n.multihash)}toString(t){return mo(this,t)}toJSON(){return{"/":mo(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:i}=e;return new r(n,o,s,i??bo(n,o,s.bytes))}else if(e[tc]===!0){let{version:n,multihash:o,code:s}=e,i=Ue(o);return r.create(n,s,i)}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!==Te)throw new Error(`Version 0 CID must use dag-pb (code: ${Te}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=bo(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Te,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=Ut(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new pe(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,E]=Le(t.subarray(e));return e+=E,l},o=n(),s=Te;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),c=n(),d=e+c,f=d-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:f,size:d}}static parse(t,e){let[n,o]=Xi(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 zr(s).set(n,t),s}};function Xi(r,t){switch(r[0]){case"Q":{let e=t??Y;return[Y.prefix,e.decode(`${Y.prefix}${r}`)]}case Y.prefix:{let e=t??Y;return[Y.prefix,e.decode(r)]}case he.prefix:{let e=t??he;return[he.prefix,e.decode(r)]}case Ie.prefix:{let e=t??Ie;return[Ie.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!==Y.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 Ji(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 Te=112,Qi=18;function bo(r,t,e){let n=de(r),o=n+de(t),s=new Uint8Array(o+e.byteLength);return le(r,s,0),le(t,s,n),s.set(e,o),s}var tc=Symbol.for("@ipld/js-cid/CID");var qr={};ht(qr,{identity:()=>wt});var xo=0,ec="identity",go=Ut;function rc(r){return Xt(xo,go(r))}var wt={code:xo,name:ec,encode:go,digest:rc};function lt(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 Et(r=0){return new Uint8Array(r)}function dt(r=0){return new Uint8Array(r)}function tr(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=dt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var Eo=Symbol.for("@achingbrain/uint8arraylist");function wo(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function er(r){return!!r?.[Eo]}var pt=class r{bufs;length;[Eo]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(er(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(er(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=wo(this.bufs,t);return e.buf[e.index]}set(t,e){let n=wo(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(er(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return tr(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:tr(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,c=a+i.byteLength;if(o=c,t>=c)continue;let d=t>=a&&t<c,f=e>a&&e<=c;if(d&&f){if(t===a&&e===c){n.push(i);break}let l=t-a;n.push(i.subarray(l,l+(e-t)));break}if(d){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(f){if(e===c){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!er(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let a=i,c=this.byteLength-n.byteLength,d=n.byteLength-1,f;for(let l=e;l<=c;l+=f){f=0;for(let E=d;E>=0;E--){let I=this.get(l+E);if(n[E]!==I){f=Math.max(1,E-a[I]);break}}if(f===0)return l}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=dt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=Et(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=Et(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=Et(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=dt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=Et(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=Et(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=Et(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=Et(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=Et(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!lt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var Vr={};ht(Vr,{base10:()=>nc});var nc=Mt({prefix:"9",name:"base10",alphabet:"0123456789"});var Fr={};ht(Fr,{base16:()=>oc,base16upper:()=>sc});var oc=G({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),sc=G({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var jr={};ht(jr,{base2:()=>ic});var ic=G({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Gr={};ht(Gr,{base256emoji:()=>hc});var _o=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}"),cc=_o.reduce((r,t,e)=>(r[e]=t,r),[]),ac=_o.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+=cc[e],t),"")}function uc(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=ac[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var hc=ue({prefix:"\u{1F680}",name:"base256emoji",encode:fc,decode:uc});var Zr={};ht(Zr,{base64:()=>lc,base64pad:()=>dc,base64url:()=>pc,base64urlpad:()=>mc});var lc=G({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),dc=G({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),pc=G({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mc=G({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Yr={};ht(Yr,{base8:()=>yc});var yc=G({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Wr={};ht(Wr,{identity:()=>bc});var bc=ue({prefix:"\0",name:"identity",encode:r=>io(r),decode:r=>so(r)});var Df=new TextEncoder,Pf=new TextDecoder;var Jr={};ht(Jr,{sha256:()=>De,sha512:()=>wc});function $r({name:r,code:t,encode:e}){return new Xr(r,t,e)}var Xr=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?Xt(this.code,e):e.then(n=>Xt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Ao(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var De=$r({name:"sha2-256",code:18,encode:Ao("SHA-256")}),wc=$r({name:"sha2-512",code:19,encode:Ao("SHA-512")});var Qr={...Wr,...jr,...Yr,...Vr,...Fr,...Or,...Mr,...Kr,...Zr,...Gr},jf={...Jr,...qr};function Bo(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var vo=Bo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),tn=Bo("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=dt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Ec={utf8:vo,"utf-8":vo,hex:Qr.base16,latin1:tn,ascii:tn,binary:tn,...Qr},rr=Ec;function J(r,t="utf8"){let e=rr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function xt(r,t="utf8"){let e=rr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var _c=parseInt("11111",2),en=parseInt("10000000",2),Sc=parseInt("01111111",2),Io={0:Pe,1:Pe,2:Ac,3:Ic,4:Cc,5:Bc,6:vc,16:Pe,22:Pe,48:Pe};function rn(r,t={offset:0}){let e=r[t.offset]&_c;if(t.offset++,Io[e]!=null)return Io[e](r,t);throw new Error("No decoder for tag "+e)}function Re(r,t){let e=0;if((r[t.offset]&en)===en){let n=r[t.offset]&Sc,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function Pe(r,t){Re(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=rn(r,t);if(n===null)break;e.push(n)}return e}function Ac(r,t){let e=Re(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function vc(r,t){let e=Re(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let a=`${s}.${i}`,c=[];for(;t.offset<n;){let d=r[t.offset];if(t.offset++,c.push(d&127),d<128){c.reverse();let f=0;for(let l=0;l<c.length;l++)f+=c[l]<<l*7;a+=`.${f}`,c=[]}}return a}function Bc(r,t){return t.offset++,null}function Ic(r,t){let e=Re(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Cc(r,t){let e=Re(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function Lc(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new pt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function nn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=Lc(r.byteLength);return new pt(Uint8Array.from([t.byteLength|en]),t)}function Co(r){let t=new pt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new pt(Uint8Array.from([2]),nn(t),t)}function Lo(r){let t=Uint8Array.from([0]),e=new pt(t,r);return new pt(Uint8Array.from([3]),nn(e),e)}function nr(r,t=48){let e=new pt;for(let n of r)e.append(n);return new pt(Uint8Array.from([t]),nn(e),e)}async function Uo(r,t,e,n){let o=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,t,e.subarray());return n?.signal?.throwIfAborted(),s}var Uc=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Tc=Uint8Array.from([6,5,43,129,4,0,34]),Dc=Uint8Array.from([6,5,43,129,4,0,35]),Pc={ext:!0,kty:"EC",crv:"P-256"},Rc={ext:!0,kty:"EC",crv:"P-384"},kc={ext:!0,kty:"EC",crv:"P-521"},on=32,sn=48,cn=66;function To(r){let t=rn(r);return Do(t)}function Do(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===on*2+1)return n=xt(t.subarray(e,e+on),"base64url"),o=xt(t.subarray(e+on),"base64url"),new me({...Pc,key_ops:["verify"],x:n,y:o});if(t.byteLength===sn*2+1)return n=xt(t.subarray(e,e+sn),"base64url"),o=xt(t.subarray(e+sn),"base64url"),new me({...Rc,key_ops:["verify"],x:n,y:o});if(t.byteLength===cn*2+1)return n=xt(t.subarray(e,e+cn),"base64url"),o=xt(t.subarray(e+cn),"base64url"),new me({...kc,key_ops:["verify"],x:n,y:o});throw new Lt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Po(r){return nr([Co(Uint8Array.from([1])),nr([Nc(r.crv)],160),nr([Lo(new pt(Uint8Array.from([4]),J(r.x??"","base64url"),J(r.y??"","base64url")))],161)]).subarray()}function Nc(r){if(r==="P-256")return Uc;if(r==="P-384")return Tc;if(r==="P-521")return Dc;throw new Lt(`Invalid curve ${r}`)}var me=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Po(this.jwk)),this._raw}toMultihash(){return wt.digest(ye(this))}toCID(){return ft.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:lt(this.raw,t.raw)}async verify(t,e,n){return Uo(this.jwk,e,t,n)}};var Jt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Kc(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function or(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Qt(r,...t){if(!Kc(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 Ro(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");or(r.outputLen),or(r.blockLen)}function xe(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 ko(r,t){Qt(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function Tt(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function sr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function _t(r,t){return r<<32-t|r>>>t}function No(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function ke(r){return typeof r=="string"&&(r=No(r)),Qt(r),r}function an(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Qt(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 be=class{};function fn(r){let t=n=>r().update(ke(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function ir(r=32){if(Jt&&typeof Jt.getRandomValues=="function")return Jt.getRandomValues(new Uint8Array(r));if(Jt&&typeof Jt.randomBytes=="function")return Uint8Array.from(Jt.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function Oc(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),a=Number(e&s),c=n?4:0,d=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+d,a,n)}function Ko(r,t,e){return r&t^~r&e}function Oo(r,t,e){return r&t^r&e^t&e}var Ne=class extends be{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=sr(this.buffer)}update(t){xe(this),t=ke(t),Qt(t);let{view:e,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=sr(t);for(;o<=s-i;i+=o)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){xe(this),ko(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,Tt(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)e[l]=0;Oc(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=sr(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=c/4,f=this.get();if(d>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<d;l++)a.setUint32(4*l,f[l],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:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=a,o%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Dt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var rt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var cr=BigInt(4294967295),Mo=BigInt(32);function Mc(r,t=!1){return t?{h:Number(r&cr),l:Number(r>>Mo&cr)}:{h:Number(r>>Mo&cr)|0,l:Number(r&cr)|0}}function Ho(r,t=!1){let e=r.length,n=new Uint32Array(e),o=new Uint32Array(e);for(let s=0;s<e;s++){let{h:i,l:a}=Mc(r[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var un=(r,t,e)=>r>>>e,hn=(r,t,e)=>r<<32-e|t>>>e,te=(r,t,e)=>r>>>e|t<<32-e,ee=(r,t,e)=>r<<32-e|t>>>e,Ke=(r,t,e)=>r<<64-e|t>>>e-32,Oe=(r,t,e)=>r>>>e-32|t<<64-e;function vt(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var zo=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),qo=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Vo=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Fo=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,jo=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Go=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var zc=Uint32Array.from([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]),Ht=new Uint32Array(64),ln=class extends Ne{constructor(t=32){super(64,t,8,!1),this.A=Dt[0]|0,this.B=Dt[1]|0,this.C=Dt[2]|0,this.D=Dt[3]|0,this.E=Dt[4]|0,this.F=Dt[5]|0,this.G=Dt[6]|0,this.H=Dt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,e,n,o,s,i,a,c]}set(t,e,n,o,s,i,a,c){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,e){for(let l=0;l<16;l++,e+=4)Ht[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let E=Ht[l-15],I=Ht[l-2],S=_t(E,7)^_t(E,18)^E>>>3,y=_t(I,17)^_t(I,19)^I>>>10;Ht[l]=y+Ht[l-7]+S+Ht[l-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:d,H:f}=this;for(let l=0;l<64;l++){let E=_t(a,6)^_t(a,11)^_t(a,25),I=f+E+Ko(a,c,d)+zc[l]+Ht[l]|0,y=(_t(n,2)^_t(n,13)^_t(n,22))+Oo(n,o,s)|0;f=d,d=c,c=a,a=i+I|0,i=s,s=o,o=n,n=I+y|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(n,o,s,i,a,c,d,f)}roundClean(){Tt(Ht)}destroy(){this.set(0,0,0,0,0,0,0,0),Tt(this.buffer)}};var Zo=Ho(["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))),qc=Zo[0],Vc=Zo[1],zt=new Uint32Array(80),qt=new Uint32Array(80),dn=class extends Ne{constructor(t=64){super(128,t,16,!1),this.Ah=rt[0]|0,this.Al=rt[1]|0,this.Bh=rt[2]|0,this.Bl=rt[3]|0,this.Ch=rt[4]|0,this.Cl=rt[5]|0,this.Dh=rt[6]|0,this.Dl=rt[7]|0,this.Eh=rt[8]|0,this.El=rt[9]|0,this.Fh=rt[10]|0,this.Fl=rt[11]|0,this.Gh=rt[12]|0,this.Gl=rt[13]|0,this.Hh=rt[14]|0,this.Hl=rt[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:d,El:f,Fh:l,Fl:E,Gh:I,Gl:S,Hh:y,Hl:P}=this;return[t,e,n,o,s,i,a,c,d,f,l,E,I,S,y,P]}set(t,e,n,o,s,i,a,c,d,f,l,E,I,S,y,P){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=d|0,this.El=f|0,this.Fh=l|0,this.Fl=E|0,this.Gh=I|0,this.Gl=S|0,this.Hh=y|0,this.Hl=P|0}process(t,e){for(let _=0;_<16;_++,e+=4)zt[_]=t.getUint32(e),qt[_]=t.getUint32(e+=4);for(let _=16;_<80;_++){let u=zt[_-15]|0,m=qt[_-15]|0,A=te(u,m,1)^te(u,m,8)^un(u,m,7),v=ee(u,m,1)^ee(u,m,8)^hn(u,m,7),B=zt[_-2]|0,D=qt[_-2]|0,K=te(B,D,19)^Ke(B,D,61)^un(B,D,6),L=ee(B,D,19)^Oe(B,D,61)^hn(B,D,6),k=Vo(v,L,qt[_-7],qt[_-16]),T=Fo(k,A,K,zt[_-7],zt[_-16]);zt[_]=T|0,qt[_]=k|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:d,Dl:f,Eh:l,El:E,Fh:I,Fl:S,Gh:y,Gl:P,Hh:R,Hl:z}=this;for(let _=0;_<80;_++){let u=te(l,E,14)^te(l,E,18)^Ke(l,E,41),m=ee(l,E,14)^ee(l,E,18)^Oe(l,E,41),A=l&I^~l&y,v=E&S^~E&P,B=jo(z,m,v,Vc[_],qt[_]),D=Go(B,R,u,A,qc[_],zt[_]),K=B|0,L=te(n,o,28)^Ke(n,o,34)^Ke(n,o,39),k=ee(n,o,28)^Oe(n,o,34)^Oe(n,o,39),T=n&s^n&a^s&a,W=o&i^o&c^i&c;R=y|0,z=P|0,y=I|0,P=S|0,I=l|0,S=E|0,{h:l,l:E}=vt(d|0,f|0,D|0,K|0),d=a|0,f=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let g=zo(K,k,W);n=qo(g,D,L,T),o=g|0}({h:n,l:o}=vt(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=vt(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=vt(this.Ch|0,this.Cl|0,a|0,c|0),{h:d,l:f}=vt(this.Dh|0,this.Dl|0,d|0,f|0),{h:l,l:E}=vt(this.Eh|0,this.El|0,l|0,E|0),{h:I,l:S}=vt(this.Fh|0,this.Fl|0,I|0,S|0),{h:y,l:P}=vt(this.Gh|0,this.Gl|0,y|0,P|0),{h:R,l:z}=vt(this.Hh|0,this.Hl|0,R|0,z|0),this.set(n,o,s,i,a,c,d,f,l,E,I,S,y,P,R,z)}roundClean(){Tt(zt,qt)}destroy(){Tt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Yo=fn(()=>new ln);var Wo=fn(()=>new dn);var bn=BigInt(0),yn=BigInt(1);function ge(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function xn(r){if(!ge(r))throw new Error("Uint8Array expected")}function Bt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function Me(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Jo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?bn:BigInt("0x"+r)}var Qo=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Fc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Vt(r){if(xn(r),Qo)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=Fc[r[e]];return t}var Pt={_0:48,_9:57,A:65,F:70,a:97,f:102};function Xo(r){if(r>=Pt._0&&r<=Pt._9)return r-Pt._0;if(r>=Pt.A&&r<=Pt.F)return r-(Pt.A-10);if(r>=Pt.a&&r<=Pt.f)return r-(Pt.a-10)}function He(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(Qo)return Uint8Array.fromHex(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 i=Xo(r.charCodeAt(s)),a=Xo(r.charCodeAt(s+1));if(i===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function Rt(r){return Jo(Vt(r))}function re(r){return xn(r),Jo(Vt(Uint8Array.from(r).reverse()))}function ne(r,t){return He(r.toString(16).padStart(t*2,"0"))}function we(r,t){return ne(r,t).reverse()}function F(r,t,e){let n;if(typeof t=="string")try{n=He(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(ge(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 Ft(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];xn(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 pn=r=>typeof r=="bigint"&&bn<=r;function ar(r,t,e){return pn(r)&&pn(t)&&pn(e)&&t<=r&&r<e}function mt(r,t,e,n){if(!ar(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function ts(r){let t;for(t=0;r>bn;r>>=yn,t+=1);return t}var oe=r=>(yn<<BigInt(r))-yn,mn=r=>new Uint8Array(r),$o=r=>Uint8Array.from(r);function es(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=mn(r),o=mn(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},a=(...l)=>e(o,n,...l),c=(l=mn(0))=>{o=a($o([0]),l),n=a(),l.length!==0&&(o=a($o([1]),l),n=a())},d=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,E=[];for(;l<t;){n=a();let I=n.slice();E.push(I),l+=n.length}return Ft(...E)};return(l,E)=>{i(),c(l);let I;for(;!(I=E(d()));)c();return i(),I}}var jc={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"||ge(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 kt(r,t,e={}){let n=(o,s,i)=>{let a=jc[s];if(typeof a!="function")throw new Error("invalid validator function");let c=r[o];if(!(i&&c===void 0)&&!a(c,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+c)};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}function Ee(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 st=BigInt(0),Q=BigInt(1),se=BigInt(2),Gc=BigInt(3),ns=BigInt(4),os=BigInt(5),ss=BigInt(8);function V(r,t){let e=r%t;return e>=st?e:t+e}function j(r,t,e){let n=r;for(;t-- >st;)n*=n,n%=e;return n}function fr(r,t){if(r===st)throw new Error("invert: expected non-zero number");if(t<=st)throw new Error("invert: expected positive modulus, got "+t);let e=V(r,t),n=t,o=st,s=Q,i=Q,a=st;for(;e!==st;){let d=n/e,f=n%e,l=o-i*d,E=s-a*d;n=e,e=f,o=i,s=a,i=l,a=E}if(n!==Q)throw new Error("invert: does not exist");return V(o,t)}function is(r,t){let e=(r.ORDER+Q)/ns,n=r.pow(t,e);if(!r.eql(r.sqr(n),t))throw new Error("Cannot find square root");return n}function Zc(r,t){let e=(r.ORDER-os)/ss,n=r.mul(t,se),o=r.pow(n,e),s=r.mul(t,o),i=r.mul(r.mul(s,se),o),a=r.mul(s,r.sub(i,r.ONE));if(!r.eql(r.sqr(a),t))throw new Error("Cannot find square root");return a}function Yc(r){if(r<BigInt(3))throw new Error("sqrt is not defined for small field");let t=r-Q,e=0;for(;t%se===st;)t/=se,e++;let n=se,o=Nt(r);for(;rs(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return is;let s=o.pow(n,t),i=(t+Q)/se;return function(c,d){if(c.is0(d))return d;if(rs(c,d)!==1)throw new Error("Cannot find square root");let f=e,l=c.mul(c.ONE,s),E=c.pow(d,t),I=c.pow(d,i);for(;!c.eql(E,c.ONE);){if(c.is0(E))return c.ZERO;let S=1,y=c.sqr(E);for(;!c.eql(y,c.ONE);)if(S++,y=c.sqr(y),S===f)throw new Error("Cannot find square root");let P=Q<<BigInt(f-S-1),R=c.pow(l,P);f=S,l=c.sqr(R),E=c.mul(E,l),I=c.mul(I,R)}return I}}function Wc(r){return r%ns===Gc?is:r%ss===os?Zc:Yc(r)}var cs=(r,t)=>(V(r,t)&Q)===Q,Xc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function gn(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Xc.reduce((n,o)=>(n[o]="function",n),t);return kt(r,e)}function $c(r,t,e){if(e<st)throw new Error("invalid exponent, negatives unsupported");if(e===st)return r.ONE;if(e===Q)return t;let n=r.ONE,o=t;for(;e>st;)e&Q&&(n=r.mul(n,o)),o=r.sqr(o),e>>=Q;return n}function _e(r,t,e=!1){let n=new Array(t.length).fill(e?r.ZERO:void 0),o=t.reduce((i,a,c)=>r.is0(a)?i:(n[c]=i,r.mul(i,a)),r.ONE),s=r.inv(o);return t.reduceRight((i,a,c)=>r.is0(a)?i:(n[c]=r.mul(i,n[c]),r.mul(i,a)),s),n}function rs(r,t){let e=(r.ORDER-Q)/se,n=r.pow(t,e),o=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),i=r.eql(n,r.neg(r.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function wn(r,t){t!==void 0&&or(t);let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Nt(r,t,e=!1,n={}){if(r<=st)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=wn(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,a=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:oe(o),ZERO:st,ONE:Q,create:c=>V(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return st<=c&&c<r},is0:c=>c===st,isOdd:c=>(c&Q)===Q,neg:c=>V(-c,r),eql:(c,d)=>c===d,sqr:c=>V(c*c,r),add:(c,d)=>V(c+d,r),sub:(c,d)=>V(c-d,r),mul:(c,d)=>V(c*d,r),pow:(c,d)=>$c(a,c,d),div:(c,d)=>V(c*fr(d,r),r),sqrN:c=>c*c,addN:(c,d)=>c+d,subN:(c,d)=>c-d,mulN:(c,d)=>c*d,inv:c=>fr(c,r),sqrt:n.sqrt||(c=>(i||(i=Wc(r)),i(a,c))),toBytes:c=>e?we(c,s):ne(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return e?re(c):Rt(c)},invertBatch:c=>_e(a,c),cmov:(c,d,f)=>f?d:c});return Object.freeze(a)}function as(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 En(r){let t=as(r);return t+Math.ceil(t/2)}function fs(r,t,e=!1){let n=r.length,o=as(t),s=En(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?re(r):Rt(r),a=V(i,t-Q)+Q;return e?we(a,o):ne(a,o)}var us=BigInt(0),Bn=BigInt(1);function _n(r,t){let e=t.negate();return r?e:t}function ls(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Sn(r,t){ls(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=oe(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function hs(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,a=Number(r&o),c=r>>i;a>n&&(a-=s,c+=Bn);let d=t*n,f=d+Math.abs(a)-1,l=a===0,E=a<0,I=t%2!==0;return{nextN:c,offset:f,isZero:l,isNeg:E,isNegF:I,offsetF:d}}function Jc(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 Qc(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 An=new WeakMap,ds=new WeakMap;function vn(r){return ds.get(r)||1}function ur(r,t){return{constTimeNegate:_n,hasPrecomputes(e){return vn(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>us;)n&Bn&&(o=o.add(s)),s=s.double(),n>>=Bn;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=Sn(n,t),i=[],a=e,c=a;for(let d=0;d<o;d++){c=a,i.push(c);for(let f=1;f<s;f++)c=c.add(a),i.push(c);a=c.double()}return i},wNAF(e,n,o){let s=r.ZERO,i=r.BASE,a=Sn(e,t);for(let c=0;c<a.windows;c++){let{nextN:d,offset:f,isZero:l,isNeg:E,isNegF:I,offsetF:S}=hs(o,c,a);o=d,l?i=i.add(_n(I,n[S])):s=s.add(_n(E,n[f]))}return{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=Sn(e,t);for(let a=0;a<i.windows&&o!==us;a++){let{nextN:c,offset:d,isZero:f,isNeg:l}=hs(o,a,i);if(o=c,!f){let E=n[d];s=s.add(l?E.negate():E)}}return s},getPrecomputes(e,n,o){let s=An.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&An.set(n,o(s))),s},wNAFCached(e,n,o){let s=vn(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=vn(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){ls(n,t),ds.set(e,n),An.delete(e)}}}function hr(r,t,e,n){Jc(e,r),Qc(n,t);let o=e.length,s=n.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");let i=r.ZERO,a=ts(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let d=oe(c),f=new Array(Number(d)+1).fill(i),l=Math.floor((t.BITS-1)/c)*c,E=i;for(let I=l;I>=0;I-=c){f.fill(i);for(let y=0;y<s;y++){let P=n[y],R=Number(P>>BigInt(I)&d);f[R]=f[R].add(e[y])}let S=i;for(let y=f.length-1,P=i;y>0;y--)P=P.add(f[y]),S=S.add(P);if(E=E.add(S),I!==0)for(let y=0;y<c;y++)E=E.double()}return E}function ze(r){return gn(r.Fp),kt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...wn(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var It=BigInt(0),it=BigInt(1),ps=BigInt(2),ta=BigInt(8),ea={zip215:!0};function ra(r){let t=ze(r);return kt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function ms(r){let t=ra(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:a,h:c}=t,d=ps<<BigInt(a*8)-it,f=e.create,l=Nt(t.n,t.nBitLength);function E(b,h){let p=e.sqr(b),w=e.sqr(h),U=e.add(e.mul(t.a,p),w),N=e.add(e.ONE,e.mul(t.d,e.mul(p,w)));return e.eql(U,N)}if(!E(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let I=t.uvRatio||((b,h)=>{try{return{isValid:!0,value:e.sqrt(b*e.inv(h))}}catch{return{isValid:!1,value:It}}}),S=t.adjustScalarBytes||(b=>b),y=t.domain||((b,h,p)=>{if(Bt("phflag",p),h.length||p)throw new Error("Contexts/pre-hash are not supported");return b});function P(b,h,p=!1){let w=p?it:It;mt("coordinate "+b,h,w,d)}function R(b){if(!(b instanceof u))throw new Error("ExtendedPoint expected")}let z=Ee((b,h)=>{let{ex:p,ey:w,ez:U}=b,N=b.is0();h==null&&(h=N?ta:e.inv(U));let O=f(p*h),M=f(w*h),H=f(U*h);if(N)return{x:It,y:it};if(H!==it)throw new Error("invZ was invalid");return{x:O,y:M}}),_=Ee(b=>{let{a:h,d:p}=t;if(b.is0())throw new Error("bad point: ZERO");let{ex:w,ey:U,ez:N,et:O}=b,M=f(w*w),H=f(U*U),q=f(N*N),X=f(q*q),Z=f(M*h),et=f(q*f(Z+H)),at=f(X+f(p*f(M*H)));if(et!==at)throw new Error("bad point: equation left != right (1)");let $=f(w*U),nt=f(N*O);if($!==nt)throw new Error("bad point: equation left != right (2)");return!0});class u{constructor(h,p,w,U){P("x",h),P("y",p),P("z",w,!0),P("t",U),this.ex=h,this.ey=p,this.ez=w,this.et=U,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(h){if(h instanceof u)throw new Error("extended point not allowed");let{x:p,y:w}=h||{};return P("x",p),P("y",w),new u(p,w,it,f(p*w))}static normalizeZ(h){let p=_e(e,h.map(w=>w.ez));return h.map((w,U)=>w.toAffine(p[U])).map(u.fromAffine)}static msm(h,p){return hr(u,l,h,p)}_setWindowSize(h){v.setWindowSize(this,h)}assertValidity(){_(this)}equals(h){R(h);let{ex:p,ey:w,ez:U}=this,{ex:N,ey:O,ez:M}=h,H=f(p*M),q=f(N*U),X=f(w*M),Z=f(O*U);return H===q&&X===Z}is0(){return this.equals(u.ZERO)}negate(){return new u(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:h}=t,{ex:p,ey:w,ez:U}=this,N=f(p*p),O=f(w*w),M=f(ps*f(U*U)),H=f(h*N),q=p+w,X=f(f(q*q)-N-O),Z=H+O,et=Z-M,at=H-O,$=f(X*et),nt=f(Z*at),ut=f(X*at),gt=f(et*Z);return new u($,nt,gt,ut)}add(h){R(h);let{a:p,d:w}=t,{ex:U,ey:N,ez:O,et:M}=this,{ex:H,ey:q,ez:X,et:Z}=h,et=f(U*H),at=f(N*q),$=f(M*w*Z),nt=f(O*X),ut=f((U+N)*(H+q)-et-at),gt=nt-$,ve=nt+$,no=f(at-p*et),ci=f(ut*gt),ai=f(ve*no),fi=f(ut*no),ui=f(gt*ve);return new u(ci,ai,ui,fi)}subtract(h){return this.add(h.negate())}wNAF(h){return v.wNAFCached(this,h,u.normalizeZ)}multiply(h){let p=h;mt("scalar",p,it,n);let{p:w,f:U}=this.wNAF(p);return u.normalizeZ([w,U])[0]}multiplyUnsafe(h,p=u.ZERO){let w=h;return mt("scalar",w,It,n),w===It?A:this.is0()||w===it?this:v.wNAFCachedUnsafe(this,w,u.normalizeZ,p)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return v.unsafeLadder(this,n).is0()}toAffine(h){return z(this,h)}clearCofactor(){let{h}=t;return h===it?this:this.multiplyUnsafe(h)}static fromHex(h,p=!1){let{d:w,a:U}=t,N=e.BYTES;h=F("pointHex",h,N),Bt("zip215",p);let O=h.slice(),M=h[N-1];O[N-1]=M&-129;let H=re(O),q=p?d:e.ORDER;mt("pointHex.y",H,It,q);let X=f(H*H),Z=f(X-it),et=f(w*X-U),{isValid:at,value:$}=I(Z,et);if(!at)throw new Error("Point.fromHex: invalid y coordinate");let nt=($&it)===it,ut=(M&128)!==0;if(!p&&$===It&&ut)throw new Error("Point.fromHex: x=0 and x_0=1");return ut!==nt&&($=f(-$)),u.fromAffine({x:$,y:H})}static fromPrivateKey(h){let{scalar:p}=K(h);return m.multiply(p)}toRawBytes(){let{x:h,y:p}=this.toAffine(),w=we(p,e.BYTES);return w[w.length-1]|=h&it?128:0,w}toHex(){return Vt(this.toRawBytes())}}u.BASE=new u(t.Gx,t.Gy,it,f(t.Gx*t.Gy)),u.ZERO=new u(It,it,it,It);let{BASE:m,ZERO:A}=u,v=ur(u,a*8);function B(b){return V(b,n)}function D(b){return B(re(b))}function K(b){let h=e.BYTES;b=F("private key",b,h);let p=F("hashed private key",s(b),2*h),w=S(p.slice(0,h)),U=p.slice(h,2*h),N=D(w);return{head:w,prefix:U,scalar:N}}function L(b){let{head:h,prefix:p,scalar:w}=K(b),U=m.multiply(w),N=U.toRawBytes();return{head:h,prefix:p,scalar:w,point:U,pointBytes:N}}function k(b){return L(b).pointBytes}function T(b=Uint8Array.of(),...h){let p=Ft(...h);return D(s(y(p,F("context",b),!!o)))}function W(b,h,p={}){b=F("message",b),o&&(b=o(b));let{prefix:w,scalar:U,pointBytes:N}=L(h),O=T(p.context,w,b),M=m.multiply(O).toRawBytes(),H=T(p.context,M,N,b),q=B(O+H*U);mt("signature.s",q,It,n);let X=Ft(M,we(q,e.BYTES));return F("result",X,e.BYTES*2)}let g=ea;function x(b,h,p,w=g){let{context:U,zip215:N}=w,O=e.BYTES;b=F("signature",b,2*O),h=F("message",h),p=F("publicKey",p,O),N!==void 0&&Bt("zip215",N),o&&(h=o(h));let M=re(b.slice(O,2*O)),H,q,X;try{H=u.fromHex(p,N),q=u.fromHex(b.slice(0,O),N),X=m.multiplyUnsafe(M)}catch{return!1}if(!N&&H.isSmallOrder())return!1;let Z=T(U,q.toRawBytes(),H.toRawBytes(),h);return q.add(H.multiplyUnsafe(Z)).subtract(X).clearCofactor().equals(u.ZERO)}return m._setWindowSize(8),{CURVE:t,getPublicKey:k,sign:W,verify:x,ExtendedPoint:u,utils:{getExtendedPublicKey:L,randomPrivateKey:()=>i(e.BYTES),precompute(b=8,h=u.BASE){return h._setWindowSize(b),h.multiply(BigInt(3)),h}}}}var In=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ys=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Yu=BigInt(0),na=BigInt(1),bs=BigInt(2),Wu=BigInt(3),oa=BigInt(5),sa=BigInt(8);function ia(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=In,a=r*r%s*r%s,c=j(a,bs,s)*a%s,d=j(c,na,s)*r%s,f=j(d,oa,s)*d%s,l=j(f,t,s)*f%s,E=j(l,e,s)*l%s,I=j(E,n,s)*E%s,S=j(I,o,s)*I%s,y=j(S,o,s)*I%s,P=j(y,t,s)*f%s;return{pow_p_5_8:j(P,bs,s)*r%s,b2:a}}function ca(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function aa(r,t){let e=In,n=V(t*t*t,e),o=V(n*n*t,e),s=ia(r*o).pow_p_5_8,i=V(r*n*s,e),a=V(t*i*i,e),c=i,d=V(i*ys,e),f=a===r,l=a===V(-r,e),E=a===V(-r*ys,e);return f&&(i=c),(l||E)&&(i=d),cs(i,e)&&(i=V(-i,e)),{isValid:f||l,value:i}}var xs=Nt(In,void 0,!0),fa={a:xs.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:xs,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:sa,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Wo,randomBytes:ir,adjustScalarBytes:ca,uvRatio:aa},gs=ms(fa);var qe=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},lr=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var ws={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new lr("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var dr=ws;var pr=32;var Cn,ua=(async()=>{try{return await dr.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function ha(r,t,e){if(r.buffer instanceof ArrayBuffer){let n=await dr.get().subtle.importKey("raw",r.buffer,{name:"Ed25519"},!1,["verify"]);return await dr.get().subtle.verify({name:"Ed25519"},n,t,e instanceof Uint8Array?e:e.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function la(r,t,e){return gs.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}async function Es(r,t,e){return Cn==null&&(Cn=await ua),Cn?ha(r,t,e):la(r,t,e)}function mr(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var yr=class{type="Ed25519";raw;constructor(t){this.raw=Ln(t,pr)}toMultihash(){return wt.digest(ye(this))}toCID(){return ft.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:lt(this.raw,t.raw)}verify(t,e,n){n?.signal?.throwIfAborted();let o=Es(this.raw,e,t);return mr(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function Ss(r){return r=Ln(r,pr),new yr(r)}function Ln(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new Lt(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var pa=Math.pow(2,7),ma=Math.pow(2,14),ya=Math.pow(2,21),As=Math.pow(2,28),vs=Math.pow(2,35),Bs=Math.pow(2,42),Is=Math.pow(2,49),ct=128,jt=127;function Ve(r){if(r<pa)return 1;if(r<ma)return 2;if(r<ya)return 3;if(r<As)return 4;if(r<vs)return 5;if(r<Bs)return 6;if(r<Is)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Cs(r,t,e=0){switch(Ve(r)){case 8:t[e++]=r&255|ct,r/=128;case 7:t[e++]=r&255|ct,r/=128;case 6:t[e++]=r&255|ct,r/=128;case 5:t[e++]=r&255|ct,r/=128;case 4:t[e++]=r&255|ct,r>>>=7;case 3:t[e++]=r&255|ct,r>>>=7;case 2:t[e++]=r&255|ct,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Ls(r,t){let e=r[t],n=0;if(n+=e&jt,e<ct||(e=r[t+1],n+=(e&jt)<<7,e<ct)||(e=r[t+2],n+=(e&jt)<<14,e<ct)||(e=r[t+3],n+=(e&jt)<<21,e<ct)||(e=r[t+4],n+=(e&jt)*As,e<ct)||(e=r[t+5],n+=(e&jt)*vs,e<ct)||(e=r[t+6],n+=(e&jt)*Bs,e<ct)||(e=r[t+7],n+=(e&jt)*Is,e<ct))return n;throw new RangeError("Could not decode varint")}var Un=new Float32Array([-0]),Gt=new Uint8Array(Un.buffer);function Us(r,t,e){Un[0]=r,t[e]=Gt[0],t[e+1]=Gt[1],t[e+2]=Gt[2],t[e+3]=Gt[3]}function Ts(r,t){return Gt[0]=r[t],Gt[1]=r[t+1],Gt[2]=r[t+2],Gt[3]=r[t+3],Un[0]}var Tn=new Float64Array([-0]),ot=new Uint8Array(Tn.buffer);function Ds(r,t,e){Tn[0]=r,t[e]=ot[0],t[e+1]=ot[1],t[e+2]=ot[2],t[e+3]=ot[3],t[e+4]=ot[4],t[e+5]=ot[5],t[e+6]=ot[6],t[e+7]=ot[7]}function Ps(r,t){return ot[0]=r[t],ot[1]=r[t+1],ot[2]=r[t+2],ot[3]=r[t+3],ot[4]=r[t+4],ot[5]=r[t+5],ot[6]=r[t+6],ot[7]=r[t+7],Tn[0]}var ba=BigInt(Number.MAX_SAFE_INTEGER),xa=BigInt(Number.MIN_SAFE_INTEGER),yt=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 ie;if(t<ba&&t>xa)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>Rs&&(o=0n,++n>Rs&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ie;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):ie}},ie=new yt(0,0);ie.toBigInt=function(){return 0n};ie.zzEncode=ie.zzDecode=function(){return this};ie.length=function(){return 1};var Rs=4294967296n;function ks(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 Ns(r,t,e){if(e-t<1)return"";let o,s=[],i=0,a;for(;t<e;)a=r[t++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(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[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function Dn(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,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 St(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function br(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Pn=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,St(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 St(this,4);return br(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw St(this,4);return br(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw St(this,4);let t=Ts(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw St(this,4);let t=Ps(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 St(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Ns(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw St(this,t);this.pos+=t}else do if(this.pos>=this.len)throw St(this);while((this.buf[this.pos++]&128)!==0);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 yt(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 St(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 St(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 St(this,8);let t=br(this.buf,this.pos+=4),e=br(this.buf,this.pos+=4);return new yt(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=Ls(this.buf,this.pos);return this.pos+=Ve(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 Rn(r){return new Pn(r instanceof Uint8Array?r:r.subarray())}function xr(r,t,e){let n=Rn(r);return t.decode(n,void 0,e)}function kn(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return dt(i);o+i>t&&(n=dt(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var ce=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Nn(){}var On=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},ga=kn();function wa(r){return globalThis.Buffer!=null?dt(r):ga(r)}var je=class{len;head;tail;states;constructor(){this.len=0,this.head=new ce(Nn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ce(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Mn((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(gr,10,yt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=yt.fromBigInt(t);return this._push(gr,e.length(),e)}uint64Number(t){return this._push(Cs,Ve(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=yt.fromBigInt(t).zzEncode();return this._push(gr,e.length(),e)}sint64Number(t){let e=yt.fromNumber(t).zzEncode();return this._push(gr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Kn,1,t?1:0)}fixed32(t){return this._push(Fe,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=yt.fromBigInt(t);return this._push(Fe,4,e.lo)._push(Fe,4,e.hi)}fixed64Number(t){let e=yt.fromNumber(t);return this._push(Fe,4,e.lo)._push(Fe,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(Us,4,t)}double(t){return this._push(Ds,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Kn,1,0):this.uint32(e)._push(_a,e,t)}string(t){let e=ks(t);return e!==0?this.uint32(e)._push(Dn,e,t):this._push(Kn,1,0)}fork(){return this.states=new On(this),this.head=this.tail=new ce(Nn,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 ce(Nn,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=wa(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Kn(r,t,e){t[e]=r&255}function Ea(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Mn=class extends ce{next;constructor(t,e){super(Ea,t,e),this.next=void 0}};function gr(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 Fe(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 _a(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(je.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Sa,t,r),this},je.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Aa,t,r),this});function Sa(r,t,e){t.set(r,e)}function Aa(r,t,e){r.length<40?Dn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(J(r),e)}function Hn(){return new je}function wr(r,t){let e=Hn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Se;(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"})(Se||(Se={}));function Er(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function zn(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let a=t(s);i.int32(a)},n=function(s){let i=s.int32();return t(i)};return Er("enum",Se.VARINT,e,n)}function _r(r,t){return Er("message",Se.LENGTH_DELIMITED,r,t)}var bt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(bt||(bt={}));var qn;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(qn||(qn={}));(function(r){r.codec=()=>zn(qn)})(bt||(bt={}));var Ge;(function(r){let t;r.codec=()=>(t==null&&(t=_r((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),bt.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={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=bt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>wr(e,r.codec()),r.decode=(e,n)=>xr(e,r.codec(),n)})(Ge||(Ge={}));var Vn;(function(r){let t;r.codec=()=>(t==null&&(t=_r((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),bt.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={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=bt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>wr(e,r.codec()),r.decode=(e,n)=>xr(e,r.codec(),n)})(Vn||(Vn={}));var Sr=class extends be{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Ro(t);let n=ke(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 i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),Tt(s)}update(t){return xe(this),this.iHash.update(t),this}digestInto(t){xe(this),Qt(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:i,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Fn=(r,t,e)=>new Sr(r,t).update(e).digest();Fn.create=(r,t)=>new Sr(r,t);function Os(r){r.lowS!==void 0&&Bt("lowS",r.lowS),r.prehash!==void 0&&Bt("prehash",r.prehash)}function Ba(r){let t=ze(r);kt(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}var Zn=class extends Error{constructor(t=""){super(t)}},Kt={Err:Zn,_tlv:{encode:(r,t)=>{let{Err:e}=Kt;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=Me(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Me(o.length/2|128):"";return Me(r)+s+o+t},decode(r,t){let{Err:e}=Kt,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),i=0;if(!s)i=o;else{let c=o&127;if(!c)throw new e("tlv.decode(long): indefinite length not supported");if(c>4)throw new e("tlv.decode(long): byte length is too big");let d=t.subarray(n,n+c);if(d.length!==c)throw new e("tlv.decode: length bytes not complete");if(d[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let f of d)i=i<<8|f;if(n+=c,i<128)throw new e("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+i);if(a.length!==i)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Kt;if(r<Ot)throw new t("integer: negative integers are not allowed");let e=Me(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}=Kt;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 Rt(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Kt,o=F("signature",r),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,s),{v:d,l:f}=n.decode(2,c);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(d)}},hexFromSig(r){let{_tlv:t,_int:e}=Kt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}};function jn(r,t){return Vt(ne(r,t))}var Ot=BigInt(0),tt=BigInt(1),al=BigInt(2),Gn=BigInt(3),Ia=BigInt(4);function Ca(r){let t=Ba(r),{Fp:e}=t,n=Nt(t.n,t.nBitLength),o=t.toBytes||((_,u,m)=>{let A=u.toAffine();return Ft(Uint8Array.from([4]),e.toBytes(A.x),e.toBytes(A.y))}),s=t.fromBytes||(_=>{let u=_.subarray(1),m=e.fromBytes(u.subarray(0,e.BYTES)),A=e.fromBytes(u.subarray(e.BYTES,2*e.BYTES));return{x:m,y:A}});function i(_){let{a:u,b:m}=t,A=e.sqr(_),v=e.mul(A,_);return e.add(e.add(v,e.mul(_,u)),m)}function a(_,u){let m=e.sqr(u),A=i(_);return e.eql(m,A)}if(!a(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let c=e.mul(e.pow(t.a,Gn),Ia),d=e.mul(e.sqr(t.b),BigInt(27));if(e.is0(e.add(c,d)))throw new Error("bad curve params: a or b");function f(_){return ar(_,tt,t.n)}function l(_){let{allowedPrivateKeyLengths:u,nByteLength:m,wrapPrivateKey:A,n:v}=t;if(u&&typeof _!="bigint"){if(ge(_)&&(_=Vt(_)),typeof _!="string"||!u.includes(_.length))throw new Error("invalid private key");_=_.padStart(m*2,"0")}let B;try{B=typeof _=="bigint"?_:Rt(F("private key",_,m))}catch{throw new Error("invalid private key, expected hex or "+m+" bytes, got "+typeof _)}return A&&(B=V(B,v)),mt("private key",B,tt,v),B}function E(_){if(!(_ instanceof y))throw new Error("ProjectivePoint expected")}let I=Ee((_,u)=>{let{px:m,py:A,pz:v}=_;if(e.eql(v,e.ONE))return{x:m,y:A};let B=_.is0();u==null&&(u=B?e.ONE:e.inv(v));let D=e.mul(m,u),K=e.mul(A,u),L=e.mul(v,u);if(B)return{x:e.ZERO,y:e.ZERO};if(!e.eql(L,e.ONE))throw new Error("invZ was invalid");return{x:D,y:K}}),S=Ee(_=>{if(_.is0()){if(t.allowInfinityPoint&&!e.is0(_.py))return;throw new Error("bad point: ZERO")}let{x:u,y:m}=_.toAffine();if(!e.isValid(u)||!e.isValid(m))throw new Error("bad point: x or y not FE");if(!a(u,m))throw new Error("bad point: equation left != right");if(!_.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class y{constructor(u,m,A){if(u==null||!e.isValid(u))throw new Error("x required");if(m==null||!e.isValid(m)||e.is0(m))throw new Error("y required");if(A==null||!e.isValid(A))throw new Error("z required");this.px=u,this.py=m,this.pz=A,Object.freeze(this)}static fromAffine(u){let{x:m,y:A}=u||{};if(!u||!e.isValid(m)||!e.isValid(A))throw new Error("invalid affine point");if(u instanceof y)throw new Error("projective point not allowed");let v=B=>e.eql(B,e.ZERO);return v(m)&&v(A)?y.ZERO:new y(m,A,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(u){let m=_e(e,u.map(A=>A.pz));return u.map((A,v)=>A.toAffine(m[v])).map(y.fromAffine)}static fromHex(u){let m=y.fromAffine(s(F("pointHex",u)));return m.assertValidity(),m}static fromPrivateKey(u){return y.BASE.multiply(l(u))}static msm(u,m){return hr(y,n,u,m)}_setWindowSize(u){z.setWindowSize(this,u)}assertValidity(){S(this)}hasEvenY(){let{y:u}=this.toAffine();if(e.isOdd)return!e.isOdd(u);throw new Error("Field doesn't support isOdd")}equals(u){E(u);let{px:m,py:A,pz:v}=this,{px:B,py:D,pz:K}=u,L=e.eql(e.mul(m,K),e.mul(B,v)),k=e.eql(e.mul(A,K),e.mul(D,v));return L&&k}negate(){return new y(this.px,e.neg(this.py),this.pz)}double(){let{a:u,b:m}=t,A=e.mul(m,Gn),{px:v,py:B,pz:D}=this,K=e.ZERO,L=e.ZERO,k=e.ZERO,T=e.mul(v,v),W=e.mul(B,B),g=e.mul(D,D),x=e.mul(v,B);return x=e.add(x,x),k=e.mul(v,D),k=e.add(k,k),K=e.mul(u,k),L=e.mul(A,g),L=e.add(K,L),K=e.sub(W,L),L=e.add(W,L),L=e.mul(K,L),K=e.mul(x,K),k=e.mul(A,k),g=e.mul(u,g),x=e.sub(T,g),x=e.mul(u,x),x=e.add(x,k),k=e.add(T,T),T=e.add(k,T),T=e.add(T,g),T=e.mul(T,x),L=e.add(L,T),g=e.mul(B,D),g=e.add(g,g),T=e.mul(g,x),K=e.sub(K,T),k=e.mul(g,W),k=e.add(k,k),k=e.add(k,k),new y(K,L,k)}add(u){E(u);let{px:m,py:A,pz:v}=this,{px:B,py:D,pz:K}=u,L=e.ZERO,k=e.ZERO,T=e.ZERO,W=t.a,g=e.mul(t.b,Gn),x=e.mul(m,B),C=e.mul(A,D),b=e.mul(v,K),h=e.add(m,A),p=e.add(B,D);h=e.mul(h,p),p=e.add(x,C),h=e.sub(h,p),p=e.add(m,v);let w=e.add(B,K);return p=e.mul(p,w),w=e.add(x,b),p=e.sub(p,w),w=e.add(A,v),L=e.add(D,K),w=e.mul(w,L),L=e.add(C,b),w=e.sub(w,L),T=e.mul(W,p),L=e.mul(g,b),T=e.add(L,T),L=e.sub(C,T),T=e.add(C,T),k=e.mul(L,T),C=e.add(x,x),C=e.add(C,x),b=e.mul(W,b),p=e.mul(g,p),C=e.add(C,b),b=e.sub(x,b),b=e.mul(W,b),p=e.add(p,b),x=e.mul(C,p),k=e.add(k,x),x=e.mul(w,p),L=e.mul(h,L),L=e.sub(L,x),x=e.mul(h,C),T=e.mul(w,T),T=e.add(T,x),new y(L,k,T)}subtract(u){return this.add(u.negate())}is0(){return this.equals(y.ZERO)}wNAF(u){return z.wNAFCached(this,u,y.normalizeZ)}multiplyUnsafe(u){let{endo:m,n:A}=t;mt("scalar",u,Ot,A);let v=y.ZERO;if(u===Ot)return v;if(this.is0()||u===tt)return this;if(!m||z.hasPrecomputes(this))return z.wNAFCachedUnsafe(this,u,y.normalizeZ);let{k1neg:B,k1:D,k2neg:K,k2:L}=m.splitScalar(u),k=v,T=v,W=this;for(;D>Ot||L>Ot;)D&tt&&(k=k.add(W)),L&tt&&(T=T.add(W)),W=W.double(),D>>=tt,L>>=tt;return B&&(k=k.negate()),K&&(T=T.negate()),T=new y(e.mul(T.px,m.beta),T.py,T.pz),k.add(T)}multiply(u){let{endo:m,n:A}=t;mt("scalar",u,tt,A);let v,B;if(m){let{k1neg:D,k1:K,k2neg:L,k2:k}=m.splitScalar(u),{p:T,f:W}=this.wNAF(K),{p:g,f:x}=this.wNAF(k);T=z.constTimeNegate(D,T),g=z.constTimeNegate(L,g),g=new y(e.mul(g.px,m.beta),g.py,g.pz),v=T.add(g),B=W.add(x)}else{let{p:D,f:K}=this.wNAF(u);v=D,B=K}return y.normalizeZ([v,B])[0]}multiplyAndAddUnsafe(u,m,A){let v=y.BASE,B=(K,L)=>L===Ot||L===tt||!K.equals(v)?K.multiplyUnsafe(L):K.multiply(L),D=B(this,m).add(B(u,A));return D.is0()?void 0:D}toAffine(u){return I(this,u)}isTorsionFree(){let{h:u,isTorsionFree:m}=t;if(u===tt)return!0;if(m)return m(y,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:u,clearCofactor:m}=t;return u===tt?this:m?m(y,this):this.multiplyUnsafe(t.h)}toRawBytes(u=!0){return Bt("isCompressed",u),this.assertValidity(),o(y,this,u)}toHex(u=!0){return Bt("isCompressed",u),Vt(this.toRawBytes(u))}}y.BASE=new y(t.Gx,t.Gy,e.ONE),y.ZERO=new y(e.ZERO,e.ONE,e.ZERO);let{endo:P,nBitLength:R}=t,z=ur(y,P?Math.ceil(R/2):R);return{CURVE:t,ProjectivePoint:y,normPrivateKeyToScalar:l,weierstrassEquation:i,isWithinCurveOrder:f}}function La(r){let t=ze(r);return kt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Ms(r){let t=La(r),{Fp:e,n,nByteLength:o,nBitLength:s}=t,i=e.BYTES+1,a=2*e.BYTES+1;function c(g){return V(g,n)}function d(g){return fr(g,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:l,weierstrassEquation:E,isWithinCurveOrder:I}=Ca({...t,toBytes(g,x,C){let b=x.toAffine(),h=e.toBytes(b.x),p=Ft;return Bt("isCompressed",C),C?p(Uint8Array.from([x.hasEvenY()?2:3]),h):p(Uint8Array.from([4]),h,e.toBytes(b.y))},fromBytes(g){let x=g.length,C=g[0],b=g.subarray(1);if(x===i&&(C===2||C===3)){let h=Rt(b);if(!ar(h,tt,e.ORDER))throw new Error("Point is not on curve");let p=E(h),w;try{w=e.sqrt(p)}catch(O){let M=O instanceof Error?": "+O.message:"";throw new Error("Point is not on curve"+M)}let U=(w&tt)===tt;return(C&1)===1!==U&&(w=e.neg(w)),{x:h,y:w}}else if(x===a&&C===4){let h=e.fromBytes(b.subarray(0,e.BYTES)),p=e.fromBytes(b.subarray(e.BYTES,2*e.BYTES));return{x:h,y:p}}else{let h=i,p=a;throw new Error("invalid Point, expected length of "+h+", or uncompressed "+p+", got "+x)}}});function S(g){let x=n>>tt;return g>x}function y(g){return S(g)?c(-g):g}let P=(g,x,C)=>Rt(g.slice(x,C));class R{constructor(x,C,b){mt("r",x,tt,n),mt("s",C,tt,n),this.r=x,this.s=C,b!=null&&(this.recovery=b),Object.freeze(this)}static fromCompact(x){let C=o;return x=F("compactSignature",x,C*2),new R(P(x,0,C),P(x,C,2*C))}static fromDER(x){let{r:C,s:b}=Kt.toSig(F("DER",x));return new R(C,b)}assertValidity(){}addRecoveryBit(x){return new R(this.r,this.s,x)}recoverPublicKey(x){let{r:C,s:b,recovery:h}=this,p=v(F("msgHash",x));if(h==null||![0,1,2,3].includes(h))throw new Error("recovery id invalid");let w=h===2||h===3?C+t.n:C;if(w>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let U=(h&1)===0?"02":"03",N=f.fromHex(U+jn(w,e.BYTES)),O=d(w),M=c(-p*O),H=c(b*O),q=f.BASE.multiplyAndAddUnsafe(N,M,H);if(!q)throw new Error("point at infinify");return q.assertValidity(),q}hasHighS(){return S(this.s)}normalizeS(){return this.hasHighS()?new R(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return He(this.toDERHex())}toDERHex(){return Kt.hexFromSig(this)}toCompactRawBytes(){return He(this.toCompactHex())}toCompactHex(){let x=o;return jn(this.r,x)+jn(this.s,x)}}let z={isValidPrivateKey(g){try{return l(g),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let g=En(t.n);return fs(t.randomBytes(g),t.n)},precompute(g=8,x=f.BASE){return x._setWindowSize(g),x.multiply(BigInt(3)),x}};function _(g,x=!0){return f.fromPrivateKey(g).toRawBytes(x)}function u(g){if(typeof g=="bigint")return!1;if(g instanceof f)return!0;let C=F("key",g).length,b=e.BYTES,h=b+1,p=2*b+1;if(!(t.allowedPrivateKeyLengths||o===h))return C===h||C===p}function m(g,x,C=!0){if(u(g)===!0)throw new Error("first arg must be private key");if(u(x)===!1)throw new Error("second arg must be public key");return f.fromHex(x).multiply(l(g)).toRawBytes(C)}let A=t.bits2int||function(g){if(g.length>8192)throw new Error("input is too large");let x=Rt(g),C=g.length*8-s;return C>0?x>>BigInt(C):x},v=t.bits2int_modN||function(g){return c(A(g))},B=oe(s);function D(g){return mt("num < 2^"+s,g,Ot,B),ne(g,o)}function K(g,x,C=L){if(["recovered","canonical"].some(Z=>Z in C))throw new Error("sign() legacy options not supported");let{hash:b,randomBytes:h}=t,{lowS:p,prehash:w,extraEntropy:U}=C;p==null&&(p=!0),g=F("msgHash",g),Os(C),w&&(g=F("prehashed msgHash",b(g)));let N=v(g),O=l(x),M=[D(O),D(N)];if(U!=null&&U!==!1){let Z=U===!0?h(e.BYTES):U;M.push(F("extraEntropy",Z))}let H=Ft(...M),q=N;function X(Z){let et=A(Z);if(!I(et))return;let at=d(et),$=f.BASE.multiply(et).toAffine(),nt=c($.x);if(nt===Ot)return;let ut=c(at*c(q+nt*O));if(ut===Ot)return;let gt=($.x===nt?0:2)|Number($.y&tt),ve=ut;return p&&S(ut)&&(ve=y(ut),gt^=1),new R(nt,ve,gt)}return{seed:H,k2sig:X}}let L={lowS:t.lowS,prehash:!1},k={lowS:t.lowS,prehash:!1};function T(g,x,C=L){let{seed:b,k2sig:h}=K(g,x,C),p=t;return es(p.hash.outputLen,p.nByteLength,p.hmac)(b,h)}f.BASE._setWindowSize(8);function W(g,x,C,b=k){let h=g;x=F("msgHash",x),C=F("publicKey",C);let{lowS:p,prehash:w,format:U}=b;if(Os(b),"strict"in b)throw new Error("options.strict was renamed to lowS");if(U!==void 0&&U!=="compact"&&U!=="der")throw new Error("format must be compact or der");let N=typeof h=="string"||ge(h),O=!N&&!U&&typeof h=="object"&&h!==null&&typeof h.r=="bigint"&&typeof h.s=="bigint";if(!N&&!O)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let M,H;try{if(O&&(M=new R(h.r,h.s)),N){try{U!=="compact"&&(M=R.fromDER(h))}catch(gt){if(!(gt instanceof Kt.Err))throw gt}!M&&U!=="der"&&(M=R.fromCompact(h))}H=f.fromHex(C)}catch{return!1}if(!M||p&&M.hasHighS())return!1;w&&(x=t.hash(x));let{r:q,s:X}=M,Z=v(x),et=d(X),at=c(Z*et),$=c(q*et),nt=f.BASE.multiplyAndAddUnsafe(H,at,$)?.toAffine();return nt?c(nt.x)===q:!1}return{CURVE:t,getPublicKey:_,getSharedSecret:m,sign:T,verify:W,ProjectivePoint:f,Signature:R,utils:z}}function Ua(r){return{hash:r,hmac:(t,...e)=>Fn(r,t,an(...e)),randomBytes:ir}}function Hs(r,t){let e=n=>Ms({...r,...Ua(n)});return{...e(t),create:e}}var Vs=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),zs=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ta=BigInt(0),Da=BigInt(1),Yn=BigInt(2),qs=(r,t)=>(r+t/Yn)/t;function Pa(r){let t=Vs,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),d=r*r*r%t,f=d*d*r%t,l=j(f,e,t)*f%t,E=j(l,e,t)*f%t,I=j(E,Yn,t)*d%t,S=j(I,o,t)*I%t,y=j(S,s,t)*S%t,P=j(y,a,t)*y%t,R=j(P,c,t)*P%t,z=j(R,a,t)*y%t,_=j(z,e,t)*f%t,u=j(_,i,t)*S%t,m=j(u,n,t)*d%t,A=j(m,Yn,t);if(!Wn.eql(Wn.sqr(A),r))throw new Error("Cannot find square root");return A}var Wn=Nt(Vs,void 0,void 0,{sqrt:Pa}),Ae=Hs({a:Ta,b:BigInt(7),Fp:Wn,n:zs,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=zs,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Da*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),a=qs(s*r,t),c=qs(-n*r,t),d=V(r-a*e-c*o,t),f=V(-a*n-c*s,t),l=d>i,E=f>i;if(l&&(d=t-d),E&&(f=t-f),d>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:d,k2neg:E,k2:f}}}},Yo);function Fs(r,t,e,n){let o=De.digest(e instanceof Uint8Array?e:e.subarray());if(mr(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),Ae.verify(t,s,r))).catch(s=>{throw s.name==="AbortError"?s:new qe(String(s))});try{return n?.signal?.throwIfAborted(),Ae.verify(t,o.digest,r)}catch(s){throw new qe(String(s))}}var Ar=class{type="secp256k1";raw;_key;constructor(t){this._key=Gs(t),this.raw=js(this._key)}toMultihash(){return wt.digest(ye(this))}toCID(){return ft.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:lt(this.raw,t.raw)}verify(t,e,n){return Fs(this._key,e,t,n)}};function Zs(r){return new Ar(r)}function js(r){return Ae.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Gs(r){try{return Ae.ProjectivePoint.fromHex(r),r}catch(t){throw new $e(String(t))}}function Ys(r){let{Type:t,Data:e}=Ge.decode(r.digest),n=e??new Uint8Array;switch(t){case bt.Ed25519:return Ss(n);case bt.secp256k1:return Zs(n);case bt.ECDSA:return To(n);default:throw new Be}}function ye(r){return Ge.encode({Type:bt[r.type],Data:r.raw})}var Ws=Symbol.for("nodejs.util.inspect.custom"),Ra=114,Ze=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()})`}[Dr]=!0;toString(){return this.string==null&&(this.string=Y.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ft.createV1(Ra,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return lt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return lt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Ws](){return`PeerId(${this.toString()})`}},vr=class extends Ze{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Br=class extends Ze{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Ir=class extends Ze{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},ka=2336,Cr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=wt.digest(J(this.url))}[Ws](){return`PeerId(${this.url})`}[Dr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ft.createV1(ka,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=xt(t)),t.toString()===this.toString())}};function Xs(r){if(Ka(r))return new vr({multihash:r});if(Na(r))try{let t=Ys(r);if(t.type==="Ed25519")return new Br({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Ir({multihash:r,publicKey:t})}catch{let e=xt(r.digest);return new Cr(new URL(e))}throw new Je("Supplied PeerID Multihash is invalid")}function Na(r){return r.code===wt.code}function Ka(r){return r.code===De.code}function Ct(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 Lr(r){let t=Ue(Y.decode(`z${r}`));return Xs(t)}var Zt=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 Ct(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 Ct(this.map.values(),t=>t.key)}values(){return Ct(this.map.values(),t=>t.value)}get size(){return this.map.size}};function $s(){return new Zt}var Yt=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 Ct(this.set.entries(),t=>{let e=Lr(t[0]);return[e,e]})}forEach(t){this.set.forEach(e=>{let n=Lr(e);t(n,n,this)})}has(t){return this.set.has(t.toString())}values(){return Ct(this.set.values(),t=>Lr(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 Js(){return new Yt}var Wt=class r{list;constructor(t){if(this.list=[],t!=null)for(let e of t)this.list.push(e)}[Symbol.iterator](){return Ct(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 Ct(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 Qs(){return new Wt}var Xn={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},ti={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},ei=new globalThis.TextEncoder;function Oa(r,t){let e=Xn[t],n=ti[t];for(let o=0;o<r.length;o++)n^=BigInt(r[o]),n=BigInt.asUintN(t,n*e);return n}function Ma(r,t,e){if(e.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");let n=Xn[t],o=ti[t],s=r;for(;s.length>0;){let i=ei.encodeInto(s,e);s=s.slice(i.read);for(let a=0;a<i.written;a++)o^=BigInt(e[a]),o=BigInt.asUintN(t,o*n)}return o}function $n(r,{size:t=32,utf8Buffer:e}={}){if(!Xn[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 Ma(r,t,e);r=ei.encode(r)}return Oa(r,t)}var Ye={hash:r=>Number($n(r,{size:32})),hashV:(r,t)=>Ha(Ye.hash(r,t))};function Ha(r){let t=r.toString(16);return t.length%2===1&&(t=`0${t}`),J(t,"base16")}var Jn=64,At=class{fp;h;seed;constructor(t,e,n,o=2){if(o>Jn)throw new TypeError("Invalid Fingerprint Size");let s=e.hashV(t,n),i=Et(o);for(let a=0;a<i.length;a++)i[a]=s[a];i.length===0&&(i[0]=7),this.fp=i,this.h=e,this.seed=n}hash(){return this.h.hash(this.fp,this.seed)}equals(t){return t?.fp instanceof Uint8Array?lt(this.fp,t.fp):!1}};function ae(r,t){return Math.floor(Math.random()*(t-r))+r}var fe=class{contents;constructor(t){this.contents=new Array(t).fill(null)}has(t){if(!(t instanceof At))throw new TypeError("Invalid Fingerprint");return this.contents.some(e=>t.equals(e))}add(t){if(!(t instanceof At))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 At))throw new TypeError("Invalid Fingerprint");let e=ae(0,this.contents.length-1),n=this.contents[e];return this.contents[e]=t,n}remove(t){if(!(t instanceof At))throw new TypeError("Invalid Fingerprint");let e=this.contents.findIndex(n=>t.equals(n));return e>-1?(this.contents[e]=null,!0):!1}};var za=500,We=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??Ye,this.seed=t.seed??ae(0,Math.pow(2,10))}add(t){typeof t=="string"&&(t=J(t));let e=new At(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 fe(this.bucketSize)),this.buckets[o]==null&&(this.buckets[o]=new fe(this.bucketSize)),this.buckets[n].add(e)||this.buckets[o].add(e))return this.count++,!0;let s=[n,o],i=s[ae(0,s.length-1)];this.buckets[i]==null&&(this.buckets[i]=new fe(this.bucketSize));for(let a=0;a<za;a++){let c=this.buckets[i].swap(e);if(c!=null&&(i=(i^c.hash())%this.filterSize,this.buckets[i]==null&&(this.buckets[i]=new fe(this.bucketSize)),this.buckets[i].add(c)))return this.count++,!0}return!1}has(t){typeof t=="string"&&(t=J(t));let e=new At(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=J(t));let e=new At(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,i=this.buckets[s]?.remove(e)??!1;return i&&this.count--,i}get reliable(){return Math.floor(100*(this.count/this.filterSize))<=90}},qa={1:.5,2:.84,4:.95,8:.98};function Va(r=.001){return r>.002?2:r>1e-5?4:8}function ri(r,t=.001){let e=Va(t),n=qa[e],o=Math.round(r/n),s=Math.min(Math.ceil(Math.log2(1/t)+Math.log2(2*e)),Jn);return{filterSize:o,bucketSize:e,fingerprintSize:s}}var Ur=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??Ye,this.seed=t.seed??ae(0,Math.pow(2,10)),this.filterSeries=[new We({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(t){if(typeof t=="string"&&(t=J(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 We({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=J(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=J(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 Qn(r,t=.001,e){return new Ur({...ri(r,t),...e??{}})}var Xe=class{filter;constructor(t,e){this.filter=Qn(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 ni(r,t=.001){return new Xe(r,t)}var to=class extends Zt{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 oi(r){let{name:t,metrics:e}=r,n;return e!=null?n=new to({name:t,metrics:e}):n=new Zt,n}var eo=class extends Yt{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 si(r){let{name:t,metrics:e}=r,n;return e!=null?n=new eo({name:t,metrics:e}):n=new Yt,n}var ro=class extends Wt{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 ii(r){let{name:t,metrics:e}=r,n;return e!=null?n=new ro({name:t,metrics:e}):n=new Wt,n}return mi(Fa);})();
3
3
  /*! Bundled license information:
4
4
 
5
5
  @noble/hashes/esm/utils.js: