@libp2p/bootstrap 12.0.28 → 12.0.29-d5534174d

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 _n=Object.defineProperty;var ra=Object.getOwnPropertyDescriptor;var na=Object.getOwnPropertyNames;var oa=Object.prototype.hasOwnProperty;var wt=(e,t)=>{for(var r in t)_n(e,r,{get:t[r],enumerable:!0})},sa=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of na(t))!oa.call(e,o)&&o!==r&&_n(e,o,{get:()=>t[o],enumerable:!(n=ra(t,o))||n.enumerable});return e};var ia=e=>sa(_n({},"__esModule",{value:!0}),e);var Al={};wt(Al,{bootstrap:()=>vl});var Rt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Er=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Sr=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},vr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var qe=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Us=Symbol.for("@libp2p/peer-discovery");var In=Symbol.for("@libp2p/peer-id");function ca(e){return typeof e?.handleEvent=="function"}function aa(e){return(e!==!0&&e!==!1&&e?.once)??!1}var Ar=class extends EventTarget{#t=new Map;constructor(){super()}listenerCount(t){let r=this.#t.get(t);return r==null?0:r.length}addEventListener(t,r,n){let o=aa(n);super.addEventListener(t,i=>{if(o){let c=this.#t.get(i.type);c!=null&&(c=c.filter(({callback:f})=>f!==r),this.#t.set(i.type,c))}ca(r)?r.handleEvent(i):r(i)},n);let s=this.#t.get(t);s==null&&(s=[],this.#t.set(t,s)),s.push({callback:r,once:o})}removeEventListener(t,r,n){super.removeEventListener(t.toString(),r??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==r),this.#t.set(t,o))}safeDispatchEvent(t,r={}){return this.dispatchEvent(new CustomEvent(t,r))}};var Ns=Symbol.for("@libp2p/service-capabilities");var Ln={};wt(Ln,{base58btc:()=>et,base58flickr:()=>ya});var ed=new Uint8Array(0);function Ks(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function At(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return ie(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return ie(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));throw new Error("Unknown type, must be binary type")}function ks(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}var Fs=4096;function Ms(e){let t=e.length;if(t<=Fs)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.subarray(n,n+=Fs));return r}function fa(e){return e?.buffer instanceof ArrayBuffer}function ie(e){return fa(e)?e:e.slice()}function ua(e,t,r){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),o=0;o<n.length;o++)n[o]=255;for(var s=0;s<e.length;s++){var i=e.charAt(s),c=i.charCodeAt(0);if(n[c]!==255)throw new TypeError(i+" is ambiguous");if(n[c]=s,r){var f=i.toLowerCase().charCodeAt(0),a=i.toUpperCase().charCodeAt(0);f!==c&&(n[f]=s),a!==c&&(n[a]=s)}}var u=e.length,l=e.charAt(0),x=Math.log(u)/Math.log(256),h=Math.log(256)/Math.log(u);function v(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var w=0,A=0,L=0,T=p.length;L!==T&&p[L]===0;)L++,w++;for(var N=(T-L)*h+1>>>0,O=new Uint8Array(N);L!==T;){for(var B=p[L],F=0,K=N-1;(B!==0||F<A)&&K!==-1;K--,F++)B+=256*O[K]>>>0,O[K]=B%u>>>0,B=B/u>>>0;if(B!==0)throw new Error("Non-zero carry");A=F,L++}for(var U=N-A;U!==N&&O[U]===0;)U++;for(var d=l.repeat(w);U<N;++U)d+=e.charAt(O[U]);return d}function I(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var w=0;if(p[w]!==" "){for(var A=0,L=0;p[w]===l;)A++,w++;for(var T=(p.length-w)*x+1>>>0,N=new Uint8Array(T);p[w];){var O=n[p.charCodeAt(w)];if(O===255)return;for(var B=0,F=T-1;(O!==0||B<L)&&F!==-1;F--,B++)O+=u*N[F]>>>0,N[F]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");L=B,w++}if(p[w]!==" "){for(var K=T-L;K!==T&&N[K]===0;)K++;for(var U=new Uint8Array(A+(T-K)),d=A;K!==T;)U[d++]=N[K++];return U}}}function m(p){var w=I(p);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:v,decodeUnsafe:I,decode:m}}var la=ua,da=la,Hs=da;var Cn=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Tn=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.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 qs(this,t)}},Dn=class{decoders;constructor(t){this.decoders=t}or(t){return qs(this,t)}decode(t){let r=t[0],n=this.decoders[r];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 qs(e,t){return new Dn({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var On=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Cn(t,r,n),this.decoder=new Tn(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function xe({name:e,prefix:t,encode:r,decode:n}){return new On(e,t,r,n)}function Yt({name:e,prefix:t,alphabet:r,caseInsensitive:n=!1}){let{encode:o,decode:s}=Hs(r,e,n);return xe({prefix:t,name:e,encode:o,decode:i=>At(s(i))})}function ha(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),i=0,c=0,f=0;for(let a=0;a<o;++a){let u=t[e[a]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|u,i+=r,i>=8&&(i-=8,s[f++]=255&c>>i)}if(i>=r||(255&c<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function pa(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,c=0;for(let f=0;f<e.length;++f)for(c=c<<8|e[f],i+=8;i>r;)i-=r,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<r-i]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function ma(e,t){let r={};for(let n=0;n<e.length;++n)if(r[e[n]]=n,t){let o=e[n].toLowerCase(),s=e[n].toUpperCase();o!==e[n]&&(r[o]=n),s!==e[n]&&(r[s]=n)}return r}function W({name:e,prefix:t,bitsPerChar:r,alphabet:n,caseInsensitive:o=!1}){let s=ma(n,o);return xe({prefix:t,name:e,encode(i){return pa(i,n,r)},decode(i){return ha(i,s,r,e)}})}var et=Yt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ya=Yt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Rn={};wt(Rn,{base32:()=>Gt,base32hex:()=>wa,base32hexpad:()=>Sa,base32hexpadupper:()=>va,base32hexupper:()=>Ea,base32pad:()=>ga,base32padupper:()=>xa,base32upper:()=>ba,base32z:()=>Aa});var Gt=W({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5,caseInsensitive:!0}),ba=W({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5,caseInsensitive:!0}),ga=W({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5,caseInsensitive:!0}),xa=W({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5,caseInsensitive:!0}),wa=W({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5,caseInsensitive:!0}),Ea=W({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5,caseInsensitive:!0}),Sa=W({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5,caseInsensitive:!0}),va=W({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5,caseInsensitive:!0}),Aa=W({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Pn={};wt(Pn,{base36:()=>ze,base36upper:()=>Ba});var ze=Yt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz",caseInsensitive:!0}),Ba=Yt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",caseInsensitive:!0});var _a=Zs,zs=128,Ia=127,Ca=~Ia,Ta=Math.pow(2,31);function Zs(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Ta;)t[r++]=e&255|zs,e/=128;for(;e&Ca;)t[r++]=e&255|zs,e>>>=7;return t[r]=e|0,Zs.bytes=r-n+1,t}var Da=Un,Oa=128,js=127;function Un(e,n){var r=0,n=n||0,o=0,s=n,i,c=e.length;do{if(s>=c)throw Un.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&js)<<o:(i&js)*Math.pow(2,o),o+=7}while(i>=Oa);return Un.bytes=s-n,r}var La=Math.pow(2,7),Ra=Math.pow(2,14),Pa=Math.pow(2,21),Ua=Math.pow(2,28),Na=Math.pow(2,35),Fa=Math.pow(2,42),Ka=Math.pow(2,49),ka=Math.pow(2,56),Ma=Math.pow(2,63),Va=function(e){return e<La?1:e<Ra?2:e<Pa?3:e<Ua?4:e<Na?5:e<Fa?6:e<Ka?7:e<ka?8:e<Ma?9:10},Ha={encode:_a,decode:Da,encodingLength:Va},qa=Ha,je=qa;function Ze(e,t=0){let r=je.decode(e,t),n=je.decode.bytes;if(n>9)throw new RangeError("Invalid varint: too long");if(n>1&&e[t+n-1]===0)throw new RangeError("Invalid varint: not minimally encoded");return[r,n]}function we(e,t,r=0){return je.encode(e,t,r),t}function Ee(e){return je.encodingLength(e)}function ve(e,t){let r=t.byteLength,n=Ee(e),o=n+Ee(r),s=new Uint8Array(o+r);return we(e,s,0),we(r,s,n),s.set(t,o),new Se(e,r,t,s)}function $e(e){let t=At(e),[r,n]=Ze(t),[o,s]=Ze(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Se(r,o,i,t)}function $s(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Ks(e.bytes,r.bytes)}}var Se=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=ie(n),this.bytes=ie(o)}};function Ys(e,t){let{bytes:r,version:n}=e;return n===0?ja(r,Nn(e),t??et.encoder):Za(r,Nn(e),t??Gt.encoder)}var Gs=new WeakMap;function Nn(e){let t=Gs.get(e);if(t==null){let r=new Map;return Gs.set(e,r),r}return t}var at=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=ie(o),this["/"]=this.bytes}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:r}=this;if(t!==Ye)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==$a)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}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:r}=this.multihash,n=ve(t,r);return e.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 e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&$s(t.multihash,n.multihash)}toString(t){return Ys(this,t)}toJSON(){return{"/":Ys(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 r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new e(n,o,s,i??Ws(n,o,s.bytes))}else if(r[Ya]===!0){let{version:n,multihash:o,code:s}=r,i=$e(o);return e.create(n,s,i)}else return null}static create(t,r,n){if(typeof r!="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(r!==Ye)throw new Error(`Version 0 CID must use dag-pb (code: ${Ye}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Ws(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Ye,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=At(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new Se(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(i):e.createV1(r.codec,i),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[l,x]=Ze(t.subarray(r));return r+=x,l},o=n(),s=Ye;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,c=n(),f=n(),a=r+f,u=a-i;return{version:o,codec:s,multihashCode:c,digestSize:f,multihashSize:u,size:a}}static parse(t,r){let[n,o]=za(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Nn(s).set(n,t),s}};function za(e,t){switch(e[0]){case"Q":{let r=t??et;return[et.prefix,r.decode(`${et.prefix}${e}`)]}case et.prefix:{let r=t??et;return[et.prefix,r.decode(e)]}case Gt.prefix:{let r=t??Gt;return[Gt.prefix,r.decode(e)]}case ze.prefix:{let r=t??ze;return[ze.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function ja(e,t,r){let{prefix:n}=r;if(n!==et.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function Za(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var Ye=112,$a=18;function Ws(e,t,r){let n=Ee(e),o=n+Ee(t),s=new Uint8Array(o+r.byteLength);return we(e,s,0),we(t,s,n),s.set(r,o),s}var Ya=Symbol.for("@ipld/js-cid/CID");var Fn={};wt(Fn,{identity:()=>Bt});var Xs=0,Ga="identity",Qs=At;function Wa(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return ve(Xs,Qs(e))}var Bt={code:Xs,name:Ga,encode:Qs,digest:Wa};function gt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Xa(e){return e.buffer instanceof ArrayBuffer}function _t(e){return Xa(e)?e:e.slice()}async function Js(e,t,r,n){let o=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,_t(t),_t(r.subarray()));return n?.signal?.throwIfAborted(),s}function Pt(e=0){return new Uint8Array(e)}function mt(e=0){return new Uint8Array(e)}function Qa(e){return e?.buffer instanceof ArrayBuffer}function Kn(e){if(Qa(e))return e;let t=e.slice();return new Uint8Array(t.buffer,0,t.byteLength)}function Ut(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=mt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return Kn(r)}var ei=Symbol.for("@achingbrain/uint8arraylist");function ti(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function _r(e){return!!e?.[ei]}var Et=class e{bufs;length;[ei]=!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 r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(_r(n)){r+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(_r(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=ti(this.bufs,t);return r.buf[r.index]}set(t,r){let n=ti(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(_r(t))for(let n=0;n<t.length;n++)this.set(r+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,r){let{bufs:n,length:o}=this._subList(t,r);return Ut(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:Ut(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),s=new e;return s.length=o,s.bufs=n,s}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===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],c=o,f=c+i.byteLength;if(o=f,t>=f)continue;let a=t>=c&&t<f,u=r>c&&r<=f;if(a&&u){if(t===c&&r===f){n.push(i);break}let l=t-c;n.push(i.subarray(l,l+(r-t)));break}if(a){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(u){if(r===f){n.push(i);break}n.push(i.subarray(0,r-c));break}n.push(i)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!_r(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(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let c=i,f=this.byteLength-n.byteLength,a=n.byteLength-1,u;for(let l=r;l<=f;l+=u){u=0;for(let x=a;x>=0;x--){let h=this.get(l+x);if(n[x]!==h){u=Math.max(1,x-c[h]);break}}if(u===0)return l}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=mt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=Pt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=Pt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=Pt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=mt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=Pt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=Pt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=Pt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=Pt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=Pt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!gt(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,s)=>o+s.byteLength,0)),n.length=r,n}};var kn={};wt(kn,{base10:()=>Ja});var Ja=Yt({prefix:"9",name:"base10",alphabet:"0123456789"});var Mn={};wt(Mn,{base16:()=>tf,base16upper:()=>ef});var tf=W({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4,caseInsensitive:!0}),ef=W({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4,caseInsensitive:!0});var Vn={};wt(Vn,{base2:()=>rf});var rf=W({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Hn={};wt(Hn,{base256emoji:()=>af});var ri=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}"),nf=ri.reduce((e,t,r)=>(e[r]=t,e),[]),of=ri.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function sf(e){return e.reduce((t,r)=>(t+=nf[r],t),"")}function cf(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=of[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var af=xe({prefix:"\u{1F680}",name:"base256emoji",encode:sf,decode:cf});var zn={};wt(zn,{base64:()=>ff,base64pad:()=>uf,base64url:()=>qn,base64urlpad:()=>lf});var ff=W({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),uf=W({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),qn=W({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),lf=W({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var jn={};wt(jn,{base8:()=>df});var df=W({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Zn={};wt(Zn,{identity:()=>hf});var hf=xe({prefix:"\0",name:"identity",encode:e=>Ms(At(e)),decode:e=>At(ks(e))});var Md=new TextEncoder,Vd=new TextDecoder;var Gn={};wt(Gn,{sha256:()=>Ge,sha512:()=>bf});var yf=20;function Yn({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new $n(e,t,r,n,o)}var $n=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,s){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??yf,this.maxDigestLength=s}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?ni(n,this.code,r?.truncate):n.then(o=>ni(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function ni(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return ve(t,e)}function si(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Ge=Yn({name:"sha2-256",code:18,encode:si("SHA-256")}),bf=Yn({name:"sha2-512",code:19,encode:si("SHA-512")});var We={...Zn,...Vn,...jn,...kn,...Mn,...Rn,...Pn,...Ln,...zn,...Hn},Jd={...Gn,...Fn};function ci(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var ii=ci("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Wn=ci("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=mt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),gf={utf8:ii,"utf-8":ii,hex:We.base16,latin1:Wn,ascii:Wn,binary:Wn,...We},Ir=gf;function xt(e,t="utf8"){let r=Ir[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function J(e,t="utf8"){let r=Ir[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var xf=parseInt("11111",2),Xn=parseInt("10000000",2),wf=parseInt("01111111",2),ai={0:Xe,1:Xe,2:Ef,3:Af,4:Bf,5:vf,6:Sf,16:Xe,22:Xe,48:Xe};function Qn(e,t={offset:0}){let r=e[t.offset]&xf;if(t.offset++,ai[r]!=null)return ai[r](e,t);throw new Error("No decoder for tag "+r)}function Qe(e,t){let r=0;if((e[t.offset]&Xn)===Xn){let n=e[t.offset]&wf,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=e[t.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=e[t.offset],t.offset++;return r}function Xe(e,t){Qe(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=Qn(e,t);if(n===null)break;r.push(n)}return r}function Ef(e,t){let r=Qe(e,t),n=t.offset,o=t.offset+r,s=[];for(let i=n;i<o;i++)i===n&&e[i]===0||s.push(e[i]);return t.offset+=r,Uint8Array.from(s)}function Sf(e,t){let r=Qe(e,t),n=t.offset+r,o=e[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 c=`${s}.${i}`,f=[];for(;t.offset<n;){let a=e[t.offset];if(t.offset++,f.push(a&127),a<128){f.reverse();let u=0;for(let l=0;l<f.length;l++)u+=f[l]<<l*7;c+=`.${u}`,f=[]}}return c}function vf(e,t){return t.offset++,null}function Af(e,t){let r=Qe(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Bf(e,t){let r=Qe(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function _f(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new Et;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Jn(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=_f(e.byteLength);return new Et(Uint8Array.from([t.byteLength|Xn]),t)}function fi(e){let t=new Et,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new Et(Uint8Array.from([2]),Jn(t),t)}function ui(e){let t=Uint8Array.from([0]),r=new Et(t,e);return new Et(Uint8Array.from([3]),Jn(r),r)}function Cr(e,t=48){let r=new Et;for(let n of e)r.append(n);return new Et(Uint8Array.from([t]),Jn(r),r)}var If=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Cf=Uint8Array.from([6,5,43,129,4,0,34]),Tf=Uint8Array.from([6,5,43,129,4,0,35]),Df={ext:!0,kty:"EC",crv:"P-256"},Of={ext:!0,kty:"EC",crv:"P-384"},Lf={ext:!0,kty:"EC",crv:"P-521"},to=32,eo=48,ro=66;function li(e){let t=Qn(e);return di(t)}function di(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===to*2+1)return n=J(t.subarray(r,r+to),"base64url"),o=J(t.subarray(r+to),"base64url"),new Be({...Df,key_ops:["verify"],x:n,y:o});if(t.byteLength===eo*2+1)return n=J(t.subarray(r,r+eo),"base64url"),o=J(t.subarray(r+eo),"base64url"),new Be({...Of,key_ops:["verify"],x:n,y:o});if(t.byteLength===ro*2+1)return n=J(t.subarray(r,r+ro),"base64url"),o=J(t.subarray(r+ro),"base64url"),new Be({...Lf,key_ops:["verify"],x:n,y:o});throw new Rt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function hi(e){return Cr([fi(Uint8Array.from([1])),Cr([Rf(e.crv)],160),Cr([ui(new Et(Uint8Array.from([4]),xt(e.x??"","base64url"),xt(e.y??"","base64url")))],161)]).subarray()}function Rf(e){if(e==="P-256")return If;if(e==="P-384")return Cf;if(e==="P-521")return Tf;throw new Rt(`Invalid curve ${e}`)}var Be=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=hi(this.jwk)),this._raw}toMultihash(){return Bt.digest(_e(this))}toCID(){return at.createV1(114,this.toMultihash())}toString(){return et.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:gt(this.raw,t.raw)}async verify(t,r,n){return Js(this.jwk,r,t,n)}};function no(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Wt(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new RangeError(`${r}expected integer >= 0, got ${e}`)}}function St(e,t,r=""){let n=no(e),o=e?.length,s=t!==void 0;if(!n||s&&o!==t){let i=r&&`"${r}" `,c=s?` of length ${t}`:"",f=n?`length=${o}`:`type=${typeof e}`,a=i+"expected Uint8Array"+c+", got "+f;throw n?new RangeError(a):new TypeError(a)}return e}function Tr(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(Wt(e.outputLen),Wt(e.blockLen),e.outputLen<1)throw new Error('"outputLen" must be >= 1');if(e.blockLen<1)throw new Error('"blockLen" must be >= 1')}function Ie(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Dr(e,t){St(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function Vt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Or(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function It(e,t){return e<<32-t|e>>>t}var mi=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Pf=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Lr(e){if(St(e),mi)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Pf[e[r]];return t}var Mt={_0:48,_9:57,A:65,F:70,a:97,f:102};function pi(e){if(e>=Mt._0&&e<=Mt._9)return e-Mt._0;if(e>=Mt.A&&e<=Mt.F)return e-(Mt.A-10);if(e>=Mt.a&&e<=Mt.f)return e-(Mt.a-10)}function Je(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(mi)try{return Uint8Array.fromHex(e)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=pi(e.charCodeAt(s)),c=pi(e.charCodeAt(s+1));if(i===void 0||c===void 0){let f=e[s]+e[s+1];throw new RangeError('hex string expected, got non-hex character "'+f+'" at index '+s)}n[o]=i*16+c}return n}function oo(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];St(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}function so(e,t={}){let r=(o,s)=>e(s).update(o).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}function yi(e=32){Wt(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var io=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function bi(e,t,r){return e&t^~e&r}function gi(e,t,r){return e&t^e&r^t&r}var tr=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,o){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=Or(this.buffer)}update(t){Ie(this),St(t);let{view:r,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let f=Or(t);for(;o<=s-i;i+=o)this.process(f,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ie(this),Dr(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,Vt(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)r[l]=0;n.setBigUint64(o-8,BigInt(this.length*8),s),this.process(n,0);let c=Or(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let a=f/4,u=this.get();if(a>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<a;l++)c.setUint32(4*l,u[l],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=c,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Ht=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ft=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Rr=BigInt(4294967295),xi=BigInt(32);function Uf(e,t=!1){return t?{h:Number(e&Rr),l:Number(e>>xi&Rr)}:{h:Number(e>>xi&Rr)|0,l:Number(e&Rr)|0}}function wi(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:c}=Uf(e[s],t);[n[s],o[s]]=[i,c]}return[n,o]}var co=(e,t,r)=>e>>>r,ao=(e,t,r)=>e<<32-r|t>>>r,ce=(e,t,r)=>e>>>r|t<<32-r,ae=(e,t,r)=>e<<32-r|t>>>r,er=(e,t,r)=>e<<64-r|t>>>r-32,rr=(e,t,r)=>e>>>r-32|t<<64-r;function Nt(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Ei=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Si=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,vi=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Ai=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Bi=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),_i=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;var Ff=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]),Xt=new Uint32Array(64),fo=class extends tr{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:c,H:f}=this;return[t,r,n,o,s,i,c,f]}set(t,r,n,o,s,i,c,f){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=f|0}process(t,r){for(let l=0;l<16;l++,r+=4)Xt[l]=t.getUint32(r,!1);for(let l=16;l<64;l++){let x=Xt[l-15],h=Xt[l-2],v=It(x,7)^It(x,18)^x>>>3,I=It(h,17)^It(h,19)^h>>>10;Xt[l]=I+Xt[l-7]+v+Xt[l-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:f,G:a,H:u}=this;for(let l=0;l<64;l++){let x=It(c,6)^It(c,11)^It(c,25),h=u+x+bi(c,f,a)+Ff[l]+Xt[l]|0,I=(It(n,2)^It(n,13)^It(n,22))+gi(n,o,s)|0;u=a,a=f,f=c,c=i+h|0,i=s,s=o,o=n,n=h+I|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,f=f+this.F|0,a=a+this.G|0,u=u+this.H|0,this.set(n,o,s,i,c,f,a,u)}roundClean(){Vt(Xt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Vt(this.buffer)}},uo=class extends fo{A=Ht[0]|0;B=Ht[1]|0;C=Ht[2]|0;D=Ht[3]|0;E=Ht[4]|0;F=Ht[5]|0;G=Ht[6]|0;H=Ht[7]|0;constructor(){super(32)}};var Ii=wi(["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(e=>BigInt(e))),Kf=Ii[0],kf=Ii[1],Qt=new Uint32Array(80),Jt=new Uint32Array(80),lo=class extends tr{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:f,Eh:a,El:u,Fh:l,Fl:x,Gh:h,Gl:v,Hh:I,Hl:m}=this;return[t,r,n,o,s,i,c,f,a,u,l,x,h,v,I,m]}set(t,r,n,o,s,i,c,f,a,u,l,x,h,v,I,m){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=f|0,this.Eh=a|0,this.El=u|0,this.Fh=l|0,this.Fl=x|0,this.Gh=h|0,this.Gl=v|0,this.Hh=I|0,this.Hl=m|0}process(t,r){for(let A=0;A<16;A++,r+=4)Qt[A]=t.getUint32(r),Jt[A]=t.getUint32(r+=4);for(let A=16;A<80;A++){let L=Qt[A-15]|0,T=Jt[A-15]|0,N=ce(L,T,1)^ce(L,T,8)^co(L,T,7),O=ae(L,T,1)^ae(L,T,8)^ao(L,T,7),B=Qt[A-2]|0,F=Jt[A-2]|0,K=ce(B,F,19)^er(B,F,61)^co(B,F,6),U=ae(B,F,19)^rr(B,F,61)^ao(B,F,6),d=vi(O,U,Jt[A-7],Jt[A-16]),y=Ai(d,N,K,Qt[A-7],Qt[A-16]);Qt[A]=y|0,Jt[A]=d|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:f,Dh:a,Dl:u,Eh:l,El:x,Fh:h,Fl:v,Gh:I,Gl:m,Hh:p,Hl:w}=this;for(let A=0;A<80;A++){let L=ce(l,x,14)^ce(l,x,18)^er(l,x,41),T=ae(l,x,14)^ae(l,x,18)^rr(l,x,41),N=l&h^~l&I,O=x&v^~x&m,B=Bi(w,T,O,kf[A],Jt[A]),F=_i(B,p,L,N,Kf[A],Qt[A]),K=B|0,U=ce(n,o,28)^er(n,o,34)^er(n,o,39),d=ae(n,o,28)^rr(n,o,34)^rr(n,o,39),y=n&s^n&c^s&c,E=o&i^o&f^i&f;p=I|0,w=m|0,I=h|0,m=v|0,h=l|0,v=x|0,{h:l,l:x}=Nt(a|0,u|0,F|0,K|0),a=c|0,u=f|0,c=s|0,f=i|0,s=n|0,i=o|0;let g=Ei(K,d,E);n=Si(g,F,U,y),o=g|0}({h:n,l:o}=Nt(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=Nt(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:f}=Nt(this.Ch|0,this.Cl|0,c|0,f|0),{h:a,l:u}=Nt(this.Dh|0,this.Dl|0,a|0,u|0),{h:l,l:x}=Nt(this.Eh|0,this.El|0,l|0,x|0),{h,l:v}=Nt(this.Fh|0,this.Fl|0,h|0,v|0),{h:I,l:m}=Nt(this.Gh|0,this.Gl|0,I|0,m|0),{h:p,l:w}=Nt(this.Hh|0,this.Hl|0,p|0,w|0),this.set(n,o,s,i,c,f,a,u,l,x,h,v,I,m,p,w)}roundClean(){Vt(Qt,Jt)}destroy(){this.destroyed=!0,Vt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},ho=class extends lo{Ah=ft[0]|0;Al=ft[1]|0;Bh=ft[2]|0;Bl=ft[3]|0;Ch=ft[4]|0;Cl=ft[5]|0;Dh=ft[6]|0;Dl=ft[7]|0;Eh=ft[8]|0;El=ft[9]|0;Fh=ft[10]|0;Fl=ft[11]|0;Gh=ft[12]|0;Gl=ft[13]|0;Hh=ft[14]|0;Hl=ft[15]|0;constructor(){super(64)}};var Ci=so(()=>new uo,io(1));var Pr=so(()=>new ho,io(3));var H=(e,t,r)=>St(e,t,r),mo=Wt,Ce=Lr,nt=(...e)=>oo(...e),Te=e=>Je(e),fe=no,nr=e=>yi(e),Nr=BigInt(0),po=BigInt(1);function Ct(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new TypeError(r+"expected boolean, got type="+typeof e)}return e}function Fr(e){if(typeof e=="bigint"){if(!Ur(e))throw new RangeError("positive bigint expected, got "+e)}else mo(e);return e}function Tt(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function or(e){let t=Fr(e).toString(16);return t.length&1?"0"+t:t}function Ti(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?Nr:BigInt("0x"+e)}function ue(e){return Ti(Lr(e))}function Ft(e){return Ti(Lr(sr(St(e)).reverse()))}function Kr(e,t){if(Wt(t),t===0)throw new RangeError("zero length");e=Fr(e);let r=e.toString(16);if(r.length>t*2)throw new RangeError("number too large");return Je(r.padStart(t*2,"0"))}function yo(e,t){return Kr(e,t).reverse()}function Di(e,t){if(e=H(e),t=H(t),e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function sr(e){return Uint8Array.from(H(e))}function kr(e){if(typeof e!="string")throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${n} at position ${r}`);return n})}var Ur=e=>typeof e=="bigint"&&Nr<=e;function Mf(e,t,r){return Ur(e)&&Ur(t)&&Ur(r)&&t<=e&&e<r}function De(e,t,r,n){if(!Mf(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Oe(e){if(e<Nr)throw new Error("expected non-negative bigint, got "+e);let t;for(t=0;e>Nr;e>>=po,t+=1);return t}var ir=e=>(po<<BigInt(e))-po;function Oi(e,t,r){if(Wt(e,"hashLen"),Wt(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=m=>new Uint8Array(m),o=Uint8Array.of(),s=Uint8Array.of(0),i=Uint8Array.of(1),c=1e3,f=n(e),a=n(e),u=0,l=()=>{f.fill(1),a.fill(0),u=0},x=(...m)=>r(a,nt(f,...m)),h=(m=o)=>{a=x(s,m),f=x(),m.length!==0&&(a=x(i,m),f=x())},v=()=>{if(u++>=c)throw new Error("drbg: tried max amount of iterations");let m=0,p=[];for(;m<t;){f=x();let w=f.slice();p.push(w),m+=f.length}return nt(...p)};return(m,p)=>{l(),h(m);let w;for(;(w=p(v()))===void 0;)h();return l(),w}}function Dt(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw new TypeError("expected valid options object");function n(s,i,c){if(!c&&i!=="function"&&!Object.hasOwn(e,s))throw new TypeError(`param "${s}" is invalid: expected own property`);let f=e[s];if(c&&f===void 0)return;let a=typeof f;if(a!==i||f===null)throw new TypeError(`param "${s}" is invalid: expected ${i}, got ${a}`)}let o=(s,i)=>Object.entries(s).forEach(([c,f])=>n(c,f,i));o(t,!1),o(r,!0)}var bo=()=>{throw new Error("not implemented")};var ut=BigInt(0),X=BigInt(1),le=BigInt(2),Ui=BigInt(3),Ni=BigInt(4),Fi=BigInt(5),Vf=BigInt(7),Ki=BigInt(8),Hf=BigInt(9),ki=BigInt(16);function tt(e,t){if(t<=ut)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=ut?r:t+r}function Y(e,t,r){if(t<ut)throw new Error("pow2: expected non-negative exponent, got "+t);let n=e;for(;t-- >ut;)n*=n,n%=r;return n}function Li(e,t){if(e===ut)throw new Error("invert: expected non-zero number");if(t<=ut)throw new Error("invert: expected positive modulus, got "+t);let r=tt(e,t),n=t,o=ut,s=X,i=X,c=ut;for(;r!==ut;){let a=n/r,u=n-r*a,l=o-i*a,x=s-c*a;n=r,r=u,o=i,s=c,i=l,c=x}if(n!==X)throw new Error("invert: does not exist");return tt(o,t)}function go(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function Mi(e,t){let r=e,n=(r.ORDER+X)/Ni,o=r.pow(t,n);return go(r,o,t),o}function qf(e,t){let r=e,n=(r.ORDER-Fi)/Ki,o=r.mul(t,le),s=r.pow(o,n),i=r.mul(t,s),c=r.mul(r.mul(i,le),s),f=r.mul(i,r.sub(c,r.ONE));return go(r,f,t),f}function zf(e){let t=Le(e),r=Vi(e),n=r(t,t.neg(t.ONE)),o=r(t,n),s=r(t,t.neg(n)),i=(e+Vf)/ki;return((c,f)=>{let a=c,u=a.pow(f,i),l=a.mul(u,n),x=a.mul(u,o),h=a.mul(u,s),v=a.eql(a.sqr(l),f),I=a.eql(a.sqr(x),f);u=a.cmov(u,l,v),l=a.cmov(h,x,I);let m=a.eql(a.sqr(l),f),p=a.cmov(u,l,m);return go(a,p,f),p})}function Vi(e){if(e<Ui)throw new Error("sqrt is not defined for small field");let t=e-X,r=0;for(;t%le===ut;)t/=le,r++;let n=le,o=Le(e);for(;Ri(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Mi;let s=o.pow(n,t),i=(t+X)/le;return function(f,a){let u=f;if(u.is0(a))return a;if(Ri(u,a)!==1)throw new Error("Cannot find square root");let l=r,x=u.mul(u.ONE,s),h=u.pow(a,t),v=u.pow(a,i);for(;!u.eql(h,u.ONE);){if(u.is0(h))return u.ZERO;let I=1,m=u.sqr(h);for(;!u.eql(m,u.ONE);)if(I++,m=u.sqr(m),I===l)throw new Error("Cannot find square root");let p=X<<BigInt(l-I-1),w=u.pow(x,p);l=I,x=u.sqr(w),h=u.mul(h,x),v=u.mul(v,w)}return v}}function jf(e){return e%Ni===Ui?Mi:e%Ki===Fi?qf:e%ki===Hf?zf(e):Vi(e)}var qt=(e,t)=>(tt(e,t)&X)===X,Zf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function xo(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Zf.reduce((n,o)=>(n[o]="function",n),t);if(Dt(e,r),Tt(e.BYTES,"BYTES"),Tt(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=X)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function $f(e,t,r){let n=e;if(r<ut)throw new Error("invalid exponent, negatives unsupported");if(r===ut)return n.ONE;if(r===X)return t;let o=n.ONE,s=t;for(;r>ut;)r&X&&(o=n.mul(o,s)),s=n.sqr(s),r>>=X;return o}function cr(e,t,r=!1){let n=e,o=new Array(t.length).fill(r?n.ZERO:void 0),s=t.reduce((c,f,a)=>n.is0(f)?c:(o[a]=c,n.mul(c,f)),n.ONE),i=n.inv(s);return t.reduceRight((c,f,a)=>n.is0(f)?c:(o[a]=n.mul(c,o[a]),n.mul(c,f)),i),o}function Ri(e,t){let r=e,n=(r.ORDER-X)/le,o=r.pow(t,n),s=r.eql(o,r.ONE),i=r.eql(o,r.ZERO),c=r.eql(o,r.neg(r.ONE));if(!s&&!i&&!c)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function Yf(e,t){if(t!==void 0&&mo(t),e<=ut)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=Oe(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let n=t!==void 0?t:r,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var Pi=new WeakMap,Mr=class{ORDER;BITS;BYTES;isLE;ZERO=ut;ONE=X;_lengths;_mod;constructor(t,r={}){if(t<=X)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:s}=Yf(t,n);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=s,Object.freeze(this)}create(t){return tt(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return ut<=t&&t<this.ORDER}is0(t){return t===ut}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&X)===X}neg(t){return tt(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return tt(t*t,this.ORDER)}add(t,r){return tt(t+r,this.ORDER)}sub(t,r){return tt(t-r,this.ORDER)}mul(t,r){return tt(t*r,this.ORDER)}pow(t,r){return $f(this,t,r)}div(t,r){return tt(t*Li(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return Li(t,this.ORDER)}sqrt(t){let r=Pi.get(this);return r||Pi.set(this,r=jf(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?yo(t,this.BYTES):Kr(t,this.BYTES)}fromBytes(t,r=!1){H(t);let{_lengths:n,BYTES:o,isLE:s,ORDER:i,_mod:c}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let a=new Uint8Array(o);a.set(t,s?0:a.length-t.length),t=a}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let f=s?Ft(t):ue(t);if(c&&(f=tt(f,i)),!r&&!this.isValid(f))throw new Error("invalid field element: outside of range 0..ORDER");return f}invertBatch(t){return cr(this,t)}cmov(t,r,n){return Ct(n,"condition"),n?r:t}};Object.freeze(Mr.prototype);function Le(e,t={}){return new Mr(e,t)}function Hi(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=X)throw new Error("field order must be greater than 1");let t=Oe(e-X);return Math.ceil(t/8)}function wo(e){let t=Hi(e);return t+Math.ceil(t/2)}function Eo(e,t,r=!1){H(e);let n=e.length,o=Hi(t),s=Math.max(wo(t),16);if(n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=r?Ft(e):ue(e),c=tt(i,t-X)+X;return r?yo(c,o):Kr(c,o)}var Re=BigInt(0),de=BigInt(1);function ar(e,t){let r=t.negate();return e?r:t}function he(e,t){let r=cr(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function Zi(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function So(e,t){Zi(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,s=ir(e),i=BigInt(e);return{windows:r,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function qi(e,t,r){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=r,c=Number(e&o),f=e>>i;c>n&&(c-=s,f+=de);let a=t*n,u=a+Math.abs(c)-1,l=c===0,x=c<0,h=t%2!==0;return{nextN:f,offset:u,isZero:l,isNeg:x,isNegF:h,offsetF:a}}var vo=new WeakMap,$i=new WeakMap;function Ao(e){return $i.get(e)||1}function zi(e){if(e!==Re)throw new Error("invalid wNAF")}var Pe=class{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let o=t;for(;r>Re;)r&de&&(n=n.add(o)),o=o.double(),r>>=de;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=So(r,this.bits),s=[],i=t,c=i;for(let f=0;f<n;f++){c=i,s.push(c);for(let a=1;a<o;a++)c=c.add(i),s.push(c);i=c.double()}return s}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE,i=So(t,this.bits);for(let c=0;c<i.windows;c++){let{nextN:f,offset:a,isZero:u,isNeg:l,isNegF:x,offsetF:h}=qi(n,c,i);n=f,u?s=s.add(ar(x,r[h])):o=o.add(ar(l,r[a]))}return zi(n),{p:o,f:s}}wNAFUnsafe(t,r,n,o=this.ZERO){let s=So(t,this.bits);for(let i=0;i<s.windows&&n!==Re;i++){let{nextN:c,offset:f,isZero:a,isNeg:u}=qi(n,i,s);if(n=c,!a){let l=r[f];o=o.add(u?l.negate():l)}}return zi(n),o}getPrecomputes(t,r,n){let o=vo.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),vo.set(r,o))),o}cached(t,r,n){let o=Ao(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let s=Ao(t);return s===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,n),r,o)}createCache(t,r){Zi(r,this.bits),$i.set(t,r),vo.delete(t)}hasCache(t){return Ao(t)!==1}};function Yi(e,t,r,n){let o=t,s=e.ZERO,i=e.ZERO;for(;r>Re||n>Re;)r&de&&(s=s.add(o)),n&de&&(i=i.add(o)),o=o.double(),r>>=de,n>>=de;return{p1:s,p2:i}}function ji(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return xo(t),t}else return Le(e,{isLE:r})}function Vr(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let f of["p","n","h"]){let a=t[f];if(!(typeof a=="bigint"&&a>Re))throw new Error(`CURVE.${f} must be positive bigint`)}let o=ji(t.p,r.Fp,n),s=ji(t.n,r.Fn,n),c=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let f of c)if(!o.isValid(t[f]))throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:s}}function Hr(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var te=BigInt(0),it=BigInt(1),Bo=BigInt(2),Gf=BigInt(8);function Wf(e,t,r,n){let o=e.sqr(r),s=e.sqr(n),i=e.add(e.mul(t.a,o),s),c=e.add(e.ONE,e.mul(t.d,e.mul(o,s)));return e.eql(i,c)}function Gi(e,t={}){let r=t,n=Vr("edwards",e,r,r.FpFnLE),{Fp:o,Fn:s}=n,i=n.CURVE,{h:c}=i;Dt(r,{},{uvRatio:"function"});let f=Bo<<BigInt(s.BYTES*8)-it,a=I=>o.create(I),u=r.uvRatio===void 0?(I,m)=>{try{return{isValid:!0,value:o.sqrt(o.div(I,m))}}catch{return{isValid:!1,value:te}}}:r.uvRatio;if(!Wf(o,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function l(I,m,p=!1){let w=p?it:te;return De("coordinate "+I,m,w,f),m}function x(I){if(!(I instanceof h))throw new Error("EdwardsPoint expected")}class h{static BASE=new h(i.Gx,i.Gy,it,a(i.Gx*i.Gy));static ZERO=new h(te,it,it,te);static Fp=o;static Fn=s;X;Y;Z;T;constructor(m,p,w,A){this.X=l("x",m),this.Y=l("y",p),this.Z=l("z",w,!0),this.T=l("t",A),Object.freeze(this)}static CURVE(){return i}static fromAffine(m){if(m instanceof h)throw new Error("extended point not allowed");let{x:p,y:w}=m||{};return l("x",p),l("y",w),new h(p,w,it,a(p*w))}static fromBytes(m,p=!1){let w=o.BYTES,{a:A,d:L}=i;m=sr(H(m,w,"point")),Ct(p,"zip215");let T=sr(m),N=m[w-1];T[w-1]=N&-129;let O=Ft(T),B=p?f:o.ORDER;De("point.y",O,te,B);let F=a(O*O),K=a(F-it),U=a(L*F-A),{isValid:d,value:y}=u(K,U);if(!d)throw new Error("bad point: invalid y coordinate");let E=(y&it)===it,g=(N&128)!==0;if(!p&&y===te&&g)throw new Error("bad point: x=0 and x_0=1");return g!==E&&(y=a(-y)),h.fromAffine({x:y,y:O})}static fromHex(m,p=!1){return h.fromBytes(Te(m),p)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(m=8,p=!0){return v.createCache(this,m),p||this.multiply(Bo),this}assertValidity(){let m=this,{a:p,d:w}=i;if(m.is0())throw new Error("bad point: ZERO");let{X:A,Y:L,Z:T,T:N}=m,O=a(A*A),B=a(L*L),F=a(T*T),K=a(F*F),U=a(O*p),d=a(F*a(U+B)),y=a(K+a(w*a(O*B)));if(d!==y)throw new Error("bad point: equation left != right (1)");let E=a(A*L),g=a(T*N);if(E!==g)throw new Error("bad point: equation left != right (2)")}equals(m){x(m);let{X:p,Y:w,Z:A}=this,{X:L,Y:T,Z:N}=m,O=a(p*N),B=a(L*A),F=a(w*N),K=a(T*A);return O===B&&F===K}is0(){return this.equals(h.ZERO)}negate(){return new h(a(-this.X),this.Y,this.Z,a(-this.T))}double(){let{a:m}=i,{X:p,Y:w,Z:A}=this,L=a(p*p),T=a(w*w),N=a(Bo*a(A*A)),O=a(m*L),B=p+w,F=a(a(B*B)-L-T),K=O+T,U=K-N,d=O-T,y=a(F*U),E=a(K*d),g=a(F*d),b=a(U*K);return new h(y,E,b,g)}add(m){x(m);let{a:p,d:w}=i,{X:A,Y:L,Z:T,T:N}=this,{X:O,Y:B,Z:F,T:K}=m,U=a(A*O),d=a(L*B),y=a(N*w*K),E=a(T*F),g=a((A+L)*(O+B)-U-d),b=E-y,S=E+y,C=a(d-p*U),_=a(g*b),D=a(S*C),P=a(g*C),V=a(b*S);return new h(_,D,V,P)}subtract(m){return x(m),this.add(m.negate())}multiply(m){if(!s.isValidNot0(m))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p,f:w}=v.cached(this,m,A=>he(h,A));return he(h,[p,w])[0]}multiplyUnsafe(m){if(!s.isValid(m))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return m===te?h.ZERO:this.is0()||m===it?this:v.unsafe(this,m,p=>he(h,p))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return v.unsafe(this,i.n).is0()}toAffine(m){let p=this,w=m,{X:A,Y:L,Z:T}=p,N=p.is0();w==null&&(w=N?Gf:o.inv(T));let O=a(A*w),B=a(L*w),F=o.mul(T,w);if(N)return{x:te,y:it};if(F!==it)throw new Error("invZ was invalid");return{x:O,y:B}}clearCofactor(){return c===it?this:this.multiplyUnsafe(c)}toBytes(){let{x:m,y:p}=this.toAffine(),w=o.toBytes(p);return w[w.length-1]|=m&it?128:0,w}toHex(){return Ce(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let v=new Pe(h,s.BITS);return s.BITS>=8&&h.BASE.precompute(8),Object.freeze(h.prototype),Object.freeze(h),h}var qr=class{static BASE;static ZERO;static Fp;static Fn;ep;constructor(t){this.ep=t}static fromBytes(t){bo()}static fromHex(t){bo()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return Ce(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,r){return this.ep.precompute(t,r),this}};function Wi(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');let n=t,o=r;Dt(o,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",zip215:"boolean",mapToCurve:"function"});let{prehash:s}=o,{BASE:i,Fp:c,Fn:f}=e,a=n.outputLen,u=2*c.BYTES;if(a!==void 0&&(Tt(a,"hash.outputLen"),a!==u))throw new Error(`hash.outputLen must be ${u}, got ${a}`);let l=o.randomBytes===void 0?nr:o.randomBytes,x=o.adjustScalarBytes===void 0?d=>d:o.adjustScalarBytes,h=o.domain===void 0?(d,y,E)=>{if(Ct(E,"phflag"),y.length||E)throw new Error("Contexts/pre-hash are not supported");return d}:o.domain;function v(d){return f.create(Ft(d))}function I(d){let y=O.secretKey;H(d,O.secretKey,"secretKey");let E=H(n(d),2*y,"hashedSecretKey"),g=x(E.slice(0,y)),b=E.slice(y,2*y),S=v(g);return{head:g,prefix:b,scalar:S}}function m(d){let{head:y,prefix:E,scalar:g}=I(d),b=i.multiply(g),S=b.toBytes();return{head:y,prefix:E,scalar:g,point:b,pointBytes:S}}function p(d){return m(d).pointBytes}function w(d=Uint8Array.of(),...y){let E=nt(...y);return v(n(h(E,H(d,void 0,"context"),!!s)))}function A(d,y,E={}){d=H(d,void 0,"message"),s&&(d=s(d));let{prefix:g,scalar:b,pointBytes:S}=m(y),C=w(E.context,g,d),_=i.multiply(C).toBytes(),D=w(E.context,_,S,d),P=f.create(C+D*b);if(!f.isValid(P))throw new Error("sign failed: invalid s");let V=nt(_,f.toBytes(P));return H(V,O.signature,"result")}let L={zip215:o.zip215};function T(d,y,E,g=L){let{context:b}=g,S=g.zip215===void 0?!!L.zip215:g.zip215,C=O.signature;d=H(d,C,"signature"),y=H(y,void 0,"message"),E=H(E,O.publicKey,"publicKey"),S!==void 0&&Ct(S,"zip215"),s&&(y=s(y));let _=C/2,D=d.subarray(0,_),P=Ft(d.subarray(_,C)),V,z,k;try{V=e.fromBytes(E,S),z=e.fromBytes(D,S),k=i.multiplyUnsafe(P)}catch{return!1}if(!S&&V.isSmallOrder())return!1;let rt=w(b,D,E,y);return z.add(V.multiplyUnsafe(rt)).subtract(k).clearCofactor().is0()}let N=c.BYTES,O={secretKey:N,publicKey:N,signature:2*N,seed:N};function B(d){return d=d===void 0?l(O.seed):d,H(d,O.seed,"seed")}function F(d){return fe(d)&&d.length===O.secretKey}function K(d,y){try{return!!e.fromBytes(d,y===void 0?L.zip215:y)}catch{return!1}}let U={getExtendedPublicKey:m,randomSecretKey:B,isValidSecretKey:F,isValidPublicKey:K,toMontgomery(d){let{y}=e.fromBytes(d),E=O.publicKey,g=E===32;if(!g&&E!==57)throw new Error("only defined for 25519 and 448");let b=g?c.div(it+y,it-y):c.div(y-it,y+it);return c.toBytes(b)},toMontgomerySecret(d){let y=O.secretKey;H(d,y);let E=n(d.subarray(0,y));return x(E).subarray(0,y)}};return Object.freeze(O),Object.freeze(U),Object.freeze({keygen:Hr(B,p),getPublicKey:p,sign:A,verify:T,utils:U,Point:e,lengths:O})}function fr(e,t){if(Tt(e),Tt(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function Xf(e,t){let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function Qf(e){if(!fe(e)&&typeof e!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof e=="string"?kr(e):e;if(t.length===0)throw new Error("DST must be non-empty");return t}function _o(e,t,r,n){H(e),Tt(r),t=Qf(t),t.length>255&&(t=n(nt(kr("H2C-OVERSIZE-DST-"),t)));let{outputLen:o,blockLen:s}=n,i=Math.ceil(r/o);if(r>65535||i>255)throw new Error("expand_message_xmd: invalid lenInBytes");let c=nt(t,fr(t.length,1)),f=new Uint8Array(s),a=fr(r,2),u=new Array(i),l=n(nt(f,e,a,fr(0,1),c));u[0]=n(nt(l,fr(1,1),c));for(let h=1;h<i;h++){let v=[Xf(l,u[h-1]),fr(h+1,1),c];u[h]=n(nt(...v))}return nt(...u).slice(0,r)}var Xi="HashToScalar-";var Jf=BigInt(0),zt=BigInt(1),Qi=BigInt(2);var tu=BigInt(5),eu=BigInt(8),Ue=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Do={p:Ue,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:eu,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function ru(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),s=Ue,c=e*e%s*e%s,f=Y(c,Qi,s)*c%s,a=Y(f,zt,s)*e%s,u=Y(a,tu,s)*a%s,l=Y(u,t,s)*u%s,x=Y(l,r,s)*l%s,h=Y(x,n,s)*x%s,v=Y(h,o,s)*h%s,I=Y(v,o,s)*h%s,m=Y(I,t,s)*u%s;return{pow_p_5_8:Y(m,Qi,s)*e%s,b2:c}}function nu(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Io=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Oo(e,t){let r=Ue,n=tt(t*t*t,r),o=tt(n*n*t,r),s=ru(e*o).pow_p_5_8,i=tt(e*n*s,r),c=tt(t*i*i,r),f=i,a=tt(i*Io,r),u=c===e,l=c===tt(-e,r),x=c===tt(-e*Io,r);return u&&(i=f),(l||x)&&(i=a),qt(i,r)&&(i=tt(-i,r)),{isValid:u||l,value:i}}var re=Gi(Do,{uvRatio:Oo}),ee=re.Fp,ec=re.Fn;function ou(e){return Wi(re,Pr,Object.assign({adjustScalarBytes:nu,zip215:!0},e))}var rc=ou({});var Co=Io,su=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),iu=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),cu=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),au=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Ji=e=>Oo(zt,e),fu=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),To=e=>ee.create(Ft(e)&fu);function tc(e){let{d:t}=Do,r=Ue,n=p=>ee.create(p),o=n(Co*e*e),s=n((o+zt)*cu),i=BigInt(-1),c=n((i-t*o)*n(o+t)),{isValid:f,value:a}=Oo(s,c),u=n(a*e);qt(u,r)||(u=n(-u)),f||(a=u),f||(i=o);let l=n(i*(o-zt)*au-c),x=a*a,h=n((a+a)*c),v=n(l*su),I=n(zt-x),m=n(zt+x);return new re(n(h*m),n(I*v),n(v*m),n(h*I))}var ne=class e extends qr{static BASE=new e(re.BASE);static ZERO=new e(re.ZERO);static Fp=ee;static Fn=ec;constructor(t){super(t)}static fromAffine(t){return new e(re.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw new Error("RistrettoPoint expected")}init(t){return new e(t)}static fromBytes(t){St(t,32);let{a:r,d:n}=Do,o=Ue,s=L=>ee.create(L),i=To(t);if(!Di(ee.toBytes(i),t)||qt(i,o))throw new Error("invalid ristretto255 encoding 1");let c=s(i*i),f=s(zt+r*c),a=s(zt-r*c),u=s(f*f),l=s(a*a),x=s(r*n*u-l),{isValid:h,value:v}=Ji(s(x*l)),I=s(v*a),m=s(v*I*x),p=s((i+i)*I);qt(p,o)&&(p=s(-p));let w=s(f*m),A=s(p*w);if(!h||qt(A,o)||w===Jf)throw new Error("invalid ristretto255 encoding 2");return new e(new re(p,w,zt,A))}static fromHex(t){return e.fromBytes(Je(t))}toBytes(){let{X:t,Y:r,Z:n,T:o}=this.ep,s=Ue,i=m=>ee.create(m),c=i(i(n+r)*i(n-r)),f=i(t*r),a=i(f*f),{value:u}=Ji(i(c*a)),l=i(u*c),x=i(u*f),h=i(l*x*o),v;if(qt(o*h,s)){let m=i(r*Co),p=i(t*Co);t=m,r=p,v=i(l*iu)}else v=x;qt(t*h,s)&&(r=i(-r));let I=i((n-r)*v);return qt(I,s)&&(I=i(-I)),ee.toBytes(I)}equals(t){this.assertSame(t);let{X:r,Y:n}=this.ep,{X:o,Y:s}=t.ep,i=a=>ee.create(a),c=i(r*s)===i(n*o),f=i(n*s)===i(r*o);return c||f}is0(){return this.equals(e.ZERO)}};Object.freeze(ne.BASE);Object.freeze(ne.ZERO);Object.freeze(ne.prototype);Object.freeze(ne);var uu=Object.freeze({Point:ne,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,n=_o(e,r,64,Pr);return uu.deriveToCurve(n)},hashToScalar(e,t={DST:Xi}){let r=_o(e,t.DST,64,Pr);return ec.create(Ft(r))},deriveToCurve(e){St(e,64);let t=To(e.subarray(0,32)),r=tc(t),n=To(e.subarray(32,64)),o=tc(n);return new ne(r.add(o))}});var ur=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},zr=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var jr={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new zr("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 Zr=32;var Lo,lu=(async()=>{try{return await jr.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function du(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await jr.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await jr.get().subtle.verify({name:"Ed25519"},n,_t(t),_t(r instanceof Uint8Array?r:r.subarray()))}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function hu(e,t,r){return rc.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function nc(e,t,r){return Lo==null&&(Lo=await lu),Lo?du(e,t,r):hu(e,t,r)}function $r(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var Yr=class{type="Ed25519";raw;constructor(t){this.raw=Ro(t,Zr)}toMultihash(){return Bt.digest(_e(this))}toCID(){return at.createV1(114,this.toMultihash())}toString(){return et.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:gt(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=nc(this.raw,r,t);return $r(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function sc(e){return e=Ro(e,Zr),new Yr(e)}function Ro(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new Rt(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var mu=Math.pow(2,7),yu=Math.pow(2,14),bu=Math.pow(2,21),Po=Math.pow(2,28),Uo=Math.pow(2,35),No=Math.pow(2,42),Fo=Math.pow(2,49),G=128,dt=127;function Kt(e){if(e<mu)return 1;if(e<yu)return 2;if(e<bu)return 3;if(e<Po)return 4;if(e<Uo)return 5;if(e<No)return 6;if(e<Fo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function lr(e,t,r=0){switch(Kt(e)){case 8:t[r++]=e&255|G,e/=128;case 7:t[r++]=e&255|G,e/=128;case 6:t[r++]=e&255|G,e/=128;case 5:t[r++]=e&255|G,e/=128;case 4:t[r++]=e&255|G,e>>>=7;case 3:t[r++]=e&255|G,e>>>=7;case 2:t[r++]=e&255|G,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Ko(e,t){let r=e[t],n=0;if(n+=r&dt,r<G||(r=e[t+1],n+=(r&dt)<<7,r<G)||(r=e[t+2],n+=(r&dt)<<14,r<G)||(r=e[t+3],n+=(r&dt)<<21,r<G)||(r=e[t+4],n+=(r&dt)*Po,r<G)||(r=e[t+5],n+=(r&dt)*Uo,r<G)||(r=e[t+6],n+=(r&dt)*No,r<G)||(r=e[t+7],n+=(r&dt)*Fo,r<G))return n;throw new RangeError("Could not decode varint")}function gu(e,t){let r=e.get(t),n=0;if(n+=r&dt,r<G||(r=e.get(t+1),n+=(r&dt)<<7,r<G)||(r=e.get(t+2),n+=(r&dt)<<14,r<G)||(r=e.get(t+3),n+=(r&dt)<<21,r<G)||(r=e.get(t+4),n+=(r&dt)*Po,r<G)||(r=e.get(t+5),n+=(r&dt)*Uo,r<G)||(r=e.get(t+6),n+=(r&dt)*No,r<G)||(r=e.get(t+7),n+=(r&dt)*Fo,r<G))return n;throw new RangeError("Could not decode varint")}function ko(e,t=0){return e instanceof Uint8Array?Ko(e,t):gu(e,t)}var Mo=new Float32Array([-0]),oe=new Uint8Array(Mo.buffer);function ic(e,t,r){Mo[0]=e,t[r]=oe[0],t[r+1]=oe[1],t[r+2]=oe[2],t[r+3]=oe[3]}function cc(e,t){return oe[0]=e[t],oe[1]=e[t+1],oe[2]=e[t+2],oe[3]=e[t+3],Mo[0]}var Vo=new Float64Array([-0]),ht=new Uint8Array(Vo.buffer);function ac(e,t,r){Vo[0]=e,t[r]=ht[0],t[r+1]=ht[1],t[r+2]=ht[2],t[r+3]=ht[3],t[r+4]=ht[4],t[r+5]=ht[5],t[r+6]=ht[6],t[r+7]=ht[7]}function fc(e,t){return ht[0]=e[t],ht[1]=e[t+1],ht[2]=e[t+2],ht[3]=e[t+3],ht[4]=e[t+4],ht[5]=e[t+5],ht[6]=e[t+6],ht[7]=e[t+7],Vo[0]}var wu=BigInt(Number.MAX_SAFE_INTEGER),Eu=BigInt(Number.MIN_SAFE_INTEGER),vt=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+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 r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(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,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return pe;if(t<wu&&t>Eu)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>uc&&(o=0n,++n>uc&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return pe;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):pe}},pe=new vt(0,0);pe.toBigInt=function(){return 0n};pe.zzEncode=pe.zzDecode=function(){return this};pe.length=function(){return 1};var uc=4294967296n;function lc(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function dc(e,t,r){if(r-t<1)return"";let o,s=[],i=0,c;for(;t<r;)c=e[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|e[t++]&63:c>239&&c<365?(c=((c&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(e[t++]&63)<<6|e[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 Ho(e,t,r){let n=r,o,s;for(let i=0;i<e.length;++i)o=e.charCodeAt(i),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((s=e.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function Ot(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Gr(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var qo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=_t(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,Ot(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 Ot(this,4);return Gr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ot(this,4);return Gr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Ot(this,4);let t=cc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Ot(this,4);let t=fc(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw Ot(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return dc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Ot(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Ot(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 vt(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*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;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Ot(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw Ot(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Ot(this,8);let t=Gr(this.buf,this.pos+=4),r=Gr(this.buf,this.pos+=4);return new vt(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Ko(this.buf,this.pos);return this.pos+=Kt(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 dr(e){return new qo(e instanceof Uint8Array?e:e.subarray())}function Wr(e,t,r){let n=dr(e);return t.decode(n,void 0,r)}function zo(e){let t=e??8192,r=t>>>1,n,o=t;return function(i){if(i<1||i>r)return mt(i);o+i>t&&(n=mt(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var me=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function jo(){}var $o=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Su=zo();function vu(e){return globalThis.Buffer!=null?mt(e):Su(e)}var pr=class{len;head;tail;states;constructor(){this.len=0,this.head=new me(jo,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new me(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Yo((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Xr,10,vt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=vt.fromBigInt(t);return this._push(Xr,r.length(),r)}uint64Number(t){return this._push(lr,Kt(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 r=vt.fromBigInt(t).zzEncode();return this._push(Xr,r.length(),r)}sint64Number(t){let r=vt.fromNumber(t).zzEncode();return this._push(Xr,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Zo,1,t?1:0)}fixed32(t){return this._push(hr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=vt.fromBigInt(t);return this._push(hr,4,r.lo)._push(hr,4,r.hi)}fixed64Number(t){let r=vt.fromNumber(t);return this._push(hr,4,r.lo)._push(hr,4,r.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(ic,4,t)}double(t){return this._push(ac,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(Zo,1,0):this.uint32(r)._push(Bu,r,t)}string(t){let r=lc(t);return r!==0?this.uint32(r)._push(Ho,r,t):this._push(Zo,1,0)}fork(){return this.states=new $o(this),this.head=this.tail=new me(jo,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 me(jo,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=vu(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function Zo(e,t,r){t[r]=e&255}function Au(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Yo=class extends me{next;constructor(t,r){super(Au,t,r),this.next=void 0}};function Xr(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function hr(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function Bu(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(pr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(_u,t,e),this},pr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Iu,t,e),this});function _u(e,t,r){t.set(e,r)}function Iu(e,t,r){e.length<40?Ho(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(xt(e),r)}function Go(){return new pr}function Qr(e,t){let r=Go();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}function*Jr(e,t,r){let n=dr(e);yield*t.stream(n,void 0,"$",r)}var tn={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function en(e,t,r,n,o){return{name:e,type:t,encode:r,decode:n,stream:o}}function Wo(e){function t(s){if(e[s.toString()]==null)throw new Error("Invalid enum value");return e[s]}let r=function(i,c){let f=t(i);c.int32(f)},n=function(i){let c=i.int32();return t(c)},o=function*(i){let c=i.int32();yield t(c)};return en("enum",tn.VARINT,r,n,o)}function rn(e,t,r){return en("message",tn.LENGTH_DELIMITED,e,t,r)}var yt;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(yt||(yt={}));var Xo;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(Xo||(Xo={}));(function(e){e.codec=()=>Wo(Xo)})(yt||(yt={}));var mr;(function(e){let t;e.codec=()=>(t==null&&(t=rn((s,i,c={})=>{c.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),yt.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),c.lengthDelimited!==!1&&i.ldelim()},(s,i,c={})=>{let f={},a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{f.Type=yt.codec().decode(s);break}case 2:{f.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return f},function*(s,i,c,f={}){let a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${c}.Type`,value:yt.codec().decode(s)};break}case 2:{yield{field:`${c}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function r(s){return Qr(s,e.codec())}e.encode=r;function n(s,i){return Wr(s,e.codec(),i)}e.decode=n;function o(s,i){return Jr(s,e.codec(),i)}e.stream=o})(mr||(mr={}));var Qo;(function(e){let t;e.codec=()=>(t==null&&(t=rn((s,i,c={})=>{c.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),yt.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),c.lengthDelimited!==!1&&i.ldelim()},(s,i,c={})=>{let f={},a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{f.Type=yt.codec().decode(s);break}case 2:{f.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return f},function*(s,i,c,f={}){let a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${c}.Type`,value:yt.codec().decode(s)};break}case 2:{yield{field:`${c}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function r(s){return Qr(s,e.codec())}e.encode=r;function n(s,i){return Wr(s,e.codec(),i)}e.decode=n;function o(s,i){return Jr(s,e.codec(),i)}e.stream=o})(Qo||(Qo={}));var nn=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,r){if(Tr(t),St(r,void 0,"key"),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 n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=t.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),Vt(o)}update(t){return Ie(this),this.iHash.update(t),this}digestInto(t){Ie(this),Dr(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},pc=(()=>{let e=((t,r,n)=>new nn(t,r).update(n).digest());return e.create=(t,r)=>new nn(t,r),e})();var mc=(e,t)=>(e+(e>=0?t:-t)/yc)/t;function Tu(e,t,r){De("scalar",e,kt,r);let[[n,o],[s,i]]=t,c=mc(i*e,r),f=mc(-o*e,r),a=e-c*n-f*s,u=-c*o-f*i,l=a<kt,x=u<kt;l&&(a=-a),x&&(u=-u);let h=ir(Math.ceil(Oe(r)/2))+se;if(a<kt||a>=h||u<kt||u>=h)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:l,k1:a,k2neg:x,k2:u}}function ts(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Jo(e,t){Dt(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return Ct(r.lowS,"lowS"),Ct(r.prehash,"prehash"),r.format!==void 0&&ts(r.format),r}var es=class extends Error{constructor(t=""){super(t)}},Lt={Err:es,_tlv:{encode:(e,t)=>{let{Err:r}=Lt;if(Tt(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!="string")throw new TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=or(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?or(o.length/2|128):"";return or(e)+s+o+t},decode(e,t){let{Err:r}=Lt;t=H(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let f=o&127;if(!f)throw new r("tlv.decode(long): indefinite length not supported");if(f>4)throw new r("tlv.decode(long): byte length is too big");let a=t.subarray(n,n+f);if(a.length!==f)throw new r("tlv.decode: length bytes not complete");if(a[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of a)i=i<<8|u;if(n+=f,i<128)throw new r("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new r("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(e){let{Err:t}=Lt;if(Fr(e),e<kt)throw new t("integer: negative integers are not allowed");let r=or(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Lt;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return ue(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=Lt,o=H(e,void 0,"signature"),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:f}=n.decode(2,s),{v:a,l:u}=n.decode(2,f);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(a)}},hexFromSig(e){let{_tlv:t,_int:r}=Lt,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),s=n+o;return t.encode(48,s)}};Object.freeze(Lt._tlv);Object.freeze(Lt._int);Object.freeze(Lt);var kt=BigInt(0),se=BigInt(1),yc=BigInt(2),on=BigInt(3),Du=BigInt(4);function bc(e,t={}){let r=Vr("weierstrass",e,t),n=r.Fp,o=r.Fn,s=r.CURVE,{h:i,n:c}=s;Dt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:f,allowInfinityPoint:a}=t;if(f&&(!n.is0(s.a)||typeof f.beta!="bigint"||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let u=xc(n,o);function l(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function x(U,d,y){if(a&&d.is0())return Uint8Array.of(0);let{x:E,y:g}=d.toAffine(),b=n.toBytes(E);if(Ct(y,"isCompressed"),y){l();let S=!n.isOdd(g);return nt(gc(S),b)}else return nt(Uint8Array.of(4),b,n.toBytes(g))}function h(U){H(U,void 0,"Point");let{publicKey:d,publicKeyUncompressed:y}=u,E=U.length,g=U[0],b=U.subarray(1);if(a&&E===1&&g===0)return{x:n.ZERO,y:n.ZERO};if(E===d&&(g===2||g===3)){let S=n.fromBytes(b);if(!n.isValid(S))throw new Error("bad point: is not on curve, wrong x");let C=m(S),_;try{_=n.sqrt(C)}catch(V){let z=V instanceof Error?": "+V.message:"";throw new Error("bad point: is not on curve, sqrt error"+z)}l();let D=n.isOdd(_);return(g&1)===1!==D&&(_=n.neg(_)),{x:S,y:_}}else if(E===y&&g===4){let S=n.BYTES,C=n.fromBytes(b.subarray(0,S)),_=n.fromBytes(b.subarray(S,S*2));if(!p(C,_))throw new Error("bad point: is not on curve");return{x:C,y:_}}else throw new Error(`bad point: got length ${E}, expected compressed=${d} or uncompressed=${y}`)}let v=t.toBytes===void 0?x:t.toBytes,I=t.fromBytes===void 0?h:t.fromBytes;function m(U){let d=n.sqr(U),y=n.mul(d,U);return n.add(n.add(y,n.mul(U,s.a)),s.b)}function p(U,d){let y=n.sqr(d),E=m(U);return n.eql(y,E)}if(!p(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let w=n.mul(n.pow(s.a,on),Du),A=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(w,A)))throw new Error("bad curve params: a or b");function L(U,d,y=!1){if(!n.isValid(d)||y&&n.is0(d))throw new Error(`bad point coordinate ${U}`);return d}function T(U){if(!(U instanceof B))throw new Error("Weierstrass Point expected")}function N(U){if(!f||!f.basises)throw new Error("no endo");return Tu(U,f.basises,o.ORDER)}function O(U,d,y,E,g){return y=new B(n.mul(y.X,U),y.Y,y.Z),d=ar(E,d),y=ar(g,y),d.add(y)}class B{static BASE=new B(s.Gx,s.Gy,n.ONE);static ZERO=new B(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(d,y,E){this.X=L("x",d),this.Y=L("y",y,!0),this.Z=L("z",E),Object.freeze(this)}static CURVE(){return s}static fromAffine(d){let{x:y,y:E}=d||{};if(!d||!n.isValid(y)||!n.isValid(E))throw new Error("invalid affine point");if(d instanceof B)throw new Error("projective point not allowed");return n.is0(y)&&n.is0(E)?B.ZERO:new B(y,E,n.ONE)}static fromBytes(d){let y=B.fromAffine(I(H(d,void 0,"point")));return y.assertValidity(),y}static fromHex(d){return B.fromBytes(Te(d))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(d=8,y=!0){return K.createCache(this,d),y||this.multiply(on),this}assertValidity(){let d=this;if(d.is0()){if(t.allowInfinityPoint&&n.is0(d.X)&&n.eql(d.Y,n.ONE)&&n.is0(d.Z))return;throw new Error("bad point: ZERO")}let{x:y,y:E}=d.toAffine();if(!n.isValid(y)||!n.isValid(E))throw new Error("bad point: x or y not field elements");if(!p(y,E))throw new Error("bad point: equation left != right");if(!d.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:d}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(d)}equals(d){T(d);let{X:y,Y:E,Z:g}=this,{X:b,Y:S,Z:C}=d,_=n.eql(n.mul(y,C),n.mul(b,g)),D=n.eql(n.mul(E,C),n.mul(S,g));return _&&D}negate(){return new B(this.X,n.neg(this.Y),this.Z)}double(){let{a:d,b:y}=s,E=n.mul(y,on),{X:g,Y:b,Z:S}=this,C=n.ZERO,_=n.ZERO,D=n.ZERO,P=n.mul(g,g),V=n.mul(b,b),z=n.mul(S,S),k=n.mul(g,b);return k=n.add(k,k),D=n.mul(g,S),D=n.add(D,D),C=n.mul(d,D),_=n.mul(E,z),_=n.add(C,_),C=n.sub(V,_),_=n.add(V,_),_=n.mul(C,_),C=n.mul(k,C),D=n.mul(E,D),z=n.mul(d,z),k=n.sub(P,z),k=n.mul(d,k),k=n.add(k,D),D=n.add(P,P),P=n.add(D,P),P=n.add(P,z),P=n.mul(P,k),_=n.add(_,P),z=n.mul(b,S),z=n.add(z,z),P=n.mul(z,k),C=n.sub(C,P),D=n.mul(z,V),D=n.add(D,D),D=n.add(D,D),new B(C,_,D)}add(d){T(d);let{X:y,Y:E,Z:g}=this,{X:b,Y:S,Z:C}=d,_=n.ZERO,D=n.ZERO,P=n.ZERO,V=s.a,z=n.mul(s.b,on),k=n.mul(y,b),rt=n.mul(E,S),ot=n.mul(g,C),st=n.add(y,E),Q=n.add(b,S);st=n.mul(st,Q),Q=n.add(k,rt),st=n.sub(st,Q),Q=n.add(y,g);let bt=n.add(b,C);return Q=n.mul(Q,bt),bt=n.add(k,ot),Q=n.sub(Q,bt),bt=n.add(E,g),_=n.add(S,C),bt=n.mul(bt,_),_=n.add(rt,ot),bt=n.sub(bt,_),P=n.mul(V,Q),_=n.mul(z,ot),P=n.add(_,P),_=n.sub(rt,P),P=n.add(rt,P),D=n.mul(_,P),rt=n.add(k,k),rt=n.add(rt,k),ot=n.mul(V,ot),Q=n.mul(z,Q),rt=n.add(rt,ot),ot=n.sub(k,ot),ot=n.mul(V,ot),Q=n.add(Q,ot),k=n.mul(rt,Q),D=n.add(D,k),k=n.mul(bt,Q),_=n.mul(st,_),_=n.sub(_,k),k=n.mul(st,rt),P=n.mul(bt,P),P=n.add(P,k),new B(_,D,P)}subtract(d){return T(d),this.add(d.negate())}is0(){return this.equals(B.ZERO)}multiply(d){let{endo:y}=t;if(!o.isValidNot0(d))throw new RangeError("invalid scalar: out of range");let E,g,b=S=>K.cached(this,S,C=>he(B,C));if(y){let{k1neg:S,k1:C,k2neg:_,k2:D}=N(d),{p:P,f:V}=b(C),{p:z,f:k}=b(D);g=V.add(k),E=O(y.beta,P,z,S,_)}else{let{p:S,f:C}=b(d);E=S,g=C}return he(B,[E,g])[0]}multiplyUnsafe(d){let{endo:y}=t,E=this,g=d;if(!o.isValid(g))throw new RangeError("invalid scalar: out of range");if(g===kt||E.is0())return B.ZERO;if(g===se)return E;if(K.hasCache(this))return this.multiply(g);if(y){let{k1neg:b,k1:S,k2neg:C,k2:_}=N(g),{p1:D,p2:P}=Yi(B,E,S,_);return O(y.beta,D,P,b,C)}else return K.unsafe(E,g)}toAffine(d){let y=this,E=d,{X:g,Y:b,Z:S}=y;if(n.eql(S,n.ONE))return{x:g,y:b};let C=y.is0();E==null&&(E=C?n.ONE:n.inv(S));let _=n.mul(g,E),D=n.mul(b,E),P=n.mul(S,E);if(C)return{x:n.ZERO,y:n.ZERO};if(!n.eql(P,n.ONE))throw new Error("invZ was invalid");return{x:_,y:D}}isTorsionFree(){let{isTorsionFree:d}=t;return i===se?!0:d?d(B,this):K.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:d}=t;return i===se?this:d?d(B,this):this.multiplyUnsafe(i)}isSmallOrder(){return i===se?this.is0():this.clearCofactor().is0()}toBytes(d=!0){return Ct(d,"isCompressed"),this.assertValidity(),v(B,this,d)}toHex(d=!0){return Ce(this.toBytes(d))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let F=o.BITS,K=new Pe(B,t.endo?Math.ceil(F/2):F);return F>=8&&B.BASE.precompute(8),Object.freeze(B.prototype),Object.freeze(B),B}function gc(e){return Uint8Array.of(e?2:3)}function xc(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Ou(e,t={}){let{Fn:r}=e,n=t.randomBytes===void 0?nr:t.randomBytes,o=Object.assign(xc(e.Fp,r),{seed:Math.max(wo(r.ORDER),16)});function s(h){try{let v=r.fromBytes(h);return r.isValidNot0(v)}catch{return!1}}function i(h,v){let{publicKey:I,publicKeyUncompressed:m}=o;try{let p=h.length;return v===!0&&p!==I||v===!1&&p!==m?!1:!!e.fromBytes(h)}catch{return!1}}function c(h){return h=h===void 0?n(o.seed):h,Eo(H(h,o.seed,"seed"),r.ORDER)}function f(h,v=!0){return e.BASE.multiply(r.fromBytes(h)).toBytes(v)}function a(h){let{secretKey:v,publicKey:I,publicKeyUncompressed:m}=o,p=r._lengths;if(!fe(h))return;let w=H(h,void 0,"key").length,A=w===I||w===m,L=w===v||!!p?.includes(w);if(!(A&&L))return A}function u(h,v,I=!0){if(a(h)===!0)throw new Error("first arg must be private key");if(a(v)===!1)throw new Error("second arg must be public key");let m=r.fromBytes(h);return e.fromBytes(v).multiply(m).toBytes(I)}let l={isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:c},x=Hr(c,f);return Object.freeze(l),Object.freeze(o),Object.freeze({getPublicKey:f,getSharedSecret:u,keygen:x,Point:e,utils:l,lengths:o})}function wc(e,t,r={}){let n=t;Tr(n),Dt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes===void 0?nr:r.randomBytes,s=r.hmac===void 0?(g,b)=>pc(n,g,b):r.hmac,{Fp:i,Fn:c}=e,{ORDER:f,BITS:a}=c,{keygen:u,getPublicKey:l,getSharedSecret:x,utils:h,lengths:v}=Ou(e,r),I={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},m=f*yc+se<i.ORDER;function p(g){let b=f>>se;return g>b}function w(g,b){if(!c.isValidNot0(b))throw new Error(`invalid signature ${g}: out of range 1..Point.Fn.ORDER`);return b}function A(){if(m)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function L(g,b){ts(b);let S=v.signature,C=b==="compact"?S:b==="recovered"?S+1:void 0;return H(g,C)}class T{r;s;recovery;constructor(b,S,C){if(this.r=w("r",b),this.s=w("s",S),C!=null){if(A(),![0,1,2,3].includes(C))throw new Error("invalid recovery id");this.recovery=C}Object.freeze(this)}static fromBytes(b,S=I.format){L(b,S);let C;if(S==="der"){let{r:V,s:z}=Lt.toSig(H(b));return new T(V,z)}S==="recovered"&&(C=b[0],S="compact",b=b.subarray(1));let _=v.signature/2,D=b.subarray(0,_),P=b.subarray(_,_*2);return new T(c.fromBytes(D),c.fromBytes(P),C)}static fromHex(b,S){return this.fromBytes(Te(b),S)}assertRecovery(){let{recovery:b}=this;if(b==null)throw new Error("invalid recovery id: must be present");return b}addRecoveryBit(b){return new T(this.r,this.s,b)}recoverPublicKey(b){let{r:S,s:C}=this,_=this.assertRecovery(),D=_===2||_===3?S+f:S;if(!i.isValid(D))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let P=i.toBytes(D),V=e.fromBytes(nt(gc((_&1)===0),P)),z=c.inv(D),k=O(H(b,void 0,"msgHash")),rt=c.create(-k*z),ot=c.create(C*z),st=e.BASE.multiplyUnsafe(rt).add(V.multiplyUnsafe(ot));if(st.is0())throw new Error("invalid recovery: point at infinify");return st.assertValidity(),st}hasHighS(){return p(this.s)}toBytes(b=I.format){if(ts(b),b==="der")return Te(Lt.hexFromSig(this));let{r:S,s:C}=this,_=c.toBytes(S),D=c.toBytes(C);return b==="recovered"?(A(),nt(Uint8Array.of(this.assertRecovery()),_,D)):nt(_,D)}toHex(b){return Ce(this.toBytes(b))}}Object.freeze(T.prototype),Object.freeze(T);let N=r.bits2int===void 0?function(b){if(b.length>8192)throw new Error("input is too large");let S=ue(b),C=b.length*8-a;return C>0?S>>BigInt(C):S}:r.bits2int,O=r.bits2int_modN===void 0?function(b){return c.create(N(b))}:r.bits2int_modN,B=ir(a);function F(g){return De("num < 2^"+a,g,kt,B),c.toBytes(g)}function K(g,b){return H(g,void 0,"message"),b?H(n(g),void 0,"prehashed message"):g}function U(g,b,S){let{lowS:C,prehash:_,extraEntropy:D}=Jo(S,I);g=K(g,_);let P=O(g),V=c.fromBytes(b);if(!c.isValidNot0(V))throw new Error("invalid private key");let z=[F(V),F(P)];if(D!=null&&D!==!1){let st=D===!0?o(v.secretKey):D;z.push(H(st,void 0,"extraEntropy"))}let k=nt(...z),rt=P;function ot(st){let Q=N(st);if(!c.isValidNot0(Q))return;let bt=c.inv(Q),ge=e.BASE.multiply(Q).toAffine(),He=c.create(ge.x);if(He===kt)return;let wr=c.create(bt*c.create(rt+He*V));if(wr===kt)return;let Rs=(ge.x===He?0:2)|Number(ge.y&se),Ps=wr;return C&&p(wr)&&(Ps=c.neg(wr),Rs^=1),new T(He,Ps,m?void 0:Rs)}return{seed:k,k2sig:ot}}function d(g,b,S={}){let{seed:C,k2sig:_}=U(g,b,S);return Oi(n.outputLen,c.BYTES,s)(C,_).toBytes(S.format)}function y(g,b,S,C={}){let{lowS:_,prehash:D,format:P}=Jo(C,I);if(S=H(S,void 0,"publicKey"),b=K(b,D),!fe(g)){let V=g instanceof T?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+V)}L(g,P);try{let V=T.fromBytes(g,P),z=e.fromBytes(S);if(_&&V.hasHighS())return!1;let{r:k,s:rt}=V,ot=O(b),st=c.inv(rt),Q=c.create(ot*st),bt=c.create(k*st),ge=e.BASE.multiplyUnsafe(Q).add(z.multiplyUnsafe(bt));return ge.is0()?!1:c.create(ge.x)===k}catch{return!1}}function E(g,b,S={}){let{prehash:C}=Jo(S,I);return b=K(b,C),T.fromBytes(g,"recovered").recoverPublicKey(b).toBytes()}return Object.freeze({keygen:u,getPublicKey:l,getSharedSecret:x,utils:h,lengths:v,Point:e,sign:d,verify:y,recoverPublicKey:E,Signature:T,hash:n})}var ns={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Lu={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Ec=BigInt(2);function Ru(e){let t=ns.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),f=BigInt(88),a=e*e*e%t,u=a*a*e%t,l=Y(u,r,t)*u%t,x=Y(l,r,t)*u%t,h=Y(x,Ec,t)*a%t,v=Y(h,o,t)*h%t,I=Y(v,s,t)*v%t,m=Y(I,c,t)*I%t,p=Y(m,f,t)*m%t,w=Y(p,c,t)*I%t,A=Y(w,r,t)*u%t,L=Y(A,i,t)*v%t,T=Y(L,n,t)*a%t,N=Y(T,Ec,t);if(!rs.eql(rs.sqr(N),e))throw new Error("Cannot find square root");return N}var rs=Le(ns.p,{sqrt:Ru}),Pu=bc(ns,{Fp:rs,endo:Lu}),Ne=wc(Pu,Ci);function Sc(e,t,r,n){let o=Ge.digest(r instanceof Uint8Array?r:r.subarray());if($r(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),Ne.verify(t,s,e,{prehash:!1,format:"der"}))).catch(s=>{throw s.name==="AbortError"?s:new ur(String(s))});try{return n?.signal?.throwIfAborted(),Ne.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(s){throw new ur(String(s))}}var sn=class{type="secp256k1";raw;_key;constructor(t){this._key=Ac(t),this.raw=vc(this._key)}toMultihash(){return Bt.digest(_e(this))}toCID(){return at.createV1(114,this.toMultihash())}toString(){return et.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:gt(this.raw,t.raw)}verify(t,r,n){return Sc(this._key,r,t,n)}};function Bc(e){return new sn(e)}function vc(e){return Ne.Point.fromBytes(e).toBytes()}function Ac(e){try{return Ne.Point.fromBytes(e),e}catch(t){throw new Er(String(t))}}function _c(e){let{Type:t,Data:r}=mr.decode(e.digest),n=r??new Uint8Array;switch(t){case yt.Ed25519:return sc(n);case yt.secp256k1:return Bc(n);case yt.ECDSA:return li(n);default:throw new qe}}function _e(e){return mr.encode({Type:yt[e.type],Data:e.raw})}var Ic=Symbol.for("nodejs.util.inspect.custom"),Uu=114,yr=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()})`}[In]=!0;toString(){return this.string==null&&(this.string=et.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return at.createV1(Uu,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return gt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return gt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Ic](){return`PeerId(${this.toString()})`}},cn=class extends yr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},an=class extends yr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},fn=class extends yr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Nu=2336,br=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Bt.digest(xt(this.url))}[Ic](){return`PeerId(${this.url})`}[In]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return at.createV1(Nu,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=J(t)),t.toString()===this.toString())}};var Fu=114,Cc=2336;function Tc(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=$e(et.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return Ku(at.parse(e));if(t==null)throw new Rt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=$e(t.decode(e))}return Dc(r)}function Dc(e){if(Mu(e))return new cn({multihash:e});if(ku(e))try{let t=_c(e);if(t.type==="Ed25519")return new an({multihash:e,publicKey:t});if(t.type==="secp256k1")return new fn({multihash:e,publicKey:t})}catch{let r=J(e.digest);return new br(new URL(r))}throw new vr("Supplied PeerID Multihash is invalid")}function Ku(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==Fu&&e.code!==Cc)throw new Sr("Supplied PeerID CID is invalid");if(e.code===Cc){let t=J(e.multihash.digest);return new br(new URL(t))}return Dc(e.multihash)}function ku(e){return e.code===Bt.code}function Mu(e){return e.code===Ge.code}var lt=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},jt=class extends Error{static name="ValidationError";name="ValidationError"},un=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},ln=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var dn=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}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 r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let s=0,i=0,c=this.peekChar();if(c===void 0)return;let f=c==="0",a=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let x=Number.parseInt(l,t);if(!Number.isNaN(x))return x});if(u===void 0)break;if(s*=t,s+=u,s>a||(i+=1,r!==void 0&&i>r))return}if(i!==0)return!n&&f&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return r[o]=i[0],r[o+1]=i[1],r[o+2]=i[2],r[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];r[o]=s>>8,r[o+1]=s&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[c]=t(s.subarray(0,i));return r.set(s.subarray(0,c),16-c),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Vu=45,Hu=15,hn=new dn;function Oc(e){if(!(e.length>Hu))return hn.new(e).parseWith(()=>hn.readIPv4Addr())}function Lc(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Vu))return hn.new(e).parseWith(()=>hn.readIPv6Addr())}function pn(e){return!!Oc(e)}function Rc(e){return!!Lc(e)}function ss(e){return t=>J(t,e)}function is(e){return t=>xt(t,e)}function Fe(e){return new DataView(e.buffer).getUint16(e.byteOffset).toString()}function ye(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof e=="string"?parseInt(e):e),new Uint8Array(t)}function Pc(e){let t=e.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 r=xt(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=ye(n);return Ut([r,o],r.length+o.length)}function Uc(e){let t=e.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 r=Gt.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=ye(n);return Ut([r,o],r.length+o.length)}function cs(e){let t=e.subarray(0,e.length-2),r=e.subarray(e.length-2),n=J(t,"base32"),o=Fe(r);return`${n}:${o}`}var as=function(e){e=e.toString().trim();let t=new Uint8Array(4);return e.split(/\./g).forEach((r,n)=>{let o=parseInt(r,10);if(isNaN(o)||o<0||o>255)throw new lt("Invalid byte value in IP address");t[n]=o}),t},Nc=function(e){let t=0;e=e.toString().trim();let r=e.split(":",8),n;for(n=0;n<r.length;n++){let s=pn(r[n]),i;s&&(i=as(r[n]),r[n]=J(i.subarray(0,2),"base16")),i!=null&&++n<8&&r.splice(n,0,J(i.subarray(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let s=[n,1];for(n=9-r.length;n>0;n--)s.push("0");r.splice.apply(r,s)}let o=new Uint8Array(t+16);for(n=0;n<r.length;n++){r[n]===""&&(r[n]="0");let s=parseInt(r[n],16);if(isNaN(s)||s<0||s>65535)throw new lt("Invalid byte value in IP address");o[t++]=s>>8&255,o[t++]=s&255}return o},Fc=function(e){if(e.byteLength!==4)throw new lt("IPv4 address was incorrect length");let t=[];for(let r=0;r<e.byteLength;r++)t.push(e[r]);return t.join(".")},Kc=function(e){if(e.byteLength!==16)throw new lt("IPv6 address was incorrect length");let t=[];for(let n=0;n<e.byteLength;n+=2){let o=e[n],s=e[n+1],i=`${o.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`;t.push(i)}let r=t.join(":");try{let n=new URL(`http://[${r}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new lt(`Invalid IPv6 address "${r}"`)}};function kc(e){try{let t=new URL(`http://[${e}]`);return t.hostname.substring(1,t.hostname.length-1)}catch{throw new lt(`Invalid IPv6 address "${e}"`)}}var os=Object.values(We).map(e=>e.decoder),qu=(function(){let e=os[0].or(os[1]);return os.slice(2).forEach(t=>e=e.or(t)),e})();function Mc(e){return qu.decode(e)}function Vc(e){return t=>e.encoder.encode(t)}function zu(e){if(parseInt(e).toString()!==e)throw new jt("Value must be an integer")}function ju(e){if(e<0)throw new jt("Value must be a positive integer, or zero")}function Zu(e){return t=>{if(t>e)throw new jt(`Value must be smaller than or equal to ${e}`)}}function $u(...e){return t=>{for(let r of e)r(t)}}var gr=$u(zu,ju,Zu(65535));var ct=-1,fs=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(t){let r;if(typeof t=="string"?r=this.protocolsByName.get(t):r=this.protocolsByCode.get(t),r==null)throw new ln(`Protocol ${t} was unknown`);return r}addProtocol(t){this.protocolsByCode.set(t.code,t),this.protocolsByName.set(t.name,t),t.aliases?.forEach(r=>{this.protocolsByName.set(r,t)})}removeProtocol(t){let r=this.protocolsByCode.get(t);r!=null&&(this.protocolsByCode.delete(r.code),this.protocolsByName.delete(r.name),r.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},$t=new fs,cl=[{code:4,name:"ip4",size:32,valueToBytes:as,bytesToValue:Fc,validate:e=>{if(!pn(e))throw new jt(`Invalid IPv4 address "${e}"`)}},{code:6,name:"tcp",size:16,valueToBytes:ye,bytesToValue:Fe,validate:gr},{code:273,name:"udp",size:16,valueToBytes:ye,bytesToValue:Fe,validate:gr},{code:33,name:"dccp",size:16,valueToBytes:ye,bytesToValue:Fe,validate:gr},{code:41,name:"ip6",size:128,valueToBytes:Nc,bytesToValue:Kc,stringToValue:kc,validate:e=>{if(!Rc(e))throw new jt(`Invalid IPv6 address "${e}"`)}},{code:42,name:"ip6zone",size:ct},{code:43,name:"ipcidr",size:8,bytesToValue:ss("base10"),valueToBytes:is("base10")},{code:53,name:"dns",size:ct},{code:54,name:"dns4",size:ct},{code:55,name:"dns6",size:ct},{code:56,name:"dnsaddr",size:ct},{code:132,name:"sctp",size:16,valueToBytes:ye,bytesToValue:Fe,validate:gr},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:ct,stringToValue:e=>decodeURIComponent(e),valueToString:e=>encodeURIComponent(e)},{code:421,name:"p2p",aliases:["ipfs"],size:ct,bytesToValue:ss("base58btc"),valueToBytes:e=>e.startsWith("Q")||e.startsWith("1")?is("base58btc")(e):at.parse(e).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:cs,valueToBytes:Pc},{code:445,name:"onion3",size:296,bytesToValue:cs,valueToBytes:Uc},{code:446,name:"garlic64",size:ct},{code:447,name:"garlic32",size:ct},{code:448,name:"tls"},{code:449,name:"sni",size:ct},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:ct,bytesToValue:Vc(qn),valueToBytes:Mc},{code:480,name:"http"},{code:481,name:"http-path",size:ct,stringToValue:e=>`/${decodeURIComponent(e)}`,valueToString:e=>encodeURIComponent(e.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:ct}];cl.forEach(e=>{$t.addProtocol(e)});function Hc(e){let t=[],r=0;for(;r<e.length;){let n=ko(e,r),o=$t.getProtocol(n),s=Kt(n),i=al(o,e,r+s),c=0;i>0&&o.size===ct&&(c=Kt(i));let f=s+c+i,a={code:n,name:o.name,bytes:_t(e.subarray(r,r+f))};if(i>0){let u=r+s+c,l=e.subarray(u,u+i);a.value=o.bytesToValue?.(l)??J(l)}t.push(a),r+=f}return t}function qc(e){let t=0,r=[];for(let n of e){if(n.bytes==null){let o=$t.getProtocol(n.code),s=Kt(n.code),i,c=0,f=0;n.value!=null&&(i=o.valueToBytes?.(n.value)??xt(n.value),c=i.byteLength,o.size===ct&&(f=Kt(c)));let a=new Uint8Array(s+f+c),u=0;lr(n.code,a,u),u+=s,i!=null&&(o.size===ct&&(lr(c,a,u),u+=f),a.set(i,u)),n.bytes=a}r.push(n.bytes),t+=n.bytes.byteLength}return Ut(r,t)}function zc(e){if(e.charAt(0)!=="/")throw new lt('String multiaddr must start with "/"');let t=[],r="protocol",n="",o="";for(let s=1;s<e.length;s++){let i=e.charAt(s);i!=="/"&&(r==="protocol"?o+=e.charAt(s):n+=e.charAt(s));let c=s===e.length-1;if(i==="/"||c){let f=$t.getProtocol(o);if(r==="protocol"){if(f.size==null||f.size===0){t.push({code:f.code,name:f.name}),n="",o="",r="protocol";continue}else if(c)throw new lt(`Component ${o} was missing value`);r="value"}else if(r==="value"){let a={code:f.code,name:f.name};if(f.size!=null&&f.size!==0){if(n==="")throw new lt(`Component ${o} was missing value`);a.value=f.stringToValue?.(n)??n}t.push(a),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new lt("Incomplete multiaddr");return t}function jc(e){return`/${e.flatMap(t=>{if(t.value==null)return t.name;let r=$t.getProtocol(t.code);if(r==null)throw new lt(`Unknown protocol code ${t.code}`);return[t.name,r.valueToString?.(t.value)??t.value]}).join("/")}`}function al(e,t,r){return e.size==null||e.size===0?0:e.size>0?e.size/8:ko(t,r)}var fl=Symbol.for("nodejs.util.inspect.custom"),_s=Symbol.for("@multiformats/multiaddr");function ul(e){if(e==null&&(e="/"),Zc(e))return e.getComponents();if(e instanceof Uint8Array)return Hc(e);if(typeof e=="string")return e=e.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),e===""&&(e="/"),zc(e);if(Array.isArray(e))return e;throw new lt("Must be a string, Uint8Array, Component[], or another Multiaddr")}var wn=class e{[_s]=!0;#t;#e;#r;constructor(t="/",r={}){this.#t=ul(t),r.validate!==!1&&ll(this)}get bytes(){return this.#r==null&&(this.#r=qc(this.#t)),this.#r}toString(){return this.#e==null&&(this.#e=jc(this.#t)),this.#e}toJSON(){return this.toString()}getComponents(){return[...this.#t.map(t=>({...t}))]}encapsulate(t){let r=new e(t);return new e([...this.#t,...r.getComponents()],{validate:!1})}decapsulate(t){let r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new un(`Address ${this.toString()} does not contain subaddress: ${r}`);return new e(n.slice(0,o),{validate:!1})}decapsulateCode(t){let r;for(let n=this.#t.length-1;n>-1;n--)if(this.#t[n].code===t){r=n;break}return new e(this.#t.slice(0,r),{validate:!1})}equals(t){return gt(this.bytes,t.bytes)}[fl](){return`Multiaddr(${this.toString()})`}};function ll(e){e.getComponents().forEach(t=>{let r=$t.getProtocol(t.code);t.value!=null&&r.validate?.(t.value)})}function Zc(e){return!!e?.[_s]}function $c(e){return new wn(e)}var Z=e=>({match:t=>{let r=t[0];return r==null||r.code!==e||r.value!=null?!1:t.slice(1)}}),R=(e,t)=>({match:r=>{let n=r[0];return n?.code!==e||n.value==null||t!=null&&n.value!==t?!1:r.slice(1)}}),Yc=e=>({match:t=>e.match(t)===!1?t:!1}),M=e=>({match:t=>{let r=e.match(t);return r===!1?t:r}}),pt=(...e)=>({match:t=>{let r;for(let n of e){let o=n.match(t);o!==!1&&(r==null||o.length<r.length)&&(r=o)}return r??!1}}),q=(...e)=>({match:t=>{for(let r of e){let n=r.match(t);if(n===!1)return!1;t=n}return t}});function $(...e){function t(o){if(o==null)return!1;let s=o.getComponents();for(let i of e){let c=i.match(s);if(c===!1)return!1;s=c}return s}function r(o){return t(o)!==!1}function n(o){let s=t(o);return s===!1?!1:s.length===0}return{matchers:e,matches:r,exactMatch:n}}var dl=R(421),Uy=$(dl),Sn=R(54),vn=R(55),An=R(56),Cs=R(53),Ny=$(Sn,M(R(421))),Fy=$(vn,M(R(421))),Ky=$(An,M(R(421))),ky=$(pt(Cs,An,Sn,vn),M(R(421))),Gc=q(R(4),M(R(43))),Wc=q(M(R(42)),R(41),M(R(43))),Ts=pt(Gc,Wc),Ve=pt(Ts,Cs,Sn,vn,An),My=$(pt(Ts,q(pt(Cs,An,Sn,vn),M(R(421))))),Vy=$(Gc),Hy=$(Wc),qy=$(Ts),Ds=q(Ve,R(6)),xr=q(Ve,R(273)),zy=$(q(Ds,M(R(421)))),jy=$(xr),Os=q(xr,Z(460),M(R(421))),Bn=q(xr,Z(461),M(R(421))),hl=pt(Os,Bn),Zy=$(Os),$y=$(Bn),Is=pt(Ve,Ds,xr,Os,Bn),Xc=pt(q(Is,Z(477),M(R(421)))),Yy=$(Xc),Qc=pt(q(Is,Z(478),M(R(421))),q(Is,Z(448),M(R(449)),Z(477),M(R(421)))),Gy=$(Qc),Jc=q(xr,Z(280),M(R(466)),M(R(466)),M(R(421))),Wy=$(Jc),ta=q(Bn,Z(465),M(R(466)),M(R(466)),M(R(421))),Xy=$(ta),En=pt(Xc,Qc,q(Ds,M(R(421))),q(hl,M(R(421))),q(Ve,M(R(421))),Jc,ta,R(421)),ea=$(En),pl=q(M(En),Z(290),Yc(Z(281)),M(R(421))),Qy=$(pl),ml=pt(q(En,Z(290),Z(281),M(R(421))),q(En,Z(281),M(R(421))),q(Z(281),M(R(421)))),Jy=$(ml),yl=q(Ve,pt(q(R(6,"80")),q(R(6),Z(480)),Z(480)),M(R(481)),M(R(421))),tb=$(yl),bl=q(Ve,pt(q(R(6,"443")),q(R(6,"443"),Z(480)),q(R(6),Z(443)),q(R(6),Z(448),Z(480)),q(Z(448),Z(480)),Z(448),Z(443)),M(R(481)),M(R(421))),eb=$(bl),gl=pt(q(R(777),M(R(421)))),rb=$(gl),xl=pt(q(R(400),M(R(421)))),nb=$(xl);var wl="bootstrap",El=50,Sl=1e3,Ls=class extends Ar{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(t,r={list:[]}){if(r.list==null||r.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=r.timeout??Sl,this.list=r.list.map(n=>$c(n)).filter(n=>ea.matches(n)?n.getComponents().findLast(s=>s.code===421)?.value==null?(this.log.error("invalid bootstrap multiaddr without peer id"),!1):!0:(this.log.error("invalid multiaddr %a",n),!1)).map(n=>({id:Tc(n.getComponents().findLast(o=>o.code===421)?.value??""),multiaddrs:[n]})),this._init=r}[Us]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[Ns]=["@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("failed to discover bootstrap peers - %e",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??wl]:{value:this._init.tagValue??El,ttl:this._init.tagTTL}},multiaddrs:t.multiaddrs}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t}),this.components.connectionManager.openConnection(t.id).catch(r=>{this.log.error("could not dial bootstrap peer %p - %e",t.id,r)})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function vl(e){return t=>new Ls(t,e)}return ia(Al);})();
2
+ "use strict";var Libp2PBootstrap=(()=>{var _n=Object.defineProperty;var uc=Object.getOwnPropertyDescriptor;var lc=Object.getOwnPropertyNames;var dc=Object.prototype.hasOwnProperty;var Et=(e,t)=>{for(var r in t)_n(e,r,{get:t[r],enumerable:!0})},hc=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of lc(t))!dc.call(e,o)&&o!==r&&_n(e,o,{get:()=>t[o],enumerable:!(n=uc(t,o))||n.enumerable});return e};var pc=e=>hc(_n({},"__esModule",{value:!0}),e);var ql={};Et(ql,{bootstrap:()=>kl});var Lt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},pr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var mr=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},yr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var ke=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Ps=Symbol.for("@libp2p/peer-discovery");var Cn=Symbol.for("@libp2p/peer-id");function mc(e){return typeof e?.handleEvent=="function"}function yc(e){return e===!0||e===!1}function bc(e){return yc(e)?e:e?.capture??!1}function In(e){let t={capture:bc(e),once:!!e?.once};return e?.passive!=null&&(t.passive=e?.passive),e?.signal!=null&&(t.signal=e?.signal),t}function Us(e,t){return In(e).capture===In(t).capture}var br=class extends EventTarget{#t=new Map;constructor(){super()}listenerCount(t){let r=this.#t.get(t);return r==null?0:r.length}addEventListener(t,r,n){let o=In(n);if(o?.signal?.aborted===!0)return;let s=f=>{o.once&&this.removeEventListener(t,r,o),mc(r)?r.handleEvent(f):r(f)},i=this.#t.get(t);if(i==null&&(i=[],this.#t.set(t,i)),i.some(f=>f.callback!==r?!1:Us(f.options,o)))return;super.addEventListener(t,s,o);let c=()=>{this.removeEventListener(t,r,o)};o.signal?.addEventListener("abort",c),i.push({callback:r,wrapper:s,options:o,onAbort:c})}removeEventListener(t,r,n){let o=this.#t.get(t);if(o==null){super.removeEventListener(t,r??null,n);return}this.#t.set(t,o.filter(s=>s.callback===r&&Us(s.options,n)?(super.removeEventListener(t,s.wrapper,n),s.options?.signal?.removeEventListener("abort",s.onAbort),!1):!0))}safeDispatchEvent(t,r={}){return this.dispatchEvent(new CustomEvent(t,r))}};var Ns=Symbol.for("@libp2p/service-capabilities");var Pn={};Et(Pn,{base58btc:()=>st,base58flickr:()=>Ac});var gd=new Uint8Array(0);function Ks(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Bt(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return oe(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return oe(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));throw new Error("Unknown type, must be binary type")}function Ms(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}var Fs=4096;function ks(e){let t=e.length;if(t<=Fs)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.subarray(n,n+=Fs));return r}function gc(e){return e?.buffer instanceof ArrayBuffer}function oe(e){return gc(e)?e:e.slice()}function xc(e,t,r){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),o=0;o<n.length;o++)n[o]=255;for(var s=0;s<e.length;s++){var i=e.charAt(s),a=i.charCodeAt(0);if(n[a]!==255)throw new TypeError(i+" is ambiguous");if(n[a]=s,r){var c=i.toLowerCase().charCodeAt(0),f=i.toUpperCase().charCodeAt(0);c!==a&&(n[c]=s),f!==a&&(n[f]=s)}}var u=e.length,l=e.charAt(0),y=Math.log(u)/Math.log(256),m=Math.log(256)/Math.log(u);function O(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var S=0,p=0,v=0,A=w.length;v!==A&&w[v]===0;)v++,S++;for(var M=(A-v)*m+1>>>0,k=new Uint8Array(M);v!==A;){for(var N=w[v],P=0,U=M-1;(N!==0||P<p)&&U!==-1;U--,P++)N+=256*k[U]>>>0,k[U]=N%u>>>0,N=N/u>>>0;if(N!==0)throw new Error("Non-zero carry");p=P,v++}for(var H=M-p;H!==M&&k[H]===0;)H++;for(var D=l.repeat(S);H<M;++H)D+=e.charAt(k[H]);return D}function B(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var S=0;if(w[S]!==" "){for(var p=0,v=0;w[S]===l;)p++,S++;for(var A=(w.length-S)*y+1>>>0,M=new Uint8Array(A);w[S];){var k=n[w.charCodeAt(S)];if(k===255)return;for(var N=0,P=A-1;(k!==0||N<v)&&P!==-1;P--,N++)k+=u*M[P]>>>0,M[P]=k%256>>>0,k=k/256>>>0;if(k!==0)throw new Error("Non-zero carry");v=N,S++}if(w[S]!==" "){for(var U=A-v;U!==A&&M[U]===0;)U++;for(var H=new Uint8Array(p+(A-U)),D=p;U!==A;)H[D++]=M[U++];return H}}}function I(w){var S=B(w);if(S)return S;throw new Error(`Non-${t} character`)}return{encode:O,decodeUnsafe:B,decode:I}}var wc=xc,Ec=wc,Hs=Ec;var Dn=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},On=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.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 zs(this,t)}},Rn=class{decoders;constructor(t){this.decoders=t}or(t){return zs(this,t)}decode(t){let r=t[0],n=this.decoders[r];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 zs(e,t){return new Rn({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Ln=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Dn(t,r,n),this.decoder=new On(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function be({name:e,prefix:t,encode:r,decode:n}){return new Ln(e,t,r,n)}function $t({name:e,prefix:t,alphabet:r,caseInsensitive:n=!1}){let{encode:o,decode:s}=Hs(r,e,n);return be({prefix:t,name:e,encode:o,decode:i=>Bt(s(i))})}function Sc(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),i=0,a=0,c=0;for(let f=0;f<o;++f){let u=t[e[f]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|u,i+=r,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=r||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function vc(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],i+=8;i>r;)i-=r,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<r-i]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function Bc(e,t){let r={};for(let n=0;n<e.length;++n)if(r[e[n]]=n,t){let o=e[n].toLowerCase(),s=e[n].toUpperCase();o!==e[n]&&(r[o]=n),s!==e[n]&&(r[s]=n)}return r}function nt({name:e,prefix:t,bitsPerChar:r,alphabet:n,caseInsensitive:o=!1}){let s=Bc(n,o);return be({prefix:t,name:e,encode(i){return vc(i,n,r)},decode(i){return Sc(i,s,r,e)}})}var st=$t({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ac=$t({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Un={};Et(Un,{base32:()=>Zt,base32hex:()=>Ic,base32hexpad:()=>Oc,base32hexpadupper:()=>Rc,base32hexupper:()=>Dc,base32pad:()=>_c,base32padupper:()=>Cc,base32upper:()=>Tc,base32z:()=>Lc});var Zt=nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5,caseInsensitive:!0}),Tc=nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5,caseInsensitive:!0}),_c=nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5,caseInsensitive:!0}),Cc=nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5,caseInsensitive:!0}),Ic=nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5,caseInsensitive:!0}),Dc=nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5,caseInsensitive:!0}),Oc=nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5,caseInsensitive:!0}),Rc=nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5,caseInsensitive:!0}),Lc=nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Nn={};Et(Nn,{base36:()=>qe,base36upper:()=>Pc});var qe=$t({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz",caseInsensitive:!0}),Pc=$t({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",caseInsensitive:!0});var Uc=$s,Vs=128,Nc=127,Fc=~Nc,Kc=Math.pow(2,31);function $s(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Kc;)t[r++]=e&255|Vs,e/=128;for(;e&Fc;)t[r++]=e&255|Vs,e>>>=7;return t[r]=e|0,$s.bytes=r-n+1,t}var Mc=Fn,kc=128,js=127;function Fn(e,n){var r=0,n=n||0,o=0,s=n,i,a=e.length;do{if(s>=a)throw Fn.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&js)<<o:(i&js)*Math.pow(2,o),o+=7}while(i>=kc);return Fn.bytes=s-n,r}var qc=Math.pow(2,7),Hc=Math.pow(2,14),zc=Math.pow(2,21),Vc=Math.pow(2,28),jc=Math.pow(2,35),$c=Math.pow(2,42),Zc=Math.pow(2,49),Yc=Math.pow(2,56),Wc=Math.pow(2,63),Gc=function(e){return e<qc?1:e<Hc?2:e<zc?3:e<Vc?4:e<jc?5:e<$c?6:e<Zc?7:e<Yc?8:e<Wc?9:10},Xc={encode:Uc,decode:Mc,encodingLength:Gc},Qc=Xc,He=Qc;function ze(e,t=0){let r=He.decode(e,t),n=He.decode.bytes;if(n>9)throw new RangeError("Invalid varint: too long");if(n>1&&e[t+n-1]===0)throw new RangeError("Invalid varint: not minimally encoded");return[r,n]}function ge(e,t,r=0){return He.encode(e,t,r),t}function xe(e){return He.encodingLength(e)}function Ee(e,t){let r=t.byteLength,n=xe(e),o=n+xe(r),s=new Uint8Array(o+r);return ge(e,s,0),ge(r,s,n),s.set(t,o),new we(e,r,t,s)}function Ve(e){let t=Bt(e),[r,n]=ze(t),[o,s]=ze(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new we(r,o,i,t)}function Zs(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Ks(e.bytes,r.bytes)}}var we=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=oe(n),this.bytes=oe(o)}};function Ys(e,t){let{bytes:r,version:n}=e;return n===0?tf(r,Kn(e),t??st.encoder):ef(r,Kn(e),t??Zt.encoder)}var Ws=new WeakMap;function Kn(e){let t=Ws.get(e);if(t==null){let r=new Map;return Ws.set(e,r),r}return t}var ct=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=oe(o),this["/"]=this.bytes}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:r}=this;if(t!==je)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==rf)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}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:r}=this.multihash,n=Ee(t,r);return e.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 e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&Zs(t.multihash,n.multihash)}toString(t){return Ys(this,t)}toJSON(){return{"/":Ys(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 r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new e(n,o,s,i??Gs(n,o,s.bytes))}else if(r[nf]===!0){let{version:n,multihash:o,code:s}=r,i=Ve(o);return e.create(n,s,i)}else return null}static create(t,r,n){if(typeof r!="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(r!==je)throw new Error(`Version 0 CID must use dag-pb (code: ${je}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Gs(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,je,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=Bt(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new we(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(i):e.createV1(r.codec,i),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[l,y]=ze(t.subarray(r));return r+=y,l},o=n(),s=je;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,a=n(),c=n(),f=r+c,u=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(t,r){let[n,o]=Jc(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Kn(s).set(n,t),s}};function Jc(e,t){switch(e[0]){case"Q":{let r=t??st;return[st.prefix,r.decode(`${st.prefix}${e}`)]}case st.prefix:{let r=t??st;return[st.prefix,r.decode(e)]}case Zt.prefix:{let r=t??Zt;return[Zt.prefix,r.decode(e)]}case qe.prefix:{let r=t??qe;return[qe.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function tf(e,t,r){let{prefix:n}=r;if(n!==st.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function ef(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var je=112,rf=18;function Gs(e,t,r){let n=xe(e),o=n+xe(t),s=new Uint8Array(o+r.byteLength);return ge(e,s,0),ge(t,s,n),s.set(r,o),s}var nf=Symbol.for("@ipld/js-cid/CID");var Mn={};Et(Mn,{identity:()=>_t});var Xs=0,of="identity",Qs=Bt;function sf(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return Ee(Xs,Qs(e))}var _t={code:Xs,name:of,encode:Qs,digest:sf};function bt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function af(e){return e.buffer instanceof ArrayBuffer}function Ct(e){return af(e)?e:e.slice()}async function Js(e,t,r,n){let o=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,Ct(t),Ct(r.subarray()));return n?.signal?.throwIfAborted(),s}function Pt(e=0){return new Uint8Array(e)}function mt(e=0){return new Uint8Array(e)}function cf(e){return e?.buffer instanceof ArrayBuffer}function kn(e){if(cf(e))return e;let t=e.slice();return new Uint8Array(t.buffer,0,t.byteLength)}function Ut(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=mt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return kn(r)}var ei=Symbol.for("@achingbrain/uint8arraylist");function ti(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function xr(e){return!!e?.[ei]}var St=class e{bufs;length;[ei]=!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 r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(xr(n)){r+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(xr(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=ti(this.bufs,t);return r.buf[r.index]}set(t,r){let n=ti(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(xr(t))for(let n=0;n<t.length;n++)this.set(r+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,r){let{bufs:n,length:o}=this._subList(t,r);return Ut(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:Ut(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),s=new e;return s.length=o,s.bufs=n,s}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===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 f=t>=a&&t<c,u=r>a&&r<=c;if(f&&u){if(t===a&&r===c){n.push(i);break}let l=t-a;n.push(i.subarray(l,l+(r-t)));break}if(f){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(u){if(r===c){n.push(i);break}n.push(i.subarray(0,r-a));break}n.push(i)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!xr(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(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let a=i,c=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=r;l<=c;l+=u){u=0;for(let y=f;y>=0;y--){let m=this.get(l+y);if(n[y]!==m){u=Math.max(1,y-a[m]);break}}if(u===0)return l}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=mt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=Pt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=Pt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=Pt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=mt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=Pt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=Pt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=Pt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=Pt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=Pt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!bt(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,s)=>o+s.byteLength,0)),n.length=r,n}};var qn={};Et(qn,{base10:()=>ff});var ff=$t({prefix:"9",name:"base10",alphabet:"0123456789"});var Hn={};Et(Hn,{base16:()=>uf,base16upper:()=>lf});var uf=nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4,caseInsensitive:!0}),lf=nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4,caseInsensitive:!0});var zn={};Et(zn,{base2:()=>df});var df=nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Vn={};Et(Vn,{base256emoji:()=>bf});var ri=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}"),hf=ri.reduce((e,t,r)=>(e[r]=t,e),[]),pf=ri.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function mf(e){return e.reduce((t,r)=>(t+=hf[r],t),"")}function yf(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=pf[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var bf=be({prefix:"\u{1F680}",name:"base256emoji",encode:mf,decode:yf});var $n={};Et($n,{base64:()=>gf,base64pad:()=>xf,base64url:()=>jn,base64urlpad:()=>wf});var gf=nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),xf=nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),jn=nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wf=nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Zn={};Et(Zn,{base8:()=>Ef});var Ef=nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Yn={};Et(Yn,{identity:()=>Sf});var Sf=be({prefix:"\0",name:"identity",encode:e=>ks(Bt(e)),decode:e=>Bt(Ms(e))});var nh=new TextEncoder,oh=new TextDecoder;var Xn={};Et(Xn,{sha256:()=>$e,sha512:()=>Tf});var Af=20;function Gn({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new Wn(e,t,r,n,o)}var Wn=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,s){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Af,this.maxDigestLength=s}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?ni(n,this.code,r?.truncate):n.then(o=>ni(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function ni(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return Ee(t,e)}function si(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var $e=Gn({name:"sha2-256",code:18,encode:si("SHA-256")}),Tf=Gn({name:"sha2-512",code:19,encode:si("SHA-512")});var Ze={...Yn,...zn,...Zn,...qn,...Hn,...Un,...Nn,...Pn,...$n,...Vn},yh={...Xn,...Mn};function ai(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var ii=ai("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Qn=ai("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=mt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),_f={utf8:ii,"utf-8":ii,hex:Ze.base16,latin1:Qn,ascii:Qn,binary:Qn,...Ze},wr=_f;function gt(e,t="utf8"){let r=wr[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function ot(e,t="utf8"){let r=wr[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var Cf=parseInt("11111",2),Jn=parseInt("10000000",2),If=parseInt("01111111",2),ci={0:Ye,1:Ye,2:Df,3:Lf,4:Pf,5:Rf,6:Of,16:Ye,22:Ye,48:Ye};function to(e,t={offset:0}){let r=e[t.offset]&Cf;if(t.offset++,ci[r]!=null)return ci[r](e,t);throw new Error("No decoder for tag "+r)}function We(e,t){let r=0;if((e[t.offset]&Jn)===Jn){let n=e[t.offset]&If,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++){if(t.offset>=e.byteLength)throw new Error("invalid DER element length");o+=e[t.offset].toString(16).padStart(2,"0")}r=parseInt(o,16)}else r=e[t.offset],t.offset++;if(!Number.isInteger(r)||r<0||r>e.byteLength-t.offset)throw new Error("invalid DER element length");return r}function Ye(e,t){We(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=to(e,t);if(n===null)break;r.push(n)}return r}function Df(e,t){let r=We(e,t),n=t.offset,o=t.offset+r,s=[];for(let i=n;i<o;i++)i===n&&e[i]===0||s.push(e[i]);return t.offset+=r,Uint8Array.from(s)}function Of(e,t){let r=We(e,t),n=t.offset+r,o=e[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 f=e[t.offset];if(t.offset++,c.push(f&127),f<128){c.reverse();let u=0;for(let l=0;l<c.length;l++)u+=c[l]<<l*7;a+=`.${u}`,c=[]}}return a}function Rf(e,t){return t.offset++,null}function Lf(e,t){let r=We(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Pf(e,t){let r=We(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function Uf(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new St;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function eo(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=Uf(e.byteLength);return new St(Uint8Array.from([t.byteLength|Jn]),t)}function fi(e){let t=new St,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new St(Uint8Array.from([2]),eo(t),t)}function ui(e){let t=Uint8Array.from([0]),r=new St(t,e);return new St(Uint8Array.from([3]),eo(r),r)}function Er(e,t=48){let r=new St;for(let n of e)r.append(n);return new St(Uint8Array.from([t]),eo(r),r)}var Nf=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Ff=Uint8Array.from([6,5,43,129,4,0,34]),Kf=Uint8Array.from([6,5,43,129,4,0,35]),Mf={ext:!0,kty:"EC",crv:"P-256"},kf={ext:!0,kty:"EC",crv:"P-384"},qf={ext:!0,kty:"EC",crv:"P-521"},ro=32,no=48,oo=66;function li(e){let t=to(e);return di(t)}function di(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===ro*2+1)return n=ot(t.subarray(r,r+ro),"base64url"),o=ot(t.subarray(r+ro),"base64url"),new ve({...Mf,key_ops:["verify"],x:n,y:o});if(t.byteLength===no*2+1)return n=ot(t.subarray(r,r+no),"base64url"),o=ot(t.subarray(r+no),"base64url"),new ve({...kf,key_ops:["verify"],x:n,y:o});if(t.byteLength===oo*2+1)return n=ot(t.subarray(r,r+oo),"base64url"),o=ot(t.subarray(r+oo),"base64url"),new ve({...qf,key_ops:["verify"],x:n,y:o});throw new Lt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function hi(e){return Er([fi(Uint8Array.from([1])),Er([Hf(e.crv)],160),Er([ui(new St(Uint8Array.from([4]),gt(e.x??"","base64url"),gt(e.y??"","base64url")))],161)]).subarray()}function Hf(e){if(e==="P-256")return Nf;if(e==="P-384")return Ff;if(e==="P-521")return Kf;throw new Lt(`Invalid curve ${e}`)}var ve=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=hi(this.jwk)),this._raw}toMultihash(){return _t.digest(Be(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return st.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}async verify(t,r,n){return Js(this.jwk,r,t,n)}};var Sr=BigInt(4294967295),pi=BigInt(32);function zf(e,t=!1){return t?{h:Number(e&Sr),l:Number(e>>pi&Sr)}:{h:Number(e>>pi&Sr)|0,l:Number(e&Sr)|0}}function mi(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=zf(e[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var Vf=e=>e/2**32|0,jf=e=>e>>>0;function yi(e,t,r,n){let o=Vf(r),s=jf(r);e.setUint32(t,n?s:o,n),e.setUint32(t+4,n?o:s,n)}var so=(e,t,r)=>e>>>r,io=(e,t,r)=>e<<32-r|t>>>r,se=(e,t,r)=>e>>>r|t<<32-r,ie=(e,t,r)=>e<<32-r|t>>>r,Ge=(e,t,r)=>e<<64-r|t>>>r-32,Xe=(e,t,r)=>e>>>r-32|t<<64-r;function Nt(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var bi=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),gi=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,xi=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),wi=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Ei=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Si=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;function vr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}var ao=e=>e?`"${e}" `:"";function Mt(e,t=""){if(typeof e!="number")throw new TypeError(ao(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(ao(t)+"expected integer >= 0, got "+e);return e}function At(e,t,r=""){if(vr(e)&&(t===void 0||e.length===t))return e;t!==void 0&&Mt(t,"length");let n=vr(e),o=t!==void 0?` of length ${t}`:"",s=n?`length=${e.length}`:`type=${typeof e}`,i=ao(r)+"expected Uint8Array"+o+", got "+s;throw n?new RangeError(i):new TypeError(i)}function Br(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(Mt(e.outputLen),Mt(e.blockLen),e.outputLen<1||e.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var vi=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof e)};function Ae(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function Ar(e,t){At(e,void 0,"output");let r=t.outputLen;if(!(e.length>=r))throw new RangeError('"output" expected length >= '+r)}function ae(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Tr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function It(e,t){return e<<32-t|e>>>t}var Ai=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Zf=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function _r(e){if(At(e),Ai)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Zf[e[r]];return t}function Bi(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function Cr(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(Ai)try{return Uint8Array.fromHex(e)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=Bi(e.charCodeAt(s)),a=Bi(e.charCodeAt(s+1));if(i===void 0||a===void 0){let c=e[s]+e[s+1];throw new RangeError('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function co(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];At(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}function Yf(e,t,r="opts"){return vi(e,"defaults"),t!==void 0&&vi(t,r),Object.assign(e,t)}function fo(e,t={}){if(typeof e!="function")throw new TypeError('"hashCons" expected function, got type='+typeof e);t=Yf({},t,"info");let r=(o,s)=>e(s).update(o).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}function Ti(e=32){Mt(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var uo=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function _i(e,t,r){return e&t^~e&r}function Ci(e,t,r){return e&t^e&r^t&r}var Qe=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,o){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=Tr(this.buffer)}update(t){Ae(this),At(t);let{view:r,buffer:n,blockLen:o}=this,s=t.length,i=!1;for(let a=0;a<s;){let c=Math.min(o-this.pos,s-a);if(c===o){let f=Tr(t);for(;o<=s-a;a+=o)this.process(f,a);i=!0;continue}n.set(a===0&&c===s?t:t.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===o&&(this.process(r,0),this.pos=0,i=!0)}return this.length+=t.length,i&&this.roundClean(),this}digestInto(t){Ae(this),Ar(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,r.fill(0,i),this.padOffset>o-i&&(this.process(n,0),r.fill(0)),yi(n,o-8,this.length*8,s),this.process(n,0),this.roundClean();let a=t===r?n:Tr(t),c=this.outputLen,f=c/4,u=this.get();if(c%4||f>u.length)throw new Error("invalid outputLen");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneIntoMeta(t){let{buffer:r,length:n,finished:o,destroyed:s,pos:i}=this;return t.destroyed=s,t.finished=o,t.length=n,t.pos=i,i&&t.buffer.set(r),t}clone(){return this._cloneInto()}},Ii=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Di=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Wf=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]),Yt=new Uint32Array(64),lo=class extends Qe{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(t,r){super(64,t,8,!1),this.A=r[0]|0,this.B=r[1]|0,this.C=r[2]|0,this.D=r[3]|0,this.E=r[4]|0,this.F=r[5]|0,this.G=r[6]|0,this.H=r[7]|0}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,r,n,o,s,i,a,c]}set(t,r,n,o,s,i,a,c){this.A=t|0,this.B=r|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}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,r){for(let l=0;l<16;l++,r+=4)Yt[l]=t.getUint32(r,!1);for(let l=16;l<64;l++){let y=Yt[l-15],m=Yt[l-2],O=It(y,7)^It(y,18)^y>>>3,B=It(m,17)^It(m,19)^m>>>10;Yt[l]=B+Yt[l-7]+O+Yt[l-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let y=It(a,6)^It(a,11)^It(a,25),m=u+y+_i(a,c,f)+Wf[l]+Yt[l]|0,B=(It(n,2)^It(n,13)^It(n,22))+Ci(n,o,s)|0;u=f,f=c,c=a,a=i+m|0,i=s,s=o,o=n,n=m+B|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,f=f+this.G|0,u=u+this.H|0,this.set(n,o,s,i,a,c,f,u)}roundClean(){ae(Yt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),ae(this.buffer)}},ho=class extends lo{constructor(){super(32,Ii)}};var Oi=mi(["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(e=>BigInt(e))),Gf=Oi[0],Xf=Oi[1],Wt=new Uint32Array(80),Gt=new Uint32Array(80),po=class extends Qe{Ah=0;Al=0;Bh=0;Bl=0;Ch=0;Cl=0;Dh=0;Dl=0;Eh=0;El=0;Fh=0;Fl=0;Gh=0;Gl=0;Hh=0;Hl=0;constructor(t,r){super(128,t,16,!1),this.Ah=r[0]|0,this.Al=r[1]|0,this.Bh=r[2]|0,this.Bl=r[3]|0,this.Ch=r[4]|0,this.Cl=r[5]|0,this.Dh=r[6]|0,this.Dl=r[7]|0,this.Eh=r[8]|0,this.El=r[9]|0,this.Fh=r[10]|0,this.Fl=r[11]|0,this.Gh=r[12]|0,this.Gl=r[13]|0,this.Hh=r[14]|0,this.Hl=r[15]|0}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:y,Gh:m,Gl:O,Hh:B,Hl:I}=this;return[t,r,n,o,s,i,a,c,f,u,l,y,m,O,B,I]}set(t,r,n,o,s,i,a,c,f,u,l,y,m,O,B,I){this.Ah=t|0,this.Al=r|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=f|0,this.El=u|0,this.Fh=l|0,this.Fl=y|0,this.Gh=m|0,this.Gl=O|0,this.Hh=B|0,this.Hl=I|0}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,r){for(let p=0;p<16;p++,r+=4)Wt[p]=t.getUint32(r),Gt[p]=t.getUint32(r+=4);for(let p=16;p<80;p++){let v=Wt[p-15]|0,A=Gt[p-15]|0,M=se(v,A,1)^se(v,A,8)^so(v,A,7),k=ie(v,A,1)^ie(v,A,8)^io(v,A,7),N=Wt[p-2]|0,P=Gt[p-2]|0,U=se(N,P,19)^Ge(N,P,61)^so(N,P,6),H=ie(N,P,19)^Xe(N,P,61)^io(N,P,6),D=xi(k,H,Gt[p-7],Gt[p-16]),X=wi(D,M,U,Wt[p-7],Wt[p-16]);Wt[p]=X|0,Gt[p]=D|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:y,Fh:m,Fl:O,Gh:B,Gl:I,Hh:w,Hl:S}=this;for(let p=0;p<80;p++){let v=se(l,y,14)^se(l,y,18)^Ge(l,y,41),A=ie(l,y,14)^ie(l,y,18)^Xe(l,y,41),M=l&m^~l&B,k=y&O^~y&I,N=Ei(S,A,k,Xf[p],Gt[p]),P=Si(N,w,v,M,Gf[p],Wt[p]),U=N|0,H=se(n,o,28)^Ge(n,o,34)^Ge(n,o,39),D=ie(n,o,28)^Xe(n,o,34)^Xe(n,o,39),X=n&s^n&a^s&a,C=o&i^o&c^i&c;w=B|0,S=I|0,B=m|0,I=O|0,m=l|0,O=y|0,{h:l,l:y}=Nt(f|0,u|0,P|0,U|0),f=a|0,u=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let _=bi(U,D,C);n=gi(_,P,H,X),o=_|0}({h:n,l:o}=Nt(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=Nt(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=Nt(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=Nt(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:y}=Nt(this.Eh|0,this.El|0,l|0,y|0),{h:m,l:O}=Nt(this.Fh|0,this.Fl|0,m|0,O|0),{h:B,l:I}=Nt(this.Gh|0,this.Gl|0,B|0,I|0),{h:w,l:S}=Nt(this.Hh|0,this.Hl|0,w|0,S|0),this.set(n,o,s,i,a,c,f,u,l,y,m,O,B,I,w,S)}roundClean(){ae(Wt,Gt)}destroy(){this.destroyed=!0,ae(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},mo=class extends po{constructor(){super(64,Di)}};var Ri=fo(()=>new ho,uo(1));var yo=fo(()=>new mo,uo(3));function Dr(e,t,r=()=>{}){if(!Array.isArray(e))throw new TypeError(`"${t}" expected array, got type=${typeof e}`);for(let n=0;n<e.length;n++)r(e[n],`${t}[${n}]`);return e}var Z=(e,t,r)=>At(e,t,r),bo=Mt;function Pi(e,t=""){if(typeof e!="string"){let r=t&&`"${t}" `;throw new TypeError(r+"expected string, got type="+typeof e)}return e}function Xt(e,t="object"){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(t==="object"?"expected valid options object":`"${t}" expected object, got type=${typeof e}`);return e}function ce(e,t){if(typeof e!="function")throw new TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}var Je=_r,Tt=(...e)=>co(...e),Te=e=>Cr(e),Jt=vr,fe=e=>Ti(e),Ir=BigInt(0),Li=BigInt(1),Qf=e=>e?`"${e}" `:"";function xt(e,t=""){if(typeof e!="boolean")throw new TypeError(Qf(t)+"expected boolean, got type="+typeof e);return e}function Or(e){if(typeof e=="bigint"){if(!Qt(e))throw new RangeError("positive bigint expected, got "+e)}else bo(e);return e}function te(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function tr(e){let t=Or(e).toString(16);return t.length&1?"0"+t:t}function Ui(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?Ir:BigInt("0x"+e)}function Ft(e){return Ui(_r(e))}function ue(e){return Ui(_r(Lr(At(e)).reverse()))}function Rr(e,t){if(Mt(t),t===0)throw new Error("zero output length is invalid");e=Or(e);let r=t*2,n=e.toString(16);if(n.length>r)throw new RangeError("number is too large");return Cr(n.padStart(r,"0"))}function go(e,t){return Rr(e,t).reverse()}function Lr(e){return Uint8Array.from(Z(e))}function Qt(e){return typeof e=="bigint"&&Ir<=e}function xo(e,t,r){return Qt(e)&&Qt(t)&&Qt(r)&&t<=e&&e<r}function _e(e,t,r,n){if(!xo(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Ce(e){if(e<Ir)throw new Error("expected non-negative bigint, got "+e);return e===Ir?0:e.toString(2).length}var er=e=>(te(e,"n"),(Li<<BigInt(e))-Li);function Ni(e,t,r){if(Mt(e,"hashLen"),Mt(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=I=>new Uint8Array(I),o=Uint8Array.of(),s=Uint8Array.of(0),i=Uint8Array.of(1),a=1e3,c=n(e),f=n(e),u=0,l=()=>{c.fill(1),f.fill(0),u=0},y=(...I)=>r(f,Tt(c,...I)),m=(I=o)=>{f=y(s,I),c=y(),I.length!==0&&(f=y(i,I),c=y())},O=()=>{if(u++>=a)throw new Error("drbg: tried max amount of iterations");let I=0,w=[];for(;I<t;){c=y();let S=c.slice();w.push(S),I+=c.length}return Tt(...w)};return(I,w)=>{l(),m(I);let S;for(;(S=w(O()))===void 0;)m();return l(),S}}function wt(e,t={},r={},n="object"){Xt(e,n),Xt(t,"fields"),Xt(r,"optFields");function o(i,a,c){let f=n==="object"?`param "${String(i)}"`:`"${n}.${String(i)}"`,u=e[i];if(!Object.hasOwn(e,i)&&(c?u!==void 0:a!=="function"))throw new TypeError(`${f} is invalid: expected own property`);if(c&&u===void 0)return;let l=typeof u;if(l!==a||u===null)throw new TypeError(`${f} is invalid: expected ${a}, got ${l}`)}let s=(i,a)=>Object.entries(i).forEach(([c,f])=>o(c,f,a));s(t,!1),s(r,!0)}var it=BigInt(0),Y=BigInt(1),ee=BigInt(2),Mi=BigInt(3),wo=BigInt(4),ki=BigInt(5),Jf=BigInt(7),qi=BigInt(8),tu=BigInt(9),eu=BigInt(15),Hi=BigInt(16),ru=BigInt("0x10000000000000000");function J(e,t){if(t<=it)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=it?r:t+r}function zi(e,t,r){if(r<=Y)throw new Error("pow: expected modulus > 1, got "+r);if(typeof t!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof t);if(t<it)throw new Error("invalid exponent, negatives unsupported");if(t===it)return Y;if(t===Y)return e;let n=e%r;if(n<it&&(n+=r),t<ru){let a=Y;for(;t>it;)t&Y&&(a=a*n%r),n=n*n%r,t>>=Y;return a}let o=[];for(;t>it;)o.push(Number(t&eu)),t>>=wo;let s=new Array(16);s[0]=Y,s[1]=n;for(let a=2;a<16;a++)s[a]=s[a-1]*n%r;let i=s[o[o.length-1]];for(let a=o.length-2;a>=0;a--){i=i*i%r,i=i*i%r,i=i*i%r,i=i*i%r;let c=o[a];c!==0&&(i=i*s[c]%r)}return i}function Q(e,t,r){if(r<=Y)throw new Error("pow2: expected modulus > 1, got "+r);if(t<it)throw new Error("pow2: expected non-negative exponent, got "+t);let n=e;for(;t-- >it;)n*=n,n%=r;return n}function Fi(e,t){if(e===it)throw new Error("invert: expected non-zero number");if(t<=Y)throw new Error("invert: expected modulus > 1, got "+t);let r=J(e,t),n=t,o=it,s=Y;for(;r!==it;){let a=n/r,c=n-r*a,f=o-s*a;n=r,r=c,o=s,s=f}if(n!==Y)throw new Error("invert: does not exist");return J(o,t)}function Vi(e,t){if(t<=Y)throw new Error("invertCt: expected prime modulus > 1, got "+t);let r=J(e,t);if(r===it)throw new Error("invertCt: expected non-zero number");let n=zi(r,t-ee,t);if(J(r*n,t)!==Y)throw new Error("invertCt: does not exist");return n}function Eo(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function So(e,t){if((e&Y)===it)throw new Error(t+": expected odd modulus, got "+e)}function ji(e,t){let r=e,n=(r.ORDER+Y)/wo,o=r.pow(t,n);return Eo(r,o,t),o}function nu(e,t){let r=e,n=(r.ORDER-ki)/qi,o=r.mul(t,ee),s=r.pow(o,n),i=r.mul(t,s),a=r.mul(r.mul(i,ee),s),c=r.mul(i,r.sub(a,r.ONE));return Eo(r,c,t),c}function ou(e){let t=De(e),r=$i(e),n=r(t,t.neg(t.ONE)),o=r(t,n),s=r(t,t.neg(n)),i=(e+Jf)/Hi;return((a,c)=>{let f=a,u=f.pow(c,i),l=f.mul(u,n),y=f.mul(u,o),m=f.mul(u,s),O=f.eql(f.sqr(l),c),B=f.eql(f.sqr(y),c);u=f.cmov(u,l,O),l=f.cmov(m,y,B);let I=f.eql(f.sqr(l),c),w=f.cmov(u,l,I);return Eo(f,w,c),w})}function $i(e){if(e<Mi)throw new Error("sqrt is not defined for small field");So(e,"tonelliShanks");let t=e-Y,r=0;for(;t%ee===it;)t/=ee,r++;let n=ee,o=De(e);for(;rr(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return ji;let s=o.pow(n,t),i=(t+Y)/ee;return function(c,f){let u=c;if(u.is0(f))return f;if(rr(u,f)!==1)throw new Error("Cannot find square root");let l=r,y=u.mul(u.ONE,s),m=u.pow(f,t),O=u.pow(f,i);for(;!u.eql(m,u.ONE);){if(u.is0(m))throw new Error("Cannot find square root: probably non-prime P");let B=1,I=u.sqr(m);for(;!u.eql(I,u.ONE);)if(B++,I=u.sqr(I),B===l)throw new Error("Cannot find square root");let w=Y<<BigInt(l-B-1),S=u.pow(y,w);l=B,y=u.sqr(S),m=u.mul(m,y),O=u.mul(O,S)}return O}}function su(e){return So(e,"Fp.sqrt"),e%wo===Mi?ji:e%qi===ki?nu:e%Hi===tu?ou(e):$i(e)}var Zi=(e,t)=>(J(e,t)&Y)===Y,iu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ie(e){if(Xt(e,"field"),typeof e.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof e.ORDER);te(e.BYTES,"BYTES"),te(e.BITS,"BITS");for(let t of iu)ce(e[t],"field."+t);if(e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=Y)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function Ur(e,t,r=!1){Ie(e),Dr(t,"nums"),xt(r,"passZero");let n=e,o=new Array(t.length).fill(r?n.ZERO:void 0),s=t.reduce((a,c,f)=>n.is0(c)?a:(o[f]=a,n.mul(a,c)),n.ONE),i=n.inv(s);return t.reduceRight((a,c,f)=>n.is0(c)?a:(o[f]=n.mul(a,o[f]),n.mul(a,c)),i),o}function rr(e,t){Ie(e);let r=e;So(r.ORDER,"FpLegendre");let n=(r.ORDER-Y)/ee,o=r.pow(t,n),s=r.eql(o,r.ONE),i=r.eql(o,r.ZERO),a=r.eql(o,r.neg(r.ONE));if(!s&&!i&&!a)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function au(e,t){if(t!==void 0&&bo(t),e<=it)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=Ce(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${r})`);let n=t!==void 0?t:r,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var Ki=new WeakMap,Pr=class{ORDER;BITS;BYTES;isLE;ZERO=it;ONE=Y;_lengths;_mod;constructor(t,r={}){if(t<=Y)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:s}=au(t,n);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=s,Object.freeze(this)}create(t){return J(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return it<=t&&t<this.ORDER}is0(t){return t===it}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&Y)===Y}neg(t){return J(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return J(t*t,this.ORDER)}add(t,r){return J(t+r,this.ORDER)}sub(t,r){return J(t-r,this.ORDER)}mul(t,r){return J(t*r,this.ORDER)}pow(t,r){return zi(t,r,this.ORDER)}div(t,r){return J(t*Fi(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return Fi(t,this.ORDER)}sqrt(t){let r=Ki.get(this);return r||Ki.set(this,r=su(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?go(t,this.BYTES):Rr(t,this.BYTES)}fromBytes(t,r=!1){Z(t);let{_lengths:n,BYTES:o,isLE:s,ORDER:i,_mod:a}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let f=new Uint8Array(o);f.set(t,s?0:f.length-t.length),t=f}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let c=s?ue(t):Ft(t);if(a&&(c=J(c,i)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(t){return Ur(this,t,!0)}cmov(t,r,n){return xt(n,"condition"),n?r:t}};function De(e,t={}){return Object.freeze(Pr.prototype),new Pr(e,t)}function Yi(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=Y)throw new Error("field order must be greater than 1");let t=Ce(e-Y);return Math.ceil(t/8)}function Nr(e){let t=Yi(e);return t+Math.ceil(t/2)}function Fr(e,t,r=!1){Z(e);let n=e.length,o=Yi(t),s=Math.max(Nr(t),16);if(n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=r?ue(e):Ft(e),a=J(i,t-Y)+Y;return r?go(a,o):Rr(a,o)}var Ao=BigInt(0),nr=BigInt(1),cu=BigInt(4),vo=16,Wi=128,fu=5,Gi=2**31;function re(e){let t=e;if(typeof t!="function")throw new TypeError('"Point" expected constructor, got type='+typeof e);ce(t.fromAffine,"Point.fromAffine"),ce(t.fromBytes,"Point.fromBytes"),ce(t.fromHex,"Point.fromHex"),Xt(t.BASE,"Point.BASE"),Xt(t.ZERO,"Point.ZERO"),Ie(t.Fp),Ie(t.Fn)}function Kr(e,t){re(e),Qi(t,e);let r=Ur(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function uu(e,t,r=1){if(!Number.isSafeInteger(e)||e<r||e>t)throw new Error("invalid window size, expected ["+r+".."+t+"], got W="+e)}function lu(e,t){let r=e*(4*t+128);if(r>Gi)throw new Error("invalid window size: table would need ~"+Math.ceil(r/2**20)+" MiB, max "+Gi/2**20+" MiB")}function To(e,t){if(e!==void 0){ce(e,"randomBytes");try{let r=e(t);if(!Jt(r)||r.length!==t)return}catch{return}return e}}function Qi(e,t){Dr(e,"points"),e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function du(e,t,r){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,o)=>{if(!(r===void 0?t.isValid(n):Qt(n)&&n<r))throw new Error("invalid scalar at index "+o)})}var Ji=new WeakMap;function Bo(e){return Ji.get(e)||1}function hu(e,t){let r=e.double(),n=[e];for(let o=1;o<t;o++)n.push(n[o-1].add(r));return n}function pu(e,t){let r=2**t,n=r/2,o=BigInt(r-1),s=[];for(;e>Ao;){let i=0;e&nr&&(i=Number(e&o),i>=n&&(i-=r),e-=BigInt(i)),s.push(i),e>>=nr}return s}function mu(e,t,r){let n=2**t,o=n/2,s=BigInt(n-1),i=BigInt(t),a=[];for(let c=0;c<r;c++){let f=Number(e&s);e>>=i,f>o&&(f-=n,e+=nr),a.push(f)}if(e!==Ao)throw new Error("invalid wnaf");return a}function yu(e,t,r){let n=0;for(let s of r)n=Math.max(n,s.length);let o=e;for(let s=n-1;s>=0;s--){s!==n-1&&(o=o.double());for(let i=0;i<r.length;i++){let a=r[i][s];if(a){let c=t[i][Math.abs(a)-1>>1];o=o.add(a<0?c.negate():c)}}}return o}var Oe=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(t,r){re(t),this.randomBytes=To(r,vo),this.Point=t,this.BASE=t.BASE,this.ZERO=t.ZERO,this.bits=t.Fn.BITS}buildWnafTable(t,r,n){let o=Math.ceil(n/r)+1,s=2**(r-1),i=[],a=t;for(let c=0;c<o;c++){let f=a;for(let u=0;u<s;u++)i.push(f),f=f.add(a);a=i[i.length-1].double()}return{W:r,bits:n,windows:o,comp:i}}wnafCachedCT(t,r){let{W:n,windows:o,comp:s}=t,i=2**(n-1),a=mu(r,n,o),c=this.ZERO,f=this.BASE;for(let u=0;u<o;u++){let l=a[u],y=u*i,m=Math.abs(l)-1,O=s[y];for(let I=1;I<i;I++)O=I===m?s[y+I]:O;let B=O.negate();l===0?f=f.add(s[y]):c=c.add(l<0?B:O)}return{p:c,f}}getWnafPrecomputes(t,r,n,o){let s=this.wnafPrecomputes.get(r),i=s?.find(a=>a.W===t&&a.bits===n);return i||(i=this.buildWnafTable(r,t,n),typeof o=="function"&&(i={...i,comp:o(i.comp)}),s||(s=[],this.wnafPrecomputes.set(r,s)),s.push(i)),i}assertPoint(t){if(!(t instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof t)}validateMulInput(t,r){if(this.assertPoint(t),!xo(r,nr,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(t,r,n,o){let s=Bo(t);return s===1?this.fixedWindowCT(t,r,n):this.wnafCachedCT(this.getWnafPrecomputes(s,t,n,o),r)}mulCT(t,r,n){return this.validateMulInput(t,r),this.runCT(t,r,this.bits,n)}mulCTBlinded(t,r,n){if(this.validateMulInput(t,r),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let o=this.Point.Fn.BITS+Wi,s=this.randomBytes(vo);if(!Jt(s)||s.length!==vo)throw new Error("randomBytes returned invalid byte array");s[0]=s[0]&63|128;let i=r+Ft(s)*this.Point.Fn.ORDER;return this.runCT(t,i,o,n)}fixedWindowCT(t,r,n){let o=fu,s=1<<o,i=er(o),a=new Array(s);a[0]=this.ZERO;for(let u=1;u<s;u++)a[u]=a[u-1].add(t);let c=Math.ceil(n/o),f=this.ZERO;for(let u=c-1;u>=0;u--){if(u!==c-1)for(let m=0;m<o;m++)f=f.double();let l=Number(r>>BigInt(u*o)&i),y=a[0];for(let m=1;m<s;m++)y=m===l?a[m]:y;f=f.add(y)}return{p:f,f}}shouldBlind(t,r){return this.randomBytes===void 0?!1:r===nr?!0:t!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(t,r,n,o){return this.shouldBlind(t,n)?this.mulCTBlinded(t,r,o):this.mulCT(t,r,o)}mulUnsafe(t,r,n){if(this.assertPoint(t),!Qt(r))throw new Error("invalid scalar");let o=Bo(t);if(o===1||r>=this.Point.Fn.ORDER)return Mr(this.Point,[t],[r],!0);let s=this.getWnafPrecomputes(o,t,this.bits,n);return this.wnafCachedCT(s,r).p}setWindowSize(t,r){this.assertPoint(t),uu(r,this.bits);let n=Math.ceil((this.bits+Wi)/r)+1;lu(n*2**(r-1),this.Point.Fp.BYTES),Ji.set(t,r),this.wnafPrecomputes.delete(t)}hasWindowSize(t){return Bo(t)!==1}};function Mr(e,t,r,n=!1){if(re(e),Qi(t,e),xt(n,"allowOversized"),du(r,e.Fn,n?e.Fn.ORDER**cu:void 0),t.length!==r.length)throw new Error("arrays of points and scalars must have equal length");let o=t.map(i=>hu(i,4)),s=r.map(i=>pu(i,4));return yu(e.ZERO,o,s)}function Xi(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Ie(t),t}else return De(e,{isLE:r})}function kr(e,t,r={},n){if(e!=="weierstrass"&&e!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);wt(r);for(let c of["p","n","h"]){let f=t[c];if(!(Qt(f)&&f!==Ao))throw new Error(`CURVE.${c} must be positive bigint`)}let o=Xi(t.p,r.Fp,n),s=Xi(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:s}}function qr(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var Hr=BigInt(0),zr=BigInt(1),Vr=BigInt(2),bu=BigInt(4),ta=BigInt(8);function gu(e,t,r,n){let o=e.sqr(r),s=e.sqr(n),i=e.add(e.mul(t.a,o),s),a=e.add(e.ONE,e.mul(t.d,e.mul(o,s)));return e.eql(i,a)}function ea(e,t={}){wt(t,{},{},"extraOpts");let r=t,n=kr("edwards",e,r,r.FpFnLE),{Fp:o,Fn:s}=n,i=n.CURVE,{h:a}=i;if(rr(o,i.a)!==1)throw new Error("edwards: CURVE.a must be a square in Fp for complete addition formulas");if(rr(o,i.d)!==-1)throw new Error("edwards: CURVE.d must be a non-square in Fp for complete addition formulas");wt(r,{},{uvRatio:"function",randomBytes:"function"});let c=r.randomBytes===void 0?fe:r.randomBytes,f=Vr<<BigInt(o.BYTES*8)-zr;function u(S){if(!o.isOdd)throw new Error("Field does not have .isOdd()");return o.isOdd(S)}let l=r.uvRatio===void 0?(S,p)=>{try{return{isValid:!0,value:o.sqrt(o.div(S,p))}}catch{return{isValid:!1,value:Hr}}}:r.uvRatio;if(!gu(o,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");let y=o.eql(i.a,o.neg(o.ONE))?S=>o.neg(S):o.eql(i.a,o.ONE)?S=>S:S=>o.mul(i.a,S);function m(S,p,v=!1){let A=v?zr:Hr;return _e("coordinate "+S,p,A,f),p}function O(S){if(!(S instanceof B))throw new Error("EdwardsPoint expected")}class B{static BASE=new B(i.Gx,i.Gy,o.ONE,o.mul(i.Gx,i.Gy));static ZERO=new B(o.ZERO,o.ONE,o.ONE,o.ZERO);static Fp=o;static Fn=s;X;Y;Z;T;constructor(p,v,A,M){this.X=m("x",p),this.Y=m("y",v),this.Z=m("z",A,!0),this.T=m("t",M),Object.freeze(this)}static CURVE(){return i}static fromAffine(p){if(p instanceof B)throw new Error("extended point not allowed");let{x:v,y:A}=p||{};return m("x",v),m("y",A),new B(v,A,o.ONE,o.mul(v,A))}static fromBytes(p,v=!1){let A=o.BYTES,{a:M,d:k}=i;p=Lr(Z(p,A,"point")),xt(v,"zip215");let N=Lr(p),P=p[A-1];N[A-1]=P&-129;let U=ue(N),H=v?f:o.ORDER;_e("point.y",U,Hr,H);let D=o.sqr(U),X=o.sub(D,o.ONE),C=o.sub(o.mulN(k,D),M),{isValid:_,value:d}=l(X,C);if(!_)throw new Error("bad point: invalid y coordinate");let b=u(d),x=(P&128)!==0;if(!v&&o.is0(d)&&x)throw new Error("bad point: x=0 and x_0=1");return x!==b&&(d=o.neg(d)),B.fromAffine({x:d,y:U})}static fromHex(p,v=!1){return B.fromBytes(Te(p),v)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(p=6,v=!0){return w.setWindowSize(this,p),v||this.multiply(Vr),this}assertValidity(){let p=this,{a:v,d:A}=i;if(p.is0())throw new Error("bad point: ZERO");let{X:M,Y:k,Z:N,T:P}=p,U=o.sqr(M),H=o.sqr(k),D=o.sqr(N),X=o.sqr(D),C=o.mul(U,v),_=o.mul(o.add(C,H),D),d=o.add(X,o.mul(A,o.mul(U,H)));if(!o.eql(_,d))throw new Error("bad point: equation left != right (1)");let b=o.mul(M,k),x=o.mul(N,P);if(!o.eql(b,x))throw new Error("bad point: equation left != right (2)")}equals(p){O(p);let{X:v,Y:A,Z:M}=this,{X:k,Y:N,Z:P}=p,U=o.mul(v,P),H=o.mul(k,M),D=o.mul(A,P),X=o.mul(N,M);return o.eql(U,H)&&o.eql(D,X)}is0(){return this.equals(B.ZERO)}negate(){return new B(o.neg(this.X),this.Y,this.Z,o.neg(this.T))}double(){let{X:p,Y:v,Z:A}=this,M=o.sqr(p),k=o.sqr(v),N=o.mul(o.sqr(A),Vr),P=y(M),U=o.addN(p,v),H=o.sub(o.subN(o.sqr(U),M),k),D=o.addN(P,k),X=o.subN(D,N),C=o.subN(P,k),_=o.mul(H,X),d=o.mul(D,C),b=o.mul(H,C),x=o.mul(X,D);return new B(_,d,x,b)}add(p){O(p);let{d:v}=i,{X:A,Y:M,Z:k,T:N}=this,{X:P,Y:U,Z:H,T:D}=p,X=o.mul(A,P),C=o.mul(M,U),_=o.mul(o.mulN(N,v),D),d=o.mul(k,H),b=o.sub(o.subN(o.mulN(o.addN(A,M),o.addN(P,U)),X),C),x=o.subN(d,_),R=o.addN(d,_),g=o.sub(C,y(X)),h=o.mul(b,x),E=o.mul(R,g),T=o.mul(b,g),F=o.mul(x,R);return new B(h,E,F,T)}subtract(p){return O(p),this.add(p.negate())}multiply(p){if(!s.isValidNot0(p))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:v,f:A}=w.mulSecret(this,p,a,I);return I([v,A])[0]}multiplyUnsafe(p){if(!s.isValid(p))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return p===Hr?B.ZERO:this.is0()||p===zr?this:w.mulUnsafe(this,p,I)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return w.mulUnsafe(this,i.n).is0()}toAffine(p){let v=this,A=p;if(A!=null&&typeof A!="bigint")throw new TypeError('"invertedZ" expected bigint, got type='+typeof A);let{X:M,Y:k,Z:N}=v,P=v.is0();A==null&&(A=P?o.create(ta):o.inv(N));let U=o.mul(M,A),H=o.mul(k,A),D=o.mul(N,A);if(P)return{x:o.ZERO,y:o.ONE};if(!o.eql(D,o.ONE))throw new Error("invZ was invalid");return{x:U,y:H}}clearCofactor(){return a===zr?this:a===Vr?this.double():a===bu?this.double().double():a===ta?this.double().double().double():this.multiplyUnsafe(a)}toBytes(){let{x:p,y:v}=this.toAffine(),A=o.toBytes(v);return A[A.length-1]|=u(p)?128:0,A}toHex(){return Je(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let I=S=>Kr(B,S),w=new Oe(B,c);return w.bits>=6&&B.BASE.precompute(6),Object.freeze(B.prototype),Object.freeze(B),B}function ra(e,t,r={}){if(re(e),typeof t!="function")throw new Error('"hash" function param is required');let n=t,o=r;wt(o,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",zip215:"boolean",mapToCurve:"function",toMontgomery:"function",toMontgomerySecret:"function"});let{prehash:s}=o,{BASE:i,Fp:a,Fn:c}=e,f=n.outputLen,u=2*a.BYTES;if(f!==void 0&&(te(f,"hash.outputLen"),f!==u))throw new Error(`hash.outputLen must be ${u}, got ${f}`);let l=o.randomBytes===void 0?fe:o.randomBytes,y=o.toMontgomery,m=o.toMontgomerySecret,O=o.adjustScalarBytes===void 0?C=>C:o.adjustScalarBytes,B=o.domain===void 0?(C,_,d)=>{if(xt(d,"phflag"),_.length||d)throw new Error("Contexts/pre-hash are not supported");return C}:o.domain;function I(C){return c.create(ue(C))}function w(C){let _=P.secretKey;Z(C,P.secretKey,"secretKey");let d=Z(n(C),2*_,"hashedSecretKey"),b=O(d.slice(0,_)),x=d.slice(_,2*_),R=I(b);return{head:b,prefix:x,scalar:R}}function S(C){let{head:_,prefix:d,scalar:b}=w(C),x=i.multiply(b),R=x.toBytes();return{head:_,prefix:d,scalar:b,point:x,pointBytes:R}}function p(C){return S(C).pointBytes}function v(C=Uint8Array.of(),..._){let d=Tt(..._);return I(n(B(d,Z(C,void 0,"context"),!!s)))}function A(C,_,d={}){wt(d,{},{},"options"),C=Z(C,void 0,"message"),s&&(C=s(C));let{prefix:b,scalar:x,pointBytes:R}=S(_),g=v(d.context,b,C),h=i.multiply(g).toBytes(),E=v(d.context,h,R,C),T=c.create(g+E*x);if(!c.isValid(T))throw new Error("sign failed: invalid s");let F=Tt(h,c.toBytes(T));return Z(F,P.signature,"result")}let M={zip215:o.zip215};function k(C,_,d,b=M){wt(b);let{context:x}=b,R=b.zip215===void 0?!!M.zip215:b.zip215,g=P.signature;C=Z(C,g,"signature"),_=Z(_,void 0,"message"),d=Z(d,P.publicKey,"publicKey"),R!==void 0&&xt(R,"zip215"),s&&(_=s(_));let h=g/2,E=C.subarray(0,h),T=ue(C.subarray(h,g)),F,K,$;try{F=e.fromBytes(d,R),K=e.fromBytes(E,R),$=i.multiplyUnsafe(T)}catch{return!1}if(!R&&F.isSmallOrder())return!1;let V=v(x,E,d,_);return K.add(F.multiplyUnsafe(V)).subtract($).clearCofactor().is0()}let N=a.BYTES,P={secretKey:N,publicKey:N,signature:2*N,seed:N};function U(C){return C=C===void 0?l(P.seed):C,Z(C,P.seed,"seed")}function H(C){return Jt(C)&&C.length===P.secretKey}function D(C,_){try{return!!e.fromBytes(C,_===void 0?M.zip215:_)}catch{return!1}}let X={getExtendedPublicKey:S,randomSecretKey:U,isValidSecretKey:H,isValidPublicKey:D,toMontgomery(C){if(y===void 0)throw new Error("Montgomery conversion is not supported for this curve");return y(e.fromBytes(C))},toMontgomerySecret(C){if(m===void 0)throw new Error("Montgomery conversion is not supported for this curve");return m(C)}};return Object.freeze(P),Object.freeze(X),Object.freeze({keygen:qr(U,p),getPublicKey:p,sign:A,verify:k,utils:X,Point:e,lengths:P})}var _o=BigInt(1),na=BigInt(2);var xu=BigInt(5),wu=BigInt(8),Co=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Eu={p:Co,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:wu,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Su(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),s=Co,a=e*e%s*e%s,c=Q(a,na,s)*a%s,f=Q(c,_o,s)*e%s,u=Q(f,xu,s)*f%s,l=Q(u,t,s)*u%s,y=Q(l,r,s)*l%s,m=Q(y,n,s)*y%s,O=Q(m,o,s)*m%s,B=Q(O,o,s)*m%s,I=Q(B,t,s)*u%s;return{pow_p_5_8:Q(I,na,s)*e%s,b2:a}}function ia(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var oa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function vu(e,t){let r=Co,n=J(t*t*t,r),o=J(n*n*t,r),s=Su(e*o).pow_p_5_8,i=J(e*n*s,r),a=J(t*i*i,r),c=i,f=J(i*oa,r),u=a===e,l=a===J(-e,r),y=a===J(-e*oa,r);return u&&(i=c),(l||y)&&(i=f),Zi(i,r)&&(i=J(-i,r)),{isValid:u||l,value:i}}var Io=ea(Eu,{uvRatio:vu}),sa=Io.Fp;function Bu(e){let{y:t}=e;return sa.toBytes(sa.div(_o+t,_o-t))}function Au(e){let t=Io.Fp.BYTES;return At(e,t),ia(yo(e.subarray(0,t))).subarray(0,t)}function Tu(e){return ra(Io,yo,Object.assign({adjustScalarBytes:ia,toMontgomery:Bu,toMontgomerySecret:Au,zip215:!0},e))}var aa=Tu({});var or=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},jr=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var $r={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new jr("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 Zr=32;var Do,_u=(async()=>{try{return await $r.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function Cu(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await $r.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await $r.get().subtle.verify({name:"Ed25519"},n,Ct(t),Ct(r instanceof Uint8Array?r:r.subarray()))}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Iu(e,t,r){return aa.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function ca(e,t,r){return Do==null&&(Do=await _u),Do?Cu(e,t,r):Iu(e,t,r)}function Yr(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var Wr=class{type="Ed25519";raw;constructor(t){this.raw=Oo(t,Zr)}toMultihash(){return _t.digest(Be(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return st.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=ca(this.raw,r,t);return Yr(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function ua(e){return e=Oo(e,Zr),new Wr(e)}function Oo(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new Lt(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var Ou=Math.pow(2,7),Ru=Math.pow(2,14),Lu=Math.pow(2,21),Ro=Math.pow(2,28),Lo=Math.pow(2,35),Po=Math.pow(2,42),Uo=Math.pow(2,49),tt=128,lt=127;function Kt(e){if(e<Ou)return 1;if(e<Ru)return 2;if(e<Lu)return 3;if(e<Ro)return 4;if(e<Lo)return 5;if(e<Po)return 6;if(e<Uo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function sr(e,t,r=0){switch(Kt(e)){case 8:t[r++]=e&255|tt,e/=128;case 7:t[r++]=e&255|tt,e/=128;case 6:t[r++]=e&255|tt,e/=128;case 5:t[r++]=e&255|tt,e/=128;case 4:t[r++]=e&255|tt,e>>>=7;case 3:t[r++]=e&255|tt,e>>>=7;case 2:t[r++]=e&255|tt,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function No(e,t){let r=e[t],n=0;if(n+=r&lt,r<tt||(r=e[t+1],n+=(r&lt)<<7,r<tt)||(r=e[t+2],n+=(r&lt)<<14,r<tt)||(r=e[t+3],n+=(r&lt)<<21,r<tt)||(r=e[t+4],n+=(r&lt)*Ro,r<tt)||(r=e[t+5],n+=(r&lt)*Lo,r<tt)||(r=e[t+6],n+=(r&lt)*Po,r<tt)||(r=e[t+7],n+=(r&lt)*Uo,r<tt))return n;throw new RangeError("Could not decode varint")}function Pu(e,t){let r=e.get(t),n=0;if(n+=r&lt,r<tt||(r=e.get(t+1),n+=(r&lt)<<7,r<tt)||(r=e.get(t+2),n+=(r&lt)<<14,r<tt)||(r=e.get(t+3),n+=(r&lt)<<21,r<tt)||(r=e.get(t+4),n+=(r&lt)*Ro,r<tt)||(r=e.get(t+5),n+=(r&lt)*Lo,r<tt)||(r=e.get(t+6),n+=(r&lt)*Po,r<tt)||(r=e.get(t+7),n+=(r&lt)*Uo,r<tt))return n;throw new RangeError("Could not decode varint")}function Fo(e,t=0){return e instanceof Uint8Array?No(e,t):Pu(e,t)}var Ko=new Float32Array([-0]),ne=new Uint8Array(Ko.buffer);function la(e,t,r){Ko[0]=e,t[r]=ne[0],t[r+1]=ne[1],t[r+2]=ne[2],t[r+3]=ne[3]}function da(e,t){return ne[0]=e[t],ne[1]=e[t+1],ne[2]=e[t+2],ne[3]=e[t+3],Ko[0]}var Mo=new Float64Array([-0]),dt=new Uint8Array(Mo.buffer);function ha(e,t,r){Mo[0]=e,t[r]=dt[0],t[r+1]=dt[1],t[r+2]=dt[2],t[r+3]=dt[3],t[r+4]=dt[4],t[r+5]=dt[5],t[r+6]=dt[6],t[r+7]=dt[7]}function pa(e,t){return dt[0]=e[t],dt[1]=e[t+1],dt[2]=e[t+2],dt[3]=e[t+3],dt[4]=e[t+4],dt[5]=e[t+5],dt[6]=e[t+6],dt[7]=e[t+7],Mo[0]}var Nu=BigInt(Number.MAX_SAFE_INTEGER),Fu=BigInt(Number.MIN_SAFE_INTEGER),vt=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+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 r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(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,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return le;if(t<Nu&&t>Fu)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>ma&&(o=0n,++n>ma&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return le;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):le}},le=new vt(0,0);le.toBigInt=function(){return 0n};le.zzEncode=le.zzDecode=function(){return this};le.length=function(){return 1};var ma=4294967296n;function ya(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function ba(e,t,r){if(r-t<1)return"";let o,s=[],i=0,a;for(;t<r;)a=e[t++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|e[t++]&63:a>239&&a<365?(a=((a&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(e[t++]&63)<<6|e[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 ko(e,t,r){let n=r,o,s;for(let i=0;i<e.length;++i)o=e.charCodeAt(i),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((s=e.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function Dt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Gr(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var qo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=Ct(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,Dt(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 Dt(this,4);return Gr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Dt(this,4);return Gr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Dt(this,4);let t=da(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Dt(this,4);let t=pa(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw Dt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return ba(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Dt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Dt(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 vt(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*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;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Dt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw Dt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Dt(this,8);let t=Gr(this.buf,this.pos+=4),r=Gr(this.buf,this.pos+=4);return new vt(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=No(this.buf,this.pos);return this.pos+=Kt(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 ir(e){return new qo(e instanceof Uint8Array?e:e.subarray())}function Xr(e,t,r){let n=ir(e);return t.decode(n,void 0,r)}function Ho(e){let t=e??8192,r=t>>>1,n,o=t;return function(i){if(i<1||i>r)return mt(i);o+i>t&&(n=mt(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var de=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function zo(){}var jo=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Ku=Ho();function Mu(e){return globalThis.Buffer!=null?mt(e):Ku(e)}var cr=class{len;head;tail;states;constructor(){this.len=0,this.head=new de(zo,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new de(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new $o((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(Qr,10,vt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=vt.fromBigInt(t);return this._push(Qr,r.length(),r)}uint64Number(t){return this._push(sr,Kt(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 r=vt.fromBigInt(t).zzEncode();return this._push(Qr,r.length(),r)}sint64Number(t){let r=vt.fromNumber(t).zzEncode();return this._push(Qr,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Vo,1,t?1:0)}fixed32(t){return this._push(ar,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=vt.fromBigInt(t);return this._push(ar,4,r.lo)._push(ar,4,r.hi)}fixed64Number(t){let r=vt.fromNumber(t);return this._push(ar,4,r.lo)._push(ar,4,r.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(la,4,t)}double(t){return this._push(ha,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(Vo,1,0):this.uint32(r)._push(qu,r,t)}string(t){let r=ya(t);return r!==0?this.uint32(r)._push(ko,r,t):this._push(Vo,1,0)}fork(){return this.states=new jo(this),this.head=this.tail=new de(zo,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 de(zo,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=Mu(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function Vo(e,t,r){t[r]=e&255}function ku(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var $o=class extends de{next;constructor(t,r){super(ku,t,r),this.next=void 0}};function Qr(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function ar(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function qu(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(cr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(Hu,t,e),this},cr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(zu,t,e),this});function Hu(e,t,r){t.set(e,r)}function zu(e,t,r){e.length<40?ko(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(gt(e),r)}function Zo(){return new cr}function Jr(e,t){let r=Zo();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}function*tn(e,t,r){let n=ir(e);yield*t.stream(n,void 0,"$",r)}var en={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function rn(e,t,r,n,o){return{name:e,type:t,encode:r,decode:n,stream:o}}function Yo(e){function t(s){if(e[s.toString()]==null)throw new Error("Invalid enum value");return e[s]}let r=function(i,a){let c=t(i);a.int32(c)},n=function(i){let a=i.int32();return t(a)},o=function*(i){let a=i.int32();yield t(a)};return rn("enum",en.VARINT,r,n,o)}function nn(e,t,r){return rn("message",en.LENGTH_DELIMITED,e,t,r)}var yt;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(yt||(yt={}));var Wo;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(Wo||(Wo={}));(function(e){e.codec=()=>Yo(Wo)})(yt||(yt={}));var fr;(function(e){let t;e.codec=()=>(t==null&&(t=nn((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),yt.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),a.lengthDelimited!==!1&&i.ldelim()},(s,i,a={})=>{let c={},f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{c.Type=yt.codec().decode(s);break}case 2:{c.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return c},function*(s,i,a,c={}){let f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${a}.Type`,value:yt.codec().decode(s)};break}case 2:{yield{field:`${a}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function r(s){return Jr(s,e.codec())}e.encode=r;function n(s,i){return Xr(s,e.codec(),i)}e.decode=n;function o(s,i){return tn(s,e.codec(),i)}e.stream=o})(fr||(fr={}));var Go;(function(e){let t;e.codec=()=>(t==null&&(t=nn((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),yt.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),a.lengthDelimited!==!1&&i.ldelim()},(s,i,a={})=>{let c={},f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{c.Type=yt.codec().decode(s);break}case 2:{c.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return c},function*(s,i,a,c={}){let f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${a}.Type`,value:yt.codec().decode(s)};break}case 2:{yield{field:`${a}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function r(s){return Jr(s,e.codec())}e.encode=r;function n(s,i){return Xr(s,e.codec(),i)}e.decode=n;function o(s,i){return tn(s,e.codec(),i)}e.stream=o})(Go||(Go={}));var on=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,r){if(Br(t),At(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=t.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),ae(o)}update(t){return Ae(this),this.iHash.update(t),this}digestInto(t){Ae(this),Ar(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:a,canXOF:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.canXOF=c,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},xa=(()=>{let e=((t,r,n)=>new on(t,r).update(n).digest());return e.create=(t,r)=>new on(t,r),e})();var ju=BigInt(0),Xo=class extends Error{constructor(t=""){super(t)}},kt={Err:Xo,_tlv:{encode:(e,t)=>{let{Err:r}=kt;if(te(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(Pi(t,"data"),t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=tr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?tr(o.length/2|128):"";return tr(e)+s+o+t},decode(e,t){let{Err:r}=kt;t=Z(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.decode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("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 r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+c);if(f.length!==c)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of f)i=i<<8|u;if(n+=c,i<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+i);if(a.length!==i)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+i)}}},_int:{encode(e){let{Err:t}=kt;if(Or(e),e<ju)throw new t("integer: negative integers are not allowed");let r=tr(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=kt;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Ft(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=kt,o=Z(e,void 0,"signature"),{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:f,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(f)}},hexFromSig(e){let{_tlv:t,_int:r}=kt;wt(e,{r:"bigint",s:"bigint"},{},"sig");let n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),s=n+o;return t.encode(48,s)}},Qo=(Object.freeze(kt._tlv),Object.freeze(kt._int),Object.freeze(kt));var wa=(e,t)=>(e+(e>=0?t:-t)/Ea)/t;function $u(e,t,r){_e("scalar",e,qt,r);let[[n,o],[s,i]]=t,a=wa(i*e,r),c=wa(-o*e,r),f=e-a*n-c*s,u=-a*o-c*i,l=f<qt,y=u<qt;l&&(f=-f),y&&(u=-u);let m=er(Math.ceil(Ce(r)/2))+he;if(f<qt||f>=m||u<qt||u>=m)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:l,k1:f,k2neg:y,k2:u}}function es(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Jo(e,t){wt(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return xt(r.lowS,"lowS"),xt(r.prehash,"prehash"),r.format!==void 0&&es(r.format),r}var qt=BigInt(0),he=BigInt(1),Ea=BigInt(2),ts=BigInt(3),Zu=BigInt(4);function Sa(e,t={}){let r=kr("weierstrass",e,t),n=r.Fp,o=r.Fn,s=r.CURVE,{h:i,n:a}=s;wt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:c,allowInfinityPoint:f}=t,u=t.randomBytes===void 0?fe:t.randomBytes;if(c&&(!n.is0(s.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let l=Ba(n,o);function y(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function m(_,d,b){if(f&&d.is0())return Uint8Array.of(0);let{x,y:R}=d.toAffine(),g=n.toBytes(x);if(xt(b,"isCompressed"),b){y();let h=!n.isOdd(R);return Tt(va(h),g)}else return Tt(Uint8Array.of(4),g,n.toBytes(R))}function O(_){Z(_,void 0,"Point");let{publicKey:d,publicKeyUncompressed:b}=l,x=_.length,R=_[0],g=_.subarray(1);if(f&&x===1&&R===0)return{x:n.ZERO,y:n.ZERO};if(x===d&&(R===2||R===3)){let h=n.fromBytes(g);if(!n.isValid(h))throw new Error("bad point: is not on curve, wrong x");let E=p(h),T;try{T=n.sqrt(E)}catch($){let V=$ instanceof Error?": "+$.message:"";throw new Error("bad point: is not on curve, sqrt error"+V)}y();let F=n.isOdd(T);return(R&1)===1!==F&&(T=n.neg(T)),{x:h,y:T}}else if(x===b&&R===4){let h=n.BYTES,E=n.fromBytes(g.subarray(0,h)),T=n.fromBytes(g.subarray(h,h*2));if(!v(E,T))throw new Error("bad point: is not on curve");return{x:E,y:T}}else throw new Error(`bad point: got length ${x}, expected compressed=${d} or uncompressed=${b}`)}let B=t.toBytes===void 0?m:t.toBytes,I=t.fromBytes===void 0?O:t.fromBytes,w=n.mul(s.b,ts),S=n.is0(s.a)?_=>n.ZERO:_=>n.mul(s.a,_);function p(_){let d=n.sqr(_),b=n.mul(d,_);return n.add(n.add(b,n.mul(_,s.a)),s.b)}function v(_,d){let b=n.sqr(d),x=p(_);return n.eql(b,x)}if(!v(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let A=n.mul(n.pow(s.a,ts),Zu),M=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(A,M)))throw new Error("bad curve params: a or b");function k(_,d,b=!1){if(!n.isValid(d)||b&&n.is0(d))throw new Error(`bad point coordinate ${_}`);return d}function N(_){if(!(_ instanceof D))throw new Error("Weierstrass Point expected")}function P(_){if(!c||!c.basises)throw new Error("no endo");return $u(_,c.basises,o.ORDER)}function U(_,d,b,x){if(!o.isValid(x))throw new RangeError("invalid scalar: out of range");if(c){let{k1neg:R,k1:g,k2neg:h,k2:E}=P(x),T=new D(n.mul(b.X,c.beta),b.Y,b.Z);_.push(R?b.negate():b,h?T.negate():T),d.push(g,E)}else _.push(b),d.push(x)}let H=new WeakSet;class D{static BASE=new D(s.Gx,s.Gy,n.ONE);static ZERO=new D(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(d,b,x){this.X=k("x",d),this.Y=k("y",b,!0),this.Z=k("z",x),Object.freeze(this)}static CURVE(){return s}static fromAffine(d){let{x:b,y:x}=d||{};if(!d||!n.isValid(b)||!n.isValid(x))throw new Error("invalid affine point");if(d instanceof D)throw new Error("projective point not allowed");return n.is0(b)&&n.is0(x)?D.ZERO:new D(b,x,n.ONE)}static fromBytes(d){let b=D.fromAffine(I(Z(d,void 0,"point")));return b.assertValidity(),b}static fromHex(d){return D.fromBytes(Te(d))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(d=6,b=!0){return C.setWindowSize(this,d),b||this.multiply(ts),this}assertValidity(){let d=this;if(d.is0()){if(t.allowInfinityPoint&&n.is0(d.X)&&n.eql(d.Y,n.ONE)&&n.is0(d.Z))return;throw new Error("bad point: ZERO")}if(H.has(d))return;let{x:b,y:x}=d.toAffine();if(!n.isValid(b)||!n.isValid(x))throw new Error("bad point: x or y not field elements");if(!v(b,x))throw new Error("bad point: equation left != right");if(!d.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");H.add(d)}hasEvenY(){let{y:d}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(d)}equals(d){N(d);let{X:b,Y:x,Z:R}=this,{X:g,Y:h,Z:E}=d,T=n.eql(n.mul(b,E),n.mul(g,R)),F=n.eql(n.mul(x,E),n.mul(h,R));return T&&F}negate(){return new D(this.X,n.neg(this.Y),this.Z)}double(){let{X:d,Y:b,Z:x}=this,R=n.ZERO,g=n.ZERO,h=n.ZERO,E=n.mul(d,d),T=n.mul(b,b),F=n.mul(x,x),K=n.mul(d,b);return K=n.add(K,K),h=n.mul(d,x),h=n.add(h,h),R=S(h),g=n.mul(w,F),g=n.add(R,g),R=n.sub(T,g),g=n.add(T,g),g=n.mul(R,g),R=n.mul(K,R),h=n.mul(w,h),F=S(F),K=n.sub(E,F),K=S(K),K=n.add(K,h),h=n.add(E,E),E=n.add(h,E),E=n.add(E,F),E=n.mul(E,K),g=n.add(g,E),F=n.mul(b,x),F=n.add(F,F),E=n.mul(F,K),R=n.sub(R,E),h=n.mul(F,T),h=n.add(h,h),h=n.add(h,h),new D(R,g,h)}add(d){N(d);let{X:b,Y:x,Z:R}=this,{X:g,Y:h,Z:E}=d,T=n.ZERO,F=n.ZERO,K=n.ZERO,$=n.mul(b,g),V=n.mul(x,h),et=n.mul(R,E),pt=n.add(b,x),rt=n.add(g,h);pt=n.mul(pt,rt),rt=n.add($,V),pt=n.sub(pt,rt),rt=n.add(b,R);let ut=n.add(g,E);return rt=n.mul(rt,ut),ut=n.add($,et),rt=n.sub(rt,ut),ut=n.add(x,R),T=n.add(h,E),ut=n.mul(ut,T),T=n.add(V,et),ut=n.sub(ut,T),K=S(rt),T=n.mul(w,et),K=n.add(T,K),T=n.sub(V,K),K=n.add(V,K),F=n.mul(T,K),V=n.add($,$),V=n.add(V,$),et=S(et),rt=n.mul(w,rt),V=n.add(V,et),et=n.sub($,et),et=S(et),rt=n.add(rt,et),$=n.mul(V,rt),F=n.add(F,$),$=n.mul(ut,rt),T=n.mul(pt,T),T=n.sub(T,$),$=n.mul(pt,V),K=n.mul(ut,K),K=n.add(K,$),new D(T,F,K)}subtract(d){return N(d),this.add(d.negate())}is0(){return this.equals(D.ZERO)}multiply(d){if(!o.isValidNot0(d))throw new RangeError("invalid scalar: out of range");let{p:b,f:x}=C.mulSecret(this,d,i,X);return X([b,x])[0]}multiplyUnsafe(d){let b=this,x=d;if(!o.isValid(x))throw new RangeError("invalid scalar: out of range");if(x===qt||b.is0())return D.ZERO;if(x===he)return b;if(C.hasWindowSize(this))return C.mulUnsafe(b,x,X);let R=[],g=[];return U(R,g,b,x),Mr(D,R,g)}mulAddUnsafe(d,b,x){N(b);let R=[],g=[];return U(R,g,this,d),U(R,g,b,x),Mr(D,R,g)}toAffine(d){let b=this,x=d;if(x!=null&&!n.isValid(x))throw new RangeError('"invertedZ" expected valid field element');let{X:R,Y:g,Z:h}=b;if(n.eql(h,n.ONE))return{x:R,y:g};let E=b.is0();x==null&&(x=E?n.ONE:n.inv(h));let T=n.mul(R,x),F=n.mul(g,x),K=n.mul(h,x);if(E)return{x:n.ZERO,y:n.ZERO};if(!n.eql(K,n.ONE))throw new Error("invZ was invalid");return{x:T,y:F}}isTorsionFree(){let{isTorsionFree:d}=t;return i===he?!0:d?d(D,this):C.mulUnsafe(this,a).is0()}clearCofactor(){let{clearCofactor:d}=t;return i===he?this:d?d(D,this):this.multiplyUnsafe(i)}isSmallOrder(){return i===he?this.is0():this.clearCofactor().is0()}toBytes(d=!0){return xt(d,"isCompressed"),this.assertValidity(),B(D,this,d)}toHex(d=!0){return Je(this.toBytes(d))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let X=_=>Kr(D,_),C=new Oe(D,u);return C.bits>=6&&D.BASE.precompute(6),Object.freeze(D.prototype),Object.freeze(D),D}function va(e){return Uint8Array.of(e?2:3)}function Ba(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Yu(e,t={}){re(e);let{Fn:r}=e,n=t.randomBytes===void 0?fe:t.randomBytes,o=Object.assign(Ba(e.Fp,r),{seed:Math.max(Nr(r.ORDER),16)});function s(m){try{let O=r.fromBytes(m);return r.isValidNot0(O)}catch{return!1}}function i(m,O){let{publicKey:B,publicKeyUncompressed:I}=o;try{let w=m.length;return O===!0&&w!==B||O===!1&&w!==I?!1:!!e.fromBytes(m)}catch{return!1}}function a(m){return m=m===void 0?n(o.seed):m,Fr(Z(m,o.seed,"seed"),r.ORDER)}function c(m,O=!0){return e.BASE.multiply(r.fromBytes(m)).toBytes(O)}function f(m){let{secretKey:O,publicKey:B,publicKeyUncompressed:I}=o,w=r._lengths;if(!Jt(m))return;let S=Z(m,void 0,"key").length,p=S===B||S===I,v=S===O||!!w?.includes(S);if(!(p&&v))return p}function u(m,O,B=!0){if(f(m)===!0)throw new Error("first arg must be private key");if(f(O)===!1)throw new Error("second arg must be public key");let I=r.fromBytes(m);return e.fromBytes(O).multiply(I).toBytes(B)}let l={isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:a},y=qr(a,c);return Object.freeze(l),Object.freeze(o),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:y,Point:e,utils:l,lengths:o})}function Aa(e,t,r={}){re(e);let n=t;Br(n),wt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let o=Object.assign({},r),s=o.randomBytes===void 0?fe:o.randomBytes,i=o.hmac===void 0?(g,h)=>xa(n,g,h):o.hmac,{Fp:a,Fn:c}=e,{ORDER:f,BITS:u}=c,l=Nr(f),y=To(s,l),{keygen:m,getPublicKey:O,getSharedSecret:B,utils:I,lengths:w}=Yu(e,o),S={prehash:!0,lowS:typeof o.lowS=="boolean"?o.lowS:!0,format:"compact",extraEntropy:!1},p=f*Ea+he<a.ORDER;function v(g){let h=f>>he;return g>h}function A(g,h){if(!c.isValidNot0(h))throw new Error(`invalid signature ${g}: out of range 1..Point.Fn.ORDER`);return h}function M(){if(!a.isOdd)throw new Error("Field doesn't support isOdd")}function k(g,h,E){return M(),(g===E?0:2)|Number(a.isOdd(h))}function N(){if(p)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function P(g,h){es(h);let E=w.signature,T=h==="compact"?E:h==="recovered"?E+1:void 0;return Z(g,T)}class U{r;s;recovery;constructor(h,E,T){if(this.r=A("r",h),this.s=A("s",E),T!=null){if(N(),![0,1,2,3].includes(T))throw new Error("invalid recovery id");this.recovery=T}Object.freeze(this)}static fromBytes(h,E=S.format){P(h,E);let T;if(E==="der"){let{r:V,s:et}=Qo.toSig(Z(h));return new U(V,et)}E==="recovered"&&(T=h[0],E="compact",h=h.subarray(1));let F=w.signature/2,K=h.subarray(0,F),$=h.subarray(F,F*2);return new U(c.fromBytes(K),c.fromBytes($),T)}static fromHex(h,E){return this.fromBytes(Te(h),E)}assertRecovery(){let{recovery:h}=this;if(h==null)throw new Error("invalid recovery id: must be present");return h}addRecoveryBit(h){return new U(this.r,this.s,h)}recoverPublicKey(h){let{r:E,s:T}=this,F=this.assertRecovery(),K=F===2||F===3?E+f:E;if(!a.isValid(K))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let $=a.toBytes(K),V=e.fromBytes(Tt(va((F&1)===0),$)),et=c.inv(K),pt=D(Z(h,void 0,"msgHash")),rt=c.create(-pt*et),ut=c.create(T*et),Ot=e.BASE.mulAddUnsafe(rt,V,ut);if(Ot.is0())throw new Error("invalid recovery: point at infinify");return Ot.assertValidity(),Ot}hasHighS(){return v(this.s)}toBytes(h=S.format){if(es(h),h==="der")return Te(Qo.hexFromSig(this));let{r:E,s:T}=this,F=c.toBytes(E),K=c.toBytes(T);return h==="recovered"?(N(),Tt(Uint8Array.of(this.assertRecovery()),F,K)):Tt(F,K)}toHex(h){return Je(this.toBytes(h))}}Object.freeze(U.prototype),Object.freeze(U);let H=o.bits2int===void 0?function(h){if(h.length>8192)throw new Error("input is too large");let E=Ft(h),T=h.length*8-u;return T>0?E>>BigInt(T):E}:o.bits2int,D=o.bits2int_modN===void 0?function(h){return c.create(H(h))}:o.bits2int_modN,X=er(u);function C(g){return _e("num < 2^"+u,g,qt,X),c.toBytes(g)}function _(g,h){return Z(g,void 0,"message"),h?Z(n(g),void 0,"prehashed message"):g}function d(g,h,E){let{lowS:T,prehash:F,extraEntropy:K}=Jo(E,S);g=_(g,F);let $=D(g),V=c.fromBytes(h);if(!c.isValidNot0(V))throw new Error("invalid private key");let et=[C(V),C($)];if(K!=null&&K!==!1){let Ot=K===!0?s(w.secretKey):K;et.push(Z(Ot,void 0,"extraEntropy"))}let pt=Tt(...et),rt=$;function ut(Ot){let ye=H(Ot);if(!c.isValidNot0(ye))return;let Ke=e.BASE.multiply(ye).toAffine(),jt=c.create(Ke.x);if(jt===qt)return;let Rt;if(y!==void 0){let Me=Ft(Fr(y(l),f)),ac=c.inv(c.mul(Me,ye)),cc=c.mul(Me,rt),fc=c.mul(Me,V);Rt=c.create(ac*c.create(cc+fc*jt))}else{let Me=Vi(ye,f);Rt=c.create(Me*c.create(rt+jt*V))}if(Rt===qt)return;let Tn=k(Ke.x,Ke.y,jt),Ls=Rt;return T&&v(Rt)&&(Ls=c.neg(Rt),Tn^=1),new U(jt,Ls,p?void 0:Tn)}return{seed:pt,k2sig:ut}}function b(g,h,E={}){let{seed:T,k2sig:F}=d(g,h,E);return Ni(n.outputLen,c.BYTES,i)(T,F).toBytes(E.format)}function x(g,h,E,T={}){let{lowS:F,prehash:K,format:$}=Jo(T,S);if(E=Z(E,void 0,"publicKey"),h=_(h,K),!Jt(g)){let V=g instanceof U?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+V)}P(g,$);try{let V=U.fromBytes(g,$),et=e.fromBytes(E);if(F&&V.hasHighS())return!1;let{r:pt,s:rt}=V,ut=D(h),Ot=c.inv(rt),ye=c.create(ut*Ot),Ke=c.create(pt*Ot),jt=e.BASE.mulAddUnsafe(ye,et,Ke);if(jt.is0())return!1;let Rt=jt.toAffine();return!(c.create(Rt.x)!==pt||$==="recovered"&&V.recovery!==k(Rt.x,Rt.y,pt))}catch{return!1}}function R(g,h,E={}){let{prehash:T}=Jo(E,S);return h=_(h,T),U.fromBytes(g,"recovered").recoverPublicKey(h).toBytes()}return Object.freeze({keygen:m,getPublicKey:O,getSharedSecret:B,utils:I,lengths:w,Point:e,sign:b,verify:x,recoverPublicKey:R,Signature:U,hash:n})}var ns={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Wu={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Ta=BigInt(2);function Gu(e){let t=ns.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),f=e*e*e%t,u=f*f*e%t,l=Q(u,r,t)*u%t,y=Q(l,r,t)*u%t,m=Q(y,Ta,t)*f%t,O=Q(m,o,t)*m%t,B=Q(O,s,t)*O%t,I=Q(B,a,t)*B%t,w=Q(I,c,t)*I%t,S=Q(w,a,t)*B%t,p=Q(S,r,t)*u%t,v=Q(p,i,t)*O%t,A=Q(v,n,t)*f%t,M=Q(A,Ta,t);if(!rs.eql(rs.sqr(M),e))throw new Error("Cannot find square root");return M}var rs=De(ns.p,{sqrt:Gu}),Xu=Sa(ns,{Fp:rs,endo:Wu}),Re=Aa(Xu,Ri);function _a(e,t,r,n){let o=$e.digest(r instanceof Uint8Array?r:r.subarray());if(Yr(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),Re.verify(t,s,e,{prehash:!1,format:"der"}))).catch(s=>{throw s.name==="AbortError"?s:new or(String(s))});try{return n?.signal?.throwIfAborted(),Re.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(s){throw new or(String(s))}}var sn=class{type="secp256k1";raw;_key;constructor(t){this._key=Ia(t),this.raw=Ca(this._key)}toMultihash(){return _t.digest(Be(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return st.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}verify(t,r,n){return _a(this._key,r,t,n)}};function Da(e){return new sn(e)}function Ca(e){return Re.Point.fromBytes(e).toBytes()}function Ia(e){try{return Re.Point.fromBytes(e),e}catch(t){throw new pr(String(t))}}function Oa(e){let{Type:t,Data:r}=fr.decode(e.digest),n=r??new Uint8Array;switch(t){case yt.Ed25519:return ua(n);case yt.secp256k1:return Da(n);case yt.ECDSA:return li(n);default:throw new ke}}function Be(e){return fr.encode({Type:yt[e.type],Data:e.raw})}var Ra=Symbol.for("nodejs.util.inspect.custom"),Qu=114,ur=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()})`}[Cn]=!0;toString(){return this.string==null&&(this.string=st.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ct.createV1(Qu,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return bt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return bt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Ra](){return`PeerId(${this.toString()})`}},an=class extends ur{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},cn=class extends ur{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},fn=class extends ur{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Ju=2336,lr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=_t.digest(gt(this.url))}[Ra](){return`PeerId(${this.url})`}[Cn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ct.createV1(Ju,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=ot(t)),t.toString()===this.toString())}};var tl=114,La=2336;function Pa(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=Ve(st.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return el(ct.parse(e));if(t==null)throw new Lt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=Ve(t.decode(e))}return Ua(r)}function Ua(e){if(nl(e))return new an({multihash:e});if(rl(e))try{let t=Oa(e);if(t.type==="Ed25519")return new cn({multihash:e,publicKey:t});if(t.type==="secp256k1")return new fn({multihash:e,publicKey:t})}catch{let r=ot(e.digest);return new lr(new URL(r))}throw new yr("Supplied PeerID Multihash is invalid")}function el(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==tl&&e.code!==La)throw new mr("Supplied PeerID CID is invalid");if(e.code===La){let t=ot(e.multihash.digest);return new lr(new URL(t))}return Ua(e.multihash)}function rl(e){return e.code===_t.code}function nl(e){return e.code===$e.code}var ft=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},Ht=class extends Error{static name="ValidationError";name="ValidationError"},un=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},ln=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var dn=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}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 r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let y=Number.parseInt(l,t);if(!Number.isNaN(y))return y});if(u===void 0)break;if(s*=t,s+=u,s>f||(i+=1,r!==void 0&&i>r))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return r[o]=i[0],r[o+1]=i[1],r[o+2]=i[2],r[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];r[o]=s>>8,r[o+1]=s&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;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 r.set(s.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var ol=45,sl=15,hn=new dn;function Na(e){if(!(e.length>sl))return hn.new(e).parseWith(()=>hn.readIPv4Addr())}function Fa(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>ol))return hn.new(e).parseWith(()=>hn.readIPv6Addr())}function pn(e){return!!Na(e)}function Ka(e){return!!Fa(e)}function ss(e){return t=>ot(t,e)}function is(e){return t=>gt(t,e)}function Le(e){return new DataView(e.buffer).getUint16(e.byteOffset).toString()}function pe(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof e=="string"?parseInt(e):e),new Uint8Array(t)}function Ma(e){let t=e.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 r=gt(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=pe(n);return Ut([r,o],r.length+o.length)}function ka(e){let t=e.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 r=Zt.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=pe(n);return Ut([r,o],r.length+o.length)}function as(e){let t=e.subarray(0,e.length-2),r=e.subarray(e.length-2),n=ot(t,"base32"),o=Le(r);return`${n}:${o}`}var cs=function(e){e=e.toString().trim();let t=new Uint8Array(4);return e.split(/\./g).forEach((r,n)=>{let o=parseInt(r,10);if(isNaN(o)||o<0||o>255)throw new ft("Invalid byte value in IP address");t[n]=o}),t},qa=function(e){let t=0;e=e.toString().trim();let r=e.split(":",8),n;for(n=0;n<r.length;n++){let s=pn(r[n]),i;s&&(i=cs(r[n]),r[n]=ot(i.subarray(0,2),"base16")),i!=null&&++n<8&&r.splice(n,0,ot(i.subarray(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let s=[n,1];for(n=9-r.length;n>0;n--)s.push("0");r.splice.apply(r,s)}let o=new Uint8Array(t+16);for(n=0;n<r.length;n++){r[n]===""&&(r[n]="0");let s=parseInt(r[n],16);if(isNaN(s)||s<0||s>65535)throw new ft("Invalid byte value in IP address");o[t++]=s>>8&255,o[t++]=s&255}return o},Ha=function(e){if(e.byteLength!==4)throw new ft("IPv4 address was incorrect length");let t=[];for(let r=0;r<e.byteLength;r++)t.push(e[r]);return t.join(".")},za=function(e){if(e.byteLength!==16)throw new ft("IPv6 address was incorrect length");let t=[];for(let n=0;n<e.byteLength;n+=2){let o=e[n],s=e[n+1],i=`${o.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`;t.push(i)}let r=t.join(":");try{let n=new URL(`http://[${r}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new ft(`Invalid IPv6 address "${r}"`)}};function Va(e){try{let t=new URL(`http://[${e}]`);return t.hostname.substring(1,t.hostname.length-1)}catch{throw new ft(`Invalid IPv6 address "${e}"`)}}var os=Object.values(Ze).map(e=>e.decoder),il=(function(){let e=os[0].or(os[1]);return os.slice(2).forEach(t=>e=e.or(t)),e})();function ja(e){return il.decode(e)}function $a(e){return t=>e.encoder.encode(t)}function al(e){if(parseInt(e).toString()!==e)throw new Ht("Value must be an integer")}function cl(e){if(e<0)throw new Ht("Value must be a positive integer, or zero")}function fl(e){return t=>{if(t>e)throw new Ht(`Value must be smaller than or equal to ${e}`)}}function ul(...e){return t=>{for(let r of e)r(t)}}var dr=ul(al,cl,fl(65535));var at=-1,fs=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(t){let r;if(typeof t=="string"?r=this.protocolsByName.get(t):r=this.protocolsByCode.get(t),r==null)throw new ln(`Protocol ${t} was unknown`);return r}addProtocol(t){this.protocolsByCode.set(t.code,t),this.protocolsByName.set(t.name,t),t.aliases?.forEach(r=>{this.protocolsByName.set(r,t)})}removeProtocol(t){let r=this.protocolsByCode.get(t);r!=null&&(this.protocolsByCode.delete(r.code),this.protocolsByName.delete(r.name),r.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},Vt=new fs,Bl=[{code:4,name:"ip4",size:32,valueToBytes:cs,bytesToValue:Ha,validate:e=>{if(!pn(e))throw new Ht(`Invalid IPv4 address "${e}"`)}},{code:6,name:"tcp",size:16,valueToBytes:pe,bytesToValue:Le,validate:dr},{code:273,name:"udp",size:16,valueToBytes:pe,bytesToValue:Le,validate:dr},{code:33,name:"dccp",size:16,valueToBytes:pe,bytesToValue:Le,validate:dr},{code:41,name:"ip6",size:128,valueToBytes:qa,bytesToValue:za,stringToValue:Va,validate:e=>{if(!Ka(e))throw new Ht(`Invalid IPv6 address "${e}"`)}},{code:42,name:"ip6zone",size:at},{code:43,name:"ipcidr",size:8,bytesToValue:ss("base10"),valueToBytes:is("base10")},{code:53,name:"dns",size:at},{code:54,name:"dns4",size:at},{code:55,name:"dns6",size:at},{code:56,name:"dnsaddr",size:at},{code:132,name:"sctp",size:16,valueToBytes:pe,bytesToValue:Le,validate:dr},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:at,stringToValue:e=>decodeURIComponent(e),valueToString:e=>encodeURIComponent(e)},{code:421,name:"p2p",aliases:["ipfs"],size:at,bytesToValue:ss("base58btc"),valueToBytes:e=>e.startsWith("Q")||e.startsWith("1")?is("base58btc")(e):ct.parse(e).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:as,valueToBytes:Ma},{code:445,name:"onion3",size:296,bytesToValue:as,valueToBytes:ka},{code:446,name:"garlic64",size:at},{code:447,name:"garlic32",size:at},{code:448,name:"tls"},{code:449,name:"sni",size:at},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:at,bytesToValue:$a(jn),valueToBytes:ja},{code:480,name:"http"},{code:481,name:"http-path",size:at,stringToValue:e=>`/${decodeURIComponent(e)}`,valueToString:e=>encodeURIComponent(e.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:at}];Bl.forEach(e=>{Vt.addProtocol(e)});function Za(e){let t=[],r=0;for(;r<e.length;){let n=Fo(e,r),o=Vt.getProtocol(n),s=Kt(n),i=Al(o,e,r+s),a=0;i>0&&o.size===at&&(a=Kt(i));let c=s+a+i,f={code:n,name:o.name,bytes:Ct(e.subarray(r,r+c))};if(i>0){let u=r+s+a,l=e.subarray(u,u+i);f.value=o.bytesToValue?.(l)??ot(l)}t.push(f),r+=c}return t}function Ya(e){let t=0,r=[];for(let n of e){if(n.bytes==null){let o=Vt.getProtocol(n.code),s=Kt(n.code),i,a=0,c=0;n.value!=null&&(i=o.valueToBytes?.(n.value)??gt(n.value),a=i.byteLength,o.size===at&&(c=Kt(a)));let f=new Uint8Array(s+c+a),u=0;sr(n.code,f,u),u+=s,i!=null&&(o.size===at&&(sr(a,f,u),u+=c),f.set(i,u)),n.bytes=f}r.push(n.bytes),t+=n.bytes.byteLength}return Ut(r,t)}function Wa(e){if(e.charAt(0)!=="/")throw new ft('String multiaddr must start with "/"');let t=[],r="protocol",n="",o="";for(let s=1;s<e.length;s++){let i=e.charAt(s);i!=="/"&&(r==="protocol"?o+=e.charAt(s):n+=e.charAt(s));let a=s===e.length-1;if(i==="/"||a){let c=Vt.getProtocol(o);if(r==="protocol"){if(c.size==null||c.size===0){t.push({code:c.code,name:c.name}),n="",o="",r="protocol";continue}else if(a)throw new ft(`Component ${o} was missing value`);r="value"}else if(r==="value"){let f={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new ft(`Component ${o} was missing value`);f.value=c.stringToValue?.(n)??n}t.push(f),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new ft("Incomplete multiaddr");return t}function Ga(e){return`/${e.flatMap(t=>{if(t.value==null)return t.name;let r=Vt.getProtocol(t.code);if(r==null)throw new ft(`Unknown protocol code ${t.code}`);return[t.name,r.valueToString?.(t.value)??t.value]}).join("/")}`}function Al(e,t,r){return e.size==null||e.size===0?0:e.size>0?e.size/8:Fo(t,r)}var Tl=Symbol.for("nodejs.util.inspect.custom"),Ts=Symbol.for("@multiformats/multiaddr");function _l(e){if(e==null&&(e="/"),Xa(e))return e.getComponents();if(e instanceof Uint8Array)return Za(e);if(typeof e=="string")return e=e.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),e===""&&(e="/"),Wa(e);if(Array.isArray(e))return e;throw new ft("Must be a string, Uint8Array, Component[], or another Multiaddr")}var wn=class e{[Ts]=!0;#t;#e;#r;constructor(t="/",r={}){this.#t=_l(t),r.validate!==!1&&Cl(this)}get bytes(){return this.#r==null&&(this.#r=Ya(this.#t)),this.#r}toString(){return this.#e==null&&(this.#e=Ga(this.#t)),this.#e}toJSON(){return this.toString()}getComponents(){return[...this.#t.map(t=>({...t}))]}encapsulate(t){let r=new e(t);return new e([...this.#t,...r.getComponents()],{validate:!1})}decapsulate(t){let r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new un(`Address ${this.toString()} does not contain subaddress: ${r}`);return new e(n.slice(0,o),{validate:!1})}decapsulateCode(t){let r;for(let n=this.#t.length-1;n>-1;n--)if(this.#t[n].code===t){r=n;break}return new e(this.#t.slice(0,r),{validate:!1})}equals(t){return bt(this.bytes,t.bytes)}[Tl](){return`Multiaddr(${this.toString()})`}};function Cl(e){e.getComponents().forEach(t=>{let r=Vt.getProtocol(t.code);t.value!=null&&r.validate?.(t.value)})}function Xa(e){return!!e?.[Ts]}function Qa(e){return new wn(e)}var W=e=>({match:t=>{let r=t[0];return r==null||r.code!==e||r.value!=null?!1:t.slice(1)}}),L=(e,t)=>({match:r=>{let n=r[0];return n?.code!==e||n.value==null||t!=null&&n.value!==t?!1:r.slice(1)}}),Ja=e=>({match:t=>e.match(t)===!1?t:!1}),q=e=>({match:t=>{let r=e.match(t);return r===!1?t:r}}),ht=(...e)=>({match:t=>{let r;for(let n of e){let o=n.match(t);o!==!1&&(r==null||o.length<r.length)&&(r=o)}return r??!1}}),z=(...e)=>({match:t=>{for(let r of e){let n=r.match(t);if(n===!1)return!1;t=n}return t}});function G(...e){function t(o){if(o==null)return!1;let s=o.getComponents();for(let i of e){let a=i.match(s);if(a===!1)return!1;s=a}return s}function r(o){return t(o)!==!1}function n(o){let s=t(o);return s===!1?!1:s.length===0}return{matchers:e,matches:r,exactMatch:n}}var Il=L(421),Qy=G(Il),Sn=L(54),vn=L(55),Bn=L(56),Cs=L(53),Jy=G(Sn,q(L(421))),tb=G(vn,q(L(421))),eb=G(Bn,q(L(421))),rb=G(ht(Cs,Bn,Sn,vn),q(L(421))),tc=z(L(4),q(L(43))),ec=z(q(L(42)),L(41),q(L(43))),Is=ht(tc,ec),Fe=ht(Is,Cs,Sn,vn,Bn),nb=G(ht(Is,z(ht(Cs,Bn,Sn,vn),q(L(421))))),ob=G(tc),sb=G(ec),ib=G(Is),Ds=z(Fe,L(6)),hr=z(Fe,L(273)),ab=G(z(Ds,q(L(421)))),cb=G(hr),Os=z(hr,W(460),q(L(421))),An=z(hr,W(461),q(L(421))),Dl=ht(Os,An),fb=G(Os),ub=G(An),_s=ht(Fe,Ds,hr,Os,An),rc=ht(z(_s,W(477),q(L(421)))),lb=G(rc),nc=ht(z(_s,W(478),q(L(421))),z(_s,W(448),q(L(449)),W(477),q(L(421)))),db=G(nc),oc=z(hr,W(280),q(L(466)),q(L(466)),q(L(421))),hb=G(oc),sc=z(An,W(465),q(L(466)),q(L(466)),q(L(421))),pb=G(sc),En=ht(rc,nc,z(Ds,q(L(421))),z(Dl,q(L(421))),z(Fe,q(L(421))),oc,sc,L(421)),ic=G(En),Ol=z(q(En),W(290),Ja(W(281)),q(L(421))),mb=G(Ol),Rl=ht(z(En,W(290),W(281),q(L(421))),z(En,W(281),q(L(421))),z(W(281),q(L(421)))),yb=G(Rl),Ll=z(Fe,ht(z(L(6,"80")),z(L(6),W(480)),W(480)),q(L(481)),q(L(421))),bb=G(Ll),Pl=z(Fe,ht(z(L(6,"443")),z(L(6,"443"),W(480)),z(L(6),W(443)),z(L(6),W(448),W(480)),z(W(448),W(480)),W(448),W(443)),q(L(481)),q(L(421))),gb=G(Pl),Ul=ht(z(L(777),q(L(421)))),xb=G(Ul),Nl=ht(z(L(400),q(L(421)))),wb=G(Nl);var Fl="bootstrap",Kl=50,Ml=1e3,Rs=class extends br{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(t,r={list:[]}){if(r.list==null||r.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=r.timeout??Ml,this.list=r.list.map(n=>Qa(n)).filter(n=>ic.matches(n)?n.getComponents().findLast(s=>s.code===421)?.value==null?(this.log.error("invalid bootstrap multiaddr without peer id"),!1):!0:(this.log.error("invalid multiaddr %a",n),!1)).map(n=>({id:Pa(n.getComponents().findLast(o=>o.code===421)?.value??""),multiaddrs:[n]})),this._init=r}[Ps]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[Ns]=["@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("failed to discover bootstrap peers - %e",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??Fl]:{value:this._init.tagValue??Kl,ttl:this._init.tagTTL}},multiaddrs:t.multiaddrs}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t}),this.components.connectionManager.openConnection(t.id).catch(r=>{this.log.error("could not dial bootstrap peer %p - %e",t.id,r)})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function kl(e){return t=>new Rs(t,e)}return pc(ql);})();
3
3
  /*! Bundled license information:
4
4
 
5
5
  @noble/curves/utils.js:
@@ -7,6 +7,7 @@
7
7
  @noble/curves/abstract/curve.js:
8
8
  @noble/curves/abstract/edwards.js:
9
9
  @noble/curves/ed25519.js:
10
+ @noble/curves/abstract/der.js:
10
11
  @noble/curves/abstract/weierstrass.js:
11
12
  @noble/curves/secp256k1.js:
12
13
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)