@libp2p/plaintext 2.0.19-a6c9aee5a → 2.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/typedoc-urls.json +6 -0
- package/package.json +6 -6
package/dist/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PPlaintext = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PPlaintext=(()=>{var _r=Object.defineProperty;var oi=Object.getOwnPropertyDescriptor;var si=Object.getOwnPropertyNames;var ii=Object.prototype.hasOwnProperty;var at=(r,t)=>{for(var e in t)_r(r,e,{get:t[e],enumerable:!0})},ci=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of si(t))!ii.call(r,o)&&o!==e&&_r(r,o,{get:()=>t[o],enumerable:!(n=oi(t,o))||n.enumerable});return r};var ai=r=>ci(_r({},"__esModule",{value:!0}),r);var ru={};at(ru,{plaintext:()=>eu});var Nr=Symbol.for("@libp2p/peer-id");var ze=class extends Error{static name="UnexpectedPeerError";constructor(t="Unexpected Peer"){super(t),this.name="UnexpectedPeerError"}},Le=class extends Error{static name="InvalidCryptoExchangeError";constructor(t="Invalid crypto exchange"){super(t),this.name="InvalidCryptoExchangeError"}},ut=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},ue=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var fe=class extends Error{static name="ProtocolError";constructor(t="Protocol error"){super(t),this.name="ProtocolError"}};var Ge=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var lo=Symbol.for("@libp2p/service-capabilities"),iu=Symbol.for("@libp2p/service-dependencies");var Or={};at(Or,{base58btc:()=>X,base58flickr:()=>pi});var Tu=new Uint8Array(0);function ho(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 Tt(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 po(r){return new TextEncoder().encode(r)}function mo(r){return new TextDecoder().decode(r)}function ui(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var c=r.length,a=r.charAt(0),f=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function l(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var b=0,h=0,g=0,B=w.length;g!==B&&w[g]===0;)g++,b++;for(var m=(B-g)*u+1>>>0,v=new Uint8Array(m);g!==B;){for(var _=w[g],U=0,I=m-1;(_!==0||U<h)&&I!==-1;I--,U++)_+=256*v[I]>>>0,v[I]=_%c>>>0,_=_/c>>>0;if(_!==0)throw new Error("Non-zero carry");h=U,g++}for(var T=m-h;T!==m&&v[T]===0;)T++;for(var L=a.repeat(b);T<m;++T)L+=r.charAt(v[T]);return L}function p(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var b=0;if(w[b]!==" "){for(var h=0,g=0;w[b]===a;)h++,b++;for(var B=(w.length-b)*f+1>>>0,m=new Uint8Array(B);w[b];){var v=e[w.charCodeAt(b)];if(v===255)return;for(var _=0,U=B-1;(v!==0||_<g)&&U!==-1;U--,_++)v+=c*m[U]>>>0,m[U]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");g=_,b++}if(w[b]!==" "){for(var I=B-g;I!==B&&m[I]===0;)I++;for(var T=new Uint8Array(h+(B-I)),L=h;I!==B;)T[L++]=m[I++];return T}}}function E(w){var b=p(w);if(b)return b;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:p,decode:E}}var fi=ui,li=fi,bo=li;var Dr=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")}},Cr=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 xo(this,t)}},Kr=class{decoders;constructor(t){this.decoders=t}or(t){return xo(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 xo(r,t){return new Kr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Pr=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 Dr(t,e,n),this.decoder=new Cr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function le({name:r,prefix:t,encode:e,decode:n}){return new Pr(r,t,e,n)}function Ot({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=bo(e,r);return le({prefix:t,name:r,encode:n,decode:s=>Tt(o(s))})}function hi(r,t,e,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),c=0,a=0,f=0;for(let u=0;u<s;++u){let l=o[r[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|l,c+=e,c>=8&&(c-=8,i[f++]=255&a>>c)}if(c>=e||(255&a<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return i}function di(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],i+=8;i>e;)i-=e,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function W({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return le({prefix:t,name:r,encode(o){return di(o,n,e)},decode(o){return hi(o,n,e,r)}})}var X=Ot({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),pi=Ot({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var kr={};at(kr,{base32:()=>he,base32hex:()=>xi,base32hexpad:()=>wi,base32hexpadupper:()=>Ei,base32hexupper:()=>gi,base32pad:()=>yi,base32padupper:()=>bi,base32upper:()=>mi,base32z:()=>Si});var he=W({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mi=W({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),yi=W({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),bi=W({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),xi=W({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),gi=W({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),wi=W({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ei=W({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Si=W({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Mr={};at(Mr,{base36:()=>Re,base36upper:()=>Bi});var Re=Ot({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Bi=Ot({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ai=Eo,go=128,vi=127,Ii=~vi,Li=Math.pow(2,31);function Eo(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Li;)t[e++]=r&255|go,r/=128;for(;r&Ii;)t[e++]=r&255|go,r>>>=7;return t[e]=r|0,Eo.bytes=e-n+1,t}var Ri=Hr,Ti=128,wo=127;function Hr(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw Hr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&wo)<<o:(i&wo)*Math.pow(2,o),o+=7}while(i>=Ti);return Hr.bytes=s-n,e}var Ui=Math.pow(2,7),_i=Math.pow(2,14),Ni=Math.pow(2,21),Di=Math.pow(2,28),Ci=Math.pow(2,35),Ki=Math.pow(2,42),Pi=Math.pow(2,49),Oi=Math.pow(2,56),ki=Math.pow(2,63),Mi=function(r){return r<Ui?1:r<_i?2:r<Ni?3:r<Di?4:r<Ci?5:r<Ki?6:r<Pi?7:r<Oi?8:r<ki?9:10},Hi={encode:Ai,decode:Ri,encodingLength:Mi},qi=Hi,Te=qi;function Ue(r,t=0){return[Te.decode(r,t),Te.decode.bytes]}function de(r,t,e=0){return Te.encode(r,t,e),t}function pe(r){return Te.encodingLength(r)}function wt(r,t){let e=t.byteLength,n=pe(r),o=n+pe(e),s=new Uint8Array(o+e);return de(r,s,0),de(e,s,n),s.set(t,o),new me(r,e,t,s)}function qr(r){let t=Tt(r),[e,n]=Ue(t),[o,s]=Ue(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new me(e,o,i,t)}function So(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&ho(r.bytes,e.bytes)}}var me=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Bo(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Fi(e,Vr(r),t??X.encoder);default:return zi(e,Vr(r),t??he.encoder)}}var Ao=new WeakMap;function Vr(r){let t=Ao.get(r);if(t==null){let e=new Map;return Ao.set(r,e),e}return t}var bt=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!==_e)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Gi)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=wt(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&&So(t.multihash,n.multihash)}toString(t){return Bo(this,t)}toJSON(){return{"/":Bo(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??vo(n,o,s.bytes))}else if(e[Zi]===!0){let{version:n,multihash:o,code:s}=e,i=qr(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==_e)throw new Error(`Version 0 CID must use dag-pb (code: ${_e}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=vo(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,_e,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=Tt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new me(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,p]=Ue(t.subarray(e));return e+=p,l},o=n(),s=_e;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,c=n(),a=n(),f=e+a,u=f-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:u,size:f}}static parse(t,e){let[n,o]=Vi(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Vr(s).set(n,t),s}};function Vi(r,t){switch(r[0]){case"Q":{let e=t??X;return[X.prefix,e.decode(`${X.prefix}${r}`)]}case X.prefix:{let e=t??X;return[X.prefix,e.decode(r)]}case he.prefix:{let e=t??he;return[he.prefix,e.decode(r)]}case Re.prefix:{let e=t??Re;return[Re.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 Fi(r,t,e){let{prefix:n}=e;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function zi(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var _e=112,Gi=18;function vo(r,t,e){let n=pe(r),o=n+pe(t),s=new Uint8Array(o+e.byteLength);return de(r,s,0),de(t,s,n),s.set(e,o),s}var Zi=Symbol.for("@ipld/js-cid/CID");var Fr={};at(Fr,{identity:()=>kt});var Io=0,ji="identity",Lo=Tt;function Wi(r){return wt(Io,Lo(r))}var kt={code:Io,name:ji,encode:Lo,digest:Wi};function lt(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 Ro(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Yi(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function be(r,...t){if(!Yi(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 To(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ro(r.outputLen),Ro(r.blockLen)}function xe(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 Uo(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 $t=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function je(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Et(r,t){return r<<32-t|r>>>t}function _o(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Ne(r){return typeof r=="string"&&(r=_o(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 s=r[n];e.set(s,o),o+=s.length}return e}var ge=class{clone(){return this._cloneInto()}};function We(r){let t=n=>r().update(Ne(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Ye(r=32){if($t&&typeof $t.getRandomValues=="function")return $t.getRandomValues(new Uint8Array(r));if($t&&typeof $t.randomBytes=="function")return $t.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Xi(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),c=Number(e&s),a=n?4:0,f=n?0:4;r.setUint32(t+a,i,n),r.setUint32(t+f,c,n)}function No(r,t,e){return r&t^~r&e}function Do(r,t,e){return r&t^r&e^t&e}var we=class extends ge{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=je(this.buffer)}update(t){xe(this);let{view:e,buffer:n,blockLen:o}=this;t=Ne(t);let s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=je(t);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){xe(this),Uo(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)e[l]=0;Xi(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=je(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=a/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)c.setUint32(4*l,u[l],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=i,o%e&&t.buffer.set(n),t}};var Xe=BigInt(4294967295),Gr=BigInt(32);function Co(r,t=!1){return t?{h:Number(r&Xe),l:Number(r>>Gr&Xe)}:{h:Number(r>>Gr&Xe)|0,l:Number(r&Xe)|0}}function $i(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:i}=Co(r[o],t);[e[o],n[o]]=[s,i]}return[e,n]}var Ji=(r,t)=>BigInt(r>>>0)<<Gr|BigInt(t>>>0),Qi=(r,t,e)=>r>>>e,tc=(r,t,e)=>r<<32-e|t>>>e,ec=(r,t,e)=>r>>>e|t<<32-e,rc=(r,t,e)=>r<<32-e|t>>>e,nc=(r,t,e)=>r<<64-e|t>>>e-32,oc=(r,t,e)=>r>>>e-32|t<<64-e,sc=(r,t)=>t,ic=(r,t)=>r,cc=(r,t,e)=>r<<e|t>>>32-e,ac=(r,t,e)=>t<<e|r>>>32-e,uc=(r,t,e)=>t<<e-32|r>>>64-e,fc=(r,t,e)=>r<<e-32|t>>>64-e;function lc(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var hc=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),dc=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,pc=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),mc=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,yc=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),bc=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var xc={fromBig:Co,split:$i,toBig:Ji,shrSH:Qi,shrSL:tc,rotrSH:ec,rotrSL:rc,rotrBH:nc,rotrBL:oc,rotr32H:sc,rotr32L:ic,rotlSH:cc,rotlSL:ac,rotlBH:uc,rotlBL:fc,add:lc,add3L:hc,add3H:dc,add4L:pc,add4H:mc,add5H:bc,add5L:yc},K=xc;var[gc,wc]=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))),Mt=new Uint32Array(80),Ht=new Uint32Array(80),Zr=class extends we{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:s,Cl:i,Dh:c,Dl:a,Eh:f,El:u,Fh:l,Fl:p,Gh:E,Gl:w,Hh:b,Hl:h}=this;return[t,e,n,o,s,i,c,a,f,u,l,p,E,w,b,h]}set(t,e,n,o,s,i,c,a,f,u,l,p,E,w,b,h){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=p|0,this.Gh=E|0,this.Gl=w|0,this.Hh=b|0,this.Hl=h|0}process(t,e){for(let m=0;m<16;m++,e+=4)Mt[m]=t.getUint32(e),Ht[m]=t.getUint32(e+=4);for(let m=16;m<80;m++){let v=Mt[m-15]|0,_=Ht[m-15]|0,U=K.rotrSH(v,_,1)^K.rotrSH(v,_,8)^K.shrSH(v,_,7),I=K.rotrSL(v,_,1)^K.rotrSL(v,_,8)^K.shrSL(v,_,7),T=Mt[m-2]|0,L=Ht[m-2]|0,z=K.rotrSH(T,L,19)^K.rotrBH(T,L,61)^K.shrSH(T,L,6),M=K.rotrSL(T,L,19)^K.rotrBL(T,L,61)^K.shrSL(T,L,6),O=K.add4L(I,M,Ht[m-7],Ht[m-16]),Y=K.add4H(O,U,z,Mt[m-7],Mt[m-16]);Mt[m]=Y|0,Ht[m]=O|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:f,Dl:u,Eh:l,El:p,Fh:E,Fl:w,Gh:b,Gl:h,Hh:g,Hl:B}=this;for(let m=0;m<80;m++){let v=K.rotrSH(l,p,14)^K.rotrSH(l,p,18)^K.rotrBH(l,p,41),_=K.rotrSL(l,p,14)^K.rotrSL(l,p,18)^K.rotrBL(l,p,41),U=l&E^~l&b,I=p&w^~p&h,T=K.add5L(B,_,I,wc[m],Ht[m]),L=K.add5H(T,g,v,U,gc[m],Mt[m]),z=T|0,M=K.rotrSH(n,o,28)^K.rotrBH(n,o,34)^K.rotrBH(n,o,39),O=K.rotrSL(n,o,28)^K.rotrBL(n,o,34)^K.rotrBL(n,o,39),Y=n&s^n&c^s&c,S=o&i^o&a^i&a;g=b|0,B=h|0,b=E|0,h=w|0,E=l|0,w=p|0,{h:l,l:p}=K.add(f|0,u|0,L|0,z|0),f=c|0,u=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let R=K.add3L(z,O,S);n=K.add3H(R,L,M,Y),o=R|0}({h:n,l:o}=K.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=K.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=K.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:f,l:u}=K.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:p}=K.add(this.Eh|0,this.El|0,l|0,p|0),{h:E,l:w}=K.add(this.Fh|0,this.Fl|0,E|0,w|0),{h:b,l:h}=K.add(this.Gh|0,this.Gl|0,b|0,h|0),{h:g,l:B}=K.add(this.Hh|0,this.Hl|0,g|0,B|0),this.set(n,o,s,i,c,a,f,u,l,p,E,w,b,h,g,B)}roundClean(){Mt.fill(0),Ht.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 Ko=We(()=>new Zr);var Qe={};at(Qe,{aInRange:()=>ht,abool:()=>St,abytes:()=>Ee,bitGet:()=>Ic,bitLen:()=>Xr,bitMask:()=>Ce,bitSet:()=>Lc,bytesToHex:()=>_t,bytesToNumberBE:()=>Nt,bytesToNumberLE:()=>Vt,concatBytes:()=>Dt,createHmacDrbg:()=>$r,ensureBytes:()=>j,equalBytes:()=>Ac,hexToBytes:()=>Qt,hexToNumber:()=>Yr,inRange:()=>De,isBytes:()=>qt,memoized:()=>ee,notImplemented:()=>Tc,numberToBytesBE:()=>Ft,numberToBytesLE:()=>te,numberToHexUnpadded:()=>Jt,numberToVarBytesBE:()=>Bc,utf8ToBytes:()=>vc,validateObject:()=>Lt});var $e=BigInt(0),Je=BigInt(1),Ec=BigInt(2);function qt(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ee(r){if(!qt(r))throw new Error("Uint8Array expected")}function St(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var Sc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function _t(r){Ee(r);let t="";for(let e=0;e<r.length;e++)t+=Sc[r[e]];return t}function Jt(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Yr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?$e:BigInt("0x"+r)}var Ut={_0:48,_9:57,A:65,F:70,a:97,f:102};function Po(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 Qt(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,s=0;o<e;o++,s+=2){let i=Po(r.charCodeAt(s)),c=Po(r.charCodeAt(s+1));if(i===void 0||c===void 0){let a=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function Nt(r){return Yr(_t(r))}function Vt(r){return Ee(r),Yr(_t(Uint8Array.from(r).reverse()))}function Ft(r,t){return Qt(r.toString(16).padStart(t*2,"0"))}function te(r,t){return Ft(r,t).reverse()}function Bc(r){return Qt(Jt(r))}function j(r,t,e){let n;if(typeof t=="string")try{n=Qt(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(qt(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];Ee(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}function Ac(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 vc(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var jr=r=>typeof r=="bigint"&&$e<=r;function De(r,t,e){return jr(r)&&jr(t)&&jr(e)&&t<=r&&r<e}function ht(r,t,e,n){if(!De(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Xr(r){let t;for(t=0;r>$e;r>>=Je,t+=1);return t}function Ic(r,t){return r>>BigInt(t)&Je}function Lc(r,t,e){return r|(e?Je:$e)<<BigInt(t)}var Ce=r=>(Ec<<BigInt(r-1))-Je,Wr=r=>new Uint8Array(r),Oo=r=>Uint8Array.from(r);function $r(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=Wr(r),o=Wr(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...l)=>e(o,n,...l),a=(l=Wr())=>{o=c(Oo([0]),l),n=c(),l.length!==0&&(o=c(Oo([1]),l),n=c())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l<t;){n=c();let E=n.slice();p.push(E),l+=n.length}return Dt(...p)};return(l,p)=>{i(),a(l);let E;for(;!(E=p(f()));)a();return i(),E}}var Rc={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"||qt(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 Lt(r,t,e={}){let n=(o,s,i)=>{let c=Rc[s];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(i&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+a)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}var Tc=()=>{throw new Error("not implemented")};function ee(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var $=BigInt(0),G=BigInt(1),re=BigInt(2),Uc=BigInt(3),Jr=BigInt(4),ko=BigInt(5),Mo=BigInt(8),_c=BigInt(9),Nc=BigInt(16);function V(r,t){let e=r%t;return e>=$?e:t+e}function Dc(r,t,e){if(t<$)throw new Error("invalid exponent, negatives unsupported");if(e<=$)throw new Error("invalid modulus");if(e===G)return $;let n=G;for(;t>$;)t&G&&(n=n*r%e),r=r*r%e,t>>=G;return n}function Z(r,t,e){let n=r;for(;t-- >$;)n*=n,n%=e;return n}function tr(r,t){if(r===$)throw new Error("invert: expected non-zero number");if(t<=$)throw new Error("invert: expected positive modulus, got "+t);let e=V(r,t),n=t,o=$,s=G,i=G,c=$;for(;e!==$;){let f=n/e,u=n%e,l=o-i*f,p=s-c*f;n=e,e=u,o=i,s=c,i=l,c=p}if(n!==G)throw new Error("invert: does not exist");return V(o,t)}function Cc(r){let t=(r-G)/re,e,n,o;for(e=r-G,n=0;e%re===$;e/=re,n++);for(o=re;o<r&&Dc(o,t,r)!==r-G;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let i=(r+G)/Jr;return function(a,f){let u=a.pow(f,i);if(!a.eql(a.sqr(u),f))throw new Error("Cannot find square root");return u}}let s=(e+G)/re;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let f=n,u=c.pow(c.mul(c.ONE,o),e),l=c.pow(a,s),p=c.pow(a,e);for(;!c.eql(p,c.ONE);){if(c.eql(p,c.ZERO))return c.ZERO;let E=1;for(let b=c.sqr(p);E<f&&!c.eql(b,c.ONE);E++)b=c.sqr(b);let w=c.pow(u,G<<BigInt(f-E-1));u=c.sqr(w),l=c.mul(l,w),p=c.mul(p,u),f=E}return l}}function Kc(r){if(r%Jr===Uc){let t=(r+G)/Jr;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%Mo===ko){let t=(r-ko)/Mo;return function(n,o){let s=n.mul(o,re),i=n.pow(s,t),c=n.mul(o,i),a=n.mul(n.mul(c,re),i),f=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return r%Nc,Cc(r)}var Ho=(r,t)=>(V(r,t)&G)===G,Pc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Qr(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Pc.reduce((n,o)=>(n[o]="function",n),t);return Lt(r,e)}function Oc(r,t,e){if(e<$)throw new Error("invalid exponent, negatives unsupported");if(e===$)return r.ONE;if(e===G)return t;let n=r.ONE,o=t;for(;e>$;)e&G&&(n=r.mul(n,o)),o=r.sqr(o),e>>=G;return n}function kc(r,t){let e=new Array(t.length),n=t.reduce((s,i,c)=>r.is0(i)?s:(e[c]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return t.reduceRight((s,i,c)=>r.is0(i)?s:(e[c]=r.mul(s,e[c]),r.mul(s,i)),o),e}function tn(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function zt(r,t,e=!1,n={}){if(r<=$)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=tn(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,c=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:Ce(o),ZERO:$,ONE:G,create:a=>V(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return $<=a&&a<r},is0:a=>a===$,isOdd:a=>(a&G)===G,neg:a=>V(-a,r),eql:(a,f)=>a===f,sqr:a=>V(a*a,r),add:(a,f)=>V(a+f,r),sub:(a,f)=>V(a-f,r),mul:(a,f)=>V(a*f,r),pow:(a,f)=>Oc(c,a,f),div:(a,f)=>V(a*tr(f,r),r),sqrN:a=>a*a,addN:(a,f)=>a+f,subN:(a,f)=>a-f,mulN:(a,f)=>a*f,inv:a=>tr(a,r),sqrt:n.sqrt||(a=>(i||(i=Kc(r)),i(c,a))),invertBatch:a=>kc(c,a),cmov:(a,f,u)=>u?f:a,toBytes:a=>e?te(a,s):Ft(a,s),fromBytes:a=>{if(a.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+a.length);return e?Vt(a):Nt(a)}});return Object.freeze(c)}function qo(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 en(r){let t=qo(r);return t+Math.ceil(t/2)}function Vo(r,t,e=!1){let n=r.length,o=qo(t),s=en(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?Vt(r):Nt(r),c=V(i,t-G)+G;return e?te(c,o):Ft(c,o)}var Fo=BigInt(0),er=BigInt(1);function rn(r,t){let e=t.negate();return r?e:t}function zo(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function nn(r,t){zo(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function Mc(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 Hc(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 on=new WeakMap,Go=new WeakMap;function sn(r){return Go.get(r)||1}function rr(r,t){return{constTimeNegate:rn,hasPrecomputes(e){return sn(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Fo;)n&er&&(o=o.add(s)),s=s.double(),n>>=er;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=nn(n,t),i=[],c=e,a=c;for(let f=0;f<o;f++){a=c,i.push(a);for(let u=1;u<s;u++)a=a.add(c),i.push(a);c=a.double()}return i},wNAF(e,n,o){let{windows:s,windowSize:i}=nn(e,t),c=r.ZERO,a=r.BASE,f=BigInt(2**e-1),u=2**e,l=BigInt(e);for(let p=0;p<s;p++){let E=p*i,w=Number(o&f);o>>=l,w>i&&(w-=u,o+=er);let b=E,h=E+Math.abs(w)-1,g=p%2!==0,B=w<0;w===0?a=a.add(rn(g,n[b])):c=c.add(rn(B,n[h]))}return{p:c,f:a}},wNAFUnsafe(e,n,o,s=r.ZERO){let{windows:i,windowSize:c}=nn(e,t),a=BigInt(2**e-1),f=2**e,u=BigInt(e);for(let l=0;l<i;l++){let p=l*c;if(o===Fo)break;let E=Number(o&a);if(o>>=u,E>c&&(E-=f,o+=er),E===0)continue;let w=n[p+Math.abs(E)-1];E<0&&(w=w.negate()),s=s.add(w)}return s},getPrecomputes(e,n,o){let s=on.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&on.set(n,o(s))),s},wNAFCached(e,n,o){let s=sn(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=sn(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){zo(n,t),Go.set(e,n),on.delete(e)}}}function nr(r,t,e,n){if(Mc(e,r),Hc(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,s=Xr(BigInt(e.length)),i=s>12?s-3:s>4?s-2:s?2:1,c=(1<<i)-1,a=new Array(c+1).fill(o),f=Math.floor((t.BITS-1)/i)*i,u=o;for(let l=f;l>=0;l-=i){a.fill(o);for(let E=0;E<n.length;E++){let w=n[E],b=Number(w>>BigInt(l)&BigInt(c));a[b]=a[b].add(e[E])}let p=o;for(let E=a.length-1,w=o;E>0;E--)w=w.add(a[E]),p=p.add(w);if(u=u.add(p),l!==0)for(let E=0;E<i;E++)u=u.double()}return u}function Ke(r){return Qr(r.Fp),Lt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...tn(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Bt=BigInt(0),dt=BigInt(1),or=BigInt(2),qc=BigInt(8),Vc={zip215:!0};function Fc(r){let t=Ke(r);return Lt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Zo(r){let t=Fc(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:c,h:a}=t,f=or<<BigInt(c*8)-dt,u=e.create,l=zt(t.n,t.nBitLength),p=t.uvRatio||((y,d)=>{try{return{isValid:!0,value:e.sqrt(y*e.inv(d))}}catch{return{isValid:!1,value:Bt}}}),E=t.adjustScalarBytes||(y=>y),w=t.domain||((y,d,x)=>{if(St("phflag",x),d.length||x)throw new Error("Contexts/pre-hash are not supported");return y});function b(y,d){ht("coordinate "+y,d,Bt,f)}function h(y){if(!(y instanceof m))throw new Error("ExtendedPoint expected")}let g=ee((y,d)=>{let{ex:x,ey:A,ez:N}=y,D=y.is0();d==null&&(d=D?qc:e.inv(N));let P=u(x*d),k=u(A*d),C=u(N*d);if(D)return{x:Bt,y:dt};if(C!==dt)throw new Error("invZ was invalid");return{x:P,y:k}}),B=ee(y=>{let{a:d,d:x}=t;if(y.is0())throw new Error("bad point: ZERO");let{ex:A,ey:N,ez:D,et:P}=y,k=u(A*A),C=u(N*N),q=u(D*D),F=u(q*q),J=u(k*d),Q=u(q*u(J+C)),nt=u(F+u(x*u(k*C)));if(Q!==nt)throw new Error("bad point: equation left != right (1)");let ot=u(A*N),ft=u(D*P);if(ot!==ft)throw new Error("bad point: equation left != right (2)");return!0});class m{constructor(d,x,A,N){this.ex=d,this.ey=x,this.ez=A,this.et=N,b("x",d),b("y",x),b("z",A),b("t",N),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(d){if(d instanceof m)throw new Error("extended point not allowed");let{x,y:A}=d||{};return b("x",x),b("y",A),new m(x,A,dt,u(x*A))}static normalizeZ(d){let x=e.invertBatch(d.map(A=>A.ez));return d.map((A,N)=>A.toAffine(x[N])).map(m.fromAffine)}static msm(d,x){return nr(m,l,d,x)}_setWindowSize(d){U.setWindowSize(this,d)}assertValidity(){B(this)}equals(d){h(d);let{ex:x,ey:A,ez:N}=this,{ex:D,ey:P,ez:k}=d,C=u(x*k),q=u(D*N),F=u(A*k),J=u(P*N);return C===q&&F===J}is0(){return this.equals(m.ZERO)}negate(){return new m(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:d}=t,{ex:x,ey:A,ez:N}=this,D=u(x*x),P=u(A*A),k=u(or*u(N*N)),C=u(d*D),q=x+A,F=u(u(q*q)-D-P),J=C+P,Q=J-k,nt=C-P,ot=u(F*Q),ft=u(J*nt),ct=u(F*nt),It=u(Q*J);return new m(ot,ft,It,ct)}add(d){h(d);let{a:x,d:A}=t,{ex:N,ey:D,ez:P,et:k}=this,{ex:C,ey:q,ez:F,et:J}=d;if(x===BigInt(-1)){let oo=u((D-N)*(q+C)),so=u((D+N)*(q-C)),Ur=u(so-oo);if(Ur===Bt)return this.double();let io=u(P*or*J),co=u(k*or*F),ao=co+io,uo=so+oo,fo=co-io,ti=u(ao*Ur),ei=u(uo*fo),ri=u(ao*fo),ni=u(Ur*uo);return new m(ti,ei,ni,ri)}let Q=u(N*C),nt=u(D*q),ot=u(k*A*J),ft=u(P*F),ct=u((N+D)*(C+q)-Q-nt),It=ft-ot,Rt=ft+ot,Ie=u(nt-x*Q),Xs=u(ct*It),$s=u(Rt*Ie),Js=u(ct*Ie),Qs=u(It*Rt);return new m(Xs,$s,Qs,Js)}subtract(d){return this.add(d.negate())}wNAF(d){return U.wNAFCached(this,d,m.normalizeZ)}multiply(d){let x=d;ht("scalar",x,dt,n);let{p:A,f:N}=this.wNAF(x);return m.normalizeZ([A,N])[0]}multiplyUnsafe(d,x=m.ZERO){let A=d;return ht("scalar",A,Bt,n),A===Bt?_:this.is0()||A===dt?this:U.wNAFCachedUnsafe(this,A,m.normalizeZ,x)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(d){return g(this,d)}clearCofactor(){let{h:d}=t;return d===dt?this:this.multiplyUnsafe(d)}static fromHex(d,x=!1){let{d:A,a:N}=t,D=e.BYTES;d=j("pointHex",d,D),St("zip215",x);let P=d.slice(),k=d[D-1];P[D-1]=k&-129;let C=Vt(P),q=x?f:e.ORDER;ht("pointHex.y",C,Bt,q);let F=u(C*C),J=u(F-dt),Q=u(A*F-N),{isValid:nt,value:ot}=p(J,Q);if(!nt)throw new Error("Point.fromHex: invalid y coordinate");let ft=(ot&dt)===dt,ct=(k&128)!==0;if(!x&&ot===Bt&&ct)throw new Error("Point.fromHex: x=0 and x_0=1");return ct!==ft&&(ot=u(-ot)),m.fromAffine({x:ot,y:C})}static fromPrivateKey(d){return L(d).point}toRawBytes(){let{x:d,y:x}=this.toAffine(),A=te(x,e.BYTES);return A[A.length-1]|=d&dt?128:0,A}toHex(){return _t(this.toRawBytes())}}m.BASE=new m(t.Gx,t.Gy,dt,u(t.Gx*t.Gy)),m.ZERO=new m(Bt,dt,dt,Bt);let{BASE:v,ZERO:_}=m,U=rr(m,c*8);function I(y){return V(y,n)}function T(y){return I(Vt(y))}function L(y){let d=e.BYTES;y=j("private key",y,d);let x=j("hashed private key",s(y),2*d),A=E(x.slice(0,d)),N=x.slice(d,2*d),D=T(A),P=v.multiply(D),k=P.toRawBytes();return{head:A,prefix:N,scalar:D,point:P,pointBytes:k}}function z(y){return L(y).pointBytes}function M(y=new Uint8Array,...d){let x=Dt(...d);return T(s(w(x,j("context",y),!!o)))}function O(y,d,x={}){y=j("message",y),o&&(y=o(y));let{prefix:A,scalar:N,pointBytes:D}=L(d),P=M(x.context,A,y),k=v.multiply(P).toRawBytes(),C=M(x.context,k,D,y),q=I(P+C*N);ht("signature.s",q,Bt,n);let F=Dt(k,te(q,e.BYTES));return j("result",F,e.BYTES*2)}let Y=Vc;function S(y,d,x,A=Y){let{context:N,zip215:D}=A,P=e.BYTES;y=j("signature",y,2*P),d=j("message",d),x=j("publicKey",x,P),D!==void 0&&St("zip215",D),o&&(d=o(d));let k=Vt(y.slice(P,2*P)),C,q,F;try{C=m.fromHex(x,D),q=m.fromHex(y.slice(0,P),D),F=v.multiplyUnsafe(k)}catch{return!1}if(!D&&C.isSmallOrder())return!1;let J=M(N,q.toRawBytes(),C.toRawBytes(),d);return q.add(C.multiplyUnsafe(J)).subtract(F).clearCofactor().equals(m.ZERO)}return v._setWindowSize(8),{CURVE:t,getPublicKey:z,sign:O,verify:S,ExtendedPoint:m,utils:{getExtendedPublicKey:L,randomPrivateKey:()=>i(e.BYTES),precompute(y=8,d=m.BASE){return d._setWindowSize(y),d.multiply(BigInt(3)),d}}}}var cn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),jo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Sf=BigInt(0),zc=BigInt(1),Wo=BigInt(2),Bf=BigInt(3),Gc=BigInt(5),Zc=BigInt(8);function jc(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=cn,c=r*r%s*r%s,a=Z(c,Wo,s)*c%s,f=Z(a,zc,s)*r%s,u=Z(f,Gc,s)*f%s,l=Z(u,t,s)*u%s,p=Z(l,e,s)*l%s,E=Z(p,n,s)*p%s,w=Z(E,o,s)*E%s,b=Z(w,o,s)*E%s,h=Z(b,t,s)*u%s;return{pow_p_5_8:Z(h,Wo,s)*r%s,b2:c}}function Wc(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Yc(r,t){let e=cn,n=V(t*t*t,e),o=V(n*n*t,e),s=jc(r*o).pow_p_5_8,i=V(r*n*s,e),c=V(t*i*i,e),a=i,f=V(i*jo,e),u=c===r,l=c===V(-r,e),p=c===V(-r*jo,e);return u&&(i=a),(l||p)&&(i=f),Ho(i,e)&&(i=V(-i,e)),{isValid:u||l,value:i}}var Xc=zt(cn,void 0,!0),$c={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Xc,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Zc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Ko,randomBytes:Ye,adjustScalarBytes:Wc,uvRatio:Yc},Yo=Zo($c);var sr=32;function Xo(r,t,e){return Yo.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var ir=class{type="Ed25519";raw;constructor(t){this.raw=an(t,sr)}toMultihash(){return kt.digest(cr(this))}toCID(){return bt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:lt(this.raw,t.raw)}verify(t,e){return Xo(this.raw,e,t)}};function Jo(r){return r=an(r,sr),new ir(r)}function an(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new ut(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function At(r=0){return new Uint8Array(r)}function pt(r=0){return new Uint8Array(r)}var Qc=Math.pow(2,7),ta=Math.pow(2,14),ea=Math.pow(2,21),un=Math.pow(2,28),fn=Math.pow(2,35),ln=Math.pow(2,42),hn=Math.pow(2,49),H=128,st=127;function Ct(r){if(r<Qc)return 1;if(r<ta)return 2;if(r<ea)return 3;if(r<un)return 4;if(r<fn)return 5;if(r<ln)return 6;if(r<hn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function dn(r,t,e=0){switch(Ct(r)){case 8:t[e++]=r&255|H,r/=128;case 7:t[e++]=r&255|H,r/=128;case 6:t[e++]=r&255|H,r/=128;case 5:t[e++]=r&255|H,r/=128;case 4:t[e++]=r&255|H,r>>>=7;case 3:t[e++]=r&255|H,r>>>=7;case 2:t[e++]=r&255|H,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function ra(r,t,e=0){switch(Ct(r)){case 8:t.set(e++,r&255|H),r/=128;case 7:t.set(e++,r&255|H),r/=128;case 6:t.set(e++,r&255|H),r/=128;case 5:t.set(e++,r&255|H),r/=128;case 4:t.set(e++,r&255|H),r>>>=7;case 3:t.set(e++,r&255|H),r>>>=7;case 2:t.set(e++,r&255|H),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function pn(r,t){let e=r[t],n=0;if(n+=e&st,e<H||(e=r[t+1],n+=(e&st)<<7,e<H)||(e=r[t+2],n+=(e&st)<<14,e<H)||(e=r[t+3],n+=(e&st)<<21,e<H)||(e=r[t+4],n+=(e&st)*un,e<H)||(e=r[t+5],n+=(e&st)*fn,e<H)||(e=r[t+6],n+=(e&st)*ln,e<H)||(e=r[t+7],n+=(e&st)*hn,e<H))return n;throw new RangeError("Could not decode varint")}function na(r,t){let e=r.get(t),n=0;if(n+=e&st,e<H||(e=r.get(t+1),n+=(e&st)<<7,e<H)||(e=r.get(t+2),n+=(e&st)<<14,e<H)||(e=r.get(t+3),n+=(e&st)<<21,e<H)||(e=r.get(t+4),n+=(e&st)*un,e<H)||(e=r.get(t+5),n+=(e&st)*fn,e<H)||(e=r.get(t+6),n+=(e&st)*ln,e<H)||(e=r.get(t+7),n+=(e&st)*hn,e<H))return n;throw new RangeError("Could not decode varint")}function Qo(r,t,e=0){return t==null&&(t=pt(Ct(r))),t instanceof Uint8Array?dn(r,t,e):ra(r,t,e)}function ts(r,t=0){return r instanceof Uint8Array?pn(r,t):na(r,t)}var mn=new Float32Array([-0]),Gt=new Uint8Array(mn.buffer);function es(r,t,e){mn[0]=r,t[e]=Gt[0],t[e+1]=Gt[1],t[e+2]=Gt[2],t[e+3]=Gt[3]}function rs(r,t){return Gt[0]=r[t],Gt[1]=r[t+1],Gt[2]=r[t+2],Gt[3]=r[t+3],mn[0]}var yn=new Float64Array([-0]),it=new Uint8Array(yn.buffer);function ns(r,t,e){yn[0]=r,t[e]=it[0],t[e+1]=it[1],t[e+2]=it[2],t[e+3]=it[3],t[e+4]=it[4],t[e+5]=it[5],t[e+6]=it[6],t[e+7]=it[7]}function os(r,t){return it[0]=r[t],it[1]=r[t+1],it[2]=r[t+2],it[3]=r[t+3],it[4]=r[t+4],it[5]=r[t+5],it[6]=r[t+6],it[7]=r[t+7],yn[0]}var sa=BigInt(Number.MAX_SAFE_INTEGER),ia=BigInt(Number.MIN_SAFE_INTEGER),xt=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 ne;if(t<sa&&t>ia)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>ss&&(o=0n,++n>ss&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ne;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):ne}},ne=new xt(0,0);ne.toBigInt=function(){return 0n};ne.zzEncode=ne.zzDecode=function(){return this};ne.length=function(){return 1};var ss=4294967296n;function is(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 cs(r,t,e){if(e-t<1)return"";let o,s=[],i=0,c;for(;t<e;)c=r[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function bn(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function vt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function ar(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var xn=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,vt(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 vt(this,4);return ar(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw vt(this,4);return ar(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw vt(this,4);let t=rs(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw vt(this,4);let t=os(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 vt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return cs(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw vt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw vt(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 xt(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 vt(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 vt(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 vt(this,8);let t=ar(this.buf,this.pos+=4),e=ar(this.buf,this.pos+=4);return new xt(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=pn(this.buf,this.pos);return this.pos+=Ct(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 gn(r){return new xn(r instanceof Uint8Array?r:r.subarray())}function oe(r,t,e){let n=gn(r);return t.decode(n,void 0,e)}var wn={};at(wn,{base10:()=>ca});var ca=Ot({prefix:"9",name:"base10",alphabet:"0123456789"});var En={};at(En,{base16:()=>aa,base16upper:()=>ua});var aa=W({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ua=W({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Sn={};at(Sn,{base2:()=>fa});var fa=W({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Bn={};at(Bn,{base256emoji:()=>ma});var us=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}"),la=us.reduce((r,t,e)=>(r[e]=t,r),[]),ha=us.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function da(r){return r.reduce((t,e)=>(t+=la[e],t),"")}function pa(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=ha[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var ma=le({prefix:"\u{1F680}",name:"base256emoji",encode:da,decode:pa});var An={};at(An,{base64:()=>ya,base64pad:()=>ba,base64url:()=>xa,base64urlpad:()=>ga});var ya=W({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ba=W({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),xa=W({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ga=W({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var vn={};at(vn,{base8:()=>wa});var wa=W({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var In={};at(In,{identity:()=>Ea});var Ea=le({prefix:"\0",name:"identity",encode:r=>mo(r),decode:r=>po(r)});var sl=new TextEncoder,il=new TextDecoder;var Tn={};at(Tn,{sha256:()=>ur,sha512:()=>Aa});function Rn({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?wt(this.code,e):e.then(n=>wt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ls(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var ur=Rn({name:"sha2-256",code:18,encode:ls("SHA-256")}),Aa=Rn({name:"sha2-512",code:19,encode:ls("SHA-512")});var Un={...In,...Sn,...vn,...wn,...En,...kr,...Mr,...Or,...An,...Bn},xl={...Tn,...Fr};function ds(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var hs=ds("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),_n=ds("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=pt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),va={utf8:hs,"utf-8":hs,hex:Un.base16,latin1:_n,ascii:_n,binary:_n,...Un},fr=va;function tt(r,t="utf8"){let e=fr[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(i){if(i<1||i>e)return pt(i);o+i>t&&(n=pt(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var se=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function 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}},Ia=Nn();function La(r){return globalThis.Buffer!=null?pt(r):Ia(r)}var Oe=class{len;head;tail;states;constructor(){this.len=0,this.head=new se(Dn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new se(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Pn((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(lr,10,xt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=xt.fromBigInt(t);return this._push(lr,e.length(),e)}uint64Number(t){return this._push(dn,Ct(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=xt.fromBigInt(t).zzEncode();return this._push(lr,e.length(),e)}sint64Number(t){let e=xt.fromNumber(t).zzEncode();return this._push(lr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Cn,1,t?1:0)}fixed32(t){return this._push(Pe,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=xt.fromBigInt(t);return this._push(Pe,4,e.lo)._push(Pe,4,e.hi)}fixed64Number(t){let e=xt.fromNumber(t);return this._push(Pe,4,e.lo)._push(Pe,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(es,4,t)}double(t){return this._push(ns,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Cn,1,0):this.uint32(e)._push(Ta,e,t)}string(t){let e=is(t);return e!==0?this.uint32(e)._push(bn,e,t):this._push(Cn,1,0)}fork(){return this.states=new Kn(this),this.head=this.tail=new se(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 se(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=La(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Cn(r,t,e){t[e]=r&255}function Ra(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Pn=class extends se{next;constructor(t,e){super(Ra,t,e),this.next=void 0}};function lr(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 Pe(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 Ta(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Oe.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Ua,t,r),this},Oe.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(_a,t,r),this});function Ua(r,t,e){t.set(r,e)}function _a(r,t,e){r.length<40?bn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(tt(r),e)}function On(){return new Oe}function ie(r,t){let e=On();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Se;(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"})(Se||(Se={}));function hr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function ke(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let c=t(s);i.int32(c)},n=function(s){let i=s.int32();return t(i)};return hr("enum",Se.VARINT,e,n)}function ce(r,t){return hr("message",Se.LENGTH_DELIMITED,r,t)}var mt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(mt||(mt={}));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=()=>ke(kn)})(mt||(mt={}));var Zt;(function(r){let t;r.codec=()=>(t==null&&(t=ce((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),mt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=mt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>ie(e,r.codec()),r.decode=(e,n)=>oe(e,r.codec(),n)})(Zt||(Zt={}));var Mn;(function(r){let t;r.codec=()=>(t==null&&(t=ce((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),mt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=mt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>ie(e,r.codec()),r.decode=(e,n)=>oe(e,r.codec(),n)})(Mn||(Mn={}));var qe={};at(qe,{MAX_RSA_KEY_SIZE:()=>zn,generateRSAKeyPair:()=>Rs,jwkToJWKKeyPair:()=>Ts,jwkToPkcs1:()=>Fa,jwkToPkix:()=>Zn,jwkToRSAPrivateKey:()=>Ls,pkcs1ToJwk:()=>As,pkcs1ToRSAPrivateKey:()=>Is,pkixToJwk:()=>vs,pkixToRSAPublicKey:()=>jn});var Na=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),Hn=class extends we{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:s,F:i,G:c,H:a}=this;return[t,e,n,o,s,i,c,a]}set(t,e,n,o,s,i,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,e){for(let l=0;l<16;l++,e+=4)Wt[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let p=Wt[l-15],E=Wt[l-2],w=Et(p,7)^Et(p,18)^p>>>3,b=Et(E,17)^Et(E,19)^E>>>10;Wt[l]=b+Wt[l-7]+w+Wt[l-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:f,H:u}=this;for(let l=0;l<64;l++){let p=Et(c,6)^Et(c,11)^Et(c,25),E=u+p+No(c,a,f)+Na[l]+Wt[l]|0,b=(Et(n,2)^Et(n,13)^Et(n,22))+Do(n,o,s)|0;u=f,f=a,a=c,c=i+E|0,i=s,s=o,o=n,n=E+b|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,s,i,c,a,f,u)}roundClean(){Wt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Be=We(()=>new Hn);function yt(r,t="utf8"){let e=fr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}function dr(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=pt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var ys=Symbol.for("@achingbrain/uint8arraylist");function ms(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function pr(r){return!!r?.[ys]}var et=class r{bufs;length;[ys]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(pr(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(pr(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=ms(this.bufs,t);return e.buf[e.index]}set(t,e){let n=ms(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(pr(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return dr(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:dr(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],c=o,a=c+i.byteLength;if(o=a,t>=a)continue;let f=t>=c&&t<a,u=e>c&&e<=a;if(f&&u){if(t===c&&e===a){n.push(i);break}let l=t-c;n.push(i.subarray(l,l+(e-t)));break}if(f){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(u){if(e===a){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!pr(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let c=i,a=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=e;l<=a;l+=u){u=0;for(let p=f;p>=0;p--){let E=this.get(l+p);if(n[p]!==E){u=Math.max(1,p-c[E]);break}}if(u===0)return l}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=pt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=At(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=At(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=At(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=pt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=At(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=At(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=At(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=At(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=At(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!lt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var Da=parseInt("11111",2),Vn=parseInt("10000000",2),Ca=parseInt("01111111",2),bs={2:Ka,3:ka,5:Oa,6:Pa,16:qn,22:qn,48:qn};function Me(r,t={offset:0}){let e=r[t.offset]&Da;if(t.offset++,bs[e]!=null)return bs[e](r,t);throw new Error("No decoder for tag "+e)}function mr(r,t){let e=0;if((r[t.offset]&Vn)===Vn){let n=r[t.offset]&Ca,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function qn(r,t){mr(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=Me(r,t);if(n===null)break;e.push(n)}return e}function Ka(r,t){let e=mr(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function Pa(r,t){let e=mr(r,t);return t.offset+=e,["oid-unimplemented"]}function Oa(r,t){return t.offset++,null}function ka(r,t){let e=mr(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return Me(o,{offset:0})}function Ma(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new et;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function Fn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=Ma(r.byteLength);return new et(Uint8Array.from([t.byteLength|Vn]),t)}function gt(r){let t=new et,e=parseInt("10000000",2);return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new et(Uint8Array.from([2]),Fn(t),t)}function xs(r){let t=Uint8Array.from([0]),e=new et(t,r);return new et(Uint8Array.from([3]),Fn(e),e)}function yr(r){let t=new et;for(let e of r)t.append(e);return new et(Uint8Array.from([48]),Fn(t),t)}var He=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},br=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var gs={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new br("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var Yt=gs;async function ws(r){let t=await Yt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),e=await Ha(t);return{privateKey:e[0],publicKey:e[1]}}async function Es(r,t){let e=await Yt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Yt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function Ss(r,t,e){let n=await Yt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Yt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function Ha(r){if(r.privateKey==null||r.publicKey==null)throw new ut("Private and public key are required");return Promise.all([Yt.get().subtle.exportKey("jwk",r.privateKey),Yt.get().subtle.exportKey("jwk",r.publicKey)])}function Bs(r){if(r.kty!=="RSA")throw new ut("invalid key type");if(r.n==null)throw new ut("invalid key modulus");return tt(r.n,"base64url").length*8}var Ae=class{type="RSA";_key;_raw;_multihash;constructor(t,e){this._key=t,this._multihash=e}get raw(){return this._raw==null&&(this._raw=qe.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return bt.createV1(114,this._multihash)}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:lt(this.raw,t.raw)}verify(t,e){return Ss(this._key,e,t)}},Ve=class{type="RSA";_key;_raw;publicKey;constructor(t,e){this._key=t,this.publicKey=e}get raw(){return this._raw==null&&(this._raw=qe.jwkToPkcs1(this._key)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:lt(this.raw,t.raw)}sign(t){return Es(this._key,t)}};var zn=8192,Gn=18,qa=1062,Va=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function As(r){let t=Me(r);return{n:yt(t[1],"base64url"),e:yt(t[2],"base64url"),d:yt(t[3],"base64url"),p:yt(t[4],"base64url"),q:yt(t[5],"base64url"),dp:yt(t[6],"base64url"),dq:yt(t[7],"base64url"),qi:yt(t[8],"base64url"),kty:"RSA"}}function Fa(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new ut("JWK was missing components");return yr([gt(Uint8Array.from([0])),gt(tt(r.n,"base64url")),gt(tt(r.e,"base64url")),gt(tt(r.d,"base64url")),gt(tt(r.p,"base64url")),gt(tt(r.q,"base64url")),gt(tt(r.dp,"base64url")),gt(tt(r.dq,"base64url")),gt(tt(r.qi,"base64url"))]).subarray()}function vs(r){let t=Me(r,{offset:0});return{kty:"RSA",n:yt(t[1][0],"base64url"),e:yt(t[1][1],"base64url")}}function Zn(r){if(r.n==null||r.e==null)throw new ut("JWK was missing components");return yr([Va,xs(yr([gt(tt(r.n,"base64url")),gt(tt(r.e,"base64url"))]))]).subarray()}function Is(r){let t=As(r);return Ls(t)}function jn(r,t){if(r.byteLength>=qa)throw new ue("Key size is too large");let e=vs(r);if(t==null){let n=Be(Zt.encode({Type:mt.RSA,Data:r}));t=wt(Gn,n)}return new Ae(e,t)}function Ls(r){if(Bs(r)>zn)throw new ut("Key size is too large");let t=Ts(r),e=Be(Zt.encode({Type:mt.RSA,Data:Zn(t.publicKey)})),n=wt(Gn,e);return new Ve(t.privateKey,new Ae(t.publicKey,n))}async function Rs(r){if(r>zn)throw new ut("Key size is too large");let t=await ws(r),e=Be(Zt.encode({Type:mt.RSA,Data:Zn(t.publicKey)})),n=wt(Gn,e);return new Ve(t.privateKey,new Ae(t.publicKey,n))}function Ts(r){if(r==null)throw new ut("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var xr=class extends ge{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,To(t);let n=Ne(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(t){return xe(this),this.iHash.update(t),this}digestInto(t){xe(this),be(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Wn=(r,t,e)=>new xr(r,t).update(e).digest();Wn.create=(r,t)=>new xr(r,t);function Us(r){r.lowS!==void 0&&St("lowS",r.lowS),r.prehash!==void 0&&St("prehash",r.prehash)}function za(r){let t=Ke(r);Lt(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:Ga,hexToBytes:Za}=Qe,Yn=class extends Error{constructor(t=""){super(t)}},Kt={Err:Yn,_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=Jt(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Jt(o.length/2|128):"";return Jt(r)+s+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++],s=!!(o&128),i=0;if(!s)i=o;else{let a=o&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+a);if(f.length!==a)throw new e("tlv.decode: length bytes not complete");if(f[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of f)i=i<<8|u;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Kt;if(r<Pt)throw new t("integer: negative integers are not allowed");let e=Jt(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 Ga(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Kt,o=typeof r=="string"?Za(r):r;Ee(o);let{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:f,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(f)}},hexFromSig(r){let{_tlv:t,_int:e}=Kt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},Pt=BigInt(0),rt=BigInt(1),Hh=BigInt(2),_s=BigInt(3),qh=BigInt(4);function ja(r){let t=za(r),{Fp:e}=t,n=zt(t.n,t.nBitLength),o=t.toBytes||((b,h,g)=>{let B=h.toAffine();return Dt(Uint8Array.from([4]),e.toBytes(B.x),e.toBytes(B.y))}),s=t.fromBytes||(b=>{let h=b.subarray(1),g=e.fromBytes(h.subarray(0,e.BYTES)),B=e.fromBytes(h.subarray(e.BYTES,2*e.BYTES));return{x:g,y:B}});function i(b){let{a:h,b:g}=t,B=e.sqr(b),m=e.mul(B,b);return e.add(e.add(m,e.mul(b,h)),g)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function c(b){return De(b,rt,t.n)}function a(b){let{allowedPrivateKeyLengths:h,nByteLength:g,wrapPrivateKey:B,n:m}=t;if(h&&typeof b!="bigint"){if(qt(b)&&(b=_t(b)),typeof b!="string"||!h.includes(b.length))throw new Error("invalid private key");b=b.padStart(g*2,"0")}let v;try{v=typeof b=="bigint"?b:Nt(j("private key",b,g))}catch{throw new Error("invalid private key, expected hex or "+g+" bytes, got "+typeof b)}return B&&(v=V(v,m)),ht("private key",v,rt,m),v}function f(b){if(!(b instanceof p))throw new Error("ProjectivePoint expected")}let u=ee((b,h)=>{let{px:g,py:B,pz:m}=b;if(e.eql(m,e.ONE))return{x:g,y:B};let v=b.is0();h==null&&(h=v?e.ONE:e.inv(m));let _=e.mul(g,h),U=e.mul(B,h),I=e.mul(m,h);if(v)return{x:e.ZERO,y:e.ZERO};if(!e.eql(I,e.ONE))throw new Error("invZ was invalid");return{x:_,y:U}}),l=ee(b=>{if(b.is0()){if(t.allowInfinityPoint&&!e.is0(b.py))return;throw new Error("bad point: ZERO")}let{x:h,y:g}=b.toAffine();if(!e.isValid(h)||!e.isValid(g))throw new Error("bad point: x or y not FE");let B=e.sqr(g),m=i(h);if(!e.eql(B,m))throw new Error("bad point: equation left != right");if(!b.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class p{constructor(h,g,B){if(this.px=h,this.py=g,this.pz=B,h==null||!e.isValid(h))throw new Error("x required");if(g==null||!e.isValid(g))throw new Error("y required");if(B==null||!e.isValid(B))throw new Error("z required");Object.freeze(this)}static fromAffine(h){let{x:g,y:B}=h||{};if(!h||!e.isValid(g)||!e.isValid(B))throw new Error("invalid affine point");if(h instanceof p)throw new Error("projective point not allowed");let m=v=>e.eql(v,e.ZERO);return m(g)&&m(B)?p.ZERO:new p(g,B,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let g=e.invertBatch(h.map(B=>B.pz));return h.map((B,m)=>B.toAffine(g[m])).map(p.fromAffine)}static fromHex(h){let g=p.fromAffine(s(j("pointHex",h)));return g.assertValidity(),g}static fromPrivateKey(h){return p.BASE.multiply(a(h))}static msm(h,g){return nr(p,n,h,g)}_setWindowSize(h){w.setWindowSize(this,h)}assertValidity(){l(this)}hasEvenY(){let{y:h}=this.toAffine();if(e.isOdd)return!e.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){f(h);let{px:g,py:B,pz:m}=this,{px:v,py:_,pz:U}=h,I=e.eql(e.mul(g,U),e.mul(v,m)),T=e.eql(e.mul(B,U),e.mul(_,m));return I&&T}negate(){return new p(this.px,e.neg(this.py),this.pz)}double(){let{a:h,b:g}=t,B=e.mul(g,_s),{px:m,py:v,pz:_}=this,U=e.ZERO,I=e.ZERO,T=e.ZERO,L=e.mul(m,m),z=e.mul(v,v),M=e.mul(_,_),O=e.mul(m,v);return O=e.add(O,O),T=e.mul(m,_),T=e.add(T,T),U=e.mul(h,T),I=e.mul(B,M),I=e.add(U,I),U=e.sub(z,I),I=e.add(z,I),I=e.mul(U,I),U=e.mul(O,U),T=e.mul(B,T),M=e.mul(h,M),O=e.sub(L,M),O=e.mul(h,O),O=e.add(O,T),T=e.add(L,L),L=e.add(T,L),L=e.add(L,M),L=e.mul(L,O),I=e.add(I,L),M=e.mul(v,_),M=e.add(M,M),L=e.mul(M,O),U=e.sub(U,L),T=e.mul(M,z),T=e.add(T,T),T=e.add(T,T),new p(U,I,T)}add(h){f(h);let{px:g,py:B,pz:m}=this,{px:v,py:_,pz:U}=h,I=e.ZERO,T=e.ZERO,L=e.ZERO,z=t.a,M=e.mul(t.b,_s),O=e.mul(g,v),Y=e.mul(B,_),S=e.mul(m,U),R=e.add(g,B),y=e.add(v,_);R=e.mul(R,y),y=e.add(O,Y),R=e.sub(R,y),y=e.add(g,m);let d=e.add(v,U);return y=e.mul(y,d),d=e.add(O,S),y=e.sub(y,d),d=e.add(B,m),I=e.add(_,U),d=e.mul(d,I),I=e.add(Y,S),d=e.sub(d,I),L=e.mul(z,y),I=e.mul(M,S),L=e.add(I,L),I=e.sub(Y,L),L=e.add(Y,L),T=e.mul(I,L),Y=e.add(O,O),Y=e.add(Y,O),S=e.mul(z,S),y=e.mul(M,y),Y=e.add(Y,S),S=e.sub(O,S),S=e.mul(z,S),y=e.add(y,S),O=e.mul(Y,y),T=e.add(T,O),O=e.mul(d,y),I=e.mul(R,I),I=e.sub(I,O),O=e.mul(R,Y),L=e.mul(d,L),L=e.add(L,O),new p(I,T,L)}subtract(h){return this.add(h.negate())}is0(){return this.equals(p.ZERO)}wNAF(h){return w.wNAFCached(this,h,p.normalizeZ)}multiplyUnsafe(h){let{endo:g,n:B}=t;ht("scalar",h,Pt,B);let m=p.ZERO;if(h===Pt)return m;if(this.is0()||h===rt)return this;if(!g||w.hasPrecomputes(this))return w.wNAFCachedUnsafe(this,h,p.normalizeZ);let{k1neg:v,k1:_,k2neg:U,k2:I}=g.splitScalar(h),T=m,L=m,z=this;for(;_>Pt||I>Pt;)_&rt&&(T=T.add(z)),I&rt&&(L=L.add(z)),z=z.double(),_>>=rt,I>>=rt;return v&&(T=T.negate()),U&&(L=L.negate()),L=new p(e.mul(L.px,g.beta),L.py,L.pz),T.add(L)}multiply(h){let{endo:g,n:B}=t;ht("scalar",h,rt,B);let m,v;if(g){let{k1neg:_,k1:U,k2neg:I,k2:T}=g.splitScalar(h),{p:L,f:z}=this.wNAF(U),{p:M,f:O}=this.wNAF(T);L=w.constTimeNegate(_,L),M=w.constTimeNegate(I,M),M=new p(e.mul(M.px,g.beta),M.py,M.pz),m=L.add(M),v=z.add(O)}else{let{p:_,f:U}=this.wNAF(h);m=_,v=U}return p.normalizeZ([m,v])[0]}multiplyAndAddUnsafe(h,g,B){let m=p.BASE,v=(U,I)=>I===Pt||I===rt||!U.equals(m)?U.multiplyUnsafe(I):U.multiply(I),_=v(this,g).add(v(h,B));return _.is0()?void 0:_}toAffine(h){return u(this,h)}isTorsionFree(){let{h,isTorsionFree:g}=t;if(h===rt)return!0;if(g)return g(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:g}=t;return h===rt?this:g?g(p,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return St("isCompressed",h),this.assertValidity(),o(p,this,h)}toHex(h=!0){return St("isCompressed",h),_t(this.toRawBytes(h))}}p.BASE=new p(t.Gx,t.Gy,e.ONE),p.ZERO=new p(e.ZERO,e.ONE,e.ZERO);let E=t.nBitLength,w=rr(p,t.endo?Math.ceil(E/2):E);return{CURVE:t,ProjectivePoint:p,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:c}}function Wa(r){let t=Ke(r);return Lt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Ns(r){let t=Wa(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(S){return V(S,n)}function c(S){return tr(S,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=ja({...t,toBytes(S,R,y){let d=R.toAffine(),x=e.toBytes(d.x),A=Dt;return St("isCompressed",y),y?A(Uint8Array.from([R.hasEvenY()?2:3]),x):A(Uint8Array.from([4]),x,e.toBytes(d.y))},fromBytes(S){let R=S.length,y=S[0],d=S.subarray(1);if(R===o&&(y===2||y===3)){let x=Nt(d);if(!De(x,rt,e.ORDER))throw new Error("Point is not on curve");let A=u(x),N;try{N=e.sqrt(A)}catch(k){let C=k instanceof Error?": "+k.message:"";throw new Error("Point is not on curve"+C)}let D=(N&rt)===rt;return(y&1)===1!==D&&(N=e.neg(N)),{x,y:N}}else if(R===s&&y===4){let x=e.fromBytes(d.subarray(0,e.BYTES)),A=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x,y:A}}else{let x=o,A=s;throw new Error("invalid Point, expected length of "+x+", or uncompressed "+A+", got "+R)}}}),p=S=>_t(Ft(S,t.nByteLength));function E(S){let R=n>>rt;return S>R}function w(S){return E(S)?i(-S):S}let b=(S,R,y)=>Nt(S.slice(R,y));class h{constructor(R,y,d){this.r=R,this.s=y,this.recovery=d,this.assertValidity()}static fromCompact(R){let y=t.nByteLength;return R=j("compactSignature",R,y*2),new h(b(R,0,y),b(R,y,2*y))}static fromDER(R){let{r:y,s:d}=Kt.toSig(j("DER",R));return new h(y,d)}assertValidity(){ht("r",this.r,rt,n),ht("s",this.s,rt,n)}addRecoveryBit(R){return new h(this.r,this.s,R)}recoverPublicKey(R){let{r:y,s:d,recovery:x}=this,A=U(j("msgHash",R));if(x==null||![0,1,2,3].includes(x))throw new Error("recovery id invalid");let N=x===2||x===3?y+t.n:y;if(N>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let D=(x&1)===0?"02":"03",P=a.fromHex(D+p(N)),k=c(N),C=i(-A*k),q=i(d*k),F=a.BASE.multiplyAndAddUnsafe(P,C,q);if(!F)throw new Error("point at infinify");return F.assertValidity(),F}hasHighS(){return E(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return Qt(this.toDERHex())}toDERHex(){return Kt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Qt(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let g={isValidPrivateKey(S){try{return f(S),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let S=en(t.n);return Vo(t.randomBytes(S),t.n)},precompute(S=8,R=a.BASE){return R._setWindowSize(S),R.multiply(BigInt(3)),R}};function B(S,R=!0){return a.fromPrivateKey(S).toRawBytes(R)}function m(S){let R=qt(S),y=typeof S=="string",d=(R||y)&&S.length;return R?d===o||d===s:y?d===2*o||d===2*s:S instanceof a}function v(S,R,y=!0){if(m(S))throw new Error("first arg must be private key");if(!m(R))throw new Error("second arg must be public key");return a.fromHex(R).multiply(f(S)).toRawBytes(y)}let _=t.bits2int||function(S){if(S.length>8192)throw new Error("input is too large");let R=Nt(S),y=S.length*8-t.nBitLength;return y>0?R>>BigInt(y):R},U=t.bits2int_modN||function(S){return i(_(S))},I=Ce(t.nBitLength);function T(S){return ht("num < 2^"+t.nBitLength,S,Pt,I),Ft(S,t.nByteLength)}function L(S,R,y=z){if(["recovered","canonical"].some(Q=>Q in y))throw new Error("sign() legacy options not supported");let{hash:d,randomBytes:x}=t,{lowS:A,prehash:N,extraEntropy:D}=y;A==null&&(A=!0),S=j("msgHash",S),Us(y),N&&(S=j("prehashed msgHash",d(S)));let P=U(S),k=f(R),C=[T(k),T(P)];if(D!=null&&D!==!1){let Q=D===!0?x(e.BYTES):D;C.push(j("extraEntropy",Q))}let q=Dt(...C),F=P;function J(Q){let nt=_(Q);if(!l(nt))return;let ot=c(nt),ft=a.BASE.multiply(nt).toAffine(),ct=i(ft.x);if(ct===Pt)return;let It=i(ot*i(F+ct*k));if(It===Pt)return;let Rt=(ft.x===ct?0:2)|Number(ft.y&rt),Ie=It;return A&&E(It)&&(Ie=w(It),Rt^=1),new h(ct,Ie,Rt)}return{seed:q,k2sig:J}}let z={lowS:t.lowS,prehash:!1},M={lowS:t.lowS,prehash:!1};function O(S,R,y=z){let{seed:d,k2sig:x}=L(S,R,y),A=t;return $r(A.hash.outputLen,A.nByteLength,A.hmac)(d,x)}a.BASE._setWindowSize(8);function Y(S,R,y,d=M){let x=S;R=j("msgHash",R),y=j("publicKey",y);let{lowS:A,prehash:N,format:D}=d;if(Us(d),"strict"in d)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 P=typeof x=="string"||qt(x),k=!P&&!D&&typeof x=="object"&&x!==null&&typeof x.r=="bigint"&&typeof x.s=="bigint";if(!P&&!k)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let C,q;try{if(k&&(C=new h(x.r,x.s)),P){try{D!=="compact"&&(C=h.fromDER(x))}catch(Rt){if(!(Rt instanceof Kt.Err))throw Rt}!C&&D!=="der"&&(C=h.fromCompact(x))}q=a.fromHex(y)}catch{return!1}if(!C||A&&C.hasHighS())return!1;N&&(R=t.hash(R));let{r:F,s:J}=C,Q=U(R),nt=c(J),ot=i(Q*nt),ft=i(F*nt),ct=a.BASE.multiplyAndAddUnsafe(q,ot,ft)?.toAffine();return ct?i(ct.x)===F:!1}return{CURVE:t,getPublicKey:B,getSharedSecret:v,sign:O,verify:Y,ProjectivePoint:a,Signature:h,utils:g}}function Ya(r){return{hash:r,hmac:(t,...e)=>Wn(r,t,zr(...e)),randomBytes:Ye}}function Ds(r,t){let e=n=>Ns({...r,...Ya(n)});return{...e(t),create:e}}var Ps=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Cs=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Xa=BigInt(1),Xn=BigInt(2),Ks=(r,t)=>(r+t/Xn)/t;function $a(r){let t=Ps,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),f=r*r*r%t,u=f*f*r%t,l=Z(u,e,t)*u%t,p=Z(l,e,t)*u%t,E=Z(p,Xn,t)*f%t,w=Z(E,o,t)*E%t,b=Z(w,s,t)*w%t,h=Z(b,c,t)*b%t,g=Z(h,a,t)*h%t,B=Z(g,c,t)*b%t,m=Z(B,e,t)*u%t,v=Z(m,i,t)*w%t,_=Z(v,n,t)*f%t,U=Z(_,Xn,t);if(!$n.eql($n.sqr(U),r))throw new Error("Cannot find square root");return U}var $n=zt(Ps,void 0,void 0,{sqrt:$a}),ae=Ds({a:BigInt(0),b:BigInt(7),Fp:$n,n:Cs,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Cs,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Xa*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=Ks(s*r,t),a=Ks(-n*r,t),f=V(r-c*e-a*o,t),u=V(-c*n-a*s,t),l=f>i,p=u>i;if(l&&(f=t-f),p&&(u=t-u),f>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:p,k2:u}}}},Be),Xh=BigInt(0);var $h=ae.ProjectivePoint;function Os(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function ks(r,t,e){let n=ur.digest(e instanceof Uint8Array?e:e.subarray());if(Os(n))return n.then(({digest:o})=>ae.verify(t,o,r)).catch(o=>{throw new He(String(o))});try{return ae.verify(t,n.digest,r)}catch(o){throw new He(String(o))}}var gr=class{type="secp256k1";raw;_key;constructor(t){this._key=Hs(t),this.raw=Ms(this._key)}toMultihash(){return kt.digest(cr(this))}toCID(){return bt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:lt(this.raw,t.raw)}verify(t,e){return ks(this._key,e,t)}};function qs(r){return new gr(r)}function Ms(r){return ae.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Hs(r){try{return ae.ProjectivePoint.fromHex(r),r}catch(t){throw new ue(String(t))}}function Vs(r){return r.byteLength===32?Jo(r):r.byteLength===33?qs(r):jn(r)}function cr(r){return Zt.encode({Type:mt[r.type],Data:r.raw})}var Fs=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()})`}[Nr]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return bt.createV1(Ja,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return lt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return lt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Fs](){return`PeerId(${this.toString()})`}},wr=class extends Fe{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Er=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}},Qa=2336,Jn=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=kt.digest(tt(this.url))}[Fs](){return`PeerId(${this.url})`}[Nr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return bt.createV1(Qa,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=yt(t)),t.toString()===this.toString())}};function zs(r){if(r.type==="Ed25519")return new Er({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new Sr({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new wr({multihash:r.toCID().multihash,publicKey:r});throw new Ge}function ve(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Br=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function Gs(r,t,e){if(t==null)return r;if(t.aborted)return r.catch(()=>{}),Promise.reject(new Br(e?.errorMessage,e?.errorCode,e?.errorName));let n,o=new Br(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((s,i)=>{n=()=>{i(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var Qn=class{readNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.readNext=ve(),this.haveNext=ve()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=ve(),t}async throw(t){return this.ended=!0,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return this.ended=!0,this.nextResult=t,this.haveNext.resolve(),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=ve(),await Gs(this.readNext.promise,e?.signal,e)}};function Zs(){return new Qn}var Ar=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};var to=class extends Error{code;constructor(t,e){super(t),this.code=e}},eo=class extends to{type;constructor(t){super(t,"ABORT_ERR"),this.type="aborted",this.name="AbortError"}};function js(r,t){let e=Zs();r.sink(e).catch(async i=>{await e.end(i)}),r.sink=async i=>{for await(let c of i)await e.push(c);await e.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let o=new et;return{read:async(i,c)=>{c?.signal?.throwIfAborted();let a,f=new Promise((u,l)=>{a=()=>{l(new eo("Read aborted"))},c?.signal?.addEventListener("abort",a)});try{if(i==null){let{done:l,value:p}=await Promise.race([n.next(),f]);return l===!0?new et:p}for(;o.byteLength<i;){let{value:l,done:p}=await Promise.race([n.next(),f]);if(p===!0)throw new Ar("unexpected end of input");o.append(l)}let u=o.sublist(0,i);return o.consume(i),u}finally{a!=null&&c?.signal?.removeEventListener("abort",a)}},write:async(i,c)=>{c?.signal?.throwIfAborted(),i instanceof Uint8Array?await e.push(i,c):await e.push(i.subarray(),c)},unwrap:()=>{if(o.byteLength>0){let i=r.source;r.source=async function*(){t?.yieldBytes===!1?yield o:yield*o,yield*i}()}return r}}}var vr=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Ir=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Lr=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function Ws(r,t={}){let e=js(r,t);t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=Ct(t.maxDataLength));let n=t?.lengthDecoder??ts,o=t?.lengthEncoder??Qo;return{read:async i=>{let c=-1,a=new et;for(;;){a.append(await e.read(1,i));try{c=n(a)}catch(f){if(f instanceof RangeError)continue;throw f}if(c<0)throw new vr("Invalid message length");if(t?.maxLengthLength!=null&&a.byteLength>t.maxLengthLength)throw new Lr("message length length too long");if(c>-1)break}if(t?.maxDataLength!=null&&c>t.maxDataLength)throw new Ir("message length too long");return e.read(c,i)},write:async(i,c)=>{await e.write(new et(o(i.byteLength),i),c)},writeV:async(i,c)=>{let a=new et(...i.flatMap(f=>[o(f.byteLength),f]));await e.write(a,c)},unwrap:()=>e.unwrap()}}function Ys(r,t){let e=Ws(r,t),n={read:async(o,s)=>{let i=await e.read(s);return o.decode(i)},write:async(o,s,i)=>{await e.write(s.encode(o),i)},writeV:async(o,s,i)=>{await e.writeV(o.map(c=>s.encode(c)),i)},pb:o=>({read:async s=>n.read(o,s),write:async(s,i)=>n.write(s,o,i),writeV:async(s,i)=>n.writeV(s,o,i),unwrap:()=>n}),unwrap:()=>e.unwrap()};return n}var Rr;(function(r){let t;r.codec=()=>(t==null&&(t=ce((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.id!=null&&(n.uint32(10),n.bytes(e.id)),e.pubkey!=null&&(n.uint32(18),Tr.codec().encode(e.pubkey,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.id=e.bytes();break}case 2:{s.pubkey=Tr.codec().decode(e,e.uint32(),{limits:o.limits?.pubkey});break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>ie(e,r.codec()),r.decode=(e,n)=>oe(e,r.codec(),n)})(Rr||(Rr={}));var Xt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(Xt||(Xt={}));var ro;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(ro||(ro={}));(function(r){r.codec=()=>ke(ro)})(Xt||(Xt={}));var Tr;(function(r){let t;r.codec=()=>(t==null&&(t=ce((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),Xt.codec().encode(e.Type,n)),e.Data!=null&&e.Data.byteLength>0&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={Data:At(0)},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=Xt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>ie(e,r.codec()),r.decode=(e,n)=>oe(e,r.codec(),n)})(Tr||(Tr={}));var tu="/plaintext/2.0.0",no=class{protocol=tu;privateKey;log;constructor(t){this.privateKey=t.privateKey,this.log=t.logger.forComponent("libp2p:plaintext")}[Symbol.toStringTag]="@libp2p/plaintext";[lo]=["@libp2p/connection-encryption"];async secureInbound(t,e){return this._encrypt(t,e)}async secureOutbound(t,e){return this._encrypt(t,e)}async _encrypt(t,e){let n=Ys(t).pb(Rr);this.log("write pubkey exchange to peer %p",e?.remotePeer);let o=this.privateKey.publicKey,[,s]=await Promise.all([n.write({id:o.toMultihash().bytes,pubkey:{Type:Xt[o.type],Data:o.raw}},e),n.read(e)]),i;try{if(s.pubkey==null)throw new fe("Public key missing");if(s.pubkey.Data.byteLength===0)throw new fe("Public key data too short");if(s.id==null)throw new fe("Remote id missing");let c=Vs(s.pubkey.Data);if(i=zs(c),!lt(i.toMultihash().bytes,s.id))throw new Le("Public key did not match id")}catch(c){throw this.log.error(c),new Le("Invalid public key - "+c.message)}if(e?.remotePeer!=null&&!i.equals(e?.remotePeer))throw new ze;return this.log("plaintext key exchange completed successfully with peer %p",i),{conn:n.unwrap().unwrap(),remotePeer:i}}};function eu(){return r=>new no(r)}return ai(ru);})();
|
|
2
|
+
"use strict";var Libp2PPlaintext=(()=>{var _r=Object.defineProperty;var oi=Object.getOwnPropertyDescriptor;var si=Object.getOwnPropertyNames;var ii=Object.prototype.hasOwnProperty;var at=(r,t)=>{for(var e in t)_r(r,e,{get:t[e],enumerable:!0})},ci=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of si(t))!ii.call(r,o)&&o!==e&&_r(r,o,{get:()=>t[o],enumerable:!(n=oi(t,o))||n.enumerable});return r};var ai=r=>ci(_r({},"__esModule",{value:!0}),r);var ru={};at(ru,{plaintext:()=>eu});var Nr=Symbol.for("@libp2p/peer-id");var ze=class extends Error{static name="UnexpectedPeerError";constructor(t="Unexpected Peer"){super(t),this.name="UnexpectedPeerError"}},Le=class extends Error{static name="InvalidCryptoExchangeError";constructor(t="Invalid crypto exchange"){super(t),this.name="InvalidCryptoExchangeError"}},ut=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},ue=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var fe=class extends Error{static name="ProtocolError";constructor(t="Protocol error"){super(t),this.name="ProtocolError"}};var Ge=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var lo=Symbol.for("@libp2p/service-capabilities"),iu=Symbol.for("@libp2p/service-dependencies");var Or={};at(Or,{base58btc:()=>X,base58flickr:()=>pi});var Tu=new Uint8Array(0);function ho(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 Tt(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 po(r){return new TextEncoder().encode(r)}function mo(r){return new TextDecoder().decode(r)}function ui(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var c=r.length,a=r.charAt(0),f=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function l(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var b=0,h=0,g=0,B=w.length;g!==B&&w[g]===0;)g++,b++;for(var m=(B-g)*u+1>>>0,v=new Uint8Array(m);g!==B;){for(var _=w[g],U=0,I=m-1;(_!==0||U<h)&&I!==-1;I--,U++)_+=256*v[I]>>>0,v[I]=_%c>>>0,_=_/c>>>0;if(_!==0)throw new Error("Non-zero carry");h=U,g++}for(var T=m-h;T!==m&&v[T]===0;)T++;for(var L=a.repeat(b);T<m;++T)L+=r.charAt(v[T]);return L}function p(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var b=0;if(w[b]!==" "){for(var h=0,g=0;w[b]===a;)h++,b++;for(var B=(w.length-b)*f+1>>>0,m=new Uint8Array(B);w[b];){var v=e[w.charCodeAt(b)];if(v===255)return;for(var _=0,U=B-1;(v!==0||_<g)&&U!==-1;U--,_++)v+=c*m[U]>>>0,m[U]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");g=_,b++}if(w[b]!==" "){for(var I=B-g;I!==B&&m[I]===0;)I++;for(var T=new Uint8Array(h+(B-I)),L=h;I!==B;)T[L++]=m[I++];return T}}}function E(w){var b=p(w);if(b)return b;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:p,decode:E}}var fi=ui,li=fi,bo=li;var Dr=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")}},Cr=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 xo(this,t)}},Kr=class{decoders;constructor(t){this.decoders=t}or(t){return xo(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 xo(r,t){return new Kr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Pr=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 Dr(t,e,n),this.decoder=new Cr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function le({name:r,prefix:t,encode:e,decode:n}){return new Pr(r,t,e,n)}function Ot({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=bo(e,r);return le({prefix:t,name:r,encode:n,decode:s=>Tt(o(s))})}function hi(r,t,e,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),c=0,a=0,f=0;for(let u=0;u<s;++u){let l=o[r[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|l,c+=e,c>=8&&(c-=8,i[f++]=255&a>>c)}if(c>=e||(255&a<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return i}function di(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],i+=8;i>e;)i-=e,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function j({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return le({prefix:t,name:r,encode(o){return di(o,n,e)},decode(o){return hi(o,n,e,r)}})}var X=Ot({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),pi=Ot({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var kr={};at(kr,{base32:()=>he,base32hex:()=>xi,base32hexpad:()=>wi,base32hexpadupper:()=>Ei,base32hexupper:()=>gi,base32pad:()=>yi,base32padupper:()=>bi,base32upper:()=>mi,base32z:()=>Si});var he=j({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mi=j({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),yi=j({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),bi=j({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),xi=j({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),gi=j({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),wi=j({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ei=j({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Si=j({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Mr={};at(Mr,{base36:()=>Re,base36upper:()=>Bi});var Re=Ot({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Bi=Ot({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ai=Eo,go=128,vi=127,Ii=~vi,Li=Math.pow(2,31);function Eo(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Li;)t[e++]=r&255|go,r/=128;for(;r&Ii;)t[e++]=r&255|go,r>>>=7;return t[e]=r|0,Eo.bytes=e-n+1,t}var Ri=qr,Ti=128,wo=127;function qr(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw qr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&wo)<<o:(i&wo)*Math.pow(2,o),o+=7}while(i>=Ti);return qr.bytes=s-n,e}var Ui=Math.pow(2,7),_i=Math.pow(2,14),Ni=Math.pow(2,21),Di=Math.pow(2,28),Ci=Math.pow(2,35),Ki=Math.pow(2,42),Pi=Math.pow(2,49),Oi=Math.pow(2,56),ki=Math.pow(2,63),Mi=function(r){return r<Ui?1:r<_i?2:r<Ni?3:r<Di?4:r<Ci?5:r<Ki?6:r<Pi?7:r<Oi?8:r<ki?9:10},qi={encode:Ai,decode:Ri,encodingLength:Mi},Hi=qi,Te=Hi;function Ue(r,t=0){return[Te.decode(r,t),Te.decode.bytes]}function de(r,t,e=0){return Te.encode(r,t,e),t}function pe(r){return Te.encodingLength(r)}function wt(r,t){let e=t.byteLength,n=pe(r),o=n+pe(e),s=new Uint8Array(o+e);return de(r,s,0),de(e,s,n),s.set(t,o),new me(r,e,t,s)}function Hr(r){let t=Tt(r),[e,n]=Ue(t),[o,s]=Ue(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new me(e,o,i,t)}function So(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&ho(r.bytes,e.bytes)}}var me=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Bo(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Fi(e,Vr(r),t??X.encoder);default:return zi(e,Vr(r),t??he.encoder)}}var Ao=new WeakMap;function Vr(r){let t=Ao.get(r);if(t==null){let e=new Map;return Ao.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!==_e)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Gi)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=wt(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&&So(t.multihash,n.multihash)}toString(t){return Bo(this,t)}toJSON(){return{"/":Bo(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??vo(n,o,s.bytes))}else if(e[Zi]===!0){let{version:n,multihash:o,code:s}=e,i=Hr(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==_e)throw new Error(`Version 0 CID must use dag-pb (code: ${_e}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=vo(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,_e,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=Tt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new me(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,p]=Ue(t.subarray(e));return e+=p,l},o=n(),s=_e;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,c=n(),a=n(),f=e+a,u=f-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:u,size:f}}static parse(t,e){let[n,o]=Vi(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Vr(s).set(n,t),s}};function Vi(r,t){switch(r[0]){case"Q":{let e=t??X;return[X.prefix,e.decode(`${X.prefix}${r}`)]}case X.prefix:{let e=t??X;return[X.prefix,e.decode(r)]}case he.prefix:{let e=t??he;return[he.prefix,e.decode(r)]}case Re.prefix:{let e=t??Re;return[Re.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 Fi(r,t,e){let{prefix:n}=e;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function zi(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var _e=112,Gi=18;function vo(r,t,e){let n=pe(r),o=n+pe(t),s=new Uint8Array(o+e.byteLength);return de(r,s,0),de(t,s,n),s.set(e,o),s}var Zi=Symbol.for("@ipld/js-cid/CID");var Fr={};at(Fr,{identity:()=>kt});var Io=0,Wi="identity",Lo=Tt;function ji(r){return wt(Io,Lo(r))}var kt={code:Io,name:Wi,encode:Lo,digest:ji};function ht(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 Ro(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Yi(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function be(r,...t){if(!Yi(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 To(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ro(r.outputLen),Ro(r.blockLen)}function xe(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 Uo(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 $t=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function We(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Et(r,t){return r<<32-t|r>>>t}function _o(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Ne(r){return typeof r=="string"&&(r=_o(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 s=r[n];e.set(s,o),o+=s.length}return e}var ge=class{clone(){return this._cloneInto()}};function je(r){let t=n=>r().update(Ne(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Ye(r=32){if($t&&typeof $t.getRandomValues=="function")return $t.getRandomValues(new Uint8Array(r));if($t&&typeof $t.randomBytes=="function")return $t.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Xi(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),c=Number(e&s),a=n?4:0,f=n?0:4;r.setUint32(t+a,i,n),r.setUint32(t+f,c,n)}function No(r,t,e){return r&t^~r&e}function Do(r,t,e){return r&t^r&e^t&e}var we=class extends ge{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=We(this.buffer)}update(t){xe(this);let{view:e,buffer:n,blockLen:o}=this;t=Ne(t);let s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=We(t);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){xe(this),Uo(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)e[l]=0;Xi(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=We(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=a/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)c.setUint32(4*l,u[l],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=i,o%e&&t.buffer.set(n),t}};var Xe=BigInt(4294967295),Gr=BigInt(32);function Co(r,t=!1){return t?{h:Number(r&Xe),l:Number(r>>Gr&Xe)}:{h:Number(r>>Gr&Xe)|0,l:Number(r&Xe)|0}}function $i(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:i}=Co(r[o],t);[e[o],n[o]]=[s,i]}return[e,n]}var Ji=(r,t)=>BigInt(r>>>0)<<Gr|BigInt(t>>>0),Qi=(r,t,e)=>r>>>e,tc=(r,t,e)=>r<<32-e|t>>>e,ec=(r,t,e)=>r>>>e|t<<32-e,rc=(r,t,e)=>r<<32-e|t>>>e,nc=(r,t,e)=>r<<64-e|t>>>e-32,oc=(r,t,e)=>r>>>e-32|t<<64-e,sc=(r,t)=>t,ic=(r,t)=>r,cc=(r,t,e)=>r<<e|t>>>32-e,ac=(r,t,e)=>t<<e|r>>>32-e,uc=(r,t,e)=>t<<e-32|r>>>64-e,fc=(r,t,e)=>r<<e-32|t>>>64-e;function lc(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var hc=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),dc=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,pc=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),mc=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,yc=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),bc=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var xc={fromBig:Co,split:$i,toBig:Ji,shrSH:Qi,shrSL:tc,rotrSH:ec,rotrSL:rc,rotrBH:nc,rotrBL:oc,rotr32H:sc,rotr32L:ic,rotlSH:cc,rotlSL:ac,rotlBH:uc,rotlBL:fc,add:lc,add3L:hc,add3H:dc,add4L:pc,add4H:mc,add5H:bc,add5L:yc},K=xc;var[gc,wc]=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))),Mt=new Uint32Array(80),qt=new Uint32Array(80),Zr=class extends we{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:s,Cl:i,Dh:c,Dl:a,Eh:f,El:u,Fh:l,Fl:p,Gh:E,Gl:w,Hh:b,Hl:h}=this;return[t,e,n,o,s,i,c,a,f,u,l,p,E,w,b,h]}set(t,e,n,o,s,i,c,a,f,u,l,p,E,w,b,h){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=p|0,this.Gh=E|0,this.Gl=w|0,this.Hh=b|0,this.Hl=h|0}process(t,e){for(let m=0;m<16;m++,e+=4)Mt[m]=t.getUint32(e),qt[m]=t.getUint32(e+=4);for(let m=16;m<80;m++){let v=Mt[m-15]|0,_=qt[m-15]|0,U=K.rotrSH(v,_,1)^K.rotrSH(v,_,8)^K.shrSH(v,_,7),I=K.rotrSL(v,_,1)^K.rotrSL(v,_,8)^K.shrSL(v,_,7),T=Mt[m-2]|0,L=qt[m-2]|0,z=K.rotrSH(T,L,19)^K.rotrBH(T,L,61)^K.shrSH(T,L,6),M=K.rotrSL(T,L,19)^K.rotrBL(T,L,61)^K.shrSL(T,L,6),O=K.add4L(I,M,qt[m-7],qt[m-16]),Y=K.add4H(O,U,z,Mt[m-7],Mt[m-16]);Mt[m]=Y|0,qt[m]=O|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:f,Dl:u,Eh:l,El:p,Fh:E,Fl:w,Gh:b,Gl:h,Hh:g,Hl:B}=this;for(let m=0;m<80;m++){let v=K.rotrSH(l,p,14)^K.rotrSH(l,p,18)^K.rotrBH(l,p,41),_=K.rotrSL(l,p,14)^K.rotrSL(l,p,18)^K.rotrBL(l,p,41),U=l&E^~l&b,I=p&w^~p&h,T=K.add5L(B,_,I,wc[m],qt[m]),L=K.add5H(T,g,v,U,gc[m],Mt[m]),z=T|0,M=K.rotrSH(n,o,28)^K.rotrBH(n,o,34)^K.rotrBH(n,o,39),O=K.rotrSL(n,o,28)^K.rotrBL(n,o,34)^K.rotrBL(n,o,39),Y=n&s^n&c^s&c,S=o&i^o&a^i&a;g=b|0,B=h|0,b=E|0,h=w|0,E=l|0,w=p|0,{h:l,l:p}=K.add(f|0,u|0,L|0,z|0),f=c|0,u=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let R=K.add3L(z,O,S);n=K.add3H(R,L,M,Y),o=R|0}({h:n,l:o}=K.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=K.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=K.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:f,l:u}=K.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:p}=K.add(this.Eh|0,this.El|0,l|0,p|0),{h:E,l:w}=K.add(this.Fh|0,this.Fl|0,E|0,w|0),{h:b,l:h}=K.add(this.Gh|0,this.Gl|0,b|0,h|0),{h:g,l:B}=K.add(this.Hh|0,this.Hl|0,g|0,B|0),this.set(n,o,s,i,c,a,f,u,l,p,E,w,b,h,g,B)}roundClean(){Mt.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 Ko=je(()=>new Zr);var Qe={};at(Qe,{aInRange:()=>dt,abool:()=>St,abytes:()=>Ee,bitGet:()=>Ic,bitLen:()=>Xr,bitMask:()=>Ce,bitSet:()=>Lc,bytesToHex:()=>_t,bytesToNumberBE:()=>Nt,bytesToNumberLE:()=>Vt,concatBytes:()=>Dt,createHmacDrbg:()=>$r,ensureBytes:()=>W,equalBytes:()=>Ac,hexToBytes:()=>Qt,hexToNumber:()=>Yr,inRange:()=>De,isBytes:()=>Ht,memoized:()=>ee,notImplemented:()=>Tc,numberToBytesBE:()=>Ft,numberToBytesLE:()=>te,numberToHexUnpadded:()=>Jt,numberToVarBytesBE:()=>Bc,utf8ToBytes:()=>vc,validateObject:()=>Lt});var $e=BigInt(0),Je=BigInt(1),Ec=BigInt(2);function Ht(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ee(r){if(!Ht(r))throw new Error("Uint8Array expected")}function St(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var Sc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function _t(r){Ee(r);let t="";for(let e=0;e<r.length;e++)t+=Sc[r[e]];return t}function Jt(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Yr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?$e:BigInt("0x"+r)}var Ut={_0:48,_9:57,A:65,F:70,a:97,f:102};function Po(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 Qt(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,s=0;o<e;o++,s+=2){let i=Po(r.charCodeAt(s)),c=Po(r.charCodeAt(s+1));if(i===void 0||c===void 0){let a=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function Nt(r){return Yr(_t(r))}function Vt(r){return Ee(r),Yr(_t(Uint8Array.from(r).reverse()))}function Ft(r,t){return Qt(r.toString(16).padStart(t*2,"0"))}function te(r,t){return Ft(r,t).reverse()}function Bc(r){return Qt(Jt(r))}function W(r,t,e){let n;if(typeof t=="string")try{n=Qt(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(Ht(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];Ee(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}function Ac(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 vc(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var Wr=r=>typeof r=="bigint"&&$e<=r;function De(r,t,e){return Wr(r)&&Wr(t)&&Wr(e)&&t<=r&&r<e}function dt(r,t,e,n){if(!De(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Xr(r){let t;for(t=0;r>$e;r>>=Je,t+=1);return t}function Ic(r,t){return r>>BigInt(t)&Je}function Lc(r,t,e){return r|(e?Je:$e)<<BigInt(t)}var Ce=r=>(Ec<<BigInt(r-1))-Je,jr=r=>new Uint8Array(r),Oo=r=>Uint8Array.from(r);function $r(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=jr(r),o=jr(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...l)=>e(o,n,...l),a=(l=jr())=>{o=c(Oo([0]),l),n=c(),l.length!==0&&(o=c(Oo([1]),l),n=c())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l<t;){n=c();let E=n.slice();p.push(E),l+=n.length}return Dt(...p)};return(l,p)=>{i(),a(l);let E;for(;!(E=p(f()));)a();return i(),E}}var Rc={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"||Ht(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 Lt(r,t,e={}){let n=(o,s,i)=>{let c=Rc[s];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(i&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+a)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}var Tc=()=>{throw new Error("not implemented")};function ee(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var $=BigInt(0),G=BigInt(1),re=BigInt(2),Uc=BigInt(3),Jr=BigInt(4),ko=BigInt(5),Mo=BigInt(8),_c=BigInt(9),Nc=BigInt(16);function V(r,t){let e=r%t;return e>=$?e:t+e}function Dc(r,t,e){if(t<$)throw new Error("invalid exponent, negatives unsupported");if(e<=$)throw new Error("invalid modulus");if(e===G)return $;let n=G;for(;t>$;)t&G&&(n=n*r%e),r=r*r%e,t>>=G;return n}function Z(r,t,e){let n=r;for(;t-- >$;)n*=n,n%=e;return n}function tr(r,t){if(r===$)throw new Error("invert: expected non-zero number");if(t<=$)throw new Error("invert: expected positive modulus, got "+t);let e=V(r,t),n=t,o=$,s=G,i=G,c=$;for(;e!==$;){let f=n/e,u=n%e,l=o-i*f,p=s-c*f;n=e,e=u,o=i,s=c,i=l,c=p}if(n!==G)throw new Error("invert: does not exist");return V(o,t)}function Cc(r){let t=(r-G)/re,e,n,o;for(e=r-G,n=0;e%re===$;e/=re,n++);for(o=re;o<r&&Dc(o,t,r)!==r-G;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let i=(r+G)/Jr;return function(a,f){let u=a.pow(f,i);if(!a.eql(a.sqr(u),f))throw new Error("Cannot find square root");return u}}let s=(e+G)/re;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let f=n,u=c.pow(c.mul(c.ONE,o),e),l=c.pow(a,s),p=c.pow(a,e);for(;!c.eql(p,c.ONE);){if(c.eql(p,c.ZERO))return c.ZERO;let E=1;for(let b=c.sqr(p);E<f&&!c.eql(b,c.ONE);E++)b=c.sqr(b);let w=c.pow(u,G<<BigInt(f-E-1));u=c.sqr(w),l=c.mul(l,w),p=c.mul(p,u),f=E}return l}}function Kc(r){if(r%Jr===Uc){let t=(r+G)/Jr;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%Mo===ko){let t=(r-ko)/Mo;return function(n,o){let s=n.mul(o,re),i=n.pow(s,t),c=n.mul(o,i),a=n.mul(n.mul(c,re),i),f=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return r%Nc,Cc(r)}var qo=(r,t)=>(V(r,t)&G)===G,Pc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Qr(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Pc.reduce((n,o)=>(n[o]="function",n),t);return Lt(r,e)}function Oc(r,t,e){if(e<$)throw new Error("invalid exponent, negatives unsupported");if(e===$)return r.ONE;if(e===G)return t;let n=r.ONE,o=t;for(;e>$;)e&G&&(n=r.mul(n,o)),o=r.sqr(o),e>>=G;return n}function kc(r,t){let e=new Array(t.length),n=t.reduce((s,i,c)=>r.is0(i)?s:(e[c]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return t.reduceRight((s,i,c)=>r.is0(i)?s:(e[c]=r.mul(s,e[c]),r.mul(s,i)),o),e}function tn(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function zt(r,t,e=!1,n={}){if(r<=$)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=tn(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,c=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:Ce(o),ZERO:$,ONE:G,create:a=>V(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return $<=a&&a<r},is0:a=>a===$,isOdd:a=>(a&G)===G,neg:a=>V(-a,r),eql:(a,f)=>a===f,sqr:a=>V(a*a,r),add:(a,f)=>V(a+f,r),sub:(a,f)=>V(a-f,r),mul:(a,f)=>V(a*f,r),pow:(a,f)=>Oc(c,a,f),div:(a,f)=>V(a*tr(f,r),r),sqrN:a=>a*a,addN:(a,f)=>a+f,subN:(a,f)=>a-f,mulN:(a,f)=>a*f,inv:a=>tr(a,r),sqrt:n.sqrt||(a=>(i||(i=Kc(r)),i(c,a))),invertBatch:a=>kc(c,a),cmov:(a,f,u)=>u?f:a,toBytes:a=>e?te(a,s):Ft(a,s),fromBytes:a=>{if(a.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+a.length);return e?Vt(a):Nt(a)}});return Object.freeze(c)}function Ho(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 en(r){let t=Ho(r);return t+Math.ceil(t/2)}function Vo(r,t,e=!1){let n=r.length,o=Ho(t),s=en(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?Vt(r):Nt(r),c=V(i,t-G)+G;return e?te(c,o):Ft(c,o)}var Fo=BigInt(0),er=BigInt(1);function rn(r,t){let e=t.negate();return r?e:t}function zo(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function nn(r,t){zo(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function Mc(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 on=new WeakMap,Go=new WeakMap;function sn(r){return Go.get(r)||1}function rr(r,t){return{constTimeNegate:rn,hasPrecomputes(e){return sn(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Fo;)n&er&&(o=o.add(s)),s=s.double(),n>>=er;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=nn(n,t),i=[],c=e,a=c;for(let f=0;f<o;f++){a=c,i.push(a);for(let u=1;u<s;u++)a=a.add(c),i.push(a);c=a.double()}return i},wNAF(e,n,o){let{windows:s,windowSize:i}=nn(e,t),c=r.ZERO,a=r.BASE,f=BigInt(2**e-1),u=2**e,l=BigInt(e);for(let p=0;p<s;p++){let E=p*i,w=Number(o&f);o>>=l,w>i&&(w-=u,o+=er);let b=E,h=E+Math.abs(w)-1,g=p%2!==0,B=w<0;w===0?a=a.add(rn(g,n[b])):c=c.add(rn(B,n[h]))}return{p:c,f:a}},wNAFUnsafe(e,n,o,s=r.ZERO){let{windows:i,windowSize:c}=nn(e,t),a=BigInt(2**e-1),f=2**e,u=BigInt(e);for(let l=0;l<i;l++){let p=l*c;if(o===Fo)break;let E=Number(o&a);if(o>>=u,E>c&&(E-=f,o+=er),E===0)continue;let w=n[p+Math.abs(E)-1];E<0&&(w=w.negate()),s=s.add(w)}return s},getPrecomputes(e,n,o){let s=on.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&on.set(n,o(s))),s},wNAFCached(e,n,o){let s=sn(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=sn(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){zo(n,t),Go.set(e,n),on.delete(e)}}}function nr(r,t,e,n){if(Mc(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,s=Xr(BigInt(e.length)),i=s>12?s-3:s>4?s-2:s?2:1,c=(1<<i)-1,a=new Array(c+1).fill(o),f=Math.floor((t.BITS-1)/i)*i,u=o;for(let l=f;l>=0;l-=i){a.fill(o);for(let E=0;E<n.length;E++){let w=n[E],b=Number(w>>BigInt(l)&BigInt(c));a[b]=a[b].add(e[E])}let p=o;for(let E=a.length-1,w=o;E>0;E--)w=w.add(a[E]),p=p.add(w);if(u=u.add(p),l!==0)for(let E=0;E<i;E++)u=u.double()}return u}function Ke(r){return Qr(r.Fp),Lt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...tn(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Bt=BigInt(0),pt=BigInt(1),or=BigInt(2),Hc=BigInt(8),Vc={zip215:!0};function Fc(r){let t=Ke(r);return Lt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Zo(r){let t=Fc(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:c,h:a}=t,f=or<<BigInt(c*8)-pt,u=e.create,l=zt(t.n,t.nBitLength),p=t.uvRatio||((y,d)=>{try{return{isValid:!0,value:e.sqrt(y*e.inv(d))}}catch{return{isValid:!1,value:Bt}}}),E=t.adjustScalarBytes||(y=>y),w=t.domain||((y,d,x)=>{if(St("phflag",x),d.length||x)throw new Error("Contexts/pre-hash are not supported");return y});function b(y,d){dt("coordinate "+y,d,Bt,f)}function h(y){if(!(y instanceof m))throw new Error("ExtendedPoint expected")}let g=ee((y,d)=>{let{ex:x,ey:A,ez:N}=y,D=y.is0();d==null&&(d=D?Hc:e.inv(N));let P=u(x*d),k=u(A*d),C=u(N*d);if(D)return{x:Bt,y:pt};if(C!==pt)throw new Error("invZ was invalid");return{x:P,y:k}}),B=ee(y=>{let{a:d,d:x}=t;if(y.is0())throw new Error("bad point: ZERO");let{ex:A,ey:N,ez:D,et:P}=y,k=u(A*A),C=u(N*N),H=u(D*D),F=u(H*H),J=u(k*d),Q=u(H*u(J+C)),nt=u(F+u(x*u(k*C)));if(Q!==nt)throw new Error("bad point: equation left != right (1)");let ot=u(A*N),ft=u(D*P);if(ot!==ft)throw new Error("bad point: equation left != right (2)");return!0});class m{constructor(d,x,A,N){this.ex=d,this.ey=x,this.ez=A,this.et=N,b("x",d),b("y",x),b("z",A),b("t",N),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(d){if(d instanceof m)throw new Error("extended point not allowed");let{x,y:A}=d||{};return b("x",x),b("y",A),new m(x,A,pt,u(x*A))}static normalizeZ(d){let x=e.invertBatch(d.map(A=>A.ez));return d.map((A,N)=>A.toAffine(x[N])).map(m.fromAffine)}static msm(d,x){return nr(m,l,d,x)}_setWindowSize(d){U.setWindowSize(this,d)}assertValidity(){B(this)}equals(d){h(d);let{ex:x,ey:A,ez:N}=this,{ex:D,ey:P,ez:k}=d,C=u(x*k),H=u(D*N),F=u(A*k),J=u(P*N);return C===H&&F===J}is0(){return this.equals(m.ZERO)}negate(){return new m(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:d}=t,{ex:x,ey:A,ez:N}=this,D=u(x*x),P=u(A*A),k=u(or*u(N*N)),C=u(d*D),H=x+A,F=u(u(H*H)-D-P),J=C+P,Q=J-k,nt=C-P,ot=u(F*Q),ft=u(J*nt),ct=u(F*nt),It=u(Q*J);return new m(ot,ft,It,ct)}add(d){h(d);let{a:x,d:A}=t,{ex:N,ey:D,ez:P,et:k}=this,{ex:C,ey:H,ez:F,et:J}=d;if(x===BigInt(-1)){let oo=u((D-N)*(H+C)),so=u((D+N)*(H-C)),Ur=u(so-oo);if(Ur===Bt)return this.double();let io=u(P*or*J),co=u(k*or*F),ao=co+io,uo=so+oo,fo=co-io,ti=u(ao*Ur),ei=u(uo*fo),ri=u(ao*fo),ni=u(Ur*uo);return new m(ti,ei,ni,ri)}let Q=u(N*C),nt=u(D*H),ot=u(k*A*J),ft=u(P*F),ct=u((N+D)*(C+H)-Q-nt),It=ft-ot,Rt=ft+ot,Ie=u(nt-x*Q),Xs=u(ct*It),$s=u(Rt*Ie),Js=u(ct*Ie),Qs=u(It*Rt);return new m(Xs,$s,Qs,Js)}subtract(d){return this.add(d.negate())}wNAF(d){return U.wNAFCached(this,d,m.normalizeZ)}multiply(d){let x=d;dt("scalar",x,pt,n);let{p:A,f:N}=this.wNAF(x);return m.normalizeZ([A,N])[0]}multiplyUnsafe(d,x=m.ZERO){let A=d;return dt("scalar",A,Bt,n),A===Bt?_:this.is0()||A===pt?this:U.wNAFCachedUnsafe(this,A,m.normalizeZ,x)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(d){return g(this,d)}clearCofactor(){let{h:d}=t;return d===pt?this:this.multiplyUnsafe(d)}static fromHex(d,x=!1){let{d:A,a:N}=t,D=e.BYTES;d=W("pointHex",d,D),St("zip215",x);let P=d.slice(),k=d[D-1];P[D-1]=k&-129;let C=Vt(P),H=x?f:e.ORDER;dt("pointHex.y",C,Bt,H);let F=u(C*C),J=u(F-pt),Q=u(A*F-N),{isValid:nt,value:ot}=p(J,Q);if(!nt)throw new Error("Point.fromHex: invalid y coordinate");let ft=(ot&pt)===pt,ct=(k&128)!==0;if(!x&&ot===Bt&&ct)throw new Error("Point.fromHex: x=0 and x_0=1");return ct!==ft&&(ot=u(-ot)),m.fromAffine({x:ot,y:C})}static fromPrivateKey(d){return L(d).point}toRawBytes(){let{x:d,y:x}=this.toAffine(),A=te(x,e.BYTES);return A[A.length-1]|=d&pt?128:0,A}toHex(){return _t(this.toRawBytes())}}m.BASE=new m(t.Gx,t.Gy,pt,u(t.Gx*t.Gy)),m.ZERO=new m(Bt,pt,pt,Bt);let{BASE:v,ZERO:_}=m,U=rr(m,c*8);function I(y){return V(y,n)}function T(y){return I(Vt(y))}function L(y){let d=e.BYTES;y=W("private key",y,d);let x=W("hashed private key",s(y),2*d),A=E(x.slice(0,d)),N=x.slice(d,2*d),D=T(A),P=v.multiply(D),k=P.toRawBytes();return{head:A,prefix:N,scalar:D,point:P,pointBytes:k}}function z(y){return L(y).pointBytes}function M(y=new Uint8Array,...d){let x=Dt(...d);return T(s(w(x,W("context",y),!!o)))}function O(y,d,x={}){y=W("message",y),o&&(y=o(y));let{prefix:A,scalar:N,pointBytes:D}=L(d),P=M(x.context,A,y),k=v.multiply(P).toRawBytes(),C=M(x.context,k,D,y),H=I(P+C*N);dt("signature.s",H,Bt,n);let F=Dt(k,te(H,e.BYTES));return W("result",F,e.BYTES*2)}let Y=Vc;function S(y,d,x,A=Y){let{context:N,zip215:D}=A,P=e.BYTES;y=W("signature",y,2*P),d=W("message",d),x=W("publicKey",x,P),D!==void 0&&St("zip215",D),o&&(d=o(d));let k=Vt(y.slice(P,2*P)),C,H,F;try{C=m.fromHex(x,D),H=m.fromHex(y.slice(0,P),D),F=v.multiplyUnsafe(k)}catch{return!1}if(!D&&C.isSmallOrder())return!1;let J=M(N,H.toRawBytes(),C.toRawBytes(),d);return H.add(C.multiplyUnsafe(J)).subtract(F).clearCofactor().equals(m.ZERO)}return v._setWindowSize(8),{CURVE:t,getPublicKey:z,sign:O,verify:S,ExtendedPoint:m,utils:{getExtendedPublicKey:L,randomPrivateKey:()=>i(e.BYTES),precompute(y=8,d=m.BASE){return d._setWindowSize(y),d.multiply(BigInt(3)),d}}}}var cn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Wo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Sf=BigInt(0),zc=BigInt(1),jo=BigInt(2),Bf=BigInt(3),Gc=BigInt(5),Zc=BigInt(8);function Wc(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=cn,c=r*r%s*r%s,a=Z(c,jo,s)*c%s,f=Z(a,zc,s)*r%s,u=Z(f,Gc,s)*f%s,l=Z(u,t,s)*u%s,p=Z(l,e,s)*l%s,E=Z(p,n,s)*p%s,w=Z(E,o,s)*E%s,b=Z(w,o,s)*E%s,h=Z(b,t,s)*u%s;return{pow_p_5_8:Z(h,jo,s)*r%s,b2:c}}function jc(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Yc(r,t){let e=cn,n=V(t*t*t,e),o=V(n*n*t,e),s=Wc(r*o).pow_p_5_8,i=V(r*n*s,e),c=V(t*i*i,e),a=i,f=V(i*Wo,e),u=c===r,l=c===V(-r,e),p=c===V(-r*Wo,e);return u&&(i=a),(l||p)&&(i=f),qo(i,e)&&(i=V(-i,e)),{isValid:u||l,value:i}}var Xc=zt(cn,void 0,!0),$c={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Xc,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Zc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Ko,randomBytes:Ye,adjustScalarBytes:jc,uvRatio:Yc},Yo=Zo($c);var sr=32;function Xo(r,t,e){return Yo.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var ir=class{type="Ed25519";raw;constructor(t){this.raw=an(t,sr)}toMultihash(){return kt.digest(cr(this))}toCID(){return lt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}verify(t,e){return Xo(this.raw,e,t)}};function Jo(r){return r=an(r,sr),new ir(r)}function an(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new ut(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function At(r=0){return new Uint8Array(r)}function mt(r=0){return new Uint8Array(r)}var Qc=Math.pow(2,7),ta=Math.pow(2,14),ea=Math.pow(2,21),un=Math.pow(2,28),fn=Math.pow(2,35),ln=Math.pow(2,42),hn=Math.pow(2,49),q=128,st=127;function Ct(r){if(r<Qc)return 1;if(r<ta)return 2;if(r<ea)return 3;if(r<un)return 4;if(r<fn)return 5;if(r<ln)return 6;if(r<hn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function dn(r,t,e=0){switch(Ct(r)){case 8:t[e++]=r&255|q,r/=128;case 7:t[e++]=r&255|q,r/=128;case 6:t[e++]=r&255|q,r/=128;case 5:t[e++]=r&255|q,r/=128;case 4:t[e++]=r&255|q,r>>>=7;case 3:t[e++]=r&255|q,r>>>=7;case 2:t[e++]=r&255|q,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function ra(r,t,e=0){switch(Ct(r)){case 8:t.set(e++,r&255|q),r/=128;case 7:t.set(e++,r&255|q),r/=128;case 6:t.set(e++,r&255|q),r/=128;case 5:t.set(e++,r&255|q),r/=128;case 4:t.set(e++,r&255|q),r>>>=7;case 3:t.set(e++,r&255|q),r>>>=7;case 2:t.set(e++,r&255|q),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function pn(r,t){let e=r[t],n=0;if(n+=e&st,e<q||(e=r[t+1],n+=(e&st)<<7,e<q)||(e=r[t+2],n+=(e&st)<<14,e<q)||(e=r[t+3],n+=(e&st)<<21,e<q)||(e=r[t+4],n+=(e&st)*un,e<q)||(e=r[t+5],n+=(e&st)*fn,e<q)||(e=r[t+6],n+=(e&st)*ln,e<q)||(e=r[t+7],n+=(e&st)*hn,e<q))return n;throw new RangeError("Could not decode varint")}function na(r,t){let e=r.get(t),n=0;if(n+=e&st,e<q||(e=r.get(t+1),n+=(e&st)<<7,e<q)||(e=r.get(t+2),n+=(e&st)<<14,e<q)||(e=r.get(t+3),n+=(e&st)<<21,e<q)||(e=r.get(t+4),n+=(e&st)*un,e<q)||(e=r.get(t+5),n+=(e&st)*fn,e<q)||(e=r.get(t+6),n+=(e&st)*ln,e<q)||(e=r.get(t+7),n+=(e&st)*hn,e<q))return n;throw new RangeError("Could not decode varint")}function Qo(r,t,e=0){return t==null&&(t=mt(Ct(r))),t instanceof Uint8Array?dn(r,t,e):ra(r,t,e)}function ts(r,t=0){return r instanceof Uint8Array?pn(r,t):na(r,t)}var mn=new Float32Array([-0]),Gt=new Uint8Array(mn.buffer);function es(r,t,e){mn[0]=r,t[e]=Gt[0],t[e+1]=Gt[1],t[e+2]=Gt[2],t[e+3]=Gt[3]}function rs(r,t){return Gt[0]=r[t],Gt[1]=r[t+1],Gt[2]=r[t+2],Gt[3]=r[t+3],mn[0]}var yn=new Float64Array([-0]),it=new Uint8Array(yn.buffer);function ns(r,t,e){yn[0]=r,t[e]=it[0],t[e+1]=it[1],t[e+2]=it[2],t[e+3]=it[3],t[e+4]=it[4],t[e+5]=it[5],t[e+6]=it[6],t[e+7]=it[7]}function os(r,t){return it[0]=r[t],it[1]=r[t+1],it[2]=r[t+2],it[3]=r[t+3],it[4]=r[t+4],it[5]=r[t+5],it[6]=r[t+6],it[7]=r[t+7],yn[0]}var sa=BigInt(Number.MAX_SAFE_INTEGER),ia=BigInt(Number.MIN_SAFE_INTEGER),xt=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 ne;if(t<sa&&t>ia)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>ss&&(o=0n,++n>ss&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ne;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):ne}},ne=new xt(0,0);ne.toBigInt=function(){return 0n};ne.zzEncode=ne.zzDecode=function(){return this};ne.length=function(){return 1};var ss=4294967296n;function is(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 cs(r,t,e){if(e-t<1)return"";let o,s=[],i=0,c;for(;t<e;)c=r[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function bn(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function vt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function ar(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var xn=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,vt(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 vt(this,4);return ar(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw vt(this,4);return ar(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw vt(this,4);let t=rs(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw vt(this,4);let t=os(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 vt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return cs(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw vt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw vt(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 xt(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 vt(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 vt(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 vt(this,8);let t=ar(this.buf,this.pos+=4),e=ar(this.buf,this.pos+=4);return new xt(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=pn(this.buf,this.pos);return this.pos+=Ct(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 gn(r){return new xn(r instanceof Uint8Array?r:r.subarray())}function oe(r,t,e){let n=gn(r);return t.decode(n,void 0,e)}var wn={};at(wn,{base10:()=>ca});var ca=Ot({prefix:"9",name:"base10",alphabet:"0123456789"});var En={};at(En,{base16:()=>aa,base16upper:()=>ua});var aa=j({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ua=j({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Sn={};at(Sn,{base2:()=>fa});var fa=j({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Bn={};at(Bn,{base256emoji:()=>ma});var us=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}"),la=us.reduce((r,t,e)=>(r[e]=t,r),[]),ha=us.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function da(r){return r.reduce((t,e)=>(t+=la[e],t),"")}function pa(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=ha[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var ma=le({prefix:"\u{1F680}",name:"base256emoji",encode:da,decode:pa});var An={};at(An,{base64:()=>ya,base64pad:()=>ba,base64url:()=>xa,base64urlpad:()=>ga});var ya=j({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ba=j({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),xa=j({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ga=j({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var vn={};at(vn,{base8:()=>wa});var wa=j({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var In={};at(In,{identity:()=>Ea});var Ea=le({prefix:"\0",name:"identity",encode:r=>mo(r),decode:r=>po(r)});var sl=new TextEncoder,il=new TextDecoder;var Tn={};at(Tn,{sha256:()=>ur,sha512:()=>Aa});function Rn({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?wt(this.code,e):e.then(n=>wt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ls(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var ur=Rn({name:"sha2-256",code:18,encode:ls("SHA-256")}),Aa=Rn({name:"sha2-512",code:19,encode:ls("SHA-512")});var Un={...In,...Sn,...vn,...wn,...En,...kr,...Mr,...Or,...An,...Bn},xl={...Tn,...Fr};function ds(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var hs=ds("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),_n=ds("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=mt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),va={utf8:hs,"utf-8":hs,hex:Un.base16,latin1:_n,ascii:_n,binary:_n,...Un},fr=va;function tt(r,t="utf8"){let e=fr[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(i){if(i<1||i>e)return mt(i);o+i>t&&(n=mt(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var se=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function 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}},Ia=Nn();function La(r){return globalThis.Buffer!=null?mt(r):Ia(r)}var Oe=class{len;head;tail;states;constructor(){this.len=0,this.head=new se(Dn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new se(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Pn((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(lr,10,xt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=xt.fromBigInt(t);return this._push(lr,e.length(),e)}uint64Number(t){return this._push(dn,Ct(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=xt.fromBigInt(t).zzEncode();return this._push(lr,e.length(),e)}sint64Number(t){let e=xt.fromNumber(t).zzEncode();return this._push(lr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Cn,1,t?1:0)}fixed32(t){return this._push(Pe,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=xt.fromBigInt(t);return this._push(Pe,4,e.lo)._push(Pe,4,e.hi)}fixed64Number(t){let e=xt.fromNumber(t);return this._push(Pe,4,e.lo)._push(Pe,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(es,4,t)}double(t){return this._push(ns,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Cn,1,0):this.uint32(e)._push(Ta,e,t)}string(t){let e=is(t);return e!==0?this.uint32(e)._push(bn,e,t):this._push(Cn,1,0)}fork(){return this.states=new Kn(this),this.head=this.tail=new se(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 se(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=La(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Cn(r,t,e){t[e]=r&255}function Ra(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Pn=class extends se{next;constructor(t,e){super(Ra,t,e),this.next=void 0}};function lr(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 Pe(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 Ta(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Oe.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Ua,t,r),this},Oe.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(_a,t,r),this});function Ua(r,t,e){t.set(r,e)}function _a(r,t,e){r.length<40?bn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(tt(r),e)}function On(){return new Oe}function ie(r,t){let e=On();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Se;(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"})(Se||(Se={}));function hr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function ke(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let c=t(s);i.int32(c)},n=function(s){let i=s.int32();return t(i)};return hr("enum",Se.VARINT,e,n)}function ce(r,t){return hr("message",Se.LENGTH_DELIMITED,r,t)}var yt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(yt||(yt={}));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=()=>ke(kn)})(yt||(yt={}));var Zt;(function(r){let t;r.codec=()=>(t==null&&(t=ce((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),yt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=yt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>ie(e,r.codec()),r.decode=(e,n)=>oe(e,r.codec(),n)})(Zt||(Zt={}));var Mn;(function(r){let t;r.codec=()=>(t==null&&(t=ce((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),yt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=yt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>ie(e,r.codec()),r.decode=(e,n)=>oe(e,r.codec(),n)})(Mn||(Mn={}));var He={};at(He,{MAX_RSA_KEY_SIZE:()=>zn,generateRSAKeyPair:()=>Rs,jwkToJWKKeyPair:()=>Ts,jwkToPkcs1:()=>Fa,jwkToPkix:()=>Zn,jwkToRSAPrivateKey:()=>Ls,pkcs1ToJwk:()=>As,pkcs1ToRSAPrivateKey:()=>Is,pkixToJwk:()=>vs,pkixToRSAPublicKey:()=>Wn});var Na=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]),Wt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),jt=new Uint32Array(64),qn=class extends we{constructor(){super(64,32,8,!1),this.A=Wt[0]|0,this.B=Wt[1]|0,this.C=Wt[2]|0,this.D=Wt[3]|0,this.E=Wt[4]|0,this.F=Wt[5]|0,this.G=Wt[6]|0,this.H=Wt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[t,e,n,o,s,i,c,a]}set(t,e,n,o,s,i,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,e){for(let l=0;l<16;l++,e+=4)jt[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let p=jt[l-15],E=jt[l-2],w=Et(p,7)^Et(p,18)^p>>>3,b=Et(E,17)^Et(E,19)^E>>>10;jt[l]=b+jt[l-7]+w+jt[l-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:f,H:u}=this;for(let l=0;l<64;l++){let p=Et(c,6)^Et(c,11)^Et(c,25),E=u+p+No(c,a,f)+Na[l]+jt[l]|0,b=(Et(n,2)^Et(n,13)^Et(n,22))+Do(n,o,s)|0;u=f,f=a,a=c,c=i+E|0,i=s,s=o,o=n,n=E+b|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,s,i,c,a,f,u)}roundClean(){jt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Be=je(()=>new qn);function bt(r,t="utf8"){let e=fr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}function dr(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=mt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var ys=Symbol.for("@achingbrain/uint8arraylist");function ms(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function pr(r){return!!r?.[ys]}var et=class r{bufs;length;[ys]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(pr(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(pr(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=ms(this.bufs,t);return e.buf[e.index]}set(t,e){let n=ms(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(pr(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return dr(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:dr(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],c=o,a=c+i.byteLength;if(o=a,t>=a)continue;let f=t>=c&&t<a,u=e>c&&e<=a;if(f&&u){if(t===c&&e===a){n.push(i);break}let l=t-c;n.push(i.subarray(l,l+(e-t)));break}if(f){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(u){if(e===a){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!pr(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let c=i,a=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=e;l<=a;l+=u){u=0;for(let p=f;p>=0;p--){let E=this.get(l+p);if(n[p]!==E){u=Math.max(1,p-c[E]);break}}if(u===0)return l}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=mt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=At(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=At(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=At(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=mt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=At(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=At(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=At(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=At(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=At(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!ht(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var Da=parseInt("11111",2),Vn=parseInt("10000000",2),Ca=parseInt("01111111",2),bs={2:Ka,3:ka,5:Oa,6:Pa,16:Hn,22:Hn,48:Hn};function Me(r,t={offset:0}){let e=r[t.offset]&Da;if(t.offset++,bs[e]!=null)return bs[e](r,t);throw new Error("No decoder for tag "+e)}function mr(r,t){let e=0;if((r[t.offset]&Vn)===Vn){let n=r[t.offset]&Ca,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function Hn(r,t){mr(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=Me(r,t);if(n===null)break;e.push(n)}return e}function Ka(r,t){let e=mr(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function Pa(r,t){let e=mr(r,t);return t.offset+=e,["oid-unimplemented"]}function Oa(r,t){return t.offset++,null}function ka(r,t){let e=mr(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return Me(o,{offset:0})}function Ma(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new et;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function Fn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=Ma(r.byteLength);return new et(Uint8Array.from([t.byteLength|Vn]),t)}function gt(r){let t=new et,e=parseInt("10000000",2);return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new et(Uint8Array.from([2]),Fn(t),t)}function xs(r){let t=Uint8Array.from([0]),e=new et(t,r);return new et(Uint8Array.from([3]),Fn(e),e)}function yr(r){let t=new et;for(let e of r)t.append(e);return new et(Uint8Array.from([48]),Fn(t),t)}var qe=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},br=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var gs={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new br("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var Yt=gs;async function ws(r){let t=await Yt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),e=await qa(t);return{privateKey:e[0],publicKey:e[1]}}async function Es(r,t){let e=await Yt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Yt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function Ss(r,t,e){let n=await Yt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Yt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function qa(r){if(r.privateKey==null||r.publicKey==null)throw new ut("Private and public key are required");return Promise.all([Yt.get().subtle.exportKey("jwk",r.privateKey),Yt.get().subtle.exportKey("jwk",r.publicKey)])}function Bs(r){if(r.kty!=="RSA")throw new ut("invalid key type");if(r.n==null)throw new ut("invalid key modulus");return tt(r.n,"base64url").length*8}var Ae=class{type="RSA";_key;_raw;_multihash;constructor(t,e){this._key=t,this._multihash=e}get raw(){return this._raw==null&&(this._raw=He.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return lt.createV1(114,this._multihash)}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}verify(t,e){return Ss(this._key,e,t)}},Ve=class{type="RSA";_key;_raw;publicKey;constructor(t,e){this._key=t,this.publicKey=e}get raw(){return this._raw==null&&(this._raw=He.jwkToPkcs1(this._key)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}sign(t){return Es(this._key,t)}};var zn=8192,Gn=18,Ha=1062,Va=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function As(r){let t=Me(r);return{n:bt(t[1],"base64url"),e:bt(t[2],"base64url"),d:bt(t[3],"base64url"),p:bt(t[4],"base64url"),q:bt(t[5],"base64url"),dp:bt(t[6],"base64url"),dq:bt(t[7],"base64url"),qi:bt(t[8],"base64url"),kty:"RSA"}}function Fa(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new ut("JWK was missing components");return yr([gt(Uint8Array.from([0])),gt(tt(r.n,"base64url")),gt(tt(r.e,"base64url")),gt(tt(r.d,"base64url")),gt(tt(r.p,"base64url")),gt(tt(r.q,"base64url")),gt(tt(r.dp,"base64url")),gt(tt(r.dq,"base64url")),gt(tt(r.qi,"base64url"))]).subarray()}function vs(r){let t=Me(r,{offset:0});return{kty:"RSA",n:bt(t[1][0],"base64url"),e:bt(t[1][1],"base64url")}}function Zn(r){if(r.n==null||r.e==null)throw new ut("JWK was missing components");return yr([Va,xs(yr([gt(tt(r.n,"base64url")),gt(tt(r.e,"base64url"))]))]).subarray()}function Is(r){let t=As(r);return Ls(t)}function Wn(r,t){if(r.byteLength>=Ha)throw new ue("Key size is too large");let e=vs(r);if(t==null){let n=Be(Zt.encode({Type:yt.RSA,Data:r}));t=wt(Gn,n)}return new Ae(e,t)}function Ls(r){if(Bs(r)>zn)throw new ut("Key size is too large");let t=Ts(r),e=Be(Zt.encode({Type:yt.RSA,Data:Zn(t.publicKey)})),n=wt(Gn,e);return new Ve(t.privateKey,new Ae(t.publicKey,n))}async function Rs(r){if(r>zn)throw new ut("Key size is too large");let t=await ws(r),e=Be(Zt.encode({Type:yt.RSA,Data:Zn(t.publicKey)})),n=wt(Gn,e);return new Ve(t.privateKey,new Ae(t.publicKey,n))}function Ts(r){if(r==null)throw new ut("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var xr=class extends ge{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,To(t);let n=Ne(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(t){return xe(this),this.iHash.update(t),this}digestInto(t){xe(this),be(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},jn=(r,t,e)=>new xr(r,t).update(e).digest();jn.create=(r,t)=>new xr(r,t);function Us(r){r.lowS!==void 0&&St("lowS",r.lowS),r.prehash!==void 0&&St("prehash",r.prehash)}function za(r){let t=Ke(r);Lt(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:Ga,hexToBytes:Za}=Qe,Yn=class extends Error{constructor(t=""){super(t)}},Kt={Err:Yn,_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=Jt(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Jt(o.length/2|128):"";return Jt(r)+s+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++],s=!!(o&128),i=0;if(!s)i=o;else{let a=o&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+a);if(f.length!==a)throw new e("tlv.decode: length bytes not complete");if(f[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of f)i=i<<8|u;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Kt;if(r<Pt)throw new t("integer: negative integers are not allowed");let e=Jt(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 Ga(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Kt,o=typeof r=="string"?Za(r):r;Ee(o);let{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:f,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(f)}},hexFromSig(r){let{_tlv:t,_int:e}=Kt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},Pt=BigInt(0),rt=BigInt(1),qh=BigInt(2),_s=BigInt(3),Hh=BigInt(4);function Wa(r){let t=za(r),{Fp:e}=t,n=zt(t.n,t.nBitLength),o=t.toBytes||((b,h,g)=>{let B=h.toAffine();return Dt(Uint8Array.from([4]),e.toBytes(B.x),e.toBytes(B.y))}),s=t.fromBytes||(b=>{let h=b.subarray(1),g=e.fromBytes(h.subarray(0,e.BYTES)),B=e.fromBytes(h.subarray(e.BYTES,2*e.BYTES));return{x:g,y:B}});function i(b){let{a:h,b:g}=t,B=e.sqr(b),m=e.mul(B,b);return e.add(e.add(m,e.mul(b,h)),g)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function c(b){return De(b,rt,t.n)}function a(b){let{allowedPrivateKeyLengths:h,nByteLength:g,wrapPrivateKey:B,n:m}=t;if(h&&typeof b!="bigint"){if(Ht(b)&&(b=_t(b)),typeof b!="string"||!h.includes(b.length))throw new Error("invalid private key");b=b.padStart(g*2,"0")}let v;try{v=typeof b=="bigint"?b:Nt(W("private key",b,g))}catch{throw new Error("invalid private key, expected hex or "+g+" bytes, got "+typeof b)}return B&&(v=V(v,m)),dt("private key",v,rt,m),v}function f(b){if(!(b instanceof p))throw new Error("ProjectivePoint expected")}let u=ee((b,h)=>{let{px:g,py:B,pz:m}=b;if(e.eql(m,e.ONE))return{x:g,y:B};let v=b.is0();h==null&&(h=v?e.ONE:e.inv(m));let _=e.mul(g,h),U=e.mul(B,h),I=e.mul(m,h);if(v)return{x:e.ZERO,y:e.ZERO};if(!e.eql(I,e.ONE))throw new Error("invZ was invalid");return{x:_,y:U}}),l=ee(b=>{if(b.is0()){if(t.allowInfinityPoint&&!e.is0(b.py))return;throw new Error("bad point: ZERO")}let{x:h,y:g}=b.toAffine();if(!e.isValid(h)||!e.isValid(g))throw new Error("bad point: x or y not FE");let B=e.sqr(g),m=i(h);if(!e.eql(B,m))throw new Error("bad point: equation left != right");if(!b.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class p{constructor(h,g,B){if(this.px=h,this.py=g,this.pz=B,h==null||!e.isValid(h))throw new Error("x required");if(g==null||!e.isValid(g))throw new Error("y required");if(B==null||!e.isValid(B))throw new Error("z required");Object.freeze(this)}static fromAffine(h){let{x:g,y:B}=h||{};if(!h||!e.isValid(g)||!e.isValid(B))throw new Error("invalid affine point");if(h instanceof p)throw new Error("projective point not allowed");let m=v=>e.eql(v,e.ZERO);return m(g)&&m(B)?p.ZERO:new p(g,B,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let g=e.invertBatch(h.map(B=>B.pz));return h.map((B,m)=>B.toAffine(g[m])).map(p.fromAffine)}static fromHex(h){let g=p.fromAffine(s(W("pointHex",h)));return g.assertValidity(),g}static fromPrivateKey(h){return p.BASE.multiply(a(h))}static msm(h,g){return nr(p,n,h,g)}_setWindowSize(h){w.setWindowSize(this,h)}assertValidity(){l(this)}hasEvenY(){let{y:h}=this.toAffine();if(e.isOdd)return!e.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){f(h);let{px:g,py:B,pz:m}=this,{px:v,py:_,pz:U}=h,I=e.eql(e.mul(g,U),e.mul(v,m)),T=e.eql(e.mul(B,U),e.mul(_,m));return I&&T}negate(){return new p(this.px,e.neg(this.py),this.pz)}double(){let{a:h,b:g}=t,B=e.mul(g,_s),{px:m,py:v,pz:_}=this,U=e.ZERO,I=e.ZERO,T=e.ZERO,L=e.mul(m,m),z=e.mul(v,v),M=e.mul(_,_),O=e.mul(m,v);return O=e.add(O,O),T=e.mul(m,_),T=e.add(T,T),U=e.mul(h,T),I=e.mul(B,M),I=e.add(U,I),U=e.sub(z,I),I=e.add(z,I),I=e.mul(U,I),U=e.mul(O,U),T=e.mul(B,T),M=e.mul(h,M),O=e.sub(L,M),O=e.mul(h,O),O=e.add(O,T),T=e.add(L,L),L=e.add(T,L),L=e.add(L,M),L=e.mul(L,O),I=e.add(I,L),M=e.mul(v,_),M=e.add(M,M),L=e.mul(M,O),U=e.sub(U,L),T=e.mul(M,z),T=e.add(T,T),T=e.add(T,T),new p(U,I,T)}add(h){f(h);let{px:g,py:B,pz:m}=this,{px:v,py:_,pz:U}=h,I=e.ZERO,T=e.ZERO,L=e.ZERO,z=t.a,M=e.mul(t.b,_s),O=e.mul(g,v),Y=e.mul(B,_),S=e.mul(m,U),R=e.add(g,B),y=e.add(v,_);R=e.mul(R,y),y=e.add(O,Y),R=e.sub(R,y),y=e.add(g,m);let d=e.add(v,U);return y=e.mul(y,d),d=e.add(O,S),y=e.sub(y,d),d=e.add(B,m),I=e.add(_,U),d=e.mul(d,I),I=e.add(Y,S),d=e.sub(d,I),L=e.mul(z,y),I=e.mul(M,S),L=e.add(I,L),I=e.sub(Y,L),L=e.add(Y,L),T=e.mul(I,L),Y=e.add(O,O),Y=e.add(Y,O),S=e.mul(z,S),y=e.mul(M,y),Y=e.add(Y,S),S=e.sub(O,S),S=e.mul(z,S),y=e.add(y,S),O=e.mul(Y,y),T=e.add(T,O),O=e.mul(d,y),I=e.mul(R,I),I=e.sub(I,O),O=e.mul(R,Y),L=e.mul(d,L),L=e.add(L,O),new p(I,T,L)}subtract(h){return this.add(h.negate())}is0(){return this.equals(p.ZERO)}wNAF(h){return w.wNAFCached(this,h,p.normalizeZ)}multiplyUnsafe(h){let{endo:g,n:B}=t;dt("scalar",h,Pt,B);let m=p.ZERO;if(h===Pt)return m;if(this.is0()||h===rt)return this;if(!g||w.hasPrecomputes(this))return w.wNAFCachedUnsafe(this,h,p.normalizeZ);let{k1neg:v,k1:_,k2neg:U,k2:I}=g.splitScalar(h),T=m,L=m,z=this;for(;_>Pt||I>Pt;)_&rt&&(T=T.add(z)),I&rt&&(L=L.add(z)),z=z.double(),_>>=rt,I>>=rt;return v&&(T=T.negate()),U&&(L=L.negate()),L=new p(e.mul(L.px,g.beta),L.py,L.pz),T.add(L)}multiply(h){let{endo:g,n:B}=t;dt("scalar",h,rt,B);let m,v;if(g){let{k1neg:_,k1:U,k2neg:I,k2:T}=g.splitScalar(h),{p:L,f:z}=this.wNAF(U),{p:M,f:O}=this.wNAF(T);L=w.constTimeNegate(_,L),M=w.constTimeNegate(I,M),M=new p(e.mul(M.px,g.beta),M.py,M.pz),m=L.add(M),v=z.add(O)}else{let{p:_,f:U}=this.wNAF(h);m=_,v=U}return p.normalizeZ([m,v])[0]}multiplyAndAddUnsafe(h,g,B){let m=p.BASE,v=(U,I)=>I===Pt||I===rt||!U.equals(m)?U.multiplyUnsafe(I):U.multiply(I),_=v(this,g).add(v(h,B));return _.is0()?void 0:_}toAffine(h){return u(this,h)}isTorsionFree(){let{h,isTorsionFree:g}=t;if(h===rt)return!0;if(g)return g(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:g}=t;return h===rt?this:g?g(p,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return St("isCompressed",h),this.assertValidity(),o(p,this,h)}toHex(h=!0){return St("isCompressed",h),_t(this.toRawBytes(h))}}p.BASE=new p(t.Gx,t.Gy,e.ONE),p.ZERO=new p(e.ZERO,e.ONE,e.ZERO);let E=t.nBitLength,w=rr(p,t.endo?Math.ceil(E/2):E);return{CURVE:t,ProjectivePoint:p,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:c}}function ja(r){let t=Ke(r);return Lt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Ns(r){let t=ja(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(S){return V(S,n)}function c(S){return tr(S,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=Wa({...t,toBytes(S,R,y){let d=R.toAffine(),x=e.toBytes(d.x),A=Dt;return St("isCompressed",y),y?A(Uint8Array.from([R.hasEvenY()?2:3]),x):A(Uint8Array.from([4]),x,e.toBytes(d.y))},fromBytes(S){let R=S.length,y=S[0],d=S.subarray(1);if(R===o&&(y===2||y===3)){let x=Nt(d);if(!De(x,rt,e.ORDER))throw new Error("Point is not on curve");let A=u(x),N;try{N=e.sqrt(A)}catch(k){let C=k instanceof Error?": "+k.message:"";throw new Error("Point is not on curve"+C)}let D=(N&rt)===rt;return(y&1)===1!==D&&(N=e.neg(N)),{x,y:N}}else if(R===s&&y===4){let x=e.fromBytes(d.subarray(0,e.BYTES)),A=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x,y:A}}else{let x=o,A=s;throw new Error("invalid Point, expected length of "+x+", or uncompressed "+A+", got "+R)}}}),p=S=>_t(Ft(S,t.nByteLength));function E(S){let R=n>>rt;return S>R}function w(S){return E(S)?i(-S):S}let b=(S,R,y)=>Nt(S.slice(R,y));class h{constructor(R,y,d){this.r=R,this.s=y,this.recovery=d,this.assertValidity()}static fromCompact(R){let y=t.nByteLength;return R=W("compactSignature",R,y*2),new h(b(R,0,y),b(R,y,2*y))}static fromDER(R){let{r:y,s:d}=Kt.toSig(W("DER",R));return new h(y,d)}assertValidity(){dt("r",this.r,rt,n),dt("s",this.s,rt,n)}addRecoveryBit(R){return new h(this.r,this.s,R)}recoverPublicKey(R){let{r:y,s:d,recovery:x}=this,A=U(W("msgHash",R));if(x==null||![0,1,2,3].includes(x))throw new Error("recovery id invalid");let N=x===2||x===3?y+t.n:y;if(N>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let D=(x&1)===0?"02":"03",P=a.fromHex(D+p(N)),k=c(N),C=i(-A*k),H=i(d*k),F=a.BASE.multiplyAndAddUnsafe(P,C,H);if(!F)throw new Error("point at infinify");return F.assertValidity(),F}hasHighS(){return E(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return Qt(this.toDERHex())}toDERHex(){return Kt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Qt(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let g={isValidPrivateKey(S){try{return f(S),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let S=en(t.n);return Vo(t.randomBytes(S),t.n)},precompute(S=8,R=a.BASE){return R._setWindowSize(S),R.multiply(BigInt(3)),R}};function B(S,R=!0){return a.fromPrivateKey(S).toRawBytes(R)}function m(S){let R=Ht(S),y=typeof S=="string",d=(R||y)&&S.length;return R?d===o||d===s:y?d===2*o||d===2*s:S instanceof a}function v(S,R,y=!0){if(m(S))throw new Error("first arg must be private key");if(!m(R))throw new Error("second arg must be public key");return a.fromHex(R).multiply(f(S)).toRawBytes(y)}let _=t.bits2int||function(S){if(S.length>8192)throw new Error("input is too large");let R=Nt(S),y=S.length*8-t.nBitLength;return y>0?R>>BigInt(y):R},U=t.bits2int_modN||function(S){return i(_(S))},I=Ce(t.nBitLength);function T(S){return dt("num < 2^"+t.nBitLength,S,Pt,I),Ft(S,t.nByteLength)}function L(S,R,y=z){if(["recovered","canonical"].some(Q=>Q in y))throw new Error("sign() legacy options not supported");let{hash:d,randomBytes:x}=t,{lowS:A,prehash:N,extraEntropy:D}=y;A==null&&(A=!0),S=W("msgHash",S),Us(y),N&&(S=W("prehashed msgHash",d(S)));let P=U(S),k=f(R),C=[T(k),T(P)];if(D!=null&&D!==!1){let Q=D===!0?x(e.BYTES):D;C.push(W("extraEntropy",Q))}let H=Dt(...C),F=P;function J(Q){let nt=_(Q);if(!l(nt))return;let ot=c(nt),ft=a.BASE.multiply(nt).toAffine(),ct=i(ft.x);if(ct===Pt)return;let It=i(ot*i(F+ct*k));if(It===Pt)return;let Rt=(ft.x===ct?0:2)|Number(ft.y&rt),Ie=It;return A&&E(It)&&(Ie=w(It),Rt^=1),new h(ct,Ie,Rt)}return{seed:H,k2sig:J}}let z={lowS:t.lowS,prehash:!1},M={lowS:t.lowS,prehash:!1};function O(S,R,y=z){let{seed:d,k2sig:x}=L(S,R,y),A=t;return $r(A.hash.outputLen,A.nByteLength,A.hmac)(d,x)}a.BASE._setWindowSize(8);function Y(S,R,y,d=M){let x=S;R=W("msgHash",R),y=W("publicKey",y);let{lowS:A,prehash:N,format:D}=d;if(Us(d),"strict"in d)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 P=typeof x=="string"||Ht(x),k=!P&&!D&&typeof x=="object"&&x!==null&&typeof x.r=="bigint"&&typeof x.s=="bigint";if(!P&&!k)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let C,H;try{if(k&&(C=new h(x.r,x.s)),P){try{D!=="compact"&&(C=h.fromDER(x))}catch(Rt){if(!(Rt instanceof Kt.Err))throw Rt}!C&&D!=="der"&&(C=h.fromCompact(x))}H=a.fromHex(y)}catch{return!1}if(!C||A&&C.hasHighS())return!1;N&&(R=t.hash(R));let{r:F,s:J}=C,Q=U(R),nt=c(J),ot=i(Q*nt),ft=i(F*nt),ct=a.BASE.multiplyAndAddUnsafe(H,ot,ft)?.toAffine();return ct?i(ct.x)===F:!1}return{CURVE:t,getPublicKey:B,getSharedSecret:v,sign:O,verify:Y,ProjectivePoint:a,Signature:h,utils:g}}function Ya(r){return{hash:r,hmac:(t,...e)=>jn(r,t,zr(...e)),randomBytes:Ye}}function Ds(r,t){let e=n=>Ns({...r,...Ya(n)});return{...e(t),create:e}}var Ps=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Cs=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Xa=BigInt(1),Xn=BigInt(2),Ks=(r,t)=>(r+t/Xn)/t;function $a(r){let t=Ps,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),f=r*r*r%t,u=f*f*r%t,l=Z(u,e,t)*u%t,p=Z(l,e,t)*u%t,E=Z(p,Xn,t)*f%t,w=Z(E,o,t)*E%t,b=Z(w,s,t)*w%t,h=Z(b,c,t)*b%t,g=Z(h,a,t)*h%t,B=Z(g,c,t)*b%t,m=Z(B,e,t)*u%t,v=Z(m,i,t)*w%t,_=Z(v,n,t)*f%t,U=Z(_,Xn,t);if(!$n.eql($n.sqr(U),r))throw new Error("Cannot find square root");return U}var $n=zt(Ps,void 0,void 0,{sqrt:$a}),ae=Ds({a:BigInt(0),b:BigInt(7),Fp:$n,n:Cs,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Cs,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Xa*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=Ks(s*r,t),a=Ks(-n*r,t),f=V(r-c*e-a*o,t),u=V(-c*n-a*s,t),l=f>i,p=u>i;if(l&&(f=t-f),p&&(u=t-u),f>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:p,k2:u}}}},Be),Xh=BigInt(0);var $h=ae.ProjectivePoint;function Os(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function ks(r,t,e){let n=ur.digest(e instanceof Uint8Array?e:e.subarray());if(Os(n))return n.then(({digest:o})=>ae.verify(t,o,r)).catch(o=>{throw new qe(String(o))});try{return ae.verify(t,n.digest,r)}catch(o){throw new qe(String(o))}}var gr=class{type="secp256k1";raw;_key;constructor(t){this._key=qs(t),this.raw=Ms(this._key)}toMultihash(){return kt.digest(cr(this))}toCID(){return lt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}verify(t,e){return ks(this._key,e,t)}};function Hs(r){return new gr(r)}function Ms(r){return ae.ProjectivePoint.fromHex(r).toRawBytes(!0)}function qs(r){try{return ae.ProjectivePoint.fromHex(r),r}catch(t){throw new ue(String(t))}}function Vs(r){return r.byteLength===32?Jo(r):r.byteLength===33?Hs(r):Wn(r)}function cr(r){return Zt.encode({Type:yt[r.type],Data:r.raw})}var Fs=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()})`}[Nr]=!0;toString(){return this.string==null&&(this.string=X.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 ht(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return ht(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Fs](){return`PeerId(${this.toString()})`}},wr=class extends Fe{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Er=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}},Qa=2336,Jn=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=kt.digest(tt(this.url))}[Fs](){return`PeerId(${this.url})`}[Nr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return lt.createV1(Qa,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=bt(t)),t.toString()===this.toString())}};function zs(r){if(r.type==="Ed25519")return new Er({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new Sr({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new wr({multihash:r.toCID().multihash,publicKey:r});throw new Ge}function ve(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Br=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function Gs(r,t,e){if(t==null)return r;if(t.aborted)return r.catch(()=>{}),Promise.reject(new Br(e?.errorMessage,e?.errorCode,e?.errorName));let n,o=new Br(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((s,i)=>{n=()=>{i(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var Qn=class{readNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.readNext=ve(),this.haveNext=ve()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=ve(),t}async throw(t){return this.ended=!0,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return this.ended=!0,this.nextResult=t,this.haveNext.resolve(),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=ve(),await Gs(this.readNext.promise,e?.signal,e)}};function Zs(){return new Qn}var Ar=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};var to=class extends Error{code;constructor(t,e){super(t),this.code=e}},eo=class extends to{type;constructor(t){super(t,"ABORT_ERR"),this.type="aborted",this.name="AbortError"}};function Ws(r,t){let e=Zs();r.sink(e).catch(async i=>{await e.end(i)}),r.sink=async i=>{for await(let c of i)await e.push(c);await e.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let o=new et;return{read:async(i,c)=>{c?.signal?.throwIfAborted();let a,f=new Promise((u,l)=>{a=()=>{l(new eo("Read aborted"))},c?.signal?.addEventListener("abort",a)});try{if(i==null){let{done:l,value:p}=await Promise.race([n.next(),f]);return l===!0?new et:p}for(;o.byteLength<i;){let{value:l,done:p}=await Promise.race([n.next(),f]);if(p===!0)throw new Ar("unexpected end of input");o.append(l)}let u=o.sublist(0,i);return o.consume(i),u}finally{a!=null&&c?.signal?.removeEventListener("abort",a)}},write:async(i,c)=>{c?.signal?.throwIfAborted(),i instanceof Uint8Array?await e.push(i,c):await e.push(i.subarray(),c)},unwrap:()=>{if(o.byteLength>0){let i=r.source;r.source=async function*(){t?.yieldBytes===!1?yield o:yield*o,yield*i}()}return r}}}var vr=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Ir=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Lr=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function js(r,t={}){let e=Ws(r,t);t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=Ct(t.maxDataLength));let n=t?.lengthDecoder??ts,o=t?.lengthEncoder??Qo;return{read:async i=>{let c=-1,a=new et;for(;;){a.append(await e.read(1,i));try{c=n(a)}catch(f){if(f instanceof RangeError)continue;throw f}if(c<0)throw new vr("Invalid message length");if(t?.maxLengthLength!=null&&a.byteLength>t.maxLengthLength)throw new Lr("message length length too long");if(c>-1)break}if(t?.maxDataLength!=null&&c>t.maxDataLength)throw new Ir("message length too long");return e.read(c,i)},write:async(i,c)=>{await e.write(new et(o(i.byteLength),i),c)},writeV:async(i,c)=>{let a=new et(...i.flatMap(f=>[o(f.byteLength),f]));await e.write(a,c)},unwrap:()=>e.unwrap()}}function Ys(r,t){let e=js(r,t),n={read:async(o,s)=>{let i=await e.read(s);return o.decode(i)},write:async(o,s,i)=>{await e.write(s.encode(o),i)},writeV:async(o,s,i)=>{await e.writeV(o.map(c=>s.encode(c)),i)},pb:o=>({read:async s=>n.read(o,s),write:async(s,i)=>n.write(s,o,i),writeV:async(s,i)=>n.writeV(s,o,i),unwrap:()=>n}),unwrap:()=>e.unwrap()};return n}var Rr;(function(r){let t;r.codec=()=>(t==null&&(t=ce((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.id!=null&&(n.uint32(10),n.bytes(e.id)),e.pubkey!=null&&(n.uint32(18),Tr.codec().encode(e.pubkey,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.id=e.bytes();break}case 2:{s.pubkey=Tr.codec().decode(e,e.uint32(),{limits:o.limits?.pubkey});break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>ie(e,r.codec()),r.decode=(e,n)=>oe(e,r.codec(),n)})(Rr||(Rr={}));var Xt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(Xt||(Xt={}));var ro;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(ro||(ro={}));(function(r){r.codec=()=>ke(ro)})(Xt||(Xt={}));var Tr;(function(r){let t;r.codec=()=>(t==null&&(t=ce((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),Xt.codec().encode(e.Type,n)),e.Data!=null&&e.Data.byteLength>0&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={Data:At(0)},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=Xt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>ie(e,r.codec()),r.decode=(e,n)=>oe(e,r.codec(),n)})(Tr||(Tr={}));var tu="/plaintext/2.0.0",no=class{protocol=tu;privateKey;log;constructor(t){this.privateKey=t.privateKey,this.log=t.logger.forComponent("libp2p:plaintext")}[Symbol.toStringTag]="@libp2p/plaintext";[lo]=["@libp2p/connection-encryption"];async secureInbound(t,e){return this._encrypt(t,e)}async secureOutbound(t,e){return this._encrypt(t,e)}async _encrypt(t,e){let n=Ys(t).pb(Rr);this.log("write pubkey exchange to peer %p",e?.remotePeer);let o=this.privateKey.publicKey,[,s]=await Promise.all([n.write({id:o.toMultihash().bytes,pubkey:{Type:Xt[o.type],Data:o.raw}},e),n.read(e)]),i;try{if(s.pubkey==null)throw new fe("Public key missing");if(s.pubkey.Data.byteLength===0)throw new fe("Public key data too short");if(s.id==null)throw new fe("Remote id missing");let c=Vs(s.pubkey.Data);if(i=zs(c),!ht(i.toMultihash().bytes,s.id))throw new Le("Public key did not match id")}catch(c){throw this.log.error(c),new Le("Invalid public key - "+c.message)}if(e?.remotePeer!=null&&!i.equals(e?.remotePeer))throw new ze;return this.log("plaintext key exchange completed successfully with peer %p",i),{conn:n.unwrap().unwrap(),remotePeer:i}}};function eu(){return r=>new no(r)}return ai(ru);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/hashes/esm/utils.js:
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"PlaintextComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_plaintext.PlaintextComponents.html",
|
|
3
|
+
".:PlaintextComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_plaintext.PlaintextComponents.html",
|
|
4
|
+
"plaintext": "https://libp2p.github.io/js-libp2p/functions/_libp2p_plaintext.plaintext.html",
|
|
5
|
+
".:plaintext": "https://libp2p.github.io/js-libp2p/functions/_libp2p_plaintext.plaintext.html"
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/plaintext",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.20",
|
|
4
4
|
"description": "An insecure connection encrypter",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext#readme",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"doc-check": "aegir doc-check"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@libp2p/crypto": "5.0.15
|
|
56
|
-
"@libp2p/interface": "2.7.0
|
|
57
|
-
"@libp2p/peer-id": "5.0
|
|
55
|
+
"@libp2p/crypto": "^5.0.15",
|
|
56
|
+
"@libp2p/interface": "^2.7.0",
|
|
57
|
+
"@libp2p/peer-id": "^5.1.0",
|
|
58
58
|
"it-protobuf-stream": "^1.1.5",
|
|
59
59
|
"it-stream-types": "^2.0.2",
|
|
60
60
|
"protons-runtime": "^5.5.0",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"uint8arrays": "^5.1.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@libp2p/crypto": "5.0.15
|
|
66
|
-
"@libp2p/logger": "5.1.
|
|
65
|
+
"@libp2p/crypto": "^5.0.15",
|
|
66
|
+
"@libp2p/logger": "^5.1.13",
|
|
67
67
|
"aegir": "^45.1.1",
|
|
68
68
|
"it-pair": "^2.0.6",
|
|
69
69
|
"protons": "^7.6.0",
|