@libp2p/bootstrap 12.0.30 → 12.0.31-5cb617ae2

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 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);})();
2
+ "use strict";var Libp2PBootstrap=(()=>{var Cn=Object.defineProperty;var uc=Object.getOwnPropertyDescriptor;var lc=Object.getOwnPropertyNames;var dc=Object.prototype.hasOwnProperty;var At=(e,t)=>{for(var r in t)Cn(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&&Cn(e,o,{get:()=>t[o],enumerable:!(n=uc(t,o))||n.enumerable});return e};var pc=e=>hc(Cn({},"__esModule",{value:!0}),e);var Hl={};At(Hl,{bootstrap:()=>ql});var Nt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},mr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var yr=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},br=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Me=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Ps=Symbol.for("@libp2p/peer-discovery");var In=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 Dn(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 Dn(e).capture===Dn(t).capture}var gr=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=Dn(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 Un={};At(Un,{base58btc:()=>ut,base58flickr:()=>Ac});var xd=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 It(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 gc(e){return e?.buffer instanceof ArrayBuffer}function ie(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,d=e.charAt(0),y=Math.log(u)/Math.log(256),m=Math.log(256)/Math.log(u);function T(x){if(x instanceof Uint8Array||(ArrayBuffer.isView(x)?x=new Uint8Array(x.buffer,x.byteOffset,x.byteLength):Array.isArray(x)&&(x=Uint8Array.from(x))),!(x instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(x.length===0)return"";for(var v=0,p=0,E=0,S=x.length;E!==S&&x[E]===0;)E++,v++;for(var U=(S-E)*m+1>>>0,K=new Uint8Array(U);E!==S;){for(var N=x[E],D=0,L=U-1;(N!==0||D<p)&&L!==-1;L--,D++)N+=256*K[L]>>>0,K[L]=N%u>>>0,N=N/u>>>0;if(N!==0)throw new Error("Non-zero carry");p=D,E++}for(var z=U-p;z!==U&&K[z]===0;)z++;for(var H=d.repeat(v);z<U;++z)H+=e.charAt(K[z]);return H}function g(x){if(typeof x!="string")throw new TypeError("Expected String");if(x.length===0)return new Uint8Array;var v=0;if(x[v]!==" "){for(var p=0,E=0;x[v]===d;)p++,v++;for(var S=(x.length-v)*y+1>>>0,U=new Uint8Array(S);x[v];){var K=n[x.charCodeAt(v)];if(K===255)return;for(var N=0,D=S-1;(K!==0||N<E)&&D!==-1;D--,N++)K+=u*U[D]>>>0,U[D]=K%256>>>0,K=K/256>>>0;if(K!==0)throw new Error("Non-zero carry");E=N,v++}if(x[v]!==" "){for(var L=S-E;L!==S&&U[L]===0;)L++;for(var z=new Uint8Array(p+(S-L)),H=p;L!==S;)z[H++]=U[L++];return z}}}function A(x){var v=g(x);if(v)return v;throw new Error(`Non-${t} character`)}return{encode:T,decodeUnsafe:g,decode:A}}var wc=xc,Ec=wc,Hs=Ec;var On=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")}},Rn=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)}},Ln=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 Ln({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Pn=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 On(t,r,n),this.decoder=new Rn(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ge({name:e,prefix:t,encode:r,decode:n}){return new Pn(e,t,r,n)}function Wt({name:e,prefix:t,alphabet:r,caseInsensitive:n=!1}){let{encode:o,decode:s}=Hs(r,e,n);return ge({prefix:t,name:e,encode:o,decode:i=>It(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 it({name:e,prefix:t,bitsPerChar:r,alphabet:n,caseInsensitive:o=!1}){let s=Bc(n,o);return ge({prefix:t,name:e,encode(i){return vc(i,n,r)},decode(i){return Sc(i,s,r,e)}})}var ut=Wt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ac=Wt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Nn={};At(Nn,{base32:()=>Gt,base32hex:()=>Ic,base32hexpad:()=>Oc,base32hexpadupper:()=>Rc,base32hexupper:()=>Dc,base32pad:()=>_c,base32padupper:()=>Cc,base32upper:()=>Tc,base32z:()=>Lc});var Gt=it({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5,caseInsensitive:!0}),Tc=it({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5,caseInsensitive:!0}),_c=it({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5,caseInsensitive:!0}),Cc=it({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5,caseInsensitive:!0}),Ic=it({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5,caseInsensitive:!0}),Dc=it({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5,caseInsensitive:!0}),Oc=it({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5,caseInsensitive:!0}),Rc=it({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5,caseInsensitive:!0}),Lc=it({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Fn={};At(Fn,{base36:()=>qe,base36upper:()=>Pc});var qe=Wt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz",caseInsensitive:!0}),Pc=Wt({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 kc=Kn,Mc=128,js=127;function Kn(e,n){var r=0,n=n||0,o=0,s=n,i,a=e.length;do{if(s>=a)throw Kn.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>=Mc);return Kn.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),Yc=Math.pow(2,49),Zc=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<Yc?7:e<Zc?8:e<Wc?9:10},Xc={encode:Uc,decode:kc,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 xe(e,t,r=0){return He.encode(e,t,r),t}function we(e){return He.encodingLength(e)}function Se(e,t){let r=t.byteLength,n=we(e),o=n+we(r),s=new Uint8Array(o+r);return xe(e,s,0),xe(r,s,n),s.set(t,o),new Ee(e,r,t,s)}function Ve(e){let t=It(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 Ee(r,o,i,t)}function Ys(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 Ee=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 Zs(e,t){let{bytes:r,version:n}=e;return n===0?tf(r,kn(e),t??ut.encoder):ef(r,kn(e),t??Gt.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 pt=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!==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=Se(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&&Ys(t.multihash,n.multihash)}toString(t){return Zs(this,t)}toJSON(){return{"/":Zs(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=It(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 Ee(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[d,y]=ze(t.subarray(r));return r+=y,d},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??ut;return[ut.prefix,r.decode(`${ut.prefix}${e}`)]}case ut.prefix:{let r=t??ut;return[ut.prefix,r.decode(e)]}case Gt.prefix:{let r=t??Gt;return[Gt.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!==ut.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=we(e),o=n+we(t),s=new Uint8Array(o+r.byteLength);return xe(e,s,0),xe(t,s,n),s.set(r,o),s}var nf=Symbol.for("@ipld/js-cid/CID");var Mn={};At(Mn,{identity:()=>Rt});var Xs=0,of="identity",Qs=It;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 Se(Xs,Qs(e))}var Rt={code:Xs,name:of,encode:Qs,digest:sf};function Et(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 Lt(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,Lt(t),Lt(r.subarray()));return n?.signal?.throwIfAborted(),s}function Ft(e=0){return new Uint8Array(e)}function xt(e=0){return new Uint8Array(e)}function cf(e){return e?.buffer instanceof ArrayBuffer}function qn(e){if(cf(e))return e;let t=e.slice();return new Uint8Array(t.buffer,0,t.byteLength)}function Kt(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=xt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return qn(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 wr(e){return!!e?.[ei]}var Tt=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(wr(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(wr(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(wr(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 Kt(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:Kt(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 d=t-a;n.push(i.subarray(d,d+(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(!wr(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 d=0;d<s;d++)i[d]=-1;for(let d=0;d<o;d++)i[n[d]]=d;let a=i,c=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let d=r;d<=c;d+=u){u=0;for(let y=f;y>=0;y--){let m=this.get(d+y);if(n[y]!==m){u=Math.max(1,y-a[m]);break}}if(u===0)return d}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=xt(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=Ft(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=Ft(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=Ft(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=xt(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=Ft(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=Ft(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=Ft(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=Ft(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=Ft(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(!Et(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 Hn={};At(Hn,{base10:()=>ff});var ff=Wt({prefix:"9",name:"base10",alphabet:"0123456789"});var zn={};At(zn,{base16:()=>uf,base16upper:()=>lf});var uf=it({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4,caseInsensitive:!0}),lf=it({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4,caseInsensitive:!0});var Vn={};At(Vn,{base2:()=>df});var df=it({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var jn={};At(jn,{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=ge({prefix:"\u{1F680}",name:"base256emoji",encode:mf,decode:yf});var Yn={};At(Yn,{base64:()=>gf,base64pad:()=>xf,base64url:()=>$n,base64urlpad:()=>wf});var gf=it({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),xf=it({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),$n=it({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wf=it({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Zn={};At(Zn,{base8:()=>Ef});var Ef=it({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Wn={};At(Wn,{identity:()=>Sf});var Sf=ge({prefix:"\0",name:"identity",encode:e=>Ms(It(e)),decode:e=>It(ks(e))});var oh=new TextEncoder,sh=new TextDecoder;var Qn={};At(Qn,{sha256:()=>$e,sha512:()=>Tf});var Af=20;function Xn({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new Gn(e,t,r,n,o)}var Gn=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 Se(t,e)}function si(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var $e=Xn({name:"sha2-256",code:18,encode:si("SHA-256")}),Tf=Xn({name:"sha2-512",code:19,encode:si("SHA-512")});var Ye={...Wn,...Vn,...Zn,...Hn,...zn,...Nn,...Fn,...Un,...Yn,...jn},bh={...Qn,...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))),Jn=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=xt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),_f={utf8:ii,"utf-8":ii,hex:Ye.base16,latin1:Jn,ascii:Jn,binary:Jn,...Ye},Er=_f;function St(e,t="utf8"){let r=Er[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function ft(e,t="utf8"){let r=Er[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var Cf=parseInt("11111",2),to=parseInt("10000000",2),If=parseInt("01111111",2),ci={0:Ze,1:Ze,2:Df,3:Lf,4:Pf,5:Rf,6:Of,16:Ze,22:Ze,48:Ze};function eo(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]&to)===to){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 Ze(e,t){We(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=eo(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 d=0;d<c.length;d++)u+=c[d]<<d*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 Tt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function ro(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=Uf(e.byteLength);return new Tt(Uint8Array.from([t.byteLength|to]),t)}function fi(e){let t=new Tt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new Tt(Uint8Array.from([2]),ro(t),t)}function ui(e){let t=Uint8Array.from([0]),r=new Tt(t,e);return new Tt(Uint8Array.from([3]),ro(r),r)}function Sr(e,t=48){let r=new Tt;for(let n of e)r.append(n);return new Tt(Uint8Array.from([t]),ro(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]),kf={ext:!0,kty:"EC",crv:"P-256"},Mf={ext:!0,kty:"EC",crv:"P-384"},qf={ext:!0,kty:"EC",crv:"P-521"},no=32,oo=48,so=66;function li(e){let t=eo(e);return di(t)}function di(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===no*2+1)return n=ft(t.subarray(r,r+no),"base64url"),o=ft(t.subarray(r+no),"base64url"),new Be({...kf,key_ops:["verify"],x:n,y:o});if(t.byteLength===oo*2+1)return n=ft(t.subarray(r,r+oo),"base64url"),o=ft(t.subarray(r+oo),"base64url"),new Be({...Mf,key_ops:["verify"],x:n,y:o});if(t.byteLength===so*2+1)return n=ft(t.subarray(r,r+so),"base64url"),o=ft(t.subarray(r+so),"base64url"),new Be({...qf,key_ops:["verify"],x:n,y:o});throw new Nt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function hi(e){return Sr([fi(Uint8Array.from([1])),Sr([Hf(e.crv)],160),Sr([ui(new Tt(Uint8Array.from([4]),St(e.x??"","base64url"),St(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 Nt(`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 Rt.digest(Ae(this))}toCID(){return pt.createV1(114,this.toMultihash())}toString(){return ut.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Et(this.raw,t.raw)}async verify(t,r,n){return Js(this.jwk,r,t,n)}};var vr=BigInt(4294967295),pi=BigInt(32);function zf(e,t=!1){return t?{h:Number(e&vr),l:Number(e>>pi&vr)}:{h:Number(e>>pi&vr)|0,l:Number(e&vr)|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 io=(e,t,r)=>e>>>r,ao=(e,t,r)=>e<<32-r|t>>>r,ae=(e,t,r)=>e>>>r|t<<32-r,ce=(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 kt(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 Br(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}var co=e=>e?`"${e}" `:"";function Ht(e,t=""){if(typeof e!="number")throw new TypeError(co(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(co(t)+"expected integer >= 0, got "+e);return e}function Dt(e,t,r=""){if(Br(e)&&(t===void 0||e.length===t))return e;t!==void 0&&Ht(t,"length");let n=Br(e),o=t!==void 0?` of length ${t}`:"",s=n?`length=${e.length}`:`type=${typeof e}`,i=co(r)+"expected Uint8Array"+o+", got "+s;throw n?new RangeError(i):new TypeError(i)}function Ar(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(Ht(e.outputLen),Ht(e.blockLen),e.outputLen<1||e.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var Yf=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof e)},vi=(e,t)=>{Yf(e,t);let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)throw new TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,"__proto__"))throw new TypeError(`"${t}.__proto__" is not allowed`)};function Te(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function Tr(e,t){Dt(e,void 0,"output");let r=t.outputLen;if(!(e.length>=r))throw new RangeError('"output" expected length >= '+r)}function fe(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function _r(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Pt(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 Cr(e){if(Dt(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 Ir(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 fo(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];Dt(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 Wf(e,t,r="opts"){return vi(e,"defaults"),t!==void 0&&vi(t,r),Object.assign(Object.create(null),e,t)}function uo(e,t={}){if(typeof e!="function")throw new TypeError('"hashCons" expected function, got type='+typeof e);t=Wf({},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){Ht(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 lo=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=_r(this.buffer)}update(t){Te(this),Dt(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=_r(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){Te(this),Tr(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:_r(t),c=this.outputLen,f=c/4,u=this.get();if(c%4||f>u.length)throw new Error("invalid outputLen");for(let d=0;d<f;d++)a.setUint32(4*d,u[d],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 Gf=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),ho=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 d=0;d<16;d++,r+=4)Xt[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){let y=Xt[d-15],m=Xt[d-2],T=Pt(y,7)^Pt(y,18)^y>>>3,g=Pt(m,17)^Pt(m,19)^m>>>10;Xt[d]=g+Xt[d-7]+T+Xt[d-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:f,H:u}=this;for(let d=0;d<64;d++){let y=Pt(a,6)^Pt(a,11)^Pt(a,25),m=u+y+_i(a,c,f)+Gf[d]+Xt[d]|0,g=(Pt(n,2)^Pt(n,13)^Pt(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+g|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(){fe(Xt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),fe(this.buffer)}},po=class extends ho{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))),Xf=Oi[0],Qf=Oi[1],Qt=new Uint32Array(80),Jt=new Uint32Array(80),mo=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:d,Fl:y,Gh:m,Gl:T,Hh:g,Hl:A}=this;return[t,r,n,o,s,i,a,c,f,u,d,y,m,T,g,A]}set(t,r,n,o,s,i,a,c,f,u,d,y,m,T,g,A){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=d|0,this.Fl=y|0,this.Gh=m|0,this.Gl=T|0,this.Hh=g|0,this.Hl=A|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)Qt[p]=t.getUint32(r),Jt[p]=t.getUint32(r+=4);for(let p=16;p<80;p++){let E=Qt[p-15]|0,S=Jt[p-15]|0,U=ae(E,S,1)^ae(E,S,8)^io(E,S,7),K=ce(E,S,1)^ce(E,S,8)^ao(E,S,7),N=Qt[p-2]|0,D=Jt[p-2]|0,L=ae(N,D,19)^Ge(N,D,61)^io(N,D,6),z=ce(N,D,19)^Xe(N,D,61)^ao(N,D,6),H=xi(K,z,Jt[p-7],Jt[p-16]),G=wi(H,U,L,Qt[p-7],Qt[p-16]);Qt[p]=G|0,Jt[p]=H|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:f,Dl:u,Eh:d,El:y,Fh:m,Fl:T,Gh:g,Gl:A,Hh:x,Hl:v}=this;for(let p=0;p<80;p++){let E=ae(d,y,14)^ae(d,y,18)^Ge(d,y,41),S=ce(d,y,14)^ce(d,y,18)^Xe(d,y,41),U=d&m^~d&g,K=y&T^~y&A,N=Ei(v,S,K,Qf[p],Jt[p]),D=Si(N,x,E,U,Xf[p],Qt[p]),L=N|0,z=ae(n,o,28)^Ge(n,o,34)^Ge(n,o,39),H=ce(n,o,28)^Xe(n,o,34)^Xe(n,o,39),G=n&s^n&a^s&a,_=o&i^o&c^i&c;x=g|0,v=A|0,g=m|0,A=T|0,m=d|0,T=y|0,{h:d,l:y}=kt(f|0,u|0,D|0,L|0),f=a|0,u=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let k=bi(L,H,_);n=gi(k,D,z,G),o=k|0}({h:n,l:o}=kt(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=kt(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=kt(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=kt(this.Dh|0,this.Dl|0,f|0,u|0),{h:d,l:y}=kt(this.Eh|0,this.El|0,d|0,y|0),{h:m,l:T}=kt(this.Fh|0,this.Fl|0,m|0,T|0),{h:g,l:A}=kt(this.Gh|0,this.Gl|0,g|0,A|0),{h:x,l:v}=kt(this.Hh|0,this.Hl|0,x|0,v|0),this.set(n,o,s,i,a,c,f,u,d,y,m,T,g,A,x,v)}roundClean(){fe(Qt,Jt)}destroy(){this.destroyed=!0,fe(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},yo=class extends mo{constructor(){super(64,Di)}};var Ri=uo(()=>new po,lo(1));var bo=uo(()=>new yo,lo(3));function Or(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)=>Dt(e,t,r),go=Ht;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 te(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 ue(e,t){if(typeof e!="function")throw new TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}var Je=Cr,Ot=(...e)=>fo(...e),_e=e=>Ir(e),re=Br,le=e=>Ti(e),Dr=BigInt(0),Li=BigInt(1),Jf=e=>e?`"${e}" `:"";function vt(e,t=""){if(typeof e!="boolean")throw new TypeError(Jf(t)+"expected boolean, got type="+typeof e);return e}function Rr(e){if(typeof e=="bigint"){if(!ee(e))throw new RangeError("positive bigint expected, got "+e)}else go(e);return e}function zt(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=Rr(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===""?Dr:BigInt("0x"+e)}function Mt(e){return Ui(Cr(e))}function de(e){return Ui(Cr(er(Dt(e)).reverse()))}function Lr(e,t){if(Ht(t),t===0)throw new Error("zero output length is invalid");e=Rr(e);let r=t*2,n=e.toString(16);if(n.length>r)throw new RangeError("number is too large");return Ir(n.padStart(r,"0"))}function xo(e,t){return Lr(e,t).reverse()}function er(e){return Uint8Array.from(Z(e))}function ee(e){return typeof e=="bigint"&&Dr<=e}function wo(e,t,r){return ee(e)&&ee(t)&&ee(r)&&t<=e&&e<r}function Ce(e,t,r,n){if(!wo(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Ie(e){if(e<Dr)throw new Error("expected non-negative bigint, got "+e);return e===Dr?0:e.toString(2).length}var rr=e=>(zt(e,"n"),(Li<<BigInt(e))-Li);function Ni(e,t,r){if(Ht(e,"hashLen"),Ht(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=A=>new Uint8Array(A),o=Uint8Array.of(),s=Uint8Array.of(0),i=Uint8Array.of(1),a=1e3,c=n(e),f=n(e),u=0,d=()=>{c.fill(1),f.fill(0),u=0},y=(...A)=>r(f,Ot(c,...A)),m=(A=o)=>{f=y(s,A),c=y(),A.length!==0&&(f=y(i,A),c=y())},T=()=>{if(u++>=a)throw new Error("drbg: tried max amount of iterations");let A=0,x=[];for(;A<t;){c=y();let v=c.slice();x.push(v),A+=c.length}return Ot(...x)};return(A,x)=>{d(),m(A);let v;for(;(v=x(T()))===void 0;)m();return d(),v}}function Bt(e,t={},r={},n="object"){te(e,n),te(t,"fields"),te(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 d=typeof u;if(d!==a||u===null)throw new TypeError(`${f} is invalid: expected ${a}, got ${d}`)}let s=(i,a)=>Object.entries(i).forEach(([c,f])=>o(c,f,a));s(t,!1),s(r,!0)}var lt=BigInt(0),W=BigInt(1),ne=BigInt(2),ki=BigInt(3),Eo=BigInt(4),Mi=BigInt(5),tu=BigInt(7),qi=BigInt(8),eu=BigInt(9),ru=BigInt(15),Hi=BigInt(16),nu=BigInt("0x10000000000000000");function ot(e,t){if(t<=lt)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=lt?r:t+r}function zi(e,t,r){if(r<=W)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<lt)throw new Error("invalid exponent, negatives unsupported");if(t===lt)return W;if(t===W)return e;let n=e%r;if(n<lt&&(n+=r),t<nu){let a=W;for(;t>lt;)t&W&&(a=a*n%r),n=n*n%r,t>>=W;return a}let o=[];for(;t>lt;)o.push(Number(t&ru)),t>>=Eo;let s=new Array(16);s[0]=W,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 rt(e,t,r){if(r<=W)throw new Error("pow2: expected modulus > 1, got "+r);if(t<lt)throw new Error("pow2: expected non-negative exponent, got "+t);let n=e;for(;t-- >lt;)n*=n,n%=r;return n}function Fi(e,t){if(e===lt)throw new Error("invert: expected non-zero number");if(t<=W)throw new Error("invert: expected modulus > 1, got "+t);let r=ot(e,t),n=t,o=lt,s=W;for(;r!==lt;){let a=n/r,c=n-r*a,f=o-s*a;n=r,r=c,o=s,s=f}if(n!==W)throw new Error("invert: does not exist");return ot(o,t)}function Vi(e,t){if(t<=W)throw new Error("invertCt: expected prime modulus > 1, got "+t);let r=ot(e,t);if(r===lt)throw new Error("invertCt: expected non-zero number");let n=zi(r,t-ne,t);if(ot(r*n,t)!==W)throw new Error("invertCt: does not exist");return n}function So(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function vo(e,t){if((e&W)===lt)throw new Error(t+": expected odd modulus, got "+e)}function ji(e,t){let r=e,n=(r.ORDER+W)/Eo,o=r.pow(t,n);return So(r,o,t),o}function ou(e,t){let r=e,n=(r.ORDER-Mi)/qi,o=r.mul(t,ne),s=r.pow(o,n),i=r.mul(t,s),a=r.mul(r.mul(i,ne),s),c=r.mul(i,r.sub(a,r.ONE));return So(r,c,t),c}function su(e){let t=Oe(e),r=$i(e),n=r(t,t.neg(t.ONE)),o=r(t,n),s=r(t,t.neg(n)),i=(e+tu)/Hi;return((a,c)=>{let f=a,u=f.pow(c,i),d=f.mul(u,n),y=f.mul(u,o),m=f.mul(u,s),T=f.eql(f.sqr(d),c),g=f.eql(f.sqr(y),c);u=f.cmov(u,d,T),d=f.cmov(m,y,g);let A=f.eql(f.sqr(d),c),x=f.cmov(u,d,A);return So(f,x,c),x})}function $i(e){if(e<ki)throw new Error("sqrt is not defined for small field");vo(e,"tonelliShanks");let t=e-W,r=0;for(;t%ne===lt;)t/=ne,r++;let n=ne,o=Oe(e);for(;nr(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+W)/ne;return function(c,f){let u=c;if(u.is0(f))return f;if(nr(u,f)!==1)throw new Error("Cannot find square root");let d=r,y=u.mul(u.ONE,s),m=u.pow(f,t),T=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 g=1,A=u.sqr(m);for(;!u.eql(A,u.ONE);)if(g++,A=u.sqr(A),g===d)throw new Error("Cannot find square root");let x=W<<BigInt(d-g-1),v=u.pow(y,x);d=g,y=u.sqr(v),m=u.mul(m,y),T=u.mul(T,v)}return T}}function iu(e){return vo(e,"Fp.sqrt"),e%Eo===ki?ji:e%qi===Mi?ou:e%Hi===eu?su(e):$i(e)}var Yi=(e,t)=>(ot(e,t)&W)===W,au=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function De(e){if(te(e,"field"),typeof e.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof e.ORDER);zt(e.BYTES,"BYTES"),zt(e.BITS,"BITS");for(let t of au)ue(e[t],"field."+t);if(e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=W)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function Ur(e,t,r=!1){De(e),Or(t,"nums"),vt(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 nr(e,t){De(e);let r=e;vo(r.ORDER,"FpLegendre");let n=(r.ORDER-W)/ne,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 cu(e,t){if(t!==void 0&&go(t),e<=lt)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=Ie(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=lt;ONE=W;_lengths;_mod;constructor(t,r={}){if(t<=W)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}=cu(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 ot(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return lt<=t&&t<this.ORDER}is0(t){return t===lt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&W)===W}neg(t){return ot(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return ot(t*t,this.ORDER)}add(t,r){return ot(t+r,this.ORDER)}sub(t,r){return ot(t-r,this.ORDER)}mul(t,r){return ot(t*r,this.ORDER)}pow(t,r){return zi(t,r,this.ORDER)}div(t,r){return ot(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=iu(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?xo(t,this.BYTES):Lr(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?de(t):Mt(t);if(a&&(c=ot(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 vt(n,"condition"),n?r:t}};function Oe(e,t={}){return Object.freeze(Pr.prototype),new Pr(e,t)}function Zi(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=W)throw new Error("field order must be greater than 1");let t=Ie(e-W);return Math.ceil(t/8)}function Nr(e){let t=Zi(e);return t+Math.ceil(t/2)}function Fr(e,t,r=!1){Z(e);let n=e.length,o=Zi(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?de(e):Mt(e),a=ot(i,t-W)+W;return r?xo(a,o):Lr(a,o)}var To=BigInt(0),or=BigInt(1),fu=BigInt(4),Bo=16,Wi=128,uu=5,Gi=2**31;function oe(e){let t=e;if(typeof t!="function")throw new TypeError('"Point" expected constructor, got type='+typeof e);ue(t.fromAffine,"Point.fromAffine"),ue(t.fromBytes,"Point.fromBytes"),ue(t.fromHex,"Point.fromHex"),te(t.BASE,"Point.BASE"),te(t.ZERO,"Point.ZERO"),De(t.Fp),De(t.Fn)}function Kr(e,t){oe(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 lu(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 du(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 _o(e,t){if(e!==void 0){ue(e,"randomBytes");try{let r=e(t);if(!re(r)||r.length!==t)return}catch{return}return e}}function Qi(e,t){Or(e,"points"),e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function hu(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):ee(n)&&n<r))throw new Error("invalid scalar at index "+o)})}var Ji=new WeakMap;function Ao(e){return Ji.get(e)||1}function pu(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 mu(e,t){let r=2**t,n=r/2,o=BigInt(r-1),s=[];for(;e>To;){let i=0;e&or&&(i=Number(e&o),i>=n&&(i-=r),e-=BigInt(i)),s.push(i),e>>=or}return s}function yu(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+=or),a.push(f)}if(e!==To)throw new Error("invalid wnaf");return a}function bu(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 Re=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(t,r){oe(t),this.randomBytes=_o(r,Bo),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=yu(r,n,o),c=this.ZERO,f=this.BASE;for(let u=0;u<o;u++){let d=a[u],y=u*i,m=Math.abs(d)-1,T=s[y];for(let A=1;A<i;A++)T=A===m?s[y+A]:T;let g=T.negate();d===0?f=f.add(s[y]):c=c.add(d<0?g:T)}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),!wo(r,or,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(t,r,n,o){let s=Ao(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(Bo);if(!re(s)||s.length!==Bo)throw new Error("randomBytes returned invalid byte array");s[0]=s[0]&63|128;let i=r+Mt(s)*this.Point.Fn.ORDER;return this.runCT(t,i,o,n)}fixedWindowCT(t,r,n){let o=uu,s=1<<o,i=rr(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 d=Number(r>>BigInt(u*o)&i),y=a[0];for(let m=1;m<s;m++)y=m===d?a[m]:y;f=f.add(y)}return{p:f,f}}shouldBlind(t,r){return this.randomBytes===void 0?!1:r===or?!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),!ee(r))throw new Error("invalid scalar");let o=Ao(t);if(o===1||r>=this.Point.Fn.ORDER)return kr(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),lu(r,this.bits);let n=Math.ceil((this.bits+Wi)/r)+1;du(n*2**(r-1),this.Point.Fp.BYTES),Ji.set(t,r),this.wnafPrecomputes.delete(t)}hasWindowSize(t){return Ao(t)!==1}};function kr(e,t,r,n=!1){if(oe(e),Qi(t,e),vt(n,"allowOversized"),hu(r,e.Fn,n?e.Fn.ORDER**fu:void 0),t.length!==r.length)throw new Error("arrays of points and scalars must have equal length");let o=t.map(i=>pu(i,4)),s=r.map(i=>mu(i,4));return bu(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 De(t),t}else return Oe(e,{isLE:r})}function Mr(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`);Bt(r);for(let c of["p","n","h"]){let f=t[c];if(!(ee(f)&&f!==To))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),gu=BigInt(4),ta=BigInt(8);function xu(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={}){Bt(t,{},{},"extraOpts");let r=t,n=Mr("edwards",e,r,r.FpFnLE),{Fp:o,Fn:s}=n,i=n.CURVE,{h:a}=i;if(nr(o,i.a)!==1)throw new Error("edwards: CURVE.a must be a square in Fp for complete addition formulas");if(nr(o,i.d)!==-1)throw new Error("edwards: CURVE.d must be a non-square in Fp for complete addition formulas");Bt(r,{},{uvRatio:"function",randomBytes:"function"});let c=r.randomBytes===void 0?le:r.randomBytes,f=Vr<<BigInt(o.BYTES*8)-zr;function u(v){if(!o.isOdd)throw new Error("Field does not have .isOdd()");return o.isOdd(v)}let d=r.uvRatio===void 0?(v,p)=>{try{return{isValid:!0,value:o.sqrt(o.div(v,p))}}catch{return{isValid:!1,value:Hr}}}:r.uvRatio;if(!xu(o,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");let y=o.eql(i.a,o.neg(o.ONE))?v=>o.neg(v):o.eql(i.a,o.ONE)?v=>v:v=>o.mul(i.a,v);function m(v,p,E=!1){let S=E?zr:Hr;return Ce("coordinate "+v,p,S,f),p}function T(v){if(!(v instanceof g))throw new Error("EdwardsPoint expected")}class g{static BASE=new g(i.Gx,i.Gy,o.ONE,o.mul(i.Gx,i.Gy));static ZERO=new g(o.ZERO,o.ONE,o.ONE,o.ZERO);static Fp=o;static Fn=s;X;Y;Z;T;constructor(p,E,S,U){this.X=m("x",p),this.Y=m("y",E),this.Z=m("z",S,!0),this.T=m("t",U),Object.freeze(this)}static CURVE(){return i}static fromAffine(p){if(p instanceof g)throw new Error("extended point not allowed");let{x:E,y:S}=p||{};return m("x",E),m("y",S),new g(E,S,o.ONE,o.mul(E,S))}static fromBytes(p,E=!1){let S=o.BYTES,{a:U,d:K}=i;p=er(Z(p,S,"point")),vt(E,"zip215");let N=er(p),D=p[S-1];N[S-1]=D&-129;let L=de(N),z=E?f:o.ORDER;Ce("point.y",L,Hr,z);let H=o.sqr(L),G=o.sub(H,o.ONE),_=o.sub(o.mulN(K,H),U),{isValid:k,value:M}=d(G,_);if(!k)throw new Error("bad point: invalid y coordinate");let R=u(M),J=(D&128)!==0;if(!E&&o.is0(M)&&J)throw new Error("bad point: x=0 and x_0=1");return J!==R&&(M=o.neg(M)),g.fromAffine({x:M,y:L})}static fromHex(p,E=!1){return g.fromBytes(_e(p),E)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(p=6,E=!0){return x.setWindowSize(this,p),E||this.multiply(Vr),this}assertValidity(){let p=this,{a:E,d:S}=i;if(p.is0())throw new Error("bad point: ZERO");let{X:U,Y:K,Z:N,T:D}=p,L=o.sqr(U),z=o.sqr(K),H=o.sqr(N),G=o.sqr(H),_=o.mul(L,E),k=o.mul(o.add(_,z),H),M=o.add(G,o.mul(S,o.mul(L,z)));if(!o.eql(k,M))throw new Error("bad point: equation left != right (1)");let R=o.mul(U,K),J=o.mul(N,D);if(!o.eql(R,J))throw new Error("bad point: equation left != right (2)")}equals(p){T(p);let{X:E,Y:S,Z:U}=this,{X:K,Y:N,Z:D}=p,L=o.mul(E,D),z=o.mul(K,U),H=o.mul(S,D),G=o.mul(N,U);return o.eql(L,z)&&o.eql(H,G)}is0(){return this.equals(g.ZERO)}negate(){return new g(o.neg(this.X),this.Y,this.Z,o.neg(this.T))}double(){let{X:p,Y:E,Z:S}=this,U=o.sqr(p),K=o.sqr(E),N=o.mul(o.sqr(S),Vr),D=y(U),L=o.addN(p,E),z=o.sub(o.subN(o.sqr(L),U),K),H=o.addN(D,K),G=o.subN(H,N),_=o.subN(D,K),k=o.mul(z,G),M=o.mul(H,_),R=o.mul(z,_),J=o.mul(G,H);return new g(k,M,J,R)}add(p){T(p);let{d:E}=i,{X:S,Y:U,Z:K,T:N}=this,{X:D,Y:L,Z:z,T:H}=p,G=o.mul(S,D),_=o.mul(U,L),k=o.mul(o.mulN(N,E),H),M=o.mul(K,z),R=o.sub(o.subN(o.mulN(o.addN(S,U),o.addN(D,L)),G),_),J=o.subN(M,k),nt=o.addN(M,k),w=o.sub(_,y(G)),l=o.mul(R,J),h=o.mul(nt,w),b=o.mul(R,w),B=o.mul(J,nt);return new g(l,h,B,b)}subtract(p){return T(p),this.add(p.negate())}multiply(p){if(!s.isValidNot0(p))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:E,f:S}=x.mulSecret(this,p,a,A);return A([E,S])[0]}multiplyUnsafe(p){if(!s.isValid(p))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return p===Hr?g.ZERO:this.is0()||p===zr?this:x.mulUnsafe(this,p,A)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return x.mulUnsafe(this,i.n).is0()}toAffine(p){let E=this,S=p;if(S!=null&&typeof S!="bigint")throw new TypeError('"invertedZ" expected bigint, got type='+typeof S);let{X:U,Y:K,Z:N}=E,D=E.is0();S==null&&(S=D?o.create(ta):o.inv(N));let L=o.mul(U,S),z=o.mul(K,S),H=o.mul(N,S);if(D)return{x:o.ZERO,y:o.ONE};if(!o.eql(H,o.ONE))throw new Error("invZ was invalid");return{x:L,y:z}}clearCofactor(){return a===zr?this:a===Vr?this.double():a===gu?this.double().double():a===ta?this.double().double().double():this.multiplyUnsafe(a)}toBytes(){let{x:p,y:E}=this.toAffine(),S=o.toBytes(E);return S[S.length-1]|=u(p)?128:0,S}toHex(){return Je(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let A=v=>Kr(g,v),x=new Re(g,c);return x.bits>=6&&g.BASE.precompute(6),Object.freeze(g.prototype),Object.freeze(g),g}function ra(e,t,r={}){if(oe(e),typeof t!="function")throw new Error('"hash" function param is required');let n=t,o=r;Bt(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&&(zt(f,"hash.outputLen"),f!==u))throw new Error(`hash.outputLen must be ${u}, got ${f}`);let d=o.randomBytes===void 0?le:o.randomBytes,y=o.toMontgomery,m=o.toMontgomerySecret,T=o.adjustScalarBytes===void 0?_=>_:o.adjustScalarBytes,g=o.domain===void 0?(_,k,M)=>{if(vt(M,"phflag"),k.length||M)throw new Error("Contexts/pre-hash are not supported");return _}:o.domain;function A(_){return c.create(de(_))}function x(_){let k=D.secretKey;Z(_,D.secretKey,"secretKey");let M=Z(n(_),2*k,"hashedSecretKey"),R=T(M.slice(0,k)),J=M.slice(k,2*k),nt=A(R);return{head:R,prefix:J,scalar:nt}}function v(_){let{head:k,prefix:M,scalar:R}=x(_),J=i.multiply(R),nt=J.toBytes();return{head:k,prefix:M,scalar:R,point:J,pointBytes:nt}}function p(_){return v(_).pointBytes}function E(_=Uint8Array.of(),...k){let M=Ot(...k);return A(n(g(M,Z(_,void 0,"context"),!!s)))}function S(_,k,M={}){Bt(M,{},{},"options"),_=er(Z(_,void 0,"message")),s&&(_=s(_));let{prefix:R,scalar:J,pointBytes:nt}=v(k),w=E(M.context,R,_),l=i.multiply(w).toBytes(),h=E(M.context,l,nt,_),b=c.create(w+h*J);if(!c.isValid(b))throw new Error("sign failed: invalid s");let B=Ot(l,c.toBytes(b));return Z(B,D.signature,"result")}let U={zip215:o.zip215};function K(_,k,M,R=U){Bt(R);let{context:J}=R,nt=R.zip215===void 0?!!U.zip215:R.zip215,w=D.signature;_=Z(_,w,"signature"),k=Z(k,void 0,"message"),M=Z(M,D.publicKey,"publicKey"),nt!==void 0&&vt(nt,"zip215"),s&&(k=s(k));let l=w/2,h=_.subarray(0,l),b=de(_.subarray(l,w)),B,C,I;try{B=e.fromBytes(M,nt),C=e.fromBytes(h,nt),I=i.multiplyUnsafe(b)}catch{return!1}if(!nt&&B.isSmallOrder())return!1;let P=E(J,h,M,k);return C.add(B.multiplyUnsafe(P)).subtract(I).clearCofactor().is0()}let N=a.BYTES,D={secretKey:N,publicKey:N,signature:2*N,seed:N};function L(_){return _=_===void 0?d(D.seed):_,Z(_,D.seed,"seed")}function z(_){return re(_)&&_.length===D.secretKey}function H(_,k){try{return!!e.fromBytes(_,k===void 0?U.zip215:k)}catch{return!1}}let G={getExtendedPublicKey:v,randomSecretKey:L,isValidSecretKey:z,isValidPublicKey:H,toMontgomery(_){if(y===void 0)throw new Error("Montgomery conversion is not supported for this curve");return y(e.fromBytes(_))},toMontgomerySecret(_){if(m===void 0)throw new Error("Montgomery conversion is not supported for this curve");return m(_)}};return Object.freeze(D),Object.freeze(G),Object.freeze({keygen:qr(L,p),getPublicKey:p,sign:S,verify:K,utils:G,Point:e,lengths:D})}var Co=BigInt(1),na=BigInt(2);var wu=BigInt(5),Eu=BigInt(8),Io=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Su={p:Io,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Eu,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function vu(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),s=Io,a=e*e%s*e%s,c=rt(a,na,s)*a%s,f=rt(c,Co,s)*e%s,u=rt(f,wu,s)*f%s,d=rt(u,t,s)*u%s,y=rt(d,r,s)*d%s,m=rt(y,n,s)*y%s,T=rt(m,o,s)*m%s,g=rt(T,o,s)*m%s,A=rt(g,t,s)*u%s;return{pow_p_5_8:rt(A,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 Bu(e,t){let r=Io,n=ot(t*t*t,r),o=ot(n*n*t,r),s=vu(e*o).pow_p_5_8,i=ot(e*n*s,r),a=ot(t*i*i,r),c=i,f=ot(i*oa,r),u=a===e,d=a===ot(-e,r),y=a===ot(-e*oa,r);return u&&(i=c),(d||y)&&(i=f),Yi(i,r)&&(i=ot(-i,r)),{isValid:u||d,value:i}}var Do=ea(Su,{uvRatio:Bu}),sa=Do.Fp;function Au(e){let{y:t}=e;return sa.toBytes(sa.div(Co+t,Co-t))}function Tu(e){let t=Do.Fp.BYTES;return Dt(e,t),ia(bo(e.subarray(0,t))).subarray(0,t)}function _u(e){return ra(Do,bo,Object.assign({adjustScalarBytes:ia,toMontgomery:Au,toMontgomerySecret:Tu,zip215:!0},e))}var aa=_u({});var sr=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 Yr=32;var Oo,Cu=(async()=>{try{return await $r.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function Iu(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,Lt(t),Lt(r instanceof Uint8Array?r:r.subarray()))}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Du(e,t,r){return aa.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function ca(e,t,r){return Oo==null&&(Oo=await Cu),Oo?Iu(e,t,r):Du(e,t,r)}function Zr(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=Ro(t,Yr)}toMultihash(){return Rt.digest(Ae(this))}toCID(){return pt.createV1(114,this.toMultihash())}toString(){return ut.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Et(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=ca(this.raw,r,t);return Zr(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function ua(e){return e=Ro(e,Yr),new Wr(e)}function Ro(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new Nt(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var Ru=Math.pow(2,7),Lu=Math.pow(2,14),Pu=Math.pow(2,21),Lo=Math.pow(2,28),Po=Math.pow(2,35),Uo=Math.pow(2,42),No=Math.pow(2,49),st=128,yt=127;function qt(e){if(e<Ru)return 1;if(e<Lu)return 2;if(e<Pu)return 3;if(e<Lo)return 4;if(e<Po)return 5;if(e<Uo)return 6;if(e<No)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ir(e,t,r=0){switch(qt(e)){case 8:t[r++]=e&255|st,e/=128;case 7:t[r++]=e&255|st,e/=128;case 6:t[r++]=e&255|st,e/=128;case 5:t[r++]=e&255|st,e/=128;case 4:t[r++]=e&255|st,e>>>=7;case 3:t[r++]=e&255|st,e>>>=7;case 2:t[r++]=e&255|st,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Fo(e,t){let r=e[t],n=0;if(n+=r&yt,r<st||(r=e[t+1],n+=(r&yt)<<7,r<st)||(r=e[t+2],n+=(r&yt)<<14,r<st)||(r=e[t+3],n+=(r&yt)<<21,r<st)||(r=e[t+4],n+=(r&yt)*Lo,r<st)||(r=e[t+5],n+=(r&yt)*Po,r<st)||(r=e[t+6],n+=(r&yt)*Uo,r<st)||(r=e[t+7],n+=(r&yt)*No,r<st))return n;throw new RangeError("Could not decode varint")}function Uu(e,t){let r=e.get(t),n=0;if(n+=r&yt,r<st||(r=e.get(t+1),n+=(r&yt)<<7,r<st)||(r=e.get(t+2),n+=(r&yt)<<14,r<st)||(r=e.get(t+3),n+=(r&yt)<<21,r<st)||(r=e.get(t+4),n+=(r&yt)*Lo,r<st)||(r=e.get(t+5),n+=(r&yt)*Po,r<st)||(r=e.get(t+6),n+=(r&yt)*Uo,r<st)||(r=e.get(t+7),n+=(r&yt)*No,r<st))return n;throw new RangeError("Could not decode varint")}function Ko(e,t=0){return e instanceof Uint8Array?Fo(e,t):Uu(e,t)}var ko=new Float32Array([-0]),se=new Uint8Array(ko.buffer);function la(e,t,r){ko[0]=e,t[r]=se[0],t[r+1]=se[1],t[r+2]=se[2],t[r+3]=se[3]}function da(e,t){return se[0]=e[t],se[1]=e[t+1],se[2]=e[t+2],se[3]=e[t+3],ko[0]}var Mo=new Float64Array([-0]),bt=new Uint8Array(Mo.buffer);function ha(e,t,r){Mo[0]=e,t[r]=bt[0],t[r+1]=bt[1],t[r+2]=bt[2],t[r+3]=bt[3],t[r+4]=bt[4],t[r+5]=bt[5],t[r+6]=bt[6],t[r+7]=bt[7]}function pa(e,t){return bt[0]=e[t],bt[1]=e[t+1],bt[2]=e[t+2],bt[3]=e[t+3],bt[4]=e[t+4],bt[5]=e[t+5],bt[6]=e[t+6],bt[7]=e[t+7],Mo[0]}var Fu=BigInt(Number.MAX_SAFE_INTEGER),Ku=BigInt(Number.MIN_SAFE_INTEGER),_t=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 he;if(t<Fu&&t>Ku)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 he;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):he}},he=new _t(0,0);he.toBigInt=function(){return 0n};he.zzEncode=he.zzDecode=function(){return this};he.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 qo(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 Ut(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 Ho=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=Lt(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,Ut(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 Ut(this,4);return Gr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ut(this,4);return Gr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Ut(this,4);let t=da(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Ut(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 Ut(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 Ut(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Ut(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 _t(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 Ut(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 Ut(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 Ut(this,8);let t=Gr(this.buf,this.pos+=4),r=Gr(this.buf,this.pos+=4);return new _t(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=Fo(this.buf,this.pos);return this.pos+=qt(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 ar(e){return new Ho(e instanceof Uint8Array?e:e.subarray())}function Xr(e,t,r){let n=ar(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 xt(i);o+i>t&&(n=xt(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var pe=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Vo(){}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}},ku=zo();function Mu(e){return globalThis.Buffer!=null?xt(e):ku(e)}var fr=class{len;head;tail;states;constructor(){this.len=0,this.head=new pe(Vo,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new pe(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(Qr,10,_t.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=_t.fromBigInt(t);return this._push(Qr,r.length(),r)}uint64Number(t){return this._push(ir,qt(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=_t.fromBigInt(t).zzEncode();return this._push(Qr,r.length(),r)}sint64Number(t){let r=_t.fromNumber(t).zzEncode();return this._push(Qr,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(jo,1,t?1:0)}fixed32(t){return this._push(cr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=_t.fromBigInt(t);return this._push(cr,4,r.lo)._push(cr,4,r.hi)}fixed64Number(t){let r=_t.fromNumber(t);return this._push(cr,4,r.lo)._push(cr,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(jo,1,0):this.uint32(r)._push(Hu,r,t)}string(t){let r=ya(t);return r!==0?this.uint32(r)._push(qo,r,t):this._push(jo,1,0)}fork(){return this.states=new $o(this),this.head=this.tail=new pe(Vo,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 pe(Vo,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 jo(e,t,r){t[r]=e&255}function qu(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Yo=class extends pe{next;constructor(t,r){super(qu,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 cr(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 Hu(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(fr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(zu,t,e),this},fr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Vu,t,e),this});function zu(e,t,r){t.set(e,r)}function Vu(e,t,r){e.length<40?qo(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(St(e),r)}function Zo(){return new fr}function Jr(e,t){let r=Zo();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}function*tn(e,t,r){let n=ar(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 Wo(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 wt;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(wt||(wt={}));var Go;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(Go||(Go={}));(function(e){e.codec=()=>Wo(Go)})(wt||(wt={}));var ur;(function(e){let t;e.codec=()=>(t==null&&(t=nn((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),wt.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=wt.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:wt.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})(ur||(ur={}));var Xo;(function(e){let t;e.codec=()=>(t==null&&(t=nn((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),wt.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=wt.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:wt.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})(Xo||(Xo={}));var on=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,r){if(Ar(t),Dt(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),fe(o)}update(t){return Te(this),this.iHash.update(t),this}digestInto(t){Te(this),Tr(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 $u=BigInt(0),Qo=class extends Error{constructor(t=""){super(t)}},Vt={Err:Qo,_tlv:{encode:(e,t)=>{let{Err:r}=Vt;if(zt(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}=Vt;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}=Vt;if(Rr(e),e<$u)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}=Vt;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 Mt(e)}},toSig(e,t){let{Err:r,_int:n,_tlv:o}=Vt;if(t!==void 0&&(zt(t,"maxScalarBytes"),t<1))throw new r("invalid signature: maxScalarBytes must be positive");let s=Z(e,void 0,"signature"),{v:i,l:a}=o.decode(48,s);if(a.length)throw new r("invalid signature: left bytes after parsing");let{v:c,l:f}=o.decode(2,i),{v:u,l:d}=o.decode(2,f);if(d.length)throw new r("invalid signature: left bytes after parsing");if(t!==void 0&&(c.length>t||u.length>t))throw new r("invalid signature: integer too large");return{r:n.decode(c),s:n.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=Vt;Bt(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)}},sn=(Object.freeze(Vt._tlv),Object.freeze(Vt._int),Object.freeze(Vt));var wa=(e,t)=>(e+(e>=0?t:-t)/Ea)/t;function Yu(e,t,r){Ce("scalar",e,jt,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,d=f<jt,y=u<jt;d&&(f=-f),y&&(u=-u);let m=rr(Math.ceil(Ie(r)/2))+me;if(f<jt||f>=m||u<jt||u>=m)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:d,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){Bt(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return vt(r.lowS,"lowS"),vt(r.prehash,"prehash"),r.format!==void 0&&es(r.format),r}var jt=BigInt(0),me=BigInt(1),Ea=BigInt(2),ts=BigInt(3),Zu=BigInt(4);function Sa(e,t={}){let r=Mr("weierstrass",e,t),n=r.Fp,o=r.Fn,s=r.CURVE,{h:i,n:a}=s;Bt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:c,allowInfinityPoint:f,clearCofactor:u,isTorsionFree:d,fromBytes:y,toBytes:m}=t,T=t.randomBytes===void 0?le: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 g=c?{beta:c.beta,basises:c.basises.map(w=>[...w])}:void 0,A=Ba(n,o);function x(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function v(w,l,h){if(l.is0()){if(!f)throw new Error("bad point: ZERO");return Uint8Array.of(0)}let{x:b,y:B}=l.toAffine(),C=n.toBytes(b);if(vt(h,"isCompressed"),h){x();let I=!n.isOdd(B);return Ot(va(I),C)}else return Ot(Uint8Array.of(4),C,n.toBytes(B))}function p(w){Z(w,void 0,"Point");let{publicKey:l,publicKeyUncompressed:h}=A,b=w.length,B=w[0],C=w.subarray(1);if(f&&b===1&&B===0)return{x:n.ZERO,y:n.ZERO};if(b===l&&(B===2||B===3)){let I=n.fromBytes(C);if(!n.isValid(I))throw new Error("bad point: is not on curve, wrong x");let P=N(I),F;try{F=n.sqrt(P)}catch(at){let tt=at instanceof Error?": "+at.message:"";throw new Error("bad point: is not on curve, sqrt error"+tt)}x();let $=n.isOdd(F);return(B&1)===1!==$&&(F=n.neg(F)),{x:I,y:F}}else if(b===h&&B===4){let I=n.BYTES,P=n.fromBytes(C.subarray(0,I)),F=n.fromBytes(C.subarray(I,I*2));if(!D(P,F))throw new Error("bad point: is not on curve");return{x:P,y:F}}else throw new Error(`bad point: got length ${b}, expected compressed=${l} or uncompressed=${h}`)}let E=m===void 0?v:m,S=y===void 0?p:y,U=n.mul(s.b,ts),K=n.is0(s.a)?w=>n.ZERO:w=>n.mul(s.a,w);function N(w){let l=n.sqr(w),h=n.mul(l,w);return n.add(n.add(h,n.mul(w,s.a)),s.b)}function D(w,l){let h=n.sqr(l),b=N(w);return n.eql(h,b)}if(!D(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let L=n.mul(n.pow(s.a,ts),Zu),z=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(L,z)))throw new Error("bad curve params: a or b");function H(w,l,h=!1){if(!n.isValid(l)||h&&n.is0(l))throw new Error(`bad point coordinate ${w}`);return typeof l=="object"&&l!==null?n.create(l):l}function G(w){if(!(w instanceof R))throw new Error("Weierstrass Point expected")}function _(w){if(!g||!g.basises)throw new Error("no endo");return Yu(w,g.basises,o.ORDER)}function k(w,l,h,b){if(!o.isValid(b))throw new RangeError("invalid scalar: out of range");if(g){let{k1neg:B,k1:C,k2neg:I,k2:P}=_(b),F=new R(n.mul(h.X,g.beta),h.Y,h.Z);w.push(B?h.negate():h,I?F.negate():F),l.push(C,P)}else w.push(h),l.push(b)}let M=new WeakSet;class R{static BASE=new R(s.Gx,s.Gy,n.ONE);static ZERO=new R(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(l,h,b){this.X=H("x",l),this.Y=H("y",h,!0),this.Z=H("z",b),Object.freeze(this)}static CURVE(){return s}static fromAffine(l){let{x:h,y:b}=l||{};if(!l||!n.isValid(h)||!n.isValid(b))throw new Error("invalid affine point");if(l instanceof R)throw new Error("projective point not allowed");return n.is0(h)&&n.is0(b)?R.ZERO:new R(h,b,n.ONE)}static fromBytes(l){let h=R.fromAffine(S(Z(l,void 0,"point")));return h.assertValidity(),h}static fromHex(l){return R.fromBytes(_e(l))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(l=6,h=!0){return nt.setWindowSize(this,l),h||this.multiply(ts),this}assertValidity(){let l=this;if(l.is0()){if(f&&n.is0(l.X)&&n.eql(l.Y,n.ONE)&&n.is0(l.Z))return;throw new Error("bad point: ZERO")}if(M.has(l))return;let{x:h,y:b}=l.toAffine();if(!n.isValid(h)||!n.isValid(b))throw new Error("bad point: x or y not field elements");if(!D(h,b))throw new Error("bad point: equation left != right");if(!l.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");M.add(l)}hasEvenY(){let{y:l}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(l)}equals(l){G(l);let{X:h,Y:b,Z:B}=this,{X:C,Y:I,Z:P}=l,F=n.eql(n.mul(h,P),n.mul(C,B)),$=n.eql(n.mul(b,P),n.mul(I,B));return F&&$}negate(){return new R(this.X,n.neg(this.Y),this.Z)}double(){let{X:l,Y:h,Z:b}=this,B=n.ZERO,C=n.ZERO,I=n.ZERO,P=n.mul(l,l),F=n.mul(h,h),$=n.mul(b,b),V=n.mul(l,h);return V=n.add(V,V),I=n.mul(l,b),I=n.add(I,I),B=K(I),C=n.mul(U,$),C=n.add(B,C),B=n.sub(F,C),C=n.add(F,C),C=n.mul(B,C),B=n.mul(V,B),I=n.mul(U,I),$=K($),V=n.sub(P,$),V=K(V),V=n.add(V,I),I=n.add(P,P),P=n.add(I,P),P=n.add(P,$),P=n.mul(P,V),C=n.add(C,P),$=n.mul(h,b),$=n.add($,$),P=n.mul($,V),B=n.sub(B,P),I=n.mul($,F),I=n.add(I,I),I=n.add(I,I),new R(B,C,I)}add(l){G(l);let{X:h,Y:b,Z:B}=this,{X:C,Y:I,Z:P}=l,F=n.ZERO,$=n.ZERO,V=n.ZERO,at=n.mul(h,C),tt=n.mul(b,I),dt=n.mul(B,P),Ct=n.add(h,b),et=n.add(C,I);Ct=n.mul(Ct,et),et=n.add(at,tt),Ct=n.sub(Ct,et),et=n.add(h,B);let ct=n.add(C,P);return et=n.mul(et,ct),ct=n.add(at,dt),et=n.sub(et,ct),ct=n.add(b,B),F=n.add(I,P),ct=n.mul(ct,F),F=n.add(tt,dt),ct=n.sub(ct,F),V=K(et),F=n.mul(U,dt),V=n.add(F,V),F=n.sub(tt,V),V=n.add(tt,V),$=n.mul(F,V),tt=n.add(at,at),tt=n.add(tt,at),dt=K(dt),et=n.mul(U,et),tt=n.add(tt,dt),dt=n.sub(at,dt),dt=K(dt),et=n.add(et,dt),at=n.mul(tt,et),$=n.add($,at),at=n.mul(ct,et),F=n.mul(Ct,F),F=n.sub(F,at),at=n.mul(Ct,tt),V=n.mul(ct,V),V=n.add(V,at),new R(F,$,V)}subtract(l){return G(l),this.add(l.negate())}is0(){return this.equals(R.ZERO)}multiply(l){if(!o.isValidNot0(l))throw new RangeError("invalid scalar: out of range");let{p:h,f:b}=nt.mulSecret(this,l,i,J);return J([h,b])[0]}multiplyUnsafe(l){let h=this,b=l;if(!o.isValid(b))throw new RangeError("invalid scalar: out of range");if(b===jt||h.is0())return R.ZERO;if(b===me)return h;if(nt.hasWindowSize(this))return nt.mulUnsafe(h,b,J);let B=[],C=[];return k(B,C,h,b),kr(R,B,C)}mulAddUnsafe(l,h,b){G(h);let B=[],C=[];return k(B,C,this,l),k(B,C,h,b),kr(R,B,C)}toAffine(l){let h=this,b=l;if(b!=null&&!n.isValid(b))throw new RangeError('"invertedZ" expected valid field element');let{X:B,Y:C,Z:I}=h;if(n.eql(I,n.ONE))return{x:B,y:C};let P=h.is0();b==null&&(b=P?n.ONE:n.inv(I));let F=n.mul(B,b),$=n.mul(C,b),V=n.mul(I,b);if(P)return{x:n.ZERO,y:n.ZERO};if(!n.eql(V,n.ONE))throw new Error("invZ was invalid");return{x:F,y:$}}isTorsionFree(){return i===me?!0:d?d(R,this):nt.mulUnsafe(this,a).is0()}clearCofactor(){return i===me?this:u?u(R,this):this.multiplyUnsafe(i)}isSmallOrder(){return i===me?this.is0():this.clearCofactor().is0()}toBytes(l=!0){return vt(l,"isCompressed"),this.assertValidity(),E(R,this,l)}toHex(l=!0){return Je(this.toBytes(l))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let J=w=>Kr(R,w),nt=new Re(R,T);return nt.bits>=6&&R.BASE.precompute(6),Object.freeze(R.prototype),Object.freeze(R),R}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 Wu(e,t={}){oe(e);let{Fn:r}=e,n=t.randomBytes===void 0?le:t.randomBytes,o=Object.assign(Ba(e.Fp,r),{seed:Math.max(Nr(r.ORDER),16)});function s(m){try{let T=r.fromBytes(m);return r.isValidNot0(T)}catch{return!1}}function i(m,T){let{publicKey:g,publicKeyUncompressed:A}=o;try{let x=m.length;return T===!0&&x!==g||T===!1&&x!==A?!1:!e.fromBytes(m).is0()}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,T=!0){return e.BASE.multiply(r.fromBytes(m)).toBytes(T)}function f(m){let{secretKey:T,publicKey:g,publicKeyUncompressed:A}=o,x=r._lengths;if(!re(m))return;let v=Z(m,void 0,"key").length,p=v===g||v===A,E=v===T||!!x?.includes(v);if(!(p&&E))return p}function u(m,T,g=!0){if(f(m)===!0)throw new Error("first arg must be private key");if(f(T)===!1)throw new Error("second arg must be public key");let A=r.fromBytes(m),x=e.fromBytes(T);if(x.is0())throw new Error("invalid public key: point at infinity");return x.multiply(A).toBytes(g)}let d={isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:a},y=qr(a,c);return Object.freeze(d),Object.freeze(o),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:y,Point:e,utils:d,lengths:o})}function Aa(e,t,r={}){oe(e);let n=t;Ar(n),Bt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let o=Object.assign({},r),s=o.randomBytes===void 0?le:o.randomBytes,i=o.hmac===void 0?(w,l)=>xa(n,w,l):o.hmac,{Fp:a,Fn:c}=e,{ORDER:f,BITS:u}=c,d=Nr(f),y=_o(s,d),{keygen:m,getPublicKey:T,getSharedSecret:g,utils:A,lengths:x}=Wu(e,o),v={prehash:!0,lowS:typeof o.lowS=="boolean"?o.lowS:!0,format:"compact",extraEntropy:!1},p=f*Ea+me<a.ORDER;function E(w){let l=f>>me;return w>l}function S(w,l){if(!c.isValidNot0(l))throw new Error(`invalid signature ${w}: out of range 1..Point.Fn.ORDER`);return l}function U(){if(!a.isOdd)throw new Error("Field doesn't support isOdd")}function K(w,l,h){return U(),(w===h?0:2)|Number(a.isOdd(l))}function N(){if(p)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function D(w,l){es(l);let h=x.signature,b=l==="compact"?h:l==="recovered"?h+1:void 0;return Z(w,b)}class L{r;s;recovery;constructor(l,h,b){if(this.r=S("r",l),this.s=S("s",h),b!=null){if(N(),![0,1,2,3].includes(b))throw new Error("invalid recovery id");this.recovery=b}Object.freeze(this)}static fromBytes(l,h=v.format){D(l,h);let b;if(h==="der"){if(l.length>2*c.BYTES+16)throw new sn.Err("invalid signature: DER signature too long");let{r:P,s:F}=sn.toSig(Z(l),c.BYTES+1);return new L(P,F)}h==="recovered"&&(b=l[0],h="compact",l=l.subarray(1));let B=x.signature/2,C=l.subarray(0,B),I=l.subarray(B,B*2);return new L(c.fromBytes(C),c.fromBytes(I),b)}static fromHex(l,h){return this.fromBytes(_e(l),h)}assertRecovery(){let{recovery:l}=this;if(l==null)throw new Error("invalid recovery id: must be present");return l}addRecoveryBit(l){return new L(this.r,this.s,l)}recoverPublicKey(l){let{r:h,s:b}=this,B=this.assertRecovery(),C=B===2||B===3?h+f:h;if(!a.isValid(C))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let I=a.toBytes(C),P=e.fromBytes(Ot(va((B&1)===0),I)),F=c.inv(C),$=H(Z(l,void 0,"msgHash")),V=c.create(-$*F),at=c.create(b*F),tt=e.BASE.mulAddUnsafe(V,P,at);if(tt.is0())throw new Error("invalid recovery: point at infinify");return tt.assertValidity(),tt}hasHighS(){return E(this.s)}toBytes(l=v.format){if(es(l),l==="der")return _e(sn.hexFromSig(this));let{r:h,s:b}=this,B=c.toBytes(h),C=c.toBytes(b);return l==="recovered"?(N(),Ot(Uint8Array.of(this.assertRecovery()),B,C)):Ot(B,C)}toHex(l){return Je(this.toBytes(l))}}Object.freeze(L.prototype),Object.freeze(L);let z=o.bits2int===void 0?function(l){if(l.length>8192)throw new Error("input is too large");let h=Mt(l),b=l.length*8-u;return b>0?h>>BigInt(b):h}:o.bits2int,H=o.bits2int_modN===void 0?function(l){return c.create(z(l))}:o.bits2int_modN,G=rr(u);function _(w){return Ce("num < 2^"+u,w,jt,G),c.toBytes(w)}function k(w,l){return Z(w,void 0,"message"),l?Z(n(w),void 0,"prehashed message"):w}function M(w,l,h){let{lowS:b,prehash:B,extraEntropy:C}=Jo(h,v);w=k(w,B);let I=H(w),P=c.fromBytes(l);if(!c.isValidNot0(P))throw new Error("invalid private key");let F=[_(P),_(I)];if(C!=null&&C!==!1){let tt=C===!0?s(x.secretKey):C;F.push(Z(tt,void 0,"extraEntropy"))}let $=Ot(...F),V=I;function at(tt){let dt=z(tt);if(!c.isValidNot0(dt))return;let Ct=e.BASE.multiply(dt).toAffine(),et=c.create(Ct.x);if(et===jt)return;let ct;if(y!==void 0){let ke=Mt(Fr(y(d),f)),ac=c.inv(c.mul(ke,dt)),cc=c.mul(ke,V),fc=c.mul(ke,P);ct=c.create(ac*c.create(cc+fc*et))}else{let ke=Vi(dt,f);ct=c.create(ke*c.create(V+et*P))}if(ct===jt)return;let _n=K(Ct.x,Ct.y,et),Ls=ct;return b&&E(ct)&&(Ls=c.neg(ct),_n^=1),new L(et,Ls,p?void 0:_n)}return{seed:$,k2sig:at}}function R(w,l,h={}){let{seed:b,k2sig:B}=M(w,l,h);return Ni(n.outputLen,c.BYTES,i)(b,B).toBytes(h.format)}function J(w,l,h,b={}){let{lowS:B,prehash:C,format:I}=Jo(b,v);if(h=Z(h,void 0,"publicKey"),l=k(l,C),!re(w)){let P=w instanceof L?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+P)}D(w,I);try{let P=L.fromBytes(w,I),F=e.fromBytes(h);if(F.is0()||B&&P.hasHighS())return!1;let{r:$,s:V}=P,at=H(l),tt=c.inv(V),dt=c.create(at*tt),Ct=c.create($*tt),et=e.BASE.mulAddUnsafe(dt,F,Ct);if(et.is0())return!1;let ct=et.toAffine();return!(c.create(ct.x)!==$||I==="recovered"&&P.recovery!==K(ct.x,ct.y,$))}catch{return!1}}function nt(w,l,h={}){let{prehash:b}=Jo(h,v);return l=k(l,b),L.fromBytes(w,"recovered").recoverPublicKey(l).toBytes()}return Object.freeze({keygen:m,getPublicKey:T,getSharedSecret:g,utils:A,lengths:x,Point:e,sign:R,verify:J,recoverPublicKey:nt,Signature:L,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")},Gu={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Ta=BigInt(2);function Xu(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,d=rt(u,r,t)*u%t,y=rt(d,r,t)*u%t,m=rt(y,Ta,t)*f%t,T=rt(m,o,t)*m%t,g=rt(T,s,t)*T%t,A=rt(g,a,t)*g%t,x=rt(A,c,t)*A%t,v=rt(x,a,t)*g%t,p=rt(v,r,t)*u%t,E=rt(p,i,t)*T%t,S=rt(E,n,t)*f%t,U=rt(S,Ta,t);if(!rs.eql(rs.sqr(U),e))throw new Error("Cannot find square root");return U}var rs=Oe(ns.p,{sqrt:Xu}),Qu=Sa(ns,{Fp:rs,endo:Gu}),Le=Aa(Qu,Ri);function _a(e,t,r,n){let o=$e.digest(r instanceof Uint8Array?r:r.subarray());if(Zr(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),Le.verify(t,s,e,{prehash:!1,format:"der"}))).catch(s=>{throw s.name==="AbortError"?s:new sr(String(s))});try{return n?.signal?.throwIfAborted(),Le.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(s){throw new sr(String(s))}}var an=class{type="secp256k1";raw;_key;constructor(t){this._key=Ia(t),this.raw=Ca(this._key)}toMultihash(){return Rt.digest(Ae(this))}toCID(){return pt.createV1(114,this.toMultihash())}toString(){return ut.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Et(this.raw,t.raw)}verify(t,r,n){return _a(this._key,r,t,n)}};function Da(e){return new an(e)}function Ca(e){return Le.Point.fromBytes(e).toBytes()}function Ia(e){try{return Le.Point.fromBytes(e),e}catch(t){throw new mr(String(t))}}function Oa(e){let{Type:t,Data:r}=ur.decode(e.digest),n=r??new Uint8Array;switch(t){case wt.Ed25519:return ua(n);case wt.secp256k1:return Da(n);case wt.ECDSA:return li(n);default:throw new Me}}function Ae(e){return ur.encode({Type:wt[e.type],Data:e.raw})}var Ra=Symbol.for("nodejs.util.inspect.custom"),Ju=114,lr=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=ut.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return pt.createV1(Ju,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Et(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Et(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Ra](){return`PeerId(${this.toString()})`}},cn=class extends lr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},fn=class extends lr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},un=class extends lr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},tl=2336,dr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Rt.digest(St(this.url))}[Ra](){return`PeerId(${this.url})`}[In]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return pt.createV1(tl,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=ft(t)),t.toString()===this.toString())}};var el=114,La=2336;function Pa(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=Ve(ut.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return rl(pt.parse(e));if(t==null)throw new Nt('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(ol(e))return new cn({multihash:e});if(nl(e))try{let t=Oa(e);if(t.type==="Ed25519")return new fn({multihash:e,publicKey:t});if(t.type==="secp256k1")return new un({multihash:e,publicKey:t})}catch{let r=ft(e.digest);return new dr(new URL(r))}throw new br("Supplied PeerID Multihash is invalid")}function rl(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==el&&e.code!==La)throw new yr("Supplied PeerID CID is invalid");if(e.code===La){let t=ft(e.multihash.digest);return new dr(new URL(t))}return Ua(e.multihash)}function nl(e){return e.code===Rt.code}function ol(e){return e.code===$e.code}var mt=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},$t=class extends Error{static name="ValidationError";name="ValidationError"},ln=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},dn=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var hn=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 d=this.readChar();if(d===void 0)return;let y=Number.parseInt(d,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 sl=45,il=15,pn=new hn;function Na(e){if(!(e.length>il))return pn.new(e).parseWith(()=>pn.readIPv4Addr())}function Fa(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>sl))return pn.new(e).parseWith(()=>pn.readIPv6Addr())}function mn(e){return!!Na(e)}function Ka(e){return!!Fa(e)}function ss(e){return t=>ft(t,e)}function is(e){return t=>St(t,e)}function Pe(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 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!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let r=St(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 Kt([r,o],r.length+o.length)}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!==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 Kt([r,o],r.length+o.length)}function as(e){let t=e.subarray(0,e.length-2),r=e.subarray(e.length-2),n=ft(t,"base32"),o=Pe(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 mt("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=mn(r[n]),i;s&&(i=cs(r[n]),r[n]=ft(i.subarray(0,2),"base16")),i!=null&&++n<8&&r.splice(n,0,ft(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 mt("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 mt("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 mt("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 mt(`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 mt(`Invalid IPv6 address "${e}"`)}}var os=Object.values(Ye).map(e=>e.decoder),al=(function(){let e=os[0].or(os[1]);return os.slice(2).forEach(t=>e=e.or(t)),e})();function ja(e){return al.decode(e)}function $a(e){return t=>e.encoder.encode(t)}function cl(e){if(parseInt(e).toString()!==e)throw new $t("Value must be an integer")}function fl(e){if(e<0)throw new $t("Value must be a positive integer, or zero")}function ul(e){return t=>{if(t>e)throw new $t(`Value must be smaller than or equal to ${e}`)}}function ll(...e){return t=>{for(let r of e)r(t)}}var hr=ll(cl,fl,ul(65535));var ht=-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 dn(`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)}))}},Zt=new fs,Al=[{code:4,name:"ip4",size:32,valueToBytes:cs,bytesToValue:Ha,validate:e=>{if(!mn(e))throw new $t(`Invalid IPv4 address "${e}"`)}},{code:6,name:"tcp",size:16,valueToBytes:ye,bytesToValue:Pe,validate:hr},{code:273,name:"udp",size:16,valueToBytes:ye,bytesToValue:Pe,validate:hr},{code:33,name:"dccp",size:16,valueToBytes:ye,bytesToValue:Pe,validate:hr},{code:41,name:"ip6",size:128,valueToBytes:qa,bytesToValue:za,stringToValue:Va,validate:e=>{if(!Ka(e))throw new $t(`Invalid IPv6 address "${e}"`)}},{code:42,name:"ip6zone",size:ht},{code:43,name:"ipcidr",size:8,bytesToValue:ss("base10"),valueToBytes:is("base10")},{code:53,name:"dns",size:ht},{code:54,name:"dns4",size:ht},{code:55,name:"dns6",size:ht},{code:56,name:"dnsaddr",size:ht},{code:132,name:"sctp",size:16,valueToBytes:ye,bytesToValue:Pe,validate:hr},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:ht,stringToValue:e=>decodeURIComponent(e),valueToString:e=>encodeURIComponent(e)},{code:421,name:"p2p",aliases:["ipfs"],size:ht,bytesToValue:ss("base58btc"),valueToBytes:e=>e.startsWith("Q")||e.startsWith("1")?is("base58btc")(e):pt.parse(e).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:as,valueToBytes:ka},{code:445,name:"onion3",size:296,bytesToValue:as,valueToBytes:Ma},{code:446,name:"garlic64",size:ht},{code:447,name:"garlic32",size:ht},{code:448,name:"tls"},{code:449,name:"sni",size:ht},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:ht,bytesToValue:$a($n),valueToBytes:ja},{code:480,name:"http"},{code:481,name:"http-path",size:ht,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:ht}];Al.forEach(e=>{Zt.addProtocol(e)});function Ya(e){let t=[],r=0;for(;r<e.length;){let n=Ko(e,r),o=Zt.getProtocol(n),s=qt(n),i=Tl(o,e,r+s),a=0;i>0&&o.size===ht&&(a=qt(i));let c=s+a+i,f={code:n,name:o.name,bytes:Lt(e.subarray(r,r+c))};if(i>0){let u=r+s+a,d=e.subarray(u,u+i);f.value=o.bytesToValue?.(d)??ft(d)}t.push(f),r+=c}return t}function Za(e){let t=0,r=[];for(let n of e){if(n.bytes==null){let o=Zt.getProtocol(n.code),s=qt(n.code),i,a=0,c=0;n.value!=null&&(i=o.valueToBytes?.(n.value)??St(n.value),a=i.byteLength,o.size===ht&&(c=qt(a)));let f=new Uint8Array(s+c+a),u=0;ir(n.code,f,u),u+=s,i!=null&&(o.size===ht&&(ir(a,f,u),u+=c),f.set(i,u)),n.bytes=f}r.push(n.bytes),t+=n.bytes.byteLength}return Kt(r,t)}function Wa(e){if(e.charAt(0)!=="/")throw new mt('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=Zt.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 mt(`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 mt(`Component ${o} was missing value`);f.value=c.stringToValue?.(n)??n}t.push(f),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new mt("Incomplete multiaddr");return t}function Ga(e){return`/${e.flatMap(t=>{if(t.value==null)return t.name;let r=Zt.getProtocol(t.code);if(r==null)throw new mt(`Unknown protocol code ${t.code}`);return[t.name,r.valueToString?.(t.value)??t.value]}).join("/")}`}function Tl(e,t,r){return e.size==null||e.size===0?0:e.size>0?e.size/8:Ko(t,r)}var _l=Symbol.for("nodejs.util.inspect.custom"),Ts=Symbol.for("@multiformats/multiaddr");function Cl(e){if(e==null&&(e="/"),Xa(e))return e.getComponents();if(e instanceof Uint8Array)return Ya(e);if(typeof e=="string")return e=e.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),e===""&&(e="/"),Wa(e);if(Array.isArray(e))return e;throw new mt("Must be a string, Uint8Array, Component[], or another Multiaddr")}var En=class e{[Ts]=!0;#t;#e;#r;constructor(t="/",r={}){this.#t=Cl(t),r.validate!==!1&&Il(this)}get bytes(){return this.#r==null&&(this.#r=Za(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 ln(`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 Et(this.bytes,t.bytes)}[_l](){return`Multiaddr(${this.toString()})`}};function Il(e){e.getComponents().forEach(t=>{let r=Zt.getProtocol(t.code);t.value!=null&&r.validate?.(t.value)})}function Xa(e){return!!e?.[Ts]}function Qa(e){return new En(e)}var X=e=>({match:t=>{let r=t[0];return r==null||r.code!==e||r.value!=null?!1:t.slice(1)}}),O=(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}}),gt=(...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}}),j=(...e)=>({match:t=>{for(let r of e){let n=r.match(t);if(n===!1)return!1;t=n}return t}});function Q(...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 Dl=O(421),Jy=Q(Dl),vn=O(54),Bn=O(55),An=O(56),Cs=O(53),tb=Q(vn,q(O(421))),eb=Q(Bn,q(O(421))),rb=Q(An,q(O(421))),nb=Q(gt(Cs,An,vn,Bn),q(O(421))),tc=j(O(4),q(O(43))),ec=j(q(O(42)),O(41),q(O(43))),Is=gt(tc,ec),Ke=gt(Is,Cs,vn,Bn,An),ob=Q(gt(Is,j(gt(Cs,An,vn,Bn),q(O(421))))),sb=Q(tc),ib=Q(ec),ab=Q(Is),Ds=j(Ke,O(6)),pr=j(Ke,O(273)),cb=Q(j(Ds,q(O(421)))),fb=Q(pr),Os=j(pr,X(460),q(O(421))),Tn=j(pr,X(461),q(O(421))),Ol=gt(Os,Tn),ub=Q(Os),lb=Q(Tn),_s=gt(Ke,Ds,pr,Os,Tn),rc=gt(j(_s,X(477),q(O(421)))),db=Q(rc),nc=gt(j(_s,X(478),q(O(421))),j(_s,X(448),q(O(449)),X(477),q(O(421)))),hb=Q(nc),oc=j(pr,X(280),q(O(466)),q(O(466)),q(O(421))),pb=Q(oc),sc=j(Tn,X(465),q(O(466)),q(O(466)),q(O(421))),mb=Q(sc),Sn=gt(rc,nc,j(Ds,q(O(421))),j(Ol,q(O(421))),j(Ke,q(O(421))),oc,sc,O(421)),ic=Q(Sn),Rl=j(q(Sn),X(290),Ja(X(281)),q(O(421))),yb=Q(Rl),Ll=gt(j(Sn,X(290),X(281),q(O(421))),j(Sn,X(281),q(O(421))),j(X(281),q(O(421)))),bb=Q(Ll),Pl=j(Ke,gt(j(O(6,"80")),j(O(6),X(480)),X(480)),q(O(481)),q(O(421))),gb=Q(Pl),Ul=j(Ke,gt(j(O(6,"443")),j(O(6,"443"),X(480)),j(O(6),X(443)),j(O(6),X(448),X(480)),j(X(448),X(480)),X(448),X(443)),q(O(481)),q(O(421))),xb=Q(Ul),Nl=gt(j(O(777),q(O(421)))),wb=Q(Nl),Fl=gt(j(O(400),q(O(421)))),Eb=Q(Fl);var Kl="bootstrap",kl=50,Ml=1e3,Rs=class extends gr{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??Kl]:{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 ql(e){return t=>new Rs(t,e)}return pc(Hl);})();
3
3
  /*! Bundled license information:
4
4
 
5
5
  @noble/curves/utils.js: