@libp2p/peer-id 6.0.9 → 6.0.10-7ae12f9b0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PPeerId = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PPeerId=(()=>{var Nr=Object.defineProperty;var li=Object.getOwnPropertyDescriptor;var di=Object.getOwnPropertyNames;var pi=Object.prototype.hasOwnProperty;var it=(e,t)=>{for(var r in t)Nr(e,r,{get:t[r],enumerable:!0})},mi=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of di(t))!pi.call(e,o)&&o!==r&&Nr(e,o,{get:()=>t[o],enumerable:!(n=li(t,o))||n.enumerable});return e};var yi=e=>mi(Nr({},"__esModule",{value:!0}),e);var za={};it(za,{peerIdFromCID:()=>hi,peerIdFromMultihash:()=>ao,peerIdFromPrivateKey:()=>qa,peerIdFromPublicKey:()=>ui,peerIdFromString:()=>Ha});var wt=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 Je=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},tr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var te=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var kr=Symbol.for("@libp2p/peer-id");var Vr={};it(Vr,{base58btc:()=>Y,base58flickr:()=>Ai});var Ga=new Uint8Array(0);function ho(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Bt(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function lo(e){return new TextEncoder().encode(e)}function po(e){return new TextDecoder().decode(e)}function bi(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var c=e.length,f=e.charAt(0),a=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function h(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var S=0,d=0,x=0,A=b.length;x!==A&&b[x]===0;)x++,S++;for(var v=(A-x)*u+1>>>0,R=new Uint8Array(v);x!==A;){for(var L=b[x],F=0,C=v-1;(L!==0||F<d)&&C!==-1;C--,F++)L+=256*R[C]>>>0,R[C]=L%c>>>0,L=L/c>>>0;if(L!==0)throw new Error("Non-zero carry");d=F,x++}for(var _=v-d;_!==v&&R[_]===0;)_++;for(var U=f.repeat(S);_<v;++_)U+=e.charAt(R[_]);return U}function w(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var S=0;if(b[S]!==" "){for(var d=0,x=0;b[S]===f;)d++,S++;for(var A=(b.length-S)*a+1>>>0,v=new Uint8Array(A);b[S];){var R=r[b.charCodeAt(S)];if(R===255)return;for(var L=0,F=A-1;(R!==0||L<x)&&F!==-1;F--,L++)R+=c*v[F]>>>0,v[F]=R%256>>>0,R=R/256>>>0;if(R!==0)throw new Error("Non-zero carry");x=L,S++}if(b[S]!==" "){for(var C=A-x;C!==A&&v[C]===0;)C++;for(var _=new Uint8Array(d+(A-C)),U=d;C!==A;)_[U++]=v[C++];return _}}}function p(b){var S=w(b);if(S)return S;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:w,decode:p}}var gi=bi,xi=gi,yo=xi;var Pr=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Mr=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return bo(this,t)}},Hr=class{decoders;constructor(t){this.decoders=t}or(t){return bo(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function bo(e,t){return new Hr({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var qr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Pr(t,r,n),this.decoder=new Mr(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ee({name:e,prefix:t,encode:r,decode:n}){return new qr(e,t,r,n)}function Rt({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=yo(r,e);return ee({prefix:t,name:e,encode:n,decode:s=>Bt(o(s))})}function wi(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),i=0,c=0,f=0;for(let a=0;a<o;++a){let u=t[e[a]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|u,i+=r,i>=8&&(i-=8,s[f++]=255&c>>i)}if(i>=r||(255&c<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function Ei(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,c=0;for(let f=0;f<e.length;++f)for(c=c<<8|e[f],i+=8;i>r;)i-=r,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<r-i]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function Si(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function V({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Si(n);return ee({prefix:t,name:e,encode(s){return Ei(s,n,r)},decode(s){return wi(s,o,r,e)}})}var Y=Rt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ai=Rt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var jr={};it(jr,{base32:()=>re,base32hex:()=>_i,base32hexpad:()=>Li,base32hexpadupper:()=>Di,base32hexupper:()=>Ti,base32pad:()=>vi,base32padupper:()=>Ii,base32upper:()=>Bi,base32z:()=>Ri});var re=V({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Bi=V({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),vi=V({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ii=V({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_i=V({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ti=V({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Li=V({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Di=V({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ri=V({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var zr={};it(zr,{base36:()=>Ee,base36upper:()=>Ci});var Ee=Rt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ci=Rt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Oi=wo,go=128,Fi=127,Ui=~Fi,Ki=Math.pow(2,31);function wo(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Ki;)t[r++]=e&255|go,e/=128;for(;e&Ui;)t[r++]=e&255|go,e>>>=7;return t[r]=e|0,wo.bytes=r-n+1,t}var Ni=Zr,ki=128,xo=127;function Zr(e,n){var r=0,n=n||0,o=0,s=n,i,c=e.length;do{if(s>=c)throw Zr.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&xo)<<o:(i&xo)*Math.pow(2,o),o+=7}while(i>=ki);return Zr.bytes=s-n,r}var Pi=Math.pow(2,7),Mi=Math.pow(2,14),Hi=Math.pow(2,21),qi=Math.pow(2,28),Vi=Math.pow(2,35),ji=Math.pow(2,42),zi=Math.pow(2,49),Zi=Math.pow(2,56),Yi=Math.pow(2,63),$i=function(e){return e<Pi?1:e<Mi?2:e<Hi?3:e<qi?4:e<Vi?5:e<ji?6:e<zi?7:e<Zi?8:e<Yi?9:10},Gi={encode:Oi,decode:Ni,encodingLength:$i},Xi=Gi,Se=Xi;function Ae(e,t=0){return[Se.decode(e,t),Se.decode.bytes]}function ne(e,t,r=0){return Se.encode(e,t,r),t}function oe(e){return Se.encodingLength(e)}function ie(e,t){let r=t.byteLength,n=oe(e),o=n+oe(r),s=new Uint8Array(o+r);return ne(e,s,0),ne(r,s,n),s.set(t,o),new se(e,r,t,s)}function Be(e){let t=Bt(e),[r,n]=Ae(t),[o,s]=Ae(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new se(r,o,i,t)}function Eo(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&ho(e.bytes,r.bytes)}}var se=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function So(e,t){let{bytes:r,version:n}=e;return n===0?Qi(r,Yr(e),t??Y.encoder):Ji(r,Yr(e),t??re.encoder)}var Ao=new WeakMap;function Yr(e){let t=Ao.get(e);if(t==null){let r=new Map;return Ao.set(e,r),r}return t}var rt=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==ve)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==tc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=ie(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&Eo(t.multihash,n.multihash)}toString(t){return So(this,t)}toJSON(){return{"/":So(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new e(n,o,s,i??Bo(n,o,s.bytes))}else if(r[ec]===!0){let{version:n,multihash:o,code:s}=r,i=Be(o);return e.create(n,s,i)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==ve)throw new Error(`Version 0 CID must use dag-pb (code: ${ve}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Bo(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,ve,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=Bt(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new se(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(i):e.createV1(r.codec,i),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[h,w]=Ae(t.subarray(r));return r+=w,h},o=n(),s=ve;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,c=n(),f=n(),a=r+f,u=a-i;return{version:o,codec:s,multihashCode:c,digestSize:f,multihashSize:u,size:a}}static parse(t,r){let[n,o]=Wi(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Yr(s).set(n,t),s}};function Wi(e,t){switch(e[0]){case"Q":{let r=t??Y;return[Y.prefix,r.decode(`${Y.prefix}${e}`)]}case Y.prefix:{let r=t??Y;return[Y.prefix,r.decode(e)]}case re.prefix:{let r=t??re;return[re.prefix,r.decode(e)]}case Ee.prefix:{let r=t??Ee;return[Ee.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Qi(e,t,r){let{prefix:n}=r;if(n!==Y.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function Ji(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var ve=112,tc=18;function Bo(e,t,r){let n=oe(e),o=n+oe(t),s=new Uint8Array(o+r.byteLength);return ne(e,s,0),ne(t,s,n),s.set(r,o),s}var ec=Symbol.for("@ipld/js-cid/CID");var $r={};it($r,{identity:()=>lt});var vo=0,rc="identity",Io=Bt;function nc(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return ie(vo,Io(e))}var lt={code:vo,name:rc,encode:Io,digest:nc};function dt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}async function _o(e,t,r,n){let o=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,t,r.subarray());return n?.signal?.throwIfAborted(),s}function vt(e=0){return new Uint8Array(e)}function ct(e=0){return new Uint8Array(e)}function rr(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=ct(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var Lo=Symbol.for("@achingbrain/uint8arraylist");function To(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function nr(e){return!!e?.[Lo]}var at=class e{bufs;length;[Lo]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(nr(n)){r+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(nr(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=To(this.bufs,t);return r.buf[r.index]}set(t,r){let n=To(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(nr(t))for(let n=0;n<t.length;n++)this.set(r+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,r){let{bufs:n,length:o}=this._subList(t,r);return rr(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:rr(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),s=new e;return s.length=o,s.bufs=n,s}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],c=o,f=c+i.byteLength;if(o=f,t>=f)continue;let a=t>=c&&t<f,u=r>c&&r<=f;if(a&&u){if(t===c&&r===f){n.push(i);break}let h=t-c;n.push(i.subarray(h,h+(r-t)));break}if(a){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(u){if(r===f){n.push(i);break}n.push(i.subarray(0,r-c));break}n.push(i)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!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(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let h=0;h<s;h++)i[h]=-1;for(let h=0;h<o;h++)i[n[h]]=h;let c=i,f=this.byteLength-n.byteLength,a=n.byteLength-1,u;for(let h=r;h<=f;h+=u){u=0;for(let w=a;w>=0;w--){let p=this.get(h+w);if(n[w]!==p){u=Math.max(1,w-c[p]);break}}if(u===0)return h}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=ct(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=vt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=vt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=vt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=ct(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=vt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=vt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=vt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=vt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=vt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!dt(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,s)=>o+s.byteLength,0)),n.length=r,n}};var Gr={};it(Gr,{base10:()=>oc});var oc=Rt({prefix:"9",name:"base10",alphabet:"0123456789"});var Xr={};it(Xr,{base16:()=>sc,base16upper:()=>ic});var sc=V({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ic=V({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Wr={};it(Wr,{base2:()=>cc});var cc=V({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Qr={};it(Qr,{base256emoji:()=>lc});var Do=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}"),ac=Do.reduce((e,t,r)=>(e[r]=t,e),[]),fc=Do.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function uc(e){return e.reduce((t,r)=>(t+=ac[r],t),"")}function hc(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=fc[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var lc=ee({prefix:"\u{1F680}",name:"base256emoji",encode:uc,decode:hc});var Jr={};it(Jr,{base64:()=>dc,base64pad:()=>pc,base64url:()=>mc,base64urlpad:()=>yc});var dc=V({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),pc=V({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),mc=V({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),yc=V({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var tn={};it(tn,{base8:()=>bc});var bc=V({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var en={};it(en,{identity:()=>gc});var gc=ee({prefix:"\0",name:"identity",encode:e=>po(e),decode:e=>lo(e)});var Ff=new TextEncoder,Uf=new TextDecoder;var on={};it(on,{sha256:()=>Ie,sha512:()=>Sc});var Ec=20;function nn({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new rn(e,t,r,n,o)}var rn=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,s){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Ec,this.maxDigestLength=s}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?Ro(n,this.code,r?.truncate):n.then(o=>Ro(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Ro(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return ie(t,e)}function Oo(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Ie=nn({name:"sha2-256",code:18,encode:Oo("SHA-256")}),Sc=nn({name:"sha2-512",code:19,encode:Oo("SHA-512")});var sn={...en,...Wr,...tn,...Gr,...Xr,...jr,...zr,...Vr,...Jr,...Qr},Yf={...on,...$r};function Uo(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Fo=Uo("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),cn=Uo("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=ct(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Ac={utf8:Fo,"utf-8":Fo,hex:sn.base16,latin1:cn,ascii:cn,binary:cn,...sn},or=Ac;function Ct(e,t="utf8"){let r=or[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function ft(e,t="utf8"){let r=or[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var Bc=parseInt("11111",2),an=parseInt("10000000",2),vc=parseInt("01111111",2),Ko={0:_e,1:_e,2:Ic,3:Lc,4:Dc,5:Tc,6:_c,16:_e,22:_e,48:_e};function fn(e,t={offset:0}){let r=e[t.offset]&Bc;if(t.offset++,Ko[r]!=null)return Ko[r](e,t);throw new Error("No decoder for tag "+r)}function Te(e,t){let r=0;if((e[t.offset]&an)===an){let n=e[t.offset]&vc,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=e[t.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=e[t.offset],t.offset++;return r}function _e(e,t){Te(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=fn(e,t);if(n===null)break;r.push(n)}return r}function Ic(e,t){let r=Te(e,t),n=t.offset,o=t.offset+r,s=[];for(let i=n;i<o;i++)i===n&&e[i]===0||s.push(e[i]);return t.offset+=r,Uint8Array.from(s)}function _c(e,t){let r=Te(e,t),n=t.offset+r,o=e[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let c=`${s}.${i}`,f=[];for(;t.offset<n;){let a=e[t.offset];if(t.offset++,f.push(a&127),a<128){f.reverse();let u=0;for(let h=0;h<f.length;h++)u+=f[h]<<h*7;c+=`.${u}`,f=[]}}return c}function Tc(e,t){return t.offset++,null}function Lc(e,t){let r=Te(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Dc(e,t){let r=Te(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function Rc(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new at;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function un(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=Rc(e.byteLength);return new at(Uint8Array.from([t.byteLength|an]),t)}function No(e){let t=new at,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new at(Uint8Array.from([2]),un(t),t)}function ko(e){let t=Uint8Array.from([0]),r=new at(t,e);return new at(Uint8Array.from([3]),un(r),r)}function sr(e,t=48){let r=new at;for(let n of e)r.append(n);return new at(Uint8Array.from([t]),un(r),r)}var Cc=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Oc=Uint8Array.from([6,5,43,129,4,0,34]),Fc=Uint8Array.from([6,5,43,129,4,0,35]),Uc={ext:!0,kty:"EC",crv:"P-256"},Kc={ext:!0,kty:"EC",crv:"P-384"},Nc={ext:!0,kty:"EC",crv:"P-521"},hn=32,ln=48,dn=66;function Po(e){let t=fn(e);return Mo(t)}function Mo(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===hn*2+1)return n=ft(t.subarray(r,r+hn),"base64url"),o=ft(t.subarray(r+hn),"base64url"),new ae({...Uc,key_ops:["verify"],x:n,y:o});if(t.byteLength===ln*2+1)return n=ft(t.subarray(r,r+ln),"base64url"),o=ft(t.subarray(r+ln),"base64url"),new ae({...Kc,key_ops:["verify"],x:n,y:o});if(t.byteLength===dn*2+1)return n=ft(t.subarray(r,r+dn),"base64url"),o=ft(t.subarray(r+dn),"base64url"),new ae({...Nc,key_ops:["verify"],x:n,y:o});throw new wt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Ho(e){return sr([No(Uint8Array.from([1])),sr([kc(e.crv)],160),sr([ko(new at(Uint8Array.from([4]),Ct(e.x??"","base64url"),Ct(e.y??"","base64url")))],161)]).subarray()}function kc(e){if(e==="P-256")return Cc;if(e==="P-384")return Oc;if(e==="P-521")return Fc;throw new wt(`Invalid curve ${e}`)}var ae=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Ho(this.jwk)),this._raw}toMultihash(){return lt.digest(fe(this))}toCID(){return rt.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:dt(this.raw,t.raw)}async verify(t,r,n){return _o(this.jwk,r,t,n)}};function pn(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Ot(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new RangeError(`${r}expected integer >= 0, got ${e}`)}}function ut(e,t,r=""){let n=pn(e),o=e?.length,s=t!==void 0;if(!n||s&&o!==t){let i=r&&`"${r}" `,c=s?` of length ${t}`:"",f=n?`length=${o}`:`type=${typeof e}`,a=i+"expected Uint8Array"+c+", got "+f;throw n?new RangeError(a):new TypeError(a)}return e}function ir(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(Ot(e.outputLen),Ot(e.blockLen),e.outputLen<1)throw new Error('"outputLen" must be >= 1');if(e.blockLen<1)throw new Error('"blockLen" must be >= 1')}function ue(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function cr(e,t){ut(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function _t(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ar(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function pt(e,t){return e<<32-t|e>>>t}var Vo=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Pc=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function fr(e){if(ut(e),Vo)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Pc[e[r]];return t}var It={_0:48,_9:57,A:65,F:70,a:97,f:102};function qo(e){if(e>=It._0&&e<=It._9)return e-It._0;if(e>=It.A&&e<=It.F)return e-(It.A-10);if(e>=It.a&&e<=It.f)return e-(It.a-10)}function Le(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(Vo)try{return Uint8Array.fromHex(e)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=qo(e.charCodeAt(s)),c=qo(e.charCodeAt(s+1));if(i===void 0||c===void 0){let f=e[s]+e[s+1];throw new RangeError('hex string expected, got non-hex character "'+f+'" at index '+s)}n[o]=i*16+c}return n}function mn(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];ut(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}function yn(e,t={}){let r=(o,s)=>e(s).update(o).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}function jo(e=32){Ot(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var bn=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function zo(e,t,r){return e&t^~e&r}function Zo(e,t,r){return e&t^e&r^t&r}var De=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,o){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=ar(this.buffer)}update(t){ue(this),ut(t);let{view:r,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let f=ar(t);for(;o<=s-i;i+=o)this.process(f,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ue(this),cr(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,_t(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let h=i;h<o;h++)r[h]=0;n.setBigUint64(o-8,BigInt(this.length*8),s),this.process(n,0);let c=ar(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let a=f/4,u=this.get();if(a>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<a;h++)c.setUint32(4*h,u[h],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=c,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Tt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var J=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var ur=BigInt(4294967295),Yo=BigInt(32);function Mc(e,t=!1){return t?{h:Number(e&ur),l:Number(e>>Yo&ur)}:{h:Number(e>>Yo&ur)|0,l:Number(e&ur)|0}}function $o(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:c}=Mc(e[s],t);[n[s],o[s]]=[i,c]}return[n,o]}var gn=(e,t,r)=>e>>>r,xn=(e,t,r)=>e<<32-r|t>>>r,jt=(e,t,r)=>e>>>r|t<<32-r,zt=(e,t,r)=>e<<32-r|t>>>r,Re=(e,t,r)=>e<<64-r|t>>>r-32,Ce=(e,t,r)=>e>>>r-32|t<<64-r;function Et(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Go=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Xo=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Wo=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Qo=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Jo=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),ts=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;var qc=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),wn=class extends De{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:c,H:f}=this;return[t,r,n,o,s,i,c,f]}set(t,r,n,o,s,i,c,f){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=f|0}process(t,r){for(let h=0;h<16;h++,r+=4)Ft[h]=t.getUint32(r,!1);for(let h=16;h<64;h++){let w=Ft[h-15],p=Ft[h-2],b=pt(w,7)^pt(w,18)^w>>>3,S=pt(p,17)^pt(p,19)^p>>>10;Ft[h]=S+Ft[h-7]+b+Ft[h-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:f,G:a,H:u}=this;for(let h=0;h<64;h++){let w=pt(c,6)^pt(c,11)^pt(c,25),p=u+w+zo(c,f,a)+qc[h]+Ft[h]|0,S=(pt(n,2)^pt(n,13)^pt(n,22))+Zo(n,o,s)|0;u=a,a=f,f=c,c=i+p|0,i=s,s=o,o=n,n=p+S|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,f=f+this.F|0,a=a+this.G|0,u=u+this.H|0,this.set(n,o,s,i,c,f,a,u)}roundClean(){_t(Ft)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),_t(this.buffer)}},En=class extends wn{A=Tt[0]|0;B=Tt[1]|0;C=Tt[2]|0;D=Tt[3]|0;E=Tt[4]|0;F=Tt[5]|0;G=Tt[6]|0;H=Tt[7]|0;constructor(){super(32)}};var es=$o(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Vc=es[0],jc=es[1],Ut=new Uint32Array(80),Kt=new Uint32Array(80),Sn=class extends De{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:f,Eh:a,El:u,Fh:h,Fl:w,Gh:p,Gl:b,Hh:S,Hl:d}=this;return[t,r,n,o,s,i,c,f,a,u,h,w,p,b,S,d]}set(t,r,n,o,s,i,c,f,a,u,h,w,p,b,S,d){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=f|0,this.Eh=a|0,this.El=u|0,this.Fh=h|0,this.Fl=w|0,this.Gh=p|0,this.Gl=b|0,this.Hh=S|0,this.Hl=d|0}process(t,r){for(let v=0;v<16;v++,r+=4)Ut[v]=t.getUint32(r),Kt[v]=t.getUint32(r+=4);for(let v=16;v<80;v++){let R=Ut[v-15]|0,L=Kt[v-15]|0,F=jt(R,L,1)^jt(R,L,8)^gn(R,L,7),C=zt(R,L,1)^zt(R,L,8)^xn(R,L,7),_=Ut[v-2]|0,U=Kt[v-2]|0,H=jt(_,U,19)^Re(_,U,61)^gn(_,U,6),K=zt(_,U,19)^Ce(_,U,61)^xn(_,U,6),l=Wo(C,K,Kt[v-7],Kt[v-16]),m=Qo(l,F,H,Ut[v-7],Ut[v-16]);Ut[v]=m|0,Kt[v]=l|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:f,Dh:a,Dl:u,Eh:h,El:w,Fh:p,Fl:b,Gh:S,Gl:d,Hh:x,Hl:A}=this;for(let v=0;v<80;v++){let R=jt(h,w,14)^jt(h,w,18)^Re(h,w,41),L=zt(h,w,14)^zt(h,w,18)^Ce(h,w,41),F=h&p^~h&S,C=w&b^~w&d,_=Jo(A,L,C,jc[v],Kt[v]),U=ts(_,x,R,F,Vc[v],Ut[v]),H=_|0,K=jt(n,o,28)^Re(n,o,34)^Re(n,o,39),l=zt(n,o,28)^Ce(n,o,34)^Ce(n,o,39),m=n&s^n&c^s&c,E=o&i^o&f^i&f;x=S|0,A=d|0,S=p|0,d=b|0,p=h|0,b=w|0,{h,l:w}=Et(a|0,u|0,U|0,H|0),a=c|0,u=f|0,c=s|0,f=i|0,s=n|0,i=o|0;let g=Go(H,l,E);n=Xo(g,U,K,m),o=g|0}({h:n,l:o}=Et(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=Et(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:f}=Et(this.Ch|0,this.Cl|0,c|0,f|0),{h:a,l:u}=Et(this.Dh|0,this.Dl|0,a|0,u|0),{h,l:w}=Et(this.Eh|0,this.El|0,h|0,w|0),{h:p,l:b}=Et(this.Fh|0,this.Fl|0,p|0,b|0),{h:S,l:d}=Et(this.Gh|0,this.Gl|0,S|0,d|0),{h:x,l:A}=Et(this.Hh|0,this.Hl|0,x|0,A|0),this.set(n,o,s,i,c,f,a,u,h,w,p,b,S,d,x,A)}roundClean(){_t(Ut,Kt)}destroy(){this.destroyed=!0,_t(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},An=class extends Sn{Ah=J[0]|0;Al=J[1]|0;Bh=J[2]|0;Bl=J[3]|0;Ch=J[4]|0;Cl=J[5]|0;Dh=J[6]|0;Dl=J[7]|0;Eh=J[8]|0;El=J[9]|0;Fh=J[10]|0;Fl=J[11]|0;Gh=J[12]|0;Gl=J[13]|0;Hh=J[14]|0;Hl=J[15]|0;constructor(){super(64)}};var rs=yn(()=>new En,bn(1));var hr=yn(()=>new An,bn(3));var P=(e,t,r)=>ut(e,t,r),vn=Ot,he=fr,G=(...e)=>mn(...e),le=e=>Le(e),Zt=pn,Oe=e=>jo(e),dr=BigInt(0),Bn=BigInt(1);function mt(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new TypeError(r+"expected boolean, got type="+typeof e)}return e}function pr(e){if(typeof e=="bigint"){if(!lr(e))throw new RangeError("positive bigint expected, got "+e)}else vn(e);return e}function yt(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function Fe(e){let t=pr(e).toString(16);return t.length&1?"0"+t:t}function ns(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?dr:BigInt("0x"+e)}function Yt(e){return ns(fr(e))}function St(e){return ns(fr(Ue(ut(e)).reverse()))}function mr(e,t){if(Ot(t),t===0)throw new RangeError("zero length");e=pr(e);let r=e.toString(16);if(r.length>t*2)throw new RangeError("number too large");return Le(r.padStart(t*2,"0"))}function In(e,t){return mr(e,t).reverse()}function os(e,t){if(e=P(e),t=P(t),e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function Ue(e){return Uint8Array.from(P(e))}function yr(e){if(typeof e!="string")throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${n} at position ${r}`);return n})}var lr=e=>typeof e=="bigint"&&dr<=e;function zc(e,t,r){return lr(e)&&lr(t)&&lr(r)&&t<=e&&e<r}function de(e,t,r,n){if(!zc(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function pe(e){if(e<dr)throw new Error("expected non-negative bigint, got "+e);let t;for(t=0;e>dr;e>>=Bn,t+=1);return t}var Ke=e=>(Bn<<BigInt(e))-Bn;function ss(e,t,r){if(Ot(e,"hashLen"),Ot(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=d=>new Uint8Array(d),o=Uint8Array.of(),s=Uint8Array.of(0),i=Uint8Array.of(1),c=1e3,f=n(e),a=n(e),u=0,h=()=>{f.fill(1),a.fill(0),u=0},w=(...d)=>r(a,G(f,...d)),p=(d=o)=>{a=w(s,d),f=w(),d.length!==0&&(a=w(i,d),f=w())},b=()=>{if(u++>=c)throw new Error("drbg: tried max amount of iterations");let d=0,x=[];for(;d<t;){f=w();let A=f.slice();x.push(A),d+=f.length}return G(...x)};return(d,x)=>{h(),p(d);let A;for(;(A=x(b()))===void 0;)p();return h(),A}}function bt(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw new TypeError("expected valid options object");function n(s,i,c){if(!c&&i!=="function"&&!Object.hasOwn(e,s))throw new TypeError(`param "${s}" is invalid: expected own property`);let f=e[s];if(c&&f===void 0)return;let a=typeof f;if(a!==i||f===null)throw new TypeError(`param "${s}" is invalid: expected ${i}, got ${a}`)}let o=(s,i)=>Object.entries(s).forEach(([c,f])=>n(c,f,i));o(t,!1),o(r,!0)}var _n=()=>{throw new Error("not implemented")};var tt=BigInt(0),j=BigInt(1),$t=BigInt(2),fs=BigInt(3),us=BigInt(4),hs=BigInt(5),Zc=BigInt(7),ls=BigInt(8),Yc=BigInt(9),ds=BigInt(16);function Z(e,t){if(t<=tt)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=tt?r:t+r}function q(e,t,r){if(t<tt)throw new Error("pow2: expected non-negative exponent, got "+t);let n=e;for(;t-- >tt;)n*=n,n%=r;return n}function is(e,t){if(e===tt)throw new Error("invert: expected non-zero number");if(t<=tt)throw new Error("invert: expected positive modulus, got "+t);let r=Z(e,t),n=t,o=tt,s=j,i=j,c=tt;for(;r!==tt;){let a=n/r,u=n-r*a,h=o-i*a,w=s-c*a;n=r,r=u,o=i,s=c,i=h,c=w}if(n!==j)throw new Error("invert: does not exist");return Z(o,t)}function Tn(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function ps(e,t){let r=e,n=(r.ORDER+j)/us,o=r.pow(t,n);return Tn(r,o,t),o}function $c(e,t){let r=e,n=(r.ORDER-hs)/ls,o=r.mul(t,$t),s=r.pow(o,n),i=r.mul(t,s),c=r.mul(r.mul(i,$t),s),f=r.mul(i,r.sub(c,r.ONE));return Tn(r,f,t),f}function Gc(e){let t=me(e),r=ms(e),n=r(t,t.neg(t.ONE)),o=r(t,n),s=r(t,t.neg(n)),i=(e+Zc)/ds;return((c,f)=>{let a=c,u=a.pow(f,i),h=a.mul(u,n),w=a.mul(u,o),p=a.mul(u,s),b=a.eql(a.sqr(h),f),S=a.eql(a.sqr(w),f);u=a.cmov(u,h,b),h=a.cmov(p,w,S);let d=a.eql(a.sqr(h),f),x=a.cmov(u,h,d);return Tn(a,x,f),x})}function ms(e){if(e<fs)throw new Error("sqrt is not defined for small field");let t=e-j,r=0;for(;t%$t===tt;)t/=$t,r++;let n=$t,o=me(e);for(;cs(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return ps;let s=o.pow(n,t),i=(t+j)/$t;return function(f,a){let u=f;if(u.is0(a))return a;if(cs(u,a)!==1)throw new Error("Cannot find square root");let h=r,w=u.mul(u.ONE,s),p=u.pow(a,t),b=u.pow(a,i);for(;!u.eql(p,u.ONE);){if(u.is0(p))return u.ZERO;let S=1,d=u.sqr(p);for(;!u.eql(d,u.ONE);)if(S++,d=u.sqr(d),S===h)throw new Error("Cannot find square root");let x=j<<BigInt(h-S-1),A=u.pow(w,x);h=S,w=u.sqr(A),p=u.mul(p,w),b=u.mul(b,A)}return b}}function Xc(e){return e%us===fs?ps:e%ls===hs?$c:e%ds===Yc?Gc(e):ms(e)}var Lt=(e,t)=>(Z(e,t)&j)===j,Wc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ln(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Wc.reduce((n,o)=>(n[o]="function",n),t);if(bt(e,r),yt(e.BYTES,"BYTES"),yt(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=j)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function Qc(e,t,r){let n=e;if(r<tt)throw new Error("invalid exponent, negatives unsupported");if(r===tt)return n.ONE;if(r===j)return t;let o=n.ONE,s=t;for(;r>tt;)r&j&&(o=n.mul(o,s)),s=n.sqr(s),r>>=j;return o}function Ne(e,t,r=!1){let n=e,o=new Array(t.length).fill(r?n.ZERO:void 0),s=t.reduce((c,f,a)=>n.is0(f)?c:(o[a]=c,n.mul(c,f)),n.ONE),i=n.inv(s);return t.reduceRight((c,f,a)=>n.is0(f)?c:(o[a]=n.mul(c,o[a]),n.mul(c,f)),i),o}function cs(e,t){let r=e,n=(r.ORDER-j)/$t,o=r.pow(t,n),s=r.eql(o,r.ONE),i=r.eql(o,r.ZERO),c=r.eql(o,r.neg(r.ONE));if(!s&&!i&&!c)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function Jc(e,t){if(t!==void 0&&vn(t),e<=tt)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=pe(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let n=t!==void 0?t:r,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var as=new WeakMap,br=class{ORDER;BITS;BYTES;isLE;ZERO=tt;ONE=j;_lengths;_mod;constructor(t,r={}){if(t<=j)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:s}=Jc(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 Z(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return tt<=t&&t<this.ORDER}is0(t){return t===tt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&j)===j}neg(t){return Z(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return Z(t*t,this.ORDER)}add(t,r){return Z(t+r,this.ORDER)}sub(t,r){return Z(t-r,this.ORDER)}mul(t,r){return Z(t*r,this.ORDER)}pow(t,r){return Qc(this,t,r)}div(t,r){return Z(t*is(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return is(t,this.ORDER)}sqrt(t){let r=as.get(this);return r||as.set(this,r=Xc(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?In(t,this.BYTES):mr(t,this.BYTES)}fromBytes(t,r=!1){P(t);let{_lengths:n,BYTES:o,isLE:s,ORDER:i,_mod:c}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let a=new Uint8Array(o);a.set(t,s?0:a.length-t.length),t=a}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let f=s?St(t):Yt(t);if(c&&(f=Z(f,i)),!r&&!this.isValid(f))throw new Error("invalid field element: outside of range 0..ORDER");return f}invertBatch(t){return Ne(this,t)}cmov(t,r,n){return mt(n,"condition"),n?r:t}};Object.freeze(br.prototype);function me(e,t={}){return new br(e,t)}function ys(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=j)throw new Error("field order must be greater than 1");let t=pe(e-j);return Math.ceil(t/8)}function Dn(e){let t=ys(e);return t+Math.ceil(t/2)}function Rn(e,t,r=!1){P(e);let n=e.length,o=ys(t),s=Math.max(Dn(t),16);if(n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=r?St(e):Yt(e),c=Z(i,t-j)+j;return r?In(c,o):mr(c,o)}var ye=BigInt(0),Gt=BigInt(1);function ke(e,t){let r=t.negate();return e?r:t}function Xt(e,t){let r=Ne(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function ws(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Cn(e,t){ws(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,s=Ke(e),i=BigInt(e);return{windows:r,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function bs(e,t,r){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=r,c=Number(e&o),f=e>>i;c>n&&(c-=s,f+=Gt);let a=t*n,u=a+Math.abs(c)-1,h=c===0,w=c<0,p=t%2!==0;return{nextN:f,offset:u,isZero:h,isNeg:w,isNegF:p,offsetF:a}}var On=new WeakMap,Es=new WeakMap;function Fn(e){return Es.get(e)||1}function gs(e){if(e!==ye)throw new Error("invalid wNAF")}var be=class{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let o=t;for(;r>ye;)r&Gt&&(n=n.add(o)),o=o.double(),r>>=Gt;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=Cn(r,this.bits),s=[],i=t,c=i;for(let f=0;f<n;f++){c=i,s.push(c);for(let a=1;a<o;a++)c=c.add(i),s.push(c);i=c.double()}return s}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE,i=Cn(t,this.bits);for(let c=0;c<i.windows;c++){let{nextN:f,offset:a,isZero:u,isNeg:h,isNegF:w,offsetF:p}=bs(n,c,i);n=f,u?s=s.add(ke(w,r[p])):o=o.add(ke(h,r[a]))}return gs(n),{p:o,f:s}}wNAFUnsafe(t,r,n,o=this.ZERO){let s=Cn(t,this.bits);for(let i=0;i<s.windows&&n!==ye;i++){let{nextN:c,offset:f,isZero:a,isNeg:u}=bs(n,i,s);if(n=c,!a){let h=r[f];o=o.add(u?h.negate():h)}}return gs(n),o}getPrecomputes(t,r,n){let o=On.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),On.set(r,o))),o}cached(t,r,n){let o=Fn(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let s=Fn(t);return s===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,n),r,o)}createCache(t,r){ws(r,this.bits),Es.set(t,r),On.delete(t)}hasCache(t){return Fn(t)!==1}};function Ss(e,t,r,n){let o=t,s=e.ZERO,i=e.ZERO;for(;r>ye||n>ye;)r&Gt&&(s=s.add(o)),n&Gt&&(i=i.add(o)),o=o.double(),r>>=Gt,n>>=Gt;return{p1:s,p2:i}}function xs(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Ln(t),t}else return me(e,{isLE:r})}function gr(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let f of["p","n","h"]){let a=t[f];if(!(typeof a=="bigint"&&a>ye))throw new Error(`CURVE.${f} must be positive bigint`)}let o=xs(t.p,r.Fp,n),s=xs(t.n,r.Fn,n),c=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let f of c)if(!o.isValid(t[f]))throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:s}}function xr(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var Nt=BigInt(0),Q=BigInt(1),Un=BigInt(2),ta=BigInt(8);function ea(e,t,r,n){let o=e.sqr(r),s=e.sqr(n),i=e.add(e.mul(t.a,o),s),c=e.add(e.ONE,e.mul(t.d,e.mul(o,s)));return e.eql(i,c)}function As(e,t={}){let r=t,n=gr("edwards",e,r,r.FpFnLE),{Fp:o,Fn:s}=n,i=n.CURVE,{h:c}=i;bt(r,{},{uvRatio:"function"});let f=Un<<BigInt(s.BYTES*8)-Q,a=S=>o.create(S),u=r.uvRatio===void 0?(S,d)=>{try{return{isValid:!0,value:o.sqrt(o.div(S,d))}}catch{return{isValid:!1,value:Nt}}}:r.uvRatio;if(!ea(o,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function h(S,d,x=!1){let A=x?Q:Nt;return de("coordinate "+S,d,A,f),d}function w(S){if(!(S instanceof p))throw new Error("EdwardsPoint expected")}class p{static BASE=new p(i.Gx,i.Gy,Q,a(i.Gx*i.Gy));static ZERO=new p(Nt,Q,Q,Nt);static Fp=o;static Fn=s;X;Y;Z;T;constructor(d,x,A,v){this.X=h("x",d),this.Y=h("y",x),this.Z=h("z",A,!0),this.T=h("t",v),Object.freeze(this)}static CURVE(){return i}static fromAffine(d){if(d instanceof p)throw new Error("extended point not allowed");let{x,y:A}=d||{};return h("x",x),h("y",A),new p(x,A,Q,a(x*A))}static fromBytes(d,x=!1){let A=o.BYTES,{a:v,d:R}=i;d=Ue(P(d,A,"point")),mt(x,"zip215");let L=Ue(d),F=d[A-1];L[A-1]=F&-129;let C=St(L),_=x?f:o.ORDER;de("point.y",C,Nt,_);let U=a(C*C),H=a(U-Q),K=a(R*U-v),{isValid:l,value:m}=u(H,K);if(!l)throw new Error("bad point: invalid y coordinate");let E=(m&Q)===Q,g=(F&128)!==0;if(!x&&m===Nt&&g)throw new Error("bad point: x=0 and x_0=1");return g!==E&&(m=a(-m)),p.fromAffine({x:m,y:C})}static fromHex(d,x=!1){return p.fromBytes(le(d),x)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(d=8,x=!0){return b.createCache(this,d),x||this.multiply(Un),this}assertValidity(){let d=this,{a:x,d:A}=i;if(d.is0())throw new Error("bad point: ZERO");let{X:v,Y:R,Z:L,T:F}=d,C=a(v*v),_=a(R*R),U=a(L*L),H=a(U*U),K=a(C*x),l=a(U*a(K+_)),m=a(H+a(A*a(C*_)));if(l!==m)throw new Error("bad point: equation left != right (1)");let E=a(v*R),g=a(L*F);if(E!==g)throw new Error("bad point: equation left != right (2)")}equals(d){w(d);let{X:x,Y:A,Z:v}=this,{X:R,Y:L,Z:F}=d,C=a(x*F),_=a(R*v),U=a(A*F),H=a(L*v);return C===_&&U===H}is0(){return this.equals(p.ZERO)}negate(){return new p(a(-this.X),this.Y,this.Z,a(-this.T))}double(){let{a:d}=i,{X:x,Y:A,Z:v}=this,R=a(x*x),L=a(A*A),F=a(Un*a(v*v)),C=a(d*R),_=x+A,U=a(a(_*_)-R-L),H=C+L,K=H-F,l=C-L,m=a(U*K),E=a(H*l),g=a(U*l),y=a(K*H);return new p(m,E,y,g)}add(d){w(d);let{a:x,d:A}=i,{X:v,Y:R,Z:L,T:F}=this,{X:C,Y:_,Z:U,T:H}=d,K=a(v*C),l=a(R*_),m=a(F*A*H),E=a(L*U),g=a((v+R)*(C+_)-K-l),y=E-m,B=E+m,T=a(l-x*K),I=a(g*y),D=a(B*T),O=a(g*T),k=a(y*B);return new p(I,D,k,O)}subtract(d){return w(d),this.add(d.negate())}multiply(d){if(!s.isValidNot0(d))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:x,f:A}=b.cached(this,d,v=>Xt(p,v));return Xt(p,[x,A])[0]}multiplyUnsafe(d){if(!s.isValid(d))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return d===Nt?p.ZERO:this.is0()||d===Q?this:b.unsafe(this,d,x=>Xt(p,x))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return b.unsafe(this,i.n).is0()}toAffine(d){let x=this,A=d,{X:v,Y:R,Z:L}=x,F=x.is0();A==null&&(A=F?ta:o.inv(L));let C=a(v*A),_=a(R*A),U=o.mul(L,A);if(F)return{x:Nt,y:Q};if(U!==Q)throw new Error("invZ was invalid");return{x:C,y:_}}clearCofactor(){return c===Q?this:this.multiplyUnsafe(c)}toBytes(){let{x:d,y:x}=this.toAffine(),A=o.toBytes(x);return A[A.length-1]|=d&Q?128:0,A}toHex(){return he(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let b=new be(p,s.BITS);return s.BITS>=8&&p.BASE.precompute(8),Object.freeze(p.prototype),Object.freeze(p),p}var wr=class{static BASE;static ZERO;static Fp;static Fn;ep;constructor(t){this.ep=t}static fromBytes(t){_n()}static fromHex(t){_n()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return he(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,r){return this.ep.precompute(t,r),this}};function Bs(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');let n=t,o=r;bt(o,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",zip215:"boolean",mapToCurve:"function"});let{prehash:s}=o,{BASE:i,Fp:c,Fn:f}=e,a=n.outputLen,u=2*c.BYTES;if(a!==void 0&&(yt(a,"hash.outputLen"),a!==u))throw new Error(`hash.outputLen must be ${u}, got ${a}`);let h=o.randomBytes===void 0?Oe:o.randomBytes,w=o.adjustScalarBytes===void 0?l=>l:o.adjustScalarBytes,p=o.domain===void 0?(l,m,E)=>{if(mt(E,"phflag"),m.length||E)throw new Error("Contexts/pre-hash are not supported");return l}:o.domain;function b(l){return f.create(St(l))}function S(l){let m=C.secretKey;P(l,C.secretKey,"secretKey");let E=P(n(l),2*m,"hashedSecretKey"),g=w(E.slice(0,m)),y=E.slice(m,2*m),B=b(g);return{head:g,prefix:y,scalar:B}}function d(l){let{head:m,prefix:E,scalar:g}=S(l),y=i.multiply(g),B=y.toBytes();return{head:m,prefix:E,scalar:g,point:y,pointBytes:B}}function x(l){return d(l).pointBytes}function A(l=Uint8Array.of(),...m){let E=G(...m);return b(n(p(E,P(l,void 0,"context"),!!s)))}function v(l,m,E={}){l=P(l,void 0,"message"),s&&(l=s(l));let{prefix:g,scalar:y,pointBytes:B}=d(m),T=A(E.context,g,l),I=i.multiply(T).toBytes(),D=A(E.context,I,B,l),O=f.create(T+D*y);if(!f.isValid(O))throw new Error("sign failed: invalid s");let k=G(I,f.toBytes(O));return P(k,C.signature,"result")}let R={zip215:o.zip215};function L(l,m,E,g=R){let{context:y}=g,B=g.zip215===void 0?!!R.zip215:g.zip215,T=C.signature;l=P(l,T,"signature"),m=P(m,void 0,"message"),E=P(E,C.publicKey,"publicKey"),B!==void 0&&mt(B,"zip215"),s&&(m=s(m));let I=T/2,D=l.subarray(0,I),O=St(l.subarray(I,T)),k,M,N;try{k=e.fromBytes(E,B),M=e.fromBytes(D,B),N=i.multiplyUnsafe(O)}catch{return!1}if(!B&&k.isSmallOrder())return!1;let $=A(y,D,E,m);return M.add(k.multiplyUnsafe($)).subtract(N).clearCofactor().is0()}let F=c.BYTES,C={secretKey:F,publicKey:F,signature:2*F,seed:F};function _(l){return l=l===void 0?h(C.seed):l,P(l,C.seed,"seed")}function U(l){return Zt(l)&&l.length===C.secretKey}function H(l,m){try{return!!e.fromBytes(l,m===void 0?R.zip215:m)}catch{return!1}}let K={getExtendedPublicKey:d,randomSecretKey:_,isValidSecretKey:U,isValidPublicKey:H,toMontgomery(l){let{y:m}=e.fromBytes(l),E=C.publicKey,g=E===32;if(!g&&E!==57)throw new Error("only defined for 25519 and 448");let y=g?c.div(Q+m,Q-m):c.div(m-Q,m+Q);return c.toBytes(y)},toMontgomerySecret(l){let m=C.secretKey;P(l,m);let E=n(l.subarray(0,m));return w(E).subarray(0,m)}};return Object.freeze(C),Object.freeze(K),Object.freeze({keygen:xr(_,x),getPublicKey:x,sign:v,verify:L,utils:K,Point:e,lengths:C})}function Pe(e,t){if(yt(e),yt(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function ra(e,t){let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function na(e){if(!Zt(e)&&typeof e!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof e=="string"?yr(e):e;if(t.length===0)throw new Error("DST must be non-empty");return t}function Kn(e,t,r,n){P(e),yt(r),t=na(t),t.length>255&&(t=n(G(yr("H2C-OVERSIZE-DST-"),t)));let{outputLen:o,blockLen:s}=n,i=Math.ceil(r/o);if(r>65535||i>255)throw new Error("expand_message_xmd: invalid lenInBytes");let c=G(t,Pe(t.length,1)),f=new Uint8Array(s),a=Pe(r,2),u=new Array(i),h=n(G(f,e,a,Pe(0,1),c));u[0]=n(G(h,Pe(1,1),c));for(let p=1;p<i;p++){let b=[ra(h,u[p-1]),Pe(p+1,1),c];u[p]=n(G(...b))}return G(...u).slice(0,r)}var vs="HashToScalar-";var oa=BigInt(0),Dt=BigInt(1),Is=BigInt(2);var sa=BigInt(5),ia=BigInt(8),ge=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Mn={p:ge,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:ia,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function ca(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),s=ge,c=e*e%s*e%s,f=q(c,Is,s)*c%s,a=q(f,Dt,s)*e%s,u=q(a,sa,s)*a%s,h=q(u,t,s)*u%s,w=q(h,r,s)*h%s,p=q(w,n,s)*w%s,b=q(p,o,s)*p%s,S=q(b,o,s)*p%s,d=q(S,t,s)*u%s;return{pow_p_5_8:q(d,Is,s)*e%s,b2:c}}function aa(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Nn=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Hn(e,t){let r=ge,n=Z(t*t*t,r),o=Z(n*n*t,r),s=ca(e*o).pow_p_5_8,i=Z(e*n*s,r),c=Z(t*i*i,r),f=i,a=Z(i*Nn,r),u=c===e,h=c===Z(-e,r),w=c===Z(-e*Nn,r);return u&&(i=f),(h||w)&&(i=a),Lt(i,r)&&(i=Z(-i,r)),{isValid:u||h,value:i}}var Pt=As(Mn,{uvRatio:Hn}),kt=Pt.Fp,Ls=Pt.Fn;function fa(e){return Bs(Pt,hr,Object.assign({adjustScalarBytes:aa,zip215:!0},e))}var Ds=fa({});var kn=Nn,ua=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),ha=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),la=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),da=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),_s=e=>Hn(Dt,e),pa=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Pn=e=>kt.create(St(e)&pa);function Ts(e){let{d:t}=Mn,r=ge,n=x=>kt.create(x),o=n(kn*e*e),s=n((o+Dt)*la),i=BigInt(-1),c=n((i-t*o)*n(o+t)),{isValid:f,value:a}=Hn(s,c),u=n(a*e);Lt(u,r)||(u=n(-u)),f||(a=u),f||(i=o);let h=n(i*(o-Dt)*da-c),w=a*a,p=n((a+a)*c),b=n(h*ua),S=n(Dt-w),d=n(Dt+w);return new Pt(n(p*d),n(S*b),n(b*d),n(p*S))}var Mt=class e extends wr{static BASE=new e(Pt.BASE);static ZERO=new e(Pt.ZERO);static Fp=kt;static Fn=Ls;constructor(t){super(t)}static fromAffine(t){return new e(Pt.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw new Error("RistrettoPoint expected")}init(t){return new e(t)}static fromBytes(t){ut(t,32);let{a:r,d:n}=Mn,o=ge,s=R=>kt.create(R),i=Pn(t);if(!os(kt.toBytes(i),t)||Lt(i,o))throw new Error("invalid ristretto255 encoding 1");let c=s(i*i),f=s(Dt+r*c),a=s(Dt-r*c),u=s(f*f),h=s(a*a),w=s(r*n*u-h),{isValid:p,value:b}=_s(s(w*h)),S=s(b*a),d=s(b*S*w),x=s((i+i)*S);Lt(x,o)&&(x=s(-x));let A=s(f*d),v=s(x*A);if(!p||Lt(v,o)||A===oa)throw new Error("invalid ristretto255 encoding 2");return new e(new Pt(x,A,Dt,v))}static fromHex(t){return e.fromBytes(Le(t))}toBytes(){let{X:t,Y:r,Z:n,T:o}=this.ep,s=ge,i=d=>kt.create(d),c=i(i(n+r)*i(n-r)),f=i(t*r),a=i(f*f),{value:u}=_s(i(c*a)),h=i(u*c),w=i(u*f),p=i(h*w*o),b;if(Lt(o*p,s)){let d=i(r*kn),x=i(t*kn);t=d,r=x,b=i(h*ha)}else b=w;Lt(t*p,s)&&(r=i(-r));let S=i((n-r)*b);return Lt(S,s)&&(S=i(-S)),kt.toBytes(S)}equals(t){this.assertSame(t);let{X:r,Y:n}=this.ep,{X:o,Y:s}=t.ep,i=a=>kt.create(a),c=i(r*s)===i(n*o),f=i(n*s)===i(r*o);return c||f}is0(){return this.equals(e.ZERO)}};Object.freeze(Mt.BASE);Object.freeze(Mt.ZERO);Object.freeze(Mt.prototype);Object.freeze(Mt);var ma=Object.freeze({Point:Mt,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,n=Kn(e,r,64,hr);return ma.deriveToCurve(n)},hashToScalar(e,t={DST:vs}){let r=Kn(e,t.DST,64,hr);return Ls.create(St(r))},deriveToCurve(e){ut(e,64);let t=Pn(e.subarray(0,32)),r=Ts(t),n=Pn(e.subarray(32,64)),o=Ts(n);return new Mt(r.add(o))}});var Me=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Er=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Rs={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Er("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 Sr=Rs;var Ar=32;var qn,ya=(async()=>{try{return await Sr.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function ba(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await Sr.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await Sr.get().subtle.verify({name:"Ed25519"},n,t,r instanceof Uint8Array?r:r.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function ga(e,t,r){return Ds.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function Cs(e,t,r){return qn==null&&(qn=await ya),qn?ba(e,t,r):ga(e,t,r)}function Br(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var vr=class{type="Ed25519";raw;constructor(t){this.raw=Vn(t,Ar)}toMultihash(){return lt.digest(fe(this))}toCID(){return rt.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:dt(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=Cs(this.raw,r,t);return Br(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function Fs(e){return e=Vn(e,Ar),new vr(e)}function Vn(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new wt(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var wa=Math.pow(2,7),Ea=Math.pow(2,14),Sa=Math.pow(2,21),Us=Math.pow(2,28),Ks=Math.pow(2,35),Ns=Math.pow(2,42),ks=Math.pow(2,49),nt=128,Ht=127;function He(e){if(e<wa)return 1;if(e<Ea)return 2;if(e<Sa)return 3;if(e<Us)return 4;if(e<Ks)return 5;if(e<Ns)return 6;if(e<ks)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Ps(e,t,r=0){switch(He(e)){case 8:t[r++]=e&255|nt,e/=128;case 7:t[r++]=e&255|nt,e/=128;case 6:t[r++]=e&255|nt,e/=128;case 5:t[r++]=e&255|nt,e/=128;case 4:t[r++]=e&255|nt,e>>>=7;case 3:t[r++]=e&255|nt,e>>>=7;case 2:t[r++]=e&255|nt,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Ms(e,t){let r=e[t],n=0;if(n+=r&Ht,r<nt||(r=e[t+1],n+=(r&Ht)<<7,r<nt)||(r=e[t+2],n+=(r&Ht)<<14,r<nt)||(r=e[t+3],n+=(r&Ht)<<21,r<nt)||(r=e[t+4],n+=(r&Ht)*Us,r<nt)||(r=e[t+5],n+=(r&Ht)*Ks,r<nt)||(r=e[t+6],n+=(r&Ht)*Ns,r<nt)||(r=e[t+7],n+=(r&Ht)*ks,r<nt))return n;throw new RangeError("Could not decode varint")}var jn=new Float32Array([-0]),qt=new Uint8Array(jn.buffer);function Hs(e,t,r){jn[0]=e,t[r]=qt[0],t[r+1]=qt[1],t[r+2]=qt[2],t[r+3]=qt[3]}function qs(e,t){return qt[0]=e[t],qt[1]=e[t+1],qt[2]=e[t+2],qt[3]=e[t+3],jn[0]}var zn=new Float64Array([-0]),et=new Uint8Array(zn.buffer);function Vs(e,t,r){zn[0]=e,t[r]=et[0],t[r+1]=et[1],t[r+2]=et[2],t[r+3]=et[3],t[r+4]=et[4],t[r+5]=et[5],t[r+6]=et[6],t[r+7]=et[7]}function js(e,t){return et[0]=e[t],et[1]=e[t+1],et[2]=e[t+2],et[3]=e[t+3],et[4]=e[t+4],et[5]=e[t+5],et[6]=e[t+6],et[7]=e[t+7],zn[0]}var Aa=BigInt(Number.MAX_SAFE_INTEGER),Ba=BigInt(Number.MIN_SAFE_INTEGER),ht=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Wt;if(t<Aa&&t>Ba)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>zs&&(o=0n,++n>zs&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Wt;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):Wt}},Wt=new ht(0,0);Wt.toBigInt=function(){return 0n};Wt.zzEncode=Wt.zzDecode=function(){return this};Wt.length=function(){return 1};var zs=4294967296n;function Zs(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Ys(e,t,r){if(r-t<1)return"";let o,s=[],i=0,c;for(;t<r;)c=e[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|e[t++]&63:c>239&&c<365?(c=((c&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(e[t++]&63)<<6|e[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function Zn(e,t,r){let n=r,o,s;for(let i=0;i<e.length;++i)o=e.charCodeAt(i),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((s=e.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function gt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Ir(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Yn=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,gt(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 gt(this,4);return Ir(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw gt(this,4);return Ir(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw gt(this,4);let t=qs(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw gt(this,4);let t=js(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw gt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Ys(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw gt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw gt(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 ht(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw gt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw gt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw gt(this,8);let t=Ir(this.buf,this.pos+=4),r=Ir(this.buf,this.pos+=4);return new ht(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Ms(this.buf,this.pos);return this.pos+=He(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 qe(e){return new Yn(e instanceof Uint8Array?e:e.subarray())}function _r(e,t,r){let n=qe(e);return t.decode(n,void 0,r)}function $n(e){let t=e??8192,r=t>>>1,n,o=t;return function(i){if(i<1||i>r)return ct(i);o+i>t&&(n=ct(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var Qt=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Gn(){}var Wn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},va=$n();function Ia(e){return globalThis.Buffer!=null?ct(e):va(e)}var je=class{len;head;tail;states;constructor(){this.len=0,this.head=new Qt(Gn,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new Qt(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Qn((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Tr,10,ht.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=ht.fromBigInt(t);return this._push(Tr,r.length(),r)}uint64Number(t){return this._push(Ps,He(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let r=ht.fromBigInt(t).zzEncode();return this._push(Tr,r.length(),r)}sint64Number(t){let r=ht.fromNumber(t).zzEncode();return this._push(Tr,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Xn,1,t?1:0)}fixed32(t){return this._push(Ve,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=ht.fromBigInt(t);return this._push(Ve,4,r.lo)._push(Ve,4,r.hi)}fixed64Number(t){let r=ht.fromNumber(t);return this._push(Ve,4,r.lo)._push(Ve,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Hs,4,t)}double(t){return this._push(Vs,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(Xn,1,0):this.uint32(r)._push(Ta,r,t)}string(t){let r=Zs(t);return r!==0?this.uint32(r)._push(Zn,r,t):this._push(Xn,1,0)}fork(){return this.states=new Wn(this),this.head=this.tail=new Qt(Gn,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 Qt(Gn,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=Ia(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function Xn(e,t,r){t[r]=e&255}function _a(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Qn=class extends Qt{next;constructor(t,r){super(_a,t,r),this.next=void 0}};function Tr(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function Ve(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function Ta(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(je.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(La,t,e),this},je.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Da,t,e),this});function La(e,t,r){t.set(e,r)}function Da(e,t,r){e.length<40?Zn(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(Ct(e),r)}function Jn(){return new je}function Lr(e,t){let r=Jn();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}function*Dr(e,t,r){let n=qe(e);yield*t.stream(n,void 0,"$",r)}var Rr={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function Cr(e,t,r,n,o){return{name:e,type:t,encode:r,decode:n,stream:o}}function to(e){function t(s){if(e[s.toString()]==null)throw new Error("Invalid enum value");return e[s]}let r=function(i,c){let f=t(i);c.int32(f)},n=function(i){let c=i.int32();return t(c)},o=function*(i){let c=i.int32();yield t(c)};return Cr("enum",Rr.VARINT,r,n,o)}function Or(e,t,r){return Cr("message",Rr.LENGTH_DELIMITED,e,t,r)}var ot;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(ot||(ot={}));var eo;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(eo||(eo={}));(function(e){e.codec=()=>to(eo)})(ot||(ot={}));var ze;(function(e){let t;e.codec=()=>(t==null&&(t=Or((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 f={},a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{f.Type=ot.codec().decode(s);break}case 2:{f.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return f},function*(s,i,c,f={}){let a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${c}.Type`,value:ot.codec().decode(s)};break}case 2:{yield{field:`${c}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function r(s){return Lr(s,e.codec())}e.encode=r;function n(s,i){return _r(s,e.codec(),i)}e.decode=n;function o(s,i){return Dr(s,e.codec(),i)}e.stream=o})(ze||(ze={}));var ro;(function(e){let t;e.codec=()=>(t==null&&(t=Or((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 f={},a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{f.Type=ot.codec().decode(s);break}case 2:{f.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return f},function*(s,i,c,f={}){let a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${c}.Type`,value:ot.codec().decode(s)};break}case 2:{yield{field:`${c}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function r(s){return Lr(s,e.codec())}e.encode=r;function n(s,i){return _r(s,e.codec(),i)}e.decode=n;function o(s,i){return Dr(s,e.codec(),i)}e.stream=o})(ro||(ro={}));var Fr=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,r){if(ir(t),ut(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=t.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),_t(o)}update(t){return ue(this),this.iHash.update(t),this}digestInto(t){ue(this),cr(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Gs=(()=>{let e=((t,r,n)=>new Fr(t,r).update(n).digest());return e.create=(t,r)=>new Fr(t,r),e})();var Xs=(e,t)=>(e+(e>=0?t:-t)/Ws)/t;function Ca(e,t,r){de("scalar",e,At,r);let[[n,o],[s,i]]=t,c=Xs(i*e,r),f=Xs(-o*e,r),a=e-c*n-f*s,u=-c*o-f*i,h=a<At,w=u<At;h&&(a=-a),w&&(u=-u);let p=Ke(Math.ceil(pe(r)/2))+Vt;if(a<At||a>=p||u<At||u>=p)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:h,k1:a,k2neg:w,k2:u}}function oo(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function no(e,t){bt(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return mt(r.lowS,"lowS"),mt(r.prehash,"prehash"),r.format!==void 0&&oo(r.format),r}var so=class extends Error{constructor(t=""){super(t)}},xt={Err:so,_tlv:{encode:(e,t)=>{let{Err:r}=xt;if(yt(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!="string")throw new TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=Fe(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?Fe(o.length/2|128):"";return Fe(e)+s+o+t},decode(e,t){let{Err:r}=xt;t=P(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let f=o&127;if(!f)throw new r("tlv.decode(long): indefinite length not supported");if(f>4)throw new r("tlv.decode(long): byte length is too big");let a=t.subarray(n,n+f);if(a.length!==f)throw new r("tlv.decode: length bytes not complete");if(a[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of a)i=i<<8|u;if(n+=f,i<128)throw new r("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new r("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(e){let{Err:t}=xt;if(pr(e),e<At)throw new t("integer: negative integers are not allowed");let r=Fe(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=xt;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Yt(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=xt,o=P(e,void 0,"signature"),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:f}=n.decode(2,s),{v:a,l:u}=n.decode(2,f);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(a)}},hexFromSig(e){let{_tlv:t,_int:r}=xt,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),s=n+o;return t.encode(48,s)}};Object.freeze(xt._tlv);Object.freeze(xt._int);Object.freeze(xt);var At=BigInt(0),Vt=BigInt(1),Ws=BigInt(2),Ur=BigInt(3),Oa=BigInt(4);function Qs(e,t={}){let r=gr("weierstrass",e,t),n=r.Fp,o=r.Fn,s=r.CURVE,{h:i,n:c}=s;bt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:f,allowInfinityPoint:a}=t;if(f&&(!n.is0(s.a)||typeof f.beta!="bigint"||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let u=ti(n,o);function h(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function w(K,l,m){if(a&&l.is0())return Uint8Array.of(0);let{x:E,y:g}=l.toAffine(),y=n.toBytes(E);if(mt(m,"isCompressed"),m){h();let B=!n.isOdd(g);return G(Js(B),y)}else return G(Uint8Array.of(4),y,n.toBytes(g))}function p(K){P(K,void 0,"Point");let{publicKey:l,publicKeyUncompressed:m}=u,E=K.length,g=K[0],y=K.subarray(1);if(a&&E===1&&g===0)return{x:n.ZERO,y:n.ZERO};if(E===l&&(g===2||g===3)){let B=n.fromBytes(y);if(!n.isValid(B))throw new Error("bad point: is not on curve, wrong x");let T=d(B),I;try{I=n.sqrt(T)}catch(k){let M=k instanceof Error?": "+k.message:"";throw new Error("bad point: is not on curve, sqrt error"+M)}h();let D=n.isOdd(I);return(g&1)===1!==D&&(I=n.neg(I)),{x:B,y:I}}else if(E===m&&g===4){let B=n.BYTES,T=n.fromBytes(y.subarray(0,B)),I=n.fromBytes(y.subarray(B,B*2));if(!x(T,I))throw new Error("bad point: is not on curve");return{x:T,y:I}}else throw new Error(`bad point: got length ${E}, expected compressed=${l} or uncompressed=${m}`)}let b=t.toBytes===void 0?w:t.toBytes,S=t.fromBytes===void 0?p:t.fromBytes;function d(K){let l=n.sqr(K),m=n.mul(l,K);return n.add(n.add(m,n.mul(K,s.a)),s.b)}function x(K,l){let m=n.sqr(l),E=d(K);return n.eql(m,E)}if(!x(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let A=n.mul(n.pow(s.a,Ur),Oa),v=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(A,v)))throw new Error("bad curve params: a or b");function R(K,l,m=!1){if(!n.isValid(l)||m&&n.is0(l))throw new Error(`bad point coordinate ${K}`);return l}function L(K){if(!(K instanceof _))throw new Error("Weierstrass Point expected")}function F(K){if(!f||!f.basises)throw new Error("no endo");return Ca(K,f.basises,o.ORDER)}function C(K,l,m,E,g){return m=new _(n.mul(m.X,K),m.Y,m.Z),l=ke(E,l),m=ke(g,m),l.add(m)}class _{static BASE=new _(s.Gx,s.Gy,n.ONE);static ZERO=new _(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(l,m,E){this.X=R("x",l),this.Y=R("y",m,!0),this.Z=R("z",E),Object.freeze(this)}static CURVE(){return s}static fromAffine(l){let{x:m,y:E}=l||{};if(!l||!n.isValid(m)||!n.isValid(E))throw new Error("invalid affine point");if(l instanceof _)throw new Error("projective point not allowed");return n.is0(m)&&n.is0(E)?_.ZERO:new _(m,E,n.ONE)}static fromBytes(l){let m=_.fromAffine(S(P(l,void 0,"point")));return m.assertValidity(),m}static fromHex(l){return _.fromBytes(le(l))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(l=8,m=!0){return H.createCache(this,l),m||this.multiply(Ur),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")}let{x:m,y:E}=l.toAffine();if(!n.isValid(m)||!n.isValid(E))throw new Error("bad point: x or y not field elements");if(!x(m,E))throw new Error("bad point: equation left != right");if(!l.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:l}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(l)}equals(l){L(l);let{X:m,Y:E,Z:g}=this,{X:y,Y:B,Z:T}=l,I=n.eql(n.mul(m,T),n.mul(y,g)),D=n.eql(n.mul(E,T),n.mul(B,g));return I&&D}negate(){return new _(this.X,n.neg(this.Y),this.Z)}double(){let{a:l,b:m}=s,E=n.mul(m,Ur),{X:g,Y:y,Z:B}=this,T=n.ZERO,I=n.ZERO,D=n.ZERO,O=n.mul(g,g),k=n.mul(y,y),M=n.mul(B,B),N=n.mul(g,y);return N=n.add(N,N),D=n.mul(g,B),D=n.add(D,D),T=n.mul(l,D),I=n.mul(E,M),I=n.add(T,I),T=n.sub(k,I),I=n.add(k,I),I=n.mul(T,I),T=n.mul(N,T),D=n.mul(E,D),M=n.mul(l,M),N=n.sub(O,M),N=n.mul(l,N),N=n.add(N,D),D=n.add(O,O),O=n.add(D,O),O=n.add(O,M),O=n.mul(O,N),I=n.add(I,O),M=n.mul(y,B),M=n.add(M,M),O=n.mul(M,N),T=n.sub(T,O),D=n.mul(M,k),D=n.add(D,D),D=n.add(D,D),new _(T,I,D)}add(l){L(l);let{X:m,Y:E,Z:g}=this,{X:y,Y:B,Z:T}=l,I=n.ZERO,D=n.ZERO,O=n.ZERO,k=s.a,M=n.mul(s.b,Ur),N=n.mul(m,y),$=n.mul(E,B),X=n.mul(g,T),W=n.add(m,E),z=n.add(y,B);W=n.mul(W,z),z=n.add(N,$),W=n.sub(W,z),z=n.add(m,g);let st=n.add(y,T);return z=n.mul(z,st),st=n.add(N,X),z=n.sub(z,st),st=n.add(E,g),I=n.add(B,T),st=n.mul(st,I),I=n.add($,X),st=n.sub(st,I),O=n.mul(k,z),I=n.mul(M,X),O=n.add(I,O),I=n.sub($,O),O=n.add($,O),D=n.mul(I,O),$=n.add(N,N),$=n.add($,N),X=n.mul(k,X),z=n.mul(M,z),$=n.add($,X),X=n.sub(N,X),X=n.mul(k,X),z=n.add(z,X),N=n.mul($,z),D=n.add(D,N),N=n.mul(st,z),I=n.mul(W,I),I=n.sub(I,N),N=n.mul(W,$),O=n.mul(st,O),O=n.add(O,N),new _(I,D,O)}subtract(l){return L(l),this.add(l.negate())}is0(){return this.equals(_.ZERO)}multiply(l){let{endo:m}=t;if(!o.isValidNot0(l))throw new RangeError("invalid scalar: out of range");let E,g,y=B=>H.cached(this,B,T=>Xt(_,T));if(m){let{k1neg:B,k1:T,k2neg:I,k2:D}=F(l),{p:O,f:k}=y(T),{p:M,f:N}=y(D);g=k.add(N),E=C(m.beta,O,M,B,I)}else{let{p:B,f:T}=y(l);E=B,g=T}return Xt(_,[E,g])[0]}multiplyUnsafe(l){let{endo:m}=t,E=this,g=l;if(!o.isValid(g))throw new RangeError("invalid scalar: out of range");if(g===At||E.is0())return _.ZERO;if(g===Vt)return E;if(H.hasCache(this))return this.multiply(g);if(m){let{k1neg:y,k1:B,k2neg:T,k2:I}=F(g),{p1:D,p2:O}=Ss(_,E,B,I);return C(m.beta,D,O,y,T)}else return H.unsafe(E,g)}toAffine(l){let m=this,E=l,{X:g,Y:y,Z:B}=m;if(n.eql(B,n.ONE))return{x:g,y};let T=m.is0();E==null&&(E=T?n.ONE:n.inv(B));let I=n.mul(g,E),D=n.mul(y,E),O=n.mul(B,E);if(T)return{x:n.ZERO,y:n.ZERO};if(!n.eql(O,n.ONE))throw new Error("invZ was invalid");return{x:I,y:D}}isTorsionFree(){let{isTorsionFree:l}=t;return i===Vt?!0:l?l(_,this):H.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:l}=t;return i===Vt?this:l?l(_,this):this.multiplyUnsafe(i)}isSmallOrder(){return i===Vt?this.is0():this.clearCofactor().is0()}toBytes(l=!0){return mt(l,"isCompressed"),this.assertValidity(),b(_,this,l)}toHex(l=!0){return he(this.toBytes(l))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let U=o.BITS,H=new be(_,t.endo?Math.ceil(U/2):U);return U>=8&&_.BASE.precompute(8),Object.freeze(_.prototype),Object.freeze(_),_}function Js(e){return Uint8Array.of(e?2:3)}function ti(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Fa(e,t={}){let{Fn:r}=e,n=t.randomBytes===void 0?Oe:t.randomBytes,o=Object.assign(ti(e.Fp,r),{seed:Math.max(Dn(r.ORDER),16)});function s(p){try{let b=r.fromBytes(p);return r.isValidNot0(b)}catch{return!1}}function i(p,b){let{publicKey:S,publicKeyUncompressed:d}=o;try{let x=p.length;return b===!0&&x!==S||b===!1&&x!==d?!1:!!e.fromBytes(p)}catch{return!1}}function c(p){return p=p===void 0?n(o.seed):p,Rn(P(p,o.seed,"seed"),r.ORDER)}function f(p,b=!0){return e.BASE.multiply(r.fromBytes(p)).toBytes(b)}function a(p){let{secretKey:b,publicKey:S,publicKeyUncompressed:d}=o,x=r._lengths;if(!Zt(p))return;let A=P(p,void 0,"key").length,v=A===S||A===d,R=A===b||!!x?.includes(A);if(!(v&&R))return v}function u(p,b,S=!0){if(a(p)===!0)throw new Error("first arg must be private key");if(a(b)===!1)throw new Error("second arg must be public key");let d=r.fromBytes(p);return e.fromBytes(b).multiply(d).toBytes(S)}let h={isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:c},w=xr(c,f);return Object.freeze(h),Object.freeze(o),Object.freeze({getPublicKey:f,getSharedSecret:u,keygen:w,Point:e,utils:h,lengths:o})}function ei(e,t,r={}){let n=t;ir(n),bt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes===void 0?Oe:r.randomBytes,s=r.hmac===void 0?(g,y)=>Gs(n,g,y):r.hmac,{Fp:i,Fn:c}=e,{ORDER:f,BITS:a}=c,{keygen:u,getPublicKey:h,getSharedSecret:w,utils:p,lengths:b}=Fa(e,r),S={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},d=f*Ws+Vt<i.ORDER;function x(g){let y=f>>Vt;return g>y}function A(g,y){if(!c.isValidNot0(y))throw new Error(`invalid signature ${g}: out of range 1..Point.Fn.ORDER`);return y}function v(){if(d)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function R(g,y){oo(y);let B=b.signature,T=y==="compact"?B:y==="recovered"?B+1:void 0;return P(g,T)}class L{r;s;recovery;constructor(y,B,T){if(this.r=A("r",y),this.s=A("s",B),T!=null){if(v(),![0,1,2,3].includes(T))throw new Error("invalid recovery id");this.recovery=T}Object.freeze(this)}static fromBytes(y,B=S.format){R(y,B);let T;if(B==="der"){let{r:k,s:M}=xt.toSig(P(y));return new L(k,M)}B==="recovered"&&(T=y[0],B="compact",y=y.subarray(1));let I=b.signature/2,D=y.subarray(0,I),O=y.subarray(I,I*2);return new L(c.fromBytes(D),c.fromBytes(O),T)}static fromHex(y,B){return this.fromBytes(le(y),B)}assertRecovery(){let{recovery:y}=this;if(y==null)throw new Error("invalid recovery id: must be present");return y}addRecoveryBit(y){return new L(this.r,this.s,y)}recoverPublicKey(y){let{r:B,s:T}=this,I=this.assertRecovery(),D=I===2||I===3?B+f:B;if(!i.isValid(D))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let O=i.toBytes(D),k=e.fromBytes(G(Js((I&1)===0),O)),M=c.inv(D),N=C(P(y,void 0,"msgHash")),$=c.create(-N*M),X=c.create(T*M),W=e.BASE.multiplyUnsafe($).add(k.multiplyUnsafe(X));if(W.is0())throw new Error("invalid recovery: point at infinify");return W.assertValidity(),W}hasHighS(){return x(this.s)}toBytes(y=S.format){if(oo(y),y==="der")return le(xt.hexFromSig(this));let{r:B,s:T}=this,I=c.toBytes(B),D=c.toBytes(T);return y==="recovered"?(v(),G(Uint8Array.of(this.assertRecovery()),I,D)):G(I,D)}toHex(y){return he(this.toBytes(y))}}Object.freeze(L.prototype),Object.freeze(L);let F=r.bits2int===void 0?function(y){if(y.length>8192)throw new Error("input is too large");let B=Yt(y),T=y.length*8-a;return T>0?B>>BigInt(T):B}:r.bits2int,C=r.bits2int_modN===void 0?function(y){return c.create(F(y))}:r.bits2int_modN,_=Ke(a);function U(g){return de("num < 2^"+a,g,At,_),c.toBytes(g)}function H(g,y){return P(g,void 0,"message"),y?P(n(g),void 0,"prehashed message"):g}function K(g,y,B){let{lowS:T,prehash:I,extraEntropy:D}=no(B,S);g=H(g,I);let O=C(g),k=c.fromBytes(y);if(!c.isValidNot0(k))throw new Error("invalid private key");let M=[U(k),U(O)];if(D!=null&&D!==!1){let W=D===!0?o(b.secretKey):D;M.push(P(W,void 0,"extraEntropy"))}let N=G(...M),$=O;function X(W){let z=F(W);if(!c.isValidNot0(z))return;let st=c.inv(z),Jt=e.BASE.multiply(z).toAffine(),we=c.create(Jt.x);if(we===At)return;let We=c.create(st*c.create($+we*k));if(We===At)return;let fo=(Jt.x===we?0:2)|Number(Jt.y&Vt),uo=We;return T&&x(We)&&(uo=c.neg(We),fo^=1),new L(we,uo,d?void 0:fo)}return{seed:N,k2sig:X}}function l(g,y,B={}){let{seed:T,k2sig:I}=K(g,y,B);return ss(n.outputLen,c.BYTES,s)(T,I).toBytes(B.format)}function m(g,y,B,T={}){let{lowS:I,prehash:D,format:O}=no(T,S);if(B=P(B,void 0,"publicKey"),y=H(y,D),!Zt(g)){let k=g instanceof L?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+k)}R(g,O);try{let k=L.fromBytes(g,O),M=e.fromBytes(B);if(I&&k.hasHighS())return!1;let{r:N,s:$}=k,X=C(y),W=c.inv($),z=c.create(X*W),st=c.create(N*W),Jt=e.BASE.multiplyUnsafe(z).add(M.multiplyUnsafe(st));return Jt.is0()?!1:c.create(Jt.x)===N}catch{return!1}}function E(g,y,B={}){let{prehash:T}=no(B,S);return y=H(y,T),L.fromBytes(g,"recovered").recoverPublicKey(y).toBytes()}return Object.freeze({keygen:u,getPublicKey:h,getSharedSecret:w,utils:p,lengths:b,Point:e,sign:l,verify:m,recoverPublicKey:E,Signature:L,hash:n})}var co={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Ua={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var ri=BigInt(2);function Ka(e){let t=co.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),f=BigInt(88),a=e*e*e%t,u=a*a*e%t,h=q(u,r,t)*u%t,w=q(h,r,t)*u%t,p=q(w,ri,t)*a%t,b=q(p,o,t)*p%t,S=q(b,s,t)*b%t,d=q(S,c,t)*S%t,x=q(d,f,t)*d%t,A=q(x,c,t)*S%t,v=q(A,r,t)*u%t,R=q(v,i,t)*b%t,L=q(R,n,t)*a%t,F=q(L,ri,t);if(!io.eql(io.sqr(F),e))throw new Error("Cannot find square root");return F}var io=me(co.p,{sqrt:Ka}),Na=Qs(co,{Fp:io,endo:Ua}),xe=ei(Na,rs);function ni(e,t,r,n){let o=Ie.digest(r instanceof Uint8Array?r:r.subarray());if(Br(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),xe.verify(t,s,e,{prehash:!1,format:"der"}))).catch(s=>{throw s.name==="AbortError"?s:new Me(String(s))});try{return n?.signal?.throwIfAborted(),xe.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(s){throw new Me(String(s))}}var Kr=class{type="secp256k1";raw;_key;constructor(t){this._key=si(t),this.raw=oi(this._key)}toMultihash(){return lt.digest(fe(this))}toCID(){return rt.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:dt(this.raw,t.raw)}verify(t,r,n){return ni(this._key,r,t,n)}};function ii(e){return new Kr(e)}function oi(e){return xe.Point.fromBytes(e).toBytes()}function si(e){try{return xe.Point.fromBytes(e),e}catch(t){throw new Qe(String(t))}}function ci(e){let{Type:t,Data:r}=ze.decode(e.digest),n=r??new Uint8Array;switch(t){case ot.Ed25519:return Fs(n);case ot.secp256k1:return ii(n);case ot.ECDSA:return Po(n);default:throw new te}}function fe(e){return ze.encode({Type:ot[e.type],Data:e.raw})}var ai=Symbol.for("nodejs.util.inspect.custom"),ka=114,Ze=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()})`}[kr]=!0;toString(){return this.string==null&&(this.string=Y.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return rt.createV1(ka,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")}[ai](){return`PeerId(${this.toString()})`}},Ye=class extends Ze{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},$e=class extends Ze{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Ge=class extends Ze{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Pa=2336,Xe=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=lt.digest(Ct(this.url))}[ai](){return`PeerId(${this.url})`}[kr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return rt.createV1(Pa,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=ft(t)),t.toString()===this.toString())}};var Ma=114,fi=2336;function Ha(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=Be(Y.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return hi(rt.parse(e));if(t==null)throw new wt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=Be(t.decode(e))}return ao(r)}function ui(e){if(e.type==="Ed25519")return new $e({multihash:e.toCID().multihash,publicKey:e});if(e.type==="secp256k1")return new Ge({multihash:e.toCID().multihash,publicKey:e});if(e.type==="RSA")return new Ye({multihash:e.toCID().multihash,publicKey:e});throw new te}function qa(e){return ui(e.publicKey)}function ao(e){if(ja(e))return new Ye({multihash:e});if(Va(e))try{let t=ci(e);if(t.type==="Ed25519")return new $e({multihash:e,publicKey:t});if(t.type==="secp256k1")return new Ge({multihash:e,publicKey:t})}catch{let r=ft(e.digest);return new Xe(new URL(r))}throw new tr("Supplied PeerID Multihash is invalid")}function hi(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==Ma&&e.code!==fi)throw new Je("Supplied PeerID CID is invalid");if(e.code===fi){let t=ft(e.multihash.digest);return new Xe(new URL(t))}return ao(e.multihash)}function Va(e){return e.code===lt.code}function ja(e){return e.code===Ie.code}return yi(za);})();
2
+ "use strict";var Libp2PPeerId=(()=>{var rn=Object.defineProperty;var Bc=Object.getOwnPropertyDescriptor;var Ic=Object.getOwnPropertyNames;var Tc=Object.prototype.hasOwnProperty;var V=(e,t)=>{for(var r in t)rn(e,r,{get:t[r],enumerable:!0})},Dc=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ic(t))!Tc.call(e,o)&&o!==r&&rn(e,o,{get:()=>t[o],enumerable:!(n=Bc(t,o))||n.enumerable});return e};var Lc=e=>Dc(rn({},"__esModule",{value:!0}),e);var bh={};V(bh,{peerIdFromCID:()=>Ac,peerIdFromMultihash:()=>Jo,peerIdFromPrivateKey:()=>lh,peerIdFromPublicKey:()=>vc,peerIdFromString:()=>dh});var gt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},br=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var yr=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},xr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var oe=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var nn=Symbol.for("@libp2p/peer-id");var fn={};V(fn,{base58btc:()=>G,base58flickr:()=>Kc});var wh=new Uint8Array(0);function es(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function At(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return Zt(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return Zt(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));throw new Error("Unknown type, must be binary type")}function rs(e){return new TextEncoder().encode(e)}function ns(e){return new TextDecoder().decode(e)}function _c(e){return e?.buffer instanceof ArrayBuffer}function Zt(e){return _c(e)?e:e.slice()}function Cc(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var c=e.length,f=e.charAt(0),a=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function h(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var w=0,p=0,b=0,S=l.length;b!==S&&l[b]===0;)b++,w++;for(var v=(S-b)*u+1>>>0,D=new Uint8Array(v);b!==S;){for(var T=l[b],R=0,C=v-1;(T!==0||R<p)&&C!==-1;C--,R++)T+=256*D[C]>>>0,D[C]=T%c>>>0,T=T/c>>>0;if(T!==0)throw new Error("Non-zero carry");p=R,b++}for(var I=v-p;I!==v&&D[I]===0;)I++;for(var F=f.repeat(w);I<v;++I)F+=e.charAt(D[I]);return F}function E(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var w=0;if(l[w]!==" "){for(var p=0,b=0;l[w]===f;)p++,w++;for(var S=(l.length-w)*a+1>>>0,v=new Uint8Array(S);l[w];){var D=r[l.charCodeAt(w)];if(D===255)return;for(var T=0,R=S-1;(D!==0||T<b)&&R!==-1;R--,T++)D+=c*v[R]>>>0,v[R]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");b=T,w++}if(l[w]!==" "){for(var C=S-b;C!==S&&v[C]===0;)C++;for(var I=new Uint8Array(p+(S-C)),F=p;C!==S;)I[F++]=v[C++];return I}}}function m(l){var w=E(l);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:E,decode:m}}var Uc=Cc,Rc=Uc,ss=Rc;var on=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},sn=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return is(this,t)}},cn=class{decoders;constructor(t){this.decoders=t}or(t){return is(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function is(e,t){return new cn({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var an=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new on(t,r,n),this.decoder=new sn(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function se({name:e,prefix:t,encode:r,decode:n}){return new an(e,t,r,n)}function Rt({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=ss(r,e);return se({prefix:t,name:e,encode:n,decode:s=>At(o(s))})}function Oc(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),i=0,c=0,f=0;for(let a=0;a<o;++a){let u=t[e[a]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|u,i+=r,i>=8&&(i-=8,s[f++]=255&c>>i)}if(i>=r||(255&c<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function Fc(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,c=0;for(let f=0;f<e.length;++f)for(c=c<<8|e[f],i+=8;i>r;)i-=r,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<r-i]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function Nc(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function z({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Nc(n);return se({prefix:t,name:e,encode(s){return Fc(s,n,r)},decode(s){return Oc(s,o,r,e)}})}var G=Rt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Kc=Rt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var un={};V(un,{base32:()=>ie,base32hex:()=>qc,base32hexpad:()=>Hc,base32hexpadupper:()=>zc,base32hexupper:()=>Vc,base32pad:()=>Pc,base32padupper:()=>Mc,base32upper:()=>kc,base32z:()=>jc});var ie=z({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),kc=z({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Pc=z({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Mc=z({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),qc=z({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Vc=z({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Hc=z({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),zc=z({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),jc=z({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var hn={};V(hn,{base36:()=>Re,base36upper:()=>Zc});var Re=Rt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Zc=Rt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var $c=fs,cs=128,Yc=127,Gc=~Yc,Xc=Math.pow(2,31);function fs(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Xc;)t[r++]=e&255|cs,e/=128;for(;e&Gc;)t[r++]=e&255|cs,e>>>=7;return t[r]=e|0,fs.bytes=r-n+1,t}var Wc=dn,Jc=128,as=127;function dn(e,n){var r=0,n=n||0,o=0,s=n,i,c=e.length;do{if(s>=c)throw dn.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&as)<<o:(i&as)*Math.pow(2,o),o+=7}while(i>=Jc);return dn.bytes=s-n,r}var Qc=Math.pow(2,7),ta=Math.pow(2,14),ea=Math.pow(2,21),ra=Math.pow(2,28),na=Math.pow(2,35),oa=Math.pow(2,42),sa=Math.pow(2,49),ia=Math.pow(2,56),ca=Math.pow(2,63),aa=function(e){return e<Qc?1:e<ta?2:e<ea?3:e<ra?4:e<na?5:e<oa?6:e<sa?7:e<ia?8:e<ca?9:10},fa={encode:$c,decode:Wc,encodingLength:aa},ua=fa,Oe=ua;function Fe(e,t=0){return[Oe.decode(e,t),Oe.decode.bytes]}function ce(e,t,r=0){return Oe.encode(e,t,r),t}function ae(e){return Oe.encodingLength(e)}function ue(e,t){let r=t.byteLength,n=ae(e),o=n+ae(r),s=new Uint8Array(o+r);return ce(e,s,0),ce(r,s,n),s.set(t,o),new fe(e,r,t,s)}function Ne(e){let t=At(e),[r,n]=Fe(t),[o,s]=Fe(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new fe(r,o,i,t)}function us(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&es(e.bytes,r.bytes)}}var fe=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=Zt(n),this.bytes=Zt(o)}};function hs(e,t){let{bytes:r,version:n}=e;return n===0?da(r,ln(e),t??G.encoder):la(r,ln(e),t??ie.encoder)}var ds=new WeakMap;function ln(e){let t=ds.get(e);if(t==null){let r=new Map;return ds.set(e,r),r}return t}var ot=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=Zt(o),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==Ke)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==pa)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=ue(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&us(t.multihash,n.multihash)}toString(t){return hs(this,t)}toJSON(){return{"/":hs(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new e(n,o,s,i??ls(n,o,s.bytes))}else if(r[ma]===!0){let{version:n,multihash:o,code:s}=r,i=Ne(o);return e.create(n,s,i)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==Ke)throw new Error(`Version 0 CID must use dag-pb (code: ${Ke}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=ls(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Ke,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=At(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new fe(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(i):e.createV1(r.codec,i),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[h,E]=Fe(t.subarray(r));return r+=E,h},o=n(),s=Ke;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,c=n(),f=n(),a=r+f,u=a-i;return{version:o,codec:s,multihashCode:c,digestSize:f,multihashSize:u,size:a}}static parse(t,r){let[n,o]=ha(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ln(s).set(n,t),s}};function ha(e,t){switch(e[0]){case"Q":{let r=t??G;return[G.prefix,r.decode(`${G.prefix}${e}`)]}case G.prefix:{let r=t??G;return[G.prefix,r.decode(e)]}case ie.prefix:{let r=t??ie;return[ie.prefix,r.decode(e)]}case Re.prefix:{let r=t??Re;return[Re.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function da(e,t,r){let{prefix:n}=r;if(n!==G.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function la(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var Ke=112,pa=18;function ls(e,t,r){let n=ae(e),o=n+ae(t),s=new Uint8Array(o+r.byteLength);return ce(e,s,0),ce(t,s,n),s.set(r,o),s}var ma=Symbol.for("@ipld/js-cid/CID");var pn={};V(pn,{identity:()=>dt});var ps=0,ba="identity",ms=At;function ya(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return ue(ps,ms(e))}var dt={code:ps,name:ba,encode:ms,digest:ya};function Bt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function xa(e){return e.buffer instanceof ArrayBuffer}function de(e){return xa(e)?e:e.slice()}async function bs(e,t,r,n){let o=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,de(t),de(r.subarray()));return n?.signal?.throwIfAborted(),s}function It(e=0){return new Uint8Array(e)}function ke(e=0){return new Uint8Array(e)}function mn(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=ke(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}function ys(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}var gs=Symbol.for("@achingbrain/uint8arraylist");function xs(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function wr(e){return!!e?.[gs]}var at=class e{bufs;length;[gs]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(wr(n)){r+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(wr(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=xs(this.bufs,t);return r.buf[r.index]}set(t,r){let n=xs(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(wr(t))for(let n=0;n<t.length;n++)this.set(r+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,r){let{bufs:n,length:o}=this._subList(t,r);return mn(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:mn(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),s=new e;return s.length=o,s.bufs=n,s}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],c=o,f=c+i.byteLength;if(o=f,t>=f)continue;let a=t>=c&&t<f,u=r>c&&r<=f;if(a&&u){if(t===c&&r===f){n.push(i);break}let h=t-c;n.push(i.subarray(h,h+(r-t)));break}if(a){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(u){if(r===f){n.push(i);break}n.push(i.subarray(0,r-c));break}n.push(i)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!wr(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let h=0;h<s;h++)i[h]=-1;for(let h=0;h<o;h++)i[n[h]]=h;let c=i,f=this.byteLength-n.byteLength,a=n.byteLength-1,u;for(let h=r;h<=f;h+=u){u=0;for(let E=a;E>=0;E--){let m=this.get(h+E);if(n[E]!==m){u=Math.max(1,E-c[m]);break}}if(u===0)return h}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=ke(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=It(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=It(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=It(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=ke(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=It(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=It(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=It(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=It(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=It(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!ys(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,s)=>o+s.byteLength,0)),n.length=r,n}};var bn={};V(bn,{base10:()=>ga});var ga=Rt({prefix:"9",name:"base10",alphabet:"0123456789"});var yn={};V(yn,{base16:()=>wa,base16upper:()=>Ea});var wa=z({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ea=z({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var xn={};V(xn,{base2:()=>Sa});var Sa=z({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var gn={};V(gn,{base256emoji:()=>Ta});var ws=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}"),va=ws.reduce((e,t,r)=>(e[r]=t,e),[]),Aa=ws.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Ba(e){return e.reduce((t,r)=>(t+=va[r],t),"")}function Ia(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Aa[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var Ta=se({prefix:"\u{1F680}",name:"base256emoji",encode:Ba,decode:Ia});var wn={};V(wn,{base64:()=>Da,base64pad:()=>La,base64url:()=>_a,base64urlpad:()=>Ca});var Da=z({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),La=z({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),_a=z({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ca=z({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var En={};V(En,{base8:()=>Ua});var Ua=z({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Sn={};V(Sn,{identity:()=>Ra});var Ra=se({prefix:"\0",name:"identity",encode:e=>ns(e),decode:e=>rs(e)});var cd=new TextEncoder,ad=new TextDecoder;var Bn={};V(Bn,{sha256:()=>Pe,sha512:()=>Ka});var Na=20;function An({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new vn(e,t,r,n,o)}var vn=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,s){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Na,this.maxDigestLength=s}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?Es(n,this.code,r?.truncate):n.then(o=>Es(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Es(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return ue(t,e)}function vs(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Pe=An({name:"sha2-256",code:18,encode:vs("SHA-256")}),Ka=An({name:"sha2-512",code:19,encode:vs("SHA-512")});var In={...Sn,...xn,...En,...bn,...yn,...un,...hn,...fn,...wn,...gn},wd={...Bn,...pn};function Tn(e=0){return new Uint8Array(e)}function Bs(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var As=Bs("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Dn=Bs("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=Tn(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),ka={utf8:As,"utf-8":As,hex:In.base16,latin1:Dn,ascii:Dn,binary:Dn,...In},Er=ka;function le(e,t="utf8"){let r=Er[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function ft(e,t="utf8"){let r=Er[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var Pa=parseInt("11111",2),Ln=parseInt("10000000",2),Ma=parseInt("01111111",2),Is={0:Me,1:Me,2:qa,3:za,4:ja,5:Ha,6:Va,16:Me,22:Me,48:Me};function _n(e,t={offset:0}){let r=e[t.offset]&Pa;if(t.offset++,Is[r]!=null)return Is[r](e,t);throw new Error("No decoder for tag "+r)}function qe(e,t){let r=0;if((e[t.offset]&Ln)===Ln){let n=e[t.offset]&Ma,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=e[t.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=e[t.offset],t.offset++;return r}function Me(e,t){qe(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=_n(e,t);if(n===null)break;r.push(n)}return r}function qa(e,t){let r=qe(e,t),n=t.offset,o=t.offset+r,s=[];for(let i=n;i<o;i++)i===n&&e[i]===0||s.push(e[i]);return t.offset+=r,Uint8Array.from(s)}function Va(e,t){let r=qe(e,t),n=t.offset+r,o=e[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let c=`${s}.${i}`,f=[];for(;t.offset<n;){let a=e[t.offset];if(t.offset++,f.push(a&127),a<128){f.reverse();let u=0;for(let h=0;h<f.length;h++)u+=f[h]<<h*7;c+=`.${u}`,f=[]}}return c}function Ha(e,t){return t.offset++,null}function za(e,t){let r=qe(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function ja(e,t){let r=qe(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function Za(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new at;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Cn(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=Za(e.byteLength);return new at(Uint8Array.from([t.byteLength|Ln]),t)}function Ts(e){let t=new at,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new at(Uint8Array.from([2]),Cn(t),t)}function Ds(e){let t=Uint8Array.from([0]),r=new at(t,e);return new at(Uint8Array.from([3]),Cn(r),r)}function Sr(e,t=48){let r=new at;for(let n of e)r.append(n);return new at(Uint8Array.from([t]),Cn(r),r)}var $a=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Ya=Uint8Array.from([6,5,43,129,4,0,34]),Ga=Uint8Array.from([6,5,43,129,4,0,35]),Xa={ext:!0,kty:"EC",crv:"P-256"},Wa={ext:!0,kty:"EC",crv:"P-384"},Ja={ext:!0,kty:"EC",crv:"P-521"},Un=32,Rn=48,On=66;function Ls(e){let t=_n(e);return _s(t)}function _s(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===Un*2+1)return n=ft(t.subarray(r,r+Un),"base64url"),o=ft(t.subarray(r+Un),"base64url"),new pe({...Xa,key_ops:["verify"],x:n,y:o});if(t.byteLength===Rn*2+1)return n=ft(t.subarray(r,r+Rn),"base64url"),o=ft(t.subarray(r+Rn),"base64url"),new pe({...Wa,key_ops:["verify"],x:n,y:o});if(t.byteLength===On*2+1)return n=ft(t.subarray(r,r+On),"base64url"),o=ft(t.subarray(r+On),"base64url"),new pe({...Ja,key_ops:["verify"],x:n,y:o});throw new gt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Cs(e){return Sr([Ts(Uint8Array.from([1])),Sr([Qa(e.crv)],160),Sr([Ds(new at(Uint8Array.from([4]),le(e.x??"","base64url"),le(e.y??"","base64url")))],161)]).subarray()}function Qa(e){if(e==="P-256")return $a;if(e==="P-384")return Ya;if(e==="P-521")return Ga;throw new gt(`Invalid curve ${e}`)}var pe=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Cs(this.jwk)),this._raw}toMultihash(){return dt.digest(me(this))}toCID(){return ot.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Bt(this.raw,t.raw)}async verify(t,r,n){return bs(this.jwk,r,t,n)}};function Fn(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Ot(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new RangeError(`${r}expected integer >= 0, got ${e}`)}}function ut(e,t,r=""){let n=Fn(e),o=e?.length,s=t!==void 0;if(!n||s&&o!==t){let i=r&&`"${r}" `,c=s?` of length ${t}`:"",f=n?`length=${o}`:`type=${typeof e}`,a=i+"expected Uint8Array"+c+", got "+f;throw n?new RangeError(a):new TypeError(a)}return e}function vr(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(Ot(e.outputLen),Ot(e.blockLen),e.outputLen<1)throw new Error('"outputLen" must be >= 1');if(e.blockLen<1)throw new Error('"blockLen" must be >= 1')}function be(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Ar(e,t){ut(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function Dt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Br(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function lt(e,t){return e<<32-t|e>>>t}var Rs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",tf=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ir(e){if(ut(e),Rs)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=tf[e[r]];return t}var Tt={_0:48,_9:57,A:65,F:70,a:97,f:102};function Us(e){if(e>=Tt._0&&e<=Tt._9)return e-Tt._0;if(e>=Tt.A&&e<=Tt.F)return e-(Tt.A-10);if(e>=Tt.a&&e<=Tt.f)return e-(Tt.a-10)}function Ve(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(Rs)try{return Uint8Array.fromHex(e)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=Us(e.charCodeAt(s)),c=Us(e.charCodeAt(s+1));if(i===void 0||c===void 0){let f=e[s]+e[s+1];throw new RangeError('hex string expected, got non-hex character "'+f+'" at index '+s)}n[o]=i*16+c}return n}function Nn(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];ut(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}function Kn(e,t={}){let r=(o,s)=>e(s).update(o).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}function Os(e=32){Ot(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var kn=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Fs(e,t,r){return e&t^~e&r}function Ns(e,t,r){return e&t^e&r^t&r}var He=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,o){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=Br(this.buffer)}update(t){be(this),ut(t);let{view:r,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let f=Br(t);for(;o<=s-i;i+=o)this.process(f,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){be(this),Ar(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,Dt(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let h=i;h<o;h++)r[h]=0;n.setBigUint64(o-8,BigInt(this.length*8),s),this.process(n,0);let c=Br(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let a=f/4,u=this.get();if(a>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<a;h++)c.setUint32(4*h,u[h],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=c,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Lt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var et=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Tr=BigInt(4294967295),Ks=BigInt(32);function ef(e,t=!1){return t?{h:Number(e&Tr),l:Number(e>>Ks&Tr)}:{h:Number(e>>Ks&Tr)|0,l:Number(e&Tr)|0}}function ks(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:c}=ef(e[s],t);[n[s],o[s]]=[i,c]}return[n,o]}var Pn=(e,t,r)=>e>>>r,Mn=(e,t,r)=>e<<32-r|t>>>r,$t=(e,t,r)=>e>>>r|t<<32-r,Yt=(e,t,r)=>e<<32-r|t>>>r,ze=(e,t,r)=>e<<64-r|t>>>r-32,je=(e,t,r)=>e>>>r-32|t<<64-r;function wt(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Ps=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Ms=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,qs=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Vs=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Hs=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),zs=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;var nf=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),qn=class extends He{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:c,H:f}=this;return[t,r,n,o,s,i,c,f]}set(t,r,n,o,s,i,c,f){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=f|0}process(t,r){for(let h=0;h<16;h++,r+=4)Ft[h]=t.getUint32(r,!1);for(let h=16;h<64;h++){let E=Ft[h-15],m=Ft[h-2],l=lt(E,7)^lt(E,18)^E>>>3,w=lt(m,17)^lt(m,19)^m>>>10;Ft[h]=w+Ft[h-7]+l+Ft[h-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:f,G:a,H:u}=this;for(let h=0;h<64;h++){let E=lt(c,6)^lt(c,11)^lt(c,25),m=u+E+Fs(c,f,a)+nf[h]+Ft[h]|0,w=(lt(n,2)^lt(n,13)^lt(n,22))+Ns(n,o,s)|0;u=a,a=f,f=c,c=i+m|0,i=s,s=o,o=n,n=m+w|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,f=f+this.F|0,a=a+this.G|0,u=u+this.H|0,this.set(n,o,s,i,c,f,a,u)}roundClean(){Dt(Ft)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Dt(this.buffer)}},Vn=class extends qn{A=Lt[0]|0;B=Lt[1]|0;C=Lt[2]|0;D=Lt[3]|0;E=Lt[4]|0;F=Lt[5]|0;G=Lt[6]|0;H=Lt[7]|0;constructor(){super(32)}};var js=ks(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),of=js[0],sf=js[1],Nt=new Uint32Array(80),Kt=new Uint32Array(80),Hn=class extends He{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:f,Eh:a,El:u,Fh:h,Fl:E,Gh:m,Gl:l,Hh:w,Hl:p}=this;return[t,r,n,o,s,i,c,f,a,u,h,E,m,l,w,p]}set(t,r,n,o,s,i,c,f,a,u,h,E,m,l,w,p){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=f|0,this.Eh=a|0,this.El=u|0,this.Fh=h|0,this.Fl=E|0,this.Gh=m|0,this.Gl=l|0,this.Hh=w|0,this.Hl=p|0}process(t,r){for(let v=0;v<16;v++,r+=4)Nt[v]=t.getUint32(r),Kt[v]=t.getUint32(r+=4);for(let v=16;v<80;v++){let D=Nt[v-15]|0,T=Kt[v-15]|0,R=$t(D,T,1)^$t(D,T,8)^Pn(D,T,7),C=Yt(D,T,1)^Yt(D,T,8)^Mn(D,T,7),I=Nt[v-2]|0,F=Kt[v-2]|0,q=$t(I,F,19)^ze(I,F,61)^Pn(I,F,6),N=Yt(I,F,19)^je(I,F,61)^Mn(I,F,6),d=qs(C,N,Kt[v-7],Kt[v-16]),y=Vs(d,R,q,Nt[v-7],Nt[v-16]);Nt[v]=y|0,Kt[v]=d|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:f,Dh:a,Dl:u,Eh:h,El:E,Fh:m,Fl:l,Gh:w,Gl:p,Hh:b,Hl:S}=this;for(let v=0;v<80;v++){let D=$t(h,E,14)^$t(h,E,18)^ze(h,E,41),T=Yt(h,E,14)^Yt(h,E,18)^je(h,E,41),R=h&m^~h&w,C=E&l^~E&p,I=Hs(S,T,C,sf[v],Kt[v]),F=zs(I,b,D,R,of[v],Nt[v]),q=I|0,N=$t(n,o,28)^ze(n,o,34)^ze(n,o,39),d=Yt(n,o,28)^je(n,o,34)^je(n,o,39),y=n&s^n&c^s&c,A=o&i^o&f^i&f;b=w|0,S=p|0,w=m|0,p=l|0,m=h|0,l=E|0,{h,l:E}=wt(a|0,u|0,F|0,q|0),a=c|0,u=f|0,c=s|0,f=i|0,s=n|0,i=o|0;let g=Ps(q,d,A);n=Ms(g,F,N,y),o=g|0}({h:n,l:o}=wt(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=wt(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:f}=wt(this.Ch|0,this.Cl|0,c|0,f|0),{h:a,l:u}=wt(this.Dh|0,this.Dl|0,a|0,u|0),{h,l:E}=wt(this.Eh|0,this.El|0,h|0,E|0),{h:m,l}=wt(this.Fh|0,this.Fl|0,m|0,l|0),{h:w,l:p}=wt(this.Gh|0,this.Gl|0,w|0,p|0),{h:b,l:S}=wt(this.Hh|0,this.Hl|0,b|0,S|0),this.set(n,o,s,i,c,f,a,u,h,E,m,l,w,p,b,S)}roundClean(){Dt(Nt,Kt)}destroy(){this.destroyed=!0,Dt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},zn=class extends Hn{Ah=et[0]|0;Al=et[1]|0;Bh=et[2]|0;Bl=et[3]|0;Ch=et[4]|0;Cl=et[5]|0;Dh=et[6]|0;Dl=et[7]|0;Eh=et[8]|0;El=et[9]|0;Fh=et[10]|0;Fl=et[11]|0;Gh=et[12]|0;Gl=et[13]|0;Hh=et[14]|0;Hl=et[15]|0;constructor(){super(64)}};var Zs=Kn(()=>new Vn,kn(1));var Dr=Kn(()=>new zn,kn(3));var P=(e,t,r)=>ut(e,t,r),Zn=Ot,ye=Ir,W=(...e)=>Nn(...e),xe=e=>Ve(e),Gt=Fn,Ze=e=>Os(e),_r=BigInt(0),jn=BigInt(1);function pt(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new TypeError(r+"expected boolean, got type="+typeof e)}return e}function Cr(e){if(typeof e=="bigint"){if(!Lr(e))throw new RangeError("positive bigint expected, got "+e)}else Zn(e);return e}function mt(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function $e(e){let t=Cr(e).toString(16);return t.length&1?"0"+t:t}function $s(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?_r:BigInt("0x"+e)}function Xt(e){return $s(Ir(e))}function Et(e){return $s(Ir(Ye(ut(e)).reverse()))}function Ur(e,t){if(Ot(t),t===0)throw new RangeError("zero length");e=Cr(e);let r=e.toString(16);if(r.length>t*2)throw new RangeError("number too large");return Ve(r.padStart(t*2,"0"))}function $n(e,t){return Ur(e,t).reverse()}function Ys(e,t){if(e=P(e),t=P(t),e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function Ye(e){return Uint8Array.from(P(e))}function Rr(e){if(typeof e!="string")throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${n} at position ${r}`);return n})}var Lr=e=>typeof e=="bigint"&&_r<=e;function cf(e,t,r){return Lr(e)&&Lr(t)&&Lr(r)&&t<=e&&e<r}function ge(e,t,r,n){if(!cf(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function we(e){if(e<_r)throw new Error("expected non-negative bigint, got "+e);let t;for(t=0;e>_r;e>>=jn,t+=1);return t}var Ge=e=>(jn<<BigInt(e))-jn;function Gs(e,t,r){if(Ot(e,"hashLen"),Ot(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=p=>new Uint8Array(p),o=Uint8Array.of(),s=Uint8Array.of(0),i=Uint8Array.of(1),c=1e3,f=n(e),a=n(e),u=0,h=()=>{f.fill(1),a.fill(0),u=0},E=(...p)=>r(a,W(f,...p)),m=(p=o)=>{a=E(s,p),f=E(),p.length!==0&&(a=E(i,p),f=E())},l=()=>{if(u++>=c)throw new Error("drbg: tried max amount of iterations");let p=0,b=[];for(;p<t;){f=E();let S=f.slice();b.push(S),p+=f.length}return W(...b)};return(p,b)=>{h(),m(p);let S;for(;(S=b(l()))===void 0;)m();return h(),S}}function bt(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw new TypeError("expected valid options object");function n(s,i,c){if(!c&&i!=="function"&&!Object.hasOwn(e,s))throw new TypeError(`param "${s}" is invalid: expected own property`);let f=e[s];if(c&&f===void 0)return;let a=typeof f;if(a!==i||f===null)throw new TypeError(`param "${s}" is invalid: expected ${i}, got ${a}`)}let o=(s,i)=>Object.entries(s).forEach(([c,f])=>n(c,f,i));o(t,!1),o(r,!0)}var Yn=()=>{throw new Error("not implemented")};var rt=BigInt(0),j=BigInt(1),Wt=BigInt(2),Qs=BigInt(3),ti=BigInt(4),ei=BigInt(5),af=BigInt(7),ri=BigInt(8),ff=BigInt(9),ni=BigInt(16);function Y(e,t){if(t<=rt)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=rt?r:t+r}function H(e,t,r){if(t<rt)throw new Error("pow2: expected non-negative exponent, got "+t);let n=e;for(;t-- >rt;)n*=n,n%=r;return n}function Xs(e,t){if(e===rt)throw new Error("invert: expected non-zero number");if(t<=rt)throw new Error("invert: expected positive modulus, got "+t);let r=Y(e,t),n=t,o=rt,s=j,i=j,c=rt;for(;r!==rt;){let a=n/r,u=n-r*a,h=o-i*a,E=s-c*a;n=r,r=u,o=i,s=c,i=h,c=E}if(n!==j)throw new Error("invert: does not exist");return Y(o,t)}function Gn(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function oi(e,t){let r=e,n=(r.ORDER+j)/ti,o=r.pow(t,n);return Gn(r,o,t),o}function uf(e,t){let r=e,n=(r.ORDER-ei)/ri,o=r.mul(t,Wt),s=r.pow(o,n),i=r.mul(t,s),c=r.mul(r.mul(i,Wt),s),f=r.mul(i,r.sub(c,r.ONE));return Gn(r,f,t),f}function hf(e){let t=Ee(e),r=si(e),n=r(t,t.neg(t.ONE)),o=r(t,n),s=r(t,t.neg(n)),i=(e+af)/ni;return((c,f)=>{let a=c,u=a.pow(f,i),h=a.mul(u,n),E=a.mul(u,o),m=a.mul(u,s),l=a.eql(a.sqr(h),f),w=a.eql(a.sqr(E),f);u=a.cmov(u,h,l),h=a.cmov(m,E,w);let p=a.eql(a.sqr(h),f),b=a.cmov(u,h,p);return Gn(a,b,f),b})}function si(e){if(e<Qs)throw new Error("sqrt is not defined for small field");let t=e-j,r=0;for(;t%Wt===rt;)t/=Wt,r++;let n=Wt,o=Ee(e);for(;Ws(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return oi;let s=o.pow(n,t),i=(t+j)/Wt;return function(f,a){let u=f;if(u.is0(a))return a;if(Ws(u,a)!==1)throw new Error("Cannot find square root");let h=r,E=u.mul(u.ONE,s),m=u.pow(a,t),l=u.pow(a,i);for(;!u.eql(m,u.ONE);){if(u.is0(m))return u.ZERO;let w=1,p=u.sqr(m);for(;!u.eql(p,u.ONE);)if(w++,p=u.sqr(p),w===h)throw new Error("Cannot find square root");let b=j<<BigInt(h-w-1),S=u.pow(E,b);h=w,E=u.sqr(S),m=u.mul(m,E),l=u.mul(l,S)}return l}}function df(e){return e%ti===Qs?oi:e%ri===ei?uf:e%ni===ff?hf(e):si(e)}var _t=(e,t)=>(Y(e,t)&j)===j,lf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Xn(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=lf.reduce((n,o)=>(n[o]="function",n),t);if(bt(e,r),mt(e.BYTES,"BYTES"),mt(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=j)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function pf(e,t,r){let n=e;if(r<rt)throw new Error("invalid exponent, negatives unsupported");if(r===rt)return n.ONE;if(r===j)return t;let o=n.ONE,s=t;for(;r>rt;)r&j&&(o=n.mul(o,s)),s=n.sqr(s),r>>=j;return o}function Xe(e,t,r=!1){let n=e,o=new Array(t.length).fill(r?n.ZERO:void 0),s=t.reduce((c,f,a)=>n.is0(f)?c:(o[a]=c,n.mul(c,f)),n.ONE),i=n.inv(s);return t.reduceRight((c,f,a)=>n.is0(f)?c:(o[a]=n.mul(c,o[a]),n.mul(c,f)),i),o}function Ws(e,t){let r=e,n=(r.ORDER-j)/Wt,o=r.pow(t,n),s=r.eql(o,r.ONE),i=r.eql(o,r.ZERO),c=r.eql(o,r.neg(r.ONE));if(!s&&!i&&!c)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function mf(e,t){if(t!==void 0&&Zn(t),e<=rt)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=we(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let n=t!==void 0?t:r,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var Js=new WeakMap,Or=class{ORDER;BITS;BYTES;isLE;ZERO=rt;ONE=j;_lengths;_mod;constructor(t,r={}){if(t<=j)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:s}=mf(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 rt<=t&&t<this.ORDER}is0(t){return t===rt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&j)===j}neg(t){return Y(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return Y(t*t,this.ORDER)}add(t,r){return Y(t+r,this.ORDER)}sub(t,r){return Y(t-r,this.ORDER)}mul(t,r){return Y(t*r,this.ORDER)}pow(t,r){return pf(this,t,r)}div(t,r){return Y(t*Xs(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return Xs(t,this.ORDER)}sqrt(t){let r=Js.get(this);return r||Js.set(this,r=df(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?$n(t,this.BYTES):Ur(t,this.BYTES)}fromBytes(t,r=!1){P(t);let{_lengths:n,BYTES:o,isLE:s,ORDER:i,_mod:c}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let a=new Uint8Array(o);a.set(t,s?0:a.length-t.length),t=a}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let f=s?Et(t):Xt(t);if(c&&(f=Y(f,i)),!r&&!this.isValid(f))throw new Error("invalid field element: outside of range 0..ORDER");return f}invertBatch(t){return Xe(this,t)}cmov(t,r,n){return pt(n,"condition"),n?r:t}};Object.freeze(Or.prototype);function Ee(e,t={}){return new Or(e,t)}function ii(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=j)throw new Error("field order must be greater than 1");let t=we(e-j);return Math.ceil(t/8)}function Wn(e){let t=ii(e);return t+Math.ceil(t/2)}function Jn(e,t,r=!1){P(e);let n=e.length,o=ii(t),s=Math.max(Wn(t),16);if(n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=r?Et(e):Xt(e),c=Y(i,t-j)+j;return r?$n(c,o):Ur(c,o)}var Se=BigInt(0),Jt=BigInt(1);function We(e,t){let r=t.negate();return e?r:t}function Qt(e,t){let r=Xe(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function ui(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Qn(e,t){ui(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,s=Ge(e),i=BigInt(e);return{windows:r,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function ci(e,t,r){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=r,c=Number(e&o),f=e>>i;c>n&&(c-=s,f+=Jt);let a=t*n,u=a+Math.abs(c)-1,h=c===0,E=c<0,m=t%2!==0;return{nextN:f,offset:u,isZero:h,isNeg:E,isNegF:m,offsetF:a}}var to=new WeakMap,hi=new WeakMap;function eo(e){return hi.get(e)||1}function ai(e){if(e!==Se)throw new Error("invalid wNAF")}var ve=class{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let o=t;for(;r>Se;)r&Jt&&(n=n.add(o)),o=o.double(),r>>=Jt;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=Qn(r,this.bits),s=[],i=t,c=i;for(let f=0;f<n;f++){c=i,s.push(c);for(let a=1;a<o;a++)c=c.add(i),s.push(c);i=c.double()}return s}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE,i=Qn(t,this.bits);for(let c=0;c<i.windows;c++){let{nextN:f,offset:a,isZero:u,isNeg:h,isNegF:E,offsetF:m}=ci(n,c,i);n=f,u?s=s.add(We(E,r[m])):o=o.add(We(h,r[a]))}return ai(n),{p:o,f:s}}wNAFUnsafe(t,r,n,o=this.ZERO){let s=Qn(t,this.bits);for(let i=0;i<s.windows&&n!==Se;i++){let{nextN:c,offset:f,isZero:a,isNeg:u}=ci(n,i,s);if(n=c,!a){let h=r[f];o=o.add(u?h.negate():h)}}return ai(n),o}getPrecomputes(t,r,n){let o=to.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),to.set(r,o))),o}cached(t,r,n){let o=eo(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let s=eo(t);return s===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,n),r,o)}createCache(t,r){ui(r,this.bits),hi.set(t,r),to.delete(t)}hasCache(t){return eo(t)!==1}};function di(e,t,r,n){let o=t,s=e.ZERO,i=e.ZERO;for(;r>Se||n>Se;)r&Jt&&(s=s.add(o)),n&Jt&&(i=i.add(o)),o=o.double(),r>>=Jt,n>>=Jt;return{p1:s,p2:i}}function fi(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Xn(t),t}else return Ee(e,{isLE:r})}function Fr(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let f of["p","n","h"]){let a=t[f];if(!(typeof a=="bigint"&&a>Se))throw new Error(`CURVE.${f} must be positive bigint`)}let o=fi(t.p,r.Fp,n),s=fi(t.n,r.Fn,n),c=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let f of c)if(!o.isValid(t[f]))throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:s}}function Nr(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var kt=BigInt(0),tt=BigInt(1),ro=BigInt(2),bf=BigInt(8);function yf(e,t,r,n){let o=e.sqr(r),s=e.sqr(n),i=e.add(e.mul(t.a,o),s),c=e.add(e.ONE,e.mul(t.d,e.mul(o,s)));return e.eql(i,c)}function li(e,t={}){let r=t,n=Fr("edwards",e,r,r.FpFnLE),{Fp:o,Fn:s}=n,i=n.CURVE,{h:c}=i;bt(r,{},{uvRatio:"function"});let f=ro<<BigInt(s.BYTES*8)-tt,a=w=>o.create(w),u=r.uvRatio===void 0?(w,p)=>{try{return{isValid:!0,value:o.sqrt(o.div(w,p))}}catch{return{isValid:!1,value:kt}}}:r.uvRatio;if(!yf(o,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function h(w,p,b=!1){let S=b?tt:kt;return ge("coordinate "+w,p,S,f),p}function E(w){if(!(w instanceof m))throw new Error("EdwardsPoint expected")}class m{static BASE=new m(i.Gx,i.Gy,tt,a(i.Gx*i.Gy));static ZERO=new m(kt,tt,tt,kt);static Fp=o;static Fn=s;X;Y;Z;T;constructor(p,b,S,v){this.X=h("x",p),this.Y=h("y",b),this.Z=h("z",S,!0),this.T=h("t",v),Object.freeze(this)}static CURVE(){return i}static fromAffine(p){if(p instanceof m)throw new Error("extended point not allowed");let{x:b,y:S}=p||{};return h("x",b),h("y",S),new m(b,S,tt,a(b*S))}static fromBytes(p,b=!1){let S=o.BYTES,{a:v,d:D}=i;p=Ye(P(p,S,"point")),pt(b,"zip215");let T=Ye(p),R=p[S-1];T[S-1]=R&-129;let C=Et(T),I=b?f:o.ORDER;ge("point.y",C,kt,I);let F=a(C*C),q=a(F-tt),N=a(D*F-v),{isValid:d,value:y}=u(q,N);if(!d)throw new Error("bad point: invalid y coordinate");let A=(y&tt)===tt,g=(R&128)!==0;if(!b&&y===kt&&g)throw new Error("bad point: x=0 and x_0=1");return g!==A&&(y=a(-y)),m.fromAffine({x:y,y:C})}static fromHex(p,b=!1){return m.fromBytes(xe(p),b)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(p=8,b=!0){return l.createCache(this,p),b||this.multiply(ro),this}assertValidity(){let p=this,{a:b,d:S}=i;if(p.is0())throw new Error("bad point: ZERO");let{X:v,Y:D,Z:T,T:R}=p,C=a(v*v),I=a(D*D),F=a(T*T),q=a(F*F),N=a(C*b),d=a(F*a(N+I)),y=a(q+a(S*a(C*I)));if(d!==y)throw new Error("bad point: equation left != right (1)");let A=a(v*D),g=a(T*R);if(A!==g)throw new Error("bad point: equation left != right (2)")}equals(p){E(p);let{X:b,Y:S,Z:v}=this,{X:D,Y:T,Z:R}=p,C=a(b*R),I=a(D*v),F=a(S*R),q=a(T*v);return C===I&&F===q}is0(){return this.equals(m.ZERO)}negate(){return new m(a(-this.X),this.Y,this.Z,a(-this.T))}double(){let{a:p}=i,{X:b,Y:S,Z:v}=this,D=a(b*b),T=a(S*S),R=a(ro*a(v*v)),C=a(p*D),I=b+S,F=a(a(I*I)-D-T),q=C+T,N=q-R,d=C-T,y=a(F*N),A=a(q*d),g=a(F*d),x=a(N*q);return new m(y,A,x,g)}add(p){E(p);let{a:b,d:S}=i,{X:v,Y:D,Z:T,T:R}=this,{X:C,Y:I,Z:F,T:q}=p,N=a(v*C),d=a(D*I),y=a(R*S*q),A=a(T*F),g=a((v+D)*(C+I)-N-d),x=A-y,B=A+y,_=a(d-b*N),L=a(g*x),U=a(B*_),O=a(g*_),k=a(x*B);return new m(L,U,k,O)}subtract(p){return E(p),this.add(p.negate())}multiply(p){if(!s.isValidNot0(p))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:b,f:S}=l.cached(this,p,v=>Qt(m,v));return Qt(m,[b,S])[0]}multiplyUnsafe(p){if(!s.isValid(p))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return p===kt?m.ZERO:this.is0()||p===tt?this:l.unsafe(this,p,b=>Qt(m,b))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return l.unsafe(this,i.n).is0()}toAffine(p){let b=this,S=p,{X:v,Y:D,Z:T}=b,R=b.is0();S==null&&(S=R?bf:o.inv(T));let C=a(v*S),I=a(D*S),F=o.mul(T,S);if(R)return{x:kt,y:tt};if(F!==tt)throw new Error("invZ was invalid");return{x:C,y:I}}clearCofactor(){return c===tt?this:this.multiplyUnsafe(c)}toBytes(){let{x:p,y:b}=this.toAffine(),S=o.toBytes(b);return S[S.length-1]|=p&tt?128:0,S}toHex(){return ye(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let l=new ve(m,s.BITS);return s.BITS>=8&&m.BASE.precompute(8),Object.freeze(m.prototype),Object.freeze(m),m}var Kr=class{static BASE;static ZERO;static Fp;static Fn;ep;constructor(t){this.ep=t}static fromBytes(t){Yn()}static fromHex(t){Yn()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return ye(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,r){return this.ep.precompute(t,r),this}};function pi(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');let n=t,o=r;bt(o,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",zip215:"boolean",mapToCurve:"function"});let{prehash:s}=o,{BASE:i,Fp:c,Fn:f}=e,a=n.outputLen,u=2*c.BYTES;if(a!==void 0&&(mt(a,"hash.outputLen"),a!==u))throw new Error(`hash.outputLen must be ${u}, got ${a}`);let h=o.randomBytes===void 0?Ze:o.randomBytes,E=o.adjustScalarBytes===void 0?d=>d:o.adjustScalarBytes,m=o.domain===void 0?(d,y,A)=>{if(pt(A,"phflag"),y.length||A)throw new Error("Contexts/pre-hash are not supported");return d}:o.domain;function l(d){return f.create(Et(d))}function w(d){let y=C.secretKey;P(d,C.secretKey,"secretKey");let A=P(n(d),2*y,"hashedSecretKey"),g=E(A.slice(0,y)),x=A.slice(y,2*y),B=l(g);return{head:g,prefix:x,scalar:B}}function p(d){let{head:y,prefix:A,scalar:g}=w(d),x=i.multiply(g),B=x.toBytes();return{head:y,prefix:A,scalar:g,point:x,pointBytes:B}}function b(d){return p(d).pointBytes}function S(d=Uint8Array.of(),...y){let A=W(...y);return l(n(m(A,P(d,void 0,"context"),!!s)))}function v(d,y,A={}){d=P(d,void 0,"message"),s&&(d=s(d));let{prefix:g,scalar:x,pointBytes:B}=p(y),_=S(A.context,g,d),L=i.multiply(_).toBytes(),U=S(A.context,L,B,d),O=f.create(_+U*x);if(!f.isValid(O))throw new Error("sign failed: invalid s");let k=W(L,f.toBytes(O));return P(k,C.signature,"result")}let D={zip215:o.zip215};function T(d,y,A,g=D){let{context:x}=g,B=g.zip215===void 0?!!D.zip215:g.zip215,_=C.signature;d=P(d,_,"signature"),y=P(y,void 0,"message"),A=P(A,C.publicKey,"publicKey"),B!==void 0&&pt(B,"zip215"),s&&(y=s(y));let L=_/2,U=d.subarray(0,L),O=Et(d.subarray(L,_)),k,M,K;try{k=e.fromBytes(A,B),M=e.fromBytes(U,B),K=i.multiplyUnsafe(O)}catch{return!1}if(!B&&k.isSmallOrder())return!1;let X=S(x,U,A,y);return M.add(k.multiplyUnsafe(X)).subtract(K).clearCofactor().is0()}let R=c.BYTES,C={secretKey:R,publicKey:R,signature:2*R,seed:R};function I(d){return d=d===void 0?h(C.seed):d,P(d,C.seed,"seed")}function F(d){return Gt(d)&&d.length===C.secretKey}function q(d,y){try{return!!e.fromBytes(d,y===void 0?D.zip215:y)}catch{return!1}}let N={getExtendedPublicKey:p,randomSecretKey:I,isValidSecretKey:F,isValidPublicKey:q,toMontgomery(d){let{y}=e.fromBytes(d),A=C.publicKey,g=A===32;if(!g&&A!==57)throw new Error("only defined for 25519 and 448");let x=g?c.div(tt+y,tt-y):c.div(y-tt,y+tt);return c.toBytes(x)},toMontgomerySecret(d){let y=C.secretKey;P(d,y);let A=n(d.subarray(0,y));return E(A).subarray(0,y)}};return Object.freeze(C),Object.freeze(N),Object.freeze({keygen:Nr(I,b),getPublicKey:b,sign:v,verify:T,utils:N,Point:e,lengths:C})}function Je(e,t){if(mt(e),mt(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function xf(e,t){let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function gf(e){if(!Gt(e)&&typeof e!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof e=="string"?Rr(e):e;if(t.length===0)throw new Error("DST must be non-empty");return t}function no(e,t,r,n){P(e),mt(r),t=gf(t),t.length>255&&(t=n(W(Rr("H2C-OVERSIZE-DST-"),t)));let{outputLen:o,blockLen:s}=n,i=Math.ceil(r/o);if(r>65535||i>255)throw new Error("expand_message_xmd: invalid lenInBytes");let c=W(t,Je(t.length,1)),f=new Uint8Array(s),a=Je(r,2),u=new Array(i),h=n(W(f,e,a,Je(0,1),c));u[0]=n(W(h,Je(1,1),c));for(let m=1;m<i;m++){let l=[xf(h,u[m-1]),Je(m+1,1),c];u[m]=n(W(...l))}return W(...u).slice(0,r)}var mi="HashToScalar-";var wf=BigInt(0),Ct=BigInt(1),bi=BigInt(2);var Ef=BigInt(5),Sf=BigInt(8),Ae=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),co={p:Ae,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Sf,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function vf(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),s=Ae,c=e*e%s*e%s,f=H(c,bi,s)*c%s,a=H(f,Ct,s)*e%s,u=H(a,Ef,s)*a%s,h=H(u,t,s)*u%s,E=H(h,r,s)*h%s,m=H(E,n,s)*E%s,l=H(m,o,s)*m%s,w=H(l,o,s)*m%s,p=H(w,t,s)*u%s;return{pow_p_5_8:H(p,bi,s)*e%s,b2:c}}function Af(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var oo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function ao(e,t){let r=Ae,n=Y(t*t*t,r),o=Y(n*n*t,r),s=vf(e*o).pow_p_5_8,i=Y(e*n*s,r),c=Y(t*i*i,r),f=i,a=Y(i*oo,r),u=c===e,h=c===Y(-e,r),E=c===Y(-e*oo,r);return u&&(i=f),(h||E)&&(i=a),_t(i,r)&&(i=Y(-i,r)),{isValid:u||h,value:i}}var Mt=li(co,{uvRatio:ao}),Pt=Mt.Fp,gi=Mt.Fn;function Bf(e){return pi(Mt,Dr,Object.assign({adjustScalarBytes:Af,zip215:!0},e))}var wi=Bf({});var so=oo,If=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Tf=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Df=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Lf=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),yi=e=>ao(Ct,e),_f=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),io=e=>Pt.create(Et(e)&_f);function xi(e){let{d:t}=co,r=Ae,n=b=>Pt.create(b),o=n(so*e*e),s=n((o+Ct)*Df),i=BigInt(-1),c=n((i-t*o)*n(o+t)),{isValid:f,value:a}=ao(s,c),u=n(a*e);_t(u,r)||(u=n(-u)),f||(a=u),f||(i=o);let h=n(i*(o-Ct)*Lf-c),E=a*a,m=n((a+a)*c),l=n(h*If),w=n(Ct-E),p=n(Ct+E);return new Mt(n(m*p),n(w*l),n(l*p),n(m*w))}var qt=class e extends Kr{static BASE=new e(Mt.BASE);static ZERO=new e(Mt.ZERO);static Fp=Pt;static Fn=gi;constructor(t){super(t)}static fromAffine(t){return new e(Mt.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw new Error("RistrettoPoint expected")}init(t){return new e(t)}static fromBytes(t){ut(t,32);let{a:r,d:n}=co,o=Ae,s=D=>Pt.create(D),i=io(t);if(!Ys(Pt.toBytes(i),t)||_t(i,o))throw new Error("invalid ristretto255 encoding 1");let c=s(i*i),f=s(Ct+r*c),a=s(Ct-r*c),u=s(f*f),h=s(a*a),E=s(r*n*u-h),{isValid:m,value:l}=yi(s(E*h)),w=s(l*a),p=s(l*w*E),b=s((i+i)*w);_t(b,o)&&(b=s(-b));let S=s(f*p),v=s(b*S);if(!m||_t(v,o)||S===wf)throw new Error("invalid ristretto255 encoding 2");return new e(new Mt(b,S,Ct,v))}static fromHex(t){return e.fromBytes(Ve(t))}toBytes(){let{X:t,Y:r,Z:n,T:o}=this.ep,s=Ae,i=p=>Pt.create(p),c=i(i(n+r)*i(n-r)),f=i(t*r),a=i(f*f),{value:u}=yi(i(c*a)),h=i(u*c),E=i(u*f),m=i(h*E*o),l;if(_t(o*m,s)){let p=i(r*so),b=i(t*so);t=p,r=b,l=i(h*Tf)}else l=E;_t(t*m,s)&&(r=i(-r));let w=i((n-r)*l);return _t(w,s)&&(w=i(-w)),Pt.toBytes(w)}equals(t){this.assertSame(t);let{X:r,Y:n}=this.ep,{X:o,Y:s}=t.ep,i=a=>Pt.create(a),c=i(r*s)===i(n*o),f=i(n*s)===i(r*o);return c||f}is0(){return this.equals(e.ZERO)}};Object.freeze(qt.BASE);Object.freeze(qt.ZERO);Object.freeze(qt.prototype);Object.freeze(qt);var Cf=Object.freeze({Point:qt,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,n=no(e,r,64,Dr);return Cf.deriveToCurve(n)},hashToScalar(e,t={DST:mi}){let r=no(e,t.DST,64,Dr);return gi.create(Et(r))},deriveToCurve(e){ut(e,64);let t=io(e.subarray(0,32)),r=xi(t),n=io(e.subarray(32,64)),o=xi(n);return new qt(r.add(o))}});var Qe=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},kr=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Pr={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new kr("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var Mr=32;var fo,Uf=(async()=>{try{return await Pr.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function Rf(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await Pr.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await Pr.get().subtle.verify({name:"Ed25519"},n,de(t),de(r instanceof Uint8Array?r:r.subarray()))}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Of(e,t,r){return wi.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function Ei(e,t,r){return fo==null&&(fo=await Uf),fo?Rf(e,t,r):Of(e,t,r)}function qr(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var Vr=class{type="Ed25519";raw;constructor(t){this.raw=uo(t,Mr)}toMultihash(){return dt.digest(me(this))}toCID(){return ot.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Bt(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=Ei(this.raw,r,t);return qr(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function vi(e){return e=uo(e,Mr),new Vr(e)}function uo(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new gt(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var Nf=Math.pow(2,7),Kf=Math.pow(2,14),kf=Math.pow(2,21),Ai=Math.pow(2,28),Bi=Math.pow(2,35),Ii=Math.pow(2,42),Ti=Math.pow(2,49),st=128,Vt=127;function tr(e){if(e<Nf)return 1;if(e<Kf)return 2;if(e<kf)return 3;if(e<Ai)return 4;if(e<Bi)return 5;if(e<Ii)return 6;if(e<Ti)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Di(e,t,r=0){switch(tr(e)){case 8:t[r++]=e&255|st,e/=128;case 7:t[r++]=e&255|st,e/=128;case 6:t[r++]=e&255|st,e/=128;case 5:t[r++]=e&255|st,e/=128;case 4:t[r++]=e&255|st,e>>>=7;case 3:t[r++]=e&255|st,e>>>=7;case 2:t[r++]=e&255|st,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Li(e,t){let r=e[t],n=0;if(n+=r&Vt,r<st||(r=e[t+1],n+=(r&Vt)<<7,r<st)||(r=e[t+2],n+=(r&Vt)<<14,r<st)||(r=e[t+3],n+=(r&Vt)<<21,r<st)||(r=e[t+4],n+=(r&Vt)*Ai,r<st)||(r=e[t+5],n+=(r&Vt)*Bi,r<st)||(r=e[t+6],n+=(r&Vt)*Ii,r<st)||(r=e[t+7],n+=(r&Vt)*Ti,r<st))return n;throw new RangeError("Could not decode varint")}var ho=new Float32Array([-0]),Ht=new Uint8Array(ho.buffer);function _i(e,t,r){ho[0]=e,t[r]=Ht[0],t[r+1]=Ht[1],t[r+2]=Ht[2],t[r+3]=Ht[3]}function Ci(e,t){return Ht[0]=e[t],Ht[1]=e[t+1],Ht[2]=e[t+2],Ht[3]=e[t+3],ho[0]}var lo=new Float64Array([-0]),nt=new Uint8Array(lo.buffer);function Ui(e,t,r){lo[0]=e,t[r]=nt[0],t[r+1]=nt[1],t[r+2]=nt[2],t[r+3]=nt[3],t[r+4]=nt[4],t[r+5]=nt[5],t[r+6]=nt[6],t[r+7]=nt[7]}function Ri(e,t){return nt[0]=e[t],nt[1]=e[t+1],nt[2]=e[t+2],nt[3]=e[t+3],nt[4]=e[t+4],nt[5]=e[t+5],nt[6]=e[t+6],nt[7]=e[t+7],lo[0]}var Pf=BigInt(Number.MAX_SAFE_INTEGER),Mf=BigInt(Number.MIN_SAFE_INTEGER),ht=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return te;if(t<Pf&&t>Mf)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>Oi&&(o=0n,++n>Oi&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return te;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):te}},te=new ht(0,0);te.toBigInt=function(){return 0n};te.zzEncode=te.zzDecode=function(){return this};te.length=function(){return 1};var Oi=4294967296n;function Fi(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Ni(e,t,r){if(r-t<1)return"";let o,s=[],i=0,c;for(;t<r;)c=e[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|e[t++]&63:c>239&&c<365?(c=((c&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(e[t++]&63)<<6|e[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function po(e,t,r){let n=r,o,s;for(let i=0;i<e.length;++i)o=e.charCodeAt(i),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((s=e.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function yt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Hr(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var mo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,yt(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 yt(this,4);return Hr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw yt(this,4);return Hr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw yt(this,4);let t=Ci(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw yt(this,4);let t=Ri(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw yt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Ni(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw yt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw yt(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 ht(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw yt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw yt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw yt(this,8);let t=Hr(this.buf,this.pos+=4),r=Hr(this.buf,this.pos+=4);return new ht(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Li(this.buf,this.pos);return this.pos+=tr(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 er(e){return new mo(e instanceof Uint8Array?e:e.subarray())}function zr(e,t,r){let n=er(e);return t.decode(n,void 0,r)}function ee(e=0){return new Uint8Array(e)}var wo={};V(wo,{base10:()=>$f});var b0=new Uint8Array(0);function ki(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Ut(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function Pi(e){return new TextEncoder().encode(e)}function Mi(e){return new TextDecoder().decode(e)}function qf(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var c=e.length,f=e.charAt(0),a=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function h(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var w=0,p=0,b=0,S=l.length;b!==S&&l[b]===0;)b++,w++;for(var v=(S-b)*u+1>>>0,D=new Uint8Array(v);b!==S;){for(var T=l[b],R=0,C=v-1;(T!==0||R<p)&&C!==-1;C--,R++)T+=256*D[C]>>>0,D[C]=T%c>>>0,T=T/c>>>0;if(T!==0)throw new Error("Non-zero carry");p=R,b++}for(var I=v-p;I!==v&&D[I]===0;)I++;for(var F=f.repeat(w);I<v;++I)F+=e.charAt(D[I]);return F}function E(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var w=0;if(l[w]!==" "){for(var p=0,b=0;l[w]===f;)p++,w++;for(var S=(l.length-w)*a+1>>>0,v=new Uint8Array(S);l[w];){var D=r[l.charCodeAt(w)];if(D===255)return;for(var T=0,R=S-1;(D!==0||T<b)&&R!==-1;R--,T++)D+=c*v[R]>>>0,v[R]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");b=T,w++}if(l[w]!==" "){for(var C=S-b;C!==S&&v[C]===0;)C++;for(var I=new Uint8Array(p+(S-C)),F=p;C!==S;)I[F++]=v[C++];return I}}}function m(l){var w=E(l);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:E,decode:m}}var Vf=qf,Hf=Vf,Vi=Hf;var bo=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},yo=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Hi(this,t)}},xo=class{decoders;constructor(t){this.decoders=t}or(t){return Hi(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Hi(e,t){return new xo({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var go=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new bo(t,r,n),this.decoder=new yo(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Be({name:e,prefix:t,encode:r,decode:n}){return new go(e,t,r,n)}function zt({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Vi(r,e);return Be({prefix:t,name:e,encode:n,decode:s=>Ut(o(s))})}function zf(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),i=0,c=0,f=0;for(let a=0;a<o;++a){let u=t[e[a]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|u,i+=r,i>=8&&(i-=8,s[f++]=255&c>>i)}if(i>=r||(255&c<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function jf(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,c=0;for(let f=0;f<e.length;++f)for(c=c<<8|e[f],i+=8;i>r;)i-=r,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<r-i]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function Zf(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function Z({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Zf(n);return Be({prefix:t,name:e,encode(s){return jf(s,n,r)},decode(s){return zf(s,o,r,e)}})}var $f=zt({prefix:"9",name:"base10",alphabet:"0123456789"});var Eo={};V(Eo,{base16:()=>Yf,base16upper:()=>Gf});var Yf=Z({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Gf=Z({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var So={};V(So,{base2:()=>Xf});var Xf=Z({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var vo={};V(vo,{base256emoji:()=>eu});var zi=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}"),Wf=zi.reduce((e,t,r)=>(e[r]=t,e),[]),Jf=zi.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Qf(e){return e.reduce((t,r)=>(t+=Wf[r],t),"")}function tu(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Jf[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var eu=Be({prefix:"\u{1F680}",name:"base256emoji",encode:Qf,decode:tu});var Ao={};V(Ao,{base32:()=>Ie,base32hex:()=>su,base32hexpad:()=>cu,base32hexpadupper:()=>au,base32hexupper:()=>iu,base32pad:()=>nu,base32padupper:()=>ou,base32upper:()=>ru,base32z:()=>fu});var Ie=Z({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ru=Z({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),nu=Z({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ou=Z({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),su=Z({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),iu=Z({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),cu=Z({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),au=Z({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),fu=Z({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Bo={};V(Bo,{base36:()=>rr,base36upper:()=>uu});var rr=zt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),uu=zt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Io={};V(Io,{base58btc:()=>St,base58flickr:()=>hu});var St=zt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),hu=zt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var To={};V(To,{base64:()=>du,base64pad:()=>lu,base64url:()=>pu,base64urlpad:()=>mu});var du=Z({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),lu=Z({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),pu=Z({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mu=Z({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Do={};V(Do,{base8:()=>bu});var bu=Z({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Lo={};V(Lo,{identity:()=>yu});var yu=Be({prefix:"\0",name:"identity",encode:e=>Mi(e),decode:e=>Pi(e)});var U0=new TextEncoder,R0=new TextDecoder;var Co={};V(Co,{identity:()=>Mu});var wu=$i,ji=128,Eu=127,Su=~Eu,vu=Math.pow(2,31);function $i(e,t,r){t=t||[],r=r||0;for(var n=r;e>=vu;)t[r++]=e&255|ji,e/=128;for(;e&Su;)t[r++]=e&255|ji,e>>>=7;return t[r]=e|0,$i.bytes=r-n+1,t}var Au=_o,Bu=128,Zi=127;function _o(e,n){var r=0,n=n||0,o=0,s=n,i,c=e.length;do{if(s>=c)throw _o.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&Zi)<<o:(i&Zi)*Math.pow(2,o),o+=7}while(i>=Bu);return _o.bytes=s-n,r}var Iu=Math.pow(2,7),Tu=Math.pow(2,14),Du=Math.pow(2,21),Lu=Math.pow(2,28),_u=Math.pow(2,35),Cu=Math.pow(2,42),Uu=Math.pow(2,49),Ru=Math.pow(2,56),Ou=Math.pow(2,63),Fu=function(e){return e<Iu?1:e<Tu?2:e<Du?3:e<Lu?4:e<_u?5:e<Cu?6:e<Uu?7:e<Ru?8:e<Ou?9:10},Nu={encode:wu,decode:Au,encodingLength:Fu},Ku=Nu,nr=Ku;function or(e,t=0){return[nr.decode(e,t),nr.decode.bytes]}function Te(e,t,r=0){return nr.encode(e,t,r),t}function De(e){return nr.encodingLength(e)}function _e(e,t){let r=t.byteLength,n=De(e),o=n+De(r),s=new Uint8Array(o+r);return Te(e,s,0),Te(r,s,n),s.set(t,o),new Le(e,r,t,s)}function Yi(e){let t=Ut(e),[r,n]=or(t),[o,s]=or(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Le(r,o,i,t)}function Gi(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&ki(e.bytes,r.bytes)}}var Le=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};var Xi=0,ku="identity",Wi=Ut;function Pu(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return _e(Xi,Wi(e))}var Mu={code:Xi,name:ku,encode:Wi,digest:Pu};var Oo={};V(Oo,{sha256:()=>Vu,sha512:()=>Hu});var qu=20;function Ro({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new Uo(e,t,r,n,o)}var Uo=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,s){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??qu,this.maxDigestLength=s}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?Ji(n,this.code,r?.truncate):n.then(o=>Ji(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Ji(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return _e(t,e)}function tc(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Vu=Ro({name:"sha2-256",code:18,encode:tc("SHA-256")}),Hu=Ro({name:"sha2-512",code:19,encode:tc("SHA-512")});function ec(e,t){let{bytes:r,version:n}=e;return n===0?ju(r,Fo(e),t??St.encoder):Zu(r,Fo(e),t??Ie.encoder)}var rc=new WeakMap;function Fo(e){let t=rc.get(e);if(t==null){let r=new Map;return rc.set(e,r),r}return t}var Zr=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==ir)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==$u)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=_e(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&Gi(t.multihash,n.multihash)}toString(t){return ec(this,t)}toJSON(){return{"/":ec(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new e(n,o,s,i??nc(n,o,s.bytes))}else if(r[Yu]===!0){let{version:n,multihash:o,code:s}=r,i=Yi(o);return e.create(n,s,i)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==ir)throw new Error(`Version 0 CID must use dag-pb (code: ${ir}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=nc(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,ir,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=Ut(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new Le(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(i):e.createV1(r.codec,i),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[h,E]=or(t.subarray(r));return r+=E,h},o=n(),s=ir;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,c=n(),f=n(),a=r+f,u=a-i;return{version:o,codec:s,multihashCode:c,digestSize:f,multihashSize:u,size:a}}static parse(t,r){let[n,o]=zu(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Fo(s).set(n,t),s}};function zu(e,t){switch(e[0]){case"Q":{let r=t??St;return[St.prefix,r.decode(`${St.prefix}${e}`)]}case St.prefix:{let r=t??St;return[St.prefix,r.decode(e)]}case Ie.prefix:{let r=t??Ie;return[Ie.prefix,r.decode(e)]}case rr.prefix:{let r=t??rr;return[rr.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function ju(e,t,r){let{prefix:n}=r;if(n!==St.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function Zu(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var ir=112,$u=18;function nc(e,t,r){let n=De(e),o=n+De(t),s=new Uint8Array(o+r.byteLength);return Te(e,s,0),Te(t,s,n),s.set(r,o),s}var Yu=Symbol.for("@ipld/js-cid/CID");var No={...Lo,...So,...Do,...wo,...Eo,...Ao,...Bo,...Io,...To,...vo},ep={...Oo,...Co};function sc(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var oc=sc("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Ko=sc("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=ee(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Gu={utf8:oc,"utf-8":oc,hex:No.base16,latin1:Ko,ascii:Ko,binary:Ko,...No},ic=Gu;function cc(e,t="utf8"){let r=ic[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function ko(e){let t=e??8192,r=t>>>1,n,o=t;return function(i){if(i<1||i>r)return ee(i);o+i>t&&(n=ee(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var re=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Po(){}var qo=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Xu=ko();function Wu(e){return globalThis.Buffer!=null?ee(e):Xu(e)}var ar=class{len;head;tail;states;constructor(){this.len=0,this.head=new re(Po,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new re(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Vo((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($r,10,ht.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=ht.fromBigInt(t);return this._push($r,r.length(),r)}uint64Number(t){return this._push(Di,tr(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let r=ht.fromBigInt(t).zzEncode();return this._push($r,r.length(),r)}sint64Number(t){let r=ht.fromNumber(t).zzEncode();return this._push($r,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Mo,1,t?1:0)}fixed32(t){return this._push(cr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=ht.fromBigInt(t);return this._push(cr,4,r.lo)._push(cr,4,r.hi)}fixed64Number(t){let r=ht.fromNumber(t);return this._push(cr,4,r.lo)._push(cr,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(_i,4,t)}double(t){return this._push(Ui,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(Mo,1,0):this.uint32(r)._push(Qu,r,t)}string(t){let r=Fi(t);return r!==0?this.uint32(r)._push(po,r,t):this._push(Mo,1,0)}fork(){return this.states=new qo(this),this.head=this.tail=new re(Po,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new re(Po,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=Wu(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function Mo(e,t,r){t[r]=e&255}function Ju(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Vo=class extends re{next;constructor(t,r){super(Ju,t,r),this.next=void 0}};function $r(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function cr(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function Qu(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(ar.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(th,t,e),this},ar.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(eh,t,e),this});function th(e,t,r){t.set(e,r)}function eh(e,t,r){e.length<40?po(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(cc(e),r)}function Ho(){return new ar}function Yr(e,t){let r=Ho();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}function*Gr(e,t,r){let n=er(e);yield*t.stream(n,void 0,"$",r)}var Xr={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function Wr(e,t,r,n,o){return{name:e,type:t,encode:r,decode:n,stream:o}}function zo(e){function t(s){if(e[s.toString()]==null)throw new Error("Invalid enum value");return e[s]}let r=function(i,c){let f=t(i);c.int32(f)},n=function(i){let c=i.int32();return t(c)},o=function*(i){let c=i.int32();yield t(c)};return Wr("enum",Xr.VARINT,r,n,o)}function Jr(e,t,r){return Wr("message",Xr.LENGTH_DELIMITED,e,t,r)}var it;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(it||(it={}));var jo;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(jo||(jo={}));(function(e){e.codec=()=>zo(jo)})(it||(it={}));var fr;(function(e){let t;e.codec=()=>(t==null&&(t=Jr((s,i,c={})=>{c.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),it.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),c.lengthDelimited!==!1&&i.ldelim()},(s,i,c={})=>{let f={},a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{f.Type=it.codec().decode(s);break}case 2:{f.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return f},function*(s,i,c,f={}){let a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${c}.Type`,value:it.codec().decode(s)};break}case 2:{yield{field:`${c}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function r(s){return Yr(s,e.codec())}e.encode=r;function n(s,i){return zr(s,e.codec(),i)}e.decode=n;function o(s,i){return Gr(s,e.codec(),i)}e.stream=o})(fr||(fr={}));var Zo;(function(e){let t;e.codec=()=>(t==null&&(t=Jr((s,i,c={})=>{c.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),it.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),c.lengthDelimited!==!1&&i.ldelim()},(s,i,c={})=>{let f={},a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{f.Type=it.codec().decode(s);break}case 2:{f.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return f},function*(s,i,c,f={}){let a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${c}.Type`,value:it.codec().decode(s)};break}case 2:{yield{field:`${c}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function r(s){return Yr(s,e.codec())}e.encode=r;function n(s,i){return zr(s,e.codec(),i)}e.decode=n;function o(s,i){return Gr(s,e.codec(),i)}e.stream=o})(Zo||(Zo={}));var Qr=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,r){if(vr(t),ut(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=t.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),Dt(o)}update(t){return be(this),this.iHash.update(t),this}digestInto(t){be(this),Ar(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ac=(()=>{let e=((t,r,n)=>new Qr(t,r).update(n).digest());return e.create=(t,r)=>new Qr(t,r),e})();var fc=(e,t)=>(e+(e>=0?t:-t)/uc)/t;function nh(e,t,r){ge("scalar",e,vt,r);let[[n,o],[s,i]]=t,c=fc(i*e,r),f=fc(-o*e,r),a=e-c*n-f*s,u=-c*o-f*i,h=a<vt,E=u<vt;h&&(a=-a),E&&(u=-u);let m=Ge(Math.ceil(we(r)/2))+jt;if(a<vt||a>=m||u<vt||u>=m)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:h,k1:a,k2neg:E,k2:u}}function Yo(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function $o(e,t){bt(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return pt(r.lowS,"lowS"),pt(r.prehash,"prehash"),r.format!==void 0&&Yo(r.format),r}var Go=class extends Error{constructor(t=""){super(t)}},xt={Err:Go,_tlv:{encode:(e,t)=>{let{Err:r}=xt;if(mt(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!="string")throw new TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=$e(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?$e(o.length/2|128):"";return $e(e)+s+o+t},decode(e,t){let{Err:r}=xt;t=P(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let f=o&127;if(!f)throw new r("tlv.decode(long): indefinite length not supported");if(f>4)throw new r("tlv.decode(long): byte length is too big");let a=t.subarray(n,n+f);if(a.length!==f)throw new r("tlv.decode: length bytes not complete");if(a[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of a)i=i<<8|u;if(n+=f,i<128)throw new r("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new r("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(e){let{Err:t}=xt;if(Cr(e),e<vt)throw new t("integer: negative integers are not allowed");let r=$e(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=xt;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Xt(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=xt,o=P(e,void 0,"signature"),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:f}=n.decode(2,s),{v:a,l:u}=n.decode(2,f);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(a)}},hexFromSig(e){let{_tlv:t,_int:r}=xt,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),s=n+o;return t.encode(48,s)}};Object.freeze(xt._tlv);Object.freeze(xt._int);Object.freeze(xt);var vt=BigInt(0),jt=BigInt(1),uc=BigInt(2),tn=BigInt(3),oh=BigInt(4);function hc(e,t={}){let r=Fr("weierstrass",e,t),n=r.Fp,o=r.Fn,s=r.CURVE,{h:i,n:c}=s;bt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:f,allowInfinityPoint:a}=t;if(f&&(!n.is0(s.a)||typeof f.beta!="bigint"||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let u=lc(n,o);function h(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function E(N,d,y){if(a&&d.is0())return Uint8Array.of(0);let{x:A,y:g}=d.toAffine(),x=n.toBytes(A);if(pt(y,"isCompressed"),y){h();let B=!n.isOdd(g);return W(dc(B),x)}else return W(Uint8Array.of(4),x,n.toBytes(g))}function m(N){P(N,void 0,"Point");let{publicKey:d,publicKeyUncompressed:y}=u,A=N.length,g=N[0],x=N.subarray(1);if(a&&A===1&&g===0)return{x:n.ZERO,y:n.ZERO};if(A===d&&(g===2||g===3)){let B=n.fromBytes(x);if(!n.isValid(B))throw new Error("bad point: is not on curve, wrong x");let _=p(B),L;try{L=n.sqrt(_)}catch(k){let M=k instanceof Error?": "+k.message:"";throw new Error("bad point: is not on curve, sqrt error"+M)}h();let U=n.isOdd(L);return(g&1)===1!==U&&(L=n.neg(L)),{x:B,y:L}}else if(A===y&&g===4){let B=n.BYTES,_=n.fromBytes(x.subarray(0,B)),L=n.fromBytes(x.subarray(B,B*2));if(!b(_,L))throw new Error("bad point: is not on curve");return{x:_,y:L}}else throw new Error(`bad point: got length ${A}, expected compressed=${d} or uncompressed=${y}`)}let l=t.toBytes===void 0?E:t.toBytes,w=t.fromBytes===void 0?m:t.fromBytes;function p(N){let d=n.sqr(N),y=n.mul(d,N);return n.add(n.add(y,n.mul(N,s.a)),s.b)}function b(N,d){let y=n.sqr(d),A=p(N);return n.eql(y,A)}if(!b(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let S=n.mul(n.pow(s.a,tn),oh),v=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(S,v)))throw new Error("bad curve params: a or b");function D(N,d,y=!1){if(!n.isValid(d)||y&&n.is0(d))throw new Error(`bad point coordinate ${N}`);return d}function T(N){if(!(N instanceof I))throw new Error("Weierstrass Point expected")}function R(N){if(!f||!f.basises)throw new Error("no endo");return nh(N,f.basises,o.ORDER)}function C(N,d,y,A,g){return y=new I(n.mul(y.X,N),y.Y,y.Z),d=We(A,d),y=We(g,y),d.add(y)}class I{static BASE=new I(s.Gx,s.Gy,n.ONE);static ZERO=new I(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(d,y,A){this.X=D("x",d),this.Y=D("y",y,!0),this.Z=D("z",A),Object.freeze(this)}static CURVE(){return s}static fromAffine(d){let{x:y,y:A}=d||{};if(!d||!n.isValid(y)||!n.isValid(A))throw new Error("invalid affine point");if(d instanceof I)throw new Error("projective point not allowed");return n.is0(y)&&n.is0(A)?I.ZERO:new I(y,A,n.ONE)}static fromBytes(d){let y=I.fromAffine(w(P(d,void 0,"point")));return y.assertValidity(),y}static fromHex(d){return I.fromBytes(xe(d))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(d=8,y=!0){return q.createCache(this,d),y||this.multiply(tn),this}assertValidity(){let d=this;if(d.is0()){if(t.allowInfinityPoint&&n.is0(d.X)&&n.eql(d.Y,n.ONE)&&n.is0(d.Z))return;throw new Error("bad point: ZERO")}let{x:y,y:A}=d.toAffine();if(!n.isValid(y)||!n.isValid(A))throw new Error("bad point: x or y not field elements");if(!b(y,A))throw new Error("bad point: equation left != right");if(!d.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:d}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(d)}equals(d){T(d);let{X:y,Y:A,Z:g}=this,{X:x,Y:B,Z:_}=d,L=n.eql(n.mul(y,_),n.mul(x,g)),U=n.eql(n.mul(A,_),n.mul(B,g));return L&&U}negate(){return new I(this.X,n.neg(this.Y),this.Z)}double(){let{a:d,b:y}=s,A=n.mul(y,tn),{X:g,Y:x,Z:B}=this,_=n.ZERO,L=n.ZERO,U=n.ZERO,O=n.mul(g,g),k=n.mul(x,x),M=n.mul(B,B),K=n.mul(g,x);return K=n.add(K,K),U=n.mul(g,B),U=n.add(U,U),_=n.mul(d,U),L=n.mul(A,M),L=n.add(_,L),_=n.sub(k,L),L=n.add(k,L),L=n.mul(_,L),_=n.mul(K,_),U=n.mul(A,U),M=n.mul(d,M),K=n.sub(O,M),K=n.mul(d,K),K=n.add(K,U),U=n.add(O,O),O=n.add(U,O),O=n.add(O,M),O=n.mul(O,K),L=n.add(L,O),M=n.mul(x,B),M=n.add(M,M),O=n.mul(M,K),_=n.sub(_,O),U=n.mul(M,k),U=n.add(U,U),U=n.add(U,U),new I(_,L,U)}add(d){T(d);let{X:y,Y:A,Z:g}=this,{X:x,Y:B,Z:_}=d,L=n.ZERO,U=n.ZERO,O=n.ZERO,k=s.a,M=n.mul(s.b,tn),K=n.mul(y,x),X=n.mul(A,B),J=n.mul(g,_),Q=n.add(y,A),$=n.add(x,B);Q=n.mul(Q,$),$=n.add(K,X),Q=n.sub(Q,$),$=n.add(y,g);let ct=n.add(x,_);return $=n.mul($,ct),ct=n.add(K,J),$=n.sub($,ct),ct=n.add(A,g),L=n.add(B,_),ct=n.mul(ct,L),L=n.add(X,J),ct=n.sub(ct,L),O=n.mul(k,$),L=n.mul(M,J),O=n.add(L,O),L=n.sub(X,O),O=n.add(X,O),U=n.mul(L,O),X=n.add(K,K),X=n.add(X,K),J=n.mul(k,J),$=n.mul(M,$),X=n.add(X,J),J=n.sub(K,J),J=n.mul(k,J),$=n.add($,J),K=n.mul(X,$),U=n.add(U,K),K=n.mul(ct,$),L=n.mul(Q,L),L=n.sub(L,K),K=n.mul(Q,X),O=n.mul(ct,O),O=n.add(O,K),new I(L,U,O)}subtract(d){return T(d),this.add(d.negate())}is0(){return this.equals(I.ZERO)}multiply(d){let{endo:y}=t;if(!o.isValidNot0(d))throw new RangeError("invalid scalar: out of range");let A,g,x=B=>q.cached(this,B,_=>Qt(I,_));if(y){let{k1neg:B,k1:_,k2neg:L,k2:U}=R(d),{p:O,f:k}=x(_),{p:M,f:K}=x(U);g=k.add(K),A=C(y.beta,O,M,B,L)}else{let{p:B,f:_}=x(d);A=B,g=_}return Qt(I,[A,g])[0]}multiplyUnsafe(d){let{endo:y}=t,A=this,g=d;if(!o.isValid(g))throw new RangeError("invalid scalar: out of range");if(g===vt||A.is0())return I.ZERO;if(g===jt)return A;if(q.hasCache(this))return this.multiply(g);if(y){let{k1neg:x,k1:B,k2neg:_,k2:L}=R(g),{p1:U,p2:O}=di(I,A,B,L);return C(y.beta,U,O,x,_)}else return q.unsafe(A,g)}toAffine(d){let y=this,A=d,{X:g,Y:x,Z:B}=y;if(n.eql(B,n.ONE))return{x:g,y:x};let _=y.is0();A==null&&(A=_?n.ONE:n.inv(B));let L=n.mul(g,A),U=n.mul(x,A),O=n.mul(B,A);if(_)return{x:n.ZERO,y:n.ZERO};if(!n.eql(O,n.ONE))throw new Error("invZ was invalid");return{x:L,y:U}}isTorsionFree(){let{isTorsionFree:d}=t;return i===jt?!0:d?d(I,this):q.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:d}=t;return i===jt?this:d?d(I,this):this.multiplyUnsafe(i)}isSmallOrder(){return i===jt?this.is0():this.clearCofactor().is0()}toBytes(d=!0){return pt(d,"isCompressed"),this.assertValidity(),l(I,this,d)}toHex(d=!0){return ye(this.toBytes(d))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let F=o.BITS,q=new ve(I,t.endo?Math.ceil(F/2):F);return F>=8&&I.BASE.precompute(8),Object.freeze(I.prototype),Object.freeze(I),I}function dc(e){return Uint8Array.of(e?2:3)}function lc(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function sh(e,t={}){let{Fn:r}=e,n=t.randomBytes===void 0?Ze:t.randomBytes,o=Object.assign(lc(e.Fp,r),{seed:Math.max(Wn(r.ORDER),16)});function s(m){try{let l=r.fromBytes(m);return r.isValidNot0(l)}catch{return!1}}function i(m,l){let{publicKey:w,publicKeyUncompressed:p}=o;try{let b=m.length;return l===!0&&b!==w||l===!1&&b!==p?!1:!!e.fromBytes(m)}catch{return!1}}function c(m){return m=m===void 0?n(o.seed):m,Jn(P(m,o.seed,"seed"),r.ORDER)}function f(m,l=!0){return e.BASE.multiply(r.fromBytes(m)).toBytes(l)}function a(m){let{secretKey:l,publicKey:w,publicKeyUncompressed:p}=o,b=r._lengths;if(!Gt(m))return;let S=P(m,void 0,"key").length,v=S===w||S===p,D=S===l||!!b?.includes(S);if(!(v&&D))return v}function u(m,l,w=!0){if(a(m)===!0)throw new Error("first arg must be private key");if(a(l)===!1)throw new Error("second arg must be public key");let p=r.fromBytes(m);return e.fromBytes(l).multiply(p).toBytes(w)}let h={isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:c},E=Nr(c,f);return Object.freeze(h),Object.freeze(o),Object.freeze({getPublicKey:f,getSharedSecret:u,keygen:E,Point:e,utils:h,lengths:o})}function pc(e,t,r={}){let n=t;vr(n),bt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes===void 0?Ze:r.randomBytes,s=r.hmac===void 0?(g,x)=>ac(n,g,x):r.hmac,{Fp:i,Fn:c}=e,{ORDER:f,BITS:a}=c,{keygen:u,getPublicKey:h,getSharedSecret:E,utils:m,lengths:l}=sh(e,r),w={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},p=f*uc+jt<i.ORDER;function b(g){let x=f>>jt;return g>x}function S(g,x){if(!c.isValidNot0(x))throw new Error(`invalid signature ${g}: out of range 1..Point.Fn.ORDER`);return x}function v(){if(p)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function D(g,x){Yo(x);let B=l.signature,_=x==="compact"?B:x==="recovered"?B+1:void 0;return P(g,_)}class T{r;s;recovery;constructor(x,B,_){if(this.r=S("r",x),this.s=S("s",B),_!=null){if(v(),![0,1,2,3].includes(_))throw new Error("invalid recovery id");this.recovery=_}Object.freeze(this)}static fromBytes(x,B=w.format){D(x,B);let _;if(B==="der"){let{r:k,s:M}=xt.toSig(P(x));return new T(k,M)}B==="recovered"&&(_=x[0],B="compact",x=x.subarray(1));let L=l.signature/2,U=x.subarray(0,L),O=x.subarray(L,L*2);return new T(c.fromBytes(U),c.fromBytes(O),_)}static fromHex(x,B){return this.fromBytes(xe(x),B)}assertRecovery(){let{recovery:x}=this;if(x==null)throw new Error("invalid recovery id: must be present");return x}addRecoveryBit(x){return new T(this.r,this.s,x)}recoverPublicKey(x){let{r:B,s:_}=this,L=this.assertRecovery(),U=L===2||L===3?B+f:B;if(!i.isValid(U))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let O=i.toBytes(U),k=e.fromBytes(W(dc((L&1)===0),O)),M=c.inv(U),K=C(P(x,void 0,"msgHash")),X=c.create(-K*M),J=c.create(_*M),Q=e.BASE.multiplyUnsafe(X).add(k.multiplyUnsafe(J));if(Q.is0())throw new Error("invalid recovery: point at infinify");return Q.assertValidity(),Q}hasHighS(){return b(this.s)}toBytes(x=w.format){if(Yo(x),x==="der")return xe(xt.hexFromSig(this));let{r:B,s:_}=this,L=c.toBytes(B),U=c.toBytes(_);return x==="recovered"?(v(),W(Uint8Array.of(this.assertRecovery()),L,U)):W(L,U)}toHex(x){return ye(this.toBytes(x))}}Object.freeze(T.prototype),Object.freeze(T);let R=r.bits2int===void 0?function(x){if(x.length>8192)throw new Error("input is too large");let B=Xt(x),_=x.length*8-a;return _>0?B>>BigInt(_):B}:r.bits2int,C=r.bits2int_modN===void 0?function(x){return c.create(R(x))}:r.bits2int_modN,I=Ge(a);function F(g){return ge("num < 2^"+a,g,vt,I),c.toBytes(g)}function q(g,x){return P(g,void 0,"message"),x?P(n(g),void 0,"prehashed message"):g}function N(g,x,B){let{lowS:_,prehash:L,extraEntropy:U}=$o(B,w);g=q(g,L);let O=C(g),k=c.fromBytes(x);if(!c.isValidNot0(k))throw new Error("invalid private key");let M=[F(k),F(O)];if(U!=null&&U!==!1){let Q=U===!0?o(l.secretKey):U;M.push(P(Q,void 0,"extraEntropy"))}let K=W(...M),X=O;function J(Q){let $=R(Q);if(!c.isValidNot0($))return;let ct=c.inv($),ne=e.BASE.multiply($).toAffine(),Ue=c.create(ne.x);if(Ue===vt)return;let mr=c.create(ct*c.create(X+Ue*k));if(mr===vt)return;let Qo=(ne.x===Ue?0:2)|Number(ne.y&jt),ts=mr;return _&&b(mr)&&(ts=c.neg(mr),Qo^=1),new T(Ue,ts,p?void 0:Qo)}return{seed:K,k2sig:J}}function d(g,x,B={}){let{seed:_,k2sig:L}=N(g,x,B);return Gs(n.outputLen,c.BYTES,s)(_,L).toBytes(B.format)}function y(g,x,B,_={}){let{lowS:L,prehash:U,format:O}=$o(_,w);if(B=P(B,void 0,"publicKey"),x=q(x,U),!Gt(g)){let k=g instanceof T?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+k)}D(g,O);try{let k=T.fromBytes(g,O),M=e.fromBytes(B);if(L&&k.hasHighS())return!1;let{r:K,s:X}=k,J=C(x),Q=c.inv(X),$=c.create(J*Q),ct=c.create(K*Q),ne=e.BASE.multiplyUnsafe($).add(M.multiplyUnsafe(ct));return ne.is0()?!1:c.create(ne.x)===K}catch{return!1}}function A(g,x,B={}){let{prehash:_}=$o(B,w);return x=q(x,_),T.fromBytes(g,"recovered").recoverPublicKey(x).toBytes()}return Object.freeze({keygen:u,getPublicKey:h,getSharedSecret:E,utils:m,lengths:l,Point:e,sign:d,verify:y,recoverPublicKey:A,Signature:T,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")},ih={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var mc=BigInt(2);function ch(e){let t=Wo.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),f=BigInt(88),a=e*e*e%t,u=a*a*e%t,h=H(u,r,t)*u%t,E=H(h,r,t)*u%t,m=H(E,mc,t)*a%t,l=H(m,o,t)*m%t,w=H(l,s,t)*l%t,p=H(w,c,t)*w%t,b=H(p,f,t)*p%t,S=H(b,c,t)*w%t,v=H(S,r,t)*u%t,D=H(v,i,t)*l%t,T=H(D,n,t)*a%t,R=H(T,mc,t);if(!Xo.eql(Xo.sqr(R),e))throw new Error("Cannot find square root");return R}var Xo=Ee(Wo.p,{sqrt:ch}),ah=hc(Wo,{Fp:Xo,endo:ih}),Ce=pc(ah,Zs);function bc(e,t,r,n){let o=Pe.digest(r instanceof Uint8Array?r:r.subarray());if(qr(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),Ce.verify(t,s,e,{prehash:!1,format:"der"}))).catch(s=>{throw s.name==="AbortError"?s:new Qe(String(s))});try{return n?.signal?.throwIfAborted(),Ce.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(s){throw new Qe(String(s))}}var en=class{type="secp256k1";raw;_key;constructor(t){this._key=xc(t),this.raw=yc(this._key)}toMultihash(){return dt.digest(me(this))}toCID(){return ot.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Bt(this.raw,t.raw)}verify(t,r,n){return bc(this._key,r,t,n)}};function gc(e){return new en(e)}function yc(e){return Ce.Point.fromBytes(e).toBytes()}function xc(e){try{return Ce.Point.fromBytes(e),e}catch(t){throw new br(String(t))}}function wc(e){let{Type:t,Data:r}=fr.decode(e.digest),n=r??new Uint8Array;switch(t){case it.Ed25519:return vi(n);case it.secp256k1:return gc(n);case it.ECDSA:return Ls(n);default:throw new oe}}function me(e){return fr.encode({Type:it[e.type],Data:e.raw})}var Ec=Symbol.for("nodejs.util.inspect.custom"),fh=114,ur=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[nn]=!0;toString(){return this.string==null&&(this.string=G.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ot.createV1(fh,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Bt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Bt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Ec](){return`PeerId(${this.toString()})`}},hr=class extends ur{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},dr=class extends ur{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},lr=class extends ur{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},uh=2336,pr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=dt.digest(le(this.url))}[Ec](){return`PeerId(${this.url})`}[nn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ot.createV1(uh,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=ft(t)),t.toString()===this.toString())}};var hh=114,Sc=2336;function dh(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=Ne(G.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return Ac(ot.parse(e));if(t==null)throw new gt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=Ne(t.decode(e))}return Jo(r)}function vc(e){if(e.type==="Ed25519")return new dr({multihash:e.toCID().multihash,publicKey:e});if(e.type==="secp256k1")return new lr({multihash:e.toCID().multihash,publicKey:e});if(e.type==="RSA")return new hr({multihash:e.toCID().multihash,publicKey:e});throw new oe}function lh(e){return vc(e.publicKey)}function Jo(e){if(mh(e))return new hr({multihash:e});if(ph(e))try{let t=wc(e);if(t.type==="Ed25519")return new dr({multihash:e,publicKey:t});if(t.type==="secp256k1")return new lr({multihash:e,publicKey:t})}catch{let r=ft(e.digest);return new pr(new URL(r))}throw new xr("Supplied PeerID Multihash is invalid")}function Ac(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==hh&&e.code!==Sc)throw new yr("Supplied PeerID CID is invalid");if(e.code===Sc){let t=ft(e.multihash.digest);return new pr(new URL(t))}return Jo(e.multihash)}function ph(e){return e.code===dt.code}function mh(e){return e.code===Pe.code}return Lc(bh);})();
3
3
  /*! Bundled license information:
4
4
 
5
5
  @noble/curves/utils.js: