@libp2p/peer-id 5.1.8-cb1c14e62 → 5.1.8-cf9aab5c8

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