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