@libp2p/bootstrap 11.0.30 → 11.0.31-a7ab9a41b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/package.json +6 -6
- package/dist/typedoc-urls.json +0 -8
package/dist/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PBootstrap = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PBootstrap=(()=>{var _r=Object.defineProperty;var xs=Object.getOwnPropertyDescriptor;var gs=Object.getOwnPropertyNames;var bs=Object.prototype.hasOwnProperty;var ht=(r,t)=>{for(var e in t)_r(r,e,{get:t[e],enumerable:!0})},ys=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of gs(t))!bs.call(r,o)&&o!==e&&_r(r,o,{get:()=>t[o],enumerable:!(n=xs(t,o))||n.enumerable});return r};var ws=r=>ys(_r({},"__esModule",{value:!0}),r);var _u={};ht(_u,{bootstrap:()=>Nu});var wo=Symbol.for("@libp2p/peer-discovery");var Dr=Symbol.for("@libp2p/peer-id");var he=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Ge=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Ze=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Le=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:i})=>i!==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 Eo=Symbol.for("@libp2p/service-capabilities"),Ku=Symbol.for("@libp2p/service-dependencies");var Kr={};ht(Kr,{base58btc:()=>Q,base58flickr:()=>Is});var ff=new Uint8Array(0);function vo(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 Ct(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 So(r){return new TextEncoder().encode(r)}function Bo(r){return new TextDecoder().decode(r)}function Es(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 i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var c=r.length,a=r.charAt(0),d=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function m(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var g=0,f=0,w=0,B=y.length;w!==B&&y[w]===0;)w++,g++;for(var h=(B-w)*u+1>>>0,I=new Uint8Array(h);w!==B;){for(var N=y[w],R=0,T=h-1;(N!==0||R<f)&&T!==-1;T--,R++)N+=256*I[T]>>>0,I[T]=N%c>>>0,N=N/c>>>0;if(N!==0)throw new Error("Non-zero carry");f=R,w++}for(var P=h-f;P!==h&&I[P]===0;)P++;for(var C=a.repeat(g);P<h;++P)C+=r.charAt(I[P]);return C}function p(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;var g=0;if(y[g]!==" "){for(var f=0,w=0;y[g]===a;)f++,g++;for(var B=(y.length-g)*d+1>>>0,h=new Uint8Array(B);y[g];){var I=e[y.charCodeAt(g)];if(I===255)return;for(var N=0,R=B-1;(I!==0||N<w)&&R!==-1;R--,N++)I+=c*h[R]>>>0,h[R]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");w=N,g++}if(y[g]!==" "){for(var T=B-w;T!==B&&h[T]===0;)T++;for(var P=new Uint8Array(f+(B-T)),C=f;T!==B;)P[C++]=h[T++];return P}}}function E(y){var g=p(y);if(g)return g;throw new Error(`Non-${t} character`)}return{encode:m,decodeUnsafe:p,decode:E}}var vs=Es,Ss=vs,Io=Ss;var Or=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")}},kr=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 To(this,t)}},Mr=class{decoders;constructor(t){this.decoders=t}or(t){return To(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 To(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 Or(t,e,n),this.decoder=new kr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function pe({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}=Io(e,r);return pe({prefix:t,name:r,encode:n,decode:i=>Ct(o(i))})}function Bs(r,t,e,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),c=0,a=0,d=0;for(let u=0;u<i;++u){let m=o[r[u]];if(m===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|m,c+=e,c>=8&&(c-=8,s[d++]=255&a>>c)}if(c>=e||(255&a<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return s}function As(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],s+=8;s>e;)s-=e,i+=t[o&c>>s];if(s!==0&&(i+=t[o&c<<e-s]),n)for(;(i.length*e&7)!==0;)i+="=";return i}function X({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return pe({prefix:t,name:r,encode(o){return As(o,n,e)},decode(o){return Bs(o,n,e,r)}})}var Q=Ht({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Is=Ht({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var qr={};ht(qr,{base32:()=>Lt,base32hex:()=>Ps,base32hexpad:()=>Us,base32hexpadupper:()=>Ns,base32hexupper:()=>Rs,base32pad:()=>Cs,base32padupper:()=>Ls,base32upper:()=>Ts,base32z:()=>_s});var Lt=X({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ts=X({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Cs=X({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ls=X({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ps=X({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Rs=X({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Us=X({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ns=X({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),_s=X({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Vr={};ht(Vr,{base36:()=>Pe,base36upper:()=>Ds});var Pe=Ht({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ds=Ht({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Os=Po,Co=128,ks=127,Ms=~ks,Hs=Math.pow(2,31);function Po(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Hs;)t[e++]=r&255|Co,r/=128;for(;r&Ms;)t[e++]=r&255|Co,r>>>=7;return t[e]=r|0,Po.bytes=e-n+1,t}var Ks=zr,qs=128,Lo=127;function zr(r,n){var e=0,n=n||0,o=0,i=n,s,c=r.length;do{if(i>=c)throw zr.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&Lo)<<o:(s&Lo)*Math.pow(2,o),o+=7}while(s>=qs);return zr.bytes=i-n,e}var Vs=Math.pow(2,7),zs=Math.pow(2,14),Fs=Math.pow(2,21),Gs=Math.pow(2,28),Zs=Math.pow(2,35),js=Math.pow(2,42),Ws=Math.pow(2,49),$s=Math.pow(2,56),Ys=Math.pow(2,63),Xs=function(r){return r<Vs?1:r<zs?2:r<Fs?3:r<Gs?4:r<Zs?5:r<js?6:r<Ws?7:r<$s?8:r<Ys?9:10},Qs={encode:Os,decode:Ks,encodingLength:Xs},Js=Qs,Re=Js;function Ue(r,t=0){return[Re.decode(r,t),Re.decode.bytes]}function me(r,t,e=0){return Re.encode(r,t,e),t}function xe(r){return Re.encodingLength(r)}function Xt(r,t){let e=t.byteLength,n=xe(r),o=n+xe(e),i=new Uint8Array(o+e);return me(r,i,0),me(e,i,n),i.set(t,o),new ge(r,e,t,i)}function Qt(r){let t=Ct(r),[e,n]=Ue(t),[o,i]=Ue(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new ge(e,o,s,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&&vo(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 Uo(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return ec(e,Fr(r),t??Q.encoder);default:return rc(e,Fr(r),t??Lt.encoder)}}var No=new WeakMap;function Fr(r){let t=No.get(r);if(t==null){let e=new Map;return No.set(r,e),e}return t}var lt=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!==Ne)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==nc)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 Uo(this,t)}toJSON(){return{"/":Uo(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:i,bytes:s}=e;return new r(n,o,i,s??_o(n,o,i.bytes))}else if(e[oc]===!0){let{version:n,multihash:o,code:i}=e,s=Qt(o);return r.create(n,i,s)}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!==Ne)throw new Error(`Version 0 CID must use dag-pb (code: ${Ne}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=_o(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Ne,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=Ct(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),s=new ge(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[m,p]=Ue(t.subarray(e));return e+=p,m},o=n(),i=Ne;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=e,c=n(),a=n(),d=e+a,u=d-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:u,size:d}}static parse(t,e){let[n,o]=tc(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Fr(i).set(n,t),i}};function tc(r,t){switch(r[0]){case"Q":{let e=t??Q;return[Q.prefix,e.decode(`${Q.prefix}${r}`)]}case Q.prefix:{let e=t??Q;return[Q.prefix,e.decode(r)]}case Lt.prefix:{let e=t??Lt;return[Lt.prefix,e.decode(r)]}case Pe.prefix:{let e=t??Pe;return[Pe.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 ec(r,t,e){let{prefix:n}=e;if(n!==Q.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o}function rc(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o}var Ne=112,nc=18;function _o(r,t,e){let n=xe(r),o=n+xe(t),i=new Uint8Array(o+e.byteLength);return me(r,i,0),me(t,i,n),i.set(e,o),i}var oc=Symbol.for("@ipld/js-cid/CID");var Gr={};ht(Gr,{identity:()=>Pt});var Do=0,ic="identity",Oo=Ct;function sc(r){return Xt(Do,Oo(r))}var Pt={code:Do,name:ic,encode:Oo,digest:sc};function Rt(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 ko(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function cc(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function be(r,...t){if(!cc(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 Mo(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ko(r.outputLen),ko(r.blockLen)}function ye(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 Ho(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 $e(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function yt(r,t){return r<<32-t|r>>>t}function Ko(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function _e(r){return typeof r=="string"&&(r=Ko(r)),be(r),r}function Zr(...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 i=r[n];e.set(i,o),o+=i.length}return e}var we=class{clone(){return this._cloneInto()}};function Ye(r){let t=n=>r().update(_e(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Xe(r=32){if(te&&typeof te.getRandomValues=="function")return te.getRandomValues(new Uint8Array(r));if(te&&typeof te.randomBytes=="function")return te.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function ac(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(e>>o&i),c=Number(e&i),a=n?4:0,d=n?0:4;r.setUint32(t+a,s,n),r.setUint32(t+d,c,n)}function qo(r,t,e){return r&t^~r&e}function Vo(r,t,e){return r&t^r&e^t&e}var Ee=class extends we{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=$e(this.buffer)}update(t){ye(this);let{view:e,buffer:n,blockLen:o}=this;t=_e(t);let i=t.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=$e(t);for(;o<=i-s;s+=o)this.process(a,s);continue}n.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ye(this),Ho(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let m=s;m<o;m++)e[m]=0;ac(n,o-8,BigInt(this.length*8),i),this.process(n,0);let c=$e(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=a/4,u=this.get();if(d>u.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<d;m++)c.setUint32(4*m,u[m],i)}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:i,destroyed:s,pos:c}=this;return t.length=o,t.pos=c,t.finished=i,t.destroyed=s,o%e&&t.buffer.set(n),t}};var Qe=BigInt(4294967295),jr=BigInt(32);function zo(r,t=!1){return t?{h:Number(r&Qe),l:Number(r>>jr&Qe)}:{h:Number(r>>jr&Qe)|0,l:Number(r&Qe)|0}}function uc(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:i,l:s}=zo(r[o],t);[e[o],n[o]]=[i,s]}return[e,n]}var fc=(r,t)=>BigInt(r>>>0)<<jr|BigInt(t>>>0),lc=(r,t,e)=>r>>>e,dc=(r,t,e)=>r<<32-e|t>>>e,hc=(r,t,e)=>r>>>e|t<<32-e,pc=(r,t,e)=>r<<32-e|t>>>e,mc=(r,t,e)=>r<<64-e|t>>>e-32,xc=(r,t,e)=>r>>>e-32|t<<64-e,gc=(r,t)=>t,bc=(r,t)=>r,yc=(r,t,e)=>r<<e|t>>>32-e,wc=(r,t,e)=>t<<e|r>>>32-e,Ec=(r,t,e)=>t<<e-32|r>>>64-e,vc=(r,t,e)=>r<<e-32|t>>>64-e;function Sc(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var Bc=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Ac=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Ic=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Tc=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Cc=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Lc=(r,t,e,n,o,i)=>t+e+n+o+i+(r/2**32|0)|0;var Pc={fromBig:zo,split:uc,toBig:fc,shrSH:lc,shrSL:dc,rotrSH:hc,rotrSL:pc,rotrBH:mc,rotrBL:xc,rotr32H:gc,rotr32L:bc,rotlSH:yc,rotlSL:wc,rotlBH:Ec,rotlBL:vc,add:Sc,add3L:Bc,add3H:Ac,add4L:Ic,add4H:Tc,add5H:Lc,add5L:Cc},k=Pc;var[Rc,Uc]=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))),Kt=new Uint32Array(80),qt=new Uint32Array(80),Wr=class extends Ee{constructor(){super(128,64,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:i,Cl:s,Dh:c,Dl:a,Eh:d,El:u,Fh:m,Fl:p,Gh:E,Gl:y,Hh:g,Hl:f}=this;return[t,e,n,o,i,s,c,a,d,u,m,p,E,y,g,f]}set(t,e,n,o,i,s,c,a,d,u,m,p,E,y,g,f){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=a|0,this.Eh=d|0,this.El=u|0,this.Fh=m|0,this.Fl=p|0,this.Gh=E|0,this.Gl=y|0,this.Hh=g|0,this.Hl=f|0}process(t,e){for(let h=0;h<16;h++,e+=4)Kt[h]=t.getUint32(e),qt[h]=t.getUint32(e+=4);for(let h=16;h<80;h++){let I=Kt[h-15]|0,N=qt[h-15]|0,R=k.rotrSH(I,N,1)^k.rotrSH(I,N,8)^k.shrSH(I,N,7),T=k.rotrSL(I,N,1)^k.rotrSL(I,N,8)^k.shrSL(I,N,7),P=Kt[h-2]|0,C=qt[h-2]|0,j=k.rotrSH(P,C,19)^k.rotrBH(P,C,61)^k.shrSH(P,C,6),q=k.rotrSL(P,C,19)^k.rotrBL(P,C,61)^k.shrSL(P,C,6),H=k.add4L(T,q,qt[h-7],qt[h-16]),tt=k.add4H(H,R,j,Kt[h-7],Kt[h-16]);Kt[h]=tt|0,qt[h]=H|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:d,Dl:u,Eh:m,El:p,Fh:E,Fl:y,Gh:g,Gl:f,Hh:w,Hl:B}=this;for(let h=0;h<80;h++){let I=k.rotrSH(m,p,14)^k.rotrSH(m,p,18)^k.rotrBH(m,p,41),N=k.rotrSL(m,p,14)^k.rotrSL(m,p,18)^k.rotrBL(m,p,41),R=m&E^~m&g,T=p&y^~p&f,P=k.add5L(B,N,T,Uc[h],qt[h]),C=k.add5H(P,w,I,R,Rc[h],Kt[h]),j=P|0,q=k.rotrSH(n,o,28)^k.rotrBH(n,o,34)^k.rotrBH(n,o,39),H=k.rotrSL(n,o,28)^k.rotrBL(n,o,34)^k.rotrBL(n,o,39),tt=n&i^n&c^i&c,S=o&s^o&a^s&a;w=g|0,B=f|0,g=E|0,f=y|0,E=m|0,y=p|0,{h:m,l:p}=k.add(d|0,u|0,C|0,j|0),d=c|0,u=a|0,c=i|0,a=s|0,i=n|0,s=o|0;let L=k.add3L(j,H,S);n=k.add3H(L,C,q,tt),o=L|0}({h:n,l:o}=k.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=k.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=k.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:d,l:u}=k.add(this.Dh|0,this.Dl|0,d|0,u|0),{h:m,l:p}=k.add(this.Eh|0,this.El|0,m|0,p|0),{h:E,l:y}=k.add(this.Fh|0,this.Fl|0,E|0,y|0),{h:g,l:f}=k.add(this.Gh|0,this.Gl|0,g|0,f|0),{h:w,l:B}=k.add(this.Hh|0,this.Hl|0,w|0,B|0),this.set(n,o,i,s,c,a,d,u,m,p,E,y,g,f,w,B)}roundClean(){Kt.fill(0),qt.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 Fo=Ye(()=>new Wr);var er={};ht(er,{aInRange:()=>pt,abool:()=>wt,abytes:()=>ve,bitGet:()=>Mc,bitLen:()=>Qr,bitMask:()=>Oe,bitSet:()=>Hc,bytesToHex:()=>Nt,bytesToNumberBE:()=>_t,bytesToNumberLE:()=>zt,concatBytes:()=>Dt,createHmacDrbg:()=>Jr,ensureBytes:()=>Y,equalBytes:()=>Oc,hexToBytes:()=>re,hexToNumber:()=>Xr,inRange:()=>De,isBytes:()=>Vt,memoized:()=>oe,notImplemented:()=>qc,numberToBytesBE:()=>Ft,numberToBytesLE:()=>ne,numberToHexUnpadded:()=>ee,numberToVarBytesBE:()=>Dc,utf8ToBytes:()=>kc,validateObject:()=>At});var Je=BigInt(0),tr=BigInt(1),Nc=BigInt(2);function Vt(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ve(r){if(!Vt(r))throw new Error("Uint8Array expected")}function wt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var _c=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Nt(r){ve(r);let t="";for(let e=0;e<r.length;e++)t+=_c[r[e]];return t}function ee(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Xr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Je:BigInt("0x"+r)}var Ut={_0:48,_9:57,A:65,F:70,a:97,f:102};function Go(r){if(r>=Ut._0&&r<=Ut._9)return r-Ut._0;if(r>=Ut.A&&r<=Ut.F)return r-(Ut.A-10);if(r>=Ut.a&&r<=Ut.f)return r-(Ut.a-10)}function re(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof 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,i=0;o<e;o++,i+=2){let s=Go(r.charCodeAt(i)),c=Go(r.charCodeAt(i+1));if(s===void 0||c===void 0){let a=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+i)}n[o]=s*16+c}return n}function _t(r){return Xr(Nt(r))}function zt(r){return ve(r),Xr(Nt(Uint8Array.from(r).reverse()))}function Ft(r,t){return re(r.toString(16).padStart(t*2,"0"))}function ne(r,t){return Ft(r,t).reverse()}function Dc(r){return re(ee(r))}function Y(r,t,e){let n;if(typeof t=="string")try{n=re(t)}catch(i){throw new Error(r+" must be hex string or Uint8Array, cause: "+i)}else if(Vt(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 Dt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];ve(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let i=r[n];e.set(i,o),o+=i.length}return e}function Oc(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function kc(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var $r=r=>typeof r=="bigint"&&Je<=r;function De(r,t,e){return $r(r)&&$r(t)&&$r(e)&&t<=r&&r<e}function pt(r,t,e,n){if(!De(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Qr(r){let t;for(t=0;r>Je;r>>=tr,t+=1);return t}function Mc(r,t){return r>>BigInt(t)&tr}function Hc(r,t,e){return r|(e?tr:Je)<<BigInt(t)}var Oe=r=>(Nc<<BigInt(r-1))-tr,Yr=r=>new Uint8Array(r),Zo=r=>Uint8Array.from(r);function Jr(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=Yr(r),o=Yr(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},c=(...m)=>e(o,n,...m),a=(m=Yr())=>{o=c(Zo([0]),m),n=c(),m.length!==0&&(o=c(Zo([1]),m),n=c())},d=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let m=0,p=[];for(;m<t;){n=c();let E=n.slice();p.push(E),m+=n.length}return Dt(...p)};return(m,p)=>{s(),a(m);let E;for(;!(E=p(d()));)a();return s(),E}}var Kc={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"||Vt(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 At(r,t,e={}){let n=(o,i,s)=>{let c=Kc[i];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(s&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+a)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(e))n(o,i,!0);return r}var qc=()=>{throw new Error("not implemented")};function oe(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let i=r(e,...n);return t.set(e,i),i}}var et=BigInt(0),W=BigInt(1),ie=BigInt(2),Vc=BigInt(3),tn=BigInt(4),jo=BigInt(5),Wo=BigInt(8),zc=BigInt(9),Fc=BigInt(16);function F(r,t){let e=r%t;return e>=et?e:t+e}function Gc(r,t,e){if(t<et)throw new Error("invalid exponent, negatives unsupported");if(e<=et)throw new Error("invalid modulus");if(e===W)return et;let n=W;for(;t>et;)t&W&&(n=n*r%e),r=r*r%e,t>>=W;return n}function $(r,t,e){let n=r;for(;t-- >et;)n*=n,n%=e;return n}function rr(r,t){if(r===et)throw new Error("invert: expected non-zero number");if(t<=et)throw new Error("invert: expected positive modulus, got "+t);let e=F(r,t),n=t,o=et,i=W,s=W,c=et;for(;e!==et;){let d=n/e,u=n%e,m=o-s*d,p=i-c*d;n=e,e=u,o=s,i=c,s=m,c=p}if(n!==W)throw new Error("invert: does not exist");return F(o,t)}function Zc(r){let t=(r-W)/ie,e,n,o;for(e=r-W,n=0;e%ie===et;e/=ie,n++);for(o=ie;o<r&&Gc(o,t,r)!==r-W;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(r+W)/tn;return function(a,d){let u=a.pow(d,s);if(!a.eql(a.sqr(u),d))throw new Error("Cannot find square root");return u}}let i=(e+W)/ie;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let d=n,u=c.pow(c.mul(c.ONE,o),e),m=c.pow(a,i),p=c.pow(a,e);for(;!c.eql(p,c.ONE);){if(c.eql(p,c.ZERO))return c.ZERO;let E=1;for(let g=c.sqr(p);E<d&&!c.eql(g,c.ONE);E++)g=c.sqr(g);let y=c.pow(u,W<<BigInt(d-E-1));u=c.sqr(y),m=c.mul(m,y),p=c.mul(p,u),d=E}return m}}function jc(r){if(r%tn===Vc){let t=(r+W)/tn;return function(n,o){let i=n.pow(o,t);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(r%Wo===jo){let t=(r-jo)/Wo;return function(n,o){let i=n.mul(o,ie),s=n.pow(i,t),c=n.mul(o,s),a=n.mul(n.mul(c,ie),s),d=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(d),o))throw new Error("Cannot find square root");return d}}return r%Fc,Zc(r)}var $o=(r,t)=>(F(r,t)&W)===W,Wc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function en(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Wc.reduce((n,o)=>(n[o]="function",n),t);return At(r,e)}function $c(r,t,e){if(e<et)throw new Error("invalid exponent, negatives unsupported");if(e===et)return r.ONE;if(e===W)return t;let n=r.ONE,o=t;for(;e>et;)e&W&&(n=r.mul(n,o)),o=r.sqr(o),e>>=W;return n}function Yc(r,t){let e=new Array(t.length),n=t.reduce((i,s,c)=>r.is0(s)?i:(e[c]=i,r.mul(i,s)),r.ONE),o=r.inv(n);return t.reduceRight((i,s,c)=>r.is0(s)?i:(e[c]=r.mul(i,e[c]),r.mul(i,s)),o),e}function rn(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Gt(r,t,e=!1,n={}){if(r<=et)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:i}=rn(r,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,c=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:i,MASK:Oe(o),ZERO:et,ONE:W,create:a=>F(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return et<=a&&a<r},is0:a=>a===et,isOdd:a=>(a&W)===W,neg:a=>F(-a,r),eql:(a,d)=>a===d,sqr:a=>F(a*a,r),add:(a,d)=>F(a+d,r),sub:(a,d)=>F(a-d,r),mul:(a,d)=>F(a*d,r),pow:(a,d)=>$c(c,a,d),div:(a,d)=>F(a*rr(d,r),r),sqrN:a=>a*a,addN:(a,d)=>a+d,subN:(a,d)=>a-d,mulN:(a,d)=>a*d,inv:a=>rr(a,r),sqrt:n.sqrt||(a=>(s||(s=jc(r)),s(c,a))),invertBatch:a=>Yc(c,a),cmov:(a,d,u)=>u?d:a,toBytes:a=>e?ne(a,i):Ft(a,i),fromBytes:a=>{if(a.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+a.length);return e?zt(a):_t(a)}});return Object.freeze(c)}function Yo(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 nn(r){let t=Yo(r);return t+Math.ceil(t/2)}function Xo(r,t,e=!1){let n=r.length,o=Yo(t),i=nn(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=e?zt(r):_t(r),c=F(s,t-W)+W;return e?ne(c,o):Ft(c,o)}var Qo=BigInt(0),nr=BigInt(1);function on(r,t){let e=t.negate();return r?e:t}function Jo(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function sn(r,t){Jo(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function Xc(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 Qc(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 cn=new WeakMap,ti=new WeakMap;function an(r){return ti.get(r)||1}function or(r,t){return{constTimeNegate:on,hasPrecomputes(e){return an(e)!==1},unsafeLadder(e,n,o=r.ZERO){let i=e;for(;n>Qo;)n&nr&&(o=o.add(i)),i=i.double(),n>>=nr;return o},precomputeWindow(e,n){let{windows:o,windowSize:i}=sn(n,t),s=[],c=e,a=c;for(let d=0;d<o;d++){a=c,s.push(a);for(let u=1;u<i;u++)a=a.add(c),s.push(a);c=a.double()}return s},wNAF(e,n,o){let{windows:i,windowSize:s}=sn(e,t),c=r.ZERO,a=r.BASE,d=BigInt(2**e-1),u=2**e,m=BigInt(e);for(let p=0;p<i;p++){let E=p*s,y=Number(o&d);o>>=m,y>s&&(y-=u,o+=nr);let g=E,f=E+Math.abs(y)-1,w=p%2!==0,B=y<0;y===0?a=a.add(on(w,n[g])):c=c.add(on(B,n[f]))}return{p:c,f:a}},wNAFUnsafe(e,n,o,i=r.ZERO){let{windows:s,windowSize:c}=sn(e,t),a=BigInt(2**e-1),d=2**e,u=BigInt(e);for(let m=0;m<s;m++){let p=m*c;if(o===Qo)break;let E=Number(o&a);if(o>>=u,E>c&&(E-=d,o+=nr),E===0)continue;let y=n[p+Math.abs(E)-1];E<0&&(y=y.negate()),i=i.add(y)}return i},getPrecomputes(e,n,o){let i=cn.get(n);return i||(i=this.precomputeWindow(n,e),e!==1&&cn.set(n,o(i))),i},wNAFCached(e,n,o){let i=an(e);return this.wNAF(i,this.getPrecomputes(i,e,o),n)},wNAFCachedUnsafe(e,n,o,i){let s=an(e);return s===1?this.unsafeLadder(e,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,e,o),n,i)},setWindowSize(e,n){Jo(n,t),ti.set(e,n),cn.delete(e)}}}function ir(r,t,e,n){if(Xc(e,r),Qc(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,i=Qr(BigInt(e.length)),s=i>12?i-3:i>4?i-2:i?2:1,c=(1<<s)-1,a=new Array(c+1).fill(o),d=Math.floor((t.BITS-1)/s)*s,u=o;for(let m=d;m>=0;m-=s){a.fill(o);for(let E=0;E<n.length;E++){let y=n[E],g=Number(y>>BigInt(m)&BigInt(c));a[g]=a[g].add(e[E])}let p=o;for(let E=a.length-1,y=o;E>0;E--)y=y.add(a[E]),p=p.add(y);if(u=u.add(p),m!==0)for(let E=0;E<s;E++)u=u.double()}return u}function ke(r){return en(r.Fp),At(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...rn(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Et=BigInt(0),mt=BigInt(1),sr=BigInt(2),Jc=BigInt(8),ta={zip215:!0};function ea(r){let t=ke(r);return At(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function ei(r){let t=ea(r),{Fp:e,n,prehash:o,hash:i,randomBytes:s,nByteLength:c,h:a}=t,d=sr<<BigInt(c*8)-mt,u=e.create,m=Gt(t.n,t.nBitLength),p=t.uvRatio||((x,l)=>{try{return{isValid:!0,value:e.sqrt(x*e.inv(l))}}catch{return{isValid:!1,value:Et}}}),E=t.adjustScalarBytes||(x=>x),y=t.domain||((x,l,b)=>{if(wt("phflag",b),l.length||b)throw new Error("Contexts/pre-hash are not supported");return x});function g(x,l){pt("coordinate "+x,l,Et,d)}function f(x){if(!(x instanceof h))throw new Error("ExtendedPoint expected")}let w=oe((x,l)=>{let{ex:b,ey:A,ez:_}=x,D=x.is0();l==null&&(l=D?Jc:e.inv(_));let M=u(b*l),K=u(A*l),O=u(_*l);if(D)return{x:Et,y:mt};if(O!==mt)throw new Error("invZ was invalid");return{x:M,y:K}}),B=oe(x=>{let{a:l,d:b}=t;if(x.is0())throw new Error("bad point: ZERO");let{ex:A,ey:_,ez:D,et:M}=x,K=u(A*A),O=u(_*_),z=u(D*D),Z=u(z*z),nt=u(K*l),ot=u(z*u(nt+O)),st=u(Z+u(b*u(K*O)));if(ot!==st)throw new Error("bad point: equation left != right (1)");let ct=u(A*_),dt=u(D*M);if(ct!==dt)throw new Error("bad point: equation left != right (2)");return!0});class h{constructor(l,b,A,_){this.ex=l,this.ey=b,this.ez=A,this.et=_,g("x",l),g("y",b),g("z",A),g("t",_),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(l){if(l instanceof h)throw new Error("extended point not allowed");let{x:b,y:A}=l||{};return g("x",b),g("y",A),new h(b,A,mt,u(b*A))}static normalizeZ(l){let b=e.invertBatch(l.map(A=>A.ez));return l.map((A,_)=>A.toAffine(b[_])).map(h.fromAffine)}static msm(l,b){return ir(h,m,l,b)}_setWindowSize(l){R.setWindowSize(this,l)}assertValidity(){B(this)}equals(l){f(l);let{ex:b,ey:A,ez:_}=this,{ex:D,ey:M,ez:K}=l,O=u(b*K),z=u(D*_),Z=u(A*K),nt=u(M*_);return O===z&&Z===nt}is0(){return this.equals(h.ZERO)}negate(){return new h(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:l}=t,{ex:b,ey:A,ez:_}=this,D=u(b*b),M=u(A*A),K=u(sr*u(_*_)),O=u(l*D),z=b+A,Z=u(u(z*z)-D-M),nt=O+M,ot=nt-K,st=O-M,ct=u(Z*ot),dt=u(nt*st),ft=u(Z*st),Bt=u(ot*nt);return new h(ct,dt,Bt,ft)}add(l){f(l);let{a:b,d:A}=t,{ex:_,ey:D,ez:M,et:K}=this,{ex:O,ey:z,ez:Z,et:nt}=l;if(b===BigInt(-1)){let ho=u((D-_)*(z+O)),po=u((D+_)*(z-O)),Nr=u(po-ho);if(Nr===Et)return this.double();let mo=u(M*sr*nt),xo=u(K*sr*Z),go=xo+mo,bo=po+ho,yo=xo-mo,ds=u(go*Nr),hs=u(bo*yo),ps=u(go*yo),ms=u(Nr*bo);return new h(ds,hs,ms,ps)}let ot=u(_*O),st=u(D*z),ct=u(K*A*nt),dt=u(M*Z),ft=u((_+D)*(O+z)-ot-st),Bt=dt-ct,Tt=dt+ct,Ce=u(st-b*ot),as=u(ft*Bt),us=u(Tt*Ce),fs=u(ft*Ce),ls=u(Bt*Tt);return new h(as,us,ls,fs)}subtract(l){return this.add(l.negate())}wNAF(l){return R.wNAFCached(this,l,h.normalizeZ)}multiply(l){let b=l;pt("scalar",b,mt,n);let{p:A,f:_}=this.wNAF(b);return h.normalizeZ([A,_])[0]}multiplyUnsafe(l,b=h.ZERO){let A=l;return pt("scalar",A,Et,n),A===Et?N:this.is0()||A===mt?this:R.wNAFCachedUnsafe(this,A,h.normalizeZ,b)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return R.unsafeLadder(this,n).is0()}toAffine(l){return w(this,l)}clearCofactor(){let{h:l}=t;return l===mt?this:this.multiplyUnsafe(l)}static fromHex(l,b=!1){let{d:A,a:_}=t,D=e.BYTES;l=Y("pointHex",l,D),wt("zip215",b);let M=l.slice(),K=l[D-1];M[D-1]=K&-129;let O=zt(M),z=b?d:e.ORDER;pt("pointHex.y",O,Et,z);let Z=u(O*O),nt=u(Z-mt),ot=u(A*Z-_),{isValid:st,value:ct}=p(nt,ot);if(!st)throw new Error("Point.fromHex: invalid y coordinate");let dt=(ct&mt)===mt,ft=(K&128)!==0;if(!b&&ct===Et&&ft)throw new Error("Point.fromHex: x=0 and x_0=1");return ft!==dt&&(ct=u(-ct)),h.fromAffine({x:ct,y:O})}static fromPrivateKey(l){return C(l).point}toRawBytes(){let{x:l,y:b}=this.toAffine(),A=ne(b,e.BYTES);return A[A.length-1]|=l&mt?128:0,A}toHex(){return Nt(this.toRawBytes())}}h.BASE=new h(t.Gx,t.Gy,mt,u(t.Gx*t.Gy)),h.ZERO=new h(Et,mt,mt,Et);let{BASE:I,ZERO:N}=h,R=or(h,c*8);function T(x){return F(x,n)}function P(x){return T(zt(x))}function C(x){let l=e.BYTES;x=Y("private key",x,l);let b=Y("hashed private key",i(x),2*l),A=E(b.slice(0,l)),_=b.slice(l,2*l),D=P(A),M=I.multiply(D),K=M.toRawBytes();return{head:A,prefix:_,scalar:D,point:M,pointBytes:K}}function j(x){return C(x).pointBytes}function q(x=new Uint8Array,...l){let b=Dt(...l);return P(i(y(b,Y("context",x),!!o)))}function H(x,l,b={}){x=Y("message",x),o&&(x=o(x));let{prefix:A,scalar:_,pointBytes:D}=C(l),M=q(b.context,A,x),K=I.multiply(M).toRawBytes(),O=q(b.context,K,D,x),z=T(M+O*_);pt("signature.s",z,Et,n);let Z=Dt(K,ne(z,e.BYTES));return Y("result",Z,e.BYTES*2)}let tt=ta;function S(x,l,b,A=tt){let{context:_,zip215:D}=A,M=e.BYTES;x=Y("signature",x,2*M),l=Y("message",l),b=Y("publicKey",b,M),D!==void 0&&wt("zip215",D),o&&(l=o(l));let K=zt(x.slice(M,2*M)),O,z,Z;try{O=h.fromHex(b,D),z=h.fromHex(x.slice(0,M),D),Z=I.multiplyUnsafe(K)}catch{return!1}if(!D&&O.isSmallOrder())return!1;let nt=q(_,z.toRawBytes(),O.toRawBytes(),l);return z.add(O.multiplyUnsafe(nt)).subtract(Z).clearCofactor().equals(h.ZERO)}return I._setWindowSize(8),{CURVE:t,getPublicKey:j,sign:H,verify:S,ExtendedPoint:h,utils:{getExtendedPublicKey:C,randomPrivateKey:()=>s(e.BYTES),precompute(x=8,l=h.BASE){return l._setWindowSize(x),l.multiply(BigInt(3)),l}}}}var un=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ri=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),rl=BigInt(0),ra=BigInt(1),ni=BigInt(2),nl=BigInt(3),na=BigInt(5),oa=BigInt(8);function ia(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),i=un,c=r*r%i*r%i,a=$(c,ni,i)*c%i,d=$(a,ra,i)*r%i,u=$(d,na,i)*d%i,m=$(u,t,i)*u%i,p=$(m,e,i)*m%i,E=$(p,n,i)*p%i,y=$(E,o,i)*E%i,g=$(y,o,i)*E%i,f=$(g,t,i)*u%i;return{pow_p_5_8:$(f,ni,i)*r%i,b2:c}}function sa(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function ca(r,t){let e=un,n=F(t*t*t,e),o=F(n*n*t,e),i=ia(r*o).pow_p_5_8,s=F(r*n*i,e),c=F(t*s*s,e),a=s,d=F(s*ri,e),u=c===r,m=c===F(-r,e),p=c===F(-r*ri,e);return u&&(s=a),(m||p)&&(s=d),$o(s,e)&&(s=F(-s,e)),{isValid:u||m,value:s}}var aa=Gt(un,void 0,!0),ua={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:aa,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:oa,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Fo,randomBytes:Xe,adjustScalarBytes:sa,uvRatio:ca},oi=ei(ua);var cr=32;function ii(r,t,e){return oi.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var ar=class{type="Ed25519";raw;constructor(t){this.raw=fn(t,cr)}toMultihash(){return Pt.digest(ur(this))}toCID(){return lt.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Rt(this.raw,t.raw)}verify(t,e){return ii(this.raw,e,t)}};function ci(r){return r=fn(r,cr),new ar(r)}function fn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new he(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function vt(r=0){return new Uint8Array(r)}var la=Math.pow(2,7),da=Math.pow(2,14),ha=Math.pow(2,21),ln=Math.pow(2,28),dn=Math.pow(2,35),hn=Math.pow(2,42),pn=Math.pow(2,49),V=128,at=127;function xt(r){if(r<la)return 1;if(r<da)return 2;if(r<ha)return 3;if(r<ln)return 4;if(r<dn)return 5;if(r<hn)return 6;if(r<pn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function mn(r,t,e=0){switch(xt(r)){case 8:t[e++]=r&255|V,r/=128;case 7:t[e++]=r&255|V,r/=128;case 6:t[e++]=r&255|V,r/=128;case 5:t[e++]=r&255|V,r/=128;case 4:t[e++]=r&255|V,r>>>=7;case 3:t[e++]=r&255|V,r>>>=7;case 2:t[e++]=r&255|V,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function pa(r,t,e=0){switch(xt(r)){case 8:t.set(e++,r&255|V),r/=128;case 7:t.set(e++,r&255|V),r/=128;case 6:t.set(e++,r&255|V),r/=128;case 5:t.set(e++,r&255|V),r/=128;case 4:t.set(e++,r&255|V),r>>>=7;case 3:t.set(e++,r&255|V),r>>>=7;case 2:t.set(e++,r&255|V),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function xn(r,t){let e=r[t],n=0;if(n+=e&at,e<V||(e=r[t+1],n+=(e&at)<<7,e<V)||(e=r[t+2],n+=(e&at)<<14,e<V)||(e=r[t+3],n+=(e&at)<<21,e<V)||(e=r[t+4],n+=(e&at)*ln,e<V)||(e=r[t+5],n+=(e&at)*dn,e<V)||(e=r[t+6],n+=(e&at)*hn,e<V)||(e=r[t+7],n+=(e&at)*pn,e<V))return n;throw new RangeError("Could not decode varint")}function ma(r,t){let e=r.get(t),n=0;if(n+=e&at,e<V||(e=r.get(t+1),n+=(e&at)<<7,e<V)||(e=r.get(t+2),n+=(e&at)<<14,e<V)||(e=r.get(t+3),n+=(e&at)<<21,e<V)||(e=r.get(t+4),n+=(e&at)*ln,e<V)||(e=r.get(t+5),n+=(e&at)*dn,e<V)||(e=r.get(t+6),n+=(e&at)*hn,e<V)||(e=r.get(t+7),n+=(e&at)*pn,e<V))return n;throw new RangeError("Could not decode varint")}function Se(r,t,e=0){return t==null&&(t=vt(xt(r))),t instanceof Uint8Array?mn(r,t,e):pa(r,t,e)}function se(r,t=0){return r instanceof Uint8Array?xn(r,t):ma(r,t)}var gn=new Float32Array([-0]),Zt=new Uint8Array(gn.buffer);function ui(r,t,e){gn[0]=r,t[e]=Zt[0],t[e+1]=Zt[1],t[e+2]=Zt[2],t[e+3]=Zt[3]}function fi(r,t){return Zt[0]=r[t],Zt[1]=r[t+1],Zt[2]=r[t+2],Zt[3]=r[t+3],gn[0]}var bn=new Float64Array([-0]),ut=new Uint8Array(bn.buffer);function li(r,t,e){bn[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 di(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],bn[0]}var xa=BigInt(Number.MAX_SAFE_INTEGER),ga=BigInt(Number.MIN_SAFE_INTEGER),gt=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<xa&&t>ga)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>hi&&(o=0n,++n>hi&&(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 gt(0,0);ce.toBigInt=function(){return 0n};ce.zzEncode=ce.zzDecode=function(){return this};ce.length=function(){return 1};var hi=4294967296n;function pi(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 mi(r,t,e){if(e-t<1)return"";let o,i=[],s=0,c;for(;t<e;)c=r[t++],c<128?i[s++]=c:c>191&&c<224?i[s++]=(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,i[s++]=55296+(c>>10),i[s++]=56320+(c&1023)):i[s++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function yn(r,t,e){let n=e,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,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 St(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function fr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var wn=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,St(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 St(this,4);return fr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw St(this,4);return fr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw St(this,4);let t=fi(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw St(this,4);let t=di(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw St(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return mi(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw St(this,t);this.pos+=t}else do if(this.pos>=this.len)throw St(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 gt(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 St(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 St(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 St(this,8);let t=fr(this.buf,this.pos+=4),e=fr(this.buf,this.pos+=4);return new gt(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=xn(this.buf,this.pos);return this.pos+=xt(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 En(r){return new wn(r instanceof Uint8Array?r:r.subarray())}function lr(r,t,e){let n=En(r);return t.decode(n,void 0,e)}var vn={};ht(vn,{base10:()=>ba});var ba=Ht({prefix:"9",name:"base10",alphabet:"0123456789"});var Sn={};ht(Sn,{base16:()=>ya,base16upper:()=>wa});var ya=X({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),wa=X({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Bn={};ht(Bn,{base2:()=>Ea});var Ea=X({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var An={};ht(An,{base256emoji:()=>Ia});var gi=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),va=gi.reduce((r,t,e)=>(r[e]=t,r),[]),Sa=gi.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Ba(r){return r.reduce((t,e)=>(t+=va[e],t),"")}function Aa(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Sa[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Ia=pe({prefix:"\u{1F680}",name:"base256emoji",encode:Ba,decode:Aa});var In={};ht(In,{base64:()=>Ta,base64pad:()=>Ca,base64url:()=>La,base64urlpad:()=>Pa});var Ta=X({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ca=X({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),La=X({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Pa=X({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Tn={};ht(Tn,{base8:()=>Ra});var Ra=X({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Cn={};ht(Cn,{identity:()=>Ua});var Ua=pe({prefix:"\0",name:"identity",encode:r=>Bo(r),decode:r=>So(r)});var Hl=new TextEncoder,Kl=new TextDecoder;var Rn={};ht(Rn,{sha256:()=>Me,sha512:()=>Da});function Pn({name:r,code:t,encode:e}){return new Ln(r,t,e)}var Ln=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 yi(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Me=Pn({name:"sha2-256",code:18,encode:yi("SHA-256")}),Da=Pn({name:"sha2-512",code:19,encode:yi("SHA-512")});var He={...Cn,...Bn,...Tn,...vn,...Sn,...qr,...Vr,...Kr,...In,...An},Ql={...Rn,...Gr};function Ei(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var wi=Ei("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Un=Ei("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=vt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Oa={utf8:wi,"utf-8":wi,hex:He.base16,latin1:Un,ascii:Un,binary:Un,...He},dr=Oa;function Ot(r,t="utf8"){let e=dr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Nn(r){let t=r??8192,e=t>>>1,n,o=t;return function(s){if(s<1||s>e)return vt(s);o+s>t&&(n=vt(t),o=0);let c=n.subarray(o,o+=s);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 _n(){}var On=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},ka=Nn();function Ma(r){return globalThis.Buffer!=null?vt(r):ka(r)}var qe=class{len;head;tail;states;constructor(){this.len=0,this.head=new ae(_n,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 kn((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(hr,10,gt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=gt.fromBigInt(t);return this._push(hr,e.length(),e)}uint64Number(t){return this._push(mn,xt(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=gt.fromBigInt(t).zzEncode();return this._push(hr,e.length(),e)}sint64Number(t){let e=gt.fromNumber(t).zzEncode();return this._push(hr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Dn,1,t?1:0)}fixed32(t){return this._push(Ke,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=gt.fromBigInt(t);return this._push(Ke,4,e.lo)._push(Ke,4,e.hi)}fixed64Number(t){let e=gt.fromNumber(t);return this._push(Ke,4,e.lo)._push(Ke,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(ui,4,t)}double(t){return this._push(li,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Dn,1,0):this.uint32(e)._push(Ka,e,t)}string(t){let e=pi(t);return e!==0?this.uint32(e)._push(yn,e,t):this._push(Dn,1,0)}fork(){return this.states=new On(this),this.head=this.tail=new ae(_n,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(_n,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=Ma(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Dn(r,t,e){t[e]=r&255}function Ha(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var kn=class extends ae{next;constructor(t,e){super(Ha,t,e),this.next=void 0}};function hr(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 Ke(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 Ka(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(qa,t,r),this},qe.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Va,t,r),this});function qa(r,t,e){t.set(r,e)}function Va(r,t,e){r.length<40?yn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Ot(r),e)}function Mn(){return new qe}function pr(r,t){let e=Mn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Be;(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"})(Be||(Be={}));function mr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Hn(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(i,s){let c=t(i);s.int32(c)},n=function(i){let s=i.int32();return t(s)};return mr("enum",Be.VARINT,e,n)}function xr(r,t){return mr("message",Be.LENGTH_DELIMITED,r,t)}var bt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(bt||(bt={}));var Kn;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(Kn||(Kn={}));(function(r){r.codec=()=>Hn(Kn)})(bt||(bt={}));var Ve;(function(r){let t;r.codec=()=>(t==null&&(t=xr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),bt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.Type=bt.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>pr(e,r.codec()),r.decode=(e,n)=>lr(e,r.codec(),n)})(Ve||(Ve={}));var qn;(function(r){let t;r.codec=()=>(t==null&&(t=xr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),bt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.Type=bt.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>pr(e,r.codec()),r.decode=(e,n)=>lr(e,r.codec(),n)})(qn||(qn={}));var Fa=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]),jt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Wt=new Uint32Array(64),Vn=class extends Ee{constructor(){super(64,32,8,!1),this.A=jt[0]|0,this.B=jt[1]|0,this.C=jt[2]|0,this.D=jt[3]|0,this.E=jt[4]|0,this.F=jt[5]|0,this.G=jt[6]|0,this.H=jt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:i,F:s,G:c,H:a}=this;return[t,e,n,o,i,s,c,a]}set(t,e,n,o,i,s,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}process(t,e){for(let m=0;m<16;m++,e+=4)Wt[m]=t.getUint32(e,!1);for(let m=16;m<64;m++){let p=Wt[m-15],E=Wt[m-2],y=yt(p,7)^yt(p,18)^p>>>3,g=yt(E,17)^yt(E,19)^E>>>10;Wt[m]=g+Wt[m-7]+y+Wt[m-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:d,H:u}=this;for(let m=0;m<64;m++){let p=yt(c,6)^yt(c,11)^yt(c,25),E=u+p+qo(c,a,d)+Fa[m]+Wt[m]|0,g=(yt(n,2)^yt(n,13)^yt(n,22))+Vo(n,o,i)|0;u=d,d=a,a=c,c=s+E|0,s=i,i=o,o=n,n=E+g|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,d=d+this.G|0,u=u+this.H|0,this.set(n,o,i,s,c,a,d,u)}roundClean(){Wt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var vi=Ye(()=>new Vn);function rt(r,t="utf8"){let e=dr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}function It(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=vt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var ze=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var gr=class extends we{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Mo(t);let n=_e(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,i=new Uint8Array(o);i.set(n.length>o?t.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(t){return ye(this),this.iHash.update(t),this}digestInto(t){ye(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:i,blockLen:s,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,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()}},zn=(r,t,e)=>new gr(r,t).update(e).digest();zn.create=(r,t)=>new gr(r,t);function Si(r){r.lowS!==void 0&&wt("lowS",r.lowS),r.prehash!==void 0&&wt("prehash",r.prehash)}function Ga(r){let t=ke(r);At(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{bytesToNumberBE:Za,hexToBytes:ja}=er,Fn=class extends Error{constructor(t=""){super(t)}},kt={Err:Fn,_tlv:{encode:(r,t)=>{let{Err:e}=kt;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=ee(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let i=n>127?ee(o.length/2|128):"";return ee(r)+i+o+t},decode(r,t){let{Err:e}=kt,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++],i=!!(o&128),s=0;if(!i)s=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 d=t.subarray(n,n+a);if(d.length!==a)throw new e("tlv.decode: length bytes not complete");if(d[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of d)s=s<<8|u;if(n+=a,s<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+s);if(c.length!==s)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+s)}}},_int:{encode(r){let{Err:t}=kt;if(r<Mt)throw new t("integer: negative integers are not allowed");let e=ee(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}=kt;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 Za(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=kt,o=typeof r=="string"?ja(r):r;ve(o);let{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,i),{v:d,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(d)}},hexFromSig(r){let{_tlv:t,_int:e}=kt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),i=n+o;return t.encode(48,i)}},Mt=BigInt(0),it=BigInt(1),Zd=BigInt(2),Bi=BigInt(3),jd=BigInt(4);function Wa(r){let t=Ga(r),{Fp:e}=t,n=Gt(t.n,t.nBitLength),o=t.toBytes||((g,f,w)=>{let B=f.toAffine();return Dt(Uint8Array.from([4]),e.toBytes(B.x),e.toBytes(B.y))}),i=t.fromBytes||(g=>{let f=g.subarray(1),w=e.fromBytes(f.subarray(0,e.BYTES)),B=e.fromBytes(f.subarray(e.BYTES,2*e.BYTES));return{x:w,y:B}});function s(g){let{a:f,b:w}=t,B=e.sqr(g),h=e.mul(B,g);return e.add(e.add(h,e.mul(g,f)),w)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function c(g){return De(g,it,t.n)}function a(g){let{allowedPrivateKeyLengths:f,nByteLength:w,wrapPrivateKey:B,n:h}=t;if(f&&typeof g!="bigint"){if(Vt(g)&&(g=Nt(g)),typeof g!="string"||!f.includes(g.length))throw new Error("invalid private key");g=g.padStart(w*2,"0")}let I;try{I=typeof g=="bigint"?g:_t(Y("private key",g,w))}catch{throw new Error("invalid private key, expected hex or "+w+" bytes, got "+typeof g)}return B&&(I=F(I,h)),pt("private key",I,it,h),I}function d(g){if(!(g instanceof p))throw new Error("ProjectivePoint expected")}let u=oe((g,f)=>{let{px:w,py:B,pz:h}=g;if(e.eql(h,e.ONE))return{x:w,y:B};let I=g.is0();f==null&&(f=I?e.ONE:e.inv(h));let N=e.mul(w,f),R=e.mul(B,f),T=e.mul(h,f);if(I)return{x:e.ZERO,y:e.ZERO};if(!e.eql(T,e.ONE))throw new Error("invZ was invalid");return{x:N,y:R}}),m=oe(g=>{if(g.is0()){if(t.allowInfinityPoint&&!e.is0(g.py))return;throw new Error("bad point: ZERO")}let{x:f,y:w}=g.toAffine();if(!e.isValid(f)||!e.isValid(w))throw new Error("bad point: x or y not FE");let B=e.sqr(w),h=s(f);if(!e.eql(B,h))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(f,w,B){if(this.px=f,this.py=w,this.pz=B,f==null||!e.isValid(f))throw new Error("x required");if(w==null||!e.isValid(w))throw new Error("y required");if(B==null||!e.isValid(B))throw new Error("z required");Object.freeze(this)}static fromAffine(f){let{x:w,y:B}=f||{};if(!f||!e.isValid(w)||!e.isValid(B))throw new Error("invalid affine point");if(f instanceof p)throw new Error("projective point not allowed");let h=I=>e.eql(I,e.ZERO);return h(w)&&h(B)?p.ZERO:new p(w,B,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(f){let w=e.invertBatch(f.map(B=>B.pz));return f.map((B,h)=>B.toAffine(w[h])).map(p.fromAffine)}static fromHex(f){let w=p.fromAffine(i(Y("pointHex",f)));return w.assertValidity(),w}static fromPrivateKey(f){return p.BASE.multiply(a(f))}static msm(f,w){return ir(p,n,f,w)}_setWindowSize(f){y.setWindowSize(this,f)}assertValidity(){m(this)}hasEvenY(){let{y:f}=this.toAffine();if(e.isOdd)return!e.isOdd(f);throw new Error("Field doesn't support isOdd")}equals(f){d(f);let{px:w,py:B,pz:h}=this,{px:I,py:N,pz:R}=f,T=e.eql(e.mul(w,R),e.mul(I,h)),P=e.eql(e.mul(B,R),e.mul(N,h));return T&&P}negate(){return new p(this.px,e.neg(this.py),this.pz)}double(){let{a:f,b:w}=t,B=e.mul(w,Bi),{px:h,py:I,pz:N}=this,R=e.ZERO,T=e.ZERO,P=e.ZERO,C=e.mul(h,h),j=e.mul(I,I),q=e.mul(N,N),H=e.mul(h,I);return H=e.add(H,H),P=e.mul(h,N),P=e.add(P,P),R=e.mul(f,P),T=e.mul(B,q),T=e.add(R,T),R=e.sub(j,T),T=e.add(j,T),T=e.mul(R,T),R=e.mul(H,R),P=e.mul(B,P),q=e.mul(f,q),H=e.sub(C,q),H=e.mul(f,H),H=e.add(H,P),P=e.add(C,C),C=e.add(P,C),C=e.add(C,q),C=e.mul(C,H),T=e.add(T,C),q=e.mul(I,N),q=e.add(q,q),C=e.mul(q,H),R=e.sub(R,C),P=e.mul(q,j),P=e.add(P,P),P=e.add(P,P),new p(R,T,P)}add(f){d(f);let{px:w,py:B,pz:h}=this,{px:I,py:N,pz:R}=f,T=e.ZERO,P=e.ZERO,C=e.ZERO,j=t.a,q=e.mul(t.b,Bi),H=e.mul(w,I),tt=e.mul(B,N),S=e.mul(h,R),L=e.add(w,B),x=e.add(I,N);L=e.mul(L,x),x=e.add(H,tt),L=e.sub(L,x),x=e.add(w,h);let l=e.add(I,R);return x=e.mul(x,l),l=e.add(H,S),x=e.sub(x,l),l=e.add(B,h),T=e.add(N,R),l=e.mul(l,T),T=e.add(tt,S),l=e.sub(l,T),C=e.mul(j,x),T=e.mul(q,S),C=e.add(T,C),T=e.sub(tt,C),C=e.add(tt,C),P=e.mul(T,C),tt=e.add(H,H),tt=e.add(tt,H),S=e.mul(j,S),x=e.mul(q,x),tt=e.add(tt,S),S=e.sub(H,S),S=e.mul(j,S),x=e.add(x,S),H=e.mul(tt,x),P=e.add(P,H),H=e.mul(l,x),T=e.mul(L,T),T=e.sub(T,H),H=e.mul(L,tt),C=e.mul(l,C),C=e.add(C,H),new p(T,P,C)}subtract(f){return this.add(f.negate())}is0(){return this.equals(p.ZERO)}wNAF(f){return y.wNAFCached(this,f,p.normalizeZ)}multiplyUnsafe(f){let{endo:w,n:B}=t;pt("scalar",f,Mt,B);let h=p.ZERO;if(f===Mt)return h;if(this.is0()||f===it)return this;if(!w||y.hasPrecomputes(this))return y.wNAFCachedUnsafe(this,f,p.normalizeZ);let{k1neg:I,k1:N,k2neg:R,k2:T}=w.splitScalar(f),P=h,C=h,j=this;for(;N>Mt||T>Mt;)N&it&&(P=P.add(j)),T&it&&(C=C.add(j)),j=j.double(),N>>=it,T>>=it;return I&&(P=P.negate()),R&&(C=C.negate()),C=new p(e.mul(C.px,w.beta),C.py,C.pz),P.add(C)}multiply(f){let{endo:w,n:B}=t;pt("scalar",f,it,B);let h,I;if(w){let{k1neg:N,k1:R,k2neg:T,k2:P}=w.splitScalar(f),{p:C,f:j}=this.wNAF(R),{p:q,f:H}=this.wNAF(P);C=y.constTimeNegate(N,C),q=y.constTimeNegate(T,q),q=new p(e.mul(q.px,w.beta),q.py,q.pz),h=C.add(q),I=j.add(H)}else{let{p:N,f:R}=this.wNAF(f);h=N,I=R}return p.normalizeZ([h,I])[0]}multiplyAndAddUnsafe(f,w,B){let h=p.BASE,I=(R,T)=>T===Mt||T===it||!R.equals(h)?R.multiplyUnsafe(T):R.multiply(T),N=I(this,w).add(I(f,B));return N.is0()?void 0:N}toAffine(f){return u(this,f)}isTorsionFree(){let{h:f,isTorsionFree:w}=t;if(f===it)return!0;if(w)return w(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:f,clearCofactor:w}=t;return f===it?this:w?w(p,this):this.multiplyUnsafe(t.h)}toRawBytes(f=!0){return wt("isCompressed",f),this.assertValidity(),o(p,this,f)}toHex(f=!0){return wt("isCompressed",f),Nt(this.toRawBytes(f))}}p.BASE=new p(t.Gx,t.Gy,e.ONE),p.ZERO=new p(e.ZERO,e.ONE,e.ZERO);let E=t.nBitLength,y=or(p,t.endo?Math.ceil(E/2):E);return{CURVE:t,ProjectivePoint:p,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:c}}function $a(r){let t=ke(r);return At(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Ai(r){let t=$a(r),{Fp:e,n}=t,o=e.BYTES+1,i=2*e.BYTES+1;function s(S){return F(S,n)}function c(S){return rr(S,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:d,weierstrassEquation:u,isWithinCurveOrder:m}=Wa({...t,toBytes(S,L,x){let l=L.toAffine(),b=e.toBytes(l.x),A=Dt;return wt("isCompressed",x),x?A(Uint8Array.from([L.hasEvenY()?2:3]),b):A(Uint8Array.from([4]),b,e.toBytes(l.y))},fromBytes(S){let L=S.length,x=S[0],l=S.subarray(1);if(L===o&&(x===2||x===3)){let b=_t(l);if(!De(b,it,e.ORDER))throw new Error("Point is not on curve");let A=u(b),_;try{_=e.sqrt(A)}catch(K){let O=K instanceof Error?": "+K.message:"";throw new Error("Point is not on curve"+O)}let D=(_&it)===it;return(x&1)===1!==D&&(_=e.neg(_)),{x:b,y:_}}else if(L===i&&x===4){let b=e.fromBytes(l.subarray(0,e.BYTES)),A=e.fromBytes(l.subarray(e.BYTES,2*e.BYTES));return{x:b,y:A}}else{let b=o,A=i;throw new Error("invalid Point, expected length of "+b+", or uncompressed "+A+", got "+L)}}}),p=S=>Nt(Ft(S,t.nByteLength));function E(S){let L=n>>it;return S>L}function y(S){return E(S)?s(-S):S}let g=(S,L,x)=>_t(S.slice(L,x));class f{constructor(L,x,l){this.r=L,this.s=x,this.recovery=l,this.assertValidity()}static fromCompact(L){let x=t.nByteLength;return L=Y("compactSignature",L,x*2),new f(g(L,0,x),g(L,x,2*x))}static fromDER(L){let{r:x,s:l}=kt.toSig(Y("DER",L));return new f(x,l)}assertValidity(){pt("r",this.r,it,n),pt("s",this.s,it,n)}addRecoveryBit(L){return new f(this.r,this.s,L)}recoverPublicKey(L){let{r:x,s:l,recovery:b}=this,A=R(Y("msgHash",L));if(b==null||![0,1,2,3].includes(b))throw new Error("recovery id invalid");let _=b===2||b===3?x+t.n:x;if(_>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let D=(b&1)===0?"02":"03",M=a.fromHex(D+p(_)),K=c(_),O=s(-A*K),z=s(l*K),Z=a.BASE.multiplyAndAddUnsafe(M,O,z);if(!Z)throw new Error("point at infinify");return Z.assertValidity(),Z}hasHighS(){return E(this.s)}normalizeS(){return this.hasHighS()?new f(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return re(this.toDERHex())}toDERHex(){return kt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return re(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let w={isValidPrivateKey(S){try{return d(S),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{let S=nn(t.n);return Xo(t.randomBytes(S),t.n)},precompute(S=8,L=a.BASE){return L._setWindowSize(S),L.multiply(BigInt(3)),L}};function B(S,L=!0){return a.fromPrivateKey(S).toRawBytes(L)}function h(S){let L=Vt(S),x=typeof S=="string",l=(L||x)&&S.length;return L?l===o||l===i:x?l===2*o||l===2*i:S instanceof a}function I(S,L,x=!0){if(h(S))throw new Error("first arg must be private key");if(!h(L))throw new Error("second arg must be public key");return a.fromHex(L).multiply(d(S)).toRawBytes(x)}let N=t.bits2int||function(S){if(S.length>8192)throw new Error("input is too large");let L=_t(S),x=S.length*8-t.nBitLength;return x>0?L>>BigInt(x):L},R=t.bits2int_modN||function(S){return s(N(S))},T=Oe(t.nBitLength);function P(S){return pt("num < 2^"+t.nBitLength,S,Mt,T),Ft(S,t.nByteLength)}function C(S,L,x=j){if(["recovered","canonical"].some(ot=>ot in x))throw new Error("sign() legacy options not supported");let{hash:l,randomBytes:b}=t,{lowS:A,prehash:_,extraEntropy:D}=x;A==null&&(A=!0),S=Y("msgHash",S),Si(x),_&&(S=Y("prehashed msgHash",l(S)));let M=R(S),K=d(L),O=[P(K),P(M)];if(D!=null&&D!==!1){let ot=D===!0?b(e.BYTES):D;O.push(Y("extraEntropy",ot))}let z=Dt(...O),Z=M;function nt(ot){let st=N(ot);if(!m(st))return;let ct=c(st),dt=a.BASE.multiply(st).toAffine(),ft=s(dt.x);if(ft===Mt)return;let Bt=s(ct*s(Z+ft*K));if(Bt===Mt)return;let Tt=(dt.x===ft?0:2)|Number(dt.y&it),Ce=Bt;return A&&E(Bt)&&(Ce=y(Bt),Tt^=1),new f(ft,Ce,Tt)}return{seed:z,k2sig:nt}}let j={lowS:t.lowS,prehash:!1},q={lowS:t.lowS,prehash:!1};function H(S,L,x=j){let{seed:l,k2sig:b}=C(S,L,x),A=t;return Jr(A.hash.outputLen,A.nByteLength,A.hmac)(l,b)}a.BASE._setWindowSize(8);function tt(S,L,x,l=q){let b=S;L=Y("msgHash",L),x=Y("publicKey",x);let{lowS:A,prehash:_,format:D}=l;if(Si(l),"strict"in l)throw new Error("options.strict was renamed to lowS");if(D!==void 0&&D!=="compact"&&D!=="der")throw new Error("format must be compact or der");let M=typeof b=="string"||Vt(b),K=!M&&!D&&typeof b=="object"&&b!==null&&typeof b.r=="bigint"&&typeof b.s=="bigint";if(!M&&!K)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let O,z;try{if(K&&(O=new f(b.r,b.s)),M){try{D!=="compact"&&(O=f.fromDER(b))}catch(Tt){if(!(Tt instanceof kt.Err))throw Tt}!O&&D!=="der"&&(O=f.fromCompact(b))}z=a.fromHex(x)}catch{return!1}if(!O||A&&O.hasHighS())return!1;_&&(L=t.hash(L));let{r:Z,s:nt}=O,ot=R(L),st=c(nt),ct=s(ot*st),dt=s(Z*st),ft=a.BASE.multiplyAndAddUnsafe(z,ct,dt)?.toAffine();return ft?s(ft.x)===Z:!1}return{CURVE:t,getPublicKey:B,getSharedSecret:I,sign:H,verify:tt,ProjectivePoint:a,Signature:f,utils:w}}function Ya(r){return{hash:r,hmac:(t,...e)=>zn(r,t,Zr(...e)),randomBytes:Xe}}function Ii(r,t){let e=n=>Ai({...r,...Ya(n)});return{...e(t),create:e}}var Li=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ti=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Xa=BigInt(1),Gn=BigInt(2),Ci=(r,t)=>(r+t/Gn)/t;function Qa(r){let t=Li,e=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),d=r*r*r%t,u=d*d*r%t,m=$(u,e,t)*u%t,p=$(m,e,t)*u%t,E=$(p,Gn,t)*d%t,y=$(E,o,t)*E%t,g=$(y,i,t)*y%t,f=$(g,c,t)*g%t,w=$(f,a,t)*f%t,B=$(w,c,t)*g%t,h=$(B,e,t)*u%t,I=$(h,s,t)*y%t,N=$(I,n,t)*d%t,R=$(N,Gn,t);if(!Zn.eql(Zn.sqr(R),r))throw new Error("Cannot find square root");return R}var Zn=Gt(Li,void 0,void 0,{sqrt:Qa}),ue=Ii({a:BigInt(0),b:BigInt(7),Fp:Zn,n:Ti,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Ti,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Xa*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,s=BigInt("0x100000000000000000000000000000000"),c=Ci(i*r,t),a=Ci(-n*r,t),d=F(r-c*e-a*o,t),u=F(-c*n-a*i,t),m=d>s,p=u>s;if(m&&(d=t-d),p&&(u=t-u),d>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:m,k1:d,k2neg:p,k2:u}}}},vi),rh=BigInt(0);var nh=ue.ProjectivePoint;function Pi(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Ri(r,t,e){let n=Me.digest(e instanceof Uint8Array?e:e.subarray());if(Pi(n))return n.then(({digest:o})=>ue.verify(t,o,r)).catch(o=>{throw new ze(String(o))});try{return ue.verify(t,n.digest,r)}catch(o){throw new ze(String(o))}}var br=class{type="secp256k1";raw;_key;constructor(t){this._key=Ni(t),this.raw=Ui(this._key)}toMultihash(){return Pt.digest(ur(this))}toCID(){return lt.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Rt(this.raw,t.raw)}verify(t,e){return Ri(this._key,e,t)}};function _i(r){return new br(r)}function Ui(r){return ue.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Ni(r){try{return ue.ProjectivePoint.fromHex(r),r}catch(t){throw new Ge(String(t))}}function Di(r){let{Type:t,Data:e}=Ve.decode(r.digest),n=e??new Uint8Array;switch(t){case bt.Ed25519:return ci(n);case bt.secp256k1:return _i(n);default:throw new Le}}function ur(r){return Ve.encode({Type:bt[r.type],Data:r.raw})}var Oi=Symbol.for("nodejs.util.inspect.custom"),Ja=114,Fe=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()})`}[Dr]=!0;toString(){return this.string==null&&(this.string=Q.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return lt.createV1(Ja,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Rt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Rt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Oi](){return`PeerId(${this.toString()})`}},yr=class extends Fe{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},wr=class extends Fe{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Er=class extends Fe{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},tu=2336,vr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Pt.digest(Ot(this.url))}[Oi](){return`PeerId(${this.url})`}[Dr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return lt.createV1(tu,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=rt(t)),t.toString()===this.toString())}};function ki(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=Qt(Q.decode(`z${r}`));else{if(t==null)throw new he('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=Qt(t.decode(r))}return eu(e)}function eu(r){if(nu(r))return new yr({multihash:r});if(ru(r))try{let t=Di(r);if(t.type==="Ed25519")return new wr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Er({multihash:r,publicKey:t})}catch{let e=rt(r.digest);return new vr(new URL(e))}throw new Ze("Supplied PeerID Multihash is invalid")}function ru(r){return r.code===Pt.code}function nu(r){return r.code===Me.code}var Sr=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 i=0,s=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",d=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let m=this.readChar();if(m===void 0)return;let p=Number.parseInt(m,t);if(!Number.isNaN(p))return p});if(u===void 0)break;if(i*=t,i+=u,i>d||(s+=1,e!==void 0&&s>e))return}if(s!==0)return!n&&a&&s>1?void 0:i})}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 s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return e[o]=s[0],e[o+1]=s[1],e[o+2]=s[2],e[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];e[o]=i>>8,e[o+1]=i&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 i=new Uint8Array(14),s=16-(n+2),[c]=t(i.subarray(0,s));return e.set(i.subarray(0,c),16-c),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Mi=45,ou=15,Ae=new Sr;function jn(r){if(!(r.length>ou))return Ae.new(r).parseWith(()=>Ae.readIPv4Addr())}function Wn(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Mi))return Ae.new(r).parseWith(()=>Ae.readIPv6Addr())}function Br(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>Mi)return;let e=Ae.new(r).parseWith(()=>Ae.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 hp=parseInt("0xFFFF",16),pp=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function qi(r){return!!jn(r)}function Vi(r){return!!Wn(r)}function Ar(r){return!!Br(r)}var zi=qi,uu=Vi,$n=function(r){let t=0;if(r=r.toString().trim(),zi(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(uu(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=zi(e[n]),s;i&&(s=$n(e[n]),e[n]=rt(s.slice(0,2),"base16")),s!=null&&++n<8&&e.splice(n,0,rt(s.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 i=[n,1];for(n=9-e.length;n>0;n--)i.push("0");e.splice.apply(e,i)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let i=parseInt(e[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},Fi=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 i=0;i<e;i++)o.push(r[t+i]);return o.join(".")}if(e===16){let o=[];for(let i=0;i<e;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Ie={},Yn={},lu=[[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"]];lu.forEach(r=>{let t=du(...r);Yn[t.code]=t,Ie[t.name]=t});function du(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function G(r){if(typeof r=="number"){if(Yn[r]!=null)return Yn[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ie[r]!=null)return Ie[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Xp=G("ip4"),Qp=G("ip6"),Jp=G("ipcidr");function to(r,t){switch(G(r).code){case 4:case 41:return pu(t);case 42:return Jn(t);case 43:return rt(t,"base10");case 6:case 273:case 33:case 132:return ji(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Jn(t);case 421:return bu(t);case 444:return Zi(t);case 445:return Zi(t);case 466:return gu(t);case 481:return globalThis.encodeURIComponent(Jn(t));default:return rt(t,"base16")}}function eo(r,t){switch(G(r).code){case 4:return Gi(t);case 41:return Gi(t);case 42:return Qn(t);case 43:return Ot(t,"base10");case 6:case 273:case 33:case 132:return ro(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Qn(t);case 421:return mu(t);case 444:return yu(t);case 445:return wu(t);case 466:return xu(t);case 481:return Qn(globalThis.decodeURIComponent(t));default:return Ot(t,"base16")}}var Xn=Object.values(He).map(r=>r.decoder),hu=function(){let r=Xn[0].or(Xn[1]);return Xn.slice(2).forEach(t=>r=r.or(t)),r}();function Gi(r){if(!Ar(r))throw new Error("invalid ip address");return $n(r)}function pu(r){let t=Fi(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Ar(t))throw new Error("invalid ip address");return t}function ro(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function ji(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Qn(r){let t=Ot(r),e=Uint8Array.from(Se(t.length));return It([e,t],e.length+t.length)}function Jn(r){let t=se(r);if(r=r.slice(xt(t)),r.length!==t)throw new Error("inconsistent lengths");return rt(r)}function mu(r){let t;r[0]==="Q"||r[0]==="1"?t=Qt(Q.decode(`z${r}`)).bytes:t=lt.parse(r).multihash.bytes;let e=Uint8Array.from(Se(t.length));return It([e,t],e.length+t.length)}function xu(r){let t=hu.decode(r),e=Uint8Array.from(Se(t.length));return It([e,t],e.length+t.length)}function gu(r){let t=se(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+rt(e,"base64url")}function bu(r){let t=se(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return rt(e,"base58btc")}function yu(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=Lt.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=ro(n);return It([e,o],e.length+o.length)}function wu(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=Lt.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=ro(n);return It([e,o],e.length+o.length)}function Zi(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=rt(t,"base32"),o=ji(e);return`${n}:${o}`}function Wi(r){r=no(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 i=0;i<o.length;i++){let s=o[i],c=G(s);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(i++,i>=o.length)throw new Ir("invalid address: "+r);if(c.path===!0){n=no(o.slice(i).join("/")),t.push([c.code,eo(c.code,n)]),e.push([c.code,n]);break}let a=eo(c.code,o[i]);t.push([c.code,a]),e.push([c.code,to(c.code,a)])}return{string:$i(e),bytes:Tr(t),tuples:t,stringTuples:e,path:n}}function oo(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=se(r,o),s=xt(i),c=G(i),a=Eu(c,r.slice(o+s));if(a===0){t.push([i]),e.push([i]),o+=s;continue}let d=r.slice(o+s,o+s+a);if(o+=a+s,o>r.length)throw new Ir("Invalid address Uint8Array: "+rt(r,"base16"));t.push([i,d]);let u=to(i,d);if(e.push([i,u]),c.path===!0){n=u;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}),no(t.join("/"))}function Tr(r){return It(r.map(t=>{let e=G(t[0]),n=Uint8Array.from(Se(e.code));return t.length>1&&t[1]!=null&&(n=It([n,t[1]])),n}))}function Eu(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=se(t instanceof Uint8Array?t:Uint8Array.from(t));return e+xt(e)}}function no(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var Ir=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var vu=Symbol.for("nodejs.util.inspect.custom"),so=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Su=[G("dns").code,G("dns4").code,G("dns6").code,G("dnsaddr").code],io=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Cr=class r{bytes;#t;#e;#r;#n;[so]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=oo(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Wi(t)}else if(Xi(t))e=oo(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,i="",s=G("tcp"),c=G("udp"),a=G("ip4"),d=G("ip6"),u=G("dns6"),m=G("ip6zone");for(let[E,y]of this.stringTuples())E===m.code&&(i=`%${y??""}`),Su.includes(E)&&(e=s.name==="tcp"?"tcp":"udp",o=443,n=`${y??""}${i}`,t=E===u.code?6:4),(E===s.code||E===c.code)&&(e=G(E).name==="tcp"?"tcp":"udp",o=parseInt(y??"")),(E===a.code||E===d.code)&&(e=G(E).name==="tcp"?"tcp":"udp",n=`${y??""}${i}`,t=E===d.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(Tr(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===Ie.p2p.code&&t.push([n,o]),n===Ie["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?rt(Q.decode(`z${n}`),"base58btc"):rt(lt.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Rt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=Yi.get(e.name);if(n==null)throw new io(`no available resolver for ${e.name}`);return(await n(this,t)).map(i=>$t(i))}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)}[vu](){return`Multiaddr(${this.#t})`}};var Yi=new Map;function Xi(r){return!!r?.[so]}function $t(r){return new Cr(r)}var Bu=v("dns4"),Au=v("dns6"),Iu=v("dnsaddr"),le=J(v("dns"),Iu,Bu,Au),Rr=J(v("ip4"),v("ip6")),Te=J(U(Rr,v("tcp")),U(le,v("tcp"))),Ur=U(Rr,v("udp")),Tu=U(Ur,v("utp")),Cu=U(Ur,v("quic")),Lu=U(Ur,v("quic-v1")),co=J(U(Te,v("ws")),U(le,v("ws"))),Lr=J(U(co,v("p2p")),co),ao=J(U(Te,v("wss")),U(le,v("wss")),U(Te,v("tls"),v("ws")),U(le,v("tls"),v("ws"))),Pr=J(U(ao,v("p2p")),ao),uo=J(U(Te,v("http")),U(Rr,v("http")),U(le,v("http"))),fo=J(U(Te,v("https")),U(Rr,v("https")),U(le,v("https"))),Qi=U(Ur,v("webrtc-direct"),v("certhash")),es=J(U(Qi,v("p2p")),Qi),Ji=U(Lu,v("webtransport"),v("certhash"),v("certhash")),rs=J(U(Ji,v("p2p")),Ji),ns=J(U(Lr,v("p2p-webrtc-star"),v("p2p")),U(Pr,v("p2p-webrtc-star"),v("p2p")),U(Lr,v("p2p-webrtc-star")),U(Pr,v("p2p-webrtc-star"))),I0=J(U(Lr,v("p2p-websocket-star"),v("p2p")),U(Pr,v("p2p-websocket-star"),v("p2p")),U(Lr,v("p2p-websocket-star")),U(Pr,v("p2p-websocket-star"))),os=J(U(uo,v("p2p-webrtc-direct"),v("p2p")),U(fo,v("p2p-webrtc-direct"),v("p2p")),U(uo,v("p2p-webrtc-direct")),U(fo,v("p2p-webrtc-direct"))),de=J(co,ao,uo,fo,ns,os,Te,Tu,Cu,le,es,rs),T0=J(U(de,v("p2p-stardust"),v("p2p")),U(de,v("p2p-stardust"))),Yt=J(U(de,v("p2p")),ns,os,es,rs,v("p2p")),ts=J(U(Yt,v("p2p-circuit"),Yt),U(Yt,v("p2p-circuit")),U(v("p2p-circuit"),Yt),U(de,v("p2p-circuit")),U(v("p2p-circuit"),de),v("p2p-circuit")),is=()=>J(U(ts,is),ts),fe=is(),ss=J(U(fe,Yt,fe),U(Yt,fe),U(fe,Yt),fe,Yt);var C0=J(U(fe,v("webrtc"),v("p2p")),U(fe,v("webrtc")),U(de,v("webrtc"),v("p2p")),U(de,v("webrtc")),v("webrtc"));function cs(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 U(...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:cs(t),partialMatch:t}}function J(...r){function t(n){let o=null;return r.some(i=>{let s=typeof i=="function"?i().partialMatch(n):i.partialMatch(n);return s!=null?(o=s,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:cs(t),partialMatch:t}}function v(r){let t=r;function e(o){let i;try{i=$t(o)}catch{return!1}let s=i.protoNames();return s.length===1&&s[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 Pu="bootstrap",Ru=50,Uu=1e3,lo=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??Uu,this.list=[];for(let n of e.list){if(!ss.matches(n)){this.log.error("Invalid multiaddr");continue}let o=$t(n),i=o.getPeerId();if(i==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let s={id:ki(i),multiaddrs:[o]};this.list.push(s)}this._init=e}[wo]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[Eo]=["@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??Pu]:{value:this._init.tagValue??Ru,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 Nu(r){return t=>new lo(t,r)}return ws(_u);})();
|
|
2
|
+
"use strict";var Libp2PBootstrap=(()=>{var Dr=Object.defineProperty;var ys=Object.getOwnPropertyDescriptor;var ws=Object.getOwnPropertyNames;var Es=Object.prototype.hasOwnProperty;var ht=(r,t)=>{for(var e in t)Dr(r,e,{get:t[e],enumerable:!0})},vs=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ws(t))!Es.call(r,o)&&o!==e&&Dr(r,o,{get:()=>t[o],enumerable:!(n=ys(t,o))||n.enumerable});return r};var Ss=r=>vs(Dr({},"__esModule",{value:!0}),r);var Mu={};ht(Mu,{bootstrap:()=>ku});var Eo=Symbol.for("@libp2p/peer-discovery");var Or=Symbol.for("@libp2p/peer-id");var he=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},je=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Ze=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},We=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Le=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var $e=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:i})=>i!==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 vo=Symbol.for("@libp2p/service-capabilities"),Fu=Symbol.for("@libp2p/service-dependencies");var qr={};ht(qr,{base58btc:()=>Q,base58flickr:()=>Ls});var pf=new Uint8Array(0);function So(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 Ct(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 Bo(r){return new TextEncoder().encode(r)}function Ao(r){return new TextDecoder().decode(r)}function Bs(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 i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var c=r.length,a=r.charAt(0),d=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function m(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var g=0,f=0,w=0,B=y.length;w!==B&&y[w]===0;)w++,g++;for(var h=(B-w)*u+1>>>0,I=new Uint8Array(h);w!==B;){for(var N=y[w],R=0,T=h-1;(N!==0||R<f)&&T!==-1;T--,R++)N+=256*I[T]>>>0,I[T]=N%c>>>0,N=N/c>>>0;if(N!==0)throw new Error("Non-zero carry");f=R,w++}for(var P=h-f;P!==h&&I[P]===0;)P++;for(var C=a.repeat(g);P<h;++P)C+=r.charAt(I[P]);return C}function p(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;var g=0;if(y[g]!==" "){for(var f=0,w=0;y[g]===a;)f++,g++;for(var B=(y.length-g)*d+1>>>0,h=new Uint8Array(B);y[g];){var I=e[y.charCodeAt(g)];if(I===255)return;for(var N=0,R=B-1;(I!==0||N<w)&&R!==-1;R--,N++)I+=c*h[R]>>>0,h[R]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");w=N,g++}if(y[g]!==" "){for(var T=B-w;T!==B&&h[T]===0;)T++;for(var P=new Uint8Array(f+(B-T)),C=f;T!==B;)P[C++]=h[T++];return P}}}function E(y){var g=p(y);if(g)return g;throw new Error(`Non-${t} character`)}return{encode:m,decodeUnsafe:p,decode:E}}var As=Bs,Is=As,To=Is;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")}},Mr=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 Co(this,t)}},Hr=class{decoders;constructor(t){this.decoders=t}or(t){return Co(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 Co(r,t){return new Hr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Kr=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 Mr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function pe({name:r,prefix:t,encode:e,decode:n}){return new Kr(r,t,e,n)}function Ht({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=To(e,r);return pe({prefix:t,name:r,encode:n,decode:i=>Ct(o(i))})}function Ts(r,t,e,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),c=0,a=0,d=0;for(let u=0;u<i;++u){let m=o[r[u]];if(m===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|m,c+=e,c>=8&&(c-=8,s[d++]=255&a>>c)}if(c>=e||(255&a<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return s}function Cs(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],s+=8;s>e;)s-=e,i+=t[o&c>>s];if(s!==0&&(i+=t[o&c<<e-s]),n)for(;(i.length*e&7)!==0;)i+="=";return i}function X({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return pe({prefix:t,name:r,encode(o){return Cs(o,n,e)},decode(o){return Ts(o,n,e,r)}})}var Q=Ht({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ls=Ht({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var zr={};ht(zr,{base32:()=>Lt,base32hex:()=>Ns,base32hexpad:()=>Ds,base32hexpadupper:()=>Os,base32hexupper:()=>_s,base32pad:()=>Rs,base32padupper:()=>Us,base32upper:()=>Ps,base32z:()=>ks});var Lt=X({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ps=X({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Rs=X({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Us=X({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ns=X({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),_s=X({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ds=X({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Os=X({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ks=X({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Vr={};ht(Vr,{base36:()=>Pe,base36upper:()=>Ms});var Pe=Ht({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ms=Ht({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Hs=Ro,Lo=128,Ks=127,qs=~Ks,zs=Math.pow(2,31);function Ro(r,t,e){t=t||[],e=e||0;for(var n=e;r>=zs;)t[e++]=r&255|Lo,r/=128;for(;r&qs;)t[e++]=r&255|Lo,r>>>=7;return t[e]=r|0,Ro.bytes=e-n+1,t}var Vs=Fr,Fs=128,Po=127;function Fr(r,n){var e=0,n=n||0,o=0,i=n,s,c=r.length;do{if(i>=c)throw Fr.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&Po)<<o:(s&Po)*Math.pow(2,o),o+=7}while(s>=Fs);return Fr.bytes=i-n,e}var Gs=Math.pow(2,7),js=Math.pow(2,14),Zs=Math.pow(2,21),Ws=Math.pow(2,28),$s=Math.pow(2,35),Ys=Math.pow(2,42),Xs=Math.pow(2,49),Qs=Math.pow(2,56),Js=Math.pow(2,63),tc=function(r){return r<Gs?1:r<js?2:r<Zs?3:r<Ws?4:r<$s?5:r<Ys?6:r<Xs?7:r<Qs?8:r<Js?9:10},ec={encode:Hs,decode:Vs,encodingLength:tc},rc=ec,Re=rc;function Ue(r,t=0){return[Re.decode(r,t),Re.decode.bytes]}function me(r,t,e=0){return Re.encode(r,t,e),t}function xe(r){return Re.encodingLength(r)}function Xt(r,t){let e=t.byteLength,n=xe(r),o=n+xe(e),i=new Uint8Array(o+e);return me(r,i,0),me(e,i,n),i.set(t,o),new ge(r,e,t,i)}function Qt(r){let t=Ct(r),[e,n]=Ue(t),[o,i]=Ue(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new ge(e,o,s,t)}function Uo(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&So(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 No(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return oc(e,Gr(r),t??Q.encoder);default:return ic(e,Gr(r),t??Lt.encoder)}}var _o=new WeakMap;function Gr(r){let t=_o.get(r);if(t==null){let e=new Map;return _o.set(r,e),e}return t}var ct=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!==Ne)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==sc)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&&Uo(t.multihash,n.multihash)}toString(t){return No(this,t)}toJSON(){return{"/":No(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:i,bytes:s}=e;return new r(n,o,i,s??Do(n,o,i.bytes))}else if(e[cc]===!0){let{version:n,multihash:o,code:i}=e,s=Qt(o);return r.create(n,i,s)}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!==Ne)throw new Error(`Version 0 CID must use dag-pb (code: ${Ne}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Do(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Ne,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=Ct(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),s=new ge(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[m,p]=Ue(t.subarray(e));return e+=p,m},o=n(),i=Ne;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=e,c=n(),a=n(),d=e+a,u=d-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:u,size:d}}static parse(t,e){let[n,o]=nc(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Gr(i).set(n,t),i}};function nc(r,t){switch(r[0]){case"Q":{let e=t??Q;return[Q.prefix,e.decode(`${Q.prefix}${r}`)]}case Q.prefix:{let e=t??Q;return[Q.prefix,e.decode(r)]}case Lt.prefix:{let e=t??Lt;return[Lt.prefix,e.decode(r)]}case Pe.prefix:{let e=t??Pe;return[Pe.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function oc(r,t,e){let{prefix:n}=e;if(n!==Q.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o}function ic(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o}var Ne=112,sc=18;function Do(r,t,e){let n=xe(r),o=n+xe(t),i=new Uint8Array(o+e.byteLength);return me(r,i,0),me(t,i,n),i.set(e,o),i}var cc=Symbol.for("@ipld/js-cid/CID");var jr={};ht(jr,{identity:()=>Pt});var Oo=0,ac="identity",ko=Ct;function uc(r){return Xt(Oo,ko(r))}var Pt={code:Oo,name:ac,encode:ko,digest:uc};function Rt(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 Mo(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function fc(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function be(r,...t){if(!fc(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 Ho(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Mo(r.outputLen),Mo(r.blockLen)}function ye(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 Ko(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 Xe(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function yt(r,t){return r<<32-t|r>>>t}function qo(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function _e(r){return typeof r=="string"&&(r=qo(r)),be(r),r}function Zr(...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 i=r[n];e.set(i,o),o+=i.length}return e}var we=class{clone(){return this._cloneInto()}};function Qe(r){let t=n=>r().update(_e(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Je(r=32){if(te&&typeof te.getRandomValues=="function")return te.getRandomValues(new Uint8Array(r));if(te&&typeof te.randomBytes=="function")return te.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function lc(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(e>>o&i),c=Number(e&i),a=n?4:0,d=n?0:4;r.setUint32(t+a,s,n),r.setUint32(t+d,c,n)}function zo(r,t,e){return r&t^~r&e}function Vo(r,t,e){return r&t^r&e^t&e}var Ee=class extends we{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Xe(this.buffer)}update(t){ye(this);let{view:e,buffer:n,blockLen:o}=this;t=_e(t);let i=t.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=Xe(t);for(;o<=i-s;s+=o)this.process(a,s);continue}n.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ye(this),Ko(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let m=s;m<o;m++)e[m]=0;lc(n,o-8,BigInt(this.length*8),i),this.process(n,0);let c=Xe(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=a/4,u=this.get();if(d>u.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<d;m++)c.setUint32(4*m,u[m],i)}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:i,destroyed:s,pos:c}=this;return t.length=o,t.pos=c,t.finished=i,t.destroyed=s,o%e&&t.buffer.set(n),t}};var tr=BigInt(4294967295),Wr=BigInt(32);function Fo(r,t=!1){return t?{h:Number(r&tr),l:Number(r>>Wr&tr)}:{h:Number(r>>Wr&tr)|0,l:Number(r&tr)|0}}function dc(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:i,l:s}=Fo(r[o],t);[e[o],n[o]]=[i,s]}return[e,n]}var hc=(r,t)=>BigInt(r>>>0)<<Wr|BigInt(t>>>0),pc=(r,t,e)=>r>>>e,mc=(r,t,e)=>r<<32-e|t>>>e,xc=(r,t,e)=>r>>>e|t<<32-e,gc=(r,t,e)=>r<<32-e|t>>>e,bc=(r,t,e)=>r<<64-e|t>>>e-32,yc=(r,t,e)=>r>>>e-32|t<<64-e,wc=(r,t)=>t,Ec=(r,t)=>r,vc=(r,t,e)=>r<<e|t>>>32-e,Sc=(r,t,e)=>t<<e|r>>>32-e,Bc=(r,t,e)=>t<<e-32|r>>>64-e,Ac=(r,t,e)=>r<<e-32|t>>>64-e;function Ic(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var Tc=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Cc=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Lc=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Pc=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Rc=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Uc=(r,t,e,n,o,i)=>t+e+n+o+i+(r/2**32|0)|0;var Nc={fromBig:Fo,split:dc,toBig:hc,shrSH:pc,shrSL:mc,rotrSH:xc,rotrSL:gc,rotrBH:bc,rotrBL:yc,rotr32H:wc,rotr32L:Ec,rotlSH:vc,rotlSL:Sc,rotlBH:Bc,rotlBL:Ac,add:Ic,add3L:Tc,add3H:Cc,add4L:Lc,add4H:Pc,add5H:Uc,add5L:Rc},k=Nc;var[_c,Dc]=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))),Kt=new Uint32Array(80),qt=new Uint32Array(80),$r=class extends Ee{constructor(){super(128,64,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:i,Cl:s,Dh:c,Dl:a,Eh:d,El:u,Fh:m,Fl:p,Gh:E,Gl:y,Hh:g,Hl:f}=this;return[t,e,n,o,i,s,c,a,d,u,m,p,E,y,g,f]}set(t,e,n,o,i,s,c,a,d,u,m,p,E,y,g,f){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=a|0,this.Eh=d|0,this.El=u|0,this.Fh=m|0,this.Fl=p|0,this.Gh=E|0,this.Gl=y|0,this.Hh=g|0,this.Hl=f|0}process(t,e){for(let h=0;h<16;h++,e+=4)Kt[h]=t.getUint32(e),qt[h]=t.getUint32(e+=4);for(let h=16;h<80;h++){let I=Kt[h-15]|0,N=qt[h-15]|0,R=k.rotrSH(I,N,1)^k.rotrSH(I,N,8)^k.shrSH(I,N,7),T=k.rotrSL(I,N,1)^k.rotrSL(I,N,8)^k.shrSL(I,N,7),P=Kt[h-2]|0,C=qt[h-2]|0,Z=k.rotrSH(P,C,19)^k.rotrBH(P,C,61)^k.shrSH(P,C,6),q=k.rotrSL(P,C,19)^k.rotrBL(P,C,61)^k.shrSL(P,C,6),H=k.add4L(T,q,qt[h-7],qt[h-16]),et=k.add4H(H,R,Z,Kt[h-7],Kt[h-16]);Kt[h]=et|0,qt[h]=H|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:d,Dl:u,Eh:m,El:p,Fh:E,Fl:y,Gh:g,Gl:f,Hh:w,Hl:B}=this;for(let h=0;h<80;h++){let I=k.rotrSH(m,p,14)^k.rotrSH(m,p,18)^k.rotrBH(m,p,41),N=k.rotrSL(m,p,14)^k.rotrSL(m,p,18)^k.rotrBL(m,p,41),R=m&E^~m&g,T=p&y^~p&f,P=k.add5L(B,N,T,Dc[h],qt[h]),C=k.add5H(P,w,I,R,_c[h],Kt[h]),Z=P|0,q=k.rotrSH(n,o,28)^k.rotrBH(n,o,34)^k.rotrBH(n,o,39),H=k.rotrSL(n,o,28)^k.rotrBL(n,o,34)^k.rotrBL(n,o,39),et=n&i^n&c^i&c,S=o&s^o&a^s&a;w=g|0,B=f|0,g=E|0,f=y|0,E=m|0,y=p|0,{h:m,l:p}=k.add(d|0,u|0,C|0,Z|0),d=c|0,u=a|0,c=i|0,a=s|0,i=n|0,s=o|0;let L=k.add3L(Z,H,S);n=k.add3H(L,C,q,et),o=L|0}({h:n,l:o}=k.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=k.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=k.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:d,l:u}=k.add(this.Dh|0,this.Dl|0,d|0,u|0),{h:m,l:p}=k.add(this.Eh|0,this.El|0,m|0,p|0),{h:E,l:y}=k.add(this.Fh|0,this.Fl|0,E|0,y|0),{h:g,l:f}=k.add(this.Gh|0,this.Gl|0,g|0,f|0),{h:w,l:B}=k.add(this.Hh|0,this.Hl|0,w|0,B|0),this.set(n,o,i,s,c,a,d,u,m,p,E,y,g,f,w,B)}roundClean(){Kt.fill(0),qt.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 Go=Qe(()=>new $r);var nr={};ht(nr,{aInRange:()=>pt,abool:()=>wt,abytes:()=>ve,bitGet:()=>qc,bitLen:()=>Jr,bitMask:()=>Oe,bitSet:()=>zc,bytesToHex:()=>Nt,bytesToNumberBE:()=>_t,bytesToNumberLE:()=>Vt,concatBytes:()=>Dt,createHmacDrbg:()=>tn,ensureBytes:()=>Y,equalBytes:()=>Hc,hexToBytes:()=>re,hexToNumber:()=>Qr,inRange:()=>De,isBytes:()=>zt,memoized:()=>oe,notImplemented:()=>Fc,numberToBytesBE:()=>Ft,numberToBytesLE:()=>ne,numberToHexUnpadded:()=>ee,numberToVarBytesBE:()=>Mc,utf8ToBytes:()=>Kc,validateObject:()=>At});var er=BigInt(0),rr=BigInt(1),Oc=BigInt(2);function zt(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ve(r){if(!zt(r))throw new Error("Uint8Array expected")}function wt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var kc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Nt(r){ve(r);let t="";for(let e=0;e<r.length;e++)t+=kc[r[e]];return t}function ee(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Qr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?er:BigInt("0x"+r)}var Ut={_0:48,_9:57,A:65,F:70,a:97,f:102};function jo(r){if(r>=Ut._0&&r<=Ut._9)return r-Ut._0;if(r>=Ut.A&&r<=Ut.F)return r-(Ut.A-10);if(r>=Ut.a&&r<=Ut.f)return r-(Ut.a-10)}function re(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof 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,i=0;o<e;o++,i+=2){let s=jo(r.charCodeAt(i)),c=jo(r.charCodeAt(i+1));if(s===void 0||c===void 0){let a=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+i)}n[o]=s*16+c}return n}function _t(r){return Qr(Nt(r))}function Vt(r){return ve(r),Qr(Nt(Uint8Array.from(r).reverse()))}function Ft(r,t){return re(r.toString(16).padStart(t*2,"0"))}function ne(r,t){return Ft(r,t).reverse()}function Mc(r){return re(ee(r))}function Y(r,t,e){let n;if(typeof t=="string")try{n=re(t)}catch(i){throw new Error(r+" must be hex string or Uint8Array, cause: "+i)}else if(zt(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 Dt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];ve(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let i=r[n];e.set(i,o),o+=i.length}return e}function Hc(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function Kc(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var Yr=r=>typeof r=="bigint"&&er<=r;function De(r,t,e){return Yr(r)&&Yr(t)&&Yr(e)&&t<=r&&r<e}function pt(r,t,e,n){if(!De(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Jr(r){let t;for(t=0;r>er;r>>=rr,t+=1);return t}function qc(r,t){return r>>BigInt(t)&rr}function zc(r,t,e){return r|(e?rr:er)<<BigInt(t)}var Oe=r=>(Oc<<BigInt(r-1))-rr,Xr=r=>new Uint8Array(r),Zo=r=>Uint8Array.from(r);function tn(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=Xr(r),o=Xr(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},c=(...m)=>e(o,n,...m),a=(m=Xr())=>{o=c(Zo([0]),m),n=c(),m.length!==0&&(o=c(Zo([1]),m),n=c())},d=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let m=0,p=[];for(;m<t;){n=c();let E=n.slice();p.push(E),m+=n.length}return Dt(...p)};return(m,p)=>{s(),a(m);let E;for(;!(E=p(d()));)a();return s(),E}}var Vc={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"||zt(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 At(r,t,e={}){let n=(o,i,s)=>{let c=Vc[i];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(s&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+a)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(e))n(o,i,!0);return r}var Fc=()=>{throw new Error("not implemented")};function oe(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let i=r(e,...n);return t.set(e,i),i}}var rt=BigInt(0),W=BigInt(1),ie=BigInt(2),Gc=BigInt(3),en=BigInt(4),Wo=BigInt(5),$o=BigInt(8),jc=BigInt(9),Zc=BigInt(16);function F(r,t){let e=r%t;return e>=rt?e:t+e}function Wc(r,t,e){if(t<rt)throw new Error("invalid exponent, negatives unsupported");if(e<=rt)throw new Error("invalid modulus");if(e===W)return rt;let n=W;for(;t>rt;)t&W&&(n=n*r%e),r=r*r%e,t>>=W;return n}function $(r,t,e){let n=r;for(;t-- >rt;)n*=n,n%=e;return n}function or(r,t){if(r===rt)throw new Error("invert: expected non-zero number");if(t<=rt)throw new Error("invert: expected positive modulus, got "+t);let e=F(r,t),n=t,o=rt,i=W,s=W,c=rt;for(;e!==rt;){let d=n/e,u=n%e,m=o-s*d,p=i-c*d;n=e,e=u,o=s,i=c,s=m,c=p}if(n!==W)throw new Error("invert: does not exist");return F(o,t)}function $c(r){let t=(r-W)/ie,e,n,o;for(e=r-W,n=0;e%ie===rt;e/=ie,n++);for(o=ie;o<r&&Wc(o,t,r)!==r-W;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(r+W)/en;return function(a,d){let u=a.pow(d,s);if(!a.eql(a.sqr(u),d))throw new Error("Cannot find square root");return u}}let i=(e+W)/ie;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let d=n,u=c.pow(c.mul(c.ONE,o),e),m=c.pow(a,i),p=c.pow(a,e);for(;!c.eql(p,c.ONE);){if(c.eql(p,c.ZERO))return c.ZERO;let E=1;for(let g=c.sqr(p);E<d&&!c.eql(g,c.ONE);E++)g=c.sqr(g);let y=c.pow(u,W<<BigInt(d-E-1));u=c.sqr(y),m=c.mul(m,y),p=c.mul(p,u),d=E}return m}}function Yc(r){if(r%en===Gc){let t=(r+W)/en;return function(n,o){let i=n.pow(o,t);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(r%$o===Wo){let t=(r-Wo)/$o;return function(n,o){let i=n.mul(o,ie),s=n.pow(i,t),c=n.mul(o,s),a=n.mul(n.mul(c,ie),s),d=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(d),o))throw new Error("Cannot find square root");return d}}return r%Zc,$c(r)}var Yo=(r,t)=>(F(r,t)&W)===W,Xc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function rn(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Xc.reduce((n,o)=>(n[o]="function",n),t);return At(r,e)}function Qc(r,t,e){if(e<rt)throw new Error("invalid exponent, negatives unsupported");if(e===rt)return r.ONE;if(e===W)return t;let n=r.ONE,o=t;for(;e>rt;)e&W&&(n=r.mul(n,o)),o=r.sqr(o),e>>=W;return n}function Jc(r,t){let e=new Array(t.length),n=t.reduce((i,s,c)=>r.is0(s)?i:(e[c]=i,r.mul(i,s)),r.ONE),o=r.inv(n);return t.reduceRight((i,s,c)=>r.is0(s)?i:(e[c]=r.mul(i,e[c]),r.mul(i,s)),o),e}function nn(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Gt(r,t,e=!1,n={}){if(r<=rt)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:i}=nn(r,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,c=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:i,MASK:Oe(o),ZERO:rt,ONE:W,create:a=>F(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return rt<=a&&a<r},is0:a=>a===rt,isOdd:a=>(a&W)===W,neg:a=>F(-a,r),eql:(a,d)=>a===d,sqr:a=>F(a*a,r),add:(a,d)=>F(a+d,r),sub:(a,d)=>F(a-d,r),mul:(a,d)=>F(a*d,r),pow:(a,d)=>Qc(c,a,d),div:(a,d)=>F(a*or(d,r),r),sqrN:a=>a*a,addN:(a,d)=>a+d,subN:(a,d)=>a-d,mulN:(a,d)=>a*d,inv:a=>or(a,r),sqrt:n.sqrt||(a=>(s||(s=Yc(r)),s(c,a))),invertBatch:a=>Jc(c,a),cmov:(a,d,u)=>u?d:a,toBytes:a=>e?ne(a,i):Ft(a,i),fromBytes:a=>{if(a.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+a.length);return e?Vt(a):_t(a)}});return Object.freeze(c)}function Xo(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 on(r){let t=Xo(r);return t+Math.ceil(t/2)}function Qo(r,t,e=!1){let n=r.length,o=Xo(t),i=on(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=e?Vt(r):_t(r),c=F(s,t-W)+W;return e?ne(c,o):Ft(c,o)}var Jo=BigInt(0),ir=BigInt(1);function sn(r,t){let e=t.negate();return r?e:t}function ti(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function cn(r,t){ti(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function ta(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 ea(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 an=new WeakMap,ei=new WeakMap;function un(r){return ei.get(r)||1}function sr(r,t){return{constTimeNegate:sn,hasPrecomputes(e){return un(e)!==1},unsafeLadder(e,n,o=r.ZERO){let i=e;for(;n>Jo;)n&ir&&(o=o.add(i)),i=i.double(),n>>=ir;return o},precomputeWindow(e,n){let{windows:o,windowSize:i}=cn(n,t),s=[],c=e,a=c;for(let d=0;d<o;d++){a=c,s.push(a);for(let u=1;u<i;u++)a=a.add(c),s.push(a);c=a.double()}return s},wNAF(e,n,o){let{windows:i,windowSize:s}=cn(e,t),c=r.ZERO,a=r.BASE,d=BigInt(2**e-1),u=2**e,m=BigInt(e);for(let p=0;p<i;p++){let E=p*s,y=Number(o&d);o>>=m,y>s&&(y-=u,o+=ir);let g=E,f=E+Math.abs(y)-1,w=p%2!==0,B=y<0;y===0?a=a.add(sn(w,n[g])):c=c.add(sn(B,n[f]))}return{p:c,f:a}},wNAFUnsafe(e,n,o,i=r.ZERO){let{windows:s,windowSize:c}=cn(e,t),a=BigInt(2**e-1),d=2**e,u=BigInt(e);for(let m=0;m<s;m++){let p=m*c;if(o===Jo)break;let E=Number(o&a);if(o>>=u,E>c&&(E-=d,o+=ir),E===0)continue;let y=n[p+Math.abs(E)-1];E<0&&(y=y.negate()),i=i.add(y)}return i},getPrecomputes(e,n,o){let i=an.get(n);return i||(i=this.precomputeWindow(n,e),e!==1&&an.set(n,o(i))),i},wNAFCached(e,n,o){let i=un(e);return this.wNAF(i,this.getPrecomputes(i,e,o),n)},wNAFCachedUnsafe(e,n,o,i){let s=un(e);return s===1?this.unsafeLadder(e,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,e,o),n,i)},setWindowSize(e,n){ti(n,t),ei.set(e,n),an.delete(e)}}}function cr(r,t,e,n){if(ta(e,r),ea(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,i=Jr(BigInt(e.length)),s=i>12?i-3:i>4?i-2:i?2:1,c=(1<<s)-1,a=new Array(c+1).fill(o),d=Math.floor((t.BITS-1)/s)*s,u=o;for(let m=d;m>=0;m-=s){a.fill(o);for(let E=0;E<n.length;E++){let y=n[E],g=Number(y>>BigInt(m)&BigInt(c));a[g]=a[g].add(e[E])}let p=o;for(let E=a.length-1,y=o;E>0;E--)y=y.add(a[E]),p=p.add(y);if(u=u.add(p),m!==0)for(let E=0;E<s;E++)u=u.double()}return u}function ke(r){return rn(r.Fp),At(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...nn(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Et=BigInt(0),mt=BigInt(1),ar=BigInt(2),ra=BigInt(8),na={zip215:!0};function oa(r){let t=ke(r);return At(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function ri(r){let t=oa(r),{Fp:e,n,prehash:o,hash:i,randomBytes:s,nByteLength:c,h:a}=t,d=ar<<BigInt(c*8)-mt,u=e.create,m=Gt(t.n,t.nBitLength),p=t.uvRatio||((x,l)=>{try{return{isValid:!0,value:e.sqrt(x*e.inv(l))}}catch{return{isValid:!1,value:Et}}}),E=t.adjustScalarBytes||(x=>x),y=t.domain||((x,l,b)=>{if(wt("phflag",b),l.length||b)throw new Error("Contexts/pre-hash are not supported");return x});function g(x,l){pt("coordinate "+x,l,Et,d)}function f(x){if(!(x instanceof h))throw new Error("ExtendedPoint expected")}let w=oe((x,l)=>{let{ex:b,ey:A,ez:_}=x,D=x.is0();l==null&&(l=D?ra:e.inv(_));let M=u(b*l),K=u(A*l),O=u(_*l);if(D)return{x:Et,y:mt};if(O!==mt)throw new Error("invZ was invalid");return{x:M,y:K}}),B=oe(x=>{let{a:l,d:b}=t;if(x.is0())throw new Error("bad point: ZERO");let{ex:A,ey:_,ez:D,et:M}=x,K=u(A*A),O=u(_*_),V=u(D*D),j=u(V*V),nt=u(K*l),ot=u(V*u(nt+O)),st=u(j+u(b*u(K*O)));if(ot!==st)throw new Error("bad point: equation left != right (1)");let at=u(A*_),dt=u(D*M);if(at!==dt)throw new Error("bad point: equation left != right (2)");return!0});class h{constructor(l,b,A,_){this.ex=l,this.ey=b,this.ez=A,this.et=_,g("x",l),g("y",b),g("z",A),g("t",_),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(l){if(l instanceof h)throw new Error("extended point not allowed");let{x:b,y:A}=l||{};return g("x",b),g("y",A),new h(b,A,mt,u(b*A))}static normalizeZ(l){let b=e.invertBatch(l.map(A=>A.ez));return l.map((A,_)=>A.toAffine(b[_])).map(h.fromAffine)}static msm(l,b){return cr(h,m,l,b)}_setWindowSize(l){R.setWindowSize(this,l)}assertValidity(){B(this)}equals(l){f(l);let{ex:b,ey:A,ez:_}=this,{ex:D,ey:M,ez:K}=l,O=u(b*K),V=u(D*_),j=u(A*K),nt=u(M*_);return O===V&&j===nt}is0(){return this.equals(h.ZERO)}negate(){return new h(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:l}=t,{ex:b,ey:A,ez:_}=this,D=u(b*b),M=u(A*A),K=u(ar*u(_*_)),O=u(l*D),V=b+A,j=u(u(V*V)-D-M),nt=O+M,ot=nt-K,st=O-M,at=u(j*ot),dt=u(nt*st),lt=u(j*st),Bt=u(ot*nt);return new h(at,dt,Bt,lt)}add(l){f(l);let{a:b,d:A}=t,{ex:_,ey:D,ez:M,et:K}=this,{ex:O,ey:V,ez:j,et:nt}=l;if(b===BigInt(-1)){let po=u((D-_)*(V+O)),mo=u((D+_)*(V-O)),_r=u(mo-po);if(_r===Et)return this.double();let xo=u(M*ar*nt),go=u(K*ar*j),bo=go+xo,yo=mo+po,wo=go-xo,ms=u(bo*_r),xs=u(yo*wo),gs=u(bo*wo),bs=u(_r*yo);return new h(ms,xs,bs,gs)}let ot=u(_*O),st=u(D*V),at=u(K*A*nt),dt=u(M*j),lt=u((_+D)*(O+V)-ot-st),Bt=dt-at,Tt=dt+at,Ce=u(st-b*ot),ls=u(lt*Bt),ds=u(Tt*Ce),hs=u(lt*Ce),ps=u(Bt*Tt);return new h(ls,ds,ps,hs)}subtract(l){return this.add(l.negate())}wNAF(l){return R.wNAFCached(this,l,h.normalizeZ)}multiply(l){let b=l;pt("scalar",b,mt,n);let{p:A,f:_}=this.wNAF(b);return h.normalizeZ([A,_])[0]}multiplyUnsafe(l,b=h.ZERO){let A=l;return pt("scalar",A,Et,n),A===Et?N:this.is0()||A===mt?this:R.wNAFCachedUnsafe(this,A,h.normalizeZ,b)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return R.unsafeLadder(this,n).is0()}toAffine(l){return w(this,l)}clearCofactor(){let{h:l}=t;return l===mt?this:this.multiplyUnsafe(l)}static fromHex(l,b=!1){let{d:A,a:_}=t,D=e.BYTES;l=Y("pointHex",l,D),wt("zip215",b);let M=l.slice(),K=l[D-1];M[D-1]=K&-129;let O=Vt(M),V=b?d:e.ORDER;pt("pointHex.y",O,Et,V);let j=u(O*O),nt=u(j-mt),ot=u(A*j-_),{isValid:st,value:at}=p(nt,ot);if(!st)throw new Error("Point.fromHex: invalid y coordinate");let dt=(at&mt)===mt,lt=(K&128)!==0;if(!b&&at===Et&<)throw new Error("Point.fromHex: x=0 and x_0=1");return lt!==dt&&(at=u(-at)),h.fromAffine({x:at,y:O})}static fromPrivateKey(l){return C(l).point}toRawBytes(){let{x:l,y:b}=this.toAffine(),A=ne(b,e.BYTES);return A[A.length-1]|=l&mt?128:0,A}toHex(){return Nt(this.toRawBytes())}}h.BASE=new h(t.Gx,t.Gy,mt,u(t.Gx*t.Gy)),h.ZERO=new h(Et,mt,mt,Et);let{BASE:I,ZERO:N}=h,R=sr(h,c*8);function T(x){return F(x,n)}function P(x){return T(Vt(x))}function C(x){let l=e.BYTES;x=Y("private key",x,l);let b=Y("hashed private key",i(x),2*l),A=E(b.slice(0,l)),_=b.slice(l,2*l),D=P(A),M=I.multiply(D),K=M.toRawBytes();return{head:A,prefix:_,scalar:D,point:M,pointBytes:K}}function Z(x){return C(x).pointBytes}function q(x=new Uint8Array,...l){let b=Dt(...l);return P(i(y(b,Y("context",x),!!o)))}function H(x,l,b={}){x=Y("message",x),o&&(x=o(x));let{prefix:A,scalar:_,pointBytes:D}=C(l),M=q(b.context,A,x),K=I.multiply(M).toRawBytes(),O=q(b.context,K,D,x),V=T(M+O*_);pt("signature.s",V,Et,n);let j=Dt(K,ne(V,e.BYTES));return Y("result",j,e.BYTES*2)}let et=na;function S(x,l,b,A=et){let{context:_,zip215:D}=A,M=e.BYTES;x=Y("signature",x,2*M),l=Y("message",l),b=Y("publicKey",b,M),D!==void 0&&wt("zip215",D),o&&(l=o(l));let K=Vt(x.slice(M,2*M)),O,V,j;try{O=h.fromHex(b,D),V=h.fromHex(x.slice(0,M),D),j=I.multiplyUnsafe(K)}catch{return!1}if(!D&&O.isSmallOrder())return!1;let nt=q(_,V.toRawBytes(),O.toRawBytes(),l);return V.add(O.multiplyUnsafe(nt)).subtract(j).clearCofactor().equals(h.ZERO)}return I._setWindowSize(8),{CURVE:t,getPublicKey:Z,sign:H,verify:S,ExtendedPoint:h,utils:{getExtendedPublicKey:C,randomPrivateKey:()=>s(e.BYTES),precompute(x=8,l=h.BASE){return l._setWindowSize(x),l.multiply(BigInt(3)),l}}}}var fn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ni=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),sl=BigInt(0),ia=BigInt(1),oi=BigInt(2),cl=BigInt(3),sa=BigInt(5),ca=BigInt(8);function aa(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),i=fn,c=r*r%i*r%i,a=$(c,oi,i)*c%i,d=$(a,ia,i)*r%i,u=$(d,sa,i)*d%i,m=$(u,t,i)*u%i,p=$(m,e,i)*m%i,E=$(p,n,i)*p%i,y=$(E,o,i)*E%i,g=$(y,o,i)*E%i,f=$(g,t,i)*u%i;return{pow_p_5_8:$(f,oi,i)*r%i,b2:c}}function ua(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function fa(r,t){let e=fn,n=F(t*t*t,e),o=F(n*n*t,e),i=aa(r*o).pow_p_5_8,s=F(r*n*i,e),c=F(t*s*s,e),a=s,d=F(s*ni,e),u=c===r,m=c===F(-r,e),p=c===F(-r*ni,e);return u&&(s=a),(m||p)&&(s=d),Yo(s,e)&&(s=F(-s,e)),{isValid:u||m,value:s}}var la=Gt(fn,void 0,!0),da={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:la,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:ca,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Go,randomBytes:Je,adjustScalarBytes:ua,uvRatio:fa},ii=ri(da);var ur=32;function si(r,t,e){return ii.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var fr=class{type="Ed25519";raw;constructor(t){this.raw=ln(t,ur)}toMultihash(){return Pt.digest(lr(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Rt(this.raw,t.raw)}verify(t,e){return si(this.raw,e,t)}};function ai(r){return r=ln(r,ur),new fr(r)}function ln(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new he(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function vt(r=0){return new Uint8Array(r)}var pa=Math.pow(2,7),ma=Math.pow(2,14),xa=Math.pow(2,21),dn=Math.pow(2,28),hn=Math.pow(2,35),pn=Math.pow(2,42),mn=Math.pow(2,49),z=128,ut=127;function xt(r){if(r<pa)return 1;if(r<ma)return 2;if(r<xa)return 3;if(r<dn)return 4;if(r<hn)return 5;if(r<pn)return 6;if(r<mn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function xn(r,t,e=0){switch(xt(r)){case 8:t[e++]=r&255|z,r/=128;case 7:t[e++]=r&255|z,r/=128;case 6:t[e++]=r&255|z,r/=128;case 5:t[e++]=r&255|z,r/=128;case 4:t[e++]=r&255|z,r>>>=7;case 3:t[e++]=r&255|z,r>>>=7;case 2:t[e++]=r&255|z,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function ga(r,t,e=0){switch(xt(r)){case 8:t.set(e++,r&255|z),r/=128;case 7:t.set(e++,r&255|z),r/=128;case 6:t.set(e++,r&255|z),r/=128;case 5:t.set(e++,r&255|z),r/=128;case 4:t.set(e++,r&255|z),r>>>=7;case 3:t.set(e++,r&255|z),r>>>=7;case 2:t.set(e++,r&255|z),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function gn(r,t){let e=r[t],n=0;if(n+=e&ut,e<z||(e=r[t+1],n+=(e&ut)<<7,e<z)||(e=r[t+2],n+=(e&ut)<<14,e<z)||(e=r[t+3],n+=(e&ut)<<21,e<z)||(e=r[t+4],n+=(e&ut)*dn,e<z)||(e=r[t+5],n+=(e&ut)*hn,e<z)||(e=r[t+6],n+=(e&ut)*pn,e<z)||(e=r[t+7],n+=(e&ut)*mn,e<z))return n;throw new RangeError("Could not decode varint")}function ba(r,t){let e=r.get(t),n=0;if(n+=e&ut,e<z||(e=r.get(t+1),n+=(e&ut)<<7,e<z)||(e=r.get(t+2),n+=(e&ut)<<14,e<z)||(e=r.get(t+3),n+=(e&ut)<<21,e<z)||(e=r.get(t+4),n+=(e&ut)*dn,e<z)||(e=r.get(t+5),n+=(e&ut)*hn,e<z)||(e=r.get(t+6),n+=(e&ut)*pn,e<z)||(e=r.get(t+7),n+=(e&ut)*mn,e<z))return n;throw new RangeError("Could not decode varint")}function Se(r,t,e=0){return t==null&&(t=vt(xt(r))),t instanceof Uint8Array?xn(r,t,e):ga(r,t,e)}function se(r,t=0){return r instanceof Uint8Array?gn(r,t):ba(r,t)}var bn=new Float32Array([-0]),jt=new Uint8Array(bn.buffer);function fi(r,t,e){bn[0]=r,t[e]=jt[0],t[e+1]=jt[1],t[e+2]=jt[2],t[e+3]=jt[3]}function li(r,t){return jt[0]=r[t],jt[1]=r[t+1],jt[2]=r[t+2],jt[3]=r[t+3],bn[0]}var yn=new Float64Array([-0]),ft=new Uint8Array(yn.buffer);function di(r,t,e){yn[0]=r,t[e]=ft[0],t[e+1]=ft[1],t[e+2]=ft[2],t[e+3]=ft[3],t[e+4]=ft[4],t[e+5]=ft[5],t[e+6]=ft[6],t[e+7]=ft[7]}function hi(r,t){return ft[0]=r[t],ft[1]=r[t+1],ft[2]=r[t+2],ft[3]=r[t+3],ft[4]=r[t+4],ft[5]=r[t+5],ft[6]=r[t+6],ft[7]=r[t+7],yn[0]}var ya=BigInt(Number.MAX_SAFE_INTEGER),wa=BigInt(Number.MIN_SAFE_INTEGER),gt=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<ya&&t>wa)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>pi&&(o=0n,++n>pi&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return 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 gt(0,0);ce.toBigInt=function(){return 0n};ce.zzEncode=ce.zzDecode=function(){return this};ce.length=function(){return 1};var pi=4294967296n;function mi(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function xi(r,t,e){if(e-t<1)return"";let o,i=[],s=0,c;for(;t<e;)c=r[t++],c<128?i[s++]=c:c>191&&c<224?i[s++]=(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,i[s++]=55296+(c>>10),i[s++]=56320+(c&1023)):i[s++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function wn(r,t,e){let n=e,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,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 St(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function dr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var En=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,St(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 St(this,4);return dr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw St(this,4);return dr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw St(this,4);let t=li(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw St(this,4);let t=hi(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 St(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return xi(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw St(this,t);this.pos+=t}else do if(this.pos>=this.len)throw St(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 gt(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 St(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 St(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 St(this,8);let t=dr(this.buf,this.pos+=4),e=dr(this.buf,this.pos+=4);return new gt(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=gn(this.buf,this.pos);return this.pos+=xt(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 vn(r){return new En(r instanceof Uint8Array?r:r.subarray())}function hr(r,t,e){let n=vn(r);return t.decode(n,void 0,e)}var Sn={};ht(Sn,{base10:()=>Ea});var Ea=Ht({prefix:"9",name:"base10",alphabet:"0123456789"});var Bn={};ht(Bn,{base16:()=>va,base16upper:()=>Sa});var va=X({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Sa=X({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var An={};ht(An,{base2:()=>Ba});var Ba=X({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var In={};ht(In,{base256emoji:()=>La});var bi=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}"),Aa=bi.reduce((r,t,e)=>(r[e]=t,r),[]),Ia=bi.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Ta(r){return r.reduce((t,e)=>(t+=Aa[e],t),"")}function Ca(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Ia[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var La=pe({prefix:"\u{1F680}",name:"base256emoji",encode:Ta,decode:Ca});var Tn={};ht(Tn,{base64:()=>Pa,base64pad:()=>Ra,base64url:()=>Ua,base64urlpad:()=>Na});var Pa=X({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ra=X({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ua=X({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Na=X({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Cn={};ht(Cn,{base8:()=>_a});var _a=X({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ln={};ht(Ln,{identity:()=>Da});var Da=pe({prefix:"\0",name:"identity",encode:r=>Ao(r),decode:r=>Bo(r)});var Vl=new TextEncoder,Fl=new TextDecoder;var Un={};ht(Un,{sha256:()=>Me,sha512:()=>Ma});function Rn({name:r,code:t,encode:e}){return new Pn(r,t,e)}var Pn=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 wi(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Me=Rn({name:"sha2-256",code:18,encode:wi("SHA-256")}),Ma=Rn({name:"sha2-512",code:19,encode:wi("SHA-512")});var He={...Ln,...An,...Cn,...Sn,...Bn,...zr,...Vr,...qr,...Tn,...In},rd={...Un,...jr};function vi(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Ei=vi("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Nn=vi("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=vt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Ha={utf8:Ei,"utf-8":Ei,hex:He.base16,latin1:Nn,ascii:Nn,binary:Nn,...He},pr=Ha;function Ot(r,t="utf8"){let e=pr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function _n(r){let t=r??8192,e=t>>>1,n,o=t;return function(s){if(s<1||s>e)return vt(s);o+s>t&&(n=vt(t),o=0);let c=n.subarray(o,o+=s);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 Dn(){}var kn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Ka=_n();function qa(r){return globalThis.Buffer!=null?vt(r):Ka(r)}var qe=class{len;head;tail;states;constructor(){this.len=0,this.head=new ae(Dn,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 Mn((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(mr,10,gt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=gt.fromBigInt(t);return this._push(mr,e.length(),e)}uint64Number(t){return this._push(xn,xt(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=gt.fromBigInt(t).zzEncode();return this._push(mr,e.length(),e)}sint64Number(t){let e=gt.fromNumber(t).zzEncode();return this._push(mr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(On,1,t?1:0)}fixed32(t){return this._push(Ke,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=gt.fromBigInt(t);return this._push(Ke,4,e.lo)._push(Ke,4,e.hi)}fixed64Number(t){let e=gt.fromNumber(t);return this._push(Ke,4,e.lo)._push(Ke,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(fi,4,t)}double(t){return this._push(di,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(On,1,0):this.uint32(e)._push(Va,e,t)}string(t){let e=mi(t);return e!==0?this.uint32(e)._push(wn,e,t):this._push(On,1,0)}fork(){return this.states=new kn(this),this.head=this.tail=new ae(Dn,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(Dn,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=qa(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function On(r,t,e){t[e]=r&255}function za(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Mn=class extends ae{next;constructor(t,e){super(za,t,e),this.next=void 0}};function mr(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 Ke(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 Va(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(Fa,t,r),this},qe.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Ga,t,r),this});function Fa(r,t,e){t.set(r,e)}function Ga(r,t,e){r.length<40?wn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Ot(r),e)}function Hn(){return new qe}function xr(r,t){let e=Hn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Be;(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"})(Be||(Be={}));function gr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Kn(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(i,s){let c=t(i);s.int32(c)},n=function(i){let s=i.int32();return t(s)};return gr("enum",Be.VARINT,e,n)}function br(r,t){return gr("message",Be.LENGTH_DELIMITED,r,t)}var bt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(bt||(bt={}));var qn;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(qn||(qn={}));(function(r){r.codec=()=>Kn(qn)})(bt||(bt={}));var ze;(function(r){let t;r.codec=()=>(t==null&&(t=br((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),bt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.Type=bt.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>xr(e,r.codec()),r.decode=(e,n)=>hr(e,r.codec(),n)})(ze||(ze={}));var zn;(function(r){let t;r.codec=()=>(t==null&&(t=br((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),bt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.Type=bt.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>xr(e,r.codec()),r.decode=(e,n)=>hr(e,r.codec(),n)})(zn||(zn={}));var Za=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]),Zt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Wt=new Uint32Array(64),Vn=class extends Ee{constructor(){super(64,32,8,!1),this.A=Zt[0]|0,this.B=Zt[1]|0,this.C=Zt[2]|0,this.D=Zt[3]|0,this.E=Zt[4]|0,this.F=Zt[5]|0,this.G=Zt[6]|0,this.H=Zt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:i,F:s,G:c,H:a}=this;return[t,e,n,o,i,s,c,a]}set(t,e,n,o,i,s,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}process(t,e){for(let m=0;m<16;m++,e+=4)Wt[m]=t.getUint32(e,!1);for(let m=16;m<64;m++){let p=Wt[m-15],E=Wt[m-2],y=yt(p,7)^yt(p,18)^p>>>3,g=yt(E,17)^yt(E,19)^E>>>10;Wt[m]=g+Wt[m-7]+y+Wt[m-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:d,H:u}=this;for(let m=0;m<64;m++){let p=yt(c,6)^yt(c,11)^yt(c,25),E=u+p+zo(c,a,d)+Za[m]+Wt[m]|0,g=(yt(n,2)^yt(n,13)^yt(n,22))+Vo(n,o,i)|0;u=d,d=a,a=c,c=s+E|0,s=i,i=o,o=n,n=E+g|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,d=d+this.G|0,u=u+this.H|0,this.set(n,o,i,s,c,a,d,u)}roundClean(){Wt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Si=Qe(()=>new Vn);function tt(r,t="utf8"){let e=pr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}function It(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=vt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var Ve=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var yr=class extends we{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Ho(t);let n=_e(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,i=new Uint8Array(o);i.set(n.length>o?t.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(t){return ye(this),this.iHash.update(t),this}digestInto(t){ye(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:i,blockLen:s,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,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()}},Fn=(r,t,e)=>new yr(r,t).update(e).digest();Fn.create=(r,t)=>new yr(r,t);function Bi(r){r.lowS!==void 0&&wt("lowS",r.lowS),r.prehash!==void 0&&wt("prehash",r.prehash)}function Wa(r){let t=ke(r);At(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{bytesToNumberBE:$a,hexToBytes:Ya}=nr,Gn=class extends Error{constructor(t=""){super(t)}},kt={Err:Gn,_tlv:{encode:(r,t)=>{let{Err:e}=kt;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=ee(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let i=n>127?ee(o.length/2|128):"";return ee(r)+i+o+t},decode(r,t){let{Err:e}=kt,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++],i=!!(o&128),s=0;if(!i)s=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 d=t.subarray(n,n+a);if(d.length!==a)throw new e("tlv.decode: length bytes not complete");if(d[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of d)s=s<<8|u;if(n+=a,s<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+s);if(c.length!==s)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+s)}}},_int:{encode(r){let{Err:t}=kt;if(r<Mt)throw new t("integer: negative integers are not allowed");let e=ee(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}=kt;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 $a(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=kt,o=typeof r=="string"?Ya(r):r;ve(o);let{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,i),{v:d,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(d)}},hexFromSig(r){let{_tlv:t,_int:e}=kt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),i=n+o;return t.encode(48,i)}},Mt=BigInt(0),it=BigInt(1),Yd=BigInt(2),Ai=BigInt(3),Xd=BigInt(4);function Xa(r){let t=Wa(r),{Fp:e}=t,n=Gt(t.n,t.nBitLength),o=t.toBytes||((g,f,w)=>{let B=f.toAffine();return Dt(Uint8Array.from([4]),e.toBytes(B.x),e.toBytes(B.y))}),i=t.fromBytes||(g=>{let f=g.subarray(1),w=e.fromBytes(f.subarray(0,e.BYTES)),B=e.fromBytes(f.subarray(e.BYTES,2*e.BYTES));return{x:w,y:B}});function s(g){let{a:f,b:w}=t,B=e.sqr(g),h=e.mul(B,g);return e.add(e.add(h,e.mul(g,f)),w)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function c(g){return De(g,it,t.n)}function a(g){let{allowedPrivateKeyLengths:f,nByteLength:w,wrapPrivateKey:B,n:h}=t;if(f&&typeof g!="bigint"){if(zt(g)&&(g=Nt(g)),typeof g!="string"||!f.includes(g.length))throw new Error("invalid private key");g=g.padStart(w*2,"0")}let I;try{I=typeof g=="bigint"?g:_t(Y("private key",g,w))}catch{throw new Error("invalid private key, expected hex or "+w+" bytes, got "+typeof g)}return B&&(I=F(I,h)),pt("private key",I,it,h),I}function d(g){if(!(g instanceof p))throw new Error("ProjectivePoint expected")}let u=oe((g,f)=>{let{px:w,py:B,pz:h}=g;if(e.eql(h,e.ONE))return{x:w,y:B};let I=g.is0();f==null&&(f=I?e.ONE:e.inv(h));let N=e.mul(w,f),R=e.mul(B,f),T=e.mul(h,f);if(I)return{x:e.ZERO,y:e.ZERO};if(!e.eql(T,e.ONE))throw new Error("invZ was invalid");return{x:N,y:R}}),m=oe(g=>{if(g.is0()){if(t.allowInfinityPoint&&!e.is0(g.py))return;throw new Error("bad point: ZERO")}let{x:f,y:w}=g.toAffine();if(!e.isValid(f)||!e.isValid(w))throw new Error("bad point: x or y not FE");let B=e.sqr(w),h=s(f);if(!e.eql(B,h))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(f,w,B){if(this.px=f,this.py=w,this.pz=B,f==null||!e.isValid(f))throw new Error("x required");if(w==null||!e.isValid(w))throw new Error("y required");if(B==null||!e.isValid(B))throw new Error("z required");Object.freeze(this)}static fromAffine(f){let{x:w,y:B}=f||{};if(!f||!e.isValid(w)||!e.isValid(B))throw new Error("invalid affine point");if(f instanceof p)throw new Error("projective point not allowed");let h=I=>e.eql(I,e.ZERO);return h(w)&&h(B)?p.ZERO:new p(w,B,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(f){let w=e.invertBatch(f.map(B=>B.pz));return f.map((B,h)=>B.toAffine(w[h])).map(p.fromAffine)}static fromHex(f){let w=p.fromAffine(i(Y("pointHex",f)));return w.assertValidity(),w}static fromPrivateKey(f){return p.BASE.multiply(a(f))}static msm(f,w){return cr(p,n,f,w)}_setWindowSize(f){y.setWindowSize(this,f)}assertValidity(){m(this)}hasEvenY(){let{y:f}=this.toAffine();if(e.isOdd)return!e.isOdd(f);throw new Error("Field doesn't support isOdd")}equals(f){d(f);let{px:w,py:B,pz:h}=this,{px:I,py:N,pz:R}=f,T=e.eql(e.mul(w,R),e.mul(I,h)),P=e.eql(e.mul(B,R),e.mul(N,h));return T&&P}negate(){return new p(this.px,e.neg(this.py),this.pz)}double(){let{a:f,b:w}=t,B=e.mul(w,Ai),{px:h,py:I,pz:N}=this,R=e.ZERO,T=e.ZERO,P=e.ZERO,C=e.mul(h,h),Z=e.mul(I,I),q=e.mul(N,N),H=e.mul(h,I);return H=e.add(H,H),P=e.mul(h,N),P=e.add(P,P),R=e.mul(f,P),T=e.mul(B,q),T=e.add(R,T),R=e.sub(Z,T),T=e.add(Z,T),T=e.mul(R,T),R=e.mul(H,R),P=e.mul(B,P),q=e.mul(f,q),H=e.sub(C,q),H=e.mul(f,H),H=e.add(H,P),P=e.add(C,C),C=e.add(P,C),C=e.add(C,q),C=e.mul(C,H),T=e.add(T,C),q=e.mul(I,N),q=e.add(q,q),C=e.mul(q,H),R=e.sub(R,C),P=e.mul(q,Z),P=e.add(P,P),P=e.add(P,P),new p(R,T,P)}add(f){d(f);let{px:w,py:B,pz:h}=this,{px:I,py:N,pz:R}=f,T=e.ZERO,P=e.ZERO,C=e.ZERO,Z=t.a,q=e.mul(t.b,Ai),H=e.mul(w,I),et=e.mul(B,N),S=e.mul(h,R),L=e.add(w,B),x=e.add(I,N);L=e.mul(L,x),x=e.add(H,et),L=e.sub(L,x),x=e.add(w,h);let l=e.add(I,R);return x=e.mul(x,l),l=e.add(H,S),x=e.sub(x,l),l=e.add(B,h),T=e.add(N,R),l=e.mul(l,T),T=e.add(et,S),l=e.sub(l,T),C=e.mul(Z,x),T=e.mul(q,S),C=e.add(T,C),T=e.sub(et,C),C=e.add(et,C),P=e.mul(T,C),et=e.add(H,H),et=e.add(et,H),S=e.mul(Z,S),x=e.mul(q,x),et=e.add(et,S),S=e.sub(H,S),S=e.mul(Z,S),x=e.add(x,S),H=e.mul(et,x),P=e.add(P,H),H=e.mul(l,x),T=e.mul(L,T),T=e.sub(T,H),H=e.mul(L,et),C=e.mul(l,C),C=e.add(C,H),new p(T,P,C)}subtract(f){return this.add(f.negate())}is0(){return this.equals(p.ZERO)}wNAF(f){return y.wNAFCached(this,f,p.normalizeZ)}multiplyUnsafe(f){let{endo:w,n:B}=t;pt("scalar",f,Mt,B);let h=p.ZERO;if(f===Mt)return h;if(this.is0()||f===it)return this;if(!w||y.hasPrecomputes(this))return y.wNAFCachedUnsafe(this,f,p.normalizeZ);let{k1neg:I,k1:N,k2neg:R,k2:T}=w.splitScalar(f),P=h,C=h,Z=this;for(;N>Mt||T>Mt;)N&it&&(P=P.add(Z)),T&it&&(C=C.add(Z)),Z=Z.double(),N>>=it,T>>=it;return I&&(P=P.negate()),R&&(C=C.negate()),C=new p(e.mul(C.px,w.beta),C.py,C.pz),P.add(C)}multiply(f){let{endo:w,n:B}=t;pt("scalar",f,it,B);let h,I;if(w){let{k1neg:N,k1:R,k2neg:T,k2:P}=w.splitScalar(f),{p:C,f:Z}=this.wNAF(R),{p:q,f:H}=this.wNAF(P);C=y.constTimeNegate(N,C),q=y.constTimeNegate(T,q),q=new p(e.mul(q.px,w.beta),q.py,q.pz),h=C.add(q),I=Z.add(H)}else{let{p:N,f:R}=this.wNAF(f);h=N,I=R}return p.normalizeZ([h,I])[0]}multiplyAndAddUnsafe(f,w,B){let h=p.BASE,I=(R,T)=>T===Mt||T===it||!R.equals(h)?R.multiplyUnsafe(T):R.multiply(T),N=I(this,w).add(I(f,B));return N.is0()?void 0:N}toAffine(f){return u(this,f)}isTorsionFree(){let{h:f,isTorsionFree:w}=t;if(f===it)return!0;if(w)return w(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:f,clearCofactor:w}=t;return f===it?this:w?w(p,this):this.multiplyUnsafe(t.h)}toRawBytes(f=!0){return wt("isCompressed",f),this.assertValidity(),o(p,this,f)}toHex(f=!0){return wt("isCompressed",f),Nt(this.toRawBytes(f))}}p.BASE=new p(t.Gx,t.Gy,e.ONE),p.ZERO=new p(e.ZERO,e.ONE,e.ZERO);let E=t.nBitLength,y=sr(p,t.endo?Math.ceil(E/2):E);return{CURVE:t,ProjectivePoint:p,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:c}}function Qa(r){let t=ke(r);return At(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Ii(r){let t=Qa(r),{Fp:e,n}=t,o=e.BYTES+1,i=2*e.BYTES+1;function s(S){return F(S,n)}function c(S){return or(S,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:d,weierstrassEquation:u,isWithinCurveOrder:m}=Xa({...t,toBytes(S,L,x){let l=L.toAffine(),b=e.toBytes(l.x),A=Dt;return wt("isCompressed",x),x?A(Uint8Array.from([L.hasEvenY()?2:3]),b):A(Uint8Array.from([4]),b,e.toBytes(l.y))},fromBytes(S){let L=S.length,x=S[0],l=S.subarray(1);if(L===o&&(x===2||x===3)){let b=_t(l);if(!De(b,it,e.ORDER))throw new Error("Point is not on curve");let A=u(b),_;try{_=e.sqrt(A)}catch(K){let O=K instanceof Error?": "+K.message:"";throw new Error("Point is not on curve"+O)}let D=(_&it)===it;return(x&1)===1!==D&&(_=e.neg(_)),{x:b,y:_}}else if(L===i&&x===4){let b=e.fromBytes(l.subarray(0,e.BYTES)),A=e.fromBytes(l.subarray(e.BYTES,2*e.BYTES));return{x:b,y:A}}else{let b=o,A=i;throw new Error("invalid Point, expected length of "+b+", or uncompressed "+A+", got "+L)}}}),p=S=>Nt(Ft(S,t.nByteLength));function E(S){let L=n>>it;return S>L}function y(S){return E(S)?s(-S):S}let g=(S,L,x)=>_t(S.slice(L,x));class f{constructor(L,x,l){this.r=L,this.s=x,this.recovery=l,this.assertValidity()}static fromCompact(L){let x=t.nByteLength;return L=Y("compactSignature",L,x*2),new f(g(L,0,x),g(L,x,2*x))}static fromDER(L){let{r:x,s:l}=kt.toSig(Y("DER",L));return new f(x,l)}assertValidity(){pt("r",this.r,it,n),pt("s",this.s,it,n)}addRecoveryBit(L){return new f(this.r,this.s,L)}recoverPublicKey(L){let{r:x,s:l,recovery:b}=this,A=R(Y("msgHash",L));if(b==null||![0,1,2,3].includes(b))throw new Error("recovery id invalid");let _=b===2||b===3?x+t.n:x;if(_>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let D=(b&1)===0?"02":"03",M=a.fromHex(D+p(_)),K=c(_),O=s(-A*K),V=s(l*K),j=a.BASE.multiplyAndAddUnsafe(M,O,V);if(!j)throw new Error("point at infinify");return j.assertValidity(),j}hasHighS(){return E(this.s)}normalizeS(){return this.hasHighS()?new f(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return re(this.toDERHex())}toDERHex(){return kt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return re(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let w={isValidPrivateKey(S){try{return d(S),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{let S=on(t.n);return Qo(t.randomBytes(S),t.n)},precompute(S=8,L=a.BASE){return L._setWindowSize(S),L.multiply(BigInt(3)),L}};function B(S,L=!0){return a.fromPrivateKey(S).toRawBytes(L)}function h(S){let L=zt(S),x=typeof S=="string",l=(L||x)&&S.length;return L?l===o||l===i:x?l===2*o||l===2*i:S instanceof a}function I(S,L,x=!0){if(h(S))throw new Error("first arg must be private key");if(!h(L))throw new Error("second arg must be public key");return a.fromHex(L).multiply(d(S)).toRawBytes(x)}let N=t.bits2int||function(S){if(S.length>8192)throw new Error("input is too large");let L=_t(S),x=S.length*8-t.nBitLength;return x>0?L>>BigInt(x):L},R=t.bits2int_modN||function(S){return s(N(S))},T=Oe(t.nBitLength);function P(S){return pt("num < 2^"+t.nBitLength,S,Mt,T),Ft(S,t.nByteLength)}function C(S,L,x=Z){if(["recovered","canonical"].some(ot=>ot in x))throw new Error("sign() legacy options not supported");let{hash:l,randomBytes:b}=t,{lowS:A,prehash:_,extraEntropy:D}=x;A==null&&(A=!0),S=Y("msgHash",S),Bi(x),_&&(S=Y("prehashed msgHash",l(S)));let M=R(S),K=d(L),O=[P(K),P(M)];if(D!=null&&D!==!1){let ot=D===!0?b(e.BYTES):D;O.push(Y("extraEntropy",ot))}let V=Dt(...O),j=M;function nt(ot){let st=N(ot);if(!m(st))return;let at=c(st),dt=a.BASE.multiply(st).toAffine(),lt=s(dt.x);if(lt===Mt)return;let Bt=s(at*s(j+lt*K));if(Bt===Mt)return;let Tt=(dt.x===lt?0:2)|Number(dt.y&it),Ce=Bt;return A&&E(Bt)&&(Ce=y(Bt),Tt^=1),new f(lt,Ce,Tt)}return{seed:V,k2sig:nt}}let Z={lowS:t.lowS,prehash:!1},q={lowS:t.lowS,prehash:!1};function H(S,L,x=Z){let{seed:l,k2sig:b}=C(S,L,x),A=t;return tn(A.hash.outputLen,A.nByteLength,A.hmac)(l,b)}a.BASE._setWindowSize(8);function et(S,L,x,l=q){let b=S;L=Y("msgHash",L),x=Y("publicKey",x);let{lowS:A,prehash:_,format:D}=l;if(Bi(l),"strict"in l)throw new Error("options.strict was renamed to lowS");if(D!==void 0&&D!=="compact"&&D!=="der")throw new Error("format must be compact or der");let M=typeof b=="string"||zt(b),K=!M&&!D&&typeof b=="object"&&b!==null&&typeof b.r=="bigint"&&typeof b.s=="bigint";if(!M&&!K)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let O,V;try{if(K&&(O=new f(b.r,b.s)),M){try{D!=="compact"&&(O=f.fromDER(b))}catch(Tt){if(!(Tt instanceof kt.Err))throw Tt}!O&&D!=="der"&&(O=f.fromCompact(b))}V=a.fromHex(x)}catch{return!1}if(!O||A&&O.hasHighS())return!1;_&&(L=t.hash(L));let{r:j,s:nt}=O,ot=R(L),st=c(nt),at=s(ot*st),dt=s(j*st),lt=a.BASE.multiplyAndAddUnsafe(V,at,dt)?.toAffine();return lt?s(lt.x)===j:!1}return{CURVE:t,getPublicKey:B,getSharedSecret:I,sign:H,verify:et,ProjectivePoint:a,Signature:f,utils:w}}function Ja(r){return{hash:r,hmac:(t,...e)=>Fn(r,t,Zr(...e)),randomBytes:Je}}function Ti(r,t){let e=n=>Ii({...r,...Ja(n)});return{...e(t),create:e}}var Pi=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ci=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),tu=BigInt(1),jn=BigInt(2),Li=(r,t)=>(r+t/jn)/t;function eu(r){let t=Pi,e=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),d=r*r*r%t,u=d*d*r%t,m=$(u,e,t)*u%t,p=$(m,e,t)*u%t,E=$(p,jn,t)*d%t,y=$(E,o,t)*E%t,g=$(y,i,t)*y%t,f=$(g,c,t)*g%t,w=$(f,a,t)*f%t,B=$(w,c,t)*g%t,h=$(B,e,t)*u%t,I=$(h,s,t)*y%t,N=$(I,n,t)*d%t,R=$(N,jn,t);if(!Zn.eql(Zn.sqr(R),r))throw new Error("Cannot find square root");return R}var Zn=Gt(Pi,void 0,void 0,{sqrt:eu}),ue=Ti({a:BigInt(0),b:BigInt(7),Fp:Zn,n:Ci,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Ci,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-tu*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,s=BigInt("0x100000000000000000000000000000000"),c=Li(i*r,t),a=Li(-n*r,t),d=F(r-c*e-a*o,t),u=F(-c*n-a*i,t),m=d>s,p=u>s;if(m&&(d=t-d),p&&(u=t-u),d>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:m,k1:d,k2neg:p,k2:u}}}},Si),sh=BigInt(0);var ch=ue.ProjectivePoint;function Ri(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Ui(r,t,e){let n=Me.digest(e instanceof Uint8Array?e:e.subarray());if(Ri(n))return n.then(({digest:o})=>ue.verify(t,o,r)).catch(o=>{throw new Ve(String(o))});try{return ue.verify(t,n.digest,r)}catch(o){throw new Ve(String(o))}}var wr=class{type="secp256k1";raw;_key;constructor(t){this._key=_i(t),this.raw=Ni(this._key)}toMultihash(){return Pt.digest(lr(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Rt(this.raw,t.raw)}verify(t,e){return Ui(this._key,e,t)}};function Di(r){return new wr(r)}function Ni(r){return ue.ProjectivePoint.fromHex(r).toRawBytes(!0)}function _i(r){try{return ue.ProjectivePoint.fromHex(r),r}catch(t){throw new je(String(t))}}function Oi(r){let{Type:t,Data:e}=ze.decode(r.digest),n=e??new Uint8Array;switch(t){case bt.Ed25519:return ai(n);case bt.secp256k1:return Di(n);default:throw new Le}}function lr(r){return ze.encode({Type:bt[r.type],Data:r.raw})}var ki=Symbol.for("nodejs.util.inspect.custom"),ru=114,Fe=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()})`}[Or]=!0;toString(){return this.string==null&&(this.string=Q.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ct.createV1(ru,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Rt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Rt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[ki](){return`PeerId(${this.toString()})`}},Er=class extends Fe{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},vr=class extends Fe{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Sr=class extends Fe{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},nu=2336,Ge=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Pt.digest(Ot(this.url))}[ki](){return`PeerId(${this.url})`}[Or]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ct.createV1(nu,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=tt(t)),t.toString()===this.toString())}};var ou=114,Mi=2336;function Hi(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=Qt(Q.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return iu(ct.parse(r));if(t==null)throw new he('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=Qt(t.decode(r))}return Ki(e)}function Ki(r){if(cu(r))return new Er({multihash:r});if(su(r))try{let t=Oi(r);if(t.type==="Ed25519")return new vr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Sr({multihash:r,publicKey:t})}catch{let e=tt(r.digest);return new Ge(new URL(e))}throw new We("Supplied PeerID Multihash is invalid")}function iu(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==ou&&r.code!==Mi)throw new Ze("Supplied PeerID CID is invalid");if(r.code===Mi){let t=tt(r.multihash.digest);return new Ge(new URL(t))}return Ki(r.multihash)}function su(r){return r.code===Pt.code}function cu(r){return r.code===Me.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 i=0,s=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",d=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let m=this.readChar();if(m===void 0)return;let p=Number.parseInt(m,t);if(!Number.isNaN(p))return p});if(u===void 0)break;if(i*=t,i+=u,i>d||(s+=1,e!==void 0&&s>e))return}if(s!==0)return!n&&a&&s>1?void 0:i})}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 s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return e[o]=s[0],e[o+1]=s[1],e[o+2]=s[2],e[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];e[o]=i>>8,e[o+1]=i&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 i=new Uint8Array(14),s=16-(n+2),[c]=t(i.subarray(0,s));return e.set(i.subarray(0,c),16-c),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var qi=45,au=15,Ae=new Br;function Wn(r){if(!(r.length>au))return Ae.new(r).parseWith(()=>Ae.readIPv4Addr())}function $n(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>qi))return Ae.new(r).parseWith(()=>Ae.readIPv6Addr())}function Ar(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>qi)return;let e=Ae.new(r).parseWith(()=>Ae.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 xp=parseInt("0xFFFF",16),gp=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Fi(r){return!!Wn(r)}function Gi(r){return!!$n(r)}function Ir(r){return!!Ar(r)}var ji=Fi,hu=Gi,Yn=function(r){let t=0;if(r=r.toString().trim(),ji(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(hu(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=ji(e[n]),s;i&&(s=Yn(e[n]),e[n]=tt(s.slice(0,2),"base16")),s!=null&&++n<8&&e.splice(n,0,tt(s.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 i=[n,1];for(n=9-e.length;n>0;n--)i.push("0");e.splice.apply(e,i)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let i=parseInt(e[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},Zi=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 i=0;i<e;i++)o.push(r[t+i]);return o.join(".")}if(e===16){let o=[];for(let i=0;i<e;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Ie={},Xn={},mu=[[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"]];mu.forEach(r=>{let t=xu(...r);Xn[t.code]=t,Ie[t.name]=t});function xu(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function G(r){if(typeof r=="number"){if(Xn[r]!=null)return Xn[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ie[r]!=null)return Ie[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var t0=G("ip4"),e0=G("ip6"),r0=G("ipcidr");function eo(r,t){switch(G(r).code){case 4:case 41:return bu(t);case 42:return to(t);case 43:return tt(t,"base10");case 6:case 273:case 33:case 132:return Yi(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return to(t);case 421:return vu(t);case 444:return $i(t);case 445:return $i(t);case 466:return Eu(t);case 481:return globalThis.encodeURIComponent(to(t));default:return tt(t,"base16")}}function ro(r,t){switch(G(r).code){case 4:return Wi(t);case 41:return Wi(t);case 42:return Jn(t);case 43:return Ot(t,"base10");case 6:case 273:case 33:case 132:return no(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Jn(t);case 421:return yu(t);case 444:return Su(t);case 445:return Bu(t);case 466:return wu(t);case 481:return Jn(globalThis.decodeURIComponent(t));default:return Ot(t,"base16")}}var Qn=Object.values(He).map(r=>r.decoder),gu=function(){let r=Qn[0].or(Qn[1]);return Qn.slice(2).forEach(t=>r=r.or(t)),r}();function Wi(r){if(!Ir(r))throw new Error("invalid ip address");return Yn(r)}function bu(r){let t=Zi(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Ir(t))throw new Error("invalid ip address");return t}function no(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Yi(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Jn(r){let t=Ot(r),e=Uint8Array.from(Se(t.length));return It([e,t],e.length+t.length)}function to(r){let t=se(r);if(r=r.slice(xt(t)),r.length!==t)throw new Error("inconsistent lengths");return tt(r)}function yu(r){let t;r[0]==="Q"||r[0]==="1"?t=Qt(Q.decode(`z${r}`)).bytes:t=ct.parse(r).multihash.bytes;let e=Uint8Array.from(Se(t.length));return It([e,t],e.length+t.length)}function wu(r){let t=gu.decode(r),e=Uint8Array.from(Se(t.length));return It([e,t],e.length+t.length)}function Eu(r){let t=se(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+tt(e,"base64url")}function vu(r){let t=se(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return tt(e,"base58btc")}function Su(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=Lt.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=no(n);return It([e,o],e.length+o.length)}function Bu(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=Lt.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=no(n);return It([e,o],e.length+o.length)}function $i(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=tt(t,"base32"),o=Yi(e);return`${n}:${o}`}function Xi(r){r=oo(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 i=0;i<o.length;i++){let s=o[i],c=G(s);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(i++,i>=o.length)throw new Tr("invalid address: "+r);if(c.path===!0){n=oo(o.slice(i).join("/")),t.push([c.code,ro(c.code,n)]),e.push([c.code,n]);break}let a=ro(c.code,o[i]);t.push([c.code,a]),e.push([c.code,eo(c.code,a)])}return{string:Qi(e),bytes:Cr(t),tuples:t,stringTuples:e,path:n}}function io(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=se(r,o),s=xt(i),c=G(i),a=Au(c,r.slice(o+s));if(a===0){t.push([i]),e.push([i]),o+=s;continue}let d=r.slice(o+s,o+s+a);if(o+=a+s,o>r.length)throw new Tr("Invalid address Uint8Array: "+tt(r,"base16"));t.push([i,d]);let u=eo(i,d);if(e.push([i,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Qi(e),tuples:t,stringTuples:e,path:n}}function Qi(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}),oo(t.join("/"))}function Cr(r){return It(r.map(t=>{let e=G(t[0]),n=Uint8Array.from(Se(e.code));return t.length>1&&t[1]!=null&&(n=It([n,t[1]])),n}))}function Au(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=se(t instanceof Uint8Array?t:Uint8Array.from(t));return e+xt(e)}}function oo(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var Tr=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var Iu=Symbol.for("nodejs.util.inspect.custom"),co=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Tu=[G("dns").code,G("dns4").code,G("dns6").code,G("dnsaddr").code],so=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Lr=class r{bytes;#t;#e;#r;#n;[co]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=io(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Xi(t)}else if(ts(t))e=io(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,i="",s=G("tcp"),c=G("udp"),a=G("ip4"),d=G("ip6"),u=G("dns6"),m=G("ip6zone");for(let[E,y]of this.stringTuples())E===m.code&&(i=`%${y??""}`),Tu.includes(E)&&(e=s.name==="tcp"?"tcp":"udp",o=443,n=`${y??""}${i}`,t=E===u.code?6:4),(E===s.code||E===c.code)&&(e=G(E).name==="tcp"?"tcp":"udp",o=parseInt(y??"")),(E===a.code||E===d.code)&&(e=G(E).name==="tcp"?"tcp":"udp",n=`${y??""}${i}`,t=E===d.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(Cr(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===Ie.p2p.code&&t.push([n,o]),n===Ie["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?tt(Q.decode(`z${n}`),"base58btc"):tt(ct.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Rt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=Ji.get(e.name);if(n==null)throw new so(`no available resolver for ${e.name}`);return(await n(this,t)).map(i=>$t(i))}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)}[Iu](){return`Multiaddr(${this.#t})`}};var Ji=new Map;function ts(r){return!!r?.[co]}function $t(r){return new Lr(r)}var Cu=v("dns4"),Lu=v("dns6"),Pu=v("dnsaddr"),le=J(v("dns"),Pu,Cu,Lu),Ur=J(v("ip4"),v("ip6")),Te=J(U(Ur,v("tcp")),U(le,v("tcp"))),Nr=U(Ur,v("udp")),Ru=U(Nr,v("utp")),Uu=U(Nr,v("quic")),Nu=U(Nr,v("quic-v1")),ao=J(U(Te,v("ws")),U(le,v("ws"))),Pr=J(U(ao,v("p2p")),ao),uo=J(U(Te,v("wss")),U(le,v("wss")),U(Te,v("tls"),v("ws")),U(le,v("tls"),v("ws"))),Rr=J(U(uo,v("p2p")),uo),fo=J(U(Te,v("http")),U(Ur,v("http")),U(le,v("http"))),lo=J(U(Te,v("https")),U(Ur,v("https")),U(le,v("https"))),es=U(Nr,v("webrtc-direct"),v("certhash")),os=J(U(es,v("p2p")),es),rs=U(Nu,v("webtransport"),v("certhash"),v("certhash")),is=J(U(rs,v("p2p")),rs),ss=J(U(Pr,v("p2p-webrtc-star"),v("p2p")),U(Rr,v("p2p-webrtc-star"),v("p2p")),U(Pr,v("p2p-webrtc-star")),U(Rr,v("p2p-webrtc-star"))),L0=J(U(Pr,v("p2p-websocket-star"),v("p2p")),U(Rr,v("p2p-websocket-star"),v("p2p")),U(Pr,v("p2p-websocket-star")),U(Rr,v("p2p-websocket-star"))),cs=J(U(fo,v("p2p-webrtc-direct"),v("p2p")),U(lo,v("p2p-webrtc-direct"),v("p2p")),U(fo,v("p2p-webrtc-direct")),U(lo,v("p2p-webrtc-direct"))),de=J(ao,uo,fo,lo,ss,cs,Te,Ru,Uu,le,os,is),P0=J(U(de,v("p2p-stardust"),v("p2p")),U(de,v("p2p-stardust"))),Yt=J(U(de,v("p2p")),ss,cs,os,is,v("p2p")),ns=J(U(Yt,v("p2p-circuit"),Yt),U(Yt,v("p2p-circuit")),U(v("p2p-circuit"),Yt),U(de,v("p2p-circuit")),U(v("p2p-circuit"),de),v("p2p-circuit")),as=()=>J(U(ns,as),ns),fe=as(),us=J(U(fe,Yt,fe),U(Yt,fe),U(fe,Yt),fe,Yt);var R0=J(U(fe,v("webrtc"),v("p2p")),U(fe,v("webrtc")),U(de,v("webrtc"),v("p2p")),U(de,v("webrtc")),v("webrtc"));function fs(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 U(...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:fs(t),partialMatch:t}}function J(...r){function t(n){let o=null;return r.some(i=>{let s=typeof i=="function"?i().partialMatch(n):i.partialMatch(n);return s!=null?(o=s,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:fs(t),partialMatch:t}}function v(r){let t=r;function e(o){let i;try{i=$t(o)}catch{return!1}let s=i.protoNames();return s.length===1&&s[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 _u="bootstrap",Du=50,Ou=1e3,ho=class extends $e{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??Ou,this.list=[];for(let n of e.list){if(!us.matches(n)){this.log.error("Invalid multiaddr");continue}let o=$t(n),i=o.getPeerId();if(i==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let s={id:Hi(i),multiaddrs:[o]};this.list.push(s)}this._init=e}[Eo]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[vo]=["@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??_u]:{value:this._init.tagValue??Du,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 ku(r){return t=>new ho(t,r)}return Ss(Mu);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/hashes/esm/utils.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/bootstrap",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.31-a7ab9a41b",
|
|
4
4
|
"description": "Peer discovery via a list of bootstrap peers",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap#readme",
|
|
@@ -54,15 +54,15 @@
|
|
|
54
54
|
"test:electron-main": "aegir test -t electron-main"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@libp2p/interface": "
|
|
58
|
-
"@libp2p/interface-internal": "
|
|
59
|
-
"@libp2p/peer-id": "
|
|
57
|
+
"@libp2p/interface": "2.7.0-a7ab9a41b",
|
|
58
|
+
"@libp2p/interface-internal": "2.3.8-a7ab9a41b",
|
|
59
|
+
"@libp2p/peer-id": "5.1.0-a7ab9a41b",
|
|
60
60
|
"@multiformats/mafmt": "^12.1.6",
|
|
61
61
|
"@multiformats/multiaddr": "^12.3.3"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@libp2p/interface-compliance-tests": "
|
|
65
|
-
"@libp2p/logger": "
|
|
64
|
+
"@libp2p/interface-compliance-tests": "6.4.1-a7ab9a41b",
|
|
65
|
+
"@libp2p/logger": "5.1.13-a7ab9a41b",
|
|
66
66
|
"aegir": "^45.1.1",
|
|
67
67
|
"sinon-ts": "^2.0.0"
|
|
68
68
|
},
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"BootstrapComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapComponents.html",
|
|
3
|
-
".:BootstrapComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapComponents.html",
|
|
4
|
-
"BootstrapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapInit.html",
|
|
5
|
-
".:BootstrapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapInit.html",
|
|
6
|
-
"bootstrap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_bootstrap.bootstrap.html",
|
|
7
|
-
".:bootstrap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_bootstrap.bootstrap.html"
|
|
8
|
-
}
|