@libp2p/bootstrap 11.0.32-fc5122110 → 11.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/typedoc-urls.json +8 -0
- package/package.json +6 -6
package/dist/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PBootstrap = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PBootstrap=(()=>{var Vr=Object.defineProperty;var qi=Object.getOwnPropertyDescriptor;var Vi=Object.getOwnPropertyNames;var zi=Object.prototype.hasOwnProperty;var dt=(r,t)=>{for(var e in t)Vr(r,e,{get:t[e],enumerable:!0})},Fi=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Vi(t))!zi.call(r,o)&&o!==e&&Vr(r,o,{get:()=>t[o],enumerable:!(n=qi(t,o))||n.enumerable});return r};var Gi=r=>Fi(Vr({},"__esModule",{value:!0}),r);var Sf={};dt(Sf,{bootstrap:()=>Ef});var Ro=Symbol.for("@libp2p/peer-discovery");var zr=Symbol.for("@libp2p/peer-id");var Ct=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Qe=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Je=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},tr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var _e=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var er=class extends EventTarget{#t=new Map;constructor(){super()}listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e={}){return this.dispatchEvent(new CustomEvent(t,e))}};var No=Symbol.for("@libp2p/service-capabilities"),Lf=Symbol.for("@libp2p/service-dependencies");async function ko(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())}function _t(r=0){return new Uint8Array(r)}function pt(r=0){return new Uint8Array(r)}function bt(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=pt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}function yt(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}var Ko=Symbol.for("@achingbrain/uint8arraylist");function Oo(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 rr(r){return!!r?.[Ko]}var wt=class r{bufs;length;[Ko]=!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(rr(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(rr(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=Oo(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Oo(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(rr(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 bt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:bt(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 l=t>=c&&t<a,u=e>c&&e<=a;if(l&&u){if(t===c&&e===a){n.push(i);break}let f=t-c;n.push(i.subarray(f,f+(e-t)));break}if(l){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(u){if(e===a){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!rr(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 f=0;f<s;f++)i[f]=-1;for(let f=0;f<o;f++)i[n[f]]=f;let c=i,a=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=e;f<=a;f+=u){u=0;for(let p=l;p>=0;p--){let y=this.get(f+p);if(n[p]!==y){u=Math.max(1,p-c[y]);break}}if(u===0)return f}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=pt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=_t(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=_t(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=_t(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=pt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=_t(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=_t(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=_t(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=_t(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=_t(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(!yt(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 Wr={};dt(Wr,{base10:()=>Xi});var ul=new Uint8Array(0);function Mo(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 Rt(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 Ho(r){return new TextEncoder().encode(r)}function qo(r){return new TextDecoder().decode(r)}function ji(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),l=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function f(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var x=0,h=0,E=0,A=w.length;E!==A&&w[E]===0;)E++,x++;for(var m=(A-E)*u+1>>>0,I=new Uint8Array(m);E!==A;){for(var _=w[E],U=0,T=m-1;(_!==0||U<h)&&T!==-1;T--,U++)_+=256*I[T]>>>0,I[T]=_%c>>>0,_=_/c>>>0;if(_!==0)throw new Error("Non-zero carry");h=U,E++}for(var C=m-h;C!==m&&I[C]===0;)C++;for(var L=a.repeat(x);C<m;++C)L+=r.charAt(I[C]);return L}function p(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var x=0;if(w[x]!==" "){for(var h=0,E=0;w[x]===a;)h++,x++;for(var A=(w.length-x)*l+1>>>0,m=new Uint8Array(A);w[x];){var I=e[w.charCodeAt(x)];if(I===255)return;for(var _=0,U=A-1;(I!==0||_<E)&&U!==-1;U--,_++)I+=c*m[U]>>>0,m[U]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");E=_,x++}if(w[x]!==" "){for(var T=A-E;T!==A&&m[T]===0;)T++;for(var C=new Uint8Array(h+(A-T)),L=h;T!==A;)C[L++]=m[T++];return C}}}function y(w){var x=p(w);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:p,decode:y}}var Zi=ji,Wi=Zi,zo=Wi;var Fr=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")}},Gr=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 Fo(this,t)}},jr=class{decoders;constructor(t){this.decoders=t}or(t){return Fo(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 Fo(r,t){return new jr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Zr=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 Fr(t,e,n),this.decoder=new Gr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ge({name:r,prefix:t,encode:e,decode:n}){return new Zr(r,t,e,n)}function Vt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=zo(e,r);return ge({prefix:t,name:r,encode:n,decode:s=>Rt(o(s))})}function $i(r,t,e,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),c=0,a=0,l=0;for(let u=0;u<s;++u){let f=o[r[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|f,c+=e,c>=8&&(c-=8,i[l++]=255&a>>c)}if(c>=e||(255&a<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return i}function Yi(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 ge({prefix:t,name:r,encode(o){return Yi(o,n,e)},decode(o){return $i(o,n,e,r)}})}var Xi=Vt({prefix:"9",name:"base10",alphabet:"0123456789"});var $r={};dt($r,{base16:()=>Qi,base16upper:()=>Ji});var Qi=J({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ji=J({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Yr={};dt(Yr,{base2:()=>tc});var tc=J({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Xr={};dt(Xr,{base256emoji:()=>sc});var Go=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}"),ec=Go.reduce((r,t,e)=>(r[e]=t,r),[]),rc=Go.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function nc(r){return r.reduce((t,e)=>(t+=ec[e],t),"")}function oc(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=rc[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var sc=ge({prefix:"\u{1F680}",name:"base256emoji",encode:nc,decode:oc});var Qr={};dt(Qr,{base32:()=>Nt,base32hex:()=>uc,base32hexpad:()=>lc,base32hexpadupper:()=>hc,base32hexupper:()=>fc,base32pad:()=>cc,base32padupper:()=>ac,base32upper:()=>ic,base32z:()=>dc});var Nt=J({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ic=J({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),cc=J({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ac=J({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),uc=J({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),fc=J({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),lc=J({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),hc=J({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),dc=J({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Jr={};dt(Jr,{base36:()=>Re,base36upper:()=>pc});var Re=Vt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),pc=Vt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var tn={};dt(tn,{base58btc:()=>$,base58flickr:()=>mc});var $=Vt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),mc=Vt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var en={};dt(en,{base64:()=>gc,base64pad:()=>xc,base64url:()=>bc,base64urlpad:()=>yc});var gc=J({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),xc=J({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),bc=J({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),yc=J({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var rn={};dt(rn,{base8:()=>wc});var wc=J({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var nn={};dt(nn,{identity:()=>Ec});var Ec=ge({prefix:"\0",name:"identity",encode:r=>qo(r),decode:r=>Ho(r)});var Bl=new TextEncoder,Il=new TextDecoder;var sn={};dt(sn,{identity:()=>At});var Ac=Wo,jo=128,Bc=127,Ic=~Bc,Tc=Math.pow(2,31);function Wo(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Tc;)t[e++]=r&255|jo,r/=128;for(;r&Ic;)t[e++]=r&255|jo,r>>>=7;return t[e]=r|0,Wo.bytes=e-n+1,t}var Lc=on,Pc=128,Zo=127;function on(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw on.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&Zo)<<o:(i&Zo)*Math.pow(2,o),o+=7}while(i>=Pc);return on.bytes=s-n,e}var Cc=Math.pow(2,7),Uc=Math.pow(2,14),Dc=Math.pow(2,21),_c=Math.pow(2,28),Rc=Math.pow(2,35),Nc=Math.pow(2,42),kc=Math.pow(2,49),Oc=Math.pow(2,56),Kc=Math.pow(2,63),Mc=function(r){return r<Cc?1:r<Uc?2:r<Dc?3:r<_c?4:r<Rc?5:r<Nc?6:r<kc?7:r<Oc?8:r<Kc?9:10},Hc={encode:Ac,decode:Lc,encodingLength:Mc},qc=Hc,Ne=qc;function ke(r,t=0){return[Ne.decode(r,t),Ne.decode.bytes]}function xe(r,t,e=0){return Ne.encode(r,t,e),t}function be(r){return Ne.encodingLength(r)}function te(r,t){let e=t.byteLength,n=be(r),o=n+be(e),s=new Uint8Array(o+e);return xe(r,s,0),xe(e,s,n),s.set(t,o),new ye(r,e,t,s)}function ee(r){let t=Rt(r),[e,n]=ke(t),[o,s]=ke(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ye(e,o,i,t)}function $o(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Mo(r.bytes,e.bytes)}}var ye=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var Yo=0,Vc="identity",Xo=Rt;function zc(r){return te(Yo,Xo(r))}var At={code:Yo,name:Vc,encode:Xo,digest:zc};var un={};dt(un,{sha256:()=>Oe,sha512:()=>Fc});function an({name:r,code:t,encode:e}){return new cn(r,t,e)}var cn=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?te(this.code,e):e.then(n=>te(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Jo(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Oe=an({name:"sha2-256",code:18,encode:Jo("SHA-256")}),Fc=an({name:"sha2-512",code:19,encode:Jo("SHA-512")});function ts(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return jc(e,fn(r),t??$.encoder);default:return Zc(e,fn(r),t??Nt.encoder)}}var es=new WeakMap;function fn(r){let t=es.get(r);if(t==null){let e=new Map;return es.set(r,e),e}return t}var rt=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!==Ke)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Wc)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=te(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&&$o(t.multihash,n.multihash)}toString(t){return ts(this,t)}toJSON(){return{"/":ts(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??rs(n,o,s.bytes))}else if(e[$c]===!0){let{version:n,multihash:o,code:s}=e,i=ee(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!==Ke)throw new Error(`Version 0 CID must use dag-pb (code: ${Ke}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=rs(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Ke,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=Rt(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 ye(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[f,p]=ke(t.subarray(e));return e+=p,f},o=n(),s=Ke;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(),l=e+a,u=l-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:u,size:l}}static parse(t,e){let[n,o]=Gc(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 fn(s).set(n,t),s}};function Gc(r,t){switch(r[0]){case"Q":{let e=t??$;return[$.prefix,e.decode(`${$.prefix}${r}`)]}case $.prefix:{let e=t??$;return[$.prefix,e.decode(r)]}case Nt.prefix:{let e=t??Nt;return[Nt.prefix,e.decode(r)]}case Re.prefix:{let e=t??Re;return[Re.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function jc(r,t,e){let{prefix:n}=e;if(n!==$.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 Zc(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 Ke=112,Wc=18;function rs(r,t,e){let n=be(r),o=n+be(t),s=new Uint8Array(o+e.byteLength);return xe(r,s,0),xe(t,s,n),s.set(e,o),s}var $c=Symbol.for("@ipld/js-cid/CID");var Me={...nn,...Yr,...rn,...Wr,...$r,...Qr,...Jr,...tn,...en,...Xr},Wl={...un,...sn};function os(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var ns=os("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ln=os("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=pt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Yc={utf8:ns,"utf-8":ns,hex:Me.base16,latin1:ln,ascii:ln,binary:ln,...Me},or=Yc;function vt(r,t="utf8"){let e=or[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function G(r,t="utf8"){let e=or[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Xc=parseInt("11111",2),hn=parseInt("10000000",2),Qc=parseInt("01111111",2),ss={0:He,1:He,2:Jc,3:ra,4:na,5:ea,6:ta,16:He,22:He,48:He};function dn(r,t={offset:0}){let e=r[t.offset]&Xc;if(t.offset++,ss[e]!=null)return ss[e](r,t);throw new Error("No decoder for tag "+e)}function qe(r,t){let e=0;if((r[t.offset]&hn)===hn){let n=r[t.offset]&Qc,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 He(r,t){qe(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=dn(r,t);if(n===null)break;e.push(n)}return e}function Jc(r,t){let e=qe(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function ta(r,t){let e=qe(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 l=r[t.offset];if(t.offset++,a.push(l&127),l<128){a.reverse();let u=0;for(let f=0;f<a.length;f++)u+=a[f]<<f*7;c+=`.${u}`,a=[]}}return c}function ea(r,t){return t.offset++,null}function ra(r,t){let e=qe(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function na(r,t){let e=qe(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function oa(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new wt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function pn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=oa(r.byteLength);return new wt(Uint8Array.from([t.byteLength|hn]),t)}function is(r){let t=new wt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new wt(Uint8Array.from([2]),pn(t),t)}function cs(r){let t=Uint8Array.from([0]),e=new wt(t,r);return new wt(Uint8Array.from([3]),pn(e),e)}function sr(r,t=48){let e=new wt;for(let n of r)e.append(n);return new wt(Uint8Array.from([t]),pn(e),e)}var we=class{type="ECDSA";raw;_key;constructor(t){this._key=t,this.raw=as(t)}toMultihash(){return At.digest(Ee(this))}toCID(){return rt.createV1(114,this.toMultihash())}toString(){return $.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}async verify(t,e){return ko(this._key,e,t)}};var sa=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),ia=Uint8Array.from([6,5,43,129,4,0,34]),ca=Uint8Array.from([6,5,43,129,4,0,35]),aa={ext:!0,kty:"EC",crv:"P-256"},ua={ext:!0,kty:"EC",crv:"P-384"},fa={ext:!0,kty:"EC",crv:"P-521"},mn=32,gn=48,xn=66;function us(r){let t=dn(r);return fs(t)}function fs(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===mn*2+1)return n=G(t.subarray(e,e+mn),"base64url"),o=G(t.subarray(e+mn),"base64url"),new we({...aa,key_ops:["verify"],x:n,y:o});if(t.byteLength===gn*2+1)return n=G(t.subarray(e,e+gn),"base64url"),o=G(t.subarray(e+gn),"base64url"),new we({...ua,key_ops:["verify"],x:n,y:o});if(t.byteLength===xn*2+1)return n=G(t.subarray(e,e+xn),"base64url"),o=G(t.subarray(e+xn),"base64url"),new we({...fa,key_ops:["verify"],x:n,y:o});throw new Ct(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function as(r){return sr([is(Uint8Array.from([1])),sr([la(r.crv)],160),sr([cs(new wt(Uint8Array.from([4]),vt(r.x??"","base64url"),vt(r.y??"","base64url")))],161)]).subarray()}function la(r){if(r==="P-256")return sa;if(r==="P-384")return ia;if(r==="P-521")return ca;throw new Ct(`Invalid curve ${r}`)}function ls(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function ha(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Se(r,...t){if(!ha(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 hs(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ls(r.outputLen),ls(r.blockLen)}function ve(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 ds(r,t){Se(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var ne=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function ir(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Bt(r,t){return r<<32-t|r>>>t}function ps(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Ve(r){return typeof r=="string"&&(r=ps(r)),Se(r),r}function bn(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Se(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 Ae=class{clone(){return this._cloneInto()}};function cr(r){let t=n=>r().update(Ve(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function ar(r=32){if(ne&&typeof ne.getRandomValues=="function")return ne.getRandomValues(new Uint8Array(r));if(ne&&typeof ne.randomBytes=="function")return ne.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function da(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),c=Number(e&s),a=n?4:0,l=n?0:4;r.setUint32(t+a,i,n),r.setUint32(t+l,c,n)}function ms(r,t,e){return r&t^~r&e}function gs(r,t,e){return r&t^r&e^t&e}var Be=class extends Ae{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ir(this.buffer)}update(t){ve(this);let{view:e,buffer:n,blockLen:o}=this;t=Ve(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=ir(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){ve(this),ds(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 f=i;f<o;f++)e[f]=0;da(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=ir(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=a/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)c.setUint32(4*f,u[f],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 ur=BigInt(4294967295),yn=BigInt(32);function xs(r,t=!1){return t?{h:Number(r&ur),l:Number(r>>yn&ur)}:{h:Number(r>>yn&ur)|0,l:Number(r&ur)|0}}function pa(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}=xs(r[o],t);[e[o],n[o]]=[s,i]}return[e,n]}var ma=(r,t)=>BigInt(r>>>0)<<yn|BigInt(t>>>0),ga=(r,t,e)=>r>>>e,xa=(r,t,e)=>r<<32-e|t>>>e,ba=(r,t,e)=>r>>>e|t<<32-e,ya=(r,t,e)=>r<<32-e|t>>>e,wa=(r,t,e)=>r<<64-e|t>>>e-32,Ea=(r,t,e)=>r>>>e-32|t<<64-e,Sa=(r,t)=>t,va=(r,t)=>r,Aa=(r,t,e)=>r<<e|t>>>32-e,Ba=(r,t,e)=>t<<e|r>>>32-e,Ia=(r,t,e)=>t<<e-32|r>>>64-e,Ta=(r,t,e)=>r<<e-32|t>>>64-e;function La(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var Pa=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Ca=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Ua=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Da=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,_a=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Ra=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Na={fromBig:xs,split:pa,toBig:ma,shrSH:ga,shrSL:xa,rotrSH:ba,rotrSL:ya,rotrBH:wa,rotrBL:Ea,rotr32H:Sa,rotr32L:va,rotlSH:Aa,rotlSL:Ba,rotlBH:Ia,rotlBL:Ta,add:La,add3L:Pa,add3H:Ca,add4L:Ua,add4H:Da,add5H:Ra,add5L:_a},O=Na;var[ka,Oa]=O.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))),zt=new Uint32Array(80),Ft=new Uint32Array(80),wn=class extends Be{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:l,El:u,Fh:f,Fl:p,Gh:y,Gl:w,Hh:x,Hl:h}=this;return[t,e,n,o,s,i,c,a,l,u,f,p,y,w,x,h]}set(t,e,n,o,s,i,c,a,l,u,f,p,y,w,x,h){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=p|0,this.Gh=y|0,this.Gl=w|0,this.Hh=x|0,this.Hl=h|0}process(t,e){for(let m=0;m<16;m++,e+=4)zt[m]=t.getUint32(e),Ft[m]=t.getUint32(e+=4);for(let m=16;m<80;m++){let I=zt[m-15]|0,_=Ft[m-15]|0,U=O.rotrSH(I,_,1)^O.rotrSH(I,_,8)^O.shrSH(I,_,7),T=O.rotrSL(I,_,1)^O.rotrSL(I,_,8)^O.shrSL(I,_,7),C=zt[m-2]|0,L=Ft[m-2]|0,W=O.rotrSH(C,L,19)^O.rotrBH(C,L,61)^O.shrSH(C,L,6),q=O.rotrSL(C,L,19)^O.rotrBL(C,L,61)^O.shrSL(C,L,6),M=O.add4L(T,q,Ft[m-7],Ft[m-16]),et=O.add4H(M,U,W,zt[m-7],zt[m-16]);zt[m]=et|0,Ft[m]=M|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:l,Dl:u,Eh:f,El:p,Fh:y,Fl:w,Gh:x,Gl:h,Hh:E,Hl:A}=this;for(let m=0;m<80;m++){let I=O.rotrSH(f,p,14)^O.rotrSH(f,p,18)^O.rotrBH(f,p,41),_=O.rotrSL(f,p,14)^O.rotrSL(f,p,18)^O.rotrBL(f,p,41),U=f&y^~f&x,T=p&w^~p&h,C=O.add5L(A,_,T,Oa[m],Ft[m]),L=O.add5H(C,E,I,U,ka[m],zt[m]),W=C|0,q=O.rotrSH(n,o,28)^O.rotrBH(n,o,34)^O.rotrBH(n,o,39),M=O.rotrSL(n,o,28)^O.rotrBL(n,o,34)^O.rotrBL(n,o,39),et=n&s^n&c^s&c,v=o&i^o&a^i&a;E=x|0,A=h|0,x=y|0,h=w|0,y=f|0,w=p|0,{h:f,l:p}=O.add(l|0,u|0,L|0,W|0),l=c|0,u=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let P=O.add3L(W,M,v);n=O.add3H(P,L,q,et),o=P|0}({h:n,l:o}=O.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=O.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=O.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:l,l:u}=O.add(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:p}=O.add(this.Eh|0,this.El|0,f|0,p|0),{h:y,l:w}=O.add(this.Fh|0,this.Fl|0,y|0,w|0),{h:x,l:h}=O.add(this.Gh|0,this.Gl|0,x|0,h|0),{h:E,l:A}=O.add(this.Hh|0,this.Hl|0,E|0,A|0),this.set(n,o,s,i,c,a,l,u,f,p,y,w,x,h,E,A)}roundClean(){zt.fill(0),Ft.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 bs=cr(()=>new wn);var hr={};dt(hr,{aInRange:()=>mt,abool:()=>It,abytes:()=>Ie,bitGet:()=>za,bitLen:()=>An,bitMask:()=>Fe,bitSet:()=>Fa,bytesToHex:()=>Ot,bytesToNumberBE:()=>Kt,bytesToNumberLE:()=>jt,concatBytes:()=>Mt,createHmacDrbg:()=>Bn,ensureBytes:()=>Q,equalBytes:()=>qa,hexToBytes:()=>se,hexToNumber:()=>vn,inRange:()=>ze,isBytes:()=>Gt,memoized:()=>ce,notImplemented:()=>ja,numberToBytesBE:()=>Zt,numberToBytesLE:()=>ie,numberToHexUnpadded:()=>oe,numberToVarBytesBE:()=>Ha,utf8ToBytes:()=>Va,validateObject:()=>Ut});var fr=BigInt(0),lr=BigInt(1),Ka=BigInt(2);function Gt(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ie(r){if(!Gt(r))throw new Error("Uint8Array expected")}function It(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var Ma=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Ot(r){Ie(r);let t="";for(let e=0;e<r.length;e++)t+=Ma[r[e]];return t}function oe(r){let t=r.toString(16);return t.length&1?"0"+t:t}function vn(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?fr:BigInt("0x"+r)}var kt={_0:48,_9:57,A:65,F:70,a:97,f:102};function ys(r){if(r>=kt._0&&r<=kt._9)return r-kt._0;if(r>=kt.A&&r<=kt.F)return r-(kt.A-10);if(r>=kt.a&&r<=kt.f)return r-(kt.a-10)}function se(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=ys(r.charCodeAt(s)),c=ys(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 Kt(r){return vn(Ot(r))}function jt(r){return Ie(r),vn(Ot(Uint8Array.from(r).reverse()))}function Zt(r,t){return se(r.toString(16).padStart(t*2,"0"))}function ie(r,t){return Zt(r,t).reverse()}function Ha(r){return se(oe(r))}function Q(r,t,e){let n;if(typeof t=="string")try{n=se(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(Gt(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 Mt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Ie(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}function qa(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function Va(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var En=r=>typeof r=="bigint"&&fr<=r;function ze(r,t,e){return En(r)&&En(t)&&En(e)&&t<=r&&r<e}function mt(r,t,e,n){if(!ze(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function An(r){let t;for(t=0;r>fr;r>>=lr,t+=1);return t}function za(r,t){return r>>BigInt(t)&lr}function Fa(r,t,e){return r|(e?lr:fr)<<BigInt(t)}var Fe=r=>(Ka<<BigInt(r-1))-lr,Sn=r=>new Uint8Array(r),ws=r=>Uint8Array.from(r);function Bn(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=Sn(r),o=Sn(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...f)=>e(o,n,...f),a=(f=Sn())=>{o=c(ws([0]),f),n=c(),f.length!==0&&(o=c(ws([1]),f),n=c())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,p=[];for(;f<t;){n=c();let y=n.slice();p.push(y),f+=n.length}return Mt(...p)};return(f,p)=>{i(),a(f);let y;for(;!(y=p(l()));)a();return i(),y}}var Ga={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"||Gt(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 Ut(r,t,e={}){let n=(o,s,i)=>{let c=Ga[s];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(i&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+a)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}var ja=()=>{throw new Error("not implemented")};function ce(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 nt=BigInt(0),Y=BigInt(1),ae=BigInt(2),Za=BigInt(3),In=BigInt(4),Es=BigInt(5),Ss=BigInt(8),Wa=BigInt(9),$a=BigInt(16);function F(r,t){let e=r%t;return e>=nt?e:t+e}function Ya(r,t,e){if(t<nt)throw new Error("invalid exponent, negatives unsupported");if(e<=nt)throw new Error("invalid modulus");if(e===Y)return nt;let n=Y;for(;t>nt;)t&Y&&(n=n*r%e),r=r*r%e,t>>=Y;return n}function X(r,t,e){let n=r;for(;t-- >nt;)n*=n,n%=e;return n}function dr(r,t){if(r===nt)throw new Error("invert: expected non-zero number");if(t<=nt)throw new Error("invert: expected positive modulus, got "+t);let e=F(r,t),n=t,o=nt,s=Y,i=Y,c=nt;for(;e!==nt;){let l=n/e,u=n%e,f=o-i*l,p=s-c*l;n=e,e=u,o=i,s=c,i=f,c=p}if(n!==Y)throw new Error("invert: does not exist");return F(o,t)}function Xa(r){let t=(r-Y)/ae,e,n,o;for(e=r-Y,n=0;e%ae===nt;e/=ae,n++);for(o=ae;o<r&&Ya(o,t,r)!==r-Y;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let i=(r+Y)/In;return function(a,l){let u=a.pow(l,i);if(!a.eql(a.sqr(u),l))throw new Error("Cannot find square root");return u}}let s=(e+Y)/ae;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let l=n,u=c.pow(c.mul(c.ONE,o),e),f=c.pow(a,s),p=c.pow(a,e);for(;!c.eql(p,c.ONE);){if(c.eql(p,c.ZERO))return c.ZERO;let y=1;for(let x=c.sqr(p);y<l&&!c.eql(x,c.ONE);y++)x=c.sqr(x);let w=c.pow(u,Y<<BigInt(l-y-1));u=c.sqr(w),f=c.mul(f,w),p=c.mul(p,u),l=y}return f}}function Qa(r){if(r%In===Za){let t=(r+Y)/In;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%Ss===Es){let t=(r-Es)/Ss;return function(n,o){let s=n.mul(o,ae),i=n.pow(s,t),c=n.mul(o,i),a=n.mul(n.mul(c,ae),i),l=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(l),o))throw new Error("Cannot find square root");return l}}return r%$a,Xa(r)}var vs=(r,t)=>(F(r,t)&Y)===Y,Ja=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Tn(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Ja.reduce((n,o)=>(n[o]="function",n),t);return Ut(r,e)}function tu(r,t,e){if(e<nt)throw new Error("invalid exponent, negatives unsupported");if(e===nt)return r.ONE;if(e===Y)return t;let n=r.ONE,o=t;for(;e>nt;)e&Y&&(n=r.mul(n,o)),o=r.sqr(o),e>>=Y;return n}function eu(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 Ln(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Wt(r,t,e=!1,n={}){if(r<=nt)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=Ln(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:Fe(o),ZERO:nt,ONE:Y,create:a=>F(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return nt<=a&&a<r},is0:a=>a===nt,isOdd:a=>(a&Y)===Y,neg:a=>F(-a,r),eql:(a,l)=>a===l,sqr:a=>F(a*a,r),add:(a,l)=>F(a+l,r),sub:(a,l)=>F(a-l,r),mul:(a,l)=>F(a*l,r),pow:(a,l)=>tu(c,a,l),div:(a,l)=>F(a*dr(l,r),r),sqrN:a=>a*a,addN:(a,l)=>a+l,subN:(a,l)=>a-l,mulN:(a,l)=>a*l,inv:a=>dr(a,r),sqrt:n.sqrt||(a=>(i||(i=Qa(r)),i(c,a))),invertBatch:a=>eu(c,a),cmov:(a,l,u)=>u?l:a,toBytes:a=>e?ie(a,s):Zt(a,s),fromBytes:a=>{if(a.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+a.length);return e?jt(a):Kt(a)}});return Object.freeze(c)}function As(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 Pn(r){let t=As(r);return t+Math.ceil(t/2)}function Bs(r,t,e=!1){let n=r.length,o=As(t),s=Pn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?jt(r):Kt(r),c=F(i,t-Y)+Y;return e?ie(c,o):Zt(c,o)}var Is=BigInt(0),pr=BigInt(1);function Cn(r,t){let e=t.negate();return r?e:t}function Ts(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Un(r,t){Ts(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function ru(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 nu(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var Dn=new WeakMap,Ls=new WeakMap;function _n(r){return Ls.get(r)||1}function mr(r,t){return{constTimeNegate:Cn,hasPrecomputes(e){return _n(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Is;)n&pr&&(o=o.add(s)),s=s.double(),n>>=pr;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=Un(n,t),i=[],c=e,a=c;for(let l=0;l<o;l++){a=c,i.push(a);for(let u=1;u<s;u++)a=a.add(c),i.push(a);c=a.double()}return i},wNAF(e,n,o){let{windows:s,windowSize:i}=Un(e,t),c=r.ZERO,a=r.BASE,l=BigInt(2**e-1),u=2**e,f=BigInt(e);for(let p=0;p<s;p++){let y=p*i,w=Number(o&l);o>>=f,w>i&&(w-=u,o+=pr);let x=y,h=y+Math.abs(w)-1,E=p%2!==0,A=w<0;w===0?a=a.add(Cn(E,n[x])):c=c.add(Cn(A,n[h]))}return{p:c,f:a}},wNAFUnsafe(e,n,o,s=r.ZERO){let{windows:i,windowSize:c}=Un(e,t),a=BigInt(2**e-1),l=2**e,u=BigInt(e);for(let f=0;f<i;f++){let p=f*c;if(o===Is)break;let y=Number(o&a);if(o>>=u,y>c&&(y-=l,o+=pr),y===0)continue;let w=n[p+Math.abs(y)-1];y<0&&(w=w.negate()),s=s.add(w)}return s},getPrecomputes(e,n,o){let s=Dn.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&Dn.set(n,o(s))),s},wNAFCached(e,n,o){let s=_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){Ts(n,t),Ls.set(e,n),Dn.delete(e)}}}function gr(r,t,e,n){if(ru(e,r),nu(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,s=An(BigInt(e.length)),i=s>12?s-3:s>4?s-2:s?2:1,c=(1<<i)-1,a=new Array(c+1).fill(o),l=Math.floor((t.BITS-1)/i)*i,u=o;for(let f=l;f>=0;f-=i){a.fill(o);for(let y=0;y<n.length;y++){let w=n[y],x=Number(w>>BigInt(f)&BigInt(c));a[x]=a[x].add(e[y])}let p=o;for(let y=a.length-1,w=o;y>0;y--)w=w.add(a[y]),p=p.add(w);if(u=u.add(p),f!==0)for(let y=0;y<i;y++)u=u.double()}return u}function Ge(r){return Tn(r.Fp),Ut(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ln(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Tt=BigInt(0),gt=BigInt(1),xr=BigInt(2),ou=BigInt(8),su={zip215:!0};function iu(r){let t=Ge(r);return Ut(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Ps(r){let t=iu(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:c,h:a}=t,l=xr<<BigInt(c*8)-gt,u=e.create,f=Wt(t.n,t.nBitLength),p=t.uvRatio||((g,d)=>{try{return{isValid:!0,value:e.sqrt(g*e.inv(d))}}catch{return{isValid:!1,value:Tt}}}),y=t.adjustScalarBytes||(g=>g),w=t.domain||((g,d,b)=>{if(It("phflag",b),d.length||b)throw new Error("Contexts/pre-hash are not supported");return g});function x(g,d){mt("coordinate "+g,d,Tt,l)}function h(g){if(!(g instanceof m))throw new Error("ExtendedPoint expected")}let E=ce((g,d)=>{let{ex:b,ey:B,ez:R}=g,N=g.is0();d==null&&(d=N?ou:e.inv(R));let K=u(b*d),H=u(B*d),k=u(R*d);if(N)return{x:Tt,y:gt};if(k!==gt)throw new Error("invZ was invalid");return{x:K,y:H}}),A=ce(g=>{let{a:d,d:b}=t;if(g.is0())throw new Error("bad point: ZERO");let{ex:B,ey:R,ez:N,et:K}=g,H=u(B*B),k=u(R*R),z=u(N*N),Z=u(z*z),ot=u(H*d),st=u(z*u(ot+k)),ct=u(Z+u(b*u(H*k)));if(st!==ct)throw new Error("bad point: equation left != right (1)");let at=u(B*R),ht=u(N*K);if(at!==ht)throw new Error("bad point: equation left != right (2)");return!0});class m{constructor(d,b,B,R){this.ex=d,this.ey=b,this.ez=B,this.et=R,x("x",d),x("y",b),x("z",B),x("t",R),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(d){if(d instanceof m)throw new Error("extended point not allowed");let{x:b,y:B}=d||{};return x("x",b),x("y",B),new m(b,B,gt,u(b*B))}static normalizeZ(d){let b=e.invertBatch(d.map(B=>B.ez));return d.map((B,R)=>B.toAffine(b[R])).map(m.fromAffine)}static msm(d,b){return gr(m,f,d,b)}_setWindowSize(d){U.setWindowSize(this,d)}assertValidity(){A(this)}equals(d){h(d);let{ex:b,ey:B,ez:R}=this,{ex:N,ey:K,ez:H}=d,k=u(b*H),z=u(N*R),Z=u(B*H),ot=u(K*R);return k===z&&Z===ot}is0(){return this.equals(m.ZERO)}negate(){return new m(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:d}=t,{ex:b,ey:B,ez:R}=this,N=u(b*b),K=u(B*B),H=u(xr*u(R*R)),k=u(d*N),z=b+B,Z=u(u(z*z)-N-K),ot=k+K,st=ot-H,ct=k-K,at=u(Z*st),ht=u(ot*ct),lt=u(Z*ct),Pt=u(st*ot);return new m(at,ht,Pt,lt)}add(d){h(d);let{a:b,d:B}=t,{ex:R,ey:N,ez:K,et:H}=this,{ex:k,ey:z,ez:Z,et:ot}=d;if(b===BigInt(-1)){let To=u((N-R)*(z+k)),Lo=u((N+R)*(z-k)),qr=u(Lo-To);if(qr===Tt)return this.double();let Po=u(K*xr*ot),Co=u(H*xr*Z),Uo=Co+Po,Do=Lo+To,_o=Co-Po,Oi=u(Uo*qr),Ki=u(Do*_o),Mi=u(Uo*_o),Hi=u(qr*Do);return new m(Oi,Ki,Hi,Mi)}let st=u(R*k),ct=u(N*z),at=u(H*B*ot),ht=u(K*Z),lt=u((R+N)*(k+z)-st-ct),Pt=ht-at,Dt=ht+at,De=u(ct-b*st),_i=u(lt*Pt),Ri=u(Dt*De),Ni=u(lt*De),ki=u(Pt*Dt);return new m(_i,Ri,ki,Ni)}subtract(d){return this.add(d.negate())}wNAF(d){return U.wNAFCached(this,d,m.normalizeZ)}multiply(d){let b=d;mt("scalar",b,gt,n);let{p:B,f:R}=this.wNAF(b);return m.normalizeZ([B,R])[0]}multiplyUnsafe(d,b=m.ZERO){let B=d;return mt("scalar",B,Tt,n),B===Tt?_:this.is0()||B===gt?this:U.wNAFCachedUnsafe(this,B,m.normalizeZ,b)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(d){return E(this,d)}clearCofactor(){let{h:d}=t;return d===gt?this:this.multiplyUnsafe(d)}static fromHex(d,b=!1){let{d:B,a:R}=t,N=e.BYTES;d=Q("pointHex",d,N),It("zip215",b);let K=d.slice(),H=d[N-1];K[N-1]=H&-129;let k=jt(K),z=b?l:e.ORDER;mt("pointHex.y",k,Tt,z);let Z=u(k*k),ot=u(Z-gt),st=u(B*Z-R),{isValid:ct,value:at}=p(ot,st);if(!ct)throw new Error("Point.fromHex: invalid y coordinate");let ht=(at>)===gt,lt=(H&128)!==0;if(!b&&at===Tt&<)throw new Error("Point.fromHex: x=0 and x_0=1");return lt!==ht&&(at=u(-at)),m.fromAffine({x:at,y:k})}static fromPrivateKey(d){return L(d).point}toRawBytes(){let{x:d,y:b}=this.toAffine(),B=ie(b,e.BYTES);return B[B.length-1]|=d>?128:0,B}toHex(){return Ot(this.toRawBytes())}}m.BASE=new m(t.Gx,t.Gy,gt,u(t.Gx*t.Gy)),m.ZERO=new m(Tt,gt,gt,Tt);let{BASE:I,ZERO:_}=m,U=mr(m,c*8);function T(g){return F(g,n)}function C(g){return T(jt(g))}function L(g){let d=e.BYTES;g=Q("private key",g,d);let b=Q("hashed private key",s(g),2*d),B=y(b.slice(0,d)),R=b.slice(d,2*d),N=C(B),K=I.multiply(N),H=K.toRawBytes();return{head:B,prefix:R,scalar:N,point:K,pointBytes:H}}function W(g){return L(g).pointBytes}function q(g=new Uint8Array,...d){let b=Mt(...d);return C(s(w(b,Q("context",g),!!o)))}function M(g,d,b={}){g=Q("message",g),o&&(g=o(g));let{prefix:B,scalar:R,pointBytes:N}=L(d),K=q(b.context,B,g),H=I.multiply(K).toRawBytes(),k=q(b.context,H,N,g),z=T(K+k*R);mt("signature.s",z,Tt,n);let Z=Mt(H,ie(z,e.BYTES));return Q("result",Z,e.BYTES*2)}let et=su;function v(g,d,b,B=et){let{context:R,zip215:N}=B,K=e.BYTES;g=Q("signature",g,2*K),d=Q("message",d),b=Q("publicKey",b,K),N!==void 0&&It("zip215",N),o&&(d=o(d));let H=jt(g.slice(K,2*K)),k,z,Z;try{k=m.fromHex(b,N),z=m.fromHex(g.slice(0,K),N),Z=I.multiplyUnsafe(H)}catch{return!1}if(!N&&k.isSmallOrder())return!1;let ot=q(R,z.toRawBytes(),k.toRawBytes(),d);return z.add(k.multiplyUnsafe(ot)).subtract(Z).clearCofactor().equals(m.ZERO)}return I._setWindowSize(8),{CURVE:t,getPublicKey:W,sign:M,verify:v,ExtendedPoint:m,utils:{getExtendedPublicKey:L,randomPrivateKey:()=>i(e.BYTES),precompute(g=8,d=m.BASE){return d._setWindowSize(g),d.multiply(BigInt(3)),d}}}}var Rn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Cs=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Xh=BigInt(0),cu=BigInt(1),Us=BigInt(2),Qh=BigInt(3),au=BigInt(5),uu=BigInt(8);function fu(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=Rn,c=r*r%s*r%s,a=X(c,Us,s)*c%s,l=X(a,cu,s)*r%s,u=X(l,au,s)*l%s,f=X(u,t,s)*u%s,p=X(f,e,s)*f%s,y=X(p,n,s)*p%s,w=X(y,o,s)*y%s,x=X(w,o,s)*y%s,h=X(x,t,s)*u%s;return{pow_p_5_8:X(h,Us,s)*r%s,b2:c}}function lu(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function hu(r,t){let e=Rn,n=F(t*t*t,e),o=F(n*n*t,e),s=fu(r*o).pow_p_5_8,i=F(r*n*s,e),c=F(t*i*i,e),a=i,l=F(i*Cs,e),u=c===r,f=c===F(-r,e),p=c===F(-r*Cs,e);return u&&(i=a),(f||p)&&(i=l),vs(i,e)&&(i=F(-i,e)),{isValid:u||f,value:i}}var du=Wt(Rn,void 0,!0),pu={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:du,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:uu,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:bs,randomBytes:ar,adjustScalarBytes:lu,uvRatio:hu},Ds=Ps(pu);var br=32;function _s(r,t,e){return Ds.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var yr=class{type="Ed25519";raw;constructor(t){this.raw=Nn(t,br)}toMultihash(){return At.digest(Ee(this))}toCID(){return rt.createV1(114,this.toMultihash())}toString(){return $.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}verify(t,e){return _s(this.raw,e,t)}};function Ns(r){return r=Nn(r,br),new yr(r)}function Nn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new Ct(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var gu=Math.pow(2,7),xu=Math.pow(2,14),bu=Math.pow(2,21),kn=Math.pow(2,28),On=Math.pow(2,35),Kn=Math.pow(2,42),Mn=Math.pow(2,49),V=128,ut=127;function xt(r){if(r<gu)return 1;if(r<xu)return 2;if(r<bu)return 3;if(r<kn)return 4;if(r<On)return 5;if(r<Kn)return 6;if(r<Mn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Hn(r,t,e=0){switch(xt(r)){case 8:t[e++]=r&255|V,r/=128;case 7:t[e++]=r&255|V,r/=128;case 6:t[e++]=r&255|V,r/=128;case 5:t[e++]=r&255|V,r/=128;case 4:t[e++]=r&255|V,r>>>=7;case 3:t[e++]=r&255|V,r>>>=7;case 2:t[e++]=r&255|V,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function yu(r,t,e=0){switch(xt(r)){case 8:t.set(e++,r&255|V),r/=128;case 7:t.set(e++,r&255|V),r/=128;case 6:t.set(e++,r&255|V),r/=128;case 5:t.set(e++,r&255|V),r/=128;case 4:t.set(e++,r&255|V),r>>>=7;case 3:t.set(e++,r&255|V),r>>>=7;case 2:t.set(e++,r&255|V),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function qn(r,t){let e=r[t],n=0;if(n+=e&ut,e<V||(e=r[t+1],n+=(e&ut)<<7,e<V)||(e=r[t+2],n+=(e&ut)<<14,e<V)||(e=r[t+3],n+=(e&ut)<<21,e<V)||(e=r[t+4],n+=(e&ut)*kn,e<V)||(e=r[t+5],n+=(e&ut)*On,e<V)||(e=r[t+6],n+=(e&ut)*Kn,e<V)||(e=r[t+7],n+=(e&ut)*Mn,e<V))return n;throw new RangeError("Could not decode varint")}function wu(r,t){let e=r.get(t),n=0;if(n+=e&ut,e<V||(e=r.get(t+1),n+=(e&ut)<<7,e<V)||(e=r.get(t+2),n+=(e&ut)<<14,e<V)||(e=r.get(t+3),n+=(e&ut)<<21,e<V)||(e=r.get(t+4),n+=(e&ut)*kn,e<V)||(e=r.get(t+5),n+=(e&ut)*On,e<V)||(e=r.get(t+6),n+=(e&ut)*Kn,e<V)||(e=r.get(t+7),n+=(e&ut)*Mn,e<V))return n;throw new RangeError("Could not decode varint")}function Te(r,t,e=0){return t==null&&(t=pt(xt(r))),t instanceof Uint8Array?Hn(r,t,e):yu(r,t,e)}function ue(r,t=0){return r instanceof Uint8Array?qn(r,t):wu(r,t)}var Vn=new Float32Array([-0]),$t=new Uint8Array(Vn.buffer);function Os(r,t,e){Vn[0]=r,t[e]=$t[0],t[e+1]=$t[1],t[e+2]=$t[2],t[e+3]=$t[3]}function Ks(r,t){return $t[0]=r[t],$t[1]=r[t+1],$t[2]=r[t+2],$t[3]=r[t+3],Vn[0]}var zn=new Float64Array([-0]),ft=new Uint8Array(zn.buffer);function Ms(r,t,e){zn[0]=r,t[e]=ft[0],t[e+1]=ft[1],t[e+2]=ft[2],t[e+3]=ft[3],t[e+4]=ft[4],t[e+5]=ft[5],t[e+6]=ft[6],t[e+7]=ft[7]}function Hs(r,t){return ft[0]=r[t],ft[1]=r[t+1],ft[2]=r[t+2],ft[3]=r[t+3],ft[4]=r[t+4],ft[5]=r[t+5],ft[6]=r[t+6],ft[7]=r[t+7],zn[0]}var Eu=BigInt(Number.MAX_SAFE_INTEGER),Su=BigInt(Number.MIN_SAFE_INTEGER),Et=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 fe;if(t<Eu&&t>Su)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>qs&&(o=0n,++n>qs&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return fe;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):fe}},fe=new Et(0,0);fe.toBigInt=function(){return 0n};fe.zzEncode=fe.zzDecode=function(){return this};fe.length=function(){return 1};var qs=4294967296n;function Vs(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 zs(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 Fn(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 Lt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function wr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Gn=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,Lt(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 Lt(this,4);return wr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Lt(this,4);return wr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Lt(this,4);let t=Ks(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Lt(this,4);let t=Hs(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Lt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return zs(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Lt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Lt(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 Et(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 Lt(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 Lt(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 Lt(this,8);let t=wr(this.buf,this.pos+=4),e=wr(this.buf,this.pos+=4);return new Et(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=qn(this.buf,this.pos);return this.pos+=xt(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function jn(r){return new Gn(r instanceof Uint8Array?r:r.subarray())}function Er(r,t,e){let n=jn(r);return t.decode(n,void 0,e)}function Zn(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return pt(i);o+i>t&&(n=pt(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var le=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Wn(){}var Yn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},vu=Zn();function Au(r){return globalThis.Buffer!=null?pt(r):vu(r)}var Ze=class{len;head;tail;states;constructor(){this.len=0,this.head=new le(Wn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new le(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Xn((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(Sr,10,Et.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=Et.fromBigInt(t);return this._push(Sr,e.length(),e)}uint64Number(t){return this._push(Hn,xt(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=Et.fromBigInt(t).zzEncode();return this._push(Sr,e.length(),e)}sint64Number(t){let e=Et.fromNumber(t).zzEncode();return this._push(Sr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push($n,1,t?1:0)}fixed32(t){return this._push(je,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=Et.fromBigInt(t);return this._push(je,4,e.lo)._push(je,4,e.hi)}fixed64Number(t){let e=Et.fromNumber(t);return this._push(je,4,e.lo)._push(je,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(Ms,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push($n,1,0):this.uint32(e)._push(Iu,e,t)}string(t){let e=Vs(t);return e!==0?this.uint32(e)._push(Fn,e,t):this._push($n,1,0)}fork(){return this.states=new Yn(this),this.head=this.tail=new le(Wn,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 le(Wn,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=Au(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function $n(r,t,e){t[e]=r&255}function Bu(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Xn=class extends le{next;constructor(t,e){super(Bu,t,e),this.next=void 0}};function Sr(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 je(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 Iu(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Ze.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Tu,t,r),this},Ze.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Lu,t,r),this});function Tu(r,t,e){t.set(r,e)}function Lu(r,t,e){r.length<40?Fn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(vt(r),e)}function Qn(){return new Ze}function vr(r,t){let e=Qn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Le;(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"})(Le||(Le={}));function Ar(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Jn(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 Ar("enum",Le.VARINT,e,n)}function Br(r,t){return Ar("message",Le.LENGTH_DELIMITED,r,t)}var St;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(St||(St={}));var to;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(to||(to={}));(function(r){r.codec=()=>Jn(to)})(St||(St={}));var We;(function(r){let t;r.codec=()=>(t==null&&(t=Br((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),St.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=St.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>vr(e,r.codec()),r.decode=(e,n)=>Er(e,r.codec(),n)})(We||(We={}));var eo;(function(r){let t;r.codec=()=>(t==null&&(t=Br((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),St.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=St.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>vr(e,r.codec()),r.decode=(e,n)=>Er(e,r.codec(),n)})(eo||(eo={}));var $e=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var Cu=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]),Yt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Xt=new Uint32Array(64),ro=class extends Be{constructor(){super(64,32,8,!1),this.A=Yt[0]|0,this.B=Yt[1]|0,this.C=Yt[2]|0,this.D=Yt[3]|0,this.E=Yt[4]|0,this.F=Yt[5]|0,this.G=Yt[6]|0,this.H=Yt[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 f=0;f<16;f++,e+=4)Xt[f]=t.getUint32(e,!1);for(let f=16;f<64;f++){let p=Xt[f-15],y=Xt[f-2],w=Bt(p,7)^Bt(p,18)^p>>>3,x=Bt(y,17)^Bt(y,19)^y>>>10;Xt[f]=x+Xt[f-7]+w+Xt[f-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:l,H:u}=this;for(let f=0;f<64;f++){let p=Bt(c,6)^Bt(c,11)^Bt(c,25),y=u+p+ms(c,a,l)+Cu[f]+Xt[f]|0,x=(Bt(n,2)^Bt(n,13)^Bt(n,22))+gs(n,o,s)|0;u=l,l=a,a=c,c=i+y|0,i=s,s=o,o=n,n=y+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,l=l+this.G|0,u=u+this.H|0,this.set(n,o,s,i,c,a,l,u)}roundClean(){Xt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Gs=cr(()=>new ro);var Ir=class extends Ae{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,hs(t);let n=Ve(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 ve(this),this.iHash.update(t),this}digestInto(t){ve(this),Se(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()}},no=(r,t,e)=>new Ir(r,t).update(e).digest();no.create=(r,t)=>new Ir(r,t);function js(r){r.lowS!==void 0&&It("lowS",r.lowS),r.prehash!==void 0&&It("prehash",r.prehash)}function Uu(r){let t=Ge(r);Ut(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:Du,hexToBytes:_u}=hr,oo=class extends Error{constructor(t=""){super(t)}},Ht={Err:oo,_tlv:{encode:(r,t)=>{let{Err:e}=Ht;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}=Ht,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 l=t.subarray(n,n+a);if(l.length!==a)throw new e("tlv.decode: length bytes not complete");if(l[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of l)i=i<<8|u;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Ht;if(r<qt)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}=Ht;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 Du(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Ht,o=typeof r=="string"?_u(r):r;Ie(o);let{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:l,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(l)}},hexFromSig(r){let{_tlv:t,_int:e}=Ht,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},qt=BigInt(0),it=BigInt(1),sp=BigInt(2),Zs=BigInt(3),ip=BigInt(4);function Ru(r){let t=Uu(r),{Fp:e}=t,n=Wt(t.n,t.nBitLength),o=t.toBytes||((x,h,E)=>{let A=h.toAffine();return Mt(Uint8Array.from([4]),e.toBytes(A.x),e.toBytes(A.y))}),s=t.fromBytes||(x=>{let h=x.subarray(1),E=e.fromBytes(h.subarray(0,e.BYTES)),A=e.fromBytes(h.subarray(e.BYTES,2*e.BYTES));return{x:E,y:A}});function i(x){let{a:h,b:E}=t,A=e.sqr(x),m=e.mul(A,x);return e.add(e.add(m,e.mul(x,h)),E)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function c(x){return ze(x,it,t.n)}function a(x){let{allowedPrivateKeyLengths:h,nByteLength:E,wrapPrivateKey:A,n:m}=t;if(h&&typeof x!="bigint"){if(Gt(x)&&(x=Ot(x)),typeof x!="string"||!h.includes(x.length))throw new Error("invalid private key");x=x.padStart(E*2,"0")}let I;try{I=typeof x=="bigint"?x:Kt(Q("private key",x,E))}catch{throw new Error("invalid private key, expected hex or "+E+" bytes, got "+typeof x)}return A&&(I=F(I,m)),mt("private key",I,it,m),I}function l(x){if(!(x instanceof p))throw new Error("ProjectivePoint expected")}let u=ce((x,h)=>{let{px:E,py:A,pz:m}=x;if(e.eql(m,e.ONE))return{x:E,y:A};let I=x.is0();h==null&&(h=I?e.ONE:e.inv(m));let _=e.mul(E,h),U=e.mul(A,h),T=e.mul(m,h);if(I)return{x:e.ZERO,y:e.ZERO};if(!e.eql(T,e.ONE))throw new Error("invZ was invalid");return{x:_,y:U}}),f=ce(x=>{if(x.is0()){if(t.allowInfinityPoint&&!e.is0(x.py))return;throw new Error("bad point: ZERO")}let{x:h,y:E}=x.toAffine();if(!e.isValid(h)||!e.isValid(E))throw new Error("bad point: x or y not FE");let A=e.sqr(E),m=i(h);if(!e.eql(A,m))throw new Error("bad point: equation left != right");if(!x.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class p{constructor(h,E,A){if(this.px=h,this.py=E,this.pz=A,h==null||!e.isValid(h))throw new Error("x required");if(E==null||!e.isValid(E))throw new Error("y required");if(A==null||!e.isValid(A))throw new Error("z required");Object.freeze(this)}static fromAffine(h){let{x:E,y:A}=h||{};if(!h||!e.isValid(E)||!e.isValid(A))throw new Error("invalid affine point");if(h instanceof p)throw new Error("projective point not allowed");let m=I=>e.eql(I,e.ZERO);return m(E)&&m(A)?p.ZERO:new p(E,A,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let E=e.invertBatch(h.map(A=>A.pz));return h.map((A,m)=>A.toAffine(E[m])).map(p.fromAffine)}static fromHex(h){let E=p.fromAffine(s(Q("pointHex",h)));return E.assertValidity(),E}static fromPrivateKey(h){return p.BASE.multiply(a(h))}static msm(h,E){return gr(p,n,h,E)}_setWindowSize(h){w.setWindowSize(this,h)}assertValidity(){f(this)}hasEvenY(){let{y:h}=this.toAffine();if(e.isOdd)return!e.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){l(h);let{px:E,py:A,pz:m}=this,{px:I,py:_,pz:U}=h,T=e.eql(e.mul(E,U),e.mul(I,m)),C=e.eql(e.mul(A,U),e.mul(_,m));return T&&C}negate(){return new p(this.px,e.neg(this.py),this.pz)}double(){let{a:h,b:E}=t,A=e.mul(E,Zs),{px:m,py:I,pz:_}=this,U=e.ZERO,T=e.ZERO,C=e.ZERO,L=e.mul(m,m),W=e.mul(I,I),q=e.mul(_,_),M=e.mul(m,I);return M=e.add(M,M),C=e.mul(m,_),C=e.add(C,C),U=e.mul(h,C),T=e.mul(A,q),T=e.add(U,T),U=e.sub(W,T),T=e.add(W,T),T=e.mul(U,T),U=e.mul(M,U),C=e.mul(A,C),q=e.mul(h,q),M=e.sub(L,q),M=e.mul(h,M),M=e.add(M,C),C=e.add(L,L),L=e.add(C,L),L=e.add(L,q),L=e.mul(L,M),T=e.add(T,L),q=e.mul(I,_),q=e.add(q,q),L=e.mul(q,M),U=e.sub(U,L),C=e.mul(q,W),C=e.add(C,C),C=e.add(C,C),new p(U,T,C)}add(h){l(h);let{px:E,py:A,pz:m}=this,{px:I,py:_,pz:U}=h,T=e.ZERO,C=e.ZERO,L=e.ZERO,W=t.a,q=e.mul(t.b,Zs),M=e.mul(E,I),et=e.mul(A,_),v=e.mul(m,U),P=e.add(E,A),g=e.add(I,_);P=e.mul(P,g),g=e.add(M,et),P=e.sub(P,g),g=e.add(E,m);let d=e.add(I,U);return g=e.mul(g,d),d=e.add(M,v),g=e.sub(g,d),d=e.add(A,m),T=e.add(_,U),d=e.mul(d,T),T=e.add(et,v),d=e.sub(d,T),L=e.mul(W,g),T=e.mul(q,v),L=e.add(T,L),T=e.sub(et,L),L=e.add(et,L),C=e.mul(T,L),et=e.add(M,M),et=e.add(et,M),v=e.mul(W,v),g=e.mul(q,g),et=e.add(et,v),v=e.sub(M,v),v=e.mul(W,v),g=e.add(g,v),M=e.mul(et,g),C=e.add(C,M),M=e.mul(d,g),T=e.mul(P,T),T=e.sub(T,M),M=e.mul(P,et),L=e.mul(d,L),L=e.add(L,M),new p(T,C,L)}subtract(h){return this.add(h.negate())}is0(){return this.equals(p.ZERO)}wNAF(h){return w.wNAFCached(this,h,p.normalizeZ)}multiplyUnsafe(h){let{endo:E,n:A}=t;mt("scalar",h,qt,A);let m=p.ZERO;if(h===qt)return m;if(this.is0()||h===it)return this;if(!E||w.hasPrecomputes(this))return w.wNAFCachedUnsafe(this,h,p.normalizeZ);let{k1neg:I,k1:_,k2neg:U,k2:T}=E.splitScalar(h),C=m,L=m,W=this;for(;_>qt||T>qt;)_&it&&(C=C.add(W)),T&it&&(L=L.add(W)),W=W.double(),_>>=it,T>>=it;return I&&(C=C.negate()),U&&(L=L.negate()),L=new p(e.mul(L.px,E.beta),L.py,L.pz),C.add(L)}multiply(h){let{endo:E,n:A}=t;mt("scalar",h,it,A);let m,I;if(E){let{k1neg:_,k1:U,k2neg:T,k2:C}=E.splitScalar(h),{p:L,f:W}=this.wNAF(U),{p:q,f:M}=this.wNAF(C);L=w.constTimeNegate(_,L),q=w.constTimeNegate(T,q),q=new p(e.mul(q.px,E.beta),q.py,q.pz),m=L.add(q),I=W.add(M)}else{let{p:_,f:U}=this.wNAF(h);m=_,I=U}return p.normalizeZ([m,I])[0]}multiplyAndAddUnsafe(h,E,A){let m=p.BASE,I=(U,T)=>T===qt||T===it||!U.equals(m)?U.multiplyUnsafe(T):U.multiply(T),_=I(this,E).add(I(h,A));return _.is0()?void 0:_}toAffine(h){return u(this,h)}isTorsionFree(){let{h,isTorsionFree:E}=t;if(h===it)return!0;if(E)return E(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:E}=t;return h===it?this:E?E(p,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return It("isCompressed",h),this.assertValidity(),o(p,this,h)}toHex(h=!0){return It("isCompressed",h),Ot(this.toRawBytes(h))}}p.BASE=new p(t.Gx,t.Gy,e.ONE),p.ZERO=new p(e.ZERO,e.ONE,e.ZERO);let y=t.nBitLength,w=mr(p,t.endo?Math.ceil(y/2):y);return{CURVE:t,ProjectivePoint:p,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:c}}function Nu(r){let t=Ge(r);return Ut(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Ws(r){let t=Nu(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(v){return F(v,n)}function c(v){return dr(v,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=Ru({...t,toBytes(v,P,g){let d=P.toAffine(),b=e.toBytes(d.x),B=Mt;return It("isCompressed",g),g?B(Uint8Array.from([P.hasEvenY()?2:3]),b):B(Uint8Array.from([4]),b,e.toBytes(d.y))},fromBytes(v){let P=v.length,g=v[0],d=v.subarray(1);if(P===o&&(g===2||g===3)){let b=Kt(d);if(!ze(b,it,e.ORDER))throw new Error("Point is not on curve");let B=u(b),R;try{R=e.sqrt(B)}catch(H){let k=H instanceof Error?": "+H.message:"";throw new Error("Point is not on curve"+k)}let N=(R&it)===it;return(g&1)===1!==N&&(R=e.neg(R)),{x:b,y:R}}else if(P===s&&g===4){let b=e.fromBytes(d.subarray(0,e.BYTES)),B=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x:b,y:B}}else{let b=o,B=s;throw new Error("invalid Point, expected length of "+b+", or uncompressed "+B+", got "+P)}}}),p=v=>Ot(Zt(v,t.nByteLength));function y(v){let P=n>>it;return v>P}function w(v){return y(v)?i(-v):v}let x=(v,P,g)=>Kt(v.slice(P,g));class h{constructor(P,g,d){this.r=P,this.s=g,this.recovery=d,this.assertValidity()}static fromCompact(P){let g=t.nByteLength;return P=Q("compactSignature",P,g*2),new h(x(P,0,g),x(P,g,2*g))}static fromDER(P){let{r:g,s:d}=Ht.toSig(Q("DER",P));return new h(g,d)}assertValidity(){mt("r",this.r,it,n),mt("s",this.s,it,n)}addRecoveryBit(P){return new h(this.r,this.s,P)}recoverPublicKey(P){let{r:g,s:d,recovery:b}=this,B=U(Q("msgHash",P));if(b==null||![0,1,2,3].includes(b))throw new Error("recovery id invalid");let R=b===2||b===3?g+t.n:g;if(R>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let N=(b&1)===0?"02":"03",K=a.fromHex(N+p(R)),H=c(R),k=i(-B*H),z=i(d*H),Z=a.BASE.multiplyAndAddUnsafe(K,k,z);if(!Z)throw new Error("point at infinify");return Z.assertValidity(),Z}hasHighS(){return y(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return se(this.toDERHex())}toDERHex(){return Ht.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return se(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let E={isValidPrivateKey(v){try{return l(v),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let v=Pn(t.n);return Bs(t.randomBytes(v),t.n)},precompute(v=8,P=a.BASE){return P._setWindowSize(v),P.multiply(BigInt(3)),P}};function A(v,P=!0){return a.fromPrivateKey(v).toRawBytes(P)}function m(v){let P=Gt(v),g=typeof v=="string",d=(P||g)&&v.length;return P?d===o||d===s:g?d===2*o||d===2*s:v instanceof a}function I(v,P,g=!0){if(m(v))throw new Error("first arg must be private key");if(!m(P))throw new Error("second arg must be public key");return a.fromHex(P).multiply(l(v)).toRawBytes(g)}let _=t.bits2int||function(v){if(v.length>8192)throw new Error("input is too large");let P=Kt(v),g=v.length*8-t.nBitLength;return g>0?P>>BigInt(g):P},U=t.bits2int_modN||function(v){return i(_(v))},T=Fe(t.nBitLength);function C(v){return mt("num < 2^"+t.nBitLength,v,qt,T),Zt(v,t.nByteLength)}function L(v,P,g=W){if(["recovered","canonical"].some(st=>st in g))throw new Error("sign() legacy options not supported");let{hash:d,randomBytes:b}=t,{lowS:B,prehash:R,extraEntropy:N}=g;B==null&&(B=!0),v=Q("msgHash",v),js(g),R&&(v=Q("prehashed msgHash",d(v)));let K=U(v),H=l(P),k=[C(H),C(K)];if(N!=null&&N!==!1){let st=N===!0?b(e.BYTES):N;k.push(Q("extraEntropy",st))}let z=Mt(...k),Z=K;function ot(st){let ct=_(st);if(!f(ct))return;let at=c(ct),ht=a.BASE.multiply(ct).toAffine(),lt=i(ht.x);if(lt===qt)return;let Pt=i(at*i(Z+lt*H));if(Pt===qt)return;let Dt=(ht.x===lt?0:2)|Number(ht.y&it),De=Pt;return B&&y(Pt)&&(De=w(Pt),Dt^=1),new h(lt,De,Dt)}return{seed:z,k2sig:ot}}let W={lowS:t.lowS,prehash:!1},q={lowS:t.lowS,prehash:!1};function M(v,P,g=W){let{seed:d,k2sig:b}=L(v,P,g),B=t;return Bn(B.hash.outputLen,B.nByteLength,B.hmac)(d,b)}a.BASE._setWindowSize(8);function et(v,P,g,d=q){let b=v;P=Q("msgHash",P),g=Q("publicKey",g);let{lowS:B,prehash:R,format:N}=d;if(js(d),"strict"in d)throw new Error("options.strict was renamed to lowS");if(N!==void 0&&N!=="compact"&&N!=="der")throw new Error("format must be compact or der");let K=typeof b=="string"||Gt(b),H=!K&&!N&&typeof b=="object"&&b!==null&&typeof b.r=="bigint"&&typeof b.s=="bigint";if(!K&&!H)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let k,z;try{if(H&&(k=new h(b.r,b.s)),K){try{N!=="compact"&&(k=h.fromDER(b))}catch(Dt){if(!(Dt instanceof Ht.Err))throw Dt}!k&&N!=="der"&&(k=h.fromCompact(b))}z=a.fromHex(g)}catch{return!1}if(!k||B&&k.hasHighS())return!1;R&&(P=t.hash(P));let{r:Z,s:ot}=k,st=U(P),ct=c(ot),at=i(st*ct),ht=i(Z*ct),lt=a.BASE.multiplyAndAddUnsafe(z,at,ht)?.toAffine();return lt?i(lt.x)===Z:!1}return{CURVE:t,getPublicKey:A,getSharedSecret:I,sign:M,verify:et,ProjectivePoint:a,Signature:h,utils:E}}function ku(r){return{hash:r,hmac:(t,...e)=>no(r,t,bn(...e)),randomBytes:ar}}function $s(r,t){let e=n=>Ws({...r,...ku(n)});return{...e(t),create:e}}var Qs=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ys=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ou=BigInt(1),so=BigInt(2),Xs=(r,t)=>(r+t/so)/t;function Ku(r){let t=Qs,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),l=r*r*r%t,u=l*l*r%t,f=X(u,e,t)*u%t,p=X(f,e,t)*u%t,y=X(p,so,t)*l%t,w=X(y,o,t)*y%t,x=X(w,s,t)*w%t,h=X(x,c,t)*x%t,E=X(h,a,t)*h%t,A=X(E,c,t)*x%t,m=X(A,e,t)*u%t,I=X(m,i,t)*w%t,_=X(I,n,t)*l%t,U=X(_,so,t);if(!io.eql(io.sqr(U),r))throw new Error("Cannot find square root");return U}var io=Wt(Qs,void 0,void 0,{sqrt:Ku}),he=$s({a:BigInt(0),b:BigInt(7),Fp:io,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=-Ou*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=Xs(s*r,t),a=Xs(-n*r,t),l=F(r-c*e-a*o,t),u=F(-c*n-a*s,t),f=l>i,p=u>i;if(f&&(l=t-l),p&&(u=t-u),l>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:f,k1:l,k2neg:p,k2:u}}}},Gs),mp=BigInt(0);var gp=he.ProjectivePoint;function Js(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function ti(r,t,e){let n=Oe.digest(e instanceof Uint8Array?e:e.subarray());if(Js(n))return n.then(({digest:o})=>he.verify(t,o,r)).catch(o=>{throw new $e(String(o))});try{return he.verify(t,n.digest,r)}catch(o){throw new $e(String(o))}}var Tr=class{type="secp256k1";raw;_key;constructor(t){this._key=ri(t),this.raw=ei(this._key)}toMultihash(){return At.digest(Ee(this))}toCID(){return rt.createV1(114,this.toMultihash())}toString(){return $.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}verify(t,e){return ti(this._key,e,t)}};function ni(r){return new Tr(r)}function ei(r){return he.ProjectivePoint.fromHex(r).toRawBytes(!0)}function ri(r){try{return he.ProjectivePoint.fromHex(r),r}catch(t){throw new Qe(String(t))}}function oi(r){let{Type:t,Data:e}=We.decode(r.digest),n=e??new Uint8Array;switch(t){case St.Ed25519:return Ns(n);case St.secp256k1:return ni(n);case St.ECDSA:return us(n);default:throw new _e}}function Ee(r){return We.encode({Type:St[r.type],Data:r.raw})}var si=Symbol.for("nodejs.util.inspect.custom"),Mu=114,Ye=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[zr]=!0;toString(){return this.string==null&&(this.string=$.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return rt.createV1(Mu,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return yt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return yt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[si](){return`PeerId(${this.toString()})`}},Lr=class extends Ye{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Pr=class extends Ye{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Cr=class extends Ye{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Hu=2336,Xe=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=At.digest(vt(this.url))}[si](){return`PeerId(${this.url})`}[zr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return rt.createV1(Hu,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=G(t)),t.toString()===this.toString())}};var qu=114,ii=2336;function ci(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=ee($.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return Vu(rt.parse(r));if(t==null)throw new Ct('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=ee(t.decode(r))}return ai(e)}function ai(r){if(Fu(r))return new Lr({multihash:r});if(zu(r))try{let t=oi(r);if(t.type==="Ed25519")return new Pr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Cr({multihash:r,publicKey:t})}catch{let e=G(r.digest);return new Xe(new URL(e))}throw new tr("Supplied PeerID Multihash is invalid")}function Vu(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==qu&&r.code!==ii)throw new Je("Supplied PeerID CID is invalid");if(r.code===ii){let t=G(r.multihash.digest);return new Xe(new URL(t))}return ai(r.multihash)}function zu(r){return r.code===At.code}function Fu(r){return r.code===Oe.code}var Ur=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,i=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",l=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let p=Number.parseInt(f,t);if(!Number.isNaN(p))return p});if(u===void 0)break;if(s*=t,s+=u,s>l||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&a&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[o]=i[0],e[o+1]=i[1],e[o+2]=i[2],e[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[c]=t(s.subarray(0,i));return e.set(s.subarray(0,c),16-c),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var ui=45,Gu=15,Pe=new Ur;function co(r){if(!(r.length>Gu))return Pe.new(r).parseWith(()=>Pe.readIPv4Addr())}function ao(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>ui))return Pe.new(r).parseWith(()=>Pe.readIPv6Addr())}function Dr(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>ui)return;let e=Pe.new(r).parseWith(()=>Pe.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}var P0=parseInt("0xFFFF",16),C0=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function hi(r){return!!co(r)}function di(r){return!!ao(r)}function _r(r){return!!Dr(r)}var pi=hi,Yu=di,uo=function(r){let t=0;if(r=r.toString().trim(),pi(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Yu(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=pi(e[n]),i;s&&(i=uo(e[n]),e[n]=G(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,G(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},mi=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Ce={},fo={},Qu=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];Qu.forEach(r=>{let t=Ju(...r);fo[t.code]=t,Ce[t.name]=t});function Ju(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function j(r){if(typeof r=="number"){if(fo[r]!=null)return fo[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ce[r]!=null)return Ce[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var dm=j("ip4"),pm=j("ip6"),mm=j("ipcidr");function mo(r,t){switch(j(r).code){case 4:case 41:return ef(t);case 42:return po(t);case 43:return G(t,"base10");case 6:case 273:case 33:case 132:return bi(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return po(t);case 421:return sf(t);case 444:return xi(t);case 445:return xi(t);case 466:return of(t);case 481:return globalThis.encodeURIComponent(po(t));default:return G(t,"base16")}}function go(r,t){switch(j(r).code){case 4:return gi(t);case 41:return gi(t);case 42:return ho(t);case 43:return vt(t,"base10");case 6:case 273:case 33:case 132:return xo(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ho(t);case 421:return rf(t);case 444:return cf(t);case 445:return af(t);case 466:return nf(t);case 481:return ho(globalThis.decodeURIComponent(t));default:return vt(t,"base16")}}var lo=Object.values(Me).map(r=>r.decoder),tf=function(){let r=lo[0].or(lo[1]);return lo.slice(2).forEach(t=>r=r.or(t)),r}();function gi(r){if(!_r(r))throw new Error("invalid ip address");return uo(r)}function ef(r){let t=mi(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!_r(t))throw new Error("invalid ip address");return t}function xo(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function bi(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function ho(r){let t=vt(r),e=Uint8Array.from(Te(t.length));return bt([e,t],e.length+t.length)}function po(r){let t=ue(r);if(r=r.slice(xt(t)),r.length!==t)throw new Error("inconsistent lengths");return G(r)}function rf(r){let t;r[0]==="Q"||r[0]==="1"?t=ee($.decode(`z${r}`)).bytes:t=rt.parse(r).multihash.bytes;let e=Uint8Array.from(Te(t.length));return bt([e,t],e.length+t.length)}function nf(r){let t=tf.decode(r),e=Uint8Array.from(Te(t.length));return bt([e,t],e.length+t.length)}function of(r){let t=ue(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+G(e,"base64url")}function sf(r){let t=ue(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return G(e,"base58btc")}function cf(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Nt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=xo(n);return bt([e,o],e.length+o.length)}function af(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Nt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=xo(n);return bt([e,o],e.length+o.length)}function xi(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=G(t,"base32"),o=bi(e);return`${n}:${o}`}function yi(r){r=bo(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],c=j(i);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(s++,s>=o.length)throw new Rr("invalid address: "+r);if(c.path===!0){n=bo(o.slice(s).join("/")),t.push([c.code,go(c.code,n)]),e.push([c.code,n]);break}let a=go(c.code,o[s]);t.push([c.code,a]),e.push([c.code,mo(c.code,a)])}return{string:wi(e),bytes:Nr(t),tuples:t,stringTuples:e,path:n}}function yo(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=ue(r,o),i=xt(s),c=j(s),a=uf(c,r.slice(o+i));if(a===0){t.push([s]),e.push([s]),o+=i;continue}let l=r.slice(o+i,o+i+a);if(o+=a+i,o>r.length)throw new Rr("Invalid address Uint8Array: "+G(r,"base16"));t.push([s,l]);let u=mo(s,l);if(e.push([s,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:wi(e),tuples:t,stringTuples:e,path:n}}function wi(r){let t=[];return r.map(e=>{let n=j(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),bo(t.join("/"))}function Nr(r){return bt(r.map(t=>{let e=j(t[0]),n=Uint8Array.from(Te(e.code));return t.length>1&&t[1]!=null&&(n=bt([n,t[1]])),n}))}function uf(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=ue(t instanceof Uint8Array?t:Uint8Array.from(t));return e+xt(e)}}function bo(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var Rr=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var ff=Symbol.for("nodejs.util.inspect.custom"),Eo=Symbol.for("@multiformats/js-multiaddr/multiaddr"),lf=[j("dns").code,j("dns4").code,j("dns6").code,j("dnsaddr").code],wo=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},kr=class r{bytes;#t;#e;#r;#n;[Eo]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=yo(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=yi(t)}else if(Si(t))e=yo(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",i=j("tcp"),c=j("udp"),a=j("ip4"),l=j("ip6"),u=j("dns6"),f=j("ip6zone");for(let[y,w]of this.stringTuples())y===f.code&&(s=`%${w??""}`),lf.includes(y)&&(e=i.name==="tcp"?"tcp":"udp",o=443,n=`${w??""}${s}`,t=y===u.code?6:4),(y===i.code||y===c.code)&&(e=j(y).name==="tcp"?"tcp":"udp",o=parseInt(w??"")),(y===a.code||y===l.code)&&(e=j(y).name==="tcp"?"tcp":"udp",n=`${w??""}${s}`,t=y===l.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},j(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>j(t).name)}tuples(){return this.#e.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(Nr(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===Ce.p2p.code&&t.push([n,o]),n===Ce["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?G($.decode(`z${n}`),"base58btc"):G(rt.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return yt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=Ei.get(e.name);if(n==null)throw new wo(`no available resolver for ${e.name}`);return(await n(this,t)).map(s=>Qt(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[ff](){return`Multiaddr(${this.#t})`}};var Ei=new Map;function Si(r){return!!r?.[Eo]}function Qt(r){return new kr(r)}var hf=S("dns4"),df=S("dns6"),pf=S("dnsaddr"),pe=tt(S("dns"),pf,hf,df),Mr=tt(S("ip4"),S("ip6")),Ue=tt(D(Mr,S("tcp")),D(pe,S("tcp"))),Hr=D(Mr,S("udp")),mf=D(Hr,S("utp")),gf=D(Hr,S("quic")),xf=D(Hr,S("quic-v1")),So=tt(D(Ue,S("ws")),D(pe,S("ws"))),Or=tt(D(So,S("p2p")),So),vo=tt(D(Ue,S("wss")),D(pe,S("wss")),D(Ue,S("tls"),S("ws")),D(pe,S("tls"),S("ws"))),Kr=tt(D(vo,S("p2p")),vo),Ao=tt(D(Ue,S("http")),D(Mr,S("http")),D(pe,S("http"))),Bo=tt(D(Ue,S("https")),D(Mr,S("https")),D(pe,S("https"))),vi=D(Hr,S("webrtc-direct"),S("certhash")),Ii=tt(D(vi,S("p2p")),vi),Ai=D(xf,S("webtransport"),S("certhash"),S("certhash")),Ti=tt(D(Ai,S("p2p")),Ai),Li=tt(D(Or,S("p2p-webrtc-star"),S("p2p")),D(Kr,S("p2p-webrtc-star"),S("p2p")),D(Or,S("p2p-webrtc-star")),D(Kr,S("p2p-webrtc-star"))),Vm=tt(D(Or,S("p2p-websocket-star"),S("p2p")),D(Kr,S("p2p-websocket-star"),S("p2p")),D(Or,S("p2p-websocket-star")),D(Kr,S("p2p-websocket-star"))),Pi=tt(D(Ao,S("p2p-webrtc-direct"),S("p2p")),D(Bo,S("p2p-webrtc-direct"),S("p2p")),D(Ao,S("p2p-webrtc-direct")),D(Bo,S("p2p-webrtc-direct"))),me=tt(So,vo,Ao,Bo,Li,Pi,Ue,mf,gf,pe,Ii,Ti),zm=tt(D(me,S("p2p-stardust"),S("p2p")),D(me,S("p2p-stardust"))),Jt=tt(D(me,S("p2p")),Li,Pi,Ii,Ti,S("p2p")),Bi=tt(D(Jt,S("p2p-circuit"),Jt),D(Jt,S("p2p-circuit")),D(S("p2p-circuit"),Jt),D(me,S("p2p-circuit")),D(S("p2p-circuit"),me),S("p2p-circuit")),Ci=()=>tt(D(Bi,Ci),Bi),de=Ci(),Ui=tt(D(de,Jt,de),D(Jt,de),D(de,Jt),de,Jt);var Fm=tt(D(de,S("webrtc"),S("p2p")),D(de,S("webrtc")),D(me,S("webrtc"),S("p2p")),D(me,S("webrtc")),S("webrtc"));function Di(r){function t(e){let n;try{n=Qt(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function D(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(o=>(n=typeof o=="function"?o().partialMatch(e):o.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Di(t),partialMatch:t}}function tt(...r){function t(n){let o=null;return r.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Di(t),partialMatch:t}}function S(r){let t=r;function e(o){let s;try{s=Qt(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var bf="bootstrap",yf=50,wf=1e3,Io=class extends er{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(t,e={list:[]}){if(e.list==null||e.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super(),this.components=t,this.log=t.logger.forComponent("libp2p:bootstrap"),this.timeout=e.timeout??wf,this.list=[];for(let n of e.list){if(!Ui.matches(n)){this.log.error("Invalid multiaddr");continue}let o=Qt(n),s=o.getPeerId();if(s==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let i={id:ci(s),multiaddrs:[o]};this.list.push(i)}this._init=e}[Ro]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[No]=["@libp2p/peer-discovery"];isStarted(){return!!this.timer}start(){this.isStarted()||(this.log("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(t=>{this.log.error(t)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(let t of this.list){if(await this.components.peerStore.merge(t.id,{tags:{[this._init.tagName??bf]:{value:this._init.tagValue??yf,ttl:this._init.tagTTL}},multiaddrs:t.multiaddrs}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t}),this.components.connectionManager.openConnection(t.id).catch(e=>{this.log.error("could not dial bootstrap peer %p",t.id,e)})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function Ef(r){return t=>new Io(t,r)}return Gi(Sf);})();
|
|
2
|
+
"use strict";var Libp2PBootstrap=(()=>{var Vr=Object.defineProperty;var qi=Object.getOwnPropertyDescriptor;var Vi=Object.getOwnPropertyNames;var zi=Object.prototype.hasOwnProperty;var dt=(r,t)=>{for(var e in t)Vr(r,e,{get:t[e],enumerable:!0})},Fi=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Vi(t))!zi.call(r,o)&&o!==e&&Vr(r,o,{get:()=>t[o],enumerable:!(n=qi(t,o))||n.enumerable});return r};var ji=r=>Fi(Vr({},"__esModule",{value:!0}),r);var Sf={};dt(Sf,{bootstrap:()=>Ef});var Ro=Symbol.for("@libp2p/peer-discovery");var zr=Symbol.for("@libp2p/peer-id");var Pt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Qe=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Je=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},tr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var _e=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var er=class extends EventTarget{#t=new Map;constructor(){super()}listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e={}){return this.dispatchEvent(new CustomEvent(t,e))}};var No=Symbol.for("@libp2p/service-capabilities"),Lf=Symbol.for("@libp2p/service-dependencies");var Wr={};dt(Wr,{base58btc:()=>$,base58flickr:()=>Xi});var Xf=new Uint8Array(0);function Ko(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 _t(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 ko(r){return new TextEncoder().encode(r)}function Oo(r){return new TextDecoder().decode(r)}function Gi(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),l=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function f(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var y=0,h=0,E=0,A=w.length;E!==A&&w[E]===0;)E++,y++;for(var m=(A-E)*u+1>>>0,I=new Uint8Array(m);E!==A;){for(var _=w[E],U=0,T=m-1;(_!==0||U<h)&&T!==-1;T--,U++)_+=256*I[T]>>>0,I[T]=_%c>>>0,_=_/c>>>0;if(_!==0)throw new Error("Non-zero carry");h=U,E++}for(var P=m-h;P!==m&&I[P]===0;)P++;for(var L=a.repeat(y);P<m;++P)L+=r.charAt(I[P]);return L}function p(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var y=0;if(w[y]!==" "){for(var h=0,E=0;w[y]===a;)h++,y++;for(var A=(w.length-y)*l+1>>>0,m=new Uint8Array(A);w[y];){var I=e[w.charCodeAt(y)];if(I===255)return;for(var _=0,U=A-1;(I!==0||_<E)&&U!==-1;U--,_++)I+=c*m[U]>>>0,m[U]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");E=_,y++}if(w[y]!==" "){for(var T=A-E;T!==A&&m[T]===0;)T++;for(var P=new Uint8Array(h+(A-T)),L=h;T!==A;)P[L++]=m[T++];return P}}}function b(w){var y=p(w);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:p,decode:b}}var Zi=Gi,Wi=Zi,Ho=Wi;var Fr=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")}},jr=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 qo(this,t)}},Gr=class{decoders;constructor(t){this.decoders=t}or(t){return qo(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 qo(r,t){return new Gr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Zr=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 Fr(t,e,n),this.decoder=new jr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ge({name:r,prefix:t,encode:e,decode:n}){return new Zr(r,t,e,n)}function Vt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Ho(e,r);return ge({prefix:t,name:r,encode:n,decode:s=>_t(o(s))})}function $i(r,t,e,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),c=0,a=0,l=0;for(let u=0;u<s;++u){let f=o[r[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|f,c+=e,c>=8&&(c-=8,i[l++]=255&a>>c)}if(c>=e||(255&a<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return i}function Yi(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 ge({prefix:t,name:r,encode(o){return Yi(o,n,e)},decode(o){return $i(o,n,e,r)}})}var $=Vt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Xi=Vt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var $r={};dt($r,{base32:()=>Rt,base32hex:()=>ec,base32hexpad:()=>nc,base32hexpadupper:()=>oc,base32hexupper:()=>rc,base32pad:()=>Ji,base32padupper:()=>tc,base32upper:()=>Qi,base32z:()=>sc});var Rt=J({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Qi=J({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ji=J({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),tc=J({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ec=J({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),rc=J({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),nc=J({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),oc=J({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),sc=J({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Yr={};dt(Yr,{base36:()=>Re,base36upper:()=>ic});var Re=Vt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ic=Vt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var cc=Fo,Vo=128,ac=127,uc=~ac,fc=Math.pow(2,31);function Fo(r,t,e){t=t||[],e=e||0;for(var n=e;r>=fc;)t[e++]=r&255|Vo,r/=128;for(;r&uc;)t[e++]=r&255|Vo,r>>>=7;return t[e]=r|0,Fo.bytes=e-n+1,t}var lc=Xr,hc=128,zo=127;function Xr(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw Xr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&zo)<<o:(i&zo)*Math.pow(2,o),o+=7}while(i>=hc);return Xr.bytes=s-n,e}var dc=Math.pow(2,7),pc=Math.pow(2,14),mc=Math.pow(2,21),gc=Math.pow(2,28),yc=Math.pow(2,35),xc=Math.pow(2,42),bc=Math.pow(2,49),wc=Math.pow(2,56),Ec=Math.pow(2,63),Sc=function(r){return r<dc?1:r<pc?2:r<mc?3:r<gc?4:r<yc?5:r<xc?6:r<bc?7:r<wc?8:r<Ec?9:10},vc={encode:cc,decode:lc,encodingLength:Sc},Ac=vc,Ne=Ac;function Ke(r,t=0){return[Ne.decode(r,t),Ne.decode.bytes]}function ye(r,t,e=0){return Ne.encode(r,t,e),t}function xe(r){return Ne.encodingLength(r)}function te(r,t){let e=t.byteLength,n=xe(r),o=n+xe(e),s=new Uint8Array(o+e);return ye(r,s,0),ye(e,s,n),s.set(t,o),new be(r,e,t,s)}function ee(r){let t=_t(r),[e,n]=Ke(t),[o,s]=Ke(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new be(e,o,i,t)}function jo(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Ko(r.bytes,e.bytes)}}var be=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Go(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Ic(e,Qr(r),t??$.encoder);default:return Tc(e,Qr(r),t??Rt.encoder)}}var Zo=new WeakMap;function Qr(r){let t=Zo.get(r);if(t==null){let e=new Map;return Zo.set(r,e),e}return t}var rt=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!==ke)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Lc)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=te(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&&jo(t.multihash,n.multihash)}toString(t){return Go(this,t)}toJSON(){return{"/":Go(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??Wo(n,o,s.bytes))}else if(e[Cc]===!0){let{version:n,multihash:o,code:s}=e,i=ee(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!==ke)throw new Error(`Version 0 CID must use dag-pb (code: ${ke}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Wo(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,ke,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=_t(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 be(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[f,p]=Ke(t.subarray(e));return e+=p,f},o=n(),s=ke;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(),l=e+a,u=l-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:u,size:l}}static parse(t,e){let[n,o]=Bc(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 Qr(s).set(n,t),s}};function Bc(r,t){switch(r[0]){case"Q":{let e=t??$;return[$.prefix,e.decode(`${$.prefix}${r}`)]}case $.prefix:{let e=t??$;return[$.prefix,e.decode(r)]}case Rt.prefix:{let e=t??Rt;return[Rt.prefix,e.decode(r)]}case Re.prefix:{let e=t??Re;return[Re.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Ic(r,t,e){let{prefix:n}=e;if(n!==$.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 Tc(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 ke=112,Lc=18;function Wo(r,t,e){let n=xe(r),o=n+xe(t),s=new Uint8Array(o+e.byteLength);return ye(r,s,0),ye(t,s,n),s.set(e,o),s}var Cc=Symbol.for("@ipld/js-cid/CID");var Jr={};dt(Jr,{identity:()=>At});var $o=0,Pc="identity",Yo=_t;function Uc(r){return te($o,Yo(r))}var At={code:$o,name:Pc,encode:Yo,digest:Uc};function xt(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 Nt(r=0){return new Uint8Array(r)}function pt(r=0){return new Uint8Array(r)}function bt(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=pt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var Qo=Symbol.for("@achingbrain/uint8arraylist");function Xo(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 nr(r){return!!r?.[Qo]}var wt=class r{bufs;length;[Qo]=!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(nr(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(nr(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=Xo(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Xo(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(nr(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 bt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:bt(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 l=t>=c&&t<a,u=e>c&&e<=a;if(l&&u){if(t===c&&e===a){n.push(i);break}let f=t-c;n.push(i.subarray(f,f+(e-t)));break}if(l){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(u){if(e===a){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!nr(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 f=0;f<s;f++)i[f]=-1;for(let f=0;f<o;f++)i[n[f]]=f;let c=i,a=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=e;f<=a;f+=u){u=0;for(let p=l;p>=0;p--){let b=this.get(f+p);if(n[p]!==b){u=Math.max(1,p-c[b]);break}}if(u===0)return f}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=pt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=Nt(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=Nt(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=Nt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=pt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=Nt(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=Nt(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=Nt(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=Nt(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=Nt(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(!xt(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 tn={};dt(tn,{base10:()=>Dc});var Dc=Vt({prefix:"9",name:"base10",alphabet:"0123456789"});var en={};dt(en,{base16:()=>_c,base16upper:()=>Rc});var _c=J({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Rc=J({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var rn={};dt(rn,{base2:()=>Nc});var Nc=J({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var nn={};dt(nn,{base256emoji:()=>Hc});var Jo=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}"),Kc=Jo.reduce((r,t,e)=>(r[e]=t,r),[]),kc=Jo.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Oc(r){return r.reduce((t,e)=>(t+=Kc[e],t),"")}function Mc(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=kc[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Hc=ge({prefix:"\u{1F680}",name:"base256emoji",encode:Oc,decode:Mc});var on={};dt(on,{base64:()=>qc,base64pad:()=>Vc,base64url:()=>zc,base64urlpad:()=>Fc});var qc=J({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Vc=J({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),zc=J({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Fc=J({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var sn={};dt(sn,{base8:()=>jc});var jc=J({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var cn={};dt(cn,{identity:()=>Gc});var Gc=ge({prefix:"\0",name:"identity",encode:r=>Oo(r),decode:r=>ko(r)});var Rl=new TextEncoder,Nl=new TextDecoder;var fn={};dt(fn,{sha256:()=>Oe,sha512:()=>$c});function un({name:r,code:t,encode:e}){return new an(r,t,e)}var an=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?te(this.code,e):e.then(n=>te(this.code,n))}else throw Error("Unknown type, must be binary type")}};function es(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Oe=un({name:"sha2-256",code:18,encode:es("SHA-256")}),$c=un({name:"sha2-512",code:19,encode:es("SHA-512")});var Me={...cn,...rn,...sn,...tn,...en,...$r,...Yr,...Wr,...on,...nn},Zl={...fn,...Jr};function ns(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var rs=ns("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ln=ns("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=pt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Yc={utf8:rs,"utf-8":rs,hex:Me.base16,latin1:ln,ascii:ln,binary:ln,...Me},or=Yc;function vt(r,t="utf8"){let e=or[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function j(r,t="utf8"){let e=or[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Xc=parseInt("11111",2),hn=parseInt("10000000",2),Qc=parseInt("01111111",2),os={0:He,1:He,2:Jc,3:ra,4:na,5:ea,6:ta,16:He,22:He,48:He};function dn(r,t={offset:0}){let e=r[t.offset]&Xc;if(t.offset++,os[e]!=null)return os[e](r,t);throw new Error("No decoder for tag "+e)}function qe(r,t){let e=0;if((r[t.offset]&hn)===hn){let n=r[t.offset]&Qc,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 He(r,t){qe(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=dn(r,t);if(n===null)break;e.push(n)}return e}function Jc(r,t){let e=qe(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function ta(r,t){let e=qe(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 l=r[t.offset];if(t.offset++,a.push(l&127),l<128){a.reverse();let u=0;for(let f=0;f<a.length;f++)u+=a[f]<<f*7;c+=`.${u}`,a=[]}}return c}function ea(r,t){return t.offset++,null}function ra(r,t){let e=qe(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function na(r,t){let e=qe(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function oa(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new wt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function pn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=oa(r.byteLength);return new wt(Uint8Array.from([t.byteLength|hn]),t)}function ss(r){let t=new wt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new wt(Uint8Array.from([2]),pn(t),t)}function is(r){let t=Uint8Array.from([0]),e=new wt(t,r);return new wt(Uint8Array.from([3]),pn(e),e)}function sr(r,t=48){let e=new wt;for(let n of r)e.append(n);return new wt(Uint8Array.from([t]),pn(e),e)}async function cs(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 sa=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),ia=Uint8Array.from([6,5,43,129,4,0,34]),ca=Uint8Array.from([6,5,43,129,4,0,35]),aa={ext:!0,kty:"EC",crv:"P-256"},ua={ext:!0,kty:"EC",crv:"P-384"},fa={ext:!0,kty:"EC",crv:"P-521"},mn=32,gn=48,yn=66;function as(r){let t=dn(r);return us(t)}function us(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===mn*2+1)return n=j(t.subarray(e,e+mn),"base64url"),o=j(t.subarray(e+mn),"base64url"),new we({...aa,key_ops:["verify"],x:n,y:o});if(t.byteLength===gn*2+1)return n=j(t.subarray(e,e+gn),"base64url"),o=j(t.subarray(e+gn),"base64url"),new we({...ua,key_ops:["verify"],x:n,y:o});if(t.byteLength===yn*2+1)return n=j(t.subarray(e,e+yn),"base64url"),o=j(t.subarray(e+yn),"base64url"),new we({...fa,key_ops:["verify"],x:n,y:o});throw new Pt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function fs(r){return sr([ss(Uint8Array.from([1])),sr([la(r.crv)],160),sr([is(new wt(Uint8Array.from([4]),vt(r.x??"","base64url"),vt(r.y??"","base64url")))],161)]).subarray()}function la(r){if(r==="P-256")return sa;if(r==="P-384")return ia;if(r==="P-521")return ca;throw new Pt(`Invalid curve ${r}`)}var we=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=fs(this.jwk)),this._raw}toMultihash(){return At.digest(Ee(this))}toCID(){return rt.createV1(114,this.toMultihash())}toString(){return $.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:xt(this.raw,t.raw)}async verify(t,e){return cs(this.jwk,e,t)}};function ls(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function ha(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Se(r,...t){if(!ha(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 hs(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ls(r.outputLen),ls(r.blockLen)}function ve(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 ds(r,t){Se(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var ne=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function ir(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Bt(r,t){return r<<32-t|r>>>t}function ps(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Ve(r){return typeof r=="string"&&(r=ps(r)),Se(r),r}function xn(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Se(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 Ae=class{clone(){return this._cloneInto()}};function cr(r){let t=n=>r().update(Ve(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function ar(r=32){if(ne&&typeof ne.getRandomValues=="function")return ne.getRandomValues(new Uint8Array(r));if(ne&&typeof ne.randomBytes=="function")return ne.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function da(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),c=Number(e&s),a=n?4:0,l=n?0:4;r.setUint32(t+a,i,n),r.setUint32(t+l,c,n)}function ms(r,t,e){return r&t^~r&e}function gs(r,t,e){return r&t^r&e^t&e}var Be=class extends Ae{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ir(this.buffer)}update(t){ve(this);let{view:e,buffer:n,blockLen:o}=this;t=Ve(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=ir(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){ve(this),ds(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 f=i;f<o;f++)e[f]=0;da(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=ir(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=a/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)c.setUint32(4*f,u[f],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 ur=BigInt(4294967295),bn=BigInt(32);function ys(r,t=!1){return t?{h:Number(r&ur),l:Number(r>>bn&ur)}:{h:Number(r>>bn&ur)|0,l:Number(r&ur)|0}}function pa(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}=ys(r[o],t);[e[o],n[o]]=[s,i]}return[e,n]}var ma=(r,t)=>BigInt(r>>>0)<<bn|BigInt(t>>>0),ga=(r,t,e)=>r>>>e,ya=(r,t,e)=>r<<32-e|t>>>e,xa=(r,t,e)=>r>>>e|t<<32-e,ba=(r,t,e)=>r<<32-e|t>>>e,wa=(r,t,e)=>r<<64-e|t>>>e-32,Ea=(r,t,e)=>r>>>e-32|t<<64-e,Sa=(r,t)=>t,va=(r,t)=>r,Aa=(r,t,e)=>r<<e|t>>>32-e,Ba=(r,t,e)=>t<<e|r>>>32-e,Ia=(r,t,e)=>t<<e-32|r>>>64-e,Ta=(r,t,e)=>r<<e-32|t>>>64-e;function La(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var Ca=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Pa=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Ua=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Da=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,_a=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Ra=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Na={fromBig:ys,split:pa,toBig:ma,shrSH:ga,shrSL:ya,rotrSH:xa,rotrSL:ba,rotrBH:wa,rotrBL:Ea,rotr32H:Sa,rotr32L:va,rotlSH:Aa,rotlSL:Ba,rotlBH:Ia,rotlBL:Ta,add:La,add3L:Ca,add3H:Pa,add4L:Ua,add4H:Da,add5H:Ra,add5L:_a},k=Na;var[Ka,ka]=k.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),zt=new Uint32Array(80),Ft=new Uint32Array(80),wn=class extends Be{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:l,El:u,Fh:f,Fl:p,Gh:b,Gl:w,Hh:y,Hl:h}=this;return[t,e,n,o,s,i,c,a,l,u,f,p,b,w,y,h]}set(t,e,n,o,s,i,c,a,l,u,f,p,b,w,y,h){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=p|0,this.Gh=b|0,this.Gl=w|0,this.Hh=y|0,this.Hl=h|0}process(t,e){for(let m=0;m<16;m++,e+=4)zt[m]=t.getUint32(e),Ft[m]=t.getUint32(e+=4);for(let m=16;m<80;m++){let I=zt[m-15]|0,_=Ft[m-15]|0,U=k.rotrSH(I,_,1)^k.rotrSH(I,_,8)^k.shrSH(I,_,7),T=k.rotrSL(I,_,1)^k.rotrSL(I,_,8)^k.shrSL(I,_,7),P=zt[m-2]|0,L=Ft[m-2]|0,W=k.rotrSH(P,L,19)^k.rotrBH(P,L,61)^k.shrSH(P,L,6),q=k.rotrSL(P,L,19)^k.rotrBL(P,L,61)^k.shrSL(P,L,6),M=k.add4L(T,q,Ft[m-7],Ft[m-16]),et=k.add4H(M,U,W,zt[m-7],zt[m-16]);zt[m]=et|0,Ft[m]=M|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:l,Dl:u,Eh:f,El:p,Fh:b,Fl:w,Gh:y,Gl:h,Hh:E,Hl:A}=this;for(let m=0;m<80;m++){let I=k.rotrSH(f,p,14)^k.rotrSH(f,p,18)^k.rotrBH(f,p,41),_=k.rotrSL(f,p,14)^k.rotrSL(f,p,18)^k.rotrBL(f,p,41),U=f&b^~f&y,T=p&w^~p&h,P=k.add5L(A,_,T,ka[m],Ft[m]),L=k.add5H(P,E,I,U,Ka[m],zt[m]),W=P|0,q=k.rotrSH(n,o,28)^k.rotrBH(n,o,34)^k.rotrBH(n,o,39),M=k.rotrSL(n,o,28)^k.rotrBL(n,o,34)^k.rotrBL(n,o,39),et=n&s^n&c^s&c,v=o&i^o&a^i&a;E=y|0,A=h|0,y=b|0,h=w|0,b=f|0,w=p|0,{h:f,l:p}=k.add(l|0,u|0,L|0,W|0),l=c|0,u=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let C=k.add3L(W,M,v);n=k.add3H(C,L,q,et),o=C|0}({h:n,l:o}=k.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=k.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=k.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:l,l:u}=k.add(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:p}=k.add(this.Eh|0,this.El|0,f|0,p|0),{h:b,l:w}=k.add(this.Fh|0,this.Fl|0,b|0,w|0),{h:y,l:h}=k.add(this.Gh|0,this.Gl|0,y|0,h|0),{h:E,l:A}=k.add(this.Hh|0,this.Hl|0,E|0,A|0),this.set(n,o,s,i,c,a,l,u,f,p,b,w,y,h,E,A)}roundClean(){zt.fill(0),Ft.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 xs=cr(()=>new wn);var hr={};dt(hr,{aInRange:()=>mt,abool:()=>It,abytes:()=>Ie,bitGet:()=>za,bitLen:()=>An,bitMask:()=>Fe,bitSet:()=>Fa,bytesToHex:()=>kt,bytesToNumberBE:()=>Ot,bytesToNumberLE:()=>Gt,concatBytes:()=>Mt,createHmacDrbg:()=>Bn,ensureBytes:()=>Q,equalBytes:()=>qa,hexToBytes:()=>se,hexToNumber:()=>vn,inRange:()=>ze,isBytes:()=>jt,memoized:()=>ce,notImplemented:()=>Ga,numberToBytesBE:()=>Zt,numberToBytesLE:()=>ie,numberToHexUnpadded:()=>oe,numberToVarBytesBE:()=>Ha,utf8ToBytes:()=>Va,validateObject:()=>Ut});var fr=BigInt(0),lr=BigInt(1),Oa=BigInt(2);function jt(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ie(r){if(!jt(r))throw new Error("Uint8Array expected")}function It(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var Ma=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function kt(r){Ie(r);let t="";for(let e=0;e<r.length;e++)t+=Ma[r[e]];return t}function oe(r){let t=r.toString(16);return t.length&1?"0"+t:t}function vn(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?fr:BigInt("0x"+r)}var Kt={_0:48,_9:57,A:65,F:70,a:97,f:102};function bs(r){if(r>=Kt._0&&r<=Kt._9)return r-Kt._0;if(r>=Kt.A&&r<=Kt.F)return r-(Kt.A-10);if(r>=Kt.a&&r<=Kt.f)return r-(Kt.a-10)}function se(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=bs(r.charCodeAt(s)),c=bs(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 Ot(r){return vn(kt(r))}function Gt(r){return Ie(r),vn(kt(Uint8Array.from(r).reverse()))}function Zt(r,t){return se(r.toString(16).padStart(t*2,"0"))}function ie(r,t){return Zt(r,t).reverse()}function Ha(r){return se(oe(r))}function Q(r,t,e){let n;if(typeof t=="string")try{n=se(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(jt(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 Mt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Ie(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}function qa(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function Va(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var En=r=>typeof r=="bigint"&&fr<=r;function ze(r,t,e){return En(r)&&En(t)&&En(e)&&t<=r&&r<e}function mt(r,t,e,n){if(!ze(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function An(r){let t;for(t=0;r>fr;r>>=lr,t+=1);return t}function za(r,t){return r>>BigInt(t)&lr}function Fa(r,t,e){return r|(e?lr:fr)<<BigInt(t)}var Fe=r=>(Oa<<BigInt(r-1))-lr,Sn=r=>new Uint8Array(r),ws=r=>Uint8Array.from(r);function Bn(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=Sn(r),o=Sn(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...f)=>e(o,n,...f),a=(f=Sn())=>{o=c(ws([0]),f),n=c(),f.length!==0&&(o=c(ws([1]),f),n=c())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,p=[];for(;f<t;){n=c();let b=n.slice();p.push(b),f+=n.length}return Mt(...p)};return(f,p)=>{i(),a(f);let b;for(;!(b=p(l()));)a();return i(),b}}var ja={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"||jt(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 Ut(r,t,e={}){let n=(o,s,i)=>{let c=ja[s];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(i&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+a)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}var Ga=()=>{throw new Error("not implemented")};function ce(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 nt=BigInt(0),Y=BigInt(1),ae=BigInt(2),Za=BigInt(3),In=BigInt(4),Es=BigInt(5),Ss=BigInt(8),Wa=BigInt(9),$a=BigInt(16);function F(r,t){let e=r%t;return e>=nt?e:t+e}function Ya(r,t,e){if(t<nt)throw new Error("invalid exponent, negatives unsupported");if(e<=nt)throw new Error("invalid modulus");if(e===Y)return nt;let n=Y;for(;t>nt;)t&Y&&(n=n*r%e),r=r*r%e,t>>=Y;return n}function X(r,t,e){let n=r;for(;t-- >nt;)n*=n,n%=e;return n}function dr(r,t){if(r===nt)throw new Error("invert: expected non-zero number");if(t<=nt)throw new Error("invert: expected positive modulus, got "+t);let e=F(r,t),n=t,o=nt,s=Y,i=Y,c=nt;for(;e!==nt;){let l=n/e,u=n%e,f=o-i*l,p=s-c*l;n=e,e=u,o=i,s=c,i=f,c=p}if(n!==Y)throw new Error("invert: does not exist");return F(o,t)}function Xa(r){let t=(r-Y)/ae,e,n,o;for(e=r-Y,n=0;e%ae===nt;e/=ae,n++);for(o=ae;o<r&&Ya(o,t,r)!==r-Y;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let i=(r+Y)/In;return function(a,l){let u=a.pow(l,i);if(!a.eql(a.sqr(u),l))throw new Error("Cannot find square root");return u}}let s=(e+Y)/ae;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let l=n,u=c.pow(c.mul(c.ONE,o),e),f=c.pow(a,s),p=c.pow(a,e);for(;!c.eql(p,c.ONE);){if(c.eql(p,c.ZERO))return c.ZERO;let b=1;for(let y=c.sqr(p);b<l&&!c.eql(y,c.ONE);b++)y=c.sqr(y);let w=c.pow(u,Y<<BigInt(l-b-1));u=c.sqr(w),f=c.mul(f,w),p=c.mul(p,u),l=b}return f}}function Qa(r){if(r%In===Za){let t=(r+Y)/In;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%Ss===Es){let t=(r-Es)/Ss;return function(n,o){let s=n.mul(o,ae),i=n.pow(s,t),c=n.mul(o,i),a=n.mul(n.mul(c,ae),i),l=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(l),o))throw new Error("Cannot find square root");return l}}return r%$a,Xa(r)}var vs=(r,t)=>(F(r,t)&Y)===Y,Ja=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Tn(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Ja.reduce((n,o)=>(n[o]="function",n),t);return Ut(r,e)}function tu(r,t,e){if(e<nt)throw new Error("invalid exponent, negatives unsupported");if(e===nt)return r.ONE;if(e===Y)return t;let n=r.ONE,o=t;for(;e>nt;)e&Y&&(n=r.mul(n,o)),o=r.sqr(o),e>>=Y;return n}function eu(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 Ln(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Wt(r,t,e=!1,n={}){if(r<=nt)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=Ln(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:Fe(o),ZERO:nt,ONE:Y,create:a=>F(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return nt<=a&&a<r},is0:a=>a===nt,isOdd:a=>(a&Y)===Y,neg:a=>F(-a,r),eql:(a,l)=>a===l,sqr:a=>F(a*a,r),add:(a,l)=>F(a+l,r),sub:(a,l)=>F(a-l,r),mul:(a,l)=>F(a*l,r),pow:(a,l)=>tu(c,a,l),div:(a,l)=>F(a*dr(l,r),r),sqrN:a=>a*a,addN:(a,l)=>a+l,subN:(a,l)=>a-l,mulN:(a,l)=>a*l,inv:a=>dr(a,r),sqrt:n.sqrt||(a=>(i||(i=Qa(r)),i(c,a))),invertBatch:a=>eu(c,a),cmov:(a,l,u)=>u?l:a,toBytes:a=>e?ie(a,s):Zt(a,s),fromBytes:a=>{if(a.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+a.length);return e?Gt(a):Ot(a)}});return Object.freeze(c)}function As(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Cn(r){let t=As(r);return t+Math.ceil(t/2)}function Bs(r,t,e=!1){let n=r.length,o=As(t),s=Cn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?Gt(r):Ot(r),c=F(i,t-Y)+Y;return e?ie(c,o):Zt(c,o)}var Is=BigInt(0),pr=BigInt(1);function Pn(r,t){let e=t.negate();return r?e:t}function Ts(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Un(r,t){Ts(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function ru(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 nu(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var Dn=new WeakMap,Ls=new WeakMap;function _n(r){return Ls.get(r)||1}function mr(r,t){return{constTimeNegate:Pn,hasPrecomputes(e){return _n(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Is;)n&pr&&(o=o.add(s)),s=s.double(),n>>=pr;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=Un(n,t),i=[],c=e,a=c;for(let l=0;l<o;l++){a=c,i.push(a);for(let u=1;u<s;u++)a=a.add(c),i.push(a);c=a.double()}return i},wNAF(e,n,o){let{windows:s,windowSize:i}=Un(e,t),c=r.ZERO,a=r.BASE,l=BigInt(2**e-1),u=2**e,f=BigInt(e);for(let p=0;p<s;p++){let b=p*i,w=Number(o&l);o>>=f,w>i&&(w-=u,o+=pr);let y=b,h=b+Math.abs(w)-1,E=p%2!==0,A=w<0;w===0?a=a.add(Pn(E,n[y])):c=c.add(Pn(A,n[h]))}return{p:c,f:a}},wNAFUnsafe(e,n,o,s=r.ZERO){let{windows:i,windowSize:c}=Un(e,t),a=BigInt(2**e-1),l=2**e,u=BigInt(e);for(let f=0;f<i;f++){let p=f*c;if(o===Is)break;let b=Number(o&a);if(o>>=u,b>c&&(b-=l,o+=pr),b===0)continue;let w=n[p+Math.abs(b)-1];b<0&&(w=w.negate()),s=s.add(w)}return s},getPrecomputes(e,n,o){let s=Dn.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&Dn.set(n,o(s))),s},wNAFCached(e,n,o){let s=_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){Ts(n,t),Ls.set(e,n),Dn.delete(e)}}}function gr(r,t,e,n){if(ru(e,r),nu(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,s=An(BigInt(e.length)),i=s>12?s-3:s>4?s-2:s?2:1,c=(1<<i)-1,a=new Array(c+1).fill(o),l=Math.floor((t.BITS-1)/i)*i,u=o;for(let f=l;f>=0;f-=i){a.fill(o);for(let b=0;b<n.length;b++){let w=n[b],y=Number(w>>BigInt(f)&BigInt(c));a[y]=a[y].add(e[b])}let p=o;for(let b=a.length-1,w=o;b>0;b--)w=w.add(a[b]),p=p.add(w);if(u=u.add(p),f!==0)for(let b=0;b<i;b++)u=u.double()}return u}function je(r){return Tn(r.Fp),Ut(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ln(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Tt=BigInt(0),gt=BigInt(1),yr=BigInt(2),ou=BigInt(8),su={zip215:!0};function iu(r){let t=je(r);return Ut(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=iu(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:c,h:a}=t,l=yr<<BigInt(c*8)-gt,u=e.create,f=Wt(t.n,t.nBitLength),p=t.uvRatio||((g,d)=>{try{return{isValid:!0,value:e.sqrt(g*e.inv(d))}}catch{return{isValid:!1,value:Tt}}}),b=t.adjustScalarBytes||(g=>g),w=t.domain||((g,d,x)=>{if(It("phflag",x),d.length||x)throw new Error("Contexts/pre-hash are not supported");return g});function y(g,d){mt("coordinate "+g,d,Tt,l)}function h(g){if(!(g instanceof m))throw new Error("ExtendedPoint expected")}let E=ce((g,d)=>{let{ex:x,ey:B,ez:R}=g,N=g.is0();d==null&&(d=N?ou:e.inv(R));let O=u(x*d),H=u(B*d),K=u(R*d);if(N)return{x:Tt,y:gt};if(K!==gt)throw new Error("invZ was invalid");return{x:O,y:H}}),A=ce(g=>{let{a:d,d:x}=t;if(g.is0())throw new Error("bad point: ZERO");let{ex:B,ey:R,ez:N,et:O}=g,H=u(B*B),K=u(R*R),z=u(N*N),Z=u(z*z),ot=u(H*d),st=u(z*u(ot+K)),ct=u(Z+u(x*u(H*K)));if(st!==ct)throw new Error("bad point: equation left != right (1)");let at=u(B*R),ht=u(N*O);if(at!==ht)throw new Error("bad point: equation left != right (2)");return!0});class m{constructor(d,x,B,R){this.ex=d,this.ey=x,this.ez=B,this.et=R,y("x",d),y("y",x),y("z",B),y("t",R),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(d){if(d instanceof m)throw new Error("extended point not allowed");let{x,y:B}=d||{};return y("x",x),y("y",B),new m(x,B,gt,u(x*B))}static normalizeZ(d){let x=e.invertBatch(d.map(B=>B.ez));return d.map((B,R)=>B.toAffine(x[R])).map(m.fromAffine)}static msm(d,x){return gr(m,f,d,x)}_setWindowSize(d){U.setWindowSize(this,d)}assertValidity(){A(this)}equals(d){h(d);let{ex:x,ey:B,ez:R}=this,{ex:N,ey:O,ez:H}=d,K=u(x*H),z=u(N*R),Z=u(B*H),ot=u(O*R);return K===z&&Z===ot}is0(){return this.equals(m.ZERO)}negate(){return new m(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:d}=t,{ex:x,ey:B,ez:R}=this,N=u(x*x),O=u(B*B),H=u(yr*u(R*R)),K=u(d*N),z=x+B,Z=u(u(z*z)-N-O),ot=K+O,st=ot-H,ct=K-O,at=u(Z*st),ht=u(ot*ct),lt=u(Z*ct),Ct=u(st*ot);return new m(at,ht,Ct,lt)}add(d){h(d);let{a:x,d:B}=t,{ex:R,ey:N,ez:O,et:H}=this,{ex:K,ey:z,ez:Z,et:ot}=d;if(x===BigInt(-1)){let To=u((N-R)*(z+K)),Lo=u((N+R)*(z-K)),qr=u(Lo-To);if(qr===Tt)return this.double();let Co=u(O*yr*ot),Po=u(H*yr*Z),Uo=Po+Co,Do=Lo+To,_o=Po-Co,ki=u(Uo*qr),Oi=u(Do*_o),Mi=u(Uo*_o),Hi=u(qr*Do);return new m(ki,Oi,Hi,Mi)}let st=u(R*K),ct=u(N*z),at=u(H*B*ot),ht=u(O*Z),lt=u((R+N)*(K+z)-st-ct),Ct=ht-at,Dt=ht+at,De=u(ct-x*st),_i=u(lt*Ct),Ri=u(Dt*De),Ni=u(lt*De),Ki=u(Ct*Dt);return new m(_i,Ri,Ki,Ni)}subtract(d){return this.add(d.negate())}wNAF(d){return U.wNAFCached(this,d,m.normalizeZ)}multiply(d){let x=d;mt("scalar",x,gt,n);let{p:B,f:R}=this.wNAF(x);return m.normalizeZ([B,R])[0]}multiplyUnsafe(d,x=m.ZERO){let B=d;return mt("scalar",B,Tt,n),B===Tt?_:this.is0()||B===gt?this:U.wNAFCachedUnsafe(this,B,m.normalizeZ,x)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(d){return E(this,d)}clearCofactor(){let{h:d}=t;return d===gt?this:this.multiplyUnsafe(d)}static fromHex(d,x=!1){let{d:B,a:R}=t,N=e.BYTES;d=Q("pointHex",d,N),It("zip215",x);let O=d.slice(),H=d[N-1];O[N-1]=H&-129;let K=Gt(O),z=x?l:e.ORDER;mt("pointHex.y",K,Tt,z);let Z=u(K*K),ot=u(Z-gt),st=u(B*Z-R),{isValid:ct,value:at}=p(ot,st);if(!ct)throw new Error("Point.fromHex: invalid y coordinate");let ht=(at>)===gt,lt=(H&128)!==0;if(!x&&at===Tt&<)throw new Error("Point.fromHex: x=0 and x_0=1");return lt!==ht&&(at=u(-at)),m.fromAffine({x:at,y:K})}static fromPrivateKey(d){return L(d).point}toRawBytes(){let{x:d,y:x}=this.toAffine(),B=ie(x,e.BYTES);return B[B.length-1]|=d>?128:0,B}toHex(){return kt(this.toRawBytes())}}m.BASE=new m(t.Gx,t.Gy,gt,u(t.Gx*t.Gy)),m.ZERO=new m(Tt,gt,gt,Tt);let{BASE:I,ZERO:_}=m,U=mr(m,c*8);function T(g){return F(g,n)}function P(g){return T(Gt(g))}function L(g){let d=e.BYTES;g=Q("private key",g,d);let x=Q("hashed private key",s(g),2*d),B=b(x.slice(0,d)),R=x.slice(d,2*d),N=P(B),O=I.multiply(N),H=O.toRawBytes();return{head:B,prefix:R,scalar:N,point:O,pointBytes:H}}function W(g){return L(g).pointBytes}function q(g=new Uint8Array,...d){let x=Mt(...d);return P(s(w(x,Q("context",g),!!o)))}function M(g,d,x={}){g=Q("message",g),o&&(g=o(g));let{prefix:B,scalar:R,pointBytes:N}=L(d),O=q(x.context,B,g),H=I.multiply(O).toRawBytes(),K=q(x.context,H,N,g),z=T(O+K*R);mt("signature.s",z,Tt,n);let Z=Mt(H,ie(z,e.BYTES));return Q("result",Z,e.BYTES*2)}let et=su;function v(g,d,x,B=et){let{context:R,zip215:N}=B,O=e.BYTES;g=Q("signature",g,2*O),d=Q("message",d),x=Q("publicKey",x,O),N!==void 0&&It("zip215",N),o&&(d=o(d));let H=Gt(g.slice(O,2*O)),K,z,Z;try{K=m.fromHex(x,N),z=m.fromHex(g.slice(0,O),N),Z=I.multiplyUnsafe(H)}catch{return!1}if(!N&&K.isSmallOrder())return!1;let ot=q(R,z.toRawBytes(),K.toRawBytes(),d);return z.add(K.multiplyUnsafe(ot)).subtract(Z).clearCofactor().equals(m.ZERO)}return I._setWindowSize(8),{CURVE:t,getPublicKey:W,sign:M,verify:v,ExtendedPoint:m,utils:{getExtendedPublicKey:L,randomPrivateKey:()=>i(e.BYTES),precompute(g=8,d=m.BASE){return d._setWindowSize(g),d.multiply(BigInt(3)),d}}}}var Rn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ps=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Xh=BigInt(0),cu=BigInt(1),Us=BigInt(2),Qh=BigInt(3),au=BigInt(5),uu=BigInt(8);function fu(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=Rn,c=r*r%s*r%s,a=X(c,Us,s)*c%s,l=X(a,cu,s)*r%s,u=X(l,au,s)*l%s,f=X(u,t,s)*u%s,p=X(f,e,s)*f%s,b=X(p,n,s)*p%s,w=X(b,o,s)*b%s,y=X(w,o,s)*b%s,h=X(y,t,s)*u%s;return{pow_p_5_8:X(h,Us,s)*r%s,b2:c}}function lu(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function hu(r,t){let e=Rn,n=F(t*t*t,e),o=F(n*n*t,e),s=fu(r*o).pow_p_5_8,i=F(r*n*s,e),c=F(t*i*i,e),a=i,l=F(i*Ps,e),u=c===r,f=c===F(-r,e),p=c===F(-r*Ps,e);return u&&(i=a),(f||p)&&(i=l),vs(i,e)&&(i=F(-i,e)),{isValid:u||f,value:i}}var du=Wt(Rn,void 0,!0),pu={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:du,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:uu,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:xs,randomBytes:ar,adjustScalarBytes:lu,uvRatio:hu},Ds=Cs(pu);var xr=32;function _s(r,t,e){return Ds.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var br=class{type="Ed25519";raw;constructor(t){this.raw=Nn(t,xr)}toMultihash(){return At.digest(Ee(this))}toCID(){return rt.createV1(114,this.toMultihash())}toString(){return $.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:xt(this.raw,t.raw)}verify(t,e){return _s(this.raw,e,t)}};function Ns(r){return r=Nn(r,xr),new br(r)}function Nn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new Pt(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var gu=Math.pow(2,7),yu=Math.pow(2,14),xu=Math.pow(2,21),Kn=Math.pow(2,28),kn=Math.pow(2,35),On=Math.pow(2,42),Mn=Math.pow(2,49),V=128,ut=127;function yt(r){if(r<gu)return 1;if(r<yu)return 2;if(r<xu)return 3;if(r<Kn)return 4;if(r<kn)return 5;if(r<On)return 6;if(r<Mn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Hn(r,t,e=0){switch(yt(r)){case 8:t[e++]=r&255|V,r/=128;case 7:t[e++]=r&255|V,r/=128;case 6:t[e++]=r&255|V,r/=128;case 5:t[e++]=r&255|V,r/=128;case 4:t[e++]=r&255|V,r>>>=7;case 3:t[e++]=r&255|V,r>>>=7;case 2:t[e++]=r&255|V,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function bu(r,t,e=0){switch(yt(r)){case 8:t.set(e++,r&255|V),r/=128;case 7:t.set(e++,r&255|V),r/=128;case 6:t.set(e++,r&255|V),r/=128;case 5:t.set(e++,r&255|V),r/=128;case 4:t.set(e++,r&255|V),r>>>=7;case 3:t.set(e++,r&255|V),r>>>=7;case 2:t.set(e++,r&255|V),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function qn(r,t){let e=r[t],n=0;if(n+=e&ut,e<V||(e=r[t+1],n+=(e&ut)<<7,e<V)||(e=r[t+2],n+=(e&ut)<<14,e<V)||(e=r[t+3],n+=(e&ut)<<21,e<V)||(e=r[t+4],n+=(e&ut)*Kn,e<V)||(e=r[t+5],n+=(e&ut)*kn,e<V)||(e=r[t+6],n+=(e&ut)*On,e<V)||(e=r[t+7],n+=(e&ut)*Mn,e<V))return n;throw new RangeError("Could not decode varint")}function wu(r,t){let e=r.get(t),n=0;if(n+=e&ut,e<V||(e=r.get(t+1),n+=(e&ut)<<7,e<V)||(e=r.get(t+2),n+=(e&ut)<<14,e<V)||(e=r.get(t+3),n+=(e&ut)<<21,e<V)||(e=r.get(t+4),n+=(e&ut)*Kn,e<V)||(e=r.get(t+5),n+=(e&ut)*kn,e<V)||(e=r.get(t+6),n+=(e&ut)*On,e<V)||(e=r.get(t+7),n+=(e&ut)*Mn,e<V))return n;throw new RangeError("Could not decode varint")}function Te(r,t,e=0){return t==null&&(t=pt(yt(r))),t instanceof Uint8Array?Hn(r,t,e):bu(r,t,e)}function ue(r,t=0){return r instanceof Uint8Array?qn(r,t):wu(r,t)}var Vn=new Float32Array([-0]),$t=new Uint8Array(Vn.buffer);function ks(r,t,e){Vn[0]=r,t[e]=$t[0],t[e+1]=$t[1],t[e+2]=$t[2],t[e+3]=$t[3]}function Os(r,t){return $t[0]=r[t],$t[1]=r[t+1],$t[2]=r[t+2],$t[3]=r[t+3],Vn[0]}var zn=new Float64Array([-0]),ft=new Uint8Array(zn.buffer);function Ms(r,t,e){zn[0]=r,t[e]=ft[0],t[e+1]=ft[1],t[e+2]=ft[2],t[e+3]=ft[3],t[e+4]=ft[4],t[e+5]=ft[5],t[e+6]=ft[6],t[e+7]=ft[7]}function Hs(r,t){return ft[0]=r[t],ft[1]=r[t+1],ft[2]=r[t+2],ft[3]=r[t+3],ft[4]=r[t+4],ft[5]=r[t+5],ft[6]=r[t+6],ft[7]=r[t+7],zn[0]}var Eu=BigInt(Number.MAX_SAFE_INTEGER),Su=BigInt(Number.MIN_SAFE_INTEGER),Et=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 fe;if(t<Eu&&t>Su)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>qs&&(o=0n,++n>qs&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return fe;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):fe}},fe=new Et(0,0);fe.toBigInt=function(){return 0n};fe.zzEncode=fe.zzDecode=function(){return this};fe.length=function(){return 1};var qs=4294967296n;function Vs(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 zs(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 Fn(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 Lt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function wr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var jn=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,Lt(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 Lt(this,4);return wr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Lt(this,4);return wr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Lt(this,4);let t=Os(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Lt(this,4);let t=Hs(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Lt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return zs(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Lt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Lt(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 Et(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 Lt(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 Lt(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 Lt(this,8);let t=wr(this.buf,this.pos+=4),e=wr(this.buf,this.pos+=4);return new Et(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=qn(this.buf,this.pos);return this.pos+=yt(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Gn(r){return new jn(r instanceof Uint8Array?r:r.subarray())}function Er(r,t,e){let n=Gn(r);return t.decode(n,void 0,e)}function Zn(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return pt(i);o+i>t&&(n=pt(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var le=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Wn(){}var Yn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},vu=Zn();function Au(r){return globalThis.Buffer!=null?pt(r):vu(r)}var Ze=class{len;head;tail;states;constructor(){this.len=0,this.head=new le(Wn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new le(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Xn((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(Sr,10,Et.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=Et.fromBigInt(t);return this._push(Sr,e.length(),e)}uint64Number(t){return this._push(Hn,yt(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=Et.fromBigInt(t).zzEncode();return this._push(Sr,e.length(),e)}sint64Number(t){let e=Et.fromNumber(t).zzEncode();return this._push(Sr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push($n,1,t?1:0)}fixed32(t){return this._push(Ge,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=Et.fromBigInt(t);return this._push(Ge,4,e.lo)._push(Ge,4,e.hi)}fixed64Number(t){let e=Et.fromNumber(t);return this._push(Ge,4,e.lo)._push(Ge,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(ks,4,t)}double(t){return this._push(Ms,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push($n,1,0):this.uint32(e)._push(Iu,e,t)}string(t){let e=Vs(t);return e!==0?this.uint32(e)._push(Fn,e,t):this._push($n,1,0)}fork(){return this.states=new Yn(this),this.head=this.tail=new le(Wn,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 le(Wn,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=Au(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function $n(r,t,e){t[e]=r&255}function Bu(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Xn=class extends le{next;constructor(t,e){super(Bu,t,e),this.next=void 0}};function Sr(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 Ge(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 Iu(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Ze.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Tu,t,r),this},Ze.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Lu,t,r),this});function Tu(r,t,e){t.set(r,e)}function Lu(r,t,e){r.length<40?Fn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(vt(r),e)}function Qn(){return new Ze}function vr(r,t){let e=Qn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Le;(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"})(Le||(Le={}));function Ar(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Jn(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 Ar("enum",Le.VARINT,e,n)}function Br(r,t){return Ar("message",Le.LENGTH_DELIMITED,r,t)}var St;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(St||(St={}));var to;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(to||(to={}));(function(r){r.codec=()=>Jn(to)})(St||(St={}));var We;(function(r){let t;r.codec=()=>(t==null&&(t=Br((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),St.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=St.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>vr(e,r.codec()),r.decode=(e,n)=>Er(e,r.codec(),n)})(We||(We={}));var eo;(function(r){let t;r.codec=()=>(t==null&&(t=Br((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),St.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=St.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>vr(e,r.codec()),r.decode=(e,n)=>Er(e,r.codec(),n)})(eo||(eo={}));var $e=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var Pu=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]),Yt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Xt=new Uint32Array(64),ro=class extends Be{constructor(){super(64,32,8,!1),this.A=Yt[0]|0,this.B=Yt[1]|0,this.C=Yt[2]|0,this.D=Yt[3]|0,this.E=Yt[4]|0,this.F=Yt[5]|0,this.G=Yt[6]|0,this.H=Yt[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 f=0;f<16;f++,e+=4)Xt[f]=t.getUint32(e,!1);for(let f=16;f<64;f++){let p=Xt[f-15],b=Xt[f-2],w=Bt(p,7)^Bt(p,18)^p>>>3,y=Bt(b,17)^Bt(b,19)^b>>>10;Xt[f]=y+Xt[f-7]+w+Xt[f-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:l,H:u}=this;for(let f=0;f<64;f++){let p=Bt(c,6)^Bt(c,11)^Bt(c,25),b=u+p+ms(c,a,l)+Pu[f]+Xt[f]|0,y=(Bt(n,2)^Bt(n,13)^Bt(n,22))+gs(n,o,s)|0;u=l,l=a,a=c,c=i+b|0,i=s,s=o,o=n,n=b+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,l=l+this.G|0,u=u+this.H|0,this.set(n,o,s,i,c,a,l,u)}roundClean(){Xt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var js=cr(()=>new ro);var Ir=class extends Ae{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,hs(t);let n=Ve(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 ve(this),this.iHash.update(t),this}digestInto(t){ve(this),Se(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()}},no=(r,t,e)=>new Ir(r,t).update(e).digest();no.create=(r,t)=>new Ir(r,t);function Gs(r){r.lowS!==void 0&&It("lowS",r.lowS),r.prehash!==void 0&&It("prehash",r.prehash)}function Uu(r){let t=je(r);Ut(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:Du,hexToBytes:_u}=hr,oo=class extends Error{constructor(t=""){super(t)}},Ht={Err:oo,_tlv:{encode:(r,t)=>{let{Err:e}=Ht;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}=Ht,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 l=t.subarray(n,n+a);if(l.length!==a)throw new e("tlv.decode: length bytes not complete");if(l[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of l)i=i<<8|u;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Ht;if(r<qt)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}=Ht;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 Du(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Ht,o=typeof r=="string"?_u(r):r;Ie(o);let{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:l,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(l)}},hexFromSig(r){let{_tlv:t,_int:e}=Ht,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},qt=BigInt(0),it=BigInt(1),sp=BigInt(2),Zs=BigInt(3),ip=BigInt(4);function Ru(r){let t=Uu(r),{Fp:e}=t,n=Wt(t.n,t.nBitLength),o=t.toBytes||((y,h,E)=>{let A=h.toAffine();return Mt(Uint8Array.from([4]),e.toBytes(A.x),e.toBytes(A.y))}),s=t.fromBytes||(y=>{let h=y.subarray(1),E=e.fromBytes(h.subarray(0,e.BYTES)),A=e.fromBytes(h.subarray(e.BYTES,2*e.BYTES));return{x:E,y:A}});function i(y){let{a:h,b:E}=t,A=e.sqr(y),m=e.mul(A,y);return e.add(e.add(m,e.mul(y,h)),E)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function c(y){return ze(y,it,t.n)}function a(y){let{allowedPrivateKeyLengths:h,nByteLength:E,wrapPrivateKey:A,n:m}=t;if(h&&typeof y!="bigint"){if(jt(y)&&(y=kt(y)),typeof y!="string"||!h.includes(y.length))throw new Error("invalid private key");y=y.padStart(E*2,"0")}let I;try{I=typeof y=="bigint"?y:Ot(Q("private key",y,E))}catch{throw new Error("invalid private key, expected hex or "+E+" bytes, got "+typeof y)}return A&&(I=F(I,m)),mt("private key",I,it,m),I}function l(y){if(!(y instanceof p))throw new Error("ProjectivePoint expected")}let u=ce((y,h)=>{let{px:E,py:A,pz:m}=y;if(e.eql(m,e.ONE))return{x:E,y:A};let I=y.is0();h==null&&(h=I?e.ONE:e.inv(m));let _=e.mul(E,h),U=e.mul(A,h),T=e.mul(m,h);if(I)return{x:e.ZERO,y:e.ZERO};if(!e.eql(T,e.ONE))throw new Error("invZ was invalid");return{x:_,y:U}}),f=ce(y=>{if(y.is0()){if(t.allowInfinityPoint&&!e.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:h,y:E}=y.toAffine();if(!e.isValid(h)||!e.isValid(E))throw new Error("bad point: x or y not FE");let A=e.sqr(E),m=i(h);if(!e.eql(A,m))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class p{constructor(h,E,A){if(this.px=h,this.py=E,this.pz=A,h==null||!e.isValid(h))throw new Error("x required");if(E==null||!e.isValid(E))throw new Error("y required");if(A==null||!e.isValid(A))throw new Error("z required");Object.freeze(this)}static fromAffine(h){let{x:E,y:A}=h||{};if(!h||!e.isValid(E)||!e.isValid(A))throw new Error("invalid affine point");if(h instanceof p)throw new Error("projective point not allowed");let m=I=>e.eql(I,e.ZERO);return m(E)&&m(A)?p.ZERO:new p(E,A,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let E=e.invertBatch(h.map(A=>A.pz));return h.map((A,m)=>A.toAffine(E[m])).map(p.fromAffine)}static fromHex(h){let E=p.fromAffine(s(Q("pointHex",h)));return E.assertValidity(),E}static fromPrivateKey(h){return p.BASE.multiply(a(h))}static msm(h,E){return gr(p,n,h,E)}_setWindowSize(h){w.setWindowSize(this,h)}assertValidity(){f(this)}hasEvenY(){let{y:h}=this.toAffine();if(e.isOdd)return!e.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){l(h);let{px:E,py:A,pz:m}=this,{px:I,py:_,pz:U}=h,T=e.eql(e.mul(E,U),e.mul(I,m)),P=e.eql(e.mul(A,U),e.mul(_,m));return T&&P}negate(){return new p(this.px,e.neg(this.py),this.pz)}double(){let{a:h,b:E}=t,A=e.mul(E,Zs),{px:m,py:I,pz:_}=this,U=e.ZERO,T=e.ZERO,P=e.ZERO,L=e.mul(m,m),W=e.mul(I,I),q=e.mul(_,_),M=e.mul(m,I);return M=e.add(M,M),P=e.mul(m,_),P=e.add(P,P),U=e.mul(h,P),T=e.mul(A,q),T=e.add(U,T),U=e.sub(W,T),T=e.add(W,T),T=e.mul(U,T),U=e.mul(M,U),P=e.mul(A,P),q=e.mul(h,q),M=e.sub(L,q),M=e.mul(h,M),M=e.add(M,P),P=e.add(L,L),L=e.add(P,L),L=e.add(L,q),L=e.mul(L,M),T=e.add(T,L),q=e.mul(I,_),q=e.add(q,q),L=e.mul(q,M),U=e.sub(U,L),P=e.mul(q,W),P=e.add(P,P),P=e.add(P,P),new p(U,T,P)}add(h){l(h);let{px:E,py:A,pz:m}=this,{px:I,py:_,pz:U}=h,T=e.ZERO,P=e.ZERO,L=e.ZERO,W=t.a,q=e.mul(t.b,Zs),M=e.mul(E,I),et=e.mul(A,_),v=e.mul(m,U),C=e.add(E,A),g=e.add(I,_);C=e.mul(C,g),g=e.add(M,et),C=e.sub(C,g),g=e.add(E,m);let d=e.add(I,U);return g=e.mul(g,d),d=e.add(M,v),g=e.sub(g,d),d=e.add(A,m),T=e.add(_,U),d=e.mul(d,T),T=e.add(et,v),d=e.sub(d,T),L=e.mul(W,g),T=e.mul(q,v),L=e.add(T,L),T=e.sub(et,L),L=e.add(et,L),P=e.mul(T,L),et=e.add(M,M),et=e.add(et,M),v=e.mul(W,v),g=e.mul(q,g),et=e.add(et,v),v=e.sub(M,v),v=e.mul(W,v),g=e.add(g,v),M=e.mul(et,g),P=e.add(P,M),M=e.mul(d,g),T=e.mul(C,T),T=e.sub(T,M),M=e.mul(C,et),L=e.mul(d,L),L=e.add(L,M),new p(T,P,L)}subtract(h){return this.add(h.negate())}is0(){return this.equals(p.ZERO)}wNAF(h){return w.wNAFCached(this,h,p.normalizeZ)}multiplyUnsafe(h){let{endo:E,n:A}=t;mt("scalar",h,qt,A);let m=p.ZERO;if(h===qt)return m;if(this.is0()||h===it)return this;if(!E||w.hasPrecomputes(this))return w.wNAFCachedUnsafe(this,h,p.normalizeZ);let{k1neg:I,k1:_,k2neg:U,k2:T}=E.splitScalar(h),P=m,L=m,W=this;for(;_>qt||T>qt;)_&it&&(P=P.add(W)),T&it&&(L=L.add(W)),W=W.double(),_>>=it,T>>=it;return I&&(P=P.negate()),U&&(L=L.negate()),L=new p(e.mul(L.px,E.beta),L.py,L.pz),P.add(L)}multiply(h){let{endo:E,n:A}=t;mt("scalar",h,it,A);let m,I;if(E){let{k1neg:_,k1:U,k2neg:T,k2:P}=E.splitScalar(h),{p:L,f:W}=this.wNAF(U),{p:q,f:M}=this.wNAF(P);L=w.constTimeNegate(_,L),q=w.constTimeNegate(T,q),q=new p(e.mul(q.px,E.beta),q.py,q.pz),m=L.add(q),I=W.add(M)}else{let{p:_,f:U}=this.wNAF(h);m=_,I=U}return p.normalizeZ([m,I])[0]}multiplyAndAddUnsafe(h,E,A){let m=p.BASE,I=(U,T)=>T===qt||T===it||!U.equals(m)?U.multiplyUnsafe(T):U.multiply(T),_=I(this,E).add(I(h,A));return _.is0()?void 0:_}toAffine(h){return u(this,h)}isTorsionFree(){let{h,isTorsionFree:E}=t;if(h===it)return!0;if(E)return E(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:E}=t;return h===it?this:E?E(p,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return It("isCompressed",h),this.assertValidity(),o(p,this,h)}toHex(h=!0){return It("isCompressed",h),kt(this.toRawBytes(h))}}p.BASE=new p(t.Gx,t.Gy,e.ONE),p.ZERO=new p(e.ZERO,e.ONE,e.ZERO);let b=t.nBitLength,w=mr(p,t.endo?Math.ceil(b/2):b);return{CURVE:t,ProjectivePoint:p,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:c}}function Nu(r){let t=je(r);return Ut(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Ws(r){let t=Nu(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(v){return F(v,n)}function c(v){return dr(v,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=Ru({...t,toBytes(v,C,g){let d=C.toAffine(),x=e.toBytes(d.x),B=Mt;return It("isCompressed",g),g?B(Uint8Array.from([C.hasEvenY()?2:3]),x):B(Uint8Array.from([4]),x,e.toBytes(d.y))},fromBytes(v){let C=v.length,g=v[0],d=v.subarray(1);if(C===o&&(g===2||g===3)){let x=Ot(d);if(!ze(x,it,e.ORDER))throw new Error("Point is not on curve");let B=u(x),R;try{R=e.sqrt(B)}catch(H){let K=H instanceof Error?": "+H.message:"";throw new Error("Point is not on curve"+K)}let N=(R&it)===it;return(g&1)===1!==N&&(R=e.neg(R)),{x,y:R}}else if(C===s&&g===4){let x=e.fromBytes(d.subarray(0,e.BYTES)),B=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x,y:B}}else{let x=o,B=s;throw new Error("invalid Point, expected length of "+x+", or uncompressed "+B+", got "+C)}}}),p=v=>kt(Zt(v,t.nByteLength));function b(v){let C=n>>it;return v>C}function w(v){return b(v)?i(-v):v}let y=(v,C,g)=>Ot(v.slice(C,g));class h{constructor(C,g,d){this.r=C,this.s=g,this.recovery=d,this.assertValidity()}static fromCompact(C){let g=t.nByteLength;return C=Q("compactSignature",C,g*2),new h(y(C,0,g),y(C,g,2*g))}static fromDER(C){let{r:g,s:d}=Ht.toSig(Q("DER",C));return new h(g,d)}assertValidity(){mt("r",this.r,it,n),mt("s",this.s,it,n)}addRecoveryBit(C){return new h(this.r,this.s,C)}recoverPublicKey(C){let{r:g,s:d,recovery:x}=this,B=U(Q("msgHash",C));if(x==null||![0,1,2,3].includes(x))throw new Error("recovery id invalid");let R=x===2||x===3?g+t.n:g;if(R>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let N=(x&1)===0?"02":"03",O=a.fromHex(N+p(R)),H=c(R),K=i(-B*H),z=i(d*H),Z=a.BASE.multiplyAndAddUnsafe(O,K,z);if(!Z)throw new Error("point at infinify");return Z.assertValidity(),Z}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return se(this.toDERHex())}toDERHex(){return Ht.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return se(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let E={isValidPrivateKey(v){try{return l(v),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let v=Cn(t.n);return Bs(t.randomBytes(v),t.n)},precompute(v=8,C=a.BASE){return C._setWindowSize(v),C.multiply(BigInt(3)),C}};function A(v,C=!0){return a.fromPrivateKey(v).toRawBytes(C)}function m(v){let C=jt(v),g=typeof v=="string",d=(C||g)&&v.length;return C?d===o||d===s:g?d===2*o||d===2*s:v instanceof a}function I(v,C,g=!0){if(m(v))throw new Error("first arg must be private key");if(!m(C))throw new Error("second arg must be public key");return a.fromHex(C).multiply(l(v)).toRawBytes(g)}let _=t.bits2int||function(v){if(v.length>8192)throw new Error("input is too large");let C=Ot(v),g=v.length*8-t.nBitLength;return g>0?C>>BigInt(g):C},U=t.bits2int_modN||function(v){return i(_(v))},T=Fe(t.nBitLength);function P(v){return mt("num < 2^"+t.nBitLength,v,qt,T),Zt(v,t.nByteLength)}function L(v,C,g=W){if(["recovered","canonical"].some(st=>st in g))throw new Error("sign() legacy options not supported");let{hash:d,randomBytes:x}=t,{lowS:B,prehash:R,extraEntropy:N}=g;B==null&&(B=!0),v=Q("msgHash",v),Gs(g),R&&(v=Q("prehashed msgHash",d(v)));let O=U(v),H=l(C),K=[P(H),P(O)];if(N!=null&&N!==!1){let st=N===!0?x(e.BYTES):N;K.push(Q("extraEntropy",st))}let z=Mt(...K),Z=O;function ot(st){let ct=_(st);if(!f(ct))return;let at=c(ct),ht=a.BASE.multiply(ct).toAffine(),lt=i(ht.x);if(lt===qt)return;let Ct=i(at*i(Z+lt*H));if(Ct===qt)return;let Dt=(ht.x===lt?0:2)|Number(ht.y&it),De=Ct;return B&&b(Ct)&&(De=w(Ct),Dt^=1),new h(lt,De,Dt)}return{seed:z,k2sig:ot}}let W={lowS:t.lowS,prehash:!1},q={lowS:t.lowS,prehash:!1};function M(v,C,g=W){let{seed:d,k2sig:x}=L(v,C,g),B=t;return Bn(B.hash.outputLen,B.nByteLength,B.hmac)(d,x)}a.BASE._setWindowSize(8);function et(v,C,g,d=q){let x=v;C=Q("msgHash",C),g=Q("publicKey",g);let{lowS:B,prehash:R,format:N}=d;if(Gs(d),"strict"in d)throw new Error("options.strict was renamed to lowS");if(N!==void 0&&N!=="compact"&&N!=="der")throw new Error("format must be compact or der");let O=typeof x=="string"||jt(x),H=!O&&!N&&typeof x=="object"&&x!==null&&typeof x.r=="bigint"&&typeof x.s=="bigint";if(!O&&!H)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let K,z;try{if(H&&(K=new h(x.r,x.s)),O){try{N!=="compact"&&(K=h.fromDER(x))}catch(Dt){if(!(Dt instanceof Ht.Err))throw Dt}!K&&N!=="der"&&(K=h.fromCompact(x))}z=a.fromHex(g)}catch{return!1}if(!K||B&&K.hasHighS())return!1;R&&(C=t.hash(C));let{r:Z,s:ot}=K,st=U(C),ct=c(ot),at=i(st*ct),ht=i(Z*ct),lt=a.BASE.multiplyAndAddUnsafe(z,at,ht)?.toAffine();return lt?i(lt.x)===Z:!1}return{CURVE:t,getPublicKey:A,getSharedSecret:I,sign:M,verify:et,ProjectivePoint:a,Signature:h,utils:E}}function Ku(r){return{hash:r,hmac:(t,...e)=>no(r,t,xn(...e)),randomBytes:ar}}function $s(r,t){let e=n=>Ws({...r,...Ku(n)});return{...e(t),create:e}}var Qs=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ys=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ku=BigInt(1),so=BigInt(2),Xs=(r,t)=>(r+t/so)/t;function Ou(r){let t=Qs,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),l=r*r*r%t,u=l*l*r%t,f=X(u,e,t)*u%t,p=X(f,e,t)*u%t,b=X(p,so,t)*l%t,w=X(b,o,t)*b%t,y=X(w,s,t)*w%t,h=X(y,c,t)*y%t,E=X(h,a,t)*h%t,A=X(E,c,t)*y%t,m=X(A,e,t)*u%t,I=X(m,i,t)*w%t,_=X(I,n,t)*l%t,U=X(_,so,t);if(!io.eql(io.sqr(U),r))throw new Error("Cannot find square root");return U}var io=Wt(Qs,void 0,void 0,{sqrt:Ou}),he=$s({a:BigInt(0),b:BigInt(7),Fp:io,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=-ku*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=Xs(s*r,t),a=Xs(-n*r,t),l=F(r-c*e-a*o,t),u=F(-c*n-a*s,t),f=l>i,p=u>i;if(f&&(l=t-l),p&&(u=t-u),l>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:f,k1:l,k2neg:p,k2:u}}}},js),mp=BigInt(0);var gp=he.ProjectivePoint;function Js(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function ti(r,t,e){let n=Oe.digest(e instanceof Uint8Array?e:e.subarray());if(Js(n))return n.then(({digest:o})=>he.verify(t,o,r)).catch(o=>{throw new $e(String(o))});try{return he.verify(t,n.digest,r)}catch(o){throw new $e(String(o))}}var Tr=class{type="secp256k1";raw;_key;constructor(t){this._key=ri(t),this.raw=ei(this._key)}toMultihash(){return At.digest(Ee(this))}toCID(){return rt.createV1(114,this.toMultihash())}toString(){return $.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:xt(this.raw,t.raw)}verify(t,e){return ti(this._key,e,t)}};function ni(r){return new Tr(r)}function ei(r){return he.ProjectivePoint.fromHex(r).toRawBytes(!0)}function ri(r){try{return he.ProjectivePoint.fromHex(r),r}catch(t){throw new Qe(String(t))}}function oi(r){let{Type:t,Data:e}=We.decode(r.digest),n=e??new Uint8Array;switch(t){case St.Ed25519:return Ns(n);case St.secp256k1:return ni(n);case St.ECDSA:return as(n);default:throw new _e}}function Ee(r){return We.encode({Type:St[r.type],Data:r.raw})}var si=Symbol.for("nodejs.util.inspect.custom"),Mu=114,Ye=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[zr]=!0;toString(){return this.string==null&&(this.string=$.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return rt.createV1(Mu,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return xt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return xt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[si](){return`PeerId(${this.toString()})`}},Lr=class extends Ye{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Cr=class extends Ye{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Pr=class extends Ye{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Hu=2336,Xe=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=At.digest(vt(this.url))}[si](){return`PeerId(${this.url})`}[zr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return rt.createV1(Hu,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=j(t)),t.toString()===this.toString())}};var qu=114,ii=2336;function ci(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=ee($.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return Vu(rt.parse(r));if(t==null)throw new Pt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=ee(t.decode(r))}return ai(e)}function ai(r){if(Fu(r))return new Lr({multihash:r});if(zu(r))try{let t=oi(r);if(t.type==="Ed25519")return new Cr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Pr({multihash:r,publicKey:t})}catch{let e=j(r.digest);return new Xe(new URL(e))}throw new tr("Supplied PeerID Multihash is invalid")}function Vu(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==qu&&r.code!==ii)throw new Je("Supplied PeerID CID is invalid");if(r.code===ii){let t=j(r.multihash.digest);return new Xe(new URL(t))}return ai(r.multihash)}function zu(r){return r.code===At.code}function Fu(r){return r.code===Oe.code}var Ur=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,i=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",l=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let p=Number.parseInt(f,t);if(!Number.isNaN(p))return p});if(u===void 0)break;if(s*=t,s+=u,s>l||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&a&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[o]=i[0],e[o+1]=i[1],e[o+2]=i[2],e[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[c]=t(s.subarray(0,i));return e.set(s.subarray(0,c),16-c),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var ui=45,ju=15,Ce=new Ur;function co(r){if(!(r.length>ju))return Ce.new(r).parseWith(()=>Ce.readIPv4Addr())}function ao(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>ui))return Ce.new(r).parseWith(()=>Ce.readIPv6Addr())}function Dr(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>ui)return;let e=Ce.new(r).parseWith(()=>Ce.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}var C0=parseInt("0xFFFF",16),P0=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function hi(r){return!!co(r)}function di(r){return!!ao(r)}function _r(r){return!!Dr(r)}var pi=hi,Yu=di,uo=function(r){let t=0;if(r=r.toString().trim(),pi(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Yu(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=pi(e[n]),i;s&&(i=uo(e[n]),e[n]=j(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,j(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},mi=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Pe={},fo={},Qu=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];Qu.forEach(r=>{let t=Ju(...r);fo[t.code]=t,Pe[t.name]=t});function Ju(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function G(r){if(typeof r=="number"){if(fo[r]!=null)return fo[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Pe[r]!=null)return Pe[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var dm=G("ip4"),pm=G("ip6"),mm=G("ipcidr");function mo(r,t){switch(G(r).code){case 4:case 41:return ef(t);case 42:return po(t);case 43:return j(t,"base10");case 6:case 273:case 33:case 132:return xi(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return po(t);case 421:return sf(t);case 444:return yi(t);case 445:return yi(t);case 466:return of(t);case 481:return globalThis.encodeURIComponent(po(t));default:return j(t,"base16")}}function go(r,t){switch(G(r).code){case 4:return gi(t);case 41:return gi(t);case 42:return ho(t);case 43:return vt(t,"base10");case 6:case 273:case 33:case 132:return yo(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ho(t);case 421:return rf(t);case 444:return cf(t);case 445:return af(t);case 466:return nf(t);case 481:return ho(globalThis.decodeURIComponent(t));default:return vt(t,"base16")}}var lo=Object.values(Me).map(r=>r.decoder),tf=function(){let r=lo[0].or(lo[1]);return lo.slice(2).forEach(t=>r=r.or(t)),r}();function gi(r){if(!_r(r))throw new Error("invalid ip address");return uo(r)}function ef(r){let t=mi(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!_r(t))throw new Error("invalid ip address");return t}function yo(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function xi(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function ho(r){let t=vt(r),e=Uint8Array.from(Te(t.length));return bt([e,t],e.length+t.length)}function po(r){let t=ue(r);if(r=r.slice(yt(t)),r.length!==t)throw new Error("inconsistent lengths");return j(r)}function rf(r){let t;r[0]==="Q"||r[0]==="1"?t=ee($.decode(`z${r}`)).bytes:t=rt.parse(r).multihash.bytes;let e=Uint8Array.from(Te(t.length));return bt([e,t],e.length+t.length)}function nf(r){let t=tf.decode(r),e=Uint8Array.from(Te(t.length));return bt([e,t],e.length+t.length)}function of(r){let t=ue(r),e=r.slice(yt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+j(e,"base64url")}function sf(r){let t=ue(r),e=r.slice(yt(t));if(e.length!==t)throw new Error("inconsistent lengths");return j(e,"base58btc")}function cf(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Rt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=yo(n);return bt([e,o],e.length+o.length)}function af(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Rt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=yo(n);return bt([e,o],e.length+o.length)}function yi(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=j(t,"base32"),o=xi(e);return`${n}:${o}`}function bi(r){r=xo(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],c=G(i);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(s++,s>=o.length)throw new Rr("invalid address: "+r);if(c.path===!0){n=xo(o.slice(s).join("/")),t.push([c.code,go(c.code,n)]),e.push([c.code,n]);break}let a=go(c.code,o[s]);t.push([c.code,a]),e.push([c.code,mo(c.code,a)])}return{string:wi(e),bytes:Nr(t),tuples:t,stringTuples:e,path:n}}function bo(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=ue(r,o),i=yt(s),c=G(s),a=uf(c,r.slice(o+i));if(a===0){t.push([s]),e.push([s]),o+=i;continue}let l=r.slice(o+i,o+i+a);if(o+=a+i,o>r.length)throw new Rr("Invalid address Uint8Array: "+j(r,"base16"));t.push([s,l]);let u=mo(s,l);if(e.push([s,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:wi(e),tuples:t,stringTuples:e,path:n}}function wi(r){let t=[];return r.map(e=>{let n=G(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),xo(t.join("/"))}function Nr(r){return bt(r.map(t=>{let e=G(t[0]),n=Uint8Array.from(Te(e.code));return t.length>1&&t[1]!=null&&(n=bt([n,t[1]])),n}))}function uf(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=ue(t instanceof Uint8Array?t:Uint8Array.from(t));return e+yt(e)}}function xo(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var Rr=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var ff=Symbol.for("nodejs.util.inspect.custom"),Eo=Symbol.for("@multiformats/js-multiaddr/multiaddr"),lf=[G("dns").code,G("dns4").code,G("dns6").code,G("dnsaddr").code],wo=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Kr=class r{bytes;#t;#e;#r;#n;[Eo]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=bo(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=bi(t)}else if(Si(t))e=bo(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",i=G("tcp"),c=G("udp"),a=G("ip4"),l=G("ip6"),u=G("dns6"),f=G("ip6zone");for(let[b,w]of this.stringTuples())b===f.code&&(s=`%${w??""}`),lf.includes(b)&&(e=i.name==="tcp"?"tcp":"udp",o=443,n=`${w??""}${s}`,t=b===u.code?6:4),(b===i.code||b===c.code)&&(e=G(b).name==="tcp"?"tcp":"udp",o=parseInt(w??"")),(b===a.code||b===l.code)&&(e=G(b).name==="tcp"?"tcp":"udp",n=`${w??""}${s}`,t=b===l.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},G(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>G(t).name)}tuples(){return this.#e.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(Nr(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===Pe.p2p.code&&t.push([n,o]),n===Pe["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?j($.decode(`z${n}`),"base58btc"):j(rt.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return xt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=Ei.get(e.name);if(n==null)throw new wo(`no available resolver for ${e.name}`);return(await n(this,t)).map(s=>Qt(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[ff](){return`Multiaddr(${this.#t})`}};var Ei=new Map;function Si(r){return!!r?.[Eo]}function Qt(r){return new Kr(r)}var hf=S("dns4"),df=S("dns6"),pf=S("dnsaddr"),pe=tt(S("dns"),pf,hf,df),Mr=tt(S("ip4"),S("ip6")),Ue=tt(D(Mr,S("tcp")),D(pe,S("tcp"))),Hr=D(Mr,S("udp")),mf=D(Hr,S("utp")),gf=D(Hr,S("quic")),yf=D(Hr,S("quic-v1")),So=tt(D(Ue,S("ws")),D(pe,S("ws"))),kr=tt(D(So,S("p2p")),So),vo=tt(D(Ue,S("wss")),D(pe,S("wss")),D(Ue,S("tls"),S("ws")),D(pe,S("tls"),S("ws"))),Or=tt(D(vo,S("p2p")),vo),Ao=tt(D(Ue,S("http")),D(Mr,S("http")),D(pe,S("http"))),Bo=tt(D(Ue,S("https")),D(Mr,S("https")),D(pe,S("https"))),vi=D(Hr,S("webrtc-direct"),S("certhash")),Ii=tt(D(vi,S("p2p")),vi),Ai=D(yf,S("webtransport"),S("certhash"),S("certhash")),Ti=tt(D(Ai,S("p2p")),Ai),Li=tt(D(kr,S("p2p-webrtc-star"),S("p2p")),D(Or,S("p2p-webrtc-star"),S("p2p")),D(kr,S("p2p-webrtc-star")),D(Or,S("p2p-webrtc-star"))),Vm=tt(D(kr,S("p2p-websocket-star"),S("p2p")),D(Or,S("p2p-websocket-star"),S("p2p")),D(kr,S("p2p-websocket-star")),D(Or,S("p2p-websocket-star"))),Ci=tt(D(Ao,S("p2p-webrtc-direct"),S("p2p")),D(Bo,S("p2p-webrtc-direct"),S("p2p")),D(Ao,S("p2p-webrtc-direct")),D(Bo,S("p2p-webrtc-direct"))),me=tt(So,vo,Ao,Bo,Li,Ci,Ue,mf,gf,pe,Ii,Ti),zm=tt(D(me,S("p2p-stardust"),S("p2p")),D(me,S("p2p-stardust"))),Jt=tt(D(me,S("p2p")),Li,Ci,Ii,Ti,S("p2p")),Bi=tt(D(Jt,S("p2p-circuit"),Jt),D(Jt,S("p2p-circuit")),D(S("p2p-circuit"),Jt),D(me,S("p2p-circuit")),D(S("p2p-circuit"),me),S("p2p-circuit")),Pi=()=>tt(D(Bi,Pi),Bi),de=Pi(),Ui=tt(D(de,Jt,de),D(Jt,de),D(de,Jt),de,Jt);var Fm=tt(D(de,S("webrtc"),S("p2p")),D(de,S("webrtc")),D(me,S("webrtc"),S("p2p")),D(me,S("webrtc")),S("webrtc"));function Di(r){function t(e){let n;try{n=Qt(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function D(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(o=>(n=typeof o=="function"?o().partialMatch(e):o.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Di(t),partialMatch:t}}function tt(...r){function t(n){let o=null;return r.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Di(t),partialMatch:t}}function S(r){let t=r;function e(o){let s;try{s=Qt(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var xf="bootstrap",bf=50,wf=1e3,Io=class extends er{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(t,e={list:[]}){if(e.list==null||e.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super(),this.components=t,this.log=t.logger.forComponent("libp2p:bootstrap"),this.timeout=e.timeout??wf,this.list=[];for(let n of e.list){if(!Ui.matches(n)){this.log.error("Invalid multiaddr");continue}let o=Qt(n),s=o.getPeerId();if(s==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let i={id:ci(s),multiaddrs:[o]};this.list.push(i)}this._init=e}[Ro]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[No]=["@libp2p/peer-discovery"];isStarted(){return!!this.timer}start(){this.isStarted()||(this.log("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(t=>{this.log.error(t)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(let t of this.list){if(await this.components.peerStore.merge(t.id,{tags:{[this._init.tagName??xf]:{value:this._init.tagValue??bf,ttl:this._init.tagTTL}},multiaddrs:t.multiaddrs}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t}),this.components.connectionManager.openConnection(t.id).catch(e=>{this.log.error("could not dial bootstrap peer %p",t.id,e)})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function Ef(r){return t=>new Io(t,r)}return ji(Sf);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/hashes/esm/utils.js:
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"BootstrapComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapComponents.html",
|
|
3
|
+
".:BootstrapComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapComponents.html",
|
|
4
|
+
"BootstrapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapInit.html",
|
|
5
|
+
".:BootstrapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapInit.html",
|
|
6
|
+
"bootstrap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_bootstrap.bootstrap.html",
|
|
7
|
+
".:bootstrap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_bootstrap.bootstrap.html"
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/bootstrap",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.33",
|
|
4
4
|
"description": "Peer discovery via a list of bootstrap peers",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap#readme",
|
|
@@ -54,15 +54,15 @@
|
|
|
54
54
|
"test:electron-main": "aegir test -t electron-main"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@libp2p/interface": "2.
|
|
58
|
-
"@libp2p/interface-internal": "2.3.
|
|
59
|
-
"@libp2p/peer-id": "5.1.
|
|
57
|
+
"@libp2p/interface": "^2.8.0",
|
|
58
|
+
"@libp2p/interface-internal": "^2.3.10",
|
|
59
|
+
"@libp2p/peer-id": "^5.1.1",
|
|
60
60
|
"@multiformats/mafmt": "^12.1.6",
|
|
61
61
|
"@multiformats/multiaddr": "^12.3.3"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@libp2p/interface-compliance-tests": "6.4.
|
|
65
|
-
"@libp2p/logger": "5.1.
|
|
64
|
+
"@libp2p/interface-compliance-tests": "^6.4.3",
|
|
65
|
+
"@libp2p/logger": "^5.1.14",
|
|
66
66
|
"aegir": "^45.1.1",
|
|
67
67
|
"sinon-ts": "^2.0.0"
|
|
68
68
|
},
|