@libp2p/peer-collections 6.0.27-6f96de86c → 6.0.27-9b33d202e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +2 -15
- package/dist/index.min.js.map +7 -0
- package/package.json +5 -5
package/dist/index.min.js
CHANGED
|
@@ -1,32 +1,19 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PPeerCollections = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PPeerCollections=(()=>{var wr=Object.defineProperty;var Hs=Object.getOwnPropertyDescriptor;var qs=Object.getOwnPropertyNames;var Fs=Object.prototype.hasOwnProperty;var ut=(r,t)=>{for(var e in t)wr(r,e,{get:t[e],enumerable:!0})},Vs=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of qs(t))!Fs.call(r,o)&&o!==e&&wr(r,o,{get:()=>t[o],enumerable:!(n=Hs(t,o))||n.enumerable});return r};var js=r=>Vs(wr({},"__esModule",{value:!0}),r);var Ka={};ut(Ka,{PeerFilter:()=>qe,PeerList:()=>Gt,PeerMap:()=>Vt,PeerSet:()=>jt,peerFilter:()=>Ps,peerList:()=>Ls,peerMap:()=>Is,peerSet:()=>Cs,trackedPeerList:()=>Ns,trackedPeerMap:()=>Rs,trackedPeerSet:()=>ks});var Er=Symbol.for("@libp2p/peer-id");var It=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Fe=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Ve=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Ee=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Br={};ut(Br,{base58btc:()=>W,base58flickr:()=>$s});var Ha=new Uint8Array(0);function jn(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Ct(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Gn(r){return new TextEncoder().encode(r)}function Zn(r){return new TextDecoder().decode(r)}function Gs(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var c=r.length,a=r.charAt(0),h=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function u(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var y=0,l=0,g=0,A=E.length;g!==A&&E[g]===0;)g++,y++;for(var p=(A-g)*f+1>>>0,v=new Uint8Array(p);g!==A;){for(var D=E[g],T=0,I=p-1;(D!==0||T<l)&&I!==-1;I--,T++)D+=256*v[I]>>>0,v[I]=D%c>>>0,D=D/c>>>0;if(D!==0)throw new Error("Non-zero carry");l=T,g++}for(var C=p-l;C!==p&&v[C]===0;)C++;for(var L=a.repeat(y);C<p;++C)L+=r.charAt(v[C]);return L}function m(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var y=0;if(E[y]!==" "){for(var l=0,g=0;E[y]===a;)l++,y++;for(var A=(E.length-y)*h+1>>>0,p=new Uint8Array(A);E[y];){var v=e[E.charCodeAt(y)];if(v===255)return;for(var D=0,T=A-1;(v!==0||D<g)&&T!==-1;T--,D++)v+=c*p[T]>>>0,p[T]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");g=D,y++}if(E[y]!==" "){for(var I=A-g;I!==A&&p[I]===0;)I++;for(var C=new Uint8Array(l+(A-I)),L=l;I!==A;)C[L++]=p[I++];return C}}}function _(E){var y=m(E);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:u,decodeUnsafe:m,decode:_}}var Zs=Gs,Ys=Zs,Wn=Ys;var _r=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Sr=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Xn(this,t)}},Ar=class{decoders;constructor(t){this.decoders=t}or(t){return Xn(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Xn(r,t){return new Ar({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var vr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new _r(t,e,n),this.decoder=new Sr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ie({name:r,prefix:t,encode:e,decode:n}){return new vr(r,t,e,n)}function Rt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Wn(e,r);return ie({prefix:t,name:r,encode:n,decode:s=>Ct(o(s))})}function Ws(r,t,e,n){let o={};for(let f=0;f<t.length;++f)o[t[f]]=f;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),c=0,a=0,h=0;for(let f=0;f<s;++f){let u=o[r[f]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|u,c+=e,c>=8&&(c-=8,i[h++]=255&a>>c)}if(c>=e||(255&a<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return i}function Xs(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],i+=8;i>e;)i-=e,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function Z({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return ie({prefix:t,name:r,encode(o){return Xs(o,n,e)},decode(o){return Ws(o,n,e,r)}})}var W=Rt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),$s=Rt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ir={};ut(Ir,{base32:()=>ce,base32hex:()=>ei,base32hexpad:()=>ni,base32hexpadupper:()=>oi,base32hexupper:()=>ri,base32pad:()=>Qs,base32padupper:()=>ti,base32upper:()=>Js,base32z:()=>si});var ce=Z({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Js=Z({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Qs=Z({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ti=Z({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ei=Z({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ri=Z({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ni=Z({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),oi=Z({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),si=Z({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Cr={};ut(Cr,{base36:()=>_e,base36upper:()=>ii});var _e=Rt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ii=Rt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ci=Qn,$n=128,ai=127,fi=~ai,ui=Math.pow(2,31);function Qn(r,t,e){t=t||[],e=e||0;for(var n=e;r>=ui;)t[e++]=r&255|$n,r/=128;for(;r&fi;)t[e++]=r&255|$n,r>>>=7;return t[e]=r|0,Qn.bytes=e-n+1,t}var hi=Lr,li=128,Jn=127;function Lr(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw Lr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&Jn)<<o:(i&Jn)*Math.pow(2,o),o+=7}while(i>=li);return Lr.bytes=s-n,e}var di=Math.pow(2,7),pi=Math.pow(2,14),mi=Math.pow(2,21),yi=Math.pow(2,28),xi=Math.pow(2,35),gi=Math.pow(2,42),bi=Math.pow(2,49),wi=Math.pow(2,56),Ei=Math.pow(2,63),_i=function(r){return r<di?1:r<pi?2:r<mi?3:r<yi?4:r<xi?5:r<gi?6:r<bi?7:r<wi?8:r<Ei?9:10},Si={encode:ci,decode:hi,encodingLength:_i},Ai=Si,Se=Ai;function Ae(r,t=0){return[Se.decode(r,t),Se.decode.bytes]}function ae(r,t,e=0){return Se.encode(r,t,e),t}function fe(r){return Se.encodingLength(r)}function Zt(r,t){let e=t.byteLength,n=fe(r),o=n+fe(e),s=new Uint8Array(o+e);return ae(r,s,0),ae(e,s,n),s.set(t,o),new ue(r,e,t,s)}function ve(r){let t=Ct(r),[e,n]=Ae(t),[o,s]=Ae(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ue(e,o,i,t)}function to(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&jn(r.bytes,e.bytes)}}var ue=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function eo(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Bi(e,Ur(r),t??W.encoder);default:return Ii(e,Ur(r),t??ce.encoder)}}var ro=new WeakMap;function Ur(r){let t=ro.get(r);if(t==null){let e=new Map;return ro.set(r,e),e}return t}var at=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Be)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Ci)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Zt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&to(t.multihash,n.multihash)}toString(t){return eo(this,t)}toJSON(){return{"/":eo(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??no(n,o,s.bytes))}else if(e[Li]===!0){let{version:n,multihash:o,code:s}=e,i=ve(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Be)throw new Error(`Version 0 CID must use dag-pb (code: ${Be}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=no(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Be,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=Ct(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new ue(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[u,m]=Ae(t.subarray(e));return e+=m,u},o=n(),s=Be;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,c=n(),a=n(),h=e+a,f=h-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:f,size:h}}static parse(t,e){let[n,o]=vi(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ur(s).set(n,t),s}};function vi(r,t){switch(r[0]){case"Q":{let e=t??W;return[W.prefix,e.decode(`${W.prefix}${r}`)]}case W.prefix:{let e=t??W;return[W.prefix,e.decode(r)]}case ce.prefix:{let e=t??ce;return[ce.prefix,e.decode(r)]}case _e.prefix:{let e=t??_e;return[_e.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Bi(r,t,e){let{prefix:n}=e;if(n!==W.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function Ii(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var Be=112,Ci=18;function no(r,t,e){let n=fe(r),o=n+fe(t),s=new Uint8Array(o+e.byteLength);return ae(r,s,0),ae(t,s,n),s.set(e,o),s}var Li=Symbol.for("@ipld/js-cid/CID");var Tr={};ut(Tr,{identity:()=>gt});var oo=0,Ui="identity",so=Ct;function Ti(r){return Zt(oo,so(r))}var gt={code:oo,name:Ui,encode:so,digest:Ti};function ht(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function bt(r=0){return new Uint8Array(r)}function lt(r=0){return new Uint8Array(r)}function Ge(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=lt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var co=Symbol.for("@achingbrain/uint8arraylist");function io(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function Ze(r){return!!r?.[co]}var dt=class r{bufs;length;[co]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(Ze(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(Ze(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=io(this.bufs,t);return e.buf[e.index]}set(t,e){let n=io(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(Ze(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return Ge(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Ge(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],c=o,a=c+i.byteLength;if(o=a,t>=a)continue;let h=t>=c&&t<a,f=e>c&&e<=a;if(h&&f){if(t===c&&e===a){n.push(i);break}let u=t-c;n.push(i.subarray(u,u+(e-t)));break}if(h){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(f){if(e===a){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Ze(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let u=0;u<s;u++)i[u]=-1;for(let u=0;u<o;u++)i[n[u]]=u;let c=i,a=this.byteLength-n.byteLength,h=n.byteLength-1,f;for(let u=e;u<=a;u+=f){f=0;for(let m=h;m>=0;m--){let _=this.get(u+m);if(n[m]!==_){f=Math.max(1,m-c[_]);break}}if(f===0)return u}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=lt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=bt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=bt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=bt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=lt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=bt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=bt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=bt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=bt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=bt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!ht(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var Dr={};ut(Dr,{base10:()=>Di});var Di=Rt({prefix:"9",name:"base10",alphabet:"0123456789"});var Pr={};ut(Pr,{base16:()=>Pi,base16upper:()=>Ri});var Pi=Z({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ri=Z({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Rr={};ut(Rr,{base2:()=>ki});var ki=Z({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var kr={};ut(kr,{base256emoji:()=>zi});var ao=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Ni=ao.reduce((r,t,e)=>(r[e]=t,r),[]),Ki=ao.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Oi(r){return r.reduce((t,e)=>(t+=Ni[e],t),"")}function Mi(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Ki[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var zi=ie({prefix:"\u{1F680}",name:"base256emoji",encode:Oi,decode:Mi});var Nr={};ut(Nr,{base64:()=>Hi,base64pad:()=>qi,base64url:()=>Fi,base64urlpad:()=>Vi});var Hi=Z({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qi=Z({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Fi=Z({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Vi=Z({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Kr={};ut(Kr,{base8:()=>ji});var ji=Z({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Or={};ut(Or,{identity:()=>Gi});var Gi=ie({prefix:"\0",name:"identity",encode:r=>Zn(r),decode:r=>Gn(r)});var vf=new TextEncoder,Bf=new TextDecoder;var Hr={};ut(Hr,{sha256:()=>Ie,sha512:()=>Wi});function zr({name:r,code:t,encode:e}){return new Mr(r,t,e)}var Mr=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Zt(this.code,e):e.then(n=>Zt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function uo(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Ie=zr({name:"sha2-256",code:18,encode:uo("SHA-256")}),Wi=zr({name:"sha2-512",code:19,encode:uo("SHA-512")});var qr={...Or,...Rr,...Kr,...Dr,...Pr,...Ir,...Cr,...Br,...Nr,...kr},Of={...Hr,...Tr};function lo(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var ho=lo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Fr=lo("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=lt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Xi={utf8:ho,"utf-8":ho,hex:qr.base16,latin1:Fr,ascii:Fr,binary:Fr,...qr},Ye=Xi;function tt(r,t="utf8"){let e=Ye[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function wt(r,t="utf8"){let e=Ye[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var $i=parseInt("11111",2),Vr=parseInt("10000000",2),Ji=parseInt("01111111",2),po={0:Ce,1:Ce,2:Qi,3:rc,4:nc,5:ec,6:tc,16:Ce,22:Ce,48:Ce};function jr(r,t={offset:0}){let e=r[t.offset]&$i;if(t.offset++,po[e]!=null)return po[e](r,t);throw new Error("No decoder for tag "+e)}function Le(r,t){let e=0;if((r[t.offset]&Vr)===Vr){let n=r[t.offset]&Ji,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function Ce(r,t){Le(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=jr(r,t);if(n===null)break;e.push(n)}return e}function Qi(r,t){let e=Le(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function tc(r,t){let e=Le(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let c=`${s}.${i}`,a=[];for(;t.offset<n;){let h=r[t.offset];if(t.offset++,a.push(h&127),h<128){a.reverse();let f=0;for(let u=0;u<a.length;u++)f+=a[u]<<u*7;c+=`.${f}`,a=[]}}return c}function ec(r,t){return t.offset++,null}function rc(r,t){let e=Le(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function nc(r,t){let e=Le(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function oc(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new dt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function Gr(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=oc(r.byteLength);return new dt(Uint8Array.from([t.byteLength|Vr]),t)}function mo(r){let t=new dt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new dt(Uint8Array.from([2]),Gr(t),t)}function yo(r){let t=Uint8Array.from([0]),e=new dt(t,r);return new dt(Uint8Array.from([3]),Gr(e),e)}function We(r,t=48){let e=new dt;for(let n of r)e.append(n);return new dt(Uint8Array.from([t]),Gr(e),e)}async function xo(r,t,e){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,e.subarray())}var sc=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),ic=Uint8Array.from([6,5,43,129,4,0,34]),cc=Uint8Array.from([6,5,43,129,4,0,35]),ac={ext:!0,kty:"EC",crv:"P-256"},fc={ext:!0,kty:"EC",crv:"P-384"},uc={ext:!0,kty:"EC",crv:"P-521"},Zr=32,Yr=48,Wr=66;function go(r){let t=jr(r);return bo(t)}function bo(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===Zr*2+1)return n=wt(t.subarray(e,e+Zr),"base64url"),o=wt(t.subarray(e+Zr),"base64url"),new he({...ac,key_ops:["verify"],x:n,y:o});if(t.byteLength===Yr*2+1)return n=wt(t.subarray(e,e+Yr),"base64url"),o=wt(t.subarray(e+Yr),"base64url"),new he({...fc,key_ops:["verify"],x:n,y:o});if(t.byteLength===Wr*2+1)return n=wt(t.subarray(e,e+Wr),"base64url"),o=wt(t.subarray(e+Wr),"base64url"),new he({...uc,key_ops:["verify"],x:n,y:o});throw new It(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function wo(r){return We([mo(Uint8Array.from([1])),We([hc(r.crv)],160),We([yo(new dt(Uint8Array.from([4]),tt(r.x??"","base64url"),tt(r.y??"","base64url")))],161)]).subarray()}function hc(r){if(r==="P-256")return sc;if(r==="P-384")return ic;if(r==="P-521")return cc;throw new It(`Invalid curve ${r}`)}var he=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=wo(this.jwk)),this._raw}toMultihash(){return gt.digest(le(this))}toCID(){return at.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}async verify(t,e){return xo(this.jwk,e,t)}};function Eo(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function lc(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function de(r,...t){if(!lc(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function _o(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Eo(r.outputLen),Eo(r.blockLen)}function pe(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function So(r,t){de(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var Wt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Xe(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Et(r,t){return r<<32-t|r>>>t}var bu=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function";function Ao(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Ue(r){return typeof r=="string"&&(r=Ao(r)),de(r),r}function Xr(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];de(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var me=class{clone(){return this._cloneInto()}};function $e(r){let t=n=>r().update(Ue(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Je(r=32){if(Wt&&typeof Wt.getRandomValues=="function")return Wt.getRandomValues(new Uint8Array(r));if(Wt&&typeof Wt.randomBytes=="function")return Uint8Array.from(Wt.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function dc(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),c=Number(e&s),a=n?4:0,h=n?0:4;r.setUint32(t+a,i,n),r.setUint32(t+h,c,n)}function vo(r,t,e){return r&t^~r&e}function Bo(r,t,e){return r&t^r&e^t&e}var ye=class extends me{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=Xe(this.buffer)}update(t){pe(this);let{view:e,buffer:n,blockLen:o}=this;t=Ue(t);let s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=Xe(t);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){pe(this),So(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let u=i;u<o;u++)e[u]=0;dc(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=Xe(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let h=a/4,f=this.get();if(h>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<h;u++)c.setUint32(4*u,f[u],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=i,o%e&&t.buffer.set(n),t}};var pc=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),kt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Nt=new Uint32Array(64),$r=class extends ye{constructor(t=32){super(64,t,8,!1),this.A=kt[0]|0,this.B=kt[1]|0,this.C=kt[2]|0,this.D=kt[3]|0,this.E=kt[4]|0,this.F=kt[5]|0,this.G=kt[6]|0,this.H=kt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[t,e,n,o,s,i,c,a]}set(t,e,n,o,s,i,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,e){for(let u=0;u<16;u++,e+=4)Nt[u]=t.getUint32(e,!1);for(let u=16;u<64;u++){let m=Nt[u-15],_=Nt[u-2],E=Et(m,7)^Et(m,18)^m>>>3,y=Et(_,17)^Et(_,19)^_>>>10;Nt[u]=y+Nt[u-7]+E+Nt[u-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:h,H:f}=this;for(let u=0;u<64;u++){let m=Et(c,6)^Et(c,11)^Et(c,25),_=f+m+vo(c,a,h)+pc[u]+Nt[u]|0,y=(Et(n,2)^Et(n,13)^Et(n,22))+Bo(n,o,s)|0;f=h,h=a,a=c,c=i+_|0,i=s,s=o,o=n,n=_+y|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,h=h+this.G|0,f=f+this.H|0,this.set(n,o,s,i,c,a,h,f)}roundClean(){Nt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Jr=$e(()=>new $r);var Qe=BigInt(4294967295),Qr=BigInt(32);function Io(r,t=!1){return t?{h:Number(r&Qe),l:Number(r>>Qr&Qe)}:{h:Number(r>>Qr&Qe)|0,l:Number(r&Qe)|0}}function mc(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:i}=Io(r[o],t);[e[o],n[o]]=[s,i]}return[e,n]}var yc=(r,t)=>BigInt(r>>>0)<<Qr|BigInt(t>>>0),xc=(r,t,e)=>r>>>e,gc=(r,t,e)=>r<<32-e|t>>>e,bc=(r,t,e)=>r>>>e|t<<32-e,wc=(r,t,e)=>r<<32-e|t>>>e,Ec=(r,t,e)=>r<<64-e|t>>>e-32,_c=(r,t,e)=>r>>>e-32|t<<64-e,Sc=(r,t)=>t,Ac=(r,t)=>r,vc=(r,t,e)=>r<<e|t>>>32-e,Bc=(r,t,e)=>t<<e|r>>>32-e,Ic=(r,t,e)=>t<<e-32|r>>>64-e,Cc=(r,t,e)=>r<<e-32|t>>>64-e;function Lc(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var Uc=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Tc=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Dc=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Pc=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Rc=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),kc=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Nc={fromBig:Io,split:mc,toBig:yc,shrSH:xc,shrSL:gc,rotrSH:bc,rotrSL:wc,rotrBH:Ec,rotrBL:_c,rotr32H:Sc,rotr32L:Ac,rotlSH:vc,rotlSL:Bc,rotlBH:Ic,rotlBL:Cc,add:Lc,add3L:Uc,add3H:Tc,add4L:Dc,add4H:Pc,add5H:kc,add5L:Rc},R=Nc;var[Kc,Oc]=R.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Kt=new Uint32Array(80),Ot=new Uint32Array(80),tn=class extends ye{constructor(t=64){super(128,t,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:h,El:f,Fh:u,Fl:m,Gh:_,Gl:E,Hh:y,Hl:l}=this;return[t,e,n,o,s,i,c,a,h,f,u,m,_,E,y,l]}set(t,e,n,o,s,i,c,a,h,f,u,m,_,E,y,l){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=h|0,this.El=f|0,this.Fh=u|0,this.Fl=m|0,this.Gh=_|0,this.Gl=E|0,this.Hh=y|0,this.Hl=l|0}process(t,e){for(let p=0;p<16;p++,e+=4)Kt[p]=t.getUint32(e),Ot[p]=t.getUint32(e+=4);for(let p=16;p<80;p++){let v=Kt[p-15]|0,D=Ot[p-15]|0,T=R.rotrSH(v,D,1)^R.rotrSH(v,D,8)^R.shrSH(v,D,7),I=R.rotrSL(v,D,1)^R.rotrSL(v,D,8)^R.shrSL(v,D,7),C=Kt[p-2]|0,L=Ot[p-2]|0,F=R.rotrSH(C,L,19)^R.rotrBH(C,L,61)^R.shrSH(C,L,6),z=R.rotrSL(C,L,19)^R.rotrBL(C,L,61)^R.shrSL(C,L,6),N=R.add4L(I,z,Ot[p-7],Ot[p-16]),$=R.add4H(N,T,F,Kt[p-7],Kt[p-16]);Kt[p]=$|0,Ot[p]=N|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:h,Dl:f,Eh:u,El:m,Fh:_,Fl:E,Gh:y,Gl:l,Hh:g,Hl:A}=this;for(let p=0;p<80;p++){let v=R.rotrSH(u,m,14)^R.rotrSH(u,m,18)^R.rotrBH(u,m,41),D=R.rotrSL(u,m,14)^R.rotrSL(u,m,18)^R.rotrBL(u,m,41),T=u&_^~u&y,I=m&E^~m&l,C=R.add5L(A,D,I,Oc[p],Ot[p]),L=R.add5H(C,g,v,T,Kc[p],Kt[p]),F=C|0,z=R.rotrSH(n,o,28)^R.rotrBH(n,o,34)^R.rotrBH(n,o,39),N=R.rotrSL(n,o,28)^R.rotrBL(n,o,34)^R.rotrBL(n,o,39),$=n&s^n&c^s&c,w=o&i^o&a^i&a;g=y|0,A=l|0,y=_|0,l=E|0,_=u|0,E=m|0,{h:u,l:m}=R.add(h|0,f|0,L|0,F|0),h=c|0,f=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let B=R.add3L(F,N,w);n=R.add3H(B,L,z,$),o=B|0}({h:n,l:o}=R.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=R.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=R.add(this.Ch|0,this.Cl|0,c|0,a|0),{h,l:f}=R.add(this.Dh|0,this.Dl|0,h|0,f|0),{h:u,l:m}=R.add(this.Eh|0,this.El|0,u|0,m|0),{h:_,l:E}=R.add(this.Fh|0,this.Fl|0,_|0,E|0),{h:y,l}=R.add(this.Gh|0,this.Gl|0,y|0,l|0),{h:g,l:A}=R.add(this.Hh|0,this.Hl|0,g|0,A|0),this.set(n,o,s,i,c,a,h,f,u,m,_,E,y,l,g,A)}roundClean(){Kt.fill(0),Ot.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var en=$e(()=>new tn);var sn=BigInt(0),on=BigInt(1);function Xt(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function cn(r){if(!Xt(r))throw new Error("Uint8Array expected")}function At(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function Te(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Uo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?sn:BigInt("0x"+r)}var To=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Mc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Mt(r){if(cn(r),To)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=Mc[r[e]];return t}var Lt={_0:48,_9:57,A:65,F:70,a:97,f:102};function Co(r){if(r>=Lt._0&&r<=Lt._9)return r-Lt._0;if(r>=Lt.A&&r<=Lt.F)return r-(Lt.A-10);if(r>=Lt.a&&r<=Lt.f)return r-(Lt.a-10)}function De(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(To)return Uint8Array.fromHex(r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=Co(r.charCodeAt(s)),c=Co(r.charCodeAt(s+1));if(i===void 0||c===void 0){let a=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function Ut(r){return Uo(Mt(r))}function $t(r){return cn(r),Uo(Mt(Uint8Array.from(r).reverse()))}function Jt(r,t){return De(r.toString(16).padStart(t*2,"0"))}function xe(r,t){return Jt(r,t).reverse()}function G(r,t,e){let n;if(typeof t=="string")try{n=De(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(Xt(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function zt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];cn(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var rn=r=>typeof r=="bigint"&&sn<=r;function tr(r,t,e){return rn(r)&&rn(t)&&rn(e)&&t<=r&&r<e}function pt(r,t,e,n){if(!tr(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Do(r){let t;for(t=0;r>sn;r>>=on,t+=1);return t}var Qt=r=>(on<<BigInt(r))-on,nn=r=>new Uint8Array(r),Lo=r=>Uint8Array.from(r);function Po(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=nn(r),o=nn(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...u)=>e(o,n,...u),a=(u=nn(0))=>{o=c(Lo([0]),u),n=c(),u.length!==0&&(o=c(Lo([1]),u),n=c())},h=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let u=0,m=[];for(;u<t;){n=c();let _=n.slice();m.push(_),u+=n.length}return zt(...m)};return(u,m)=>{i(),a(u);let _;for(;!(_=m(h()));)a();return i(),_}}var zc={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Xt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Tt(r,t,e={}){let n=(o,s,i)=>{let c=zc[s];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(i&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+a)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}function ge(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var J=BigInt(0),V=BigInt(1),te=BigInt(2),Hc=BigInt(3),an=BigInt(4),Ro=BigInt(5),ko=BigInt(8),qc=BigInt(9),Fc=BigInt(16);function q(r,t){let e=r%t;return e>=J?e:t+e}function Vc(r,t,e){if(t<J)throw new Error("invalid exponent, negatives unsupported");if(e<=J)throw new Error("invalid modulus");if(e===V)return J;let n=V;for(;t>J;)t&V&&(n=n*r%e),r=r*r%e,t>>=V;return n}function j(r,t,e){let n=r;for(;t-- >J;)n*=n,n%=e;return n}function er(r,t){if(r===J)throw new Error("invert: expected non-zero number");if(t<=J)throw new Error("invert: expected positive modulus, got "+t);let e=q(r,t),n=t,o=J,s=V,i=V,c=J;for(;e!==J;){let h=n/e,f=n%e,u=o-i*h,m=s-c*h;n=e,e=f,o=i,s=c,i=u,c=m}if(n!==V)throw new Error("invert: does not exist");return q(o,t)}function jc(r){let t=(r-V)/te,e,n,o;for(e=r-V,n=0;e%te===J;e/=te,n++);for(o=te;o<r&&Vc(o,t,r)!==r-V;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let i=(r+V)/an;return function(a,h){let f=a.pow(h,i);if(!a.eql(a.sqr(f),h))throw new Error("Cannot find square root");return f}}let s=(e+V)/te;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let h=n,f=c.pow(c.mul(c.ONE,o),e),u=c.pow(a,s),m=c.pow(a,e);for(;!c.eql(m,c.ONE);){if(c.eql(m,c.ZERO))return c.ZERO;let _=1;for(let y=c.sqr(m);_<h&&!c.eql(y,c.ONE);_++)y=c.sqr(y);let E=c.pow(f,V<<BigInt(h-_-1));f=c.sqr(E),u=c.mul(u,E),m=c.mul(m,f),h=_}return u}}function Gc(r){if(r%an===Hc){let t=(r+V)/an;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%ko===Ro){let t=(r-Ro)/ko;return function(n,o){let s=n.mul(o,te),i=n.pow(s,t),c=n.mul(o,i),a=n.mul(n.mul(c,te),i),h=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(h),o))throw new Error("Cannot find square root");return h}}return r%Fc,jc(r)}var No=(r,t)=>(q(r,t)&V)===V,Zc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function fn(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Zc.reduce((n,o)=>(n[o]="function",n),t);return Tt(r,e)}function Yc(r,t,e){if(e<J)throw new Error("invalid exponent, negatives unsupported");if(e===J)return r.ONE;if(e===V)return t;let n=r.ONE,o=t;for(;e>J;)e&V&&(n=r.mul(n,o)),o=r.sqr(o),e>>=V;return n}function Wc(r,t){let e=new Array(t.length),n=t.reduce((s,i,c)=>r.is0(i)?s:(e[c]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return t.reduceRight((s,i,c)=>r.is0(i)?s:(e[c]=r.mul(s,e[c]),r.mul(s,i)),o),e}function un(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Ht(r,t,e=!1,n={}){if(r<=J)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=un(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,c=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:Qt(o),ZERO:J,ONE:V,create:a=>q(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return J<=a&&a<r},is0:a=>a===J,isOdd:a=>(a&V)===V,neg:a=>q(-a,r),eql:(a,h)=>a===h,sqr:a=>q(a*a,r),add:(a,h)=>q(a+h,r),sub:(a,h)=>q(a-h,r),mul:(a,h)=>q(a*h,r),pow:(a,h)=>Yc(c,a,h),div:(a,h)=>q(a*er(h,r),r),sqrN:a=>a*a,addN:(a,h)=>a+h,subN:(a,h)=>a-h,mulN:(a,h)=>a*h,inv:a=>er(a,r),sqrt:n.sqrt||(a=>(i||(i=Gc(r)),i(c,a))),invertBatch:a=>Wc(c,a),cmov:(a,h,f)=>f?h:a,toBytes:a=>e?xe(a,s):Jt(a,s),fromBytes:a=>{if(a.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+a.length);return e?$t(a):Ut(a)}});return Object.freeze(c)}function Ko(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function hn(r){let t=Ko(r);return t+Math.ceil(t/2)}function Oo(r,t,e=!1){let n=r.length,o=Ko(t),s=hn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?$t(r):Ut(r),c=q(i,t-V)+V;return e?xe(c,o):Jt(c,o)}var Mo=BigInt(0),yn=BigInt(1);function ln(r,t){let e=t.negate();return r?e:t}function Ho(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function dn(r,t){Ho(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=Qt(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function zo(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,c=Number(r&o),a=r>>i;c>n&&(c-=s,a+=yn);let h=t*n,f=h+Math.abs(c)-1,u=c===0,m=c<0,_=t%2!==0;return{nextN:a,offset:f,isZero:u,isNeg:m,isNegF:_,offsetF:h}}function Xc(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function $c(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var pn=new WeakMap,qo=new WeakMap;function mn(r){return qo.get(r)||1}function rr(r,t){return{constTimeNegate:ln,hasPrecomputes(e){return mn(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Mo;)n&yn&&(o=o.add(s)),s=s.double(),n>>=yn;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=dn(n,t),i=[],c=e,a=c;for(let h=0;h<o;h++){a=c,i.push(a);for(let f=1;f<s;f++)a=a.add(c),i.push(a);c=a.double()}return i},wNAF(e,n,o){let s=r.ZERO,i=r.BASE,c=dn(e,t);for(let a=0;a<c.windows;a++){let{nextN:h,offset:f,isZero:u,isNeg:m,isNegF:_,offsetF:E}=zo(o,a,c);o=h,u?i=i.add(ln(_,n[E])):s=s.add(ln(m,n[f]))}return{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=dn(e,t);for(let c=0;c<i.windows&&o!==Mo;c++){let{nextN:a,offset:h,isZero:f,isNeg:u}=zo(o,c,i);if(o=a,!f){let m=n[h];s=s.add(u?m.negate():m)}}return s},getPrecomputes(e,n,o){let s=pn.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&pn.set(n,o(s))),s},wNAFCached(e,n,o){let s=mn(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=mn(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){Ho(n,t),qo.set(e,n),pn.delete(e)}}}function nr(r,t,e,n){if(Xc(e,r),$c(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,s=Do(BigInt(e.length)),i=s>12?s-3:s>4?s-2:s?2:1,c=Qt(i),a=new Array(Number(c)+1).fill(o),h=Math.floor((t.BITS-1)/i)*i,f=o;for(let u=h;u>=0;u-=i){a.fill(o);for(let _=0;_<n.length;_++){let E=n[_],y=Number(E>>BigInt(u)&c);a[y]=a[y].add(e[_])}let m=o;for(let _=a.length-1,E=o;_>0;_--)E=E.add(a[_]),m=m.add(E);if(f=f.add(m),u!==0)for(let _=0;_<i;_++)f=f.double()}return f}function Pe(r){return fn(r.Fp),Tt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...un(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var vt=BigInt(0),st=BigInt(1),Fo=BigInt(2),Jc=BigInt(8),Qc={zip215:!0};function ta(r){let t=Pe(r);return Tt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Vo(r){let t=ta(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:c,h:a}=t,h=Fo<<BigInt(c*8)-st,f=e.create,u=Ht(t.n,t.nBitLength),m=t.uvRatio||((x,d)=>{try{return{isValid:!0,value:e.sqrt(x*e.inv(d))}}catch{return{isValid:!1,value:vt}}}),_=t.adjustScalarBytes||(x=>x),E=t.domain||((x,d,b)=>{if(At("phflag",b),d.length||b)throw new Error("Contexts/pre-hash are not supported");return x});function y(x,d,b=!1){let S=b?st:vt;pt("coordinate "+x,d,S,h)}function l(x){if(!(x instanceof p))throw new Error("ExtendedPoint expected")}let g=ge((x,d)=>{let{ex:b,ey:S,ez:P}=x,k=x.is0();d==null&&(d=k?Jc:e.inv(P));let K=f(b*d),O=f(S*d),M=f(P*d);if(k)return{x:vt,y:st};if(M!==st)throw new Error("invZ was invalid");return{x:K,y:O}}),A=ge(x=>{let{a:d,d:b}=t;if(x.is0())throw new Error("bad point: ZERO");let{ex:S,ey:P,ez:k,et:K}=x,O=f(S*S),M=f(P*P),H=f(k*k),X=f(H*H),Y=f(O*d),rt=f(H*f(Y+M)),ct=f(X+f(b*f(O*M)));if(rt!==ct)throw new Error("bad point: equation left != right (1)");let Q=f(S*P),nt=f(k*K);if(Q!==nt)throw new Error("bad point: equation left != right (2)");return!0});class p{constructor(d,b,S,P){y("x",d),y("y",b),y("z",S,!0),y("t",P),this.ex=d,this.ey=b,this.ez=S,this.et=P,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(d){if(d instanceof p)throw new Error("extended point not allowed");let{x:b,y:S}=d||{};return y("x",b),y("y",S),new p(b,S,st,f(b*S))}static normalizeZ(d){let b=e.invertBatch(d.map(S=>S.ez));return d.map((S,P)=>S.toAffine(b[P])).map(p.fromAffine)}static msm(d,b){return nr(p,u,d,b)}_setWindowSize(d){T.setWindowSize(this,d)}assertValidity(){A(this)}equals(d){l(d);let{ex:b,ey:S,ez:P}=this,{ex:k,ey:K,ez:O}=d,M=f(b*O),H=f(k*P),X=f(S*O),Y=f(K*P);return M===H&&X===Y}is0(){return this.equals(p.ZERO)}negate(){return new p(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:d}=t,{ex:b,ey:S,ez:P}=this,k=f(b*b),K=f(S*S),O=f(Fo*f(P*P)),M=f(d*k),H=b+S,X=f(f(H*H)-k-K),Y=M+K,rt=Y-O,ct=M-K,Q=f(X*rt),nt=f(Y*ct),ft=f(X*ct),xt=f(rt*Y);return new p(Q,nt,xt,ft)}add(d){l(d);let{a:b,d:S}=t,{ex:P,ey:k,ez:K,et:O}=this,{ex:M,ey:H,ez:X,et:Y}=d,rt=f(P*M),ct=f(k*H),Q=f(O*S*Y),nt=f(K*X),ft=f((P+k)*(M+H)-rt-ct),xt=nt-Q,we=nt+Q,Vn=f(ct-b*rt),Ks=f(ft*xt),Os=f(we*Vn),Ms=f(ft*Vn),zs=f(xt*we);return new p(Ks,Os,zs,Ms)}subtract(d){return this.add(d.negate())}wNAF(d){return T.wNAFCached(this,d,p.normalizeZ)}multiply(d){let b=d;pt("scalar",b,st,n);let{p:S,f:P}=this.wNAF(b);return p.normalizeZ([S,P])[0]}multiplyUnsafe(d,b=p.ZERO){let S=d;return pt("scalar",S,vt,n),S===vt?D:this.is0()||S===st?this:T.wNAFCachedUnsafe(this,S,p.normalizeZ,b)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return T.unsafeLadder(this,n).is0()}toAffine(d){return g(this,d)}clearCofactor(){let{h:d}=t;return d===st?this:this.multiplyUnsafe(d)}static fromHex(d,b=!1){let{d:S,a:P}=t,k=e.BYTES;d=G("pointHex",d,k),At("zip215",b);let K=d.slice(),O=d[k-1];K[k-1]=O&-129;let M=$t(K),H=b?h:e.ORDER;pt("pointHex.y",M,vt,H);let X=f(M*M),Y=f(X-st),rt=f(S*X-P),{isValid:ct,value:Q}=m(Y,rt);if(!ct)throw new Error("Point.fromHex: invalid y coordinate");let nt=(Q&st)===st,ft=(O&128)!==0;if(!b&&Q===vt&&ft)throw new Error("Point.fromHex: x=0 and x_0=1");return ft!==nt&&(Q=f(-Q)),p.fromAffine({x:Q,y:M})}static fromPrivateKey(d){let{scalar:b}=L(d);return v.multiply(b)}toRawBytes(){let{x:d,y:b}=this.toAffine(),S=xe(b,e.BYTES);return S[S.length-1]|=d&st?128:0,S}toHex(){return Mt(this.toRawBytes())}}p.BASE=new p(t.Gx,t.Gy,st,f(t.Gx*t.Gy)),p.ZERO=new p(vt,st,st,vt);let{BASE:v,ZERO:D}=p,T=rr(p,c*8);function I(x){return q(x,n)}function C(x){return I($t(x))}function L(x){let d=e.BYTES;x=G("private key",x,d);let b=G("hashed private key",s(x),2*d),S=_(b.slice(0,d)),P=b.slice(d,2*d),k=C(S);return{head:S,prefix:P,scalar:k}}function F(x){let{head:d,prefix:b,scalar:S}=L(x),P=v.multiply(S),k=P.toRawBytes();return{head:d,prefix:b,scalar:S,point:P,pointBytes:k}}function z(x){return F(x).pointBytes}function N(x=new Uint8Array,...d){let b=zt(...d);return C(s(E(b,G("context",x),!!o)))}function $(x,d,b={}){x=G("message",x),o&&(x=o(x));let{prefix:S,scalar:P,pointBytes:k}=F(d),K=N(b.context,S,x),O=v.multiply(K).toRawBytes(),M=N(b.context,O,k,x),H=I(K+M*P);pt("signature.s",H,vt,n);let X=zt(O,xe(H,e.BYTES));return G("result",X,e.BYTES*2)}let w=Qc;function B(x,d,b,S=w){let{context:P,zip215:k}=S,K=e.BYTES;x=G("signature",x,2*K),d=G("message",d),b=G("publicKey",b,K),k!==void 0&&At("zip215",k),o&&(d=o(d));let O=$t(x.slice(K,2*K)),M,H,X;try{M=p.fromHex(b,k),H=p.fromHex(x.slice(0,K),k),X=v.multiplyUnsafe(O)}catch{return!1}if(!k&&M.isSmallOrder())return!1;let Y=N(P,H.toRawBytes(),M.toRawBytes(),d);return H.add(M.multiplyUnsafe(Y)).subtract(X).clearCofactor().equals(p.ZERO)}return v._setWindowSize(8),{CURVE:t,getPublicKey:z,sign:$,verify:B,ExtendedPoint:p,utils:{getExtendedPublicKey:F,randomPrivateKey:()=>i(e.BYTES),precompute(x=8,d=p.BASE){return d._setWindowSize(x),d.multiply(BigInt(3)),d}}}}var xn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),jo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),th=BigInt(0),ea=BigInt(1),Go=BigInt(2),eh=BigInt(3),ra=BigInt(5),na=BigInt(8);function oa(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=xn,c=r*r%s*r%s,a=j(c,Go,s)*c%s,h=j(a,ea,s)*r%s,f=j(h,ra,s)*h%s,u=j(f,t,s)*f%s,m=j(u,e,s)*u%s,_=j(m,n,s)*m%s,E=j(_,o,s)*_%s,y=j(E,o,s)*_%s,l=j(y,t,s)*f%s;return{pow_p_5_8:j(l,Go,s)*r%s,b2:c}}function sa(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function ia(r,t){let e=xn,n=q(t*t*t,e),o=q(n*n*t,e),s=oa(r*o).pow_p_5_8,i=q(r*n*s,e),c=q(t*i*i,e),a=i,h=q(i*jo,e),f=c===r,u=c===q(-r,e),m=c===q(-r*jo,e);return f&&(i=a),(u||m)&&(i=h),No(i,e)&&(i=q(-i,e)),{isValid:f||u,value:i}}var Zo=Ht(xn,void 0,!0),ca={a:Zo.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Zo,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:na,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:en,randomBytes:Je,adjustScalarBytes:sa,uvRatio:ia},Yo=Vo(ca);var or=32;function Wo(r,t,e){return Yo.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var sr=class{type="Ed25519";raw;constructor(t){this.raw=gn(t,or)}toMultihash(){return gt.digest(le(this))}toCID(){return at.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}verify(t,e){return Wo(this.raw,e,t)}};function $o(r){return r=gn(r,or),new sr(r)}function gn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new It(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var fa=Math.pow(2,7),ua=Math.pow(2,14),ha=Math.pow(2,21),Jo=Math.pow(2,28),Qo=Math.pow(2,35),ts=Math.pow(2,42),es=Math.pow(2,49),it=128,qt=127;function Re(r){if(r<fa)return 1;if(r<ua)return 2;if(r<ha)return 3;if(r<Jo)return 4;if(r<Qo)return 5;if(r<ts)return 6;if(r<es)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function rs(r,t,e=0){switch(Re(r)){case 8:t[e++]=r&255|it,r/=128;case 7:t[e++]=r&255|it,r/=128;case 6:t[e++]=r&255|it,r/=128;case 5:t[e++]=r&255|it,r/=128;case 4:t[e++]=r&255|it,r>>>=7;case 3:t[e++]=r&255|it,r>>>=7;case 2:t[e++]=r&255|it,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function ns(r,t){let e=r[t],n=0;if(n+=e&qt,e<it||(e=r[t+1],n+=(e&qt)<<7,e<it)||(e=r[t+2],n+=(e&qt)<<14,e<it)||(e=r[t+3],n+=(e&qt)<<21,e<it)||(e=r[t+4],n+=(e&qt)*Jo,e<it)||(e=r[t+5],n+=(e&qt)*Qo,e<it)||(e=r[t+6],n+=(e&qt)*ts,e<it)||(e=r[t+7],n+=(e&qt)*es,e<it))return n;throw new RangeError("Could not decode varint")}var bn=new Float32Array([-0]),Ft=new Uint8Array(bn.buffer);function os(r,t,e){bn[0]=r,t[e]=Ft[0],t[e+1]=Ft[1],t[e+2]=Ft[2],t[e+3]=Ft[3]}function ss(r,t){return Ft[0]=r[t],Ft[1]=r[t+1],Ft[2]=r[t+2],Ft[3]=r[t+3],bn[0]}var wn=new Float64Array([-0]),ot=new Uint8Array(wn.buffer);function is(r,t,e){wn[0]=r,t[e]=ot[0],t[e+1]=ot[1],t[e+2]=ot[2],t[e+3]=ot[3],t[e+4]=ot[4],t[e+5]=ot[5],t[e+6]=ot[6],t[e+7]=ot[7]}function cs(r,t){return ot[0]=r[t],ot[1]=r[t+1],ot[2]=r[t+2],ot[3]=r[t+3],ot[4]=r[t+4],ot[5]=r[t+5],ot[6]=r[t+6],ot[7]=r[t+7],wn[0]}var la=BigInt(Number.MAX_SAFE_INTEGER),da=BigInt(Number.MIN_SAFE_INTEGER),mt=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return ee;if(t<la&&t>da)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>as&&(o=0n,++n>as&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ee;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):ee}},ee=new mt(0,0);ee.toBigInt=function(){return 0n};ee.zzEncode=ee.zzDecode=function(){return this};ee.length=function(){return 1};var as=4294967296n;function fs(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function us(r,t,e){if(e-t<1)return"";let o,s=[],i=0,c;for(;t<e;)c=r[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function En(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function _t(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function ir(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var _n=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,_t(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 _t(this,4);return ir(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw _t(this,4);return ir(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw _t(this,4);let t=ss(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw _t(this,4);let t=cs(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw _t(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return us(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw _t(this,t);this.pos+=t}else do if(this.pos>=this.len)throw _t(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new mt(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw _t(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw _t(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw _t(this,8);let t=ir(this.buf,this.pos+=4),e=ir(this.buf,this.pos+=4);return new mt(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=ns(this.buf,this.pos);return this.pos+=Re(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Sn(r){return new _n(r instanceof Uint8Array?r:r.subarray())}function cr(r,t,e){let n=Sn(r);return t.decode(n,void 0,e)}function An(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return lt(i);o+i>t&&(n=lt(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,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function vn(){}var In=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},pa=An();function ma(r){return globalThis.Buffer!=null?lt(r):pa(r)}var Ne=class{len;head;tail;states;constructor(){this.len=0,this.head=new re(vn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new re(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Cn((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,mt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=mt.fromBigInt(t);return this._push(ar,e.length(),e)}uint64Number(t){return this._push(rs,Re(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=mt.fromBigInt(t).zzEncode();return this._push(ar,e.length(),e)}sint64Number(t){let e=mt.fromNumber(t).zzEncode();return this._push(ar,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Bn,1,t?1:0)}fixed32(t){return this._push(ke,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=mt.fromBigInt(t);return this._push(ke,4,e.lo)._push(ke,4,e.hi)}fixed64Number(t){let e=mt.fromNumber(t);return this._push(ke,4,e.lo)._push(ke,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(os,4,t)}double(t){return this._push(is,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Bn,1,0):this.uint32(e)._push(xa,e,t)}string(t){let e=fs(t);return e!==0?this.uint32(e)._push(En,e,t):this._push(Bn,1,0)}fork(){return this.states=new In(this),this.head=this.tail=new re(vn,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new re(vn,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=ma(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Bn(r,t,e){t[e]=r&255}function ya(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Cn=class extends re{next;constructor(t,e){super(ya,t,e),this.next=void 0}};function ar(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function ke(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function xa(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Ne.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(ga,t,r),this},Ne.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(ba,t,r),this});function ga(r,t,e){t.set(r,e)}function ba(r,t,e){r.length<40?En(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(tt(r),e)}function Ln(){return new Ne}function fr(r,t){let e=Ln();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var be;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(be||(be={}));function ur(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Un(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let c=t(s);i.int32(c)},n=function(s){let i=s.int32();return t(i)};return ur("enum",be.VARINT,e,n)}function hr(r,t){return ur("message",be.LENGTH_DELIMITED,r,t)}var yt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(yt||(yt={}));var Tn;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(Tn||(Tn={}));(function(r){r.codec=()=>Un(Tn)})(yt||(yt={}));var Ke;(function(r){let t;r.codec=()=>(t==null&&(t=hr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),yt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=yt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>fr(e,r.codec()),r.decode=(e,n)=>cr(e,r.codec(),n)})(Ke||(Ke={}));var Dn;(function(r){let t;r.codec=()=>(t==null&&(t=hr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),yt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=yt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>fr(e,r.codec()),r.decode=(e,n)=>cr(e,r.codec(),n)})(Dn||(Dn={}));var Oe=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var lr=class extends me{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,_o(t);let n=Ue(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(t){return pe(this),this.iHash.update(t),this}digestInto(t){pe(this),de(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Pn=(r,t,e)=>new lr(r,t).update(e).digest();Pn.create=(r,t)=>new lr(r,t);function ls(r){r.lowS!==void 0&&At("lowS",r.lowS),r.prehash!==void 0&&At("prehash",r.prehash)}function Ea(r){let t=Pe(r);Tt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var Rn=class extends Error{constructor(t=""){super(t)}},Dt={Err:Rn,_tlv:{encode:(r,t)=>{let{Err:e}=Dt;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=Te(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Te(o.length/2|128):"";return Te(r)+s+o+t},decode(r,t){let{Err:e}=Dt,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let a=o&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let h=t.subarray(n,n+a);if(h.length!==a)throw new e("tlv.decode: length bytes not complete");if(h[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let f of h)i=i<<8|f;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Dt;if(r<Pt)throw new t("integer: negative integers are not allowed");let e=Te(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=Dt;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Ut(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Dt,o=G("signature",r),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:h,l:f}=n.decode(2,a);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(h)}},hexFromSig(r){let{_tlv:t,_int:e}=Dt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},Pt=BigInt(0),et=BigInt(1),il=BigInt(2),ds=BigInt(3),cl=BigInt(4);function _a(r){let t=Ea(r),{Fp:e}=t,n=Ht(t.n,t.nBitLength),o=t.toBytes||((y,l,g)=>{let A=l.toAffine();return zt(Uint8Array.from([4]),e.toBytes(A.x),e.toBytes(A.y))}),s=t.fromBytes||(y=>{let l=y.subarray(1),g=e.fromBytes(l.subarray(0,e.BYTES)),A=e.fromBytes(l.subarray(e.BYTES,2*e.BYTES));return{x:g,y:A}});function i(y){let{a:l,b:g}=t,A=e.sqr(y),p=e.mul(A,y);return e.add(e.add(p,e.mul(y,l)),g)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function c(y){return tr(y,et,t.n)}function a(y){let{allowedPrivateKeyLengths:l,nByteLength:g,wrapPrivateKey:A,n:p}=t;if(l&&typeof y!="bigint"){if(Xt(y)&&(y=Mt(y)),typeof y!="string"||!l.includes(y.length))throw new Error("invalid private key");y=y.padStart(g*2,"0")}let v;try{v=typeof y=="bigint"?y:Ut(G("private key",y,g))}catch{throw new Error("invalid private key, expected hex or "+g+" bytes, got "+typeof y)}return A&&(v=q(v,p)),pt("private key",v,et,p),v}function h(y){if(!(y instanceof m))throw new Error("ProjectivePoint expected")}let f=ge((y,l)=>{let{px:g,py:A,pz:p}=y;if(e.eql(p,e.ONE))return{x:g,y:A};let v=y.is0();l==null&&(l=v?e.ONE:e.inv(p));let D=e.mul(g,l),T=e.mul(A,l),I=e.mul(p,l);if(v)return{x:e.ZERO,y:e.ZERO};if(!e.eql(I,e.ONE))throw new Error("invZ was invalid");return{x:D,y:T}}),u=ge(y=>{if(y.is0()){if(t.allowInfinityPoint&&!e.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:l,y:g}=y.toAffine();if(!e.isValid(l)||!e.isValid(g))throw new Error("bad point: x or y not FE");let A=e.sqr(g),p=i(l);if(!e.eql(A,p))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(l,g,A){if(l==null||!e.isValid(l))throw new Error("x required");if(g==null||!e.isValid(g))throw new Error("y required");if(A==null||!e.isValid(A))throw new Error("z required");this.px=l,this.py=g,this.pz=A,Object.freeze(this)}static fromAffine(l){let{x:g,y:A}=l||{};if(!l||!e.isValid(g)||!e.isValid(A))throw new Error("invalid affine point");if(l instanceof m)throw new Error("projective point not allowed");let p=v=>e.eql(v,e.ZERO);return p(g)&&p(A)?m.ZERO:new m(g,A,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(l){let g=e.invertBatch(l.map(A=>A.pz));return l.map((A,p)=>A.toAffine(g[p])).map(m.fromAffine)}static fromHex(l){let g=m.fromAffine(s(G("pointHex",l)));return g.assertValidity(),g}static fromPrivateKey(l){return m.BASE.multiply(a(l))}static msm(l,g){return nr(m,n,l,g)}_setWindowSize(l){E.setWindowSize(this,l)}assertValidity(){u(this)}hasEvenY(){let{y:l}=this.toAffine();if(e.isOdd)return!e.isOdd(l);throw new Error("Field doesn't support isOdd")}equals(l){h(l);let{px:g,py:A,pz:p}=this,{px:v,py:D,pz:T}=l,I=e.eql(e.mul(g,T),e.mul(v,p)),C=e.eql(e.mul(A,T),e.mul(D,p));return I&&C}negate(){return new m(this.px,e.neg(this.py),this.pz)}double(){let{a:l,b:g}=t,A=e.mul(g,ds),{px:p,py:v,pz:D}=this,T=e.ZERO,I=e.ZERO,C=e.ZERO,L=e.mul(p,p),F=e.mul(v,v),z=e.mul(D,D),N=e.mul(p,v);return N=e.add(N,N),C=e.mul(p,D),C=e.add(C,C),T=e.mul(l,C),I=e.mul(A,z),I=e.add(T,I),T=e.sub(F,I),I=e.add(F,I),I=e.mul(T,I),T=e.mul(N,T),C=e.mul(A,C),z=e.mul(l,z),N=e.sub(L,z),N=e.mul(l,N),N=e.add(N,C),C=e.add(L,L),L=e.add(C,L),L=e.add(L,z),L=e.mul(L,N),I=e.add(I,L),z=e.mul(v,D),z=e.add(z,z),L=e.mul(z,N),T=e.sub(T,L),C=e.mul(z,F),C=e.add(C,C),C=e.add(C,C),new m(T,I,C)}add(l){h(l);let{px:g,py:A,pz:p}=this,{px:v,py:D,pz:T}=l,I=e.ZERO,C=e.ZERO,L=e.ZERO,F=t.a,z=e.mul(t.b,ds),N=e.mul(g,v),$=e.mul(A,D),w=e.mul(p,T),B=e.add(g,A),U=e.add(v,D);B=e.mul(B,U),U=e.add(N,$),B=e.sub(B,U),U=e.add(g,p);let x=e.add(v,T);return U=e.mul(U,x),x=e.add(N,w),U=e.sub(U,x),x=e.add(A,p),I=e.add(D,T),x=e.mul(x,I),I=e.add($,w),x=e.sub(x,I),L=e.mul(F,U),I=e.mul(z,w),L=e.add(I,L),I=e.sub($,L),L=e.add($,L),C=e.mul(I,L),$=e.add(N,N),$=e.add($,N),w=e.mul(F,w),U=e.mul(z,U),$=e.add($,w),w=e.sub(N,w),w=e.mul(F,w),U=e.add(U,w),N=e.mul($,U),C=e.add(C,N),N=e.mul(x,U),I=e.mul(B,I),I=e.sub(I,N),N=e.mul(B,$),L=e.mul(x,L),L=e.add(L,N),new m(I,C,L)}subtract(l){return this.add(l.negate())}is0(){return this.equals(m.ZERO)}wNAF(l){return E.wNAFCached(this,l,m.normalizeZ)}multiplyUnsafe(l){let{endo:g,n:A}=t;pt("scalar",l,Pt,A);let p=m.ZERO;if(l===Pt)return p;if(this.is0()||l===et)return this;if(!g||E.hasPrecomputes(this))return E.wNAFCachedUnsafe(this,l,m.normalizeZ);let{k1neg:v,k1:D,k2neg:T,k2:I}=g.splitScalar(l),C=p,L=p,F=this;for(;D>Pt||I>Pt;)D&et&&(C=C.add(F)),I&et&&(L=L.add(F)),F=F.double(),D>>=et,I>>=et;return v&&(C=C.negate()),T&&(L=L.negate()),L=new m(e.mul(L.px,g.beta),L.py,L.pz),C.add(L)}multiply(l){let{endo:g,n:A}=t;pt("scalar",l,et,A);let p,v;if(g){let{k1neg:D,k1:T,k2neg:I,k2:C}=g.splitScalar(l),{p:L,f:F}=this.wNAF(T),{p:z,f:N}=this.wNAF(C);L=E.constTimeNegate(D,L),z=E.constTimeNegate(I,z),z=new m(e.mul(z.px,g.beta),z.py,z.pz),p=L.add(z),v=F.add(N)}else{let{p:D,f:T}=this.wNAF(l);p=D,v=T}return m.normalizeZ([p,v])[0]}multiplyAndAddUnsafe(l,g,A){let p=m.BASE,v=(T,I)=>I===Pt||I===et||!T.equals(p)?T.multiplyUnsafe(I):T.multiply(I),D=v(this,g).add(v(l,A));return D.is0()?void 0:D}toAffine(l){return f(this,l)}isTorsionFree(){let{h:l,isTorsionFree:g}=t;if(l===et)return!0;if(g)return g(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:l,clearCofactor:g}=t;return l===et?this:g?g(m,this):this.multiplyUnsafe(t.h)}toRawBytes(l=!0){return At("isCompressed",l),this.assertValidity(),o(m,this,l)}toHex(l=!0){return At("isCompressed",l),Mt(this.toRawBytes(l))}}m.BASE=new m(t.Gx,t.Gy,e.ONE),m.ZERO=new m(e.ZERO,e.ONE,e.ZERO);let _=t.nBitLength,E=rr(m,t.endo?Math.ceil(_/2):_);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:c}}function Sa(r){let t=Pe(r);return Tt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function ps(r){let t=Sa(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(w){return q(w,n)}function c(w){return er(w,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:h,weierstrassEquation:f,isWithinCurveOrder:u}=_a({...t,toBytes(w,B,U){let x=B.toAffine(),d=e.toBytes(x.x),b=zt;return At("isCompressed",U),U?b(Uint8Array.from([B.hasEvenY()?2:3]),d):b(Uint8Array.from([4]),d,e.toBytes(x.y))},fromBytes(w){let B=w.length,U=w[0],x=w.subarray(1);if(B===o&&(U===2||U===3)){let d=Ut(x);if(!tr(d,et,e.ORDER))throw new Error("Point is not on curve");let b=f(d),S;try{S=e.sqrt(b)}catch(K){let O=K instanceof Error?": "+K.message:"";throw new Error("Point is not on curve"+O)}let P=(S&et)===et;return(U&1)===1!==P&&(S=e.neg(S)),{x:d,y:S}}else if(B===s&&U===4){let d=e.fromBytes(x.subarray(0,e.BYTES)),b=e.fromBytes(x.subarray(e.BYTES,2*e.BYTES));return{x:d,y:b}}else{let d=o,b=s;throw new Error("invalid Point, expected length of "+d+", or uncompressed "+b+", got "+B)}}}),m=w=>Mt(Jt(w,t.nByteLength));function _(w){let B=n>>et;return w>B}function E(w){return _(w)?i(-w):w}let y=(w,B,U)=>Ut(w.slice(B,U));class l{constructor(B,U,x){pt("r",B,et,n),pt("s",U,et,n),this.r=B,this.s=U,x!=null&&(this.recovery=x),Object.freeze(this)}static fromCompact(B){let U=t.nByteLength;return B=G("compactSignature",B,U*2),new l(y(B,0,U),y(B,U,2*U))}static fromDER(B){let{r:U,s:x}=Dt.toSig(G("DER",B));return new l(U,x)}assertValidity(){}addRecoveryBit(B){return new l(this.r,this.s,B)}recoverPublicKey(B){let{r:U,s:x,recovery:d}=this,b=T(G("msgHash",B));if(d==null||![0,1,2,3].includes(d))throw new Error("recovery id invalid");let S=d===2||d===3?U+t.n:U;if(S>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let P=(d&1)===0?"02":"03",k=a.fromHex(P+m(S)),K=c(S),O=i(-b*K),M=i(x*K),H=a.BASE.multiplyAndAddUnsafe(k,O,M);if(!H)throw new Error("point at infinify");return H.assertValidity(),H}hasHighS(){return _(this.s)}normalizeS(){return this.hasHighS()?new l(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return De(this.toDERHex())}toDERHex(){return Dt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return De(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let g={isValidPrivateKey(w){try{return h(w),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{let w=hn(t.n);return Oo(t.randomBytes(w),t.n)},precompute(w=8,B=a.BASE){return B._setWindowSize(w),B.multiply(BigInt(3)),B}};function A(w,B=!0){return a.fromPrivateKey(w).toRawBytes(B)}function p(w){let B=Xt(w),U=typeof w=="string",x=(B||U)&&w.length;return B?x===o||x===s:U?x===2*o||x===2*s:w instanceof a}function v(w,B,U=!0){if(p(w))throw new Error("first arg must be private key");if(!p(B))throw new Error("second arg must be public key");return a.fromHex(B).multiply(h(w)).toRawBytes(U)}let D=t.bits2int||function(w){if(w.length>8192)throw new Error("input is too large");let B=Ut(w),U=w.length*8-t.nBitLength;return U>0?B>>BigInt(U):B},T=t.bits2int_modN||function(w){return i(D(w))},I=Qt(t.nBitLength);function C(w){return pt("num < 2^"+t.nBitLength,w,Pt,I),Jt(w,t.nByteLength)}function L(w,B,U=F){if(["recovered","canonical"].some(Y=>Y in U))throw new Error("sign() legacy options not supported");let{hash:x,randomBytes:d}=t,{lowS:b,prehash:S,extraEntropy:P}=U;b==null&&(b=!0),w=G("msgHash",w),ls(U),S&&(w=G("prehashed msgHash",x(w)));let k=T(w),K=h(B),O=[C(K),C(k)];if(P!=null&&P!==!1){let Y=P===!0?d(e.BYTES):P;O.push(G("extraEntropy",Y))}let M=zt(...O),H=k;function X(Y){let rt=D(Y);if(!u(rt))return;let ct=c(rt),Q=a.BASE.multiply(rt).toAffine(),nt=i(Q.x);if(nt===Pt)return;let ft=i(ct*i(H+nt*K));if(ft===Pt)return;let xt=(Q.x===nt?0:2)|Number(Q.y&et),we=ft;return b&&_(ft)&&(we=E(ft),xt^=1),new l(nt,we,xt)}return{seed:M,k2sig:X}}let F={lowS:t.lowS,prehash:!1},z={lowS:t.lowS,prehash:!1};function N(w,B,U=F){let{seed:x,k2sig:d}=L(w,B,U),b=t;return Po(b.hash.outputLen,b.nByteLength,b.hmac)(x,d)}a.BASE._setWindowSize(8);function $(w,B,U,x=z){let d=w;B=G("msgHash",B),U=G("publicKey",U);let{lowS:b,prehash:S,format:P}=x;if(ls(x),"strict"in x)throw new Error("options.strict was renamed to lowS");if(P!==void 0&&P!=="compact"&&P!=="der")throw new Error("format must be compact or der");let k=typeof d=="string"||Xt(d),K=!k&&!P&&typeof d=="object"&&d!==null&&typeof d.r=="bigint"&&typeof d.s=="bigint";if(!k&&!K)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let O,M;try{if(K&&(O=new l(d.r,d.s)),k){try{P!=="compact"&&(O=l.fromDER(d))}catch(xt){if(!(xt instanceof Dt.Err))throw xt}!O&&P!=="der"&&(O=l.fromCompact(d))}M=a.fromHex(U)}catch{return!1}if(!O||b&&O.hasHighS())return!1;S&&(B=t.hash(B));let{r:H,s:X}=O,Y=T(B),rt=c(X),ct=i(Y*rt),Q=i(H*rt),nt=a.BASE.multiplyAndAddUnsafe(M,ct,Q)?.toAffine();return nt?i(nt.x)===H:!1}return{CURVE:t,getPublicKey:A,getSharedSecret:v,sign:N,verify:$,ProjectivePoint:a,Signature:l,utils:g}}function Aa(r){return{hash:r,hmac:(t,...e)=>Pn(r,t,Xr(...e)),randomBytes:Je}}function ms(r,t){let e=n=>ps({...r,...Aa(n)});return{...e(t),create:e}}var gs=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ys=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),va=BigInt(1),kn=BigInt(2),xs=(r,t)=>(r+t/kn)/t;function Ba(r){let t=gs,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),h=r*r*r%t,f=h*h*r%t,u=j(f,e,t)*f%t,m=j(u,e,t)*f%t,_=j(m,kn,t)*h%t,E=j(_,o,t)*_%t,y=j(E,s,t)*E%t,l=j(y,c,t)*y%t,g=j(l,a,t)*l%t,A=j(g,c,t)*y%t,p=j(A,e,t)*f%t,v=j(p,i,t)*E%t,D=j(v,n,t)*h%t,T=j(D,kn,t);if(!Nn.eql(Nn.sqr(T),r))throw new Error("Cannot find square root");return T}var Nn=Ht(gs,void 0,void 0,{sqrt:Ba}),ne=ms({a:BigInt(0),b:BigInt(7),Fp:Nn,n:ys,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=ys,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-va*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=xs(s*r,t),a=xs(-n*r,t),h=q(r-c*e-a*o,t),f=q(-c*n-a*s,t),u=h>i,m=f>i;if(u&&(h=t-h),m&&(f=t-f),h>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:u,k1:h,k2neg:m,k2:f}}}},Jr),yl=BigInt(0);var xl=ne.ProjectivePoint;function bs(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function ws(r,t,e){let n=Ie.digest(e instanceof Uint8Array?e:e.subarray());if(bs(n))return n.then(({digest:o})=>ne.verify(t,o,r)).catch(o=>{throw new Oe(String(o))});try{return ne.verify(t,n.digest,r)}catch(o){throw new Oe(String(o))}}var dr=class{type="secp256k1";raw;_key;constructor(t){this._key=_s(t),this.raw=Es(this._key)}toMultihash(){return gt.digest(le(this))}toCID(){return at.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}verify(t,e){return ws(this._key,e,t)}};function Ss(r){return new dr(r)}function Es(r){return ne.ProjectivePoint.fromHex(r).toRawBytes(!0)}function _s(r){try{return ne.ProjectivePoint.fromHex(r),r}catch(t){throw new Fe(String(t))}}function As(r){let{Type:t,Data:e}=Ke.decode(r.digest),n=e??new Uint8Array;switch(t){case yt.Ed25519:return $o(n);case yt.secp256k1:return Ss(n);case yt.ECDSA:return go(n);default:throw new Ee}}function le(r){return Ke.encode({Type:yt[r.type],Data:r.raw})}var vs=Symbol.for("nodejs.util.inspect.custom"),Ia=114,Me=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Er]=!0;toString(){return this.string==null&&(this.string=W.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return at.createV1(Ia,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return ht(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return ht(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[vs](){return`PeerId(${this.toString()})`}},pr=class extends Me{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},mr=class extends Me{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},yr=class extends Me{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Ca=2336,xr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=gt.digest(tt(this.url))}[vs](){return`PeerId(${this.url})`}[Er]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return at.createV1(Ca,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=wt(t)),t.toString()===this.toString())}};function Bs(r){if(Ua(r))return new pr({multihash:r});if(La(r))try{let t=As(r);if(t.type==="Ed25519")return new mr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new yr({multihash:r,publicKey:t})}catch{let e=wt(r.digest);return new xr(new URL(e))}throw new Ve("Supplied PeerID Multihash is invalid")}function La(r){return r.code===gt.code}function Ua(r){return r.code===Ie.code}function Bt(r,t){let e={[Symbol.iterator]:()=>e,next:()=>{let n=r.next(),o=n.value;return n.done===!0||o==null?{done:!0,value:void 0}:{done:!1,value:t(o)}}};return e}function gr(r){let t=ve(W.decode(`z${r}`));return Bs(t)}var Vt=class{map;constructor(t){if(this.map=new Map,t!=null)for(let[e,n]of t.entries())this.map.set(e.toString(),{key:e,value:n})}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(t){return this.map.delete(t.toString())}entries(){return Bt(this.map.entries(),t=>[t[1].key,t[1].value])}forEach(t){this.map.forEach((e,n)=>{t(e.value,e.key,this)})}get(t){return this.map.get(t.toString())?.value}has(t){return this.map.has(t.toString())}set(t,e){this.map.set(t.toString(),{key:t,value:e})}keys(){return Bt(this.map.values(),t=>t.key)}values(){return Bt(this.map.values(),t=>t.value)}get size(){return this.map.size}};function Is(){return new Vt}var jt=class r{set;constructor(t){if(this.set=new Set,t!=null)for(let e of t)this.set.add(e.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(t){this.set.add(t.toString())}clear(){this.set.clear()}delete(t){this.set.delete(t.toString())}entries(){return Bt(this.set.entries(),t=>{let e=gr(t[0]);return[e,e]})}forEach(t){this.set.forEach(e=>{let n=gr(e);t(n,n,this)})}has(t){return this.set.has(t.toString())}values(){return Bt(this.set.values(),t=>gr(t))}intersection(t){let e=new r;for(let n of t)this.has(n)&&e.add(n);return e}difference(t){let e=new r;for(let n of this)t.has(n)||e.add(n);return e}union(t){let e=new r;for(let n of t)e.add(n);for(let n of this)e.add(n);return e}};function Cs(){return new jt}var Gt=class r{list;constructor(t){if(this.list=[],t!=null)for(let e of t)this.list.push(e)}[Symbol.iterator](){return Bt(this.list.entries(),t=>t[1])}concat(t){let e=new r(this);for(let n of t)e.push(n);return e}entries(){return Bt(this.list.entries(),t=>[t[0],t[1]])}every(t){return this.list.every((e,n)=>t(e,n,this))}filter(t){let e=new r;return this.list.forEach((n,o)=>{t(n,o,this)&&e.push(n)}),e}find(t){let e=this.list.find((n,o)=>t(n,o,this));if(e!=null)return e}findIndex(t){return this.list.findIndex((e,n)=>t(e,n,this))}forEach(t){this.list.forEach((e,n)=>{t(e,n,this)})}includes(t){return this.includes(t)}indexOf(t){return this.list.findIndex(e=>e.equals(t))}pop(){let t=this.list.pop();if(t!=null)return t}push(...t){for(let e of t)this.list.push(e)}shift(){let t=this.list.shift();if(t!=null)return t}unshift(...t){let e=this.list.length;for(let n=t.length-1;n>-1;n--)e=this.list.unshift(t[n]);return e}clear(){this.list=[]}get length(){return this.list.length}};function Ls(){return new Gt}var Kn={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},Us={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},Ts=new globalThis.TextEncoder;function Ta(r,t){let e=Kn[t],n=Us[t];for(let o=0;o<r.length;o++)n^=BigInt(r[o]),n=BigInt.asUintN(t,n*e);return n}function Da(r,t,e){if(e.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");let n=Kn[t],o=Us[t],s=r;for(;s.length>0;){let i=Ts.encodeInto(s,e);s=s.slice(i.read);for(let c=0;c<i.written;c++)o^=BigInt(e[c]),o=BigInt.asUintN(t,o*n)}return o}function On(r,{size:t=32,utf8Buffer:e}={}){if(!Kn[t])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if(typeof r=="string"){if(e)return Da(r,t,e);r=Ts.encode(r)}return Ta(r,t)}var ze={hash:r=>Number(On(r,{size:32})),hashV:(r,t)=>Pa(ze.hash(r,t))};function Pa(r){let t=r.toString(16);return t.length%2===1&&(t=`0${t}`),tt(t,"base16")}var Mn=64,St=class{fp;h;seed;constructor(t,e,n,o=2){if(o>Mn)throw new TypeError("Invalid Fingerprint Size");let s=e.hashV(t,n),i=bt(o);for(let c=0;c<i.length;c++)i[c]=s[c];i.length===0&&(i[0]=7),this.fp=i,this.h=e,this.seed=n}hash(){return this.h.hash(this.fp,this.seed)}equals(t){return t?.fp instanceof Uint8Array?ht(this.fp,t.fp):!1}};function oe(r,t){return Math.floor(Math.random()*(t-r))+r}var se=class{contents;constructor(t){this.contents=new Array(t).fill(null)}has(t){if(!(t instanceof St))throw new TypeError("Invalid Fingerprint");return this.contents.some(e=>t.equals(e))}add(t){if(!(t instanceof St))throw new TypeError("Invalid Fingerprint");for(let e=0;e<this.contents.length;e++)if(this.contents[e]==null)return this.contents[e]=t,!0;return!0}swap(t){if(!(t instanceof St))throw new TypeError("Invalid Fingerprint");let e=oe(0,this.contents.length-1),n=this.contents[e];return this.contents[e]=t,n}remove(t){if(!(t instanceof St))throw new TypeError("Invalid Fingerprint");let e=this.contents.findIndex(n=>t.equals(n));return e>-1?(this.contents[e]=null,!0):!1}};var Ra=500,He=class{bucketSize;filterSize;fingerprintSize;buckets;count;hash;seed;constructor(t){this.filterSize=t.filterSize,this.bucketSize=t.bucketSize??4,this.fingerprintSize=t.fingerprintSize??2,this.count=0,this.buckets=[],this.hash=t.hash??ze,this.seed=t.seed??oe(0,Math.pow(2,10))}add(t){typeof t=="string"&&(t=tt(t));let e=new St(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=(n^e.hash())%this.filterSize;if(this.buckets[n]==null&&(this.buckets[n]=new se(this.bucketSize)),this.buckets[o]==null&&(this.buckets[o]=new se(this.bucketSize)),this.buckets[n].add(e)||this.buckets[o].add(e))return this.count++,!0;let s=[n,o],i=s[oe(0,s.length-1)];this.buckets[i]==null&&(this.buckets[i]=new se(this.bucketSize));for(let c=0;c<Ra;c++){let a=this.buckets[i].swap(e);if(a!=null&&(i=(i^a.hash())%this.filterSize,this.buckets[i]==null&&(this.buckets[i]=new se(this.bucketSize)),this.buckets[i].add(a)))return this.count++,!0}return!1}has(t){typeof t=="string"&&(t=tt(t));let e=new St(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.has(e)??!1;if(o)return o;let s=(n^e.hash())%this.filterSize;return this.buckets[s]?.has(e)??!1}remove(t){typeof t=="string"&&(t=tt(t));let e=new St(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.remove(e)??!1;if(o)return this.count--,o;let s=(n^e.hash())%this.filterSize,i=this.buckets[s]?.remove(e)??!1;return i&&this.count--,i}get reliable(){return Math.floor(100*(this.count/this.filterSize))<=90}},ka={1:.5,2:.84,4:.95,8:.98};function Na(r=.001){return r>.002?2:r>1e-5?4:8}function Ds(r,t=.001){let e=Na(t),n=ka[e],o=Math.round(r/n),s=Math.min(Math.ceil(Math.log2(1/t)+Math.log2(2*e)),Mn);return{filterSize:o,bucketSize:e,fingerprintSize:s}}var br=class{filterSize;bucketSize;fingerprintSize;scale;filterSeries;hash;seed;constructor(t){this.bucketSize=t.bucketSize??4,this.filterSize=t.filterSize??(1<<18)/this.bucketSize,this.fingerprintSize=t.fingerprintSize??2,this.scale=t.scale??2,this.hash=t.hash??ze,this.seed=t.seed??oe(0,Math.pow(2,10)),this.filterSeries=[new He({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(t){if(typeof t=="string"&&(t=tt(t)),this.has(t))return!0;let e=this.filterSeries.find(n=>n.reliable);if(e==null){let n=this.filterSize*Math.pow(this.scale,this.filterSeries.length);e=new He({filterSize:n,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(e)}return e.add(t)}has(t){typeof t=="string"&&(t=tt(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].has(t))return!0;return!1}remove(t){typeof t=="string"&&(t=tt(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].remove(t))return!0;return!1}get count(){return this.filterSeries.reduce((t,e)=>t+e.count,0)}};function zn(r,t=.001,e){return new br({...Ds(r,t),...e??{}})}var qe=class{filter;constructor(t,e){this.filter=zn(t,e)}has(t){return this.filter.has(t.toMultihash().bytes)}add(t){this.filter.add(t.toMultihash().bytes)}remove(t){this.filter.remove?.(t.toMultihash().bytes)}};function Ps(r,t=.001){return new qe(r,t)}var Hn=class extends Vt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}set(t,e){return super.set(t,e),this.updateComponentMetric(),this}delete(t){let e=super.delete(t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function Rs(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Hn({name:t,metrics:e}):n=new Vt,n}var qn=class extends jt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}add(t){super.add(t),this.updateComponentMetric()}delete(t){super.delete(t),this.updateComponentMetric()}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function ks(r){let{name:t,metrics:e}=r,n;return e!=null?n=new qn({name:t,metrics:e}):n=new jt,n}var Fn=class extends Gt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}pop(){let t=super.pop();return this.updateComponentMetric(),t}push(...t){super.push(...t),this.updateComponentMetric()}shift(){let t=super.shift();return this.updateComponentMetric(),t}unshift(...t){let e=super.unshift(...t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.length)}};function Ns(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Fn({name:t,metrics:e}):n=new Gt,n}return js(Ka);})();
|
|
2
|
+
"use strict";var Libp2PPeerCollections=(()=>{var Ir=Object.defineProperty;var oi=Object.getOwnPropertyDescriptor;var si=Object.getOwnPropertyNames;var ii=Object.prototype.hasOwnProperty;var ut=(r,t)=>{for(var e in t)Ir(r,e,{get:t[e],enumerable:!0})},ci=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of si(t))!ii.call(r,o)&&o!==e&&Ir(r,o,{get:()=>t[o],enumerable:!(n=oi(t,o))||n.enumerable});return r};var ai=r=>ci(Ir({},"__esModule",{value:!0}),r);var Pa={};ut(Pa,{PeerFilter:()=>We,PeerList:()=>Yt,PeerMap:()=>Gt,PeerSet:()=>Zt,peerFilter:()=>Xs,peerList:()=>Gs,peerMap:()=>Fs,peerSet:()=>js,trackedPeerList:()=>Qs,trackedPeerMap:()=>$s,trackedPeerSet:()=>Js});var Lr=Symbol.for("@libp2p/peer-id");var Lt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Xe=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var $e=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var ve=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Pr={};ut(Pr,{base58btc:()=>Z,base58flickr:()=>pi});var Na=new Uint8Array(0);function Jn(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Ct(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Qn(r){return new TextEncoder().encode(r)}function to(r){return new TextDecoder().decode(r)}function fi(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var c=r.length,a=r.charAt(0),h=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function u(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var x=0,l=0,b=0,A=E.length;b!==A&&E[b]===0;)b++,x++;for(var p=(A-b)*f+1>>>0,v=new Uint8Array(p);b!==A;){for(var D=E[b],T=0,I=p-1;(D!==0||T<l)&&I!==-1;I--,T++)D+=256*v[I]>>>0,v[I]=D%c>>>0,D=D/c>>>0;if(D!==0)throw new Error("Non-zero carry");l=T,b++}for(var L=p-l;L!==p&&v[L]===0;)L++;for(var C=a.repeat(x);L<p;++L)C+=r.charAt(v[L]);return C}function m(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var x=0;if(E[x]!==" "){for(var l=0,b=0;E[x]===a;)l++,x++;for(var A=(E.length-x)*h+1>>>0,p=new Uint8Array(A);E[x];){var v=e[E.charCodeAt(x)];if(v===255)return;for(var D=0,T=A-1;(v!==0||D<b)&&T!==-1;T--,D++)v+=c*p[T]>>>0,p[T]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");b=D,x++}if(E[x]!==" "){for(var I=A-b;I!==A&&p[I]===0;)I++;for(var L=new Uint8Array(l+(A-I)),C=l;I!==A;)L[C++]=p[I++];return L}}}function _(E){var x=m(E);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:u,decodeUnsafe:m,decode:_}}var ui=fi,hi=ui,ro=hi;var Cr=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Ur=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return no(this,t)}},Tr=class{decoders;constructor(t){this.decoders=t}or(t){return no(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function no(r,t){return new Tr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Dr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Cr(t,e,n),this.decoder=new Ur(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function he({name:r,prefix:t,encode:e,decode:n}){return new Dr(r,t,e,n)}function Ot({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=ro(e,r);return he({prefix:t,name:r,encode:n,decode:s=>Ct(o(s))})}function li(r,t,e,n){let o={};for(let f=0;f<t.length;++f)o[t[f]]=f;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),c=0,a=0,h=0;for(let f=0;f<s;++f){let u=o[r[f]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|u,c+=e,c>=8&&(c-=8,i[h++]=255&a>>c)}if(c>=e||(255&a<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return i}function di(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],i+=8;i>e;)i-=e,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function j({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return he({prefix:t,name:r,encode(o){return di(o,n,e)},decode(o){return li(o,n,e,r)}})}var Z=Ot({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),pi=Ot({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Rr={};ut(Rr,{base32:()=>le,base32hex:()=>bi,base32hexpad:()=>wi,base32hexpadupper:()=>Ei,base32hexupper:()=>gi,base32pad:()=>xi,base32padupper:()=>yi,base32upper:()=>mi,base32z:()=>_i});var le=j({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mi=j({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),xi=j({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yi=j({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bi=j({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),gi=j({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),wi=j({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ei=j({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),_i=j({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var kr={};ut(kr,{base36:()=>Be,base36upper:()=>Si});var Be=Ot({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Si=Ot({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ai=io,oo=128,vi=127,Bi=~vi,Ii=Math.pow(2,31);function io(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Ii;)t[e++]=r&255|oo,r/=128;for(;r&Bi;)t[e++]=r&255|oo,r>>>=7;return t[e]=r|0,io.bytes=e-n+1,t}var Li=Kr,Ci=128,so=127;function Kr(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw Kr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&so)<<o:(i&so)*Math.pow(2,o),o+=7}while(i>=Ci);return Kr.bytes=s-n,e}var Ui=Math.pow(2,7),Ti=Math.pow(2,14),Di=Math.pow(2,21),Pi=Math.pow(2,28),Ri=Math.pow(2,35),ki=Math.pow(2,42),Ki=Math.pow(2,49),Ni=Math.pow(2,56),Oi=Math.pow(2,63),Mi=function(r){return r<Ui?1:r<Ti?2:r<Di?3:r<Pi?4:r<Ri?5:r<ki?6:r<Ki?7:r<Ni?8:r<Oi?9:10},Hi={encode:Ai,decode:Li,encodingLength:Mi},zi=Hi,Ie=zi;function Le(r,t=0){return[Ie.decode(r,t),Ie.decode.bytes]}function de(r,t,e=0){return Ie.encode(r,t,e),t}function pe(r){return Ie.encodingLength(r)}function Wt(r,t){let e=t.byteLength,n=pe(r),o=n+pe(e),s=new Uint8Array(o+e);return de(r,s,0),de(e,s,n),s.set(t,o),new me(r,e,t,s)}function Ce(r){let t=Ct(r),[e,n]=Le(t),[o,s]=Le(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new me(e,o,i,t)}function co(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Jn(r.bytes,e.bytes)}}var me=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function ao(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Vi(e,Nr(r),t??Z.encoder);default:return Fi(e,Nr(r),t??le.encoder)}}var fo=new WeakMap;function Nr(r){let t=fo.get(r);if(t==null){let e=new Map;return fo.set(r,e),e}return t}var at=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Ue)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==ji)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Wt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&co(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 e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??uo(n,o,s.bytes))}else if(e[Gi]===!0){let{version:n,multihash:o,code:s}=e,i=Ce(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Ue)throw new Error(`Version 0 CID must use dag-pb (code: ${Ue}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=uo(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Ue,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=Ct(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new me(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[u,m]=Le(t.subarray(e));return e+=m,u},o=n(),s=Ue;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,c=n(),a=n(),h=e+a,f=h-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:f,size:h}}static parse(t,e){let[n,o]=qi(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Nr(s).set(n,t),s}};function qi(r,t){switch(r[0]){case"Q":{let e=t??Z;return[Z.prefix,e.decode(`${Z.prefix}${r}`)]}case Z.prefix:{let e=t??Z;return[Z.prefix,e.decode(r)]}case le.prefix:{let e=t??le;return[le.prefix,e.decode(r)]}case Be.prefix:{let e=t??Be;return[Be.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Vi(r,t,e){let{prefix:n}=e;if(n!==Z.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function Fi(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var Ue=112,ji=18;function uo(r,t,e){let n=pe(r),o=n+pe(t),s=new Uint8Array(o+e.byteLength);return de(r,s,0),de(t,s,n),s.set(e,o),s}var Gi=Symbol.for("@ipld/js-cid/CID");var Or={};ut(Or,{identity:()=>bt});var ho=0,Zi="identity",lo=Ct;function Yi(r){return Wt(ho,lo(r))}var bt={code:ho,name:Zi,encode:lo,digest:Yi};function ht(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function gt(r=0){return new Uint8Array(r)}function lt(r=0){return new Uint8Array(r)}function Qe(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=lt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var mo=Symbol.for("@achingbrain/uint8arraylist");function po(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function tr(r){return!!r?.[mo]}var dt=class r{bufs;length;[mo]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(tr(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(tr(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=po(this.bufs,t);return e.buf[e.index]}set(t,e){let n=po(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(tr(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return Qe(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Qe(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],c=o,a=c+i.byteLength;if(o=a,t>=a)continue;let h=t>=c&&t<a,f=e>c&&e<=a;if(h&&f){if(t===c&&e===a){n.push(i);break}let u=t-c;n.push(i.subarray(u,u+(e-t)));break}if(h){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(f){if(e===a){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!tr(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let u=0;u<s;u++)i[u]=-1;for(let u=0;u<o;u++)i[n[u]]=u;let c=i,a=this.byteLength-n.byteLength,h=n.byteLength-1,f;for(let u=e;u<=a;u+=f){f=0;for(let m=h;m>=0;m--){let _=this.get(u+m);if(n[m]!==_){f=Math.max(1,m-c[_]);break}}if(f===0)return u}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=lt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=gt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=gt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=gt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=lt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=gt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=gt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=gt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=gt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=gt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!ht(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var Mr={};ut(Mr,{base10:()=>Wi});var Wi=Ot({prefix:"9",name:"base10",alphabet:"0123456789"});var Hr={};ut(Hr,{base16:()=>Xi,base16upper:()=>$i});var Xi=j({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),$i=j({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var zr={};ut(zr,{base2:()=>Ji});var Ji=j({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var qr={};ut(qr,{base256emoji:()=>nc});var xo=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}"),Qi=xo.reduce((r,t,e)=>(r[e]=t,r),[]),tc=xo.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function ec(r){return r.reduce((t,e)=>(t+=Qi[e],t),"")}function rc(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=tc[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var nc=he({prefix:"\u{1F680}",name:"base256emoji",encode:ec,decode:rc});var Vr={};ut(Vr,{base64:()=>oc,base64pad:()=>sc,base64url:()=>ic,base64urlpad:()=>cc});var oc=j({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),sc=j({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ic=j({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),cc=j({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Fr={};ut(Fr,{base8:()=>ac});var ac=j({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var jr={};ut(jr,{identity:()=>fc});var fc=he({prefix:"\0",name:"identity",encode:r=>to(r),decode:r=>Qn(r)});var Ef=new TextEncoder,_f=new TextDecoder;var Yr={};ut(Yr,{sha256:()=>Te,sha512:()=>lc});function Zr({name:r,code:t,encode:e}){return new Gr(r,t,e)}var Gr=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Wt(this.code,e):e.then(n=>Wt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function bo(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Te=Zr({name:"sha2-256",code:18,encode:bo("SHA-256")}),lc=Zr({name:"sha2-512",code:19,encode:bo("SHA-512")});var Wr={...jr,...zr,...Fr,...Mr,...Hr,...Rr,...kr,...Pr,...Vr,...qr},Rf={...Yr,...Or};function wo(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var go=wo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Xr=wo("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=lt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),dc={utf8:go,"utf-8":go,hex:Wr.base16,latin1:Xr,ascii:Xr,binary:Xr,...Wr},er=dc;function J(r,t="utf8"){let e=er[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function wt(r,t="utf8"){let e=er[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var pc=parseInt("11111",2),$r=parseInt("10000000",2),mc=parseInt("01111111",2),Eo={0:De,1:De,2:xc,3:gc,4:wc,5:bc,6:yc,16:De,22:De,48:De};function Jr(r,t={offset:0}){let e=r[t.offset]&pc;if(t.offset++,Eo[e]!=null)return Eo[e](r,t);throw new Error("No decoder for tag "+e)}function Pe(r,t){let e=0;if((r[t.offset]&$r)===$r){let n=r[t.offset]&mc,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function De(r,t){Pe(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=Jr(r,t);if(n===null)break;e.push(n)}return e}function xc(r,t){let e=Pe(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function yc(r,t){let e=Pe(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let c=`${s}.${i}`,a=[];for(;t.offset<n;){let h=r[t.offset];if(t.offset++,a.push(h&127),h<128){a.reverse();let f=0;for(let u=0;u<a.length;u++)f+=a[u]<<u*7;c+=`.${f}`,a=[]}}return c}function bc(r,t){return t.offset++,null}function gc(r,t){let e=Pe(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function wc(r,t){let e=Pe(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function Ec(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new dt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function Qr(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=Ec(r.byteLength);return new dt(Uint8Array.from([t.byteLength|$r]),t)}function _o(r){let t=new dt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new dt(Uint8Array.from([2]),Qr(t),t)}function So(r){let t=Uint8Array.from([0]),e=new dt(t,r);return new dt(Uint8Array.from([3]),Qr(e),e)}function rr(r,t=48){let e=new dt;for(let n of r)e.append(n);return new dt(Uint8Array.from([t]),Qr(e),e)}async function Ao(r,t,e){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,e.subarray())}var _c=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Sc=Uint8Array.from([6,5,43,129,4,0,34]),Ac=Uint8Array.from([6,5,43,129,4,0,35]),vc={ext:!0,kty:"EC",crv:"P-256"},Bc={ext:!0,kty:"EC",crv:"P-384"},Ic={ext:!0,kty:"EC",crv:"P-521"},tn=32,en=48,rn=66;function vo(r){let t=Jr(r);return Bo(t)}function Bo(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===tn*2+1)return n=wt(t.subarray(e,e+tn),"base64url"),o=wt(t.subarray(e+tn),"base64url"),new xe({...vc,key_ops:["verify"],x:n,y:o});if(t.byteLength===en*2+1)return n=wt(t.subarray(e,e+en),"base64url"),o=wt(t.subarray(e+en),"base64url"),new xe({...Bc,key_ops:["verify"],x:n,y:o});if(t.byteLength===rn*2+1)return n=wt(t.subarray(e,e+rn),"base64url"),o=wt(t.subarray(e+rn),"base64url"),new xe({...Ic,key_ops:["verify"],x:n,y:o});throw new Lt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Io(r){return rr([_o(Uint8Array.from([1])),rr([Lc(r.crv)],160),rr([So(new dt(Uint8Array.from([4]),J(r.x??"","base64url"),J(r.y??"","base64url")))],161)]).subarray()}function Lc(r){if(r==="P-256")return _c;if(r==="P-384")return Sc;if(r==="P-521")return Ac;throw new Lt(`Invalid curve ${r}`)}var xe=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 bt.digest(ye(this))}toCID(){return at.createV1(114,this.toMultihash())}toString(){return Z.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}async verify(t,e){return Ao(this.jwk,e,t)}};var $t=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Cc(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function nr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Jt(r,...t){if(!Cc(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function Lo(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");nr(r.outputLen),nr(r.blockLen)}function ge(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Co(r,t){Jt(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function Ut(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function or(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Et(r,t){return r<<32-t|r>>>t}function Uo(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function Re(r){return typeof r=="string"&&(r=Uo(r)),Jt(r),r}function nn(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Jt(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var be=class{};function on(r){let t=n=>r().update(Re(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function sr(r=32){if($t&&typeof $t.getRandomValues=="function")return $t.getRandomValues(new Uint8Array(r));if($t&&typeof $t.randomBytes=="function")return Uint8Array.from($t.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function Uc(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),c=Number(e&s),a=n?4:0,h=n?0:4;r.setUint32(t+a,i,n),r.setUint32(t+h,c,n)}function To(r,t,e){return r&t^~r&e}function Do(r,t,e){return r&t^r&e^t&e}var ke=class extends be{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=or(this.buffer)}update(t){ge(this),t=Re(t),Jt(t);let{view:e,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=or(t);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ge(this),Co(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,Ut(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let u=i;u<o;u++)e[u]=0;Uc(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=or(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let h=a/4,f=this.get();if(h>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<h;u++)c.setUint32(4*u,f[u],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=c,o%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Tt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var et=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var ir=BigInt(4294967295),Po=BigInt(32);function Tc(r,t=!1){return t?{h:Number(r&ir),l:Number(r>>Po&ir)}:{h:Number(r>>Po&ir)|0,l:Number(r&ir)|0}}function Ro(r,t=!1){let e=r.length,n=new Uint32Array(e),o=new Uint32Array(e);for(let s=0;s<e;s++){let{h:i,l:c}=Tc(r[s],t);[n[s],o[s]]=[i,c]}return[n,o]}var sn=(r,t,e)=>r>>>e,cn=(r,t,e)=>r<<32-e|t>>>e,Qt=(r,t,e)=>r>>>e|t<<32-e,te=(r,t,e)=>r<<32-e|t>>>e,Ke=(r,t,e)=>r<<64-e|t>>>e-32,Ne=(r,t,e)=>r>>>e-32|t<<64-e;function At(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var ko=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Ko=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,No=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Oo=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Mo=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Ho=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Pc=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),an=class extends ke{constructor(t=32){super(64,t,8,!1),this.A=Tt[0]|0,this.B=Tt[1]|0,this.C=Tt[2]|0,this.D=Tt[3]|0,this.E=Tt[4]|0,this.F=Tt[5]|0,this.G=Tt[6]|0,this.H=Tt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[t,e,n,o,s,i,c,a]}set(t,e,n,o,s,i,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,e){for(let u=0;u<16;u++,e+=4)Mt[u]=t.getUint32(e,!1);for(let u=16;u<64;u++){let m=Mt[u-15],_=Mt[u-2],E=Et(m,7)^Et(m,18)^m>>>3,x=Et(_,17)^Et(_,19)^_>>>10;Mt[u]=x+Mt[u-7]+E+Mt[u-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:h,H:f}=this;for(let u=0;u<64;u++){let m=Et(c,6)^Et(c,11)^Et(c,25),_=f+m+To(c,a,h)+Pc[u]+Mt[u]|0,x=(Et(n,2)^Et(n,13)^Et(n,22))+Do(n,o,s)|0;f=h,h=a,a=c,c=i+_|0,i=s,s=o,o=n,n=_+x|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,h=h+this.G|0,f=f+this.H|0,this.set(n,o,s,i,c,a,h,f)}roundClean(){Ut(Mt)}destroy(){this.set(0,0,0,0,0,0,0,0),Ut(this.buffer)}};var zo=Ro(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Rc=zo[0],kc=zo[1],Ht=new Uint32Array(80),zt=new Uint32Array(80),fn=class extends ke{constructor(t=64){super(128,t,16,!1),this.Ah=et[0]|0,this.Al=et[1]|0,this.Bh=et[2]|0,this.Bl=et[3]|0,this.Ch=et[4]|0,this.Cl=et[5]|0,this.Dh=et[6]|0,this.Dl=et[7]|0,this.Eh=et[8]|0,this.El=et[9]|0,this.Fh=et[10]|0,this.Fl=et[11]|0,this.Gh=et[12]|0,this.Gl=et[13]|0,this.Hh=et[14]|0,this.Hl=et[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:h,El:f,Fh:u,Fl:m,Gh:_,Gl:E,Hh:x,Hl:l}=this;return[t,e,n,o,s,i,c,a,h,f,u,m,_,E,x,l]}set(t,e,n,o,s,i,c,a,h,f,u,m,_,E,x,l){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=h|0,this.El=f|0,this.Fh=u|0,this.Fl=m|0,this.Gh=_|0,this.Gl=E|0,this.Hh=x|0,this.Hl=l|0}process(t,e){for(let p=0;p<16;p++,e+=4)Ht[p]=t.getUint32(e),zt[p]=t.getUint32(e+=4);for(let p=16;p<80;p++){let v=Ht[p-15]|0,D=zt[p-15]|0,T=Qt(v,D,1)^Qt(v,D,8)^sn(v,D,7),I=te(v,D,1)^te(v,D,8)^cn(v,D,7),L=Ht[p-2]|0,C=zt[p-2]|0,q=Qt(L,C,19)^Ke(L,C,61)^sn(L,C,6),M=te(L,C,19)^Ne(L,C,61)^cn(L,C,6),k=No(I,M,zt[p-7],zt[p-16]),W=Oo(k,T,q,Ht[p-7],Ht[p-16]);Ht[p]=W|0,zt[p]=k|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:h,Dl:f,Eh:u,El:m,Fh:_,Fl:E,Gh:x,Gl:l,Hh:b,Hl:A}=this;for(let p=0;p<80;p++){let v=Qt(u,m,14)^Qt(u,m,18)^Ke(u,m,41),D=te(u,m,14)^te(u,m,18)^Ne(u,m,41),T=u&_^~u&x,I=m&E^~m&l,L=Mo(A,D,I,kc[p],zt[p]),C=Ho(L,b,v,T,Rc[p],Ht[p]),q=L|0,M=Qt(n,o,28)^Ke(n,o,34)^Ke(n,o,39),k=te(n,o,28)^Ne(n,o,34)^Ne(n,o,39),W=n&s^n&c^s&c,w=o&i^o&a^i&a;b=x|0,A=l|0,x=_|0,l=E|0,_=u|0,E=m|0,{h:u,l:m}=At(h|0,f|0,C|0,q|0),h=c|0,f=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let B=ko(q,k,w);n=Ko(B,C,M,W),o=B|0}({h:n,l:o}=At(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=At(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=At(this.Ch|0,this.Cl|0,c|0,a|0),{h,l:f}=At(this.Dh|0,this.Dl|0,h|0,f|0),{h:u,l:m}=At(this.Eh|0,this.El|0,u|0,m|0),{h:_,l:E}=At(this.Fh|0,this.Fl|0,_|0,E|0),{h:x,l}=At(this.Gh|0,this.Gl|0,x|0,l|0),{h:b,l:A}=At(this.Hh|0,this.Hl|0,b|0,A|0),this.set(n,o,s,i,c,a,h,f,u,m,_,E,x,l,b,A)}roundClean(){Ut(Ht,zt)}destroy(){Ut(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var qo=on(()=>new an);var Vo=on(()=>new fn);var dn=BigInt(0),ln=BigInt(1);function ee(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function pn(r){if(!ee(r))throw new Error("Uint8Array expected")}function vt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function Oe(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Go(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?dn:BigInt("0x"+r)}var Zo=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Kc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function qt(r){if(pn(r),Zo)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=Kc[r[e]];return t}var Dt={_0:48,_9:57,A:65,F:70,a:97,f:102};function Fo(r){if(r>=Dt._0&&r<=Dt._9)return r-Dt._0;if(r>=Dt.A&&r<=Dt.F)return r-(Dt.A-10);if(r>=Dt.a&&r<=Dt.f)return r-(Dt.a-10)}function Me(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(Zo)return Uint8Array.fromHex(r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=Fo(r.charCodeAt(s)),c=Fo(r.charCodeAt(s+1));if(i===void 0||c===void 0){let a=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function Pt(r){return Go(qt(r))}function re(r){return pn(r),Go(qt(Uint8Array.from(r).reverse()))}function ne(r,t){return Me(r.toString(16).padStart(t*2,"0"))}function we(r,t){return ne(r,t).reverse()}function F(r,t,e){let n;if(typeof t=="string")try{n=Me(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(ee(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function Vt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];pn(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var un=r=>typeof r=="bigint"&&dn<=r;function cr(r,t,e){return un(r)&&un(t)&&un(e)&&t<=r&&r<e}function pt(r,t,e,n){if(!cr(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Yo(r){let t;for(t=0;r>dn;r>>=ln,t+=1);return t}var oe=r=>(ln<<BigInt(r))-ln,hn=r=>new Uint8Array(r),jo=r=>Uint8Array.from(r);function Wo(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=hn(r),o=hn(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...u)=>e(o,n,...u),a=(u=hn(0))=>{o=c(jo([0]),u),n=c(),u.length!==0&&(o=c(jo([1]),u),n=c())},h=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let u=0,m=[];for(;u<t;){n=c();let _=n.slice();m.push(_),u+=n.length}return Vt(...m)};return(u,m)=>{i(),a(u);let _;for(;!(_=m(h()));)a();return i(),_}}var Nc={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||ee(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Rt(r,t,e={}){let n=(o,s,i)=>{let c=Nc[s];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(i&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+a)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}function Ee(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var ot=BigInt(0),X=BigInt(1),se=BigInt(2),Oc=BigInt(3),mn=BigInt(4),Xo=BigInt(5),$o=BigInt(8),Mc=BigInt(9),Hc=BigInt(16);function z(r,t){let e=r%t;return e>=ot?e:t+e}function V(r,t,e){let n=r;for(;t-- >ot;)n*=n,n%=e;return n}function ar(r,t){if(r===ot)throw new Error("invert: expected non-zero number");if(t<=ot)throw new Error("invert: expected positive modulus, got "+t);let e=z(r,t),n=t,o=ot,s=X,i=X,c=ot;for(;e!==ot;){let h=n/e,f=n%e,u=o-i*h,m=s-c*h;n=e,e=f,o=i,s=c,i=u,c=m}if(n!==X)throw new Error("invert: does not exist");return z(o,t)}function zc(r){let t=r-X,e=0;for(;t%se===ot;)t/=se,e++;let n=se,o=kt(r);for(;n<r&&Jo(o,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1){let i=(r+X)/mn;return function(a,h){let f=a.pow(h,i);if(!a.eql(a.sqr(f),h))throw new Error("Cannot find square root");return f}}let s=(t+X)/se;return function(c,a){if(!Jo(c,a))throw new Error("Cannot find square root");let h=e,f=c.pow(c.mul(c.ONE,n),t),u=c.pow(a,s),m=c.pow(a,t);for(;!c.eql(m,c.ONE);){if(c.eql(m,c.ZERO))return c.ZERO;let _=1;for(let x=c.sqr(m);_<h&&!c.eql(x,c.ONE);_++)x=c.sqr(x);let E=c.pow(f,X<<BigInt(h-_-1));f=c.sqr(E),u=c.mul(u,E),m=c.mul(m,f),h=_}return u}}function qc(r){return r%mn===Oc?function(e,n){let o=(r+X)/mn,s=e.pow(n,o);if(!e.eql(e.sqr(s),n))throw new Error("Cannot find square root");return s}:r%$o===Xo?function(e,n){let o=e.mul(n,se),s=(r-Xo)/$o,i=e.pow(o,s),c=e.mul(n,i),a=e.mul(e.mul(c,se),i),h=e.mul(c,e.sub(a,e.ONE));if(!e.eql(e.sqr(h),n))throw new Error("Cannot find square root");return h}:(r%Hc,zc(r))}var Qo=(r,t)=>(z(r,t)&X)===X,Vc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function xn(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Vc.reduce((n,o)=>(n[o]="function",n),t);return Rt(r,e)}function Fc(r,t,e){if(e<ot)throw new Error("invalid exponent, negatives unsupported");if(e===ot)return r.ONE;if(e===X)return t;let n=r.ONE,o=t;for(;e>ot;)e&X&&(n=r.mul(n,o)),o=r.sqr(o),e>>=X;return n}function _e(r,t,e=!1){let n=new Array(t.length).fill(e?r.ZERO:void 0),o=t.reduce((i,c,a)=>r.is0(c)?i:(n[a]=i,r.mul(i,c)),r.ONE),s=r.inv(o);return t.reduceRight((i,c,a)=>r.is0(c)?i:(n[a]=r.mul(i,n[a]),r.mul(i,c)),s),n}function jc(r,t){let e=(r.ORDER-X)/se,n=r.pow(t,e),o=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),i=r.eql(n,r.neg(r.ONE));if(!o&&!s&&!i)throw new Error("Cannot find square root: probably non-prime P");return o?1:s?0:-1}function Jo(r,t){let e=jc(r,t);return e===0||e===1}function yn(r,t){t!==void 0&&nr(t);let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function kt(r,t,e=!1,n={}){if(r<=ot)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=yn(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,c=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:oe(o),ZERO:ot,ONE:X,create:a=>z(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return ot<=a&&a<r},is0:a=>a===ot,isOdd:a=>(a&X)===X,neg:a=>z(-a,r),eql:(a,h)=>a===h,sqr:a=>z(a*a,r),add:(a,h)=>z(a+h,r),sub:(a,h)=>z(a-h,r),mul:(a,h)=>z(a*h,r),pow:(a,h)=>Fc(c,a,h),div:(a,h)=>z(a*ar(h,r),r),sqrN:a=>a*a,addN:(a,h)=>a+h,subN:(a,h)=>a-h,mulN:(a,h)=>a*h,inv:a=>ar(a,r),sqrt:n.sqrt||(a=>(i||(i=qc(r)),i(c,a))),toBytes:a=>e?we(a,s):ne(a,s),fromBytes:a=>{if(a.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+a.length);return e?re(a):Pt(a)},invertBatch:a=>_e(c,a),cmov:(a,h,f)=>f?h:a});return Object.freeze(c)}function ts(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function bn(r){let t=ts(r);return t+Math.ceil(t/2)}function es(r,t,e=!1){let n=r.length,o=ts(t),s=bn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?re(r):Pt(r),c=z(i,t-X)+X;return e?we(c,o):ne(c,o)}var rs=BigInt(0),Sn=BigInt(1);function gn(r,t){let e=t.negate();return r?e:t}function os(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function wn(r,t){os(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=oe(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function ns(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,c=Number(r&o),a=r>>i;c>n&&(c-=s,a+=Sn);let h=t*n,f=h+Math.abs(c)-1,u=c===0,m=c<0,_=t%2!==0;return{nextN:a,offset:f,isZero:u,isNeg:m,isNegF:_,offsetF:h}}function Gc(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function Zc(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var En=new WeakMap,ss=new WeakMap;function _n(r){return ss.get(r)||1}function fr(r,t){return{constTimeNegate:gn,hasPrecomputes(e){return _n(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>rs;)n&Sn&&(o=o.add(s)),s=s.double(),n>>=Sn;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=wn(n,t),i=[],c=e,a=c;for(let h=0;h<o;h++){a=c,i.push(a);for(let f=1;f<s;f++)a=a.add(c),i.push(a);c=a.double()}return i},wNAF(e,n,o){let s=r.ZERO,i=r.BASE,c=wn(e,t);for(let a=0;a<c.windows;a++){let{nextN:h,offset:f,isZero:u,isNeg:m,isNegF:_,offsetF:E}=ns(o,a,c);o=h,u?i=i.add(gn(_,n[E])):s=s.add(gn(m,n[f]))}return{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=wn(e,t);for(let c=0;c<i.windows&&o!==rs;c++){let{nextN:a,offset:h,isZero:f,isNeg:u}=ns(o,c,i);if(o=a,!f){let m=n[h];s=s.add(u?m.negate():m)}}return s},getPrecomputes(e,n,o){let s=En.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&En.set(n,o(s))),s},wNAFCached(e,n,o){let s=_n(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=_n(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){os(n,t),ss.set(e,n),En.delete(e)}}}function ur(r,t,e,n){if(Gc(e,r),Zc(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,s=Yo(BigInt(e.length)),i=s>12?s-3:s>4?s-2:s?2:1,c=oe(i),a=new Array(Number(c)+1).fill(o),h=Math.floor((t.BITS-1)/i)*i,f=o;for(let u=h;u>=0;u-=i){a.fill(o);for(let _=0;_<n.length;_++){let E=n[_],x=Number(E>>BigInt(u)&c);a[x]=a[x].add(e[_])}let m=o;for(let _=a.length-1,E=o;_>0;_--)E=E.add(a[_]),m=m.add(E);if(f=f.add(m),u!==0)for(let _=0;_<i;_++)f=f.double()}return f}function He(r){return xn(r.Fp),Rt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...yn(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Bt=BigInt(0),st=BigInt(1),is=BigInt(2),Yc=BigInt(8),Wc={zip215:!0};function Xc(r){let t=He(r);return Rt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function cs(r){let t=Xc(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:c,h:a}=t,h=is<<BigInt(c*8)-st,f=e.create,u=kt(t.n,t.nBitLength),m=t.uvRatio||((y,d)=>{try{return{isValid:!0,value:e.sqrt(y*e.inv(d))}}catch{return{isValid:!1,value:Bt}}}),_=t.adjustScalarBytes||(y=>y),E=t.domain||((y,d,g)=>{if(vt("phflag",g),d.length||g)throw new Error("Contexts/pre-hash are not supported");return y});function x(y,d,g=!1){let S=g?st:Bt;pt("coordinate "+y,d,S,h)}function l(y){if(!(y instanceof p))throw new Error("ExtendedPoint expected")}let b=Ee((y,d)=>{let{ex:g,ey:S,ez:P}=y,R=y.is0();d==null&&(d=R?Yc:e.inv(P));let K=f(g*d),N=f(S*d),O=f(P*d);if(R)return{x:Bt,y:st};if(O!==st)throw new Error("invZ was invalid");return{x:K,y:N}}),A=Ee(y=>{let{a:d,d:g}=t;if(y.is0())throw new Error("bad point: ZERO");let{ex:S,ey:P,ez:R,et:K}=y,N=f(S*S),O=f(P*P),H=f(R*R),Y=f(H*H),G=f(N*d),tt=f(H*f(G+O)),ct=f(Y+f(g*f(N*O)));if(tt!==ct)throw new Error("bad point: equation left != right (1)");let $=f(S*P),rt=f(R*K);if($!==rt)throw new Error("bad point: equation left != right (2)");return!0});class p{constructor(d,g,S,P){x("x",d),x("y",g),x("z",S,!0),x("t",P),this.ex=d,this.ey=g,this.ez=S,this.et=P,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(d){if(d instanceof p)throw new Error("extended point not allowed");let{x:g,y:S}=d||{};return x("x",g),x("y",S),new p(g,S,st,f(g*S))}static normalizeZ(d){let g=_e(e,d.map(S=>S.ez));return d.map((S,P)=>S.toAffine(g[P])).map(p.fromAffine)}static msm(d,g){return ur(p,u,d,g)}_setWindowSize(d){T.setWindowSize(this,d)}assertValidity(){A(this)}equals(d){l(d);let{ex:g,ey:S,ez:P}=this,{ex:R,ey:K,ez:N}=d,O=f(g*N),H=f(R*P),Y=f(S*N),G=f(K*P);return O===H&&Y===G}is0(){return this.equals(p.ZERO)}negate(){return new p(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:d}=t,{ex:g,ey:S,ez:P}=this,R=f(g*g),K=f(S*S),N=f(is*f(P*P)),O=f(d*R),H=g+S,Y=f(f(H*H)-R-K),G=O+K,tt=G-N,ct=O-K,$=f(Y*tt),rt=f(G*ct),ft=f(Y*ct),yt=f(tt*G);return new p($,rt,yt,ft)}add(d){l(d);let{a:g,d:S}=t,{ex:P,ey:R,ez:K,et:N}=this,{ex:O,ey:H,ez:Y,et:G}=d,tt=f(P*O),ct=f(R*H),$=f(N*S*G),rt=f(K*Y),ft=f((P+R)*(O+H)-tt-ct),yt=rt-$,Ae=rt+$,$n=f(ct-g*tt),ti=f(ft*yt),ei=f(Ae*$n),ri=f(ft*$n),ni=f(yt*Ae);return new p(ti,ei,ni,ri)}subtract(d){return this.add(d.negate())}wNAF(d){return T.wNAFCached(this,d,p.normalizeZ)}multiply(d){let g=d;pt("scalar",g,st,n);let{p:S,f:P}=this.wNAF(g);return p.normalizeZ([S,P])[0]}multiplyUnsafe(d,g=p.ZERO){let S=d;return pt("scalar",S,Bt,n),S===Bt?D:this.is0()||S===st?this:T.wNAFCachedUnsafe(this,S,p.normalizeZ,g)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return T.unsafeLadder(this,n).is0()}toAffine(d){return b(this,d)}clearCofactor(){let{h:d}=t;return d===st?this:this.multiplyUnsafe(d)}static fromHex(d,g=!1){let{d:S,a:P}=t,R=e.BYTES;d=F("pointHex",d,R),vt("zip215",g);let K=d.slice(),N=d[R-1];K[R-1]=N&-129;let O=re(K),H=g?h:e.ORDER;pt("pointHex.y",O,Bt,H);let Y=f(O*O),G=f(Y-st),tt=f(S*Y-P),{isValid:ct,value:$}=m(G,tt);if(!ct)throw new Error("Point.fromHex: invalid y coordinate");let rt=($&st)===st,ft=(N&128)!==0;if(!g&&$===Bt&&ft)throw new Error("Point.fromHex: x=0 and x_0=1");return ft!==rt&&($=f(-$)),p.fromAffine({x:$,y:O})}static fromPrivateKey(d){let{scalar:g}=C(d);return v.multiply(g)}toRawBytes(){let{x:d,y:g}=this.toAffine(),S=we(g,e.BYTES);return S[S.length-1]|=d&st?128:0,S}toHex(){return qt(this.toRawBytes())}}p.BASE=new p(t.Gx,t.Gy,st,f(t.Gx*t.Gy)),p.ZERO=new p(Bt,st,st,Bt);let{BASE:v,ZERO:D}=p,T=fr(p,c*8);function I(y){return z(y,n)}function L(y){return I(re(y))}function C(y){let d=e.BYTES;y=F("private key",y,d);let g=F("hashed private key",s(y),2*d),S=_(g.slice(0,d)),P=g.slice(d,2*d),R=L(S);return{head:S,prefix:P,scalar:R}}function q(y){let{head:d,prefix:g,scalar:S}=C(y),P=v.multiply(S),R=P.toRawBytes();return{head:d,prefix:g,scalar:S,point:P,pointBytes:R}}function M(y){return q(y).pointBytes}function k(y=Uint8Array.of(),...d){let g=Vt(...d);return L(s(E(g,F("context",y),!!o)))}function W(y,d,g={}){y=F("message",y),o&&(y=o(y));let{prefix:S,scalar:P,pointBytes:R}=q(d),K=k(g.context,S,y),N=v.multiply(K).toRawBytes(),O=k(g.context,N,R,y),H=I(K+O*P);pt("signature.s",H,Bt,n);let Y=Vt(N,we(H,e.BYTES));return F("result",Y,e.BYTES*2)}let w=Wc;function B(y,d,g,S=w){let{context:P,zip215:R}=S,K=e.BYTES;y=F("signature",y,2*K),d=F("message",d),g=F("publicKey",g,K),R!==void 0&&vt("zip215",R),o&&(d=o(d));let N=re(y.slice(K,2*K)),O,H,Y;try{O=p.fromHex(g,R),H=p.fromHex(y.slice(0,K),R),Y=v.multiplyUnsafe(N)}catch{return!1}if(!R&&O.isSmallOrder())return!1;let G=k(P,H.toRawBytes(),O.toRawBytes(),d);return H.add(O.multiplyUnsafe(G)).subtract(Y).clearCofactor().equals(p.ZERO)}return v._setWindowSize(8),{CURVE:t,getPublicKey:M,sign:W,verify:B,ExtendedPoint:p,utils:{getExtendedPublicKey:q,randomPrivateKey:()=>i(e.BYTES),precompute(y=8,d=p.BASE){return d._setWindowSize(y),d.multiply(BigInt(3)),d}}}}var An=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),as=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Nu=BigInt(0),$c=BigInt(1),fs=BigInt(2),Ou=BigInt(3),Jc=BigInt(5),Qc=BigInt(8);function ta(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=An,c=r*r%s*r%s,a=V(c,fs,s)*c%s,h=V(a,$c,s)*r%s,f=V(h,Jc,s)*h%s,u=V(f,t,s)*f%s,m=V(u,e,s)*u%s,_=V(m,n,s)*m%s,E=V(_,o,s)*_%s,x=V(E,o,s)*_%s,l=V(x,t,s)*f%s;return{pow_p_5_8:V(l,fs,s)*r%s,b2:c}}function ea(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function ra(r,t){let e=An,n=z(t*t*t,e),o=z(n*n*t,e),s=ta(r*o).pow_p_5_8,i=z(r*n*s,e),c=z(t*i*i,e),a=i,h=z(i*as,e),f=c===r,u=c===z(-r,e),m=c===z(-r*as,e);return f&&(i=a),(u||m)&&(i=h),Qo(i,e)&&(i=z(-i,e)),{isValid:f||u,value:i}}var us=kt(An,void 0,!0),na={a:us.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:us,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Qc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Vo,randomBytes:sr,adjustScalarBytes:ea,uvRatio:ra},hs=cs(na);var hr=32;function ls(r,t,e){return hs.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var lr=class{type="Ed25519";raw;constructor(t){this.raw=vn(t,hr)}toMultihash(){return bt.digest(ye(this))}toCID(){return at.createV1(114,this.toMultihash())}toString(){return Z.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}verify(t,e){return ls(this.raw,e,t)}};function ps(r){return r=vn(r,hr),new lr(r)}function vn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new Lt(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var sa=Math.pow(2,7),ia=Math.pow(2,14),ca=Math.pow(2,21),ms=Math.pow(2,28),xs=Math.pow(2,35),ys=Math.pow(2,42),bs=Math.pow(2,49),it=128,Ft=127;function ze(r){if(r<sa)return 1;if(r<ia)return 2;if(r<ca)return 3;if(r<ms)return 4;if(r<xs)return 5;if(r<ys)return 6;if(r<bs)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function gs(r,t,e=0){switch(ze(r)){case 8:t[e++]=r&255|it,r/=128;case 7:t[e++]=r&255|it,r/=128;case 6:t[e++]=r&255|it,r/=128;case 5:t[e++]=r&255|it,r/=128;case 4:t[e++]=r&255|it,r>>>=7;case 3:t[e++]=r&255|it,r>>>=7;case 2:t[e++]=r&255|it,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function ws(r,t){let e=r[t],n=0;if(n+=e&Ft,e<it||(e=r[t+1],n+=(e&Ft)<<7,e<it)||(e=r[t+2],n+=(e&Ft)<<14,e<it)||(e=r[t+3],n+=(e&Ft)<<21,e<it)||(e=r[t+4],n+=(e&Ft)*ms,e<it)||(e=r[t+5],n+=(e&Ft)*xs,e<it)||(e=r[t+6],n+=(e&Ft)*ys,e<it)||(e=r[t+7],n+=(e&Ft)*bs,e<it))return n;throw new RangeError("Could not decode varint")}var Bn=new Float32Array([-0]),jt=new Uint8Array(Bn.buffer);function Es(r,t,e){Bn[0]=r,t[e]=jt[0],t[e+1]=jt[1],t[e+2]=jt[2],t[e+3]=jt[3]}function _s(r,t){return jt[0]=r[t],jt[1]=r[t+1],jt[2]=r[t+2],jt[3]=r[t+3],Bn[0]}var In=new Float64Array([-0]),nt=new Uint8Array(In.buffer);function Ss(r,t,e){In[0]=r,t[e]=nt[0],t[e+1]=nt[1],t[e+2]=nt[2],t[e+3]=nt[3],t[e+4]=nt[4],t[e+5]=nt[5],t[e+6]=nt[6],t[e+7]=nt[7]}function As(r,t){return nt[0]=r[t],nt[1]=r[t+1],nt[2]=r[t+2],nt[3]=r[t+3],nt[4]=r[t+4],nt[5]=r[t+5],nt[6]=r[t+6],nt[7]=r[t+7],In[0]}var aa=BigInt(Number.MAX_SAFE_INTEGER),fa=BigInt(Number.MIN_SAFE_INTEGER),mt=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return ie;if(t<aa&&t>fa)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>vs&&(o=0n,++n>vs&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ie;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):ie}},ie=new mt(0,0);ie.toBigInt=function(){return 0n};ie.zzEncode=ie.zzDecode=function(){return this};ie.length=function(){return 1};var vs=4294967296n;function Bs(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Is(r,t,e){if(e-t<1)return"";let o,s=[],i=0,c;for(;t<e;)c=r[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function Ln(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function _t(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function dr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Cn=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,_t(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 _t(this,4);return dr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw _t(this,4);return dr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw _t(this,4);let t=_s(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw _t(this,4);let t=As(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw _t(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Is(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw _t(this,t);this.pos+=t}else do if(this.pos>=this.len)throw _t(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new mt(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw _t(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw _t(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw _t(this,8);let t=dr(this.buf,this.pos+=4),e=dr(this.buf,this.pos+=4);return new mt(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=ws(this.buf,this.pos);return this.pos+=ze(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 Un(r){return new Cn(r instanceof Uint8Array?r:r.subarray())}function pr(r,t,e){let n=Un(r);return t.decode(n,void 0,e)}function Tn(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return lt(i);o+i>t&&(n=lt(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var ce=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Dn(){}var Rn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},ua=Tn();function ha(r){return globalThis.Buffer!=null?lt(r):ua(r)}var Ve=class{len;head;tail;states;constructor(){this.len=0,this.head=new ce(Dn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ce(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new kn((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(mr,10,mt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=mt.fromBigInt(t);return this._push(mr,e.length(),e)}uint64Number(t){return this._push(gs,ze(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=mt.fromBigInt(t).zzEncode();return this._push(mr,e.length(),e)}sint64Number(t){let e=mt.fromNumber(t).zzEncode();return this._push(mr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Pn,1,t?1:0)}fixed32(t){return this._push(qe,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=mt.fromBigInt(t);return this._push(qe,4,e.lo)._push(qe,4,e.hi)}fixed64Number(t){let e=mt.fromNumber(t);return this._push(qe,4,e.lo)._push(qe,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Es,4,t)}double(t){return this._push(Ss,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Pn,1,0):this.uint32(e)._push(da,e,t)}string(t){let e=Bs(t);return e!==0?this.uint32(e)._push(Ln,e,t):this._push(Pn,1,0)}fork(){return this.states=new Rn(this),this.head=this.tail=new ce(Dn,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new ce(Dn,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=ha(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Pn(r,t,e){t[e]=r&255}function la(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var kn=class extends ce{next;constructor(t,e){super(la,t,e),this.next=void 0}};function mr(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function qe(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function da(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Ve.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(pa,t,r),this},Ve.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(ma,t,r),this});function pa(r,t,e){t.set(r,e)}function ma(r,t,e){r.length<40?Ln(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(J(r),e)}function Kn(){return new Ve}function xr(r,t){let e=Kn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Se;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Se||(Se={}));function yr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Nn(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let c=t(s);i.int32(c)},n=function(s){let i=s.int32();return t(i)};return yr("enum",Se.VARINT,e,n)}function br(r,t){return yr("message",Se.LENGTH_DELIMITED,r,t)}var xt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(xt||(xt={}));var On;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(On||(On={}));(function(r){r.codec=()=>Nn(On)})(xt||(xt={}));var Fe;(function(r){let t;r.codec=()=>(t==null&&(t=br((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),xt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=xt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>xr(e,r.codec()),r.decode=(e,n)=>pr(e,r.codec(),n)})(Fe||(Fe={}));var Mn;(function(r){let t;r.codec=()=>(t==null&&(t=br((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),xt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=xt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>xr(e,r.codec()),r.decode=(e,n)=>pr(e,r.codec(),n)})(Mn||(Mn={}));var je=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var gr=class extends be{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Lo(t);let n=Re(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),Ut(s)}update(t){return ge(this),this.iHash.update(t),this}digestInto(t){ge(this),Jt(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Hn=(r,t,e)=>new gr(r,t).update(e).digest();Hn.create=(r,t)=>new gr(r,t);function Cs(r){r.lowS!==void 0&&vt("lowS",r.lowS),r.prehash!==void 0&&vt("prehash",r.prehash)}function ya(r){let t=He(r);Rt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var zn=class extends Error{constructor(t=""){super(t)}},Kt={Err:zn,_tlv:{encode:(r,t)=>{let{Err:e}=Kt;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=Oe(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Oe(o.length/2|128):"";return Oe(r)+s+o+t},decode(r,t){let{Err:e}=Kt,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let a=o&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let h=t.subarray(n,n+a);if(h.length!==a)throw new e("tlv.decode: length bytes not complete");if(h[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let f of h)i=i<<8|f;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Kt;if(r<Nt)throw new t("integer: negative integers are not allowed");let e=Oe(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=Kt;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Pt(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Kt,o=F("signature",r),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:h,l:f}=n.decode(2,a);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(h)}},hexFromSig(r){let{_tlv:t,_int:e}=Kt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},Nt=BigInt(0),Q=BigInt(1),qh=BigInt(2),Us=BigInt(3),Vh=BigInt(4);function ba(r){let t=ya(r),{Fp:e}=t,n=kt(t.n,t.nBitLength),o=t.toBytes||((x,l,b)=>{let A=l.toAffine();return Vt(Uint8Array.from([4]),e.toBytes(A.x),e.toBytes(A.y))}),s=t.fromBytes||(x=>{let l=x.subarray(1),b=e.fromBytes(l.subarray(0,e.BYTES)),A=e.fromBytes(l.subarray(e.BYTES,2*e.BYTES));return{x:b,y:A}});function i(x){let{a:l,b}=t,A=e.sqr(x),p=e.mul(A,x);return e.add(e.add(p,e.mul(x,l)),b)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function c(x){return cr(x,Q,t.n)}function a(x){let{allowedPrivateKeyLengths:l,nByteLength:b,wrapPrivateKey:A,n:p}=t;if(l&&typeof x!="bigint"){if(ee(x)&&(x=qt(x)),typeof x!="string"||!l.includes(x.length))throw new Error("invalid private key");x=x.padStart(b*2,"0")}let v;try{v=typeof x=="bigint"?x:Pt(F("private key",x,b))}catch{throw new Error("invalid private key, expected hex or "+b+" bytes, got "+typeof x)}return A&&(v=z(v,p)),pt("private key",v,Q,p),v}function h(x){if(!(x instanceof m))throw new Error("ProjectivePoint expected")}let f=Ee((x,l)=>{let{px:b,py:A,pz:p}=x;if(e.eql(p,e.ONE))return{x:b,y:A};let v=x.is0();l==null&&(l=v?e.ONE:e.inv(p));let D=e.mul(b,l),T=e.mul(A,l),I=e.mul(p,l);if(v)return{x:e.ZERO,y:e.ZERO};if(!e.eql(I,e.ONE))throw new Error("invZ was invalid");return{x:D,y:T}}),u=Ee(x=>{if(x.is0()){if(t.allowInfinityPoint&&!e.is0(x.py))return;throw new Error("bad point: ZERO")}let{x:l,y:b}=x.toAffine();if(!e.isValid(l)||!e.isValid(b))throw new Error("bad point: x or y not FE");let A=e.sqr(b),p=i(l);if(!e.eql(A,p))throw new Error("bad point: equation left != right");if(!x.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(l,b,A){if(l==null||!e.isValid(l))throw new Error("x required");if(b==null||!e.isValid(b)||e.is0(b))throw new Error("y required");if(A==null||!e.isValid(A))throw new Error("z required");this.px=l,this.py=b,this.pz=A,Object.freeze(this)}static fromAffine(l){let{x:b,y:A}=l||{};if(!l||!e.isValid(b)||!e.isValid(A))throw new Error("invalid affine point");if(l instanceof m)throw new Error("projective point not allowed");let p=v=>e.eql(v,e.ZERO);return p(b)&&p(A)?m.ZERO:new m(b,A,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(l){let b=_e(e,l.map(A=>A.pz));return l.map((A,p)=>A.toAffine(b[p])).map(m.fromAffine)}static fromHex(l){let b=m.fromAffine(s(F("pointHex",l)));return b.assertValidity(),b}static fromPrivateKey(l){return m.BASE.multiply(a(l))}static msm(l,b){return ur(m,n,l,b)}_setWindowSize(l){E.setWindowSize(this,l)}assertValidity(){u(this)}hasEvenY(){let{y:l}=this.toAffine();if(e.isOdd)return!e.isOdd(l);throw new Error("Field doesn't support isOdd")}equals(l){h(l);let{px:b,py:A,pz:p}=this,{px:v,py:D,pz:T}=l,I=e.eql(e.mul(b,T),e.mul(v,p)),L=e.eql(e.mul(A,T),e.mul(D,p));return I&&L}negate(){return new m(this.px,e.neg(this.py),this.pz)}double(){let{a:l,b}=t,A=e.mul(b,Us),{px:p,py:v,pz:D}=this,T=e.ZERO,I=e.ZERO,L=e.ZERO,C=e.mul(p,p),q=e.mul(v,v),M=e.mul(D,D),k=e.mul(p,v);return k=e.add(k,k),L=e.mul(p,D),L=e.add(L,L),T=e.mul(l,L),I=e.mul(A,M),I=e.add(T,I),T=e.sub(q,I),I=e.add(q,I),I=e.mul(T,I),T=e.mul(k,T),L=e.mul(A,L),M=e.mul(l,M),k=e.sub(C,M),k=e.mul(l,k),k=e.add(k,L),L=e.add(C,C),C=e.add(L,C),C=e.add(C,M),C=e.mul(C,k),I=e.add(I,C),M=e.mul(v,D),M=e.add(M,M),C=e.mul(M,k),T=e.sub(T,C),L=e.mul(M,q),L=e.add(L,L),L=e.add(L,L),new m(T,I,L)}add(l){h(l);let{px:b,py:A,pz:p}=this,{px:v,py:D,pz:T}=l,I=e.ZERO,L=e.ZERO,C=e.ZERO,q=t.a,M=e.mul(t.b,Us),k=e.mul(b,v),W=e.mul(A,D),w=e.mul(p,T),B=e.add(b,A),U=e.add(v,D);B=e.mul(B,U),U=e.add(k,W),B=e.sub(B,U),U=e.add(b,p);let y=e.add(v,T);return U=e.mul(U,y),y=e.add(k,w),U=e.sub(U,y),y=e.add(A,p),I=e.add(D,T),y=e.mul(y,I),I=e.add(W,w),y=e.sub(y,I),C=e.mul(q,U),I=e.mul(M,w),C=e.add(I,C),I=e.sub(W,C),C=e.add(W,C),L=e.mul(I,C),W=e.add(k,k),W=e.add(W,k),w=e.mul(q,w),U=e.mul(M,U),W=e.add(W,w),w=e.sub(k,w),w=e.mul(q,w),U=e.add(U,w),k=e.mul(W,U),L=e.add(L,k),k=e.mul(y,U),I=e.mul(B,I),I=e.sub(I,k),k=e.mul(B,W),C=e.mul(y,C),C=e.add(C,k),new m(I,L,C)}subtract(l){return this.add(l.negate())}is0(){return this.equals(m.ZERO)}wNAF(l){return E.wNAFCached(this,l,m.normalizeZ)}multiplyUnsafe(l){let{endo:b,n:A}=t;pt("scalar",l,Nt,A);let p=m.ZERO;if(l===Nt)return p;if(this.is0()||l===Q)return this;if(!b||E.hasPrecomputes(this))return E.wNAFCachedUnsafe(this,l,m.normalizeZ);let{k1neg:v,k1:D,k2neg:T,k2:I}=b.splitScalar(l),L=p,C=p,q=this;for(;D>Nt||I>Nt;)D&Q&&(L=L.add(q)),I&Q&&(C=C.add(q)),q=q.double(),D>>=Q,I>>=Q;return v&&(L=L.negate()),T&&(C=C.negate()),C=new m(e.mul(C.px,b.beta),C.py,C.pz),L.add(C)}multiply(l){let{endo:b,n:A}=t;pt("scalar",l,Q,A);let p,v;if(b){let{k1neg:D,k1:T,k2neg:I,k2:L}=b.splitScalar(l),{p:C,f:q}=this.wNAF(T),{p:M,f:k}=this.wNAF(L);C=E.constTimeNegate(D,C),M=E.constTimeNegate(I,M),M=new m(e.mul(M.px,b.beta),M.py,M.pz),p=C.add(M),v=q.add(k)}else{let{p:D,f:T}=this.wNAF(l);p=D,v=T}return m.normalizeZ([p,v])[0]}multiplyAndAddUnsafe(l,b,A){let p=m.BASE,v=(T,I)=>I===Nt||I===Q||!T.equals(p)?T.multiplyUnsafe(I):T.multiply(I),D=v(this,b).add(v(l,A));return D.is0()?void 0:D}toAffine(l){return f(this,l)}isTorsionFree(){let{h:l,isTorsionFree:b}=t;if(l===Q)return!0;if(b)return b(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:l,clearCofactor:b}=t;return l===Q?this:b?b(m,this):this.multiplyUnsafe(t.h)}toRawBytes(l=!0){return vt("isCompressed",l),this.assertValidity(),o(m,this,l)}toHex(l=!0){return vt("isCompressed",l),qt(this.toRawBytes(l))}}m.BASE=new m(t.Gx,t.Gy,e.ONE),m.ZERO=new m(e.ZERO,e.ONE,e.ZERO);let _=t.nBitLength,E=fr(m,t.endo?Math.ceil(_/2):_);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:c}}function ga(r){let t=He(r);return Rt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Ts(r){let t=ga(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(w){return z(w,n)}function c(w){return ar(w,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:h,weierstrassEquation:f,isWithinCurveOrder:u}=ba({...t,toBytes(w,B,U){let y=B.toAffine(),d=e.toBytes(y.x),g=Vt;return vt("isCompressed",U),U?g(Uint8Array.from([B.hasEvenY()?2:3]),d):g(Uint8Array.from([4]),d,e.toBytes(y.y))},fromBytes(w){let B=w.length,U=w[0],y=w.subarray(1);if(B===o&&(U===2||U===3)){let d=Pt(y);if(!cr(d,Q,e.ORDER))throw new Error("Point is not on curve");let g=f(d),S;try{S=e.sqrt(g)}catch(K){let N=K instanceof Error?": "+K.message:"";throw new Error("Point is not on curve"+N)}let P=(S&Q)===Q;return(U&1)===1!==P&&(S=e.neg(S)),{x:d,y:S}}else if(B===s&&U===4){let d=e.fromBytes(y.subarray(0,e.BYTES)),g=e.fromBytes(y.subarray(e.BYTES,2*e.BYTES));return{x:d,y:g}}else{let d=o,g=s;throw new Error("invalid Point, expected length of "+d+", or uncompressed "+g+", got "+B)}}}),m=w=>qt(ne(w,t.nByteLength));function _(w){let B=n>>Q;return w>B}function E(w){return _(w)?i(-w):w}let x=(w,B,U)=>Pt(w.slice(B,U));class l{constructor(B,U,y){pt("r",B,Q,n),pt("s",U,Q,n),this.r=B,this.s=U,y!=null&&(this.recovery=y),Object.freeze(this)}static fromCompact(B){let U=t.nByteLength;return B=F("compactSignature",B,U*2),new l(x(B,0,U),x(B,U,2*U))}static fromDER(B){let{r:U,s:y}=Kt.toSig(F("DER",B));return new l(U,y)}assertValidity(){}addRecoveryBit(B){return new l(this.r,this.s,B)}recoverPublicKey(B){let{r:U,s:y,recovery:d}=this,g=T(F("msgHash",B));if(d==null||![0,1,2,3].includes(d))throw new Error("recovery id invalid");let S=d===2||d===3?U+t.n:U;if(S>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let P=(d&1)===0?"02":"03",R=a.fromHex(P+m(S)),K=c(S),N=i(-g*K),O=i(y*K),H=a.BASE.multiplyAndAddUnsafe(R,N,O);if(!H)throw new Error("point at infinify");return H.assertValidity(),H}hasHighS(){return _(this.s)}normalizeS(){return this.hasHighS()?new l(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return Me(this.toDERHex())}toDERHex(){return Kt.hexFromSig(this)}toCompactRawBytes(){return Me(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let b={isValidPrivateKey(w){try{return h(w),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{let w=bn(t.n);return es(t.randomBytes(w),t.n)},precompute(w=8,B=a.BASE){return B._setWindowSize(w),B.multiply(BigInt(3)),B}};function A(w,B=!0){return a.fromPrivateKey(w).toRawBytes(B)}function p(w){let B=ee(w),U=typeof w=="string",y=(B||U)&&w.length;return B?y===o||y===s:U?y===2*o||y===2*s:w instanceof a}function v(w,B,U=!0){if(p(w))throw new Error("first arg must be private key");if(!p(B))throw new Error("second arg must be public key");return a.fromHex(B).multiply(h(w)).toRawBytes(U)}let D=t.bits2int||function(w){if(w.length>8192)throw new Error("input is too large");let B=Pt(w),U=w.length*8-t.nBitLength;return U>0?B>>BigInt(U):B},T=t.bits2int_modN||function(w){return i(D(w))},I=oe(t.nBitLength);function L(w){return pt("num < 2^"+t.nBitLength,w,Nt,I),ne(w,t.nByteLength)}function C(w,B,U=q){if(["recovered","canonical"].some(G=>G in U))throw new Error("sign() legacy options not supported");let{hash:y,randomBytes:d}=t,{lowS:g,prehash:S,extraEntropy:P}=U;g==null&&(g=!0),w=F("msgHash",w),Cs(U),S&&(w=F("prehashed msgHash",y(w)));let R=T(w),K=h(B),N=[L(K),L(R)];if(P!=null&&P!==!1){let G=P===!0?d(e.BYTES):P;N.push(F("extraEntropy",G))}let O=Vt(...N),H=R;function Y(G){let tt=D(G);if(!u(tt))return;let ct=c(tt),$=a.BASE.multiply(tt).toAffine(),rt=i($.x);if(rt===Nt)return;let ft=i(ct*i(H+rt*K));if(ft===Nt)return;let yt=($.x===rt?0:2)|Number($.y&Q),Ae=ft;return g&&_(ft)&&(Ae=E(ft),yt^=1),new l(rt,Ae,yt)}return{seed:O,k2sig:Y}}let q={lowS:t.lowS,prehash:!1},M={lowS:t.lowS,prehash:!1};function k(w,B,U=q){let{seed:y,k2sig:d}=C(w,B,U),g=t;return Wo(g.hash.outputLen,g.nByteLength,g.hmac)(y,d)}a.BASE._setWindowSize(8);function W(w,B,U,y=M){let d=w;B=F("msgHash",B),U=F("publicKey",U);let{lowS:g,prehash:S,format:P}=y;if(Cs(y),"strict"in y)throw new Error("options.strict was renamed to lowS");if(P!==void 0&&P!=="compact"&&P!=="der")throw new Error("format must be compact or der");let R=typeof d=="string"||ee(d),K=!R&&!P&&typeof d=="object"&&d!==null&&typeof d.r=="bigint"&&typeof d.s=="bigint";if(!R&&!K)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let N,O;try{if(K&&(N=new l(d.r,d.s)),R){try{P!=="compact"&&(N=l.fromDER(d))}catch(yt){if(!(yt instanceof Kt.Err))throw yt}!N&&P!=="der"&&(N=l.fromCompact(d))}O=a.fromHex(U)}catch{return!1}if(!N||g&&N.hasHighS())return!1;S&&(B=t.hash(B));let{r:H,s:Y}=N,G=T(B),tt=c(Y),ct=i(G*tt),$=i(H*tt),rt=a.BASE.multiplyAndAddUnsafe(O,ct,$)?.toAffine();return rt?i(rt.x)===H:!1}return{CURVE:t,getPublicKey:A,getSharedSecret:v,sign:k,verify:W,ProjectivePoint:a,Signature:l,utils:b}}function wa(r){return{hash:r,hmac:(t,...e)=>Hn(r,t,nn(...e)),randomBytes:sr}}function Ds(r,t){let e=n=>Ts({...r,...wa(n)});return{...e(t),create:e}}var ks=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ps=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ea=BigInt(1),qn=BigInt(2),Rs=(r,t)=>(r+t/qn)/t;function _a(r){let t=ks,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),h=r*r*r%t,f=h*h*r%t,u=V(f,e,t)*f%t,m=V(u,e,t)*f%t,_=V(m,qn,t)*h%t,E=V(_,o,t)*_%t,x=V(E,s,t)*E%t,l=V(x,c,t)*x%t,b=V(l,a,t)*l%t,A=V(b,c,t)*x%t,p=V(A,e,t)*f%t,v=V(p,i,t)*E%t,D=V(v,n,t)*h%t,T=V(D,qn,t);if(!Vn.eql(Vn.sqr(T),r))throw new Error("Cannot find square root");return T}var Vn=kt(ks,void 0,void 0,{sqrt:_a}),ae=Ds({a:BigInt(0),b:BigInt(7),Fp:Vn,n:Ps,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Ps,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Ea*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=Rs(s*r,t),a=Rs(-n*r,t),h=z(r-c*e-a*o,t),f=z(-c*n-a*s,t),u=h>i,m=f>i;if(u&&(h=t-h),m&&(f=t-f),h>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:u,k1:h,k2neg:m,k2:f}}}},qo),Jh=BigInt(0);var Qh=ae.ProjectivePoint;function Ks(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Ns(r,t,e){let n=Te.digest(e instanceof Uint8Array?e:e.subarray());if(Ks(n))return n.then(({digest:o})=>ae.verify(t,o,r)).catch(o=>{throw new je(String(o))});try{return ae.verify(t,n.digest,r)}catch(o){throw new je(String(o))}}var wr=class{type="secp256k1";raw;_key;constructor(t){this._key=Ms(t),this.raw=Os(this._key)}toMultihash(){return bt.digest(ye(this))}toCID(){return at.createV1(114,this.toMultihash())}toString(){return Z.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}verify(t,e){return Ns(this._key,e,t)}};function Hs(r){return new wr(r)}function Os(r){return ae.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Ms(r){try{return ae.ProjectivePoint.fromHex(r),r}catch(t){throw new Xe(String(t))}}function zs(r){let{Type:t,Data:e}=Fe.decode(r.digest),n=e??new Uint8Array;switch(t){case xt.Ed25519:return ps(n);case xt.secp256k1:return Hs(n);case xt.ECDSA:return vo(n);default:throw new ve}}function ye(r){return Fe.encode({Type:xt[r.type],Data:r.raw})}var qs=Symbol.for("nodejs.util.inspect.custom"),Sa=114,Ge=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()})`}[Lr]=!0;toString(){return this.string==null&&(this.string=Z.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return at.createV1(Sa,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return ht(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return ht(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[qs](){return`PeerId(${this.toString()})`}},Er=class extends Ge{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},_r=class extends Ge{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Sr=class extends Ge{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Aa=2336,Ar=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=bt.digest(J(this.url))}[qs](){return`PeerId(${this.url})`}[Lr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return at.createV1(Aa,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=wt(t)),t.toString()===this.toString())}};function Vs(r){if(Ba(r))return new Er({multihash:r});if(va(r))try{let t=zs(r);if(t.type==="Ed25519")return new _r({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Sr({multihash:r,publicKey:t})}catch{let e=wt(r.digest);return new Ar(new URL(e))}throw new $e("Supplied PeerID Multihash is invalid")}function va(r){return r.code===bt.code}function Ba(r){return r.code===Te.code}function It(r,t){let e={[Symbol.iterator]:()=>e,next:()=>{let n=r.next(),o=n.value;return n.done===!0||o==null?{done:!0,value:void 0}:{done:!1,value:t(o)}}};return e}function vr(r){let t=Ce(Z.decode(`z${r}`));return Vs(t)}var Gt=class{map;constructor(t){if(this.map=new Map,t!=null)for(let[e,n]of t.entries())this.map.set(e.toString(),{key:e,value:n})}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(t){return this.map.delete(t.toString())}entries(){return It(this.map.entries(),t=>[t[1].key,t[1].value])}forEach(t){this.map.forEach((e,n)=>{t(e.value,e.key,this)})}get(t){return this.map.get(t.toString())?.value}has(t){return this.map.has(t.toString())}set(t,e){this.map.set(t.toString(),{key:t,value:e})}keys(){return It(this.map.values(),t=>t.key)}values(){return It(this.map.values(),t=>t.value)}get size(){return this.map.size}};function Fs(){return new Gt}var Zt=class r{set;constructor(t){if(this.set=new Set,t!=null)for(let e of t)this.set.add(e.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(t){this.set.add(t.toString())}clear(){this.set.clear()}delete(t){this.set.delete(t.toString())}entries(){return It(this.set.entries(),t=>{let e=vr(t[0]);return[e,e]})}forEach(t){this.set.forEach(e=>{let n=vr(e);t(n,n,this)})}has(t){return this.set.has(t.toString())}values(){return It(this.set.values(),t=>vr(t))}intersection(t){let e=new r;for(let n of t)this.has(n)&&e.add(n);return e}difference(t){let e=new r;for(let n of this)t.has(n)||e.add(n);return e}union(t){let e=new r;for(let n of t)e.add(n);for(let n of this)e.add(n);return e}};function js(){return new Zt}var Yt=class r{list;constructor(t){if(this.list=[],t!=null)for(let e of t)this.list.push(e)}[Symbol.iterator](){return It(this.list.entries(),t=>t[1])}concat(t){let e=new r(this);for(let n of t)e.push(n);return e}entries(){return It(this.list.entries(),t=>[t[0],t[1]])}every(t){return this.list.every((e,n)=>t(e,n,this))}filter(t){let e=new r;return this.list.forEach((n,o)=>{t(n,o,this)&&e.push(n)}),e}find(t){let e=this.list.find((n,o)=>t(n,o,this));if(e!=null)return e}findIndex(t){return this.list.findIndex((e,n)=>t(e,n,this))}forEach(t){this.list.forEach((e,n)=>{t(e,n,this)})}includes(t){return this.includes(t)}indexOf(t){return this.list.findIndex(e=>e.equals(t))}pop(){let t=this.list.pop();if(t!=null)return t}push(...t){for(let e of t)this.list.push(e)}shift(){let t=this.list.shift();if(t!=null)return t}unshift(...t){let e=this.list.length;for(let n=t.length-1;n>-1;n--)e=this.list.unshift(t[n]);return e}clear(){this.list=[]}get length(){return this.list.length}};function Gs(){return new Yt}var Fn={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},Zs={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},Ys=new globalThis.TextEncoder;function Ia(r,t){let e=Fn[t],n=Zs[t];for(let o=0;o<r.length;o++)n^=BigInt(r[o]),n=BigInt.asUintN(t,n*e);return n}function La(r,t,e){if(e.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");let n=Fn[t],o=Zs[t],s=r;for(;s.length>0;){let i=Ys.encodeInto(s,e);s=s.slice(i.read);for(let c=0;c<i.written;c++)o^=BigInt(e[c]),o=BigInt.asUintN(t,o*n)}return o}function jn(r,{size:t=32,utf8Buffer:e}={}){if(!Fn[t])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if(typeof r=="string"){if(e)return La(r,t,e);r=Ys.encode(r)}return Ia(r,t)}var Ze={hash:r=>Number(jn(r,{size:32})),hashV:(r,t)=>Ca(Ze.hash(r,t))};function Ca(r){let t=r.toString(16);return t.length%2===1&&(t=`0${t}`),J(t,"base16")}var Gn=64,St=class{fp;h;seed;constructor(t,e,n,o=2){if(o>Gn)throw new TypeError("Invalid Fingerprint Size");let s=e.hashV(t,n),i=gt(o);for(let c=0;c<i.length;c++)i[c]=s[c];i.length===0&&(i[0]=7),this.fp=i,this.h=e,this.seed=n}hash(){return this.h.hash(this.fp,this.seed)}equals(t){return t?.fp instanceof Uint8Array?ht(this.fp,t.fp):!1}};function fe(r,t){return Math.floor(Math.random()*(t-r))+r}var ue=class{contents;constructor(t){this.contents=new Array(t).fill(null)}has(t){if(!(t instanceof St))throw new TypeError("Invalid Fingerprint");return this.contents.some(e=>t.equals(e))}add(t){if(!(t instanceof St))throw new TypeError("Invalid Fingerprint");for(let e=0;e<this.contents.length;e++)if(this.contents[e]==null)return this.contents[e]=t,!0;return!0}swap(t){if(!(t instanceof St))throw new TypeError("Invalid Fingerprint");let e=fe(0,this.contents.length-1),n=this.contents[e];return this.contents[e]=t,n}remove(t){if(!(t instanceof St))throw new TypeError("Invalid Fingerprint");let e=this.contents.findIndex(n=>t.equals(n));return e>-1?(this.contents[e]=null,!0):!1}};var Ua=500,Ye=class{bucketSize;filterSize;fingerprintSize;buckets;count;hash;seed;constructor(t){this.filterSize=t.filterSize,this.bucketSize=t.bucketSize??4,this.fingerprintSize=t.fingerprintSize??2,this.count=0,this.buckets=[],this.hash=t.hash??Ze,this.seed=t.seed??fe(0,Math.pow(2,10))}add(t){typeof t=="string"&&(t=J(t));let e=new St(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=(n^e.hash())%this.filterSize;if(this.buckets[n]==null&&(this.buckets[n]=new ue(this.bucketSize)),this.buckets[o]==null&&(this.buckets[o]=new ue(this.bucketSize)),this.buckets[n].add(e)||this.buckets[o].add(e))return this.count++,!0;let s=[n,o],i=s[fe(0,s.length-1)];this.buckets[i]==null&&(this.buckets[i]=new ue(this.bucketSize));for(let c=0;c<Ua;c++){let a=this.buckets[i].swap(e);if(a!=null&&(i=(i^a.hash())%this.filterSize,this.buckets[i]==null&&(this.buckets[i]=new ue(this.bucketSize)),this.buckets[i].add(a)))return this.count++,!0}return!1}has(t){typeof t=="string"&&(t=J(t));let e=new St(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.has(e)??!1;if(o)return o;let s=(n^e.hash())%this.filterSize;return this.buckets[s]?.has(e)??!1}remove(t){typeof t=="string"&&(t=J(t));let e=new St(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.remove(e)??!1;if(o)return this.count--,o;let s=(n^e.hash())%this.filterSize,i=this.buckets[s]?.remove(e)??!1;return i&&this.count--,i}get reliable(){return Math.floor(100*(this.count/this.filterSize))<=90}},Ta={1:.5,2:.84,4:.95,8:.98};function Da(r=.001){return r>.002?2:r>1e-5?4:8}function Ws(r,t=.001){let e=Da(t),n=Ta[e],o=Math.round(r/n),s=Math.min(Math.ceil(Math.log2(1/t)+Math.log2(2*e)),Gn);return{filterSize:o,bucketSize:e,fingerprintSize:s}}var Br=class{filterSize;bucketSize;fingerprintSize;scale;filterSeries;hash;seed;constructor(t){this.bucketSize=t.bucketSize??4,this.filterSize=t.filterSize??(1<<18)/this.bucketSize,this.fingerprintSize=t.fingerprintSize??2,this.scale=t.scale??2,this.hash=t.hash??Ze,this.seed=t.seed??fe(0,Math.pow(2,10)),this.filterSeries=[new Ye({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(t){if(typeof t=="string"&&(t=J(t)),this.has(t))return!0;let e=this.filterSeries.find(n=>n.reliable);if(e==null){let n=this.filterSize*Math.pow(this.scale,this.filterSeries.length);e=new Ye({filterSize:n,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(e)}return e.add(t)}has(t){typeof t=="string"&&(t=J(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].has(t))return!0;return!1}remove(t){typeof t=="string"&&(t=J(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].remove(t))return!0;return!1}get count(){return this.filterSeries.reduce((t,e)=>t+e.count,0)}};function Zn(r,t=.001,e){return new Br({...Ws(r,t),...e??{}})}var We=class{filter;constructor(t,e){this.filter=Zn(t,e)}has(t){return this.filter.has(t.toMultihash().bytes)}add(t){this.filter.add(t.toMultihash().bytes)}remove(t){this.filter.remove?.(t.toMultihash().bytes)}};function Xs(r,t=.001){return new We(r,t)}var Yn=class extends Gt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}set(t,e){return super.set(t,e),this.updateComponentMetric(),this}delete(t){let e=super.delete(t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function $s(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Yn({name:t,metrics:e}):n=new Gt,n}var Wn=class extends Zt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}add(t){super.add(t),this.updateComponentMetric()}delete(t){super.delete(t),this.updateComponentMetric()}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function Js(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Wn({name:t,metrics:e}):n=new Zt,n}var Xn=class extends Yt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}pop(){let t=super.pop();return this.updateComponentMetric(),t}push(...t){super.push(...t),this.updateComponentMetric()}shift(){let t=super.shift();return this.updateComponentMetric(),t}unshift(...t){let e=super.unshift(...t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.length)}};function Qs(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Xn({name:t,metrics:e}):n=new Yt,n}return ai(Pa);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/hashes/esm/utils.js:
|
|
6
6
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
7
7
|
|
|
8
8
|
@noble/curves/esm/abstract/utils.js:
|
|
9
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
10
|
-
|
|
11
9
|
@noble/curves/esm/abstract/modular.js:
|
|
12
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
13
|
-
|
|
14
10
|
@noble/curves/esm/abstract/curve.js:
|
|
15
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
16
|
-
|
|
17
11
|
@noble/curves/esm/abstract/edwards.js:
|
|
18
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
19
|
-
|
|
20
12
|
@noble/curves/esm/ed25519.js:
|
|
21
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
22
|
-
|
|
23
13
|
@noble/curves/esm/abstract/weierstrass.js:
|
|
24
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
25
|
-
|
|
26
14
|
@noble/curves/esm/_shortw_utils.js:
|
|
27
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
28
|
-
|
|
29
15
|
@noble/curves/esm/secp256k1.js:
|
|
30
16
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
31
17
|
*/
|
|
32
18
|
return Libp2PPeerCollections}));
|
|
19
|
+
//# sourceMappingURL=index.min.js.map
|