@libp2p/bootstrap 11.0.34-afa5c9f59 → 11.0.35-772b4011e
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 +2 -15
- package/dist/index.min.js.map +7 -0
- package/package.json +6 -6
package/dist/index.min.js
CHANGED
|
@@ -1,32 +1,19 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PBootstrap = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PBootstrap=(()=>{var Rr=Object.defineProperty;var Di=Object.getOwnPropertyDescriptor;var _i=Object.getOwnPropertyNames;var Ni=Object.prototype.hasOwnProperty;var xt=(r,t)=>{for(var e in t)Rr(r,e,{get:t[e],enumerable:!0})},Ri=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _i(t))!Ni.call(r,o)&&o!==e&&Rr(r,o,{get:()=>t[o],enumerable:!(n=Di(t,o))||n.enumerable});return r};var Ki=r=>Ri(Rr({},"__esModule",{value:!0}),r);var nu={};xt(nu,{bootstrap:()=>ru});var Ao=Symbol.for("@libp2p/peer-discovery");var Kr=Symbol.for("@libp2p/peer-id");var Ct=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Ye=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Xe=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Qe=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Ue=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Je=class extends EventTarget{#t=new Map;constructor(){super()}listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e={}){return this.dispatchEvent(new CustomEvent(t,e))}};var Bo=Symbol.for("@libp2p/service-capabilities"),fu=Symbol.for("@libp2p/service-dependencies");var qr={};xt(qr,{base58btc:()=>$,base58flickr:()=>Vi});var Du=new Uint8Array(0);function Io(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Dt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function To(r){return new TextEncoder().encode(r)}function Lo(r){return new TextDecoder().decode(r)}function ki(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var c=r.length,a=r.charAt(0),u=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function l(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var g=0,h=0,y=0,B=E.length;y!==B&&E[y]===0;)y++,g++;for(var m=(B-y)*f+1>>>0,I=new Uint8Array(m);y!==B;){for(var N=E[y],D=0,L=m-1;(N!==0||D<h)&&L!==-1;L--,D++)N+=256*I[L]>>>0,I[L]=N%c>>>0,N=N/c>>>0;if(N!==0)throw new Error("Non-zero carry");h=D,y++}for(var C=m-h;C!==m&&I[C]===0;)C++;for(var P=a.repeat(g);C<m;++C)P+=r.charAt(I[C]);return P}function p(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var g=0;if(E[g]!==" "){for(var h=0,y=0;E[g]===a;)h++,g++;for(var B=(E.length-g)*u+1>>>0,m=new Uint8Array(B);E[g];){var I=e[E.charCodeAt(g)];if(I===255)return;for(var N=0,D=B-1;(I!==0||N<y)&&D!==-1;D--,N++)I+=c*m[D]>>>0,m[D]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");y=N,g++}if(E[g]!==" "){for(var L=B-y;L!==B&&m[L]===0;)L++;for(var C=new Uint8Array(h+(B-L)),P=h;L!==B;)C[P++]=m[L++];return C}}}function w(E){var g=p(E);if(g)return g;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:p,decode:w}}var Oi=ki,Mi=Oi,Po=Mi;var kr=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Or=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Uo(this,t)}},Mr=class{decoders;constructor(t){this.decoders=t}or(t){return Uo(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Uo(r,t){return new Mr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Hr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new kr(t,e,n),this.decoder=new Or(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function de({name:r,prefix:t,encode:e,decode:n}){return new Hr(r,t,e,n)}function Ht({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Po(e,r);return de({prefix:t,name:r,encode:n,decode:s=>Dt(o(s))})}function Hi(r,t,e,n){let o={};for(let f=0;f<t.length;++f)o[t[f]]=f;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),c=0,a=0,u=0;for(let f=0;f<s;++f){let l=o[r[f]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|l,c+=e,c>=8&&(c-=8,i[u++]=255&a>>c)}if(c>=e||(255&a<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return i}function qi(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],i+=8;i>e;)i-=e,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function J({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return de({prefix:t,name:r,encode(o){return qi(o,n,e)},decode(o){return Hi(o,n,e,r)}})}var $=Ht({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Vi=Ht({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Vr={};xt(Vr,{base32:()=>_t,base32hex:()=>Gi,base32hexpad:()=>Wi,base32hexpadupper:()=>$i,base32hexupper:()=>Zi,base32pad:()=>zi,base32padupper:()=>ji,base32upper:()=>Fi,base32z:()=>Yi});var _t=J({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Fi=J({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),zi=J({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ji=J({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Gi=J({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Zi=J({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Wi=J({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),$i=J({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Yi=J({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Fr={};xt(Fr,{base36:()=>De,base36upper:()=>Xi});var De=Ht({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Xi=Ht({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Qi=No,Do=128,Ji=127,tc=~Ji,ec=Math.pow(2,31);function No(r,t,e){t=t||[],e=e||0;for(var n=e;r>=ec;)t[e++]=r&255|Do,r/=128;for(;r&tc;)t[e++]=r&255|Do,r>>>=7;return t[e]=r|0,No.bytes=e-n+1,t}var rc=zr,nc=128,_o=127;function zr(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw zr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&_o)<<o:(i&_o)*Math.pow(2,o),o+=7}while(i>=nc);return zr.bytes=s-n,e}var oc=Math.pow(2,7),sc=Math.pow(2,14),ic=Math.pow(2,21),cc=Math.pow(2,28),ac=Math.pow(2,35),fc=Math.pow(2,42),uc=Math.pow(2,49),lc=Math.pow(2,56),hc=Math.pow(2,63),dc=function(r){return r<oc?1:r<sc?2:r<ic?3:r<cc?4:r<ac?5:r<fc?6:r<uc?7:r<lc?8:r<hc?9:10},pc={encode:Qi,decode:rc,encodingLength:dc},mc=pc,_e=mc;function Ne(r,t=0){return[_e.decode(r,t),_e.decode.bytes]}function pe(r,t,e=0){return _e.encode(r,t,e),t}function me(r){return _e.encodingLength(r)}function Xt(r,t){let e=t.byteLength,n=me(r),o=n+me(e),s=new Uint8Array(o+e);return pe(r,s,0),pe(e,s,n),s.set(t,o),new ge(r,e,t,s)}function Qt(r){let t=Dt(r),[e,n]=Ne(t),[o,s]=Ne(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ge(e,o,i,t)}function Ro(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Io(r.bytes,e.bytes)}}var ge=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Ko(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return xc(e,jr(r),t??$.encoder);default:return yc(e,jr(r),t??_t.encoder)}}var ko=new WeakMap;function jr(r){let t=ko.get(r);if(t==null){let e=new Map;return ko.set(r,e),e}return t}var ot=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,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:e}=this;if(t!==Re)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==bc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Xt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Ro(t.multihash,n.multihash)}toString(t){return Ko(this,t)}toJSON(){return{"/":Ko(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??Oo(n,o,s.bytes))}else if(e[wc]===!0){let{version:n,multihash:o,code:s}=e,i=Qt(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Re)throw new Error(`Version 0 CID must use dag-pb (code: ${Re}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Oo(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Re,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=Dt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new ge(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,p]=Ne(t.subarray(e));return e+=p,l},o=n(),s=Re;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,c=n(),a=n(),u=e+a,f=u-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:f,size:u}}static parse(t,e){let[n,o]=gc(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return jr(s).set(n,t),s}};function gc(r,t){switch(r[0]){case"Q":{let e=t??$;return[$.prefix,e.decode(`${$.prefix}${r}`)]}case $.prefix:{let e=t??$;return[$.prefix,e.decode(r)]}case _t.prefix:{let e=t??_t;return[_t.prefix,e.decode(r)]}case De.prefix:{let e=t??De;return[De.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function xc(r,t,e){let{prefix:n}=e;if(n!==$.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function yc(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var Re=112,bc=18;function Oo(r,t,e){let n=me(r),o=n+me(t),s=new Uint8Array(o+e.byteLength);return pe(r,s,0),pe(t,s,n),s.set(e,o),s}var wc=Symbol.for("@ipld/js-cid/CID");var Gr={};xt(Gr,{identity:()=>It});var Mo=0,Ec="identity",Ho=Dt;function Sc(r){return Xt(Mo,Ho(r))}var It={code:Mo,name:Ec,encode:Ho,digest:Sc};function yt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Nt(r=0){return new Uint8Array(r)}function pt(r=0){return new Uint8Array(r)}function bt(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=pt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var Vo=Symbol.for("@achingbrain/uint8arraylist");function qo(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function er(r){return!!r?.[Vo]}var wt=class r{bufs;length;[Vo]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(er(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(er(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=qo(this.bufs,t);return e.buf[e.index]}set(t,e){let n=qo(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(er(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return bt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:bt(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],c=o,a=c+i.byteLength;if(o=a,t>=a)continue;let u=t>=c&&t<a,f=e>c&&e<=a;if(u&&f){if(t===c&&e===a){n.push(i);break}let l=t-c;n.push(i.subarray(l,l+(e-t)));break}if(u){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(f){if(e===a){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!er(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let c=i,a=this.byteLength-n.byteLength,u=n.byteLength-1,f;for(let l=e;l<=a;l+=f){f=0;for(let p=u;p>=0;p--){let w=this.get(l+p);if(n[p]!==w){f=Math.max(1,p-c[w]);break}}if(f===0)return l}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=pt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=Nt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=Nt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=Nt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=pt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=Nt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=Nt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=Nt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=Nt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=Nt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!yt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var Zr={};xt(Zr,{base10:()=>vc});var vc=Ht({prefix:"9",name:"base10",alphabet:"0123456789"});var Wr={};xt(Wr,{base16:()=>Ac,base16upper:()=>Bc});var Ac=J({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Bc=J({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var $r={};xt($r,{base2:()=>Ic});var Ic=J({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Yr={};xt(Yr,{base256emoji:()=>Uc});var Fo=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}"),Tc=Fo.reduce((r,t,e)=>(r[e]=t,r),[]),Lc=Fo.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Cc(r){return r.reduce((t,e)=>(t+=Tc[e],t),"")}function Pc(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Lc[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Uc=de({prefix:"\u{1F680}",name:"base256emoji",encode:Cc,decode:Pc});var Xr={};xt(Xr,{base64:()=>Dc,base64pad:()=>_c,base64url:()=>Nc,base64urlpad:()=>Rc});var Dc=J({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),_c=J({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Nc=J({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Rc=J({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Qr={};xt(Qr,{base8:()=>Kc});var Kc=J({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Jr={};xt(Jr,{identity:()=>kc});var kc=de({prefix:"\0",name:"identity",encode:r=>Lo(r),decode:r=>To(r)});var ml=new TextEncoder,gl=new TextDecoder;var rn={};xt(rn,{sha256:()=>Ke,sha512:()=>Hc});function en({name:r,code:t,encode:e}){return new tn(r,t,e)}var tn=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Xt(this.code,e):e.then(n=>Xt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function jo(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Ke=en({name:"sha2-256",code:18,encode:jo("SHA-256")}),Hc=en({name:"sha2-512",code:19,encode:jo("SHA-512")});var ke={...Jr,...$r,...Qr,...Zr,...Wr,...Vr,...Fr,...qr,...Xr,...Yr},Ll={...rn,...Gr};function Zo(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Go=Zo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),nn=Zo("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=pt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),qc={utf8:Go,"utf-8":Go,hex:ke.base16,latin1:nn,ascii:nn,binary:nn,...ke},rr=qc;function At(r,t="utf8"){let e=rr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function G(r,t="utf8"){let e=rr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Vc=parseInt("11111",2),on=parseInt("10000000",2),Fc=parseInt("01111111",2),Wo={0:Oe,1:Oe,2:zc,3:Zc,4:Wc,5:Gc,6:jc,16:Oe,22:Oe,48:Oe};function sn(r,t={offset:0}){let e=r[t.offset]&Vc;if(t.offset++,Wo[e]!=null)return Wo[e](r,t);throw new Error("No decoder for tag "+e)}function Me(r,t){let e=0;if((r[t.offset]&on)===on){let n=r[t.offset]&Fc,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function Oe(r,t){Me(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=sn(r,t);if(n===null)break;e.push(n)}return e}function zc(r,t){let e=Me(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function jc(r,t){let e=Me(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let c=`${s}.${i}`,a=[];for(;t.offset<n;){let u=r[t.offset];if(t.offset++,a.push(u&127),u<128){a.reverse();let f=0;for(let l=0;l<a.length;l++)f+=a[l]<<l*7;c+=`.${f}`,a=[]}}return c}function Gc(r,t){return t.offset++,null}function Zc(r,t){let e=Me(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Wc(r,t){let e=Me(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function $c(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new wt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function cn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=$c(r.byteLength);return new wt(Uint8Array.from([t.byteLength|on]),t)}function $o(r){let t=new wt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new wt(Uint8Array.from([2]),cn(t),t)}function Yo(r){let t=Uint8Array.from([0]),e=new wt(t,r);return new wt(Uint8Array.from([3]),cn(e),e)}function nr(r,t=48){let e=new wt;for(let n of r)e.append(n);return new wt(Uint8Array.from([t]),cn(e),e)}async function Xo(r,t,e){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,e.subarray())}var Yc=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Xc=Uint8Array.from([6,5,43,129,4,0,34]),Qc=Uint8Array.from([6,5,43,129,4,0,35]),Jc={ext:!0,kty:"EC",crv:"P-256"},ta={ext:!0,kty:"EC",crv:"P-384"},ea={ext:!0,kty:"EC",crv:"P-521"},an=32,fn=48,un=66;function Qo(r){let t=sn(r);return Jo(t)}function Jo(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===an*2+1)return n=G(t.subarray(e,e+an),"base64url"),o=G(t.subarray(e+an),"base64url"),new xe({...Jc,key_ops:["verify"],x:n,y:o});if(t.byteLength===fn*2+1)return n=G(t.subarray(e,e+fn),"base64url"),o=G(t.subarray(e+fn),"base64url"),new xe({...ta,key_ops:["verify"],x:n,y:o});if(t.byteLength===un*2+1)return n=G(t.subarray(e,e+un),"base64url"),o=G(t.subarray(e+un),"base64url"),new xe({...ea,key_ops:["verify"],x:n,y:o});throw new Ct(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function ts(r){return nr([$o(Uint8Array.from([1])),nr([ra(r.crv)],160),nr([Yo(new wt(Uint8Array.from([4]),At(r.x??"","base64url"),At(r.y??"","base64url")))],161)]).subarray()}function ra(r){if(r==="P-256")return Yc;if(r==="P-384")return Xc;if(r==="P-521")return Qc;throw new Ct(`Invalid curve ${r}`)}var xe=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=ts(this.jwk)),this._raw}toMultihash(){return It.digest(ye(this))}toCID(){return ot.createV1(114,this.toMultihash())}toString(){return $.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}async verify(t,e){return Xo(this.jwk,e,t)}};function es(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function na(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function be(r,...t){if(!na(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function rs(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");es(r.outputLen),es(r.blockLen)}function we(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function ns(r,t){be(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var te=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function or(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Tt(r,t){return r<<32-t|r>>>t}var fh=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function";function os(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function He(r){return typeof r=="string"&&(r=os(r)),be(r),r}function ln(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];be(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var Ee=class{clone(){return this._cloneInto()}};function sr(r){let t=n=>r().update(He(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function ir(r=32){if(te&&typeof te.getRandomValues=="function")return te.getRandomValues(new Uint8Array(r));if(te&&typeof te.randomBytes=="function")return Uint8Array.from(te.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function oa(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),c=Number(e&s),a=n?4:0,u=n?0:4;r.setUint32(t+a,i,n),r.setUint32(t+u,c,n)}function ss(r,t,e){return r&t^~r&e}function is(r,t,e){return r&t^r&e^t&e}var Se=class extends Ee{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=or(this.buffer)}update(t){we(this);let{view:e,buffer:n,blockLen:o}=this;t=He(t);let s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=or(t);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){we(this),ns(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)e[l]=0;oa(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=or(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=a/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)c.setUint32(4*l,f[l],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=i,o%e&&t.buffer.set(n),t}};var sa=new Uint32Array([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]),qt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Vt=new Uint32Array(64),hn=class extends Se{constructor(t=32){super(64,t,8,!1),this.A=qt[0]|0,this.B=qt[1]|0,this.C=qt[2]|0,this.D=qt[3]|0,this.E=qt[4]|0,this.F=qt[5]|0,this.G=qt[6]|0,this.H=qt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[t,e,n,o,s,i,c,a]}set(t,e,n,o,s,i,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,e){for(let l=0;l<16;l++,e+=4)Vt[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let p=Vt[l-15],w=Vt[l-2],E=Tt(p,7)^Tt(p,18)^p>>>3,g=Tt(w,17)^Tt(w,19)^w>>>10;Vt[l]=g+Vt[l-7]+E+Vt[l-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:u,H:f}=this;for(let l=0;l<64;l++){let p=Tt(c,6)^Tt(c,11)^Tt(c,25),w=f+p+ss(c,a,u)+sa[l]+Vt[l]|0,g=(Tt(n,2)^Tt(n,13)^Tt(n,22))+is(n,o,s)|0;f=u,u=a,a=c,c=i+w|0,i=s,s=o,o=n,n=w+g|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(n,o,s,i,c,a,u,f)}roundClean(){Vt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var dn=sr(()=>new hn);var cr=BigInt(4294967295),pn=BigInt(32);function cs(r,t=!1){return t?{h:Number(r&cr),l:Number(r>>pn&cr)}:{h:Number(r>>pn&cr)|0,l:Number(r&cr)|0}}function ia(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:i}=cs(r[o],t);[e[o],n[o]]=[s,i]}return[e,n]}var ca=(r,t)=>BigInt(r>>>0)<<pn|BigInt(t>>>0),aa=(r,t,e)=>r>>>e,fa=(r,t,e)=>r<<32-e|t>>>e,ua=(r,t,e)=>r>>>e|t<<32-e,la=(r,t,e)=>r<<32-e|t>>>e,ha=(r,t,e)=>r<<64-e|t>>>e-32,da=(r,t,e)=>r>>>e-32|t<<64-e,pa=(r,t)=>t,ma=(r,t)=>r,ga=(r,t,e)=>r<<e|t>>>32-e,xa=(r,t,e)=>t<<e|r>>>32-e,ya=(r,t,e)=>t<<e-32|r>>>64-e,ba=(r,t,e)=>r<<e-32|t>>>64-e;function wa(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var Ea=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Sa=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,va=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Aa=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Ba=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Ia=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Ta={fromBig:cs,split:ia,toBig:ca,shrSH:aa,shrSL:fa,rotrSH:ua,rotrSL:la,rotrBH:ha,rotrBL:da,rotr32H:pa,rotr32L:ma,rotlSH:ga,rotlSL:xa,rotlBH:ya,rotlBL:ba,add:wa,add3L:Ea,add3H:Sa,add4L:va,add4H:Aa,add5H:Ia,add5L:Ba},K=Ta;var[La,Ca]=K.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Ft=new Uint32Array(80),zt=new Uint32Array(80),mn=class extends Se{constructor(t=64){super(128,t,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:u,El:f,Fh:l,Fl:p,Gh:w,Gl:E,Hh:g,Hl:h}=this;return[t,e,n,o,s,i,c,a,u,f,l,p,w,E,g,h]}set(t,e,n,o,s,i,c,a,u,f,l,p,w,E,g,h){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=u|0,this.El=f|0,this.Fh=l|0,this.Fl=p|0,this.Gh=w|0,this.Gl=E|0,this.Hh=g|0,this.Hl=h|0}process(t,e){for(let m=0;m<16;m++,e+=4)Ft[m]=t.getUint32(e),zt[m]=t.getUint32(e+=4);for(let m=16;m<80;m++){let I=Ft[m-15]|0,N=zt[m-15]|0,D=K.rotrSH(I,N,1)^K.rotrSH(I,N,8)^K.shrSH(I,N,7),L=K.rotrSL(I,N,1)^K.rotrSL(I,N,8)^K.shrSL(I,N,7),C=Ft[m-2]|0,P=zt[m-2]|0,W=K.rotrSH(C,P,19)^K.rotrBH(C,P,61)^K.shrSH(C,P,6),V=K.rotrSL(C,P,19)^K.rotrBL(C,P,61)^K.shrSL(C,P,6),O=K.add4L(L,V,zt[m-7],zt[m-16]),nt=K.add4H(O,D,W,Ft[m-7],Ft[m-16]);Ft[m]=nt|0,zt[m]=O|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:u,Dl:f,Eh:l,El:p,Fh:w,Fl:E,Gh:g,Gl:h,Hh:y,Hl:B}=this;for(let m=0;m<80;m++){let I=K.rotrSH(l,p,14)^K.rotrSH(l,p,18)^K.rotrBH(l,p,41),N=K.rotrSL(l,p,14)^K.rotrSL(l,p,18)^K.rotrBL(l,p,41),D=l&w^~l&g,L=p&E^~p&h,C=K.add5L(B,N,L,Ca[m],zt[m]),P=K.add5H(C,y,I,D,La[m],Ft[m]),W=C|0,V=K.rotrSH(n,o,28)^K.rotrBH(n,o,34)^K.rotrBH(n,o,39),O=K.rotrSL(n,o,28)^K.rotrBL(n,o,34)^K.rotrBL(n,o,39),nt=n&s^n&c^s&c,v=o&i^o&a^i&a;y=g|0,B=h|0,g=w|0,h=E|0,w=l|0,E=p|0,{h:l,l:p}=K.add(u|0,f|0,P|0,W|0),u=c|0,f=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let T=K.add3L(W,O,v);n=K.add3H(T,P,V,nt),o=T|0}({h:n,l:o}=K.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=K.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=K.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:u,l:f}=K.add(this.Dh|0,this.Dl|0,u|0,f|0),{h:l,l:p}=K.add(this.Eh|0,this.El|0,l|0,p|0),{h:w,l:E}=K.add(this.Fh|0,this.Fl|0,w|0,E|0),{h:g,l:h}=K.add(this.Gh|0,this.Gl|0,g|0,h|0),{h:y,l:B}=K.add(this.Hh|0,this.Hl|0,y|0,B|0),this.set(n,o,s,i,c,a,u,f,l,p,w,E,g,h,y,B)}roundClean(){Ft.fill(0),zt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var gn=sr(()=>new mn);var wn=BigInt(0),bn=BigInt(1);function ee(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function En(r){if(!ee(r))throw new Error("Uint8Array expected")}function Pt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function qe(r){let t=r.toString(16);return t.length&1?"0"+t:t}function us(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?wn:BigInt("0x"+r)}var ls=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Pa=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function jt(r){if(En(r),ls)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=Pa[r[e]];return t}var Rt={_0:48,_9:57,A:65,F:70,a:97,f:102};function as(r){if(r>=Rt._0&&r<=Rt._9)return r-Rt._0;if(r>=Rt.A&&r<=Rt.F)return r-(Rt.A-10);if(r>=Rt.a&&r<=Rt.f)return r-(Rt.a-10)}function Ve(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(ls)return Uint8Array.fromHex(r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=as(r.charCodeAt(s)),c=as(r.charCodeAt(s+1));if(i===void 0||c===void 0){let a=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function Kt(r){return us(jt(r))}function re(r){return En(r),us(jt(Uint8Array.from(r).reverse()))}function ne(r,t){return Ve(r.toString(16).padStart(t*2,"0"))}function ve(r,t){return ne(r,t).reverse()}function Q(r,t,e){let n;if(typeof t=="string")try{n=Ve(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(ee(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function Gt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];En(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var xn=r=>typeof r=="bigint"&&wn<=r;function ar(r,t,e){return xn(r)&&xn(t)&&xn(e)&&t<=r&&r<e}function Et(r,t,e,n){if(!ar(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function hs(r){let t;for(t=0;r>wn;r>>=bn,t+=1);return t}var oe=r=>(bn<<BigInt(r))-bn,yn=r=>new Uint8Array(r),fs=r=>Uint8Array.from(r);function ds(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=yn(r),o=yn(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...l)=>e(o,n,...l),a=(l=yn(0))=>{o=c(fs([0]),l),n=c(),l.length!==0&&(o=c(fs([1]),l),n=c())},u=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l<t;){n=c();let w=n.slice();p.push(w),l+=n.length}return Gt(...p)};return(l,p)=>{i(),a(l);let w;for(;!(w=p(u()));)a();return i(),w}}var Ua={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||ee(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function kt(r,t,e={}){let n=(o,s,i)=>{let c=Ua[s];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(i&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+a)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}function Ae(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var st=BigInt(0),Y=BigInt(1),se=BigInt(2),Da=BigInt(3),Sn=BigInt(4),ps=BigInt(5),ms=BigInt(8),_a=BigInt(9),Na=BigInt(16);function j(r,t){let e=r%t;return e>=st?e:t+e}function Ra(r,t,e){if(t<st)throw new Error("invalid exponent, negatives unsupported");if(e<=st)throw new Error("invalid modulus");if(e===Y)return st;let n=Y;for(;t>st;)t&Y&&(n=n*r%e),r=r*r%e,t>>=Y;return n}function X(r,t,e){let n=r;for(;t-- >st;)n*=n,n%=e;return n}function fr(r,t){if(r===st)throw new Error("invert: expected non-zero number");if(t<=st)throw new Error("invert: expected positive modulus, got "+t);let e=j(r,t),n=t,o=st,s=Y,i=Y,c=st;for(;e!==st;){let u=n/e,f=n%e,l=o-i*u,p=s-c*u;n=e,e=f,o=i,s=c,i=l,c=p}if(n!==Y)throw new Error("invert: does not exist");return j(o,t)}function Ka(r){let t=(r-Y)/se,e,n,o;for(e=r-Y,n=0;e%se===st;e/=se,n++);for(o=se;o<r&&Ra(o,t,r)!==r-Y;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let i=(r+Y)/Sn;return function(a,u){let f=a.pow(u,i);if(!a.eql(a.sqr(f),u))throw new Error("Cannot find square root");return f}}let s=(e+Y)/se;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let u=n,f=c.pow(c.mul(c.ONE,o),e),l=c.pow(a,s),p=c.pow(a,e);for(;!c.eql(p,c.ONE);){if(c.eql(p,c.ZERO))return c.ZERO;let w=1;for(let g=c.sqr(p);w<u&&!c.eql(g,c.ONE);w++)g=c.sqr(g);let E=c.pow(f,Y<<BigInt(u-w-1));f=c.sqr(E),l=c.mul(l,E),p=c.mul(p,f),u=w}return l}}function ka(r){if(r%Sn===Da){let t=(r+Y)/Sn;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%ms===ps){let t=(r-ps)/ms;return function(n,o){let s=n.mul(o,se),i=n.pow(s,t),c=n.mul(o,i),a=n.mul(n.mul(c,se),i),u=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(u),o))throw new Error("Cannot find square root");return u}}return r%Na,Ka(r)}var gs=(r,t)=>(j(r,t)&Y)===Y,Oa=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function vn(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Oa.reduce((n,o)=>(n[o]="function",n),t);return kt(r,e)}function Ma(r,t,e){if(e<st)throw new Error("invalid exponent, negatives unsupported");if(e===st)return r.ONE;if(e===Y)return t;let n=r.ONE,o=t;for(;e>st;)e&Y&&(n=r.mul(n,o)),o=r.sqr(o),e>>=Y;return n}function Ha(r,t){let e=new Array(t.length),n=t.reduce((s,i,c)=>r.is0(i)?s:(e[c]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return t.reduceRight((s,i,c)=>r.is0(i)?s:(e[c]=r.mul(s,e[c]),r.mul(s,i)),o),e}function An(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Zt(r,t,e=!1,n={}){if(r<=st)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=An(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,c=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:oe(o),ZERO:st,ONE:Y,create:a=>j(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return st<=a&&a<r},is0:a=>a===st,isOdd:a=>(a&Y)===Y,neg:a=>j(-a,r),eql:(a,u)=>a===u,sqr:a=>j(a*a,r),add:(a,u)=>j(a+u,r),sub:(a,u)=>j(a-u,r),mul:(a,u)=>j(a*u,r),pow:(a,u)=>Ma(c,a,u),div:(a,u)=>j(a*fr(u,r),r),sqrN:a=>a*a,addN:(a,u)=>a+u,subN:(a,u)=>a-u,mulN:(a,u)=>a*u,inv:a=>fr(a,r),sqrt:n.sqrt||(a=>(i||(i=ka(r)),i(c,a))),invertBatch:a=>Ha(c,a),cmov:(a,u,f)=>f?u:a,toBytes:a=>e?ve(a,s):ne(a,s),fromBytes:a=>{if(a.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+a.length);return e?re(a):Kt(a)}});return Object.freeze(c)}function xs(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Bn(r){let t=xs(r);return t+Math.ceil(t/2)}function ys(r,t,e=!1){let n=r.length,o=xs(t),s=Bn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?re(r):Kt(r),c=j(i,t-Y)+Y;return e?ve(c,o):ne(c,o)}var bs=BigInt(0),Pn=BigInt(1);function In(r,t){let e=t.negate();return r?e:t}function Es(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Tn(r,t){Es(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=oe(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function ws(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,c=Number(r&o),a=r>>i;c>n&&(c-=s,a+=Pn);let u=t*n,f=u+Math.abs(c)-1,l=c===0,p=c<0,w=t%2!==0;return{nextN:a,offset:f,isZero:l,isNeg:p,isNegF:w,offsetF:u}}function qa(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function Va(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var Ln=new WeakMap,Ss=new WeakMap;function Cn(r){return Ss.get(r)||1}function ur(r,t){return{constTimeNegate:In,hasPrecomputes(e){return Cn(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>bs;)n&Pn&&(o=o.add(s)),s=s.double(),n>>=Pn;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=Tn(n,t),i=[],c=e,a=c;for(let u=0;u<o;u++){a=c,i.push(a);for(let f=1;f<s;f++)a=a.add(c),i.push(a);c=a.double()}return i},wNAF(e,n,o){let s=r.ZERO,i=r.BASE,c=Tn(e,t);for(let a=0;a<c.windows;a++){let{nextN:u,offset:f,isZero:l,isNeg:p,isNegF:w,offsetF:E}=ws(o,a,c);o=u,l?i=i.add(In(w,n[E])):s=s.add(In(p,n[f]))}return{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=Tn(e,t);for(let c=0;c<i.windows&&o!==bs;c++){let{nextN:a,offset:u,isZero:f,isNeg:l}=ws(o,c,i);if(o=a,!f){let p=n[u];s=s.add(l?p.negate():p)}}return s},getPrecomputes(e,n,o){let s=Ln.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&Ln.set(n,o(s))),s},wNAFCached(e,n,o){let s=Cn(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=Cn(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){Es(n,t),Ss.set(e,n),Ln.delete(e)}}}function lr(r,t,e,n){if(qa(e,r),Va(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,s=hs(BigInt(e.length)),i=s>12?s-3:s>4?s-2:s?2:1,c=oe(i),a=new Array(Number(c)+1).fill(o),u=Math.floor((t.BITS-1)/i)*i,f=o;for(let l=u;l>=0;l-=i){a.fill(o);for(let w=0;w<n.length;w++){let E=n[w],g=Number(E>>BigInt(l)&c);a[g]=a[g].add(e[w])}let p=o;for(let w=a.length-1,E=o;w>0;w--)E=E.add(a[w]),p=p.add(E);if(f=f.add(p),l!==0)for(let w=0;w<i;w++)f=f.double()}return f}function Fe(r){return vn(r.Fp),kt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...An(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Ut=BigInt(0),ht=BigInt(1),vs=BigInt(2),Fa=BigInt(8),za={zip215:!0};function ja(r){let t=Fe(r);return kt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function As(r){let t=ja(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:c,h:a}=t,u=vs<<BigInt(c*8)-ht,f=e.create,l=Zt(t.n,t.nBitLength),p=t.uvRatio||((x,d)=>{try{return{isValid:!0,value:e.sqrt(x*e.inv(d))}}catch{return{isValid:!1,value:Ut}}}),w=t.adjustScalarBytes||(x=>x),E=t.domain||((x,d,b)=>{if(Pt("phflag",b),d.length||b)throw new Error("Contexts/pre-hash are not supported");return x});function g(x,d,b=!1){let A=b?ht:Ut;Et("coordinate "+x,d,A,u)}function h(x){if(!(x instanceof m))throw new Error("ExtendedPoint expected")}let y=Ae((x,d)=>{let{ex:b,ey:A,ez:R}=x,k=x.is0();d==null&&(d=k?Fa:e.inv(R));let M=f(b*d),H=f(A*d),q=f(R*d);if(k)return{x:Ut,y:ht};if(q!==ht)throw new Error("invZ was invalid");return{x:M,y:H}}),B=Ae(x=>{let{a:d,d:b}=t;if(x.is0())throw new Error("bad point: ZERO");let{ex:A,ey:R,ez:k,et:M}=x,H=f(A*A),q=f(R*R),z=f(k*k),rt=f(z*z),tt=f(H*d),at=f(z*f(tt+q)),dt=f(rt+f(b*f(H*q)));if(at!==dt)throw new Error("bad point: equation left != right (1)");let it=f(A*R),ft=f(k*M);if(it!==ft)throw new Error("bad point: equation left != right (2)");return!0});class m{constructor(d,b,A,R){g("x",d),g("y",b),g("z",A,!0),g("t",R),this.ex=d,this.ey=b,this.ez=A,this.et=R,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(d){if(d instanceof m)throw new Error("extended point not allowed");let{x:b,y:A}=d||{};return g("x",b),g("y",A),new m(b,A,ht,f(b*A))}static normalizeZ(d){let b=e.invertBatch(d.map(A=>A.ez));return d.map((A,R)=>A.toAffine(b[R])).map(m.fromAffine)}static msm(d,b){return lr(m,l,d,b)}_setWindowSize(d){D.setWindowSize(this,d)}assertValidity(){B(this)}equals(d){h(d);let{ex:b,ey:A,ez:R}=this,{ex:k,ey:M,ez:H}=d,q=f(b*H),z=f(k*R),rt=f(A*H),tt=f(M*R);return q===z&&rt===tt}is0(){return this.equals(m.ZERO)}negate(){return new m(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:d}=t,{ex:b,ey:A,ez:R}=this,k=f(b*b),M=f(A*A),H=f(vs*f(R*R)),q=f(d*k),z=b+A,rt=f(f(z*z)-k-M),tt=q+M,at=tt-H,dt=q-M,it=f(rt*at),ft=f(tt*dt),gt=f(rt*dt),Bt=f(at*tt);return new m(it,ft,Bt,gt)}add(d){h(d);let{a:b,d:A}=t,{ex:R,ey:k,ez:M,et:H}=this,{ex:q,ey:z,ez:rt,et:tt}=d,at=f(R*q),dt=f(k*z),it=f(H*A*tt),ft=f(M*rt),gt=f((R+k)*(q+z)-at-dt),Bt=ft-it,Pe=ft+it,vo=f(dt-b*at),Li=f(gt*Bt),Ci=f(Pe*vo),Pi=f(gt*vo),Ui=f(Bt*Pe);return new m(Li,Ci,Ui,Pi)}subtract(d){return this.add(d.negate())}wNAF(d){return D.wNAFCached(this,d,m.normalizeZ)}multiply(d){let b=d;Et("scalar",b,ht,n);let{p:A,f:R}=this.wNAF(b);return m.normalizeZ([A,R])[0]}multiplyUnsafe(d,b=m.ZERO){let A=d;return Et("scalar",A,Ut,n),A===Ut?N:this.is0()||A===ht?this:D.wNAFCachedUnsafe(this,A,m.normalizeZ,b)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return D.unsafeLadder(this,n).is0()}toAffine(d){return y(this,d)}clearCofactor(){let{h:d}=t;return d===ht?this:this.multiplyUnsafe(d)}static fromHex(d,b=!1){let{d:A,a:R}=t,k=e.BYTES;d=Q("pointHex",d,k),Pt("zip215",b);let M=d.slice(),H=d[k-1];M[k-1]=H&-129;let q=re(M),z=b?u:e.ORDER;Et("pointHex.y",q,Ut,z);let rt=f(q*q),tt=f(rt-ht),at=f(A*rt-R),{isValid:dt,value:it}=p(tt,at);if(!dt)throw new Error("Point.fromHex: invalid y coordinate");let ft=(it&ht)===ht,gt=(H&128)!==0;if(!b&&it===Ut&>)throw new Error("Point.fromHex: x=0 and x_0=1");return gt!==ft&&(it=f(-it)),m.fromAffine({x:it,y:q})}static fromPrivateKey(d){let{scalar:b}=P(d);return I.multiply(b)}toRawBytes(){let{x:d,y:b}=this.toAffine(),A=ve(b,e.BYTES);return A[A.length-1]|=d&ht?128:0,A}toHex(){return jt(this.toRawBytes())}}m.BASE=new m(t.Gx,t.Gy,ht,f(t.Gx*t.Gy)),m.ZERO=new m(Ut,ht,ht,Ut);let{BASE:I,ZERO:N}=m,D=ur(m,c*8);function L(x){return j(x,n)}function C(x){return L(re(x))}function P(x){let d=e.BYTES;x=Q("private key",x,d);let b=Q("hashed private key",s(x),2*d),A=w(b.slice(0,d)),R=b.slice(d,2*d),k=C(A);return{head:A,prefix:R,scalar:k}}function W(x){let{head:d,prefix:b,scalar:A}=P(x),R=I.multiply(A),k=R.toRawBytes();return{head:d,prefix:b,scalar:A,point:R,pointBytes:k}}function V(x){return W(x).pointBytes}function O(x=new Uint8Array,...d){let b=Gt(...d);return C(s(E(b,Q("context",x),!!o)))}function nt(x,d,b={}){x=Q("message",x),o&&(x=o(x));let{prefix:A,scalar:R,pointBytes:k}=W(d),M=O(b.context,A,x),H=I.multiply(M).toRawBytes(),q=O(b.context,H,k,x),z=L(M+q*R);Et("signature.s",z,Ut,n);let rt=Gt(H,ve(z,e.BYTES));return Q("result",rt,e.BYTES*2)}let v=za;function T(x,d,b,A=v){let{context:R,zip215:k}=A,M=e.BYTES;x=Q("signature",x,2*M),d=Q("message",d),b=Q("publicKey",b,M),k!==void 0&&Pt("zip215",k),o&&(d=o(d));let H=re(x.slice(M,2*M)),q,z,rt;try{q=m.fromHex(b,k),z=m.fromHex(x.slice(0,M),k),rt=I.multiplyUnsafe(H)}catch{return!1}if(!k&&q.isSmallOrder())return!1;let tt=O(R,z.toRawBytes(),q.toRawBytes(),d);return z.add(q.multiplyUnsafe(tt)).subtract(rt).clearCofactor().equals(m.ZERO)}return I._setWindowSize(8),{CURVE:t,getPublicKey:V,sign:nt,verify:T,ExtendedPoint:m,utils:{getExtendedPublicKey:W,randomPrivateKey:()=>i(e.BYTES),precompute(x=8,d=m.BASE){return d._setWindowSize(x),d.multiply(BigInt(3)),d}}}}var Un=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Bs=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),zh=BigInt(0),Ga=BigInt(1),Is=BigInt(2),jh=BigInt(3),Za=BigInt(5),Wa=BigInt(8);function $a(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=Un,c=r*r%s*r%s,a=X(c,Is,s)*c%s,u=X(a,Ga,s)*r%s,f=X(u,Za,s)*u%s,l=X(f,t,s)*f%s,p=X(l,e,s)*l%s,w=X(p,n,s)*p%s,E=X(w,o,s)*w%s,g=X(E,o,s)*w%s,h=X(g,t,s)*f%s;return{pow_p_5_8:X(h,Is,s)*r%s,b2:c}}function Ya(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Xa(r,t){let e=Un,n=j(t*t*t,e),o=j(n*n*t,e),s=$a(r*o).pow_p_5_8,i=j(r*n*s,e),c=j(t*i*i,e),a=i,u=j(i*Bs,e),f=c===r,l=c===j(-r,e),p=c===j(-r*Bs,e);return f&&(i=a),(l||p)&&(i=u),gs(i,e)&&(i=j(-i,e)),{isValid:f||l,value:i}}var Ts=Zt(Un,void 0,!0),Qa={a:Ts.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ts,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Wa,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:gn,randomBytes:ir,adjustScalarBytes:Ya,uvRatio:Xa},Ls=As(Qa);var hr=32;function Cs(r,t,e){return Ls.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var dr=class{type="Ed25519";raw;constructor(t){this.raw=Dn(t,hr)}toMultihash(){return It.digest(ye(this))}toCID(){return ot.createV1(114,this.toMultihash())}toString(){return $.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}verify(t,e){return Cs(this.raw,e,t)}};function Us(r){return r=Dn(r,hr),new dr(r)}function Dn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new Ct(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var tf=Math.pow(2,7),ef=Math.pow(2,14),rf=Math.pow(2,21),_n=Math.pow(2,28),Nn=Math.pow(2,35),Rn=Math.pow(2,42),Kn=Math.pow(2,49),F=128,ut=127;function mt(r){if(r<tf)return 1;if(r<ef)return 2;if(r<rf)return 3;if(r<_n)return 4;if(r<Nn)return 5;if(r<Rn)return 6;if(r<Kn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function kn(r,t,e=0){switch(mt(r)){case 8:t[e++]=r&255|F,r/=128;case 7:t[e++]=r&255|F,r/=128;case 6:t[e++]=r&255|F,r/=128;case 5:t[e++]=r&255|F,r/=128;case 4:t[e++]=r&255|F,r>>>=7;case 3:t[e++]=r&255|F,r>>>=7;case 2:t[e++]=r&255|F,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function nf(r,t,e=0){switch(mt(r)){case 8:t.set(e++,r&255|F),r/=128;case 7:t.set(e++,r&255|F),r/=128;case 6:t.set(e++,r&255|F),r/=128;case 5:t.set(e++,r&255|F),r/=128;case 4:t.set(e++,r&255|F),r>>>=7;case 3:t.set(e++,r&255|F),r>>>=7;case 2:t.set(e++,r&255|F),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function On(r,t){let e=r[t],n=0;if(n+=e&ut,e<F||(e=r[t+1],n+=(e&ut)<<7,e<F)||(e=r[t+2],n+=(e&ut)<<14,e<F)||(e=r[t+3],n+=(e&ut)<<21,e<F)||(e=r[t+4],n+=(e&ut)*_n,e<F)||(e=r[t+5],n+=(e&ut)*Nn,e<F)||(e=r[t+6],n+=(e&ut)*Rn,e<F)||(e=r[t+7],n+=(e&ut)*Kn,e<F))return n;throw new RangeError("Could not decode varint")}function of(r,t){let e=r.get(t),n=0;if(n+=e&ut,e<F||(e=r.get(t+1),n+=(e&ut)<<7,e<F)||(e=r.get(t+2),n+=(e&ut)<<14,e<F)||(e=r.get(t+3),n+=(e&ut)<<21,e<F)||(e=r.get(t+4),n+=(e&ut)*_n,e<F)||(e=r.get(t+5),n+=(e&ut)*Nn,e<F)||(e=r.get(t+6),n+=(e&ut)*Rn,e<F)||(e=r.get(t+7),n+=(e&ut)*Kn,e<F))return n;throw new RangeError("Could not decode varint")}function Be(r,t,e=0){return t==null&&(t=pt(mt(r))),t instanceof Uint8Array?kn(r,t,e):nf(r,t,e)}function ie(r,t=0){return r instanceof Uint8Array?On(r,t):of(r,t)}var Mn=new Float32Array([-0]),Wt=new Uint8Array(Mn.buffer);function _s(r,t,e){Mn[0]=r,t[e]=Wt[0],t[e+1]=Wt[1],t[e+2]=Wt[2],t[e+3]=Wt[3]}function Ns(r,t){return Wt[0]=r[t],Wt[1]=r[t+1],Wt[2]=r[t+2],Wt[3]=r[t+3],Mn[0]}var Hn=new Float64Array([-0]),lt=new Uint8Array(Hn.buffer);function Rs(r,t,e){Hn[0]=r,t[e]=lt[0],t[e+1]=lt[1],t[e+2]=lt[2],t[e+3]=lt[3],t[e+4]=lt[4],t[e+5]=lt[5],t[e+6]=lt[6],t[e+7]=lt[7]}function Ks(r,t){return lt[0]=r[t],lt[1]=r[t+1],lt[2]=r[t+2],lt[3]=r[t+3],lt[4]=r[t+4],lt[5]=r[t+5],lt[6]=r[t+6],lt[7]=r[t+7],Hn[0]}var sf=BigInt(Number.MAX_SAFE_INTEGER),cf=BigInt(Number.MIN_SAFE_INTEGER),St=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return ce;if(t<sf&&t>cf)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>ks&&(o=0n,++n>ks&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ce;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):ce}},ce=new St(0,0);ce.toBigInt=function(){return 0n};ce.zzEncode=ce.zzDecode=function(){return this};ce.length=function(){return 1};var ks=4294967296n;function Os(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Ms(r,t,e){if(e-t<1)return"";let o,s=[],i=0,c;for(;t<e;)c=r[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function qn(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function Lt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function pr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Vn=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,Lt(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 Lt(this,4);return pr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Lt(this,4);return pr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Lt(this,4);let t=Ns(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Lt(this,4);let t=Ks(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Lt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Ms(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Lt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Lt(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 St(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw Lt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw Lt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Lt(this,8);let t=pr(this.buf,this.pos+=4),e=pr(this.buf,this.pos+=4);return new St(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=On(this.buf,this.pos);return this.pos+=mt(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 Fn(r){return new Vn(r instanceof Uint8Array?r:r.subarray())}function mr(r,t,e){let n=Fn(r);return t.decode(n,void 0,e)}function zn(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return pt(i);o+i>t&&(n=pt(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var ae=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function jn(){}var Zn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},af=zn();function ff(r){return globalThis.Buffer!=null?pt(r):af(r)}var je=class{len;head;tail;states;constructor(){this.len=0,this.head=new ae(jn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ae(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Wn((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(gr,10,St.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=St.fromBigInt(t);return this._push(gr,e.length(),e)}uint64Number(t){return this._push(kn,mt(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=St.fromBigInt(t).zzEncode();return this._push(gr,e.length(),e)}sint64Number(t){let e=St.fromNumber(t).zzEncode();return this._push(gr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Gn,1,t?1:0)}fixed32(t){return this._push(ze,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=St.fromBigInt(t);return this._push(ze,4,e.lo)._push(ze,4,e.hi)}fixed64Number(t){let e=St.fromNumber(t);return this._push(ze,4,e.lo)._push(ze,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(_s,4,t)}double(t){return this._push(Rs,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Gn,1,0):this.uint32(e)._push(lf,e,t)}string(t){let e=Os(t);return e!==0?this.uint32(e)._push(qn,e,t):this._push(Gn,1,0)}fork(){return this.states=new Zn(this),this.head=this.tail=new ae(jn,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 ae(jn,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=ff(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Gn(r,t,e){t[e]=r&255}function uf(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Wn=class extends ae{next;constructor(t,e){super(uf,t,e),this.next=void 0}};function gr(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function ze(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function lf(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(je.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(hf,t,r),this},je.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(df,t,r),this});function hf(r,t,e){t.set(r,e)}function df(r,t,e){r.length<40?qn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(At(r),e)}function $n(){return new je}function xr(r,t){let e=$n();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Ie;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Ie||(Ie={}));function yr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Yn(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let c=t(s);i.int32(c)},n=function(s){let i=s.int32();return t(i)};return yr("enum",Ie.VARINT,e,n)}function br(r,t){return yr("message",Ie.LENGTH_DELIMITED,r,t)}var vt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(vt||(vt={}));var Xn;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(Xn||(Xn={}));(function(r){r.codec=()=>Yn(Xn)})(vt||(vt={}));var Ge;(function(r){let t;r.codec=()=>(t==null&&(t=br((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),vt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=vt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>xr(e,r.codec()),r.decode=(e,n)=>mr(e,r.codec(),n)})(Ge||(Ge={}));var Qn;(function(r){let t;r.codec=()=>(t==null&&(t=br((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),vt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=vt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>xr(e,r.codec()),r.decode=(e,n)=>mr(e,r.codec(),n)})(Qn||(Qn={}));var Ze=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var wr=class extends Ee{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,rs(t);let n=He(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(t){return we(this),this.iHash.update(t),this}digestInto(t){we(this),be(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,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=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Jn=(r,t,e)=>new wr(r,t).update(e).digest();Jn.create=(r,t)=>new wr(r,t);function qs(r){r.lowS!==void 0&&Pt("lowS",r.lowS),r.prehash!==void 0&&Pt("prehash",r.prehash)}function mf(r){let t=Fe(r);kt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var to=class extends Error{constructor(t=""){super(t)}},Ot={Err:to,_tlv:{encode:(r,t)=>{let{Err:e}=Ot;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=qe(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?qe(o.length/2|128):"";return qe(r)+s+o+t},decode(r,t){let{Err:e}=Ot,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let a=o&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let u=t.subarray(n,n+a);if(u.length!==a)throw new e("tlv.decode: length bytes not complete");if(u[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let f of u)i=i<<8|f;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Ot;if(r<Mt)throw new t("integer: negative integers are not allowed");let e=qe(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=Ot;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Kt(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Ot,o=Q("signature",r),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:u,l:f}=n.decode(2,a);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(u)}},hexFromSig(r){let{_tlv:t,_int:e}=Ot,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},Mt=BigInt(0),ct=BigInt(1),$d=BigInt(2),Vs=BigInt(3),Yd=BigInt(4);function gf(r){let t=mf(r),{Fp:e}=t,n=Zt(t.n,t.nBitLength),o=t.toBytes||((g,h,y)=>{let B=h.toAffine();return Gt(Uint8Array.from([4]),e.toBytes(B.x),e.toBytes(B.y))}),s=t.fromBytes||(g=>{let h=g.subarray(1),y=e.fromBytes(h.subarray(0,e.BYTES)),B=e.fromBytes(h.subarray(e.BYTES,2*e.BYTES));return{x:y,y:B}});function i(g){let{a:h,b:y}=t,B=e.sqr(g),m=e.mul(B,g);return e.add(e.add(m,e.mul(g,h)),y)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function c(g){return ar(g,ct,t.n)}function a(g){let{allowedPrivateKeyLengths:h,nByteLength:y,wrapPrivateKey:B,n:m}=t;if(h&&typeof g!="bigint"){if(ee(g)&&(g=jt(g)),typeof g!="string"||!h.includes(g.length))throw new Error("invalid private key");g=g.padStart(y*2,"0")}let I;try{I=typeof g=="bigint"?g:Kt(Q("private key",g,y))}catch{throw new Error("invalid private key, expected hex or "+y+" bytes, got "+typeof g)}return B&&(I=j(I,m)),Et("private key",I,ct,m),I}function u(g){if(!(g instanceof p))throw new Error("ProjectivePoint expected")}let f=Ae((g,h)=>{let{px:y,py:B,pz:m}=g;if(e.eql(m,e.ONE))return{x:y,y:B};let I=g.is0();h==null&&(h=I?e.ONE:e.inv(m));let N=e.mul(y,h),D=e.mul(B,h),L=e.mul(m,h);if(I)return{x:e.ZERO,y:e.ZERO};if(!e.eql(L,e.ONE))throw new Error("invZ was invalid");return{x:N,y:D}}),l=Ae(g=>{if(g.is0()){if(t.allowInfinityPoint&&!e.is0(g.py))return;throw new Error("bad point: ZERO")}let{x:h,y}=g.toAffine();if(!e.isValid(h)||!e.isValid(y))throw new Error("bad point: x or y not FE");let B=e.sqr(y),m=i(h);if(!e.eql(B,m))throw new Error("bad point: equation left != right");if(!g.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class p{constructor(h,y,B){if(h==null||!e.isValid(h))throw new Error("x required");if(y==null||!e.isValid(y))throw new Error("y required");if(B==null||!e.isValid(B))throw new Error("z required");this.px=h,this.py=y,this.pz=B,Object.freeze(this)}static fromAffine(h){let{x:y,y:B}=h||{};if(!h||!e.isValid(y)||!e.isValid(B))throw new Error("invalid affine point");if(h instanceof p)throw new Error("projective point not allowed");let m=I=>e.eql(I,e.ZERO);return m(y)&&m(B)?p.ZERO:new p(y,B,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let y=e.invertBatch(h.map(B=>B.pz));return h.map((B,m)=>B.toAffine(y[m])).map(p.fromAffine)}static fromHex(h){let y=p.fromAffine(s(Q("pointHex",h)));return y.assertValidity(),y}static fromPrivateKey(h){return p.BASE.multiply(a(h))}static msm(h,y){return lr(p,n,h,y)}_setWindowSize(h){E.setWindowSize(this,h)}assertValidity(){l(this)}hasEvenY(){let{y:h}=this.toAffine();if(e.isOdd)return!e.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){u(h);let{px:y,py:B,pz:m}=this,{px:I,py:N,pz:D}=h,L=e.eql(e.mul(y,D),e.mul(I,m)),C=e.eql(e.mul(B,D),e.mul(N,m));return L&&C}negate(){return new p(this.px,e.neg(this.py),this.pz)}double(){let{a:h,b:y}=t,B=e.mul(y,Vs),{px:m,py:I,pz:N}=this,D=e.ZERO,L=e.ZERO,C=e.ZERO,P=e.mul(m,m),W=e.mul(I,I),V=e.mul(N,N),O=e.mul(m,I);return O=e.add(O,O),C=e.mul(m,N),C=e.add(C,C),D=e.mul(h,C),L=e.mul(B,V),L=e.add(D,L),D=e.sub(W,L),L=e.add(W,L),L=e.mul(D,L),D=e.mul(O,D),C=e.mul(B,C),V=e.mul(h,V),O=e.sub(P,V),O=e.mul(h,O),O=e.add(O,C),C=e.add(P,P),P=e.add(C,P),P=e.add(P,V),P=e.mul(P,O),L=e.add(L,P),V=e.mul(I,N),V=e.add(V,V),P=e.mul(V,O),D=e.sub(D,P),C=e.mul(V,W),C=e.add(C,C),C=e.add(C,C),new p(D,L,C)}add(h){u(h);let{px:y,py:B,pz:m}=this,{px:I,py:N,pz:D}=h,L=e.ZERO,C=e.ZERO,P=e.ZERO,W=t.a,V=e.mul(t.b,Vs),O=e.mul(y,I),nt=e.mul(B,N),v=e.mul(m,D),T=e.add(y,B),U=e.add(I,N);T=e.mul(T,U),U=e.add(O,nt),T=e.sub(T,U),U=e.add(y,m);let x=e.add(I,D);return U=e.mul(U,x),x=e.add(O,v),U=e.sub(U,x),x=e.add(B,m),L=e.add(N,D),x=e.mul(x,L),L=e.add(nt,v),x=e.sub(x,L),P=e.mul(W,U),L=e.mul(V,v),P=e.add(L,P),L=e.sub(nt,P),P=e.add(nt,P),C=e.mul(L,P),nt=e.add(O,O),nt=e.add(nt,O),v=e.mul(W,v),U=e.mul(V,U),nt=e.add(nt,v),v=e.sub(O,v),v=e.mul(W,v),U=e.add(U,v),O=e.mul(nt,U),C=e.add(C,O),O=e.mul(x,U),L=e.mul(T,L),L=e.sub(L,O),O=e.mul(T,nt),P=e.mul(x,P),P=e.add(P,O),new p(L,C,P)}subtract(h){return this.add(h.negate())}is0(){return this.equals(p.ZERO)}wNAF(h){return E.wNAFCached(this,h,p.normalizeZ)}multiplyUnsafe(h){let{endo:y,n:B}=t;Et("scalar",h,Mt,B);let m=p.ZERO;if(h===Mt)return m;if(this.is0()||h===ct)return this;if(!y||E.hasPrecomputes(this))return E.wNAFCachedUnsafe(this,h,p.normalizeZ);let{k1neg:I,k1:N,k2neg:D,k2:L}=y.splitScalar(h),C=m,P=m,W=this;for(;N>Mt||L>Mt;)N&ct&&(C=C.add(W)),L&ct&&(P=P.add(W)),W=W.double(),N>>=ct,L>>=ct;return I&&(C=C.negate()),D&&(P=P.negate()),P=new p(e.mul(P.px,y.beta),P.py,P.pz),C.add(P)}multiply(h){let{endo:y,n:B}=t;Et("scalar",h,ct,B);let m,I;if(y){let{k1neg:N,k1:D,k2neg:L,k2:C}=y.splitScalar(h),{p:P,f:W}=this.wNAF(D),{p:V,f:O}=this.wNAF(C);P=E.constTimeNegate(N,P),V=E.constTimeNegate(L,V),V=new p(e.mul(V.px,y.beta),V.py,V.pz),m=P.add(V),I=W.add(O)}else{let{p:N,f:D}=this.wNAF(h);m=N,I=D}return p.normalizeZ([m,I])[0]}multiplyAndAddUnsafe(h,y,B){let m=p.BASE,I=(D,L)=>L===Mt||L===ct||!D.equals(m)?D.multiplyUnsafe(L):D.multiply(L),N=I(this,y).add(I(h,B));return N.is0()?void 0:N}toAffine(h){return f(this,h)}isTorsionFree(){let{h,isTorsionFree:y}=t;if(h===ct)return!0;if(y)return y(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:y}=t;return h===ct?this:y?y(p,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return Pt("isCompressed",h),this.assertValidity(),o(p,this,h)}toHex(h=!0){return Pt("isCompressed",h),jt(this.toRawBytes(h))}}p.BASE=new p(t.Gx,t.Gy,e.ONE),p.ZERO=new p(e.ZERO,e.ONE,e.ZERO);let w=t.nBitLength,E=ur(p,t.endo?Math.ceil(w/2):w);return{CURVE:t,ProjectivePoint:p,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:c}}function xf(r){let t=Fe(r);return kt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Fs(r){let t=xf(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(v){return j(v,n)}function c(v){return fr(v,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:u,weierstrassEquation:f,isWithinCurveOrder:l}=gf({...t,toBytes(v,T,U){let x=T.toAffine(),d=e.toBytes(x.x),b=Gt;return Pt("isCompressed",U),U?b(Uint8Array.from([T.hasEvenY()?2:3]),d):b(Uint8Array.from([4]),d,e.toBytes(x.y))},fromBytes(v){let T=v.length,U=v[0],x=v.subarray(1);if(T===o&&(U===2||U===3)){let d=Kt(x);if(!ar(d,ct,e.ORDER))throw new Error("Point is not on curve");let b=f(d),A;try{A=e.sqrt(b)}catch(M){let H=M instanceof Error?": "+M.message:"";throw new Error("Point is not on curve"+H)}let R=(A&ct)===ct;return(U&1)===1!==R&&(A=e.neg(A)),{x:d,y:A}}else if(T===s&&U===4){let d=e.fromBytes(x.subarray(0,e.BYTES)),b=e.fromBytes(x.subarray(e.BYTES,2*e.BYTES));return{x:d,y:b}}else{let d=o,b=s;throw new Error("invalid Point, expected length of "+d+", or uncompressed "+b+", got "+T)}}}),p=v=>jt(ne(v,t.nByteLength));function w(v){let T=n>>ct;return v>T}function E(v){return w(v)?i(-v):v}let g=(v,T,U)=>Kt(v.slice(T,U));class h{constructor(T,U,x){Et("r",T,ct,n),Et("s",U,ct,n),this.r=T,this.s=U,x!=null&&(this.recovery=x),Object.freeze(this)}static fromCompact(T){let U=t.nByteLength;return T=Q("compactSignature",T,U*2),new h(g(T,0,U),g(T,U,2*U))}static fromDER(T){let{r:U,s:x}=Ot.toSig(Q("DER",T));return new h(U,x)}assertValidity(){}addRecoveryBit(T){return new h(this.r,this.s,T)}recoverPublicKey(T){let{r:U,s:x,recovery:d}=this,b=D(Q("msgHash",T));if(d==null||![0,1,2,3].includes(d))throw new Error("recovery id invalid");let A=d===2||d===3?U+t.n:U;if(A>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let R=(d&1)===0?"02":"03",k=a.fromHex(R+p(A)),M=c(A),H=i(-b*M),q=i(x*M),z=a.BASE.multiplyAndAddUnsafe(k,H,q);if(!z)throw new Error("point at infinify");return z.assertValidity(),z}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return Ve(this.toDERHex())}toDERHex(){return Ot.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ve(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let y={isValidPrivateKey(v){try{return u(v),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let v=Bn(t.n);return ys(t.randomBytes(v),t.n)},precompute(v=8,T=a.BASE){return T._setWindowSize(v),T.multiply(BigInt(3)),T}};function B(v,T=!0){return a.fromPrivateKey(v).toRawBytes(T)}function m(v){let T=ee(v),U=typeof v=="string",x=(T||U)&&v.length;return T?x===o||x===s:U?x===2*o||x===2*s:v instanceof a}function I(v,T,U=!0){if(m(v))throw new Error("first arg must be private key");if(!m(T))throw new Error("second arg must be public key");return a.fromHex(T).multiply(u(v)).toRawBytes(U)}let N=t.bits2int||function(v){if(v.length>8192)throw new Error("input is too large");let T=Kt(v),U=v.length*8-t.nBitLength;return U>0?T>>BigInt(U):T},D=t.bits2int_modN||function(v){return i(N(v))},L=oe(t.nBitLength);function C(v){return Et("num < 2^"+t.nBitLength,v,Mt,L),ne(v,t.nByteLength)}function P(v,T,U=W){if(["recovered","canonical"].some(tt=>tt in U))throw new Error("sign() legacy options not supported");let{hash:x,randomBytes:d}=t,{lowS:b,prehash:A,extraEntropy:R}=U;b==null&&(b=!0),v=Q("msgHash",v),qs(U),A&&(v=Q("prehashed msgHash",x(v)));let k=D(v),M=u(T),H=[C(M),C(k)];if(R!=null&&R!==!1){let tt=R===!0?d(e.BYTES):R;H.push(Q("extraEntropy",tt))}let q=Gt(...H),z=k;function rt(tt){let at=N(tt);if(!l(at))return;let dt=c(at),it=a.BASE.multiply(at).toAffine(),ft=i(it.x);if(ft===Mt)return;let gt=i(dt*i(z+ft*M));if(gt===Mt)return;let Bt=(it.x===ft?0:2)|Number(it.y&ct),Pe=gt;return b&&w(gt)&&(Pe=E(gt),Bt^=1),new h(ft,Pe,Bt)}return{seed:q,k2sig:rt}}let W={lowS:t.lowS,prehash:!1},V={lowS:t.lowS,prehash:!1};function O(v,T,U=W){let{seed:x,k2sig:d}=P(v,T,U),b=t;return ds(b.hash.outputLen,b.nByteLength,b.hmac)(x,d)}a.BASE._setWindowSize(8);function nt(v,T,U,x=V){let d=v;T=Q("msgHash",T),U=Q("publicKey",U);let{lowS:b,prehash:A,format:R}=x;if(qs(x),"strict"in x)throw new Error("options.strict was renamed to lowS");if(R!==void 0&&R!=="compact"&&R!=="der")throw new Error("format must be compact or der");let k=typeof d=="string"||ee(d),M=!k&&!R&&typeof d=="object"&&d!==null&&typeof d.r=="bigint"&&typeof d.s=="bigint";if(!k&&!M)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let H,q;try{if(M&&(H=new h(d.r,d.s)),k){try{R!=="compact"&&(H=h.fromDER(d))}catch(Bt){if(!(Bt instanceof Ot.Err))throw Bt}!H&&R!=="der"&&(H=h.fromCompact(d))}q=a.fromHex(U)}catch{return!1}if(!H||b&&H.hasHighS())return!1;A&&(T=t.hash(T));let{r:z,s:rt}=H,tt=D(T),at=c(rt),dt=i(tt*at),it=i(z*at),ft=a.BASE.multiplyAndAddUnsafe(q,dt,it)?.toAffine();return ft?i(ft.x)===z:!1}return{CURVE:t,getPublicKey:B,getSharedSecret:I,sign:O,verify:nt,ProjectivePoint:a,Signature:h,utils:y}}function yf(r){return{hash:r,hmac:(t,...e)=>Jn(r,t,ln(...e)),randomBytes:ir}}function zs(r,t){let e=n=>Fs({...r,...yf(n)});return{...e(t),create:e}}var Zs=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),js=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),bf=BigInt(1),eo=BigInt(2),Gs=(r,t)=>(r+t/eo)/t;function wf(r){let t=Zs,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),u=r*r*r%t,f=u*u*r%t,l=X(f,e,t)*f%t,p=X(l,e,t)*f%t,w=X(p,eo,t)*u%t,E=X(w,o,t)*w%t,g=X(E,s,t)*E%t,h=X(g,c,t)*g%t,y=X(h,a,t)*h%t,B=X(y,c,t)*g%t,m=X(B,e,t)*f%t,I=X(m,i,t)*E%t,N=X(I,n,t)*u%t,D=X(N,eo,t);if(!ro.eql(ro.sqr(D),r))throw new Error("Cannot find square root");return D}var ro=Zt(Zs,void 0,void 0,{sqrt:wf}),fe=zs({a:BigInt(0),b:BigInt(7),Fp:ro,n:js,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=js,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-bf*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=Gs(s*r,t),a=Gs(-n*r,t),u=j(r-c*e-a*o,t),f=j(-c*n-a*s,t),l=u>i,p=f>i;if(l&&(u=t-u),p&&(f=t-f),u>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:u,k2neg:p,k2:f}}}},dn),sp=BigInt(0);var ip=fe.ProjectivePoint;function Ws(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function $s(r,t,e){let n=Ke.digest(e instanceof Uint8Array?e:e.subarray());if(Ws(n))return n.then(({digest:o})=>fe.verify(t,o,r)).catch(o=>{throw new Ze(String(o))});try{return fe.verify(t,n.digest,r)}catch(o){throw new Ze(String(o))}}var Er=class{type="secp256k1";raw;_key;constructor(t){this._key=Xs(t),this.raw=Ys(this._key)}toMultihash(){return It.digest(ye(this))}toCID(){return ot.createV1(114,this.toMultihash())}toString(){return $.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}verify(t,e){return $s(this._key,e,t)}};function Qs(r){return new Er(r)}function Ys(r){return fe.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Xs(r){try{return fe.ProjectivePoint.fromHex(r),r}catch(t){throw new Ye(String(t))}}function Js(r){let{Type:t,Data:e}=Ge.decode(r.digest),n=e??new Uint8Array;switch(t){case vt.Ed25519:return Us(n);case vt.secp256k1:return Qs(n);case vt.ECDSA:return Qo(n);default:throw new Ue}}function ye(r){return Ge.encode({Type:vt[r.type],Data:r.raw})}var ti=Symbol.for("nodejs.util.inspect.custom"),Ef=114,We=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=$.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ot.createV1(Ef,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return yt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return yt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[ti](){return`PeerId(${this.toString()})`}},Sr=class extends We{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},vr=class extends We{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Ar=class extends We{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Sf=2336,$e=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=It.digest(At(this.url))}[ti](){return`PeerId(${this.url})`}[Kr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ot.createV1(Sf,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=G(t)),t.toString()===this.toString())}};var vf=114,ei=2336;function ri(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=Qt($.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return Af(ot.parse(r));if(t==null)throw new Ct('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=Qt(t.decode(r))}return ni(e)}function ni(r){if(If(r))return new Sr({multihash:r});if(Bf(r))try{let t=Js(r);if(t.type==="Ed25519")return new vr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Ar({multihash:r,publicKey:t})}catch{let e=G(r.digest);return new $e(new URL(e))}throw new Qe("Supplied PeerID Multihash is invalid")}function Af(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==vf&&r.code!==ei)throw new Xe("Supplied PeerID CID is invalid");if(r.code===ei){let t=G(r.multihash.digest);return new $e(new URL(t))}return ni(r.multihash)}function Bf(r){return r.code===It.code}function If(r){return r.code===Ke.code}var Br=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,i=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",u=2**(8*o)-1;for(;;){let f=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let p=Number.parseInt(l,t);if(!Number.isNaN(p))return p});if(f===void 0)break;if(s*=t,s+=f,s>u||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&a&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[o]=i[0],e[o+1]=i[1],e[o+2]=i[2],e[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[c]=t(s.subarray(0,i));return e.set(s.subarray(0,c),16-c),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var oi=45,Tf=15,Te=new Br;function no(r){if(!(r.length>Tf))return Te.new(r).parseWith(()=>Te.readIPv4Addr())}function oo(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>oi))return Te.new(r).parseWith(()=>Te.readIPv6Addr())}function Ir(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>oi)return;let e=Te.new(r).parseWith(()=>Te.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}var b0=parseInt("0xFFFF",16),w0=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function ci(r){return!!no(r)}function ai(r){return!!oo(r)}function Tr(r){return!!Ir(r)}var fi=ci,Df=ai,so=function(r){let t=0;if(r=r.toString().trim(),fi(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Df(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=fi(e[n]),i;s&&(i=so(e[n]),e[n]=G(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,G(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},ui=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Le={},io={},Nf=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];Nf.forEach(r=>{let t=Rf(...r);io[t.code]=t,Le[t.name]=t});function Rf(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function Z(r){if(typeof r=="number"){if(io[r]!=null)return io[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Le[r]!=null)return Le[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var nm=Z("ip4"),om=Z("ip6"),sm=Z("ipcidr");function uo(r,t){switch(Z(r).code){case 4:case 41:return kf(t);case 42:return fo(t);case 43:return G(t,"base10");case 6:case 273:case 33:case 132:return di(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return fo(t);case 421:return qf(t);case 444:return hi(t);case 445:return hi(t);case 466:return Hf(t);case 481:return globalThis.encodeURIComponent(fo(t));default:return G(t,"base16")}}function lo(r,t){switch(Z(r).code){case 4:return li(t);case 41:return li(t);case 42:return ao(t);case 43:return At(t,"base10");case 6:case 273:case 33:case 132:return ho(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ao(t);case 421:return Of(t);case 444:return Vf(t);case 445:return Ff(t);case 466:return Mf(t);case 481:return ao(globalThis.decodeURIComponent(t));default:return At(t,"base16")}}var co=Object.values(ke).map(r=>r.decoder),Kf=function(){let r=co[0].or(co[1]);return co.slice(2).forEach(t=>r=r.or(t)),r}();function li(r){if(!Tr(r))throw new Error("invalid ip address");return so(r)}function kf(r){let t=ui(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Tr(t))throw new Error("invalid ip address");return t}function ho(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function di(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function ao(r){let t=At(r),e=Uint8Array.from(Be(t.length));return bt([e,t],e.length+t.length)}function fo(r){let t=ie(r);if(r=r.slice(mt(t)),r.length!==t)throw new Error("inconsistent lengths");return G(r)}function Of(r){let t;r[0]==="Q"||r[0]==="1"?t=Qt($.decode(`z${r}`)).bytes:t=ot.parse(r).multihash.bytes;let e=Uint8Array.from(Be(t.length));return bt([e,t],e.length+t.length)}function Mf(r){let t=Kf.decode(r),e=Uint8Array.from(Be(t.length));return bt([e,t],e.length+t.length)}function Hf(r){let t=ie(r),e=r.slice(mt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+G(e,"base64url")}function qf(r){let t=ie(r),e=r.slice(mt(t));if(e.length!==t)throw new Error("inconsistent lengths");return G(e,"base58btc")}function Vf(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=_t.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ho(n);return bt([e,o],e.length+o.length)}function Ff(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=_t.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ho(n);return bt([e,o],e.length+o.length)}function hi(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=G(t,"base32"),o=di(e);return`${n}:${o}`}function pi(r){r=po(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],c=Z(i);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(s++,s>=o.length)throw new Lr("invalid address: "+r);if(c.path===!0){n=po(o.slice(s).join("/")),t.push([c.code,lo(c.code,n)]),e.push([c.code,n]);break}let a=lo(c.code,o[s]);t.push([c.code,a]),e.push([c.code,uo(c.code,a)])}return{string:mi(e),bytes:Cr(t),tuples:t,stringTuples:e,path:n}}function mo(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=ie(r,o),i=mt(s),c=Z(s),a=zf(c,r.slice(o+i));if(a===0){t.push([s]),e.push([s]),o+=i;continue}let u=r.slice(o+i,o+i+a);if(o+=a+i,o>r.length)throw new Lr("Invalid address Uint8Array: "+G(r,"base16"));t.push([s,u]);let f=uo(s,u);if(e.push([s,f]),c.path===!0){n=f;break}}return{bytes:Uint8Array.from(r),string:mi(e),tuples:t,stringTuples:e,path:n}}function mi(r){let t=[];return r.map(e=>{let n=Z(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),po(t.join("/"))}function Cr(r){return bt(r.map(t=>{let e=Z(t[0]),n=Uint8Array.from(Be(e.code));return t.length>1&&t[1]!=null&&(n=bt([n,t[1]])),n}))}function zf(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=ie(t instanceof Uint8Array?t:Uint8Array.from(t));return e+mt(e)}}function po(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var Lr=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var jf=Symbol.for("nodejs.util.inspect.custom"),xo=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Gf=[Z("dns").code,Z("dns4").code,Z("dns6").code,Z("dnsaddr").code],go=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Pr=class r{bytes;#t;#e;#r;#n;[xo]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=mo(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=pi(t)}else if(xi(t))e=mo(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",i=Z("tcp"),c=Z("udp"),a=Z("ip4"),u=Z("ip6"),f=Z("dns6"),l=Z("ip6zone");for(let[w,E]of this.stringTuples())w===l.code&&(s=`%${E??""}`),Gf.includes(w)&&(e=i.name==="tcp"?"tcp":"udp",o=443,n=`${E??""}${s}`,t=w===f.code?6:4),(w===i.code||w===c.code)&&(e=Z(w).name==="tcp"?"tcp":"udp",o=parseInt(E??"")),(w===a.code||w===u.code)&&(e=Z(w).name==="tcp"?"tcp":"udp",n=`${E??""}${s}`,t=w===u.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},Z(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>Z(t).name)}tuples(){return this.#e.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(Cr(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===Le.p2p.code&&t.push([n,o]),n===Le["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?G($.decode(`z${n}`),"base58btc"):G(ot.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return yt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=gi.get(e.name);if(n==null)throw new go(`no available resolver for ${e.name}`);return(await n(this,t)).map(s=>$t(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[jf](){return`Multiaddr(${this.#t})`}};var gi=new Map;function xi(r){return!!r?.[xo]}function $t(r){return new Pr(r)}var Zf=S("dns4"),Wf=S("dns6"),$f=S("dnsaddr"),le=et(S("dns"),$f,Zf,Wf),_r=et(S("ip4"),S("ip6")),Ce=et(_(_r,S("tcp")),_(le,S("tcp"))),Nr=_(_r,S("udp")),Yf=_(Nr,S("utp")),Xf=_(Nr,S("quic")),Qf=_(Nr,S("quic-v1")),yo=et(_(Ce,S("ws")),_(le,S("ws"))),Ur=et(_(yo,S("p2p")),yo),bo=et(_(Ce,S("wss")),_(le,S("wss")),_(Ce,S("tls"),S("ws")),_(le,S("tls"),S("ws"))),Dr=et(_(bo,S("p2p")),bo),wo=et(_(Ce,S("http")),_(_r,S("http")),_(le,S("http"))),Eo=et(_(Ce,S("https")),_(_r,S("https")),_(le,S("https"))),yi=_(Nr,S("webrtc-direct"),S("certhash")),Ei=et(_(yi,S("p2p")),yi),bi=_(Qf,S("webtransport"),S("certhash"),S("certhash")),Si=et(_(bi,S("p2p")),bi),vi=et(_(Ur,S("p2p-webrtc-star"),S("p2p")),_(Dr,S("p2p-webrtc-star"),S("p2p")),_(Ur,S("p2p-webrtc-star")),_(Dr,S("p2p-webrtc-star"))),Dm=et(_(Ur,S("p2p-websocket-star"),S("p2p")),_(Dr,S("p2p-websocket-star"),S("p2p")),_(Ur,S("p2p-websocket-star")),_(Dr,S("p2p-websocket-star"))),Ai=et(_(wo,S("p2p-webrtc-direct"),S("p2p")),_(Eo,S("p2p-webrtc-direct"),S("p2p")),_(wo,S("p2p-webrtc-direct")),_(Eo,S("p2p-webrtc-direct"))),he=et(yo,bo,wo,Eo,vi,Ai,Ce,Yf,Xf,le,Ei,Si),_m=et(_(he,S("p2p-stardust"),S("p2p")),_(he,S("p2p-stardust"))),Yt=et(_(he,S("p2p")),vi,Ai,Ei,Si,S("p2p")),wi=et(_(Yt,S("p2p-circuit"),Yt),_(Yt,S("p2p-circuit")),_(S("p2p-circuit"),Yt),_(he,S("p2p-circuit")),_(S("p2p-circuit"),he),S("p2p-circuit")),Bi=()=>et(_(wi,Bi),wi),ue=Bi(),Ii=et(_(ue,Yt,ue),_(Yt,ue),_(ue,Yt),ue,Yt);var Nm=et(_(ue,S("webrtc"),S("p2p")),_(ue,S("webrtc")),_(he,S("webrtc"),S("p2p")),_(he,S("webrtc")),S("webrtc"));function Ti(r){function t(e){let n;try{n=$t(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function _(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(o=>(n=typeof o=="function"?o().partialMatch(e):o.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Ti(t),partialMatch:t}}function et(...r){function t(n){let o=null;return r.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Ti(t),partialMatch:t}}function S(r){let t=r;function e(o){let s;try{s=$t(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var Jf="bootstrap",tu=50,eu=1e3,So=class extends Je{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(t,e={list:[]}){if(e.list==null||e.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super(),this.components=t,this.log=t.logger.forComponent("libp2p:bootstrap"),this.timeout=e.timeout??eu,this.list=[];for(let n of e.list){if(!Ii.matches(n)){this.log.error("Invalid multiaddr");continue}let o=$t(n),s=o.getPeerId();if(s==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let i={id:ri(s),multiaddrs:[o]};this.list.push(i)}this._init=e}[Ao]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[Bo]=["@libp2p/peer-discovery"];isStarted(){return!!this.timer}start(){this.isStarted()||(this.log("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(t=>{this.log.error(t)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(let t of this.list){if(await this.components.peerStore.merge(t.id,{tags:{[this._init.tagName??Jf]:{value:this._init.tagValue??tu,ttl:this._init.tagTTL}},multiaddrs:t.multiaddrs}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t}),this.components.connectionManager.openConnection(t.id).catch(e=>{this.log.error("could not dial bootstrap peer %p",t.id,e)})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function ru(r){return t=>new So(t,r)}return Ki(nu);})();
|
|
2
|
+
"use strict";var Libp2PBootstrap=(()=>{var qr=Object.defineProperty;var $i=Object.getOwnPropertyDescriptor;var Yi=Object.getOwnPropertyNames;var Xi=Object.prototype.hasOwnProperty;var gt=(r,t)=>{for(var e in t)qr(r,e,{get:t[e],enumerable:!0})},Qi=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Yi(t))!Xi.call(r,o)&&o!==e&&qr(r,o,{get:()=>t[o],enumerable:!(n=$i(t,o))||n.enumerable});return r};var Ji=r=>Qi(qr({},"__esModule",{value:!0}),r);var Jf={};gt(Jf,{bootstrap:()=>Qf});var Uo=Symbol.for("@libp2p/peer-discovery");var zr=Symbol.for("@libp2p/peer-id");var Ct=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},nr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var or=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},sr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Re=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var ir=class extends EventTarget{#t=new Map;constructor(){super()}listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e={}){return this.dispatchEvent(new CustomEvent(t,e))}};var _o=Symbol.for("@libp2p/service-capabilities"),su=Symbol.for("@libp2p/service-dependencies");var Wr={};gt(Wr,{base58btc:()=>W,base58flickr:()=>sc});var Lu=new Uint8Array(0);function Do(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Dt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function No(r){return new TextEncoder().encode(r)}function Ro(r){return new TextDecoder().decode(r)}function tc(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var c=r.length,a=r.charAt(0),u=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function l(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var x=0,h=0,y=0,B=E.length;y!==B&&E[y]===0;)y++,x++;for(var m=(B-y)*f+1>>>0,I=new Uint8Array(m);y!==B;){for(var N=E[y],_=0,L=m-1;(N!==0||_<h)&&L!==-1;L--,_++)N+=256*I[L]>>>0,I[L]=N%c>>>0,N=N/c>>>0;if(N!==0)throw new Error("Non-zero carry");h=_,y++}for(var C=m-h;C!==m&&I[C]===0;)C++;for(var P=a.repeat(x);C<m;++C)P+=r.charAt(I[C]);return P}function p(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var x=0;if(E[x]!==" "){for(var h=0,y=0;E[x]===a;)h++,x++;for(var B=(E.length-x)*u+1>>>0,m=new Uint8Array(B);E[x];){var I=e[E.charCodeAt(x)];if(I===255)return;for(var N=0,_=B-1;(I!==0||N<y)&&_!==-1;_--,N++)I+=c*m[_]>>>0,m[_]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");y=N,x++}if(E[x]!==" "){for(var L=B-y;L!==B&&m[L]===0;)L++;for(var C=new Uint8Array(h+(B-L)),P=h;L!==B;)C[P++]=m[L++];return C}}}function w(E){var x=p(E);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:p,decode:w}}var ec=tc,rc=ec,ko=rc;var Fr=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},jr=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Oo(this,t)}},Gr=class{decoders;constructor(t){this.decoders=t}or(t){return Oo(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Oo(r,t){return new Gr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Zr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Fr(t,e,n),this.decoder=new jr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ye({name:r,prefix:t,encode:e,decode:n}){return new Zr(r,t,e,n)}function Ft({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=ko(e,r);return ye({prefix:t,name:r,encode:n,decode:s=>Dt(o(s))})}function nc(r,t,e,n){let o={};for(let f=0;f<t.length;++f)o[t[f]]=f;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),c=0,a=0,u=0;for(let f=0;f<s;++f){let l=o[r[f]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|l,c+=e,c>=8&&(c-=8,i[u++]=255&a>>c)}if(c>=e||(255&a<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return i}function oc(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],i+=8;i>e;)i-=e,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function X({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return ye({prefix:t,name:r,encode(o){return oc(o,n,e)},decode(o){return nc(o,n,e,r)}})}var W=Ft({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),sc=Ft({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var $r={};gt($r,{base32:()=>Nt,base32hex:()=>fc,base32hexpad:()=>lc,base32hexpadupper:()=>hc,base32hexupper:()=>uc,base32pad:()=>cc,base32padupper:()=>ac,base32upper:()=>ic,base32z:()=>dc});var Nt=X({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ic=X({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),cc=X({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ac=X({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),fc=X({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),uc=X({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),lc=X({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),hc=X({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),dc=X({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Yr={};gt(Yr,{base36:()=>Ke,base36upper:()=>pc});var Ke=Ft({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),pc=Ft({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var mc=Vo,Mo=128,xc=127,gc=~xc,yc=Math.pow(2,31);function Vo(r,t,e){t=t||[],e=e||0;for(var n=e;r>=yc;)t[e++]=r&255|Mo,r/=128;for(;r&gc;)t[e++]=r&255|Mo,r>>>=7;return t[e]=r|0,Vo.bytes=e-n+1,t}var bc=Xr,wc=128,Ho=127;function Xr(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw Xr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&Ho)<<o:(i&Ho)*Math.pow(2,o),o+=7}while(i>=wc);return Xr.bytes=s-n,e}var Ec=Math.pow(2,7),Sc=Math.pow(2,14),vc=Math.pow(2,21),Ac=Math.pow(2,28),Bc=Math.pow(2,35),Ic=Math.pow(2,42),Tc=Math.pow(2,49),Lc=Math.pow(2,56),Cc=Math.pow(2,63),Pc=function(r){return r<Ec?1:r<Sc?2:r<vc?3:r<Ac?4:r<Bc?5:r<Ic?6:r<Tc?7:r<Lc?8:r<Cc?9:10},Uc={encode:mc,decode:bc,encodingLength:Pc},_c=Uc,ke=_c;function Oe(r,t=0){return[ke.decode(r,t),ke.decode.bytes]}function be(r,t,e=0){return ke.encode(r,t,e),t}function we(r){return ke.encodingLength(r)}function Jt(r,t){let e=t.byteLength,n=we(r),o=n+we(e),s=new Uint8Array(o+e);return be(r,s,0),be(e,s,n),s.set(t,o),new Ee(r,e,t,s)}function te(r){let t=Dt(r),[e,n]=Oe(t),[o,s]=Oe(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Ee(e,o,i,t)}function qo(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Do(r.bytes,e.bytes)}}var Ee=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function zo(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Nc(e,Qr(r),t??W.encoder);default:return Rc(e,Qr(r),t??Nt.encoder)}}var Fo=new WeakMap;function Qr(r){let t=Fo.get(r);if(t==null){let e=new Map;return Fo.set(r,e),e}return t}var rt=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,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:e}=this;if(t!==Me)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Kc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Jt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&qo(t.multihash,n.multihash)}toString(t){return zo(this,t)}toJSON(){return{"/":zo(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??jo(n,o,s.bytes))}else if(e[kc]===!0){let{version:n,multihash:o,code:s}=e,i=te(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Me)throw new Error(`Version 0 CID must use dag-pb (code: ${Me}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=jo(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Me,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=Dt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new Ee(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,p]=Oe(t.subarray(e));return e+=p,l},o=n(),s=Me;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,c=n(),a=n(),u=e+a,f=u-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:f,size:u}}static parse(t,e){let[n,o]=Dc(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Qr(s).set(n,t),s}};function Dc(r,t){switch(r[0]){case"Q":{let e=t??W;return[W.prefix,e.decode(`${W.prefix}${r}`)]}case W.prefix:{let e=t??W;return[W.prefix,e.decode(r)]}case Nt.prefix:{let e=t??Nt;return[Nt.prefix,e.decode(r)]}case Ke.prefix:{let e=t??Ke;return[Ke.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Nc(r,t,e){let{prefix:n}=e;if(n!==W.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function Rc(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var Me=112,Kc=18;function jo(r,t,e){let n=we(r),o=n+we(t),s=new Uint8Array(o+e.byteLength);return be(r,s,0),be(t,s,n),s.set(e,o),s}var kc=Symbol.for("@ipld/js-cid/CID");var Jr={};gt(Jr,{identity:()=>It});var Go=0,Oc="identity",Zo=Dt;function Mc(r){return Jt(Go,Zo(r))}var It={code:Go,name:Oc,encode:Zo,digest:Mc};function yt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Rt(r=0){return new Uint8Array(r)}function pt(r=0){return new Uint8Array(r)}function bt(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=pt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var $o=Symbol.for("@achingbrain/uint8arraylist");function Wo(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function ar(r){return!!r?.[$o]}var wt=class r{bufs;length;[$o]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(ar(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(ar(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Wo(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Wo(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(ar(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return bt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:bt(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],c=o,a=c+i.byteLength;if(o=a,t>=a)continue;let u=t>=c&&t<a,f=e>c&&e<=a;if(u&&f){if(t===c&&e===a){n.push(i);break}let l=t-c;n.push(i.subarray(l,l+(e-t)));break}if(u){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(f){if(e===a){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!ar(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let c=i,a=this.byteLength-n.byteLength,u=n.byteLength-1,f;for(let l=e;l<=a;l+=f){f=0;for(let p=u;p>=0;p--){let w=this.get(l+p);if(n[p]!==w){f=Math.max(1,p-c[w]);break}}if(f===0)return l}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=pt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=Rt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=Rt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=Rt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=pt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=Rt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=Rt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=Rt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=Rt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=Rt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!yt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var tn={};gt(tn,{base10:()=>Hc});var Hc=Ft({prefix:"9",name:"base10",alphabet:"0123456789"});var en={};gt(en,{base16:()=>Vc,base16upper:()=>qc});var Vc=X({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),qc=X({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var rn={};gt(rn,{base2:()=>zc});var zc=X({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var nn={};gt(nn,{base256emoji:()=>Wc});var Yo=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}"),Fc=Yo.reduce((r,t,e)=>(r[e]=t,r),[]),jc=Yo.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Gc(r){return r.reduce((t,e)=>(t+=Fc[e],t),"")}function Zc(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=jc[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Wc=ye({prefix:"\u{1F680}",name:"base256emoji",encode:Gc,decode:Zc});var on={};gt(on,{base64:()=>$c,base64pad:()=>Yc,base64url:()=>Xc,base64urlpad:()=>Qc});var $c=X({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Yc=X({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Xc=X({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Qc=X({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var sn={};gt(sn,{base8:()=>Jc});var Jc=X({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var cn={};gt(cn,{identity:()=>ta});var ta=ye({prefix:"\0",name:"identity",encode:r=>Ro(r),decode:r=>No(r)});var ll=new TextEncoder,hl=new TextDecoder;var un={};gt(un,{sha256:()=>He,sha512:()=>na});function fn({name:r,code:t,encode:e}){return new an(r,t,e)}var an=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Jt(this.code,e):e.then(n=>Jt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Qo(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var He=fn({name:"sha2-256",code:18,encode:Qo("SHA-256")}),na=fn({name:"sha2-512",code:19,encode:Qo("SHA-512")});var Ve={...cn,...rn,...sn,...tn,...en,...$r,...Yr,...Wr,...on,...nn},Al={...un,...Jr};function ts(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Jo=ts("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ln=ts("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=pt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),oa={utf8:Jo,"utf-8":Jo,hex:Ve.base16,latin1:ln,ascii:ln,binary:ln,...Ve},fr=oa;function At(r,t="utf8"){let e=fr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function j(r,t="utf8"){let e=fr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var sa=parseInt("11111",2),hn=parseInt("10000000",2),ia=parseInt("01111111",2),es={0:qe,1:qe,2:ca,3:ua,4:la,5:fa,6:aa,16:qe,22:qe,48:qe};function dn(r,t={offset:0}){let e=r[t.offset]&sa;if(t.offset++,es[e]!=null)return es[e](r,t);throw new Error("No decoder for tag "+e)}function ze(r,t){let e=0;if((r[t.offset]&hn)===hn){let n=r[t.offset]&ia,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function qe(r,t){ze(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=dn(r,t);if(n===null)break;e.push(n)}return e}function ca(r,t){let e=ze(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function aa(r,t){let e=ze(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let c=`${s}.${i}`,a=[];for(;t.offset<n;){let u=r[t.offset];if(t.offset++,a.push(u&127),u<128){a.reverse();let f=0;for(let l=0;l<a.length;l++)f+=a[l]<<l*7;c+=`.${f}`,a=[]}}return c}function fa(r,t){return t.offset++,null}function ua(r,t){let e=ze(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function la(r,t){let e=ze(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function ha(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new wt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function pn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=ha(r.byteLength);return new wt(Uint8Array.from([t.byteLength|hn]),t)}function rs(r){let t=new wt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new wt(Uint8Array.from([2]),pn(t),t)}function ns(r){let t=Uint8Array.from([0]),e=new wt(t,r);return new wt(Uint8Array.from([3]),pn(e),e)}function ur(r,t=48){let e=new wt;for(let n of r)e.append(n);return new wt(Uint8Array.from([t]),pn(e),e)}async function os(r,t,e){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,e.subarray())}var da=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),pa=Uint8Array.from([6,5,43,129,4,0,34]),ma=Uint8Array.from([6,5,43,129,4,0,35]),xa={ext:!0,kty:"EC",crv:"P-256"},ga={ext:!0,kty:"EC",crv:"P-384"},ya={ext:!0,kty:"EC",crv:"P-521"},mn=32,xn=48,gn=66;function ss(r){let t=dn(r);return is(t)}function is(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===mn*2+1)return n=j(t.subarray(e,e+mn),"base64url"),o=j(t.subarray(e+mn),"base64url"),new Se({...xa,key_ops:["verify"],x:n,y:o});if(t.byteLength===xn*2+1)return n=j(t.subarray(e,e+xn),"base64url"),o=j(t.subarray(e+xn),"base64url"),new Se({...ga,key_ops:["verify"],x:n,y:o});if(t.byteLength===gn*2+1)return n=j(t.subarray(e,e+gn),"base64url"),o=j(t.subarray(e+gn),"base64url"),new Se({...ya,key_ops:["verify"],x:n,y:o});throw new Ct(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function cs(r){return ur([rs(Uint8Array.from([1])),ur([ba(r.crv)],160),ur([ns(new wt(Uint8Array.from([4]),At(r.x??"","base64url"),At(r.y??"","base64url")))],161)]).subarray()}function ba(r){if(r==="P-256")return da;if(r==="P-384")return pa;if(r==="P-521")return ma;throw new Ct(`Invalid curve ${r}`)}var Se=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 It.digest(ve(this))}toCID(){return rt.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}async verify(t,e){return os(this.jwk,e,t)}};var re=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function wa(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function lr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function ne(r,...t){if(!wa(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function as(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");lr(r.outputLen),lr(r.blockLen)}function Be(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function fs(r,t){ne(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function Kt(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function hr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Tt(r,t){return r<<32-t|r>>>t}function us(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function Fe(r){return typeof r=="string"&&(r=us(r)),ne(r),r}function yn(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];ne(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var Ae=class{};function bn(r){let t=n=>r().update(Fe(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function dr(r=32){if(re&&typeof re.getRandomValues=="function")return re.getRandomValues(new Uint8Array(r));if(re&&typeof re.randomBytes=="function")return Uint8Array.from(re.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function Ea(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),c=Number(e&s),a=n?4:0,u=n?0:4;r.setUint32(t+a,i,n),r.setUint32(t+u,c,n)}function ls(r,t,e){return r&t^~r&e}function hs(r,t,e){return r&t^r&e^t&e}var je=class extends Ae{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=hr(this.buffer)}update(t){Be(this),t=Fe(t),ne(t);let{view:e,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 a=hr(t);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Be(this),fs(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,Kt(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)e[l]=0;Ea(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=hr(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=a/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)c.setUint32(4*l,f[l],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,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%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},kt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ct=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var pr=BigInt(4294967295),ds=BigInt(32);function Sa(r,t=!1){return t?{h:Number(r&pr),l:Number(r>>ds&pr)}:{h:Number(r>>ds&pr)|0,l:Number(r&pr)|0}}function ps(r,t=!1){let e=r.length,n=new Uint32Array(e),o=new Uint32Array(e);for(let s=0;s<e;s++){let{h:i,l:c}=Sa(r[s],t);[n[s],o[s]]=[i,c]}return[n,o]}var wn=(r,t,e)=>r>>>e,En=(r,t,e)=>r<<32-e|t>>>e,oe=(r,t,e)=>r>>>e|t<<32-e,se=(r,t,e)=>r<<32-e|t>>>e,Ge=(r,t,e)=>r<<64-e|t>>>e-32,Ze=(r,t,e)=>r>>>e-32|t<<64-e;function Pt(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var ms=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),xs=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,gs=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),ys=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,bs=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),ws=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Aa=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]),jt=new Uint32Array(64),Sn=class extends je{constructor(t=32){super(64,t,8,!1),this.A=kt[0]|0,this.B=kt[1]|0,this.C=kt[2]|0,this.D=kt[3]|0,this.E=kt[4]|0,this.F=kt[5]|0,this.G=kt[6]|0,this.H=kt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[t,e,n,o,s,i,c,a]}set(t,e,n,o,s,i,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,e){for(let l=0;l<16;l++,e+=4)jt[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let p=jt[l-15],w=jt[l-2],E=Tt(p,7)^Tt(p,18)^p>>>3,x=Tt(w,17)^Tt(w,19)^w>>>10;jt[l]=x+jt[l-7]+E+jt[l-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:u,H:f}=this;for(let l=0;l<64;l++){let p=Tt(c,6)^Tt(c,11)^Tt(c,25),w=f+p+ls(c,a,u)+Aa[l]+jt[l]|0,x=(Tt(n,2)^Tt(n,13)^Tt(n,22))+hs(n,o,s)|0;f=u,u=a,a=c,c=i+w|0,i=s,s=o,o=n,n=w+x|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(n,o,s,i,c,a,u,f)}roundClean(){Kt(jt)}destroy(){this.set(0,0,0,0,0,0,0,0),Kt(this.buffer)}};var Es=ps(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Ba=Es[0],Ia=Es[1],Gt=new Uint32Array(80),Zt=new Uint32Array(80),vn=class extends je{constructor(t=64){super(128,t,16,!1),this.Ah=ct[0]|0,this.Al=ct[1]|0,this.Bh=ct[2]|0,this.Bl=ct[3]|0,this.Ch=ct[4]|0,this.Cl=ct[5]|0,this.Dh=ct[6]|0,this.Dl=ct[7]|0,this.Eh=ct[8]|0,this.El=ct[9]|0,this.Fh=ct[10]|0,this.Fl=ct[11]|0,this.Gh=ct[12]|0,this.Gl=ct[13]|0,this.Hh=ct[14]|0,this.Hl=ct[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:u,El:f,Fh:l,Fl:p,Gh:w,Gl:E,Hh:x,Hl:h}=this;return[t,e,n,o,s,i,c,a,u,f,l,p,w,E,x,h]}set(t,e,n,o,s,i,c,a,u,f,l,p,w,E,x,h){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=u|0,this.El=f|0,this.Fh=l|0,this.Fl=p|0,this.Gh=w|0,this.Gl=E|0,this.Hh=x|0,this.Hl=h|0}process(t,e){for(let m=0;m<16;m++,e+=4)Gt[m]=t.getUint32(e),Zt[m]=t.getUint32(e+=4);for(let m=16;m<80;m++){let I=Gt[m-15]|0,N=Zt[m-15]|0,_=oe(I,N,1)^oe(I,N,8)^wn(I,N,7),L=se(I,N,1)^se(I,N,8)^En(I,N,7),C=Gt[m-2]|0,P=Zt[m-2]|0,Z=oe(C,P,19)^Ge(C,P,61)^wn(C,P,6),V=se(C,P,19)^Ze(C,P,61)^En(C,P,6),k=gs(L,V,Zt[m-7],Zt[m-16]),et=ys(k,_,Z,Gt[m-7],Gt[m-16]);Gt[m]=et|0,Zt[m]=k|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:u,Dl:f,Eh:l,El:p,Fh:w,Fl:E,Gh:x,Gl:h,Hh:y,Hl:B}=this;for(let m=0;m<80;m++){let I=oe(l,p,14)^oe(l,p,18)^Ge(l,p,41),N=se(l,p,14)^se(l,p,18)^Ze(l,p,41),_=l&w^~l&x,L=p&E^~p&h,C=bs(B,N,L,Ia[m],Zt[m]),P=ws(C,y,I,_,Ba[m],Gt[m]),Z=C|0,V=oe(n,o,28)^Ge(n,o,34)^Ge(n,o,39),k=se(n,o,28)^Ze(n,o,34)^Ze(n,o,39),et=n&s^n&c^s&c,v=o&i^o&a^i&a;y=x|0,B=h|0,x=w|0,h=E|0,w=l|0,E=p|0,{h:l,l:p}=Pt(u|0,f|0,P|0,Z|0),u=c|0,f=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let T=ms(Z,k,v);n=xs(T,P,V,et),o=T|0}({h:n,l:o}=Pt(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=Pt(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=Pt(this.Ch|0,this.Cl|0,c|0,a|0),{h:u,l:f}=Pt(this.Dh|0,this.Dl|0,u|0,f|0),{h:l,l:p}=Pt(this.Eh|0,this.El|0,l|0,p|0),{h:w,l:E}=Pt(this.Fh|0,this.Fl|0,w|0,E|0),{h:x,l:h}=Pt(this.Gh|0,this.Gl|0,x|0,h|0),{h:y,l:B}=Pt(this.Hh|0,this.Hl|0,y|0,B|0),this.set(n,o,s,i,c,a,u,f,l,p,w,E,x,h,y,B)}roundClean(){Kt(Gt,Zt)}destroy(){Kt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Ss=bn(()=>new Sn);var vs=bn(()=>new vn);var Tn=BigInt(0),In=BigInt(1);function ie(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ln(r){if(!ie(r))throw new Error("Uint8Array expected")}function Ut(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function We(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Is(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Tn:BigInt("0x"+r)}var Ts=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Ta=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Wt(r){if(Ln(r),Ts)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=Ta[r[e]];return t}var Ot={_0:48,_9:57,A:65,F:70,a:97,f:102};function As(r){if(r>=Ot._0&&r<=Ot._9)return r-Ot._0;if(r>=Ot.A&&r<=Ot.F)return r-(Ot.A-10);if(r>=Ot.a&&r<=Ot.f)return r-(Ot.a-10)}function $e(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(Ts)return Uint8Array.fromHex(r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=As(r.charCodeAt(s)),c=As(r.charCodeAt(s+1));if(i===void 0||c===void 0){let a=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function Mt(r){return Is(Wt(r))}function ce(r){return Ln(r),Is(Wt(Uint8Array.from(r).reverse()))}function ae(r,t){return $e(r.toString(16).padStart(t*2,"0"))}function Ie(r,t){return ae(r,t).reverse()}function Y(r,t,e){let n;if(typeof t=="string")try{n=$e(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(ie(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function $t(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Ln(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var An=r=>typeof r=="bigint"&&Tn<=r;function mr(r,t,e){return An(r)&&An(t)&&An(e)&&t<=r&&r<e}function Et(r,t,e,n){if(!mr(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Ls(r){let t;for(t=0;r>Tn;r>>=In,t+=1);return t}var fe=r=>(In<<BigInt(r))-In,Bn=r=>new Uint8Array(r),Bs=r=>Uint8Array.from(r);function Cs(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=Bn(r),o=Bn(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...l)=>e(o,n,...l),a=(l=Bn(0))=>{o=c(Bs([0]),l),n=c(),l.length!==0&&(o=c(Bs([1]),l),n=c())},u=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l<t;){n=c();let w=n.slice();p.push(w),l+=n.length}return $t(...p)};return(l,p)=>{i(),a(l);let w;for(;!(w=p(u()));)a();return i(),w}}var La={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||ie(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Ht(r,t,e={}){let n=(o,s,i)=>{let c=La[s];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(i&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+a)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}function Te(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var lt=BigInt(0),nt=BigInt(1),ue=BigInt(2),Ca=BigInt(3),Cn=BigInt(4),Ps=BigInt(5),Us=BigInt(8),Pa=BigInt(9),Ua=BigInt(16);function F(r,t){let e=r%t;return e>=lt?e:t+e}function $(r,t,e){let n=r;for(;t-- >lt;)n*=n,n%=e;return n}function xr(r,t){if(r===lt)throw new Error("invert: expected non-zero number");if(t<=lt)throw new Error("invert: expected positive modulus, got "+t);let e=F(r,t),n=t,o=lt,s=nt,i=nt,c=lt;for(;e!==lt;){let u=n/e,f=n%e,l=o-i*u,p=s-c*u;n=e,e=f,o=i,s=c,i=l,c=p}if(n!==nt)throw new Error("invert: does not exist");return F(o,t)}function _a(r){let t=r-nt,e=0;for(;t%ue===lt;)t/=ue,e++;let n=ue,o=Vt(r);for(;n<r&&_s(o,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1){let i=(r+nt)/Cn;return function(a,u){let f=a.pow(u,i);if(!a.eql(a.sqr(f),u))throw new Error("Cannot find square root");return f}}let s=(t+nt)/ue;return function(c,a){if(!_s(c,a))throw new Error("Cannot find square root");let u=e,f=c.pow(c.mul(c.ONE,n),t),l=c.pow(a,s),p=c.pow(a,t);for(;!c.eql(p,c.ONE);){if(c.eql(p,c.ZERO))return c.ZERO;let w=1;for(let x=c.sqr(p);w<u&&!c.eql(x,c.ONE);w++)x=c.sqr(x);let E=c.pow(f,nt<<BigInt(u-w-1));f=c.sqr(E),l=c.mul(l,E),p=c.mul(p,f),u=w}return l}}function Da(r){return r%Cn===Ca?function(e,n){let o=(r+nt)/Cn,s=e.pow(n,o);if(!e.eql(e.sqr(s),n))throw new Error("Cannot find square root");return s}:r%Us===Ps?function(e,n){let o=e.mul(n,ue),s=(r-Ps)/Us,i=e.pow(o,s),c=e.mul(n,i),a=e.mul(e.mul(c,ue),i),u=e.mul(c,e.sub(a,e.ONE));if(!e.eql(e.sqr(u),n))throw new Error("Cannot find square root");return u}:(r%Ua,_a(r))}var Ds=(r,t)=>(F(r,t)&nt)===nt,Na=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Pn(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Na.reduce((n,o)=>(n[o]="function",n),t);return Ht(r,e)}function Ra(r,t,e){if(e<lt)throw new Error("invalid exponent, negatives unsupported");if(e===lt)return r.ONE;if(e===nt)return t;let n=r.ONE,o=t;for(;e>lt;)e&nt&&(n=r.mul(n,o)),o=r.sqr(o),e>>=nt;return n}function Le(r,t,e=!1){let n=new Array(t.length).fill(e?r.ZERO:void 0),o=t.reduce((i,c,a)=>r.is0(c)?i:(n[a]=i,r.mul(i,c)),r.ONE),s=r.inv(o);return t.reduceRight((i,c,a)=>r.is0(c)?i:(n[a]=r.mul(i,n[a]),r.mul(i,c)),s),n}function Ka(r,t){let e=(r.ORDER-nt)/ue,n=r.pow(t,e),o=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),i=r.eql(n,r.neg(r.ONE));if(!o&&!s&&!i)throw new Error("Cannot find square root: probably non-prime P");return o?1:s?0:-1}function _s(r,t){let e=Ka(r,t);return e===0||e===1}function Un(r,t){t!==void 0&&lr(t);let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Vt(r,t,e=!1,n={}){if(r<=lt)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=Un(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,c=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:fe(o),ZERO:lt,ONE:nt,create:a=>F(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return lt<=a&&a<r},is0:a=>a===lt,isOdd:a=>(a&nt)===nt,neg:a=>F(-a,r),eql:(a,u)=>a===u,sqr:a=>F(a*a,r),add:(a,u)=>F(a+u,r),sub:(a,u)=>F(a-u,r),mul:(a,u)=>F(a*u,r),pow:(a,u)=>Ra(c,a,u),div:(a,u)=>F(a*xr(u,r),r),sqrN:a=>a*a,addN:(a,u)=>a+u,subN:(a,u)=>a-u,mulN:(a,u)=>a*u,inv:a=>xr(a,r),sqrt:n.sqrt||(a=>(i||(i=Da(r)),i(c,a))),toBytes:a=>e?Ie(a,s):ae(a,s),fromBytes:a=>{if(a.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+a.length);return e?ce(a):Mt(a)},invertBatch:a=>Le(c,a),cmov:(a,u,f)=>f?u:a});return Object.freeze(c)}function Ns(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function _n(r){let t=Ns(r);return t+Math.ceil(t/2)}function Rs(r,t,e=!1){let n=r.length,o=Ns(t),s=_n(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?ce(r):Mt(r),c=F(i,t-nt)+nt;return e?Ie(c,o):ae(c,o)}var Ks=BigInt(0),kn=BigInt(1);function Dn(r,t){let e=t.negate();return r?e:t}function Os(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Nn(r,t){Os(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=fe(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function ks(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,c=Number(r&o),a=r>>i;c>n&&(c-=s,a+=kn);let u=t*n,f=u+Math.abs(c)-1,l=c===0,p=c<0,w=t%2!==0;return{nextN:a,offset:f,isZero:l,isNeg:p,isNegF:w,offsetF:u}}function ka(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function Oa(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var Rn=new WeakMap,Ms=new WeakMap;function Kn(r){return Ms.get(r)||1}function gr(r,t){return{constTimeNegate:Dn,hasPrecomputes(e){return Kn(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Ks;)n&kn&&(o=o.add(s)),s=s.double(),n>>=kn;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=Nn(n,t),i=[],c=e,a=c;for(let u=0;u<o;u++){a=c,i.push(a);for(let f=1;f<s;f++)a=a.add(c),i.push(a);c=a.double()}return i},wNAF(e,n,o){let s=r.ZERO,i=r.BASE,c=Nn(e,t);for(let a=0;a<c.windows;a++){let{nextN:u,offset:f,isZero:l,isNeg:p,isNegF:w,offsetF:E}=ks(o,a,c);o=u,l?i=i.add(Dn(w,n[E])):s=s.add(Dn(p,n[f]))}return{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=Nn(e,t);for(let c=0;c<i.windows&&o!==Ks;c++){let{nextN:a,offset:u,isZero:f,isNeg:l}=ks(o,c,i);if(o=a,!f){let p=n[u];s=s.add(l?p.negate():p)}}return s},getPrecomputes(e,n,o){let s=Rn.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&Rn.set(n,o(s))),s},wNAFCached(e,n,o){let s=Kn(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=Kn(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){Os(n,t),Ms.set(e,n),Rn.delete(e)}}}function yr(r,t,e,n){if(ka(e,r),Oa(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,s=Ls(BigInt(e.length)),i=s>12?s-3:s>4?s-2:s?2:1,c=fe(i),a=new Array(Number(c)+1).fill(o),u=Math.floor((t.BITS-1)/i)*i,f=o;for(let l=u;l>=0;l-=i){a.fill(o);for(let w=0;w<n.length;w++){let E=n[w],x=Number(E>>BigInt(l)&c);a[x]=a[x].add(e[w])}let p=o;for(let w=a.length-1,E=o;w>0;w--)E=E.add(a[w]),p=p.add(E);if(f=f.add(p),l!==0)for(let w=0;w<i;w++)f=f.double()}return f}function Ye(r){return Pn(r.Fp),Ht(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Un(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var _t=BigInt(0),ht=BigInt(1),Hs=BigInt(2),Ma=BigInt(8),Ha={zip215:!0};function Va(r){let t=Ye(r);return Ht(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Vs(r){let t=Va(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:c,h:a}=t,u=Hs<<BigInt(c*8)-ht,f=e.create,l=Vt(t.n,t.nBitLength),p=t.uvRatio||((g,d)=>{try{return{isValid:!0,value:e.sqrt(g*e.inv(d))}}catch{return{isValid:!1,value:_t}}}),w=t.adjustScalarBytes||(g=>g),E=t.domain||((g,d,b)=>{if(Ut("phflag",b),d.length||b)throw new Error("Contexts/pre-hash are not supported");return g});function x(g,d,b=!1){let A=b?ht:_t;Et("coordinate "+g,d,A,u)}function h(g){if(!(g instanceof m))throw new Error("ExtendedPoint expected")}let y=Te((g,d)=>{let{ex:b,ey:A,ez:R}=g,K=g.is0();d==null&&(d=K?Ma:e.inv(R));let O=f(b*d),M=f(A*d),H=f(R*d);if(K)return{x:_t,y:ht};if(H!==ht)throw new Error("invZ was invalid");return{x:O,y:M}}),B=Te(g=>{let{a:d,d:b}=t;if(g.is0())throw new Error("bad point: ZERO");let{ex:A,ey:R,ez:K,et:O}=g,M=f(A*A),H=f(R*R),z=f(K*K),tt=f(z*z),Q=f(M*d),it=f(z*f(Q+H)),dt=f(tt+f(b*f(M*H)));if(it!==dt)throw new Error("bad point: equation left != right (1)");let ot=f(A*R),at=f(K*O);if(ot!==at)throw new Error("bad point: equation left != right (2)");return!0});class m{constructor(d,b,A,R){x("x",d),x("y",b),x("z",A,!0),x("t",R),this.ex=d,this.ey=b,this.ez=A,this.et=R,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(d){if(d instanceof m)throw new Error("extended point not allowed");let{x:b,y:A}=d||{};return x("x",b),x("y",A),new m(b,A,ht,f(b*A))}static normalizeZ(d){let b=Le(e,d.map(A=>A.ez));return d.map((A,R)=>A.toAffine(b[R])).map(m.fromAffine)}static msm(d,b){return yr(m,l,d,b)}_setWindowSize(d){_.setWindowSize(this,d)}assertValidity(){B(this)}equals(d){h(d);let{ex:b,ey:A,ez:R}=this,{ex:K,ey:O,ez:M}=d,H=f(b*M),z=f(K*R),tt=f(A*M),Q=f(O*R);return H===z&&tt===Q}is0(){return this.equals(m.ZERO)}negate(){return new m(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:d}=t,{ex:b,ey:A,ez:R}=this,K=f(b*b),O=f(A*A),M=f(Hs*f(R*R)),H=f(d*K),z=b+A,tt=f(f(z*z)-K-O),Q=H+O,it=Q-M,dt=H-O,ot=f(tt*it),at=f(Q*dt),xt=f(tt*dt),Bt=f(it*Q);return new m(ot,at,Bt,xt)}add(d){h(d);let{a:b,d:A}=t,{ex:R,ey:K,ez:O,et:M}=this,{ex:H,ey:z,ez:tt,et:Q}=d,it=f(R*H),dt=f(K*z),ot=f(M*A*Q),at=f(O*tt),xt=f((R+K)*(H+z)-it-dt),Bt=at-ot,Ne=at+ot,Po=f(dt-b*it),ji=f(xt*Bt),Gi=f(Ne*Po),Zi=f(xt*Po),Wi=f(Bt*Ne);return new m(ji,Gi,Wi,Zi)}subtract(d){return this.add(d.negate())}wNAF(d){return _.wNAFCached(this,d,m.normalizeZ)}multiply(d){let b=d;Et("scalar",b,ht,n);let{p:A,f:R}=this.wNAF(b);return m.normalizeZ([A,R])[0]}multiplyUnsafe(d,b=m.ZERO){let A=d;return Et("scalar",A,_t,n),A===_t?N:this.is0()||A===ht?this:_.wNAFCachedUnsafe(this,A,m.normalizeZ,b)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return _.unsafeLadder(this,n).is0()}toAffine(d){return y(this,d)}clearCofactor(){let{h:d}=t;return d===ht?this:this.multiplyUnsafe(d)}static fromHex(d,b=!1){let{d:A,a:R}=t,K=e.BYTES;d=Y("pointHex",d,K),Ut("zip215",b);let O=d.slice(),M=d[K-1];O[K-1]=M&-129;let H=ce(O),z=b?u:e.ORDER;Et("pointHex.y",H,_t,z);let tt=f(H*H),Q=f(tt-ht),it=f(A*tt-R),{isValid:dt,value:ot}=p(Q,it);if(!dt)throw new Error("Point.fromHex: invalid y coordinate");let at=(ot&ht)===ht,xt=(M&128)!==0;if(!b&&ot===_t&&xt)throw new Error("Point.fromHex: x=0 and x_0=1");return xt!==at&&(ot=f(-ot)),m.fromAffine({x:ot,y:H})}static fromPrivateKey(d){let{scalar:b}=P(d);return I.multiply(b)}toRawBytes(){let{x:d,y:b}=this.toAffine(),A=Ie(b,e.BYTES);return A[A.length-1]|=d&ht?128:0,A}toHex(){return Wt(this.toRawBytes())}}m.BASE=new m(t.Gx,t.Gy,ht,f(t.Gx*t.Gy)),m.ZERO=new m(_t,ht,ht,_t);let{BASE:I,ZERO:N}=m,_=gr(m,c*8);function L(g){return F(g,n)}function C(g){return L(ce(g))}function P(g){let d=e.BYTES;g=Y("private key",g,d);let b=Y("hashed private key",s(g),2*d),A=w(b.slice(0,d)),R=b.slice(d,2*d),K=C(A);return{head:A,prefix:R,scalar:K}}function Z(g){let{head:d,prefix:b,scalar:A}=P(g),R=I.multiply(A),K=R.toRawBytes();return{head:d,prefix:b,scalar:A,point:R,pointBytes:K}}function V(g){return Z(g).pointBytes}function k(g=Uint8Array.of(),...d){let b=$t(...d);return C(s(E(b,Y("context",g),!!o)))}function et(g,d,b={}){g=Y("message",g),o&&(g=o(g));let{prefix:A,scalar:R,pointBytes:K}=Z(d),O=k(b.context,A,g),M=I.multiply(O).toRawBytes(),H=k(b.context,M,K,g),z=L(O+H*R);Et("signature.s",z,_t,n);let tt=$t(M,Ie(z,e.BYTES));return Y("result",tt,e.BYTES*2)}let v=Ha;function T(g,d,b,A=v){let{context:R,zip215:K}=A,O=e.BYTES;g=Y("signature",g,2*O),d=Y("message",d),b=Y("publicKey",b,O),K!==void 0&&Ut("zip215",K),o&&(d=o(d));let M=ce(g.slice(O,2*O)),H,z,tt;try{H=m.fromHex(b,K),z=m.fromHex(g.slice(0,O),K),tt=I.multiplyUnsafe(M)}catch{return!1}if(!K&&H.isSmallOrder())return!1;let Q=k(R,z.toRawBytes(),H.toRawBytes(),d);return z.add(H.multiplyUnsafe(Q)).subtract(tt).clearCofactor().equals(m.ZERO)}return I._setWindowSize(8),{CURVE:t,getPublicKey:V,sign:et,verify:T,ExtendedPoint:m,utils:{getExtendedPublicKey:Z,randomPrivateKey:()=>i(e.BYTES),precompute(g=8,d=m.BASE){return d._setWindowSize(g),d.multiply(BigInt(3)),d}}}}var On=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),qs=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Th=BigInt(0),qa=BigInt(1),zs=BigInt(2),Lh=BigInt(3),za=BigInt(5),Fa=BigInt(8);function ja(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=On,c=r*r%s*r%s,a=$(c,zs,s)*c%s,u=$(a,qa,s)*r%s,f=$(u,za,s)*u%s,l=$(f,t,s)*f%s,p=$(l,e,s)*l%s,w=$(p,n,s)*p%s,E=$(w,o,s)*w%s,x=$(E,o,s)*w%s,h=$(x,t,s)*f%s;return{pow_p_5_8:$(h,zs,s)*r%s,b2:c}}function Ga(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Za(r,t){let e=On,n=F(t*t*t,e),o=F(n*n*t,e),s=ja(r*o).pow_p_5_8,i=F(r*n*s,e),c=F(t*i*i,e),a=i,u=F(i*qs,e),f=c===r,l=c===F(-r,e),p=c===F(-r*qs,e);return f&&(i=a),(l||p)&&(i=u),Ds(i,e)&&(i=F(-i,e)),{isValid:f||l,value:i}}var Fs=Vt(On,void 0,!0),Wa={a:Fs.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Fs,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Fa,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:vs,randomBytes:dr,adjustScalarBytes:Ga,uvRatio:Za},js=Vs(Wa);var br=32;function Gs(r,t,e){return js.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var wr=class{type="Ed25519";raw;constructor(t){this.raw=Mn(t,br)}toMultihash(){return It.digest(ve(this))}toCID(){return rt.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}verify(t,e){return Gs(this.raw,e,t)}};function Ws(r){return r=Mn(r,br),new wr(r)}function Mn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new Ct(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var Ya=Math.pow(2,7),Xa=Math.pow(2,14),Qa=Math.pow(2,21),Hn=Math.pow(2,28),Vn=Math.pow(2,35),qn=Math.pow(2,42),zn=Math.pow(2,49),q=128,ft=127;function mt(r){if(r<Ya)return 1;if(r<Xa)return 2;if(r<Qa)return 3;if(r<Hn)return 4;if(r<Vn)return 5;if(r<qn)return 6;if(r<zn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Fn(r,t,e=0){switch(mt(r)){case 8:t[e++]=r&255|q,r/=128;case 7:t[e++]=r&255|q,r/=128;case 6:t[e++]=r&255|q,r/=128;case 5:t[e++]=r&255|q,r/=128;case 4:t[e++]=r&255|q,r>>>=7;case 3:t[e++]=r&255|q,r>>>=7;case 2:t[e++]=r&255|q,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Ja(r,t,e=0){switch(mt(r)){case 8:t.set(e++,r&255|q),r/=128;case 7:t.set(e++,r&255|q),r/=128;case 6:t.set(e++,r&255|q),r/=128;case 5:t.set(e++,r&255|q),r/=128;case 4:t.set(e++,r&255|q),r>>>=7;case 3:t.set(e++,r&255|q),r>>>=7;case 2:t.set(e++,r&255|q),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function jn(r,t){let e=r[t],n=0;if(n+=e&ft,e<q||(e=r[t+1],n+=(e&ft)<<7,e<q)||(e=r[t+2],n+=(e&ft)<<14,e<q)||(e=r[t+3],n+=(e&ft)<<21,e<q)||(e=r[t+4],n+=(e&ft)*Hn,e<q)||(e=r[t+5],n+=(e&ft)*Vn,e<q)||(e=r[t+6],n+=(e&ft)*qn,e<q)||(e=r[t+7],n+=(e&ft)*zn,e<q))return n;throw new RangeError("Could not decode varint")}function tf(r,t){let e=r.get(t),n=0;if(n+=e&ft,e<q||(e=r.get(t+1),n+=(e&ft)<<7,e<q)||(e=r.get(t+2),n+=(e&ft)<<14,e<q)||(e=r.get(t+3),n+=(e&ft)<<21,e<q)||(e=r.get(t+4),n+=(e&ft)*Hn,e<q)||(e=r.get(t+5),n+=(e&ft)*Vn,e<q)||(e=r.get(t+6),n+=(e&ft)*qn,e<q)||(e=r.get(t+7),n+=(e&ft)*zn,e<q))return n;throw new RangeError("Could not decode varint")}function Ce(r,t,e=0){return t==null&&(t=pt(mt(r))),t instanceof Uint8Array?Fn(r,t,e):Ja(r,t,e)}function le(r,t=0){return r instanceof Uint8Array?jn(r,t):tf(r,t)}var Gn=new Float32Array([-0]),Yt=new Uint8Array(Gn.buffer);function Ys(r,t,e){Gn[0]=r,t[e]=Yt[0],t[e+1]=Yt[1],t[e+2]=Yt[2],t[e+3]=Yt[3]}function Xs(r,t){return Yt[0]=r[t],Yt[1]=r[t+1],Yt[2]=r[t+2],Yt[3]=r[t+3],Gn[0]}var Zn=new Float64Array([-0]),ut=new Uint8Array(Zn.buffer);function Qs(r,t,e){Zn[0]=r,t[e]=ut[0],t[e+1]=ut[1],t[e+2]=ut[2],t[e+3]=ut[3],t[e+4]=ut[4],t[e+5]=ut[5],t[e+6]=ut[6],t[e+7]=ut[7]}function Js(r,t){return ut[0]=r[t],ut[1]=r[t+1],ut[2]=r[t+2],ut[3]=r[t+3],ut[4]=r[t+4],ut[5]=r[t+5],ut[6]=r[t+6],ut[7]=r[t+7],Zn[0]}var ef=BigInt(Number.MAX_SAFE_INTEGER),rf=BigInt(Number.MIN_SAFE_INTEGER),St=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return he;if(t<ef&&t>rf)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>ti&&(o=0n,++n>ti&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return he;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):he}},he=new St(0,0);he.toBigInt=function(){return 0n};he.zzEncode=he.zzDecode=function(){return this};he.length=function(){return 1};var ti=4294967296n;function ei(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function ri(r,t,e){if(e-t<1)return"";let o,s=[],i=0,c;for(;t<e;)c=r[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function Wn(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function Lt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Er(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var $n=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,Lt(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 Lt(this,4);return Er(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Lt(this,4);return Er(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Lt(this,4);let t=Xs(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Lt(this,4);let t=Js(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Lt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return ri(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Lt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Lt(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 St(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw Lt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw Lt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Lt(this,8);let t=Er(this.buf,this.pos+=4),e=Er(this.buf,this.pos+=4);return new St(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=jn(this.buf,this.pos);return this.pos+=mt(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 Yn(r){return new $n(r instanceof Uint8Array?r:r.subarray())}function Sr(r,t,e){let n=Yn(r);return t.decode(n,void 0,e)}function Xn(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return pt(i);o+i>t&&(n=pt(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var de=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Qn(){}var to=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},nf=Xn();function of(r){return globalThis.Buffer!=null?pt(r):nf(r)}var Qe=class{len;head;tail;states;constructor(){this.len=0,this.head=new de(Qn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new de(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new eo((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(vr,10,St.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=St.fromBigInt(t);return this._push(vr,e.length(),e)}uint64Number(t){return this._push(Fn,mt(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=St.fromBigInt(t).zzEncode();return this._push(vr,e.length(),e)}sint64Number(t){let e=St.fromNumber(t).zzEncode();return this._push(vr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Jn,1,t?1:0)}fixed32(t){return this._push(Xe,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=St.fromBigInt(t);return this._push(Xe,4,e.lo)._push(Xe,4,e.hi)}fixed64Number(t){let e=St.fromNumber(t);return this._push(Xe,4,e.lo)._push(Xe,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Ys,4,t)}double(t){return this._push(Qs,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Jn,1,0):this.uint32(e)._push(cf,e,t)}string(t){let e=ei(t);return e!==0?this.uint32(e)._push(Wn,e,t):this._push(Jn,1,0)}fork(){return this.states=new to(this),this.head=this.tail=new de(Qn,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new de(Qn,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=of(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Jn(r,t,e){t[e]=r&255}function sf(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var eo=class extends de{next;constructor(t,e){super(sf,t,e),this.next=void 0}};function vr(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Xe(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function cf(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Qe.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(af,t,r),this},Qe.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(ff,t,r),this});function af(r,t,e){t.set(r,e)}function ff(r,t,e){r.length<40?Wn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(At(r),e)}function ro(){return new Qe}function Ar(r,t){let e=ro();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Pe;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Pe||(Pe={}));function Br(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function no(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let c=t(s);i.int32(c)},n=function(s){let i=s.int32();return t(i)};return Br("enum",Pe.VARINT,e,n)}function Ir(r,t){return Br("message",Pe.LENGTH_DELIMITED,r,t)}var vt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(vt||(vt={}));var oo;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(oo||(oo={}));(function(r){r.codec=()=>no(oo)})(vt||(vt={}));var Je;(function(r){let t;r.codec=()=>(t==null&&(t=Ir((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),vt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=vt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>Ar(e,r.codec()),r.decode=(e,n)=>Sr(e,r.codec(),n)})(Je||(Je={}));var so;(function(r){let t;r.codec=()=>(t==null&&(t=Ir((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),vt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=vt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>Ar(e,r.codec()),r.decode=(e,n)=>Sr(e,r.codec(),n)})(so||(so={}));var tr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var Tr=class extends Ae{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,as(t);let n=Fe(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),Kt(s)}update(t){return Be(this),this.iHash.update(t),this}digestInto(t){Be(this),ne(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,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=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},io=(r,t,e)=>new Tr(r,t).update(e).digest();io.create=(r,t)=>new Tr(r,t);function oi(r){r.lowS!==void 0&&Ut("lowS",r.lowS),r.prehash!==void 0&&Ut("prehash",r.prehash)}function lf(r){let t=Ye(r);Ht(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var co=class extends Error{constructor(t=""){super(t)}},qt={Err:co,_tlv:{encode:(r,t)=>{let{Err:e}=qt;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=We(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?We(o.length/2|128):"";return We(r)+s+o+t},decode(r,t){let{Err:e}=qt,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let a=o&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let u=t.subarray(n,n+a);if(u.length!==a)throw new e("tlv.decode: length bytes not complete");if(u[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let f of u)i=i<<8|f;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=qt;if(r<zt)throw new t("integer: negative integers are not allowed");let e=We(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=qt;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Mt(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=qt,o=Y("signature",r),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:u,l:f}=n.decode(2,a);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(u)}},hexFromSig(r){let{_tlv:t,_int:e}=qt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},zt=BigInt(0),st=BigInt(1),Ud=BigInt(2),si=BigInt(3),_d=BigInt(4);function hf(r){let t=lf(r),{Fp:e}=t,n=Vt(t.n,t.nBitLength),o=t.toBytes||((x,h,y)=>{let B=h.toAffine();return $t(Uint8Array.from([4]),e.toBytes(B.x),e.toBytes(B.y))}),s=t.fromBytes||(x=>{let h=x.subarray(1),y=e.fromBytes(h.subarray(0,e.BYTES)),B=e.fromBytes(h.subarray(e.BYTES,2*e.BYTES));return{x:y,y:B}});function i(x){let{a:h,b:y}=t,B=e.sqr(x),m=e.mul(B,x);return e.add(e.add(m,e.mul(x,h)),y)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function c(x){return mr(x,st,t.n)}function a(x){let{allowedPrivateKeyLengths:h,nByteLength:y,wrapPrivateKey:B,n:m}=t;if(h&&typeof x!="bigint"){if(ie(x)&&(x=Wt(x)),typeof x!="string"||!h.includes(x.length))throw new Error("invalid private key");x=x.padStart(y*2,"0")}let I;try{I=typeof x=="bigint"?x:Mt(Y("private key",x,y))}catch{throw new Error("invalid private key, expected hex or "+y+" bytes, got "+typeof x)}return B&&(I=F(I,m)),Et("private key",I,st,m),I}function u(x){if(!(x instanceof p))throw new Error("ProjectivePoint expected")}let f=Te((x,h)=>{let{px:y,py:B,pz:m}=x;if(e.eql(m,e.ONE))return{x:y,y:B};let I=x.is0();h==null&&(h=I?e.ONE:e.inv(m));let N=e.mul(y,h),_=e.mul(B,h),L=e.mul(m,h);if(I)return{x:e.ZERO,y:e.ZERO};if(!e.eql(L,e.ONE))throw new Error("invZ was invalid");return{x:N,y:_}}),l=Te(x=>{if(x.is0()){if(t.allowInfinityPoint&&!e.is0(x.py))return;throw new Error("bad point: ZERO")}let{x:h,y}=x.toAffine();if(!e.isValid(h)||!e.isValid(y))throw new Error("bad point: x or y not FE");let B=e.sqr(y),m=i(h);if(!e.eql(B,m))throw new Error("bad point: equation left != right");if(!x.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class p{constructor(h,y,B){if(h==null||!e.isValid(h))throw new Error("x required");if(y==null||!e.isValid(y)||e.is0(y))throw new Error("y required");if(B==null||!e.isValid(B))throw new Error("z required");this.px=h,this.py=y,this.pz=B,Object.freeze(this)}static fromAffine(h){let{x:y,y:B}=h||{};if(!h||!e.isValid(y)||!e.isValid(B))throw new Error("invalid affine point");if(h instanceof p)throw new Error("projective point not allowed");let m=I=>e.eql(I,e.ZERO);return m(y)&&m(B)?p.ZERO:new p(y,B,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let y=Le(e,h.map(B=>B.pz));return h.map((B,m)=>B.toAffine(y[m])).map(p.fromAffine)}static fromHex(h){let y=p.fromAffine(s(Y("pointHex",h)));return y.assertValidity(),y}static fromPrivateKey(h){return p.BASE.multiply(a(h))}static msm(h,y){return yr(p,n,h,y)}_setWindowSize(h){E.setWindowSize(this,h)}assertValidity(){l(this)}hasEvenY(){let{y:h}=this.toAffine();if(e.isOdd)return!e.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){u(h);let{px:y,py:B,pz:m}=this,{px:I,py:N,pz:_}=h,L=e.eql(e.mul(y,_),e.mul(I,m)),C=e.eql(e.mul(B,_),e.mul(N,m));return L&&C}negate(){return new p(this.px,e.neg(this.py),this.pz)}double(){let{a:h,b:y}=t,B=e.mul(y,si),{px:m,py:I,pz:N}=this,_=e.ZERO,L=e.ZERO,C=e.ZERO,P=e.mul(m,m),Z=e.mul(I,I),V=e.mul(N,N),k=e.mul(m,I);return k=e.add(k,k),C=e.mul(m,N),C=e.add(C,C),_=e.mul(h,C),L=e.mul(B,V),L=e.add(_,L),_=e.sub(Z,L),L=e.add(Z,L),L=e.mul(_,L),_=e.mul(k,_),C=e.mul(B,C),V=e.mul(h,V),k=e.sub(P,V),k=e.mul(h,k),k=e.add(k,C),C=e.add(P,P),P=e.add(C,P),P=e.add(P,V),P=e.mul(P,k),L=e.add(L,P),V=e.mul(I,N),V=e.add(V,V),P=e.mul(V,k),_=e.sub(_,P),C=e.mul(V,Z),C=e.add(C,C),C=e.add(C,C),new p(_,L,C)}add(h){u(h);let{px:y,py:B,pz:m}=this,{px:I,py:N,pz:_}=h,L=e.ZERO,C=e.ZERO,P=e.ZERO,Z=t.a,V=e.mul(t.b,si),k=e.mul(y,I),et=e.mul(B,N),v=e.mul(m,_),T=e.add(y,B),U=e.add(I,N);T=e.mul(T,U),U=e.add(k,et),T=e.sub(T,U),U=e.add(y,m);let g=e.add(I,_);return U=e.mul(U,g),g=e.add(k,v),U=e.sub(U,g),g=e.add(B,m),L=e.add(N,_),g=e.mul(g,L),L=e.add(et,v),g=e.sub(g,L),P=e.mul(Z,U),L=e.mul(V,v),P=e.add(L,P),L=e.sub(et,P),P=e.add(et,P),C=e.mul(L,P),et=e.add(k,k),et=e.add(et,k),v=e.mul(Z,v),U=e.mul(V,U),et=e.add(et,v),v=e.sub(k,v),v=e.mul(Z,v),U=e.add(U,v),k=e.mul(et,U),C=e.add(C,k),k=e.mul(g,U),L=e.mul(T,L),L=e.sub(L,k),k=e.mul(T,et),P=e.mul(g,P),P=e.add(P,k),new p(L,C,P)}subtract(h){return this.add(h.negate())}is0(){return this.equals(p.ZERO)}wNAF(h){return E.wNAFCached(this,h,p.normalizeZ)}multiplyUnsafe(h){let{endo:y,n:B}=t;Et("scalar",h,zt,B);let m=p.ZERO;if(h===zt)return m;if(this.is0()||h===st)return this;if(!y||E.hasPrecomputes(this))return E.wNAFCachedUnsafe(this,h,p.normalizeZ);let{k1neg:I,k1:N,k2neg:_,k2:L}=y.splitScalar(h),C=m,P=m,Z=this;for(;N>zt||L>zt;)N&st&&(C=C.add(Z)),L&st&&(P=P.add(Z)),Z=Z.double(),N>>=st,L>>=st;return I&&(C=C.negate()),_&&(P=P.negate()),P=new p(e.mul(P.px,y.beta),P.py,P.pz),C.add(P)}multiply(h){let{endo:y,n:B}=t;Et("scalar",h,st,B);let m,I;if(y){let{k1neg:N,k1:_,k2neg:L,k2:C}=y.splitScalar(h),{p:P,f:Z}=this.wNAF(_),{p:V,f:k}=this.wNAF(C);P=E.constTimeNegate(N,P),V=E.constTimeNegate(L,V),V=new p(e.mul(V.px,y.beta),V.py,V.pz),m=P.add(V),I=Z.add(k)}else{let{p:N,f:_}=this.wNAF(h);m=N,I=_}return p.normalizeZ([m,I])[0]}multiplyAndAddUnsafe(h,y,B){let m=p.BASE,I=(_,L)=>L===zt||L===st||!_.equals(m)?_.multiplyUnsafe(L):_.multiply(L),N=I(this,y).add(I(h,B));return N.is0()?void 0:N}toAffine(h){return f(this,h)}isTorsionFree(){let{h,isTorsionFree:y}=t;if(h===st)return!0;if(y)return y(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:y}=t;return h===st?this:y?y(p,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return Ut("isCompressed",h),this.assertValidity(),o(p,this,h)}toHex(h=!0){return Ut("isCompressed",h),Wt(this.toRawBytes(h))}}p.BASE=new p(t.Gx,t.Gy,e.ONE),p.ZERO=new p(e.ZERO,e.ONE,e.ZERO);let w=t.nBitLength,E=gr(p,t.endo?Math.ceil(w/2):w);return{CURVE:t,ProjectivePoint:p,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:c}}function df(r){let t=Ye(r);return Ht(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function ii(r){let t=df(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(v){return F(v,n)}function c(v){return xr(v,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:u,weierstrassEquation:f,isWithinCurveOrder:l}=hf({...t,toBytes(v,T,U){let g=T.toAffine(),d=e.toBytes(g.x),b=$t;return Ut("isCompressed",U),U?b(Uint8Array.from([T.hasEvenY()?2:3]),d):b(Uint8Array.from([4]),d,e.toBytes(g.y))},fromBytes(v){let T=v.length,U=v[0],g=v.subarray(1);if(T===o&&(U===2||U===3)){let d=Mt(g);if(!mr(d,st,e.ORDER))throw new Error("Point is not on curve");let b=f(d),A;try{A=e.sqrt(b)}catch(O){let M=O instanceof Error?": "+O.message:"";throw new Error("Point is not on curve"+M)}let R=(A&st)===st;return(U&1)===1!==R&&(A=e.neg(A)),{x:d,y:A}}else if(T===s&&U===4){let d=e.fromBytes(g.subarray(0,e.BYTES)),b=e.fromBytes(g.subarray(e.BYTES,2*e.BYTES));return{x:d,y:b}}else{let d=o,b=s;throw new Error("invalid Point, expected length of "+d+", or uncompressed "+b+", got "+T)}}}),p=v=>Wt(ae(v,t.nByteLength));function w(v){let T=n>>st;return v>T}function E(v){return w(v)?i(-v):v}let x=(v,T,U)=>Mt(v.slice(T,U));class h{constructor(T,U,g){Et("r",T,st,n),Et("s",U,st,n),this.r=T,this.s=U,g!=null&&(this.recovery=g),Object.freeze(this)}static fromCompact(T){let U=t.nByteLength;return T=Y("compactSignature",T,U*2),new h(x(T,0,U),x(T,U,2*U))}static fromDER(T){let{r:U,s:g}=qt.toSig(Y("DER",T));return new h(U,g)}assertValidity(){}addRecoveryBit(T){return new h(this.r,this.s,T)}recoverPublicKey(T){let{r:U,s:g,recovery:d}=this,b=_(Y("msgHash",T));if(d==null||![0,1,2,3].includes(d))throw new Error("recovery id invalid");let A=d===2||d===3?U+t.n:U;if(A>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let R=(d&1)===0?"02":"03",K=a.fromHex(R+p(A)),O=c(A),M=i(-b*O),H=i(g*O),z=a.BASE.multiplyAndAddUnsafe(K,M,H);if(!z)throw new Error("point at infinify");return z.assertValidity(),z}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return $e(this.toDERHex())}toDERHex(){return qt.hexFromSig(this)}toCompactRawBytes(){return $e(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let y={isValidPrivateKey(v){try{return u(v),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let v=_n(t.n);return Rs(t.randomBytes(v),t.n)},precompute(v=8,T=a.BASE){return T._setWindowSize(v),T.multiply(BigInt(3)),T}};function B(v,T=!0){return a.fromPrivateKey(v).toRawBytes(T)}function m(v){let T=ie(v),U=typeof v=="string",g=(T||U)&&v.length;return T?g===o||g===s:U?g===2*o||g===2*s:v instanceof a}function I(v,T,U=!0){if(m(v))throw new Error("first arg must be private key");if(!m(T))throw new Error("second arg must be public key");return a.fromHex(T).multiply(u(v)).toRawBytes(U)}let N=t.bits2int||function(v){if(v.length>8192)throw new Error("input is too large");let T=Mt(v),U=v.length*8-t.nBitLength;return U>0?T>>BigInt(U):T},_=t.bits2int_modN||function(v){return i(N(v))},L=fe(t.nBitLength);function C(v){return Et("num < 2^"+t.nBitLength,v,zt,L),ae(v,t.nByteLength)}function P(v,T,U=Z){if(["recovered","canonical"].some(Q=>Q in U))throw new Error("sign() legacy options not supported");let{hash:g,randomBytes:d}=t,{lowS:b,prehash:A,extraEntropy:R}=U;b==null&&(b=!0),v=Y("msgHash",v),oi(U),A&&(v=Y("prehashed msgHash",g(v)));let K=_(v),O=u(T),M=[C(O),C(K)];if(R!=null&&R!==!1){let Q=R===!0?d(e.BYTES):R;M.push(Y("extraEntropy",Q))}let H=$t(...M),z=K;function tt(Q){let it=N(Q);if(!l(it))return;let dt=c(it),ot=a.BASE.multiply(it).toAffine(),at=i(ot.x);if(at===zt)return;let xt=i(dt*i(z+at*O));if(xt===zt)return;let Bt=(ot.x===at?0:2)|Number(ot.y&st),Ne=xt;return b&&w(xt)&&(Ne=E(xt),Bt^=1),new h(at,Ne,Bt)}return{seed:H,k2sig:tt}}let Z={lowS:t.lowS,prehash:!1},V={lowS:t.lowS,prehash:!1};function k(v,T,U=Z){let{seed:g,k2sig:d}=P(v,T,U),b=t;return Cs(b.hash.outputLen,b.nByteLength,b.hmac)(g,d)}a.BASE._setWindowSize(8);function et(v,T,U,g=V){let d=v;T=Y("msgHash",T),U=Y("publicKey",U);let{lowS:b,prehash:A,format:R}=g;if(oi(g),"strict"in g)throw new Error("options.strict was renamed to lowS");if(R!==void 0&&R!=="compact"&&R!=="der")throw new Error("format must be compact or der");let K=typeof d=="string"||ie(d),O=!K&&!R&&typeof d=="object"&&d!==null&&typeof d.r=="bigint"&&typeof d.s=="bigint";if(!K&&!O)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let M,H;try{if(O&&(M=new h(d.r,d.s)),K){try{R!=="compact"&&(M=h.fromDER(d))}catch(Bt){if(!(Bt instanceof qt.Err))throw Bt}!M&&R!=="der"&&(M=h.fromCompact(d))}H=a.fromHex(U)}catch{return!1}if(!M||b&&M.hasHighS())return!1;A&&(T=t.hash(T));let{r:z,s:tt}=M,Q=_(T),it=c(tt),dt=i(Q*it),ot=i(z*it),at=a.BASE.multiplyAndAddUnsafe(H,dt,ot)?.toAffine();return at?i(at.x)===z:!1}return{CURVE:t,getPublicKey:B,getSharedSecret:I,sign:k,verify:et,ProjectivePoint:a,Signature:h,utils:y}}function pf(r){return{hash:r,hmac:(t,...e)=>io(r,t,yn(...e)),randomBytes:dr}}function ci(r,t){let e=n=>ii({...r,...pf(n)});return{...e(t),create:e}}var ui=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ai=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),mf=BigInt(1),ao=BigInt(2),fi=(r,t)=>(r+t/ao)/t;function xf(r){let t=ui,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),u=r*r*r%t,f=u*u*r%t,l=$(f,e,t)*f%t,p=$(l,e,t)*f%t,w=$(p,ao,t)*u%t,E=$(w,o,t)*w%t,x=$(E,s,t)*E%t,h=$(x,c,t)*x%t,y=$(h,a,t)*h%t,B=$(y,c,t)*x%t,m=$(B,e,t)*f%t,I=$(m,i,t)*E%t,N=$(I,n,t)*u%t,_=$(N,ao,t);if(!fo.eql(fo.sqr(_),r))throw new Error("Cannot find square root");return _}var fo=Vt(ui,void 0,void 0,{sqrt:xf}),pe=ci({a:BigInt(0),b:BigInt(7),Fp:fo,n:ai,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=ai,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-mf*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=fi(s*r,t),a=fi(-n*r,t),u=F(r-c*e-a*o,t),f=F(-c*n-a*s,t),l=u>i,p=f>i;if(l&&(u=t-u),p&&(f=t-f),u>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:u,k2neg:p,k2:f}}}},Ss),Vd=BigInt(0);var qd=pe.ProjectivePoint;function li(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function hi(r,t,e){let n=He.digest(e instanceof Uint8Array?e:e.subarray());if(li(n))return n.then(({digest:o})=>pe.verify(t,o,r)).catch(o=>{throw new tr(String(o))});try{return pe.verify(t,n.digest,r)}catch(o){throw new tr(String(o))}}var Lr=class{type="secp256k1";raw;_key;constructor(t){this._key=pi(t),this.raw=di(this._key)}toMultihash(){return It.digest(ve(this))}toCID(){return rt.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}verify(t,e){return hi(this._key,e,t)}};function mi(r){return new Lr(r)}function di(r){return pe.ProjectivePoint.fromHex(r).toRawBytes(!0)}function pi(r){try{return pe.ProjectivePoint.fromHex(r),r}catch(t){throw new nr(String(t))}}function xi(r){let{Type:t,Data:e}=Je.decode(r.digest),n=e??new Uint8Array;switch(t){case vt.Ed25519:return Ws(n);case vt.secp256k1:return mi(n);case vt.ECDSA:return ss(n);default:throw new Re}}function ve(r){return Je.encode({Type:vt[r.type],Data:r.raw})}var gi=Symbol.for("nodejs.util.inspect.custom"),gf=114,er=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()})`}[zr]=!0;toString(){return this.string==null&&(this.string=W.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return rt.createV1(gf,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return yt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return yt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[gi](){return`PeerId(${this.toString()})`}},Cr=class extends er{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Pr=class extends er{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Ur=class extends er{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},yf=2336,rr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=It.digest(At(this.url))}[gi](){return`PeerId(${this.url})`}[zr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return rt.createV1(yf,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=j(t)),t.toString()===this.toString())}};var bf=114,yi=2336;function bi(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=te(W.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return wf(rt.parse(r));if(t==null)throw new Ct('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=te(t.decode(r))}return wi(e)}function wi(r){if(Sf(r))return new Cr({multihash:r});if(Ef(r))try{let t=xi(r);if(t.type==="Ed25519")return new Pr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Ur({multihash:r,publicKey:t})}catch{let e=j(r.digest);return new rr(new URL(e))}throw new sr("Supplied PeerID Multihash is invalid")}function wf(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==bf&&r.code!==yi)throw new or("Supplied PeerID CID is invalid");if(r.code===yi){let t=j(r.multihash.digest);return new rr(new URL(t))}return wi(r.multihash)}function Ef(r){return r.code===It.code}function Sf(r){return r.code===He.code}var _r=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,i=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",u=2**(8*o)-1;for(;;){let f=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let p=Number.parseInt(l,t);if(!Number.isNaN(p))return p});if(f===void 0)break;if(s*=t,s+=f,s>u||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&a&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[o]=i[0],e[o+1]=i[1],e[o+2]=i[2],e[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[c]=t(s.subarray(0,i));return e.set(s.subarray(0,c),16-c),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Ei=45,vf=15,Ue=new _r;function uo(r){if(!(r.length>vf))return Ue.new(r).parseWith(()=>Ue.readIPv4Addr())}function lo(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ei))return Ue.new(r).parseWith(()=>Ue.readIPv6Addr())}function Dr(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>Ei)return;let e=Ue.new(r).parseWith(()=>Ue.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}var e0=parseInt("0xFFFF",16),r0=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Ai(r){return!!uo(r)}function Bi(r){return!!lo(r)}function Nr(r){return!!Dr(r)}var Ii=Ai,Lf=Bi,ho=function(r){let t=0;if(r=r.toString().trim(),Ii(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Lf(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=Ii(e[n]),i;s&&(i=ho(e[n]),e[n]=j(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,j(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},Ti=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var _e={},po={},Pf=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];Pf.forEach(r=>{let t=Uf(...r);po[t.code]=t,_e[t.name]=t});function Uf(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function G(r){if(typeof r=="number"){if(po[r]!=null)return po[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(_e[r]!=null)return _e[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var M0=G("ip4"),H0=G("ip6"),V0=G("ipcidr");function yo(r,t){switch(G(r).code){case 4:case 41:return Df(t);case 42:return go(t);case 43:return j(t,"base10");case 6:case 273:case 33:case 132:return Pi(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return go(t);case 421:return kf(t);case 444:return Ci(t);case 445:return Ci(t);case 466:return Kf(t);case 481:return globalThis.encodeURIComponent(go(t));default:return j(t,"base16")}}function bo(r,t){switch(G(r).code){case 4:return Li(t);case 41:return Li(t);case 42:return xo(t);case 43:return At(t,"base10");case 6:case 273:case 33:case 132:return wo(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return xo(t);case 421:return Nf(t);case 444:return Of(t);case 445:return Mf(t);case 466:return Rf(t);case 481:return xo(globalThis.decodeURIComponent(t));default:return At(t,"base16")}}var mo=Object.values(Ve).map(r=>r.decoder),_f=function(){let r=mo[0].or(mo[1]);return mo.slice(2).forEach(t=>r=r.or(t)),r}();function Li(r){if(!Nr(r))throw new Error("invalid ip address");return ho(r)}function Df(r){let t=Ti(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Nr(t))throw new Error("invalid ip address");return t}function wo(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Pi(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function xo(r){let t=At(r),e=Uint8Array.from(Ce(t.length));return bt([e,t],e.length+t.length)}function go(r){let t=le(r);if(r=r.slice(mt(t)),r.length!==t)throw new Error("inconsistent lengths");return j(r)}function Nf(r){let t;r[0]==="Q"||r[0]==="1"?t=te(W.decode(`z${r}`)).bytes:t=rt.parse(r).multihash.bytes;let e=Uint8Array.from(Ce(t.length));return bt([e,t],e.length+t.length)}function Rf(r){let t=_f.decode(r),e=Uint8Array.from(Ce(t.length));return bt([e,t],e.length+t.length)}function Kf(r){let t=le(r),e=r.slice(mt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+j(e,"base64url")}function kf(r){let t=le(r),e=r.slice(mt(t));if(e.length!==t)throw new Error("inconsistent lengths");return j(e,"base58btc")}function Of(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Nt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=wo(n);return bt([e,o],e.length+o.length)}function Mf(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Nt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=wo(n);return bt([e,o],e.length+o.length)}function Ci(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=j(t,"base32"),o=Pi(e);return`${n}:${o}`}function Ui(r){r=Eo(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],c=G(i);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(s++,s>=o.length)throw new Rr("invalid address: "+r);if(c.path===!0){n=Eo(o.slice(s).join("/")),t.push([c.code,bo(c.code,n)]),e.push([c.code,n]);break}let a=bo(c.code,o[s]);t.push([c.code,a]),e.push([c.code,yo(c.code,a)])}return{string:_i(e),bytes:Kr(t),tuples:t,stringTuples:e,path:n}}function So(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=le(r,o),i=mt(s),c=G(s),a=Hf(c,r.slice(o+i));if(a===0){t.push([s]),e.push([s]),o+=i;continue}let u=r.slice(o+i,o+i+a);if(o+=a+i,o>r.length)throw new Rr("Invalid address Uint8Array: "+j(r,"base16"));t.push([s,u]);let f=yo(s,u);if(e.push([s,f]),c.path===!0){n=f;break}}return{bytes:Uint8Array.from(r),string:_i(e),tuples:t,stringTuples:e,path:n}}function _i(r){let t=[];return r.map(e=>{let n=G(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Eo(t.join("/"))}function Kr(r){return bt(r.map(t=>{let e=G(t[0]),n=Uint8Array.from(Ce(e.code));return t.length>1&&t[1]!=null&&(n=bt([n,t[1]])),n}))}function Hf(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=le(t instanceof Uint8Array?t:Uint8Array.from(t));return e+mt(e)}}function Eo(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var Rr=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var Vf=Symbol.for("nodejs.util.inspect.custom"),Ao=Symbol.for("@multiformats/js-multiaddr/multiaddr"),qf=[G("dns").code,G("dns4").code,G("dns6").code,G("dnsaddr").code],vo=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},kr=class r{bytes;#t;#e;#r;#n;[Ao]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=So(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Ui(t)}else if(Ni(t))e=So(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",i=G("tcp"),c=G("udp"),a=G("ip4"),u=G("ip6"),f=G("dns6"),l=G("ip6zone");for(let[w,E]of this.stringTuples())w===l.code&&(s=`%${E??""}`),qf.includes(w)&&(e=i.name==="tcp"?"tcp":"udp",o=443,n=`${E??""}${s}`,t=w===f.code?6:4),(w===i.code||w===c.code)&&(e=G(w).name==="tcp"?"tcp":"udp",o=parseInt(E??"")),(w===a.code||w===u.code)&&(e=G(w).name==="tcp"?"tcp":"udp",n=`${E??""}${s}`,t=w===u.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},G(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>G(t).name)}tuples(){return this.#e.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(Kr(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===_e.p2p.code&&t.push([n,o]),n===_e["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?j(W.decode(`z${n}`),"base58btc"):j(rt.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return yt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=Di.get(e.name);if(n==null)throw new vo(`no available resolver for ${e.name}`);return(await n(this,t)).map(s=>Xt(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[Vf](){return`Multiaddr(${this.#t})`}};var Di=new Map;function Ni(r){return!!r?.[Ao]}function Xt(r){return new kr(r)}var zf=S("dns4"),Ff=S("dns6"),jf=S("dnsaddr"),xe=J(S("dns"),jf,zf,Ff),Hr=J(S("ip4"),S("ip6")),De=J(D(Hr,S("tcp")),D(xe,S("tcp"))),Vr=D(Hr,S("udp")),Gf=D(Vr,S("utp")),Zf=D(Vr,S("quic")),Wf=D(Vr,S("quic-v1")),Bo=J(D(De,S("ws")),D(xe,S("ws"))),Or=J(D(Bo,S("p2p")),Bo),Io=J(D(De,S("wss")),D(xe,S("wss")),D(De,S("tls"),S("ws")),D(xe,S("tls"),S("ws"))),Mr=J(D(Io,S("p2p")),Io),To=J(D(De,S("http")),D(Hr,S("http")),D(xe,S("http"))),Lo=J(D(De,S("https")),D(Hr,S("https")),D(xe,S("https"))),Ri=D(Vr,S("webrtc-direct"),S("certhash")),Oi=J(D(Ri,S("p2p")),Ri),Ki=D(Wf,S("webtransport"),S("certhash"),S("certhash")),Mi=J(D(Ki,S("p2p")),Ki),Hi=J(D(Or,S("p2p-webrtc-star"),S("p2p")),D(Mr,S("p2p-webrtc-star"),S("p2p")),D(Or,S("p2p-webrtc-star")),D(Mr,S("p2p-webrtc-star"))),pm=J(D(Or,S("p2p-websocket-star"),S("p2p")),D(Mr,S("p2p-websocket-star"),S("p2p")),D(Or,S("p2p-websocket-star")),D(Mr,S("p2p-websocket-star"))),Vi=J(D(To,S("p2p-webrtc-direct"),S("p2p")),D(Lo,S("p2p-webrtc-direct"),S("p2p")),D(To,S("p2p-webrtc-direct")),D(Lo,S("p2p-webrtc-direct"))),ge=J(Bo,Io,To,Lo,Hi,Vi,De,Gf,Zf,xe,Oi,Mi),mm=J(D(ge,S("p2p-stardust"),S("p2p")),D(ge,S("p2p-stardust"))),Qt=J(D(ge,S("p2p")),Hi,Vi,Oi,Mi,S("p2p")),ki=J(D(Qt,S("p2p-circuit"),Qt),D(Qt,S("p2p-circuit")),D(S("p2p-circuit"),Qt),D(ge,S("p2p-circuit")),D(S("p2p-circuit"),ge),S("p2p-circuit")),qi=()=>J(D(ki,qi),ki),me=qi(),zi=J(D(me,Qt,me),D(Qt,me),D(me,Qt),me,Qt);var xm=J(D(me,S("webrtc"),S("p2p")),D(me,S("webrtc")),D(ge,S("webrtc"),S("p2p")),D(ge,S("webrtc")),S("webrtc"));function Fi(r){function t(e){let n;try{n=Xt(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function D(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(o=>(n=typeof o=="function"?o().partialMatch(e):o.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Fi(t),partialMatch:t}}function J(...r){function t(n){let o=null;return r.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Fi(t),partialMatch:t}}function S(r){let t=r;function e(o){let s;try{s=Xt(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var $f="bootstrap",Yf=50,Xf=1e3,Co=class extends ir{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(t,e={list:[]}){if(e.list==null||e.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super(),this.components=t,this.log=t.logger.forComponent("libp2p:bootstrap"),this.timeout=e.timeout??Xf,this.list=[];for(let n of e.list){if(!zi.matches(n)){this.log.error("Invalid multiaddr");continue}let o=Xt(n),s=o.getPeerId();if(s==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let i={id:bi(s),multiaddrs:[o]};this.list.push(i)}this._init=e}[Uo]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[_o]=["@libp2p/peer-discovery"];isStarted(){return!!this.timer}start(){this.isStarted()||(this.log("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(t=>{this.log.error(t)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(let t of this.list){if(await this.components.peerStore.merge(t.id,{tags:{[this._init.tagName??$f]:{value:this._init.tagValue??Yf,ttl:this._init.tagTTL}},multiaddrs:t.multiaddrs}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t}),this.components.connectionManager.openConnection(t.id).catch(e=>{this.log.error("could not dial bootstrap peer %p",t.id,e)})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function Qf(r){return t=>new Co(t,r)}return Ji(Jf);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/hashes/esm/utils.js:
|
|
6
6
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
7
7
|
|
|
8
8
|
@noble/curves/esm/abstract/utils.js:
|
|
9
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
10
|
-
|
|
11
9
|
@noble/curves/esm/abstract/modular.js:
|
|
12
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
13
|
-
|
|
14
10
|
@noble/curves/esm/abstract/curve.js:
|
|
15
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
16
|
-
|
|
17
11
|
@noble/curves/esm/abstract/edwards.js:
|
|
18
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
19
|
-
|
|
20
12
|
@noble/curves/esm/ed25519.js:
|
|
21
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
22
|
-
|
|
23
13
|
@noble/curves/esm/abstract/weierstrass.js:
|
|
24
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
25
|
-
|
|
26
14
|
@noble/curves/esm/_shortw_utils.js:
|
|
27
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
28
|
-
|
|
29
15
|
@noble/curves/esm/secp256k1.js:
|
|
30
16
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
31
17
|
*/
|
|
32
18
|
return Libp2PBootstrap}));
|
|
19
|
+
//# sourceMappingURL=index.min.js.map
|