@libp2p/peer-collections 7.0.27 → 7.0.28-185d901cd
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 +3 -3
- package/package.json +5 -5
- package/dist/typedoc-urls.json +0 -16
package/dist/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PPeerCollections = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PPeerCollections=(()=>{var Wr=Object.defineProperty;var Zi=Object.getOwnPropertyDescriptor;var Yi=Object.getOwnPropertyNames;var $i=Object.prototype.hasOwnProperty;var at=(r,t)=>{for(var e in t)Wr(r,e,{get:t[e],enumerable:!0})},Gi=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Yi(t))!$i.call(r,o)&&o!==e&&Wr(r,o,{get:()=>t[o],enumerable:!(n=Zi(t,o))||n.enumerable});return r};var Xi=r=>Gi(Wr({},"__esModule",{value:!0}),r);var Pf={};at(Pf,{PeerFilter:()=>Je,PeerList:()=>Yt,PeerMap:()=>Vt,PeerSet:()=>Zt,peerFilter:()=>Mi,peerList:()=>Ui,peerMap:()=>Oi,peerSet:()=>Fi,trackedPeerList:()=>qi,trackedPeerMap:()=>Pi,trackedPeerSet:()=>zi});var It=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Qe=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var tr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var ve=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Jr=Symbol.for("@libp2p/peer-id");var nn={};at(nn,{base58btc:()=>W,base58flickr:()=>oc});var jf=new Uint8Array(0);function Co(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function dt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return $t(r);if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return $t(new Uint8Array(r.buffer,r.byteOffset,r.byteLength));throw new Error("Unknown type, must be binary type")}function Lo(r){let t=new Uint8Array(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}var Ro=4096;function Do(r){let t=r.length;if(t<=Ro)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.subarray(n,n+=Ro));return e}function Wi(r){return r?.buffer instanceof ArrayBuffer}function $t(r){return Wi(r)?r:r.slice()}function Ji(r,t,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),o=0;o<n.length;o++)n[o]=255;for(var s=0;s<r.length;s++){var i=r.charAt(s),c=i.charCodeAt(0);if(n[c]!==255)throw new TypeError(i+" is ambiguous");if(n[c]=s,e){var a=i.toLowerCase().charCodeAt(0),f=i.toUpperCase().charCodeAt(0);a!==c&&(n[a]=s),f!==c&&(n[f]=s)}}var u=r.length,h=r.charAt(0),b=Math.log(u)/Math.log(256),m=Math.log(256)/Math.log(u);function L(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var S=0,p=0,_=0,A=w.length;_!==A&&w[_]===0;)_++,S++;for(var K=(A-_)*m+1>>>0,M=new Uint8Array(K);_!==A;){for(var U=w[_],O=0,F=K-1;(U!==0||O<p)&&F!==-1;F--,O++)U+=256*M[F]>>>0,M[F]=U%u>>>0,U=U/u>>>0;if(U!==0)throw new Error("Non-zero carry");p=O,_++}for(var P=K-p;P!==K&&M[P]===0;)P++;for(var C=h.repeat(S);P<K;++P)C+=r.charAt(M[P]);return C}function B(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var S=0;if(w[S]!==" "){for(var p=0,_=0;w[S]===h;)p++,S++;for(var A=(w.length-S)*b+1>>>0,K=new Uint8Array(A);w[S];){var M=n[w.charCodeAt(S)];if(M===255)return;for(var U=0,O=A-1;(M!==0||U<_)&&O!==-1;O--,U++)M+=u*K[O]>>>0,K[O]=M%256>>>0,M=M/256>>>0;if(M!==0)throw new Error("Non-zero carry");_=U,S++}if(w[S]!==" "){for(var F=A-_;F!==A&&K[F]===0;)F++;for(var P=new Uint8Array(p+(A-F)),C=p;F!==A;)P[C++]=K[F++];return P}}}function R(w){var S=B(w);if(S)return S;throw new Error(`Non-${t} character`)}return{encode:L,decodeUnsafe:B,decode:R}}var Qi=Ji,tc=Qi,Fo=tc;var Qr=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},tn=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Uo(this,t)}},en=class{decoders;constructor(t){this.decoders=t}or(t){return Uo(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Uo(r,t){return new en({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var rn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Qr(t,e,n),this.decoder=new tn(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ae({name:r,prefix:t,encode:e,decode:n}){return new rn(r,t,e,n)}function Dt({name:r,prefix:t,alphabet:e,caseInsensitive:n=!1}){let{encode:o,decode:s}=Fo(e,r,n);return ae({prefix:t,name:r,encode:o,decode:i=>dt(s(i))})}function ec(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,c=0,a=0;for(let f=0;f<o;++f){let u=t[r[f]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|u,i+=e,i>=8&&(i-=8,s[a++]=255&c>>i)}if(i>=e||(255&c<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function rc(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],i+=8;i>e;)i-=e,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function nc(r,t){let e={};for(let n=0;n<r.length;++n)if(e[r[n]]=n,t){let o=r[n].toLowerCase(),s=r[n].toUpperCase();o!==r[n]&&(e[o]=n),s!==r[n]&&(e[s]=n)}return e}function X({name:r,prefix:t,bitsPerChar:e,alphabet:n,caseInsensitive:o=!1}){let s=nc(n,o);return ae({prefix:t,name:r,encode(i){return rc(i,n,e)},decode(i){return ec(i,s,e,r)}})}var W=Dt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),oc=Dt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var on={};at(on,{base32:()=>fe,base32hex:()=>ac,base32hexpad:()=>uc,base32hexpadupper:()=>hc,base32hexupper:()=>fc,base32pad:()=>ic,base32padupper:()=>cc,base32upper:()=>sc,base32z:()=>lc});var fe=X({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5,caseInsensitive:!0}),sc=X({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5,caseInsensitive:!0}),ic=X({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5,caseInsensitive:!0}),cc=X({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5,caseInsensitive:!0}),ac=X({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5,caseInsensitive:!0}),fc=X({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5,caseInsensitive:!0}),uc=X({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5,caseInsensitive:!0}),hc=X({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5,caseInsensitive:!0}),lc=X({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var sn={};at(sn,{base36:()=>Ie,base36upper:()=>dc});var Ie=Dt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz",caseInsensitive:!0}),dc=Dt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",caseInsensitive:!0});var pc=Ko,ko=128,mc=127,yc=~mc,bc=Math.pow(2,31);function Ko(r,t,e){t=t||[],e=e||0;for(var n=e;r>=bc;)t[e++]=r&255|ko,r/=128;for(;r&yc;)t[e++]=r&255|ko,r>>>=7;return t[e]=r|0,Ko.bytes=e-n+1,t}var gc=cn,xc=128,No=127;function cn(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw cn.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&No)<<o:(i&No)*Math.pow(2,o),o+=7}while(i>=xc);return cn.bytes=s-n,e}var wc=Math.pow(2,7),Ec=Math.pow(2,14),Sc=Math.pow(2,21),_c=Math.pow(2,28),Bc=Math.pow(2,35),Ac=Math.pow(2,42),vc=Math.pow(2,49),Ic=Math.pow(2,56),Tc=Math.pow(2,63),Rc=function(r){return r<wc?1:r<Ec?2:r<Sc?3:r<_c?4:r<Bc?5:r<Ac?6:r<vc?7:r<Ic?8:r<Tc?9:10},Cc={encode:pc,decode:gc,encodingLength:Rc},Lc=Cc,Te=Lc;function Re(r,t=0){let e=Te.decode(r,t),n=Te.decode.bytes;if(n>9)throw new RangeError("Invalid varint: too long");if(n>1&&r[t+n-1]===0)throw new RangeError("Invalid varint: not minimally encoded");return[e,n]}function ue(r,t,e=0){return Te.encode(r,t,e),t}function he(r){return Te.encodingLength(r)}function de(r,t){let e=t.byteLength,n=he(r),o=n+he(e),s=new Uint8Array(o+e);return ue(r,s,0),ue(e,s,n),s.set(t,o),new le(r,e,t,s)}function Ce(r){let t=dt(r),[e,n]=Re(t),[o,s]=Re(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new le(e,o,i,t)}function Mo(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Co(r.bytes,e.bytes)}}var le=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=$t(n),this.bytes=$t(o)}};function Po(r,t){let{bytes:e,version:n}=r;return n===0?Oc(e,an(r),t??W.encoder):Fc(e,an(r),t??fe.encoder)}var zo=new WeakMap;function an(r){let t=zo.get(r);if(t==null){let e=new Map;return zo.set(r,e),e}return t}var st=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=$t(o),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Le)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Uc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=de(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Mo(t.multihash,n.multihash)}toString(t){return Po(this,t)}toJSON(){return{"/":Po(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??qo(n,o,s.bytes))}else if(e[kc]===!0){let{version:n,multihash:o,code:s}=e,i=Ce(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Le)throw new Error(`Version 0 CID must use dag-pb (code: ${Le}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=qo(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Le,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=dt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new le(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[h,b]=Re(t.subarray(e));return e+=b,h},o=n(),s=Le;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,c=n(),a=n(),f=e+a,u=f-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:u,size:f}}static parse(t,e){let[n,o]=Dc(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return an(s).set(n,t),s}};function Dc(r,t){switch(r[0]){case"Q":{let e=t??W;return[W.prefix,e.decode(`${W.prefix}${r}`)]}case W.prefix:{let e=t??W;return[W.prefix,e.decode(r)]}case fe.prefix:{let e=t??fe;return[fe.prefix,e.decode(r)]}case Ie.prefix:{let e=t??Ie;return[Ie.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Oc(r,t,e){let{prefix:n}=e;if(n!==W.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function Fc(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var Le=112,Uc=18;function qo(r,t,e){let n=he(r),o=n+he(t),s=new Uint8Array(o+e.byteLength);return ue(r,s,0),ue(t,s,n),s.set(e,o),s}var kc=Symbol.for("@ipld/js-cid/CID");var fn={};at(fn,{identity:()=>bt});var Ho=0,Nc="identity",jo=dt;function Kc(r,t){if(t?.truncate!=null&&t.truncate!==r.byteLength){if(t.truncate<0||t.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t.truncate)}return de(Ho,jo(r))}var bt={code:Ho,name:Nc,encode:jo,digest:Kc};function ft(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Mc(r){return r.buffer instanceof ArrayBuffer}function Ot(r){return Mc(r)?r:r.slice()}async function Vo(r,t,e,n){let o=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,Ot(t),Ot(e.subarray()));return n?.signal?.throwIfAborted(),s}function gt(r=0){return new Uint8Array(r)}function ut(r=0){return new Uint8Array(r)}function Pc(r){return r?.buffer instanceof ArrayBuffer}function Zo(r){if(Pc(r))return r;let t=r.slice();return new Uint8Array(t.buffer,0,t.byteLength)}function rr(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=ut(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return Zo(e)}var $o=Symbol.for("@achingbrain/uint8arraylist");function Yo(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function nr(r){return!!r?.[$o]}var ht=class r{bufs;length;[$o]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(nr(n)){e+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(nr(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Yo(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Yo(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(nr(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return rr(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:rr(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=n,s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],c=o,a=c+i.byteLength;if(o=a,t>=a)continue;let f=t>=c&&t<a,u=e>c&&e<=a;if(f&&u){if(t===c&&e===a){n.push(i);break}let h=t-c;n.push(i.subarray(h,h+(e-t)));break}if(f){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(u){if(e===a){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!nr(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let h=0;h<s;h++)i[h]=-1;for(let h=0;h<o;h++)i[n[h]]=h;let c=i,a=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let h=e;h<=a;h+=u){u=0;for(let b=f;b>=0;b--){let m=this.get(h+b);if(n[b]!==m){u=Math.max(1,b-c[m]);break}}if(u===0)return h}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=ut(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=gt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=gt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=gt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=ut(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=gt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=gt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=gt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=gt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=gt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!ft(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var un={};at(un,{base10:()=>zc});var zc=Dt({prefix:"9",name:"base10",alphabet:"0123456789"});var hn={};at(hn,{base16:()=>qc,base16upper:()=>Hc});var qc=X({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4,caseInsensitive:!0}),Hc=X({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4,caseInsensitive:!0});var ln={};at(ln,{base2:()=>jc});var jc=X({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var dn={};at(dn,{base256emoji:()=>Gc});var Go=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}"),Vc=Go.reduce((r,t,e)=>(r[e]=t,r),[]),Zc=Go.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Yc(r){return r.reduce((t,e)=>(t+=Vc[e],t),"")}function $c(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Zc[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Gc=ae({prefix:"\u{1F680}",name:"base256emoji",encode:Yc,decode:$c});var pn={};at(pn,{base64:()=>Xc,base64pad:()=>Wc,base64url:()=>Jc,base64urlpad:()=>Qc});var Xc=X({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Wc=X({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Jc=X({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Qc=X({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var mn={};at(mn,{base8:()=>ta});var ta=X({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var yn={};at(yn,{identity:()=>ea});var ea=ae({prefix:"\0",name:"identity",encode:r=>Do(dt(r)),decode:r=>dt(Lo(r))});var Ru=new TextEncoder,Cu=new TextDecoder;var xn={};at(xn,{sha256:()=>De,sha512:()=>sa});var oa=20;function gn({name:r,code:t,encode:e,minDigestLength:n,maxDigestLength:o}){return new bn(r,t,e,n,o)}var bn=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,e,n,o,s){this.name=t,this.code=e,this.encode=n,this.minDigestLength=o??oa,this.maxDigestLength=s}digest(t,e){if(e?.truncate!=null){if(e.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&e.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?Xo(n,this.code,e?.truncate):n.then(o=>Xo(o,this.code,e?.truncate))}else throw Error("Unknown type, must be binary type")}};function Xo(r,t,e){if(e!=null&&e!==r.byteLength){if(e>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e)}return de(t,r)}function Jo(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var De=gn({name:"sha2-256",code:18,encode:Jo("SHA-256")}),sa=gn({name:"sha2-512",code:19,encode:Jo("SHA-512")});var wn={...yn,...ln,...mn,...un,...hn,...on,...sn,...nn,...pn,...dn},qu={...xn,...fn};function ts(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Qo=ts("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),En=ts("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=ut(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),ia={utf8:Qo,"utf-8":Qo,hex:wn.base16,latin1:En,ascii:En,binary:En,...wn},or=ia;function Q(r,t="utf8"){let e=or[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function pt(r,t="utf8"){let e=or[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var ca=parseInt("11111",2),Sn=parseInt("10000000",2),aa=parseInt("01111111",2),es={0:Oe,1:Oe,2:fa,3:la,4:da,5:ha,6:ua,16:Oe,22:Oe,48:Oe};function _n(r,t={offset:0}){let e=r[t.offset]&ca;if(t.offset++,es[e]!=null)return es[e](r,t);throw new Error("No decoder for tag "+e)}function Fe(r,t){let e=0;if((r[t.offset]&Sn)===Sn){let n=r[t.offset]&aa,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++){if(t.offset>=r.byteLength)throw new Error("invalid DER element length");o+=r[t.offset].toString(16).padStart(2,"0")}e=parseInt(o,16)}else e=r[t.offset],t.offset++;if(!Number.isInteger(e)||e<0||e>r.byteLength-t.offset)throw new Error("invalid DER element length");return e}function Oe(r,t){Fe(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=_n(r,t);if(n===null)break;e.push(n)}return e}function fa(r,t){let e=Fe(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function ua(r,t){let e=Fe(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let c=`${s}.${i}`,a=[];for(;t.offset<n;){let f=r[t.offset];if(t.offset++,a.push(f&127),f<128){a.reverse();let u=0;for(let h=0;h<a.length;h++)u+=a[h]<<h*7;c+=`.${u}`,a=[]}}return c}function ha(r,t){return t.offset++,null}function la(r,t){let e=Fe(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function da(r,t){let e=Fe(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function pa(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new ht;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function Bn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=pa(r.byteLength);return new ht(Uint8Array.from([t.byteLength|Sn]),t)}function rs(r){let t=new ht,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new ht(Uint8Array.from([2]),Bn(t),t)}function ns(r){let t=Uint8Array.from([0]),e=new ht(t,r);return new ht(Uint8Array.from([3]),Bn(e),e)}function sr(r,t=48){let e=new ht;for(let n of r)e.append(n);return new ht(Uint8Array.from([t]),Bn(e),e)}var ma=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),ya=Uint8Array.from([6,5,43,129,4,0,34]),ba=Uint8Array.from([6,5,43,129,4,0,35]),ga={ext:!0,kty:"EC",crv:"P-256"},xa={ext:!0,kty:"EC",crv:"P-384"},wa={ext:!0,kty:"EC",crv:"P-521"},An=32,vn=48,In=66;function os(r){let t=_n(r);return ss(t)}function ss(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===An*2+1)return n=pt(t.subarray(e,e+An),"base64url"),o=pt(t.subarray(e+An),"base64url"),new pe({...ga,key_ops:["verify"],x:n,y:o});if(t.byteLength===vn*2+1)return n=pt(t.subarray(e,e+vn),"base64url"),o=pt(t.subarray(e+vn),"base64url"),new pe({...xa,key_ops:["verify"],x:n,y:o});if(t.byteLength===In*2+1)return n=pt(t.subarray(e,e+In),"base64url"),o=pt(t.subarray(e+In),"base64url"),new pe({...wa,key_ops:["verify"],x:n,y:o});throw new It(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function is(r){return sr([rs(Uint8Array.from([1])),sr([Ea(r.crv)],160),sr([ns(new ht(Uint8Array.from([4]),Q(r.x??"","base64url"),Q(r.y??"","base64url")))],161)]).subarray()}function Ea(r){if(r==="P-256")return ma;if(r==="P-384")return ya;if(r==="P-521")return ba;throw new It(`Invalid curve ${r}`)}var pe=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=is(this.jwk)),this._raw}toMultihash(){return bt.digest(me(this))}toCID(){return st.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ft(this.raw,t.raw)}async verify(t,e,n){return Vo(this.jwk,e,t,n)}};var ir=BigInt(4294967295),cs=BigInt(32);function Sa(r,t=!1){return t?{h:Number(r&ir),l:Number(r>>cs&ir)}:{h:Number(r>>cs&ir)|0,l:Number(r&ir)|0}}function as(r,t=!1){let e=r.length,n=new Uint32Array(e),o=new Uint32Array(e);for(let s=0;s<e;s++){let{h:i,l:c}=Sa(r[s],t);[n[s],o[s]]=[i,c]}return[n,o]}var _a=r=>r/2**32|0,Ba=r=>r>>>0;function fs(r,t,e,n){let o=_a(e),s=Ba(e);r.setUint32(t,n?s:o,n),r.setUint32(t+4,n?o:s,n)}var Tn=(r,t,e)=>r>>>e,Rn=(r,t,e)=>r<<32-e|t>>>e,Xt=(r,t,e)=>r>>>e|t<<32-e,Wt=(r,t,e)=>r<<32-e|t>>>e,Ue=(r,t,e)=>r<<64-e|t>>>e-32,ke=(r,t,e)=>r>>>e-32|t<<64-e;function Bt(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var us=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),hs=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,ls=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),ds=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,ps=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),ms=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;function cr(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in r&&r.BYTES_PER_ELEMENT===1}var Cn=r=>r?`"${r}" `:"";function Tt(r,t=""){if(typeof r!="number")throw new TypeError(Cn(t)+"expected number, got "+typeof r);if(!Number.isSafeInteger(r)||r<0)throw new RangeError(Cn(t)+"expected integer >= 0, got "+r);return r}function mt(r,t,e=""){if(cr(r)&&(t===void 0||r.length===t))return r;t!==void 0&&Tt(t,"length");let n=cr(r),o=t!==void 0?` of length ${t}`:"",s=n?`length=${r.length}`:`type=${typeof r}`,i=Cn(e)+"expected Uint8Array"+o+", got "+s;throw n?new RangeError(i):new TypeError(i)}function ar(r){if(typeof r!="function"||typeof r.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(Tt(r.outputLen),Tt(r.blockLen),r.outputLen<1||r.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var ys=(r,t)=>{if(r===null||typeof r!="object"||Array.isArray(r))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof r)};function ye(r,t=!0){if(r.destroyed)throw new Error("hash was destroyed");if(t&&r.finished)throw new Error("digest() was already called")}function fr(r,t){mt(r,void 0,"output");let e=t.outputLen;if(!(r.length>=e))throw new RangeError('"output" expected length >= '+e)}function Jt(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function ur(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function xt(r,t){return r<<32-t|r>>>t}var gs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",va=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function hr(r){if(mt(r),gs)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=va[r[e]];return t}function bs(r){return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void 0}function lr(r){if(typeof r!="string")throw new TypeError("hex string expected, got "+typeof r);if(gs)try{return Uint8Array.fromHex(r)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let t=r.length,e=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=bs(r.charCodeAt(s)),c=bs(r.charCodeAt(s+1));if(i===void 0||c===void 0){let a=r[s]+r[s+1];throw new RangeError('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function Ln(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];mt(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}function Ia(r,t,e="opts"){return ys(r,"defaults"),t!==void 0&&ys(t,e),Object.assign(r,t)}function Dn(r,t={}){if(typeof r!="function")throw new TypeError('"hashCons" expected function, got type='+typeof r);t=Ia({},t,"info");let e=(o,s)=>r(s).update(o).digest(),n=r(void 0);return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.canXOF=n.canXOF,e.create=o=>r(o),Object.assign(e,t),Object.freeze(e)}function xs(r=32){Tt(r,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(r>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${r}`);return t.getRandomValues(new Uint8Array(r))}var On=r=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,r])});function ws(r,t,e){return r&t^~r&e}function Es(r,t,e){return r&t^r&e^t&e}var Ne=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,e,n,o){this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=ur(this.buffer)}update(t){ye(this),mt(t);let{view:e,buffer:n,blockLen:o}=this,s=t.length,i=!1;for(let c=0;c<s;){let a=Math.min(o-this.pos,s-c);if(a===o){let f=ur(t);for(;o<=s-c;c+=o)this.process(f,c);i=!0;continue}n.set(c===0&&a===s?t:t.subarray(c,c+a),this.pos),this.pos+=a,c+=a,this.pos===o&&(this.process(e,0),this.pos=0,i=!0)}return this.length+=t.length,i&&this.roundClean(),this}digestInto(t){ye(this),fr(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,e.fill(0,i),this.padOffset>o-i&&(this.process(n,0),e.fill(0)),fs(n,o-8,this.length*8,s),this.process(n,0),this.roundClean();let c=t===e?n:ur(t),a=this.outputLen,f=a/4,u=this.get();if(a%4||f>u.length)throw new Error("invalid outputLen");for(let h=0;h<f;h++)c.setUint32(4*h,u[h],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneIntoMeta(t){let{buffer:e,length:n,finished:o,destroyed:s,pos:i}=this;return t.destroyed=s,t.finished=o,t.length=n,t.pos=i,i&&t.buffer.set(e),t}clone(){return this._cloneInto()}},Ss=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var _s=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Ta=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]),Ft=new Uint32Array(64),Fn=class extends Ne{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(t,e){super(64,t,8,!1),this.A=e[0]|0,this.B=e[1]|0,this.C=e[2]|0,this.D=e[3]|0,this.E=e[4]|0,this.F=e[5]|0,this.G=e[6]|0,this.H=e[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[t,e,n,o,s,i,c,a]}set(t,e,n,o,s,i,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,e){for(let h=0;h<16;h++,e+=4)Ft[h]=t.getUint32(e,!1);for(let h=16;h<64;h++){let b=Ft[h-15],m=Ft[h-2],L=xt(b,7)^xt(b,18)^b>>>3,B=xt(m,17)^xt(m,19)^m>>>10;Ft[h]=B+Ft[h-7]+L+Ft[h-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:f,H:u}=this;for(let h=0;h<64;h++){let b=xt(c,6)^xt(c,11)^xt(c,25),m=u+b+ws(c,a,f)+Ta[h]+Ft[h]|0,B=(xt(n,2)^xt(n,13)^xt(n,22))+Es(n,o,s)|0;u=f,f=a,a=c,c=i+m|0,i=s,s=o,o=n,n=m+B|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,s,i,c,a,f,u)}roundClean(){Jt(Ft)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Jt(this.buffer)}},Un=class extends Fn{constructor(){super(32,Ss)}};var Bs=as(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Ra=Bs[0],Ca=Bs[1],Ut=new Uint32Array(80),kt=new Uint32Array(80),kn=class extends Ne{Ah=0;Al=0;Bh=0;Bl=0;Ch=0;Cl=0;Dh=0;Dl=0;Eh=0;El=0;Fh=0;Fl=0;Gh=0;Gl=0;Hh=0;Hl=0;constructor(t,e){super(128,t,16,!1),this.Ah=e[0]|0,this.Al=e[1]|0,this.Bh=e[2]|0,this.Bl=e[3]|0,this.Ch=e[4]|0,this.Cl=e[5]|0,this.Dh=e[6]|0,this.Dl=e[7]|0,this.Eh=e[8]|0,this.El=e[9]|0,this.Fh=e[10]|0,this.Fl=e[11]|0,this.Gh=e[12]|0,this.Gl=e[13]|0,this.Hh=e[14]|0,this.Hl=e[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:f,El:u,Fh:h,Fl:b,Gh:m,Gl:L,Hh:B,Hl:R}=this;return[t,e,n,o,s,i,c,a,f,u,h,b,m,L,B,R]}set(t,e,n,o,s,i,c,a,f,u,h,b,m,L,B,R){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=f|0,this.El=u|0,this.Fh=h|0,this.Fl=b|0,this.Gh=m|0,this.Gl=L|0,this.Hh=B|0,this.Hl=R|0}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,e){for(let p=0;p<16;p++,e+=4)Ut[p]=t.getUint32(e),kt[p]=t.getUint32(e+=4);for(let p=16;p<80;p++){let _=Ut[p-15]|0,A=kt[p-15]|0,K=Xt(_,A,1)^Xt(_,A,8)^Tn(_,A,7),M=Wt(_,A,1)^Wt(_,A,8)^Rn(_,A,7),U=Ut[p-2]|0,O=kt[p-2]|0,F=Xt(U,O,19)^Ue(U,O,61)^Tn(U,O,6),P=Wt(U,O,19)^ke(U,O,61)^Rn(U,O,6),C=ls(M,P,kt[p-7],kt[p-16]),V=ds(C,K,F,Ut[p-7],Ut[p-16]);Ut[p]=V|0,kt[p]=C|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:f,Dl:u,Eh:h,El:b,Fh:m,Fl:L,Gh:B,Gl:R,Hh:w,Hl:S}=this;for(let p=0;p<80;p++){let _=Xt(h,b,14)^Xt(h,b,18)^Ue(h,b,41),A=Wt(h,b,14)^Wt(h,b,18)^ke(h,b,41),K=h&m^~h&B,M=b&L^~b&R,U=ps(S,A,M,Ca[p],kt[p]),O=ms(U,w,_,K,Ra[p],Ut[p]),F=U|0,P=Xt(n,o,28)^Ue(n,o,34)^Ue(n,o,39),C=Wt(n,o,28)^ke(n,o,34)^ke(n,o,39),V=n&s^n&c^s&c,T=o&i^o&a^i&a;w=B|0,S=R|0,B=m|0,R=L|0,m=h|0,L=b|0,{h,l:b}=Bt(f|0,u|0,O|0,F|0),f=c|0,u=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let I=us(F,C,T);n=hs(I,O,P,V),o=I|0}({h:n,l:o}=Bt(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=Bt(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=Bt(this.Ch|0,this.Cl|0,c|0,a|0),{h:f,l:u}=Bt(this.Dh|0,this.Dl|0,f|0,u|0),{h,l:b}=Bt(this.Eh|0,this.El|0,h|0,b|0),{h:m,l:L}=Bt(this.Fh|0,this.Fl|0,m|0,L|0),{h:B,l:R}=Bt(this.Gh|0,this.Gl|0,B|0,R|0),{h:w,l:S}=Bt(this.Hh|0,this.Hl|0,w|0,S|0),this.set(n,o,s,i,c,a,f,u,h,b,m,L,B,R,w,S)}roundClean(){Jt(Ut,kt)}destroy(){this.destroyed=!0,Jt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Nn=class extends kn{constructor(){super(64,_s)}};var As=Dn(()=>new Un,On(1));var Kn=Dn(()=>new Nn,On(3));function pr(r,t,e=()=>{}){if(!Array.isArray(r))throw new TypeError(`"${t}" expected array, got type=${typeof r}`);for(let n=0;n<r.length;n++)e(r[n],`${t}[${n}]`);return r}var H=(r,t,e)=>mt(r,t,e),Mn=Tt;function Is(r,t=""){if(typeof r!="string"){let e=t&&`"${t}" `;throw new TypeError(e+"expected string, got type="+typeof r)}return r}function Nt(r,t="object"){if(r===null||typeof r!="object"||Array.isArray(r))throw new TypeError(t==="object"?"expected valid options object":`"${t}" expected object, got type=${typeof r}`);return r}function Qt(r,t){if(typeof r!="function")throw new TypeError(`"${t}" is invalid: expected function, got ${typeof r}`);return r}var Ke=hr,yt=(...r)=>Ln(...r),be=r=>lr(r),Mt=cr,te=r=>xs(r),dr=BigInt(0),vs=BigInt(1),La=r=>r?`"${r}" `:"";function it(r,t=""){if(typeof r!="boolean")throw new TypeError(La(t)+"expected boolean, got type="+typeof r);return r}function mr(r){if(typeof r=="bigint"){if(!Kt(r))throw new RangeError("positive bigint expected, got "+r)}else Mn(r);return r}function Pt(r,t=""){if(typeof r!="number"){let e=t&&`"${t}" `;throw new TypeError(e+"expected number, got type="+typeof r)}if(!Number.isSafeInteger(r)){let e=t&&`"${t}" `;throw new RangeError(e+"expected safe integer, got "+r)}}function Me(r){let t=mr(r).toString(16);return t.length&1?"0"+t:t}function Ts(r){if(typeof r!="string")throw new TypeError("hex string expected, got "+typeof r);return r===""?dr:BigInt("0x"+r)}function At(r){return Ts(hr(r))}function ee(r){return Ts(hr(br(mt(r)).reverse()))}function yr(r,t){if(Tt(t),t===0)throw new Error("zero output length is invalid");r=mr(r);let e=t*2,n=r.toString(16);if(n.length>e)throw new RangeError("number is too large");return lr(n.padStart(e,"0"))}function Pn(r,t){return yr(r,t).reverse()}function br(r){return Uint8Array.from(H(r))}function Kt(r){return typeof r=="bigint"&&dr<=r}function zn(r,t,e){return Kt(r)&&Kt(t)&&Kt(e)&&t<=r&&r<e}function ge(r,t,e,n){if(!zn(t,e,n))throw new RangeError("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function xe(r){if(r<dr)throw new Error("expected non-negative bigint, got "+r);return r===dr?0:r.toString(2).length}var Pe=r=>(Pt(r,"n"),(vs<<BigInt(r))-vs);function Rs(r,t,e){if(Tt(r,"hashLen"),Tt(t,"qByteLen"),typeof e!="function")throw new TypeError("hmacFn must be a function");let n=R=>new Uint8Array(R),o=Uint8Array.of(),s=Uint8Array.of(0),i=Uint8Array.of(1),c=1e3,a=n(r),f=n(r),u=0,h=()=>{a.fill(1),f.fill(0),u=0},b=(...R)=>e(f,yt(a,...R)),m=(R=o)=>{f=b(s,R),a=b(),R.length!==0&&(f=b(i,R),a=b())},L=()=>{if(u++>=c)throw new Error("drbg: tried max amount of iterations");let R=0,w=[];for(;R<t;){a=b();let S=a.slice();w.push(S),R+=a.length}return yt(...w)};return(R,w)=>{h(),m(R);let S;for(;(S=w(L()))===void 0;)m();return h(),S}}function ct(r,t={},e={},n="object"){Nt(r,n),Nt(t,"fields"),Nt(e,"optFields");function o(i,c,a){let f=n==="object"?`param "${String(i)}"`:`"${n}.${String(i)}"`,u=r[i];if(!Object.hasOwn(r,i)&&(a?u!==void 0:c!=="function"))throw new TypeError(`${f} is invalid: expected own property`);if(a&&u===void 0)return;let h=typeof u;if(h!==c||u===null)throw new TypeError(`${f} is invalid: expected ${c}, got ${h}`)}let s=(i,c)=>Object.entries(i).forEach(([a,f])=>o(a,f,c));s(t,!1),s(e,!0)}var J=BigInt(0),j=BigInt(1),zt=BigInt(2),Ds=BigInt(3),qn=BigInt(4),Os=BigInt(5),Da=BigInt(7),Fs=BigInt(8),Oa=BigInt(9),Fa=BigInt(15),Us=BigInt(16),Ua=BigInt("0x10000000000000000");function Y(r,t){if(t<=J)throw new Error("mod: expected positive modulus, got "+t);let e=r%t;return e>=J?e:t+e}function ks(r,t,e){if(e<=j)throw new Error("pow: expected modulus > 1, got "+e);if(typeof t!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof t);if(t<J)throw new Error("invalid exponent, negatives unsupported");if(t===J)return j;if(t===j)return r;let n=r%e;if(n<J&&(n+=e),t<Ua){let c=j;for(;t>J;)t&j&&(c=c*n%e),n=n*n%e,t>>=j;return c}let o=[];for(;t>J;)o.push(Number(t&Fa)),t>>=qn;let s=new Array(16);s[0]=j,s[1]=n;for(let c=2;c<16;c++)s[c]=s[c-1]*n%e;let i=s[o[o.length-1]];for(let c=o.length-2;c>=0;c--){i=i*i%e,i=i*i%e,i=i*i%e,i=i*i%e;let a=o[c];a!==0&&(i=i*s[a]%e)}return i}function Z(r,t,e){if(e<=j)throw new Error("pow2: expected modulus > 1, got "+e);if(t<J)throw new Error("pow2: expected non-negative exponent, got "+t);let n=r;for(;t-- >J;)n*=n,n%=e;return n}function Cs(r,t){if(r===J)throw new Error("invert: expected non-zero number");if(t<=j)throw new Error("invert: expected modulus > 1, got "+t);let e=Y(r,t),n=t,o=J,s=j;for(;e!==J;){let c=n/e,a=n-e*c,f=o-s*c;n=e,e=a,o=s,s=f}if(n!==j)throw new Error("invert: does not exist");return Y(o,t)}function Ns(r,t){if(t<=j)throw new Error("invertCt: expected prime modulus > 1, got "+t);let e=Y(r,t);if(e===J)throw new Error("invertCt: expected non-zero number");let n=ks(e,t-zt,t);if(Y(e*n,t)!==j)throw new Error("invertCt: does not exist");return n}function Hn(r,t,e){let n=r;if(!n.eql(n.sqr(t),e))throw new Error("Cannot find square root")}function jn(r,t){if((r&j)===J)throw new Error(t+": expected odd modulus, got "+r)}function Ks(r,t){let e=r,n=(e.ORDER+j)/qn,o=e.pow(t,n);return Hn(e,o,t),o}function ka(r,t){let e=r,n=(e.ORDER-Os)/Fs,o=e.mul(t,zt),s=e.pow(o,n),i=e.mul(t,s),c=e.mul(e.mul(i,zt),s),a=e.mul(i,e.sub(c,e.ONE));return Hn(e,a,t),a}function Na(r){let t=Ee(r),e=Ms(r),n=e(t,t.neg(t.ONE)),o=e(t,n),s=e(t,t.neg(n)),i=(r+Da)/Us;return((c,a)=>{let f=c,u=f.pow(a,i),h=f.mul(u,n),b=f.mul(u,o),m=f.mul(u,s),L=f.eql(f.sqr(h),a),B=f.eql(f.sqr(b),a);u=f.cmov(u,h,L),h=f.cmov(m,b,B);let R=f.eql(f.sqr(h),a),w=f.cmov(u,h,R);return Hn(f,w,a),w})}function Ms(r){if(r<Ds)throw new Error("sqrt is not defined for small field");jn(r,"tonelliShanks");let t=r-j,e=0;for(;t%zt===J;)t/=zt,e++;let n=zt,o=Ee(r);for(;ze(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return Ks;let s=o.pow(n,t),i=(t+j)/zt;return function(a,f){let u=a;if(u.is0(f))return f;if(ze(u,f)!==1)throw new Error("Cannot find square root");let h=e,b=u.mul(u.ONE,s),m=u.pow(f,t),L=u.pow(f,i);for(;!u.eql(m,u.ONE);){if(u.is0(m))throw new Error("Cannot find square root: probably non-prime P");let B=1,R=u.sqr(m);for(;!u.eql(R,u.ONE);)if(B++,R=u.sqr(R),B===h)throw new Error("Cannot find square root");let w=j<<BigInt(h-B-1),S=u.pow(b,w);h=B,b=u.sqr(S),m=u.mul(m,b),L=u.mul(L,S)}return L}}function Ka(r){return jn(r,"Fp.sqrt"),r%qn===Ds?Ks:r%Fs===Os?ka:r%Us===Oa?Na(r):Ms(r)}var Ps=(r,t)=>(Y(r,t)&j)===j,Ma=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function we(r){if(Nt(r,"field"),typeof r.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof r.ORDER);Pt(r.BYTES,"BYTES"),Pt(r.BITS,"BITS");for(let t of Ma)Qt(r[t],"field."+t);if(r.BYTES<1||r.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(r.ORDER<=j)throw new Error("invalid field: expected ORDER > 1, got "+r.ORDER);return r}function xr(r,t,e=!1){we(r),pr(t,"nums"),it(e,"passZero");let n=r,o=new Array(t.length).fill(e?n.ZERO:void 0),s=t.reduce((c,a,f)=>n.is0(a)?c:(o[f]=c,n.mul(c,a)),n.ONE),i=n.inv(s);return t.reduceRight((c,a,f)=>n.is0(a)?c:(o[f]=n.mul(c,o[f]),n.mul(c,a)),i),o}function ze(r,t){we(r);let e=r;jn(e.ORDER,"FpLegendre");let n=(e.ORDER-j)/zt,o=e.pow(t,n),s=e.eql(o,e.ONE),i=e.eql(o,e.ZERO),c=e.eql(o,e.neg(e.ONE));if(!s&&!i&&!c)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function Pa(r,t){if(t!==void 0&&Mn(t),r<=J)throw new Error("invalid n length: expected positive n, got "+r);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let e=xe(r);if(t!==void 0&&t<e)throw new Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${e})`);let n=t!==void 0?t:e,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var Ls=new WeakMap,gr=class{ORDER;BITS;BYTES;isLE;ZERO=J;ONE=j;_lengths;_mod;constructor(t,e={}){if(t<=j)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,e!=null&&typeof e=="object"&&(typeof e.BITS=="number"&&(n=e.BITS),typeof e.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:e.sqrt,enumerable:!0}),typeof e.isLE=="boolean"&&(this.isLE=e.isLE),e.allowedLengths&&(this._lengths=Object.freeze(e.allowedLengths.slice())),typeof e.modFromBytes=="boolean"&&(this._mod=e.modFromBytes));let{nBitLength:o,nByteLength:s}=Pa(t,n);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=s,Object.freeze(this)}create(t){return Y(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return J<=t&&t<this.ORDER}is0(t){return t===J}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&j)===j}neg(t){return Y(-t,this.ORDER)}eql(t,e){return t===e}sqr(t){return Y(t*t,this.ORDER)}add(t,e){return Y(t+e,this.ORDER)}sub(t,e){return Y(t-e,this.ORDER)}mul(t,e){return Y(t*e,this.ORDER)}pow(t,e){return ks(t,e,this.ORDER)}div(t,e){return Y(t*Cs(e,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,e){return t+e}subN(t,e){return t-e}mulN(t,e){return t*e}inv(t){return Cs(t,this.ORDER)}sqrt(t){let e=Ls.get(this);return e||Ls.set(this,e=Ka(this.ORDER)),e(this,t)}toBytes(t){return this.isLE?Pn(t,this.BYTES):yr(t,this.BYTES)}fromBytes(t,e=!1){H(t);let{_lengths:n,BYTES:o,isLE:s,ORDER:i,_mod:c}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let f=new Uint8Array(o);f.set(t,s?0:f.length-t.length),t=f}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let a=s?ee(t):At(t);if(c&&(a=Y(a,i)),!e&&!this.isValid(a))throw new Error("invalid field element: outside of range 0..ORDER");return a}invertBatch(t){return xr(this,t,!0)}cmov(t,e,n){return it(n,"condition"),n?e:t}};function Ee(r,t={}){return Object.freeze(gr.prototype),new gr(r,t)}function zs(r){if(typeof r!="bigint")throw new Error("field order must be bigint");if(r<=j)throw new Error("field order must be greater than 1");let t=xe(r-j);return Math.ceil(t/8)}function wr(r){let t=zs(r);return t+Math.ceil(t/2)}function Er(r,t,e=!1){H(r);let n=r.length,o=zs(t),s=Math.max(wr(t),16);if(n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?ee(r):At(r),c=Y(i,t-j)+j;return e?Pn(c,o):yr(c,o)}var Yn=BigInt(0),qe=BigInt(1),za=BigInt(4),Vn=16,qs=128,qa=5,Hs=2**31;function qt(r){let t=r;if(typeof t!="function")throw new TypeError('"Point" expected constructor, got type='+typeof r);Qt(t.fromAffine,"Point.fromAffine"),Qt(t.fromBytes,"Point.fromBytes"),Qt(t.fromHex,"Point.fromHex"),Nt(t.BASE,"Point.BASE"),Nt(t.ZERO,"Point.ZERO"),we(t.Fp),we(t.Fn)}function Sr(r,t){qt(r),Vs(t,r);let e=xr(r.Fp,t.map(n=>n.Z));return t.map((n,o)=>r.fromAffine(n.toAffine(e[o])))}function Ha(r,t,e=1){if(!Number.isSafeInteger(r)||r<e||r>t)throw new Error("invalid window size, expected ["+e+".."+t+"], got W="+r)}function ja(r,t){let e=r*(4*t+128);if(e>Hs)throw new Error("invalid window size: table would need ~"+Math.ceil(e/2**20)+" MiB, max "+Hs/2**20+" MiB")}function $n(r,t){if(r!==void 0){Qt(r,"randomBytes");try{let e=r(t);if(!Mt(e)||e.length!==t)return}catch{return}return r}}function Vs(r,t){pr(r,"points"),r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function Va(r,t,e){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((n,o)=>{if(!(e===void 0?t.isValid(n):Kt(n)&&n<e))throw new Error("invalid scalar at index "+o)})}var Zs=new WeakMap;function Zn(r){return Zs.get(r)||1}function Za(r,t){let e=r.double(),n=[r];for(let o=1;o<t;o++)n.push(n[o-1].add(e));return n}function Ya(r,t){let e=2**t,n=e/2,o=BigInt(e-1),s=[];for(;r>Yn;){let i=0;r&qe&&(i=Number(r&o),i>=n&&(i-=e),r-=BigInt(i)),s.push(i),r>>=qe}return s}function $a(r,t,e){let n=2**t,o=n/2,s=BigInt(n-1),i=BigInt(t),c=[];for(let a=0;a<e;a++){let f=Number(r&s);r>>=i,f>o&&(f-=n,r+=qe),c.push(f)}if(r!==Yn)throw new Error("invalid wnaf");return c}function Ga(r,t,e){let n=0;for(let s of e)n=Math.max(n,s.length);let o=r;for(let s=n-1;s>=0;s--){s!==n-1&&(o=o.double());for(let i=0;i<e.length;i++){let c=e[i][s];if(c){let a=t[i][Math.abs(c)-1>>1];o=o.add(c<0?a.negate():a)}}}return o}var Se=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(t,e){qt(t),this.randomBytes=$n(e,Vn),this.Point=t,this.BASE=t.BASE,this.ZERO=t.ZERO,this.bits=t.Fn.BITS}buildWnafTable(t,e,n){let o=Math.ceil(n/e)+1,s=2**(e-1),i=[],c=t;for(let a=0;a<o;a++){let f=c;for(let u=0;u<s;u++)i.push(f),f=f.add(c);c=i[i.length-1].double()}return{W:e,bits:n,windows:o,comp:i}}wnafCachedCT(t,e){let{W:n,windows:o,comp:s}=t,i=2**(n-1),c=$a(e,n,o),a=this.ZERO,f=this.BASE;for(let u=0;u<o;u++){let h=c[u],b=u*i,m=Math.abs(h)-1,L=s[b];for(let R=1;R<i;R++)L=R===m?s[b+R]:L;let B=L.negate();h===0?f=f.add(s[b]):a=a.add(h<0?B:L)}return{p:a,f}}getWnafPrecomputes(t,e,n,o){let s=this.wnafPrecomputes.get(e),i=s?.find(c=>c.W===t&&c.bits===n);return i||(i=this.buildWnafTable(e,t,n),typeof o=="function"&&(i={...i,comp:o(i.comp)}),s||(s=[],this.wnafPrecomputes.set(e,s)),s.push(i)),i}assertPoint(t){if(!(t instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof t)}validateMulInput(t,e){if(this.assertPoint(t),!zn(e,qe,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(t,e,n,o){let s=Zn(t);return s===1?this.fixedWindowCT(t,e,n):this.wnafCachedCT(this.getWnafPrecomputes(s,t,n,o),e)}mulCT(t,e,n){return this.validateMulInput(t,e),this.runCT(t,e,this.bits,n)}mulCTBlinded(t,e,n){if(this.validateMulInput(t,e),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let o=this.Point.Fn.BITS+qs,s=this.randomBytes(Vn);if(!Mt(s)||s.length!==Vn)throw new Error("randomBytes returned invalid byte array");s[0]=s[0]&63|128;let i=e+At(s)*this.Point.Fn.ORDER;return this.runCT(t,i,o,n)}fixedWindowCT(t,e,n){let o=qa,s=1<<o,i=Pe(o),c=new Array(s);c[0]=this.ZERO;for(let u=1;u<s;u++)c[u]=c[u-1].add(t);let a=Math.ceil(n/o),f=this.ZERO;for(let u=a-1;u>=0;u--){if(u!==a-1)for(let m=0;m<o;m++)f=f.double();let h=Number(e>>BigInt(u*o)&i),b=c[0];for(let m=1;m<s;m++)b=m===h?c[m]:b;f=f.add(b)}return{p:f,f}}shouldBlind(t,e){return this.randomBytes===void 0?!1:e===qe?!0:t!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(t,e,n,o){return this.shouldBlind(t,n)?this.mulCTBlinded(t,e,o):this.mulCT(t,e,o)}mulUnsafe(t,e,n){if(this.assertPoint(t),!Kt(e))throw new Error("invalid scalar");let o=Zn(t);if(o===1||e>=this.Point.Fn.ORDER)return _r(this.Point,[t],[e],!0);let s=this.getWnafPrecomputes(o,t,this.bits,n);return this.wnafCachedCT(s,e).p}setWindowSize(t,e){this.assertPoint(t),Ha(e,this.bits);let n=Math.ceil((this.bits+qs)/e)+1;ja(n*2**(e-1),this.Point.Fp.BYTES),Zs.set(t,e),this.wnafPrecomputes.delete(t)}hasWindowSize(t){return Zn(t)!==1}};function _r(r,t,e,n=!1){if(qt(r),Vs(t,r),it(n,"allowOversized"),Va(e,r.Fn,n?r.Fn.ORDER**za:void 0),t.length!==e.length)throw new Error("arrays of points and scalars must have equal length");let o=t.map(i=>Za(i,4)),s=e.map(i=>Ya(i,4));return Ga(r.ZERO,o,s)}function js(r,t,e){if(t){if(t.ORDER!==r)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return we(t),t}else return Ee(r,{isLE:e})}function Br(r,t,e={},n){if(r!=="weierstrass"&&r!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(n===void 0&&(n=r==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${r} CURVE object`);ct(e);for(let a of["p","n","h"]){let f=t[a];if(!(Kt(f)&&f!==Yn))throw new Error(`CURVE.${a} must be positive bigint`)}let o=js(t.p,e.Fp,n),s=js(t.n,e.Fn,n),c=["Gx","Gy","a",r==="weierstrass"?"b":"d"];for(let a of c)if(!o.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:s}}function Ar(r,t){return function(n){let o=r(n);return{secretKey:o,publicKey:t(o)}}}var vr=BigInt(0),Ir=BigInt(1),Tr=BigInt(2),Xa=BigInt(4),Ys=BigInt(8);function Wa(r,t,e,n){let o=r.sqr(e),s=r.sqr(n),i=r.add(r.mul(t.a,o),s),c=r.add(r.ONE,r.mul(t.d,r.mul(o,s)));return r.eql(i,c)}function $s(r,t={}){ct(t,{},{},"extraOpts");let e=t,n=Br("edwards",r,e,e.FpFnLE),{Fp:o,Fn:s}=n,i=n.CURVE,{h:c}=i;if(ze(o,i.a)!==1)throw new Error("edwards: CURVE.a must be a square in Fp for complete addition formulas");if(ze(o,i.d)!==-1)throw new Error("edwards: CURVE.d must be a non-square in Fp for complete addition formulas");ct(e,{},{uvRatio:"function",randomBytes:"function"});let a=e.randomBytes===void 0?te:e.randomBytes,f=Tr<<BigInt(o.BYTES*8)-Ir;function u(S){if(!o.isOdd)throw new Error("Field does not have .isOdd()");return o.isOdd(S)}let h=e.uvRatio===void 0?(S,p)=>{try{return{isValid:!0,value:o.sqrt(o.div(S,p))}}catch{return{isValid:!1,value:vr}}}:e.uvRatio;if(!Wa(o,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");let b=o.eql(i.a,o.neg(o.ONE))?S=>o.neg(S):o.eql(i.a,o.ONE)?S=>S:S=>o.mul(i.a,S);function m(S,p,_=!1){let A=_?Ir:vr;return ge("coordinate "+S,p,A,f),p}function L(S){if(!(S instanceof B))throw new Error("EdwardsPoint expected")}class B{static BASE=new B(i.Gx,i.Gy,o.ONE,o.mul(i.Gx,i.Gy));static ZERO=new B(o.ZERO,o.ONE,o.ONE,o.ZERO);static Fp=o;static Fn=s;X;Y;Z;T;constructor(p,_,A,K){this.X=m("x",p),this.Y=m("y",_),this.Z=m("z",A,!0),this.T=m("t",K),Object.freeze(this)}static CURVE(){return i}static fromAffine(p){if(p instanceof B)throw new Error("extended point not allowed");let{x:_,y:A}=p||{};return m("x",_),m("y",A),new B(_,A,o.ONE,o.mul(_,A))}static fromBytes(p,_=!1){let A=o.BYTES,{a:K,d:M}=i;p=br(H(p,A,"point")),it(_,"zip215");let U=br(p),O=p[A-1];U[A-1]=O&-129;let F=ee(U),P=_?f:o.ORDER;ge("point.y",F,vr,P);let C=o.sqr(F),V=o.sub(C,o.ONE),T=o.sub(o.mulN(M,C),K),{isValid:I,value:l}=h(V,T);if(!I)throw new Error("bad point: invalid y coordinate");let y=u(l),x=(O&128)!==0;if(!_&&o.is0(l)&&x)throw new Error("bad point: x=0 and x_0=1");return x!==y&&(l=o.neg(l)),B.fromAffine({x:l,y:F})}static fromHex(p,_=!1){return B.fromBytes(be(p),_)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(p=6,_=!0){return w.setWindowSize(this,p),_||this.multiply(Tr),this}assertValidity(){let p=this,{a:_,d:A}=i;if(p.is0())throw new Error("bad point: ZERO");let{X:K,Y:M,Z:U,T:O}=p,F=o.sqr(K),P=o.sqr(M),C=o.sqr(U),V=o.sqr(C),T=o.mul(F,_),I=o.mul(o.add(T,P),C),l=o.add(V,o.mul(A,o.mul(F,P)));if(!o.eql(I,l))throw new Error("bad point: equation left != right (1)");let y=o.mul(K,M),x=o.mul(U,O);if(!o.eql(y,x))throw new Error("bad point: equation left != right (2)")}equals(p){L(p);let{X:_,Y:A,Z:K}=this,{X:M,Y:U,Z:O}=p,F=o.mul(_,O),P=o.mul(M,K),C=o.mul(A,O),V=o.mul(U,K);return o.eql(F,P)&&o.eql(C,V)}is0(){return this.equals(B.ZERO)}negate(){return new B(o.neg(this.X),this.Y,this.Z,o.neg(this.T))}double(){let{X:p,Y:_,Z:A}=this,K=o.sqr(p),M=o.sqr(_),U=o.mul(o.sqr(A),Tr),O=b(K),F=o.addN(p,_),P=o.sub(o.subN(o.sqr(F),K),M),C=o.addN(O,M),V=o.subN(C,U),T=o.subN(O,M),I=o.mul(P,V),l=o.mul(C,T),y=o.mul(P,T),x=o.mul(V,C);return new B(I,l,x,y)}add(p){L(p);let{d:_}=i,{X:A,Y:K,Z:M,T:U}=this,{X:O,Y:F,Z:P,T:C}=p,V=o.mul(A,O),T=o.mul(K,F),I=o.mul(o.mulN(U,_),C),l=o.mul(M,P),y=o.sub(o.subN(o.mulN(o.addN(A,K),o.addN(O,F)),V),T),x=o.subN(l,I),D=o.addN(l,I),g=o.sub(T,b(V)),d=o.mul(y,x),E=o.mul(D,g),v=o.mul(y,g),k=o.mul(x,D);return new B(d,E,k,v)}subtract(p){return L(p),this.add(p.negate())}multiply(p){if(!s.isValidNot0(p))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:_,f:A}=w.mulSecret(this,p,c,R);return R([_,A])[0]}multiplyUnsafe(p){if(!s.isValid(p))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return p===vr?B.ZERO:this.is0()||p===Ir?this:w.mulUnsafe(this,p,R)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return w.mulUnsafe(this,i.n).is0()}toAffine(p){let _=this,A=p;if(A!=null&&typeof A!="bigint")throw new TypeError('"invertedZ" expected bigint, got type='+typeof A);let{X:K,Y:M,Z:U}=_,O=_.is0();A==null&&(A=O?o.create(Ys):o.inv(U));let F=o.mul(K,A),P=o.mul(M,A),C=o.mul(U,A);if(O)return{x:o.ZERO,y:o.ONE};if(!o.eql(C,o.ONE))throw new Error("invZ was invalid");return{x:F,y:P}}clearCofactor(){return c===Ir?this:c===Tr?this.double():c===Xa?this.double().double():c===Ys?this.double().double().double():this.multiplyUnsafe(c)}toBytes(){let{x:p,y:_}=this.toAffine(),A=o.toBytes(_);return A[A.length-1]|=u(p)?128:0,A}toHex(){return Ke(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let R=S=>Sr(B,S),w=new Se(B,a);return w.bits>=6&&B.BASE.precompute(6),Object.freeze(B.prototype),Object.freeze(B),B}function Gs(r,t,e={}){if(qt(r),typeof t!="function")throw new Error('"hash" function param is required');let n=t,o=e;ct(o,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",zip215:"boolean",mapToCurve:"function",toMontgomery:"function",toMontgomerySecret:"function"});let{prehash:s}=o,{BASE:i,Fp:c,Fn:a}=r,f=n.outputLen,u=2*c.BYTES;if(f!==void 0&&(Pt(f,"hash.outputLen"),f!==u))throw new Error(`hash.outputLen must be ${u}, got ${f}`);let h=o.randomBytes===void 0?te:o.randomBytes,b=o.toMontgomery,m=o.toMontgomerySecret,L=o.adjustScalarBytes===void 0?T=>T:o.adjustScalarBytes,B=o.domain===void 0?(T,I,l)=>{if(it(l,"phflag"),I.length||l)throw new Error("Contexts/pre-hash are not supported");return T}:o.domain;function R(T){return a.create(ee(T))}function w(T){let I=O.secretKey;H(T,O.secretKey,"secretKey");let l=H(n(T),2*I,"hashedSecretKey"),y=L(l.slice(0,I)),x=l.slice(I,2*I),D=R(y);return{head:y,prefix:x,scalar:D}}function S(T){let{head:I,prefix:l,scalar:y}=w(T),x=i.multiply(y),D=x.toBytes();return{head:I,prefix:l,scalar:y,point:x,pointBytes:D}}function p(T){return S(T).pointBytes}function _(T=Uint8Array.of(),...I){let l=yt(...I);return R(n(B(l,H(T,void 0,"context"),!!s)))}function A(T,I,l={}){ct(l,{},{},"options"),T=H(T,void 0,"message"),s&&(T=s(T));let{prefix:y,scalar:x,pointBytes:D}=S(I),g=_(l.context,y,T),d=i.multiply(g).toBytes(),E=_(l.context,d,D,T),v=a.create(g+E*x);if(!a.isValid(v))throw new Error("sign failed: invalid s");let k=yt(d,a.toBytes(v));return H(k,O.signature,"result")}let K={zip215:o.zip215};function M(T,I,l,y=K){ct(y);let{context:x}=y,D=y.zip215===void 0?!!K.zip215:y.zip215,g=O.signature;T=H(T,g,"signature"),I=H(I,void 0,"message"),l=H(l,O.publicKey,"publicKey"),D!==void 0&&it(D,"zip215"),s&&(I=s(I));let d=g/2,E=T.subarray(0,d),v=ee(T.subarray(d,g)),k,N,q;try{k=r.fromBytes(l,D),N=r.fromBytes(E,D),q=i.multiplyUnsafe(v)}catch{return!1}if(!D&&k.isSmallOrder())return!1;let z=_(x,E,l,I);return N.add(k.multiplyUnsafe(z)).subtract(q).clearCofactor().is0()}let U=c.BYTES,O={secretKey:U,publicKey:U,signature:2*U,seed:U};function F(T){return T=T===void 0?h(O.seed):T,H(T,O.seed,"seed")}function P(T){return Mt(T)&&T.length===O.secretKey}function C(T,I){try{return!!r.fromBytes(T,I===void 0?K.zip215:I)}catch{return!1}}let V={getExtendedPublicKey:S,randomSecretKey:F,isValidSecretKey:P,isValidPublicKey:C,toMontgomery(T){if(b===void 0)throw new Error("Montgomery conversion is not supported for this curve");return b(r.fromBytes(T))},toMontgomerySecret(T){if(m===void 0)throw new Error("Montgomery conversion is not supported for this curve");return m(T)}};return Object.freeze(O),Object.freeze(V),Object.freeze({keygen:Ar(F,p),getPublicKey:p,sign:A,verify:M,utils:V,Point:r,lengths:O})}var Gn=BigInt(1),Xs=BigInt(2);var Ja=BigInt(5),Qa=BigInt(8),Xn=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),tf={p:Xn,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Qa,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function ef(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=Xn,c=r*r%s*r%s,a=Z(c,Xs,s)*c%s,f=Z(a,Gn,s)*r%s,u=Z(f,Ja,s)*f%s,h=Z(u,t,s)*u%s,b=Z(h,e,s)*h%s,m=Z(b,n,s)*b%s,L=Z(m,o,s)*m%s,B=Z(L,o,s)*m%s,R=Z(B,t,s)*u%s;return{pow_p_5_8:Z(R,Xs,s)*r%s,b2:c}}function Qs(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}var Ws=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function rf(r,t){let e=Xn,n=Y(t*t*t,e),o=Y(n*n*t,e),s=ef(r*o).pow_p_5_8,i=Y(r*n*s,e),c=Y(t*i*i,e),a=i,f=Y(i*Ws,e),u=c===r,h=c===Y(-r,e),b=c===Y(-r*Ws,e);return u&&(i=a),(h||b)&&(i=f),Ps(i,e)&&(i=Y(-i,e)),{isValid:u||h,value:i}}var Wn=$s(tf,{uvRatio:rf}),Js=Wn.Fp;function nf(r){let{y:t}=r;return Js.toBytes(Js.div(Gn+t,Gn-t))}function of(r){let t=Wn.Fp.BYTES;return mt(r,t),Qs(Kn(r.subarray(0,t))).subarray(0,t)}function sf(r){return Gs(Wn,Kn,Object.assign({adjustScalarBytes:Qs,toMontgomery:nf,toMontgomerySecret:of,zip215:!0},r))}var ti=sf({});var He=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Rr=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Cr={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new Rr("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 Lr=32;var Jn,cf=(async()=>{try{return await Cr.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function af(r,t,e){if(r.buffer instanceof ArrayBuffer){let n=await Cr.get().subtle.importKey("raw",r.buffer,{name:"Ed25519"},!1,["verify"]);return await Cr.get().subtle.verify({name:"Ed25519"},n,Ot(t),Ot(e instanceof Uint8Array?e:e.subarray()))}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function ff(r,t,e){return ti.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}async function ei(r,t,e){return Jn==null&&(Jn=await cf),Jn?af(r,t,e):ff(r,t,e)}function Dr(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var Or=class{type="Ed25519";raw;constructor(t){this.raw=Qn(t,Lr)}toMultihash(){return bt.digest(me(this))}toCID(){return st.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ft(this.raw,t.raw)}verify(t,e,n){n?.signal?.throwIfAborted();let o=ei(this.raw,e,t);return Dr(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function ni(r){return r=Qn(r,Lr),new Or(r)}function Qn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new It(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var hf=Math.pow(2,7),lf=Math.pow(2,14),df=Math.pow(2,21),oi=Math.pow(2,28),si=Math.pow(2,35),ii=Math.pow(2,42),ci=Math.pow(2,49),nt=128,Ht=127;function je(r){if(r<hf)return 1;if(r<lf)return 2;if(r<df)return 3;if(r<oi)return 4;if(r<si)return 5;if(r<ii)return 6;if(r<ci)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ai(r,t,e=0){switch(je(r)){case 8:t[e++]=r&255|nt,r/=128;case 7:t[e++]=r&255|nt,r/=128;case 6:t[e++]=r&255|nt,r/=128;case 5:t[e++]=r&255|nt,r/=128;case 4:t[e++]=r&255|nt,r>>>=7;case 3:t[e++]=r&255|nt,r>>>=7;case 2:t[e++]=r&255|nt,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function fi(r,t){let e=r[t],n=0;if(n+=e&Ht,e<nt||(e=r[t+1],n+=(e&Ht)<<7,e<nt)||(e=r[t+2],n+=(e&Ht)<<14,e<nt)||(e=r[t+3],n+=(e&Ht)<<21,e<nt)||(e=r[t+4],n+=(e&Ht)*oi,e<nt)||(e=r[t+5],n+=(e&Ht)*si,e<nt)||(e=r[t+6],n+=(e&Ht)*ii,e<nt)||(e=r[t+7],n+=(e&Ht)*ci,e<nt))return n;throw new RangeError("Could not decode varint")}var to=new Float32Array([-0]),jt=new Uint8Array(to.buffer);function ui(r,t,e){to[0]=r,t[e]=jt[0],t[e+1]=jt[1],t[e+2]=jt[2],t[e+3]=jt[3]}function hi(r,t){return jt[0]=r[t],jt[1]=r[t+1],jt[2]=r[t+2],jt[3]=r[t+3],to[0]}var eo=new Float64Array([-0]),et=new Uint8Array(eo.buffer);function li(r,t,e){eo[0]=r,t[e]=et[0],t[e+1]=et[1],t[e+2]=et[2],t[e+3]=et[3],t[e+4]=et[4],t[e+5]=et[5],t[e+6]=et[6],t[e+7]=et[7]}function di(r,t){return et[0]=r[t],et[1]=r[t+1],et[2]=r[t+2],et[3]=r[t+3],et[4]=r[t+4],et[5]=r[t+5],et[6]=r[t+6],et[7]=r[t+7],eo[0]}var pf=BigInt(Number.MAX_SAFE_INTEGER),mf=BigInt(Number.MIN_SAFE_INTEGER),lt=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return re;if(t<pf&&t>mf)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>pi&&(o=0n,++n>pi&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return re;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):re}},re=new lt(0,0);re.toBigInt=function(){return 0n};re.zzEncode=re.zzDecode=function(){return this};re.length=function(){return 1};var pi=4294967296n;function mi(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function yi(r,t,e){if(e-t<1)return"";let o,s=[],i=0,c;for(;t<e;)c=r[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function ro(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function wt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Fr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var no=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=Ot(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,wt(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 wt(this,4);return Fr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw wt(this,4);return Fr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw wt(this,4);let t=hi(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw wt(this,4);let t=di(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw wt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,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 wt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw wt(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 lt(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw wt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw wt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw wt(this,8);let t=Fr(this.buf,this.pos+=4),e=Fr(this.buf,this.pos+=4);return new lt(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=fi(this.buf,this.pos);return this.pos+=je(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 Ve(r){return new no(r instanceof Uint8Array?r:r.subarray())}function Ur(r,t,e){let n=Ve(r);return t.decode(n,void 0,e)}function oo(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return ut(i);o+i>t&&(n=ut(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var ne=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function so(){}var co=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},yf=oo();function bf(r){return globalThis.Buffer!=null?ut(r):yf(r)}var Ye=class{len;head;tail;states;constructor(){this.len=0,this.head=new ne(so,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ne(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new ao((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(kr,10,lt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=lt.fromBigInt(t);return this._push(kr,e.length(),e)}uint64Number(t){return this._push(ai,je(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=lt.fromBigInt(t).zzEncode();return this._push(kr,e.length(),e)}sint64Number(t){let e=lt.fromNumber(t).zzEncode();return this._push(kr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(io,1,t?1:0)}fixed32(t){return this._push(Ze,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=lt.fromBigInt(t);return this._push(Ze,4,e.lo)._push(Ze,4,e.hi)}fixed64Number(t){let e=lt.fromNumber(t);return this._push(Ze,4,e.lo)._push(Ze,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(ui,4,t)}double(t){return this._push(li,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(io,1,0):this.uint32(e)._push(xf,e,t)}string(t){let e=mi(t);return e!==0?this.uint32(e)._push(ro,e,t):this._push(io,1,0)}fork(){return this.states=new co(this),this.head=this.tail=new ne(so,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new ne(so,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=bf(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function io(r,t,e){t[e]=r&255}function gf(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var ao=class extends ne{next;constructor(t,e){super(gf,t,e),this.next=void 0}};function kr(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Ze(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function xf(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Ye.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(wf,t,r),this},Ye.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Ef,t,r),this});function wf(r,t,e){t.set(r,e)}function Ef(r,t,e){r.length<40?ro(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Q(r),e)}function fo(){return new Ye}function Nr(r,t){let e=fo();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}function*Kr(r,t,e){let n=Ve(r);yield*t.stream(n,void 0,"$",e)}var Mr={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function Pr(r,t,e,n,o){return{name:r,type:t,encode:e,decode:n,stream:o}}function uo(r){function t(s){if(r[s.toString()]==null)throw new Error("Invalid enum value");return r[s]}let e=function(i,c){let a=t(i);c.int32(a)},n=function(i){let c=i.int32();return t(c)},o=function*(i){let c=i.int32();yield t(c)};return Pr("enum",Mr.VARINT,e,n,o)}function zr(r,t,e){return Pr("message",Mr.LENGTH_DELIMITED,r,t,e)}var ot;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(ot||(ot={}));var ho;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(ho||(ho={}));(function(r){r.codec=()=>uo(ho)})(ot||(ot={}));var $e;(function(r){let t;r.codec=()=>(t==null&&(t=zr((s,i,c={})=>{c.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),ot.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),c.lengthDelimited!==!1&&i.ldelim()},(s,i,c={})=>{let a={},f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{a.Type=ot.codec().decode(s);break}case 2:{a.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return a},function*(s,i,c,a={}){let f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${c}.Type`,value:ot.codec().decode(s)};break}case 2:{yield{field:`${c}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function e(s){return Nr(s,r.codec())}r.encode=e;function n(s,i){return Ur(s,r.codec(),i)}r.decode=n;function o(s,i){return Kr(s,r.codec(),i)}r.stream=o})($e||($e={}));var lo;(function(r){let t;r.codec=()=>(t==null&&(t=zr((s,i,c={})=>{c.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),ot.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),c.lengthDelimited!==!1&&i.ldelim()},(s,i,c={})=>{let a={},f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{a.Type=ot.codec().decode(s);break}case 2:{a.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return a},function*(s,i,c,a={}){let f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${c}.Type`,value:ot.codec().decode(s)};break}case 2:{yield{field:`${c}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function e(s){return Nr(s,r.codec())}r.encode=e;function n(s,i){return Ur(s,r.codec(),i)}r.decode=n;function o(s,i){return Kr(s,r.codec(),i)}r.stream=o})(lo||(lo={}));var qr=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,e){if(ar(t),mt(e,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(e.length>n?t.create().update(e).digest():e);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=t.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),Jt(o)}update(t){return ye(this),this.iHash.update(t),this}digestInto(t){ye(this),fr(t,this),this.finished=!0;let e=t.subarray(0,this.outputLen);this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c,canXOF:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.canXOF=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},gi=(()=>{let r=((t,e,n)=>new qr(t,e).update(n).digest());return r.create=(t,e)=>new qr(t,e),r})();var _f=BigInt(0),po=class extends Error{constructor(t=""){super(t)}},Rt={Err:po,_tlv:{encode:(r,t)=>{let{Err:e}=Rt;if(Pt(r,"tag"),r<0||r>255)throw new e("tlv.encode: wrong tag");if(Is(t,"data"),t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=Me(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Me(o.length/2|128):"";return Me(r)+s+o+t},decode(r,t){let{Err:e}=Rt;t=H(t,void 0,"DER data");let n=0;if(r<0||r>255)throw new e("tlv.decode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let a=o&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+a);if(f.length!==a)throw new e("tlv.decode: length bytes not complete");if(f[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of f)i=i<<8|u;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Rt;if(mr(r),r<_f)throw new t("integer: negative integers are not allowed");let e=Me(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=Rt;if(r.length<1)throw new t("invalid signature integer: empty");if(r[0]&128)throw new t("invalid signature integer: negative");if(r.length>1&&r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return At(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Rt,o=H(r,void 0,"signature"),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:f,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(f)}},hexFromSig(r){let{_tlv:t,_int:e}=Rt;ct(r,{r:"bigint",s:"bigint"},{},"sig");let n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},mo=(Object.freeze(Rt._tlv),Object.freeze(Rt._int),Object.freeze(Rt));var xi=(r,t)=>(r+(r>=0?t:-t)/wi)/t;function Bf(r,t,e){ge("scalar",r,Ct,e);let[[n,o],[s,i]]=t,c=xi(i*r,e),a=xi(-o*r,e),f=r-c*n-a*s,u=-c*o-a*i,h=f<Ct,b=u<Ct;h&&(f=-f),b&&(u=-u);let m=Pe(Math.ceil(xe(e)/2))+oe;if(f<Ct||f>=m||u<Ct||u>=m)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:h,k1:f,k2neg:b,k2:u}}function go(r){if(!["compact","recovered","der"].includes(r))throw new Error('Signature format must be "compact", "recovered", or "der"');return r}function yo(r,t){ct(r);let e={};for(let n of Object.keys(t))e[n]=r[n]===void 0?t[n]:r[n];return it(e.lowS,"lowS"),it(e.prehash,"prehash"),e.format!==void 0&&go(e.format),e}var Ct=BigInt(0),oe=BigInt(1),wi=BigInt(2),bo=BigInt(3),Af=BigInt(4);function Ei(r,t={}){let e=Br("weierstrass",r,t),n=e.Fp,o=e.Fn,s=e.CURVE,{h:i,n:c}=s;ct(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:a,allowInfinityPoint:f}=t,u=t.randomBytes===void 0?te:t.randomBytes;if(a&&(!n.is0(s.a)||typeof a.beta!="bigint"||!Array.isArray(a.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let h=_i(n,o);function b(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function m(I,l,y){if(f&&l.is0())return Uint8Array.of(0);let{x,y:D}=l.toAffine(),g=n.toBytes(x);if(it(y,"isCompressed"),y){b();let d=!n.isOdd(D);return yt(Si(d),g)}else return yt(Uint8Array.of(4),g,n.toBytes(D))}function L(I){H(I,void 0,"Point");let{publicKey:l,publicKeyUncompressed:y}=h,x=I.length,D=I[0],g=I.subarray(1);if(f&&x===1&&D===0)return{x:n.ZERO,y:n.ZERO};if(x===l&&(D===2||D===3)){let d=n.fromBytes(g);if(!n.isValid(d))throw new Error("bad point: is not on curve, wrong x");let E=p(d),v;try{v=n.sqrt(E)}catch(q){let z=q instanceof Error?": "+q.message:"";throw new Error("bad point: is not on curve, sqrt error"+z)}b();let k=n.isOdd(v);return(D&1)===1!==k&&(v=n.neg(v)),{x:d,y:v}}else if(x===y&&D===4){let d=n.BYTES,E=n.fromBytes(g.subarray(0,d)),v=n.fromBytes(g.subarray(d,d*2));if(!_(E,v))throw new Error("bad point: is not on curve");return{x:E,y:v}}else throw new Error(`bad point: got length ${x}, expected compressed=${l} or uncompressed=${y}`)}let B=t.toBytes===void 0?m:t.toBytes,R=t.fromBytes===void 0?L:t.fromBytes,w=n.mul(s.b,bo),S=n.is0(s.a)?I=>n.ZERO:I=>n.mul(s.a,I);function p(I){let l=n.sqr(I),y=n.mul(l,I);return n.add(n.add(y,n.mul(I,s.a)),s.b)}function _(I,l){let y=n.sqr(l),x=p(I);return n.eql(y,x)}if(!_(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let A=n.mul(n.pow(s.a,bo),Af),K=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(A,K)))throw new Error("bad curve params: a or b");function M(I,l,y=!1){if(!n.isValid(l)||y&&n.is0(l))throw new Error(`bad point coordinate ${I}`);return l}function U(I){if(!(I instanceof C))throw new Error("Weierstrass Point expected")}function O(I){if(!a||!a.basises)throw new Error("no endo");return Bf(I,a.basises,o.ORDER)}function F(I,l,y,x){if(!o.isValid(x))throw new RangeError("invalid scalar: out of range");if(a){let{k1neg:D,k1:g,k2neg:d,k2:E}=O(x),v=new C(n.mul(y.X,a.beta),y.Y,y.Z);I.push(D?y.negate():y,d?v.negate():v),l.push(g,E)}else I.push(y),l.push(x)}let P=new WeakSet;class C{static BASE=new C(s.Gx,s.Gy,n.ONE);static ZERO=new C(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(l,y,x){this.X=M("x",l),this.Y=M("y",y,!0),this.Z=M("z",x),Object.freeze(this)}static CURVE(){return s}static fromAffine(l){let{x:y,y:x}=l||{};if(!l||!n.isValid(y)||!n.isValid(x))throw new Error("invalid affine point");if(l instanceof C)throw new Error("projective point not allowed");return n.is0(y)&&n.is0(x)?C.ZERO:new C(y,x,n.ONE)}static fromBytes(l){let y=C.fromAffine(R(H(l,void 0,"point")));return y.assertValidity(),y}static fromHex(l){return C.fromBytes(be(l))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(l=6,y=!0){return T.setWindowSize(this,l),y||this.multiply(bo),this}assertValidity(){let l=this;if(l.is0()){if(t.allowInfinityPoint&&n.is0(l.X)&&n.eql(l.Y,n.ONE)&&n.is0(l.Z))return;throw new Error("bad point: ZERO")}if(P.has(l))return;let{x:y,y:x}=l.toAffine();if(!n.isValid(y)||!n.isValid(x))throw new Error("bad point: x or y not field elements");if(!_(y,x))throw new Error("bad point: equation left != right");if(!l.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");P.add(l)}hasEvenY(){let{y:l}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(l)}equals(l){U(l);let{X:y,Y:x,Z:D}=this,{X:g,Y:d,Z:E}=l,v=n.eql(n.mul(y,E),n.mul(g,D)),k=n.eql(n.mul(x,E),n.mul(d,D));return v&&k}negate(){return new C(this.X,n.neg(this.Y),this.Z)}double(){let{X:l,Y:y,Z:x}=this,D=n.ZERO,g=n.ZERO,d=n.ZERO,E=n.mul(l,l),v=n.mul(y,y),k=n.mul(x,x),N=n.mul(l,y);return N=n.add(N,N),d=n.mul(l,x),d=n.add(d,d),D=S(d),g=n.mul(w,k),g=n.add(D,g),D=n.sub(v,g),g=n.add(v,g),g=n.mul(D,g),D=n.mul(N,D),d=n.mul(w,d),k=S(k),N=n.sub(E,k),N=S(N),N=n.add(N,d),d=n.add(E,E),E=n.add(d,E),E=n.add(E,k),E=n.mul(E,N),g=n.add(g,E),k=n.mul(y,x),k=n.add(k,k),E=n.mul(k,N),D=n.sub(D,E),d=n.mul(k,v),d=n.add(d,d),d=n.add(d,d),new C(D,g,d)}add(l){U(l);let{X:y,Y:x,Z:D}=this,{X:g,Y:d,Z:E}=l,v=n.ZERO,k=n.ZERO,N=n.ZERO,q=n.mul(y,g),z=n.mul(x,d),$=n.mul(D,E),rt=n.add(y,x),G=n.add(g,d);rt=n.mul(rt,G),G=n.add(q,z),rt=n.sub(rt,G),G=n.add(y,D);let tt=n.add(g,E);return G=n.mul(G,tt),tt=n.add(q,$),G=n.sub(G,tt),tt=n.add(x,D),v=n.add(d,E),tt=n.mul(tt,v),v=n.add(z,$),tt=n.sub(tt,v),N=S(G),v=n.mul(w,$),N=n.add(v,N),v=n.sub(z,N),N=n.add(z,N),k=n.mul(v,N),z=n.add(q,q),z=n.add(z,q),$=S($),G=n.mul(w,G),z=n.add(z,$),$=n.sub(q,$),$=S($),G=n.add(G,$),q=n.mul(z,G),k=n.add(k,q),q=n.mul(tt,G),v=n.mul(rt,v),v=n.sub(v,q),q=n.mul(rt,z),N=n.mul(tt,N),N=n.add(N,q),new C(v,k,N)}subtract(l){return U(l),this.add(l.negate())}is0(){return this.equals(C.ZERO)}multiply(l){if(!o.isValidNot0(l))throw new RangeError("invalid scalar: out of range");let{p:y,f:x}=T.mulSecret(this,l,i,V);return V([y,x])[0]}multiplyUnsafe(l){let y=this,x=l;if(!o.isValid(x))throw new RangeError("invalid scalar: out of range");if(x===Ct||y.is0())return C.ZERO;if(x===oe)return y;if(T.hasWindowSize(this))return T.mulUnsafe(y,x,V);let D=[],g=[];return F(D,g,y,x),_r(C,D,g)}mulAddUnsafe(l,y,x){U(y);let D=[],g=[];return F(D,g,this,l),F(D,g,y,x),_r(C,D,g)}toAffine(l){let y=this,x=l;if(x!=null&&!n.isValid(x))throw new RangeError('"invertedZ" expected valid field element');let{X:D,Y:g,Z:d}=y;if(n.eql(d,n.ONE))return{x:D,y:g};let E=y.is0();x==null&&(x=E?n.ONE:n.inv(d));let v=n.mul(D,x),k=n.mul(g,x),N=n.mul(d,x);if(E)return{x:n.ZERO,y:n.ZERO};if(!n.eql(N,n.ONE))throw new Error("invZ was invalid");return{x:v,y:k}}isTorsionFree(){let{isTorsionFree:l}=t;return i===oe?!0:l?l(C,this):T.mulUnsafe(this,c).is0()}clearCofactor(){let{clearCofactor:l}=t;return i===oe?this:l?l(C,this):this.multiplyUnsafe(i)}isSmallOrder(){return i===oe?this.is0():this.clearCofactor().is0()}toBytes(l=!0){return it(l,"isCompressed"),this.assertValidity(),B(C,this,l)}toHex(l=!0){return Ke(this.toBytes(l))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let V=I=>Sr(C,I),T=new Se(C,u);return T.bits>=6&&C.BASE.precompute(6),Object.freeze(C.prototype),Object.freeze(C),C}function Si(r){return Uint8Array.of(r?2:3)}function _i(r,t){return{secretKey:t.BYTES,publicKey:1+r.BYTES,publicKeyUncompressed:1+2*r.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function vf(r,t={}){qt(r);let{Fn:e}=r,n=t.randomBytes===void 0?te:t.randomBytes,o=Object.assign(_i(r.Fp,e),{seed:Math.max(wr(e.ORDER),16)});function s(m){try{let L=e.fromBytes(m);return e.isValidNot0(L)}catch{return!1}}function i(m,L){let{publicKey:B,publicKeyUncompressed:R}=o;try{let w=m.length;return L===!0&&w!==B||L===!1&&w!==R?!1:!!r.fromBytes(m)}catch{return!1}}function c(m){return m=m===void 0?n(o.seed):m,Er(H(m,o.seed,"seed"),e.ORDER)}function a(m,L=!0){return r.BASE.multiply(e.fromBytes(m)).toBytes(L)}function f(m){let{secretKey:L,publicKey:B,publicKeyUncompressed:R}=o,w=e._lengths;if(!Mt(m))return;let S=H(m,void 0,"key").length,p=S===B||S===R,_=S===L||!!w?.includes(S);if(!(p&&_))return p}function u(m,L,B=!0){if(f(m)===!0)throw new Error("first arg must be private key");if(f(L)===!1)throw new Error("second arg must be public key");let R=e.fromBytes(m);return r.fromBytes(L).multiply(R).toBytes(B)}let h={isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:c},b=Ar(c,a);return Object.freeze(h),Object.freeze(o),Object.freeze({getPublicKey:a,getSharedSecret:u,keygen:b,Point:r,utils:h,lengths:o})}function Bi(r,t,e={}){qt(r);let n=t;ar(n),ct(e,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let o=Object.assign({},e),s=o.randomBytes===void 0?te:o.randomBytes,i=o.hmac===void 0?(g,d)=>gi(n,g,d):o.hmac,{Fp:c,Fn:a}=r,{ORDER:f,BITS:u}=a,h=wr(f),b=$n(s,h),{keygen:m,getPublicKey:L,getSharedSecret:B,utils:R,lengths:w}=vf(r,o),S={prehash:!0,lowS:typeof o.lowS=="boolean"?o.lowS:!0,format:"compact",extraEntropy:!1},p=f*wi+oe<c.ORDER;function _(g){let d=f>>oe;return g>d}function A(g,d){if(!a.isValidNot0(d))throw new Error(`invalid signature ${g}: out of range 1..Point.Fn.ORDER`);return d}function K(){if(!c.isOdd)throw new Error("Field doesn't support isOdd")}function M(g,d,E){return K(),(g===E?0:2)|Number(c.isOdd(d))}function U(){if(p)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function O(g,d){go(d);let E=w.signature,v=d==="compact"?E:d==="recovered"?E+1:void 0;return H(g,v)}class F{r;s;recovery;constructor(d,E,v){if(this.r=A("r",d),this.s=A("s",E),v!=null){if(U(),![0,1,2,3].includes(v))throw new Error("invalid recovery id");this.recovery=v}Object.freeze(this)}static fromBytes(d,E=S.format){O(d,E);let v;if(E==="der"){let{r:z,s:$}=mo.toSig(H(d));return new F(z,$)}E==="recovered"&&(v=d[0],E="compact",d=d.subarray(1));let k=w.signature/2,N=d.subarray(0,k),q=d.subarray(k,k*2);return new F(a.fromBytes(N),a.fromBytes(q),v)}static fromHex(d,E){return this.fromBytes(be(d),E)}assertRecovery(){let{recovery:d}=this;if(d==null)throw new Error("invalid recovery id: must be present");return d}addRecoveryBit(d){return new F(this.r,this.s,d)}recoverPublicKey(d){let{r:E,s:v}=this,k=this.assertRecovery(),N=k===2||k===3?E+f:E;if(!c.isValid(N))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let q=c.toBytes(N),z=r.fromBytes(yt(Si((k&1)===0),q)),$=a.inv(N),rt=C(H(d,void 0,"msgHash")),G=a.create(-rt*$),tt=a.create(v*$),St=r.BASE.mulAddUnsafe(G,z,tt);if(St.is0())throw new Error("invalid recovery: point at infinify");return St.assertValidity(),St}hasHighS(){return _(this.s)}toBytes(d=S.format){if(go(d),d==="der")return be(mo.hexFromSig(this));let{r:E,s:v}=this,k=a.toBytes(E),N=a.toBytes(v);return d==="recovered"?(U(),yt(Uint8Array.of(this.assertRecovery()),k,N)):yt(k,N)}toHex(d){return Ke(this.toBytes(d))}}Object.freeze(F.prototype),Object.freeze(F);let P=o.bits2int===void 0?function(d){if(d.length>8192)throw new Error("input is too large");let E=At(d),v=d.length*8-u;return v>0?E>>BigInt(v):E}:o.bits2int,C=o.bits2int_modN===void 0?function(d){return a.create(P(d))}:o.bits2int_modN,V=Pe(u);function T(g){return ge("num < 2^"+u,g,Ct,V),a.toBytes(g)}function I(g,d){return H(g,void 0,"message"),d?H(n(g),void 0,"prehashed message"):g}function l(g,d,E){let{lowS:v,prehash:k,extraEntropy:N}=yo(E,S);g=I(g,k);let q=C(g),z=a.fromBytes(d);if(!a.isValidNot0(z))throw new Error("invalid private key");let $=[T(z),T(q)];if(N!=null&&N!==!1){let St=N===!0?s(w.secretKey):N;$.push(H(St,void 0,"extraEntropy"))}let rt=yt(...$),G=q;function tt(St){let ce=P(St);if(!a.isValidNot0(ce))return;let Be=r.BASE.multiply(ce).toAffine(),Lt=a.create(Be.x);if(Lt===Ct)return;let _t;if(b!==void 0){let Ae=At(Er(b(h),f)),Hi=a.inv(a.mul(Ae,ce)),ji=a.mul(Ae,G),Vi=a.mul(Ae,z);_t=a.create(Hi*a.create(ji+Vi*Lt))}else{let Ae=Ns(ce,f);_t=a.create(Ae*a.create(G+Lt*z))}if(_t===Ct)return;let Xr=M(Be.x,Be.y,Lt),To=_t;return v&&_(_t)&&(To=a.neg(_t),Xr^=1),new F(Lt,To,p?void 0:Xr)}return{seed:rt,k2sig:tt}}function y(g,d,E={}){let{seed:v,k2sig:k}=l(g,d,E);return Rs(n.outputLen,a.BYTES,i)(v,k).toBytes(E.format)}function x(g,d,E,v={}){let{lowS:k,prehash:N,format:q}=yo(v,S);if(E=H(E,void 0,"publicKey"),d=I(d,N),!Mt(g)){let z=g instanceof F?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+z)}O(g,q);try{let z=F.fromBytes(g,q),$=r.fromBytes(E);if(k&&z.hasHighS())return!1;let{r:rt,s:G}=z,tt=C(d),St=a.inv(G),ce=a.create(tt*St),Be=a.create(rt*St),Lt=r.BASE.mulAddUnsafe(ce,$,Be);if(Lt.is0())return!1;let _t=Lt.toAffine();return!(a.create(_t.x)!==rt||q==="recovered"&&z.recovery!==M(_t.x,_t.y,rt))}catch{return!1}}function D(g,d,E={}){let{prehash:v}=yo(E,S);return d=I(d,v),F.fromBytes(g,"recovered").recoverPublicKey(d).toBytes()}return Object.freeze({keygen:m,getPublicKey:L,getSharedSecret:B,utils:R,lengths:w,Point:r,sign:y,verify:x,recoverPublicKey:D,Signature:F,hash:n})}var wo={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},If={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Ai=BigInt(2);function Tf(r){let t=wo.p,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),f=r*r*r%t,u=f*f*r%t,h=Z(u,e,t)*u%t,b=Z(h,e,t)*u%t,m=Z(b,Ai,t)*f%t,L=Z(m,o,t)*m%t,B=Z(L,s,t)*L%t,R=Z(B,c,t)*B%t,w=Z(R,a,t)*R%t,S=Z(w,c,t)*B%t,p=Z(S,e,t)*u%t,_=Z(p,i,t)*L%t,A=Z(_,n,t)*f%t,K=Z(A,Ai,t);if(!xo.eql(xo.sqr(K),r))throw new Error("Cannot find square root");return K}var xo=Ee(wo.p,{sqrt:Tf}),Rf=Ei(wo,{Fp:xo,endo:If}),_e=Bi(Rf,As);function vi(r,t,e,n){let o=De.digest(e instanceof Uint8Array?e:e.subarray());if(Dr(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),_e.verify(t,s,r,{prehash:!1,format:"der"}))).catch(s=>{throw s.name==="AbortError"?s:new He(String(s))});try{return n?.signal?.throwIfAborted(),_e.verify(t,o.digest,r,{prehash:!1,format:"der"})}catch(s){throw new He(String(s))}}var Hr=class{type="secp256k1";raw;_key;constructor(t){this._key=Ti(t),this.raw=Ii(this._key)}toMultihash(){return bt.digest(me(this))}toCID(){return st.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ft(this.raw,t.raw)}verify(t,e,n){return vi(this._key,e,t,n)}};function Ri(r){return new Hr(r)}function Ii(r){return _e.Point.fromBytes(r).toBytes()}function Ti(r){try{return _e.Point.fromBytes(r),r}catch(t){throw new Qe(String(t))}}function Ci(r){let{Type:t,Data:e}=$e.decode(r.digest),n=e??new Uint8Array;switch(t){case ot.Ed25519:return ni(n);case ot.secp256k1:return Ri(n);case ot.ECDSA:return os(n);default:throw new ve}}function me(r){return $e.encode({Type:ot[r.type],Data:r.raw})}var Li=Symbol.for("nodejs.util.inspect.custom"),Cf=114,Ge=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()})`}[Jr]=!0;toString(){return this.string==null&&(this.string=W.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return st.createV1(Cf,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return ft(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return ft(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Li](){return`PeerId(${this.toString()})`}},jr=class extends Ge{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Vr=class extends Ge{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Zr=class extends Ge{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Lf=2336,Yr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=bt.digest(Q(this.url))}[Li](){return`PeerId(${this.url})`}[Jr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return st.createV1(Lf,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=pt(t)),t.toString()===this.toString())}};function Di(r){if(Of(r))return new jr({multihash:r});if(Df(r))try{let t=Ci(r);if(t.type==="Ed25519")return new Vr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Zr({multihash:r,publicKey:t})}catch{let e=pt(r.digest);return new Yr(new URL(e))}throw new tr("Supplied PeerID Multihash is invalid")}function Df(r){return r.code===bt.code}function Of(r){return r.code===De.code}function vt(r,t){let e={[Symbol.iterator]:()=>e,next:()=>{let n=r.next(),o=n.value;return n.done===!0||o==null?{done:!0,value:void 0}:{done:!1,value:t(o)}}};return e}function $r(r){let t=Ce(W.decode(`z${r}`));return Di(t)}var Vt=class{map;constructor(t){if(this.map=new Map,t!=null)for(let[e,n]of t.entries())this.map.set(e.toString(),{key:e,value:n})}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(t){return this.map.delete(t.toString())}entries(){return vt(this.map.entries(),t=>[t[1].key,t[1].value])}forEach(t){this.map.forEach((e,n)=>{t(e.value,e.key,this)})}get(t){return this.map.get(t.toString())?.value}has(t){return this.map.has(t.toString())}set(t,e){this.map.set(t.toString(),{key:t,value:e})}keys(){return vt(this.map.values(),t=>t.key)}values(){return vt(this.map.values(),t=>t.value)}get size(){return this.map.size}};function Oi(){return new Vt}var Zt=class r{set;constructor(t){if(this.set=new Set,t!=null)for(let e of t)this.set.add(e.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(t){this.set.add(t.toString())}clear(){this.set.clear()}delete(t){this.set.delete(t.toString())}entries(){return vt(this.set.entries(),t=>{let e=$r(t[0]);return[e,e]})}forEach(t){this.set.forEach(e=>{let n=$r(e);t(n,n,this)})}has(t){return this.set.has(t.toString())}values(){return vt(this.set.values(),t=>$r(t))}intersection(t){let e=new r;for(let n of t)this.has(n)&&e.add(n);return e}difference(t){let e=new r;for(let n of this)t.has(n)||e.add(n);return e}union(t){let e=new r;for(let n of t)e.add(n);for(let n of this)e.add(n);return e}};function Fi(){return new Zt}var Yt=class r{list;constructor(t){if(this.list=[],t!=null)for(let e of t)this.list.push(e)}[Symbol.iterator](){return vt(this.list.entries(),t=>t[1])}concat(t){let e=new r(this);for(let n of t)e.push(n);return e}entries(){return vt(this.list.entries(),t=>[t[0],t[1]])}every(t){return this.list.every((e,n)=>t(e,n,this))}filter(t){let e=new r;return this.list.forEach((n,o)=>{t(n,o,this)&&e.push(n)}),e}find(t){let e=this.list.find((n,o)=>t(n,o,this));if(e!=null)return e}findIndex(t){return this.list.findIndex((e,n)=>t(e,n,this))}forEach(t){this.list.forEach((e,n)=>{t(e,n,this)})}includes(t){return this.includes(t)}indexOf(t){return this.list.findIndex(e=>e.equals(t))}pop(){let t=this.list.pop();if(t!=null)return t}push(...t){for(let e of t)this.list.push(e)}shift(){let t=this.list.shift();if(t!=null)return t}unshift(...t){let e=this.list.length;for(let n=t.length-1;n>-1;n--)e=this.list.unshift(t[n]);return e}clear(){this.list=[]}get length(){return this.list.length}};function Ui(){return new Yt}var Eo={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},ki={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},Ni=new globalThis.TextEncoder;function Ff(r,t){let e=Eo[t],n=ki[t];for(let o=0;o<r.length;o++)n^=BigInt(r[o]),n=BigInt.asUintN(t,n*e);return n}function Uf(r,t,e){if(e.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");let n=Eo[t],o=ki[t],s=r;for(;s.length>0;){let i=Ni.encodeInto(s,e);s=s.slice(i.read);for(let c=0;c<i.written;c++)o^=BigInt(e[c]),o=BigInt.asUintN(t,o*n)}return o}function So(r,{size:t=32,utf8Buffer:e}={}){if(!Eo[t])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if(typeof r=="string"){if(e)return Uf(r,t,e);r=Ni.encode(r)}return Ff(r,t)}var Xe={hash:r=>Number(So(r,{size:32})),hashV:(r,t)=>kf(Xe.hash(r,t))};function kf(r){let t=r.toString(16);return t.length%2===1&&(t=`0${t}`),Q(t,"base16")}var _o=64,Et=class{fp;h;seed;constructor(t,e,n,o=2){if(o>_o)throw new TypeError("Invalid Fingerprint Size");let s=e.hashV(t,n),i=gt(o);for(let c=0;c<i.length;c++)i[c]=s[c];i.length===0&&(i[0]=7),this.fp=i,this.h=e,this.seed=n}hash(){return this.h.hash(this.fp,this.seed)}equals(t){return t?.fp instanceof Uint8Array?ft(this.fp,t.fp):!1}};function se(r,t){return Math.floor(Math.random()*(t-r))+r}var ie=class{contents;constructor(t){this.contents=new Array(t).fill(null)}has(t){if(!(t instanceof Et))throw new TypeError("Invalid Fingerprint");return this.contents.some(e=>t.equals(e))}add(t){if(!(t instanceof Et))throw new TypeError("Invalid Fingerprint");for(let e=0;e<this.contents.length;e++)if(this.contents[e]==null)return this.contents[e]=t,!0;return!0}swap(t){if(!(t instanceof Et))throw new TypeError("Invalid Fingerprint");let e=se(0,this.contents.length-1),n=this.contents[e];return this.contents[e]=t,n}remove(t){if(!(t instanceof Et))throw new TypeError("Invalid Fingerprint");let e=this.contents.findIndex(n=>t.equals(n));return e>-1?(this.contents[e]=null,!0):!1}};var Nf=500,We=class{bucketSize;filterSize;fingerprintSize;buckets;count;hash;seed;constructor(t){this.filterSize=t.filterSize,this.bucketSize=t.bucketSize??4,this.fingerprintSize=t.fingerprintSize??2,this.count=0,this.buckets=[],this.hash=t.hash??Xe,this.seed=t.seed??se(0,Math.pow(2,10))}add(t){typeof t=="string"&&(t=Q(t));let e=new Et(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=(n^e.hash())%this.filterSize;if(this.buckets[n]==null&&(this.buckets[n]=new ie(this.bucketSize)),this.buckets[o]==null&&(this.buckets[o]=new ie(this.bucketSize)),this.buckets[n].add(e)||this.buckets[o].add(e))return this.count++,!0;let s=[n,o],i=s[se(0,s.length-1)];this.buckets[i]==null&&(this.buckets[i]=new ie(this.bucketSize));for(let c=0;c<Nf;c++){let a=this.buckets[i].swap(e);if(a!=null&&(i=(i^a.hash())%this.filterSize,this.buckets[i]==null&&(this.buckets[i]=new ie(this.bucketSize)),this.buckets[i].add(a)))return this.count++,!0}return!1}has(t){typeof t=="string"&&(t=Q(t));let e=new Et(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.has(e)??!1;if(o)return o;let s=(n^e.hash())%this.filterSize;return this.buckets[s]?.has(e)??!1}remove(t){typeof t=="string"&&(t=Q(t));let e=new Et(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.remove(e)??!1;if(o)return this.count--,o;let s=(n^e.hash())%this.filterSize,i=this.buckets[s]?.remove(e)??!1;return i&&this.count--,i}get reliable(){return Math.floor(100*(this.count/this.filterSize))<=90}},Kf={1:.5,2:.84,4:.95,8:.98};function Mf(r=.001){return r>.002?2:r>1e-5?4:8}function Ki(r,t=.001){let e=Mf(t),n=Kf[e],o=Math.round(r/n),s=Math.min(Math.ceil(Math.log2(1/t)+Math.log2(2*e)),_o);return{filterSize:o,bucketSize:e,fingerprintSize:s}}var Gr=class{filterSize;bucketSize;fingerprintSize;scale;filterSeries;hash;seed;constructor(t){this.bucketSize=t.bucketSize??4,this.filterSize=t.filterSize??(1<<18)/this.bucketSize,this.fingerprintSize=t.fingerprintSize??2,this.scale=t.scale??2,this.hash=t.hash??Xe,this.seed=t.seed??se(0,Math.pow(2,10)),this.filterSeries=[new We({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(t){if(typeof t=="string"&&(t=Q(t)),this.has(t))return!0;let e=this.filterSeries.find(n=>n.reliable);if(e==null){let n=this.filterSize*Math.pow(this.scale,this.filterSeries.length);e=new We({filterSize:n,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(e)}return e.add(t)}has(t){typeof t=="string"&&(t=Q(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].has(t))return!0;return!1}remove(t){typeof t=="string"&&(t=Q(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].remove(t))return!0;return!1}get count(){return this.filterSeries.reduce((t,e)=>t+e.count,0)}};function Bo(r,t=.001,e){return new Gr({...Ki(r,t),...e??{}})}var Je=class{filter;constructor(t,e){this.filter=Bo(t,e)}has(t){return this.filter.has(t.toMultihash().bytes)}add(t){this.filter.add(t.toMultihash().bytes)}remove(t){this.filter.remove?.(t.toMultihash().bytes)}};function Mi(r,t=.001){return new Je(r,t)}var Ao=class extends Vt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}set(t,e){return super.set(t,e),this.updateComponentMetric(),this}delete(t){let e=super.delete(t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function Pi(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Ao({name:t,metrics:e}):n=new Vt,n}var vo=class extends Zt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}add(t){super.add(t),this.updateComponentMetric()}delete(t){super.delete(t),this.updateComponentMetric()}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function zi(r){let{name:t,metrics:e}=r,n;return e!=null?n=new vo({name:t,metrics:e}):n=new Zt,n}var Io=class extends Yt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}pop(){let t=super.pop();return this.updateComponentMetric(),t}push(...t){super.push(...t),this.updateComponentMetric()}shift(){let t=super.shift();return this.updateComponentMetric(),t}unshift(...t){let e=super.unshift(...t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.length)}};function qi(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Io({name:t,metrics:e}):n=new Yt,n}return Xi(Pf);})();
|
|
2
|
+
"use strict";var Libp2PPeerCollections=(()=>{var Jr=Object.defineProperty;var Zi=Object.getOwnPropertyDescriptor;var Yi=Object.getOwnPropertyNames;var $i=Object.prototype.hasOwnProperty;var lt=(r,t)=>{for(var e in t)Jr(r,e,{get:t[e],enumerable:!0})},Gi=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Yi(t))!$i.call(r,o)&&o!==e&&Jr(r,o,{get:()=>t[o],enumerable:!(n=Zi(t,o))||n.enumerable});return r};var Xi=r=>Gi(Jr({},"__esModule",{value:!0}),r);var zf={};lt(zf,{PeerFilter:()=>Qe,PeerList:()=>Gt,PeerMap:()=>Yt,PeerSet:()=>$t,peerFilter:()=>Pi,peerList:()=>Ui,peerMap:()=>Li,peerSet:()=>Fi,trackedPeerList:()=>qi,trackedPeerMap:()=>Mi,trackedPeerSet:()=>zi});var Ot=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},tr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var er=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var ve=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Qr=Symbol.for("@libp2p/peer-id");var on={};lt(on,{base58btc:()=>rt,base58flickr:()=>oc});var Vf=new Uint8Array(0);function Oo(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function gt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return Xt(r);if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return Xt(new Uint8Array(r.buffer,r.byteOffset,r.byteLength));throw new Error("Unknown type, must be binary type")}function Co(r){let t=new Uint8Array(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}var Ro=4096;function Do(r){let t=r.length;if(t<=Ro)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.subarray(n,n+=Ro));return e}function Wi(r){return r?.buffer instanceof ArrayBuffer}function Xt(r){return Wi(r)?r:r.slice()}function Ji(r,t,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),o=0;o<n.length;o++)n[o]=255;for(var s=0;s<r.length;s++){var i=r.charAt(s),c=i.charCodeAt(0);if(n[c]!==255)throw new TypeError(i+" is ambiguous");if(n[c]=s,e){var a=i.toLowerCase().charCodeAt(0),f=i.toUpperCase().charCodeAt(0);a!==c&&(n[a]=s),f!==c&&(n[f]=s)}}var u=r.length,l=r.charAt(0),b=Math.log(u)/Math.log(256),m=Math.log(256)/Math.log(u);function v(x){if(x instanceof Uint8Array||(ArrayBuffer.isView(x)?x=new Uint8Array(x.buffer,x.byteOffset,x.byteLength):Array.isArray(x)&&(x=Uint8Array.from(x))),!(x instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(x.length===0)return"";for(var _=0,p=0,E=0,S=x.length;E!==S&&x[E]===0;)E++,_++;for(var F=(S-E)*m+1>>>0,N=new Uint8Array(F);E!==S;){for(var U=x[E],O=0,D=F-1;(U!==0||O<p)&&D!==-1;D--,O++)U+=256*N[D]>>>0,N[D]=U%u>>>0,U=U/u>>>0;if(U!==0)throw new Error("Non-zero carry");p=O,E++}for(var z=F-p;z!==F&&N[z]===0;)z++;for(var M=l.repeat(_);z<F;++z)M+=r.charAt(N[z]);return M}function g(x){if(typeof x!="string")throw new TypeError("Expected String");if(x.length===0)return new Uint8Array;var _=0;if(x[_]!==" "){for(var p=0,E=0;x[_]===l;)p++,_++;for(var S=(x.length-_)*b+1>>>0,F=new Uint8Array(S);x[_];){var N=n[x.charCodeAt(_)];if(N===255)return;for(var U=0,O=S-1;(N!==0||U<E)&&O!==-1;O--,U++)N+=u*F[O]>>>0,F[O]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");E=U,_++}if(x[_]!==" "){for(var D=S-E;D!==S&&F[D]===0;)D++;for(var z=new Uint8Array(p+(S-D)),M=p;D!==S;)z[M++]=F[D++];return z}}}function A(x){var _=g(x);if(_)return _;throw new Error(`Non-${t} character`)}return{encode:v,decodeUnsafe:g,decode:A}}var Qi=Ji,tc=Qi,Fo=tc;var tn=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},en=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Uo(this,t)}},rn=class{decoders;constructor(t){this.decoders=t}or(t){return Uo(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Uo(r,t){return new rn({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var nn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new tn(t,e,n),this.decoder=new en(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function fe({name:r,prefix:t,encode:e,decode:n}){return new nn(r,t,e,n)}function Ut({name:r,prefix:t,alphabet:e,caseInsensitive:n=!1}){let{encode:o,decode:s}=Fo(e,r,n);return fe({prefix:t,name:r,encode:o,decode:i=>gt(s(i))})}function ec(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,c=0,a=0;for(let f=0;f<o;++f){let u=t[r[f]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|u,i+=e,i>=8&&(i-=8,s[a++]=255&c>>i)}if(i>=e||(255&c<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function rc(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],i+=8;i>e;)i-=e,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function nc(r,t){let e={};for(let n=0;n<r.length;++n)if(e[r[n]]=n,t){let o=r[n].toLowerCase(),s=r[n].toUpperCase();o!==r[n]&&(e[o]=n),s!==r[n]&&(e[s]=n)}return e}function Q({name:r,prefix:t,bitsPerChar:e,alphabet:n,caseInsensitive:o=!1}){let s=nc(n,o);return fe({prefix:t,name:r,encode(i){return rc(i,n,e)},decode(i){return ec(i,s,e,r)}})}var rt=Ut({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),oc=Ut({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var sn={};lt(sn,{base32:()=>ue,base32hex:()=>ac,base32hexpad:()=>uc,base32hexpadupper:()=>hc,base32hexupper:()=>fc,base32pad:()=>ic,base32padupper:()=>cc,base32upper:()=>sc,base32z:()=>lc});var ue=Q({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5,caseInsensitive:!0}),sc=Q({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5,caseInsensitive:!0}),ic=Q({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5,caseInsensitive:!0}),cc=Q({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5,caseInsensitive:!0}),ac=Q({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5,caseInsensitive:!0}),fc=Q({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5,caseInsensitive:!0}),uc=Q({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5,caseInsensitive:!0}),hc=Q({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5,caseInsensitive:!0}),lc=Q({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var cn={};lt(cn,{base36:()=>Ie,base36upper:()=>dc});var Ie=Ut({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz",caseInsensitive:!0}),dc=Ut({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",caseInsensitive:!0});var pc=Ko,ko=128,mc=127,yc=~mc,bc=Math.pow(2,31);function Ko(r,t,e){t=t||[],e=e||0;for(var n=e;r>=bc;)t[e++]=r&255|ko,r/=128;for(;r&yc;)t[e++]=r&255|ko,r>>>=7;return t[e]=r|0,Ko.bytes=e-n+1,t}var gc=an,xc=128,No=127;function an(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw an.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&No)<<o:(i&No)*Math.pow(2,o),o+=7}while(i>=xc);return an.bytes=s-n,e}var wc=Math.pow(2,7),Ec=Math.pow(2,14),Sc=Math.pow(2,21),_c=Math.pow(2,28),Bc=Math.pow(2,35),Ac=Math.pow(2,42),vc=Math.pow(2,49),Ic=Math.pow(2,56),Tc=Math.pow(2,63),Rc=function(r){return r<wc?1:r<Ec?2:r<Sc?3:r<_c?4:r<Bc?5:r<Ac?6:r<vc?7:r<Ic?8:r<Tc?9:10},Oc={encode:pc,decode:gc,encodingLength:Rc},Cc=Oc,Te=Cc;function Re(r,t=0){let e=Te.decode(r,t),n=Te.decode.bytes;if(n>9)throw new RangeError("Invalid varint: too long");if(n>1&&r[t+n-1]===0)throw new RangeError("Invalid varint: not minimally encoded");return[e,n]}function he(r,t,e=0){return Te.encode(r,t,e),t}function le(r){return Te.encodingLength(r)}function pe(r,t){let e=t.byteLength,n=le(r),o=n+le(e),s=new Uint8Array(o+e);return he(r,s,0),he(e,s,n),s.set(t,o),new de(r,e,t,s)}function Oe(r){let t=gt(r),[e,n]=Re(t),[o,s]=Re(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new de(e,o,i,t)}function Po(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Oo(r.bytes,e.bytes)}}var de=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=Xt(n),this.bytes=Xt(o)}};function Mo(r,t){let{bytes:e,version:n}=r;return n===0?Lc(e,fn(r),t??rt.encoder):Fc(e,fn(r),t??ue.encoder)}var zo=new WeakMap;function fn(r){let t=zo.get(r);if(t==null){let e=new Map;return zo.set(r,e),e}return t}var ft=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=Xt(o),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Ce)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Uc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=pe(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Po(t.multihash,n.multihash)}toString(t){return Mo(this,t)}toJSON(){return{"/":Mo(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??qo(n,o,s.bytes))}else if(e[kc]===!0){let{version:n,multihash:o,code:s}=e,i=Oe(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Ce)throw new Error(`Version 0 CID must use dag-pb (code: ${Ce}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=qo(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Ce,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=gt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new de(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,b]=Re(t.subarray(e));return e+=b,l},o=n(),s=Ce;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,c=n(),a=n(),f=e+a,u=f-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:u,size:f}}static parse(t,e){let[n,o]=Dc(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return fn(s).set(n,t),s}};function Dc(r,t){switch(r[0]){case"Q":{let e=t??rt;return[rt.prefix,e.decode(`${rt.prefix}${r}`)]}case rt.prefix:{let e=t??rt;return[rt.prefix,e.decode(r)]}case ue.prefix:{let e=t??ue;return[ue.prefix,e.decode(r)]}case Ie.prefix:{let e=t??Ie;return[Ie.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Lc(r,t,e){let{prefix:n}=e;if(n!==rt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function Fc(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var Ce=112,Uc=18;function qo(r,t,e){let n=le(r),o=n+le(t),s=new Uint8Array(o+e.byteLength);return he(r,s,0),he(t,s,n),s.set(e,o),s}var kc=Symbol.for("@ipld/js-cid/CID");var un={};lt(un,{identity:()=>St});var Ho=0,Nc="identity",jo=gt;function Kc(r,t){if(t?.truncate!=null&&t.truncate!==r.byteLength){if(t.truncate<0||t.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t.truncate)}return pe(Ho,jo(r))}var St={code:Ho,name:Nc,encode:jo,digest:Kc};function dt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Pc(r){return r.buffer instanceof ArrayBuffer}function kt(r){return Pc(r)?r:r.slice()}async function Vo(r,t,e,n){let o=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,kt(t),kt(e.subarray()));return n?.signal?.throwIfAborted(),s}function _t(r=0){return new Uint8Array(r)}function pt(r=0){return new Uint8Array(r)}function Mc(r){return r?.buffer instanceof ArrayBuffer}function Zo(r){if(Mc(r))return r;let t=r.slice();return new Uint8Array(t.buffer,0,t.byteLength)}function nr(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=pt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return Zo(e)}var $o=Symbol.for("@achingbrain/uint8arraylist");function Yo(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function or(r){return!!r?.[$o]}var mt=class r{bufs;length;[$o]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(or(n)){e+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(or(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Yo(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Yo(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(or(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return nr(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:nr(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=n,s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],c=o,a=c+i.byteLength;if(o=a,t>=a)continue;let f=t>=c&&t<a,u=e>c&&e<=a;if(f&&u){if(t===c&&e===a){n.push(i);break}let l=t-c;n.push(i.subarray(l,l+(e-t)));break}if(f){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(u){if(e===a){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!or(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let c=i,a=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=e;l<=a;l+=u){u=0;for(let b=f;b>=0;b--){let m=this.get(l+b);if(n[b]!==m){u=Math.max(1,b-c[m]);break}}if(u===0)return l}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=pt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=_t(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=_t(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=_t(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=pt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=_t(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=_t(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=_t(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=_t(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=_t(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!dt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var hn={};lt(hn,{base10:()=>zc});var zc=Ut({prefix:"9",name:"base10",alphabet:"0123456789"});var ln={};lt(ln,{base16:()=>qc,base16upper:()=>Hc});var qc=Q({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4,caseInsensitive:!0}),Hc=Q({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4,caseInsensitive:!0});var dn={};lt(dn,{base2:()=>jc});var jc=Q({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var pn={};lt(pn,{base256emoji:()=>Gc});var Go=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}"),Vc=Go.reduce((r,t,e)=>(r[e]=t,r),[]),Zc=Go.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Yc(r){return r.reduce((t,e)=>(t+=Vc[e],t),"")}function $c(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Zc[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Gc=fe({prefix:"\u{1F680}",name:"base256emoji",encode:Yc,decode:$c});var mn={};lt(mn,{base64:()=>Xc,base64pad:()=>Wc,base64url:()=>Jc,base64urlpad:()=>Qc});var Xc=Q({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Wc=Q({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Jc=Q({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Qc=Q({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var yn={};lt(yn,{base8:()=>ta});var ta=Q({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var bn={};lt(bn,{identity:()=>ea});var ea=fe({prefix:"\0",name:"identity",encode:r=>Do(gt(r)),decode:r=>gt(Co(r))});var Ou=new TextEncoder,Cu=new TextDecoder;var wn={};lt(wn,{sha256:()=>De,sha512:()=>sa});var oa=20;function xn({name:r,code:t,encode:e,minDigestLength:n,maxDigestLength:o}){return new gn(r,t,e,n,o)}var gn=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,e,n,o,s){this.name=t,this.code=e,this.encode=n,this.minDigestLength=o??oa,this.maxDigestLength=s}digest(t,e){if(e?.truncate!=null){if(e.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&e.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?Xo(n,this.code,e?.truncate):n.then(o=>Xo(o,this.code,e?.truncate))}else throw Error("Unknown type, must be binary type")}};function Xo(r,t,e){if(e!=null&&e!==r.byteLength){if(e>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e)}return pe(t,r)}function Jo(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var De=xn({name:"sha2-256",code:18,encode:Jo("SHA-256")}),sa=xn({name:"sha2-512",code:19,encode:Jo("SHA-512")});var En={...bn,...dn,...yn,...hn,...ln,...sn,...cn,...on,...mn,...pn},Hu={...wn,...un};function ts(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Qo=ts("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Sn=ts("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=pt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),ia={utf8:Qo,"utf-8":Qo,hex:En.base16,latin1:Sn,ascii:Sn,binary:Sn,...En},sr=ia;function st(r,t="utf8"){let e=sr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function xt(r,t="utf8"){let e=sr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var ca=parseInt("11111",2),_n=parseInt("10000000",2),aa=parseInt("01111111",2),es={0:Le,1:Le,2:fa,3:la,4:da,5:ha,6:ua,16:Le,22:Le,48:Le};function Bn(r,t={offset:0}){let e=r[t.offset]&ca;if(t.offset++,es[e]!=null)return es[e](r,t);throw new Error("No decoder for tag "+e)}function Fe(r,t){let e=0;if((r[t.offset]&_n)===_n){let n=r[t.offset]&aa,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++){if(t.offset>=r.byteLength)throw new Error("invalid DER element length");o+=r[t.offset].toString(16).padStart(2,"0")}e=parseInt(o,16)}else e=r[t.offset],t.offset++;if(!Number.isInteger(e)||e<0||e>r.byteLength-t.offset)throw new Error("invalid DER element length");return e}function Le(r,t){Fe(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=Bn(r,t);if(n===null)break;e.push(n)}return e}function fa(r,t){let e=Fe(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function ua(r,t){let e=Fe(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let c=`${s}.${i}`,a=[];for(;t.offset<n;){let f=r[t.offset];if(t.offset++,a.push(f&127),f<128){a.reverse();let u=0;for(let l=0;l<a.length;l++)u+=a[l]<<l*7;c+=`.${u}`,a=[]}}return c}function ha(r,t){return t.offset++,null}function la(r,t){let e=Fe(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function da(r,t){let e=Fe(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function pa(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new mt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function An(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=pa(r.byteLength);return new mt(Uint8Array.from([t.byteLength|_n]),t)}function rs(r){let t=new mt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new mt(Uint8Array.from([2]),An(t),t)}function ns(r){let t=Uint8Array.from([0]),e=new mt(t,r);return new mt(Uint8Array.from([3]),An(e),e)}function ir(r,t=48){let e=new mt;for(let n of r)e.append(n);return new mt(Uint8Array.from([t]),An(e),e)}var ma=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),ya=Uint8Array.from([6,5,43,129,4,0,34]),ba=Uint8Array.from([6,5,43,129,4,0,35]),ga={ext:!0,kty:"EC",crv:"P-256"},xa={ext:!0,kty:"EC",crv:"P-384"},wa={ext:!0,kty:"EC",crv:"P-521"},vn=32,In=48,Tn=66;function os(r){let t=Bn(r);return ss(t)}function ss(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===vn*2+1)return n=xt(t.subarray(e,e+vn),"base64url"),o=xt(t.subarray(e+vn),"base64url"),new me({...ga,key_ops:["verify"],x:n,y:o});if(t.byteLength===In*2+1)return n=xt(t.subarray(e,e+In),"base64url"),o=xt(t.subarray(e+In),"base64url"),new me({...xa,key_ops:["verify"],x:n,y:o});if(t.byteLength===Tn*2+1)return n=xt(t.subarray(e,e+Tn),"base64url"),o=xt(t.subarray(e+Tn),"base64url"),new me({...wa,key_ops:["verify"],x:n,y:o});throw new Ot(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function is(r){return ir([rs(Uint8Array.from([1])),ir([Ea(r.crv)],160),ir([ns(new mt(Uint8Array.from([4]),st(r.x??"","base64url"),st(r.y??"","base64url")))],161)]).subarray()}function Ea(r){if(r==="P-256")return ma;if(r==="P-384")return ya;if(r==="P-521")return ba;throw new Ot(`Invalid curve ${r}`)}var me=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=is(this.jwk)),this._raw}toMultihash(){return St.digest(ye(this))}toCID(){return ft.createV1(114,this.toMultihash())}toString(){return rt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:dt(this.raw,t.raw)}async verify(t,e,n){return Vo(this.jwk,e,t,n)}};var cr=BigInt(4294967295),cs=BigInt(32);function Sa(r,t=!1){return t?{h:Number(r&cr),l:Number(r>>cs&cr)}:{h:Number(r>>cs&cr)|0,l:Number(r&cr)|0}}function as(r,t=!1){let e=r.length,n=new Uint32Array(e),o=new Uint32Array(e);for(let s=0;s<e;s++){let{h:i,l:c}=Sa(r[s],t);[n[s],o[s]]=[i,c]}return[n,o]}var _a=r=>r/2**32|0,Ba=r=>r>>>0;function fs(r,t,e,n){let o=_a(e),s=Ba(e);r.setUint32(t,n?s:o,n),r.setUint32(t+4,n?o:s,n)}var Rn=(r,t,e)=>r>>>e,On=(r,t,e)=>r<<32-e|t>>>e,Jt=(r,t,e)=>r>>>e|t<<32-e,Qt=(r,t,e)=>r<<32-e|t>>>e,Ue=(r,t,e)=>r<<64-e|t>>>e-32,ke=(r,t,e)=>r>>>e-32|t<<64-e;function It(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var us=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),hs=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,ls=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),ds=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,ps=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),ms=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;function ar(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in r&&r.BYTES_PER_ELEMENT===1}var Cn=r=>r?`"${r}" `:"";function Ct(r,t=""){if(typeof r!="number")throw new TypeError(Cn(t)+"expected number, got "+typeof r);if(!Number.isSafeInteger(r)||r<0)throw new RangeError(Cn(t)+"expected integer >= 0, got "+r);return r}function wt(r,t,e=""){if(ar(r)&&(t===void 0||r.length===t))return r;t!==void 0&&Ct(t,"length");let n=ar(r),o=t!==void 0?` of length ${t}`:"",s=n?`length=${r.length}`:`type=${typeof r}`,i=Cn(e)+"expected Uint8Array"+o+", got "+s;throw n?new RangeError(i):new TypeError(i)}function fr(r){if(typeof r!="function"||typeof r.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(Ct(r.outputLen),Ct(r.blockLen),r.outputLen<1||r.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var va=(r,t)=>{if(r===null||typeof r!="object"||Array.isArray(r))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof r)},ys=(r,t)=>{va(r,t);let e=Object.getPrototypeOf(r);if(e!==Object.prototype&&e!==null)throw new TypeError(`"${t}" expected plain object`);if(Object.hasOwn(r,"__proto__"))throw new TypeError(`"${t}.__proto__" is not allowed`)};function be(r,t=!0){if(r.destroyed)throw new Error("hash was destroyed");if(t&&r.finished)throw new Error("digest() was already called")}function ur(r,t){wt(r,void 0,"output");let e=t.outputLen;if(!(r.length>=e))throw new RangeError('"output" expected length >= '+e)}function te(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function hr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Bt(r,t){return r<<32-t|r>>>t}var gs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Ia=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function lr(r){if(wt(r),gs)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=Ia[r[e]];return t}function bs(r){return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void 0}function dr(r){if(typeof r!="string")throw new TypeError("hex string expected, got "+typeof r);if(gs)try{return Uint8Array.fromHex(r)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let t=r.length,e=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=bs(r.charCodeAt(s)),c=bs(r.charCodeAt(s+1));if(i===void 0||c===void 0){let a=r[s]+r[s+1];throw new RangeError('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function Dn(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];wt(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}function Ta(r,t,e="opts"){return ys(r,"defaults"),t!==void 0&&ys(t,e),Object.assign(Object.create(null),r,t)}function Ln(r,t={}){if(typeof r!="function")throw new TypeError('"hashCons" expected function, got type='+typeof r);t=Ta({},t,"info");let e=(o,s)=>r(s).update(o).digest(),n=r(void 0);return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.canXOF=n.canXOF,e.create=o=>r(o),Object.assign(e,t),Object.freeze(e)}function xs(r=32){Ct(r,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(r>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${r}`);return t.getRandomValues(new Uint8Array(r))}var Fn=r=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,r])});function ws(r,t,e){return r&t^~r&e}function Es(r,t,e){return r&t^r&e^t&e}var Ne=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,e,n,o){this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=hr(this.buffer)}update(t){be(this),wt(t);let{view:e,buffer:n,blockLen:o}=this,s=t.length,i=!1;for(let c=0;c<s;){let a=Math.min(o-this.pos,s-c);if(a===o){let f=hr(t);for(;o<=s-c;c+=o)this.process(f,c);i=!0;continue}n.set(c===0&&a===s?t:t.subarray(c,c+a),this.pos),this.pos+=a,c+=a,this.pos===o&&(this.process(e,0),this.pos=0,i=!0)}return this.length+=t.length,i&&this.roundClean(),this}digestInto(t){be(this),ur(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,e.fill(0,i),this.padOffset>o-i&&(this.process(n,0),e.fill(0)),fs(n,o-8,this.length*8,s),this.process(n,0),this.roundClean();let c=t===e?n:hr(t),a=this.outputLen,f=a/4,u=this.get();if(a%4||f>u.length)throw new Error("invalid outputLen");for(let l=0;l<f;l++)c.setUint32(4*l,u[l],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneIntoMeta(t){let{buffer:e,length:n,finished:o,destroyed:s,pos:i}=this;return t.destroyed=s,t.finished=o,t.length=n,t.pos=i,i&&t.buffer.set(e),t}clone(){return this._cloneInto()}},Ss=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var _s=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Ra=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]),Nt=new Uint32Array(64),Un=class extends Ne{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(t,e){super(64,t,8,!1),this.A=e[0]|0,this.B=e[1]|0,this.C=e[2]|0,this.D=e[3]|0,this.E=e[4]|0,this.F=e[5]|0,this.G=e[6]|0,this.H=e[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[t,e,n,o,s,i,c,a]}set(t,e,n,o,s,i,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,e){for(let l=0;l<16;l++,e+=4)Nt[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let b=Nt[l-15],m=Nt[l-2],v=Bt(b,7)^Bt(b,18)^b>>>3,g=Bt(m,17)^Bt(m,19)^m>>>10;Nt[l]=g+Nt[l-7]+v+Nt[l-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:f,H:u}=this;for(let l=0;l<64;l++){let b=Bt(c,6)^Bt(c,11)^Bt(c,25),m=u+b+ws(c,a,f)+Ra[l]+Nt[l]|0,g=(Bt(n,2)^Bt(n,13)^Bt(n,22))+Es(n,o,s)|0;u=f,f=a,a=c,c=i+m|0,i=s,s=o,o=n,n=m+g|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,s,i,c,a,f,u)}roundClean(){te(Nt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),te(this.buffer)}},kn=class extends Un{constructor(){super(32,Ss)}};var Bs=as(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Oa=Bs[0],Ca=Bs[1],Kt=new Uint32Array(80),Pt=new Uint32Array(80),Nn=class extends Ne{Ah=0;Al=0;Bh=0;Bl=0;Ch=0;Cl=0;Dh=0;Dl=0;Eh=0;El=0;Fh=0;Fl=0;Gh=0;Gl=0;Hh=0;Hl=0;constructor(t,e){super(128,t,16,!1),this.Ah=e[0]|0,this.Al=e[1]|0,this.Bh=e[2]|0,this.Bl=e[3]|0,this.Ch=e[4]|0,this.Cl=e[5]|0,this.Dh=e[6]|0,this.Dl=e[7]|0,this.Eh=e[8]|0,this.El=e[9]|0,this.Fh=e[10]|0,this.Fl=e[11]|0,this.Gh=e[12]|0,this.Gl=e[13]|0,this.Hh=e[14]|0,this.Hl=e[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:f,El:u,Fh:l,Fl:b,Gh:m,Gl:v,Hh:g,Hl:A}=this;return[t,e,n,o,s,i,c,a,f,u,l,b,m,v,g,A]}set(t,e,n,o,s,i,c,a,f,u,l,b,m,v,g,A){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=b|0,this.Gh=m|0,this.Gl=v|0,this.Hh=g|0,this.Hl=A|0}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,e){for(let p=0;p<16;p++,e+=4)Kt[p]=t.getUint32(e),Pt[p]=t.getUint32(e+=4);for(let p=16;p<80;p++){let E=Kt[p-15]|0,S=Pt[p-15]|0,F=Jt(E,S,1)^Jt(E,S,8)^Rn(E,S,7),N=Qt(E,S,1)^Qt(E,S,8)^On(E,S,7),U=Kt[p-2]|0,O=Pt[p-2]|0,D=Jt(U,O,19)^Ue(U,O,61)^Rn(U,O,6),z=Qt(U,O,19)^ke(U,O,61)^On(U,O,6),M=ls(N,z,Pt[p-7],Pt[p-16]),Z=ds(M,F,D,Kt[p-7],Kt[p-16]);Kt[p]=Z|0,Pt[p]=M|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:f,Dl:u,Eh:l,El:b,Fh:m,Fl:v,Gh:g,Gl:A,Hh:x,Hl:_}=this;for(let p=0;p<80;p++){let E=Jt(l,b,14)^Jt(l,b,18)^Ue(l,b,41),S=Qt(l,b,14)^Qt(l,b,18)^ke(l,b,41),F=l&m^~l&g,N=b&v^~b&A,U=ps(_,S,N,Ca[p],Pt[p]),O=ms(U,x,E,F,Oa[p],Kt[p]),D=U|0,z=Jt(n,o,28)^Ue(n,o,34)^Ue(n,o,39),M=Qt(n,o,28)^ke(n,o,34)^ke(n,o,39),Z=n&s^n&c^s&c,I=o&i^o&a^i&a;x=g|0,_=A|0,g=m|0,A=v|0,m=l|0,v=b|0,{h:l,l:b}=It(f|0,u|0,O|0,D|0),f=c|0,u=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let K=us(D,M,I);n=hs(K,O,z,Z),o=K|0}({h:n,l:o}=It(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=It(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=It(this.Ch|0,this.Cl|0,c|0,a|0),{h:f,l:u}=It(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:b}=It(this.Eh|0,this.El|0,l|0,b|0),{h:m,l:v}=It(this.Fh|0,this.Fl|0,m|0,v|0),{h:g,l:A}=It(this.Gh|0,this.Gl|0,g|0,A|0),{h:x,l:_}=It(this.Hh|0,this.Hl|0,x|0,_|0),this.set(n,o,s,i,c,a,f,u,l,b,m,v,g,A,x,_)}roundClean(){te(Kt,Pt)}destroy(){this.destroyed=!0,te(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Kn=class extends Nn{constructor(){super(64,_s)}};var As=Ln(()=>new kn,Fn(1));var Pn=Ln(()=>new Kn,Fn(3));function mr(r,t,e=()=>{}){if(!Array.isArray(r))throw new TypeError(`"${t}" expected array, got type=${typeof r}`);for(let n=0;n<r.length;n++)e(r[n],`${t}[${n}]`);return r}var j=(r,t,e)=>wt(r,t,e),Mn=Ct;function Is(r,t=""){if(typeof r!="string"){let e=t&&`"${t}" `;throw new TypeError(e+"expected string, got type="+typeof r)}return r}function Mt(r,t="object"){if(r===null||typeof r!="object"||Array.isArray(r))throw new TypeError(t==="object"?"expected valid options object":`"${t}" expected object, got type=${typeof r}`);return r}function ee(r,t){if(typeof r!="function")throw new TypeError(`"${t}" is invalid: expected function, got ${typeof r}`);return r}var Ke=lr,Et=(...r)=>Dn(...r),ge=r=>dr(r),qt=ar,re=r=>xs(r),pr=BigInt(0),vs=BigInt(1),Da=r=>r?`"${r}" `:"";function ut(r,t=""){if(typeof r!="boolean")throw new TypeError(Da(t)+"expected boolean, got type="+typeof r);return r}function yr(r){if(typeof r=="bigint"){if(!zt(r))throw new RangeError("positive bigint expected, got "+r)}else Mn(r);return r}function Dt(r,t=""){if(typeof r!="number"){let e=t&&`"${t}" `;throw new TypeError(e+"expected number, got type="+typeof r)}if(!Number.isSafeInteger(r)){let e=t&&`"${t}" `;throw new RangeError(e+"expected safe integer, got "+r)}}function Pe(r){let t=yr(r).toString(16);return t.length&1?"0"+t:t}function Ts(r){if(typeof r!="string")throw new TypeError("hex string expected, got "+typeof r);return r===""?pr:BigInt("0x"+r)}function Tt(r){return Ts(lr(r))}function ne(r){return Ts(lr(Me(wt(r)).reverse()))}function br(r,t){if(Ct(t),t===0)throw new Error("zero output length is invalid");r=yr(r);let e=t*2,n=r.toString(16);if(n.length>e)throw new RangeError("number is too large");return dr(n.padStart(e,"0"))}function zn(r,t){return br(r,t).reverse()}function Me(r){return Uint8Array.from(j(r))}function zt(r){return typeof r=="bigint"&&pr<=r}function qn(r,t,e){return zt(r)&&zt(t)&&zt(e)&&t<=r&&r<e}function xe(r,t,e,n){if(!qn(t,e,n))throw new RangeError("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function we(r){if(r<pr)throw new Error("expected non-negative bigint, got "+r);return r===pr?0:r.toString(2).length}var ze=r=>(Dt(r,"n"),(vs<<BigInt(r))-vs);function Rs(r,t,e){if(Ct(r,"hashLen"),Ct(t,"qByteLen"),typeof e!="function")throw new TypeError("hmacFn must be a function");let n=A=>new Uint8Array(A),o=Uint8Array.of(),s=Uint8Array.of(0),i=Uint8Array.of(1),c=1e3,a=n(r),f=n(r),u=0,l=()=>{a.fill(1),f.fill(0),u=0},b=(...A)=>e(f,Et(a,...A)),m=(A=o)=>{f=b(s,A),a=b(),A.length!==0&&(f=b(i,A),a=b())},v=()=>{if(u++>=c)throw new Error("drbg: tried max amount of iterations");let A=0,x=[];for(;A<t;){a=b();let _=a.slice();x.push(_),A+=a.length}return Et(...x)};return(A,x)=>{l(),m(A);let _;for(;(_=x(v()))===void 0;)m();return l(),_}}function ht(r,t={},e={},n="object"){Mt(r,n),Mt(t,"fields"),Mt(e,"optFields");function o(i,c,a){let f=n==="object"?`param "${String(i)}"`:`"${n}.${String(i)}"`,u=r[i];if(!Object.hasOwn(r,i)&&(a?u!==void 0:c!=="function"))throw new TypeError(`${f} is invalid: expected own property`);if(a&&u===void 0)return;let l=typeof u;if(l!==c||u===null)throw new TypeError(`${f} is invalid: expected ${c}, got ${l}`)}let s=(i,c)=>Object.entries(i).forEach(([a,f])=>o(a,f,c));s(t,!1),s(e,!0)}var nt=BigInt(0),V=BigInt(1),Ht=BigInt(2),Ds=BigInt(3),Hn=BigInt(4),Ls=BigInt(5),La=BigInt(7),Fs=BigInt(8),Fa=BigInt(9),Ua=BigInt(15),Us=BigInt(16),ka=BigInt("0x10000000000000000");function J(r,t){if(t<=nt)throw new Error("mod: expected positive modulus, got "+t);let e=r%t;return e>=nt?e:t+e}function ks(r,t,e){if(e<=V)throw new Error("pow: expected modulus > 1, got "+e);if(typeof t!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof t);if(t<nt)throw new Error("invalid exponent, negatives unsupported");if(t===nt)return V;if(t===V)return r;let n=r%e;if(n<nt&&(n+=e),t<ka){let c=V;for(;t>nt;)t&V&&(c=c*n%e),n=n*n%e,t>>=V;return c}let o=[];for(;t>nt;)o.push(Number(t&Ua)),t>>=Hn;let s=new Array(16);s[0]=V,s[1]=n;for(let c=2;c<16;c++)s[c]=s[c-1]*n%e;let i=s[o[o.length-1]];for(let c=o.length-2;c>=0;c--){i=i*i%e,i=i*i%e,i=i*i%e,i=i*i%e;let a=o[c];a!==0&&(i=i*s[a]%e)}return i}function X(r,t,e){if(e<=V)throw new Error("pow2: expected modulus > 1, got "+e);if(t<nt)throw new Error("pow2: expected non-negative exponent, got "+t);let n=r;for(;t-- >nt;)n*=n,n%=e;return n}function Os(r,t){if(r===nt)throw new Error("invert: expected non-zero number");if(t<=V)throw new Error("invert: expected modulus > 1, got "+t);let e=J(r,t),n=t,o=nt,s=V;for(;e!==nt;){let c=n/e,a=n-e*c,f=o-s*c;n=e,e=a,o=s,s=f}if(n!==V)throw new Error("invert: does not exist");return J(o,t)}function Ns(r,t){if(t<=V)throw new Error("invertCt: expected prime modulus > 1, got "+t);let e=J(r,t);if(e===nt)throw new Error("invertCt: expected non-zero number");let n=ks(e,t-Ht,t);if(J(e*n,t)!==V)throw new Error("invertCt: does not exist");return n}function jn(r,t,e){let n=r;if(!n.eql(n.sqr(t),e))throw new Error("Cannot find square root")}function Vn(r,t){if((r&V)===nt)throw new Error(t+": expected odd modulus, got "+r)}function Ks(r,t){let e=r,n=(e.ORDER+V)/Hn,o=e.pow(t,n);return jn(e,o,t),o}function Na(r,t){let e=r,n=(e.ORDER-Ls)/Fs,o=e.mul(t,Ht),s=e.pow(o,n),i=e.mul(t,s),c=e.mul(e.mul(i,Ht),s),a=e.mul(i,e.sub(c,e.ONE));return jn(e,a,t),a}function Ka(r){let t=Se(r),e=Ps(r),n=e(t,t.neg(t.ONE)),o=e(t,n),s=e(t,t.neg(n)),i=(r+La)/Us;return((c,a)=>{let f=c,u=f.pow(a,i),l=f.mul(u,n),b=f.mul(u,o),m=f.mul(u,s),v=f.eql(f.sqr(l),a),g=f.eql(f.sqr(b),a);u=f.cmov(u,l,v),l=f.cmov(m,b,g);let A=f.eql(f.sqr(l),a),x=f.cmov(u,l,A);return jn(f,x,a),x})}function Ps(r){if(r<Ds)throw new Error("sqrt is not defined for small field");Vn(r,"tonelliShanks");let t=r-V,e=0;for(;t%Ht===nt;)t/=Ht,e++;let n=Ht,o=Se(r);for(;qe(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return Ks;let s=o.pow(n,t),i=(t+V)/Ht;return function(a,f){let u=a;if(u.is0(f))return f;if(qe(u,f)!==1)throw new Error("Cannot find square root");let l=e,b=u.mul(u.ONE,s),m=u.pow(f,t),v=u.pow(f,i);for(;!u.eql(m,u.ONE);){if(u.is0(m))throw new Error("Cannot find square root: probably non-prime P");let g=1,A=u.sqr(m);for(;!u.eql(A,u.ONE);)if(g++,A=u.sqr(A),g===l)throw new Error("Cannot find square root");let x=V<<BigInt(l-g-1),_=u.pow(b,x);l=g,b=u.sqr(_),m=u.mul(m,b),v=u.mul(v,_)}return v}}function Pa(r){return Vn(r,"Fp.sqrt"),r%Hn===Ds?Ks:r%Fs===Ls?Na:r%Us===Fa?Ka(r):Ps(r)}var Ms=(r,t)=>(J(r,t)&V)===V,Ma=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ee(r){if(Mt(r,"field"),typeof r.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof r.ORDER);Dt(r.BYTES,"BYTES"),Dt(r.BITS,"BITS");for(let t of Ma)ee(r[t],"field."+t);if(r.BYTES<1||r.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(r.ORDER<=V)throw new Error("invalid field: expected ORDER > 1, got "+r.ORDER);return r}function xr(r,t,e=!1){Ee(r),mr(t,"nums"),ut(e,"passZero");let n=r,o=new Array(t.length).fill(e?n.ZERO:void 0),s=t.reduce((c,a,f)=>n.is0(a)?c:(o[f]=c,n.mul(c,a)),n.ONE),i=n.inv(s);return t.reduceRight((c,a,f)=>n.is0(a)?c:(o[f]=n.mul(c,o[f]),n.mul(c,a)),i),o}function qe(r,t){Ee(r);let e=r;Vn(e.ORDER,"FpLegendre");let n=(e.ORDER-V)/Ht,o=e.pow(t,n),s=e.eql(o,e.ONE),i=e.eql(o,e.ZERO),c=e.eql(o,e.neg(e.ONE));if(!s&&!i&&!c)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function za(r,t){if(t!==void 0&&Mn(t),r<=nt)throw new Error("invalid n length: expected positive n, got "+r);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let e=we(r);if(t!==void 0&&t<e)throw new Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${e})`);let n=t!==void 0?t:e,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var Cs=new WeakMap,gr=class{ORDER;BITS;BYTES;isLE;ZERO=nt;ONE=V;_lengths;_mod;constructor(t,e={}){if(t<=V)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,e!=null&&typeof e=="object"&&(typeof e.BITS=="number"&&(n=e.BITS),typeof e.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:e.sqrt,enumerable:!0}),typeof e.isLE=="boolean"&&(this.isLE=e.isLE),e.allowedLengths&&(this._lengths=Object.freeze(e.allowedLengths.slice())),typeof e.modFromBytes=="boolean"&&(this._mod=e.modFromBytes));let{nBitLength:o,nByteLength:s}=za(t,n);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=s,Object.freeze(this)}create(t){return J(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return nt<=t&&t<this.ORDER}is0(t){return t===nt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&V)===V}neg(t){return J(-t,this.ORDER)}eql(t,e){return t===e}sqr(t){return J(t*t,this.ORDER)}add(t,e){return J(t+e,this.ORDER)}sub(t,e){return J(t-e,this.ORDER)}mul(t,e){return J(t*e,this.ORDER)}pow(t,e){return ks(t,e,this.ORDER)}div(t,e){return J(t*Os(e,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,e){return t+e}subN(t,e){return t-e}mulN(t,e){return t*e}inv(t){return Os(t,this.ORDER)}sqrt(t){let e=Cs.get(this);return e||Cs.set(this,e=Pa(this.ORDER)),e(this,t)}toBytes(t){return this.isLE?zn(t,this.BYTES):br(t,this.BYTES)}fromBytes(t,e=!1){j(t);let{_lengths:n,BYTES:o,isLE:s,ORDER:i,_mod:c}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let f=new Uint8Array(o);f.set(t,s?0:f.length-t.length),t=f}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let a=s?ne(t):Tt(t);if(c&&(a=J(a,i)),!e&&!this.isValid(a))throw new Error("invalid field element: outside of range 0..ORDER");return a}invertBatch(t){return xr(this,t,!0)}cmov(t,e,n){return ut(n,"condition"),n?e:t}};function Se(r,t={}){return Object.freeze(gr.prototype),new gr(r,t)}function zs(r){if(typeof r!="bigint")throw new Error("field order must be bigint");if(r<=V)throw new Error("field order must be greater than 1");let t=we(r-V);return Math.ceil(t/8)}function wr(r){let t=zs(r);return t+Math.ceil(t/2)}function Er(r,t,e=!1){j(r);let n=r.length,o=zs(t),s=Math.max(wr(t),16);if(n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?ne(r):Tt(r),c=J(i,t-V)+V;return e?zn(c,o):br(c,o)}var $n=BigInt(0),He=BigInt(1),qa=BigInt(4),Zn=16,qs=128,Ha=5,Hs=2**31;function jt(r){let t=r;if(typeof t!="function")throw new TypeError('"Point" expected constructor, got type='+typeof r);ee(t.fromAffine,"Point.fromAffine"),ee(t.fromBytes,"Point.fromBytes"),ee(t.fromHex,"Point.fromHex"),Mt(t.BASE,"Point.BASE"),Mt(t.ZERO,"Point.ZERO"),Ee(t.Fp),Ee(t.Fn)}function Sr(r,t){jt(r),Vs(t,r);let e=xr(r.Fp,t.map(n=>n.Z));return t.map((n,o)=>r.fromAffine(n.toAffine(e[o])))}function ja(r,t,e=1){if(!Number.isSafeInteger(r)||r<e||r>t)throw new Error("invalid window size, expected ["+e+".."+t+"], got W="+r)}function Va(r,t){let e=r*(4*t+128);if(e>Hs)throw new Error("invalid window size: table would need ~"+Math.ceil(e/2**20)+" MiB, max "+Hs/2**20+" MiB")}function Gn(r,t){if(r!==void 0){ee(r,"randomBytes");try{let e=r(t);if(!qt(e)||e.length!==t)return}catch{return}return r}}function Vs(r,t){mr(r,"points"),r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function Za(r,t,e){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((n,o)=>{if(!(e===void 0?t.isValid(n):zt(n)&&n<e))throw new Error("invalid scalar at index "+o)})}var Zs=new WeakMap;function Yn(r){return Zs.get(r)||1}function Ya(r,t){let e=r.double(),n=[r];for(let o=1;o<t;o++)n.push(n[o-1].add(e));return n}function $a(r,t){let e=2**t,n=e/2,o=BigInt(e-1),s=[];for(;r>$n;){let i=0;r&He&&(i=Number(r&o),i>=n&&(i-=e),r-=BigInt(i)),s.push(i),r>>=He}return s}function Ga(r,t,e){let n=2**t,o=n/2,s=BigInt(n-1),i=BigInt(t),c=[];for(let a=0;a<e;a++){let f=Number(r&s);r>>=i,f>o&&(f-=n,r+=He),c.push(f)}if(r!==$n)throw new Error("invalid wnaf");return c}function Xa(r,t,e){let n=0;for(let s of e)n=Math.max(n,s.length);let o=r;for(let s=n-1;s>=0;s--){s!==n-1&&(o=o.double());for(let i=0;i<e.length;i++){let c=e[i][s];if(c){let a=t[i][Math.abs(c)-1>>1];o=o.add(c<0?a.negate():a)}}}return o}var _e=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(t,e){jt(t),this.randomBytes=Gn(e,Zn),this.Point=t,this.BASE=t.BASE,this.ZERO=t.ZERO,this.bits=t.Fn.BITS}buildWnafTable(t,e,n){let o=Math.ceil(n/e)+1,s=2**(e-1),i=[],c=t;for(let a=0;a<o;a++){let f=c;for(let u=0;u<s;u++)i.push(f),f=f.add(c);c=i[i.length-1].double()}return{W:e,bits:n,windows:o,comp:i}}wnafCachedCT(t,e){let{W:n,windows:o,comp:s}=t,i=2**(n-1),c=Ga(e,n,o),a=this.ZERO,f=this.BASE;for(let u=0;u<o;u++){let l=c[u],b=u*i,m=Math.abs(l)-1,v=s[b];for(let A=1;A<i;A++)v=A===m?s[b+A]:v;let g=v.negate();l===0?f=f.add(s[b]):a=a.add(l<0?g:v)}return{p:a,f}}getWnafPrecomputes(t,e,n,o){let s=this.wnafPrecomputes.get(e),i=s?.find(c=>c.W===t&&c.bits===n);return i||(i=this.buildWnafTable(e,t,n),typeof o=="function"&&(i={...i,comp:o(i.comp)}),s||(s=[],this.wnafPrecomputes.set(e,s)),s.push(i)),i}assertPoint(t){if(!(t instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof t)}validateMulInput(t,e){if(this.assertPoint(t),!qn(e,He,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(t,e,n,o){let s=Yn(t);return s===1?this.fixedWindowCT(t,e,n):this.wnafCachedCT(this.getWnafPrecomputes(s,t,n,o),e)}mulCT(t,e,n){return this.validateMulInput(t,e),this.runCT(t,e,this.bits,n)}mulCTBlinded(t,e,n){if(this.validateMulInput(t,e),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let o=this.Point.Fn.BITS+qs,s=this.randomBytes(Zn);if(!qt(s)||s.length!==Zn)throw new Error("randomBytes returned invalid byte array");s[0]=s[0]&63|128;let i=e+Tt(s)*this.Point.Fn.ORDER;return this.runCT(t,i,o,n)}fixedWindowCT(t,e,n){let o=Ha,s=1<<o,i=ze(o),c=new Array(s);c[0]=this.ZERO;for(let u=1;u<s;u++)c[u]=c[u-1].add(t);let a=Math.ceil(n/o),f=this.ZERO;for(let u=a-1;u>=0;u--){if(u!==a-1)for(let m=0;m<o;m++)f=f.double();let l=Number(e>>BigInt(u*o)&i),b=c[0];for(let m=1;m<s;m++)b=m===l?c[m]:b;f=f.add(b)}return{p:f,f}}shouldBlind(t,e){return this.randomBytes===void 0?!1:e===He?!0:t!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(t,e,n,o){return this.shouldBlind(t,n)?this.mulCTBlinded(t,e,o):this.mulCT(t,e,o)}mulUnsafe(t,e,n){if(this.assertPoint(t),!zt(e))throw new Error("invalid scalar");let o=Yn(t);if(o===1||e>=this.Point.Fn.ORDER)return _r(this.Point,[t],[e],!0);let s=this.getWnafPrecomputes(o,t,this.bits,n);return this.wnafCachedCT(s,e).p}setWindowSize(t,e){this.assertPoint(t),ja(e,this.bits);let n=Math.ceil((this.bits+qs)/e)+1;Va(n*2**(e-1),this.Point.Fp.BYTES),Zs.set(t,e),this.wnafPrecomputes.delete(t)}hasWindowSize(t){return Yn(t)!==1}};function _r(r,t,e,n=!1){if(jt(r),Vs(t,r),ut(n,"allowOversized"),Za(e,r.Fn,n?r.Fn.ORDER**qa:void 0),t.length!==e.length)throw new Error("arrays of points and scalars must have equal length");let o=t.map(i=>Ya(i,4)),s=e.map(i=>$a(i,4));return Xa(r.ZERO,o,s)}function js(r,t,e){if(t){if(t.ORDER!==r)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Ee(t),t}else return Se(r,{isLE:e})}function Br(r,t,e={},n){if(r!=="weierstrass"&&r!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(n===void 0&&(n=r==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${r} CURVE object`);ht(e);for(let a of["p","n","h"]){let f=t[a];if(!(zt(f)&&f!==$n))throw new Error(`CURVE.${a} must be positive bigint`)}let o=js(t.p,e.Fp,n),s=js(t.n,e.Fn,n),c=["Gx","Gy","a",r==="weierstrass"?"b":"d"];for(let a of c)if(!o.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:s}}function Ar(r,t){return function(n){let o=r(n);return{secretKey:o,publicKey:t(o)}}}var vr=BigInt(0),Ir=BigInt(1),Tr=BigInt(2),Wa=BigInt(4),Ys=BigInt(8);function Ja(r,t,e,n){let o=r.sqr(e),s=r.sqr(n),i=r.add(r.mul(t.a,o),s),c=r.add(r.ONE,r.mul(t.d,r.mul(o,s)));return r.eql(i,c)}function $s(r,t={}){ht(t,{},{},"extraOpts");let e=t,n=Br("edwards",r,e,e.FpFnLE),{Fp:o,Fn:s}=n,i=n.CURVE,{h:c}=i;if(qe(o,i.a)!==1)throw new Error("edwards: CURVE.a must be a square in Fp for complete addition formulas");if(qe(o,i.d)!==-1)throw new Error("edwards: CURVE.d must be a non-square in Fp for complete addition formulas");ht(e,{},{uvRatio:"function",randomBytes:"function"});let a=e.randomBytes===void 0?re:e.randomBytes,f=Tr<<BigInt(o.BYTES*8)-Ir;function u(_){if(!o.isOdd)throw new Error("Field does not have .isOdd()");return o.isOdd(_)}let l=e.uvRatio===void 0?(_,p)=>{try{return{isValid:!0,value:o.sqrt(o.div(_,p))}}catch{return{isValid:!1,value:vr}}}:e.uvRatio;if(!Ja(o,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");let b=o.eql(i.a,o.neg(o.ONE))?_=>o.neg(_):o.eql(i.a,o.ONE)?_=>_:_=>o.mul(i.a,_);function m(_,p,E=!1){let S=E?Ir:vr;return xe("coordinate "+_,p,S,f),p}function v(_){if(!(_ instanceof g))throw new Error("EdwardsPoint expected")}class g{static BASE=new g(i.Gx,i.Gy,o.ONE,o.mul(i.Gx,i.Gy));static ZERO=new g(o.ZERO,o.ONE,o.ONE,o.ZERO);static Fp=o;static Fn=s;X;Y;Z;T;constructor(p,E,S,F){this.X=m("x",p),this.Y=m("y",E),this.Z=m("z",S,!0),this.T=m("t",F),Object.freeze(this)}static CURVE(){return i}static fromAffine(p){if(p instanceof g)throw new Error("extended point not allowed");let{x:E,y:S}=p||{};return m("x",E),m("y",S),new g(E,S,o.ONE,o.mul(E,S))}static fromBytes(p,E=!1){let S=o.BYTES,{a:F,d:N}=i;p=Me(j(p,S,"point")),ut(E,"zip215");let U=Me(p),O=p[S-1];U[S-1]=O&-129;let D=ne(U),z=E?f:o.ORDER;xe("point.y",D,vr,z);let M=o.sqr(D),Z=o.sub(M,o.ONE),I=o.sub(o.mulN(N,M),F),{isValid:K,value:P}=l(Z,I);if(!K)throw new Error("bad point: invalid y coordinate");let C=u(P),Y=(O&128)!==0;if(!E&&o.is0(P)&&Y)throw new Error("bad point: x=0 and x_0=1");return Y!==C&&(P=o.neg(P)),g.fromAffine({x:P,y:D})}static fromHex(p,E=!1){return g.fromBytes(ge(p),E)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(p=6,E=!0){return x.setWindowSize(this,p),E||this.multiply(Tr),this}assertValidity(){let p=this,{a:E,d:S}=i;if(p.is0())throw new Error("bad point: ZERO");let{X:F,Y:N,Z:U,T:O}=p,D=o.sqr(F),z=o.sqr(N),M=o.sqr(U),Z=o.sqr(M),I=o.mul(D,E),K=o.mul(o.add(I,z),M),P=o.add(Z,o.mul(S,o.mul(D,z)));if(!o.eql(K,P))throw new Error("bad point: equation left != right (1)");let C=o.mul(F,N),Y=o.mul(U,O);if(!o.eql(C,Y))throw new Error("bad point: equation left != right (2)")}equals(p){v(p);let{X:E,Y:S,Z:F}=this,{X:N,Y:U,Z:O}=p,D=o.mul(E,O),z=o.mul(N,F),M=o.mul(S,O),Z=o.mul(U,F);return o.eql(D,z)&&o.eql(M,Z)}is0(){return this.equals(g.ZERO)}negate(){return new g(o.neg(this.X),this.Y,this.Z,o.neg(this.T))}double(){let{X:p,Y:E,Z:S}=this,F=o.sqr(p),N=o.sqr(E),U=o.mul(o.sqr(S),Tr),O=b(F),D=o.addN(p,E),z=o.sub(o.subN(o.sqr(D),F),N),M=o.addN(O,N),Z=o.subN(M,U),I=o.subN(O,N),K=o.mul(z,Z),P=o.mul(M,I),C=o.mul(z,I),Y=o.mul(Z,M);return new g(K,P,Y,C)}add(p){v(p);let{d:E}=i,{X:S,Y:F,Z:N,T:U}=this,{X:O,Y:D,Z:z,T:M}=p,Z=o.mul(S,O),I=o.mul(F,D),K=o.mul(o.mulN(U,E),M),P=o.mul(N,z),C=o.sub(o.subN(o.mulN(o.addN(S,F),o.addN(O,D)),Z),I),Y=o.subN(P,K),W=o.addN(P,K),w=o.sub(I,b(Z)),h=o.mul(C,Y),d=o.mul(W,w),y=o.mul(C,w),B=o.mul(Y,W);return new g(h,d,B,y)}subtract(p){return v(p),this.add(p.negate())}multiply(p){if(!s.isValidNot0(p))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:E,f:S}=x.mulSecret(this,p,c,A);return A([E,S])[0]}multiplyUnsafe(p){if(!s.isValid(p))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return p===vr?g.ZERO:this.is0()||p===Ir?this:x.mulUnsafe(this,p,A)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return x.mulUnsafe(this,i.n).is0()}toAffine(p){let E=this,S=p;if(S!=null&&typeof S!="bigint")throw new TypeError('"invertedZ" expected bigint, got type='+typeof S);let{X:F,Y:N,Z:U}=E,O=E.is0();S==null&&(S=O?o.create(Ys):o.inv(U));let D=o.mul(F,S),z=o.mul(N,S),M=o.mul(U,S);if(O)return{x:o.ZERO,y:o.ONE};if(!o.eql(M,o.ONE))throw new Error("invZ was invalid");return{x:D,y:z}}clearCofactor(){return c===Ir?this:c===Tr?this.double():c===Wa?this.double().double():c===Ys?this.double().double().double():this.multiplyUnsafe(c)}toBytes(){let{x:p,y:E}=this.toAffine(),S=o.toBytes(E);return S[S.length-1]|=u(p)?128:0,S}toHex(){return Ke(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let A=_=>Sr(g,_),x=new _e(g,a);return x.bits>=6&&g.BASE.precompute(6),Object.freeze(g.prototype),Object.freeze(g),g}function Gs(r,t,e={}){if(jt(r),typeof t!="function")throw new Error('"hash" function param is required');let n=t,o=e;ht(o,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",zip215:"boolean",mapToCurve:"function",toMontgomery:"function",toMontgomerySecret:"function"});let{prehash:s}=o,{BASE:i,Fp:c,Fn:a}=r,f=n.outputLen,u=2*c.BYTES;if(f!==void 0&&(Dt(f,"hash.outputLen"),f!==u))throw new Error(`hash.outputLen must be ${u}, got ${f}`);let l=o.randomBytes===void 0?re:o.randomBytes,b=o.toMontgomery,m=o.toMontgomerySecret,v=o.adjustScalarBytes===void 0?I=>I:o.adjustScalarBytes,g=o.domain===void 0?(I,K,P)=>{if(ut(P,"phflag"),K.length||P)throw new Error("Contexts/pre-hash are not supported");return I}:o.domain;function A(I){return a.create(ne(I))}function x(I){let K=O.secretKey;j(I,O.secretKey,"secretKey");let P=j(n(I),2*K,"hashedSecretKey"),C=v(P.slice(0,K)),Y=P.slice(K,2*K),W=A(C);return{head:C,prefix:Y,scalar:W}}function _(I){let{head:K,prefix:P,scalar:C}=x(I),Y=i.multiply(C),W=Y.toBytes();return{head:K,prefix:P,scalar:C,point:Y,pointBytes:W}}function p(I){return _(I).pointBytes}function E(I=Uint8Array.of(),...K){let P=Et(...K);return A(n(g(P,j(I,void 0,"context"),!!s)))}function S(I,K,P={}){ht(P,{},{},"options"),I=Me(j(I,void 0,"message")),s&&(I=s(I));let{prefix:C,scalar:Y,pointBytes:W}=_(K),w=E(P.context,C,I),h=i.multiply(w).toBytes(),d=E(P.context,h,W,I),y=a.create(w+d*Y);if(!a.isValid(y))throw new Error("sign failed: invalid s");let B=Et(h,a.toBytes(y));return j(B,O.signature,"result")}let F={zip215:o.zip215};function N(I,K,P,C=F){ht(C);let{context:Y}=C,W=C.zip215===void 0?!!F.zip215:C.zip215,w=O.signature;I=j(I,w,"signature"),K=j(K,void 0,"message"),P=j(P,O.publicKey,"publicKey"),W!==void 0&&ut(W,"zip215"),s&&(K=s(K));let h=w/2,d=I.subarray(0,h),y=ne(I.subarray(h,w)),B,T,R;try{B=r.fromBytes(P,W),T=r.fromBytes(d,W),R=i.multiplyUnsafe(y)}catch{return!1}if(!W&&B.isSmallOrder())return!1;let L=E(Y,d,P,K);return T.add(B.multiplyUnsafe(L)).subtract(R).clearCofactor().is0()}let U=c.BYTES,O={secretKey:U,publicKey:U,signature:2*U,seed:U};function D(I){return I=I===void 0?l(O.seed):I,j(I,O.seed,"seed")}function z(I){return qt(I)&&I.length===O.secretKey}function M(I,K){try{return!!r.fromBytes(I,K===void 0?F.zip215:K)}catch{return!1}}let Z={getExtendedPublicKey:_,randomSecretKey:D,isValidSecretKey:z,isValidPublicKey:M,toMontgomery(I){if(b===void 0)throw new Error("Montgomery conversion is not supported for this curve");return b(r.fromBytes(I))},toMontgomerySecret(I){if(m===void 0)throw new Error("Montgomery conversion is not supported for this curve");return m(I)}};return Object.freeze(O),Object.freeze(Z),Object.freeze({keygen:Ar(D,p),getPublicKey:p,sign:S,verify:N,utils:Z,Point:r,lengths:O})}var Xn=BigInt(1),Xs=BigInt(2);var Qa=BigInt(5),tf=BigInt(8),Wn=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),ef={p:Wn,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:tf,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function rf(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=Wn,c=r*r%s*r%s,a=X(c,Xs,s)*c%s,f=X(a,Xn,s)*r%s,u=X(f,Qa,s)*f%s,l=X(u,t,s)*u%s,b=X(l,e,s)*l%s,m=X(b,n,s)*b%s,v=X(m,o,s)*m%s,g=X(v,o,s)*m%s,A=X(g,t,s)*u%s;return{pow_p_5_8:X(A,Xs,s)*r%s,b2:c}}function Qs(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}var Ws=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function nf(r,t){let e=Wn,n=J(t*t*t,e),o=J(n*n*t,e),s=rf(r*o).pow_p_5_8,i=J(r*n*s,e),c=J(t*i*i,e),a=i,f=J(i*Ws,e),u=c===r,l=c===J(-r,e),b=c===J(-r*Ws,e);return u&&(i=a),(l||b)&&(i=f),Ms(i,e)&&(i=J(-i,e)),{isValid:u||l,value:i}}var Jn=$s(ef,{uvRatio:nf}),Js=Jn.Fp;function of(r){let{y:t}=r;return Js.toBytes(Js.div(Xn+t,Xn-t))}function sf(r){let t=Jn.Fp.BYTES;return wt(r,t),Qs(Pn(r.subarray(0,t))).subarray(0,t)}function cf(r){return Gs(Jn,Pn,Object.assign({adjustScalarBytes:Qs,toMontgomery:of,toMontgomerySecret:sf,zip215:!0},r))}var ti=cf({});var je=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Rr=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Or={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new Rr("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 Cr=32;var Qn,af=(async()=>{try{return await Or.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function ff(r,t,e){if(r.buffer instanceof ArrayBuffer){let n=await Or.get().subtle.importKey("raw",r.buffer,{name:"Ed25519"},!1,["verify"]);return await Or.get().subtle.verify({name:"Ed25519"},n,kt(t),kt(e instanceof Uint8Array?e:e.subarray()))}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function uf(r,t,e){return ti.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}async function ei(r,t,e){return Qn==null&&(Qn=await af),Qn?ff(r,t,e):uf(r,t,e)}function Dr(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var Lr=class{type="Ed25519";raw;constructor(t){this.raw=to(t,Cr)}toMultihash(){return St.digest(ye(this))}toCID(){return ft.createV1(114,this.toMultihash())}toString(){return rt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:dt(this.raw,t.raw)}verify(t,e,n){n?.signal?.throwIfAborted();let o=ei(this.raw,e,t);return Dr(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function ni(r){return r=to(r,Cr),new Lr(r)}function to(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new Ot(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var lf=Math.pow(2,7),df=Math.pow(2,14),pf=Math.pow(2,21),oi=Math.pow(2,28),si=Math.pow(2,35),ii=Math.pow(2,42),ci=Math.pow(2,49),ct=128,Vt=127;function Ve(r){if(r<lf)return 1;if(r<df)return 2;if(r<pf)return 3;if(r<oi)return 4;if(r<si)return 5;if(r<ii)return 6;if(r<ci)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ai(r,t,e=0){switch(Ve(r)){case 8:t[e++]=r&255|ct,r/=128;case 7:t[e++]=r&255|ct,r/=128;case 6:t[e++]=r&255|ct,r/=128;case 5:t[e++]=r&255|ct,r/=128;case 4:t[e++]=r&255|ct,r>>>=7;case 3:t[e++]=r&255|ct,r>>>=7;case 2:t[e++]=r&255|ct,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function fi(r,t){let e=r[t],n=0;if(n+=e&Vt,e<ct||(e=r[t+1],n+=(e&Vt)<<7,e<ct)||(e=r[t+2],n+=(e&Vt)<<14,e<ct)||(e=r[t+3],n+=(e&Vt)<<21,e<ct)||(e=r[t+4],n+=(e&Vt)*oi,e<ct)||(e=r[t+5],n+=(e&Vt)*si,e<ct)||(e=r[t+6],n+=(e&Vt)*ii,e<ct)||(e=r[t+7],n+=(e&Vt)*ci,e<ct))return n;throw new RangeError("Could not decode varint")}var eo=new Float32Array([-0]),Zt=new Uint8Array(eo.buffer);function ui(r,t,e){eo[0]=r,t[e]=Zt[0],t[e+1]=Zt[1],t[e+2]=Zt[2],t[e+3]=Zt[3]}function hi(r,t){return Zt[0]=r[t],Zt[1]=r[t+1],Zt[2]=r[t+2],Zt[3]=r[t+3],eo[0]}var ro=new Float64Array([-0]),it=new Uint8Array(ro.buffer);function li(r,t,e){ro[0]=r,t[e]=it[0],t[e+1]=it[1],t[e+2]=it[2],t[e+3]=it[3],t[e+4]=it[4],t[e+5]=it[5],t[e+6]=it[6],t[e+7]=it[7]}function di(r,t){return it[0]=r[t],it[1]=r[t+1],it[2]=r[t+2],it[3]=r[t+3],it[4]=r[t+4],it[5]=r[t+5],it[6]=r[t+6],it[7]=r[t+7],ro[0]}var mf=BigInt(Number.MAX_SAFE_INTEGER),yf=BigInt(Number.MIN_SAFE_INTEGER),yt=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return oe;if(t<mf&&t>yf)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>pi&&(o=0n,++n>pi&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return oe;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):oe}},oe=new yt(0,0);oe.toBigInt=function(){return 0n};oe.zzEncode=oe.zzDecode=function(){return this};oe.length=function(){return 1};var pi=4294967296n;function mi(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function yi(r,t,e){if(e-t<1)return"";let o,s=[],i=0,c;for(;t<e;)c=r[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function no(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function At(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Fr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var oo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=kt(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,At(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 At(this,4);return Fr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw At(this,4);return Fr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw At(this,4);let t=hi(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw At(this,4);let t=di(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw At(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,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 At(this,t);this.pos+=t}else do if(this.pos>=this.len)throw At(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new yt(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw At(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw At(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw At(this,8);let t=Fr(this.buf,this.pos+=4),e=Fr(this.buf,this.pos+=4);return new yt(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=fi(this.buf,this.pos);return this.pos+=Ve(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Ze(r){return new oo(r instanceof Uint8Array?r:r.subarray())}function Ur(r,t,e){let n=Ze(r);return t.decode(n,void 0,e)}function so(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return pt(i);o+i>t&&(n=pt(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var se=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function io(){}var ao=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},bf=so();function gf(r){return globalThis.Buffer!=null?pt(r):bf(r)}var $e=class{len;head;tail;states;constructor(){this.len=0,this.head=new se(io,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new se(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new fo((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(kr,10,yt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=yt.fromBigInt(t);return this._push(kr,e.length(),e)}uint64Number(t){return this._push(ai,Ve(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=yt.fromBigInt(t).zzEncode();return this._push(kr,e.length(),e)}sint64Number(t){let e=yt.fromNumber(t).zzEncode();return this._push(kr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(co,1,t?1:0)}fixed32(t){return this._push(Ye,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=yt.fromBigInt(t);return this._push(Ye,4,e.lo)._push(Ye,4,e.hi)}fixed64Number(t){let e=yt.fromNumber(t);return this._push(Ye,4,e.lo)._push(Ye,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(ui,4,t)}double(t){return this._push(li,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(co,1,0):this.uint32(e)._push(wf,e,t)}string(t){let e=mi(t);return e!==0?this.uint32(e)._push(no,e,t):this._push(co,1,0)}fork(){return this.states=new ao(this),this.head=this.tail=new se(io,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 se(io,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=gf(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function co(r,t,e){t[e]=r&255}function xf(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var fo=class extends se{next;constructor(t,e){super(xf,t,e),this.next=void 0}};function kr(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Ye(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function wf(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&($e.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Ef,t,r),this},$e.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Sf,t,r),this});function Ef(r,t,e){t.set(r,e)}function Sf(r,t,e){r.length<40?no(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(st(r),e)}function uo(){return new $e}function Nr(r,t){let e=uo();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}function*Kr(r,t,e){let n=Ze(r);yield*t.stream(n,void 0,"$",e)}var Pr={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function Mr(r,t,e,n,o){return{name:r,type:t,encode:e,decode:n,stream:o}}function ho(r){function t(s){if(r[s.toString()]==null)throw new Error("Invalid enum value");return r[s]}let e=function(i,c){let a=t(i);c.int32(a)},n=function(i){let c=i.int32();return t(c)},o=function*(i){let c=i.int32();yield t(c)};return Mr("enum",Pr.VARINT,e,n,o)}function zr(r,t,e){return Mr("message",Pr.LENGTH_DELIMITED,r,t,e)}var at;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(at||(at={}));var lo;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(lo||(lo={}));(function(r){r.codec=()=>ho(lo)})(at||(at={}));var Ge;(function(r){let t;r.codec=()=>(t==null&&(t=zr((s,i,c={})=>{c.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),at.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),c.lengthDelimited!==!1&&i.ldelim()},(s,i,c={})=>{let a={},f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{a.Type=at.codec().decode(s);break}case 2:{a.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return a},function*(s,i,c,a={}){let f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${c}.Type`,value:at.codec().decode(s)};break}case 2:{yield{field:`${c}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function e(s){return Nr(s,r.codec())}r.encode=e;function n(s,i){return Ur(s,r.codec(),i)}r.decode=n;function o(s,i){return Kr(s,r.codec(),i)}r.stream=o})(Ge||(Ge={}));var po;(function(r){let t;r.codec=()=>(t==null&&(t=zr((s,i,c={})=>{c.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),at.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),c.lengthDelimited!==!1&&i.ldelim()},(s,i,c={})=>{let a={},f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{a.Type=at.codec().decode(s);break}case 2:{a.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return a},function*(s,i,c,a={}){let f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${c}.Type`,value:at.codec().decode(s)};break}case 2:{yield{field:`${c}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function e(s){return Nr(s,r.codec())}r.encode=e;function n(s,i){return Ur(s,r.codec(),i)}r.decode=n;function o(s,i){return Kr(s,r.codec(),i)}r.stream=o})(po||(po={}));var qr=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,e){if(fr(t),wt(e,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(e.length>n?t.create().update(e).digest():e);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=t.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),te(o)}update(t){return be(this),this.iHash.update(t),this}digestInto(t){be(this),ur(t,this),this.finished=!0;let e=t.subarray(0,this.outputLen);this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c,canXOF:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.canXOF=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},gi=(()=>{let r=((t,e,n)=>new qr(t,e).update(n).digest());return r.create=(t,e)=>new qr(t,e),r})();var Bf=BigInt(0),mo=class extends Error{constructor(t=""){super(t)}},Lt={Err:mo,_tlv:{encode:(r,t)=>{let{Err:e}=Lt;if(Dt(r,"tag"),r<0||r>255)throw new e("tlv.encode: wrong tag");if(Is(t,"data"),t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=Pe(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Pe(o.length/2|128):"";return Pe(r)+s+o+t},decode(r,t){let{Err:e}=Lt;t=j(t,void 0,"DER data");let n=0;if(r<0||r>255)throw new e("tlv.decode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let a=o&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+a);if(f.length!==a)throw new e("tlv.decode: length bytes not complete");if(f[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of f)i=i<<8|u;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Lt;if(yr(r),r<Bf)throw new t("integer: negative integers are not allowed");let e=Pe(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=Lt;if(r.length<1)throw new t("invalid signature integer: empty");if(r[0]&128)throw new t("invalid signature integer: negative");if(r.length>1&&r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Tt(r)}},toSig(r,t){let{Err:e,_int:n,_tlv:o}=Lt;if(t!==void 0&&(Dt(t,"maxScalarBytes"),t<1))throw new e("invalid signature: maxScalarBytes must be positive");let s=j(r,void 0,"signature"),{v:i,l:c}=o.decode(48,s);if(c.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:f}=o.decode(2,i),{v:u,l}=o.decode(2,f);if(l.length)throw new e("invalid signature: left bytes after parsing");if(t!==void 0&&(a.length>t||u.length>t))throw new e("invalid signature: integer too large");return{r:n.decode(a),s:n.decode(u)}},hexFromSig(r){let{_tlv:t,_int:e}=Lt;ht(r,{r:"bigint",s:"bigint"},{},"sig");let n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},Hr=(Object.freeze(Lt._tlv),Object.freeze(Lt._int),Object.freeze(Lt));var xi=(r,t)=>(r+(r>=0?t:-t)/wi)/t;function Af(r,t,e){xe("scalar",r,Ft,e);let[[n,o],[s,i]]=t,c=xi(i*r,e),a=xi(-o*r,e),f=r-c*n-a*s,u=-c*o-a*i,l=f<Ft,b=u<Ft;l&&(f=-f),b&&(u=-u);let m=ze(Math.ceil(we(e)/2))+ie;if(f<Ft||f>=m||u<Ft||u>=m)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:l,k1:f,k2neg:b,k2:u}}function go(r){if(!["compact","recovered","der"].includes(r))throw new Error('Signature format must be "compact", "recovered", or "der"');return r}function yo(r,t){ht(r);let e={};for(let n of Object.keys(t))e[n]=r[n]===void 0?t[n]:r[n];return ut(e.lowS,"lowS"),ut(e.prehash,"prehash"),e.format!==void 0&&go(e.format),e}var Ft=BigInt(0),ie=BigInt(1),wi=BigInt(2),bo=BigInt(3),vf=BigInt(4);function Ei(r,t={}){let e=Br("weierstrass",r,t),n=e.Fp,o=e.Fn,s=e.CURVE,{h:i,n:c}=s;ht(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:a,allowInfinityPoint:f,clearCofactor:u,isTorsionFree:l,fromBytes:b,toBytes:m}=t,v=t.randomBytes===void 0?re:t.randomBytes;if(a&&(!n.is0(s.a)||typeof a.beta!="bigint"||!Array.isArray(a.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let g=a?{beta:a.beta,basises:a.basises.map(w=>[...w])}:void 0,A=_i(n,o);function x(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function _(w,h,d){if(h.is0()){if(!f)throw new Error("bad point: ZERO");return Uint8Array.of(0)}let{x:y,y:B}=h.toAffine(),T=n.toBytes(y);if(ut(d,"isCompressed"),d){x();let R=!n.isOdd(B);return Et(Si(R),T)}else return Et(Uint8Array.of(4),T,n.toBytes(B))}function p(w){j(w,void 0,"Point");let{publicKey:h,publicKeyUncompressed:d}=A,y=w.length,B=w[0],T=w.subarray(1);if(f&&y===1&&B===0)return{x:n.ZERO,y:n.ZERO};if(y===h&&(B===2||B===3)){let R=n.fromBytes(T);if(!n.isValid(R))throw new Error("bad point: is not on curve, wrong x");let L=U(R),k;try{k=n.sqrt(L)}catch(tt){let $=tt instanceof Error?": "+tt.message:"";throw new Error("bad point: is not on curve, sqrt error"+$)}x();let H=n.isOdd(k);return(B&1)===1!==H&&(k=n.neg(k)),{x:R,y:k}}else if(y===d&&B===4){let R=n.BYTES,L=n.fromBytes(T.subarray(0,R)),k=n.fromBytes(T.subarray(R,R*2));if(!O(L,k))throw new Error("bad point: is not on curve");return{x:L,y:k}}else throw new Error(`bad point: got length ${y}, expected compressed=${h} or uncompressed=${d}`)}let E=m===void 0?_:m,S=b===void 0?p:b,F=n.mul(s.b,bo),N=n.is0(s.a)?w=>n.ZERO:w=>n.mul(s.a,w);function U(w){let h=n.sqr(w),d=n.mul(h,w);return n.add(n.add(d,n.mul(w,s.a)),s.b)}function O(w,h){let d=n.sqr(h),y=U(w);return n.eql(d,y)}if(!O(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let D=n.mul(n.pow(s.a,bo),vf),z=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(D,z)))throw new Error("bad curve params: a or b");function M(w,h,d=!1){if(!n.isValid(h)||d&&n.is0(h))throw new Error(`bad point coordinate ${w}`);return typeof h=="object"&&h!==null?n.create(h):h}function Z(w){if(!(w instanceof C))throw new Error("Weierstrass Point expected")}function I(w){if(!g||!g.basises)throw new Error("no endo");return Af(w,g.basises,o.ORDER)}function K(w,h,d,y){if(!o.isValid(y))throw new RangeError("invalid scalar: out of range");if(g){let{k1neg:B,k1:T,k2neg:R,k2:L}=I(y),k=new C(n.mul(d.X,g.beta),d.Y,d.Z);w.push(B?d.negate():d,R?k.negate():k),h.push(T,L)}else w.push(d),h.push(y)}let P=new WeakSet;class C{static BASE=new C(s.Gx,s.Gy,n.ONE);static ZERO=new C(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(h,d,y){this.X=M("x",h),this.Y=M("y",d,!0),this.Z=M("z",y),Object.freeze(this)}static CURVE(){return s}static fromAffine(h){let{x:d,y}=h||{};if(!h||!n.isValid(d)||!n.isValid(y))throw new Error("invalid affine point");if(h instanceof C)throw new Error("projective point not allowed");return n.is0(d)&&n.is0(y)?C.ZERO:new C(d,y,n.ONE)}static fromBytes(h){let d=C.fromAffine(S(j(h,void 0,"point")));return d.assertValidity(),d}static fromHex(h){return C.fromBytes(ge(h))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(h=6,d=!0){return W.setWindowSize(this,h),d||this.multiply(bo),this}assertValidity(){let h=this;if(h.is0()){if(f&&n.is0(h.X)&&n.eql(h.Y,n.ONE)&&n.is0(h.Z))return;throw new Error("bad point: ZERO")}if(P.has(h))return;let{x:d,y}=h.toAffine();if(!n.isValid(d)||!n.isValid(y))throw new Error("bad point: x or y not field elements");if(!O(d,y))throw new Error("bad point: equation left != right");if(!h.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");P.add(h)}hasEvenY(){let{y:h}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(h)}equals(h){Z(h);let{X:d,Y:y,Z:B}=this,{X:T,Y:R,Z:L}=h,k=n.eql(n.mul(d,L),n.mul(T,B)),H=n.eql(n.mul(y,L),n.mul(R,B));return k&&H}negate(){return new C(this.X,n.neg(this.Y),this.Z)}double(){let{X:h,Y:d,Z:y}=this,B=n.ZERO,T=n.ZERO,R=n.ZERO,L=n.mul(h,h),k=n.mul(d,d),H=n.mul(y,y),q=n.mul(h,d);return q=n.add(q,q),R=n.mul(h,y),R=n.add(R,R),B=N(R),T=n.mul(F,H),T=n.add(B,T),B=n.sub(k,T),T=n.add(k,T),T=n.mul(B,T),B=n.mul(q,B),R=n.mul(F,R),H=N(H),q=n.sub(L,H),q=N(q),q=n.add(q,R),R=n.add(L,L),L=n.add(R,L),L=n.add(L,H),L=n.mul(L,q),T=n.add(T,L),H=n.mul(d,y),H=n.add(H,H),L=n.mul(H,q),B=n.sub(B,L),R=n.mul(H,k),R=n.add(R,R),R=n.add(R,R),new C(B,T,R)}add(h){Z(h);let{X:d,Y:y,Z:B}=this,{X:T,Y:R,Z:L}=h,k=n.ZERO,H=n.ZERO,q=n.ZERO,tt=n.mul(d,T),$=n.mul(y,R),ot=n.mul(B,L),bt=n.add(d,y),G=n.add(T,R);bt=n.mul(bt,G),G=n.add(tt,$),bt=n.sub(bt,G),G=n.add(d,B);let et=n.add(T,L);return G=n.mul(G,et),et=n.add(tt,ot),G=n.sub(G,et),et=n.add(y,B),k=n.add(R,L),et=n.mul(et,k),k=n.add($,ot),et=n.sub(et,k),q=N(G),k=n.mul(F,ot),q=n.add(k,q),k=n.sub($,q),q=n.add($,q),H=n.mul(k,q),$=n.add(tt,tt),$=n.add($,tt),ot=N(ot),G=n.mul(F,G),$=n.add($,ot),ot=n.sub(tt,ot),ot=N(ot),G=n.add(G,ot),tt=n.mul($,G),H=n.add(H,tt),tt=n.mul(et,G),k=n.mul(bt,k),k=n.sub(k,tt),tt=n.mul(bt,$),q=n.mul(et,q),q=n.add(q,tt),new C(k,H,q)}subtract(h){return Z(h),this.add(h.negate())}is0(){return this.equals(C.ZERO)}multiply(h){if(!o.isValidNot0(h))throw new RangeError("invalid scalar: out of range");let{p:d,f:y}=W.mulSecret(this,h,i,Y);return Y([d,y])[0]}multiplyUnsafe(h){let d=this,y=h;if(!o.isValid(y))throw new RangeError("invalid scalar: out of range");if(y===Ft||d.is0())return C.ZERO;if(y===ie)return d;if(W.hasWindowSize(this))return W.mulUnsafe(d,y,Y);let B=[],T=[];return K(B,T,d,y),_r(C,B,T)}mulAddUnsafe(h,d,y){Z(d);let B=[],T=[];return K(B,T,this,h),K(B,T,d,y),_r(C,B,T)}toAffine(h){let d=this,y=h;if(y!=null&&!n.isValid(y))throw new RangeError('"invertedZ" expected valid field element');let{X:B,Y:T,Z:R}=d;if(n.eql(R,n.ONE))return{x:B,y:T};let L=d.is0();y==null&&(y=L?n.ONE:n.inv(R));let k=n.mul(B,y),H=n.mul(T,y),q=n.mul(R,y);if(L)return{x:n.ZERO,y:n.ZERO};if(!n.eql(q,n.ONE))throw new Error("invZ was invalid");return{x:k,y:H}}isTorsionFree(){return i===ie?!0:l?l(C,this):W.mulUnsafe(this,c).is0()}clearCofactor(){return i===ie?this:u?u(C,this):this.multiplyUnsafe(i)}isSmallOrder(){return i===ie?this.is0():this.clearCofactor().is0()}toBytes(h=!0){return ut(h,"isCompressed"),this.assertValidity(),E(C,this,h)}toHex(h=!0){return Ke(this.toBytes(h))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let Y=w=>Sr(C,w),W=new _e(C,v);return W.bits>=6&&C.BASE.precompute(6),Object.freeze(C.prototype),Object.freeze(C),C}function Si(r){return Uint8Array.of(r?2:3)}function _i(r,t){return{secretKey:t.BYTES,publicKey:1+r.BYTES,publicKeyUncompressed:1+2*r.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function If(r,t={}){jt(r);let{Fn:e}=r,n=t.randomBytes===void 0?re:t.randomBytes,o=Object.assign(_i(r.Fp,e),{seed:Math.max(wr(e.ORDER),16)});function s(m){try{let v=e.fromBytes(m);return e.isValidNot0(v)}catch{return!1}}function i(m,v){let{publicKey:g,publicKeyUncompressed:A}=o;try{let x=m.length;return v===!0&&x!==g||v===!1&&x!==A?!1:!r.fromBytes(m).is0()}catch{return!1}}function c(m){return m=m===void 0?n(o.seed):m,Er(j(m,o.seed,"seed"),e.ORDER)}function a(m,v=!0){return r.BASE.multiply(e.fromBytes(m)).toBytes(v)}function f(m){let{secretKey:v,publicKey:g,publicKeyUncompressed:A}=o,x=e._lengths;if(!qt(m))return;let _=j(m,void 0,"key").length,p=_===g||_===A,E=_===v||!!x?.includes(_);if(!(p&&E))return p}function u(m,v,g=!0){if(f(m)===!0)throw new Error("first arg must be private key");if(f(v)===!1)throw new Error("second arg must be public key");let A=e.fromBytes(m),x=r.fromBytes(v);if(x.is0())throw new Error("invalid public key: point at infinity");return x.multiply(A).toBytes(g)}let l={isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:c},b=Ar(c,a);return Object.freeze(l),Object.freeze(o),Object.freeze({getPublicKey:a,getSharedSecret:u,keygen:b,Point:r,utils:l,lengths:o})}function Bi(r,t,e={}){jt(r);let n=t;fr(n),ht(e,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let o=Object.assign({},e),s=o.randomBytes===void 0?re:o.randomBytes,i=o.hmac===void 0?(w,h)=>gi(n,w,h):o.hmac,{Fp:c,Fn:a}=r,{ORDER:f,BITS:u}=a,l=wr(f),b=Gn(s,l),{keygen:m,getPublicKey:v,getSharedSecret:g,utils:A,lengths:x}=If(r,o),_={prehash:!0,lowS:typeof o.lowS=="boolean"?o.lowS:!0,format:"compact",extraEntropy:!1},p=f*wi+ie<c.ORDER;function E(w){let h=f>>ie;return w>h}function S(w,h){if(!a.isValidNot0(h))throw new Error(`invalid signature ${w}: out of range 1..Point.Fn.ORDER`);return h}function F(){if(!c.isOdd)throw new Error("Field doesn't support isOdd")}function N(w,h,d){return F(),(w===d?0:2)|Number(c.isOdd(h))}function U(){if(p)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function O(w,h){go(h);let d=x.signature,y=h==="compact"?d:h==="recovered"?d+1:void 0;return j(w,y)}class D{r;s;recovery;constructor(h,d,y){if(this.r=S("r",h),this.s=S("s",d),y!=null){if(U(),![0,1,2,3].includes(y))throw new Error("invalid recovery id");this.recovery=y}Object.freeze(this)}static fromBytes(h,d=_.format){O(h,d);let y;if(d==="der"){if(h.length>2*a.BYTES+16)throw new Hr.Err("invalid signature: DER signature too long");let{r:L,s:k}=Hr.toSig(j(h),a.BYTES+1);return new D(L,k)}d==="recovered"&&(y=h[0],d="compact",h=h.subarray(1));let B=x.signature/2,T=h.subarray(0,B),R=h.subarray(B,B*2);return new D(a.fromBytes(T),a.fromBytes(R),y)}static fromHex(h,d){return this.fromBytes(ge(h),d)}assertRecovery(){let{recovery:h}=this;if(h==null)throw new Error("invalid recovery id: must be present");return h}addRecoveryBit(h){return new D(this.r,this.s,h)}recoverPublicKey(h){let{r:d,s:y}=this,B=this.assertRecovery(),T=B===2||B===3?d+f:d;if(!c.isValid(T))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let R=c.toBytes(T),L=r.fromBytes(Et(Si((B&1)===0),R)),k=a.inv(T),H=M(j(h,void 0,"msgHash")),q=a.create(-H*k),tt=a.create(y*k),$=r.BASE.mulAddUnsafe(q,L,tt);if($.is0())throw new Error("invalid recovery: point at infinify");return $.assertValidity(),$}hasHighS(){return E(this.s)}toBytes(h=_.format){if(go(h),h==="der")return ge(Hr.hexFromSig(this));let{r:d,s:y}=this,B=a.toBytes(d),T=a.toBytes(y);return h==="recovered"?(U(),Et(Uint8Array.of(this.assertRecovery()),B,T)):Et(B,T)}toHex(h){return Ke(this.toBytes(h))}}Object.freeze(D.prototype),Object.freeze(D);let z=o.bits2int===void 0?function(h){if(h.length>8192)throw new Error("input is too large");let d=Tt(h),y=h.length*8-u;return y>0?d>>BigInt(y):d}:o.bits2int,M=o.bits2int_modN===void 0?function(h){return a.create(z(h))}:o.bits2int_modN,Z=ze(u);function I(w){return xe("num < 2^"+u,w,Ft,Z),a.toBytes(w)}function K(w,h){return j(w,void 0,"message"),h?j(n(w),void 0,"prehashed message"):w}function P(w,h,d){let{lowS:y,prehash:B,extraEntropy:T}=yo(d,_);w=K(w,B);let R=M(w),L=a.fromBytes(h);if(!a.isValidNot0(L))throw new Error("invalid private key");let k=[I(L),I(R)];if(T!=null&&T!==!1){let $=T===!0?s(x.secretKey):T;k.push(j($,void 0,"extraEntropy"))}let H=Et(...k),q=R;function tt($){let ot=z($);if(!a.isValidNot0(ot))return;let bt=r.BASE.multiply(ot).toAffine(),G=a.create(bt.x);if(G===Ft)return;let et;if(b!==void 0){let Ae=Tt(Er(b(l),f)),Hi=a.inv(a.mul(Ae,ot)),ji=a.mul(Ae,q),Vi=a.mul(Ae,L);et=a.create(Hi*a.create(ji+Vi*G))}else{let Ae=Ns(ot,f);et=a.create(Ae*a.create(q+G*L))}if(et===Ft)return;let Wr=N(bt.x,bt.y,G),To=et;return y&&E(et)&&(To=a.neg(et),Wr^=1),new D(G,To,p?void 0:Wr)}return{seed:H,k2sig:tt}}function C(w,h,d={}){let{seed:y,k2sig:B}=P(w,h,d);return Rs(n.outputLen,a.BYTES,i)(y,B).toBytes(d.format)}function Y(w,h,d,y={}){let{lowS:B,prehash:T,format:R}=yo(y,_);if(d=j(d,void 0,"publicKey"),h=K(h,T),!qt(w)){let L=w instanceof D?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+L)}O(w,R);try{let L=D.fromBytes(w,R),k=r.fromBytes(d);if(k.is0()||B&&L.hasHighS())return!1;let{r:H,s:q}=L,tt=M(h),$=a.inv(q),ot=a.create(tt*$),bt=a.create(H*$),G=r.BASE.mulAddUnsafe(ot,k,bt);if(G.is0())return!1;let et=G.toAffine();return!(a.create(et.x)!==H||R==="recovered"&&L.recovery!==N(et.x,et.y,H))}catch{return!1}}function W(w,h,d={}){let{prehash:y}=yo(d,_);return h=K(h,y),D.fromBytes(w,"recovered").recoverPublicKey(h).toBytes()}return Object.freeze({keygen:m,getPublicKey:v,getSharedSecret:g,utils:A,lengths:x,Point:r,sign:C,verify:Y,recoverPublicKey:W,Signature:D,hash:n})}var wo={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Tf={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Ai=BigInt(2);function Rf(r){let t=wo.p,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),f=r*r*r%t,u=f*f*r%t,l=X(u,e,t)*u%t,b=X(l,e,t)*u%t,m=X(b,Ai,t)*f%t,v=X(m,o,t)*m%t,g=X(v,s,t)*v%t,A=X(g,c,t)*g%t,x=X(A,a,t)*A%t,_=X(x,c,t)*g%t,p=X(_,e,t)*u%t,E=X(p,i,t)*v%t,S=X(E,n,t)*f%t,F=X(S,Ai,t);if(!xo.eql(xo.sqr(F),r))throw new Error("Cannot find square root");return F}var xo=Se(wo.p,{sqrt:Rf}),Of=Ei(wo,{Fp:xo,endo:Tf}),Be=Bi(Of,As);function vi(r,t,e,n){let o=De.digest(e instanceof Uint8Array?e:e.subarray());if(Dr(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),Be.verify(t,s,r,{prehash:!1,format:"der"}))).catch(s=>{throw s.name==="AbortError"?s:new je(String(s))});try{return n?.signal?.throwIfAborted(),Be.verify(t,o.digest,r,{prehash:!1,format:"der"})}catch(s){throw new je(String(s))}}var jr=class{type="secp256k1";raw;_key;constructor(t){this._key=Ti(t),this.raw=Ii(this._key)}toMultihash(){return St.digest(ye(this))}toCID(){return ft.createV1(114,this.toMultihash())}toString(){return rt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:dt(this.raw,t.raw)}verify(t,e,n){return vi(this._key,e,t,n)}};function Ri(r){return new jr(r)}function Ii(r){return Be.Point.fromBytes(r).toBytes()}function Ti(r){try{return Be.Point.fromBytes(r),r}catch(t){throw new tr(String(t))}}function Oi(r){let{Type:t,Data:e}=Ge.decode(r.digest),n=e??new Uint8Array;switch(t){case at.Ed25519:return ni(n);case at.secp256k1:return Ri(n);case at.ECDSA:return os(n);default:throw new ve}}function ye(r){return Ge.encode({Type:at[r.type],Data:r.raw})}var Ci=Symbol.for("nodejs.util.inspect.custom"),Cf=114,Xe=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()})`}[Qr]=!0;toString(){return this.string==null&&(this.string=rt.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ft.createV1(Cf,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return dt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return dt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Ci](){return`PeerId(${this.toString()})`}},Vr=class extends Xe{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Zr=class extends Xe{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Yr=class extends Xe{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Df=2336,$r=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=St.digest(st(this.url))}[Ci](){return`PeerId(${this.url})`}[Qr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ft.createV1(Df,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=xt(t)),t.toString()===this.toString())}};function Di(r){if(Ff(r))return new Vr({multihash:r});if(Lf(r))try{let t=Oi(r);if(t.type==="Ed25519")return new Zr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Yr({multihash:r,publicKey:t})}catch{let e=xt(r.digest);return new $r(new URL(e))}throw new er("Supplied PeerID Multihash is invalid")}function Lf(r){return r.code===St.code}function Ff(r){return r.code===De.code}function Rt(r,t){let e={[Symbol.iterator]:()=>e,next:()=>{let n=r.next(),o=n.value;return n.done===!0||o==null?{done:!0,value:void 0}:{done:!1,value:t(o)}}};return e}function Gr(r){let t=Oe(rt.decode(`z${r}`));return Di(t)}var Yt=class{map;constructor(t){if(this.map=new Map,t!=null)for(let[e,n]of t.entries())this.map.set(e.toString(),{key:e,value:n})}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(t){return this.map.delete(t.toString())}entries(){return Rt(this.map.entries(),t=>[t[1].key,t[1].value])}forEach(t){this.map.forEach((e,n)=>{t(e.value,e.key,this)})}get(t){return this.map.get(t.toString())?.value}has(t){return this.map.has(t.toString())}set(t,e){this.map.set(t.toString(),{key:t,value:e})}keys(){return Rt(this.map.values(),t=>t.key)}values(){return Rt(this.map.values(),t=>t.value)}get size(){return this.map.size}};function Li(){return new Yt}var $t=class r{set;constructor(t){if(this.set=new Set,t!=null)for(let e of t)this.set.add(e.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(t){this.set.add(t.toString())}clear(){this.set.clear()}delete(t){this.set.delete(t.toString())}entries(){return Rt(this.set.entries(),t=>{let e=Gr(t[0]);return[e,e]})}forEach(t){this.set.forEach(e=>{let n=Gr(e);t(n,n,this)})}has(t){return this.set.has(t.toString())}values(){return Rt(this.set.values(),t=>Gr(t))}intersection(t){let e=new r;for(let n of t)this.has(n)&&e.add(n);return e}difference(t){let e=new r;for(let n of this)t.has(n)||e.add(n);return e}union(t){let e=new r;for(let n of t)e.add(n);for(let n of this)e.add(n);return e}};function Fi(){return new $t}var Gt=class r{list;constructor(t){if(this.list=[],t!=null)for(let e of t)this.list.push(e)}[Symbol.iterator](){return Rt(this.list.entries(),t=>t[1])}concat(t){let e=new r(this);for(let n of t)e.push(n);return e}entries(){return Rt(this.list.entries(),t=>[t[0],t[1]])}every(t){return this.list.every((e,n)=>t(e,n,this))}filter(t){let e=new r;return this.list.forEach((n,o)=>{t(n,o,this)&&e.push(n)}),e}find(t){let e=this.list.find((n,o)=>t(n,o,this));if(e!=null)return e}findIndex(t){return this.list.findIndex((e,n)=>t(e,n,this))}forEach(t){this.list.forEach((e,n)=>{t(e,n,this)})}includes(t){return this.includes(t)}indexOf(t){return this.list.findIndex(e=>e.equals(t))}pop(){let t=this.list.pop();if(t!=null)return t}push(...t){for(let e of t)this.list.push(e)}shift(){let t=this.list.shift();if(t!=null)return t}unshift(...t){let e=this.list.length;for(let n=t.length-1;n>-1;n--)e=this.list.unshift(t[n]);return e}clear(){this.list=[]}get length(){return this.list.length}};function Ui(){return new Gt}var Eo={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},ki={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},Ni=new globalThis.TextEncoder;function Uf(r,t){let e=Eo[t],n=ki[t];for(let o=0;o<r.length;o++)n^=BigInt(r[o]),n=BigInt.asUintN(t,n*e);return n}function kf(r,t,e){if(e.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");let n=Eo[t],o=ki[t],s=r;for(;s.length>0;){let i=Ni.encodeInto(s,e);s=s.slice(i.read);for(let c=0;c<i.written;c++)o^=BigInt(e[c]),o=BigInt.asUintN(t,o*n)}return o}function So(r,{size:t=32,utf8Buffer:e}={}){if(!Eo[t])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if(typeof r=="string"){if(e)return kf(r,t,e);r=Ni.encode(r)}return Uf(r,t)}var We={hash:r=>Number(So(r,{size:32})),hashV:(r,t)=>Nf(We.hash(r,t))};function Nf(r){let t=r.toString(16);return t.length%2===1&&(t=`0${t}`),st(t,"base16")}var _o=64,vt=class{fp;h;seed;constructor(t,e,n,o=2){if(o>_o)throw new TypeError("Invalid Fingerprint Size");let s=e.hashV(t,n),i=_t(o);for(let c=0;c<i.length;c++)i[c]=s[c];i.length===0&&(i[0]=7),this.fp=i,this.h=e,this.seed=n}hash(){return this.h.hash(this.fp,this.seed)}equals(t){return t?.fp instanceof Uint8Array?dt(this.fp,t.fp):!1}};function ce(r,t){return Math.floor(Math.random()*(t-r))+r}var ae=class{contents;constructor(t){this.contents=new Array(t).fill(null)}has(t){if(!(t instanceof vt))throw new TypeError("Invalid Fingerprint");return this.contents.some(e=>t.equals(e))}add(t){if(!(t instanceof vt))throw new TypeError("Invalid Fingerprint");for(let e=0;e<this.contents.length;e++)if(this.contents[e]==null)return this.contents[e]=t,!0;return!0}swap(t){if(!(t instanceof vt))throw new TypeError("Invalid Fingerprint");let e=ce(0,this.contents.length-1),n=this.contents[e];return this.contents[e]=t,n}remove(t){if(!(t instanceof vt))throw new TypeError("Invalid Fingerprint");let e=this.contents.findIndex(n=>t.equals(n));return e>-1?(this.contents[e]=null,!0):!1}};var Kf=500,Je=class{bucketSize;filterSize;fingerprintSize;buckets;count;hash;seed;constructor(t){this.filterSize=t.filterSize,this.bucketSize=t.bucketSize??4,this.fingerprintSize=t.fingerprintSize??2,this.count=0,this.buckets=[],this.hash=t.hash??We,this.seed=t.seed??ce(0,Math.pow(2,10))}add(t){typeof t=="string"&&(t=st(t));let e=new vt(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=(n^e.hash())%this.filterSize;if(this.buckets[n]==null&&(this.buckets[n]=new ae(this.bucketSize)),this.buckets[o]==null&&(this.buckets[o]=new ae(this.bucketSize)),this.buckets[n].add(e)||this.buckets[o].add(e))return this.count++,!0;let s=[n,o],i=s[ce(0,s.length-1)];this.buckets[i]==null&&(this.buckets[i]=new ae(this.bucketSize));for(let c=0;c<Kf;c++){let a=this.buckets[i].swap(e);if(a!=null&&(i=(i^a.hash())%this.filterSize,this.buckets[i]==null&&(this.buckets[i]=new ae(this.bucketSize)),this.buckets[i].add(a)))return this.count++,!0}return!1}has(t){typeof t=="string"&&(t=st(t));let e=new vt(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.has(e)??!1;if(o)return o;let s=(n^e.hash())%this.filterSize;return this.buckets[s]?.has(e)??!1}remove(t){typeof t=="string"&&(t=st(t));let e=new vt(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.remove(e)??!1;if(o)return this.count--,o;let s=(n^e.hash())%this.filterSize,i=this.buckets[s]?.remove(e)??!1;return i&&this.count--,i}get reliable(){return Math.floor(100*(this.count/this.filterSize))<=90}},Pf={1:.5,2:.84,4:.95,8:.98};function Mf(r=.001){return r>.002?2:r>1e-5?4:8}function Ki(r,t=.001){let e=Mf(t),n=Pf[e],o=Math.round(r/n),s=Math.min(Math.ceil(Math.log2(1/t)+Math.log2(2*e)),_o);return{filterSize:o,bucketSize:e,fingerprintSize:s}}var Xr=class{filterSize;bucketSize;fingerprintSize;scale;filterSeries;hash;seed;constructor(t){this.bucketSize=t.bucketSize??4,this.filterSize=t.filterSize??(1<<18)/this.bucketSize,this.fingerprintSize=t.fingerprintSize??2,this.scale=t.scale??2,this.hash=t.hash??We,this.seed=t.seed??ce(0,Math.pow(2,10)),this.filterSeries=[new Je({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(t){if(typeof t=="string"&&(t=st(t)),this.has(t))return!0;let e=this.filterSeries.find(n=>n.reliable);if(e==null){let n=this.filterSize*Math.pow(this.scale,this.filterSeries.length);e=new Je({filterSize:n,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(e)}return e.add(t)}has(t){typeof t=="string"&&(t=st(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].has(t))return!0;return!1}remove(t){typeof t=="string"&&(t=st(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].remove(t))return!0;return!1}get count(){return this.filterSeries.reduce((t,e)=>t+e.count,0)}};function Bo(r,t=.001,e){return new Xr({...Ki(r,t),...e??{}})}var Qe=class{filter;constructor(t,e){this.filter=Bo(t,e)}has(t){return this.filter.has(t.toMultihash().bytes)}add(t){this.filter.add(t.toMultihash().bytes)}remove(t){this.filter.remove?.(t.toMultihash().bytes)}};function Pi(r,t=.001){return new Qe(r,t)}var Ao=class extends Yt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}set(t,e){return super.set(t,e),this.updateComponentMetric(),this}delete(t){let e=super.delete(t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function Mi(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Ao({name:t,metrics:e}):n=new Yt,n}var vo=class extends $t{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}add(t){super.add(t),this.updateComponentMetric()}delete(t){super.delete(t),this.updateComponentMetric()}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function zi(r){let{name:t,metrics:e}=r,n;return e!=null?n=new vo({name:t,metrics:e}):n=new $t,n}var Io=class extends Gt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}pop(){let t=super.pop();return this.updateComponentMetric(),t}push(...t){super.push(...t),this.updateComponentMetric()}shift(){let t=super.shift();return this.updateComponentMetric(),t}unshift(...t){let e=super.unshift(...t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.length)}};function qi(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Io({name:t,metrics:e}):n=new Gt,n}return Xi(zf);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/curves/utils.js:
|