@libp2p/peer-id 5.1.5-ec73d59a6 → 5.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PPeerId = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PPeerId=(()=>{var xr=Object.defineProperty;var Ns=Object.getOwnPropertyDescriptor;var Os=Object.getOwnPropertyNames;var ks=Object.prototype.hasOwnProperty;var ut=(r,t)=>{for(var e in t)xr(r,e,{get:t[e],enumerable:!0})},Hs=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Os(t))!ks.call(r,o)&&o!==e&&xr(r,o,{get:()=>t[o],enumerable:!(n=Ns(t,o))||n.enumerable});return r};var Ms=r=>Hs(xr({},"__esModule",{value:!0}),r);var fa={};ut(fa,{peerIdFromCID:()=>Ts,peerIdFromMultihash:()=>Kn,peerIdFromPrivateKey:()=>ia,peerIdFromPublicKey:()=>Cs,peerIdFromString:()=>sa});var br=Symbol.for("@libp2p/peer-id");var At=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},je=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Ge=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Ze=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var re=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Sr={};ut(Sr,{base58btc:()=>X,base58flickr:()=>Zs});var da=new Uint8Array(0);function On(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 It(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 kn(r){return new TextEncoder().encode(r)}function Hn(r){return new TextDecoder().decode(r)}function qs(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 a=r.length,c=r.charAt(0),d=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(S){if(S instanceof Uint8Array||(ArrayBuffer.isView(S)?S=new Uint8Array(S.buffer,S.byteOffset,S.byteLength):Array.isArray(S)&&(S=Uint8Array.from(S))),!(S instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(S.length===0)return"";for(var y=0,R=0,P=0,q=S.length;P!==q&&S[P]===0;)P++,y++;for(var A=(q-P)*f+1>>>0,u=new Uint8Array(A);P!==q;){for(var m=S[P],B=0,v=A-1;(m!==0||B<R)&&v!==-1;v--,B++)m+=256*u[v]>>>0,u[v]=m%a>>>0,m=m/a>>>0;if(m!==0)throw new Error("Non-zero carry");R=B,P++}for(var I=A-R;I!==A&&u[I]===0;)I++;for(var D=c.repeat(y);I<A;++I)D+=r.charAt(u[I]);return D}function E(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var y=0;if(S[y]!==" "){for(var R=0,P=0;S[y]===c;)R++,y++;for(var q=(S.length-y)*d+1>>>0,A=new Uint8Array(q);S[y];){var u=e[S.charCodeAt(y)];if(u===255)return;for(var m=0,B=q-1;(u!==0||m<P)&&B!==-1;B--,m++)u+=a*A[B]>>>0,A[B]=u%256>>>0,u=u/256>>>0;if(u!==0)throw new Error("Non-zero carry");P=m,y++}if(S[y]!==" "){for(var v=q-P;v!==q&&A[v]===0;)v++;for(var I=new Uint8Array(R+(q-v)),D=R;v!==q;)I[D++]=A[v++];return I}}}function L(S){var y=E(S);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:E,decode:L}}var Vs=qs,zs=Vs,qn=zs;var gr=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")}},wr=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 Vn(this,t)}},Er=class{decoders;constructor(t){this.decoders=t}or(t){return Vn(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 Vn(r,t){return new Er({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Ar=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 gr(t,e,n),this.decoder=new wr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ne({name:r,prefix:t,encode:e,decode:n}){return new Ar(r,t,e,n)}function Nt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=qn(e,r);return ne({prefix:t,name:r,encode:n,decode:s=>It(o(s))})}function Fs(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,a=0,c=0;for(let d=0;d<o;++d){let f=t[r[d]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|f,i+=e,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=e||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function js(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function Gs(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function G({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=Gs(n);return ne({prefix:t,name:r,encode(s){return js(s,n,e)},decode(s){return Fs(s,o,e,r)}})}var X=Nt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Zs=Nt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Br={};ut(Br,{base32:()=>oe,base32hex:()=>$s,base32hexpad:()=>Qs,base32hexpadupper:()=>ti,base32hexupper:()=>Js,base32pad:()=>Ws,base32padupper:()=>Xs,base32upper:()=>Ys,base32z:()=>ei});var oe=G({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ys=G({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ws=G({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Xs=G({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),$s=G({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Js=G({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Qs=G({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ti=G({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ei=G({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var vr={};ut(vr,{base36:()=>we,base36upper:()=>ri});var we=Nt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ri=Nt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ni=jn,zn=128,oi=127,si=~oi,ii=Math.pow(2,31);function jn(r,t,e){t=t||[],e=e||0;for(var n=e;r>=ii;)t[e++]=r&255|zn,r/=128;for(;r&si;)t[e++]=r&255|zn,r>>>=7;return t[e]=r|0,jn.bytes=e-n+1,t}var ci=Ir,ai=128,Fn=127;function Ir(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Ir.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&Fn)<<o:(i&Fn)*Math.pow(2,o),o+=7}while(i>=ai);return Ir.bytes=s-n,e}var fi=Math.pow(2,7),ui=Math.pow(2,14),hi=Math.pow(2,21),li=Math.pow(2,28),di=Math.pow(2,35),pi=Math.pow(2,42),mi=Math.pow(2,49),yi=Math.pow(2,56),xi=Math.pow(2,63),bi=function(r){return r<fi?1:r<ui?2:r<hi?3:r<li?4:r<di?5:r<pi?6:r<mi?7:r<yi?8:r<xi?9:10},gi={encode:ni,decode:ci,encodingLength:bi},wi=gi,Ee=wi;function Ae(r,t=0){return[Ee.decode(r,t),Ee.decode.bytes]}function se(r,t,e=0){return Ee.encode(r,t,e),t}function ie(r){return Ee.encodingLength(r)}function jt(r,t){let e=t.byteLength,n=ie(r),o=n+ie(e),s=new Uint8Array(o+e);return se(r,s,0),se(e,s,n),s.set(t,o),new ce(r,e,t,s)}function Se(r){let t=It(r),[e,n]=Ae(t),[o,s]=Ae(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ce(e,o,i,t)}function Gn(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&On(r.bytes,e.bytes)}}var ce=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Zn(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Ai(e,Lr(r),t??X.encoder);default:return Si(e,Lr(r),t??oe.encoder)}}var Yn=new WeakMap;function Lr(r){let t=Yn.get(r);if(t==null){let e=new Map;return Yn.set(r,e),e}return t}var ot=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Be)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Bi)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=jt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Gn(t.multihash,n.multihash)}toString(t){return Zn(this,t)}toJSON(){return{"/":Zn(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??Wn(n,o,s.bytes))}else if(e[vi]===!0){let{version:n,multihash:o,code:s}=e,i=Se(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!==Be)throw new Error(`Version 0 CID must use dag-pb (code: ${Be}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Wn(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Be,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=It(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 ce(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,E]=Ae(t.subarray(e));return e+=E,l},o=n(),s=Be;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),c=n(),d=e+c,f=d-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:f,size:d}}static parse(t,e){let[n,o]=Ei(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 Lr(s).set(n,t),s}};function Ei(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 oe.prefix:{let e=t??oe;return[oe.prefix,e.decode(r)]}case we.prefix:{let e=t??we;return[we.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 Ai(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 Si(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 Be=112,Bi=18;function Wn(r,t,e){let n=ie(r),o=n+ie(t),s=new Uint8Array(o+e.byteLength);return se(r,s,0),se(t,s,n),s.set(e,o),s}var vi=Symbol.for("@ipld/js-cid/CID");var _r={};ut(_r,{identity:()=>bt});var Xn=0,Ii="identity",$n=It;function Li(r){return jt(Xn,$n(r))}var bt={code:Xn,name:Ii,encode:$n,digest:Li};function gt(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 Lt(r=0){return new Uint8Array(r)}function ht(r=0){return new Uint8Array(r)}function We(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=ht(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var Qn=Symbol.for("@achingbrain/uint8arraylist");function Jn(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 Xe(r){return!!r?.[Qn]}var lt=class r{bufs;length;[Qn]=!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(Xe(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(Xe(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=Jn(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Jn(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(Xe(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 We(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:We(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],a=o,c=a+i.byteLength;if(o=c,t>=c)continue;let d=t>=a&&t<c,f=e>a&&e<=c;if(d&&f){if(t===a&&e===c){n.push(i);break}let l=t-a;n.push(i.subarray(l,l+(e-t)));break}if(d){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(f){if(e===c){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Xe(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 a=i,c=this.byteLength-n.byteLength,d=n.byteLength-1,f;for(let l=e;l<=c;l+=f){f=0;for(let E=d;E>=0;E--){let L=this.get(l+E);if(n[E]!==L){f=Math.max(1,E-a[L]);break}}if(f===0)return l}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=ht(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=Lt(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=Lt(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=Lt(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=ht(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=Lt(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=Lt(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=Lt(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=Lt(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=Lt(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(!gt(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 Ur={};ut(Ur,{base10:()=>_i});var _i=Nt({prefix:"9",name:"base10",alphabet:"0123456789"});var Cr={};ut(Cr,{base16:()=>Ui,base16upper:()=>Ci});var Ui=G({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ci=G({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Tr={};ut(Tr,{base2:()=>Ti});var Ti=G({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Dr={};ut(Dr,{base256emoji:()=>Ni});var to=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}"),Di=to.reduce((r,t,e)=>(r[e]=t,r),[]),Ri=to.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Pi(r){return r.reduce((t,e)=>(t+=Di[e],t),"")}function Ki(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Ri[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Ni=ne({prefix:"\u{1F680}",name:"base256emoji",encode:Pi,decode:Ki});var Rr={};ut(Rr,{base64:()=>Oi,base64pad:()=>ki,base64url:()=>Hi,base64urlpad:()=>Mi});var Oi=G({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ki=G({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Hi=G({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Mi=G({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Pr={};ut(Pr,{base8:()=>qi});var qi=G({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Kr={};ut(Kr,{identity:()=>Vi});var Vi=ne({prefix:"\0",name:"identity",encode:r=>Hn(r),decode:r=>kn(r)});var Xa=new TextEncoder,$a=new TextDecoder;var kr={};ut(kr,{sha256:()=>ve,sha512:()=>ji});function Or({name:r,code:t,encode:e}){return new Nr(r,t,e)}var Nr=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?jt(this.code,e):e.then(n=>jt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ro(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var ve=Or({name:"sha2-256",code:18,encode:ro("SHA-256")}),ji=Or({name:"sha2-512",code:19,encode:ro("SHA-512")});var Hr={...Kr,...Tr,...Pr,...Ur,...Cr,...Br,...vr,...Sr,...Rr,...Dr},uf={...kr,..._r};function oo(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var no=oo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Mr=oo("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=ht(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Gi={utf8:no,"utf-8":no,hex:Hr.base16,latin1:Mr,ascii:Mr,binary:Mr,...Hr},$e=Gi;function Ot(r,t="utf8"){let e=$e[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function yt(r,t="utf8"){let e=$e[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Zi=parseInt("11111",2),qr=parseInt("10000000",2),Yi=parseInt("01111111",2),so={0:Ie,1:Ie,2:Wi,3:Ji,4:Qi,5:$i,6:Xi,16:Ie,22:Ie,48:Ie};function Vr(r,t={offset:0}){let e=r[t.offset]&Zi;if(t.offset++,so[e]!=null)return so[e](r,t);throw new Error("No decoder for tag "+e)}function Le(r,t){let e=0;if((r[t.offset]&qr)===qr){let n=r[t.offset]&Yi,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 Ie(r,t){Le(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=Vr(r,t);if(n===null)break;e.push(n)}return e}function Wi(r,t){let e=Le(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 Xi(r,t){let e=Le(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let a=`${s}.${i}`,c=[];for(;t.offset<n;){let d=r[t.offset];if(t.offset++,c.push(d&127),d<128){c.reverse();let f=0;for(let l=0;l<c.length;l++)f+=c[l]<<l*7;a+=`.${f}`,c=[]}}return a}function $i(r,t){return t.offset++,null}function Ji(r,t){let e=Le(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Qi(r,t){let e=Le(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function tc(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new lt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function zr(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=tc(r.byteLength);return new lt(Uint8Array.from([t.byteLength|qr]),t)}function io(r){let t=new lt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new lt(Uint8Array.from([2]),zr(t),t)}function co(r){let t=Uint8Array.from([0]),e=new lt(t,r);return new lt(Uint8Array.from([3]),zr(e),e)}function Je(r,t=48){let e=new lt;for(let n of r)e.append(n);return new lt(Uint8Array.from([t]),zr(e),e)}async function ao(r,t,e,n){let o=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,t,e.subarray());return n?.signal?.throwIfAborted(),s}var ec=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),rc=Uint8Array.from([6,5,43,129,4,0,34]),nc=Uint8Array.from([6,5,43,129,4,0,35]),oc={ext:!0,kty:"EC",crv:"P-256"},sc={ext:!0,kty:"EC",crv:"P-384"},ic={ext:!0,kty:"EC",crv:"P-521"},Fr=32,jr=48,Gr=66;function fo(r){let t=Vr(r);return uo(t)}function uo(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===Fr*2+1)return n=yt(t.subarray(e,e+Fr),"base64url"),o=yt(t.subarray(e+Fr),"base64url"),new fe({...oc,key_ops:["verify"],x:n,y:o});if(t.byteLength===jr*2+1)return n=yt(t.subarray(e,e+jr),"base64url"),o=yt(t.subarray(e+jr),"base64url"),new fe({...sc,key_ops:["verify"],x:n,y:o});if(t.byteLength===Gr*2+1)return n=yt(t.subarray(e,e+Gr),"base64url"),o=yt(t.subarray(e+Gr),"base64url"),new fe({...ic,key_ops:["verify"],x:n,y:o});throw new At(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function ho(r){return Je([io(Uint8Array.from([1])),Je([cc(r.crv)],160),Je([co(new lt(Uint8Array.from([4]),Ot(r.x??"","base64url"),Ot(r.y??"","base64url")))],161)]).subarray()}function cc(r){if(r==="P-256")return ec;if(r==="P-384")return rc;if(r==="P-521")return nc;throw new At(`Invalid curve ${r}`)}var fe=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=ho(this.jwk)),this._raw}toMultihash(){return bt.digest(ue(this))}toCID(){return ot.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:gt(this.raw,t.raw)}async verify(t,e,n){return ao(this.jwk,e,t,n)}};var Gt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function ac(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Qe(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Zt(r,...t){if(!ac(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 lo(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Qe(r.outputLen),Qe(r.blockLen)}function le(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 po(r,t){Zt(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function _t(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function tr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function wt(r,t){return r<<32-t|r>>>t}function mo(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function _e(r){return typeof r=="string"&&(r=mo(r)),Zt(r),r}function Zr(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Zt(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 he=class{};function Yr(r){let t=n=>r().update(_e(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function er(r=32){if(Gt&&typeof Gt.getRandomValues=="function")return Gt.getRandomValues(new Uint8Array(r));if(Gt&&typeof Gt.randomBytes=="function")return Uint8Array.from(Gt.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function fc(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),a=Number(e&s),c=n?4:0,d=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+d,a,n)}function yo(r,t,e){return r&t^~r&e}function xo(r,t,e){return r&t^r&e^t&e}var Ue=class extends he{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=tr(this.buffer)}update(t){le(this),t=_e(t),Zt(t);let{view:e,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=tr(t);for(;o<=s-i;i+=o)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){le(this),po(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,_t(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)e[l]=0;fc(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=tr(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=c/4,f=this.get();if(d>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<d;l++)a.setUint32(4*l,f[l],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=a,o%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Ut=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var et=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var rr=BigInt(4294967295),bo=BigInt(32);function uc(r,t=!1){return t?{h:Number(r&rr),l:Number(r>>bo&rr)}:{h:Number(r>>bo&rr)|0,l:Number(r&rr)|0}}function go(r,t=!1){let e=r.length,n=new Uint32Array(e),o=new Uint32Array(e);for(let s=0;s<e;s++){let{h:i,l:a}=uc(r[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var Wr=(r,t,e)=>r>>>e,Xr=(r,t,e)=>r<<32-e|t>>>e,Yt=(r,t,e)=>r>>>e|t<<32-e,Wt=(r,t,e)=>r<<32-e|t>>>e,Ce=(r,t,e)=>r<<64-e|t>>>e-32,Te=(r,t,e)=>r>>>e-32|t<<64-e;function St(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var wo=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Eo=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Ao=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),So=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Bo=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),vo=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var lc=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),kt=new Uint32Array(64),$r=class extends Ue{constructor(t=32){super(64,t,8,!1),this.A=Ut[0]|0,this.B=Ut[1]|0,this.C=Ut[2]|0,this.D=Ut[3]|0,this.E=Ut[4]|0,this.F=Ut[5]|0,this.G=Ut[6]|0,this.H=Ut[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,e,n,o,s,i,a,c]}set(t,e,n,o,s,i,a,c){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=a|0,this.H=c|0}process(t,e){for(let l=0;l<16;l++,e+=4)kt[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let E=kt[l-15],L=kt[l-2],S=wt(E,7)^wt(E,18)^E>>>3,y=wt(L,17)^wt(L,19)^L>>>10;kt[l]=y+kt[l-7]+S+kt[l-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:d,H:f}=this;for(let l=0;l<64;l++){let E=wt(a,6)^wt(a,11)^wt(a,25),L=f+E+yo(a,c,d)+lc[l]+kt[l]|0,y=(wt(n,2)^wt(n,13)^wt(n,22))+xo(n,o,s)|0;f=d,d=c,c=a,a=i+L|0,i=s,s=o,o=n,n=L+y|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(n,o,s,i,a,c,d,f)}roundClean(){_t(kt)}destroy(){this.set(0,0,0,0,0,0,0,0),_t(this.buffer)}};var Io=go(["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))),dc=Io[0],pc=Io[1],Ht=new Uint32Array(80),Mt=new Uint32Array(80),Jr=class extends Ue{constructor(t=64){super(128,t,16,!1),this.Ah=et[0]|0,this.Al=et[1]|0,this.Bh=et[2]|0,this.Bl=et[3]|0,this.Ch=et[4]|0,this.Cl=et[5]|0,this.Dh=et[6]|0,this.Dl=et[7]|0,this.Eh=et[8]|0,this.El=et[9]|0,this.Fh=et[10]|0,this.Fl=et[11]|0,this.Gh=et[12]|0,this.Gl=et[13]|0,this.Hh=et[14]|0,this.Hl=et[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:d,El:f,Fh:l,Fl:E,Gh:L,Gl:S,Hh:y,Hl:R}=this;return[t,e,n,o,s,i,a,c,d,f,l,E,L,S,y,R]}set(t,e,n,o,s,i,a,c,d,f,l,E,L,S,y,R){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=d|0,this.El=f|0,this.Fh=l|0,this.Fl=E|0,this.Gh=L|0,this.Gl=S|0,this.Hh=y|0,this.Hl=R|0}process(t,e){for(let A=0;A<16;A++,e+=4)Ht[A]=t.getUint32(e),Mt[A]=t.getUint32(e+=4);for(let A=16;A<80;A++){let u=Ht[A-15]|0,m=Mt[A-15]|0,B=Yt(u,m,1)^Yt(u,m,8)^Wr(u,m,7),v=Wt(u,m,1)^Wt(u,m,8)^Xr(u,m,7),I=Ht[A-2]|0,D=Mt[A-2]|0,O=Yt(I,D,19)^Ce(I,D,61)^Wr(I,D,6),U=Wt(I,D,19)^Te(I,D,61)^Xr(I,D,6),K=Ao(v,U,Mt[A-7],Mt[A-16]),T=So(K,B,O,Ht[A-7],Ht[A-16]);Ht[A]=T|0,Mt[A]=K|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:d,Dl:f,Eh:l,El:E,Fh:L,Fl:S,Gh:y,Gl:R,Hh:P,Hl:q}=this;for(let A=0;A<80;A++){let u=Yt(l,E,14)^Yt(l,E,18)^Ce(l,E,41),m=Wt(l,E,14)^Wt(l,E,18)^Te(l,E,41),B=l&L^~l&y,v=E&S^~E&R,I=Bo(q,m,v,pc[A],Mt[A]),D=vo(I,P,u,B,dc[A],Ht[A]),O=I|0,U=Yt(n,o,28)^Ce(n,o,34)^Ce(n,o,39),K=Wt(n,o,28)^Te(n,o,34)^Te(n,o,39),T=n&s^n&a^s&a,Y=o&i^o&c^i&c;P=y|0,q=R|0,y=L|0,R=S|0,L=l|0,S=E|0,{h:l,l:E}=St(d|0,f|0,D|0,O|0),d=a|0,f=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let g=wo(O,K,Y);n=Eo(g,D,U,T),o=g|0}({h:n,l:o}=St(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=St(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=St(this.Ch|0,this.Cl|0,a|0,c|0),{h:d,l:f}=St(this.Dh|0,this.Dl|0,d|0,f|0),{h:l,l:E}=St(this.Eh|0,this.El|0,l|0,E|0),{h:L,l:S}=St(this.Fh|0,this.Fl|0,L|0,S|0),{h:y,l:R}=St(this.Gh|0,this.Gl|0,y|0,R|0),{h:P,l:q}=St(this.Hh|0,this.Hl|0,P|0,q|0),this.set(n,o,s,i,a,c,d,f,l,E,L,S,y,R,P,q)}roundClean(){_t(Ht,Mt)}destroy(){_t(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Lo=Yr(()=>new $r);var _o=Yr(()=>new Jr);var rn=BigInt(0),en=BigInt(1);function de(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function nn(r){if(!de(r))throw new Error("Uint8Array expected")}function Bt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function De(r){let t=r.toString(16);return t.length&1?"0"+t:t}function To(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?rn:BigInt("0x"+r)}var Do=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",mc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function qt(r){if(nn(r),Do)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=mc[r[e]];return t}var Ct={_0:48,_9:57,A:65,F:70,a:97,f:102};function Uo(r){if(r>=Ct._0&&r<=Ct._9)return r-Ct._0;if(r>=Ct.A&&r<=Ct.F)return r-(Ct.A-10);if(r>=Ct.a&&r<=Ct.f)return r-(Ct.a-10)}function Re(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(Do)return Uint8Array.fromHex(r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=Uo(r.charCodeAt(s)),a=Uo(r.charCodeAt(s+1));if(i===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function Tt(r){return To(qt(r))}function Xt(r){return nn(r),To(qt(Uint8Array.from(r).reverse()))}function $t(r,t){return Re(r.toString(16).padStart(t*2,"0"))}function pe(r,t){return $t(r,t).reverse()}function F(r,t,e){let n;if(typeof t=="string")try{n=Re(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(de(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 Vt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];nn(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 Qr=r=>typeof r=="bigint"&&rn<=r;function nr(r,t,e){return Qr(r)&&Qr(t)&&Qr(e)&&t<=r&&r<e}function dt(r,t,e,n){if(!nr(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Ro(r){let t;for(t=0;r>rn;r>>=en,t+=1);return t}var Jt=r=>(en<<BigInt(r))-en,tn=r=>new Uint8Array(r),Co=r=>Uint8Array.from(r);function Po(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=tn(r),o=tn(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},a=(...l)=>e(o,n,...l),c=(l=tn(0))=>{o=a(Co([0]),l),n=a(),l.length!==0&&(o=a(Co([1]),l),n=a())},d=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,E=[];for(;l<t;){n=a();let L=n.slice();E.push(L),l+=n.length}return Vt(...E)};return(l,E)=>{i(),c(l);let L;for(;!(L=E(d()));)c();return i(),L}}var yc={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"||de(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 Dt(r,t,e={}){let n=(o,s,i)=>{let a=yc[s];if(typeof a!="function")throw new Error("invalid validator function");let c=r[o];if(!(i&&c===void 0)&&!a(c,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+c)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}function me(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var st=BigInt(0),J=BigInt(1),Qt=BigInt(2),xc=BigInt(3),No=BigInt(4),Oo=BigInt(5),ko=BigInt(8);function z(r,t){let e=r%t;return e>=st?e:t+e}function j(r,t,e){let n=r;for(;t-- >st;)n*=n,n%=e;return n}function or(r,t){if(r===st)throw new Error("invert: expected non-zero number");if(t<=st)throw new Error("invert: expected positive modulus, got "+t);let e=z(r,t),n=t,o=st,s=J,i=J,a=st;for(;e!==st;){let d=n/e,f=n%e,l=o-i*d,E=s-a*d;n=e,e=f,o=i,s=a,i=l,a=E}if(n!==J)throw new Error("invert: does not exist");return z(o,t)}function Ho(r,t){let e=(r.ORDER+J)/No,n=r.pow(t,e);if(!r.eql(r.sqr(n),t))throw new Error("Cannot find square root");return n}function bc(r,t){let e=(r.ORDER-Oo)/ko,n=r.mul(t,Qt),o=r.pow(n,e),s=r.mul(t,o),i=r.mul(r.mul(s,Qt),o),a=r.mul(s,r.sub(i,r.ONE));if(!r.eql(r.sqr(a),t))throw new Error("Cannot find square root");return a}function gc(r){if(r<BigInt(3))throw new Error("sqrt is not defined for small field");let t=r-J,e=0;for(;t%Qt===st;)t/=Qt,e++;let n=Qt,o=Rt(r);for(;Ko(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return Ho;let s=o.pow(n,t),i=(t+J)/Qt;return function(c,d){if(c.is0(d))return d;if(Ko(c,d)!==1)throw new Error("Cannot find square root");let f=e,l=c.mul(c.ONE,s),E=c.pow(d,t),L=c.pow(d,i);for(;!c.eql(E,c.ONE);){if(c.is0(E))return c.ZERO;let S=1,y=c.sqr(E);for(;!c.eql(y,c.ONE);)if(S++,y=c.sqr(y),S===f)throw new Error("Cannot find square root");let R=J<<BigInt(f-S-1),P=c.pow(l,R);f=S,l=c.sqr(P),E=c.mul(E,l),L=c.mul(L,P)}return L}}function wc(r){return r%No===xc?Ho:r%ko===Oo?bc:gc(r)}var Mo=(r,t)=>(z(r,t)&J)===J,Ec=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function on(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Ec.reduce((n,o)=>(n[o]="function",n),t);return Dt(r,e)}function Ac(r,t,e){if(e<st)throw new Error("invalid exponent, negatives unsupported");if(e===st)return r.ONE;if(e===J)return t;let n=r.ONE,o=t;for(;e>st;)e&J&&(n=r.mul(n,o)),o=r.sqr(o),e>>=J;return n}function ye(r,t,e=!1){let n=new Array(t.length).fill(e?r.ZERO:void 0),o=t.reduce((i,a,c)=>r.is0(a)?i:(n[c]=i,r.mul(i,a)),r.ONE),s=r.inv(o);return t.reduceRight((i,a,c)=>r.is0(a)?i:(n[c]=r.mul(i,n[c]),r.mul(i,a)),s),n}function Ko(r,t){let e=(r.ORDER-J)/Qt,n=r.pow(t,e),o=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),i=r.eql(n,r.neg(r.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function sn(r,t){t!==void 0&&Qe(t);let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Rt(r,t,e=!1,n={}){if(r<=st)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=sn(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,a=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:Jt(o),ZERO:st,ONE:J,create:c=>z(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return st<=c&&c<r},is0:c=>c===st,isOdd:c=>(c&J)===J,neg:c=>z(-c,r),eql:(c,d)=>c===d,sqr:c=>z(c*c,r),add:(c,d)=>z(c+d,r),sub:(c,d)=>z(c-d,r),mul:(c,d)=>z(c*d,r),pow:(c,d)=>Ac(a,c,d),div:(c,d)=>z(c*or(d,r),r),sqrN:c=>c*c,addN:(c,d)=>c+d,subN:(c,d)=>c-d,mulN:(c,d)=>c*d,inv:c=>or(c,r),sqrt:n.sqrt||(c=>(i||(i=wc(r)),i(a,c))),toBytes:c=>e?pe(c,s):$t(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return e?Xt(c):Tt(c)},invertBatch:c=>ye(a,c),cmov:(c,d,f)=>f?d:c});return Object.freeze(a)}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 cn(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=cn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?Xt(r):Tt(r),a=z(i,t-J)+J;return e?pe(a,o):$t(a,o)}var zo=BigInt(0),ln=BigInt(1);function an(r,t){let e=t.negate();return r?e:t}function jo(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function fn(r,t){jo(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=Jt(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function Fo(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,a=Number(r&o),c=r>>i;a>n&&(a-=s,c+=ln);let d=t*n,f=d+Math.abs(a)-1,l=a===0,E=a<0,L=t%2!==0;return{nextN:c,offset:f,isZero:l,isNeg:E,isNegF:L,offsetF:d}}function Sc(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 Bc(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 un=new WeakMap,Go=new WeakMap;function hn(r){return Go.get(r)||1}function sr(r,t){return{constTimeNegate:an,hasPrecomputes(e){return hn(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>zo;)n&ln&&(o=o.add(s)),s=s.double(),n>>=ln;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=fn(n,t),i=[],a=e,c=a;for(let d=0;d<o;d++){c=a,i.push(c);for(let f=1;f<s;f++)c=c.add(a),i.push(c);a=c.double()}return i},wNAF(e,n,o){let s=r.ZERO,i=r.BASE,a=fn(e,t);for(let c=0;c<a.windows;c++){let{nextN:d,offset:f,isZero:l,isNeg:E,isNegF:L,offsetF:S}=Fo(o,c,a);o=d,l?i=i.add(an(L,n[S])):s=s.add(an(E,n[f]))}return{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=fn(e,t);for(let a=0;a<i.windows&&o!==zo;a++){let{nextN:c,offset:d,isZero:f,isNeg:l}=Fo(o,a,i);if(o=c,!f){let E=n[d];s=s.add(l?E.negate():E)}}return s},getPrecomputes(e,n,o){let s=un.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&un.set(n,o(s))),s},wNAFCached(e,n,o){let s=hn(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=hn(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){jo(n,t),Go.set(e,n),un.delete(e)}}}function ir(r,t,e,n){Sc(e,r),Bc(n,t);let o=e.length,s=n.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");let i=r.ZERO,a=Ro(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let d=Jt(c),f=new Array(Number(d)+1).fill(i),l=Math.floor((t.BITS-1)/c)*c,E=i;for(let L=l;L>=0;L-=c){f.fill(i);for(let y=0;y<s;y++){let R=n[y],P=Number(R>>BigInt(L)&d);f[P]=f[P].add(e[y])}let S=i;for(let y=f.length-1,R=i;y>0;y--)R=R.add(f[y]),S=S.add(R);if(E=E.add(S),L!==0)for(let y=0;y<c;y++)E=E.double()}return E}function Pe(r){return on(r.Fp),Dt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...sn(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var vt=BigInt(0),it=BigInt(1),Zo=BigInt(2),vc=BigInt(8),Ic={zip215:!0};function Lc(r){let t=Pe(r);return Dt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Yo(r){let t=Lc(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:a,h:c}=t,d=Zo<<BigInt(a*8)-it,f=e.create,l=Rt(t.n,t.nBitLength);function E(x,h){let p=e.sqr(x),w=e.sqr(h),C=e.add(e.mul(t.a,p),w),N=e.add(e.ONE,e.mul(t.d,e.mul(p,w)));return e.eql(C,N)}if(!E(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let L=t.uvRatio||((x,h)=>{try{return{isValid:!0,value:e.sqrt(x*e.inv(h))}}catch{return{isValid:!1,value:vt}}}),S=t.adjustScalarBytes||(x=>x),y=t.domain||((x,h,p)=>{if(Bt("phflag",p),h.length||p)throw new Error("Contexts/pre-hash are not supported");return x});function R(x,h,p=!1){let w=p?it:vt;dt("coordinate "+x,h,w,d)}function P(x){if(!(x instanceof u))throw new Error("ExtendedPoint expected")}let q=me((x,h)=>{let{ex:p,ey:w,ez:C}=x,N=x.is0();h==null&&(h=N?vc:e.inv(C));let k=f(p*h),H=f(w*h),M=f(C*h);if(N)return{x:vt,y:it};if(M!==it)throw new Error("invZ was invalid");return{x:k,y:H}}),A=me(x=>{let{a:h,d:p}=t;if(x.is0())throw new Error("bad point: ZERO");let{ex:w,ey:C,ez:N,et:k}=x,H=f(w*w),M=f(C*C),V=f(N*N),W=f(V*V),Z=f(H*h),tt=f(V*f(Z+M)),at=f(W+f(p*f(H*M)));if(tt!==at)throw new Error("bad point: equation left != right (1)");let $=f(w*C),rt=f(N*k);if($!==rt)throw new Error("bad point: equation left != right (2)");return!0});class u{constructor(h,p,w,C){R("x",h),R("y",p),R("z",w,!0),R("t",C),this.ex=h,this.ey=p,this.ez=w,this.et=C,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(h){if(h instanceof u)throw new Error("extended point not allowed");let{x:p,y:w}=h||{};return R("x",p),R("y",w),new u(p,w,it,f(p*w))}static normalizeZ(h){let p=ye(e,h.map(w=>w.ez));return h.map((w,C)=>w.toAffine(p[C])).map(u.fromAffine)}static msm(h,p){return ir(u,l,h,p)}_setWindowSize(h){v.setWindowSize(this,h)}assertValidity(){A(this)}equals(h){P(h);let{ex:p,ey:w,ez:C}=this,{ex:N,ey:k,ez:H}=h,M=f(p*H),V=f(N*C),W=f(w*H),Z=f(k*C);return M===V&&W===Z}is0(){return this.equals(u.ZERO)}negate(){return new u(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:h}=t,{ex:p,ey:w,ez:C}=this,N=f(p*p),k=f(w*w),H=f(Zo*f(C*C)),M=f(h*N),V=p+w,W=f(f(V*V)-N-k),Z=M+k,tt=Z-H,at=M-k,$=f(W*tt),rt=f(Z*at),ft=f(W*at),xt=f(tt*Z);return new u($,rt,xt,ft)}add(h){P(h);let{a:p,d:w}=t,{ex:C,ey:N,ez:k,et:H}=this,{ex:M,ey:V,ez:W,et:Z}=h,tt=f(C*M),at=f(N*V),$=f(H*w*Z),rt=f(k*W),ft=f((C+N)*(M+V)-tt-at),xt=rt-$,ge=rt+$,Nn=f(at-p*tt),Ds=f(ft*xt),Rs=f(ge*Nn),Ps=f(ft*Nn),Ks=f(xt*ge);return new u(Ds,Rs,Ks,Ps)}subtract(h){return this.add(h.negate())}wNAF(h){return v.wNAFCached(this,h,u.normalizeZ)}multiply(h){let p=h;dt("scalar",p,it,n);let{p:w,f:C}=this.wNAF(p);return u.normalizeZ([w,C])[0]}multiplyUnsafe(h,p=u.ZERO){let w=h;return dt("scalar",w,vt,n),w===vt?B:this.is0()||w===it?this:v.wNAFCachedUnsafe(this,w,u.normalizeZ,p)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return v.unsafeLadder(this,n).is0()}toAffine(h){return q(this,h)}clearCofactor(){let{h}=t;return h===it?this:this.multiplyUnsafe(h)}static fromHex(h,p=!1){let{d:w,a:C}=t,N=e.BYTES;h=F("pointHex",h,N),Bt("zip215",p);let k=h.slice(),H=h[N-1];k[N-1]=H&-129;let M=Xt(k),V=p?d:e.ORDER;dt("pointHex.y",M,vt,V);let W=f(M*M),Z=f(W-it),tt=f(w*W-C),{isValid:at,value:$}=L(Z,tt);if(!at)throw new Error("Point.fromHex: invalid y coordinate");let rt=($&it)===it,ft=(H&128)!==0;if(!p&&$===vt&&ft)throw new Error("Point.fromHex: x=0 and x_0=1");return ft!==rt&&($=f(-$)),u.fromAffine({x:$,y:M})}static fromPrivateKey(h){let{scalar:p}=O(h);return m.multiply(p)}toRawBytes(){let{x:h,y:p}=this.toAffine(),w=pe(p,e.BYTES);return w[w.length-1]|=h&it?128:0,w}toHex(){return qt(this.toRawBytes())}}u.BASE=new u(t.Gx,t.Gy,it,f(t.Gx*t.Gy)),u.ZERO=new u(vt,it,it,vt);let{BASE:m,ZERO:B}=u,v=sr(u,a*8);function I(x){return z(x,n)}function D(x){return I(Xt(x))}function O(x){let h=e.BYTES;x=F("private key",x,h);let p=F("hashed private key",s(x),2*h),w=S(p.slice(0,h)),C=p.slice(h,2*h),N=D(w);return{head:w,prefix:C,scalar:N}}function U(x){let{head:h,prefix:p,scalar:w}=O(x),C=m.multiply(w),N=C.toRawBytes();return{head:h,prefix:p,scalar:w,point:C,pointBytes:N}}function K(x){return U(x).pointBytes}function T(x=Uint8Array.of(),...h){let p=Vt(...h);return D(s(y(p,F("context",x),!!o)))}function Y(x,h,p={}){x=F("message",x),o&&(x=o(x));let{prefix:w,scalar:C,pointBytes:N}=U(h),k=T(p.context,w,x),H=m.multiply(k).toRawBytes(),M=T(p.context,H,N,x),V=I(k+M*C);dt("signature.s",V,vt,n);let W=Vt(H,pe(V,e.BYTES));return F("result",W,e.BYTES*2)}let g=Ic;function b(x,h,p,w=g){let{context:C,zip215:N}=w,k=e.BYTES;x=F("signature",x,2*k),h=F("message",h),p=F("publicKey",p,k),N!==void 0&&Bt("zip215",N),o&&(h=o(h));let H=Xt(x.slice(k,2*k)),M,V,W;try{M=u.fromHex(p,N),V=u.fromHex(x.slice(0,k),N),W=m.multiplyUnsafe(H)}catch{return!1}if(!N&&M.isSmallOrder())return!1;let Z=T(C,V.toRawBytes(),M.toRawBytes(),h);return V.add(M.multiplyUnsafe(Z)).subtract(W).clearCofactor().equals(u.ZERO)}return m._setWindowSize(8),{CURVE:t,getPublicKey:K,sign:Y,verify:b,ExtendedPoint:u,utils:{getExtendedPublicKey:U,randomPrivateKey:()=>i(e.BYTES),precompute(x=8,h=u.BASE){return h._setWindowSize(x),h.multiply(BigInt(3)),h}}}}var dn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Wo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),du=BigInt(0),_c=BigInt(1),Xo=BigInt(2),pu=BigInt(3),Uc=BigInt(5),Cc=BigInt(8);function Tc(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=dn,a=r*r%s*r%s,c=j(a,Xo,s)*a%s,d=j(c,_c,s)*r%s,f=j(d,Uc,s)*d%s,l=j(f,t,s)*f%s,E=j(l,e,s)*l%s,L=j(E,n,s)*E%s,S=j(L,o,s)*L%s,y=j(S,o,s)*L%s,R=j(y,t,s)*f%s;return{pow_p_5_8:j(R,Xo,s)*r%s,b2:a}}function Dc(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Rc(r,t){let e=dn,n=z(t*t*t,e),o=z(n*n*t,e),s=Tc(r*o).pow_p_5_8,i=z(r*n*s,e),a=z(t*i*i,e),c=i,d=z(i*Wo,e),f=a===r,l=a===z(-r,e),E=a===z(-r*Wo,e);return f&&(i=c),(l||E)&&(i=d),Mo(i,e)&&(i=z(-i,e)),{isValid:f||l,value:i}}var $o=Rt(dn,void 0,!0),Pc={a:$o.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:$o,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Cc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:_o,randomBytes:er,adjustScalarBytes:Dc,uvRatio:Rc},Jo=Yo(Pc);var cr=32;function Qo(r,t,e){return Jo.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var ar=class{type="Ed25519";raw;constructor(t){this.raw=pn(t,cr)}toMultihash(){return bt.digest(ue(this))}toCID(){return ot.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:gt(this.raw,t.raw)}verify(t,e,n){return n?.signal?.throwIfAborted(),Qo(this.raw,e,t)}};function es(r){return r=pn(r,cr),new ar(r)}function pn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new At(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var Nc=Math.pow(2,7),Oc=Math.pow(2,14),kc=Math.pow(2,21),rs=Math.pow(2,28),ns=Math.pow(2,35),os=Math.pow(2,42),ss=Math.pow(2,49),ct=128,zt=127;function Ke(r){if(r<Nc)return 1;if(r<Oc)return 2;if(r<kc)return 3;if(r<rs)return 4;if(r<ns)return 5;if(r<os)return 6;if(r<ss)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function is(r,t,e=0){switch(Ke(r)){case 8:t[e++]=r&255|ct,r/=128;case 7:t[e++]=r&255|ct,r/=128;case 6:t[e++]=r&255|ct,r/=128;case 5:t[e++]=r&255|ct,r/=128;case 4:t[e++]=r&255|ct,r>>>=7;case 3:t[e++]=r&255|ct,r>>>=7;case 2:t[e++]=r&255|ct,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function cs(r,t){let e=r[t],n=0;if(n+=e&zt,e<ct||(e=r[t+1],n+=(e&zt)<<7,e<ct)||(e=r[t+2],n+=(e&zt)<<14,e<ct)||(e=r[t+3],n+=(e&zt)<<21,e<ct)||(e=r[t+4],n+=(e&zt)*rs,e<ct)||(e=r[t+5],n+=(e&zt)*ns,e<ct)||(e=r[t+6],n+=(e&zt)*os,e<ct)||(e=r[t+7],n+=(e&zt)*ss,e<ct))return n;throw new RangeError("Could not decode varint")}var mn=new Float32Array([-0]),Ft=new Uint8Array(mn.buffer);function as(r,t,e){mn[0]=r,t[e]=Ft[0],t[e+1]=Ft[1],t[e+2]=Ft[2],t[e+3]=Ft[3]}function fs(r,t){return Ft[0]=r[t],Ft[1]=r[t+1],Ft[2]=r[t+2],Ft[3]=r[t+3],mn[0]}var yn=new Float64Array([-0]),nt=new Uint8Array(yn.buffer);function us(r,t,e){yn[0]=r,t[e]=nt[0],t[e+1]=nt[1],t[e+2]=nt[2],t[e+3]=nt[3],t[e+4]=nt[4],t[e+5]=nt[5],t[e+6]=nt[6],t[e+7]=nt[7]}function hs(r,t){return nt[0]=r[t],nt[1]=r[t+1],nt[2]=r[t+2],nt[3]=r[t+3],nt[4]=r[t+4],nt[5]=r[t+5],nt[6]=r[t+6],nt[7]=r[t+7],yn[0]}var Hc=BigInt(Number.MAX_SAFE_INTEGER),Mc=BigInt(Number.MIN_SAFE_INTEGER),pt=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 te;if(t<Hc&&t>Mc)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>ls&&(o=0n,++n>ls&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return te;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):te}},te=new pt(0,0);te.toBigInt=function(){return 0n};te.zzEncode=te.zzDecode=function(){return this};te.length=function(){return 1};var ls=4294967296n;function ds(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 ps(r,t,e){if(e-t<1)return"";let o,s=[],i=0,a;for(;t<e;)a=r[t++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&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 xn(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 Et(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function fr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var bn=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,Et(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 Et(this,4);return fr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Et(this,4);return fr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Et(this,4);let t=fs(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Et(this,4);let t=hs(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 Et(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return ps(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Et(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Et(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 pt(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 Et(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 Et(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 Et(this,8);let t=fr(this.buf,this.pos+=4),e=fr(this.buf,this.pos+=4);return new pt(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=cs(this.buf,this.pos);return this.pos+=Ke(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 bn(r instanceof Uint8Array?r:r.subarray())}function ur(r,t,e){let n=gn(r);return t.decode(n,void 0,e)}function wn(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return ht(i);o+i>t&&(n=ht(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var ee=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function En(){}var Sn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},qc=wn();function Vc(r){return globalThis.Buffer!=null?ht(r):qc(r)}var Oe=class{len;head;tail;states;constructor(){this.len=0,this.head=new ee(En,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ee(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Bn((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(hr,10,pt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=pt.fromBigInt(t);return this._push(hr,e.length(),e)}uint64Number(t){return this._push(is,Ke(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=pt.fromBigInt(t).zzEncode();return this._push(hr,e.length(),e)}sint64Number(t){let e=pt.fromNumber(t).zzEncode();return this._push(hr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(An,1,t?1:0)}fixed32(t){return this._push(Ne,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=pt.fromBigInt(t);return this._push(Ne,4,e.lo)._push(Ne,4,e.hi)}fixed64Number(t){let e=pt.fromNumber(t);return this._push(Ne,4,e.lo)._push(Ne,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(as,4,t)}double(t){return this._push(us,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(An,1,0):this.uint32(e)._push(Fc,e,t)}string(t){let e=ds(t);return e!==0?this.uint32(e)._push(xn,e,t):this._push(An,1,0)}fork(){return this.states=new Sn(this),this.head=this.tail=new ee(En,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 ee(En,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=Vc(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function An(r,t,e){t[e]=r&255}function zc(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Bn=class extends ee{next;constructor(t,e){super(zc,t,e),this.next=void 0}};function hr(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Ne(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 Fc(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(jc,t,r),this},Oe.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Gc,t,r),this});function jc(r,t,e){t.set(r,e)}function Gc(r,t,e){r.length<40?xn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Ot(r),e)}function vn(){return new Oe}function lr(r,t){let e=vn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var xe;(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"})(xe||(xe={}));function dr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function In(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let a=t(s);i.int32(a)},n=function(s){let i=s.int32();return t(i)};return dr("enum",xe.VARINT,e,n)}function pr(r,t){return dr("message",xe.LENGTH_DELIMITED,r,t)}var mt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(mt||(mt={}));var Ln;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(Ln||(Ln={}));(function(r){r.codec=()=>In(Ln)})(mt||(mt={}));var ke;(function(r){let t;r.codec=()=>(t==null&&(t=pr((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 a=e.uint32();switch(a>>>3){case 1:{s.Type=mt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>lr(e,r.codec()),r.decode=(e,n)=>ur(e,r.codec(),n)})(ke||(ke={}));var _n;(function(r){let t;r.codec=()=>(t==null&&(t=pr((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 a=e.uint32();switch(a>>>3){case 1:{s.Type=mt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>lr(e,r.codec()),r.decode=(e,n)=>ur(e,r.codec(),n)})(_n||(_n={}));var He=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var mr=class extends he{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,lo(t);let n=_e(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,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),_t(s)}update(t){return le(this),this.iHash.update(t),this}digestInto(t){le(this),Zt(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:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Un=(r,t,e)=>new mr(r,t).update(e).digest();Un.create=(r,t)=>new mr(r,t);function ys(r){r.lowS!==void 0&&Bt("lowS",r.lowS),r.prehash!==void 0&&Bt("prehash",r.prehash)}function Yc(r){let t=Pe(r);Dt(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}var Dn=class extends Error{constructor(t=""){super(t)}},Pt={Err:Dn,_tlv:{encode:(r,t)=>{let{Err:e}=Pt;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=De(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?De(o.length/2|128):"";return De(r)+s+o+t},decode(r,t){let{Err:e}=Pt,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 c=o&127;if(!c)throw new e("tlv.decode(long): indefinite length not supported");if(c>4)throw new e("tlv.decode(long): byte length is too big");let d=t.subarray(n,n+c);if(d.length!==c)throw new e("tlv.decode: length bytes not complete");if(d[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let f of d)i=i<<8|f;if(n+=c,i<128)throw new e("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+i);if(a.length!==i)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Pt;if(r<Kt)throw new t("integer: negative integers are not allowed");let e=De(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}=Pt;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 Tt(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Pt,o=F("signature",r),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,s),{v:d,l:f}=n.decode(2,c);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(d)}},hexFromSig(r){let{_tlv:t,_int:e}=Pt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}};function Cn(r,t){return qt($t(r,t))}var Kt=BigInt(0),Q=BigInt(1),xh=BigInt(2),Tn=BigInt(3),Wc=BigInt(4);function Xc(r){let t=Yc(r),{Fp:e}=t,n=Rt(t.n,t.nBitLength),o=t.toBytes||((A,u,m)=>{let B=u.toAffine();return Vt(Uint8Array.from([4]),e.toBytes(B.x),e.toBytes(B.y))}),s=t.fromBytes||(A=>{let u=A.subarray(1),m=e.fromBytes(u.subarray(0,e.BYTES)),B=e.fromBytes(u.subarray(e.BYTES,2*e.BYTES));return{x:m,y:B}});function i(A){let{a:u,b:m}=t,B=e.sqr(A),v=e.mul(B,A);return e.add(e.add(v,e.mul(A,u)),m)}function a(A,u){let m=e.sqr(u),B=i(A);return e.eql(m,B)}if(!a(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let c=e.mul(e.pow(t.a,Tn),Wc),d=e.mul(e.sqr(t.b),BigInt(27));if(e.is0(e.add(c,d)))throw new Error("bad curve params: a or b");function f(A){return nr(A,Q,t.n)}function l(A){let{allowedPrivateKeyLengths:u,nByteLength:m,wrapPrivateKey:B,n:v}=t;if(u&&typeof A!="bigint"){if(de(A)&&(A=qt(A)),typeof A!="string"||!u.includes(A.length))throw new Error("invalid private key");A=A.padStart(m*2,"0")}let I;try{I=typeof A=="bigint"?A:Tt(F("private key",A,m))}catch{throw new Error("invalid private key, expected hex or "+m+" bytes, got "+typeof A)}return B&&(I=z(I,v)),dt("private key",I,Q,v),I}function E(A){if(!(A instanceof y))throw new Error("ProjectivePoint expected")}let L=me((A,u)=>{let{px:m,py:B,pz:v}=A;if(e.eql(v,e.ONE))return{x:m,y:B};let I=A.is0();u==null&&(u=I?e.ONE:e.inv(v));let D=e.mul(m,u),O=e.mul(B,u),U=e.mul(v,u);if(I)return{x:e.ZERO,y:e.ZERO};if(!e.eql(U,e.ONE))throw new Error("invZ was invalid");return{x:D,y:O}}),S=me(A=>{if(A.is0()){if(t.allowInfinityPoint&&!e.is0(A.py))return;throw new Error("bad point: ZERO")}let{x:u,y:m}=A.toAffine();if(!e.isValid(u)||!e.isValid(m))throw new Error("bad point: x or y not FE");if(!a(u,m))throw new Error("bad point: equation left != right");if(!A.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class y{constructor(u,m,B){if(u==null||!e.isValid(u))throw new Error("x required");if(m==null||!e.isValid(m)||e.is0(m))throw new Error("y required");if(B==null||!e.isValid(B))throw new Error("z required");this.px=u,this.py=m,this.pz=B,Object.freeze(this)}static fromAffine(u){let{x:m,y:B}=u||{};if(!u||!e.isValid(m)||!e.isValid(B))throw new Error("invalid affine point");if(u instanceof y)throw new Error("projective point not allowed");let v=I=>e.eql(I,e.ZERO);return v(m)&&v(B)?y.ZERO:new y(m,B,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(u){let m=ye(e,u.map(B=>B.pz));return u.map((B,v)=>B.toAffine(m[v])).map(y.fromAffine)}static fromHex(u){let m=y.fromAffine(s(F("pointHex",u)));return m.assertValidity(),m}static fromPrivateKey(u){return y.BASE.multiply(l(u))}static msm(u,m){return ir(y,n,u,m)}_setWindowSize(u){q.setWindowSize(this,u)}assertValidity(){S(this)}hasEvenY(){let{y:u}=this.toAffine();if(e.isOdd)return!e.isOdd(u);throw new Error("Field doesn't support isOdd")}equals(u){E(u);let{px:m,py:B,pz:v}=this,{px:I,py:D,pz:O}=u,U=e.eql(e.mul(m,O),e.mul(I,v)),K=e.eql(e.mul(B,O),e.mul(D,v));return U&&K}negate(){return new y(this.px,e.neg(this.py),this.pz)}double(){let{a:u,b:m}=t,B=e.mul(m,Tn),{px:v,py:I,pz:D}=this,O=e.ZERO,U=e.ZERO,K=e.ZERO,T=e.mul(v,v),Y=e.mul(I,I),g=e.mul(D,D),b=e.mul(v,I);return b=e.add(b,b),K=e.mul(v,D),K=e.add(K,K),O=e.mul(u,K),U=e.mul(B,g),U=e.add(O,U),O=e.sub(Y,U),U=e.add(Y,U),U=e.mul(O,U),O=e.mul(b,O),K=e.mul(B,K),g=e.mul(u,g),b=e.sub(T,g),b=e.mul(u,b),b=e.add(b,K),K=e.add(T,T),T=e.add(K,T),T=e.add(T,g),T=e.mul(T,b),U=e.add(U,T),g=e.mul(I,D),g=e.add(g,g),T=e.mul(g,b),O=e.sub(O,T),K=e.mul(g,Y),K=e.add(K,K),K=e.add(K,K),new y(O,U,K)}add(u){E(u);let{px:m,py:B,pz:v}=this,{px:I,py:D,pz:O}=u,U=e.ZERO,K=e.ZERO,T=e.ZERO,Y=t.a,g=e.mul(t.b,Tn),b=e.mul(m,I),_=e.mul(B,D),x=e.mul(v,O),h=e.add(m,B),p=e.add(I,D);h=e.mul(h,p),p=e.add(b,_),h=e.sub(h,p),p=e.add(m,v);let w=e.add(I,O);return p=e.mul(p,w),w=e.add(b,x),p=e.sub(p,w),w=e.add(B,v),U=e.add(D,O),w=e.mul(w,U),U=e.add(_,x),w=e.sub(w,U),T=e.mul(Y,p),U=e.mul(g,x),T=e.add(U,T),U=e.sub(_,T),T=e.add(_,T),K=e.mul(U,T),_=e.add(b,b),_=e.add(_,b),x=e.mul(Y,x),p=e.mul(g,p),_=e.add(_,x),x=e.sub(b,x),x=e.mul(Y,x),p=e.add(p,x),b=e.mul(_,p),K=e.add(K,b),b=e.mul(w,p),U=e.mul(h,U),U=e.sub(U,b),b=e.mul(h,_),T=e.mul(w,T),T=e.add(T,b),new y(U,K,T)}subtract(u){return this.add(u.negate())}is0(){return this.equals(y.ZERO)}wNAF(u){return q.wNAFCached(this,u,y.normalizeZ)}multiplyUnsafe(u){let{endo:m,n:B}=t;dt("scalar",u,Kt,B);let v=y.ZERO;if(u===Kt)return v;if(this.is0()||u===Q)return this;if(!m||q.hasPrecomputes(this))return q.wNAFCachedUnsafe(this,u,y.normalizeZ);let{k1neg:I,k1:D,k2neg:O,k2:U}=m.splitScalar(u),K=v,T=v,Y=this;for(;D>Kt||U>Kt;)D&Q&&(K=K.add(Y)),U&Q&&(T=T.add(Y)),Y=Y.double(),D>>=Q,U>>=Q;return I&&(K=K.negate()),O&&(T=T.negate()),T=new y(e.mul(T.px,m.beta),T.py,T.pz),K.add(T)}multiply(u){let{endo:m,n:B}=t;dt("scalar",u,Q,B);let v,I;if(m){let{k1neg:D,k1:O,k2neg:U,k2:K}=m.splitScalar(u),{p:T,f:Y}=this.wNAF(O),{p:g,f:b}=this.wNAF(K);T=q.constTimeNegate(D,T),g=q.constTimeNegate(U,g),g=new y(e.mul(g.px,m.beta),g.py,g.pz),v=T.add(g),I=Y.add(b)}else{let{p:D,f:O}=this.wNAF(u);v=D,I=O}return y.normalizeZ([v,I])[0]}multiplyAndAddUnsafe(u,m,B){let v=y.BASE,I=(O,U)=>U===Kt||U===Q||!O.equals(v)?O.multiplyUnsafe(U):O.multiply(U),D=I(this,m).add(I(u,B));return D.is0()?void 0:D}toAffine(u){return L(this,u)}isTorsionFree(){let{h:u,isTorsionFree:m}=t;if(u===Q)return!0;if(m)return m(y,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:u,clearCofactor:m}=t;return u===Q?this:m?m(y,this):this.multiplyUnsafe(t.h)}toRawBytes(u=!0){return Bt("isCompressed",u),this.assertValidity(),o(y,this,u)}toHex(u=!0){return Bt("isCompressed",u),qt(this.toRawBytes(u))}}y.BASE=new y(t.Gx,t.Gy,e.ONE),y.ZERO=new y(e.ZERO,e.ONE,e.ZERO);let{endo:R,nBitLength:P}=t,q=sr(y,R?Math.ceil(P/2):P);return{CURVE:t,ProjectivePoint:y,normPrivateKeyToScalar:l,weierstrassEquation:i,isWithinCurveOrder:f}}function $c(r){let t=Pe(r);return Dt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function xs(r){let t=$c(r),{Fp:e,n,nByteLength:o,nBitLength:s}=t,i=e.BYTES+1,a=2*e.BYTES+1;function c(g){return z(g,n)}function d(g){return or(g,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:l,weierstrassEquation:E,isWithinCurveOrder:L}=Xc({...t,toBytes(g,b,_){let x=b.toAffine(),h=e.toBytes(x.x),p=Vt;return Bt("isCompressed",_),_?p(Uint8Array.from([b.hasEvenY()?2:3]),h):p(Uint8Array.from([4]),h,e.toBytes(x.y))},fromBytes(g){let b=g.length,_=g[0],x=g.subarray(1);if(b===i&&(_===2||_===3)){let h=Tt(x);if(!nr(h,Q,e.ORDER))throw new Error("Point is not on curve");let p=E(h),w;try{w=e.sqrt(p)}catch(k){let H=k instanceof Error?": "+k.message:"";throw new Error("Point is not on curve"+H)}let C=(w&Q)===Q;return(_&1)===1!==C&&(w=e.neg(w)),{x:h,y:w}}else if(b===a&&_===4){let h=e.fromBytes(x.subarray(0,e.BYTES)),p=e.fromBytes(x.subarray(e.BYTES,2*e.BYTES));return{x:h,y:p}}else{let h=i,p=a;throw new Error("invalid Point, expected length of "+h+", or uncompressed "+p+", got "+b)}}});function S(g){let b=n>>Q;return g>b}function y(g){return S(g)?c(-g):g}let R=(g,b,_)=>Tt(g.slice(b,_));class P{constructor(b,_,x){dt("r",b,Q,n),dt("s",_,Q,n),this.r=b,this.s=_,x!=null&&(this.recovery=x),Object.freeze(this)}static fromCompact(b){let _=o;return b=F("compactSignature",b,_*2),new P(R(b,0,_),R(b,_,2*_))}static fromDER(b){let{r:_,s:x}=Pt.toSig(F("DER",b));return new P(_,x)}assertValidity(){}addRecoveryBit(b){return new P(this.r,this.s,b)}recoverPublicKey(b){let{r:_,s:x,recovery:h}=this,p=v(F("msgHash",b));if(h==null||![0,1,2,3].includes(h))throw new Error("recovery id invalid");let w=h===2||h===3?_+t.n:_;if(w>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let C=(h&1)===0?"02":"03",N=f.fromHex(C+Cn(w,e.BYTES)),k=d(w),H=c(-p*k),M=c(x*k),V=f.BASE.multiplyAndAddUnsafe(N,H,M);if(!V)throw new Error("point at infinify");return V.assertValidity(),V}hasHighS(){return S(this.s)}normalizeS(){return this.hasHighS()?new P(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return Re(this.toDERHex())}toDERHex(){return Pt.hexFromSig(this)}toCompactRawBytes(){return Re(this.toCompactHex())}toCompactHex(){let b=o;return Cn(this.r,b)+Cn(this.s,b)}}let q={isValidPrivateKey(g){try{return l(g),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let g=cn(t.n);return Vo(t.randomBytes(g),t.n)},precompute(g=8,b=f.BASE){return b._setWindowSize(g),b.multiply(BigInt(3)),b}};function A(g,b=!0){return f.fromPrivateKey(g).toRawBytes(b)}function u(g){if(typeof g=="bigint")return!1;if(g instanceof f)return!0;let _=F("key",g).length,x=e.BYTES,h=x+1,p=2*x+1;if(!(t.allowedPrivateKeyLengths||o===h))return _===h||_===p}function m(g,b,_=!0){if(u(g)===!0)throw new Error("first arg must be private key");if(u(b)===!1)throw new Error("second arg must be public key");return f.fromHex(b).multiply(l(g)).toRawBytes(_)}let B=t.bits2int||function(g){if(g.length>8192)throw new Error("input is too large");let b=Tt(g),_=g.length*8-s;return _>0?b>>BigInt(_):b},v=t.bits2int_modN||function(g){return c(B(g))},I=Jt(s);function D(g){return dt("num < 2^"+s,g,Kt,I),$t(g,o)}function O(g,b,_=U){if(["recovered","canonical"].some(Z=>Z in _))throw new Error("sign() legacy options not supported");let{hash:x,randomBytes:h}=t,{lowS:p,prehash:w,extraEntropy:C}=_;p==null&&(p=!0),g=F("msgHash",g),ys(_),w&&(g=F("prehashed msgHash",x(g)));let N=v(g),k=l(b),H=[D(k),D(N)];if(C!=null&&C!==!1){let Z=C===!0?h(e.BYTES):C;H.push(F("extraEntropy",Z))}let M=Vt(...H),V=N;function W(Z){let tt=B(Z);if(!L(tt))return;let at=d(tt),$=f.BASE.multiply(tt).toAffine(),rt=c($.x);if(rt===Kt)return;let ft=c(at*c(V+rt*k));if(ft===Kt)return;let xt=($.x===rt?0:2)|Number($.y&Q),ge=ft;return p&&S(ft)&&(ge=y(ft),xt^=1),new P(rt,ge,xt)}return{seed:M,k2sig:W}}let U={lowS:t.lowS,prehash:!1},K={lowS:t.lowS,prehash:!1};function T(g,b,_=U){let{seed:x,k2sig:h}=O(g,b,_),p=t;return Po(p.hash.outputLen,p.nByteLength,p.hmac)(x,h)}f.BASE._setWindowSize(8);function Y(g,b,_,x=K){let h=g;b=F("msgHash",b),_=F("publicKey",_);let{lowS:p,prehash:w,format:C}=x;if(ys(x),"strict"in x)throw new Error("options.strict was renamed to lowS");if(C!==void 0&&C!=="compact"&&C!=="der")throw new Error("format must be compact or der");let N=typeof h=="string"||de(h),k=!N&&!C&&typeof h=="object"&&h!==null&&typeof h.r=="bigint"&&typeof h.s=="bigint";if(!N&&!k)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let H,M;try{if(k&&(H=new P(h.r,h.s)),N){try{C!=="compact"&&(H=P.fromDER(h))}catch(xt){if(!(xt instanceof Pt.Err))throw xt}!H&&C!=="der"&&(H=P.fromCompact(h))}M=f.fromHex(_)}catch{return!1}if(!H||p&&H.hasHighS())return!1;w&&(b=t.hash(b));let{r:V,s:W}=H,Z=v(b),tt=d(W),at=c(Z*tt),$=c(V*tt),rt=f.BASE.multiplyAndAddUnsafe(M,at,$)?.toAffine();return rt?c(rt.x)===V:!1}return{CURVE:t,getPublicKey:A,getSharedSecret:m,sign:T,verify:Y,ProjectivePoint:f,Signature:P,utils:q}}function Jc(r){return{hash:r,hmac:(t,...e)=>Un(r,t,Zr(...e)),randomBytes:er}}function bs(r,t){let e=n=>xs({...r,...Jc(n)});return{...e(t),create:e}}var Es=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),gs=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Qc=BigInt(0),ta=BigInt(1),Rn=BigInt(2),ws=(r,t)=>(r+t/Rn)/t;function ea(r){let t=Es,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),d=r*r*r%t,f=d*d*r%t,l=j(f,e,t)*f%t,E=j(l,e,t)*f%t,L=j(E,Rn,t)*d%t,S=j(L,o,t)*L%t,y=j(S,s,t)*S%t,R=j(y,a,t)*y%t,P=j(R,c,t)*R%t,q=j(P,a,t)*y%t,A=j(q,e,t)*f%t,u=j(A,i,t)*S%t,m=j(u,n,t)*d%t,B=j(m,Rn,t);if(!Pn.eql(Pn.sqr(B),r))throw new Error("Cannot find square root");return B}var Pn=Rt(Es,void 0,void 0,{sqrt:ea}),be=bs({a:Qc,b:BigInt(7),Fp:Pn,n:gs,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=gs,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-ta*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),a=ws(s*r,t),c=ws(-n*r,t),d=z(r-a*e-c*o,t),f=z(-a*n-c*s,t),l=d>i,E=f>i;if(l&&(d=t-d),E&&(f=t-f),d>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:d,k2neg:E,k2:f}}}},Lo);function As(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Ss(r,t,e,n){let o=ve.digest(e instanceof Uint8Array?e:e.subarray());if(As(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),be.verify(t,s,r))).catch(s=>{throw s.name==="AbortError"?s:new He(String(s))});try{return n?.signal?.throwIfAborted(),be.verify(t,o.digest,r)}catch(s){throw new He(String(s))}}var yr=class{type="secp256k1";raw;_key;constructor(t){this._key=vs(t),this.raw=Bs(this._key)}toMultihash(){return bt.digest(ue(this))}toCID(){return ot.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:gt(this.raw,t.raw)}verify(t,e,n){return Ss(this._key,e,t,n)}};function Is(r){return new yr(r)}function Bs(r){return be.ProjectivePoint.fromHex(r).toRawBytes(!0)}function vs(r){try{return be.ProjectivePoint.fromHex(r),r}catch(t){throw new je(String(t))}}function Ls(r){let{Type:t,Data:e}=ke.decode(r.digest),n=e??new Uint8Array;switch(t){case mt.Ed25519:return es(n);case mt.secp256k1:return Is(n);case mt.ECDSA:return fo(n);default:throw new re}}function ue(r){return ke.encode({Type:mt[r.type],Data:r.raw})}var _s=Symbol.for("nodejs.util.inspect.custom"),ra=114,Me=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()})`}[br]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ot.createV1(ra,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return gt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return gt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[_s](){return`PeerId(${this.toString()})`}},qe=class extends Me{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Ve=class extends Me{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},ze=class extends Me{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},na=2336,Fe=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=bt.digest(Ot(this.url))}[_s](){return`PeerId(${this.url})`}[br]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ot.createV1(na,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=yt(t)),t.toString()===this.toString())}};var oa=114,Us=2336;function sa(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=Se(X.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return Ts(ot.parse(r));if(t==null)throw new At('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=Se(t.decode(r))}return Kn(e)}function Cs(r){if(r.type==="Ed25519")return new Ve({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new ze({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new qe({multihash:r.toCID().multihash,publicKey:r});throw new re}function ia(r){return Cs(r.publicKey)}function Kn(r){if(aa(r))return new qe({multihash:r});if(ca(r))try{let t=Ls(r);if(t.type==="Ed25519")return new Ve({multihash:r,publicKey:t});if(t.type==="secp256k1")return new ze({multihash:r,publicKey:t})}catch{let e=yt(r.digest);return new Fe(new URL(e))}throw new Ze("Supplied PeerID Multihash is invalid")}function Ts(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==oa&&r.code!==Us)throw new Ge("Supplied PeerID CID is invalid");if(r.code===Us){let t=yt(r.multihash.digest);return new Fe(new URL(t))}return Kn(r.multihash)}function ca(r){return r.code===bt.code}function aa(r){return r.code===ve.code}return Ms(fa);})();
2
+ "use strict";var Libp2PPeerId=(()=>{var wr=Object.defineProperty;var Ms=Object.getOwnPropertyDescriptor;var qs=Object.getOwnPropertyNames;var Vs=Object.prototype.hasOwnProperty;var ut=(r,t)=>{for(var e in t)wr(r,e,{get:t[e],enumerable:!0})},zs=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of qs(t))!Vs.call(r,o)&&o!==e&&wr(r,o,{get:()=>t[o],enumerable:!(n=Ms(t,o))||n.enumerable});return r};var Fs=r=>zs(wr({},"__esModule",{value:!0}),r);var yc={};ut(yc,{peerIdFromCID:()=>Ks,peerIdFromMultihash:()=>Hn,peerIdFromPrivateKey:()=>dc,peerIdFromPublicKey:()=>Rs,peerIdFromString:()=>lc});var Er=Symbol.for("@libp2p/peer-id");var At=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},je=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Ge=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Ze=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var re=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Ir={};ut(Ir,{base58btc:()=>X,base58flickr:()=>$s});var wc=new Uint8Array(0);function qn(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 It(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 Vn(r){return new TextEncoder().encode(r)}function zn(r){return new TextDecoder().decode(r)}function js(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),d=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function l(S){if(S instanceof Uint8Array||(ArrayBuffer.isView(S)?S=new Uint8Array(S.buffer,S.byteOffset,S.byteLength):Array.isArray(S)&&(S=Uint8Array.from(S))),!(S instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(S.length===0)return"";for(var y=0,P=0,R=0,q=S.length;R!==q&&S[R]===0;)R++,y++;for(var A=(q-R)*f+1>>>0,u=new Uint8Array(A);R!==q;){for(var m=S[R],B=0,v=A-1;(m!==0||B<P)&&v!==-1;v--,B++)m+=256*u[v]>>>0,u[v]=m%c>>>0,m=m/c>>>0;if(m!==0)throw new Error("Non-zero carry");P=B,R++}for(var I=A-P;I!==A&&u[I]===0;)I++;for(var D=a.repeat(y);I<A;++I)D+=r.charAt(u[I]);return D}function E(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var y=0;if(S[y]!==" "){for(var P=0,R=0;S[y]===a;)P++,y++;for(var q=(S.length-y)*d+1>>>0,A=new Uint8Array(q);S[y];){var u=e[S.charCodeAt(y)];if(u===255)return;for(var m=0,B=q-1;(u!==0||m<R)&&B!==-1;B--,m++)u+=c*A[B]>>>0,A[B]=u%256>>>0,u=u/256>>>0;if(u!==0)throw new Error("Non-zero carry");R=m,y++}if(S[y]!==" "){for(var v=q-R;v!==q&&A[v]===0;)v++;for(var I=new Uint8Array(P+(q-v)),D=P;v!==q;)I[D++]=A[v++];return I}}}function L(S){var y=E(S);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:E,decode:L}}var Gs=js,Zs=Gs,jn=Zs;var Ar=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")}},Sr=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 Gn(this,t)}},Br=class{decoders;constructor(t){this.decoders=t}or(t){return Gn(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 Gn(r,t){return new Br({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var vr=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 Ar(t,e,n),this.decoder=new Sr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ne({name:r,prefix:t,encode:e,decode:n}){return new vr(r,t,e,n)}function Nt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=jn(e,r);return ne({prefix:t,name:r,encode:n,decode:s=>It(o(s))})}function Ys(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,c=0,a=0;for(let d=0;d<o;++d){let f=t[r[d]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|f,i+=e,i>=8&&(i-=8,s[a++]=255&c>>i)}if(i>=e||(255&c<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function Ws(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 Xs(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function G({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=Xs(n);return ne({prefix:t,name:r,encode(s){return Ws(s,n,e)},decode(s){return Ys(s,o,e,r)}})}var X=Nt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),$s=Nt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Lr={};ut(Lr,{base32:()=>oe,base32hex:()=>ei,base32hexpad:()=>ni,base32hexpadupper:()=>oi,base32hexupper:()=>ri,base32pad:()=>Qs,base32padupper:()=>ti,base32upper:()=>Js,base32z:()=>si});var oe=G({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Js=G({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Qs=G({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ti=G({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ei=G({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ri=G({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ni=G({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),oi=G({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),si=G({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var _r={};ut(_r,{base36:()=>we,base36upper:()=>ii});var we=Nt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ii=Nt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ai=Wn,Zn=128,ci=127,fi=~ci,ui=Math.pow(2,31);function Wn(r,t,e){t=t||[],e=e||0;for(var n=e;r>=ui;)t[e++]=r&255|Zn,r/=128;for(;r&fi;)t[e++]=r&255|Zn,r>>>=7;return t[e]=r|0,Wn.bytes=e-n+1,t}var hi=Ur,li=128,Yn=127;function Ur(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw Ur.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&Yn)<<o:(i&Yn)*Math.pow(2,o),o+=7}while(i>=li);return Ur.bytes=s-n,e}var di=Math.pow(2,7),pi=Math.pow(2,14),mi=Math.pow(2,21),yi=Math.pow(2,28),bi=Math.pow(2,35),xi=Math.pow(2,42),gi=Math.pow(2,49),wi=Math.pow(2,56),Ei=Math.pow(2,63),Ai=function(r){return r<di?1:r<pi?2:r<mi?3:r<yi?4:r<bi?5:r<xi?6:r<gi?7:r<wi?8:r<Ei?9:10},Si={encode:ai,decode:hi,encodingLength:Ai},Bi=Si,Ee=Bi;function Ae(r,t=0){return[Ee.decode(r,t),Ee.decode.bytes]}function se(r,t,e=0){return Ee.encode(r,t,e),t}function ie(r){return Ee.encodingLength(r)}function jt(r,t){let e=t.byteLength,n=ie(r),o=n+ie(e),s=new Uint8Array(o+e);return se(r,s,0),se(e,s,n),s.set(t,o),new ae(r,e,t,s)}function Se(r){let t=It(r),[e,n]=Ae(t),[o,s]=Ae(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ae(e,o,i,t)}function Xn(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&qn(r.bytes,e.bytes)}}var ae=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function $n(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Ii(e,Cr(r),t??X.encoder);default:return Li(e,Cr(r),t??oe.encoder)}}var Jn=new WeakMap;function Cr(r){let t=Jn.get(r);if(t==null){let e=new Map;return Jn.set(r,e),e}return t}var ot=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Be)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==_i)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=jt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Xn(t.multihash,n.multihash)}toString(t){return $n(this,t)}toJSON(){return{"/":$n(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??Qn(n,o,s.bytes))}else if(e[Ui]===!0){let{version:n,multihash:o,code:s}=e,i=Se(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!==Be)throw new Error(`Version 0 CID must use dag-pb (code: ${Be}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Qn(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Be,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=It(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 ae(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,E]=Ae(t.subarray(e));return e+=E,l},o=n(),s=Be;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(),d=e+a,f=d-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:f,size:d}}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 Cr(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 oe.prefix:{let e=t??oe;return[oe.prefix,e.decode(r)]}case we.prefix:{let e=t??we;return[we.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 Ii(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 Li(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 Be=112,_i=18;function Qn(r,t,e){let n=ie(r),o=n+ie(t),s=new Uint8Array(o+e.byteLength);return se(r,s,0),se(t,s,n),s.set(e,o),s}var Ui=Symbol.for("@ipld/js-cid/CID");var Tr={};ut(Tr,{identity:()=>xt});var to=0,Ci="identity",eo=It;function Ti(r){return jt(to,eo(r))}var xt={code:to,name:Ci,encode:eo,digest:Ti};function gt(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 Lt(r=0){return new Uint8Array(r)}function ht(r=0){return new Uint8Array(r)}function We(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=ht(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var no=Symbol.for("@achingbrain/uint8arraylist");function ro(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 Xe(r){return!!r?.[no]}var lt=class r{bufs;length;[no]=!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(Xe(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(Xe(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=ro(this.bufs,t);return e.buf[e.index]}set(t,e){let n=ro(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(Xe(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 We(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:We(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 d=t>=c&&t<a,f=e>c&&e<=a;if(d&&f){if(t===c&&e===a){n.push(i);break}let l=t-c;n.push(i.subarray(l,l+(e-t)));break}if(d){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(f){if(e===a){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Xe(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,d=n.byteLength-1,f;for(let l=e;l<=a;l+=f){f=0;for(let E=d;E>=0;E--){let L=this.get(l+E);if(n[E]!==L){f=Math.max(1,E-c[L]);break}}if(f===0)return l}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=ht(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=Lt(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=Lt(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=Lt(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=ht(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=Lt(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=Lt(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=Lt(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=Lt(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=Lt(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(!gt(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 Dr={};ut(Dr,{base10:()=>Di});var Di=Nt({prefix:"9",name:"base10",alphabet:"0123456789"});var Pr={};ut(Pr,{base16:()=>Pi,base16upper:()=>Ri});var Pi=G({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ri=G({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Rr={};ut(Rr,{base2:()=>Ki});var Ki=G({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Kr={};ut(Kr,{base256emoji:()=>Mi});var oo=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}"),Ni=oo.reduce((r,t,e)=>(r[e]=t,r),[]),Oi=oo.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function ki(r){return r.reduce((t,e)=>(t+=Ni[e],t),"")}function Hi(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Oi[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Mi=ne({prefix:"\u{1F680}",name:"base256emoji",encode:ki,decode:Hi});var Nr={};ut(Nr,{base64:()=>qi,base64pad:()=>Vi,base64url:()=>zi,base64urlpad:()=>Fi});var qi=G({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Vi=G({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),zi=G({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Fi=G({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Or={};ut(Or,{base8:()=>ji});var ji=G({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var kr={};ut(kr,{identity:()=>Gi});var Gi=ne({prefix:"\0",name:"identity",encode:r=>zn(r),decode:r=>Vn(r)});var nf=new TextEncoder,of=new TextDecoder;var qr={};ut(qr,{sha256:()=>ve,sha512:()=>Wi});function Mr({name:r,code:t,encode:e}){return new Hr(r,t,e)}var Hr=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?jt(this.code,e):e.then(n=>jt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function io(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var ve=Mr({name:"sha2-256",code:18,encode:io("SHA-256")}),Wi=Mr({name:"sha2-512",code:19,encode:io("SHA-512")});var Vr={...kr,...Rr,...Or,...Dr,...Pr,...Lr,..._r,...Ir,...Nr,...Kr},bf={...qr,...Tr};function co(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var ao=co("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),zr=co("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=ht(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Xi={utf8:ao,"utf-8":ao,hex:Vr.base16,latin1:zr,ascii:zr,binary:zr,...Vr},$e=Xi;function Ot(r,t="utf8"){let e=$e[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function dt(r,t="utf8"){let e=$e[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var $i=parseInt("11111",2),Fr=parseInt("10000000",2),Ji=parseInt("01111111",2),fo={0:Ie,1:Ie,2:Qi,3:ra,4:na,5:ea,6:ta,16:Ie,22:Ie,48:Ie};function jr(r,t={offset:0}){let e=r[t.offset]&$i;if(t.offset++,fo[e]!=null)return fo[e](r,t);throw new Error("No decoder for tag "+e)}function Le(r,t){let e=0;if((r[t.offset]&Fr)===Fr){let n=r[t.offset]&Ji,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 Ie(r,t){Le(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=jr(r,t);if(n===null)break;e.push(n)}return e}function Qi(r,t){let e=Le(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 ta(r,t){let e=Le(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let c=`${s}.${i}`,a=[];for(;t.offset<n;){let d=r[t.offset];if(t.offset++,a.push(d&127),d<128){a.reverse();let f=0;for(let l=0;l<a.length;l++)f+=a[l]<<l*7;c+=`.${f}`,a=[]}}return c}function ea(r,t){return t.offset++,null}function ra(r,t){let e=Le(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function na(r,t){let e=Le(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function oa(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new lt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function Gr(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=oa(r.byteLength);return new lt(Uint8Array.from([t.byteLength|Fr]),t)}function uo(r){let t=new lt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new lt(Uint8Array.from([2]),Gr(t),t)}function ho(r){let t=Uint8Array.from([0]),e=new lt(t,r);return new lt(Uint8Array.from([3]),Gr(e),e)}function Je(r,t=48){let e=new lt;for(let n of r)e.append(n);return new lt(Uint8Array.from([t]),Gr(e),e)}async function lo(r,t,e,n){let o=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,t,e.subarray());return n?.signal?.throwIfAborted(),s}var sa=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),ia=Uint8Array.from([6,5,43,129,4,0,34]),aa=Uint8Array.from([6,5,43,129,4,0,35]),ca={ext:!0,kty:"EC",crv:"P-256"},fa={ext:!0,kty:"EC",crv:"P-384"},ua={ext:!0,kty:"EC",crv:"P-521"},Zr=32,Yr=48,Wr=66;function po(r){let t=jr(r);return mo(t)}function mo(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===Zr*2+1)return n=dt(t.subarray(e,e+Zr),"base64url"),o=dt(t.subarray(e+Zr),"base64url"),new fe({...ca,key_ops:["verify"],x:n,y:o});if(t.byteLength===Yr*2+1)return n=dt(t.subarray(e,e+Yr),"base64url"),o=dt(t.subarray(e+Yr),"base64url"),new fe({...fa,key_ops:["verify"],x:n,y:o});if(t.byteLength===Wr*2+1)return n=dt(t.subarray(e,e+Wr),"base64url"),o=dt(t.subarray(e+Wr),"base64url"),new fe({...ua,key_ops:["verify"],x:n,y:o});throw new At(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function yo(r){return Je([uo(Uint8Array.from([1])),Je([ha(r.crv)],160),Je([ho(new lt(Uint8Array.from([4]),Ot(r.x??"","base64url"),Ot(r.y??"","base64url")))],161)]).subarray()}function ha(r){if(r==="P-256")return sa;if(r==="P-384")return ia;if(r==="P-521")return aa;throw new At(`Invalid curve ${r}`)}var fe=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=yo(this.jwk)),this._raw}toMultihash(){return xt.digest(ue(this))}toCID(){return ot.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:gt(this.raw,t.raw)}async verify(t,e,n){return lo(this.jwk,e,t,n)}};var Gt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function la(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Qe(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Zt(r,...t){if(!la(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 bo(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Qe(r.outputLen),Qe(r.blockLen)}function le(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 xo(r,t){Zt(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function _t(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function tr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function wt(r,t){return r<<32-t|r>>>t}function go(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function _e(r){return typeof r=="string"&&(r=go(r)),Zt(r),r}function Xr(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Zt(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 he=class{};function $r(r){let t=n=>r().update(_e(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function er(r=32){if(Gt&&typeof Gt.getRandomValues=="function")return Gt.getRandomValues(new Uint8Array(r));if(Gt&&typeof Gt.randomBytes=="function")return Uint8Array.from(Gt.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function da(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,d=n?0:4;r.setUint32(t+a,i,n),r.setUint32(t+d,c,n)}function wo(r,t,e){return r&t^~r&e}function Eo(r,t,e){return r&t^r&e^t&e}var Ue=class extends he{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=tr(this.buffer)}update(t){le(this),t=_e(t),Zt(t);let{view:e,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=tr(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){le(this),xo(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,_t(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)e[l]=0;da(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=tr(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=a/4,f=this.get();if(d>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<d;l++)c.setUint32(4*l,f[l],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=c,o%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Ut=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var et=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var rr=BigInt(4294967295),Ao=BigInt(32);function pa(r,t=!1){return t?{h:Number(r&rr),l:Number(r>>Ao&rr)}:{h:Number(r>>Ao&rr)|0,l:Number(r&rr)|0}}function So(r,t=!1){let e=r.length,n=new Uint32Array(e),o=new Uint32Array(e);for(let s=0;s<e;s++){let{h:i,l:c}=pa(r[s],t);[n[s],o[s]]=[i,c]}return[n,o]}var Jr=(r,t,e)=>r>>>e,Qr=(r,t,e)=>r<<32-e|t>>>e,Yt=(r,t,e)=>r>>>e|t<<32-e,Wt=(r,t,e)=>r<<32-e|t>>>e,Ce=(r,t,e)=>r<<64-e|t>>>e-32,Te=(r,t,e)=>r>>>e-32|t<<64-e;function St(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var Bo=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),vo=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Io=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Lo=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,_o=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Uo=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var ya=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),kt=new Uint32Array(64),tn=class extends Ue{constructor(t=32){super(64,t,8,!1),this.A=Ut[0]|0,this.B=Ut[1]|0,this.C=Ut[2]|0,this.D=Ut[3]|0,this.E=Ut[4]|0,this.F=Ut[5]|0,this.G=Ut[6]|0,this.H=Ut[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)kt[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let E=kt[l-15],L=kt[l-2],S=wt(E,7)^wt(E,18)^E>>>3,y=wt(L,17)^wt(L,19)^L>>>10;kt[l]=y+kt[l-7]+S+kt[l-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:d,H:f}=this;for(let l=0;l<64;l++){let E=wt(c,6)^wt(c,11)^wt(c,25),L=f+E+wo(c,a,d)+ya[l]+kt[l]|0,y=(wt(n,2)^wt(n,13)^wt(n,22))+Eo(n,o,s)|0;f=d,d=a,a=c,c=i+L|0,i=s,s=o,o=n,n=L+y|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,d=d+this.G|0,f=f+this.H|0,this.set(n,o,s,i,c,a,d,f)}roundClean(){_t(kt)}destroy(){this.set(0,0,0,0,0,0,0,0),_t(this.buffer)}};var Co=So(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),ba=Co[0],xa=Co[1],Ht=new Uint32Array(80),Mt=new Uint32Array(80),en=class extends Ue{constructor(t=64){super(128,t,16,!1),this.Ah=et[0]|0,this.Al=et[1]|0,this.Bh=et[2]|0,this.Bl=et[3]|0,this.Ch=et[4]|0,this.Cl=et[5]|0,this.Dh=et[6]|0,this.Dl=et[7]|0,this.Eh=et[8]|0,this.El=et[9]|0,this.Fh=et[10]|0,this.Fl=et[11]|0,this.Gh=et[12]|0,this.Gl=et[13]|0,this.Hh=et[14]|0,this.Hl=et[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:d,El:f,Fh:l,Fl:E,Gh:L,Gl:S,Hh:y,Hl:P}=this;return[t,e,n,o,s,i,c,a,d,f,l,E,L,S,y,P]}set(t,e,n,o,s,i,c,a,d,f,l,E,L,S,y,P){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=d|0,this.El=f|0,this.Fh=l|0,this.Fl=E|0,this.Gh=L|0,this.Gl=S|0,this.Hh=y|0,this.Hl=P|0}process(t,e){for(let A=0;A<16;A++,e+=4)Ht[A]=t.getUint32(e),Mt[A]=t.getUint32(e+=4);for(let A=16;A<80;A++){let u=Ht[A-15]|0,m=Mt[A-15]|0,B=Yt(u,m,1)^Yt(u,m,8)^Jr(u,m,7),v=Wt(u,m,1)^Wt(u,m,8)^Qr(u,m,7),I=Ht[A-2]|0,D=Mt[A-2]|0,O=Yt(I,D,19)^Ce(I,D,61)^Jr(I,D,6),U=Wt(I,D,19)^Te(I,D,61)^Qr(I,D,6),K=Io(v,U,Mt[A-7],Mt[A-16]),T=Lo(K,B,O,Ht[A-7],Ht[A-16]);Ht[A]=T|0,Mt[A]=K|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:d,Dl:f,Eh:l,El:E,Fh:L,Fl:S,Gh:y,Gl:P,Hh:R,Hl:q}=this;for(let A=0;A<80;A++){let u=Yt(l,E,14)^Yt(l,E,18)^Ce(l,E,41),m=Wt(l,E,14)^Wt(l,E,18)^Te(l,E,41),B=l&L^~l&y,v=E&S^~E&P,I=_o(q,m,v,xa[A],Mt[A]),D=Uo(I,R,u,B,ba[A],Ht[A]),O=I|0,U=Yt(n,o,28)^Ce(n,o,34)^Ce(n,o,39),K=Wt(n,o,28)^Te(n,o,34)^Te(n,o,39),T=n&s^n&c^s&c,Y=o&i^o&a^i&a;R=y|0,q=P|0,y=L|0,P=S|0,L=l|0,S=E|0,{h:l,l:E}=St(d|0,f|0,D|0,O|0),d=c|0,f=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let g=Bo(O,K,Y);n=vo(g,D,U,T),o=g|0}({h:n,l:o}=St(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=St(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=St(this.Ch|0,this.Cl|0,c|0,a|0),{h:d,l:f}=St(this.Dh|0,this.Dl|0,d|0,f|0),{h:l,l:E}=St(this.Eh|0,this.El|0,l|0,E|0),{h:L,l:S}=St(this.Fh|0,this.Fl|0,L|0,S|0),{h:y,l:P}=St(this.Gh|0,this.Gl|0,y|0,P|0),{h:R,l:q}=St(this.Hh|0,this.Hl|0,R|0,q|0),this.set(n,o,s,i,c,a,d,f,l,E,L,S,y,P,R,q)}roundClean(){_t(Ht,Mt)}destroy(){_t(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var To=$r(()=>new tn);var Do=$r(()=>new en);var sn=BigInt(0),on=BigInt(1);function de(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function an(r){if(!de(r))throw new Error("Uint8Array expected")}function Bt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function De(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Ko(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?sn:BigInt("0x"+r)}var No=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",ga=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function qt(r){if(an(r),No)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=ga[r[e]];return t}var Ct={_0:48,_9:57,A:65,F:70,a:97,f:102};function Po(r){if(r>=Ct._0&&r<=Ct._9)return r-Ct._0;if(r>=Ct.A&&r<=Ct.F)return r-(Ct.A-10);if(r>=Ct.a&&r<=Ct.f)return r-(Ct.a-10)}function Pe(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(No)return Uint8Array.fromHex(r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=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 Tt(r){return Ko(qt(r))}function Xt(r){return an(r),Ko(qt(Uint8Array.from(r).reverse()))}function $t(r,t){return Pe(r.toString(16).padStart(t*2,"0"))}function pe(r,t){return $t(r,t).reverse()}function F(r,t,e){let n;if(typeof t=="string")try{n=Pe(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(de(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 Vt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];an(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 rn=r=>typeof r=="bigint"&&sn<=r;function nr(r,t,e){return rn(r)&&rn(t)&&rn(e)&&t<=r&&r<e}function pt(r,t,e,n){if(!nr(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Oo(r){let t;for(t=0;r>sn;r>>=on,t+=1);return t}var Jt=r=>(on<<BigInt(r))-on,nn=r=>new Uint8Array(r),Ro=r=>Uint8Array.from(r);function ko(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=nn(r),o=nn(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...l)=>e(o,n,...l),a=(l=nn(0))=>{o=c(Ro([0]),l),n=c(),l.length!==0&&(o=c(Ro([1]),l),n=c())},d=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,E=[];for(;l<t;){n=c();let L=n.slice();E.push(L),l+=n.length}return Vt(...E)};return(l,E)=>{i(),a(l);let L;for(;!(L=E(d()));)a();return i(),L}}var wa={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"||de(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 Dt(r,t,e={}){let n=(o,s,i)=>{let c=wa[s];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(i&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+a)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}function me(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var st=BigInt(0),J=BigInt(1),Qt=BigInt(2),Ea=BigInt(3),Mo=BigInt(4),qo=BigInt(5),Vo=BigInt(8);function z(r,t){let e=r%t;return e>=st?e:t+e}function j(r,t,e){let n=r;for(;t-- >st;)n*=n,n%=e;return n}function or(r,t){if(r===st)throw new Error("invert: expected non-zero number");if(t<=st)throw new Error("invert: expected positive modulus, got "+t);let e=z(r,t),n=t,o=st,s=J,i=J,c=st;for(;e!==st;){let d=n/e,f=n%e,l=o-i*d,E=s-c*d;n=e,e=f,o=i,s=c,i=l,c=E}if(n!==J)throw new Error("invert: does not exist");return z(o,t)}function zo(r,t){let e=(r.ORDER+J)/Mo,n=r.pow(t,e);if(!r.eql(r.sqr(n),t))throw new Error("Cannot find square root");return n}function Aa(r,t){let e=(r.ORDER-qo)/Vo,n=r.mul(t,Qt),o=r.pow(n,e),s=r.mul(t,o),i=r.mul(r.mul(s,Qt),o),c=r.mul(s,r.sub(i,r.ONE));if(!r.eql(r.sqr(c),t))throw new Error("Cannot find square root");return c}function Sa(r){if(r<BigInt(3))throw new Error("sqrt is not defined for small field");let t=r-J,e=0;for(;t%Qt===st;)t/=Qt,e++;let n=Qt,o=Pt(r);for(;Ho(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return zo;let s=o.pow(n,t),i=(t+J)/Qt;return function(a,d){if(a.is0(d))return d;if(Ho(a,d)!==1)throw new Error("Cannot find square root");let f=e,l=a.mul(a.ONE,s),E=a.pow(d,t),L=a.pow(d,i);for(;!a.eql(E,a.ONE);){if(a.is0(E))return a.ZERO;let S=1,y=a.sqr(E);for(;!a.eql(y,a.ONE);)if(S++,y=a.sqr(y),S===f)throw new Error("Cannot find square root");let P=J<<BigInt(f-S-1),R=a.pow(l,P);f=S,l=a.sqr(R),E=a.mul(E,l),L=a.mul(L,R)}return L}}function Ba(r){return r%Mo===Ea?zo:r%Vo===qo?Aa:Sa(r)}var Fo=(r,t)=>(z(r,t)&J)===J,va=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function cn(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=va.reduce((n,o)=>(n[o]="function",n),t);return Dt(r,e)}function Ia(r,t,e){if(e<st)throw new Error("invalid exponent, negatives unsupported");if(e===st)return r.ONE;if(e===J)return t;let n=r.ONE,o=t;for(;e>st;)e&J&&(n=r.mul(n,o)),o=r.sqr(o),e>>=J;return n}function ye(r,t,e=!1){let n=new Array(t.length).fill(e?r.ZERO:void 0),o=t.reduce((i,c,a)=>r.is0(c)?i:(n[a]=i,r.mul(i,c)),r.ONE),s=r.inv(o);return t.reduceRight((i,c,a)=>r.is0(c)?i:(n[a]=r.mul(i,n[a]),r.mul(i,c)),s),n}function Ho(r,t){let e=(r.ORDER-J)/Qt,n=r.pow(t,e),o=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),i=r.eql(n,r.neg(r.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function fn(r,t){t!==void 0&&Qe(t);let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Pt(r,t,e=!1,n={}){if(r<=st)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=fn(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:Jt(o),ZERO:st,ONE:J,create:a=>z(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return st<=a&&a<r},is0:a=>a===st,isOdd:a=>(a&J)===J,neg:a=>z(-a,r),eql:(a,d)=>a===d,sqr:a=>z(a*a,r),add:(a,d)=>z(a+d,r),sub:(a,d)=>z(a-d,r),mul:(a,d)=>z(a*d,r),pow:(a,d)=>Ia(c,a,d),div:(a,d)=>z(a*or(d,r),r),sqrN:a=>a*a,addN:(a,d)=>a+d,subN:(a,d)=>a-d,mulN:(a,d)=>a*d,inv:a=>or(a,r),sqrt:n.sqrt||(a=>(i||(i=Ba(r)),i(c,a))),toBytes:a=>e?pe(a,s):$t(a,s),fromBytes:a=>{if(a.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+a.length);return e?Xt(a):Tt(a)},invertBatch:a=>ye(c,a),cmov:(a,d,f)=>f?d:a});return Object.freeze(c)}function jo(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 un(r){let t=jo(r);return t+Math.ceil(t/2)}function Go(r,t,e=!1){let n=r.length,o=jo(t),s=un(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?Xt(r):Tt(r),c=z(i,t-J)+J;return e?pe(c,o):$t(c,o)}var Zo=BigInt(0),mn=BigInt(1);function hn(r,t){let e=t.negate();return r?e:t}function Wo(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function ln(r,t){Wo(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=Jt(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function Yo(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,c=Number(r&o),a=r>>i;c>n&&(c-=s,a+=mn);let d=t*n,f=d+Math.abs(c)-1,l=c===0,E=c<0,L=t%2!==0;return{nextN:a,offset:f,isZero:l,isNeg:E,isNegF:L,offsetF:d}}function La(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 _a(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 dn=new WeakMap,Xo=new WeakMap;function pn(r){return Xo.get(r)||1}function sr(r,t){return{constTimeNegate:hn,hasPrecomputes(e){return pn(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Zo;)n&mn&&(o=o.add(s)),s=s.double(),n>>=mn;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=ln(n,t),i=[],c=e,a=c;for(let d=0;d<o;d++){a=c,i.push(a);for(let f=1;f<s;f++)a=a.add(c),i.push(a);c=a.double()}return i},wNAF(e,n,o){let s=r.ZERO,i=r.BASE,c=ln(e,t);for(let a=0;a<c.windows;a++){let{nextN:d,offset:f,isZero:l,isNeg:E,isNegF:L,offsetF:S}=Yo(o,a,c);o=d,l?i=i.add(hn(L,n[S])):s=s.add(hn(E,n[f]))}return{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=ln(e,t);for(let c=0;c<i.windows&&o!==Zo;c++){let{nextN:a,offset:d,isZero:f,isNeg:l}=Yo(o,c,i);if(o=a,!f){let E=n[d];s=s.add(l?E.negate():E)}}return s},getPrecomputes(e,n,o){let s=dn.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&dn.set(n,o(s))),s},wNAFCached(e,n,o){let s=pn(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=pn(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){Wo(n,t),Xo.set(e,n),dn.delete(e)}}}function ir(r,t,e,n){La(e,r),_a(n,t);let o=e.length,s=n.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");let i=r.ZERO,c=Oo(BigInt(o)),a=1;c>12?a=c-3:c>4?a=c-2:c>0&&(a=2);let d=Jt(a),f=new Array(Number(d)+1).fill(i),l=Math.floor((t.BITS-1)/a)*a,E=i;for(let L=l;L>=0;L-=a){f.fill(i);for(let y=0;y<s;y++){let P=n[y],R=Number(P>>BigInt(L)&d);f[R]=f[R].add(e[y])}let S=i;for(let y=f.length-1,P=i;y>0;y--)P=P.add(f[y]),S=S.add(P);if(E=E.add(S),L!==0)for(let y=0;y<a;y++)E=E.double()}return E}function Re(r){return cn(r.Fp),Dt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...fn(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var vt=BigInt(0),it=BigInt(1),$o=BigInt(2),Ua=BigInt(8),Ca={zip215:!0};function Ta(r){let t=Re(r);return Dt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Jo(r){let t=Ta(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:c,h:a}=t,d=$o<<BigInt(c*8)-it,f=e.create,l=Pt(t.n,t.nBitLength);function E(b,h){let p=e.sqr(b),w=e.sqr(h),C=e.add(e.mul(t.a,p),w),N=e.add(e.ONE,e.mul(t.d,e.mul(p,w)));return e.eql(C,N)}if(!E(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let L=t.uvRatio||((b,h)=>{try{return{isValid:!0,value:e.sqrt(b*e.inv(h))}}catch{return{isValid:!1,value:vt}}}),S=t.adjustScalarBytes||(b=>b),y=t.domain||((b,h,p)=>{if(Bt("phflag",p),h.length||p)throw new Error("Contexts/pre-hash are not supported");return b});function P(b,h,p=!1){let w=p?it:vt;pt("coordinate "+b,h,w,d)}function R(b){if(!(b instanceof u))throw new Error("ExtendedPoint expected")}let q=me((b,h)=>{let{ex:p,ey:w,ez:C}=b,N=b.is0();h==null&&(h=N?Ua:e.inv(C));let k=f(p*h),H=f(w*h),M=f(C*h);if(N)return{x:vt,y:it};if(M!==it)throw new Error("invZ was invalid");return{x:k,y:H}}),A=me(b=>{let{a:h,d:p}=t;if(b.is0())throw new Error("bad point: ZERO");let{ex:w,ey:C,ez:N,et:k}=b,H=f(w*w),M=f(C*C),V=f(N*N),W=f(V*V),Z=f(H*h),tt=f(V*f(Z+M)),ct=f(W+f(p*f(H*M)));if(tt!==ct)throw new Error("bad point: equation left != right (1)");let $=f(w*C),rt=f(N*k);if($!==rt)throw new Error("bad point: equation left != right (2)");return!0});class u{constructor(h,p,w,C){P("x",h),P("y",p),P("z",w,!0),P("t",C),this.ex=h,this.ey=p,this.ez=w,this.et=C,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(h){if(h instanceof u)throw new Error("extended point not allowed");let{x:p,y:w}=h||{};return P("x",p),P("y",w),new u(p,w,it,f(p*w))}static normalizeZ(h){let p=ye(e,h.map(w=>w.ez));return h.map((w,C)=>w.toAffine(p[C])).map(u.fromAffine)}static msm(h,p){return ir(u,l,h,p)}_setWindowSize(h){v.setWindowSize(this,h)}assertValidity(){A(this)}equals(h){R(h);let{ex:p,ey:w,ez:C}=this,{ex:N,ey:k,ez:H}=h,M=f(p*H),V=f(N*C),W=f(w*H),Z=f(k*C);return M===V&&W===Z}is0(){return this.equals(u.ZERO)}negate(){return new u(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:h}=t,{ex:p,ey:w,ez:C}=this,N=f(p*p),k=f(w*w),H=f($o*f(C*C)),M=f(h*N),V=p+w,W=f(f(V*V)-N-k),Z=M+k,tt=Z-H,ct=M-k,$=f(W*tt),rt=f(Z*ct),ft=f(W*ct),bt=f(tt*Z);return new u($,rt,bt,ft)}add(h){R(h);let{a:p,d:w}=t,{ex:C,ey:N,ez:k,et:H}=this,{ex:M,ey:V,ez:W,et:Z}=h,tt=f(C*M),ct=f(N*V),$=f(H*w*Z),rt=f(k*W),ft=f((C+N)*(M+V)-tt-ct),bt=rt-$,ge=rt+$,Mn=f(ct-p*tt),Ns=f(ft*bt),Os=f(ge*Mn),ks=f(ft*Mn),Hs=f(bt*ge);return new u(Ns,Os,Hs,ks)}subtract(h){return this.add(h.negate())}wNAF(h){return v.wNAFCached(this,h,u.normalizeZ)}multiply(h){let p=h;pt("scalar",p,it,n);let{p:w,f:C}=this.wNAF(p);return u.normalizeZ([w,C])[0]}multiplyUnsafe(h,p=u.ZERO){let w=h;return pt("scalar",w,vt,n),w===vt?B:this.is0()||w===it?this:v.wNAFCachedUnsafe(this,w,u.normalizeZ,p)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return v.unsafeLadder(this,n).is0()}toAffine(h){return q(this,h)}clearCofactor(){let{h}=t;return h===it?this:this.multiplyUnsafe(h)}static fromHex(h,p=!1){let{d:w,a:C}=t,N=e.BYTES;h=F("pointHex",h,N),Bt("zip215",p);let k=h.slice(),H=h[N-1];k[N-1]=H&-129;let M=Xt(k),V=p?d:e.ORDER;pt("pointHex.y",M,vt,V);let W=f(M*M),Z=f(W-it),tt=f(w*W-C),{isValid:ct,value:$}=L(Z,tt);if(!ct)throw new Error("Point.fromHex: invalid y coordinate");let rt=($&it)===it,ft=(H&128)!==0;if(!p&&$===vt&&ft)throw new Error("Point.fromHex: x=0 and x_0=1");return ft!==rt&&($=f(-$)),u.fromAffine({x:$,y:M})}static fromPrivateKey(h){let{scalar:p}=O(h);return m.multiply(p)}toRawBytes(){let{x:h,y:p}=this.toAffine(),w=pe(p,e.BYTES);return w[w.length-1]|=h&it?128:0,w}toHex(){return qt(this.toRawBytes())}}u.BASE=new u(t.Gx,t.Gy,it,f(t.Gx*t.Gy)),u.ZERO=new u(vt,it,it,vt);let{BASE:m,ZERO:B}=u,v=sr(u,c*8);function I(b){return z(b,n)}function D(b){return I(Xt(b))}function O(b){let h=e.BYTES;b=F("private key",b,h);let p=F("hashed private key",s(b),2*h),w=S(p.slice(0,h)),C=p.slice(h,2*h),N=D(w);return{head:w,prefix:C,scalar:N}}function U(b){let{head:h,prefix:p,scalar:w}=O(b),C=m.multiply(w),N=C.toRawBytes();return{head:h,prefix:p,scalar:w,point:C,pointBytes:N}}function K(b){return U(b).pointBytes}function T(b=Uint8Array.of(),...h){let p=Vt(...h);return D(s(y(p,F("context",b),!!o)))}function Y(b,h,p={}){b=F("message",b),o&&(b=o(b));let{prefix:w,scalar:C,pointBytes:N}=U(h),k=T(p.context,w,b),H=m.multiply(k).toRawBytes(),M=T(p.context,H,N,b),V=I(k+M*C);pt("signature.s",V,vt,n);let W=Vt(H,pe(V,e.BYTES));return F("result",W,e.BYTES*2)}let g=Ca;function x(b,h,p,w=g){let{context:C,zip215:N}=w,k=e.BYTES;b=F("signature",b,2*k),h=F("message",h),p=F("publicKey",p,k),N!==void 0&&Bt("zip215",N),o&&(h=o(h));let H=Xt(b.slice(k,2*k)),M,V,W;try{M=u.fromHex(p,N),V=u.fromHex(b.slice(0,k),N),W=m.multiplyUnsafe(H)}catch{return!1}if(!N&&M.isSmallOrder())return!1;let Z=T(C,V.toRawBytes(),M.toRawBytes(),h);return V.add(M.multiplyUnsafe(Z)).subtract(W).clearCofactor().equals(u.ZERO)}return m._setWindowSize(8),{CURVE:t,getPublicKey:K,sign:Y,verify:x,ExtendedPoint:u,utils:{getExtendedPublicKey:U,randomPrivateKey:()=>i(e.BYTES),precompute(b=8,h=u.BASE){return h._setWindowSize(b),h.multiply(BigInt(3)),h}}}}var yn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Qo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),wu=BigInt(0),Da=BigInt(1),ts=BigInt(2),Eu=BigInt(3),Pa=BigInt(5),Ra=BigInt(8);function Ka(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=yn,c=r*r%s*r%s,a=j(c,ts,s)*c%s,d=j(a,Da,s)*r%s,f=j(d,Pa,s)*d%s,l=j(f,t,s)*f%s,E=j(l,e,s)*l%s,L=j(E,n,s)*E%s,S=j(L,o,s)*L%s,y=j(S,o,s)*L%s,P=j(y,t,s)*f%s;return{pow_p_5_8:j(P,ts,s)*r%s,b2:c}}function Na(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Oa(r,t){let e=yn,n=z(t*t*t,e),o=z(n*n*t,e),s=Ka(r*o).pow_p_5_8,i=z(r*n*s,e),c=z(t*i*i,e),a=i,d=z(i*Qo,e),f=c===r,l=c===z(-r,e),E=c===z(-r*Qo,e);return f&&(i=a),(l||E)&&(i=d),Fo(i,e)&&(i=z(-i,e)),{isValid:f||l,value:i}}var es=Pt(yn,void 0,!0),ka={a:es.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:es,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Ra,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Do,randomBytes:er,adjustScalarBytes:Na,uvRatio:Oa},rs=Jo(ka);var Ke=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},ar=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var ns={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new ar("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var cr=ns;var fr=32;var bn,Ha=(async()=>{try{return await cr.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function Ma(r,t,e){if(r.buffer instanceof ArrayBuffer){let n=await cr.get().subtle.importKey("raw",r.buffer,{name:"Ed25519"},!1,["verify"]);return await cr.get().subtle.verify({name:"Ed25519"},n,t,e instanceof Uint8Array?e:e.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function qa(r,t,e){return rs.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}async function os(r,t,e){return bn==null&&(bn=await Ha),bn?Ma(r,t,e):qa(r,t,e)}function ur(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var hr=class{type="Ed25519";raw;constructor(t){this.raw=xn(t,fr)}toMultihash(){return xt.digest(ue(this))}toCID(){return ot.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:gt(this.raw,t.raw)}verify(t,e,n){n?.signal?.throwIfAborted();let o=os(this.raw,e,t);return ur(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function is(r){return r=xn(r,fr),new hr(r)}function xn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new At(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var za=Math.pow(2,7),Fa=Math.pow(2,14),ja=Math.pow(2,21),as=Math.pow(2,28),cs=Math.pow(2,35),fs=Math.pow(2,42),us=Math.pow(2,49),at=128,zt=127;function Ne(r){if(r<za)return 1;if(r<Fa)return 2;if(r<ja)return 3;if(r<as)return 4;if(r<cs)return 5;if(r<fs)return 6;if(r<us)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function hs(r,t,e=0){switch(Ne(r)){case 8:t[e++]=r&255|at,r/=128;case 7:t[e++]=r&255|at,r/=128;case 6:t[e++]=r&255|at,r/=128;case 5:t[e++]=r&255|at,r/=128;case 4:t[e++]=r&255|at,r>>>=7;case 3:t[e++]=r&255|at,r>>>=7;case 2:t[e++]=r&255|at,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function ls(r,t){let e=r[t],n=0;if(n+=e&zt,e<at||(e=r[t+1],n+=(e&zt)<<7,e<at)||(e=r[t+2],n+=(e&zt)<<14,e<at)||(e=r[t+3],n+=(e&zt)<<21,e<at)||(e=r[t+4],n+=(e&zt)*as,e<at)||(e=r[t+5],n+=(e&zt)*cs,e<at)||(e=r[t+6],n+=(e&zt)*fs,e<at)||(e=r[t+7],n+=(e&zt)*us,e<at))return n;throw new RangeError("Could not decode varint")}var gn=new Float32Array([-0]),Ft=new Uint8Array(gn.buffer);function ds(r,t,e){gn[0]=r,t[e]=Ft[0],t[e+1]=Ft[1],t[e+2]=Ft[2],t[e+3]=Ft[3]}function ps(r,t){return Ft[0]=r[t],Ft[1]=r[t+1],Ft[2]=r[t+2],Ft[3]=r[t+3],gn[0]}var wn=new Float64Array([-0]),nt=new Uint8Array(wn.buffer);function ms(r,t,e){wn[0]=r,t[e]=nt[0],t[e+1]=nt[1],t[e+2]=nt[2],t[e+3]=nt[3],t[e+4]=nt[4],t[e+5]=nt[5],t[e+6]=nt[6],t[e+7]=nt[7]}function ys(r,t){return nt[0]=r[t],nt[1]=r[t+1],nt[2]=r[t+2],nt[3]=r[t+3],nt[4]=r[t+4],nt[5]=r[t+5],nt[6]=r[t+6],nt[7]=r[t+7],wn[0]}var Ga=BigInt(Number.MAX_SAFE_INTEGER),Za=BigInt(Number.MIN_SAFE_INTEGER),mt=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 te;if(t<Ga&&t>Za)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>bs&&(o=0n,++n>bs&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return te;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):te}},te=new mt(0,0);te.toBigInt=function(){return 0n};te.zzEncode=te.zzDecode=function(){return this};te.length=function(){return 1};var bs=4294967296n;function xs(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 gs(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 En(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 Et(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function lr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var An=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,Et(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 Et(this,4);return lr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Et(this,4);return lr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Et(this,4);let t=ps(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Et(this,4);let t=ys(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 Et(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return gs(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Et(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Et(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 mt(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 Et(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 Et(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 Et(this,8);let t=lr(this.buf,this.pos+=4),e=lr(this.buf,this.pos+=4);return new mt(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=ls(this.buf,this.pos);return this.pos+=Ne(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 Sn(r){return new An(r instanceof Uint8Array?r:r.subarray())}function dr(r,t,e){let n=Sn(r);return t.decode(n,void 0,e)}function Bn(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return ht(i);o+i>t&&(n=ht(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var ee=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function vn(){}var Ln=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Ya=Bn();function Wa(r){return globalThis.Buffer!=null?ht(r):Ya(r)}var ke=class{len;head;tail;states;constructor(){this.len=0,this.head=new ee(vn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ee(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new _n((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(pr,10,mt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=mt.fromBigInt(t);return this._push(pr,e.length(),e)}uint64Number(t){return this._push(hs,Ne(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=mt.fromBigInt(t).zzEncode();return this._push(pr,e.length(),e)}sint64Number(t){let e=mt.fromNumber(t).zzEncode();return this._push(pr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(In,1,t?1:0)}fixed32(t){return this._push(Oe,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=mt.fromBigInt(t);return this._push(Oe,4,e.lo)._push(Oe,4,e.hi)}fixed64Number(t){let e=mt.fromNumber(t);return this._push(Oe,4,e.lo)._push(Oe,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(ds,4,t)}double(t){return this._push(ms,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(In,1,0):this.uint32(e)._push($a,e,t)}string(t){let e=xs(t);return e!==0?this.uint32(e)._push(En,e,t):this._push(In,1,0)}fork(){return this.states=new Ln(this),this.head=this.tail=new ee(vn,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 ee(vn,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=Wa(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function In(r,t,e){t[e]=r&255}function Xa(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var _n=class extends ee{next;constructor(t,e){super(Xa,t,e),this.next=void 0}};function pr(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 Oe(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 $a(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(ke.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Ja,t,r),this},ke.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Qa,t,r),this});function Ja(r,t,e){t.set(r,e)}function Qa(r,t,e){r.length<40?En(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Ot(r),e)}function Un(){return new ke}function mr(r,t){let e=Un();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var be;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(be||(be={}));function yr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Cn(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let c=t(s);i.int32(c)},n=function(s){let i=s.int32();return t(i)};return yr("enum",be.VARINT,e,n)}function br(r,t){return yr("message",be.LENGTH_DELIMITED,r,t)}var yt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(yt||(yt={}));var Tn;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(Tn||(Tn={}));(function(r){r.codec=()=>Cn(Tn)})(yt||(yt={}));var He;(function(r){let t;r.codec=()=>(t==null&&(t=br((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=>mr(e,r.codec()),r.decode=(e,n)=>dr(e,r.codec(),n)})(He||(He={}));var Dn;(function(r){let t;r.codec=()=>(t==null&&(t=br((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=>mr(e,r.codec()),r.decode=(e,n)=>dr(e,r.codec(),n)})(Dn||(Dn={}));var xr=class extends he{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,bo(t);let n=_e(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,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),_t(s)}update(t){return le(this),this.iHash.update(t),this}digestInto(t){le(this),Zt(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Pn=(r,t,e)=>new xr(r,t).update(e).digest();Pn.create=(r,t)=>new xr(r,t);function Es(r){r.lowS!==void 0&&Bt("lowS",r.lowS),r.prehash!==void 0&&Bt("prehash",r.prehash)}function ec(r){let t=Re(r);Dt(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}var Nn=class extends Error{constructor(t=""){super(t)}},Rt={Err:Nn,_tlv:{encode:(r,t)=>{let{Err:e}=Rt;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=De(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?De(o.length/2|128):"";return De(r)+s+o+t},decode(r,t){let{Err:e}=Rt,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 d=t.subarray(n,n+a);if(d.length!==a)throw new e("tlv.decode: length bytes not complete");if(d[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let f of d)i=i<<8|f;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Rt;if(r<Kt)throw new t("integer: negative integers are not allowed");let e=De(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=Rt;if(r[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 Tt(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Rt,o=F("signature",r),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:d,l:f}=n.decode(2,a);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(d)}},hexFromSig(r){let{_tlv:t,_int:e}=Rt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}};function Rn(r,t){return qt($t(r,t))}var Kt=BigInt(0),Q=BigInt(1),Rh=BigInt(2),Kn=BigInt(3),rc=BigInt(4);function nc(r){let t=ec(r),{Fp:e}=t,n=Pt(t.n,t.nBitLength),o=t.toBytes||((A,u,m)=>{let B=u.toAffine();return Vt(Uint8Array.from([4]),e.toBytes(B.x),e.toBytes(B.y))}),s=t.fromBytes||(A=>{let u=A.subarray(1),m=e.fromBytes(u.subarray(0,e.BYTES)),B=e.fromBytes(u.subarray(e.BYTES,2*e.BYTES));return{x:m,y:B}});function i(A){let{a:u,b:m}=t,B=e.sqr(A),v=e.mul(B,A);return e.add(e.add(v,e.mul(A,u)),m)}function c(A,u){let m=e.sqr(u),B=i(A);return e.eql(m,B)}if(!c(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let a=e.mul(e.pow(t.a,Kn),rc),d=e.mul(e.sqr(t.b),BigInt(27));if(e.is0(e.add(a,d)))throw new Error("bad curve params: a or b");function f(A){return nr(A,Q,t.n)}function l(A){let{allowedPrivateKeyLengths:u,nByteLength:m,wrapPrivateKey:B,n:v}=t;if(u&&typeof A!="bigint"){if(de(A)&&(A=qt(A)),typeof A!="string"||!u.includes(A.length))throw new Error("invalid private key");A=A.padStart(m*2,"0")}let I;try{I=typeof A=="bigint"?A:Tt(F("private key",A,m))}catch{throw new Error("invalid private key, expected hex or "+m+" bytes, got "+typeof A)}return B&&(I=z(I,v)),pt("private key",I,Q,v),I}function E(A){if(!(A instanceof y))throw new Error("ProjectivePoint expected")}let L=me((A,u)=>{let{px:m,py:B,pz:v}=A;if(e.eql(v,e.ONE))return{x:m,y:B};let I=A.is0();u==null&&(u=I?e.ONE:e.inv(v));let D=e.mul(m,u),O=e.mul(B,u),U=e.mul(v,u);if(I)return{x:e.ZERO,y:e.ZERO};if(!e.eql(U,e.ONE))throw new Error("invZ was invalid");return{x:D,y:O}}),S=me(A=>{if(A.is0()){if(t.allowInfinityPoint&&!e.is0(A.py))return;throw new Error("bad point: ZERO")}let{x:u,y:m}=A.toAffine();if(!e.isValid(u)||!e.isValid(m))throw new Error("bad point: x or y not FE");if(!c(u,m))throw new Error("bad point: equation left != right");if(!A.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class y{constructor(u,m,B){if(u==null||!e.isValid(u))throw new Error("x required");if(m==null||!e.isValid(m)||e.is0(m))throw new Error("y required");if(B==null||!e.isValid(B))throw new Error("z required");this.px=u,this.py=m,this.pz=B,Object.freeze(this)}static fromAffine(u){let{x:m,y:B}=u||{};if(!u||!e.isValid(m)||!e.isValid(B))throw new Error("invalid affine point");if(u instanceof y)throw new Error("projective point not allowed");let v=I=>e.eql(I,e.ZERO);return v(m)&&v(B)?y.ZERO:new y(m,B,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(u){let m=ye(e,u.map(B=>B.pz));return u.map((B,v)=>B.toAffine(m[v])).map(y.fromAffine)}static fromHex(u){let m=y.fromAffine(s(F("pointHex",u)));return m.assertValidity(),m}static fromPrivateKey(u){return y.BASE.multiply(l(u))}static msm(u,m){return ir(y,n,u,m)}_setWindowSize(u){q.setWindowSize(this,u)}assertValidity(){S(this)}hasEvenY(){let{y:u}=this.toAffine();if(e.isOdd)return!e.isOdd(u);throw new Error("Field doesn't support isOdd")}equals(u){E(u);let{px:m,py:B,pz:v}=this,{px:I,py:D,pz:O}=u,U=e.eql(e.mul(m,O),e.mul(I,v)),K=e.eql(e.mul(B,O),e.mul(D,v));return U&&K}negate(){return new y(this.px,e.neg(this.py),this.pz)}double(){let{a:u,b:m}=t,B=e.mul(m,Kn),{px:v,py:I,pz:D}=this,O=e.ZERO,U=e.ZERO,K=e.ZERO,T=e.mul(v,v),Y=e.mul(I,I),g=e.mul(D,D),x=e.mul(v,I);return x=e.add(x,x),K=e.mul(v,D),K=e.add(K,K),O=e.mul(u,K),U=e.mul(B,g),U=e.add(O,U),O=e.sub(Y,U),U=e.add(Y,U),U=e.mul(O,U),O=e.mul(x,O),K=e.mul(B,K),g=e.mul(u,g),x=e.sub(T,g),x=e.mul(u,x),x=e.add(x,K),K=e.add(T,T),T=e.add(K,T),T=e.add(T,g),T=e.mul(T,x),U=e.add(U,T),g=e.mul(I,D),g=e.add(g,g),T=e.mul(g,x),O=e.sub(O,T),K=e.mul(g,Y),K=e.add(K,K),K=e.add(K,K),new y(O,U,K)}add(u){E(u);let{px:m,py:B,pz:v}=this,{px:I,py:D,pz:O}=u,U=e.ZERO,K=e.ZERO,T=e.ZERO,Y=t.a,g=e.mul(t.b,Kn),x=e.mul(m,I),_=e.mul(B,D),b=e.mul(v,O),h=e.add(m,B),p=e.add(I,D);h=e.mul(h,p),p=e.add(x,_),h=e.sub(h,p),p=e.add(m,v);let w=e.add(I,O);return p=e.mul(p,w),w=e.add(x,b),p=e.sub(p,w),w=e.add(B,v),U=e.add(D,O),w=e.mul(w,U),U=e.add(_,b),w=e.sub(w,U),T=e.mul(Y,p),U=e.mul(g,b),T=e.add(U,T),U=e.sub(_,T),T=e.add(_,T),K=e.mul(U,T),_=e.add(x,x),_=e.add(_,x),b=e.mul(Y,b),p=e.mul(g,p),_=e.add(_,b),b=e.sub(x,b),b=e.mul(Y,b),p=e.add(p,b),x=e.mul(_,p),K=e.add(K,x),x=e.mul(w,p),U=e.mul(h,U),U=e.sub(U,x),x=e.mul(h,_),T=e.mul(w,T),T=e.add(T,x),new y(U,K,T)}subtract(u){return this.add(u.negate())}is0(){return this.equals(y.ZERO)}wNAF(u){return q.wNAFCached(this,u,y.normalizeZ)}multiplyUnsafe(u){let{endo:m,n:B}=t;pt("scalar",u,Kt,B);let v=y.ZERO;if(u===Kt)return v;if(this.is0()||u===Q)return this;if(!m||q.hasPrecomputes(this))return q.wNAFCachedUnsafe(this,u,y.normalizeZ);let{k1neg:I,k1:D,k2neg:O,k2:U}=m.splitScalar(u),K=v,T=v,Y=this;for(;D>Kt||U>Kt;)D&Q&&(K=K.add(Y)),U&Q&&(T=T.add(Y)),Y=Y.double(),D>>=Q,U>>=Q;return I&&(K=K.negate()),O&&(T=T.negate()),T=new y(e.mul(T.px,m.beta),T.py,T.pz),K.add(T)}multiply(u){let{endo:m,n:B}=t;pt("scalar",u,Q,B);let v,I;if(m){let{k1neg:D,k1:O,k2neg:U,k2:K}=m.splitScalar(u),{p:T,f:Y}=this.wNAF(O),{p:g,f:x}=this.wNAF(K);T=q.constTimeNegate(D,T),g=q.constTimeNegate(U,g),g=new y(e.mul(g.px,m.beta),g.py,g.pz),v=T.add(g),I=Y.add(x)}else{let{p:D,f:O}=this.wNAF(u);v=D,I=O}return y.normalizeZ([v,I])[0]}multiplyAndAddUnsafe(u,m,B){let v=y.BASE,I=(O,U)=>U===Kt||U===Q||!O.equals(v)?O.multiplyUnsafe(U):O.multiply(U),D=I(this,m).add(I(u,B));return D.is0()?void 0:D}toAffine(u){return L(this,u)}isTorsionFree(){let{h:u,isTorsionFree:m}=t;if(u===Q)return!0;if(m)return m(y,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:u,clearCofactor:m}=t;return u===Q?this:m?m(y,this):this.multiplyUnsafe(t.h)}toRawBytes(u=!0){return Bt("isCompressed",u),this.assertValidity(),o(y,this,u)}toHex(u=!0){return Bt("isCompressed",u),qt(this.toRawBytes(u))}}y.BASE=new y(t.Gx,t.Gy,e.ONE),y.ZERO=new y(e.ZERO,e.ONE,e.ZERO);let{endo:P,nBitLength:R}=t,q=sr(y,P?Math.ceil(R/2):R);return{CURVE:t,ProjectivePoint:y,normPrivateKeyToScalar:l,weierstrassEquation:i,isWithinCurveOrder:f}}function oc(r){let t=Re(r);return Dt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function As(r){let t=oc(r),{Fp:e,n,nByteLength:o,nBitLength:s}=t,i=e.BYTES+1,c=2*e.BYTES+1;function a(g){return z(g,n)}function d(g){return or(g,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:l,weierstrassEquation:E,isWithinCurveOrder:L}=nc({...t,toBytes(g,x,_){let b=x.toAffine(),h=e.toBytes(b.x),p=Vt;return Bt("isCompressed",_),_?p(Uint8Array.from([x.hasEvenY()?2:3]),h):p(Uint8Array.from([4]),h,e.toBytes(b.y))},fromBytes(g){let x=g.length,_=g[0],b=g.subarray(1);if(x===i&&(_===2||_===3)){let h=Tt(b);if(!nr(h,Q,e.ORDER))throw new Error("Point is not on curve");let p=E(h),w;try{w=e.sqrt(p)}catch(k){let H=k instanceof Error?": "+k.message:"";throw new Error("Point is not on curve"+H)}let C=(w&Q)===Q;return(_&1)===1!==C&&(w=e.neg(w)),{x:h,y:w}}else if(x===c&&_===4){let h=e.fromBytes(b.subarray(0,e.BYTES)),p=e.fromBytes(b.subarray(e.BYTES,2*e.BYTES));return{x:h,y:p}}else{let h=i,p=c;throw new Error("invalid Point, expected length of "+h+", or uncompressed "+p+", got "+x)}}});function S(g){let x=n>>Q;return g>x}function y(g){return S(g)?a(-g):g}let P=(g,x,_)=>Tt(g.slice(x,_));class R{constructor(x,_,b){pt("r",x,Q,n),pt("s",_,Q,n),this.r=x,this.s=_,b!=null&&(this.recovery=b),Object.freeze(this)}static fromCompact(x){let _=o;return x=F("compactSignature",x,_*2),new R(P(x,0,_),P(x,_,2*_))}static fromDER(x){let{r:_,s:b}=Rt.toSig(F("DER",x));return new R(_,b)}assertValidity(){}addRecoveryBit(x){return new R(this.r,this.s,x)}recoverPublicKey(x){let{r:_,s:b,recovery:h}=this,p=v(F("msgHash",x));if(h==null||![0,1,2,3].includes(h))throw new Error("recovery id invalid");let w=h===2||h===3?_+t.n:_;if(w>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let C=(h&1)===0?"02":"03",N=f.fromHex(C+Rn(w,e.BYTES)),k=d(w),H=a(-p*k),M=a(b*k),V=f.BASE.multiplyAndAddUnsafe(N,H,M);if(!V)throw new Error("point at infinify");return V.assertValidity(),V}hasHighS(){return S(this.s)}normalizeS(){return this.hasHighS()?new R(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Pe(this.toDERHex())}toDERHex(){return Rt.hexFromSig(this)}toCompactRawBytes(){return Pe(this.toCompactHex())}toCompactHex(){let x=o;return Rn(this.r,x)+Rn(this.s,x)}}let q={isValidPrivateKey(g){try{return l(g),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let g=un(t.n);return Go(t.randomBytes(g),t.n)},precompute(g=8,x=f.BASE){return x._setWindowSize(g),x.multiply(BigInt(3)),x}};function A(g,x=!0){return f.fromPrivateKey(g).toRawBytes(x)}function u(g){if(typeof g=="bigint")return!1;if(g instanceof f)return!0;let _=F("key",g).length,b=e.BYTES,h=b+1,p=2*b+1;if(!(t.allowedPrivateKeyLengths||o===h))return _===h||_===p}function m(g,x,_=!0){if(u(g)===!0)throw new Error("first arg must be private key");if(u(x)===!1)throw new Error("second arg must be public key");return f.fromHex(x).multiply(l(g)).toRawBytes(_)}let B=t.bits2int||function(g){if(g.length>8192)throw new Error("input is too large");let x=Tt(g),_=g.length*8-s;return _>0?x>>BigInt(_):x},v=t.bits2int_modN||function(g){return a(B(g))},I=Jt(s);function D(g){return pt("num < 2^"+s,g,Kt,I),$t(g,o)}function O(g,x,_=U){if(["recovered","canonical"].some(Z=>Z in _))throw new Error("sign() legacy options not supported");let{hash:b,randomBytes:h}=t,{lowS:p,prehash:w,extraEntropy:C}=_;p==null&&(p=!0),g=F("msgHash",g),Es(_),w&&(g=F("prehashed msgHash",b(g)));let N=v(g),k=l(x),H=[D(k),D(N)];if(C!=null&&C!==!1){let Z=C===!0?h(e.BYTES):C;H.push(F("extraEntropy",Z))}let M=Vt(...H),V=N;function W(Z){let tt=B(Z);if(!L(tt))return;let ct=d(tt),$=f.BASE.multiply(tt).toAffine(),rt=a($.x);if(rt===Kt)return;let ft=a(ct*a(V+rt*k));if(ft===Kt)return;let bt=($.x===rt?0:2)|Number($.y&Q),ge=ft;return p&&S(ft)&&(ge=y(ft),bt^=1),new R(rt,ge,bt)}return{seed:M,k2sig:W}}let U={lowS:t.lowS,prehash:!1},K={lowS:t.lowS,prehash:!1};function T(g,x,_=U){let{seed:b,k2sig:h}=O(g,x,_),p=t;return ko(p.hash.outputLen,p.nByteLength,p.hmac)(b,h)}f.BASE._setWindowSize(8);function Y(g,x,_,b=K){let h=g;x=F("msgHash",x),_=F("publicKey",_);let{lowS:p,prehash:w,format:C}=b;if(Es(b),"strict"in b)throw new Error("options.strict was renamed to lowS");if(C!==void 0&&C!=="compact"&&C!=="der")throw new Error("format must be compact or der");let N=typeof h=="string"||de(h),k=!N&&!C&&typeof h=="object"&&h!==null&&typeof h.r=="bigint"&&typeof h.s=="bigint";if(!N&&!k)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let H,M;try{if(k&&(H=new R(h.r,h.s)),N){try{C!=="compact"&&(H=R.fromDER(h))}catch(bt){if(!(bt instanceof Rt.Err))throw bt}!H&&C!=="der"&&(H=R.fromCompact(h))}M=f.fromHex(_)}catch{return!1}if(!H||p&&H.hasHighS())return!1;w&&(x=t.hash(x));let{r:V,s:W}=H,Z=v(x),tt=d(W),ct=a(Z*tt),$=a(V*tt),rt=f.BASE.multiplyAndAddUnsafe(M,ct,$)?.toAffine();return rt?a(rt.x)===V:!1}return{CURVE:t,getPublicKey:A,getSharedSecret:m,sign:T,verify:Y,ProjectivePoint:f,Signature:R,utils:q}}function sc(r){return{hash:r,hmac:(t,...e)=>Pn(r,t,Xr(...e)),randomBytes:er}}function Ss(r,t){let e=n=>As({...r,...sc(n)});return{...e(t),create:e}}var Is=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Bs=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ic=BigInt(0),ac=BigInt(1),On=BigInt(2),vs=(r,t)=>(r+t/On)/t;function cc(r){let t=Is,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),d=r*r*r%t,f=d*d*r%t,l=j(f,e,t)*f%t,E=j(l,e,t)*f%t,L=j(E,On,t)*d%t,S=j(L,o,t)*L%t,y=j(S,s,t)*S%t,P=j(y,c,t)*y%t,R=j(P,a,t)*P%t,q=j(R,c,t)*y%t,A=j(q,e,t)*f%t,u=j(A,i,t)*S%t,m=j(u,n,t)*d%t,B=j(m,On,t);if(!kn.eql(kn.sqr(B),r))throw new Error("Cannot find square root");return B}var kn=Pt(Is,void 0,void 0,{sqrt:cc}),xe=Ss({a:ic,b:BigInt(7),Fp:kn,n:Bs,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Bs,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-ac*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=vs(s*r,t),a=vs(-n*r,t),d=z(r-c*e-a*o,t),f=z(-c*n-a*s,t),l=d>i,E=f>i;if(l&&(d=t-d),E&&(f=t-f),d>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:d,k2neg:E,k2:f}}}},To);function Ls(r,t,e,n){let o=ve.digest(e instanceof Uint8Array?e:e.subarray());if(ur(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),xe.verify(t,s,r))).catch(s=>{throw s.name==="AbortError"?s:new Ke(String(s))});try{return n?.signal?.throwIfAborted(),xe.verify(t,o.digest,r)}catch(s){throw new Ke(String(s))}}var gr=class{type="secp256k1";raw;_key;constructor(t){this._key=Us(t),this.raw=_s(this._key)}toMultihash(){return xt.digest(ue(this))}toCID(){return ot.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:gt(this.raw,t.raw)}verify(t,e,n){return Ls(this._key,e,t,n)}};function Cs(r){return new gr(r)}function _s(r){return xe.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Us(r){try{return xe.ProjectivePoint.fromHex(r),r}catch(t){throw new je(String(t))}}function Ts(r){let{Type:t,Data:e}=He.decode(r.digest),n=e??new Uint8Array;switch(t){case yt.Ed25519:return is(n);case yt.secp256k1:return Cs(n);case yt.ECDSA:return po(n);default:throw new re}}function ue(r){return He.encode({Type:yt[r.type],Data:r.raw})}var Ds=Symbol.for("nodejs.util.inspect.custom"),fc=114,Me=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()})`}[Er]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ot.createV1(fc,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return gt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return gt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Ds](){return`PeerId(${this.toString()})`}},qe=class extends Me{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Ve=class extends Me{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},ze=class extends Me{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},uc=2336,Fe=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=xt.digest(Ot(this.url))}[Ds](){return`PeerId(${this.url})`}[Er]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ot.createV1(uc,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=dt(t)),t.toString()===this.toString())}};var hc=114,Ps=2336;function lc(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=Se(X.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return Ks(ot.parse(r));if(t==null)throw new At('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=Se(t.decode(r))}return Hn(e)}function Rs(r){if(r.type==="Ed25519")return new Ve({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new ze({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new qe({multihash:r.toCID().multihash,publicKey:r});throw new re}function dc(r){return Rs(r.publicKey)}function Hn(r){if(mc(r))return new qe({multihash:r});if(pc(r))try{let t=Ts(r);if(t.type==="Ed25519")return new Ve({multihash:r,publicKey:t});if(t.type==="secp256k1")return new ze({multihash:r,publicKey:t})}catch{let e=dt(r.digest);return new Fe(new URL(e))}throw new Ze("Supplied PeerID Multihash is invalid")}function Ks(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==hc&&r.code!==Ps)throw new Ge("Supplied PeerID CID is invalid");if(r.code===Ps){let t=dt(r.multihash.digest);return new Fe(new URL(t))}return Hn(r.multihash)}function pc(r){return r.code===xt.code}function mc(r){return r.code===ve.code}return Fs(yc);})();
3
3
  /*! Bundled license information:
4
4
 
5
5
  @noble/hashes/esm/utils.js: