@libp2p/bootstrap 11.0.41-53001addf → 11.0.41

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.Libp2PBootstrap = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PBootstrap=(()=>{var tn=Object.defineProperty;var sa=Object.getOwnPropertyDescriptor;var ia=Object.getOwnPropertyNames;var aa=Object.prototype.hasOwnProperty;var ut=(r,t)=>{for(var e in t)tn(r,e,{get:t[e],enumerable:!0})},ca=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ia(t))!aa.call(r,o)&&o!==e&&tn(r,o,{get:()=>t[o],enumerable:!(n=sa(t,o))||n.enumerable});return r};var fa=r=>ca(tn({},"__esModule",{value:!0}),r);var qu={};ut(qu,{bootstrap:()=>zu});var Mo=Symbol.for("@libp2p/peer-discovery");var en=Symbol.for("@libp2p/peer-id");var St=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},ir=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var ar=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},cr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var De=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var fr=class extends EventTarget{#t=new Map;constructor(){super()}listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e={}){return this.dispatchEvent(new CustomEvent(t,e))}};var Ho=Symbol.for("@libp2p/service-capabilities"),Zu=Symbol.for("@libp2p/service-dependencies");var an={};ut(an,{base58btc:()=>G,base58flickr:()=>ya});var bl=new Uint8Array(0);function Vo(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 Ct(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 zo(r){return new TextEncoder().encode(r)}function qo(r){return new TextDecoder().decode(r)}function ua(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),l=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function u(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 E=0,m=0,v=0,D=S.length;v!==D&&S[v]===0;)v++,E++;for(var B=(D-v)*f+1>>>0,U=new Uint8Array(B);v!==D;){for(var p=S[v],L=0,P=B-1;(p!==0||L<m)&&P!==-1;P--,L++)p+=256*U[P]>>>0,U[P]=p%a>>>0,p=p/a>>>0;if(p!==0)throw new Error("Non-zero carry");m=L,v++}for(var C=B-m;C!==B&&U[C]===0;)C++;for(var h=c.repeat(E);C<B;++C)h+=r.charAt(U[C]);return h}function x(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var E=0;if(S[E]!==" "){for(var m=0,v=0;S[E]===c;)m++,E++;for(var D=(S.length-E)*l+1>>>0,B=new Uint8Array(D);S[E];){var U=e[S.charCodeAt(E)];if(U===255)return;for(var p=0,L=D-1;(U!==0||p<v)&&L!==-1;L--,p++)U+=a*B[L]>>>0,B[L]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");v=p,E++}if(S[E]!==" "){for(var P=D-v;P!==D&&B[P]===0;)P++;for(var C=new Uint8Array(m+(D-P)),h=m;P!==D;)C[h++]=B[P++];return C}}}function b(S){var E=x(S);if(E)return E;throw new Error(`Non-${t} character`)}return{encode:u,decodeUnsafe:x,decode:b}}var la=ua,ha=la,jo=ha;var rn=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")}},nn=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 Go(this,t)}},on=class{decoders;constructor(t){this.decoders=t}or(t){return Go(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 Go(r,t){return new on({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var sn=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 rn(t,e,n),this.decoder=new nn(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function fe({name:r,prefix:t,encode:e,decode:n}){return new sn(r,t,e,n)}function Rt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=jo(e,r);return fe({prefix:t,name:r,encode:n,decode:s=>Ct(o(s))})}function da(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 l=0;l<o;++l){let f=t[r[l]];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 pa(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 ma(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function j({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=ma(n);return fe({prefix:t,name:r,encode(s){return pa(s,n,e)},decode(s){return da(s,o,e,r)}})}var G=Rt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ya=Rt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var cn={};ut(cn,{base32:()=>Kt,base32hex:()=>wa,base32hexpad:()=>Sa,base32hexpadupper:()=>va,base32hexupper:()=>Ea,base32pad:()=>xa,base32padupper:()=>ga,base32upper:()=>ba,base32z:()=>Aa});var Kt=j({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ba=j({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),xa=j({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ga=j({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),wa=j({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ea=j({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Sa=j({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),va=j({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Aa=j({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var fn={};ut(fn,{base36:()=>Pe,base36upper:()=>Ia});var Pe=Rt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ia=Rt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ba=Zo,Wo=128,Ca=127,_a=~Ca,Ta=Math.pow(2,31);function Zo(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Ta;)t[e++]=r&255|Wo,r/=128;for(;r&_a;)t[e++]=r&255|Wo,r>>>=7;return t[e]=r|0,Zo.bytes=e-n+1,t}var Da=un,Pa=128,$o=127;function un(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw un.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&$o)<<o:(i&$o)*Math.pow(2,o),o+=7}while(i>=Pa);return un.bytes=s-n,e}var La=Math.pow(2,7),Oa=Math.pow(2,14),Ua=Math.pow(2,21),Na=Math.pow(2,28),Ra=Math.pow(2,35),Ka=Math.pow(2,42),ka=Math.pow(2,49),Ma=Math.pow(2,56),Ha=Math.pow(2,63),Va=function(r){return r<La?1:r<Oa?2:r<Ua?3:r<Na?4:r<Ra?5:r<Ka?6:r<ka?7:r<Ma?8:r<Ha?9:10},za={encode:Ba,decode:Da,encodingLength:Va},qa=za,Le=qa;function Oe(r,t=0){return[Le.decode(r,t),Le.decode.bytes]}function ue(r,t,e=0){return Le.encode(r,t,e),t}function le(r){return Le.encodingLength(r)}function Wt(r,t){let e=t.byteLength,n=le(r),o=n+le(e),s=new Uint8Array(o+e);return ue(r,s,0),ue(e,s,n),s.set(t,o),new he(r,e,t,s)}function Ue(r){let t=Ct(r),[e,n]=Oe(t),[o,s]=Oe(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new he(e,o,i,t)}function Yo(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Vo(r.bytes,e.bytes)}}var he=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Xo(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return ja(e,ln(r),t??G.encoder);default:return Ga(e,ln(r),t??Kt.encoder)}}var Qo=new WeakMap;function ln(r){let t=Qo.get(r);if(t==null){let e=new Map;return Qo.set(r,e),e}return t}var Y=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!==Ne)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Wa)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=Wt(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&&Yo(t.multihash,n.multihash)}toString(t){return Xo(this,t)}toJSON(){return{"/":Xo(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??Jo(n,o,s.bytes))}else if(e[$a]===!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!==Ne)throw new Error(`Version 0 CID must use dag-pb (code: ${Ne}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Jo(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Ne,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=Ct(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 he(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[u,x]=Oe(t.subarray(e));return e+=x,u},o=n(),s=Ne;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(),l=e+c,f=l-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:f,size:l}}static parse(t,e){let[n,o]=Fa(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 ln(s).set(n,t),s}};function Fa(r,t){switch(r[0]){case"Q":{let e=t??G;return[G.prefix,e.decode(`${G.prefix}${r}`)]}case G.prefix:{let e=t??G;return[G.prefix,e.decode(r)]}case Kt.prefix:{let e=t??Kt;return[Kt.prefix,e.decode(r)]}case Pe.prefix:{let e=t??Pe;return[Pe.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 ja(r,t,e){let{prefix:n}=e;if(n!==G.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 Ga(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 Ne=112,Wa=18;function Jo(r,t,e){let n=le(r),o=n+le(t),s=new Uint8Array(o+e.byteLength);return ue(r,s,0),ue(t,s,n),s.set(e,o),s}var $a=Symbol.for("@ipld/js-cid/CID");var hn={};ut(hn,{identity:()=>xt});var ts=0,Za="identity",es=Ct;function Ya(r){return Wt(ts,es(r))}var xt={code:ts,name:Za,encode:es,digest:Ya};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 _t(r=0){return new Uint8Array(r)}function ht(r=0){return new Uint8Array(r)}function Tt(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=ht(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var ns=Symbol.for("@achingbrain/uint8arraylist");function rs(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 lr(r){return!!r?.[ns]}var dt=class r{bufs;length;[ns]=!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(lr(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(lr(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=rs(this.bufs,t);return e.buf[e.index]}set(t,e){let n=rs(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(lr(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 Tt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Tt(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 l=t>=a&&t<c,f=e>a&&e<=c;if(l&&f){if(t===a&&e===c){n.push(i);break}let u=t-a;n.push(i.subarray(u,u+(e-t)));break}if(l){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(!lr(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 u=0;u<s;u++)i[u]=-1;for(let u=0;u<o;u++)i[n[u]]=u;let a=i,c=this.byteLength-n.byteLength,l=n.byteLength-1,f;for(let u=e;u<=c;u+=f){f=0;for(let x=l;x>=0;x--){let b=this.get(u+x);if(n[x]!==b){f=Math.max(1,x-a[b]);break}}if(f===0)return u}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=ht(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=_t(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=_t(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=_t(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=ht(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=_t(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=_t(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=_t(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=_t(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=_t(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 dn={};ut(dn,{base10:()=>Xa});var Xa=Rt({prefix:"9",name:"base10",alphabet:"0123456789"});var pn={};ut(pn,{base16:()=>Qa,base16upper:()=>Ja});var Qa=j({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ja=j({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var mn={};ut(mn,{base2:()=>tc});var tc=j({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var yn={};ut(yn,{base256emoji:()=>sc});var os=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}"),ec=os.reduce((r,t,e)=>(r[e]=t,r),[]),rc=os.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function nc(r){return r.reduce((t,e)=>(t+=ec[e],t),"")}function oc(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=rc[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var sc=fe({prefix:"\u{1F680}",name:"base256emoji",encode:nc,decode:oc});var xn={};ut(xn,{base64:()=>ic,base64pad:()=>ac,base64url:()=>bn,base64urlpad:()=>cc});var ic=j({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ac=j({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),bn=j({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),cc=j({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var gn={};ut(gn,{base8:()=>fc});var fc=j({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var wn={};ut(wn,{identity:()=>uc});var uc=fe({prefix:"\0",name:"identity",encode:r=>qo(r),decode:r=>zo(r)});var th=new TextEncoder,eh=new TextDecoder;var vn={};ut(vn,{sha256:()=>Re,sha512:()=>dc});function Sn({name:r,code:t,encode:e}){return new En(r,t,e)}var En=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?Wt(this.code,e):e.then(n=>Wt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function is(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Re=Sn({name:"sha2-256",code:18,encode:is("SHA-256")}),dc=Sn({name:"sha2-512",code:19,encode:is("SHA-512")});var Ke={...wn,...mn,...gn,...dn,...pn,...cn,...fn,...an,...xn,...yn},dh={...vn,...hn};function cs(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var as=cs("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),An=cs("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=ht(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),pc={utf8:as,"utf-8":as,hex:Ke.base16,latin1:An,ascii:An,binary:An,...Ke},hr=pc;function nt(r,t="utf8"){let e=hr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function H(r,t="utf8"){let e=hr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var mc=parseInt("11111",2),In=parseInt("10000000",2),yc=parseInt("01111111",2),fs={0:ke,1:ke,2:bc,3:wc,4:Ec,5:gc,6:xc,16:ke,22:ke,48:ke};function Bn(r,t={offset:0}){let e=r[t.offset]&mc;if(t.offset++,fs[e]!=null)return fs[e](r,t);throw new Error("No decoder for tag "+e)}function Me(r,t){let e=0;if((r[t.offset]&In)===In){let n=r[t.offset]&yc,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 ke(r,t){Me(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=Bn(r,t);if(n===null)break;e.push(n)}return e}function bc(r,t){let e=Me(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 xc(r,t){let e=Me(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 l=r[t.offset];if(t.offset++,c.push(l&127),l<128){c.reverse();let f=0;for(let u=0;u<c.length;u++)f+=c[u]<<u*7;a+=`.${f}`,c=[]}}return a}function gc(r,t){return t.offset++,null}function wc(r,t){let e=Me(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 Ec(r,t){let e=Me(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function Sc(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new dt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function Cn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=Sc(r.byteLength);return new dt(Uint8Array.from([t.byteLength|In]),t)}function us(r){let t=new dt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new dt(Uint8Array.from([2]),Cn(t),t)}function ls(r){let t=Uint8Array.from([0]),e=new dt(t,r);return new dt(Uint8Array.from([3]),Cn(e),e)}function dr(r,t=48){let e=new dt;for(let n of r)e.append(n);return new dt(Uint8Array.from([t]),Cn(e),e)}async function hs(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 vc=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Ac=Uint8Array.from([6,5,43,129,4,0,34]),Ic=Uint8Array.from([6,5,43,129,4,0,35]),Bc={ext:!0,kty:"EC",crv:"P-256"},Cc={ext:!0,kty:"EC",crv:"P-384"},_c={ext:!0,kty:"EC",crv:"P-521"},_n=32,Tn=48,Dn=66;function ds(r){let t=Bn(r);return ps(t)}function ps(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===_n*2+1)return n=H(t.subarray(e,e+_n),"base64url"),o=H(t.subarray(e+_n),"base64url"),new pe({...Bc,key_ops:["verify"],x:n,y:o});if(t.byteLength===Tn*2+1)return n=H(t.subarray(e,e+Tn),"base64url"),o=H(t.subarray(e+Tn),"base64url"),new pe({...Cc,key_ops:["verify"],x:n,y:o});if(t.byteLength===Dn*2+1)return n=H(t.subarray(e,e+Dn),"base64url"),o=H(t.subarray(e+Dn),"base64url"),new pe({..._c,key_ops:["verify"],x:n,y:o});throw new St(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function ms(r){return dr([us(Uint8Array.from([1])),dr([Tc(r.crv)],160),dr([ls(new dt(Uint8Array.from([4]),nt(r.x??"","base64url"),nt(r.y??"","base64url")))],161)]).subarray()}function Tc(r){if(r==="P-256")return vc;if(r==="P-384")return Ac;if(r==="P-521")return Ic;throw new St(`Invalid curve ${r}`)}var pe=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=ms(this.jwk)),this._raw}toMultihash(){return xt.digest(me(this))}toCID(){return Y.createV1(114,this.toMultihash())}toString(){return G.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 hs(this.jwk,e,t,n)}};var $t=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function be(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function He(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function ot(r,...t){if(!be(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 bs(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");He(r.outputLen),He(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 xs(r,t){ot(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function Pt(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function pr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function gt(r,t){return r<<32-t|r>>>t}var gs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Dc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function vt(r){if(ot(r),gs)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=Dc[r[e]];return t}var Dt={_0:48,_9:57,A:65,F:70,a:97,f:102};function ys(r){if(r>=Dt._0&&r<=Dt._9)return r-Dt._0;if(r>=Dt.A&&r<=Dt.F)return r-(Dt.A-10);if(r>=Dt.a&&r<=Dt.f)return r-(Dt.a-10)}function ge(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(gs)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=ys(r.charCodeAt(s)),a=ys(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 ws(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function Ve(r){return typeof r=="string"&&(r=ws(r)),ot(r),r}function pt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];ot(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 Pn(r){let t=n=>r().update(Ve(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function ze(r=32){if($t&&typeof $t.getRandomValues=="function")return $t.getRandomValues(new Uint8Array(r));if($t&&typeof $t.randomBytes=="function")return Uint8Array.from($t.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function Pc(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,l=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+l,a,n)}function Es(r,t,e){return r&t^~r&e}function Ss(r,t,e){return r&t^r&e^t&e}var qe=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=pr(this.buffer)}update(t){xe(this),t=Ve(t),ot(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=pr(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),xs(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,Pt(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let u=i;u<o;u++)e[u]=0;Pc(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=pr(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,f[u],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()}},Lt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var tt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var mr=BigInt(4294967295),vs=BigInt(32);function Lc(r,t=!1){return t?{h:Number(r&mr),l:Number(r>>vs&mr)}:{h:Number(r>>vs&mr)|0,l:Number(r&mr)|0}}function As(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}=Lc(r[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var Ln=(r,t,e)=>r>>>e,On=(r,t,e)=>r<<32-e|t>>>e,Zt=(r,t,e)=>r>>>e|t<<32-e,Yt=(r,t,e)=>r<<32-e|t>>>e,Fe=(r,t,e)=>r<<64-e|t>>>e-32,je=(r,t,e)=>r>>>e-32|t<<64-e;function At(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var Is=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Bs=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Cs=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),_s=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Ts=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Ds=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Uc=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]),kt=new Uint32Array(64),Un=class extends qe{constructor(t=32){super(64,t,8,!1),this.A=Lt[0]|0,this.B=Lt[1]|0,this.C=Lt[2]|0,this.D=Lt[3]|0,this.E=Lt[4]|0,this.F=Lt[5]|0,this.G=Lt[6]|0,this.H=Lt[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 u=0;u<16;u++,e+=4)kt[u]=t.getUint32(e,!1);for(let u=16;u<64;u++){let x=kt[u-15],b=kt[u-2],S=gt(x,7)^gt(x,18)^x>>>3,E=gt(b,17)^gt(b,19)^b>>>10;kt[u]=E+kt[u-7]+S+kt[u-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:l,H:f}=this;for(let u=0;u<64;u++){let x=gt(a,6)^gt(a,11)^gt(a,25),b=f+x+Es(a,c,l)+Uc[u]+kt[u]|0,E=(gt(n,2)^gt(n,13)^gt(n,22))+Ss(n,o,s)|0;f=l,l=c,c=a,a=i+b|0,i=s,s=o,o=n,n=b+E|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,l=l+this.G|0,f=f+this.H|0,this.set(n,o,s,i,a,c,l,f)}roundClean(){Pt(kt)}destroy(){this.set(0,0,0,0,0,0,0,0),Pt(this.buffer)}};var Ps=As(["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))),Nc=Ps[0],Rc=Ps[1],Mt=new Uint32Array(80),Ht=new Uint32Array(80),Nn=class extends qe{constructor(t=64){super(128,t,16,!1),this.Ah=tt[0]|0,this.Al=tt[1]|0,this.Bh=tt[2]|0,this.Bl=tt[3]|0,this.Ch=tt[4]|0,this.Cl=tt[5]|0,this.Dh=tt[6]|0,this.Dl=tt[7]|0,this.Eh=tt[8]|0,this.El=tt[9]|0,this.Fh=tt[10]|0,this.Fl=tt[11]|0,this.Gh=tt[12]|0,this.Gl=tt[13]|0,this.Hh=tt[14]|0,this.Hl=tt[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:l,El:f,Fh:u,Fl:x,Gh:b,Gl:S,Hh:E,Hl:m}=this;return[t,e,n,o,s,i,a,c,l,f,u,x,b,S,E,m]}set(t,e,n,o,s,i,a,c,l,f,u,x,b,S,E,m){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=l|0,this.El=f|0,this.Fh=u|0,this.Fl=x|0,this.Gh=b|0,this.Gl=S|0,this.Hh=E|0,this.Hl=m|0}process(t,e){for(let B=0;B<16;B++,e+=4)Mt[B]=t.getUint32(e),Ht[B]=t.getUint32(e+=4);for(let B=16;B<80;B++){let U=Mt[B-15]|0,p=Ht[B-15]|0,L=Zt(U,p,1)^Zt(U,p,8)^Ln(U,p,7),P=Yt(U,p,1)^Yt(U,p,8)^On(U,p,7),C=Mt[B-2]|0,h=Ht[B-2]|0,g=Zt(C,h,19)^Fe(C,h,61)^Ln(C,h,6),d=Yt(C,h,19)^je(C,h,61)^On(C,h,6),y=Cs(P,d,Ht[B-7],Ht[B-16]),w=_s(y,L,g,Mt[B-7],Mt[B-16]);Mt[B]=w|0,Ht[B]=y|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:l,Dl:f,Eh:u,El:x,Fh:b,Fl:S,Gh:E,Gl:m,Hh:v,Hl:D}=this;for(let B=0;B<80;B++){let U=Zt(u,x,14)^Zt(u,x,18)^Fe(u,x,41),p=Yt(u,x,14)^Yt(u,x,18)^je(u,x,41),L=u&b^~u&E,P=x&S^~x&m,C=Ts(D,p,P,Rc[B],Ht[B]),h=Ds(C,v,U,L,Nc[B],Mt[B]),g=C|0,d=Zt(n,o,28)^Fe(n,o,34)^Fe(n,o,39),y=Yt(n,o,28)^je(n,o,34)^je(n,o,39),w=n&s^n&a^s&a,_=o&i^o&c^i&c;v=E|0,D=m|0,E=b|0,m=S|0,b=u|0,S=x|0,{h:u,l:x}=At(l|0,f|0,h|0,g|0),l=a|0,f=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let I=Is(g,y,_);n=Bs(I,h,d,w),o=I|0}({h:n,l:o}=At(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=At(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=At(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:f}=At(this.Dh|0,this.Dl|0,l|0,f|0),{h:u,l:x}=At(this.Eh|0,this.El|0,u|0,x|0),{h:b,l:S}=At(this.Fh|0,this.Fl|0,b|0,S|0),{h:E,l:m}=At(this.Gh|0,this.Gl|0,E|0,m|0),{h:v,l:D}=At(this.Hh|0,this.Hl|0,v|0,D|0),this.set(n,o,s,i,a,c,l,f,u,x,b,S,E,m,v,D)}roundClean(){Pt(Mt,Ht)}destroy(){Pt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Ls=Pn(()=>new Un);var Os=Pn(()=>new Nn);var kn=BigInt(0),Kn=BigInt(1);function Ot(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function Ge(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Us(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?kn:BigInt("0x"+r)}function we(r){return Us(vt(r))}function Xt(r){return ot(r),Us(vt(Uint8Array.from(r).reverse()))}function yr(r,t){return ge(r.toString(16).padStart(t*2,"0"))}function Ee(r,t){return yr(r,t).reverse()}function V(r,t,e){let n;if(typeof t=="string")try{n=ge(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(be(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}var Rn=r=>typeof r=="bigint"&&kn<=r;function Ns(r,t,e){return Rn(r)&&Rn(t)&&Rn(e)&&t<=r&&r<e}function Vt(r,t,e,n){if(!Ns(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Rs(r){let t;for(t=0;r>kn;r>>=Kn,t+=1);return t}var Qt=r=>(Kn<<BigInt(r))-Kn;function Ks(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=b=>new Uint8Array(b),o=b=>Uint8Array.of(b),s=n(r),i=n(r),a=0,c=()=>{s.fill(1),i.fill(0),a=0},l=(...b)=>e(i,s,...b),f=(b=n(0))=>{i=l(o(0),b),s=l(),b.length!==0&&(i=l(o(1),b),s=l())},u=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let b=0,S=[];for(;b<t;){s=l();let E=s.slice();S.push(E),b+=s.length}return pt(...S)};return(b,S)=>{c(),f(b);let E;for(;!(E=S(u()));)f();return c(),E}}function zt(r,t,e={}){if(!r||typeof r!="object")throw new Error("expected valid options object");function n(o,s,i){let a=r[o];if(i&&a===void 0)return;let c=typeof a;if(c!==s||a===null)throw new Error(`param "${o}" is invalid: expected ${s}, got ${c}`)}Object.entries(t).forEach(([o,s])=>n(o,s,!1)),Object.entries(e).forEach(([o,s])=>n(o,s,!0))}function Se(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 ct=BigInt(0),Q=BigInt(1),Jt=BigInt(2),Kc=BigInt(3),Hs=BigInt(4),Vs=BigInt(5),zs=BigInt(8);function q(r,t){let e=r%t;return e>=ct?e:t+e}function z(r,t,e){let n=r;for(;t-- >ct;)n*=n,n%=e;return n}function ks(r,t){if(r===ct)throw new Error("invert: expected non-zero number");if(t<=ct)throw new Error("invert: expected positive modulus, got "+t);let e=q(r,t),n=t,o=ct,s=Q,i=Q,a=ct;for(;e!==ct;){let l=n/e,f=n%e,u=o-i*l,x=s-a*l;n=e,e=f,o=i,s=a,i=u,a=x}if(n!==Q)throw new Error("invert: does not exist");return q(o,t)}function qs(r,t){let e=(r.ORDER+Q)/Hs,n=r.pow(t,e);if(!r.eql(r.sqr(n),t))throw new Error("Cannot find square root");return n}function kc(r,t){let e=(r.ORDER-Vs)/zs,n=r.mul(t,Jt),o=r.pow(n,e),s=r.mul(t,o),i=r.mul(r.mul(s,Jt),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 Mc(r){if(r<BigInt(3))throw new Error("sqrt is not defined for small field");let t=r-Q,e=0;for(;t%Jt===ct;)t/=Jt,e++;let n=Jt,o=wt(r);for(;Ms(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return qs;let s=o.pow(n,t),i=(t+Q)/Jt;return function(c,l){if(c.is0(l))return l;if(Ms(c,l)!==1)throw new Error("Cannot find square root");let f=e,u=c.mul(c.ONE,s),x=c.pow(l,t),b=c.pow(l,i);for(;!c.eql(x,c.ONE);){if(c.is0(x))return c.ZERO;let S=1,E=c.sqr(x);for(;!c.eql(E,c.ONE);)if(S++,E=c.sqr(E),S===f)throw new Error("Cannot find square root");let m=Q<<BigInt(f-S-1),v=c.pow(u,m);f=S,u=c.sqr(v),x=c.mul(x,u),b=c.mul(b,v)}return b}}function Hc(r){return r%Hs===Kc?qs:r%zs===Vs?kc:Mc(r)}var Fs=(r,t)=>(q(r,t)&Q)===Q,Vc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Mn(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},e=Vc.reduce((n,o)=>(n[o]="function",n),t);return zt(r,e),r}function zc(r,t,e){if(e<ct)throw new Error("invalid exponent, negatives unsupported");if(e===ct)return r.ONE;if(e===Q)return t;let n=r.ONE,o=t;for(;e>ct;)e&Q&&(n=r.mul(n,o)),o=r.sqr(o),e>>=Q;return n}function We(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 Ms(r,t){let e=(r.ORDER-Q)/Jt,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 js(r,t){t!==void 0&&He(t);let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function wt(r,t,e=!1,n={}){if(r<=ct)throw new Error("invalid field: expected ORDER > 0, got "+r);let o,s;if(typeof t=="object"&&t!=null){if(n.sqrt||e)throw new Error("cannot specify opts in two arguments");let f=t;f.BITS&&(o=f.BITS),f.sqrt&&(s=f.sqrt),typeof f.isLE=="boolean"&&(e=f.isLE)}else typeof t=="number"&&(o=t),n.sqrt&&(s=n.sqrt);let{nBitLength:i,nByteLength:a}=js(r,o);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c,l=Object.freeze({ORDER:r,isLE:e,BITS:i,BYTES:a,MASK:Qt(i),ZERO:ct,ONE:Q,create:f=>q(f,r),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return ct<=f&&f<r},is0:f=>f===ct,isValidNot0:f=>!l.is0(f)&&l.isValid(f),isOdd:f=>(f&Q)===Q,neg:f=>q(-f,r),eql:(f,u)=>f===u,sqr:f=>q(f*f,r),add:(f,u)=>q(f+u,r),sub:(f,u)=>q(f-u,r),mul:(f,u)=>q(f*u,r),pow:(f,u)=>zc(l,f,u),div:(f,u)=>q(f*ks(u,r),r),sqrN:f=>f*f,addN:(f,u)=>f+u,subN:(f,u)=>f-u,mulN:(f,u)=>f*u,inv:f=>ks(f,r),sqrt:s||(f=>(c||(c=Hc(r)),c(l,f))),toBytes:f=>e?Ee(f,a):yr(f,a),fromBytes:f=>{if(f.length!==a)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+f.length);return e?Xt(f):we(f)},invertBatch:f=>We(l,f),cmov:(f,u,x)=>x?u:f});return Object.freeze(l)}function Gs(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 Hn(r){let t=Gs(r);return t+Math.ceil(t/2)}function Ws(r,t,e=!1){let n=r.length,o=Gs(t),s=Hn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?Xt(r):we(r),a=q(i,t-Q)+Q;return e?Ee(a,o):yr(a,o)}var Ae=BigInt(0),te=BigInt(1);function ve(r,t){let e=t.negate();return r?e:t}function br(r,t,e){let n=t==="pz"?i=>i.pz:i=>i.ez,o=We(r.Fp,e.map(n));return e.map((i,a)=>i.toAffine(o[a])).map(r.fromAffine)}function Xs(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Vn(r,t){Xs(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=Qt(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function $s(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+=te);let l=t*n,f=l+Math.abs(a)-1,u=a===0,x=a<0,b=t%2!==0;return{nextN:c,offset:f,isZero:u,isNeg:x,isNegF:b,offsetF:l}}function qc(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 Fc(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 zn=new WeakMap,Qs=new WeakMap;function qn(r){return Qs.get(r)||1}function Zs(r){if(r!==Ae)throw new Error("invalid wNAF")}function xr(r,t){return{constTimeNegate:ve,hasPrecomputes(e){return qn(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Ae;)n&te&&(o=o.add(s)),s=s.double(),n>>=te;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=Vn(n,t),i=[],a=e,c=a;for(let l=0;l<o;l++){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=Vn(e,t);for(let c=0;c<a.windows;c++){let{nextN:l,offset:f,isZero:u,isNeg:x,isNegF:b,offsetF:S}=$s(o,c,a);o=l,u?i=i.add(ve(b,n[S])):s=s.add(ve(x,n[f]))}return Zs(o),{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=Vn(e,t);for(let a=0;a<i.windows&&o!==Ae;a++){let{nextN:c,offset:l,isZero:f,isNeg:u}=$s(o,a,i);if(o=c,!f){let x=n[l];s=s.add(u?x.negate():x)}}return Zs(o),s},getPrecomputes(e,n,o){let s=zn.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&(typeof o=="function"&&(s=o(s)),zn.set(n,s))),s},wNAFCached(e,n,o){let s=qn(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=qn(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){Xs(n,t),Qs.set(e,n),zn.delete(e)}}}function Js(r,t,e,n){let o=t,s=r.ZERO,i=r.ZERO;for(;e>Ae||n>Ae;)e&te&&(s=s.add(o)),n&te&&(i=i.add(o)),o=o.double(),e>>=te,n>>=te;return{p1:s,p2:i}}function gr(r,t,e,n){qc(e,r),Fc(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=Rs(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let l=Qt(c),f=new Array(Number(l)+1).fill(i),u=Math.floor((t.BITS-1)/c)*c,x=i;for(let b=u;b>=0;b-=c){f.fill(i);for(let E=0;E<s;E++){let m=n[E],v=Number(m>>BigInt(b)&l);f[v]=f[v].add(e[E])}let S=i;for(let E=f.length-1,m=i;E>0;E--)m=m.add(f[E]),S=S.add(m);if(x=x.add(S),b!==0)for(let E=0;E<c;E++)x=x.double()}return x}function Ys(r,t){if(t){if(t.ORDER!==r)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Mn(t),t}else return wt(r)}function wr(r,t,e={}){if(!t||typeof t!="object")throw new Error(`expected valid ${r} CURVE object`);for(let a of["p","n","h"]){let c=t[a];if(!(typeof c=="bigint"&&c>Ae))throw new Error(`CURVE.${a} must be positive bigint`)}let n=Ys(t.p,e.Fp),o=Ys(t.n,e.Fn),i=["Gx","Gy","a",r==="weierstrass"?"b":"d"];for(let a of i)if(!n.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return{Fp:n,Fn:o}}var It=BigInt(0),ft=BigInt(1),Fn=BigInt(2),jc=BigInt(8),Gc={zip215:!0};function Wc(r,t,e,n){let o=r.sqr(e),s=r.sqr(n),i=r.add(r.mul(t.a,o),s),a=r.add(r.ONE,r.mul(t.d,r.mul(o,s)));return r.eql(i,a)}function $c(r,t={}){let{Fp:e,Fn:n}=wr("edwards",r,t),{h:o,n:s}=r;zt(t,{},{uvRatio:"function"});let i=Fn<<BigInt(n.BYTES*8)-ft,a=E=>e.create(E),c=t.uvRatio||((E,m)=>{try{return{isValid:!0,value:e.sqrt(e.div(E,m))}}catch{return{isValid:!1,value:It}}});if(!Wc(e,r,r.Gx,r.Gy))throw new Error("bad curve params: generator point");function l(E,m,v=!1){let D=v?ft:It;return Vt("coordinate "+E,m,D,i),m}function f(E){if(!(E instanceof b))throw new Error("ExtendedPoint expected")}let u=Se((E,m)=>{let{ex:v,ey:D,ez:B}=E,U=E.is0();m==null&&(m=U?jc:e.inv(B));let p=a(v*m),L=a(D*m),P=a(B*m);if(U)return{x:It,y:ft};if(P!==ft)throw new Error("invZ was invalid");return{x:p,y:L}}),x=Se(E=>{let{a:m,d:v}=r;if(E.is0())throw new Error("bad point: ZERO");let{ex:D,ey:B,ez:U,et:p}=E,L=a(D*D),P=a(B*B),C=a(U*U),h=a(C*C),g=a(L*m),d=a(C*a(g+P)),y=a(h+a(v*a(L*P)));if(d!==y)throw new Error("bad point: equation left != right (1)");let w=a(D*B),_=a(U*p);if(w!==_)throw new Error("bad point: equation left != right (2)");return!0});class b{constructor(m,v,D,B){this.ex=l("x",m),this.ey=l("y",v),this.ez=l("z",D,!0),this.et=l("t",B),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(m){if(m instanceof b)throw new Error("extended point not allowed");let{x:v,y:D}=m||{};return l("x",v),l("y",D),new b(v,D,ft,a(v*D))}static normalizeZ(m){return br(b,"ez",m)}static msm(m,v){return gr(b,n,m,v)}_setWindowSize(m){this.precompute(m)}precompute(m=8,v=!0){return S.setWindowSize(this,m),v||this.multiply(Fn),this}assertValidity(){x(this)}equals(m){f(m);let{ex:v,ey:D,ez:B}=this,{ex:U,ey:p,ez:L}=m,P=a(v*L),C=a(U*B),h=a(D*L),g=a(p*B);return P===C&&h===g}is0(){return this.equals(b.ZERO)}negate(){return new b(a(-this.ex),this.ey,this.ez,a(-this.et))}double(){let{a:m}=r,{ex:v,ey:D,ez:B}=this,U=a(v*v),p=a(D*D),L=a(Fn*a(B*B)),P=a(m*U),C=v+D,h=a(a(C*C)-U-p),g=P+p,d=g-L,y=P-p,w=a(h*d),_=a(g*y),I=a(h*y),T=a(d*g);return new b(w,_,T,I)}add(m){f(m);let{a:v,d:D}=r,{ex:B,ey:U,ez:p,et:L}=this,{ex:P,ey:C,ez:h,et:g}=m,d=a(B*P),y=a(U*C),w=a(L*D*g),_=a(p*h),I=a((B+U)*(P+C)-d-y),T=_-w,R=_+w,N=a(y-v*d),W=a(I*T),k=a(R*N),K=a(I*N),Z=a(T*R);return new b(W,k,Z,K)}subtract(m){return this.add(m.negate())}multiply(m){let v=m;Vt("scalar",v,ft,s);let{p:D,f:B}=S.wNAFCached(this,v,b.normalizeZ);return b.normalizeZ([D,B])[0]}multiplyUnsafe(m,v=b.ZERO){let D=m;return Vt("scalar",D,It,s),D===It?b.ZERO:this.is0()||D===ft?this:S.wNAFCachedUnsafe(this,D,b.normalizeZ,v)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}isTorsionFree(){return S.wNAFCachedUnsafe(this,s).is0()}toAffine(m){return u(this,m)}clearCofactor(){return o===ft?this:this.multiplyUnsafe(o)}static fromBytes(m,v=!1){return ot(m),this.fromHex(m,v)}static fromHex(m,v=!1){let{d:D,a:B}=r,U=e.BYTES;m=V("pointHex",m,U),Ot("zip215",v);let p=m.slice(),L=m[U-1];p[U-1]=L&-129;let P=Xt(p),C=v?i:e.ORDER;Vt("pointHex.y",P,It,C);let h=a(P*P),g=a(h-ft),d=a(D*h-B),{isValid:y,value:w}=c(g,d);if(!y)throw new Error("Point.fromHex: invalid y coordinate");let _=(w&ft)===ft,I=(L&128)!==0;if(!v&&w===It&&I)throw new Error("Point.fromHex: x=0 and x_0=1");return I!==_&&(w=a(-w)),b.fromAffine({x:w,y:P})}static fromPrivateScalar(m){return b.BASE.multiply(m)}toBytes(){let{x:m,y:v}=this.toAffine(),D=Ee(v,e.BYTES);return D[D.length-1]|=m&ft?128:0,D}toRawBytes(){return this.toBytes()}toHex(){return vt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}b.BASE=new b(r.Gx,r.Gy,ft,a(r.Gx*r.Gy)),b.ZERO=new b(It,ft,ft,It),b.Fp=e,b.Fn=n;let S=xr(b,n.BYTES*8);return b}function Zc(r,t){zt(t,{hash:"function"},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:e,hash:n}=t,{BASE:o,Fp:s,Fn:i}=r,a=i.ORDER,c=t.randomBytes||ze,l=t.adjustScalarBytes||(p=>p),f=t.domain||((p,L,P)=>{if(Ot("phflag",P),L.length||P)throw new Error("Contexts/pre-hash are not supported");return p});function u(p){return i.create(p)}function x(p){return u(Xt(p))}function b(p){let L=s.BYTES;p=V("private key",p,L);let P=V("hashed private key",n(p),2*L),C=l(P.slice(0,L)),h=P.slice(L,2*L),g=x(C);return{head:C,prefix:h,scalar:g}}function S(p){let{head:L,prefix:P,scalar:C}=b(p),h=o.multiply(C),g=h.toBytes();return{head:L,prefix:P,scalar:C,point:h,pointBytes:g}}function E(p){return S(p).pointBytes}function m(p=Uint8Array.of(),...L){let P=pt(...L);return x(n(f(P,V("context",p),!!e)))}function v(p,L,P={}){p=V("message",p),e&&(p=e(p));let{prefix:C,scalar:h,pointBytes:g}=S(L),d=m(P.context,C,p),y=o.multiply(d).toBytes(),w=m(P.context,y,g,p),_=u(d+w*h);Vt("signature.s",_,It,a);let I=s.BYTES,T=pt(y,Ee(_,I));return V("result",T,I*2)}let D=Gc;function B(p,L,P,C=D){let{context:h,zip215:g}=C,d=s.BYTES;p=V("signature",p,2*d),L=V("message",L),P=V("publicKey",P,d),g!==void 0&&Ot("zip215",g),e&&(L=e(L));let y=Xt(p.slice(d,2*d)),w,_,I;try{w=r.fromHex(P,g),_=r.fromHex(p.slice(0,d),g),I=o.multiplyUnsafe(y)}catch{return!1}if(!g&&w.isSmallOrder())return!1;let T=m(h,_.toBytes(),w.toBytes(),L);return _.add(w.multiplyUnsafe(T)).subtract(I).clearCofactor().is0()}return o.precompute(8),{getPublicKey:E,sign:v,verify:B,utils:{getExtendedPublicKey:S,randomPrivateKey:()=>c(s.BYTES),precompute(p=8,L=r.BASE){return L.precompute(p,!1)}},Point:r}}function Yc(r){let t={a:r.a,d:r.d,p:r.Fp.ORDER,n:r.n,h:r.h,Gx:r.Gx,Gy:r.Gy},e=r.Fp,n=wt(t.n,r.nBitLength,!0),o={Fp:e,Fn:n,uvRatio:r.uvRatio},s={hash:r.hash,randomBytes:r.randomBytes,adjustScalarBytes:r.adjustScalarBytes,domain:r.domain,prehash:r.prehash,mapToCurve:r.mapToCurve};return{CURVE:t,curveOpts:o,eddsaOpts:s}}function Xc(r,t){return Object.assign({},t,{ExtendedPoint:t.Point,CURVE:r})}function ti(r){let{CURVE:t,curveOpts:e,eddsaOpts:n}=Yc(r),o=$c(t,e),s=Zc(o,n);return Xc(r,s)}var xd=BigInt(0),Qc=BigInt(1),ei=BigInt(2),gd=BigInt(3),Jc=BigInt(5),tf=BigInt(8),Er={p:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:tf,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function ef(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=Er.p,a=r*r%s*r%s,c=z(a,ei,s)*a%s,l=z(c,Qc,s)*r%s,f=z(l,Jc,s)*l%s,u=z(f,t,s)*f%s,x=z(u,e,s)*u%s,b=z(x,n,s)*x%s,S=z(b,o,s)*b%s,E=z(S,o,s)*b%s,m=z(E,t,s)*f%s;return{pow_p_5_8:z(m,ei,s)*r%s,b2:a}}function rf(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}var ri=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function nf(r,t){let e=Er.p,n=q(t*t*t,e),o=q(n*n*t,e),s=ef(r*o).pow_p_5_8,i=q(r*n*s,e),a=q(t*i*i,e),c=i,l=q(i*ri,e),f=a===r,u=a===q(-r,e),x=a===q(-r*ri,e);return f&&(i=c),(u||x)&&(i=l),Fs(i,e)&&(i=q(-i,e)),{isValid:f||u,value:i}}var of=wt(Er.p,void 0,!0),sf={...Er,Fp:of,hash:Os,adjustScalarBytes:rf,uvRatio:nf},ni=ti(sf);var $e=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Sr=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var oi={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new Sr("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 vr=oi;var Ar=32;var jn,af=(async()=>{try{return await vr.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function cf(r,t,e){if(r.buffer instanceof ArrayBuffer){let n=await vr.get().subtle.importKey("raw",r.buffer,{name:"Ed25519"},!1,["verify"]);return await vr.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 ff(r,t,e){return ni.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}async function si(r,t,e){return jn==null&&(jn=await af),jn?cf(r,t,e):ff(r,t,e)}function Ir(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var Br=class{type="Ed25519";raw;constructor(t){this.raw=Gn(t,Ar)}toMultihash(){return xt.digest(me(this))}toCID(){return Y.createV1(114,this.toMultihash())}toString(){return G.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=si(this.raw,e,t);return Ir(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function ai(r){return r=Gn(r,Ar),new Br(r)}function Gn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new St(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var lf=Math.pow(2,7),hf=Math.pow(2,14),df=Math.pow(2,21),Wn=Math.pow(2,28),$n=Math.pow(2,35),Zn=Math.pow(2,42),Yn=Math.pow(2,49),F=128,st=127;function Bt(r){if(r<lf)return 1;if(r<hf)return 2;if(r<df)return 3;if(r<Wn)return 4;if(r<$n)return 5;if(r<Zn)return 6;if(r<Yn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Ze(r,t,e=0){switch(Bt(r)){case 8:t[e++]=r&255|F,r/=128;case 7:t[e++]=r&255|F,r/=128;case 6:t[e++]=r&255|F,r/=128;case 5:t[e++]=r&255|F,r/=128;case 4:t[e++]=r&255|F,r>>>=7;case 3:t[e++]=r&255|F,r>>>=7;case 2:t[e++]=r&255|F,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Xn(r,t){let e=r[t],n=0;if(n+=e&st,e<F||(e=r[t+1],n+=(e&st)<<7,e<F)||(e=r[t+2],n+=(e&st)<<14,e<F)||(e=r[t+3],n+=(e&st)<<21,e<F)||(e=r[t+4],n+=(e&st)*Wn,e<F)||(e=r[t+5],n+=(e&st)*$n,e<F)||(e=r[t+6],n+=(e&st)*Zn,e<F)||(e=r[t+7],n+=(e&st)*Yn,e<F))return n;throw new RangeError("Could not decode varint")}function pf(r,t){let e=r.get(t),n=0;if(n+=e&st,e<F||(e=r.get(t+1),n+=(e&st)<<7,e<F)||(e=r.get(t+2),n+=(e&st)<<14,e<F)||(e=r.get(t+3),n+=(e&st)<<21,e<F)||(e=r.get(t+4),n+=(e&st)*Wn,e<F)||(e=r.get(t+5),n+=(e&st)*$n,e<F)||(e=r.get(t+6),n+=(e&st)*Zn,e<F)||(e=r.get(t+7),n+=(e&st)*Yn,e<F))return n;throw new RangeError("Could not decode varint")}function Qn(r,t=0){return r instanceof Uint8Array?Xn(r,t):pf(r,t)}var Jn=new Float32Array([-0]),qt=new Uint8Array(Jn.buffer);function ci(r,t,e){Jn[0]=r,t[e]=qt[0],t[e+1]=qt[1],t[e+2]=qt[2],t[e+3]=qt[3]}function fi(r,t){return qt[0]=r[t],qt[1]=r[t+1],qt[2]=r[t+2],qt[3]=r[t+3],Jn[0]}var to=new Float64Array([-0]),it=new Uint8Array(to.buffer);function ui(r,t,e){to[0]=r,t[e]=it[0],t[e+1]=it[1],t[e+2]=it[2],t[e+3]=it[3],t[e+4]=it[4],t[e+5]=it[5],t[e+6]=it[6],t[e+7]=it[7]}function li(r,t){return it[0]=r[t],it[1]=r[t+1],it[2]=r[t+2],it[3]=r[t+3],it[4]=r[t+4],it[5]=r[t+5],it[6]=r[t+6],it[7]=r[t+7],to[0]}var yf=BigInt(Number.MAX_SAFE_INTEGER),bf=BigInt(Number.MIN_SAFE_INTEGER),mt=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 ee;if(t<yf&&t>bf)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>hi&&(o=0n,++n>hi&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ee;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):ee}},ee=new mt(0,0);ee.toBigInt=function(){return 0n};ee.zzEncode=ee.zzDecode=function(){return this};ee.length=function(){return 1};var hi=4294967296n;function di(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 pi(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 eo(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 Et(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Cr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var ro=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,Et(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 Et(this,4);return Cr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Et(this,4);return Cr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Et(this,4);let t=fi(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Et(this,4);let t=li(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 Et(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return pi(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Et(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Et(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 mt(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 Et(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 Et(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 Et(this,8);let t=Cr(this.buf,this.pos+=4),e=Cr(this.buf,this.pos+=4);return new mt(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=Xn(this.buf,this.pos);return this.pos+=Bt(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 no(r){return new ro(r instanceof Uint8Array?r:r.subarray())}function _r(r,t,e){let n=no(r);return t.decode(n,void 0,e)}function oo(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return ht(i);o+i>t&&(n=ht(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var re=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function so(){}var ao=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},xf=oo();function gf(r){return globalThis.Buffer!=null?ht(r):xf(r)}var Xe=class{len;head;tail;states;constructor(){this.len=0,this.head=new re(so,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new re(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new co((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(Tr,10,mt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=mt.fromBigInt(t);return this._push(Tr,e.length(),e)}uint64Number(t){return this._push(Ze,Bt(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=mt.fromBigInt(t).zzEncode();return this._push(Tr,e.length(),e)}sint64Number(t){let e=mt.fromNumber(t).zzEncode();return this._push(Tr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(io,1,t?1:0)}fixed32(t){return this._push(Ye,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=mt.fromBigInt(t);return this._push(Ye,4,e.lo)._push(Ye,4,e.hi)}fixed64Number(t){let e=mt.fromNumber(t);return this._push(Ye,4,e.lo)._push(Ye,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(ci,4,t)}double(t){return this._push(ui,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(io,1,0):this.uint32(e)._push(Ef,e,t)}string(t){let e=di(t);return e!==0?this.uint32(e)._push(eo,e,t):this._push(io,1,0)}fork(){return this.states=new ao(this),this.head=this.tail=new re(so,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 re(so,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=gf(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function io(r,t,e){t[e]=r&255}function wf(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var co=class extends re{next;constructor(t,e){super(wf,t,e),this.next=void 0}};function Tr(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 Ye(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 Ef(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Xe.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Sf,t,r),this},Xe.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(vf,t,r),this});function Sf(r,t,e){t.set(r,e)}function vf(r,t,e){r.length<40?eo(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(nt(r),e)}function fo(){return new Xe}function Dr(r,t){let e=fo();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Ie;(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"})(Ie||(Ie={}));function Pr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function uo(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 Pr("enum",Ie.VARINT,e,n)}function Lr(r,t){return Pr("message",Ie.LENGTH_DELIMITED,r,t)}var yt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(yt||(yt={}));var lo;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(lo||(lo={}));(function(r){r.codec=()=>uo(lo)})(yt||(yt={}));var Qe;(function(r){let t;r.codec=()=>(t==null&&(t=Lr((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=>Dr(e,r.codec()),r.decode=(e,n)=>_r(e,r.codec(),n)})(Qe||(Qe={}));var ho;(function(r){let t;r.codec=()=>(t==null&&(t=Lr((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=>Dr(e,r.codec()),r.decode=(e,n)=>_r(e,r.codec(),n)})(ho||(ho={}));var Or=class extends ye{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,bs(t);let n=Ve(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),Pt(s)}update(t){return xe(this),this.iHash.update(t),this}digestInto(t){xe(this),ot(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()}},po=(r,t,e)=>new Or(r,t).update(e).digest();po.create=(r,t)=>new Or(r,t);function yi(r){r.lowS!==void 0&&Ot("lowS",r.lowS),r.prehash!==void 0&&Ot("prehash",r.prehash)}var mo=class extends Error{constructor(t=""){super(t)}},Ut={Err:mo,_tlv:{encode:(r,t)=>{let{Err:e}=Ut;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=Ge(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Ge(o.length/2|128):"";return Ge(r)+s+o+t},decode(r,t){let{Err:e}=Ut,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 l=t.subarray(n,n+c);if(l.length!==c)throw new e("tlv.decode: length bytes not complete");if(l[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let f of l)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}=Ut;if(r<Je)throw new t("integer: negative integers are not allowed");let e=Ge(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}=Ut;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 we(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Ut,o=V("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:l,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(l)}},hexFromSig(r){let{_tlv:t,_int:e}=Ut,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},Je=BigInt(0),tr=BigInt(1),If=BigInt(2),Ur=BigInt(3),Bf=BigInt(4);function Cf(r,t,e){function n(o){let s=r.sqr(o),i=r.mul(s,o);return r.add(r.add(i,r.mul(o,t)),e)}return n}function bi(r,t,e){let{BYTES:n}=r;function o(s){let i;if(typeof s=="bigint")i=s;else{let a=V("private key",s);if(t){if(!t.includes(a.length*2))throw new Error("invalid private key");let c=new Uint8Array(n);c.set(a,c.length-a.length),a=c}try{i=r.fromBytes(a)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof s}`)}}if(e&&(i=r.create(i)),!r.isValidNot0(i))throw new Error("invalid private key: out of range [1..N-1]");return i}return o}function _f(r,t={}){let{Fp:e,Fn:n}=wr("weierstrass",r,t),{h:o,n:s}=r;zt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:i}=t;if(i&&(!e.is0(r.a)||typeof i.beta!="bigint"||typeof i.splitScalar!="function"))throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');function a(){if(!e.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function c(C,h,g){let{x:d,y}=h.toAffine(),w=e.toBytes(d);if(Ot("isCompressed",g),g){a();let _=!e.isOdd(y);return pt(xi(_),w)}else return pt(Uint8Array.of(4),w,e.toBytes(y))}function l(C){ot(C);let h=e.BYTES,g=h+1,d=2*h+1,y=C.length,w=C[0],_=C.subarray(1);if(y===g&&(w===2||w===3)){let I=e.fromBytes(_);if(!e.isValid(I))throw new Error("bad point: is not on curve, wrong x");let T=x(I),R;try{R=e.sqrt(T)}catch(k){let K=k instanceof Error?": "+k.message:"";throw new Error("bad point: is not on curve, sqrt error"+K)}a();let N=e.isOdd(R);return(w&1)===1!==N&&(R=e.neg(R)),{x:I,y:R}}else if(y===d&&w===4){let I=e.fromBytes(_.subarray(h*0,h*1)),T=e.fromBytes(_.subarray(h*1,h*2));if(!b(I,T))throw new Error("bad point: is not on curve");return{x:I,y:T}}else throw new Error(`bad point: got length ${y}, expected compressed=${g} or uncompressed=${d}`)}let f=t.toBytes||c,u=t.fromBytes||l,x=Cf(e,r.a,r.b);function b(C,h){let g=e.sqr(h),d=x(C);return e.eql(g,d)}if(!b(r.Gx,r.Gy))throw new Error("bad curve params: generator point");let S=e.mul(e.pow(r.a,Ur),Bf),E=e.mul(e.sqr(r.b),BigInt(27));if(e.is0(e.add(S,E)))throw new Error("bad curve params: a or b");function m(C,h,g=!1){if(!e.isValid(h)||g&&e.is0(h))throw new Error(`bad point coordinate ${C}`);return h}function v(C){if(!(C instanceof p))throw new Error("ProjectivePoint expected")}let D=Se((C,h)=>{let{px:g,py:d,pz:y}=C;if(e.eql(y,e.ONE))return{x:g,y:d};let w=C.is0();h==null&&(h=w?e.ONE:e.inv(y));let _=e.mul(g,h),I=e.mul(d,h),T=e.mul(y,h);if(w)return{x:e.ZERO,y:e.ZERO};if(!e.eql(T,e.ONE))throw new Error("invZ was invalid");return{x:_,y:I}}),B=Se(C=>{if(C.is0()){if(t.allowInfinityPoint&&!e.is0(C.py))return;throw new Error("bad point: ZERO")}let{x:h,y:g}=C.toAffine();if(!e.isValid(h)||!e.isValid(g))throw new Error("bad point: x or y not field elements");if(!b(h,g))throw new Error("bad point: equation left != right");if(!C.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function U(C,h,g,d,y){return g=new p(e.mul(g.px,C),g.py,g.pz),h=ve(d,h),g=ve(y,g),h.add(g)}class p{constructor(h,g,d){this.px=m("x",h),this.py=m("y",g,!0),this.pz=m("z",d),Object.freeze(this)}static fromAffine(h){let{x:g,y:d}=h||{};if(!h||!e.isValid(g)||!e.isValid(d))throw new Error("invalid affine point");if(h instanceof p)throw new Error("projective point not allowed");return e.is0(g)&&e.is0(d)?p.ZERO:new p(g,d,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){return br(p,"pz",h)}static fromBytes(h){return ot(h),p.fromHex(h)}static fromHex(h){let g=p.fromAffine(u(V("pointHex",h)));return g.assertValidity(),g}static fromPrivateKey(h){let g=bi(n,t.allowedPrivateKeyLengths,t.wrapPrivateKey);return p.BASE.multiply(g(h))}static msm(h,g){return gr(p,n,h,g)}precompute(h=8,g=!0){return P.setWindowSize(this,h),g||this.multiply(Ur),this}_setWindowSize(h){this.precompute(h)}assertValidity(){B(this)}hasEvenY(){let{y:h}=this.toAffine();if(!e.isOdd)throw new Error("Field doesn't support isOdd");return!e.isOdd(h)}equals(h){v(h);let{px:g,py:d,pz:y}=this,{px:w,py:_,pz:I}=h,T=e.eql(e.mul(g,I),e.mul(w,y)),R=e.eql(e.mul(d,I),e.mul(_,y));return T&&R}negate(){return new p(this.px,e.neg(this.py),this.pz)}double(){let{a:h,b:g}=r,d=e.mul(g,Ur),{px:y,py:w,pz:_}=this,I=e.ZERO,T=e.ZERO,R=e.ZERO,N=e.mul(y,y),W=e.mul(w,w),k=e.mul(_,_),K=e.mul(y,w);return K=e.add(K,K),R=e.mul(y,_),R=e.add(R,R),I=e.mul(h,R),T=e.mul(d,k),T=e.add(I,T),I=e.sub(W,T),T=e.add(W,T),T=e.mul(I,T),I=e.mul(K,I),R=e.mul(d,R),k=e.mul(h,k),K=e.sub(N,k),K=e.mul(h,K),K=e.add(K,R),R=e.add(N,N),N=e.add(R,N),N=e.add(N,k),N=e.mul(N,K),T=e.add(T,N),k=e.mul(w,_),k=e.add(k,k),N=e.mul(k,K),I=e.sub(I,N),R=e.mul(k,W),R=e.add(R,R),R=e.add(R,R),new p(I,T,R)}add(h){v(h);let{px:g,py:d,pz:y}=this,{px:w,py:_,pz:I}=h,T=e.ZERO,R=e.ZERO,N=e.ZERO,W=r.a,k=e.mul(r.b,Ur),K=e.mul(g,w),Z=e.mul(d,_),X=e.mul(y,I),rt=e.add(g,d),M=e.add(w,_);rt=e.mul(rt,M),M=e.add(K,Z),rt=e.sub(rt,M),M=e.add(g,y);let at=e.add(w,I);return M=e.mul(M,at),at=e.add(K,X),M=e.sub(M,at),at=e.add(d,y),T=e.add(_,I),at=e.mul(at,T),T=e.add(Z,X),at=e.sub(at,T),N=e.mul(W,M),T=e.mul(k,X),N=e.add(T,N),T=e.sub(Z,N),N=e.add(Z,N),R=e.mul(T,N),Z=e.add(K,K),Z=e.add(Z,K),X=e.mul(W,X),M=e.mul(k,M),Z=e.add(Z,X),X=e.sub(K,X),X=e.mul(W,X),M=e.add(M,X),K=e.mul(Z,M),R=e.add(R,K),K=e.mul(at,M),T=e.mul(rt,T),T=e.sub(T,K),K=e.mul(rt,Z),N=e.mul(at,N),N=e.add(N,K),new p(T,R,N)}subtract(h){return this.add(h.negate())}is0(){return this.equals(p.ZERO)}multiply(h){let{endo:g}=t;if(!n.isValidNot0(h))throw new Error("invalid scalar: out of range");let d,y,w=_=>P.wNAFCached(this,_,p.normalizeZ);if(g){let{k1neg:_,k1:I,k2neg:T,k2:R}=g.splitScalar(h),{p:N,f:W}=w(I),{p:k,f:K}=w(R);y=W.add(K),d=U(g.beta,N,k,_,T)}else{let{p:_,f:I}=w(h);d=_,y=I}return p.normalizeZ([d,y])[0]}multiplyUnsafe(h){let{endo:g}=t,d=this;if(!n.isValid(h))throw new Error("invalid scalar: out of range");if(h===Je||d.is0())return p.ZERO;if(h===tr)return d;if(P.hasPrecomputes(this))return this.multiply(h);if(g){let{k1neg:y,k1:w,k2neg:_,k2:I}=g.splitScalar(h),{p1:T,p2:R}=Js(p,d,w,I);return U(g.beta,T,R,y,_)}else return P.wNAFCachedUnsafe(d,h)}multiplyAndAddUnsafe(h,g,d){let y=this.multiplyUnsafe(g).add(h.multiplyUnsafe(d));return y.is0()?void 0:y}toAffine(h){return D(this,h)}isTorsionFree(){let{isTorsionFree:h}=t;return o===tr?!0:h?h(p,this):P.wNAFCachedUnsafe(this,s).is0()}clearCofactor(){let{clearCofactor:h}=t;return o===tr?this:h?h(p,this):this.multiplyUnsafe(o)}toBytes(h=!0){return Ot("isCompressed",h),this.assertValidity(),f(p,this,h)}toRawBytes(h=!0){return this.toBytes(h)}toHex(h=!0){return vt(this.toBytes(h))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}p.BASE=new p(r.Gx,r.Gy,e.ONE),p.ZERO=new p(e.ZERO,e.ONE,e.ZERO),p.Fp=e,p.Fn=n;let L=n.BITS,P=xr(p,t.endo?Math.ceil(L/2):L);return p}function xi(r){return Uint8Array.of(r?2:3)}function Tf(r,t,e={}){zt(t,{hash:"function"},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let n=t.randomBytes||ze,o=t.hmac||((d,...y)=>po(t.hash,d,pt(...y))),{Fp:s,Fn:i}=r,{ORDER:a,BITS:c}=i;function l(d){let y=a>>tr;return d>y}function f(d){return l(d)?i.neg(d):d}function u(d,y){if(!i.isValidNot0(y))throw new Error(`invalid signature ${d}: out of range 1..CURVE.n`)}class x{constructor(y,w,_){u("r",y),u("s",w),this.r=y,this.s=w,_!=null&&(this.recovery=_),Object.freeze(this)}static fromCompact(y){let w=i.BYTES,_=V("compactSignature",y,w*2);return new x(i.fromBytes(_.subarray(0,w)),i.fromBytes(_.subarray(w,w*2)))}static fromDER(y){let{r:w,s:_}=Ut.toSig(V("DER",y));return new x(w,_)}assertValidity(){}addRecoveryBit(y){return new x(this.r,this.s,y)}recoverPublicKey(y){let w=s.ORDER,{r:_,s:I,recovery:T}=this;if(T==null||![0,1,2,3].includes(T))throw new Error("recovery id invalid");if(a*If<w&&T>1)throw new Error("recovery id is ambiguous for h>1 curve");let N=T===2||T===3?_+a:_;if(!s.isValid(N))throw new Error("recovery id 2 or 3 invalid");let W=s.toBytes(N),k=r.fromHex(pt(xi((T&1)===0),W)),K=i.inv(N),Z=B(V("msgHash",y)),X=i.create(-Z*K),rt=i.create(I*K),M=r.BASE.multiplyUnsafe(X).add(k.multiplyUnsafe(rt));if(M.is0())throw new Error("point at infinify");return M.assertValidity(),M}hasHighS(){return l(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,i.neg(this.s),this.recovery):this}toBytes(y){if(y==="compact")return pt(i.toBytes(this.r),i.toBytes(this.s));if(y==="der")return ge(Ut.hexFromSig(this));throw new Error("invalid format")}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return vt(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return vt(this.toBytes("compact"))}}let b=bi(i,e.allowedPrivateKeyLengths,e.wrapPrivateKey),S={isValidPrivateKey(d){try{return b(d),!0}catch{return!1}},normPrivateKeyToScalar:b,randomPrivateKey:()=>{let d=a;return Ws(n(Hn(d)),d)},precompute(d=8,y=r.BASE){return y.precompute(d,!1)}};function E(d,y=!0){return r.fromPrivateKey(d).toBytes(y)}function m(d){if(typeof d=="bigint")return!1;if(d instanceof r)return!0;let w=V("key",d).length,_=s.BYTES,I=_+1,T=2*_+1;if(!(e.allowedPrivateKeyLengths||i.BYTES===I))return w===I||w===T}function v(d,y,w=!0){if(m(d)===!0)throw new Error("first arg must be private key");if(m(y)===!1)throw new Error("second arg must be public key");return r.fromHex(y).multiply(b(d)).toBytes(w)}let D=t.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");let y=we(d),w=d.length*8-c;return w>0?y>>BigInt(w):y},B=t.bits2int_modN||function(d){return i.create(D(d))},U=Qt(c);function p(d){return Vt("num < 2^"+c,d,Je,U),i.toBytes(d)}function L(d,y,w=P){if(["recovered","canonical"].some(rt=>rt in w))throw new Error("sign() legacy options not supported");let{hash:_}=t,{lowS:I,prehash:T,extraEntropy:R}=w;I==null&&(I=!0),d=V("msgHash",d),yi(w),T&&(d=V("prehashed msgHash",_(d)));let N=B(d),W=b(y),k=[p(W),p(N)];if(R!=null&&R!==!1){let rt=R===!0?n(s.BYTES):R;k.push(V("extraEntropy",rt))}let K=pt(...k),Z=N;function X(rt){let M=D(rt);if(!i.isValidNot0(M))return;let at=i.inv(M),Te=r.BASE.multiply(M).toAffine(),ae=i.create(Te.x);if(ae===Je)return;let Gt=i.create(at*i.create(Z+ae*W));if(Gt===Je)return;let Jr=(Te.x===ae?0:2)|Number(Te.y&tr),ce=Gt;return I&&l(Gt)&&(ce=f(Gt),Jr^=1),new x(ae,ce,Jr)}return{seed:K,k2sig:X}}let P={lowS:t.lowS,prehash:!1},C={lowS:t.lowS,prehash:!1};function h(d,y,w=P){let{seed:_,k2sig:I}=L(d,y,w);return Ks(t.hash.outputLen,i.BYTES,o)(_,I)}r.BASE.precompute(8);function g(d,y,w,_=C){let I=d;y=V("msgHash",y),w=V("publicKey",w),yi(_);let{lowS:T,prehash:R,format:N}=_;if("strict"in _)throw new Error("options.strict was renamed to lowS");if(N!==void 0&&!["compact","der","js"].includes(N))throw new Error('format must be "compact", "der" or "js"');let W=typeof I=="string"||be(I),k=!W&&!N&&typeof I=="object"&&I!==null&&typeof I.r=="bigint"&&typeof I.s=="bigint";if(!W&&!k)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let K,Z;try{if(k)if(N===void 0||N==="js")K=new x(I.r,I.s);else throw new Error("invalid format");if(W){try{N!=="compact"&&(K=x.fromDER(I))}catch(ce){if(!(ce instanceof Ut.Err))throw ce}!K&&N!=="der"&&(K=x.fromCompact(I))}Z=r.fromHex(w)}catch{return!1}if(!K||T&&K.hasHighS())return!1;R&&(y=t.hash(y));let{r:X,s:rt}=K,M=B(y),at=i.inv(rt),Te=i.create(M*at),ae=i.create(X*at),Gt=r.BASE.multiplyUnsafe(Te).add(Z.multiplyUnsafe(ae));return Gt.is0()?!1:i.create(Gt.x)===X}return Object.freeze({getPublicKey:E,getSharedSecret:v,sign:h,verify:g,utils:S,Point:r,Signature:x})}function Df(r){let t={a:r.a,b:r.b,p:r.Fp.ORDER,n:r.n,h:r.h,Gx:r.Gx,Gy:r.Gy},e=r.Fp,n=wt(t.n,r.nBitLength),o={Fp:e,Fn:n,allowedPrivateKeyLengths:r.allowedPrivateKeyLengths,allowInfinityPoint:r.allowInfinityPoint,endo:r.endo,wrapPrivateKey:r.wrapPrivateKey,isTorsionFree:r.isTorsionFree,clearCofactor:r.clearCofactor,fromBytes:r.fromBytes,toBytes:r.toBytes};return{CURVE:t,curveOpts:o}}function Pf(r){let{CURVE:t,curveOpts:e}=Df(r),n={hash:r.hash,hmac:r.hmac,randomBytes:r.randomBytes,lowS:r.lowS,bits2int:r.bits2int,bits2int_modN:r.bits2int_modN};return{CURVE:t,curveOpts:e,ecdsaOpts:n}}function Lf(r,t){return Object.assign({},t,{ProjectivePoint:t.Point,CURVE:r})}function gi(r){let{CURVE:t,curveOpts:e,ecdsaOpts:n}=Pf(r),o=_f(t,e),s=Tf(o,n,e);return Lf(r,s)}function wi(r,t){let e=n=>gi({...r,hash:n});return{...e(t),create:e}}var Nr={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},kp=BigInt(0),Of=BigInt(1),yo=BigInt(2),Ei=(r,t)=>(r+t/yo)/t;function Uf(r){let t=Nr.p,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),l=r*r*r%t,f=l*l*r%t,u=z(f,e,t)*f%t,x=z(u,e,t)*f%t,b=z(x,yo,t)*l%t,S=z(b,o,t)*b%t,E=z(S,s,t)*S%t,m=z(E,a,t)*E%t,v=z(m,c,t)*m%t,D=z(v,a,t)*E%t,B=z(D,e,t)*f%t,U=z(B,i,t)*S%t,p=z(U,n,t)*l%t,L=z(p,yo,t);if(!bo.eql(bo.sqr(L),r))throw new Error("Cannot find square root");return L}var bo=wt(Nr.p,void 0,void 0,{sqrt:Uf}),Be=wi({...Nr,Fp:bo,lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Nr.n,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Of*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),a=Ei(s*r,t),c=Ei(-n*r,t),l=q(r-a*e-c*o,t),f=q(-a*n-c*s,t),u=l>i,x=f>i;if(u&&(l=t-l),x&&(f=t-f),l>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:u,k1:l,k2neg:x,k2:f}}}},Ls);function Si(r,t,e,n){let o=Re.digest(e instanceof Uint8Array?e:e.subarray());if(Ir(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),Be.verify(t,s,r))).catch(s=>{throw s.name==="AbortError"?s:new $e(String(s))});try{return n?.signal?.throwIfAborted(),Be.verify(t,o.digest,r)}catch(s){throw new $e(String(s))}}var Rr=class{type="secp256k1";raw;_key;constructor(t){this._key=Ai(t),this.raw=vi(this._key)}toMultihash(){return xt.digest(me(this))}toCID(){return Y.createV1(114,this.toMultihash())}toString(){return G.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 Si(this._key,e,t,n)}};function Ii(r){return new Rr(r)}function vi(r){return Be.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Ai(r){try{return Be.ProjectivePoint.fromHex(r),r}catch(t){throw new ir(String(t))}}function Bi(r){let{Type:t,Data:e}=Qe.decode(r.digest),n=e??new Uint8Array;switch(t){case yt.Ed25519:return ai(n);case yt.secp256k1:return Ii(n);case yt.ECDSA:return ds(n);default:throw new De}}function me(r){return Qe.encode({Type:yt[r.type],Data:r.raw})}var Ci=Symbol.for("nodejs.util.inspect.custom"),Nf=114,er=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()})`}[en]=!0;toString(){return this.string==null&&(this.string=G.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return Y.createV1(Nf,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")}[Ci](){return`PeerId(${this.toString()})`}},Kr=class extends er{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},kr=class extends er{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Mr=class extends er{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Rf=2336,rr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=xt.digest(nt(this.url))}[Ci](){return`PeerId(${this.url})`}[en]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return Y.createV1(Rf,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=H(t)),t.toString()===this.toString())}};var Kf=114,_i=2336;function Ti(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=Ue(G.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return kf(Y.parse(r));if(t==null)throw new St('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=Ue(t.decode(r))}return Di(e)}function Di(r){if(Hf(r))return new Kr({multihash:r});if(Mf(r))try{let t=Bi(r);if(t.type==="Ed25519")return new kr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Mr({multihash:r,publicKey:t})}catch{let e=H(r.digest);return new rr(new URL(e))}throw new cr("Supplied PeerID Multihash is invalid")}function kf(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==Kf&&r.code!==_i)throw new ar("Supplied PeerID CID is invalid");if(r.code===_i){let t=H(r.multihash.digest);return new rr(new URL(t))}return Di(r.multihash)}function Mf(r){return r.code===xt.code}function Hf(r){return r.code===Re.code}var et=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},Nt=class extends Error{static name="ValidationError";name="ValidationError"},nr=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Hr=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var Vr=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*o)-1;for(;;){let f=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let x=Number.parseInt(u,t);if(!Number.isNaN(x))return x});if(f===void 0)break;if(s*=t,s+=f,s>l||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[o]=i[0],e[o+1]=i[1],e[o+2]=i[2],e[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=t(s.subarray(0,i));return e.set(s.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Vf=45,zf=15,zr=new Vr;function xo(r){if(!(r.length>zf))return zr.new(r).parseWith(()=>zr.readIPv4Addr())}function go(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Vf))return zr.new(r).parseWith(()=>zr.readIPv6Addr())}function qr(r){return!!xo(r)}function Li(r){return!!go(r)}function Eo(r){return t=>H(t,r)}function So(r){return t=>nt(t,r)}function Ce(r){return new DataView(r.buffer).getUint16(r.byteOffset).toString()}function ne(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof r=="string"?parseInt(r):r),new Uint8Array(t)}function Oi(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=nt(t[0],"base32"),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ne(n);return Tt([e,o],e.length+o.length)}function Ui(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Kt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ne(n);return Tt([e,o],e.length+o.length)}function vo(r){let t=r.subarray(0,r.length-2),e=r.subarray(r.length-2),n=H(t,"base32"),o=Ce(e);return`${n}:${o}`}var Ao=function(r){r=r.toString().trim();let t=new Uint8Array(4);return r.split(/\./g).forEach((e,n)=>{let o=parseInt(e,10);if(isNaN(o)||o<0||o>255)throw new et("Invalid byte value in IP address");t[n]=o}),t},Ni=function(r){let t=0;r=r.toString().trim();let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=qr(e[n]),i;s&&(i=Ao(e[n]),e[n]=H(i.subarray(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,H(i.subarray(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){e[n]===""&&(e[n]="0");let s=parseInt(e[n],16);if(isNaN(s)||s<0||s>65535)throw new et("Invalid byte value in IP address");o[t++]=s>>8&255,o[t++]=s&255}return o},Ri=function(r){if(r.byteLength!==4)throw new et("IPv4 address was incorrect length");let t=[];for(let e=0;e<r.byteLength;e++)t.push(r[e]);return t.join(".")},Ki=function(r){if(r.byteLength!==16)throw new et("IPv6 address was incorrect length");let t=[];for(let n=0;n<r.byteLength;n+=2){let o=r[n],s=r[n+1],i=`${o.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`;t.push(i)}let e=t.join(":");try{let n=new URL(`http://[${e}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new et(`Invalid IPv6 address "${e}"`)}};function ki(r){try{let t=new URL(`http://[${r}]`);return t.hostname.substring(1,t.hostname.length-1)}catch{throw new et(`Invalid IPv6 address "${r}"`)}}var wo=Object.values(Ke).map(r=>r.decoder),qf=function(){let r=wo[0].or(wo[1]);return wo.slice(2).forEach(t=>r=r.or(t)),r}();function Mi(r){return qf.decode(r)}function Hi(r){return t=>r.encoder.encode(t)}function Ff(r){if(parseInt(r).toString()!==r)throw new Nt("Value must be an integer")}function jf(r){if(r<0)throw new Nt("Value must be a positive integer, or zero")}function Gf(r){return t=>{if(t>r)throw new Nt(`Value must be smaller than or equal to ${r}`)}}function Wf(...r){return t=>{for(let e of r)e(t)}}var or=Wf(Ff,jf,Gf(65535));var J=-1,Io=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(t){let e;if(typeof t=="string"?e=this.protocolsByName.get(t):e=this.protocolsByCode.get(t),e==null)throw new Hr(`Protocol ${t} was unknown`);return e}addProtocol(t){this.protocolsByCode.set(t.code,t),this.protocolsByName.set(t.name,t),t.aliases?.forEach(e=>{this.protocolsByName.set(e,t)})}removeProtocol(t){let e=this.protocolsByCode.get(t);e!=null&&(this.protocolsByCode.delete(e.code),this.protocolsByName.delete(e.name),e.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},bt=new Io,vu=[{code:4,name:"ip4",size:32,valueToBytes:Ao,bytesToValue:Ri,validate:r=>{if(!qr(r))throw new Nt(`Invalid IPv4 address "${r}"`)}},{code:6,name:"tcp",size:16,valueToBytes:ne,bytesToValue:Ce,validate:or},{code:273,name:"udp",size:16,valueToBytes:ne,bytesToValue:Ce,validate:or},{code:33,name:"dccp",size:16,valueToBytes:ne,bytesToValue:Ce,validate:or},{code:41,name:"ip6",size:128,valueToBytes:Ni,bytesToValue:Ki,stringToValue:ki,validate:r=>{if(!Li(r))throw new Nt(`Invalid IPv6 address "${r}"`)}},{code:42,name:"ip6zone",size:J},{code:43,name:"ipcidr",size:8,bytesToValue:Eo("base10"),valueToBytes:So("base10")},{code:53,name:"dns",size:J,resolvable:!0},{code:54,name:"dns4",size:J,resolvable:!0},{code:55,name:"dns6",size:J,resolvable:!0},{code:56,name:"dnsaddr",size:J,resolvable:!0},{code:132,name:"sctp",size:16,valueToBytes:ne,bytesToValue:Ce,validate:or},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:J,path:!0,stringToValue:r=>decodeURIComponent(r),valueToString:r=>encodeURIComponent(r)},{code:421,name:"p2p",aliases:["ipfs"],size:J,bytesToValue:Eo("base58btc"),valueToBytes:r=>r.startsWith("Q")||r.startsWith("1")?So("base58btc")(r):Y.parse(r).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:vo,valueToBytes:Oi},{code:445,name:"onion3",size:296,bytesToValue:vo,valueToBytes:Ui},{code:446,name:"garlic64",size:J},{code:447,name:"garlic32",size:J},{code:448,name:"tls"},{code:449,name:"sni",size:J},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:J,bytesToValue:Hi(bn),valueToBytes:Mi},{code:480,name:"http"},{code:481,name:"http-path",size:J,stringToValue:r=>`/${decodeURIComponent(r)}`,valueToString:r=>encodeURIComponent(r.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:J}];vu.forEach(r=>{bt.addProtocol(r)});function Vi(r){let t=[],e=0;for(;e<r.length;){let n=Qn(r,e),o=bt.getProtocol(n),s=Bt(n),i=Au(o,r,e+s),a=0;i>0&&o.size===J&&(a=Bt(i));let c=s+a+i,l={code:n,name:o.name,bytes:r.subarray(e,e+c)};if(i>0){let f=e+s+a,u=r.subarray(f,f+i);l.value=o.bytesToValue?.(u)??H(u)}t.push(l),e+=c}return t}function zi(r){let t=0,e=[];for(let n of r){if(n.bytes==null){let o=bt.getProtocol(n.code),s=Bt(n.code),i,a=0,c=0;n.value!=null&&(i=o.valueToBytes?.(n.value)??nt(n.value),a=i.byteLength,o.size===J&&(c=Bt(a)));let l=new Uint8Array(s+c+a),f=0;Ze(n.code,l,f),f+=s,i!=null&&(o.size===J&&(Ze(a,l,f),f+=c),l.set(i,f)),n.bytes=l}e.push(n.bytes),t+=n.bytes.byteLength}return Tt(e,t)}function qi(r){if(r.charAt(0)!=="/")throw new et('String multiaddr must start with "/"');let t=[],e="protocol",n="",o="";for(let s=1;s<r.length;s++){let i=r.charAt(s);i!=="/"&&(e==="protocol"?o+=r.charAt(s):n+=r.charAt(s));let a=s===r.length-1;if(i==="/"||a){let c=bt.getProtocol(o);if(e==="protocol"){if(c.size==null||c.size===0){t.push({code:c.code,name:c.name}),n="",o="",e="protocol";continue}else if(a)throw new et(`Component ${o} was missing value`);e="value"}else if(e==="value"){let l={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new et(`Component ${o} was missing value`);l.value=c.stringToValue?.(n)??n}t.push(l),n="",o="",e="protocol"}}}if(o!==""&&n!=="")throw new et("Incomplete multiaddr");return t}function Fi(r){return`/${r.flatMap(t=>{if(t.value==null)return t.name;let e=bt.getProtocol(t.code);if(e==null)throw new et(`Unknown protocol code ${t.code}`);return[t.name,e.valueToString?.(t.value)??t.value]}).join("/")}`}function Au(r,t,e){return r.size==null||r.size===0?0:r.size>0?r.size/8:Qn(t,e)}var Iu=Symbol.for("nodejs.util.inspect.custom"),Oo=Symbol.for("@multiformats/multiaddr"),Bu=[53,54,55,56],Lo=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}};function Cu(r){if(r==null&&(r="/"),Gi(r))return r.getComponents();if(r instanceof Uint8Array)return Vi(r);if(typeof r=="string")return r=r.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),r===""&&(r="/"),qi(r);if(Array.isArray(r))return r;throw new et("Must be a string, Uint8Array, Component[], or another Multiaddr")}var $r=class r{[Oo]=!0;#t;#e;#r;constructor(t="/",e={}){this.#t=Cu(t),e.validate!==!1&&_u(this)}get bytes(){return this.#r==null&&(this.#r=zi(this.#t)),this.#r}toString(){return this.#e==null&&(this.#e=Fi(this.#t)),this.#e}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="";for(let{code:a,name:c,value:l}of this.#t)a===42&&(s=`%${l??""}`),Bu.includes(a)&&(e="tcp",o=443,n=`${l??""}${s}`,t=a===55?6:4),(a===6||a===273)&&(e=c==="tcp"?"tcp":"udp",o=parseInt(l??"")),(a===4||a===41)&&(e="tcp",n=`${l??""}${s}`,t=a===41?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}getComponents(){return[...this.#t]}protos(){return this.#t.map(({code:t,value:e})=>{let n=bt.getProtocol(t);return{code:t,size:n.size??0,name:n.name,resolvable:!!n.resolvable,path:!!n.path}})}protoCodes(){return this.#t.map(({code:t})=>t)}protoNames(){return this.#t.map(({name:t})=>t)}tuples(){return this.#t.map(({code:t,value:e})=>{if(e==null)return[t];let n=bt.getProtocol(t),o=[t];return e!=null&&o.push(n.valueToBytes?.(e)??nt(e)),o})}stringTuples(){return this.#t.map(({code:t,value:e})=>e==null?[t]:[t,e])}encapsulate(t){let e=new r(t);return new r([...this.#t,...e.getComponents()],{validate:!1})}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new nr(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o),{validate:!1})}decapsulateCode(t){let e;for(let n=this.#t.length-1;n>-1;n--)if(this.#t[n].code===t){e=n;break}return new r(this.#t.slice(0,e),{validate:!1})}getPeerId(){try{let t=[];this.#t.forEach(({code:n,value:o})=>{n===421&&t.push([n,o]),n===290&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?H(G.decode(`z${n}`),"base58btc"):H(Y.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){for(let t of this.#t)if(bt.getProtocol(t.code).path)return t.value??null;return null}equals(t){return lt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=ji.get(e.name);if(n==null)throw new Lo(`no available resolver for ${e.name}`);return(await n(this,t)).map(s=>Ft(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(){return!(this.#t.length!==2||this.#t[0].code!==4&&this.#t[0].code!==41||this.#t[1].code!==6&&this.#t[1].code!==273)}[Iu](){return`Multiaddr(${this.toString()})`}};function _u(r){r.getComponents().forEach(t=>{let e=bt.getProtocol(t.code);t.value!=null&&e.validate?.(t.value)})}var Om=parseInt("0xFFFF",16),Um=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var ji=new Map;function Gi(r){return!!r?.[Oo]}function Ft(r){return new $r(r)}var Ou=A("dns4"),Uu=A("dns6"),Nu=A("dnsaddr"),se=$(A("dns"),Nu,Ou,Uu),Xr=$(A("ip4"),A("ip6")),_e=$(O(Xr,A("tcp")),O(se,A("tcp"))),Qr=O(Xr,A("udp")),Ru=O(Qr,A("utp")),Ku=O(Qr,A("quic")),ku=O(Qr,A("quic-v1")),Uo=$(O(_e,A("ws")),O(se,A("ws"))),Zr=$(O(Uo,A("p2p")),Uo),No=$(O(_e,A("wss")),O(se,A("wss")),O(_e,A("tls"),A("ws")),O(se,A("tls"),A("ws"))),Yr=$(O(No,A("p2p")),No),Ro=$(O(_e,A("http")),O(Xr,A("http")),O(se,A("http"))),Ko=$(O(_e,A("https")),O(Xr,A("https")),O(se,A("https"))),Zi=O(Qr,A("webrtc-direct"),A("certhash")),Qi=$(O(Zi,A("p2p")),Zi),Yi=O(ku,A("webtransport"),A("certhash"),A("certhash")),Ji=$(O(Yi,A("p2p")),Yi),ta=$(O(Zr,A("p2p-webrtc-star"),A("p2p")),O(Yr,A("p2p-webrtc-star"),A("p2p")),O(Zr,A("p2p-webrtc-star")),O(Yr,A("p2p-webrtc-star"))),wy=$(O(Zr,A("p2p-websocket-star"),A("p2p")),O(Yr,A("p2p-websocket-star"),A("p2p")),O(Zr,A("p2p-websocket-star")),O(Yr,A("p2p-websocket-star"))),ea=$(O(Ro,A("p2p-webrtc-direct"),A("p2p")),O(Ko,A("p2p-webrtc-direct"),A("p2p")),O(Ro,A("p2p-webrtc-direct")),O(Ko,A("p2p-webrtc-direct"))),ie=$(Uo,No,Ro,Ko,ta,ea,_e,Ru,Ku,se,Qi,Ji),Ey=$(O(ie,A("p2p-stardust"),A("p2p")),O(ie,A("p2p-stardust"))),jt=$(O(ie,A("p2p")),ta,ea,Qi,Ji,A("p2p")),Xi=$(O(jt,A("p2p-circuit"),jt),O(jt,A("p2p-circuit")),O(A("p2p-circuit"),jt),O(ie,A("p2p-circuit")),O(A("p2p-circuit"),ie),A("p2p-circuit")),ra=()=>$(O(Xi,ra),Xi),oe=ra(),na=$(O(oe,jt,oe),O(jt,oe),O(oe,jt),oe,jt);var Sy=$(O(oe,A("webrtc"),A("p2p")),O(oe,A("webrtc")),O(ie,A("webrtc"),A("p2p")),O(ie,A("webrtc")),A("webrtc"));function oa(r){function t(e){let n;try{n=Ft(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function O(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(o=>(n=typeof o=="function"?o().partialMatch(e):o.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:oa(t),partialMatch:t}}function $(...r){function t(n){let o=null;return r.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:oa(t),partialMatch:t}}function A(r){let t=r;function e(o){let s;try{s=Ft(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var Mu="bootstrap",Hu=50,Vu=1e3,ko=class extends fr{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(t,e={list:[]}){if(e.list==null||e.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super(),this.components=t,this.log=t.logger.forComponent("libp2p:bootstrap"),this.timeout=e.timeout??Vu,this.list=[];for(let n of e.list){if(!na.matches(n)){this.log.error("Invalid multiaddr");continue}let o=Ft(n),s=o.getPeerId();if(s==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let i={id:Ti(s),multiaddrs:[o]};this.list.push(i)}this._init=e}[Mo]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[Ho]=["@libp2p/peer-discovery"];isStarted(){return!!this.timer}start(){this.isStarted()||(this.log("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(t=>{this.log.error(t)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(let t of this.list){if(await this.components.peerStore.merge(t.id,{tags:{[this._init.tagName??Mu]:{value:this._init.tagValue??Hu,ttl:this._init.tagTTL}},multiaddrs:t.multiaddrs}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t}),this.components.connectionManager.openConnection(t.id).catch(e=>{this.log.error("could not dial bootstrap peer %p",t.id,e)})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function zu(r){return t=>new ko(t,r)}return fa(qu);})();
2
+ "use strict";var Libp2PBootstrap=(()=>{var tn=Object.defineProperty;var sa=Object.getOwnPropertyDescriptor;var ia=Object.getOwnPropertyNames;var aa=Object.prototype.hasOwnProperty;var ut=(r,t)=>{for(var e in t)tn(r,e,{get:t[e],enumerable:!0})},ca=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ia(t))!aa.call(r,o)&&o!==e&&tn(r,o,{get:()=>t[o],enumerable:!(n=sa(t,o))||n.enumerable});return r};var fa=r=>ca(tn({},"__esModule",{value:!0}),r);var qu={};ut(qu,{bootstrap:()=>zu});var Mo=Symbol.for("@libp2p/peer-discovery");var en=Symbol.for("@libp2p/peer-id");var St=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},ir=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var ar=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},cr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var De=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var fr=class extends EventTarget{#t=new Map;constructor(){super()}listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e={}){return this.dispatchEvent(new CustomEvent(t,e))}};var Ho=Symbol.for("@libp2p/service-capabilities"),Zu=Symbol.for("@libp2p/service-dependencies");var an={};ut(an,{base58btc:()=>G,base58flickr:()=>ya});var bl=new Uint8Array(0);function Vo(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 Ct(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 zo(r){return new TextEncoder().encode(r)}function qo(r){return new TextDecoder().decode(r)}function ua(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),l=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function u(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 E=0,m=0,v=0,D=S.length;v!==D&&S[v]===0;)v++,E++;for(var B=(D-v)*f+1>>>0,U=new Uint8Array(B);v!==D;){for(var p=S[v],L=0,P=B-1;(p!==0||L<m)&&P!==-1;P--,L++)p+=256*U[P]>>>0,U[P]=p%a>>>0,p=p/a>>>0;if(p!==0)throw new Error("Non-zero carry");m=L,v++}for(var C=B-m;C!==B&&U[C]===0;)C++;for(var h=c.repeat(E);C<B;++C)h+=r.charAt(U[C]);return h}function x(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var E=0;if(S[E]!==" "){for(var m=0,v=0;S[E]===c;)m++,E++;for(var D=(S.length-E)*l+1>>>0,B=new Uint8Array(D);S[E];){var U=e[S.charCodeAt(E)];if(U===255)return;for(var p=0,L=D-1;(U!==0||p<v)&&L!==-1;L--,p++)U+=a*B[L]>>>0,B[L]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");v=p,E++}if(S[E]!==" "){for(var P=D-v;P!==D&&B[P]===0;)P++;for(var C=new Uint8Array(m+(D-P)),h=m;P!==D;)C[h++]=B[P++];return C}}}function b(S){var E=x(S);if(E)return E;throw new Error(`Non-${t} character`)}return{encode:u,decodeUnsafe:x,decode:b}}var la=ua,ha=la,jo=ha;var rn=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")}},nn=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 Go(this,t)}},on=class{decoders;constructor(t){this.decoders=t}or(t){return Go(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 Go(r,t){return new on({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var sn=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 rn(t,e,n),this.decoder=new nn(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function fe({name:r,prefix:t,encode:e,decode:n}){return new sn(r,t,e,n)}function Rt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=jo(e,r);return fe({prefix:t,name:r,encode:n,decode:s=>Ct(o(s))})}function da(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 l=0;l<o;++l){let f=t[r[l]];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 pa(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 ma(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function j({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=ma(n);return fe({prefix:t,name:r,encode(s){return pa(s,n,e)},decode(s){return da(s,o,e,r)}})}var G=Rt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ya=Rt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var cn={};ut(cn,{base32:()=>Kt,base32hex:()=>wa,base32hexpad:()=>Sa,base32hexpadupper:()=>va,base32hexupper:()=>Ea,base32pad:()=>xa,base32padupper:()=>ga,base32upper:()=>ba,base32z:()=>Aa});var Kt=j({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ba=j({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),xa=j({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ga=j({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),wa=j({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ea=j({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Sa=j({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),va=j({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Aa=j({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var fn={};ut(fn,{base36:()=>Pe,base36upper:()=>Ia});var Pe=Rt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ia=Rt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ba=Zo,Wo=128,Ca=127,_a=~Ca,Ta=Math.pow(2,31);function Zo(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Ta;)t[e++]=r&255|Wo,r/=128;for(;r&_a;)t[e++]=r&255|Wo,r>>>=7;return t[e]=r|0,Zo.bytes=e-n+1,t}var Da=un,Pa=128,$o=127;function un(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw un.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&$o)<<o:(i&$o)*Math.pow(2,o),o+=7}while(i>=Pa);return un.bytes=s-n,e}var La=Math.pow(2,7),Oa=Math.pow(2,14),Ua=Math.pow(2,21),Na=Math.pow(2,28),Ra=Math.pow(2,35),Ka=Math.pow(2,42),ka=Math.pow(2,49),Ma=Math.pow(2,56),Ha=Math.pow(2,63),Va=function(r){return r<La?1:r<Oa?2:r<Ua?3:r<Na?4:r<Ra?5:r<Ka?6:r<ka?7:r<Ma?8:r<Ha?9:10},za={encode:Ba,decode:Da,encodingLength:Va},qa=za,Le=qa;function Oe(r,t=0){return[Le.decode(r,t),Le.decode.bytes]}function ue(r,t,e=0){return Le.encode(r,t,e),t}function le(r){return Le.encodingLength(r)}function Wt(r,t){let e=t.byteLength,n=le(r),o=n+le(e),s=new Uint8Array(o+e);return ue(r,s,0),ue(e,s,n),s.set(t,o),new he(r,e,t,s)}function Ue(r){let t=Ct(r),[e,n]=Oe(t),[o,s]=Oe(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new he(e,o,i,t)}function Yo(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Vo(r.bytes,e.bytes)}}var he=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Xo(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return ja(e,ln(r),t??G.encoder);default:return Ga(e,ln(r),t??Kt.encoder)}}var Qo=new WeakMap;function ln(r){let t=Qo.get(r);if(t==null){let e=new Map;return Qo.set(r,e),e}return t}var Y=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!==Ne)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Wa)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=Wt(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&&Yo(t.multihash,n.multihash)}toString(t){return Xo(this,t)}toJSON(){return{"/":Xo(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??Jo(n,o,s.bytes))}else if(e[$a]===!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!==Ne)throw new Error(`Version 0 CID must use dag-pb (code: ${Ne}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Jo(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Ne,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=Ct(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 he(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[u,x]=Oe(t.subarray(e));return e+=x,u},o=n(),s=Ne;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(),l=e+c,f=l-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:f,size:l}}static parse(t,e){let[n,o]=Fa(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 ln(s).set(n,t),s}};function Fa(r,t){switch(r[0]){case"Q":{let e=t??G;return[G.prefix,e.decode(`${G.prefix}${r}`)]}case G.prefix:{let e=t??G;return[G.prefix,e.decode(r)]}case Kt.prefix:{let e=t??Kt;return[Kt.prefix,e.decode(r)]}case Pe.prefix:{let e=t??Pe;return[Pe.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 ja(r,t,e){let{prefix:n}=e;if(n!==G.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 Ga(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 Ne=112,Wa=18;function Jo(r,t,e){let n=le(r),o=n+le(t),s=new Uint8Array(o+e.byteLength);return ue(r,s,0),ue(t,s,n),s.set(e,o),s}var $a=Symbol.for("@ipld/js-cid/CID");var hn={};ut(hn,{identity:()=>xt});var ts=0,Za="identity",es=Ct;function Ya(r){return Wt(ts,es(r))}var xt={code:ts,name:Za,encode:es,digest:Ya};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 _t(r=0){return new Uint8Array(r)}function ht(r=0){return new Uint8Array(r)}function Tt(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=ht(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var ns=Symbol.for("@achingbrain/uint8arraylist");function rs(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 lr(r){return!!r?.[ns]}var dt=class r{bufs;length;[ns]=!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(lr(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(lr(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=rs(this.bufs,t);return e.buf[e.index]}set(t,e){let n=rs(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(lr(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 Tt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Tt(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 l=t>=a&&t<c,f=e>a&&e<=c;if(l&&f){if(t===a&&e===c){n.push(i);break}let u=t-a;n.push(i.subarray(u,u+(e-t)));break}if(l){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(!lr(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 u=0;u<s;u++)i[u]=-1;for(let u=0;u<o;u++)i[n[u]]=u;let a=i,c=this.byteLength-n.byteLength,l=n.byteLength-1,f;for(let u=e;u<=c;u+=f){f=0;for(let x=l;x>=0;x--){let b=this.get(u+x);if(n[x]!==b){f=Math.max(1,x-a[b]);break}}if(f===0)return u}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=ht(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=_t(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=_t(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=_t(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=ht(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=_t(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=_t(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=_t(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=_t(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=_t(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 dn={};ut(dn,{base10:()=>Xa});var Xa=Rt({prefix:"9",name:"base10",alphabet:"0123456789"});var pn={};ut(pn,{base16:()=>Qa,base16upper:()=>Ja});var Qa=j({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ja=j({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var mn={};ut(mn,{base2:()=>tc});var tc=j({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var yn={};ut(yn,{base256emoji:()=>sc});var os=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}"),ec=os.reduce((r,t,e)=>(r[e]=t,r),[]),rc=os.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function nc(r){return r.reduce((t,e)=>(t+=ec[e],t),"")}function oc(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=rc[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var sc=fe({prefix:"\u{1F680}",name:"base256emoji",encode:nc,decode:oc});var xn={};ut(xn,{base64:()=>ic,base64pad:()=>ac,base64url:()=>bn,base64urlpad:()=>cc});var ic=j({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ac=j({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),bn=j({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),cc=j({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var gn={};ut(gn,{base8:()=>fc});var fc=j({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var wn={};ut(wn,{identity:()=>uc});var uc=fe({prefix:"\0",name:"identity",encode:r=>qo(r),decode:r=>zo(r)});var th=new TextEncoder,eh=new TextDecoder;var vn={};ut(vn,{sha256:()=>Re,sha512:()=>dc});function Sn({name:r,code:t,encode:e}){return new En(r,t,e)}var En=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?Wt(this.code,e):e.then(n=>Wt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function is(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Re=Sn({name:"sha2-256",code:18,encode:is("SHA-256")}),dc=Sn({name:"sha2-512",code:19,encode:is("SHA-512")});var Ke={...wn,...mn,...gn,...dn,...pn,...cn,...fn,...an,...xn,...yn},dh={...vn,...hn};function cs(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var as=cs("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),An=cs("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=ht(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),pc={utf8:as,"utf-8":as,hex:Ke.base16,latin1:An,ascii:An,binary:An,...Ke},hr=pc;function nt(r,t="utf8"){let e=hr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function H(r,t="utf8"){let e=hr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var mc=parseInt("11111",2),In=parseInt("10000000",2),yc=parseInt("01111111",2),fs={0:ke,1:ke,2:bc,3:wc,4:Ec,5:gc,6:xc,16:ke,22:ke,48:ke};function Bn(r,t={offset:0}){let e=r[t.offset]&mc;if(t.offset++,fs[e]!=null)return fs[e](r,t);throw new Error("No decoder for tag "+e)}function Me(r,t){let e=0;if((r[t.offset]&In)===In){let n=r[t.offset]&yc,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 ke(r,t){Me(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=Bn(r,t);if(n===null)break;e.push(n)}return e}function bc(r,t){let e=Me(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 xc(r,t){let e=Me(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 l=r[t.offset];if(t.offset++,c.push(l&127),l<128){c.reverse();let f=0;for(let u=0;u<c.length;u++)f+=c[u]<<u*7;a+=`.${f}`,c=[]}}return a}function gc(r,t){return t.offset++,null}function wc(r,t){let e=Me(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 Ec(r,t){let e=Me(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function Sc(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new dt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function Cn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=Sc(r.byteLength);return new dt(Uint8Array.from([t.byteLength|In]),t)}function us(r){let t=new dt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new dt(Uint8Array.from([2]),Cn(t),t)}function ls(r){let t=Uint8Array.from([0]),e=new dt(t,r);return new dt(Uint8Array.from([3]),Cn(e),e)}function dr(r,t=48){let e=new dt;for(let n of r)e.append(n);return new dt(Uint8Array.from([t]),Cn(e),e)}async function hs(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 vc=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Ac=Uint8Array.from([6,5,43,129,4,0,34]),Ic=Uint8Array.from([6,5,43,129,4,0,35]),Bc={ext:!0,kty:"EC",crv:"P-256"},Cc={ext:!0,kty:"EC",crv:"P-384"},_c={ext:!0,kty:"EC",crv:"P-521"},_n=32,Tn=48,Dn=66;function ds(r){let t=Bn(r);return ps(t)}function ps(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===_n*2+1)return n=H(t.subarray(e,e+_n),"base64url"),o=H(t.subarray(e+_n),"base64url"),new pe({...Bc,key_ops:["verify"],x:n,y:o});if(t.byteLength===Tn*2+1)return n=H(t.subarray(e,e+Tn),"base64url"),o=H(t.subarray(e+Tn),"base64url"),new pe({...Cc,key_ops:["verify"],x:n,y:o});if(t.byteLength===Dn*2+1)return n=H(t.subarray(e,e+Dn),"base64url"),o=H(t.subarray(e+Dn),"base64url"),new pe({..._c,key_ops:["verify"],x:n,y:o});throw new St(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function ms(r){return dr([us(Uint8Array.from([1])),dr([Tc(r.crv)],160),dr([ls(new dt(Uint8Array.from([4]),nt(r.x??"","base64url"),nt(r.y??"","base64url")))],161)]).subarray()}function Tc(r){if(r==="P-256")return vc;if(r==="P-384")return Ac;if(r==="P-521")return Ic;throw new St(`Invalid curve ${r}`)}var pe=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=ms(this.jwk)),this._raw}toMultihash(){return xt.digest(me(this))}toCID(){return Y.createV1(114,this.toMultihash())}toString(){return G.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 hs(this.jwk,e,t,n)}};var $t=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function be(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function He(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function ot(r,...t){if(!be(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 bs(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");He(r.outputLen),He(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 xs(r,t){ot(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function Pt(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function pr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function gt(r,t){return r<<32-t|r>>>t}var gs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Dc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function vt(r){if(ot(r),gs)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=Dc[r[e]];return t}var Dt={_0:48,_9:57,A:65,F:70,a:97,f:102};function ys(r){if(r>=Dt._0&&r<=Dt._9)return r-Dt._0;if(r>=Dt.A&&r<=Dt.F)return r-(Dt.A-10);if(r>=Dt.a&&r<=Dt.f)return r-(Dt.a-10)}function ge(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(gs)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=ys(r.charCodeAt(s)),a=ys(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 ws(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function Ve(r){return typeof r=="string"&&(r=ws(r)),ot(r),r}function pt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];ot(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 Pn(r){let t=n=>r().update(Ve(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function ze(r=32){if($t&&typeof $t.getRandomValues=="function")return $t.getRandomValues(new Uint8Array(r));if($t&&typeof $t.randomBytes=="function")return Uint8Array.from($t.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function Pc(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,l=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+l,a,n)}function Es(r,t,e){return r&t^~r&e}function Ss(r,t,e){return r&t^r&e^t&e}var qe=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=pr(this.buffer)}update(t){xe(this),t=Ve(t),ot(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=pr(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),xs(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,Pt(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let u=i;u<o;u++)e[u]=0;Pc(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=pr(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,f[u],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()}},Lt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var J=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var mr=BigInt(4294967295),vs=BigInt(32);function Lc(r,t=!1){return t?{h:Number(r&mr),l:Number(r>>vs&mr)}:{h:Number(r>>vs&mr)|0,l:Number(r&mr)|0}}function As(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}=Lc(r[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var Ln=(r,t,e)=>r>>>e,On=(r,t,e)=>r<<32-e|t>>>e,Zt=(r,t,e)=>r>>>e|t<<32-e,Yt=(r,t,e)=>r<<32-e|t>>>e,Fe=(r,t,e)=>r<<64-e|t>>>e-32,je=(r,t,e)=>r>>>e-32|t<<64-e;function At(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var Is=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Bs=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Cs=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),_s=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Ts=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Ds=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Uc=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]),kt=new Uint32Array(64),Un=class extends qe{constructor(t=32){super(64,t,8,!1),this.A=Lt[0]|0,this.B=Lt[1]|0,this.C=Lt[2]|0,this.D=Lt[3]|0,this.E=Lt[4]|0,this.F=Lt[5]|0,this.G=Lt[6]|0,this.H=Lt[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 u=0;u<16;u++,e+=4)kt[u]=t.getUint32(e,!1);for(let u=16;u<64;u++){let x=kt[u-15],b=kt[u-2],S=gt(x,7)^gt(x,18)^x>>>3,E=gt(b,17)^gt(b,19)^b>>>10;kt[u]=E+kt[u-7]+S+kt[u-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:l,H:f}=this;for(let u=0;u<64;u++){let x=gt(a,6)^gt(a,11)^gt(a,25),b=f+x+Es(a,c,l)+Uc[u]+kt[u]|0,E=(gt(n,2)^gt(n,13)^gt(n,22))+Ss(n,o,s)|0;f=l,l=c,c=a,a=i+b|0,i=s,s=o,o=n,n=b+E|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,l=l+this.G|0,f=f+this.H|0,this.set(n,o,s,i,a,c,l,f)}roundClean(){Pt(kt)}destroy(){this.set(0,0,0,0,0,0,0,0),Pt(this.buffer)}};var Ps=As(["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))),Nc=Ps[0],Rc=Ps[1],Mt=new Uint32Array(80),Ht=new Uint32Array(80),Nn=class extends qe{constructor(t=64){super(128,t,16,!1),this.Ah=J[0]|0,this.Al=J[1]|0,this.Bh=J[2]|0,this.Bl=J[3]|0,this.Ch=J[4]|0,this.Cl=J[5]|0,this.Dh=J[6]|0,this.Dl=J[7]|0,this.Eh=J[8]|0,this.El=J[9]|0,this.Fh=J[10]|0,this.Fl=J[11]|0,this.Gh=J[12]|0,this.Gl=J[13]|0,this.Hh=J[14]|0,this.Hl=J[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:l,El:f,Fh:u,Fl:x,Gh:b,Gl:S,Hh:E,Hl:m}=this;return[t,e,n,o,s,i,a,c,l,f,u,x,b,S,E,m]}set(t,e,n,o,s,i,a,c,l,f,u,x,b,S,E,m){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=l|0,this.El=f|0,this.Fh=u|0,this.Fl=x|0,this.Gh=b|0,this.Gl=S|0,this.Hh=E|0,this.Hl=m|0}process(t,e){for(let B=0;B<16;B++,e+=4)Mt[B]=t.getUint32(e),Ht[B]=t.getUint32(e+=4);for(let B=16;B<80;B++){let U=Mt[B-15]|0,p=Ht[B-15]|0,L=Zt(U,p,1)^Zt(U,p,8)^Ln(U,p,7),P=Yt(U,p,1)^Yt(U,p,8)^On(U,p,7),C=Mt[B-2]|0,h=Ht[B-2]|0,g=Zt(C,h,19)^Fe(C,h,61)^Ln(C,h,6),d=Yt(C,h,19)^je(C,h,61)^On(C,h,6),y=Cs(P,d,Ht[B-7],Ht[B-16]),w=_s(y,L,g,Mt[B-7],Mt[B-16]);Mt[B]=w|0,Ht[B]=y|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:l,Dl:f,Eh:u,El:x,Fh:b,Fl:S,Gh:E,Gl:m,Hh:v,Hl:D}=this;for(let B=0;B<80;B++){let U=Zt(u,x,14)^Zt(u,x,18)^Fe(u,x,41),p=Yt(u,x,14)^Yt(u,x,18)^je(u,x,41),L=u&b^~u&E,P=x&S^~x&m,C=Ts(D,p,P,Rc[B],Ht[B]),h=Ds(C,v,U,L,Nc[B],Mt[B]),g=C|0,d=Zt(n,o,28)^Fe(n,o,34)^Fe(n,o,39),y=Yt(n,o,28)^je(n,o,34)^je(n,o,39),w=n&s^n&a^s&a,_=o&i^o&c^i&c;v=E|0,D=m|0,E=b|0,m=S|0,b=u|0,S=x|0,{h:u,l:x}=At(l|0,f|0,h|0,g|0),l=a|0,f=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let I=Is(g,y,_);n=Bs(I,h,d,w),o=I|0}({h:n,l:o}=At(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=At(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=At(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:f}=At(this.Dh|0,this.Dl|0,l|0,f|0),{h:u,l:x}=At(this.Eh|0,this.El|0,u|0,x|0),{h:b,l:S}=At(this.Fh|0,this.Fl|0,b|0,S|0),{h:E,l:m}=At(this.Gh|0,this.Gl|0,E|0,m|0),{h:v,l:D}=At(this.Hh|0,this.Hl|0,v|0,D|0),this.set(n,o,s,i,a,c,l,f,u,x,b,S,E,m,v,D)}roundClean(){Pt(Mt,Ht)}destroy(){Pt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Ls=Pn(()=>new Un);var Os=Pn(()=>new Nn);var kn=BigInt(0),Kn=BigInt(1);function Ot(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function Ge(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Us(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?kn:BigInt("0x"+r)}function we(r){return Us(vt(r))}function Xt(r){return ot(r),Us(vt(Uint8Array.from(r).reverse()))}function yr(r,t){return ge(r.toString(16).padStart(t*2,"0"))}function Ee(r,t){return yr(r,t).reverse()}function V(r,t,e){let n;if(typeof t=="string")try{n=ge(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(be(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}var Rn=r=>typeof r=="bigint"&&kn<=r;function Ns(r,t,e){return Rn(r)&&Rn(t)&&Rn(e)&&t<=r&&r<e}function Vt(r,t,e,n){if(!Ns(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Rs(r){let t;for(t=0;r>kn;r>>=Kn,t+=1);return t}var Qt=r=>(Kn<<BigInt(r))-Kn;function Ks(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=b=>new Uint8Array(b),o=b=>Uint8Array.of(b),s=n(r),i=n(r),a=0,c=()=>{s.fill(1),i.fill(0),a=0},l=(...b)=>e(i,s,...b),f=(b=n(0))=>{i=l(o(0),b),s=l(),b.length!==0&&(i=l(o(1),b),s=l())},u=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let b=0,S=[];for(;b<t;){s=l();let E=s.slice();S.push(E),b+=s.length}return pt(...S)};return(b,S)=>{c(),f(b);let E;for(;!(E=S(u()));)f();return c(),E}}function zt(r,t,e={}){if(!r||typeof r!="object")throw new Error("expected valid options object");function n(o,s,i){let a=r[o];if(i&&a===void 0)return;let c=typeof a;if(c!==s||a===null)throw new Error(`param "${o}" is invalid: expected ${s}, got ${c}`)}Object.entries(t).forEach(([o,s])=>n(o,s,!1)),Object.entries(e).forEach(([o,s])=>n(o,s,!0))}function Se(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 ct=BigInt(0),Q=BigInt(1),Jt=BigInt(2),Kc=BigInt(3),Hs=BigInt(4),Vs=BigInt(5),zs=BigInt(8);function q(r,t){let e=r%t;return e>=ct?e:t+e}function z(r,t,e){let n=r;for(;t-- >ct;)n*=n,n%=e;return n}function ks(r,t){if(r===ct)throw new Error("invert: expected non-zero number");if(t<=ct)throw new Error("invert: expected positive modulus, got "+t);let e=q(r,t),n=t,o=ct,s=Q,i=Q,a=ct;for(;e!==ct;){let l=n/e,f=n%e,u=o-i*l,x=s-a*l;n=e,e=f,o=i,s=a,i=u,a=x}if(n!==Q)throw new Error("invert: does not exist");return q(o,t)}function qs(r,t){let e=(r.ORDER+Q)/Hs,n=r.pow(t,e);if(!r.eql(r.sqr(n),t))throw new Error("Cannot find square root");return n}function kc(r,t){let e=(r.ORDER-Vs)/zs,n=r.mul(t,Jt),o=r.pow(n,e),s=r.mul(t,o),i=r.mul(r.mul(s,Jt),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 Mc(r){if(r<BigInt(3))throw new Error("sqrt is not defined for small field");let t=r-Q,e=0;for(;t%Jt===ct;)t/=Jt,e++;let n=Jt,o=wt(r);for(;Ms(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return qs;let s=o.pow(n,t),i=(t+Q)/Jt;return function(c,l){if(c.is0(l))return l;if(Ms(c,l)!==1)throw new Error("Cannot find square root");let f=e,u=c.mul(c.ONE,s),x=c.pow(l,t),b=c.pow(l,i);for(;!c.eql(x,c.ONE);){if(c.is0(x))return c.ZERO;let S=1,E=c.sqr(x);for(;!c.eql(E,c.ONE);)if(S++,E=c.sqr(E),S===f)throw new Error("Cannot find square root");let m=Q<<BigInt(f-S-1),v=c.pow(u,m);f=S,u=c.sqr(v),x=c.mul(x,u),b=c.mul(b,v)}return b}}function Hc(r){return r%Hs===Kc?qs:r%zs===Vs?kc:Mc(r)}var Fs=(r,t)=>(q(r,t)&Q)===Q,Vc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Mn(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},e=Vc.reduce((n,o)=>(n[o]="function",n),t);return zt(r,e),r}function zc(r,t,e){if(e<ct)throw new Error("invalid exponent, negatives unsupported");if(e===ct)return r.ONE;if(e===Q)return t;let n=r.ONE,o=t;for(;e>ct;)e&Q&&(n=r.mul(n,o)),o=r.sqr(o),e>>=Q;return n}function We(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 Ms(r,t){let e=(r.ORDER-Q)/Jt,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 js(r,t){t!==void 0&&He(t);let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function wt(r,t,e=!1,n={}){if(r<=ct)throw new Error("invalid field: expected ORDER > 0, got "+r);let o,s;if(typeof t=="object"&&t!=null){if(n.sqrt||e)throw new Error("cannot specify opts in two arguments");let f=t;f.BITS&&(o=f.BITS),f.sqrt&&(s=f.sqrt),typeof f.isLE=="boolean"&&(e=f.isLE)}else typeof t=="number"&&(o=t),n.sqrt&&(s=n.sqrt);let{nBitLength:i,nByteLength:a}=js(r,o);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c,l=Object.freeze({ORDER:r,isLE:e,BITS:i,BYTES:a,MASK:Qt(i),ZERO:ct,ONE:Q,create:f=>q(f,r),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return ct<=f&&f<r},is0:f=>f===ct,isValidNot0:f=>!l.is0(f)&&l.isValid(f),isOdd:f=>(f&Q)===Q,neg:f=>q(-f,r),eql:(f,u)=>f===u,sqr:f=>q(f*f,r),add:(f,u)=>q(f+u,r),sub:(f,u)=>q(f-u,r),mul:(f,u)=>q(f*u,r),pow:(f,u)=>zc(l,f,u),div:(f,u)=>q(f*ks(u,r),r),sqrN:f=>f*f,addN:(f,u)=>f+u,subN:(f,u)=>f-u,mulN:(f,u)=>f*u,inv:f=>ks(f,r),sqrt:s||(f=>(c||(c=Hc(r)),c(l,f))),toBytes:f=>e?Ee(f,a):yr(f,a),fromBytes:f=>{if(f.length!==a)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+f.length);return e?Xt(f):we(f)},invertBatch:f=>We(l,f),cmov:(f,u,x)=>x?u:f});return Object.freeze(l)}function Gs(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 Hn(r){let t=Gs(r);return t+Math.ceil(t/2)}function Ws(r,t,e=!1){let n=r.length,o=Gs(t),s=Hn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?Xt(r):we(r),a=q(i,t-Q)+Q;return e?Ee(a,o):yr(a,o)}var Ae=BigInt(0),te=BigInt(1);function ve(r,t){let e=t.negate();return r?e:t}function br(r,t,e){let n=t==="pz"?i=>i.pz:i=>i.ez,o=We(r.Fp,e.map(n));return e.map((i,a)=>i.toAffine(o[a])).map(r.fromAffine)}function Xs(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Vn(r,t){Xs(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=Qt(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function $s(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+=te);let l=t*n,f=l+Math.abs(a)-1,u=a===0,x=a<0,b=t%2!==0;return{nextN:c,offset:f,isZero:u,isNeg:x,isNegF:b,offsetF:l}}function qc(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 Fc(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 zn=new WeakMap,Qs=new WeakMap;function qn(r){return Qs.get(r)||1}function Zs(r){if(r!==Ae)throw new Error("invalid wNAF")}function xr(r,t){return{constTimeNegate:ve,hasPrecomputes(e){return qn(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Ae;)n&te&&(o=o.add(s)),s=s.double(),n>>=te;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=Vn(n,t),i=[],a=e,c=a;for(let l=0;l<o;l++){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=Vn(e,t);for(let c=0;c<a.windows;c++){let{nextN:l,offset:f,isZero:u,isNeg:x,isNegF:b,offsetF:S}=$s(o,c,a);o=l,u?i=i.add(ve(b,n[S])):s=s.add(ve(x,n[f]))}return Zs(o),{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=Vn(e,t);for(let a=0;a<i.windows&&o!==Ae;a++){let{nextN:c,offset:l,isZero:f,isNeg:u}=$s(o,a,i);if(o=c,!f){let x=n[l];s=s.add(u?x.negate():x)}}return Zs(o),s},getPrecomputes(e,n,o){let s=zn.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&(typeof o=="function"&&(s=o(s)),zn.set(n,s))),s},wNAFCached(e,n,o){let s=qn(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=qn(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){Xs(n,t),Qs.set(e,n),zn.delete(e)}}}function Js(r,t,e,n){let o=t,s=r.ZERO,i=r.ZERO;for(;e>Ae||n>Ae;)e&te&&(s=s.add(o)),n&te&&(i=i.add(o)),o=o.double(),e>>=te,n>>=te;return{p1:s,p2:i}}function gr(r,t,e,n){qc(e,r),Fc(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=Rs(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let l=Qt(c),f=new Array(Number(l)+1).fill(i),u=Math.floor((t.BITS-1)/c)*c,x=i;for(let b=u;b>=0;b-=c){f.fill(i);for(let E=0;E<s;E++){let m=n[E],v=Number(m>>BigInt(b)&l);f[v]=f[v].add(e[E])}let S=i;for(let E=f.length-1,m=i;E>0;E--)m=m.add(f[E]),S=S.add(m);if(x=x.add(S),b!==0)for(let E=0;E<c;E++)x=x.double()}return x}function Ys(r,t){if(t){if(t.ORDER!==r)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Mn(t),t}else return wt(r)}function wr(r,t,e={}){if(!t||typeof t!="object")throw new Error(`expected valid ${r} CURVE object`);for(let a of["p","n","h"]){let c=t[a];if(!(typeof c=="bigint"&&c>Ae))throw new Error(`CURVE.${a} must be positive bigint`)}let n=Ys(t.p,e.Fp),o=Ys(t.n,e.Fn),i=["Gx","Gy","a",r==="weierstrass"?"b":"d"];for(let a of i)if(!n.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return{Fp:n,Fn:o}}var It=BigInt(0),ft=BigInt(1),Fn=BigInt(2),jc=BigInt(8),Gc={zip215:!0};function Wc(r,t,e,n){let o=r.sqr(e),s=r.sqr(n),i=r.add(r.mul(t.a,o),s),a=r.add(r.ONE,r.mul(t.d,r.mul(o,s)));return r.eql(i,a)}function $c(r,t={}){let{Fp:e,Fn:n}=wr("edwards",r,t),{h:o,n:s}=r;zt(t,{},{uvRatio:"function"});let i=Fn<<BigInt(n.BYTES*8)-ft,a=E=>e.create(E),c=t.uvRatio||((E,m)=>{try{return{isValid:!0,value:e.sqrt(e.div(E,m))}}catch{return{isValid:!1,value:It}}});if(!Wc(e,r,r.Gx,r.Gy))throw new Error("bad curve params: generator point");function l(E,m,v=!1){let D=v?ft:It;return Vt("coordinate "+E,m,D,i),m}function f(E){if(!(E instanceof b))throw new Error("ExtendedPoint expected")}let u=Se((E,m)=>{let{ex:v,ey:D,ez:B}=E,U=E.is0();m==null&&(m=U?jc:e.inv(B));let p=a(v*m),L=a(D*m),P=a(B*m);if(U)return{x:It,y:ft};if(P!==ft)throw new Error("invZ was invalid");return{x:p,y:L}}),x=Se(E=>{let{a:m,d:v}=r;if(E.is0())throw new Error("bad point: ZERO");let{ex:D,ey:B,ez:U,et:p}=E,L=a(D*D),P=a(B*B),C=a(U*U),h=a(C*C),g=a(L*m),d=a(C*a(g+P)),y=a(h+a(v*a(L*P)));if(d!==y)throw new Error("bad point: equation left != right (1)");let w=a(D*B),_=a(U*p);if(w!==_)throw new Error("bad point: equation left != right (2)");return!0});class b{constructor(m,v,D,B){this.ex=l("x",m),this.ey=l("y",v),this.ez=l("z",D,!0),this.et=l("t",B),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(m){if(m instanceof b)throw new Error("extended point not allowed");let{x:v,y:D}=m||{};return l("x",v),l("y",D),new b(v,D,ft,a(v*D))}static normalizeZ(m){return br(b,"ez",m)}static msm(m,v){return gr(b,n,m,v)}_setWindowSize(m){this.precompute(m)}precompute(m=8,v=!0){return S.setWindowSize(this,m),v||this.multiply(Fn),this}assertValidity(){x(this)}equals(m){f(m);let{ex:v,ey:D,ez:B}=this,{ex:U,ey:p,ez:L}=m,P=a(v*L),C=a(U*B),h=a(D*L),g=a(p*B);return P===C&&h===g}is0(){return this.equals(b.ZERO)}negate(){return new b(a(-this.ex),this.ey,this.ez,a(-this.et))}double(){let{a:m}=r,{ex:v,ey:D,ez:B}=this,U=a(v*v),p=a(D*D),L=a(Fn*a(B*B)),P=a(m*U),C=v+D,h=a(a(C*C)-U-p),g=P+p,d=g-L,y=P-p,w=a(h*d),_=a(g*y),I=a(h*y),T=a(d*g);return new b(w,_,T,I)}add(m){f(m);let{a:v,d:D}=r,{ex:B,ey:U,ez:p,et:L}=this,{ex:P,ey:C,ez:h,et:g}=m,d=a(B*P),y=a(U*C),w=a(L*D*g),_=a(p*h),I=a((B+U)*(P+C)-d-y),T=_-w,R=_+w,N=a(y-v*d),W=a(I*T),k=a(R*N),K=a(I*N),Z=a(T*R);return new b(W,k,Z,K)}subtract(m){return this.add(m.negate())}multiply(m){let v=m;Vt("scalar",v,ft,s);let{p:D,f:B}=S.wNAFCached(this,v,b.normalizeZ);return b.normalizeZ([D,B])[0]}multiplyUnsafe(m,v=b.ZERO){let D=m;return Vt("scalar",D,It,s),D===It?b.ZERO:this.is0()||D===ft?this:S.wNAFCachedUnsafe(this,D,b.normalizeZ,v)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}isTorsionFree(){return S.wNAFCachedUnsafe(this,s).is0()}toAffine(m){return u(this,m)}clearCofactor(){return o===ft?this:this.multiplyUnsafe(o)}static fromBytes(m,v=!1){return ot(m),this.fromHex(m,v)}static fromHex(m,v=!1){let{d:D,a:B}=r,U=e.BYTES;m=V("pointHex",m,U),Ot("zip215",v);let p=m.slice(),L=m[U-1];p[U-1]=L&-129;let P=Xt(p),C=v?i:e.ORDER;Vt("pointHex.y",P,It,C);let h=a(P*P),g=a(h-ft),d=a(D*h-B),{isValid:y,value:w}=c(g,d);if(!y)throw new Error("Point.fromHex: invalid y coordinate");let _=(w&ft)===ft,I=(L&128)!==0;if(!v&&w===It&&I)throw new Error("Point.fromHex: x=0 and x_0=1");return I!==_&&(w=a(-w)),b.fromAffine({x:w,y:P})}static fromPrivateScalar(m){return b.BASE.multiply(m)}toBytes(){let{x:m,y:v}=this.toAffine(),D=Ee(v,e.BYTES);return D[D.length-1]|=m&ft?128:0,D}toRawBytes(){return this.toBytes()}toHex(){return vt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}b.BASE=new b(r.Gx,r.Gy,ft,a(r.Gx*r.Gy)),b.ZERO=new b(It,ft,ft,It),b.Fp=e,b.Fn=n;let S=xr(b,n.BYTES*8);return b}function Zc(r,t){zt(t,{hash:"function"},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:e,hash:n}=t,{BASE:o,Fp:s,Fn:i}=r,a=i.ORDER,c=t.randomBytes||ze,l=t.adjustScalarBytes||(p=>p),f=t.domain||((p,L,P)=>{if(Ot("phflag",P),L.length||P)throw new Error("Contexts/pre-hash are not supported");return p});function u(p){return i.create(p)}function x(p){return u(Xt(p))}function b(p){let L=s.BYTES;p=V("private key",p,L);let P=V("hashed private key",n(p),2*L),C=l(P.slice(0,L)),h=P.slice(L,2*L),g=x(C);return{head:C,prefix:h,scalar:g}}function S(p){let{head:L,prefix:P,scalar:C}=b(p),h=o.multiply(C),g=h.toBytes();return{head:L,prefix:P,scalar:C,point:h,pointBytes:g}}function E(p){return S(p).pointBytes}function m(p=Uint8Array.of(),...L){let P=pt(...L);return x(n(f(P,V("context",p),!!e)))}function v(p,L,P={}){p=V("message",p),e&&(p=e(p));let{prefix:C,scalar:h,pointBytes:g}=S(L),d=m(P.context,C,p),y=o.multiply(d).toBytes(),w=m(P.context,y,g,p),_=u(d+w*h);Vt("signature.s",_,It,a);let I=s.BYTES,T=pt(y,Ee(_,I));return V("result",T,I*2)}let D=Gc;function B(p,L,P,C=D){let{context:h,zip215:g}=C,d=s.BYTES;p=V("signature",p,2*d),L=V("message",L),P=V("publicKey",P,d),g!==void 0&&Ot("zip215",g),e&&(L=e(L));let y=Xt(p.slice(d,2*d)),w,_,I;try{w=r.fromHex(P,g),_=r.fromHex(p.slice(0,d),g),I=o.multiplyUnsafe(y)}catch{return!1}if(!g&&w.isSmallOrder())return!1;let T=m(h,_.toBytes(),w.toBytes(),L);return _.add(w.multiplyUnsafe(T)).subtract(I).clearCofactor().is0()}return o.precompute(8),{getPublicKey:E,sign:v,verify:B,utils:{getExtendedPublicKey:S,randomPrivateKey:()=>c(s.BYTES),precompute(p=8,L=r.BASE){return L.precompute(p,!1)}},Point:r}}function Yc(r){let t={a:r.a,d:r.d,p:r.Fp.ORDER,n:r.n,h:r.h,Gx:r.Gx,Gy:r.Gy},e=r.Fp,n=wt(t.n,r.nBitLength,!0),o={Fp:e,Fn:n,uvRatio:r.uvRatio},s={hash:r.hash,randomBytes:r.randomBytes,adjustScalarBytes:r.adjustScalarBytes,domain:r.domain,prehash:r.prehash,mapToCurve:r.mapToCurve};return{CURVE:t,curveOpts:o,eddsaOpts:s}}function Xc(r,t){return Object.assign({},t,{ExtendedPoint:t.Point,CURVE:r})}function ti(r){let{CURVE:t,curveOpts:e,eddsaOpts:n}=Yc(r),o=$c(t,e),s=Zc(o,n);return Xc(r,s)}var xd=BigInt(0),Qc=BigInt(1),ei=BigInt(2),gd=BigInt(3),Jc=BigInt(5),tf=BigInt(8),Er={p:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:tf,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function ef(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=Er.p,a=r*r%s*r%s,c=z(a,ei,s)*a%s,l=z(c,Qc,s)*r%s,f=z(l,Jc,s)*l%s,u=z(f,t,s)*f%s,x=z(u,e,s)*u%s,b=z(x,n,s)*x%s,S=z(b,o,s)*b%s,E=z(S,o,s)*b%s,m=z(E,t,s)*f%s;return{pow_p_5_8:z(m,ei,s)*r%s,b2:a}}function rf(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}var ri=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function nf(r,t){let e=Er.p,n=q(t*t*t,e),o=q(n*n*t,e),s=ef(r*o).pow_p_5_8,i=q(r*n*s,e),a=q(t*i*i,e),c=i,l=q(i*ri,e),f=a===r,u=a===q(-r,e),x=a===q(-r*ri,e);return f&&(i=c),(u||x)&&(i=l),Fs(i,e)&&(i=q(-i,e)),{isValid:f||u,value:i}}var of=wt(Er.p,void 0,!0),sf={...Er,Fp:of,hash:Os,adjustScalarBytes:rf,uvRatio:nf},ni=ti(sf);var $e=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Sr=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var oi={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new Sr("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 vr=oi;var Ar=32;var jn,af=(async()=>{try{return await vr.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function cf(r,t,e){if(r.buffer instanceof ArrayBuffer){let n=await vr.get().subtle.importKey("raw",r.buffer,{name:"Ed25519"},!1,["verify"]);return await vr.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 ff(r,t,e){return ni.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}async function si(r,t,e){return jn==null&&(jn=await af),jn?cf(r,t,e):ff(r,t,e)}function Ir(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var Br=class{type="Ed25519";raw;constructor(t){this.raw=Gn(t,Ar)}toMultihash(){return xt.digest(me(this))}toCID(){return Y.createV1(114,this.toMultihash())}toString(){return G.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=si(this.raw,e,t);return Ir(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function ai(r){return r=Gn(r,Ar),new Br(r)}function Gn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new St(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var lf=Math.pow(2,7),hf=Math.pow(2,14),df=Math.pow(2,21),Wn=Math.pow(2,28),$n=Math.pow(2,35),Zn=Math.pow(2,42),Yn=Math.pow(2,49),F=128,st=127;function Bt(r){if(r<lf)return 1;if(r<hf)return 2;if(r<df)return 3;if(r<Wn)return 4;if(r<$n)return 5;if(r<Zn)return 6;if(r<Yn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Ze(r,t,e=0){switch(Bt(r)){case 8:t[e++]=r&255|F,r/=128;case 7:t[e++]=r&255|F,r/=128;case 6:t[e++]=r&255|F,r/=128;case 5:t[e++]=r&255|F,r/=128;case 4:t[e++]=r&255|F,r>>>=7;case 3:t[e++]=r&255|F,r>>>=7;case 2:t[e++]=r&255|F,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Xn(r,t){let e=r[t],n=0;if(n+=e&st,e<F||(e=r[t+1],n+=(e&st)<<7,e<F)||(e=r[t+2],n+=(e&st)<<14,e<F)||(e=r[t+3],n+=(e&st)<<21,e<F)||(e=r[t+4],n+=(e&st)*Wn,e<F)||(e=r[t+5],n+=(e&st)*$n,e<F)||(e=r[t+6],n+=(e&st)*Zn,e<F)||(e=r[t+7],n+=(e&st)*Yn,e<F))return n;throw new RangeError("Could not decode varint")}function pf(r,t){let e=r.get(t),n=0;if(n+=e&st,e<F||(e=r.get(t+1),n+=(e&st)<<7,e<F)||(e=r.get(t+2),n+=(e&st)<<14,e<F)||(e=r.get(t+3),n+=(e&st)<<21,e<F)||(e=r.get(t+4),n+=(e&st)*Wn,e<F)||(e=r.get(t+5),n+=(e&st)*$n,e<F)||(e=r.get(t+6),n+=(e&st)*Zn,e<F)||(e=r.get(t+7),n+=(e&st)*Yn,e<F))return n;throw new RangeError("Could not decode varint")}function Qn(r,t=0){return r instanceof Uint8Array?Xn(r,t):pf(r,t)}var Jn=new Float32Array([-0]),qt=new Uint8Array(Jn.buffer);function ci(r,t,e){Jn[0]=r,t[e]=qt[0],t[e+1]=qt[1],t[e+2]=qt[2],t[e+3]=qt[3]}function fi(r,t){return qt[0]=r[t],qt[1]=r[t+1],qt[2]=r[t+2],qt[3]=r[t+3],Jn[0]}var to=new Float64Array([-0]),it=new Uint8Array(to.buffer);function ui(r,t,e){to[0]=r,t[e]=it[0],t[e+1]=it[1],t[e+2]=it[2],t[e+3]=it[3],t[e+4]=it[4],t[e+5]=it[5],t[e+6]=it[6],t[e+7]=it[7]}function li(r,t){return it[0]=r[t],it[1]=r[t+1],it[2]=r[t+2],it[3]=r[t+3],it[4]=r[t+4],it[5]=r[t+5],it[6]=r[t+6],it[7]=r[t+7],to[0]}var yf=BigInt(Number.MAX_SAFE_INTEGER),bf=BigInt(Number.MIN_SAFE_INTEGER),mt=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 ee;if(t<yf&&t>bf)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>hi&&(o=0n,++n>hi&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ee;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):ee}},ee=new mt(0,0);ee.toBigInt=function(){return 0n};ee.zzEncode=ee.zzDecode=function(){return this};ee.length=function(){return 1};var hi=4294967296n;function di(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 pi(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 eo(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 Et(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Cr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var ro=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,Et(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 Et(this,4);return Cr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Et(this,4);return Cr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Et(this,4);let t=fi(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Et(this,4);let t=li(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 Et(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return pi(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Et(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Et(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 mt(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 Et(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 Et(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 Et(this,8);let t=Cr(this.buf,this.pos+=4),e=Cr(this.buf,this.pos+=4);return new mt(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=Xn(this.buf,this.pos);return this.pos+=Bt(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 no(r){return new ro(r instanceof Uint8Array?r:r.subarray())}function _r(r,t,e){let n=no(r);return t.decode(n,void 0,e)}function oo(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return ht(i);o+i>t&&(n=ht(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var re=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function so(){}var ao=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},xf=oo();function gf(r){return globalThis.Buffer!=null?ht(r):xf(r)}var Xe=class{len;head;tail;states;constructor(){this.len=0,this.head=new re(so,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new re(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new co((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(Tr,10,mt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=mt.fromBigInt(t);return this._push(Tr,e.length(),e)}uint64Number(t){return this._push(Ze,Bt(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=mt.fromBigInt(t).zzEncode();return this._push(Tr,e.length(),e)}sint64Number(t){let e=mt.fromNumber(t).zzEncode();return this._push(Tr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(io,1,t?1:0)}fixed32(t){return this._push(Ye,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=mt.fromBigInt(t);return this._push(Ye,4,e.lo)._push(Ye,4,e.hi)}fixed64Number(t){let e=mt.fromNumber(t);return this._push(Ye,4,e.lo)._push(Ye,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(ci,4,t)}double(t){return this._push(ui,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(io,1,0):this.uint32(e)._push(Ef,e,t)}string(t){let e=di(t);return e!==0?this.uint32(e)._push(eo,e,t):this._push(io,1,0)}fork(){return this.states=new ao(this),this.head=this.tail=new re(so,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 re(so,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=gf(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function io(r,t,e){t[e]=r&255}function wf(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var co=class extends re{next;constructor(t,e){super(wf,t,e),this.next=void 0}};function Tr(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 Ye(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 Ef(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Xe.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Sf,t,r),this},Xe.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(vf,t,r),this});function Sf(r,t,e){t.set(r,e)}function vf(r,t,e){r.length<40?eo(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(nt(r),e)}function fo(){return new Xe}function Dr(r,t){let e=fo();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Ie;(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"})(Ie||(Ie={}));function Pr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function uo(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 Pr("enum",Ie.VARINT,e,n)}function Lr(r,t){return Pr("message",Ie.LENGTH_DELIMITED,r,t)}var yt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(yt||(yt={}));var lo;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(lo||(lo={}));(function(r){r.codec=()=>uo(lo)})(yt||(yt={}));var Qe;(function(r){let t;r.codec=()=>(t==null&&(t=Lr((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=>Dr(e,r.codec()),r.decode=(e,n)=>_r(e,r.codec(),n)})(Qe||(Qe={}));var ho;(function(r){let t;r.codec=()=>(t==null&&(t=Lr((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=>Dr(e,r.codec()),r.decode=(e,n)=>_r(e,r.codec(),n)})(ho||(ho={}));var Or=class extends ye{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,bs(t);let n=Ve(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),Pt(s)}update(t){return xe(this),this.iHash.update(t),this}digestInto(t){xe(this),ot(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()}},po=(r,t,e)=>new Or(r,t).update(e).digest();po.create=(r,t)=>new Or(r,t);function yi(r){r.lowS!==void 0&&Ot("lowS",r.lowS),r.prehash!==void 0&&Ot("prehash",r.prehash)}var mo=class extends Error{constructor(t=""){super(t)}},Ut={Err:mo,_tlv:{encode:(r,t)=>{let{Err:e}=Ut;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=Ge(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Ge(o.length/2|128):"";return Ge(r)+s+o+t},decode(r,t){let{Err:e}=Ut,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 l=t.subarray(n,n+c);if(l.length!==c)throw new e("tlv.decode: length bytes not complete");if(l[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let f of l)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}=Ut;if(r<Je)throw new t("integer: negative integers are not allowed");let e=Ge(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}=Ut;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 we(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Ut,o=V("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:l,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(l)}},hexFromSig(r){let{_tlv:t,_int:e}=Ut,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},Je=BigInt(0),tr=BigInt(1),If=BigInt(2),Ur=BigInt(3),Bf=BigInt(4);function Cf(r,t,e){function n(o){let s=r.sqr(o),i=r.mul(s,o);return r.add(r.add(i,r.mul(o,t)),e)}return n}function bi(r,t,e){let{BYTES:n}=r;function o(s){let i;if(typeof s=="bigint")i=s;else{let a=V("private key",s);if(t){if(!t.includes(a.length*2))throw new Error("invalid private key");let c=new Uint8Array(n);c.set(a,c.length-a.length),a=c}try{i=r.fromBytes(a)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof s}`)}}if(e&&(i=r.create(i)),!r.isValidNot0(i))throw new Error("invalid private key: out of range [1..N-1]");return i}return o}function _f(r,t={}){let{Fp:e,Fn:n}=wr("weierstrass",r,t),{h:o,n:s}=r;zt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:i}=t;if(i&&(!e.is0(r.a)||typeof i.beta!="bigint"||typeof i.splitScalar!="function"))throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');function a(){if(!e.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function c(C,h,g){let{x:d,y}=h.toAffine(),w=e.toBytes(d);if(Ot("isCompressed",g),g){a();let _=!e.isOdd(y);return pt(xi(_),w)}else return pt(Uint8Array.of(4),w,e.toBytes(y))}function l(C){ot(C);let h=e.BYTES,g=h+1,d=2*h+1,y=C.length,w=C[0],_=C.subarray(1);if(y===g&&(w===2||w===3)){let I=e.fromBytes(_);if(!e.isValid(I))throw new Error("bad point: is not on curve, wrong x");let T=x(I),R;try{R=e.sqrt(T)}catch(k){let K=k instanceof Error?": "+k.message:"";throw new Error("bad point: is not on curve, sqrt error"+K)}a();let N=e.isOdd(R);return(w&1)===1!==N&&(R=e.neg(R)),{x:I,y:R}}else if(y===d&&w===4){let I=e.fromBytes(_.subarray(h*0,h*1)),T=e.fromBytes(_.subarray(h*1,h*2));if(!b(I,T))throw new Error("bad point: is not on curve");return{x:I,y:T}}else throw new Error(`bad point: got length ${y}, expected compressed=${g} or uncompressed=${d}`)}let f=t.toBytes||c,u=t.fromBytes||l,x=Cf(e,r.a,r.b);function b(C,h){let g=e.sqr(h),d=x(C);return e.eql(g,d)}if(!b(r.Gx,r.Gy))throw new Error("bad curve params: generator point");let S=e.mul(e.pow(r.a,Ur),Bf),E=e.mul(e.sqr(r.b),BigInt(27));if(e.is0(e.add(S,E)))throw new Error("bad curve params: a or b");function m(C,h,g=!1){if(!e.isValid(h)||g&&e.is0(h))throw new Error(`bad point coordinate ${C}`);return h}function v(C){if(!(C instanceof p))throw new Error("ProjectivePoint expected")}let D=Se((C,h)=>{let{px:g,py:d,pz:y}=C;if(e.eql(y,e.ONE))return{x:g,y:d};let w=C.is0();h==null&&(h=w?e.ONE:e.inv(y));let _=e.mul(g,h),I=e.mul(d,h),T=e.mul(y,h);if(w)return{x:e.ZERO,y:e.ZERO};if(!e.eql(T,e.ONE))throw new Error("invZ was invalid");return{x:_,y:I}}),B=Se(C=>{if(C.is0()){if(t.allowInfinityPoint&&!e.is0(C.py))return;throw new Error("bad point: ZERO")}let{x:h,y:g}=C.toAffine();if(!e.isValid(h)||!e.isValid(g))throw new Error("bad point: x or y not field elements");if(!b(h,g))throw new Error("bad point: equation left != right");if(!C.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function U(C,h,g,d,y){return g=new p(e.mul(g.px,C),g.py,g.pz),h=ve(d,h),g=ve(y,g),h.add(g)}class p{constructor(h,g,d){this.px=m("x",h),this.py=m("y",g,!0),this.pz=m("z",d),Object.freeze(this)}static fromAffine(h){let{x:g,y:d}=h||{};if(!h||!e.isValid(g)||!e.isValid(d))throw new Error("invalid affine point");if(h instanceof p)throw new Error("projective point not allowed");return e.is0(g)&&e.is0(d)?p.ZERO:new p(g,d,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){return br(p,"pz",h)}static fromBytes(h){return ot(h),p.fromHex(h)}static fromHex(h){let g=p.fromAffine(u(V("pointHex",h)));return g.assertValidity(),g}static fromPrivateKey(h){let g=bi(n,t.allowedPrivateKeyLengths,t.wrapPrivateKey);return p.BASE.multiply(g(h))}static msm(h,g){return gr(p,n,h,g)}precompute(h=8,g=!0){return P.setWindowSize(this,h),g||this.multiply(Ur),this}_setWindowSize(h){this.precompute(h)}assertValidity(){B(this)}hasEvenY(){let{y:h}=this.toAffine();if(!e.isOdd)throw new Error("Field doesn't support isOdd");return!e.isOdd(h)}equals(h){v(h);let{px:g,py:d,pz:y}=this,{px:w,py:_,pz:I}=h,T=e.eql(e.mul(g,I),e.mul(w,y)),R=e.eql(e.mul(d,I),e.mul(_,y));return T&&R}negate(){return new p(this.px,e.neg(this.py),this.pz)}double(){let{a:h,b:g}=r,d=e.mul(g,Ur),{px:y,py:w,pz:_}=this,I=e.ZERO,T=e.ZERO,R=e.ZERO,N=e.mul(y,y),W=e.mul(w,w),k=e.mul(_,_),K=e.mul(y,w);return K=e.add(K,K),R=e.mul(y,_),R=e.add(R,R),I=e.mul(h,R),T=e.mul(d,k),T=e.add(I,T),I=e.sub(W,T),T=e.add(W,T),T=e.mul(I,T),I=e.mul(K,I),R=e.mul(d,R),k=e.mul(h,k),K=e.sub(N,k),K=e.mul(h,K),K=e.add(K,R),R=e.add(N,N),N=e.add(R,N),N=e.add(N,k),N=e.mul(N,K),T=e.add(T,N),k=e.mul(w,_),k=e.add(k,k),N=e.mul(k,K),I=e.sub(I,N),R=e.mul(k,W),R=e.add(R,R),R=e.add(R,R),new p(I,T,R)}add(h){v(h);let{px:g,py:d,pz:y}=this,{px:w,py:_,pz:I}=h,T=e.ZERO,R=e.ZERO,N=e.ZERO,W=r.a,k=e.mul(r.b,Ur),K=e.mul(g,w),Z=e.mul(d,_),X=e.mul(y,I),rt=e.add(g,d),M=e.add(w,_);rt=e.mul(rt,M),M=e.add(K,Z),rt=e.sub(rt,M),M=e.add(g,y);let at=e.add(w,I);return M=e.mul(M,at),at=e.add(K,X),M=e.sub(M,at),at=e.add(d,y),T=e.add(_,I),at=e.mul(at,T),T=e.add(Z,X),at=e.sub(at,T),N=e.mul(W,M),T=e.mul(k,X),N=e.add(T,N),T=e.sub(Z,N),N=e.add(Z,N),R=e.mul(T,N),Z=e.add(K,K),Z=e.add(Z,K),X=e.mul(W,X),M=e.mul(k,M),Z=e.add(Z,X),X=e.sub(K,X),X=e.mul(W,X),M=e.add(M,X),K=e.mul(Z,M),R=e.add(R,K),K=e.mul(at,M),T=e.mul(rt,T),T=e.sub(T,K),K=e.mul(rt,Z),N=e.mul(at,N),N=e.add(N,K),new p(T,R,N)}subtract(h){return this.add(h.negate())}is0(){return this.equals(p.ZERO)}multiply(h){let{endo:g}=t;if(!n.isValidNot0(h))throw new Error("invalid scalar: out of range");let d,y,w=_=>P.wNAFCached(this,_,p.normalizeZ);if(g){let{k1neg:_,k1:I,k2neg:T,k2:R}=g.splitScalar(h),{p:N,f:W}=w(I),{p:k,f:K}=w(R);y=W.add(K),d=U(g.beta,N,k,_,T)}else{let{p:_,f:I}=w(h);d=_,y=I}return p.normalizeZ([d,y])[0]}multiplyUnsafe(h){let{endo:g}=t,d=this;if(!n.isValid(h))throw new Error("invalid scalar: out of range");if(h===Je||d.is0())return p.ZERO;if(h===tr)return d;if(P.hasPrecomputes(this))return this.multiply(h);if(g){let{k1neg:y,k1:w,k2neg:_,k2:I}=g.splitScalar(h),{p1:T,p2:R}=Js(p,d,w,I);return U(g.beta,T,R,y,_)}else return P.wNAFCachedUnsafe(d,h)}multiplyAndAddUnsafe(h,g,d){let y=this.multiplyUnsafe(g).add(h.multiplyUnsafe(d));return y.is0()?void 0:y}toAffine(h){return D(this,h)}isTorsionFree(){let{isTorsionFree:h}=t;return o===tr?!0:h?h(p,this):P.wNAFCachedUnsafe(this,s).is0()}clearCofactor(){let{clearCofactor:h}=t;return o===tr?this:h?h(p,this):this.multiplyUnsafe(o)}toBytes(h=!0){return Ot("isCompressed",h),this.assertValidity(),f(p,this,h)}toRawBytes(h=!0){return this.toBytes(h)}toHex(h=!0){return vt(this.toBytes(h))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}p.BASE=new p(r.Gx,r.Gy,e.ONE),p.ZERO=new p(e.ZERO,e.ONE,e.ZERO),p.Fp=e,p.Fn=n;let L=n.BITS,P=xr(p,t.endo?Math.ceil(L/2):L);return p}function xi(r){return Uint8Array.of(r?2:3)}function Tf(r,t,e={}){zt(t,{hash:"function"},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let n=t.randomBytes||ze,o=t.hmac||((d,...y)=>po(t.hash,d,pt(...y))),{Fp:s,Fn:i}=r,{ORDER:a,BITS:c}=i;function l(d){let y=a>>tr;return d>y}function f(d){return l(d)?i.neg(d):d}function u(d,y){if(!i.isValidNot0(y))throw new Error(`invalid signature ${d}: out of range 1..CURVE.n`)}class x{constructor(y,w,_){u("r",y),u("s",w),this.r=y,this.s=w,_!=null&&(this.recovery=_),Object.freeze(this)}static fromCompact(y){let w=i.BYTES,_=V("compactSignature",y,w*2);return new x(i.fromBytes(_.subarray(0,w)),i.fromBytes(_.subarray(w,w*2)))}static fromDER(y){let{r:w,s:_}=Ut.toSig(V("DER",y));return new x(w,_)}assertValidity(){}addRecoveryBit(y){return new x(this.r,this.s,y)}recoverPublicKey(y){let w=s.ORDER,{r:_,s:I,recovery:T}=this;if(T==null||![0,1,2,3].includes(T))throw new Error("recovery id invalid");if(a*If<w&&T>1)throw new Error("recovery id is ambiguous for h>1 curve");let N=T===2||T===3?_+a:_;if(!s.isValid(N))throw new Error("recovery id 2 or 3 invalid");let W=s.toBytes(N),k=r.fromHex(pt(xi((T&1)===0),W)),K=i.inv(N),Z=B(V("msgHash",y)),X=i.create(-Z*K),rt=i.create(I*K),M=r.BASE.multiplyUnsafe(X).add(k.multiplyUnsafe(rt));if(M.is0())throw new Error("point at infinify");return M.assertValidity(),M}hasHighS(){return l(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,i.neg(this.s),this.recovery):this}toBytes(y){if(y==="compact")return pt(i.toBytes(this.r),i.toBytes(this.s));if(y==="der")return ge(Ut.hexFromSig(this));throw new Error("invalid format")}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return vt(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return vt(this.toBytes("compact"))}}let b=bi(i,e.allowedPrivateKeyLengths,e.wrapPrivateKey),S={isValidPrivateKey(d){try{return b(d),!0}catch{return!1}},normPrivateKeyToScalar:b,randomPrivateKey:()=>{let d=a;return Ws(n(Hn(d)),d)},precompute(d=8,y=r.BASE){return y.precompute(d,!1)}};function E(d,y=!0){return r.fromPrivateKey(d).toBytes(y)}function m(d){if(typeof d=="bigint")return!1;if(d instanceof r)return!0;let w=V("key",d).length,_=s.BYTES,I=_+1,T=2*_+1;if(!(e.allowedPrivateKeyLengths||i.BYTES===I))return w===I||w===T}function v(d,y,w=!0){if(m(d)===!0)throw new Error("first arg must be private key");if(m(y)===!1)throw new Error("second arg must be public key");return r.fromHex(y).multiply(b(d)).toBytes(w)}let D=t.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");let y=we(d),w=d.length*8-c;return w>0?y>>BigInt(w):y},B=t.bits2int_modN||function(d){return i.create(D(d))},U=Qt(c);function p(d){return Vt("num < 2^"+c,d,Je,U),i.toBytes(d)}function L(d,y,w=P){if(["recovered","canonical"].some(rt=>rt in w))throw new Error("sign() legacy options not supported");let{hash:_}=t,{lowS:I,prehash:T,extraEntropy:R}=w;I==null&&(I=!0),d=V("msgHash",d),yi(w),T&&(d=V("prehashed msgHash",_(d)));let N=B(d),W=b(y),k=[p(W),p(N)];if(R!=null&&R!==!1){let rt=R===!0?n(s.BYTES):R;k.push(V("extraEntropy",rt))}let K=pt(...k),Z=N;function X(rt){let M=D(rt);if(!i.isValidNot0(M))return;let at=i.inv(M),Te=r.BASE.multiply(M).toAffine(),ae=i.create(Te.x);if(ae===Je)return;let Gt=i.create(at*i.create(Z+ae*W));if(Gt===Je)return;let Jr=(Te.x===ae?0:2)|Number(Te.y&tr),ce=Gt;return I&&l(Gt)&&(ce=f(Gt),Jr^=1),new x(ae,ce,Jr)}return{seed:K,k2sig:X}}let P={lowS:t.lowS,prehash:!1},C={lowS:t.lowS,prehash:!1};function h(d,y,w=P){let{seed:_,k2sig:I}=L(d,y,w);return Ks(t.hash.outputLen,i.BYTES,o)(_,I)}r.BASE.precompute(8);function g(d,y,w,_=C){let I=d;y=V("msgHash",y),w=V("publicKey",w),yi(_);let{lowS:T,prehash:R,format:N}=_;if("strict"in _)throw new Error("options.strict was renamed to lowS");if(N!==void 0&&!["compact","der","js"].includes(N))throw new Error('format must be "compact", "der" or "js"');let W=typeof I=="string"||be(I),k=!W&&!N&&typeof I=="object"&&I!==null&&typeof I.r=="bigint"&&typeof I.s=="bigint";if(!W&&!k)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let K,Z;try{if(k)if(N===void 0||N==="js")K=new x(I.r,I.s);else throw new Error("invalid format");if(W){try{N!=="compact"&&(K=x.fromDER(I))}catch(ce){if(!(ce instanceof Ut.Err))throw ce}!K&&N!=="der"&&(K=x.fromCompact(I))}Z=r.fromHex(w)}catch{return!1}if(!K||T&&K.hasHighS())return!1;R&&(y=t.hash(y));let{r:X,s:rt}=K,M=B(y),at=i.inv(rt),Te=i.create(M*at),ae=i.create(X*at),Gt=r.BASE.multiplyUnsafe(Te).add(Z.multiplyUnsafe(ae));return Gt.is0()?!1:i.create(Gt.x)===X}return Object.freeze({getPublicKey:E,getSharedSecret:v,sign:h,verify:g,utils:S,Point:r,Signature:x})}function Df(r){let t={a:r.a,b:r.b,p:r.Fp.ORDER,n:r.n,h:r.h,Gx:r.Gx,Gy:r.Gy},e=r.Fp,n=wt(t.n,r.nBitLength),o={Fp:e,Fn:n,allowedPrivateKeyLengths:r.allowedPrivateKeyLengths,allowInfinityPoint:r.allowInfinityPoint,endo:r.endo,wrapPrivateKey:r.wrapPrivateKey,isTorsionFree:r.isTorsionFree,clearCofactor:r.clearCofactor,fromBytes:r.fromBytes,toBytes:r.toBytes};return{CURVE:t,curveOpts:o}}function Pf(r){let{CURVE:t,curveOpts:e}=Df(r),n={hash:r.hash,hmac:r.hmac,randomBytes:r.randomBytes,lowS:r.lowS,bits2int:r.bits2int,bits2int_modN:r.bits2int_modN};return{CURVE:t,curveOpts:e,ecdsaOpts:n}}function Lf(r,t){return Object.assign({},t,{ProjectivePoint:t.Point,CURVE:r})}function gi(r){let{CURVE:t,curveOpts:e,ecdsaOpts:n}=Pf(r),o=_f(t,e),s=Tf(o,n,e);return Lf(r,s)}function wi(r,t){let e=n=>gi({...r,hash:n});return{...e(t),create:e}}var Nr={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},kp=BigInt(0),Of=BigInt(1),yo=BigInt(2),Ei=(r,t)=>(r+t/yo)/t;function Uf(r){let t=Nr.p,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),l=r*r*r%t,f=l*l*r%t,u=z(f,e,t)*f%t,x=z(u,e,t)*f%t,b=z(x,yo,t)*l%t,S=z(b,o,t)*b%t,E=z(S,s,t)*S%t,m=z(E,a,t)*E%t,v=z(m,c,t)*m%t,D=z(v,a,t)*E%t,B=z(D,e,t)*f%t,U=z(B,i,t)*S%t,p=z(U,n,t)*l%t,L=z(p,yo,t);if(!bo.eql(bo.sqr(L),r))throw new Error("Cannot find square root");return L}var bo=wt(Nr.p,void 0,void 0,{sqrt:Uf}),Be=wi({...Nr,Fp:bo,lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Nr.n,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Of*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),a=Ei(s*r,t),c=Ei(-n*r,t),l=q(r-a*e-c*o,t),f=q(-a*n-c*s,t),u=l>i,x=f>i;if(u&&(l=t-l),x&&(f=t-f),l>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:u,k1:l,k2neg:x,k2:f}}}},Ls);function Si(r,t,e,n){let o=Re.digest(e instanceof Uint8Array?e:e.subarray());if(Ir(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),Be.verify(t,s,r))).catch(s=>{throw s.name==="AbortError"?s:new $e(String(s))});try{return n?.signal?.throwIfAborted(),Be.verify(t,o.digest,r)}catch(s){throw new $e(String(s))}}var Rr=class{type="secp256k1";raw;_key;constructor(t){this._key=Ai(t),this.raw=vi(this._key)}toMultihash(){return xt.digest(me(this))}toCID(){return Y.createV1(114,this.toMultihash())}toString(){return G.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 Si(this._key,e,t,n)}};function Ii(r){return new Rr(r)}function vi(r){return Be.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Ai(r){try{return Be.ProjectivePoint.fromHex(r),r}catch(t){throw new ir(String(t))}}function Bi(r){let{Type:t,Data:e}=Qe.decode(r.digest),n=e??new Uint8Array;switch(t){case yt.Ed25519:return ai(n);case yt.secp256k1:return Ii(n);case yt.ECDSA:return ds(n);default:throw new De}}function me(r){return Qe.encode({Type:yt[r.type],Data:r.raw})}var Ci=Symbol.for("nodejs.util.inspect.custom"),Nf=114,er=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()})`}[en]=!0;toString(){return this.string==null&&(this.string=G.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return Y.createV1(Nf,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")}[Ci](){return`PeerId(${this.toString()})`}},Kr=class extends er{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},kr=class extends er{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Mr=class extends er{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Rf=2336,rr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=xt.digest(nt(this.url))}[Ci](){return`PeerId(${this.url})`}[en]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return Y.createV1(Rf,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=H(t)),t.toString()===this.toString())}};var Kf=114,_i=2336;function Ti(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=Ue(G.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return kf(Y.parse(r));if(t==null)throw new St('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=Ue(t.decode(r))}return Di(e)}function Di(r){if(Hf(r))return new Kr({multihash:r});if(Mf(r))try{let t=Bi(r);if(t.type==="Ed25519")return new kr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Mr({multihash:r,publicKey:t})}catch{let e=H(r.digest);return new rr(new URL(e))}throw new cr("Supplied PeerID Multihash is invalid")}function kf(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==Kf&&r.code!==_i)throw new ar("Supplied PeerID CID is invalid");if(r.code===_i){let t=H(r.multihash.digest);return new rr(new URL(t))}return Di(r.multihash)}function Mf(r){return r.code===xt.code}function Hf(r){return r.code===Re.code}var tt=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},Nt=class extends Error{static name="ValidationError";name="ValidationError"},nr=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Hr=class extends Error{static name="InvalidProtocolError";name="InvalidProtocolError"};var Vr=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*o)-1;for(;;){let f=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let x=Number.parseInt(u,t);if(!Number.isNaN(x))return x});if(f===void 0)break;if(s*=t,s+=f,s>l||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[o]=i[0],e[o+1]=i[1],e[o+2]=i[2],e[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=t(s.subarray(0,i));return e.set(s.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Vf=45,zf=15,zr=new Vr;function xo(r){if(!(r.length>zf))return zr.new(r).parseWith(()=>zr.readIPv4Addr())}function go(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Vf))return zr.new(r).parseWith(()=>zr.readIPv6Addr())}function qr(r){return!!xo(r)}function Li(r){return!!go(r)}function Eo(r){return t=>H(t,r)}function So(r){return t=>nt(t,r)}function Ce(r){return new DataView(r.buffer).getUint16(r.byteOffset).toString()}function ne(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof r=="string"?parseInt(r):r),new Uint8Array(t)}function Oi(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=nt(t[0],"base32"),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ne(n);return Tt([e,o],e.length+o.length)}function Ui(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Kt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ne(n);return Tt([e,o],e.length+o.length)}function vo(r){let t=r.subarray(0,r.length-2),e=r.subarray(r.length-2),n=H(t,"base32"),o=Ce(e);return`${n}:${o}`}var Ao=function(r){r=r.toString().trim();let t=new Uint8Array(4);return r.split(/\./g).forEach((e,n)=>{let o=parseInt(e,10);if(isNaN(o)||o<0||o>255)throw new tt("Invalid byte value in IP address");t[n]=o}),t},Ni=function(r){let t=0;r=r.toString().trim();let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=qr(e[n]),i;s&&(i=Ao(e[n]),e[n]=H(i.subarray(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,H(i.subarray(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){e[n]===""&&(e[n]="0");let s=parseInt(e[n],16);if(isNaN(s)||s<0||s>65535)throw new tt("Invalid byte value in IP address");o[t++]=s>>8&255,o[t++]=s&255}return o},Ri=function(r){if(r.byteLength!==4)throw new tt("IPv4 address was incorrect length");let t=[];for(let e=0;e<r.byteLength;e++)t.push(r[e]);return t.join(".")},Ki=function(r){if(r.byteLength!==16)throw new tt("IPv6 address was incorrect length");let t=[];for(let n=0;n<r.byteLength;n+=2){let o=r[n],s=r[n+1],i=`${o.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`;t.push(i)}let e=t.join(":");try{let n=new URL(`http://[${e}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new tt(`Invalid IPv6 address "${e}"`)}};function ki(r){try{let t=new URL(`http://[${r}]`);return t.hostname.substring(1,t.hostname.length-1)}catch{throw new tt(`Invalid IPv6 address "${r}"`)}}var wo=Object.values(Ke).map(r=>r.decoder),qf=function(){let r=wo[0].or(wo[1]);return wo.slice(2).forEach(t=>r=r.or(t)),r}();function Mi(r){return qf.decode(r)}function Hi(r){return t=>r.encoder.encode(t)}function Ff(r){if(parseInt(r).toString()!==r)throw new Nt("Value must be an integer")}function jf(r){if(r<0)throw new Nt("Value must be a positive integer, or zero")}function Gf(r){return t=>{if(t>r)throw new Nt(`Value must be smaller than or equal to ${r}`)}}function Wf(...r){return t=>{for(let e of r)e(t)}}var or=Wf(Ff,jf,Gf(65535));var et=-1,Io=class{protocolsByCode=new Map;protocolsByName=new Map;getCodec(t){let e;if(typeof t=="string"?e=this.protocolsByName.get(t):e=this.protocolsByCode.get(t),e==null)throw new Hr(`Protocol ${t} was unknown`);return e}addCodec(t,e,n){this.protocolsByCode.set(t,e),this.protocolsByName.set(e.name,e),n?.forEach(o=>{this.protocolsByName.set(o,e)})}deleteCodec(t){let e=this.getCodec(t);e!=null&&(this.protocolsByCode.delete(e.code),this.protocolsByName.delete(e.name),e.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},bt=new Io,vu=[{code:4,name:"ip4",size:32,valueToBytes:Ao,bytesToValue:Ri,validate:r=>{if(!qr(r))throw new Nt(`Invalid IPv4 address "${r}"`)}},{code:6,name:"tcp",size:16,valueToBytes:ne,bytesToValue:Ce,validate:or},{code:273,name:"udp",size:16,valueToBytes:ne,bytesToValue:Ce,validate:or},{code:33,name:"dccp",size:16,valueToBytes:ne,bytesToValue:Ce,validate:or},{code:41,name:"ip6",size:128,valueToBytes:Ni,bytesToValue:Ki,stringToValue:ki,validate:r=>{if(!Li(r))throw new Nt(`Invalid IPv6 address "${r}"`)}},{code:42,name:"ip6zone",size:et},{code:43,name:"ipcidr",size:8,bytesToValue:Eo("base10"),valueToBytes:So("base10")},{code:53,name:"dns",size:et,resolvable:!0},{code:54,name:"dns4",size:et,resolvable:!0},{code:55,name:"dns6",size:et,resolvable:!0},{code:56,name:"dnsaddr",size:et,resolvable:!0},{code:132,name:"sctp",size:16,valueToBytes:ne,bytesToValue:Ce,validate:or},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:et,path:!0,stringToValue:r=>decodeURIComponent(r),valueToString:r=>encodeURIComponent(r)},{code:421,name:"p2p",aliases:["ipfs"],size:et,bytesToValue:Eo("base58btc"),valueToBytes:r=>r.startsWith("Q")||r.startsWith("1")?So("base58btc")(r):Y.parse(r).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:vo,valueToBytes:Oi},{code:445,name:"onion3",size:296,bytesToValue:vo,valueToBytes:Ui},{code:446,name:"garlic64",size:et},{code:447,name:"garlic32",size:et},{code:448,name:"tls"},{code:449,name:"sni",size:et},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:et,bytesToValue:Hi(bn),valueToBytes:Mi},{code:480,name:"http"},{code:481,name:"http-path",size:et,stringToValue:r=>`/${decodeURIComponent(r)}`,valueToString:r=>encodeURIComponent(r.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:et}];vu.forEach(r=>{bt.addCodec(r.code,r,r.aliases)});function Vi(r){let t=[],e=0;for(;e<r.length;){let n=Qn(r,e),o=bt.getCodec(n),s=Bt(n),i=Au(o,r,e+s),a=0;i>0&&o.size===et&&(a=Bt(i));let c=s+a+i,l={code:n,name:o.name,bytes:r.subarray(e,e+c)};if(i>0){let f=e+s+a,u=r.subarray(f,f+i);l.value=o.bytesToValue?.(u)??H(u)}t.push(l),e+=c}return t}function zi(r){let t=0,e=[];for(let n of r){if(n.bytes==null){let o=bt.getCodec(n.code),s=Bt(n.code),i,a=0,c=0;n.value!=null&&(i=o.valueToBytes?.(n.value)??nt(n.value),a=i.byteLength,o.size===et&&(c=Bt(a)));let l=new Uint8Array(s+c+a),f=0;Ze(n.code,l,f),f+=s,i!=null&&(o.size===et&&(Ze(a,l,f),f+=c),l.set(i,f)),n.bytes=l}e.push(n.bytes),t+=n.bytes.byteLength}return Tt(e,t)}function qi(r){if(r.charAt(0)!=="/")throw new tt('String multiaddr must start with "/"');let t=[],e="protocol",n="",o="";for(let s=1;s<r.length;s++){let i=r.charAt(s);i!=="/"&&(e==="protocol"?o+=r.charAt(s):n+=r.charAt(s));let a=s===r.length-1;if(i==="/"||a){let c=bt.getCodec(o);if(e==="protocol"){if(c.size==null||c.size===0){t.push({code:c.code,name:c.name}),n="",o="",e="protocol";continue}else if(a)throw new tt(`Component ${o} was missing value`);e="value"}else if(e==="value"){let l={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new tt(`Component ${o} was missing value`);l.value=c.stringToValue?.(n)??n}t.push(l),n="",o="",e="protocol"}}}if(o!==""&&n!=="")throw new tt("Incomplete multiaddr");return t}function Fi(r){return`/${r.flatMap(t=>{if(t.value==null)return t.name;let e=bt.getCodec(t.code);if(e==null)throw new tt(`Unknown protocol code ${t.code}`);return[t.name,e.valueToString?.(t.value)??t.value]}).join("/")}`}function Au(r,t,e){return r.size==null||r.size===0?0:r.size>0?r.size/8:Qn(t,e)}var Iu=Symbol.for("nodejs.util.inspect.custom"),Oo=Symbol.for("@multiformats/multiaddr"),Bu=[53,54,55,56],Lo=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}};function Cu(r){if(r==null&&(r="/"),Gi(r))return r.getComponents();if(r instanceof Uint8Array)return Vi(r);if(typeof r=="string")return r=r.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),r===""&&(r="/"),qi(r);if(Array.isArray(r))return r;throw new tt("Must be a string, Uint8Array, Component[], or another Multiaddr")}var $r=class r{[Oo]=!0;#t;#e;#r;constructor(t="/",e={}){this.#t=Cu(t),e.validate!==!1&&_u(this)}get bytes(){return this.#r==null&&(this.#r=zi(this.#t)),this.#r}toString(){return this.#e==null&&(this.#e=Fi(this.#t)),this.#e}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="";for(let{code:a,name:c,value:l}of this.#t)a===42&&(s=`%${l??""}`),Bu.includes(a)&&(e="tcp",o=443,n=`${l??""}${s}`,t=a===55?6:4),(a===6||a===273)&&(e=c==="tcp"?"tcp":"udp",o=parseInt(l??"")),(a===4||a===41)&&(e="tcp",n=`${l??""}${s}`,t=a===41?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}getComponents(){return[...this.#t]}protos(){return this.#t.map(({code:t,value:e})=>{let n=bt.getCodec(t);return{code:t,size:n.size??0,name:n.name,resolvable:!!n.resolvable,path:!!n.path}})}protoCodes(){return this.#t.map(({code:t})=>t)}protoNames(){return this.#t.map(({name:t})=>t)}tuples(){return this.#t.map(({code:t,value:e})=>{if(e==null)return[t];let n=bt.getCodec(t),o=[t];return e!=null&&o.push(n.valueToBytes?.(e)??nt(e)),o})}stringTuples(){return this.#t.map(({code:t,value:e})=>e==null?[t]:[t,e])}encapsulate(t){let e=new r(t);return new r([...this.#t,...e.getComponents()],{validate:!1})}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new nr(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o),{validate:!1})}decapsulateCode(t){let e;for(let n=this.#t.length-1;n>-1;n--)if(this.#t[n].code===t){e=n;break}return new r(this.#t.slice(0,e),{validate:!1})}getPeerId(){try{let t=[];this.#t.forEach(({code:n,value:o})=>{n===421&&t.push([n,o]),n===290&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?H(G.decode(`z${n}`),"base58btc"):H(Y.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){for(let t of this.#t)if(bt.getCodec(t.code).path)return t.value??null;return null}equals(t){return lt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=ji.get(e.name);if(n==null)throw new Lo(`no available resolver for ${e.name}`);return(await n(this,t)).map(s=>Ft(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(){return!(this.#t.length!==2||this.#t[0].code!==4&&this.#t[0].code!==41||this.#t[1].code!==6&&this.#t[1].code!==273)}[Iu](){return`Multiaddr(${this.toString()})`}};function _u(r){r.getComponents().forEach(t=>{let e=bt.getCodec(t.code);t.value!=null&&e.validate?.(t.value)})}var Om=parseInt("0xFFFF",16),Um=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var ji=new Map;function Gi(r){return!!r?.[Oo]}function Ft(r){return new $r(r)}var Ou=A("dns4"),Uu=A("dns6"),Nu=A("dnsaddr"),se=$(A("dns"),Nu,Ou,Uu),Xr=$(A("ip4"),A("ip6")),_e=$(O(Xr,A("tcp")),O(se,A("tcp"))),Qr=O(Xr,A("udp")),Ru=O(Qr,A("utp")),Ku=O(Qr,A("quic")),ku=O(Qr,A("quic-v1")),Uo=$(O(_e,A("ws")),O(se,A("ws"))),Zr=$(O(Uo,A("p2p")),Uo),No=$(O(_e,A("wss")),O(se,A("wss")),O(_e,A("tls"),A("ws")),O(se,A("tls"),A("ws"))),Yr=$(O(No,A("p2p")),No),Ro=$(O(_e,A("http")),O(Xr,A("http")),O(se,A("http"))),Ko=$(O(_e,A("https")),O(Xr,A("https")),O(se,A("https"))),Zi=O(Qr,A("webrtc-direct"),A("certhash")),Qi=$(O(Zi,A("p2p")),Zi),Yi=O(ku,A("webtransport"),A("certhash"),A("certhash")),Ji=$(O(Yi,A("p2p")),Yi),ta=$(O(Zr,A("p2p-webrtc-star"),A("p2p")),O(Yr,A("p2p-webrtc-star"),A("p2p")),O(Zr,A("p2p-webrtc-star")),O(Yr,A("p2p-webrtc-star"))),wy=$(O(Zr,A("p2p-websocket-star"),A("p2p")),O(Yr,A("p2p-websocket-star"),A("p2p")),O(Zr,A("p2p-websocket-star")),O(Yr,A("p2p-websocket-star"))),ea=$(O(Ro,A("p2p-webrtc-direct"),A("p2p")),O(Ko,A("p2p-webrtc-direct"),A("p2p")),O(Ro,A("p2p-webrtc-direct")),O(Ko,A("p2p-webrtc-direct"))),ie=$(Uo,No,Ro,Ko,ta,ea,_e,Ru,Ku,se,Qi,Ji),Ey=$(O(ie,A("p2p-stardust"),A("p2p")),O(ie,A("p2p-stardust"))),jt=$(O(ie,A("p2p")),ta,ea,Qi,Ji,A("p2p")),Xi=$(O(jt,A("p2p-circuit"),jt),O(jt,A("p2p-circuit")),O(A("p2p-circuit"),jt),O(ie,A("p2p-circuit")),O(A("p2p-circuit"),ie),A("p2p-circuit")),ra=()=>$(O(Xi,ra),Xi),oe=ra(),na=$(O(oe,jt,oe),O(jt,oe),O(oe,jt),oe,jt);var Sy=$(O(oe,A("webrtc"),A("p2p")),O(oe,A("webrtc")),O(ie,A("webrtc"),A("p2p")),O(ie,A("webrtc")),A("webrtc"));function oa(r){function t(e){let n;try{n=Ft(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function O(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(o=>(n=typeof o=="function"?o().partialMatch(e):o.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:oa(t),partialMatch:t}}function $(...r){function t(n){let o=null;return r.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:oa(t),partialMatch:t}}function A(r){let t=r;function e(o){let s;try{s=Ft(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var Mu="bootstrap",Hu=50,Vu=1e3,ko=class extends fr{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(t,e={list:[]}){if(e.list==null||e.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super(),this.components=t,this.log=t.logger.forComponent("libp2p:bootstrap"),this.timeout=e.timeout??Vu,this.list=[];for(let n of e.list){if(!na.matches(n)){this.log.error("Invalid multiaddr");continue}let o=Ft(n),s=o.getPeerId();if(s==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let i={id:Ti(s),multiaddrs:[o]};this.list.push(i)}this._init=e}[Mo]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[Ho]=["@libp2p/peer-discovery"];isStarted(){return!!this.timer}start(){this.isStarted()||(this.log("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(t=>{this.log.error(t)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(let t of this.list){if(await this.components.peerStore.merge(t.id,{tags:{[this._init.tagName??Mu]:{value:this._init.tagValue??Hu,ttl:this._init.tagTTL}},multiaddrs:t.multiaddrs}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t}),this.components.connectionManager.openConnection(t.id).catch(e=>{this.log.error("could not dial bootstrap peer %p",t.id,e)})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function zu(r){return t=>new ko(t,r)}return fa(qu);})();
3
3
  /*! Bundled license information:
4
4
 
5
5
  @noble/hashes/esm/utils.js: