@helia/ipns 9.1.8 → 9.1.9-12fd8522

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaIpns = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var HeliaIpns=(()=>{var vf=Object.create;var dn=Object.defineProperty;var Af=Object.getOwnPropertyDescriptor;var If=Object.getOwnPropertyNames;var Tf=Object.getPrototypeOf,Bf=Object.prototype.hasOwnProperty;var Cf=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),xe=(t,e)=>{for(var r in e)dn(t,r,{get:e[r],enumerable:!0})},Ds=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of If(e))!Bf.call(t,o)&&o!==r&&dn(t,o,{get:()=>e[o],enumerable:!(n=Af(e,o))||n.enumerable});return t};var Do=(t,e,r)=>(r=t!=null?vf(Tf(t)):{},Ds(e||!t||!t.__esModule?dn(r,"default",{value:t,enumerable:!0}):r,t)),_f=t=>Ds(dn({},"__esModule",{value:!0}),t);var qn=Cf((Wg,cs)=>{var Xg=(function(){typeof cs<"u"&&(cs.exports=T);var t=86400,e=3200,r=146097*e/400,n=t*r,o=1e3*n,i=864e13,s=4294967296,c=1e6,a="000000000",f=Math.trunc||function(p){var m=p-p%1;return m==0&&(p<0||p===0&&1/p!=1/0)?-0:m},u=T.prototype,l=(T.fromDate=function(p){return new T(+p)},T.fromInt64BE=U(0,1,2,3,0,4),T.fromInt64LE=U(3,2,1,0,4,0),T.fromString=function(R){var m,_=new T,R=(R+="").replace(/^\s*[+\-]?\d+/,function(y){var y=+y,b=1970+(y-1970)%400;return _.year=y-b,b}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(I,y,b){return y<0&&(b*=-1),m=6e4*(60*+y+ +b),""}).replace(/\.\d+$/,function(I){return _.nano=+(I+a).substr(1,9),""}).split(/\D+/);if(1<R.length?R[1]--:R[1]=0,_.time=m=Date.UTC.apply(Date,R)-(m||0),isNaN(m))throw new TypeError("Invalid Date");return E(_)},T.fromTimeT=function(p){return B(p,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(p){return this.nano+=+p||0,this},u.getNano=function(){var p=E(this);return(p.time%1e3*c+ +p.nano+1e9)%1e9},u.getTimeT=function(){var m=E(this),p=Math.floor(m.time/1e3),m=m.year;return m&&(p+=m*r*t/e),p},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return w(E(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(p){var m=this,_=m.toDate(),R={H:function(){return F(_.getUTCHours())},L:function(){return M(_.getUTCMilliseconds(),3)},M:function(){return F(_.getUTCMinutes())},N:function(){return M(m.getNano(),9)},S:function(){return F(_.getUTCSeconds())},Y:function(){var I=m.getYear();return 999999<I?"+"+I:9999<I?"+"+M(I,6):0<=I?M(I,4):-999999<=I?"-"+M(-I,6):I},a:function(){return S[_.getUTCDay()]},b:function(){return g[_.getUTCMonth()]},d:function(){return F(_.getUTCDate())},e:function(){return(function(I){return(9<I?"":" ")+(0|I)})(_.getUTCDate())},m:function(){return F(_.getUTCMonth()+1)}};return(function I(y){return y.replace(/%./g,function(b){var A=b[1],d=x[A],A=R[A];return d?I(d):A?A():b})})(p||l)},u.writeInt64BE=v(0,1,2,3,0,4),u.writeInt64LE=v(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),g=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],S=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],x={"%":"%",F:"%Y-%m-%d",n:`
3
- `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return T;function T(p,m,_){var R=this;if(!(R instanceof T))return new T(p,m,_);R.time=+p||0,R.nano=+m||0,R.year=+_||0,E(R)}function E(p){var m,_,R,I=p.year,y=p.time,b=p.nano,d=((b<0||c<=b)&&(b-=(_=Math.floor(b/c))*c,y+=_,_=1),I%e);return(y<-i||i<y||d)&&((m=f(y/o))&&(I+=m*e,y-=m*o),(R=w(y)).setUTCFullYear(d+R.getUTCFullYear()),R=(y=+R)+(m=f((I-=d)/e))*o,m&&-i<=R&&R<=i&&(I-=m*e,y=R),_=1),_&&(p.year=I,p.time=y,p.nano=b),p}function w(p){var m=new Date(0);return m.setTime(p),m}function B(I,R){I=+I||0;var _=f((R=(R|0)*s)/n)+f(I/n),R=R%n+I%n,I=f(R/n);return I&&(_+=I,R-=I*n),new T(1e3*R,0,_*e)}function v(p,m,_,R,I,y){return function(d,A){var N=E(this);d=d||new Array(8),P(d,A|=0);var k=Math.floor(N.time/1e3),N=N.year*(r*t/e),L=f(N/s)+f(k/s),N=N%s+k%s,k=Math.floor(N/s);return k&&(L+=k,N-=k*s),b(d,A+I,L),b(d,A+y,N),d};function b(d,A,L){d[A+p]=L>>24&255,d[A+m]=L>>16&255,d[A+_]=L>>8&255,d[A+R]=255&L}}function U(p,m,_,R,I,y){return function(d,A){P(d,A|=0);var L=b(d,A+I);return B(b(d,A+y),L)};function b(d,A){return 16777216*d[A+p]+(d[A+m]<<16|d[A+_]<<8|d[A+R])}}function P(p,m){if(p=p&&p.length,p==null)throw new TypeError("Invalid Buffer");if(p<m+8)throw new RangeError("Out of range")}function F(p){return(9<p?"":"0")+(0|p)}function M(p,m){return(a+(0|p)).substr(-m)}})()});var Cp={};xe(Cp,{ipns:()=>Tp,ipnsResolver:()=>Bp,ipnsSelector:()=>ho,ipnsValidator:()=>nn});var Je=class extends Error{static name="AbortError";constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var te=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},Vt=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}},gr=class extends Error{static name="InvalidPrivateKeyError";constructor(e="Invalid private key"){super(e),this.name="InvalidPrivateKeyError"}};var hn=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var qt=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};function Us(t){return t==null?!1:(t.type==="RSA"||t.type==="Ed25519"||t.type==="secp256k1"||t.type==="ECDSA")&&t.raw instanceof Uint8Array&&typeof t.equals=="function"&&typeof t.toMultihash=="function"&&typeof t.toCID=="function"&&typeof t.verify=="function"}var Rf=Symbol.for("@libp2p/peer-id");function pn(t){return!!t?.[Rf]}var mn=class extends EventTarget{#e=new Map;constructor(){super()}listenerCount(e){let r=this.#e.get(e);return r==null?0:r.length}addEventListener(e,r,n){super.addEventListener(e,r,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:r,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,r,n){super.removeEventListener(e.toString(),r??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:i})=>i!==r),this.#e.set(e,o))}dispatchEvent(e){let r=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),r}safeDispatchEvent(e,r={}){return this.dispatchEvent(new CustomEvent(e,r))}};var Po={};xe(Po,{base58btc:()=>X,base58flickr:()=>Pf});var Np=new Uint8Array(0);function Ns(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function Qe(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function ks(t){return new TextEncoder().encode(t)}function Ks(t){return new TextDecoder().decode(t)}function Lf(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var c=t.length,a=t.charAt(0),f=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function l(x){if(x instanceof Uint8Array||(ArrayBuffer.isView(x)?x=new Uint8Array(x.buffer,x.byteOffset,x.byteLength):Array.isArray(x)&&(x=Uint8Array.from(x))),!(x instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(x.length===0)return"";for(var T=0,E=0,w=0,B=x.length;w!==B&&x[w]===0;)w++,T++;for(var v=(B-w)*u+1>>>0,U=new Uint8Array(v);w!==B;){for(var P=x[w],F=0,M=v-1;(P!==0||F<E)&&M!==-1;M--,F++)P+=256*U[M]>>>0,U[M]=P%c>>>0,P=P/c>>>0;if(P!==0)throw new Error("Non-zero carry");E=F,w++}for(var p=v-E;p!==v&&U[p]===0;)p++;for(var m=a.repeat(T);p<v;++p)m+=t.charAt(U[p]);return m}function g(x){if(typeof x!="string")throw new TypeError("Expected String");if(x.length===0)return new Uint8Array;var T=0;if(x[T]!==" "){for(var E=0,w=0;x[T]===a;)E++,T++;for(var B=(x.length-T)*f+1>>>0,v=new Uint8Array(B);x[T];){var U=r[x.charCodeAt(T)];if(U===255)return;for(var P=0,F=B-1;(U!==0||P<w)&&F!==-1;F--,P++)U+=c*v[F]>>>0,v[F]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");w=P,T++}if(x[T]!==" "){for(var M=B-w;M!==B&&v[M]===0;)M++;for(var p=new Uint8Array(E+(B-M)),m=E;M!==B;)p[m++]=v[M++];return p}}}function S(x){var T=g(x);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:g,decode:S}}var Df=Lf,Uf=Df,Os=Uf;var Uo=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},No=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ms(this,e)}},ko=class{decoders;constructor(e){this.decoders=e}or(e){return Ms(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ms(t,e){return new ko({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var Ko=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Uo(e,r,n),this.decoder=new No(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Ht({name:t,prefix:e,encode:r,decode:n}){return new Ko(t,e,r,n)}function ft({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=Os(r,t);return Ht({prefix:e,name:t,encode:n,decode:i=>Qe(o(i))})}function Nf(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,c=0,a=0;for(let f=0;f<o;++f){let u=e[t[f]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|u,s+=r,s>=8&&(s-=8,i[a++]=255&c>>s)}if(s>=r||(255&c<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function kf(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,c=0;for(let a=0;a<t.length;++a)for(c=c<<8|t[a],s+=8;s>r;)s-=r,i+=e[o&c>>s];if(s!==0&&(i+=e[o&c<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function Kf(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function re({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=Kf(n);return Ht({prefix:e,name:t,encode(i){return kf(i,n,r)},decode(i){return Nf(i,o,r,t)}})}var X=ft({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Pf=ft({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Oo={};xe(Oo,{base32:()=>lt,base32hex:()=>Vf,base32hexpad:()=>Hf,base32hexpadupper:()=>$f,base32hexupper:()=>qf,base32pad:()=>Mf,base32padupper:()=>Ff,base32upper:()=>Of,base32z:()=>zf});var lt=re({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Of=re({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Mf=re({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ff=re({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Vf=re({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),qf=re({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Hf=re({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),$f=re({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),zf=re({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Mo={};xe(Mo,{base36:()=>Ne,base36upper:()=>jf});var Ne=ft({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),jf=ft({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Zf=qs,Fs=128,Yf=127,Gf=~Yf,Xf=Math.pow(2,31);function qs(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Xf;)e[r++]=t&255|Fs,t/=128;for(;t&Gf;)e[r++]=t&255|Fs,t>>>=7;return e[r]=t|0,qs.bytes=r-n+1,e}var Wf=Fo,Jf=128,Vs=127;function Fo(t,n){var r=0,n=n||0,o=0,i=n,s,c=t.length;do{if(i>=c)throw Fo.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&Vs)<<o:(s&Vs)*Math.pow(2,o),o+=7}while(s>=Jf);return Fo.bytes=i-n,r}var Qf=Math.pow(2,7),el=Math.pow(2,14),tl=Math.pow(2,21),rl=Math.pow(2,28),nl=Math.pow(2,35),ol=Math.pow(2,42),il=Math.pow(2,49),sl=Math.pow(2,56),al=Math.pow(2,63),cl=function(t){return t<Qf?1:t<el?2:t<tl?3:t<rl?4:t<nl?5:t<ol?6:t<il?7:t<sl?8:t<al?9:10},ul={encode:Zf,decode:Wf,encodingLength:cl},fl=ul,br=fl;function xr(t,e=0){return[br.decode(t,e),br.decode.bytes]}function $t(t,e,r=0){return br.encode(t,e,r),e}function zt(t){return br.encodingLength(t)}function He(t,e){let r=e.byteLength,n=zt(t),o=n+zt(r),i=new Uint8Array(o+r);return $t(t,i,0),$t(r,i,n),i.set(e,o),new jt(t,r,e,i)}function Zt(t){let e=Qe(t),[r,n]=xr(e),[o,i]=xr(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new jt(r,o,s,e)}function Hs(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Ns(t.bytes,r.bytes)}}var jt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function $s(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return dl(r,Vo(t),e??X.encoder);default:return hl(r,Vo(t),e??lt.encoder)}}var zs=new WeakMap;function Vo(t){let e=zs.get(t);if(e==null){let r=new Map;return zs.set(t,r),r}return e}var se=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,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:e,multihash:r}=this;if(e!==wr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==pl)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=He(e,r);return t.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(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&Hs(e.multihash,n.multihash)}toString(e){return $s(this,e)}toJSON(){return{"/":$s(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new t(n,o,i,s??js(n,o,i.bytes))}else if(r[ml]===!0){let{version:n,multihash:o,code:i}=r,s=Zt(o);return t.create(n,i,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==wr)throw new Error(`Version 0 CID must use dag-pb (code: ${wr}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=js(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,wr,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=Qe(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new jt(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,g]=xr(e.subarray(r));return r+=g,l},o=n(),i=wr;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,c=n(),a=n(),f=r+a,u=f-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:u,size:f}}static parse(e,r){let[n,o]=ll(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Vo(i).set(n,e),i}};function ll(t,e){switch(t[0]){case"Q":{let r=e??X;return[X.prefix,r.decode(`${X.prefix}${t}`)]}case X.prefix:{let r=e??X;return[X.prefix,r.decode(t)]}case lt.prefix:{let r=e??lt;return[lt.prefix,r.decode(t)]}case Ne.prefix:{let r=e??Ne;return[Ne.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function dl(t,e,r){let{prefix:n}=r;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o}function hl(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o}var wr=112,pl=18;function js(t,e,r){let n=zt(t),o=n+zt(e),i=new Uint8Array(o+r.byteLength);return $t(t,i,0),$t(e,i,n),i.set(r,o),i}var ml=Symbol.for("@ipld/js-cid/CID");var qo={};xe(qo,{identity:()=>Tt});var Zs=0,yl="identity",Ys=Qe;function gl(t,e){if(e?.truncate!=null&&e.truncate!==t.byteLength){if(e.truncate<0||e.truncate>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e.truncate)}return He(Zs,Ys(t))}var Tt={code:Zs,name:yl,encode:Ys,digest:gl};function ne(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function Le(t=0){return new Uint8Array(t)}function Ae(t=0){return new Uint8Array(t)}function dt(t,e){e==null&&(e=t.reduce((o,i)=>o+i.length,0));let r=Ae(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}var Xs=Symbol.for("@achingbrain/uint8arraylist");function Gs(t,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let r=0;for(let n of t){let o=r+n.byteLength;if(e<o)return{buf:n,index:e-r};r=o}throw new RangeError("index is out of bounds")}function gn(t){return!!t?.[Xs]}var me=class t{bufs;length;[Xs]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let r=0;for(let n of e)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(gn(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...e){this.prependAll(e)}prependAll(e){let r=0;for(let n of e.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(gn(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(e){let r=Gs(this.bufs,e);return r.buf[r.index]}set(e,r){let n=Gs(this.bufs,e);n.buf[n.index]=r}write(e,r=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(r+n,e[n]);else if(gn(e))for(let n=0;n<e.length;n++)this.set(r+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,r){let{bufs:n,length:o}=this._subList(e,r);return dt(n,o)}subarray(e,r){let{bufs:n,length:o}=this._subList(e,r);return n.length===1?n[0]:dt(n,o)}sublist(e,r){let{bufs:n,length:o}=this._subList(e,r),i=new t;return i.length=o,i.bufs=[...n],i}_subList(e,r){if(e=e??0,r=r??this.length,e<0&&(e=this.length+e),r<0&&(r=this.length+r),e<0||r>this.length)throw new RangeError("index is out of bounds");if(e===r)return{bufs:[],length:0};if(e===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],c=o,a=c+s.byteLength;if(o=a,e>=a)continue;let f=e>=c&&e<a,u=r>c&&r<=a;if(f&&u){if(e===c&&r===a){n.push(s);break}let l=e-c;n.push(s.subarray(l,l+(r-e)));break}if(f){if(e===0){n.push(s);continue}n.push(s.subarray(e-c));continue}if(u){if(r===a){n.push(s);break}n.push(s.subarray(0,r-c));break}n.push(s)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!gn(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),e.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let c=s,a=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=r;l<=a;l+=u){u=0;for(let g=f;g>=0;g--){let S=this.get(l+g);if(n[g]!==S){u=Math.max(1,g-c[S]);break}}if(u===0)return l}return-1}getInt8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(e,r){let n=Ae(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,e)}getInt16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(e,r,n){let o=Le(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,e)}getInt32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(e,r,n){let o=Le(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,e)}getBigInt64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(e,r,n){let o=Le(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,e)}getUint8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(e,r){let n=Ae(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,e)}getUint16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(e,r,n){let o=Le(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,e)}getUint32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(e,r,n){let o=Le(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,e)}getBigUint64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(e,r,n){let o=Le(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,e)}getFloat32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(e,r,n){let o=Le(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,e)}getFloat64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(e,r,n){let o=Le(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof t)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!ne(this.bufs[r],e.bufs[r]))return!1;return!0}static fromUint8Arrays(e,r){let n=new t;return n.bufs=e,r==null&&(r=e.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var Ho={};xe(Ho,{base10:()=>bl});var bl=ft({prefix:"9",name:"base10",alphabet:"0123456789"});var $o={};xe($o,{base16:()=>xl,base16upper:()=>wl});var xl=re({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),wl=re({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var zo={};xe(zo,{base2:()=>El});var El=re({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var jo={};xe(jo,{base256emoji:()=>Tl});var Ws=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}"),Sl=Ws.reduce((t,e,r)=>(t[r]=e,t),[]),vl=Ws.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function Al(t){return t.reduce((e,r)=>(e+=Sl[r],e),"")}function Il(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=vl[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Tl=Ht({prefix:"\u{1F680}",name:"base256emoji",encode:Al,decode:Il});var Yo={};xe(Yo,{base64:()=>Zo,base64pad:()=>Bl,base64url:()=>Cl,base64urlpad:()=>_l});var Zo=re({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Bl=re({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Cl=re({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_l=re({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Go={};xe(Go,{base8:()=>Rl});var Rl=re({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Xo={};xe(Xo,{identity:()=>Ll});var Ll=Ht({prefix:"\0",name:"identity",encode:t=>Ks(t),decode:t=>ks(t)});var g0=new TextEncoder,b0=new TextDecoder;var Qo={};xe(Qo,{sha256:()=>bn,sha512:()=>kl});var Nl=20;function Jo({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new Wo(t,e,r,n,o)}var Wo=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,i){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Nl,this.maxDigestLength=i}digest(e,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?Js(n,this.code,r?.truncate):n.then(o=>Js(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Js(t,e,r){if(r!=null&&r!==t.byteLength){if(r>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,r)}return He(e,t)}function ea(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var bn=Jo({name:"sha2-256",code:18,encode:ea("SHA-256")}),kl=Jo({name:"sha2-512",code:19,encode:ea("SHA-512")});var ei={...Xo,...zo,...Go,...Ho,...$o,...Oo,...Mo,...Po,...Yo,...jo},R0={...Qo,...qo};function ra(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var ta=ra("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),ti=ra("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Ae(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Kl={utf8:ta,"utf-8":ta,hex:ei.base16,latin1:ti,ascii:ti,binary:ti,...ei},xn=Kl;function $(t,e="utf8"){let r=xn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}function Z(t,e="utf8"){let r=xn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.encoder.encode(t).substring(1)}var Pl=parseInt("11111",2),ri=parseInt("10000000",2),Ol=parseInt("01111111",2),na={0:Er,1:Er,2:Ml,3:ql,4:Hl,5:Vl,6:Fl,16:Er,22:Er,48:Er};function et(t,e={offset:0}){let r=t[e.offset]&Pl;if(e.offset++,na[r]!=null)return na[r](t,e);throw new Error("No decoder for tag "+r)}function Sr(t,e){let r=0;if((t[e.offset]&ri)===ri){let n=t[e.offset]&Ol,o="0x";e.offset++;for(let i=0;i<n;i++,e.offset++)o+=t[e.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=t[e.offset],e.offset++;return r}function Er(t,e){Sr(t,e);let r=[];for(;!(e.offset>=t.byteLength);){let n=et(t,e);if(n===null)break;r.push(n)}return r}function Ml(t,e){let r=Sr(t,e),n=e.offset,o=e.offset+r,i=[];for(let s=n;s<o;s++)s===n&&t[s]===0||i.push(t[s]);return e.offset+=r,Uint8Array.from(i)}function Fl(t,e){let r=Sr(t,e),n=e.offset+r,o=t[e.offset];e.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let c=`${i}.${s}`,a=[];for(;e.offset<n;){let f=t[e.offset];if(e.offset++,a.push(f&127),f<128){a.reverse();let u=0;for(let l=0;l<a.length;l++)u+=a[l]<<l*7;c+=`.${u}`,a=[]}}return c}function Vl(t,e){return e.offset++,null}function ql(t,e){let r=Sr(t,e),n=t[e.offset];e.offset++;let o=t.subarray(e.offset,e.offset+r-1);if(e.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Hl(t,e){let r=Sr(t,e),n=t.subarray(e.offset,e.offset+r);return e.offset+=r,n}function $l(t){let e=t.toString(16);e.length%2===1&&(e="0"+e);let r=new me;for(let n=0;n<e.length;n+=2)r.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return r}function wn(t){if(t.byteLength<128)return Uint8Array.from([t.byteLength]);let e=$l(t.byteLength);return new me(Uint8Array.from([e.byteLength|ri]),e)}function ye(t){let e=new me,r=128;return(t.subarray()[0]&r)===r&&e.append(Uint8Array.from([0])),e.append(t),new me(Uint8Array.from([2]),wn(e),e)}function vr(t){let e=Uint8Array.from([0]),r=new me(e,t);return new me(Uint8Array.from([3]),wn(r),r)}function oa(t){return new me(Uint8Array.from([4]),wn(t),t)}function ke(t,e=48){let r=new me;for(let n of t)r.append(n);return new me(Uint8Array.from([e]),wn(r),r)}async function ia(t="P-256"){let e=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:t},!0,["sign","verify"]);return{publicKey:await crypto.subtle.exportKey("jwk",e.publicKey),privateKey:await crypto.subtle.exportKey("jwk",e.privateKey)}}async function sa(t,e,r){let n=await crypto.subtle.importKey("jwk",t,{name:"ECDSA",namedCurve:t.crv??"P-256"},!1,["sign"]);r?.signal?.throwIfAborted();let o=await crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},n,e.subarray());return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function aa(t,e,r,n){let o=await crypto.subtle.importKey("jwk",t,{name:"ECDSA",namedCurve:t.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,e,r.subarray());return n?.signal?.throwIfAborted(),i}var zl=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),jl=Uint8Array.from([6,5,43,129,4,0,34]),Zl=Uint8Array.from([6,5,43,129,4,0,35]),Yl={ext:!0,kty:"EC",crv:"P-256"},Gl={ext:!0,kty:"EC",crv:"P-384"},Xl={ext:!0,kty:"EC",crv:"P-521"},ni=32,oi=48,ii=66;function si(t){let e=et(t);return ca(e)}function ca(t){let e=t[1][1][0],r=1,n,o;if(e.byteLength===ni*2+1)return n=Z(e.subarray(r,r+ni),"base64url"),o=Z(e.subarray(r+ni),"base64url"),new Bt({...Yl,key_ops:["verify"],x:n,y:o});if(e.byteLength===oi*2+1)return n=Z(e.subarray(r,r+oi),"base64url"),o=Z(e.subarray(r+oi),"base64url"),new Bt({...Gl,key_ops:["verify"],x:n,y:o});if(e.byteLength===ii*2+1)return n=Z(e.subarray(r,r+ii),"base64url"),o=Z(e.subarray(r+ii),"base64url"),new Bt({...Xl,key_ops:["verify"],x:n,y:o});throw new te(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function ua(t){return ke([ye(Uint8Array.from([1])),oa($(t.d??"","base64url")),ke([la(t.crv)],160),ke([vr(new me(Uint8Array.from([4]),$(t.x??"","base64url"),$(t.y??"","base64url")))],161)]).subarray()}function fa(t){return ke([ye(Uint8Array.from([1])),ke([la(t.crv)],160),ke([vr(new me(Uint8Array.from([4]),$(t.x??"","base64url"),$(t.y??"","base64url")))],161)]).subarray()}function la(t){if(t==="P-256")return zl;if(t==="P-384")return jl;if(t==="P-521")return Zl;throw new te(`Invalid curve ${t}`)}async function da(t="P-256"){let e=await ia(t);return new En(e.privateKey)}var Bt=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=fa(this.jwk)),this._raw}toMultihash(){return Tt.digest(ht(this))}toCID(){return se.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ne(this.raw,e.raw)}async verify(e,r,n){return aa(this.jwk,r,e,n)}},En=class{type="ECDSA";jwk;publicKey;_raw;constructor(e){this.jwk=e,this.publicKey=new Bt({crv:e.crv,ext:e.ext,key_ops:["verify"],kty:"EC",x:e.x,y:e.y})}get raw(){return this._raw==null&&(this._raw=ua(this.jwk)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ne(this.raw,e.raw)}async sign(e,r){return sa(this.jwk,e,r)}};function Ct(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function $e(t,e=""){if(!Number.isSafeInteger(t)||t<0){let r=e&&`"${e}" `;throw new Error(`${r}expected integer >= 0, got ${t}`)}}function H(t,e,r=""){let n=Ct(t),o=t?.length,i=e!==void 0;if(!n||i&&o!==e){let s=r&&`"${r}" `,c=i?` of length ${e}`:"",a=n?`length=${o}`:`type=${typeof t}`;throw new Error(s+"expected Uint8Array"+c+", got "+a)}return t}function Sn(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash must wrapped by utils.createHasher");$e(t.outputLen),$e(t.blockLen)}function Yt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function pa(t,e){H(t,void 0,"digestInto() output");let r=e.outputLen;if(t.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function rt(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function vn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ke(t,e){return t<<32-e|t>>>e}var ma=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Wl=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function nt(t){if(H(t),ma)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=Wl[t[r]];return e}var tt={_0:48,_9:57,A:65,F:70,a:97,f:102};function ha(t){if(t>=tt._0&&t<=tt._9)return t-tt._0;if(t>=tt.A&&t<=tt.F)return t-(tt.A-10);if(t>=tt.a&&t<=tt.f)return t-(tt.a-10)}function ot(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(ma)return Uint8Array.fromHex(t);let e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=ha(t.charCodeAt(i)),c=ha(t.charCodeAt(i+1));if(s===void 0||c===void 0){let a=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+i)}n[o]=s*16+c}return n}function we(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];H(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}function ai(t,e={}){let r=(o,i)=>t(i).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function Gt(t=32){let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(t))}var ci=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function ya(t,e,r){return t&e^~t&r}function ga(t,e,r){return t&e^t&r^e&r}var Ar=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,r,n,o){this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=vn(this.buffer)}update(e){Yt(this),H(e);let{view:r,buffer:n,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=vn(e);for(;o<=i-s;s+=o)this.process(a,s);continue}n.set(e.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Yt(this),pa(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,rt(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let c=vn(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let f=a/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)c.setUint32(4*l,u[l],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:c}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=c,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},it=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var le=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var An=BigInt(4294967295),ba=BigInt(32);function Jl(t,e=!1){return e?{h:Number(t&An),l:Number(t>>ba&An)}:{h:Number(t>>ba&An)|0,l:Number(t&An)|0}}function xa(t,e=!1){let r=t.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:c}=Jl(t[i],e);[n[i],o[i]]=[s,c]}return[n,o]}var ui=(t,e,r)=>t>>>r,fi=(t,e,r)=>t<<32-r|e>>>r,_t=(t,e,r)=>t>>>r|e<<32-r,Rt=(t,e,r)=>t<<32-r|e>>>r,Ir=(t,e,r)=>t<<64-r|e>>>r-32,Tr=(t,e,r)=>t>>>r-32|e<<64-r;function ze(t,e,r,n){let o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:o|0}}var wa=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Ea=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Sa=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),va=(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,Aa=(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Ia=(t,e,r,n,o,i)=>e+r+n+o+i+(t/2**32|0)|0;var ed=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),pt=new Uint32Array(64),li=class extends Ar{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:c,H:a}=this;return[e,r,n,o,i,s,c,a]}set(e,r,n,o,i,s,c,a){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}process(e,r){for(let l=0;l<16;l++,r+=4)pt[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let g=pt[l-15],S=pt[l-2],x=Ke(g,7)^Ke(g,18)^g>>>3,T=Ke(S,17)^Ke(S,19)^S>>>10;pt[l]=T+pt[l-7]+x+pt[l-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:f,H:u}=this;for(let l=0;l<64;l++){let g=Ke(c,6)^Ke(c,11)^Ke(c,25),S=u+g+ya(c,a,f)+ed[l]+pt[l]|0,T=(Ke(n,2)^Ke(n,13)^Ke(n,22))+ga(n,o,i)|0;u=f,f=a,a=c,c=s+S|0,s=i,i=o,o=n,n=S+T|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,c,a,f,u)}roundClean(){rt(pt)}destroy(){this.set(0,0,0,0,0,0,0,0),rt(this.buffer)}},di=class extends li{A=it[0]|0;B=it[1]|0;C=it[2]|0;D=it[3]|0;E=it[4]|0;F=it[5]|0;G=it[6]|0;H=it[7]|0;constructor(){super(32)}};var Ta=xa(["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(t=>BigInt(t))),td=Ta[0],rd=Ta[1],mt=new Uint32Array(80),yt=new Uint32Array(80),hi=class extends Ar{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:c,Dl:a,Eh:f,El:u,Fh:l,Fl:g,Gh:S,Gl:x,Hh:T,Hl:E}=this;return[e,r,n,o,i,s,c,a,f,u,l,g,S,x,T,E]}set(e,r,n,o,i,s,c,a,f,u,l,g,S,x,T,E){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=a|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=g|0,this.Gh=S|0,this.Gl=x|0,this.Hh=T|0,this.Hl=E|0}process(e,r){for(let v=0;v<16;v++,r+=4)mt[v]=e.getUint32(r),yt[v]=e.getUint32(r+=4);for(let v=16;v<80;v++){let U=mt[v-15]|0,P=yt[v-15]|0,F=_t(U,P,1)^_t(U,P,8)^ui(U,P,7),M=Rt(U,P,1)^Rt(U,P,8)^fi(U,P,7),p=mt[v-2]|0,m=yt[v-2]|0,_=_t(p,m,19)^Ir(p,m,61)^ui(p,m,6),R=Rt(p,m,19)^Tr(p,m,61)^fi(p,m,6),I=Sa(M,R,yt[v-7],yt[v-16]),y=va(I,F,_,mt[v-7],mt[v-16]);mt[v]=y|0,yt[v]=I|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:f,Dl:u,Eh:l,El:g,Fh:S,Fl:x,Gh:T,Gl:E,Hh:w,Hl:B}=this;for(let v=0;v<80;v++){let U=_t(l,g,14)^_t(l,g,18)^Ir(l,g,41),P=Rt(l,g,14)^Rt(l,g,18)^Tr(l,g,41),F=l&S^~l&T,M=g&x^~g&E,p=Aa(B,P,M,rd[v],yt[v]),m=Ia(p,w,U,F,td[v],mt[v]),_=p|0,R=_t(n,o,28)^Ir(n,o,34)^Ir(n,o,39),I=Rt(n,o,28)^Tr(n,o,34)^Tr(n,o,39),y=n&i^n&c^i&c,b=o&s^o&a^s&a;w=T|0,B=E|0,T=S|0,E=x|0,S=l|0,x=g|0,{h:l,l:g}=ze(f|0,u|0,m|0,_|0),f=c|0,u=a|0,c=i|0,a=s|0,i=n|0,s=o|0;let d=wa(_,I,b);n=Ea(d,m,R,y),o=d|0}({h:n,l:o}=ze(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=ze(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=ze(this.Ch|0,this.Cl|0,c|0,a|0),{h:f,l:u}=ze(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:g}=ze(this.Eh|0,this.El|0,l|0,g|0),{h:S,l:x}=ze(this.Fh|0,this.Fl|0,S|0,x|0),{h:T,l:E}=ze(this.Gh|0,this.Gl|0,T|0,E|0),{h:w,l:B}=ze(this.Hh|0,this.Hl|0,w|0,B|0),this.set(n,o,i,s,c,a,f,u,l,g,S,x,T,E,w,B)}roundClean(){rt(mt,yt)}destroy(){rt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},pi=class extends hi{Ah=le[0]|0;Al=le[1]|0;Bh=le[2]|0;Bl=le[3]|0;Ch=le[4]|0;Cl=le[5]|0;Dh=le[6]|0;Dl=le[7]|0;Eh=le[8]|0;El=le[9]|0;Fh=le[10]|0;Fl=le[11]|0;Gh=le[12]|0;Gl=le[13]|0;Hh=le[14]|0;Hl=le[15]|0;constructor(){super(64)}};var Xt=ai(()=>new di,ci(1));var Ba=ai(()=>new pi,ci(3));var yi=BigInt(0),mi=BigInt(1);function st(t,e=""){if(typeof t!="boolean"){let r=e&&`"${e}" `;throw new Error(r+"expected boolean, got type="+typeof t)}return t}function Ca(t){if(typeof t=="bigint"){if(!In(t))throw new Error("positive bigint expected, got "+t)}else $e(t);return t}function Br(t){let e=Ca(t).toString(16);return e.length&1?"0"+e:e}function _a(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?yi:BigInt("0x"+t)}function Wt(t){return _a(nt(t))}function Lt(t){return _a(nt(Bn(H(t)).reverse()))}function Tn(t,e){$e(e),t=Ca(t);let r=ot(t.toString(16).padStart(e*2,"0"));if(r.length!==e)throw new Error("number too large");return r}function gi(t,e){return Tn(t,e).reverse()}function Bn(t){return Uint8Array.from(t)}var In=t=>typeof t=="bigint"&&yi<=t;function nd(t,e,r){return In(t)&&In(e)&&In(r)&&e<=t&&t<r}function Cr(t,e,r,n){if(!nd(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function bi(t){let e;for(e=0;t>yi;t>>=mi,e+=1);return e}var _r=t=>(mi<<BigInt(t))-mi;function Ra(t,e,r){if($e(t,"hashLen"),$e(e,"qByteLen"),typeof r!="function")throw new Error("hmacFn must be a function");let n=E=>new Uint8Array(E),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),c=1e3,a=n(t),f=n(t),u=0,l=()=>{a.fill(1),f.fill(0),u=0},g=(...E)=>r(f,we(a,...E)),S=(E=o)=>{f=g(i,E),a=g(),E.length!==0&&(f=g(s,E),a=g())},x=()=>{if(u++>=c)throw new Error("drbg: tried max amount of iterations");let E=0,w=[];for(;E<e;){a=g();let B=a.slice();w.push(B),E+=a.length}return we(...w)};return(E,w)=>{l(),S(E);let B;for(;!(B=w(x()));)S();return l(),B}}function gt(t,e={},r={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function n(i,s,c){let a=t[i];if(c&&a===void 0)return;let f=typeof a;if(f!==s||a===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${f}`)}let o=(i,s)=>Object.entries(i).forEach(([c,a])=>n(c,a,s));o(e,!1),o(r,!0)}function Jt(t){let e=new WeakMap;return(r,...n)=>{let o=e.get(r);if(o!==void 0)return o;let i=t(r,...n);return e.set(r,i),i}}var ge=BigInt(0),ae=BigInt(1),Dt=BigInt(2),Ua=BigInt(3),Na=BigInt(4),ka=BigInt(5),od=BigInt(7),Ka=BigInt(8),id=BigInt(9),Pa=BigInt(16);function oe(t,e){let r=t%e;return r>=ge?r:e+r}function W(t,e,r){let n=t;for(;e-- >ge;)n*=n,n%=r;return n}function La(t,e){if(t===ge)throw new Error("invert: expected non-zero number");if(e<=ge)throw new Error("invert: expected positive modulus, got "+e);let r=oe(t,e),n=e,o=ge,i=ae,s=ae,c=ge;for(;r!==ge;){let f=n/r,u=n%r,l=o-s*f,g=i-c*f;n=r,r=u,o=s,i=c,s=l,c=g}if(n!==ae)throw new Error("invert: does not exist");return oe(o,e)}function wi(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function Oa(t,e){let r=(t.ORDER+ae)/Na,n=t.pow(e,r);return wi(t,n,e),n}function sd(t,e){let r=(t.ORDER-ka)/Ka,n=t.mul(e,Dt),o=t.pow(n,r),i=t.mul(e,o),s=t.mul(t.mul(i,Dt),o),c=t.mul(i,t.sub(s,t.ONE));return wi(t,c,e),c}function ad(t){let e=Qt(t),r=Ma(t),n=r(e,e.neg(e.ONE)),o=r(e,n),i=r(e,e.neg(n)),s=(t+od)/Pa;return(c,a)=>{let f=c.pow(a,s),u=c.mul(f,n),l=c.mul(f,o),g=c.mul(f,i),S=c.eql(c.sqr(u),a),x=c.eql(c.sqr(l),a);f=c.cmov(f,u,S),u=c.cmov(g,l,x);let T=c.eql(c.sqr(u),a),E=c.cmov(f,u,T);return wi(c,E,a),E}}function Ma(t){if(t<Ua)throw new Error("sqrt is not defined for small field");let e=t-ae,r=0;for(;e%Dt===ge;)e/=Dt,r++;let n=Dt,o=Qt(t);for(;Da(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Oa;let i=o.pow(n,e),s=(e+ae)/Dt;return function(a,f){if(a.is0(f))return f;if(Da(a,f)!==1)throw new Error("Cannot find square root");let u=r,l=a.mul(a.ONE,i),g=a.pow(f,e),S=a.pow(f,s);for(;!a.eql(g,a.ONE);){if(a.is0(g))return a.ZERO;let x=1,T=a.sqr(g);for(;!a.eql(T,a.ONE);)if(x++,T=a.sqr(T),x===u)throw new Error("Cannot find square root");let E=ae<<BigInt(u-x-1),w=a.pow(l,E);u=x,l=a.sqr(w),g=a.mul(g,l),S=a.mul(S,w)}return S}}function cd(t){return t%Na===Ua?Oa:t%Ka===ka?sd:t%Pa===id?ad(t):Ma(t)}var Fa=(t,e)=>(oe(t,e)&ae)===ae,ud=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ei(t){let e={ORDER:"bigint",BYTES:"number",BITS:"number"},r=ud.reduce((n,o)=>(n[o]="function",n),e);return gt(t,r),t}function fd(t,e,r){if(r<ge)throw new Error("invalid exponent, negatives unsupported");if(r===ge)return t.ONE;if(r===ae)return e;let n=t.ONE,o=e;for(;r>ge;)r&ae&&(n=t.mul(n,o)),o=t.sqr(o),r>>=ae;return n}function Rr(t,e,r=!1){let n=new Array(e.length).fill(r?t.ZERO:void 0),o=e.reduce((s,c,a)=>t.is0(c)?s:(n[a]=s,t.mul(s,c)),t.ONE),i=t.inv(o);return e.reduceRight((s,c,a)=>t.is0(c)?s:(n[a]=t.mul(s,n[a]),t.mul(s,c)),i),n}function Da(t,e){let r=(t.ORDER-ae)/Dt,n=t.pow(e,r),o=t.eql(n,t.ONE),i=t.eql(n,t.ZERO),s=t.eql(n,t.neg(t.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function ld(t,e){e!==void 0&&$e(e);let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var xi=class{ORDER;BITS;BYTES;isLE;ZERO=ge;ONE=ae;_lengths;_sqrt;_mod;constructor(e,r={}){if(e<=ge)throw new Error("invalid field: expected ORDER > 0, got "+e);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:i}=ld(e,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=i,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return oe(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof e);return ge<=e&&e<this.ORDER}is0(e){return e===ge}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&ae)===ae}neg(e){return oe(-e,this.ORDER)}eql(e,r){return e===r}sqr(e){return oe(e*e,this.ORDER)}add(e,r){return oe(e+r,this.ORDER)}sub(e,r){return oe(e-r,this.ORDER)}mul(e,r){return oe(e*r,this.ORDER)}pow(e,r){return fd(this,e,r)}div(e,r){return oe(e*La(r,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,r){return e+r}subN(e,r){return e-r}mulN(e,r){return e*r}inv(e){return La(e,this.ORDER)}sqrt(e){return this._sqrt||(this._sqrt=cd(this.ORDER)),this._sqrt(this,e)}toBytes(e){return this.isLE?gi(e,this.BYTES):Tn(e,this.BYTES)}fromBytes(e,r=!1){H(e);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:c}=this;if(n){if(!n.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);let f=new Uint8Array(o);f.set(e,i?0:f.length-e.length),e=f}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=i?Lt(e):Wt(e);if(c&&(a=oe(a,s)),!r&&!this.isValid(a))throw new Error("invalid field element: outside of range 0..ORDER");return a}invertBatch(e){return Rr(this,e)}cmov(e,r,n){return n?r:e}};function Qt(t,e={}){return new xi(t,e)}function Va(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function Si(t){let e=Va(t);return e+Math.ceil(e/2)}function vi(t,e,r=!1){H(t);let n=t.length,o=Va(e),i=Si(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Lt(t):Wt(t),c=oe(s,e-ae)+ae;return r?gi(c,o):Tn(c,o)}var er=BigInt(0),Ut=BigInt(1);function Lr(t,e){let r=e.negate();return t?r:e}function Nt(t,e){let r=Rr(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function za(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Ai(t,e){za(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1),o=2**t,i=_r(t),s=BigInt(t);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function qa(t,e,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,c=Number(t&o),a=t>>s;c>n&&(c-=i,a+=Ut);let f=e*n,u=f+Math.abs(c)-1,l=c===0,g=c<0,S=e%2!==0;return{nextN:a,offset:u,isZero:l,isNeg:g,isNegF:S,offsetF:f}}var Ii=new WeakMap,ja=new WeakMap;function Ti(t){return ja.get(t)||1}function Ha(t){if(t!==er)throw new Error("invalid wNAF")}var tr=class{BASE;ZERO;Fn;bits;constructor(e,r){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=r}_unsafeLadder(e,r,n=this.ZERO){let o=e;for(;r>er;)r&Ut&&(n=n.add(o)),o=o.double(),r>>=Ut;return n}precomputeWindow(e,r){let{windows:n,windowSize:o}=Ai(r,this.bits),i=[],s=e,c=s;for(let a=0;a<n;a++){c=s,i.push(c);for(let f=1;f<o;f++)c=c.add(s),i.push(c);s=c.double()}return i}wNAF(e,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=Ai(e,this.bits);for(let c=0;c<s.windows;c++){let{nextN:a,offset:f,isZero:u,isNeg:l,isNegF:g,offsetF:S}=qa(n,c,s);n=a,u?i=i.add(Lr(g,r[S])):o=o.add(Lr(l,r[f]))}return Ha(n),{p:o,f:i}}wNAFUnsafe(e,r,n,o=this.ZERO){let i=Ai(e,this.bits);for(let s=0;s<i.windows&&n!==er;s++){let{nextN:c,offset:a,isZero:f,isNeg:u}=qa(n,s,i);if(n=c,!f){let l=r[a];o=o.add(u?l.negate():l)}}return Ha(n),o}getPrecomputes(e,r,n){let o=Ii.get(r);return o||(o=this.precomputeWindow(r,e),e!==1&&(typeof n=="function"&&(o=n(o)),Ii.set(r,o))),o}cached(e,r,n){let o=Ti(e);return this.wNAF(o,this.getPrecomputes(o,e,n),r)}unsafe(e,r,n,o){let i=Ti(e);return i===1?this._unsafeLadder(e,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),r,o)}createCache(e,r){za(r,this.bits),ja.set(e,r),Ii.delete(e)}hasCache(e){return Ti(e)!==1}};function Za(t,e,r,n){let o=e,i=t.ZERO,s=t.ZERO;for(;r>er||n>er;)r&Ut&&(i=i.add(o)),n&Ut&&(s=s.add(o)),o=o.double(),r>>=Ut,n>>=Ut;return{p1:i,p2:s}}function $a(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Ei(e),e}else return Qt(t,{isLE:r})}function Cn(t,e,r={},n){if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(let a of["p","n","h"]){let f=e[a];if(!(typeof f=="bigint"&&f>er))throw new Error(`CURVE.${a} must be positive bigint`)}let o=$a(e.p,r.Fp,n),i=$a(e.n,r.Fn,n),c=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let a of c)if(!o.isValid(e[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:i}}function _n(t,e){return function(n){let o=t(n);return{secretKey:o,publicKey:e(o)}}}var bt=BigInt(0),ce=BigInt(1),Bi=BigInt(2),dd=BigInt(8);function hd(t,e,r,n){let o=t.sqr(r),i=t.sqr(n),s=t.add(t.mul(e.a,o),i),c=t.add(t.ONE,t.mul(e.d,t.mul(o,i)));return t.eql(s,c)}function Ya(t,e={}){let r=Cn("edwards",t,e,e.FpFnLE),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s}=i;gt(e,{},{uvRatio:"function"});let c=Bi<<BigInt(o.BYTES*8)-ce,a=E=>n.create(E),f=e.uvRatio||((E,w)=>{try{return{isValid:!0,value:n.sqrt(n.div(E,w))}}catch{return{isValid:!1,value:bt}}});if(!hd(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function u(E,w,B=!1){let v=B?ce:bt;return Cr("coordinate "+E,w,v,c),w}function l(E){if(!(E instanceof x))throw new Error("EdwardsPoint expected")}let g=Jt((E,w)=>{let{X:B,Y:v,Z:U}=E,P=E.is0();w==null&&(w=P?dd:n.inv(U));let F=a(B*w),M=a(v*w),p=n.mul(U,w);if(P)return{x:bt,y:ce};if(p!==ce)throw new Error("invZ was invalid");return{x:F,y:M}}),S=Jt(E=>{let{a:w,d:B}=i;if(E.is0())throw new Error("bad point: ZERO");let{X:v,Y:U,Z:P,T:F}=E,M=a(v*v),p=a(U*U),m=a(P*P),_=a(m*m),R=a(M*w),I=a(m*a(R+p)),y=a(_+a(B*a(M*p)));if(I!==y)throw new Error("bad point: equation left != right (1)");let b=a(v*U),d=a(P*F);if(b!==d)throw new Error("bad point: equation left != right (2)");return!0});class x{static BASE=new x(i.Gx,i.Gy,ce,a(i.Gx*i.Gy));static ZERO=new x(bt,ce,ce,bt);static Fp=n;static Fn=o;X;Y;Z;T;constructor(w,B,v,U){this.X=u("x",w),this.Y=u("y",B),this.Z=u("z",v,!0),this.T=u("t",U),Object.freeze(this)}static CURVE(){return i}static fromAffine(w){if(w instanceof x)throw new Error("extended point not allowed");let{x:B,y:v}=w||{};return u("x",B),u("y",v),new x(B,v,ce,a(B*v))}static fromBytes(w,B=!1){let v=n.BYTES,{a:U,d:P}=i;w=Bn(H(w,v,"point")),st(B,"zip215");let F=Bn(w),M=w[v-1];F[v-1]=M&-129;let p=Lt(F),m=B?c:n.ORDER;Cr("point.y",p,bt,m);let _=a(p*p),R=a(_-ce),I=a(P*_-U),{isValid:y,value:b}=f(R,I);if(!y)throw new Error("bad point: invalid y coordinate");let d=(b&ce)===ce,A=(M&128)!==0;if(!B&&b===bt&&A)throw new Error("bad point: x=0 and x_0=1");return A!==d&&(b=a(-b)),x.fromAffine({x:b,y:p})}static fromHex(w,B=!1){return x.fromBytes(ot(w),B)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,B=!0){return T.createCache(this,w),B||this.multiply(Bi),this}assertValidity(){S(this)}equals(w){l(w);let{X:B,Y:v,Z:U}=this,{X:P,Y:F,Z:M}=w,p=a(B*M),m=a(P*U),_=a(v*M),R=a(F*U);return p===m&&_===R}is0(){return this.equals(x.ZERO)}negate(){return new x(a(-this.X),this.Y,this.Z,a(-this.T))}double(){let{a:w}=i,{X:B,Y:v,Z:U}=this,P=a(B*B),F=a(v*v),M=a(Bi*a(U*U)),p=a(w*P),m=B+v,_=a(a(m*m)-P-F),R=p+F,I=R-M,y=p-F,b=a(_*I),d=a(R*y),A=a(_*y),L=a(I*R);return new x(b,d,L,A)}add(w){l(w);let{a:B,d:v}=i,{X:U,Y:P,Z:F,T:M}=this,{X:p,Y:m,Z:_,T:R}=w,I=a(U*p),y=a(P*m),b=a(M*v*R),d=a(F*_),A=a((U+P)*(p+m)-I-y),L=d-b,N=d+b,k=a(y-B*I),K=a(A*L),O=a(N*k),q=a(A*k),J=a(L*N);return new x(K,O,J,q)}subtract(w){return this.add(w.negate())}multiply(w){if(!o.isValidNot0(w))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:B,f:v}=T.cached(this,w,U=>Nt(x,U));return Nt(x,[B,v])[0]}multiplyUnsafe(w,B=x.ZERO){if(!o.isValid(w))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return w===bt?x.ZERO:this.is0()||w===ce?this:T.unsafe(this,w,v=>Nt(x,v),B)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return T.unsafe(this,i.n).is0()}toAffine(w){return g(this,w)}clearCofactor(){return s===ce?this:this.multiplyUnsafe(s)}toBytes(){let{x:w,y:B}=this.toAffine(),v=n.toBytes(B);return v[v.length-1]|=w&ce?128:0,v}toHex(){return nt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let T=new tr(x,o.BITS);return x.BASE.precompute(8),x}function Ga(t,e,r={}){if(typeof e!="function")throw new Error('"hash" function param is required');gt(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:n}=r,{BASE:o,Fp:i,Fn:s}=t,c=r.randomBytes||Gt,a=r.adjustScalarBytes||(p=>p),f=r.domain||((p,m,_)=>{if(st(_,"phflag"),m.length||_)throw new Error("Contexts/pre-hash are not supported");return p});function u(p){return s.create(Lt(p))}function l(p){let m=v.secretKey;H(p,v.secretKey,"secretKey");let _=H(e(p),2*m,"hashedSecretKey"),R=a(_.slice(0,m)),I=_.slice(m,2*m),y=u(R);return{head:R,prefix:I,scalar:y}}function g(p){let{head:m,prefix:_,scalar:R}=l(p),I=o.multiply(R),y=I.toBytes();return{head:m,prefix:_,scalar:R,point:I,pointBytes:y}}function S(p){return g(p).pointBytes}function x(p=Uint8Array.of(),...m){let _=we(...m);return u(e(f(_,H(p,void 0,"context"),!!n)))}function T(p,m,_={}){p=H(p,void 0,"message"),n&&(p=n(p));let{prefix:R,scalar:I,pointBytes:y}=g(m),b=x(_.context,R,p),d=o.multiply(b).toBytes(),A=x(_.context,d,y,p),L=s.create(b+A*I);if(!s.isValid(L))throw new Error("sign failed: invalid s");let N=we(d,s.toBytes(L));return H(N,v.signature,"result")}let E={zip215:!0};function w(p,m,_,R=E){let{context:I,zip215:y}=R,b=v.signature;p=H(p,b,"signature"),m=H(m,void 0,"message"),_=H(_,v.publicKey,"publicKey"),y!==void 0&&st(y,"zip215"),n&&(m=n(m));let d=b/2,A=p.subarray(0,d),L=Lt(p.subarray(d,b)),N,k,K;try{N=t.fromBytes(_,y),k=t.fromBytes(A,y),K=o.multiplyUnsafe(L)}catch{return!1}if(!y&&N.isSmallOrder())return!1;let O=x(I,k.toBytes(),N.toBytes(),m);return k.add(N.multiplyUnsafe(O)).subtract(K).clearCofactor().is0()}let B=i.BYTES,v={secretKey:B,publicKey:B,signature:2*B,seed:B};function U(p=c(v.seed)){return H(p,v.seed,"seed")}function P(p){return Ct(p)&&p.length===s.BYTES}function F(p,m){try{return!!t.fromBytes(p,m)}catch{return!1}}let M={getExtendedPublicKey:g,randomSecretKey:U,isValidSecretKey:P,isValidPublicKey:F,toMontgomery(p){let{y:m}=t.fromBytes(p),_=v.publicKey,R=_===32;if(!R&&_!==57)throw new Error("only defined for 25519 and 448");let I=R?i.div(ce+m,ce-m):i.div(m-ce,m+ce);return i.toBytes(I)},toMontgomerySecret(p){let m=v.secretKey;H(p,m);let _=e(p.subarray(0,m));return a(_).subarray(0,m)}};return Object.freeze({keygen:_n(U,S),getPublicKey:S,sign:T,verify:w,utils:M,Point:t,lengths:v})}var pd=BigInt(1),Xa=BigInt(2);var md=BigInt(5),yd=BigInt(8),Ci=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),gd={p:Ci,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:yd,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function bd(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=Ci,c=t*t%i*t%i,a=W(c,Xa,i)*c%i,f=W(a,pd,i)*t%i,u=W(f,md,i)*f%i,l=W(u,e,i)*u%i,g=W(l,r,i)*l%i,S=W(g,n,i)*g%i,x=W(S,o,i)*S%i,T=W(x,o,i)*S%i,E=W(T,e,i)*u%i;return{pow_p_5_8:W(E,Xa,i)*t%i,b2:c}}function xd(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}var Wa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function wd(t,e){let r=Ci,n=oe(e*e*e,r),o=oe(n*n*e,r),i=bd(t*o).pow_p_5_8,s=oe(t*n*i,r),c=oe(e*s*s,r),a=s,f=oe(s*Wa,r),u=c===t,l=c===oe(-t,r),g=c===oe(-t*Wa,r);return u&&(s=a),(l||g)&&(s=f),Fa(s,r)&&(s=oe(-s,r)),{isValid:u||l,value:s}}var Ed=Ya(gd,{uvRatio:wd});function Sd(t){return Ga(Ed,Ba,Object.assign({adjustScalarBytes:xd},t))}var Dr=Sd({});var Ur=class extends Error{constructor(e="An error occurred while signing a message"){super(e),this.name="SigningError"}},Nr=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},Rn=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var Ja={get(t=globalThis){let e=t.crypto;if(e?.subtle==null)throw new Rn("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return e}};var Ee=Ja;var Ln=32,kr=64,_i=32;var rr,Qa=(async()=>{try{return await Ee.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();function ec(){let t=Dr.utils.randomSecretKey(),e=Dr.getPublicKey(t);return{privateKey:Bd(t,e),publicKey:e}}async function vd(t,e){let r;t.length===kr?r=t.subarray(0,32):r=t;let n={crv:"Ed25519",kty:"OKP",x:Z(t.subarray(32),"base64url"),d:Z(r,"base64url"),ext:!0,key_ops:["sign"]},o=await Ee.get().subtle.importKey("jwk",n,{name:"Ed25519"},!0,["sign"]),i=await Ee.get().subtle.sign({name:"Ed25519"},o,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(i,0,i.byteLength)}function Ad(t,e){let r=t.subarray(0,_i);return Dr.sign(e instanceof Uint8Array?e:e.subarray(),r)}async function tc(t,e){return rr==null&&(rr=await Qa),rr?vd(t,e):Ad(t,e)}async function Id(t,e,r){if(t.buffer instanceof ArrayBuffer){let n=await Ee.get().subtle.importKey("raw",t.buffer,{name:"Ed25519"},!1,["verify"]);return await Ee.get().subtle.verify({name:"Ed25519"},n,e,r instanceof Uint8Array?r:r.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Td(t,e,r){return Dr.verify(e,r instanceof Uint8Array?r:r.subarray(),t)}async function rc(t,e,r){return rr==null&&(rr=await Qa),rr?Id(t,e,r):Td(t,e,r)}function Bd(t,e){let r=new Uint8Array(kr);for(let n=0;n<_i;n++)r[n]=t[n],r[_i+n]=e[n];return r}function nr(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}var Kr=class{type="Ed25519";raw;constructor(e){this.raw=Un(e,Ln)}toMultihash(){return Tt.digest(ht(this))}toCID(){return se.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ne(this.raw,e.raw)}verify(e,r,n){n?.signal?.throwIfAborted();let o=rc(this.raw,r,e);return nr(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}},Dn=class{type="Ed25519";raw;publicKey;constructor(e,r){this.raw=Un(e,kr),this.publicKey=new Kr(r)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ne(this.raw,e.raw)}sign(e,r){r?.signal?.throwIfAborted();let n=tc(this.raw,e);return nr(n)?n.then(o=>(r?.signal?.throwIfAborted(),o)):(r?.signal?.throwIfAborted(),n)}};function Ri(t){return t=Un(t,Ln),new Kr(t)}async function oc(){let{privateKey:t,publicKey:e}=ec();return new Dn(t,e)}function Un(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new te(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}var Cd=Math.pow(2,7),_d=Math.pow(2,14),Rd=Math.pow(2,21),ic=Math.pow(2,28),sc=Math.pow(2,35),ac=Math.pow(2,42),cc=Math.pow(2,49),be=128,xt=127;function Pr(t){if(t<Cd)return 1;if(t<_d)return 2;if(t<Rd)return 3;if(t<ic)return 4;if(t<sc)return 5;if(t<ac)return 6;if(t<cc)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function uc(t,e,r=0){switch(Pr(t)){case 8:e[r++]=t&255|be,t/=128;case 7:e[r++]=t&255|be,t/=128;case 6:e[r++]=t&255|be,t/=128;case 5:e[r++]=t&255|be,t/=128;case 4:e[r++]=t&255|be,t>>>=7;case 3:e[r++]=t&255|be,t>>>=7;case 2:e[r++]=t&255|be,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function fc(t,e){let r=t[e],n=0;if(n+=r&xt,r<be||(r=t[e+1],n+=(r&xt)<<7,r<be)||(r=t[e+2],n+=(r&xt)<<14,r<be)||(r=t[e+3],n+=(r&xt)<<21,r<be)||(r=t[e+4],n+=(r&xt)*ic,r<be)||(r=t[e+5],n+=(r&xt)*sc,r<be)||(r=t[e+6],n+=(r&xt)*ac,r<be)||(r=t[e+7],n+=(r&xt)*cc,r<be))return n;throw new RangeError("Could not decode varint")}var Li=new Float32Array([-0]),wt=new Uint8Array(Li.buffer);function lc(t,e,r){Li[0]=t,e[r]=wt[0],e[r+1]=wt[1],e[r+2]=wt[2],e[r+3]=wt[3]}function dc(t,e){return wt[0]=t[e],wt[1]=t[e+1],wt[2]=t[e+2],wt[3]=t[e+3],Li[0]}var Di=new Float64Array([-0]),pe=new Uint8Array(Di.buffer);function hc(t,e,r){Di[0]=t,e[r]=pe[0],e[r+1]=pe[1],e[r+2]=pe[2],e[r+3]=pe[3],e[r+4]=pe[4],e[r+5]=pe[5],e[r+6]=pe[6],e[r+7]=pe[7]}function pc(t,e){return pe[0]=t[e],pe[1]=t[e+1],pe[2]=t[e+2],pe[3]=t[e+3],pe[4]=t[e+4],pe[5]=t[e+5],pe[6]=t[e+6],pe[7]=t[e+7],Di[0]}var Ld=BigInt(Number.MAX_SAFE_INTEGER),Dd=BigInt(Number.MIN_SAFE_INTEGER),Ie=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return kt;if(e<Ld&&e>Dd)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>mc&&(o=0n,++n>mc&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return kt;let r=e<0;r&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new t(n,o)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):kt}},kt=new Ie(0,0);kt.toBigInt=function(){return 0n};kt.zzEncode=kt.zzDecode=function(){return this};kt.length=function(){return 1};var mc=4294967296n;function yc(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function gc(t,e,r){if(r-e<1)return"";let o,i=[],s=0,c;for(;e<r;)c=t[e++],c<128?i[s++]=c:c>191&&c<224?i[s++]=(c&31)<<6|t[e++]&63:c>239&&c<365?(c=((c&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(c>>10),i[s++]=56320+(c&1023)):i[s++]=(c&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function Ui(t,e,r){let n=r,o,i;for(let s=0;s<t.length;++s)o=t.charCodeAt(s),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((i=t.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-n}function Pe(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function Nn(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var Ni=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Pe(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Pe(this,4);return Nn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Pe(this,4);return Nn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Pe(this,4);let e=dc(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Pe(this,4);let e=pc(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw Pe(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return gc(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Pe(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Pe(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Ie(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Pe(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw Pe(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Pe(this,8);let e=Nn(this.buf,this.pos+=4),r=Nn(this.buf,this.pos+=4);return new Ie(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=fc(this.buf,this.pos);return this.pos+=Pr(e),e}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 ki(t){return new Ni(t instanceof Uint8Array?t:t.subarray())}function je(t,e,r){let n=ki(t);return e.decode(n,void 0,r)}function Ki(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return Ae(s);o+s>e&&(n=Ae(e),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var Kt=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function Pi(){}var Mi=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Ud=Ki();function Nd(t){return globalThis.Buffer!=null?Ae(t):Ud(t)}var Mr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Kt(Pi,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new Kt(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Fi((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(kn,10,Ie.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=Ie.fromBigInt(e);return this._push(kn,r.length(),r)}uint64Number(e){return this._push(uc,Pr(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=Ie.fromBigInt(e).zzEncode();return this._push(kn,r.length(),r)}sint64Number(e){let r=Ie.fromNumber(e).zzEncode();return this._push(kn,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Oi,1,e?1:0)}fixed32(e){return this._push(Or,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=Ie.fromBigInt(e);return this._push(Or,4,r.lo)._push(Or,4,r.hi)}fixed64Number(e){let r=Ie.fromNumber(e);return this._push(Or,4,r.lo)._push(Or,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(lc,4,e)}double(e){return this._push(hc,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(Oi,1,0):this.uint32(r)._push(Kd,r,e)}string(e){let r=yc(e);return r!==0?this.uint32(r)._push(Ui,r,e):this._push(Oi,1,0)}fork(){return this.states=new Mi(this),this.head=this.tail=new Kt(Pi,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 Kt(Pi,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=Nd(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function Oi(t,e,r){e[r]=t&255}function kd(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var Fi=class extends Kt{next;constructor(e,r){super(kd,e,r),this.next=void 0}};function kn(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function Or(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function Kd(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(Mr.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(Pd,e,t),this},Mr.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(Od,e,t),this});function Pd(t,e,r){e.set(t,r)}function Od(t,e,r){t.length<40?Ui(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set($(t),r)}function Vi(){return new Mr}function Ze(t,e){let r=Vi();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var or;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(or||(or={}));function Kn(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function Fr(t){function e(o){if(t[o.toString()]==null)throw new Error("Invalid enum value");return t[o]}let r=function(i,s){let c=e(i);s.int32(c)},n=function(i){let s=i.int32();return e(s)};return Kn("enum",or.VARINT,r,n)}function Ye(t,e){return Kn("message",or.LENGTH_DELIMITED,t,e)}var ie;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.ECDSA="ECDSA"})(ie||(ie={}));var qi;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1",t[t.ECDSA=3]="ECDSA"})(qi||(qi={}));(function(t){t.codec=()=>Fr(qi)})(ie||(ie={}));var Ge;(function(t){let e;t.codec=()=>(e==null&&(e=Ye((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ie.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.Type=ie.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),e),t.encode=r=>Ze(r,t.codec()),t.decode=(r,n)=>je(r,t.codec(),n)})(Ge||(Ge={}));var Hi;(function(t){let e;t.codec=()=>(e==null&&(e=Ye((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ie.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.Type=ie.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),e),t.encode=r=>Ze(r,t.codec()),t.decode=(r,n)=>je(r,t.codec(),n)})(Hi||(Hi={}));var qr={};xe(qr,{MAX_RSA_KEY_SIZE:()=>$i,generateRSAKeyPair:()=>Qi,jwkToJWKKeyPair:()=>vc,jwkToPkcs1:()=>qd,jwkToPkix:()=>Yi,jwkToRSAPrivateKey:()=>Ji,pkcs1MessageToJwk:()=>ji,pkcs1MessageToRSAPrivateKey:()=>Gi,pkcs1ToJwk:()=>Vd,pkcs1ToRSAPrivateKey:()=>Sc,pkixMessageToJwk:()=>Zi,pkixMessageToRSAPublicKey:()=>Wi,pkixToJwk:()=>Hd,pkixToRSAPublicKey:()=>Xi});var ir=class{type="RSA";jwk;_raw;_multihash;constructor(e,r){this.jwk=e,this._multihash=r}get raw(){return this._raw==null&&(this._raw=qr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return se.createV1(114,this._multihash)}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ne(this.raw,e.raw)}verify(e,r,n){return Ec(this.jwk,r,e,n)}},Vr=class{type="RSA";jwk;_raw;publicKey;constructor(e,r){this.jwk=e,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=qr.jwkToPkcs1(this.jwk)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ne(this.raw,e.raw)}sign(e,r){return wc(this.jwk,e,r)}};var $i=8192,zi=18,Md=1062,Fd=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Vd(t){let e=et(t);return ji(e)}function ji(t){return{n:Z(t[1],"base64url"),e:Z(t[2],"base64url"),d:Z(t[3],"base64url"),p:Z(t[4],"base64url"),q:Z(t[5],"base64url"),dp:Z(t[6],"base64url"),dq:Z(t[7],"base64url"),qi:Z(t[8],"base64url"),kty:"RSA"}}function qd(t){if(t.n==null||t.e==null||t.d==null||t.p==null||t.q==null||t.dp==null||t.dq==null||t.qi==null)throw new te("JWK was missing components");return ke([ye(Uint8Array.from([0])),ye($(t.n,"base64url")),ye($(t.e,"base64url")),ye($(t.d,"base64url")),ye($(t.p,"base64url")),ye($(t.q,"base64url")),ye($(t.dp,"base64url")),ye($(t.dq,"base64url")),ye($(t.qi,"base64url"))]).subarray()}function Hd(t){let e=et(t,{offset:0});return Zi(e)}function Zi(t){let e=et(t[1],{offset:0});return{kty:"RSA",n:Z(e[0],"base64url"),e:Z(e[1],"base64url")}}function Yi(t){if(t.n==null||t.e==null)throw new te("JWK was missing components");return ke([Fd,vr(ke([ye($(t.n,"base64url")),ye($(t.e,"base64url"))]))]).subarray()}function Sc(t){let e=et(t);return Gi(e)}function Gi(t){let e=ji(t);return Ji(e)}function Xi(t,e){if(t.byteLength>=Md)throw new Vt("Key size is too large");let r=et(t,{offset:0});return Wi(r,t,e)}function Wi(t,e,r){let n=Zi(t);if(r==null){let o=Xt(Ge.encode({Type:ie.RSA,Data:e}));r=He(zi,o)}return new ir(n,r)}function Ji(t){if(Ic(t)>$i)throw new te("Key size is too large");let e=vc(t),r=Xt(Ge.encode({Type:ie.RSA,Data:Yi(e.publicKey)})),n=He(zi,r);return new Vr(e.privateKey,new ir(e.publicKey,n))}async function Qi(t){if(t>$i)throw new te("Key size is too large");let e=await Ac(t),r=Xt(Ge.encode({Type:ie.RSA,Data:Yi(e.publicKey)})),n=He(zi,r);return new Vr(e.privateKey,new ir(e.publicKey,n))}function vc(t){if(t==null)throw new te("Missing key parameter");return{privateKey:t,publicKey:{kty:t.kty,n:t.n,e:t.e}}}async function Ac(t,e){let r=await Ee.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);e?.signal?.throwIfAborted();let n=await $d(r,e);return{privateKey:n[0],publicKey:n[1]}}async function wc(t,e,r){let n=await Ee.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await Ee.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,e instanceof Uint8Array?e:e.subarray());return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function Ec(t,e,r,n){let o=await Ee.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await Ee.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,e,r instanceof Uint8Array?r:r.subarray());return n?.signal?.throwIfAborted(),i}async function $d(t,e){if(t.privateKey==null||t.publicKey==null)throw new te("Private and public key are required");let r=await Promise.all([Ee.get().subtle.exportKey("jwk",t.privateKey),Ee.get().subtle.exportKey("jwk",t.publicKey)]);return e?.signal?.throwIfAborted(),r}function Ic(t){if(t.kty!=="RSA")throw new te("invalid key type");if(t.n==null)throw new te("invalid key modulus");return $(t.n,"base64url").length*8}var Pn=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,r){if(Sn(e),H(r,void 0,"key"),this.iHash=e.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 n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),rt(o)}update(e){return Yt(this),this.iHash.update(e),this}digestInto(e){Yt(this),H(e,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=c,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},es=(t,e,r)=>new Pn(t,e).update(r).digest();es.create=(t,e)=>new Pn(t,e);var Tc=(t,e)=>(t+(t>=0?e:-e)/Bc)/e;function zd(t,e,r){let[[n,o],[i,s]]=e,c=Tc(s*t,r),a=Tc(-o*t,r),f=t-c*n-a*i,u=-c*o-a*s,l=f<at,g=u<at;l&&(f=-f),g&&(u=-u);let S=_r(Math.ceil(bi(r)/2))+sr;if(f<at||f>=S||u<at||u>=S)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:l,k1:f,k2neg:g,k2:u}}function rs(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function ts(t,e){let r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return st(r.lowS,"lowS"),st(r.prehash,"prehash"),r.format!==void 0&&rs(r.format),r}var ns=class extends Error{constructor(e=""){super(e)}},Et={Err:ns,_tlv:{encode:(t,e)=>{let{Err:r}=Et;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=Br(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Br(o.length/2|128):"";return Br(t)+i+o+e},decode(t,e){let{Err:r}=Et,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let a=o&127;if(!a)throw new r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");let f=e.subarray(n,n+a);if(f.length!==a)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(n+=a,s<128)throw new r("tlv.decode(long): not minimal encoding")}let c=e.subarray(n,n+s);if(c.length!==s)throw new r("tlv.decode: wrong value length");return{v:c,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=Et;if(t<at)throw new e("integer: negative integers are not allowed");let r=Br(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=Et;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Wt(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=Et,o=H(t,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,i),{v:f,l:u}=n.decode(2,a);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(f)}},hexFromSig(t){let{_tlv:e,_int:r}=Et,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}},at=BigInt(0),sr=BigInt(1),Bc=BigInt(2),On=BigInt(3),jd=BigInt(4);function Cc(t,e={}){let r=Cn("weierstrass",t,e),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s,n:c}=i;gt(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:a}=e;if(a&&(!n.is0(i.a)||typeof a.beta!="bigint"||!Array.isArray(a.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let f=Rc(n,o);function u(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(I,y,b){let{x:d,y:A}=y.toAffine(),L=n.toBytes(d);if(st(b,"isCompressed"),b){u();let N=!n.isOdd(A);return we(_c(N),L)}else return we(Uint8Array.of(4),L,n.toBytes(A))}function g(I){H(I,void 0,"Point");let{publicKey:y,publicKeyUncompressed:b}=f,d=I.length,A=I[0],L=I.subarray(1);if(d===y&&(A===2||A===3)){let N=n.fromBytes(L);if(!n.isValid(N))throw new Error("bad point: is not on curve, wrong x");let k=T(N),K;try{K=n.sqrt(k)}catch(J){let G=J instanceof Error?": "+J.message:"";throw new Error("bad point: is not on curve, sqrt error"+G)}u();let O=n.isOdd(K);return(A&1)===1!==O&&(K=n.neg(K)),{x:N,y:K}}else if(d===b&&A===4){let N=n.BYTES,k=n.fromBytes(L.subarray(0,N)),K=n.fromBytes(L.subarray(N,N*2));if(!E(k,K))throw new Error("bad point: is not on curve");return{x:k,y:K}}else throw new Error(`bad point: got length ${d}, expected compressed=${y} or uncompressed=${b}`)}let S=e.toBytes||l,x=e.fromBytes||g;function T(I){let y=n.sqr(I),b=n.mul(y,I);return n.add(n.add(b,n.mul(I,i.a)),i.b)}function E(I,y){let b=n.sqr(y),d=T(I);return n.eql(b,d)}if(!E(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let w=n.mul(n.pow(i.a,On),jd),B=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(w,B)))throw new Error("bad curve params: a or b");function v(I,y,b=!1){if(!n.isValid(y)||b&&n.is0(y))throw new Error(`bad point coordinate ${I}`);return y}function U(I){if(!(I instanceof m))throw new Error("Weierstrass Point expected")}function P(I){if(!a||!a.basises)throw new Error("no endo");return zd(I,a.basises,o.ORDER)}let F=Jt((I,y)=>{let{X:b,Y:d,Z:A}=I;if(n.eql(A,n.ONE))return{x:b,y:d};let L=I.is0();y==null&&(y=L?n.ONE:n.inv(A));let N=n.mul(b,y),k=n.mul(d,y),K=n.mul(A,y);if(L)return{x:n.ZERO,y:n.ZERO};if(!n.eql(K,n.ONE))throw new Error("invZ was invalid");return{x:N,y:k}}),M=Jt(I=>{if(I.is0()){if(e.allowInfinityPoint&&!n.is0(I.Y))return;throw new Error("bad point: ZERO")}let{x:y,y:b}=I.toAffine();if(!n.isValid(y)||!n.isValid(b))throw new Error("bad point: x or y not field elements");if(!E(y,b))throw new Error("bad point: equation left != right");if(!I.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function p(I,y,b,d,A){return b=new m(n.mul(b.X,I),b.Y,b.Z),y=Lr(d,y),b=Lr(A,b),y.add(b)}class m{static BASE=new m(i.Gx,i.Gy,n.ONE);static ZERO=new m(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(y,b,d){this.X=v("x",y),this.Y=v("y",b,!0),this.Z=v("z",d),Object.freeze(this)}static CURVE(){return i}static fromAffine(y){let{x:b,y:d}=y||{};if(!y||!n.isValid(b)||!n.isValid(d))throw new Error("invalid affine point");if(y instanceof m)throw new Error("projective point not allowed");return n.is0(b)&&n.is0(d)?m.ZERO:new m(b,d,n.ONE)}static fromBytes(y){let b=m.fromAffine(x(H(y,void 0,"point")));return b.assertValidity(),b}static fromHex(y){return m.fromBytes(ot(y))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,b=!0){return R.createCache(this,y),b||this.multiply(On),this}assertValidity(){M(this)}hasEvenY(){let{y}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(y)}equals(y){U(y);let{X:b,Y:d,Z:A}=this,{X:L,Y:N,Z:k}=y,K=n.eql(n.mul(b,k),n.mul(L,A)),O=n.eql(n.mul(d,k),n.mul(N,A));return K&&O}negate(){return new m(this.X,n.neg(this.Y),this.Z)}double(){let{a:y,b}=i,d=n.mul(b,On),{X:A,Y:L,Z:N}=this,k=n.ZERO,K=n.ZERO,O=n.ZERO,q=n.mul(A,A),J=n.mul(L,L),G=n.mul(N,N),z=n.mul(A,L);return z=n.add(z,z),O=n.mul(A,N),O=n.add(O,O),k=n.mul(y,O),K=n.mul(d,G),K=n.add(k,K),k=n.sub(J,K),K=n.add(J,K),K=n.mul(k,K),k=n.mul(z,k),O=n.mul(d,O),G=n.mul(y,G),z=n.sub(q,G),z=n.mul(y,z),z=n.add(z,O),O=n.add(q,q),q=n.add(O,q),q=n.add(q,G),q=n.mul(q,z),K=n.add(K,q),G=n.mul(L,N),G=n.add(G,G),q=n.mul(G,z),k=n.sub(k,q),O=n.mul(G,J),O=n.add(O,O),O=n.add(O,O),new m(k,K,O)}add(y){U(y);let{X:b,Y:d,Z:A}=this,{X:L,Y:N,Z:k}=y,K=n.ZERO,O=n.ZERO,q=n.ZERO,J=i.a,G=n.mul(i.b,On),z=n.mul(b,L),Q=n.mul(d,N),fe=n.mul(A,k),qe=n.add(b,d),ee=n.add(L,N);qe=n.mul(qe,ee),ee=n.add(z,Q),qe=n.sub(qe,ee),ee=n.add(b,A);let he=n.add(L,k);return ee=n.mul(ee,he),he=n.add(z,fe),ee=n.sub(ee,he),he=n.add(d,A),K=n.add(N,k),he=n.mul(he,K),K=n.add(Q,fe),he=n.sub(he,K),q=n.mul(J,ee),K=n.mul(G,fe),q=n.add(K,q),K=n.sub(Q,q),q=n.add(Q,q),O=n.mul(K,q),Q=n.add(z,z),Q=n.add(Q,z),fe=n.mul(J,fe),ee=n.mul(G,ee),Q=n.add(Q,fe),fe=n.sub(z,fe),fe=n.mul(J,fe),ee=n.add(ee,fe),z=n.mul(Q,ee),O=n.add(O,z),z=n.mul(he,ee),K=n.mul(qe,K),K=n.sub(K,z),z=n.mul(qe,Q),q=n.mul(he,q),q=n.add(q,z),new m(K,O,q)}subtract(y){return this.add(y.negate())}is0(){return this.equals(m.ZERO)}multiply(y){let{endo:b}=e;if(!o.isValidNot0(y))throw new Error("invalid scalar: out of range");let d,A,L=N=>R.cached(this,N,k=>Nt(m,k));if(b){let{k1neg:N,k1:k,k2neg:K,k2:O}=P(y),{p:q,f:J}=L(k),{p:G,f:z}=L(O);A=J.add(z),d=p(b.beta,q,G,N,K)}else{let{p:N,f:k}=L(y);d=N,A=k}return Nt(m,[d,A])[0]}multiplyUnsafe(y){let{endo:b}=e,d=this;if(!o.isValid(y))throw new Error("invalid scalar: out of range");if(y===at||d.is0())return m.ZERO;if(y===sr)return d;if(R.hasCache(this))return this.multiply(y);if(b){let{k1neg:A,k1:L,k2neg:N,k2:k}=P(y),{p1:K,p2:O}=Za(m,d,L,k);return p(b.beta,K,O,A,N)}else return R.unsafe(d,y)}toAffine(y){return F(this,y)}isTorsionFree(){let{isTorsionFree:y}=e;return s===sr?!0:y?y(m,this):R.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:y}=e;return s===sr?this:y?y(m,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(y=!0){return st(y,"isCompressed"),this.assertValidity(),S(m,this,y)}toHex(y=!0){return nt(this.toBytes(y))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let _=o.BITS,R=new tr(m,e.endo?Math.ceil(_/2):_);return m.BASE.precompute(8),m}function _c(t){return Uint8Array.of(t?2:3)}function Rc(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function Zd(t,e={}){let{Fn:r}=t,n=e.randomBytes||Gt,o=Object.assign(Rc(t.Fp,r),{seed:Si(r.ORDER)});function i(S){try{let x=r.fromBytes(S);return r.isValidNot0(x)}catch{return!1}}function s(S,x){let{publicKey:T,publicKeyUncompressed:E}=o;try{let w=S.length;return x===!0&&w!==T||x===!1&&w!==E?!1:!!t.fromBytes(S)}catch{return!1}}function c(S=n(o.seed)){return vi(H(S,o.seed,"seed"),r.ORDER)}function a(S,x=!0){return t.BASE.multiply(r.fromBytes(S)).toBytes(x)}function f(S){let{secretKey:x,publicKey:T,publicKeyUncompressed:E}=o;if(!Ct(S)||"_lengths"in r&&r._lengths||x===T)return;let w=H(S,void 0,"key").length;return w===T||w===E}function u(S,x,T=!0){if(f(S)===!0)throw new Error("first arg must be private key");if(f(x)===!1)throw new Error("second arg must be public key");let E=r.fromBytes(S);return t.fromBytes(x).multiply(E).toBytes(T)}let l={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:c},g=_n(c,a);return Object.freeze({getPublicKey:a,getSharedSecret:u,keygen:g,Point:t,utils:l,lengths:o})}function Lc(t,e,r={}){Sn(e),gt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||Gt,o=r.hmac||((b,d)=>es(e,b,d)),{Fp:i,Fn:s}=t,{ORDER:c,BITS:a}=s,{keygen:f,getPublicKey:u,getSharedSecret:l,utils:g,lengths:S}=Zd(t,r),x={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},T=c*Bc<i.ORDER;function E(b){let d=c>>sr;return b>d}function w(b,d){if(!s.isValidNot0(d))throw new Error(`invalid signature ${b}: out of range 1..Point.Fn.ORDER`);return d}function B(){if(T)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function v(b,d){rs(d);let A=S.signature,L=d==="compact"?A:d==="recovered"?A+1:void 0;return H(b,L)}class U{r;s;recovery;constructor(d,A,L){if(this.r=w("r",d),this.s=w("s",A),L!=null){if(B(),![0,1,2,3].includes(L))throw new Error("invalid recovery id");this.recovery=L}Object.freeze(this)}static fromBytes(d,A=x.format){v(d,A);let L;if(A==="der"){let{r:O,s:q}=Et.toSig(H(d));return new U(O,q)}A==="recovered"&&(L=d[0],A="compact",d=d.subarray(1));let N=S.signature/2,k=d.subarray(0,N),K=d.subarray(N,N*2);return new U(s.fromBytes(k),s.fromBytes(K),L)}static fromHex(d,A){return this.fromBytes(ot(d),A)}assertRecovery(){let{recovery:d}=this;if(d==null)throw new Error("invalid recovery id: must be present");return d}addRecoveryBit(d){return new U(this.r,this.s,d)}recoverPublicKey(d){let{r:A,s:L}=this,N=this.assertRecovery(),k=N===2||N===3?A+c:A;if(!i.isValid(k))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let K=i.toBytes(k),O=t.fromBytes(we(_c((N&1)===0),K)),q=s.inv(k),J=F(H(d,void 0,"msgHash")),G=s.create(-J*q),z=s.create(L*q),Q=t.BASE.multiplyUnsafe(G).add(O.multiplyUnsafe(z));if(Q.is0())throw new Error("invalid recovery: point at infinify");return Q.assertValidity(),Q}hasHighS(){return E(this.s)}toBytes(d=x.format){if(rs(d),d==="der")return ot(Et.hexFromSig(this));let{r:A,s:L}=this,N=s.toBytes(A),k=s.toBytes(L);return d==="recovered"?(B(),we(Uint8Array.of(this.assertRecovery()),N,k)):we(N,k)}toHex(d){return nt(this.toBytes(d))}}let P=r.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");let A=Wt(d),L=d.length*8-a;return L>0?A>>BigInt(L):A},F=r.bits2int_modN||function(d){return s.create(P(d))},M=_r(a);function p(b){return Cr("num < 2^"+a,b,at,M),s.toBytes(b)}function m(b,d){return H(b,void 0,"message"),d?H(e(b),void 0,"prehashed message"):b}function _(b,d,A){let{lowS:L,prehash:N,extraEntropy:k}=ts(A,x);b=m(b,N);let K=F(b),O=s.fromBytes(d);if(!s.isValidNot0(O))throw new Error("invalid private key");let q=[p(O),p(K)];if(k!=null&&k!==!1){let Q=k===!0?n(S.secretKey):k;q.push(H(Q,void 0,"extraEntropy"))}let J=we(...q),G=K;function z(Q){let fe=P(Q);if(!s.isValidNot0(fe))return;let qe=s.inv(fe),ee=t.BASE.multiply(fe).toAffine(),he=s.create(ee.x);if(he===at)return;let ln=s.create(qe*s.create(G+he*O));if(ln===at)return;let Rs=(ee.x===he?0:2)|Number(ee.y&sr),Ls=ln;return L&&E(ln)&&(Ls=s.neg(ln),Rs^=1),new U(he,Ls,T?void 0:Rs)}return{seed:J,k2sig:z}}function R(b,d,A={}){let{seed:L,k2sig:N}=_(b,d,A);return Ra(e.outputLen,s.BYTES,o)(L,N).toBytes(A.format)}function I(b,d,A,L={}){let{lowS:N,prehash:k,format:K}=ts(L,x);if(A=H(A,void 0,"publicKey"),d=m(d,k),!Ct(b)){let O=b instanceof U?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+O)}v(b,K);try{let O=U.fromBytes(b,K),q=t.fromBytes(A);if(N&&O.hasHighS())return!1;let{r:J,s:G}=O,z=F(d),Q=s.inv(G),fe=s.create(z*Q),qe=s.create(J*Q),ee=t.BASE.multiplyUnsafe(fe).add(q.multiplyUnsafe(qe));return ee.is0()?!1:s.create(ee.x)===J}catch{return!1}}function y(b,d,A={}){let{prehash:L}=ts(A,x);return d=m(d,L),U.fromBytes(b,"recovered").recoverPublicKey(d).toBytes()}return Object.freeze({keygen:f,getPublicKey:u,getSharedSecret:l,utils:g,lengths:S,Point:t,sign:R,verify:I,recoverPublicKey:y,Signature:U,hash:e})}var is={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Yd={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Dc=BigInt(2);function Gd(t){let e=is.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),f=t*t*t%e,u=f*f*t%e,l=W(u,r,e)*u%e,g=W(l,r,e)*u%e,S=W(g,Dc,e)*f%e,x=W(S,o,e)*S%e,T=W(x,i,e)*x%e,E=W(T,c,e)*T%e,w=W(E,a,e)*E%e,B=W(w,c,e)*T%e,v=W(B,r,e)*u%e,U=W(v,s,e)*x%e,P=W(U,n,e)*f%e,F=W(P,Dc,e);if(!os.eql(os.sqr(F),t))throw new Error("Cannot find square root");return F}var os=Qt(is.p,{sqrt:Gd}),Xd=Cc(is,{Fp:os,endo:Yd}),Oe=Lc(Xd,Xt);function Uc(t,e,r){let n=bn.digest(e instanceof Uint8Array?e:e.subarray());if(nr(n))return n.then(({digest:o})=>(r?.signal?.throwIfAborted(),Oe.sign(o,t,{prehash:!1,format:"der"}))).catch(o=>{throw o.name==="AbortError"?o:new Ur(String(o))});try{return Oe.sign(n.digest,t,{prehash:!1,format:"der"})}catch(o){throw new Ur(String(o))}}function Nc(t,e,r,n){let o=bn.digest(r instanceof Uint8Array?r:r.subarray());if(nr(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),Oe.verify(e,i,t,{prehash:!1,format:"der"}))).catch(i=>{throw i.name==="AbortError"?i:new Nr(String(i))});try{return n?.signal?.throwIfAborted(),Oe.verify(e,o.digest,t,{prehash:!1,format:"der"})}catch(i){throw new Nr(String(i))}}var Hr=class{type="secp256k1";raw;_key;constructor(e){this._key=Pc(e),this.raw=kc(this._key)}toMultihash(){return Tt.digest(ht(this))}toCID(){return se.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ne(this.raw,e.raw)}verify(e,r,n){return Nc(this._key,r,e,n)}},Mn=class{type="secp256k1";raw;publicKey;constructor(e,r){this.raw=Kc(e),this.publicKey=new Hr(r??Oc(e))}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ne(this.raw,e.raw)}sign(e,r){return Uc(this.raw,e,r)}};function ss(t){return new Hr(t)}async function Mc(){let t=Wd();return new Mn(t)}function kc(t){return Oe.Point.fromBytes(t).toBytes()}function Kc(t){try{return Oe.getPublicKey(t,!0),t}catch(e){throw new gr(String(e))}}function Pc(t){try{return Oe.Point.fromBytes(t),t}catch(e){throw new Vt(String(e))}}function Oc(t){try{return Oe.getPublicKey(t,!0)}catch(e){throw new gr(String(e))}}function Wd(){return Oe.utils.randomSecretKey()}async function Fc(t,e){if(t==="Ed25519")return oc();if(t==="secp256k1")return Mc();if(t==="RSA")return Qi(Jd(e));if(t==="ECDSA")return da(Qd(e));throw new qt}function Vc(t,e){let{Type:r,Data:n}=Ge.decode(t),o=n??new Uint8Array;switch(r){case ie.RSA:return Xi(o,e);case ie.Ed25519:return Ri(o);case ie.secp256k1:return ss(o);case ie.ECDSA:return si(o);default:throw new qt}}function qc(t){let{Type:e,Data:r}=Ge.decode(t.digest),n=r??new Uint8Array;switch(e){case ie.Ed25519:return Ri(n);case ie.secp256k1:return ss(n);case ie.ECDSA:return si(n);default:throw new qt}}function ht(t){return Ge.encode({Type:ie[t.type],Data:t.raw})}function Jd(t){return t==null?2048:parseInt(t,10)}function Qd(t){if(t==="P-256"||t==null)return"P-256";if(t==="P-384")return"P-384";if(t==="P-521")return"P-521";throw new te("Unsupported curve, should be P-256, P-384 or P-521")}function eh(t,e){if(typeof t=="string")return th(t);if(typeof t=="number")return oh(t,e);throw Error(`Value provided to ms() must be a string or number. value=${JSON.stringify(t)}`)}var Fn=eh;function th(t){if(typeof t!="string"||t.length===0||t.length>100)throw Error(`Value provided to ms.parse() must be a string with length between 1 and 99. value=${JSON.stringify(t)}`);let e=/^(?<value>-?\d*\.?\d+) *(?<unit>milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.exec(t);if(!e?.groups)return NaN;let{value:r,unit:n="ms"}=e.groups,o=parseFloat(r),i=n.toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return o*315576e5;case"months":case"month":case"mo":return o*26298e5;case"weeks":case"week":case"w":return o*6048e5;case"days":case"day":case"d":return o*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return o*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return o*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return o*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return o;default:throw Error(`Unknown unit "${i}" provided to ms.parse(). value=${JSON.stringify(t)}`)}}function rh(t){let e=Math.abs(t);return e>=315576e5?`${Math.round(t/315576e5)}y`:e>=26298e5?`${Math.round(t/26298e5)}mo`:e>=6048e5?`${Math.round(t/6048e5)}w`:e>=864e5?`${Math.round(t/864e5)}d`:e>=36e5?`${Math.round(t/36e5)}h`:e>=6e4?`${Math.round(t/6e4)}m`:e>=1e3?`${Math.round(t/1e3)}s`:`${t}ms`}function nh(t){let e=Math.abs(t);return e>=315576e5?Pt(t,e,315576e5,"year"):e>=26298e5?Pt(t,e,26298e5,"month"):e>=6048e5?Pt(t,e,6048e5,"week"):e>=864e5?Pt(t,e,864e5,"day"):e>=36e5?Pt(t,e,36e5,"hour"):e>=6e4?Pt(t,e,6e4,"minute"):e>=1e3?Pt(t,e,1e3,"second"):`${t} ms`}function oh(t,e){if(typeof t!="number"||!Number.isFinite(t))throw Error("Value provided to ms.format() must be of type number.");return e?.long?nh(t):rh(t)}function Pt(t,e,r,n){let o=e>=r*1.5;return`${Math.round(t/r)} ${n}${o?"s":""}`}function as(t){r.debug=r,r.default=r,r.coerce=a,r.disable=i,r.enable=o,r.enabled=s,r.humanize=Fn,r.destroy=f,Object.keys(t).forEach(u=>{r[u]=t[u]}),r.names=[],r.skips=[],r.formatters={};function e(u){let l=0;for(let g=0;g<u.length;g++)l=(l<<5)-l+u.charCodeAt(g),l|=0;return r.colors[Math.abs(l)%r.colors.length]}r.selectColor=e;function r(u,l){let g,S=null,x,T;function E(...w){if(!E.enabled)return;let B=E,v=Number(new Date),U=v-(g||v);B.diff=U,B.prev=g,B.curr=v,g=v,w[0]=r.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let P=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(M,p)=>{if(M==="%%")return"%";P++;let m=r.formatters[p];if(typeof m=="function"){let _=w[P];M=m.call(B,_),w.splice(P,1),P--}return M}),r.formatArgs.call(B,w),l?.onLog!=null&&l.onLog(...w),(B.log||r.log).apply(B,w)}return E.namespace=u,E.useColors=r.useColors(),E.color=r.selectColor(u),E.extend=n,E.destroy=r.destroy,Object.defineProperty(E,"enabled",{enumerable:!0,configurable:!1,get:()=>S!==null?S:(x!==r.namespaces&&(x=r.namespaces,T=r.enabled(u)),T),set:w=>{S=w}}),typeof r.init=="function"&&r.init(E),E}function n(u,l){let g=r(this.namespace+(typeof l>"u"?":":l)+u);return g.log=this.log,g}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let l,g=(typeof u=="string"?u:"").split(/[\s,]+/),S=g.length;for(l=0;l<S;l++)g[l]&&(u=g[l].replace(/\*/g,".*?"),u[0]==="-"?r.skips.push(new RegExp("^"+u.substr(1)+"$")):r.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...r.names.map(c),...r.skips.map(c).map(l=>"-"+l)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,g;for(l=0,g=r.skips.length;l<g;l++)if(r.skips[l].test(u))return!1;for(l=0,g=r.names.length;l<g;l++)if(r.names[l].test(u))return!0;return!1}function c(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function a(u){return u instanceof Error?u.stack??u.message:u}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.setupFormatters(r.formatters),r.enable(r.load()),r}var Vn=lh(),ih=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function sh(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/(edge|trident)\/(\d+)/)!=null?!1:typeof document<"u"&&document.documentElement?.style?.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/firefox\/(\d+)/)!=null&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/)}function ah(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+Fn(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}var ch=console.debug??console.log??(()=>{});function uh(t){try{t?Vn?.setItem("debug",t):Vn?.removeItem("debug")}catch{}}function fh(){let t;try{t=Vn?.getItem("debug")}catch{}return!t&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(t=globalThis.process.env.DEBUG),t}function lh(){try{return localStorage}catch{}}function dh(t){t.j=function(e){try{return JSON.stringify(e)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var Hc=as({formatArgs:ah,save:uh,load:fh,useColors:sh,setupFormatters:dh,colors:ih,storage:Vn,log:ch});var Se=Hc;Se.formatters.b=t=>t==null?"undefined":X.baseEncode(t);Se.formatters.t=t=>t==null?"undefined":lt.baseEncode(t);Se.formatters.m=t=>t==null?"undefined":Zo.baseEncode(t);Se.formatters.p=t=>t==null?"undefined":t.toString();Se.formatters.c=t=>t==null?"undefined":t.toString();Se.formatters.k=t=>t==null?"undefined":t.toString();Se.formatters.a=t=>t==null?"undefined":t.toString();function $c(t,e=""){let r=zc(t.message),n=zc(t.stack);return r!=null&&n!=null?n.includes(r)?`${n.split(`
2
+ "use strict";var HeliaIpns=(()=>{var vf=Object.create;var dn=Object.defineProperty;var Af=Object.getOwnPropertyDescriptor;var If=Object.getOwnPropertyNames;var Tf=Object.getPrototypeOf,Bf=Object.prototype.hasOwnProperty;var Cf=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),xe=(t,e)=>{for(var r in e)dn(t,r,{get:e[r],enumerable:!0})},Ds=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of If(e))!Bf.call(t,o)&&o!==r&&dn(t,o,{get:()=>e[o],enumerable:!(n=Af(e,o))||n.enumerable});return t};var Do=(t,e,r)=>(r=t!=null?vf(Tf(t)):{},Ds(e||!t||!t.__esModule?dn(r,"default",{value:t,enumerable:!0}):r,t)),_f=t=>Ds(dn({},"__esModule",{value:!0}),t);var qn=Cf((Wg,cs)=>{var Xg=(function(){typeof cs<"u"&&(cs.exports=T);var t=86400,e=3200,r=146097*e/400,n=t*r,o=1e3*n,i=864e13,s=4294967296,c=1e6,a="000000000",f=Math.trunc||function(p){var m=p-p%1;return m==0&&(p<0||p===0&&1/p!=1/0)?-0:m},u=T.prototype,l=(T.fromDate=function(p){return new T(+p)},T.fromInt64BE=U(0,1,2,3,0,4),T.fromInt64LE=U(3,2,1,0,4,0),T.fromString=function(L){var m,_=new T,L=(L+="").replace(/^\s*[+\-]?\d+/,function(y){var y=+y,b=1970+(y-1970)%400;return _.year=y-b,b}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(I,y,b){return y<0&&(b*=-1),m=6e4*(60*+y+ +b),""}).replace(/\.\d+$/,function(I){return _.nano=+(I+a).substr(1,9),""}).split(/\D+/);if(1<L.length?L[1]--:L[1]=0,_.time=m=Date.UTC.apply(Date,L)-(m||0),isNaN(m))throw new TypeError("Invalid Date");return E(_)},T.fromTimeT=function(p){return B(p,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(p){return this.nano+=+p||0,this},u.getNano=function(){var p=E(this);return(p.time%1e3*c+ +p.nano+1e9)%1e9},u.getTimeT=function(){var m=E(this),p=Math.floor(m.time/1e3),m=m.year;return m&&(p+=m*r*t/e),p},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return w(E(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(p){var m=this,_=m.toDate(),L={H:function(){return F(_.getUTCHours())},L:function(){return M(_.getUTCMilliseconds(),3)},M:function(){return F(_.getUTCMinutes())},N:function(){return M(m.getNano(),9)},S:function(){return F(_.getUTCSeconds())},Y:function(){var I=m.getYear();return 999999<I?"+"+I:9999<I?"+"+M(I,6):0<=I?M(I,4):-999999<=I?"-"+M(-I,6):I},a:function(){return S[_.getUTCDay()]},b:function(){return g[_.getUTCMonth()]},d:function(){return F(_.getUTCDate())},e:function(){return(function(I){return(9<I?"":" ")+(0|I)})(_.getUTCDate())},m:function(){return F(_.getUTCMonth()+1)}};return(function I(y){return y.replace(/%./g,function(b){var A=b[1],d=x[A],A=L[A];return d?I(d):A?A():b})})(p||l)},u.writeInt64BE=v(0,1,2,3,0,4),u.writeInt64LE=v(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),g=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],S=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],x={"%":"%",F:"%Y-%m-%d",n:`
3
+ `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return T;function T(p,m,_){var L=this;if(!(L instanceof T))return new T(p,m,_);L.time=+p||0,L.nano=+m||0,L.year=+_||0,E(L)}function E(p){var m,_,L,I=p.year,y=p.time,b=p.nano,d=((b<0||c<=b)&&(b-=(_=Math.floor(b/c))*c,y+=_,_=1),I%e);return(y<-i||i<y||d)&&((m=f(y/o))&&(I+=m*e,y-=m*o),(L=w(y)).setUTCFullYear(d+L.getUTCFullYear()),L=(y=+L)+(m=f((I-=d)/e))*o,m&&-i<=L&&L<=i&&(I-=m*e,y=L),_=1),_&&(p.year=I,p.time=y,p.nano=b),p}function w(p){var m=new Date(0);return m.setTime(p),m}function B(I,L){I=+I||0;var _=f((L=(L|0)*s)/n)+f(I/n),L=L%n+I%n,I=f(L/n);return I&&(_+=I,L-=I*n),new T(1e3*L,0,_*e)}function v(p,m,_,L,I,y){return function(d,A){var N=E(this);d=d||new Array(8),P(d,A|=0);var k=Math.floor(N.time/1e3),N=N.year*(r*t/e),R=f(N/s)+f(k/s),N=N%s+k%s,k=Math.floor(N/s);return k&&(R+=k,N-=k*s),b(d,A+I,R),b(d,A+y,N),d};function b(d,A,R){d[A+p]=R>>24&255,d[A+m]=R>>16&255,d[A+_]=R>>8&255,d[A+L]=255&R}}function U(p,m,_,L,I,y){return function(d,A){P(d,A|=0);var R=b(d,A+I);return B(b(d,A+y),R)};function b(d,A){return 16777216*d[A+p]+(d[A+m]<<16|d[A+_]<<8|d[A+L])}}function P(p,m){if(p=p&&p.length,p==null)throw new TypeError("Invalid Buffer");if(p<m+8)throw new RangeError("Out of range")}function F(p){return(9<p?"":"0")+(0|p)}function M(p,m){return(a+(0|p)).substr(-m)}})()});var Cp={};xe(Cp,{ipns:()=>Tp,ipnsResolver:()=>Bp,ipnsSelector:()=>ho,ipnsValidator:()=>nn});var Je=class extends Error{static name="AbortError";constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var te=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},Vt=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}},gr=class extends Error{static name="InvalidPrivateKeyError";constructor(e="Invalid private key"){super(e),this.name="InvalidPrivateKeyError"}};var hn=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var qt=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};function Us(t){return t==null?!1:(t.type==="RSA"||t.type==="Ed25519"||t.type==="secp256k1"||t.type==="ECDSA")&&t.raw instanceof Uint8Array&&typeof t.equals=="function"&&typeof t.toMultihash=="function"&&typeof t.toCID=="function"&&typeof t.verify=="function"}var Lf=Symbol.for("@libp2p/peer-id");function pn(t){return!!t?.[Lf]}var mn=class extends EventTarget{#e=new Map;constructor(){super()}listenerCount(e){let r=this.#e.get(e);return r==null?0:r.length}addEventListener(e,r,n){super.addEventListener(e,r,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:r,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,r,n){super.removeEventListener(e.toString(),r??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:i})=>i!==r),this.#e.set(e,o))}dispatchEvent(e){let r=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),r}safeDispatchEvent(e,r={}){return this.dispatchEvent(new CustomEvent(e,r))}};var Po={};xe(Po,{base58btc:()=>X,base58flickr:()=>Pf});var Np=new Uint8Array(0);function Ns(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function Qe(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function ks(t){return new TextEncoder().encode(t)}function Ks(t){return new TextDecoder().decode(t)}function Rf(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var c=t.length,a=t.charAt(0),f=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function l(x){if(x instanceof Uint8Array||(ArrayBuffer.isView(x)?x=new Uint8Array(x.buffer,x.byteOffset,x.byteLength):Array.isArray(x)&&(x=Uint8Array.from(x))),!(x instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(x.length===0)return"";for(var T=0,E=0,w=0,B=x.length;w!==B&&x[w]===0;)w++,T++;for(var v=(B-w)*u+1>>>0,U=new Uint8Array(v);w!==B;){for(var P=x[w],F=0,M=v-1;(P!==0||F<E)&&M!==-1;M--,F++)P+=256*U[M]>>>0,U[M]=P%c>>>0,P=P/c>>>0;if(P!==0)throw new Error("Non-zero carry");E=F,w++}for(var p=v-E;p!==v&&U[p]===0;)p++;for(var m=a.repeat(T);p<v;++p)m+=t.charAt(U[p]);return m}function g(x){if(typeof x!="string")throw new TypeError("Expected String");if(x.length===0)return new Uint8Array;var T=0;if(x[T]!==" "){for(var E=0,w=0;x[T]===a;)E++,T++;for(var B=(x.length-T)*f+1>>>0,v=new Uint8Array(B);x[T];){var U=r[x.charCodeAt(T)];if(U===255)return;for(var P=0,F=B-1;(U!==0||P<w)&&F!==-1;F--,P++)U+=c*v[F]>>>0,v[F]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");w=P,T++}if(x[T]!==" "){for(var M=B-w;M!==B&&v[M]===0;)M++;for(var p=new Uint8Array(E+(B-M)),m=E;M!==B;)p[m++]=v[M++];return p}}}function S(x){var T=g(x);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:g,decode:S}}var Df=Rf,Uf=Df,Os=Uf;var Uo=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},No=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ms(this,e)}},ko=class{decoders;constructor(e){this.decoders=e}or(e){return Ms(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ms(t,e){return new ko({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var Ko=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Uo(e,r,n),this.decoder=new No(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Ht({name:t,prefix:e,encode:r,decode:n}){return new Ko(t,e,r,n)}function ft({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=Os(r,t);return Ht({prefix:e,name:t,encode:n,decode:i=>Qe(o(i))})}function Nf(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,c=0,a=0;for(let f=0;f<o;++f){let u=e[t[f]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|u,s+=r,s>=8&&(s-=8,i[a++]=255&c>>s)}if(s>=r||(255&c<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function kf(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,c=0;for(let a=0;a<t.length;++a)for(c=c<<8|t[a],s+=8;s>r;)s-=r,i+=e[o&c>>s];if(s!==0&&(i+=e[o&c<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function Kf(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function re({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=Kf(n);return Ht({prefix:e,name:t,encode(i){return kf(i,n,r)},decode(i){return Nf(i,o,r,t)}})}var X=ft({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Pf=ft({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Oo={};xe(Oo,{base32:()=>lt,base32hex:()=>Vf,base32hexpad:()=>Hf,base32hexpadupper:()=>$f,base32hexupper:()=>qf,base32pad:()=>Mf,base32padupper:()=>Ff,base32upper:()=>Of,base32z:()=>zf});var lt=re({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Of=re({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Mf=re({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ff=re({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Vf=re({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),qf=re({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Hf=re({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),$f=re({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),zf=re({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Mo={};xe(Mo,{base36:()=>Ne,base36upper:()=>jf});var Ne=ft({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),jf=ft({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Zf=qs,Fs=128,Yf=127,Gf=~Yf,Xf=Math.pow(2,31);function qs(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Xf;)e[r++]=t&255|Fs,t/=128;for(;t&Gf;)e[r++]=t&255|Fs,t>>>=7;return e[r]=t|0,qs.bytes=r-n+1,e}var Wf=Fo,Jf=128,Vs=127;function Fo(t,n){var r=0,n=n||0,o=0,i=n,s,c=t.length;do{if(i>=c)throw Fo.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&Vs)<<o:(s&Vs)*Math.pow(2,o),o+=7}while(s>=Jf);return Fo.bytes=i-n,r}var Qf=Math.pow(2,7),el=Math.pow(2,14),tl=Math.pow(2,21),rl=Math.pow(2,28),nl=Math.pow(2,35),ol=Math.pow(2,42),il=Math.pow(2,49),sl=Math.pow(2,56),al=Math.pow(2,63),cl=function(t){return t<Qf?1:t<el?2:t<tl?3:t<rl?4:t<nl?5:t<ol?6:t<il?7:t<sl?8:t<al?9:10},ul={encode:Zf,decode:Wf,encodingLength:cl},fl=ul,br=fl;function xr(t,e=0){return[br.decode(t,e),br.decode.bytes]}function $t(t,e,r=0){return br.encode(t,e,r),e}function zt(t){return br.encodingLength(t)}function He(t,e){let r=e.byteLength,n=zt(t),o=n+zt(r),i=new Uint8Array(o+r);return $t(t,i,0),$t(r,i,n),i.set(e,o),new jt(t,r,e,i)}function Zt(t){let e=Qe(t),[r,n]=xr(e),[o,i]=xr(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new jt(r,o,s,e)}function Hs(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Ns(t.bytes,r.bytes)}}var jt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function $s(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return dl(r,Vo(t),e??X.encoder);default:return hl(r,Vo(t),e??lt.encoder)}}var zs=new WeakMap;function Vo(t){let e=zs.get(t);if(e==null){let r=new Map;return zs.set(t,r),r}return e}var se=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,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:e,multihash:r}=this;if(e!==wr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==pl)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=He(e,r);return t.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(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&Hs(e.multihash,n.multihash)}toString(e){return $s(this,e)}toJSON(){return{"/":$s(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new t(n,o,i,s??js(n,o,i.bytes))}else if(r[ml]===!0){let{version:n,multihash:o,code:i}=r,s=Zt(o);return t.create(n,i,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==wr)throw new Error(`Version 0 CID must use dag-pb (code: ${wr}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=js(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,wr,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=Qe(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new jt(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,g]=xr(e.subarray(r));return r+=g,l},o=n(),i=wr;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,c=n(),a=n(),f=r+a,u=f-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:u,size:f}}static parse(e,r){let[n,o]=ll(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Vo(i).set(n,e),i}};function ll(t,e){switch(t[0]){case"Q":{let r=e??X;return[X.prefix,r.decode(`${X.prefix}${t}`)]}case X.prefix:{let r=e??X;return[X.prefix,r.decode(t)]}case lt.prefix:{let r=e??lt;return[lt.prefix,r.decode(t)]}case Ne.prefix:{let r=e??Ne;return[Ne.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function dl(t,e,r){let{prefix:n}=r;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o}function hl(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o}var wr=112,pl=18;function js(t,e,r){let n=zt(t),o=n+zt(e),i=new Uint8Array(o+r.byteLength);return $t(t,i,0),$t(e,i,n),i.set(r,o),i}var ml=Symbol.for("@ipld/js-cid/CID");var qo={};xe(qo,{identity:()=>Tt});var Zs=0,yl="identity",Ys=Qe;function gl(t,e){if(e?.truncate!=null&&e.truncate!==t.byteLength){if(e.truncate<0||e.truncate>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e.truncate)}return He(Zs,Ys(t))}var Tt={code:Zs,name:yl,encode:Ys,digest:gl};function ne(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function Re(t=0){return new Uint8Array(t)}function Ae(t=0){return new Uint8Array(t)}function dt(t,e){e==null&&(e=t.reduce((o,i)=>o+i.length,0));let r=Ae(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}var Xs=Symbol.for("@achingbrain/uint8arraylist");function Gs(t,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let r=0;for(let n of t){let o=r+n.byteLength;if(e<o)return{buf:n,index:e-r};r=o}throw new RangeError("index is out of bounds")}function gn(t){return!!t?.[Xs]}var me=class t{bufs;length;[Xs]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let r=0;for(let n of e)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(gn(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...e){this.prependAll(e)}prependAll(e){let r=0;for(let n of e.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(gn(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(e){let r=Gs(this.bufs,e);return r.buf[r.index]}set(e,r){let n=Gs(this.bufs,e);n.buf[n.index]=r}write(e,r=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(r+n,e[n]);else if(gn(e))for(let n=0;n<e.length;n++)this.set(r+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,r){let{bufs:n,length:o}=this._subList(e,r);return dt(n,o)}subarray(e,r){let{bufs:n,length:o}=this._subList(e,r);return n.length===1?n[0]:dt(n,o)}sublist(e,r){let{bufs:n,length:o}=this._subList(e,r),i=new t;return i.length=o,i.bufs=[...n],i}_subList(e,r){if(e=e??0,r=r??this.length,e<0&&(e=this.length+e),r<0&&(r=this.length+r),e<0||r>this.length)throw new RangeError("index is out of bounds");if(e===r)return{bufs:[],length:0};if(e===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],c=o,a=c+s.byteLength;if(o=a,e>=a)continue;let f=e>=c&&e<a,u=r>c&&r<=a;if(f&&u){if(e===c&&r===a){n.push(s);break}let l=e-c;n.push(s.subarray(l,l+(r-e)));break}if(f){if(e===0){n.push(s);continue}n.push(s.subarray(e-c));continue}if(u){if(r===a){n.push(s);break}n.push(s.subarray(0,r-c));break}n.push(s)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!gn(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),e.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let c=s,a=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=r;l<=a;l+=u){u=0;for(let g=f;g>=0;g--){let S=this.get(l+g);if(n[g]!==S){u=Math.max(1,g-c[S]);break}}if(u===0)return l}return-1}getInt8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(e,r){let n=Ae(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,e)}getInt16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(e,r,n){let o=Re(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,e)}getInt32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(e,r,n){let o=Re(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,e)}getBigInt64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(e,r,n){let o=Re(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,e)}getUint8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(e,r){let n=Ae(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,e)}getUint16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(e,r,n){let o=Re(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,e)}getUint32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(e,r,n){let o=Re(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,e)}getBigUint64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(e,r,n){let o=Re(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,e)}getFloat32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(e,r,n){let o=Re(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,e)}getFloat64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(e,r,n){let o=Re(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof t)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!ne(this.bufs[r],e.bufs[r]))return!1;return!0}static fromUint8Arrays(e,r){let n=new t;return n.bufs=e,r==null&&(r=e.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var Ho={};xe(Ho,{base10:()=>bl});var bl=ft({prefix:"9",name:"base10",alphabet:"0123456789"});var $o={};xe($o,{base16:()=>xl,base16upper:()=>wl});var xl=re({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),wl=re({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var zo={};xe(zo,{base2:()=>El});var El=re({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var jo={};xe(jo,{base256emoji:()=>Tl});var Ws=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}"),Sl=Ws.reduce((t,e,r)=>(t[r]=e,t),[]),vl=Ws.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function Al(t){return t.reduce((e,r)=>(e+=Sl[r],e),"")}function Il(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=vl[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Tl=Ht({prefix:"\u{1F680}",name:"base256emoji",encode:Al,decode:Il});var Yo={};xe(Yo,{base64:()=>Zo,base64pad:()=>Bl,base64url:()=>Cl,base64urlpad:()=>_l});var Zo=re({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Bl=re({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Cl=re({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_l=re({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Go={};xe(Go,{base8:()=>Ll});var Ll=re({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Xo={};xe(Xo,{identity:()=>Rl});var Rl=Ht({prefix:"\0",name:"identity",encode:t=>Ks(t),decode:t=>ks(t)});var g0=new TextEncoder,b0=new TextDecoder;var Qo={};xe(Qo,{sha256:()=>bn,sha512:()=>kl});var Nl=20;function Jo({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new Wo(t,e,r,n,o)}var Wo=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,i){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Nl,this.maxDigestLength=i}digest(e,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?Js(n,this.code,r?.truncate):n.then(o=>Js(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Js(t,e,r){if(r!=null&&r!==t.byteLength){if(r>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,r)}return He(e,t)}function ea(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var bn=Jo({name:"sha2-256",code:18,encode:ea("SHA-256")}),kl=Jo({name:"sha2-512",code:19,encode:ea("SHA-512")});var ei={...Xo,...zo,...Go,...Ho,...$o,...Oo,...Mo,...Po,...Yo,...jo},L0={...Qo,...qo};function ra(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var ta=ra("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),ti=ra("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Ae(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Kl={utf8:ta,"utf-8":ta,hex:ei.base16,latin1:ti,ascii:ti,binary:ti,...ei},xn=Kl;function $(t,e="utf8"){let r=xn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}function Z(t,e="utf8"){let r=xn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.encoder.encode(t).substring(1)}var Pl=parseInt("11111",2),ri=parseInt("10000000",2),Ol=parseInt("01111111",2),na={0:Er,1:Er,2:Ml,3:ql,4:Hl,5:Vl,6:Fl,16:Er,22:Er,48:Er};function et(t,e={offset:0}){let r=t[e.offset]&Pl;if(e.offset++,na[r]!=null)return na[r](t,e);throw new Error("No decoder for tag "+r)}function Sr(t,e){let r=0;if((t[e.offset]&ri)===ri){let n=t[e.offset]&Ol,o="0x";e.offset++;for(let i=0;i<n;i++,e.offset++)o+=t[e.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=t[e.offset],e.offset++;return r}function Er(t,e){Sr(t,e);let r=[];for(;!(e.offset>=t.byteLength);){let n=et(t,e);if(n===null)break;r.push(n)}return r}function Ml(t,e){let r=Sr(t,e),n=e.offset,o=e.offset+r,i=[];for(let s=n;s<o;s++)s===n&&t[s]===0||i.push(t[s]);return e.offset+=r,Uint8Array.from(i)}function Fl(t,e){let r=Sr(t,e),n=e.offset+r,o=t[e.offset];e.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let c=`${i}.${s}`,a=[];for(;e.offset<n;){let f=t[e.offset];if(e.offset++,a.push(f&127),f<128){a.reverse();let u=0;for(let l=0;l<a.length;l++)u+=a[l]<<l*7;c+=`.${u}`,a=[]}}return c}function Vl(t,e){return e.offset++,null}function ql(t,e){let r=Sr(t,e),n=t[e.offset];e.offset++;let o=t.subarray(e.offset,e.offset+r-1);if(e.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Hl(t,e){let r=Sr(t,e),n=t.subarray(e.offset,e.offset+r);return e.offset+=r,n}function $l(t){let e=t.toString(16);e.length%2===1&&(e="0"+e);let r=new me;for(let n=0;n<e.length;n+=2)r.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return r}function wn(t){if(t.byteLength<128)return Uint8Array.from([t.byteLength]);let e=$l(t.byteLength);return new me(Uint8Array.from([e.byteLength|ri]),e)}function ye(t){let e=new me,r=128;return(t.subarray()[0]&r)===r&&e.append(Uint8Array.from([0])),e.append(t),new me(Uint8Array.from([2]),wn(e),e)}function vr(t){let e=Uint8Array.from([0]),r=new me(e,t);return new me(Uint8Array.from([3]),wn(r),r)}function oa(t){return new me(Uint8Array.from([4]),wn(t),t)}function ke(t,e=48){let r=new me;for(let n of t)r.append(n);return new me(Uint8Array.from([e]),wn(r),r)}async function ia(t="P-256"){let e=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:t},!0,["sign","verify"]);return{publicKey:await crypto.subtle.exportKey("jwk",e.publicKey),privateKey:await crypto.subtle.exportKey("jwk",e.privateKey)}}async function sa(t,e,r){let n=await crypto.subtle.importKey("jwk",t,{name:"ECDSA",namedCurve:t.crv??"P-256"},!1,["sign"]);r?.signal?.throwIfAborted();let o=await crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},n,e.subarray());return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function aa(t,e,r,n){let o=await crypto.subtle.importKey("jwk",t,{name:"ECDSA",namedCurve:t.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,e,r.subarray());return n?.signal?.throwIfAborted(),i}var zl=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),jl=Uint8Array.from([6,5,43,129,4,0,34]),Zl=Uint8Array.from([6,5,43,129,4,0,35]),Yl={ext:!0,kty:"EC",crv:"P-256"},Gl={ext:!0,kty:"EC",crv:"P-384"},Xl={ext:!0,kty:"EC",crv:"P-521"},ni=32,oi=48,ii=66;function si(t){let e=et(t);return ca(e)}function ca(t){let e=t[1][1][0],r=1,n,o;if(e.byteLength===ni*2+1)return n=Z(e.subarray(r,r+ni),"base64url"),o=Z(e.subarray(r+ni),"base64url"),new Bt({...Yl,key_ops:["verify"],x:n,y:o});if(e.byteLength===oi*2+1)return n=Z(e.subarray(r,r+oi),"base64url"),o=Z(e.subarray(r+oi),"base64url"),new Bt({...Gl,key_ops:["verify"],x:n,y:o});if(e.byteLength===ii*2+1)return n=Z(e.subarray(r,r+ii),"base64url"),o=Z(e.subarray(r+ii),"base64url"),new Bt({...Xl,key_ops:["verify"],x:n,y:o});throw new te(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function ua(t){return ke([ye(Uint8Array.from([1])),oa($(t.d??"","base64url")),ke([la(t.crv)],160),ke([vr(new me(Uint8Array.from([4]),$(t.x??"","base64url"),$(t.y??"","base64url")))],161)]).subarray()}function fa(t){return ke([ye(Uint8Array.from([1])),ke([la(t.crv)],160),ke([vr(new me(Uint8Array.from([4]),$(t.x??"","base64url"),$(t.y??"","base64url")))],161)]).subarray()}function la(t){if(t==="P-256")return zl;if(t==="P-384")return jl;if(t==="P-521")return Zl;throw new te(`Invalid curve ${t}`)}async function da(t="P-256"){let e=await ia(t);return new En(e.privateKey)}var Bt=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=fa(this.jwk)),this._raw}toMultihash(){return Tt.digest(ht(this))}toCID(){return se.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ne(this.raw,e.raw)}async verify(e,r,n){return aa(this.jwk,r,e,n)}},En=class{type="ECDSA";jwk;publicKey;_raw;constructor(e){this.jwk=e,this.publicKey=new Bt({crv:e.crv,ext:e.ext,key_ops:["verify"],kty:"EC",x:e.x,y:e.y})}get raw(){return this._raw==null&&(this._raw=ua(this.jwk)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ne(this.raw,e.raw)}async sign(e,r){return sa(this.jwk,e,r)}};function Ct(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function $e(t,e=""){if(!Number.isSafeInteger(t)||t<0){let r=e&&`"${e}" `;throw new Error(`${r}expected integer >= 0, got ${t}`)}}function H(t,e,r=""){let n=Ct(t),o=t?.length,i=e!==void 0;if(!n||i&&o!==e){let s=r&&`"${r}" `,c=i?` of length ${e}`:"",a=n?`length=${o}`:`type=${typeof t}`;throw new Error(s+"expected Uint8Array"+c+", got "+a)}return t}function Sn(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash must wrapped by utils.createHasher");$e(t.outputLen),$e(t.blockLen)}function Yt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function pa(t,e){H(t,void 0,"digestInto() output");let r=e.outputLen;if(t.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function rt(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function vn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ke(t,e){return t<<32-e|t>>>e}var ma=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Wl=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function nt(t){if(H(t),ma)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=Wl[t[r]];return e}var tt={_0:48,_9:57,A:65,F:70,a:97,f:102};function ha(t){if(t>=tt._0&&t<=tt._9)return t-tt._0;if(t>=tt.A&&t<=tt.F)return t-(tt.A-10);if(t>=tt.a&&t<=tt.f)return t-(tt.a-10)}function ot(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(ma)return Uint8Array.fromHex(t);let e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=ha(t.charCodeAt(i)),c=ha(t.charCodeAt(i+1));if(s===void 0||c===void 0){let a=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+i)}n[o]=s*16+c}return n}function we(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];H(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}function ai(t,e={}){let r=(o,i)=>t(i).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function Gt(t=32){let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(t))}var ci=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function ya(t,e,r){return t&e^~t&r}function ga(t,e,r){return t&e^t&r^e&r}var Ar=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,r,n,o){this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=vn(this.buffer)}update(e){Yt(this),H(e);let{view:r,buffer:n,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=vn(e);for(;o<=i-s;s+=o)this.process(a,s);continue}n.set(e.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Yt(this),pa(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,rt(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let c=vn(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let f=a/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)c.setUint32(4*l,u[l],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:c}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=c,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},it=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var le=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var An=BigInt(4294967295),ba=BigInt(32);function Jl(t,e=!1){return e?{h:Number(t&An),l:Number(t>>ba&An)}:{h:Number(t>>ba&An)|0,l:Number(t&An)|0}}function xa(t,e=!1){let r=t.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:c}=Jl(t[i],e);[n[i],o[i]]=[s,c]}return[n,o]}var ui=(t,e,r)=>t>>>r,fi=(t,e,r)=>t<<32-r|e>>>r,_t=(t,e,r)=>t>>>r|e<<32-r,Lt=(t,e,r)=>t<<32-r|e>>>r,Ir=(t,e,r)=>t<<64-r|e>>>r-32,Tr=(t,e,r)=>t>>>r-32|e<<64-r;function ze(t,e,r,n){let o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:o|0}}var wa=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Ea=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Sa=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),va=(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,Aa=(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Ia=(t,e,r,n,o,i)=>e+r+n+o+i+(t/2**32|0)|0;var ed=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),pt=new Uint32Array(64),li=class extends Ar{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:c,H:a}=this;return[e,r,n,o,i,s,c,a]}set(e,r,n,o,i,s,c,a){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}process(e,r){for(let l=0;l<16;l++,r+=4)pt[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let g=pt[l-15],S=pt[l-2],x=Ke(g,7)^Ke(g,18)^g>>>3,T=Ke(S,17)^Ke(S,19)^S>>>10;pt[l]=T+pt[l-7]+x+pt[l-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:f,H:u}=this;for(let l=0;l<64;l++){let g=Ke(c,6)^Ke(c,11)^Ke(c,25),S=u+g+ya(c,a,f)+ed[l]+pt[l]|0,T=(Ke(n,2)^Ke(n,13)^Ke(n,22))+ga(n,o,i)|0;u=f,f=a,a=c,c=s+S|0,s=i,i=o,o=n,n=S+T|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,c,a,f,u)}roundClean(){rt(pt)}destroy(){this.set(0,0,0,0,0,0,0,0),rt(this.buffer)}},di=class extends li{A=it[0]|0;B=it[1]|0;C=it[2]|0;D=it[3]|0;E=it[4]|0;F=it[5]|0;G=it[6]|0;H=it[7]|0;constructor(){super(32)}};var Ta=xa(["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(t=>BigInt(t))),td=Ta[0],rd=Ta[1],mt=new Uint32Array(80),yt=new Uint32Array(80),hi=class extends Ar{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:c,Dl:a,Eh:f,El:u,Fh:l,Fl:g,Gh:S,Gl:x,Hh:T,Hl:E}=this;return[e,r,n,o,i,s,c,a,f,u,l,g,S,x,T,E]}set(e,r,n,o,i,s,c,a,f,u,l,g,S,x,T,E){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=a|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=g|0,this.Gh=S|0,this.Gl=x|0,this.Hh=T|0,this.Hl=E|0}process(e,r){for(let v=0;v<16;v++,r+=4)mt[v]=e.getUint32(r),yt[v]=e.getUint32(r+=4);for(let v=16;v<80;v++){let U=mt[v-15]|0,P=yt[v-15]|0,F=_t(U,P,1)^_t(U,P,8)^ui(U,P,7),M=Lt(U,P,1)^Lt(U,P,8)^fi(U,P,7),p=mt[v-2]|0,m=yt[v-2]|0,_=_t(p,m,19)^Ir(p,m,61)^ui(p,m,6),L=Lt(p,m,19)^Tr(p,m,61)^fi(p,m,6),I=Sa(M,L,yt[v-7],yt[v-16]),y=va(I,F,_,mt[v-7],mt[v-16]);mt[v]=y|0,yt[v]=I|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:f,Dl:u,Eh:l,El:g,Fh:S,Fl:x,Gh:T,Gl:E,Hh:w,Hl:B}=this;for(let v=0;v<80;v++){let U=_t(l,g,14)^_t(l,g,18)^Ir(l,g,41),P=Lt(l,g,14)^Lt(l,g,18)^Tr(l,g,41),F=l&S^~l&T,M=g&x^~g&E,p=Aa(B,P,M,rd[v],yt[v]),m=Ia(p,w,U,F,td[v],mt[v]),_=p|0,L=_t(n,o,28)^Ir(n,o,34)^Ir(n,o,39),I=Lt(n,o,28)^Tr(n,o,34)^Tr(n,o,39),y=n&i^n&c^i&c,b=o&s^o&a^s&a;w=T|0,B=E|0,T=S|0,E=x|0,S=l|0,x=g|0,{h:l,l:g}=ze(f|0,u|0,m|0,_|0),f=c|0,u=a|0,c=i|0,a=s|0,i=n|0,s=o|0;let d=wa(_,I,b);n=Ea(d,m,L,y),o=d|0}({h:n,l:o}=ze(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=ze(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=ze(this.Ch|0,this.Cl|0,c|0,a|0),{h:f,l:u}=ze(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:g}=ze(this.Eh|0,this.El|0,l|0,g|0),{h:S,l:x}=ze(this.Fh|0,this.Fl|0,S|0,x|0),{h:T,l:E}=ze(this.Gh|0,this.Gl|0,T|0,E|0),{h:w,l:B}=ze(this.Hh|0,this.Hl|0,w|0,B|0),this.set(n,o,i,s,c,a,f,u,l,g,S,x,T,E,w,B)}roundClean(){rt(mt,yt)}destroy(){rt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},pi=class extends hi{Ah=le[0]|0;Al=le[1]|0;Bh=le[2]|0;Bl=le[3]|0;Ch=le[4]|0;Cl=le[5]|0;Dh=le[6]|0;Dl=le[7]|0;Eh=le[8]|0;El=le[9]|0;Fh=le[10]|0;Fl=le[11]|0;Gh=le[12]|0;Gl=le[13]|0;Hh=le[14]|0;Hl=le[15]|0;constructor(){super(64)}};var Xt=ai(()=>new di,ci(1));var Ba=ai(()=>new pi,ci(3));var yi=BigInt(0),mi=BigInt(1);function st(t,e=""){if(typeof t!="boolean"){let r=e&&`"${e}" `;throw new Error(r+"expected boolean, got type="+typeof t)}return t}function Ca(t){if(typeof t=="bigint"){if(!In(t))throw new Error("positive bigint expected, got "+t)}else $e(t);return t}function Br(t){let e=Ca(t).toString(16);return e.length&1?"0"+e:e}function _a(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?yi:BigInt("0x"+t)}function Wt(t){return _a(nt(t))}function Rt(t){return _a(nt(Bn(H(t)).reverse()))}function Tn(t,e){$e(e),t=Ca(t);let r=ot(t.toString(16).padStart(e*2,"0"));if(r.length!==e)throw new Error("number too large");return r}function gi(t,e){return Tn(t,e).reverse()}function Bn(t){return Uint8Array.from(t)}var In=t=>typeof t=="bigint"&&yi<=t;function nd(t,e,r){return In(t)&&In(e)&&In(r)&&e<=t&&t<r}function Cr(t,e,r,n){if(!nd(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function bi(t){let e;for(e=0;t>yi;t>>=mi,e+=1);return e}var _r=t=>(mi<<BigInt(t))-mi;function La(t,e,r){if($e(t,"hashLen"),$e(e,"qByteLen"),typeof r!="function")throw new Error("hmacFn must be a function");let n=E=>new Uint8Array(E),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),c=1e3,a=n(t),f=n(t),u=0,l=()=>{a.fill(1),f.fill(0),u=0},g=(...E)=>r(f,we(a,...E)),S=(E=o)=>{f=g(i,E),a=g(),E.length!==0&&(f=g(s,E),a=g())},x=()=>{if(u++>=c)throw new Error("drbg: tried max amount of iterations");let E=0,w=[];for(;E<e;){a=g();let B=a.slice();w.push(B),E+=a.length}return we(...w)};return(E,w)=>{l(),S(E);let B;for(;!(B=w(x()));)S();return l(),B}}function gt(t,e={},r={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function n(i,s,c){let a=t[i];if(c&&a===void 0)return;let f=typeof a;if(f!==s||a===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${f}`)}let o=(i,s)=>Object.entries(i).forEach(([c,a])=>n(c,a,s));o(e,!1),o(r,!0)}function Jt(t){let e=new WeakMap;return(r,...n)=>{let o=e.get(r);if(o!==void 0)return o;let i=t(r,...n);return e.set(r,i),i}}var ge=BigInt(0),ae=BigInt(1),Dt=BigInt(2),Ua=BigInt(3),Na=BigInt(4),ka=BigInt(5),od=BigInt(7),Ka=BigInt(8),id=BigInt(9),Pa=BigInt(16);function oe(t,e){let r=t%e;return r>=ge?r:e+r}function W(t,e,r){let n=t;for(;e-- >ge;)n*=n,n%=r;return n}function Ra(t,e){if(t===ge)throw new Error("invert: expected non-zero number");if(e<=ge)throw new Error("invert: expected positive modulus, got "+e);let r=oe(t,e),n=e,o=ge,i=ae,s=ae,c=ge;for(;r!==ge;){let f=n/r,u=n%r,l=o-s*f,g=i-c*f;n=r,r=u,o=s,i=c,s=l,c=g}if(n!==ae)throw new Error("invert: does not exist");return oe(o,e)}function wi(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function Oa(t,e){let r=(t.ORDER+ae)/Na,n=t.pow(e,r);return wi(t,n,e),n}function sd(t,e){let r=(t.ORDER-ka)/Ka,n=t.mul(e,Dt),o=t.pow(n,r),i=t.mul(e,o),s=t.mul(t.mul(i,Dt),o),c=t.mul(i,t.sub(s,t.ONE));return wi(t,c,e),c}function ad(t){let e=Qt(t),r=Ma(t),n=r(e,e.neg(e.ONE)),o=r(e,n),i=r(e,e.neg(n)),s=(t+od)/Pa;return(c,a)=>{let f=c.pow(a,s),u=c.mul(f,n),l=c.mul(f,o),g=c.mul(f,i),S=c.eql(c.sqr(u),a),x=c.eql(c.sqr(l),a);f=c.cmov(f,u,S),u=c.cmov(g,l,x);let T=c.eql(c.sqr(u),a),E=c.cmov(f,u,T);return wi(c,E,a),E}}function Ma(t){if(t<Ua)throw new Error("sqrt is not defined for small field");let e=t-ae,r=0;for(;e%Dt===ge;)e/=Dt,r++;let n=Dt,o=Qt(t);for(;Da(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Oa;let i=o.pow(n,e),s=(e+ae)/Dt;return function(a,f){if(a.is0(f))return f;if(Da(a,f)!==1)throw new Error("Cannot find square root");let u=r,l=a.mul(a.ONE,i),g=a.pow(f,e),S=a.pow(f,s);for(;!a.eql(g,a.ONE);){if(a.is0(g))return a.ZERO;let x=1,T=a.sqr(g);for(;!a.eql(T,a.ONE);)if(x++,T=a.sqr(T),x===u)throw new Error("Cannot find square root");let E=ae<<BigInt(u-x-1),w=a.pow(l,E);u=x,l=a.sqr(w),g=a.mul(g,l),S=a.mul(S,w)}return S}}function cd(t){return t%Na===Ua?Oa:t%Ka===ka?sd:t%Pa===id?ad(t):Ma(t)}var Fa=(t,e)=>(oe(t,e)&ae)===ae,ud=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ei(t){let e={ORDER:"bigint",BYTES:"number",BITS:"number"},r=ud.reduce((n,o)=>(n[o]="function",n),e);return gt(t,r),t}function fd(t,e,r){if(r<ge)throw new Error("invalid exponent, negatives unsupported");if(r===ge)return t.ONE;if(r===ae)return e;let n=t.ONE,o=e;for(;r>ge;)r&ae&&(n=t.mul(n,o)),o=t.sqr(o),r>>=ae;return n}function Lr(t,e,r=!1){let n=new Array(e.length).fill(r?t.ZERO:void 0),o=e.reduce((s,c,a)=>t.is0(c)?s:(n[a]=s,t.mul(s,c)),t.ONE),i=t.inv(o);return e.reduceRight((s,c,a)=>t.is0(c)?s:(n[a]=t.mul(s,n[a]),t.mul(s,c)),i),n}function Da(t,e){let r=(t.ORDER-ae)/Dt,n=t.pow(e,r),o=t.eql(n,t.ONE),i=t.eql(n,t.ZERO),s=t.eql(n,t.neg(t.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function ld(t,e){e!==void 0&&$e(e);let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var xi=class{ORDER;BITS;BYTES;isLE;ZERO=ge;ONE=ae;_lengths;_sqrt;_mod;constructor(e,r={}){if(e<=ge)throw new Error("invalid field: expected ORDER > 0, got "+e);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:i}=ld(e,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=i,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return oe(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof e);return ge<=e&&e<this.ORDER}is0(e){return e===ge}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&ae)===ae}neg(e){return oe(-e,this.ORDER)}eql(e,r){return e===r}sqr(e){return oe(e*e,this.ORDER)}add(e,r){return oe(e+r,this.ORDER)}sub(e,r){return oe(e-r,this.ORDER)}mul(e,r){return oe(e*r,this.ORDER)}pow(e,r){return fd(this,e,r)}div(e,r){return oe(e*Ra(r,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,r){return e+r}subN(e,r){return e-r}mulN(e,r){return e*r}inv(e){return Ra(e,this.ORDER)}sqrt(e){return this._sqrt||(this._sqrt=cd(this.ORDER)),this._sqrt(this,e)}toBytes(e){return this.isLE?gi(e,this.BYTES):Tn(e,this.BYTES)}fromBytes(e,r=!1){H(e);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:c}=this;if(n){if(!n.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);let f=new Uint8Array(o);f.set(e,i?0:f.length-e.length),e=f}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=i?Rt(e):Wt(e);if(c&&(a=oe(a,s)),!r&&!this.isValid(a))throw new Error("invalid field element: outside of range 0..ORDER");return a}invertBatch(e){return Lr(this,e)}cmov(e,r,n){return n?r:e}};function Qt(t,e={}){return new xi(t,e)}function Va(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function Si(t){let e=Va(t);return e+Math.ceil(e/2)}function vi(t,e,r=!1){H(t);let n=t.length,o=Va(e),i=Si(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Rt(t):Wt(t),c=oe(s,e-ae)+ae;return r?gi(c,o):Tn(c,o)}var er=BigInt(0),Ut=BigInt(1);function Rr(t,e){let r=e.negate();return t?r:e}function Nt(t,e){let r=Lr(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function za(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Ai(t,e){za(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1),o=2**t,i=_r(t),s=BigInt(t);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function qa(t,e,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,c=Number(t&o),a=t>>s;c>n&&(c-=i,a+=Ut);let f=e*n,u=f+Math.abs(c)-1,l=c===0,g=c<0,S=e%2!==0;return{nextN:a,offset:u,isZero:l,isNeg:g,isNegF:S,offsetF:f}}var Ii=new WeakMap,ja=new WeakMap;function Ti(t){return ja.get(t)||1}function Ha(t){if(t!==er)throw new Error("invalid wNAF")}var tr=class{BASE;ZERO;Fn;bits;constructor(e,r){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=r}_unsafeLadder(e,r,n=this.ZERO){let o=e;for(;r>er;)r&Ut&&(n=n.add(o)),o=o.double(),r>>=Ut;return n}precomputeWindow(e,r){let{windows:n,windowSize:o}=Ai(r,this.bits),i=[],s=e,c=s;for(let a=0;a<n;a++){c=s,i.push(c);for(let f=1;f<o;f++)c=c.add(s),i.push(c);s=c.double()}return i}wNAF(e,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=Ai(e,this.bits);for(let c=0;c<s.windows;c++){let{nextN:a,offset:f,isZero:u,isNeg:l,isNegF:g,offsetF:S}=qa(n,c,s);n=a,u?i=i.add(Rr(g,r[S])):o=o.add(Rr(l,r[f]))}return Ha(n),{p:o,f:i}}wNAFUnsafe(e,r,n,o=this.ZERO){let i=Ai(e,this.bits);for(let s=0;s<i.windows&&n!==er;s++){let{nextN:c,offset:a,isZero:f,isNeg:u}=qa(n,s,i);if(n=c,!f){let l=r[a];o=o.add(u?l.negate():l)}}return Ha(n),o}getPrecomputes(e,r,n){let o=Ii.get(r);return o||(o=this.precomputeWindow(r,e),e!==1&&(typeof n=="function"&&(o=n(o)),Ii.set(r,o))),o}cached(e,r,n){let o=Ti(e);return this.wNAF(o,this.getPrecomputes(o,e,n),r)}unsafe(e,r,n,o){let i=Ti(e);return i===1?this._unsafeLadder(e,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),r,o)}createCache(e,r){za(r,this.bits),ja.set(e,r),Ii.delete(e)}hasCache(e){return Ti(e)!==1}};function Za(t,e,r,n){let o=e,i=t.ZERO,s=t.ZERO;for(;r>er||n>er;)r&Ut&&(i=i.add(o)),n&Ut&&(s=s.add(o)),o=o.double(),r>>=Ut,n>>=Ut;return{p1:i,p2:s}}function $a(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Ei(e),e}else return Qt(t,{isLE:r})}function Cn(t,e,r={},n){if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(let a of["p","n","h"]){let f=e[a];if(!(typeof f=="bigint"&&f>er))throw new Error(`CURVE.${a} must be positive bigint`)}let o=$a(e.p,r.Fp,n),i=$a(e.n,r.Fn,n),c=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let a of c)if(!o.isValid(e[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:i}}function _n(t,e){return function(n){let o=t(n);return{secretKey:o,publicKey:e(o)}}}var bt=BigInt(0),ce=BigInt(1),Bi=BigInt(2),dd=BigInt(8);function hd(t,e,r,n){let o=t.sqr(r),i=t.sqr(n),s=t.add(t.mul(e.a,o),i),c=t.add(t.ONE,t.mul(e.d,t.mul(o,i)));return t.eql(s,c)}function Ya(t,e={}){let r=Cn("edwards",t,e,e.FpFnLE),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s}=i;gt(e,{},{uvRatio:"function"});let c=Bi<<BigInt(o.BYTES*8)-ce,a=E=>n.create(E),f=e.uvRatio||((E,w)=>{try{return{isValid:!0,value:n.sqrt(n.div(E,w))}}catch{return{isValid:!1,value:bt}}});if(!hd(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function u(E,w,B=!1){let v=B?ce:bt;return Cr("coordinate "+E,w,v,c),w}function l(E){if(!(E instanceof x))throw new Error("EdwardsPoint expected")}let g=Jt((E,w)=>{let{X:B,Y:v,Z:U}=E,P=E.is0();w==null&&(w=P?dd:n.inv(U));let F=a(B*w),M=a(v*w),p=n.mul(U,w);if(P)return{x:bt,y:ce};if(p!==ce)throw new Error("invZ was invalid");return{x:F,y:M}}),S=Jt(E=>{let{a:w,d:B}=i;if(E.is0())throw new Error("bad point: ZERO");let{X:v,Y:U,Z:P,T:F}=E,M=a(v*v),p=a(U*U),m=a(P*P),_=a(m*m),L=a(M*w),I=a(m*a(L+p)),y=a(_+a(B*a(M*p)));if(I!==y)throw new Error("bad point: equation left != right (1)");let b=a(v*U),d=a(P*F);if(b!==d)throw new Error("bad point: equation left != right (2)");return!0});class x{static BASE=new x(i.Gx,i.Gy,ce,a(i.Gx*i.Gy));static ZERO=new x(bt,ce,ce,bt);static Fp=n;static Fn=o;X;Y;Z;T;constructor(w,B,v,U){this.X=u("x",w),this.Y=u("y",B),this.Z=u("z",v,!0),this.T=u("t",U),Object.freeze(this)}static CURVE(){return i}static fromAffine(w){if(w instanceof x)throw new Error("extended point not allowed");let{x:B,y:v}=w||{};return u("x",B),u("y",v),new x(B,v,ce,a(B*v))}static fromBytes(w,B=!1){let v=n.BYTES,{a:U,d:P}=i;w=Bn(H(w,v,"point")),st(B,"zip215");let F=Bn(w),M=w[v-1];F[v-1]=M&-129;let p=Rt(F),m=B?c:n.ORDER;Cr("point.y",p,bt,m);let _=a(p*p),L=a(_-ce),I=a(P*_-U),{isValid:y,value:b}=f(L,I);if(!y)throw new Error("bad point: invalid y coordinate");let d=(b&ce)===ce,A=(M&128)!==0;if(!B&&b===bt&&A)throw new Error("bad point: x=0 and x_0=1");return A!==d&&(b=a(-b)),x.fromAffine({x:b,y:p})}static fromHex(w,B=!1){return x.fromBytes(ot(w),B)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,B=!0){return T.createCache(this,w),B||this.multiply(Bi),this}assertValidity(){S(this)}equals(w){l(w);let{X:B,Y:v,Z:U}=this,{X:P,Y:F,Z:M}=w,p=a(B*M),m=a(P*U),_=a(v*M),L=a(F*U);return p===m&&_===L}is0(){return this.equals(x.ZERO)}negate(){return new x(a(-this.X),this.Y,this.Z,a(-this.T))}double(){let{a:w}=i,{X:B,Y:v,Z:U}=this,P=a(B*B),F=a(v*v),M=a(Bi*a(U*U)),p=a(w*P),m=B+v,_=a(a(m*m)-P-F),L=p+F,I=L-M,y=p-F,b=a(_*I),d=a(L*y),A=a(_*y),R=a(I*L);return new x(b,d,R,A)}add(w){l(w);let{a:B,d:v}=i,{X:U,Y:P,Z:F,T:M}=this,{X:p,Y:m,Z:_,T:L}=w,I=a(U*p),y=a(P*m),b=a(M*v*L),d=a(F*_),A=a((U+P)*(p+m)-I-y),R=d-b,N=d+b,k=a(y-B*I),K=a(A*R),O=a(N*k),q=a(A*k),J=a(R*N);return new x(K,O,J,q)}subtract(w){return this.add(w.negate())}multiply(w){if(!o.isValidNot0(w))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:B,f:v}=T.cached(this,w,U=>Nt(x,U));return Nt(x,[B,v])[0]}multiplyUnsafe(w,B=x.ZERO){if(!o.isValid(w))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return w===bt?x.ZERO:this.is0()||w===ce?this:T.unsafe(this,w,v=>Nt(x,v),B)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return T.unsafe(this,i.n).is0()}toAffine(w){return g(this,w)}clearCofactor(){return s===ce?this:this.multiplyUnsafe(s)}toBytes(){let{x:w,y:B}=this.toAffine(),v=n.toBytes(B);return v[v.length-1]|=w&ce?128:0,v}toHex(){return nt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let T=new tr(x,o.BITS);return x.BASE.precompute(8),x}function Ga(t,e,r={}){if(typeof e!="function")throw new Error('"hash" function param is required');gt(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:n}=r,{BASE:o,Fp:i,Fn:s}=t,c=r.randomBytes||Gt,a=r.adjustScalarBytes||(p=>p),f=r.domain||((p,m,_)=>{if(st(_,"phflag"),m.length||_)throw new Error("Contexts/pre-hash are not supported");return p});function u(p){return s.create(Rt(p))}function l(p){let m=v.secretKey;H(p,v.secretKey,"secretKey");let _=H(e(p),2*m,"hashedSecretKey"),L=a(_.slice(0,m)),I=_.slice(m,2*m),y=u(L);return{head:L,prefix:I,scalar:y}}function g(p){let{head:m,prefix:_,scalar:L}=l(p),I=o.multiply(L),y=I.toBytes();return{head:m,prefix:_,scalar:L,point:I,pointBytes:y}}function S(p){return g(p).pointBytes}function x(p=Uint8Array.of(),...m){let _=we(...m);return u(e(f(_,H(p,void 0,"context"),!!n)))}function T(p,m,_={}){p=H(p,void 0,"message"),n&&(p=n(p));let{prefix:L,scalar:I,pointBytes:y}=g(m),b=x(_.context,L,p),d=o.multiply(b).toBytes(),A=x(_.context,d,y,p),R=s.create(b+A*I);if(!s.isValid(R))throw new Error("sign failed: invalid s");let N=we(d,s.toBytes(R));return H(N,v.signature,"result")}let E={zip215:!0};function w(p,m,_,L=E){let{context:I,zip215:y}=L,b=v.signature;p=H(p,b,"signature"),m=H(m,void 0,"message"),_=H(_,v.publicKey,"publicKey"),y!==void 0&&st(y,"zip215"),n&&(m=n(m));let d=b/2,A=p.subarray(0,d),R=Rt(p.subarray(d,b)),N,k,K;try{N=t.fromBytes(_,y),k=t.fromBytes(A,y),K=o.multiplyUnsafe(R)}catch{return!1}if(!y&&N.isSmallOrder())return!1;let O=x(I,k.toBytes(),N.toBytes(),m);return k.add(N.multiplyUnsafe(O)).subtract(K).clearCofactor().is0()}let B=i.BYTES,v={secretKey:B,publicKey:B,signature:2*B,seed:B};function U(p=c(v.seed)){return H(p,v.seed,"seed")}function P(p){return Ct(p)&&p.length===s.BYTES}function F(p,m){try{return!!t.fromBytes(p,m)}catch{return!1}}let M={getExtendedPublicKey:g,randomSecretKey:U,isValidSecretKey:P,isValidPublicKey:F,toMontgomery(p){let{y:m}=t.fromBytes(p),_=v.publicKey,L=_===32;if(!L&&_!==57)throw new Error("only defined for 25519 and 448");let I=L?i.div(ce+m,ce-m):i.div(m-ce,m+ce);return i.toBytes(I)},toMontgomerySecret(p){let m=v.secretKey;H(p,m);let _=e(p.subarray(0,m));return a(_).subarray(0,m)}};return Object.freeze({keygen:_n(U,S),getPublicKey:S,sign:T,verify:w,utils:M,Point:t,lengths:v})}var pd=BigInt(1),Xa=BigInt(2);var md=BigInt(5),yd=BigInt(8),Ci=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),gd={p:Ci,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:yd,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function bd(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=Ci,c=t*t%i*t%i,a=W(c,Xa,i)*c%i,f=W(a,pd,i)*t%i,u=W(f,md,i)*f%i,l=W(u,e,i)*u%i,g=W(l,r,i)*l%i,S=W(g,n,i)*g%i,x=W(S,o,i)*S%i,T=W(x,o,i)*S%i,E=W(T,e,i)*u%i;return{pow_p_5_8:W(E,Xa,i)*t%i,b2:c}}function xd(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}var Wa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function wd(t,e){let r=Ci,n=oe(e*e*e,r),o=oe(n*n*e,r),i=bd(t*o).pow_p_5_8,s=oe(t*n*i,r),c=oe(e*s*s,r),a=s,f=oe(s*Wa,r),u=c===t,l=c===oe(-t,r),g=c===oe(-t*Wa,r);return u&&(s=a),(l||g)&&(s=f),Fa(s,r)&&(s=oe(-s,r)),{isValid:u||l,value:s}}var Ed=Ya(gd,{uvRatio:wd});function Sd(t){return Ga(Ed,Ba,Object.assign({adjustScalarBytes:xd},t))}var Dr=Sd({});var Ur=class extends Error{constructor(e="An error occurred while signing a message"){super(e),this.name="SigningError"}},Nr=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},Ln=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var Ja={get(t=globalThis){let e=t.crypto;if(e?.subtle==null)throw new Ln("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return e}};var Ee=Ja;var Rn=32,kr=64,_i=32;var rr,Qa=(async()=>{try{return await Ee.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();function ec(){let t=Dr.utils.randomSecretKey(),e=Dr.getPublicKey(t);return{privateKey:Bd(t,e),publicKey:e}}async function vd(t,e){let r;t.length===kr?r=t.subarray(0,32):r=t;let n={crv:"Ed25519",kty:"OKP",x:Z(t.subarray(32),"base64url"),d:Z(r,"base64url"),ext:!0,key_ops:["sign"]},o=await Ee.get().subtle.importKey("jwk",n,{name:"Ed25519"},!0,["sign"]),i=await Ee.get().subtle.sign({name:"Ed25519"},o,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(i,0,i.byteLength)}function Ad(t,e){let r=t.subarray(0,_i);return Dr.sign(e instanceof Uint8Array?e:e.subarray(),r)}async function tc(t,e){return rr==null&&(rr=await Qa),rr?vd(t,e):Ad(t,e)}async function Id(t,e,r){if(t.buffer instanceof ArrayBuffer){let n=await Ee.get().subtle.importKey("raw",t.buffer,{name:"Ed25519"},!1,["verify"]);return await Ee.get().subtle.verify({name:"Ed25519"},n,e,r instanceof Uint8Array?r:r.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Td(t,e,r){return Dr.verify(e,r instanceof Uint8Array?r:r.subarray(),t)}async function rc(t,e,r){return rr==null&&(rr=await Qa),rr?Id(t,e,r):Td(t,e,r)}function Bd(t,e){let r=new Uint8Array(kr);for(let n=0;n<_i;n++)r[n]=t[n],r[_i+n]=e[n];return r}function nr(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}var Kr=class{type="Ed25519";raw;constructor(e){this.raw=Un(e,Rn)}toMultihash(){return Tt.digest(ht(this))}toCID(){return se.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ne(this.raw,e.raw)}verify(e,r,n){n?.signal?.throwIfAborted();let o=rc(this.raw,r,e);return nr(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}},Dn=class{type="Ed25519";raw;publicKey;constructor(e,r){this.raw=Un(e,kr),this.publicKey=new Kr(r)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ne(this.raw,e.raw)}sign(e,r){r?.signal?.throwIfAborted();let n=tc(this.raw,e);return nr(n)?n.then(o=>(r?.signal?.throwIfAborted(),o)):(r?.signal?.throwIfAborted(),n)}};function Li(t){return t=Un(t,Rn),new Kr(t)}async function oc(){let{privateKey:t,publicKey:e}=ec();return new Dn(t,e)}function Un(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new te(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}var Cd=Math.pow(2,7),_d=Math.pow(2,14),Ld=Math.pow(2,21),ic=Math.pow(2,28),sc=Math.pow(2,35),ac=Math.pow(2,42),cc=Math.pow(2,49),be=128,xt=127;function Pr(t){if(t<Cd)return 1;if(t<_d)return 2;if(t<Ld)return 3;if(t<ic)return 4;if(t<sc)return 5;if(t<ac)return 6;if(t<cc)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function uc(t,e,r=0){switch(Pr(t)){case 8:e[r++]=t&255|be,t/=128;case 7:e[r++]=t&255|be,t/=128;case 6:e[r++]=t&255|be,t/=128;case 5:e[r++]=t&255|be,t/=128;case 4:e[r++]=t&255|be,t>>>=7;case 3:e[r++]=t&255|be,t>>>=7;case 2:e[r++]=t&255|be,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function fc(t,e){let r=t[e],n=0;if(n+=r&xt,r<be||(r=t[e+1],n+=(r&xt)<<7,r<be)||(r=t[e+2],n+=(r&xt)<<14,r<be)||(r=t[e+3],n+=(r&xt)<<21,r<be)||(r=t[e+4],n+=(r&xt)*ic,r<be)||(r=t[e+5],n+=(r&xt)*sc,r<be)||(r=t[e+6],n+=(r&xt)*ac,r<be)||(r=t[e+7],n+=(r&xt)*cc,r<be))return n;throw new RangeError("Could not decode varint")}var Ri=new Float32Array([-0]),wt=new Uint8Array(Ri.buffer);function lc(t,e,r){Ri[0]=t,e[r]=wt[0],e[r+1]=wt[1],e[r+2]=wt[2],e[r+3]=wt[3]}function dc(t,e){return wt[0]=t[e],wt[1]=t[e+1],wt[2]=t[e+2],wt[3]=t[e+3],Ri[0]}var Di=new Float64Array([-0]),pe=new Uint8Array(Di.buffer);function hc(t,e,r){Di[0]=t,e[r]=pe[0],e[r+1]=pe[1],e[r+2]=pe[2],e[r+3]=pe[3],e[r+4]=pe[4],e[r+5]=pe[5],e[r+6]=pe[6],e[r+7]=pe[7]}function pc(t,e){return pe[0]=t[e],pe[1]=t[e+1],pe[2]=t[e+2],pe[3]=t[e+3],pe[4]=t[e+4],pe[5]=t[e+5],pe[6]=t[e+6],pe[7]=t[e+7],Di[0]}var Rd=BigInt(Number.MAX_SAFE_INTEGER),Dd=BigInt(Number.MIN_SAFE_INTEGER),Ie=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return kt;if(e<Rd&&e>Dd)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>mc&&(o=0n,++n>mc&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return kt;let r=e<0;r&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new t(n,o)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):kt}},kt=new Ie(0,0);kt.toBigInt=function(){return 0n};kt.zzEncode=kt.zzDecode=function(){return this};kt.length=function(){return 1};var mc=4294967296n;function yc(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function gc(t,e,r){if(r-e<1)return"";let o,i=[],s=0,c;for(;e<r;)c=t[e++],c<128?i[s++]=c:c>191&&c<224?i[s++]=(c&31)<<6|t[e++]&63:c>239&&c<365?(c=((c&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(c>>10),i[s++]=56320+(c&1023)):i[s++]=(c&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function Ui(t,e,r){let n=r,o,i;for(let s=0;s<t.length;++s)o=t.charCodeAt(s),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((i=t.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-n}function Pe(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function Nn(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var Ni=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Pe(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Pe(this,4);return Nn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Pe(this,4);return Nn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Pe(this,4);let e=dc(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Pe(this,4);let e=pc(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw Pe(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return gc(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Pe(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Pe(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Ie(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Pe(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw Pe(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Pe(this,8);let e=Nn(this.buf,this.pos+=4),r=Nn(this.buf,this.pos+=4);return new Ie(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=fc(this.buf,this.pos);return this.pos+=Pr(e),e}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 ki(t){return new Ni(t instanceof Uint8Array?t:t.subarray())}function je(t,e,r){let n=ki(t);return e.decode(n,void 0,r)}function Ki(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return Ae(s);o+s>e&&(n=Ae(e),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var Kt=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function Pi(){}var Mi=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Ud=Ki();function Nd(t){return globalThis.Buffer!=null?Ae(t):Ud(t)}var Mr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Kt(Pi,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new Kt(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Fi((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(kn,10,Ie.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=Ie.fromBigInt(e);return this._push(kn,r.length(),r)}uint64Number(e){return this._push(uc,Pr(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=Ie.fromBigInt(e).zzEncode();return this._push(kn,r.length(),r)}sint64Number(e){let r=Ie.fromNumber(e).zzEncode();return this._push(kn,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Oi,1,e?1:0)}fixed32(e){return this._push(Or,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=Ie.fromBigInt(e);return this._push(Or,4,r.lo)._push(Or,4,r.hi)}fixed64Number(e){let r=Ie.fromNumber(e);return this._push(Or,4,r.lo)._push(Or,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(lc,4,e)}double(e){return this._push(hc,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(Oi,1,0):this.uint32(r)._push(Kd,r,e)}string(e){let r=yc(e);return r!==0?this.uint32(r)._push(Ui,r,e):this._push(Oi,1,0)}fork(){return this.states=new Mi(this),this.head=this.tail=new Kt(Pi,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 Kt(Pi,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=Nd(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function Oi(t,e,r){e[r]=t&255}function kd(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var Fi=class extends Kt{next;constructor(e,r){super(kd,e,r),this.next=void 0}};function kn(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function Or(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function Kd(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(Mr.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(Pd,e,t),this},Mr.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(Od,e,t),this});function Pd(t,e,r){e.set(t,r)}function Od(t,e,r){t.length<40?Ui(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set($(t),r)}function Vi(){return new Mr}function Ze(t,e){let r=Vi();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var or;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(or||(or={}));function Kn(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function Fr(t){function e(o){if(t[o.toString()]==null)throw new Error("Invalid enum value");return t[o]}let r=function(i,s){let c=e(i);s.int32(c)},n=function(i){let s=i.int32();return e(s)};return Kn("enum",or.VARINT,r,n)}function Ye(t,e){return Kn("message",or.LENGTH_DELIMITED,t,e)}var ie;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.ECDSA="ECDSA"})(ie||(ie={}));var qi;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1",t[t.ECDSA=3]="ECDSA"})(qi||(qi={}));(function(t){t.codec=()=>Fr(qi)})(ie||(ie={}));var Ge;(function(t){let e;t.codec=()=>(e==null&&(e=Ye((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ie.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.Type=ie.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),e),t.encode=r=>Ze(r,t.codec()),t.decode=(r,n)=>je(r,t.codec(),n)})(Ge||(Ge={}));var Hi;(function(t){let e;t.codec=()=>(e==null&&(e=Ye((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ie.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.Type=ie.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),e),t.encode=r=>Ze(r,t.codec()),t.decode=(r,n)=>je(r,t.codec(),n)})(Hi||(Hi={}));var qr={};xe(qr,{MAX_RSA_KEY_SIZE:()=>$i,generateRSAKeyPair:()=>Qi,jwkToJWKKeyPair:()=>vc,jwkToPkcs1:()=>qd,jwkToPkix:()=>Yi,jwkToRSAPrivateKey:()=>Ji,pkcs1MessageToJwk:()=>ji,pkcs1MessageToRSAPrivateKey:()=>Gi,pkcs1ToJwk:()=>Vd,pkcs1ToRSAPrivateKey:()=>Sc,pkixMessageToJwk:()=>Zi,pkixMessageToRSAPublicKey:()=>Wi,pkixToJwk:()=>Hd,pkixToRSAPublicKey:()=>Xi});var ir=class{type="RSA";jwk;_raw;_multihash;constructor(e,r){this.jwk=e,this._multihash=r}get raw(){return this._raw==null&&(this._raw=qr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return se.createV1(114,this._multihash)}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ne(this.raw,e.raw)}verify(e,r,n){return Ec(this.jwk,r,e,n)}},Vr=class{type="RSA";jwk;_raw;publicKey;constructor(e,r){this.jwk=e,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=qr.jwkToPkcs1(this.jwk)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ne(this.raw,e.raw)}sign(e,r){return wc(this.jwk,e,r)}};var $i=8192,zi=18,Md=1062,Fd=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Vd(t){let e=et(t);return ji(e)}function ji(t){return{n:Z(t[1],"base64url"),e:Z(t[2],"base64url"),d:Z(t[3],"base64url"),p:Z(t[4],"base64url"),q:Z(t[5],"base64url"),dp:Z(t[6],"base64url"),dq:Z(t[7],"base64url"),qi:Z(t[8],"base64url"),kty:"RSA"}}function qd(t){if(t.n==null||t.e==null||t.d==null||t.p==null||t.q==null||t.dp==null||t.dq==null||t.qi==null)throw new te("JWK was missing components");return ke([ye(Uint8Array.from([0])),ye($(t.n,"base64url")),ye($(t.e,"base64url")),ye($(t.d,"base64url")),ye($(t.p,"base64url")),ye($(t.q,"base64url")),ye($(t.dp,"base64url")),ye($(t.dq,"base64url")),ye($(t.qi,"base64url"))]).subarray()}function Hd(t){let e=et(t,{offset:0});return Zi(e)}function Zi(t){let e=et(t[1],{offset:0});return{kty:"RSA",n:Z(e[0],"base64url"),e:Z(e[1],"base64url")}}function Yi(t){if(t.n==null||t.e==null)throw new te("JWK was missing components");return ke([Fd,vr(ke([ye($(t.n,"base64url")),ye($(t.e,"base64url"))]))]).subarray()}function Sc(t){let e=et(t);return Gi(e)}function Gi(t){let e=ji(t);return Ji(e)}function Xi(t,e){if(t.byteLength>=Md)throw new Vt("Key size is too large");let r=et(t,{offset:0});return Wi(r,t,e)}function Wi(t,e,r){let n=Zi(t);if(r==null){let o=Xt(Ge.encode({Type:ie.RSA,Data:e}));r=He(zi,o)}return new ir(n,r)}function Ji(t){if(Ic(t)>$i)throw new te("Key size is too large");let e=vc(t),r=Xt(Ge.encode({Type:ie.RSA,Data:Yi(e.publicKey)})),n=He(zi,r);return new Vr(e.privateKey,new ir(e.publicKey,n))}async function Qi(t){if(t>$i)throw new te("Key size is too large");let e=await Ac(t),r=Xt(Ge.encode({Type:ie.RSA,Data:Yi(e.publicKey)})),n=He(zi,r);return new Vr(e.privateKey,new ir(e.publicKey,n))}function vc(t){if(t==null)throw new te("Missing key parameter");return{privateKey:t,publicKey:{kty:t.kty,n:t.n,e:t.e}}}async function Ac(t,e){let r=await Ee.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);e?.signal?.throwIfAborted();let n=await $d(r,e);return{privateKey:n[0],publicKey:n[1]}}async function wc(t,e,r){let n=await Ee.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await Ee.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,e instanceof Uint8Array?e:e.subarray());return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function Ec(t,e,r,n){let o=await Ee.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await Ee.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,e,r instanceof Uint8Array?r:r.subarray());return n?.signal?.throwIfAborted(),i}async function $d(t,e){if(t.privateKey==null||t.publicKey==null)throw new te("Private and public key are required");let r=await Promise.all([Ee.get().subtle.exportKey("jwk",t.privateKey),Ee.get().subtle.exportKey("jwk",t.publicKey)]);return e?.signal?.throwIfAborted(),r}function Ic(t){if(t.kty!=="RSA")throw new te("invalid key type");if(t.n==null)throw new te("invalid key modulus");return $(t.n,"base64url").length*8}var Pn=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,r){if(Sn(e),H(r,void 0,"key"),this.iHash=e.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 n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),rt(o)}update(e){return Yt(this),this.iHash.update(e),this}digestInto(e){Yt(this),H(e,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=c,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},es=(t,e,r)=>new Pn(t,e).update(r).digest();es.create=(t,e)=>new Pn(t,e);var Tc=(t,e)=>(t+(t>=0?e:-e)/Bc)/e;function zd(t,e,r){let[[n,o],[i,s]]=e,c=Tc(s*t,r),a=Tc(-o*t,r),f=t-c*n-a*i,u=-c*o-a*s,l=f<at,g=u<at;l&&(f=-f),g&&(u=-u);let S=_r(Math.ceil(bi(r)/2))+sr;if(f<at||f>=S||u<at||u>=S)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:l,k1:f,k2neg:g,k2:u}}function rs(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function ts(t,e){let r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return st(r.lowS,"lowS"),st(r.prehash,"prehash"),r.format!==void 0&&rs(r.format),r}var ns=class extends Error{constructor(e=""){super(e)}},Et={Err:ns,_tlv:{encode:(t,e)=>{let{Err:r}=Et;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=Br(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Br(o.length/2|128):"";return Br(t)+i+o+e},decode(t,e){let{Err:r}=Et,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let a=o&127;if(!a)throw new r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");let f=e.subarray(n,n+a);if(f.length!==a)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(n+=a,s<128)throw new r("tlv.decode(long): not minimal encoding")}let c=e.subarray(n,n+s);if(c.length!==s)throw new r("tlv.decode: wrong value length");return{v:c,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=Et;if(t<at)throw new e("integer: negative integers are not allowed");let r=Br(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=Et;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Wt(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=Et,o=H(t,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,i),{v:f,l:u}=n.decode(2,a);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(f)}},hexFromSig(t){let{_tlv:e,_int:r}=Et,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}},at=BigInt(0),sr=BigInt(1),Bc=BigInt(2),On=BigInt(3),jd=BigInt(4);function Cc(t,e={}){let r=Cn("weierstrass",t,e),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s,n:c}=i;gt(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:a}=e;if(a&&(!n.is0(i.a)||typeof a.beta!="bigint"||!Array.isArray(a.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let f=Lc(n,o);function u(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(I,y,b){let{x:d,y:A}=y.toAffine(),R=n.toBytes(d);if(st(b,"isCompressed"),b){u();let N=!n.isOdd(A);return we(_c(N),R)}else return we(Uint8Array.of(4),R,n.toBytes(A))}function g(I){H(I,void 0,"Point");let{publicKey:y,publicKeyUncompressed:b}=f,d=I.length,A=I[0],R=I.subarray(1);if(d===y&&(A===2||A===3)){let N=n.fromBytes(R);if(!n.isValid(N))throw new Error("bad point: is not on curve, wrong x");let k=T(N),K;try{K=n.sqrt(k)}catch(J){let G=J instanceof Error?": "+J.message:"";throw new Error("bad point: is not on curve, sqrt error"+G)}u();let O=n.isOdd(K);return(A&1)===1!==O&&(K=n.neg(K)),{x:N,y:K}}else if(d===b&&A===4){let N=n.BYTES,k=n.fromBytes(R.subarray(0,N)),K=n.fromBytes(R.subarray(N,N*2));if(!E(k,K))throw new Error("bad point: is not on curve");return{x:k,y:K}}else throw new Error(`bad point: got length ${d}, expected compressed=${y} or uncompressed=${b}`)}let S=e.toBytes||l,x=e.fromBytes||g;function T(I){let y=n.sqr(I),b=n.mul(y,I);return n.add(n.add(b,n.mul(I,i.a)),i.b)}function E(I,y){let b=n.sqr(y),d=T(I);return n.eql(b,d)}if(!E(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let w=n.mul(n.pow(i.a,On),jd),B=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(w,B)))throw new Error("bad curve params: a or b");function v(I,y,b=!1){if(!n.isValid(y)||b&&n.is0(y))throw new Error(`bad point coordinate ${I}`);return y}function U(I){if(!(I instanceof m))throw new Error("Weierstrass Point expected")}function P(I){if(!a||!a.basises)throw new Error("no endo");return zd(I,a.basises,o.ORDER)}let F=Jt((I,y)=>{let{X:b,Y:d,Z:A}=I;if(n.eql(A,n.ONE))return{x:b,y:d};let R=I.is0();y==null&&(y=R?n.ONE:n.inv(A));let N=n.mul(b,y),k=n.mul(d,y),K=n.mul(A,y);if(R)return{x:n.ZERO,y:n.ZERO};if(!n.eql(K,n.ONE))throw new Error("invZ was invalid");return{x:N,y:k}}),M=Jt(I=>{if(I.is0()){if(e.allowInfinityPoint&&!n.is0(I.Y))return;throw new Error("bad point: ZERO")}let{x:y,y:b}=I.toAffine();if(!n.isValid(y)||!n.isValid(b))throw new Error("bad point: x or y not field elements");if(!E(y,b))throw new Error("bad point: equation left != right");if(!I.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function p(I,y,b,d,A){return b=new m(n.mul(b.X,I),b.Y,b.Z),y=Rr(d,y),b=Rr(A,b),y.add(b)}class m{static BASE=new m(i.Gx,i.Gy,n.ONE);static ZERO=new m(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(y,b,d){this.X=v("x",y),this.Y=v("y",b,!0),this.Z=v("z",d),Object.freeze(this)}static CURVE(){return i}static fromAffine(y){let{x:b,y:d}=y||{};if(!y||!n.isValid(b)||!n.isValid(d))throw new Error("invalid affine point");if(y instanceof m)throw new Error("projective point not allowed");return n.is0(b)&&n.is0(d)?m.ZERO:new m(b,d,n.ONE)}static fromBytes(y){let b=m.fromAffine(x(H(y,void 0,"point")));return b.assertValidity(),b}static fromHex(y){return m.fromBytes(ot(y))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,b=!0){return L.createCache(this,y),b||this.multiply(On),this}assertValidity(){M(this)}hasEvenY(){let{y}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(y)}equals(y){U(y);let{X:b,Y:d,Z:A}=this,{X:R,Y:N,Z:k}=y,K=n.eql(n.mul(b,k),n.mul(R,A)),O=n.eql(n.mul(d,k),n.mul(N,A));return K&&O}negate(){return new m(this.X,n.neg(this.Y),this.Z)}double(){let{a:y,b}=i,d=n.mul(b,On),{X:A,Y:R,Z:N}=this,k=n.ZERO,K=n.ZERO,O=n.ZERO,q=n.mul(A,A),J=n.mul(R,R),G=n.mul(N,N),z=n.mul(A,R);return z=n.add(z,z),O=n.mul(A,N),O=n.add(O,O),k=n.mul(y,O),K=n.mul(d,G),K=n.add(k,K),k=n.sub(J,K),K=n.add(J,K),K=n.mul(k,K),k=n.mul(z,k),O=n.mul(d,O),G=n.mul(y,G),z=n.sub(q,G),z=n.mul(y,z),z=n.add(z,O),O=n.add(q,q),q=n.add(O,q),q=n.add(q,G),q=n.mul(q,z),K=n.add(K,q),G=n.mul(R,N),G=n.add(G,G),q=n.mul(G,z),k=n.sub(k,q),O=n.mul(G,J),O=n.add(O,O),O=n.add(O,O),new m(k,K,O)}add(y){U(y);let{X:b,Y:d,Z:A}=this,{X:R,Y:N,Z:k}=y,K=n.ZERO,O=n.ZERO,q=n.ZERO,J=i.a,G=n.mul(i.b,On),z=n.mul(b,R),Q=n.mul(d,N),fe=n.mul(A,k),qe=n.add(b,d),ee=n.add(R,N);qe=n.mul(qe,ee),ee=n.add(z,Q),qe=n.sub(qe,ee),ee=n.add(b,A);let he=n.add(R,k);return ee=n.mul(ee,he),he=n.add(z,fe),ee=n.sub(ee,he),he=n.add(d,A),K=n.add(N,k),he=n.mul(he,K),K=n.add(Q,fe),he=n.sub(he,K),q=n.mul(J,ee),K=n.mul(G,fe),q=n.add(K,q),K=n.sub(Q,q),q=n.add(Q,q),O=n.mul(K,q),Q=n.add(z,z),Q=n.add(Q,z),fe=n.mul(J,fe),ee=n.mul(G,ee),Q=n.add(Q,fe),fe=n.sub(z,fe),fe=n.mul(J,fe),ee=n.add(ee,fe),z=n.mul(Q,ee),O=n.add(O,z),z=n.mul(he,ee),K=n.mul(qe,K),K=n.sub(K,z),z=n.mul(qe,Q),q=n.mul(he,q),q=n.add(q,z),new m(K,O,q)}subtract(y){return this.add(y.negate())}is0(){return this.equals(m.ZERO)}multiply(y){let{endo:b}=e;if(!o.isValidNot0(y))throw new Error("invalid scalar: out of range");let d,A,R=N=>L.cached(this,N,k=>Nt(m,k));if(b){let{k1neg:N,k1:k,k2neg:K,k2:O}=P(y),{p:q,f:J}=R(k),{p:G,f:z}=R(O);A=J.add(z),d=p(b.beta,q,G,N,K)}else{let{p:N,f:k}=R(y);d=N,A=k}return Nt(m,[d,A])[0]}multiplyUnsafe(y){let{endo:b}=e,d=this;if(!o.isValid(y))throw new Error("invalid scalar: out of range");if(y===at||d.is0())return m.ZERO;if(y===sr)return d;if(L.hasCache(this))return this.multiply(y);if(b){let{k1neg:A,k1:R,k2neg:N,k2:k}=P(y),{p1:K,p2:O}=Za(m,d,R,k);return p(b.beta,K,O,A,N)}else return L.unsafe(d,y)}toAffine(y){return F(this,y)}isTorsionFree(){let{isTorsionFree:y}=e;return s===sr?!0:y?y(m,this):L.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:y}=e;return s===sr?this:y?y(m,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(y=!0){return st(y,"isCompressed"),this.assertValidity(),S(m,this,y)}toHex(y=!0){return nt(this.toBytes(y))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let _=o.BITS,L=new tr(m,e.endo?Math.ceil(_/2):_);return m.BASE.precompute(8),m}function _c(t){return Uint8Array.of(t?2:3)}function Lc(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function Zd(t,e={}){let{Fn:r}=t,n=e.randomBytes||Gt,o=Object.assign(Lc(t.Fp,r),{seed:Si(r.ORDER)});function i(S){try{let x=r.fromBytes(S);return r.isValidNot0(x)}catch{return!1}}function s(S,x){let{publicKey:T,publicKeyUncompressed:E}=o;try{let w=S.length;return x===!0&&w!==T||x===!1&&w!==E?!1:!!t.fromBytes(S)}catch{return!1}}function c(S=n(o.seed)){return vi(H(S,o.seed,"seed"),r.ORDER)}function a(S,x=!0){return t.BASE.multiply(r.fromBytes(S)).toBytes(x)}function f(S){let{secretKey:x,publicKey:T,publicKeyUncompressed:E}=o;if(!Ct(S)||"_lengths"in r&&r._lengths||x===T)return;let w=H(S,void 0,"key").length;return w===T||w===E}function u(S,x,T=!0){if(f(S)===!0)throw new Error("first arg must be private key");if(f(x)===!1)throw new Error("second arg must be public key");let E=r.fromBytes(S);return t.fromBytes(x).multiply(E).toBytes(T)}let l={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:c},g=_n(c,a);return Object.freeze({getPublicKey:a,getSharedSecret:u,keygen:g,Point:t,utils:l,lengths:o})}function Rc(t,e,r={}){Sn(e),gt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||Gt,o=r.hmac||((b,d)=>es(e,b,d)),{Fp:i,Fn:s}=t,{ORDER:c,BITS:a}=s,{keygen:f,getPublicKey:u,getSharedSecret:l,utils:g,lengths:S}=Zd(t,r),x={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},T=c*Bc<i.ORDER;function E(b){let d=c>>sr;return b>d}function w(b,d){if(!s.isValidNot0(d))throw new Error(`invalid signature ${b}: out of range 1..Point.Fn.ORDER`);return d}function B(){if(T)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function v(b,d){rs(d);let A=S.signature,R=d==="compact"?A:d==="recovered"?A+1:void 0;return H(b,R)}class U{r;s;recovery;constructor(d,A,R){if(this.r=w("r",d),this.s=w("s",A),R!=null){if(B(),![0,1,2,3].includes(R))throw new Error("invalid recovery id");this.recovery=R}Object.freeze(this)}static fromBytes(d,A=x.format){v(d,A);let R;if(A==="der"){let{r:O,s:q}=Et.toSig(H(d));return new U(O,q)}A==="recovered"&&(R=d[0],A="compact",d=d.subarray(1));let N=S.signature/2,k=d.subarray(0,N),K=d.subarray(N,N*2);return new U(s.fromBytes(k),s.fromBytes(K),R)}static fromHex(d,A){return this.fromBytes(ot(d),A)}assertRecovery(){let{recovery:d}=this;if(d==null)throw new Error("invalid recovery id: must be present");return d}addRecoveryBit(d){return new U(this.r,this.s,d)}recoverPublicKey(d){let{r:A,s:R}=this,N=this.assertRecovery(),k=N===2||N===3?A+c:A;if(!i.isValid(k))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let K=i.toBytes(k),O=t.fromBytes(we(_c((N&1)===0),K)),q=s.inv(k),J=F(H(d,void 0,"msgHash")),G=s.create(-J*q),z=s.create(R*q),Q=t.BASE.multiplyUnsafe(G).add(O.multiplyUnsafe(z));if(Q.is0())throw new Error("invalid recovery: point at infinify");return Q.assertValidity(),Q}hasHighS(){return E(this.s)}toBytes(d=x.format){if(rs(d),d==="der")return ot(Et.hexFromSig(this));let{r:A,s:R}=this,N=s.toBytes(A),k=s.toBytes(R);return d==="recovered"?(B(),we(Uint8Array.of(this.assertRecovery()),N,k)):we(N,k)}toHex(d){return nt(this.toBytes(d))}}let P=r.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");let A=Wt(d),R=d.length*8-a;return R>0?A>>BigInt(R):A},F=r.bits2int_modN||function(d){return s.create(P(d))},M=_r(a);function p(b){return Cr("num < 2^"+a,b,at,M),s.toBytes(b)}function m(b,d){return H(b,void 0,"message"),d?H(e(b),void 0,"prehashed message"):b}function _(b,d,A){let{lowS:R,prehash:N,extraEntropy:k}=ts(A,x);b=m(b,N);let K=F(b),O=s.fromBytes(d);if(!s.isValidNot0(O))throw new Error("invalid private key");let q=[p(O),p(K)];if(k!=null&&k!==!1){let Q=k===!0?n(S.secretKey):k;q.push(H(Q,void 0,"extraEntropy"))}let J=we(...q),G=K;function z(Q){let fe=P(Q);if(!s.isValidNot0(fe))return;let qe=s.inv(fe),ee=t.BASE.multiply(fe).toAffine(),he=s.create(ee.x);if(he===at)return;let ln=s.create(qe*s.create(G+he*O));if(ln===at)return;let Ls=(ee.x===he?0:2)|Number(ee.y&sr),Rs=ln;return R&&E(ln)&&(Rs=s.neg(ln),Ls^=1),new U(he,Rs,T?void 0:Ls)}return{seed:J,k2sig:z}}function L(b,d,A={}){let{seed:R,k2sig:N}=_(b,d,A);return La(e.outputLen,s.BYTES,o)(R,N).toBytes(A.format)}function I(b,d,A,R={}){let{lowS:N,prehash:k,format:K}=ts(R,x);if(A=H(A,void 0,"publicKey"),d=m(d,k),!Ct(b)){let O=b instanceof U?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+O)}v(b,K);try{let O=U.fromBytes(b,K),q=t.fromBytes(A);if(N&&O.hasHighS())return!1;let{r:J,s:G}=O,z=F(d),Q=s.inv(G),fe=s.create(z*Q),qe=s.create(J*Q),ee=t.BASE.multiplyUnsafe(fe).add(q.multiplyUnsafe(qe));return ee.is0()?!1:s.create(ee.x)===J}catch{return!1}}function y(b,d,A={}){let{prehash:R}=ts(A,x);return d=m(d,R),U.fromBytes(b,"recovered").recoverPublicKey(d).toBytes()}return Object.freeze({keygen:f,getPublicKey:u,getSharedSecret:l,utils:g,lengths:S,Point:t,sign:L,verify:I,recoverPublicKey:y,Signature:U,hash:e})}var is={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Yd={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Dc=BigInt(2);function Gd(t){let e=is.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),f=t*t*t%e,u=f*f*t%e,l=W(u,r,e)*u%e,g=W(l,r,e)*u%e,S=W(g,Dc,e)*f%e,x=W(S,o,e)*S%e,T=W(x,i,e)*x%e,E=W(T,c,e)*T%e,w=W(E,a,e)*E%e,B=W(w,c,e)*T%e,v=W(B,r,e)*u%e,U=W(v,s,e)*x%e,P=W(U,n,e)*f%e,F=W(P,Dc,e);if(!os.eql(os.sqr(F),t))throw new Error("Cannot find square root");return F}var os=Qt(is.p,{sqrt:Gd}),Xd=Cc(is,{Fp:os,endo:Yd}),Oe=Rc(Xd,Xt);function Uc(t,e,r){let n=bn.digest(e instanceof Uint8Array?e:e.subarray());if(nr(n))return n.then(({digest:o})=>(r?.signal?.throwIfAborted(),Oe.sign(o,t,{prehash:!1,format:"der"}))).catch(o=>{throw o.name==="AbortError"?o:new Ur(String(o))});try{return Oe.sign(n.digest,t,{prehash:!1,format:"der"})}catch(o){throw new Ur(String(o))}}function Nc(t,e,r,n){let o=bn.digest(r instanceof Uint8Array?r:r.subarray());if(nr(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),Oe.verify(e,i,t,{prehash:!1,format:"der"}))).catch(i=>{throw i.name==="AbortError"?i:new Nr(String(i))});try{return n?.signal?.throwIfAborted(),Oe.verify(e,o.digest,t,{prehash:!1,format:"der"})}catch(i){throw new Nr(String(i))}}var Hr=class{type="secp256k1";raw;_key;constructor(e){this._key=Pc(e),this.raw=kc(this._key)}toMultihash(){return Tt.digest(ht(this))}toCID(){return se.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ne(this.raw,e.raw)}verify(e,r,n){return Nc(this._key,r,e,n)}},Mn=class{type="secp256k1";raw;publicKey;constructor(e,r){this.raw=Kc(e),this.publicKey=new Hr(r??Oc(e))}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ne(this.raw,e.raw)}sign(e,r){return Uc(this.raw,e,r)}};function ss(t){return new Hr(t)}async function Mc(){let t=Wd();return new Mn(t)}function kc(t){return Oe.Point.fromBytes(t).toBytes()}function Kc(t){try{return Oe.getPublicKey(t,!0),t}catch(e){throw new gr(String(e))}}function Pc(t){try{return Oe.Point.fromBytes(t),t}catch(e){throw new Vt(String(e))}}function Oc(t){try{return Oe.getPublicKey(t,!0)}catch(e){throw new gr(String(e))}}function Wd(){return Oe.utils.randomSecretKey()}async function Fc(t,e){if(t==="Ed25519")return oc();if(t==="secp256k1")return Mc();if(t==="RSA")return Qi(Jd(e));if(t==="ECDSA")return da(Qd(e));throw new qt}function Vc(t,e){let{Type:r,Data:n}=Ge.decode(t),o=n??new Uint8Array;switch(r){case ie.RSA:return Xi(o,e);case ie.Ed25519:return Li(o);case ie.secp256k1:return ss(o);case ie.ECDSA:return si(o);default:throw new qt}}function qc(t){let{Type:e,Data:r}=Ge.decode(t.digest),n=r??new Uint8Array;switch(e){case ie.Ed25519:return Li(n);case ie.secp256k1:return ss(n);case ie.ECDSA:return si(n);default:throw new qt}}function ht(t){return Ge.encode({Type:ie[t.type],Data:t.raw})}function Jd(t){return t==null?2048:parseInt(t,10)}function Qd(t){if(t==="P-256"||t==null)return"P-256";if(t==="P-384")return"P-384";if(t==="P-521")return"P-521";throw new te("Unsupported curve, should be P-256, P-384 or P-521")}function eh(t,e){if(typeof t=="string")return th(t);if(typeof t=="number")return oh(t,e);throw Error(`Value provided to ms() must be a string or number. value=${JSON.stringify(t)}`)}var Fn=eh;function th(t){if(typeof t!="string"||t.length===0||t.length>100)throw Error(`Value provided to ms.parse() must be a string with length between 1 and 99. value=${JSON.stringify(t)}`);let e=/^(?<value>-?\d*\.?\d+) *(?<unit>milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.exec(t);if(!e?.groups)return NaN;let{value:r,unit:n="ms"}=e.groups,o=parseFloat(r),i=n.toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return o*315576e5;case"months":case"month":case"mo":return o*26298e5;case"weeks":case"week":case"w":return o*6048e5;case"days":case"day":case"d":return o*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return o*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return o*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return o*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return o;default:throw Error(`Unknown unit "${i}" provided to ms.parse(). value=${JSON.stringify(t)}`)}}function rh(t){let e=Math.abs(t);return e>=315576e5?`${Math.round(t/315576e5)}y`:e>=26298e5?`${Math.round(t/26298e5)}mo`:e>=6048e5?`${Math.round(t/6048e5)}w`:e>=864e5?`${Math.round(t/864e5)}d`:e>=36e5?`${Math.round(t/36e5)}h`:e>=6e4?`${Math.round(t/6e4)}m`:e>=1e3?`${Math.round(t/1e3)}s`:`${t}ms`}function nh(t){let e=Math.abs(t);return e>=315576e5?Pt(t,e,315576e5,"year"):e>=26298e5?Pt(t,e,26298e5,"month"):e>=6048e5?Pt(t,e,6048e5,"week"):e>=864e5?Pt(t,e,864e5,"day"):e>=36e5?Pt(t,e,36e5,"hour"):e>=6e4?Pt(t,e,6e4,"minute"):e>=1e3?Pt(t,e,1e3,"second"):`${t} ms`}function oh(t,e){if(typeof t!="number"||!Number.isFinite(t))throw Error("Value provided to ms.format() must be of type number.");return e?.long?nh(t):rh(t)}function Pt(t,e,r,n){let o=e>=r*1.5;return`${Math.round(t/r)} ${n}${o?"s":""}`}function as(t){r.debug=r,r.default=r,r.coerce=a,r.disable=i,r.enable=o,r.enabled=s,r.humanize=Fn,r.destroy=f,Object.keys(t).forEach(u=>{r[u]=t[u]}),r.names=[],r.skips=[],r.formatters={};function e(u){let l=0;for(let g=0;g<u.length;g++)l=(l<<5)-l+u.charCodeAt(g),l|=0;return r.colors[Math.abs(l)%r.colors.length]}r.selectColor=e;function r(u,l){let g,S=null,x,T;function E(...w){if(!E.enabled)return;let B=E,v=Number(new Date),U=v-(g||v);B.diff=U,B.prev=g,B.curr=v,g=v,w[0]=r.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let P=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(M,p)=>{if(M==="%%")return"%";P++;let m=r.formatters[p];if(typeof m=="function"){let _=w[P];M=m.call(B,_),w.splice(P,1),P--}return M}),r.formatArgs.call(B,w),l?.onLog!=null&&l.onLog(...w),(B.log||r.log).apply(B,w)}return E.namespace=u,E.useColors=r.useColors(),E.color=r.selectColor(u),E.extend=n,E.destroy=r.destroy,Object.defineProperty(E,"enabled",{enumerable:!0,configurable:!1,get:()=>S!==null?S:(x!==r.namespaces&&(x=r.namespaces,T=r.enabled(u)),T),set:w=>{S=w}}),typeof r.init=="function"&&r.init(E),E}function n(u,l){let g=r(this.namespace+(typeof l>"u"?":":l)+u);return g.log=this.log,g}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let l,g=(typeof u=="string"?u:"").split(/[\s,]+/),S=g.length;for(l=0;l<S;l++)g[l]&&(u=g[l].replace(/\*/g,".*?"),u[0]==="-"?r.skips.push(new RegExp("^"+u.substr(1)+"$")):r.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...r.names.map(c),...r.skips.map(c).map(l=>"-"+l)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,g;for(l=0,g=r.skips.length;l<g;l++)if(r.skips[l].test(u))return!1;for(l=0,g=r.names.length;l<g;l++)if(r.names[l].test(u))return!0;return!1}function c(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function a(u){return u instanceof Error?u.stack??u.message:u}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.setupFormatters(r.formatters),r.enable(r.load()),r}var Vn=lh(),ih=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function sh(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/(edge|trident)\/(\d+)/)!=null?!1:typeof document<"u"&&document.documentElement?.style?.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/firefox\/(\d+)/)!=null&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/)}function ah(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+Fn(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}var ch=console.debug??console.log??(()=>{});function uh(t){try{t?Vn?.setItem("debug",t):Vn?.removeItem("debug")}catch{}}function fh(){let t;try{t=Vn?.getItem("debug")}catch{}return!t&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(t=globalThis.process.env.DEBUG),t}function lh(){try{return localStorage}catch{}}function dh(t){t.j=function(e){try{return JSON.stringify(e)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var Hc=as({formatArgs:ah,save:uh,load:fh,useColors:sh,setupFormatters:dh,colors:ih,storage:Vn,log:ch});var Se=Hc;Se.formatters.b=t=>t==null?"undefined":X.baseEncode(t);Se.formatters.t=t=>t==null?"undefined":lt.baseEncode(t);Se.formatters.m=t=>t==null?"undefined":Zo.baseEncode(t);Se.formatters.p=t=>t==null?"undefined":t.toString();Se.formatters.c=t=>t==null?"undefined":t.toString();Se.formatters.k=t=>t==null?"undefined":t.toString();Se.formatters.a=t=>t==null?"undefined":t.toString();function $c(t,e=""){let r=zc(t.message),n=zc(t.stack);return r!=null&&n!=null?n.includes(r)?`${n.split(`
4
4
  `).join(`
5
5
  ${e}`)}`:`${r}
6
6
  ${e}${n.split(`
@@ -10,7 +10,7 @@ ${e}`)}`:n!=null?`${n.split(`
10
10
  ${e}`)}`:r!=null?`${r}`:`${t.toString()}`}function hh(t){return t instanceof AggregateError||t?.name==="AggregateError"&&Array.isArray(t.errors)}function jc(t,e=""){if(hh(t)){let r=$c(t,e);return t.errors.length>0?(e=`${e} `,r+=`
11
11
  ${e}${t.errors.map(n=>`${jc(n,`${e}`)}`).join(`
12
12
  ${e}`)}`):r+=`
13
- ${e}[Error list was empty]`,r.trim()}return $c(t,e)}Se.formatters.e=t=>t==null?"undefined":jc(t);function ph(t){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=t,e.destroy=()=>!0,e.extend=()=>e,e}function Ot(t,e){let r=ph(`${t}:trace`);return Se.enabled(`${t}:trace`)&&Se.names.map(n=>n.toString()).find(n=>n.includes(":trace"))!=null&&(r=Se(`${t}:trace`,e)),Object.assign(Se(t,e),{error:Se(`${t}:error`,e),trace:r,newScope:n=>Ot(`${t}:${n}`,e)})}function zc(t){if(t!=null&&(t=t.trim(),t.length!==0))return t}var sf=Do(qn(),1);var Hn=class extends Error{static name="SignatureCreationError";constructor(e="Record signature creation failed"){super(e),this.name="SignatureCreationError"}},Me=class extends Error{static name="SignatureVerificationError";constructor(e="Record signature verification failed"){super(e),this.name="SignatureVerificationError"}},$n=class extends Error{static name="RecordExpiredError";constructor(e="Record has expired"){super(e),this.name="RecordExpiredError"}},Mt=class extends Error{static name="UnsupportedValidityError";constructor(e="The validity type is unsupported"){super(e),this.name="UnsupportedValidityError"}},zn=class extends Error{static name="RecordTooLargeError";constructor(e="The record is too large"){super(e),this.name="RecordTooLargeError"}},$r=class extends Error{static name="InvalidValueError";constructor(e="Value must be a valid content path starting with /"){super(e),this.name="InvalidValueError"}},jn=class extends Error{static name="InvalidRecordDataError";constructor(e="Invalid record data"){super(e),this.name="InvalidRecordDataError"}},zr=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(e="Invalid embedded public key"){super(e),this.name="InvalidEmbeddedPublicKeyError"}};var de;(function(t){let e;(function(o){o.EOL="EOL"})(e=t.ValidityType||(t.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),(function(o){o.codec=()=>Fr(r)})(e=t.ValidityType||(t.ValidityType={}));let n;t.codec=()=>(n==null&&(n=Ye((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),t.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let c={},a=i==null?o.len:o.pos+i;for(;o.pos<a;){let f=o.uint32();switch(f>>>3){case 1:{c.value=o.bytes();break}case 2:{c.signatureV1=o.bytes();break}case 3:{c.validityType=t.ValidityType.codec().decode(o);break}case 4:{c.validity=o.bytes();break}case 5:{c.sequence=o.uint64();break}case 6:{c.ttl=o.uint64();break}case 7:{c.pubKey=o.bytes();break}case 8:{c.signatureV2=o.bytes();break}case 9:{c.data=o.bytes();break}default:{o.skipType(f&7);break}}}return c})),n),t.encode=o=>Ze(o,t.codec()),t.decode=(o,i)=>je(o,t.codec(),i)})(de||(de={}));var mh=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function us(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(e==="string"||e==="number"||e==="bigint"||e==="symbol")return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(t instanceof Uint8Array)return"Uint8Array";if(t.constructor===Object)return"Object";let r=yh(t);return r||"Object"}function yh(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(mh.includes(e))return e}var h=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}static equals(e,r){return e===r||e.major===r.major&&e.name===r.name}};h.uint=new h(0,"uint",!0);h.negint=new h(1,"negint",!0);h.bytes=new h(2,"bytes",!0);h.string=new h(3,"string",!0);h.array=new h(4,"array",!1);h.map=new h(5,"map",!1);h.tag=new h(6,"tag",!1);h.float=new h(7,"float",!0);h.false=new h(7,"false",!0);h.true=new h(7,"true",!0);h.null=new h(7,"null",!0);h.undefined=new h(7,"undefined",!0);h.break=new h(7,"break",!0);var D=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var jr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",gh=new TextEncoder;function Zn(t){return jr&&globalThis.Buffer.isBuffer(t)}function Zr(t){return t instanceof Uint8Array?Zn(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var bh=24,xh=200,Yn=jr?t=>t.length>=bh?globalThis.Buffer.from(t):Zc(t):t=>t.length>=xh?gh.encode(t):Zc(t),Xe=t=>Uint8Array.from(t),Yc=jr?(t,e,r)=>Zn(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),Gc=jr?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Zr(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let o of t)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Xc=jr?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function Gn(t,e){if(Zn(t)&&Zn(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function Zc(t){let e=[],r=0;for(let n=0;n<t.length;n++){let o=t.charCodeAt(n);o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&n+1<t.length&&(t.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(t.charCodeAt(++n)&1023),e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128)}return e}var wh=256,Yr=class{constructor(e=wh){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(e,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(r=Xc(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Yc(n,0,this.cursor)}else r=Gc(this.chunks,this.cursor);return e&&this.reset(),r}},Xn=class{constructor(e){this.dest=e,this.cursor=0,this.chunks=[e]}reset(){this.cursor=0}push(e){if(this.cursor+e.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(e,this.cursor),this.cursor+=e.length}toBytes(e=!1){let r=this.dest.subarray(0,this.cursor);return e&&this.reset(),r}};var V="CBOR decode error:",Wn="CBOR encode error:",Gr=[];Gr[23]=1;Gr[24]=2;Gr[25]=3;Gr[26]=5;Gr[27]=9;function ct(t,e,r){if(t.length-e<r)throw new Error(`${V} not enough data for type`)}var ue=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Te(t,e,r){ct(t,e,1);let n=t[e];if(r.strict===!0&&n<ue[0])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);return n}function Be(t,e,r){ct(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<ue[1])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);return n}function Ce(t,e,r){ct(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<ue[2])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);return n}function _e(t,e,r){ct(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],o=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<ue[3])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${V} integers outside of the safe integer range are not supported`)}function Wc(t,e,r,n){return new D(h.uint,Te(t,e+1,n),2)}function Jc(t,e,r,n){return new D(h.uint,Be(t,e+1,n),3)}function Qc(t,e,r,n){return new D(h.uint,Ce(t,e+1,n),5)}function eu(t,e,r,n){return new D(h.uint,_e(t,e+1,n),9)}function De(t,e){return Y(t,0,e.value)}function Y(t,e,r){if(r<ue[0]){let n=Number(r);t.push([e|n])}else if(r<ue[1]){let n=Number(r);t.push([e|24,n])}else if(r<ue[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<ue[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<ue[4]){let o=[e|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,t.push(o)}else throw new Error(`${V} encountered BigInt larger than allowable range`)}}De.encodedSize=function(e){return Y.encodedSize(e.value)};Y.encodedSize=function(e){return e<ue[0]?1:e<ue[1]?2:e<ue[2]?3:e<ue[3]?5:9};De.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};function tu(t,e,r,n){return new D(h.negint,-1-Te(t,e+1,n),2)}function ru(t,e,r,n){return new D(h.negint,-1-Be(t,e+1,n),3)}function nu(t,e,r,n){return new D(h.negint,-1-Ce(t,e+1,n),5)}var fs=BigInt(-1),ou=BigInt(1);function iu(t,e,r,n){let o=_e(t,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new D(h.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${V} integers outside of the safe integer range are not supported`);return new D(h.negint,fs-BigInt(o),9)}function Jn(t,e){let r=e.value,n=typeof r=="bigint"?r*fs-ou:r*-1-1;Y(t,e.type.majorEncoded,n)}Jn.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*fs-ou:r*-1-1;return n<ue[0]?1:n<ue[1]?2:n<ue[2]?3:n<ue[3]?5:9};Jn.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};function Xr(t,e,r,n){ct(t,e,r+n);let o=t.slice(e+r,e+r+n);return new D(h.bytes,o,r+n)}function su(t,e,r,n){return Xr(t,e,1,r)}function au(t,e,r,n){return Xr(t,e,2,Te(t,e+1,n))}function cu(t,e,r,n){return Xr(t,e,3,Be(t,e+1,n))}function uu(t,e,r,n){return Xr(t,e,5,Ce(t,e+1,n))}function fu(t,e,r,n){let o=_e(t,e+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer bytes lengths not supported`);return Xr(t,e,9,o)}function Qn(t){return t.encodedBytes===void 0&&(t.encodedBytes=h.equals(t.type,h.string)?Yn(t.value):t.value),t.encodedBytes}function ar(t,e){let r=Qn(e);Y(t,e.type.majorEncoded,r.length),t.push(r)}ar.encodedSize=function(e){let r=Qn(e);return Y.encodedSize(r.length)+r.length};ar.compareTokens=function(e,r){return Sh(Qn(e),Qn(r))};function Sh(t,e){return t.length<e.length?-1:t.length>e.length?1:Gn(t,e)}var lu=new TextDecoder,Ah=32;function Ih(t,e,r){if(r-e<Ah){let o="";for(let i=e;i<r;i++){let s=t[i];if(s&128)return lu.decode(t.subarray(e,r));o+=String.fromCharCode(s)}return o}return lu.decode(t.subarray(e,r))}function Wr(t,e,r,n,o){let i=r+n;ct(t,e,i);let s=new D(h.string,Ih(t,e+r,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=t.slice(e+r,e+i)),s}function du(t,e,r,n){return Wr(t,e,1,r,n)}function hu(t,e,r,n){return Wr(t,e,2,Te(t,e+1,n),n)}function pu(t,e,r,n){return Wr(t,e,3,Be(t,e+1,n),n)}function mu(t,e,r,n){return Wr(t,e,5,Ce(t,e+1,n),n)}function yu(t,e,r,n){let o=_e(t,e+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer string lengths not supported`);return Wr(t,e,9,o,n)}var gu=ar;function cr(t,e,r,n){return new D(h.array,n,r)}function bu(t,e,r,n){return cr(t,e,1,r)}function xu(t,e,r,n){return cr(t,e,2,Te(t,e+1,n))}function wu(t,e,r,n){return cr(t,e,3,Be(t,e+1,n))}function Eu(t,e,r,n){return cr(t,e,5,Ce(t,e+1,n))}function Su(t,e,r,n){let o=_e(t,e+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer array lengths not supported`);return cr(t,e,9,o)}function vu(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${V} indefinite length items not allowed`);return cr(t,e,1,1/0)}function eo(t,e){Y(t,h.array.majorEncoded,e.value)}eo.compareTokens=De.compareTokens;eo.encodedSize=function(e){return Y.encodedSize(e.value)};function ur(t,e,r,n){return new D(h.map,n,r)}function Au(t,e,r,n){return ur(t,e,1,r)}function Iu(t,e,r,n){return ur(t,e,2,Te(t,e+1,n))}function Tu(t,e,r,n){return ur(t,e,3,Be(t,e+1,n))}function Bu(t,e,r,n){return ur(t,e,5,Ce(t,e+1,n))}function Cu(t,e,r,n){let o=_e(t,e+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer map lengths not supported`);return ur(t,e,9,o)}function _u(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${V} indefinite length items not allowed`);return ur(t,e,1,1/0)}function to(t,e){Y(t,h.map.majorEncoded,e.value)}to.compareTokens=De.compareTokens;to.encodedSize=function(e){return Y.encodedSize(e.value)};function Ru(t,e,r,n){return new D(h.tag,r,1)}function Lu(t,e,r,n){return new D(h.tag,Te(t,e+1,n),2)}function Du(t,e,r,n){return new D(h.tag,Be(t,e+1,n),3)}function Uu(t,e,r,n){return new D(h.tag,Ce(t,e+1,n),5)}function Nu(t,e,r,n){return new D(h.tag,_e(t,e+1,n),9)}function ro(t,e){Y(t,h.tag.majorEncoded,e.value)}ro.compareTokens=De.compareTokens;ro.encodedSize=function(e){return Y.encodedSize(e.value)};var ls=20,ds=21,hs=22,ps=23;function ku(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${V} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new D(h.null,null,1):new D(h.undefined,void 0,1)}function Ku(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${V} indefinite length items not allowed`);return new D(h.break,void 0,1)}function ms(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${V} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${V} Infinity values are not supported`)}return new D(h.float,t,e)}function Pu(t,e,r,n){return ms(ys(t,e+1),3,n)}function Ou(t,e,r,n){return ms(gs(t,e+1),5,n)}function Mu(t,e,r,n){return ms(Hu(t,e+1),9,n)}function Jr(t,e,r){let n=e.value;if(n===!1)t.push([h.float.majorEncoded|ls]);else if(n===!0)t.push([h.float.majorEncoded|ds]);else if(n===null)t.push([h.float.majorEncoded|hs]);else if(n===void 0)t.push([h.float.majorEncoded|ps]);else{let o,i=!1;(!r||r.float64!==!0)&&(Vu(n),o=ys(Fe,1),n===o||Number.isNaN(n)?(Fe[0]=249,t.push(Fe.slice(0,3)),i=!0):(qu(n),o=gs(Fe,1),n===o&&(Fe[0]=250,t.push(Fe.slice(0,5)),i=!0))),i||(Rh(n),o=Hu(Fe,1),Fe[0]=251,t.push(Fe.slice(0,9)))}}Jr.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Vu(n);let o=ys(Fe,1);if(n===o||Number.isNaN(n))return 3;if(qu(n),o=gs(Fe,1),n===o)return 5}return 9};var Fu=new ArrayBuffer(9),Ue=new DataView(Fu,1),Fe=new Uint8Array(Fu,0);function Vu(t){if(t===1/0)Ue.setUint16(0,31744,!1);else if(t===-1/0)Ue.setUint16(0,64512,!1);else if(Number.isNaN(t))Ue.setUint16(0,32256,!1);else{Ue.setFloat32(0,t);let e=Ue.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)Ue.setUint16(0,31744,!1);else if(r===0)Ue.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Ue.setUint16(0,0):o<-14?Ue.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):Ue.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function ys(t,e){if(t.length-e<2)throw new Error(`${V} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function qu(t){Ue.setFloat32(0,t,!1)}function gs(t,e){if(t.length-e<4)throw new Error(`${V} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function Rh(t){Ue.setFloat64(0,t,!1)}function Hu(t,e){if(t.length-e<8)throw new Error(`${V} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}Jr.compareTokens=De.compareTokens;function j(t,e,r){throw new Error(`${V} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function no(t){return()=>{throw new Error(`${V} ${t}`)}}var C=[];for(let t=0;t<=23;t++)C[t]=j;C[24]=Wc;C[25]=Jc;C[26]=Qc;C[27]=eu;C[28]=j;C[29]=j;C[30]=j;C[31]=j;for(let t=32;t<=55;t++)C[t]=j;C[56]=tu;C[57]=ru;C[58]=nu;C[59]=iu;C[60]=j;C[61]=j;C[62]=j;C[63]=j;for(let t=64;t<=87;t++)C[t]=su;C[88]=au;C[89]=cu;C[90]=uu;C[91]=fu;C[92]=j;C[93]=j;C[94]=j;C[95]=no("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)C[t]=du;C[120]=hu;C[121]=pu;C[122]=mu;C[123]=yu;C[124]=j;C[125]=j;C[126]=j;C[127]=no("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)C[t]=bu;C[152]=xu;C[153]=wu;C[154]=Eu;C[155]=Su;C[156]=j;C[157]=j;C[158]=j;C[159]=vu;for(let t=160;t<=183;t++)C[t]=Au;C[184]=Iu;C[185]=Tu;C[186]=Bu;C[187]=Cu;C[188]=j;C[189]=j;C[190]=j;C[191]=_u;for(let t=192;t<=215;t++)C[t]=Ru;C[216]=Lu;C[217]=Du;C[218]=Uu;C[219]=Nu;C[220]=j;C[221]=j;C[222]=j;C[223]=j;for(let t=224;t<=243;t++)C[t]=no("simple values are not supported");C[244]=j;C[245]=j;C[246]=j;C[247]=ku;C[248]=no("simple values are not supported");C[249]=Pu;C[250]=Ou;C[251]=Mu;C[252]=j;C[253]=j;C[254]=j;C[255]=Ku;var Ve=[];for(let t=0;t<24;t++)Ve[t]=new D(h.uint,t,1);for(let t=-1;t>=-24;t--)Ve[31-t]=new D(h.negint,t,1);Ve[64]=new D(h.bytes,new Uint8Array(0),1);Ve[96]=new D(h.string,"",1);Ve[128]=new D(h.array,0,1);Ve[160]=new D(h.map,0,1);Ve[244]=new D(h.false,!1,1);Ve[245]=new D(h.true,!0,1);Ve[246]=new D(h.null,null,1);function bs(t){switch(t.type){case h.false:return Xe([244]);case h.true:return Xe([245]);case h.null:return Xe([246]);case h.bytes:return t.value.length?void 0:Xe([64]);case h.string:return t.value===""?Xe([96]):void 0;case h.array:return t.value===0?Xe([128]):void 0;case h.map:return t.value===0?Xe([160]):void 0;case h.uint:return t.value<24?Xe([Number(t.value)]):void 0;case h.negint:if(t.value>=-24)return Xe([31-Number(t.value)])}}var Dh={float64:!1,mapSorter:kh,quickEncodeToken:bs},Yu=Object.freeze({float64:!0,mapSorter:Kh,quickEncodeToken:bs});function Uh(){let t=[];return t[h.uint.major]=De,t[h.negint.major]=Jn,t[h.bytes.major]=ar,t[h.string.major]=gu,t[h.array.major]=eo,t[h.map.major]=to,t[h.tag.major]=ro,t[h.float.major]=Jr,t}var fr=Uh(),oo=new Yr,en=class t{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${Wn} object contains circular references`);return new t(r,e)}},St={null:new D(h.null,null),undefined:new D(h.undefined,void 0),true:new D(h.true,!0),false:new D(h.false,!1),emptyArray:new D(h.array,0),emptyMap:new D(h.map,0)},We={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new D(h.float,t):t>=0?new D(h.uint,t):new D(h.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new D(h.uint,t):new D(h.negint,t)},Uint8Array(t,e,r,n){return new D(h.bytes,t)},string(t,e,r,n){return new D(h.string,t)},boolean(t,e,r,n){return t?St.true:St.false},null(t,e,r,n){return St.null},undefined(t,e,r,n){return St.undefined},ArrayBuffer(t,e,r,n){return new D(h.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new D(h.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[St.emptyArray,new D(h.break)]:St.emptyArray;n=en.createCheck(n,t);let o=[],i=0;for(let s of t)o[i++]=io(s,r,n);return r.addBreakTokens?[new D(h.array,t.length),o,new D(h.break)]:[new D(h.array,t.length),o]},Object(t,e,r,n){let o=e!=="Object",i=o?t.keys():Object.keys(t),s=o?t.size:i.length,c;if(s){c=new Array(s),n=en.createCheck(n,t);let a=!o&&r.ignoreUndefinedProperties,f=0;for(let u of i){let l=o?t.get(u):t[u];a&&l===void 0||(c[f++]=[io(u,r,n),io(l,r,n)])}f<s&&(c.length=f)}return c?.length?(Nh(c,r),r.addBreakTokens?[new D(h.map,c.length),c,new D(h.break)]:[new D(h.map,c.length),c]):r.addBreakTokens===!0?[St.emptyMap,new D(h.break)]:St.emptyMap}};We.Map=We.Object;We.Buffer=We.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))We[`${t}Array`]=We.DataView;function io(t,e={},r){let n=us(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||We[n];if(typeof o=="function"){let s=o(t,n,e,r);if(s!=null)return s}let i=We[n];if(!i)throw new Error(`${Wn} unsupported type: ${n}`);return i(t,n,e,r)}function Nh(t,e){e.mapSorter&&t.sort(e.mapSorter)}function kh(t,e){let r=Array.isArray(t[0])?t[0][0]:t[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=fr[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Kh(t,e){if(t[0]instanceof D&&e[0]instanceof D){let r=t[0],n=e[0];return r._keyBytes||(r._keyBytes=$u(r.value)),n._keyBytes||(n._keyBytes=$u(n.value)),Gn(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function $u(t){return Xu(t,fr,Yu)}function Qr(t,e,r,n){if(Array.isArray(e))for(let o of e)Qr(t,o,r,n);else r[e.type.major](t,e,n)}var zu=h.uint.majorEncoded,ju=h.negint.majorEncoded,Ph=h.bytes.majorEncoded,Oh=h.string.majorEncoded,Zu=h.array.majorEncoded,Mh=h.float.majorEncoded|ls,Fh=h.float.majorEncoded|ds,Vh=h.float.majorEncoded|hs,qh=h.float.majorEncoded|ps,Hh=BigInt(-1),$h=BigInt(1);function zh(t){return t.addBreakTokens!==!0}function Gu(t,e,r,n){let o=us(e),i=r.typeEncoders&&r.typeEncoders[o];if(i){let s=i(e,o,r,n);if(s!=null){Qr(t,s,fr,r);return}}switch(o){case"null":t.push([Vh]);return;case"undefined":t.push([qh]);return;case"boolean":t.push([e?Fh:Mh]);return;case"number":!Number.isInteger(e)||!Number.isSafeInteger(e)?Jr(t,new D(h.float,e),r):e>=0?Y(t,zu,e):Y(t,ju,e*-1-1);return;case"bigint":e>=BigInt(0)?Y(t,zu,e):Y(t,ju,e*Hh-$h);return;case"string":{let s=Yn(e);Y(t,Oh,s.length),t.push(s);return}case"Uint8Array":Y(t,Ph,e.length),t.push(e);return;case"Array":if(!e.length){t.push([Zu]);return}n=en.createCheck(n,e),Y(t,Zu,e.length);for(let s of e)Gu(t,s,r,n);return;case"Object":case"Map":{let s=We.Object(e,o,r,n);Qr(t,s,fr,r)}return;default:{let s=We[o];if(!s)throw new Error(`${Wn} unsupported type: ${o}`);let c=s(e,o,r,n);Qr(t,c,fr,r)}}}function Xu(t,e,r,n){let o=n instanceof Uint8Array,i=o?new Xn(n):oo,s=io(t,r);if(!Array.isArray(s)&&r.quickEncodeToken){let c=r.quickEncodeToken(s);if(c)return o?(i.push(c),i.toBytes()):c;let a=e[s.type.major];if(a.encodedSize){let f=a.encodedSize(s,r);if(o||(i=new Yr(f)),a(i,s,r),i.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${s} was wrong`);return o?i.toBytes():Zr(i.chunks[0])}}return i.reset(),Qr(i,s,e,r),i.toBytes(!0)}function xs(t,e){return e=Object.assign({},Dh,e),zh(e)?(oo.reset(),Gu(oo,t,e,void 0),oo.toBytes(!0)):Xu(t,fr,e)}var jh={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},so=class{constructor(e,r={}){this._pos=0,this.data=e,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],r=Ve[e];if(r===void 0){let n=C[e];if(!n)throw new Error(`${V} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},tn=Symbol.for("DONE"),ao=Symbol.for("BREAK");function Zh(t,e,r){let n=[];for(let o=0;o<t.value;o++){let i=lr(e,r);if(i===ao){if(t.value===1/0)break;throw new Error(`${V} got unexpected break to lengthed array`)}if(i===tn)throw new Error(`${V} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=i}return n}function Yh(t,e,r){let n=r.useMaps===!0,o=r.rejectDuplicateMapKeys===!0,i=n?void 0:{},s=n?new Map:void 0;for(let c=0;c<t.value;c++){let a=lr(e,r);if(a===ao){if(t.value===1/0)break;throw new Error(`${V} got unexpected break to lengthed map`)}if(a===tn)throw new Error(`${V} found map but not enough entries (got ${c} [no key], expected ${t.value})`);if(!n&&typeof a!="string")throw new Error(`${V} non-string keys not supported (got ${typeof a})`);if(o&&(n&&s.has(a)||!n&&Object.hasOwn(i,a)))throw new Error(`${V} found repeat map key "${a}"`);let f=lr(e,r);if(f===tn)throw new Error(`${V} found map but not enough entries (got ${c} [no value], expected ${t.value})`);n?s.set(a,f):i[a]=f}return n?s:i}function lr(t,e){if(t.done())return tn;let r=t.next();if(h.equals(r.type,h.break))return ao;if(r.type.terminal)return r.value;if(h.equals(r.type,h.array))return Zh(r,t,e);if(h.equals(r.type,h.map))return Yh(r,t,e);if(h.equals(r.type,h.tag)){if(e.tags&&typeof e.tags[r.value]=="function"){let n=lr(t,e);return e.tags[r.value](n)}throw new Error(`${V} tag not supported (${r.value})`)}throw new Error("unsupported")}function Wu(t,e){if(!(t instanceof Uint8Array))throw new Error(`${V} data to decode must be a Uint8Array`);e=Object.assign({},jh,e);let r=Zr(t),n=e.tokenizer||new so(r,e),o=lr(n,e);if(o===tn)throw new Error(`${V} did not find any content to decode`);if(o===ao)throw new Error(`${V} got unexpected break`);return[o,t.subarray(n.pos())]}function ws(t,e){let[r,n]=Wu(t,e);if(n.length>0)throw new Error(`${V} too many terminals, data makes no sense`);return r}var Xh=Ot("ipns:utils"),Ju=$("/ipns/"),Wh=114,Jh=0,Qh=18;function Qu(t){let e;if(t.pubKey!=null)try{e=Vc(t.pubKey)}catch(r){throw Xh.error(r),r}if(e!=null)return e}function ef(t,e,r){let n=$(e);return dt([t,r,n])}function uo(t){let e=$("ipns-signature:");return dt([e,t])}function rn(t){return"signatureV1"in t?de.encode({value:$(t.value),signatureV1:t.signatureV1,validityType:t.validityType,validity:$(t.validity),sequence:t.sequence,ttl:t.ttl,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data}):de.encode({pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data})}function Re(t){let e=de.decode(t);if(e.sequence!=null&&(e.sequence=BigInt(e.sequence)),e.ttl!=null&&(e.ttl=BigInt(e.ttl)),e.signatureV2==null||e.data==null)throw new Me("Missing data or signatureV2");let r=nf(e.data),n=ep(r.Value),o=Z(r.Validity);if(e.value!=null&&e.signatureV1!=null)return tp(e),{value:n,validityType:de.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:e.pubKey,signatureV1:e.signatureV1,signatureV2:e.signatureV2,data:e.data};if(e.signatureV2!=null)return{value:n,validityType:de.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function vt(t){return dt([Ju,t.bytes])}function tf(t){let e=Zt(t.slice(Ju.length));if(!co(e,Jh)&&!co(e,Qh))throw new hn("Multihash in IPNS key was not identity or sha2-256");return e}function rf(t,e,r,n,o){let i;if(e===de.ValidityType.EOL)i=0;else throw new Mt("The validity type is unsupported");return xs({Value:t,Validity:r,ValidityType:i,Sequence:n,TTL:o})}function nf(t){let e=ws(t);if(e.ValidityType===0)e.ValidityType=de.ValidityType.EOL;else throw new Mt("The validity type is unsupported");return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e}function ep(t){let e=Z(t).trim();if(e.startsWith("/"))return e;try{return`/ipfs/${se.decode(t).toV1().toString()}`}catch{}try{return`/ipfs/${se.parse(e).toV1().toString()}`}catch{}throw new $r("Value must be a valid content path starting with /")}function of(t){if(t!=null){let e=op(t);if(e!=null)return e.code===Wh?`/ipns/${e.toString(Ne)}`:`/ipfs/${e.toV1().toString()}`;if(rp(t))return`/ipns/${Ne.encode(t.bytes)}`;let r=t.toString().trim();if(r.startsWith("/")&&r.length>1)return r}throw new $r("Value must be a valid content path starting with /")}function tp(t){if(t.data==null)throw new jn("Record data is missing");let e=nf(t.data);if(!ne(e.Value,t.value??new Uint8Array(0)))throw new Me('Field "value" did not match between protobuf and CBOR');if(!ne(e.Validity,t.validity??new Uint8Array(0)))throw new Me('Field "validity" did not match between protobuf and CBOR');if(e.ValidityType!==t.validityType)throw new Me('Field "validityType" did not match between protobuf and CBOR');if(e.Sequence!==t.sequence)throw new Me('Field "sequence" did not match between protobuf and CBOR');if(e.TTL!==t.ttl)throw new Me('Field "ttl" did not match between protobuf and CBOR')}function rp(t){return t.bytes instanceof Uint8Array}function np(t){return typeof t?.toCID=="function"}function op(t){if(np(t))return t.toCID();try{return se.parse(t)}catch{}return se.asCID(t)}function co(t,e){return t.code===e}var fo=Ot("ipns:validator"),ip=1024*10;async function sp(t,e){let r=Re(e),n;try{let o=uo(r.data);n=await t.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw fo.error("record signature verification failed"),new Me("Record signature verification failed");if(r.validityType===de.ValidityType.EOL){if(sf.default.fromString(r.validity).toDate().getTime()<Date.now())throw fo.error("record has expired"),new $n("record has expired")}else if(r.validityType!=null)throw fo.error("the validity type is unsupported"),new Mt("The validity type is unsupported");fo("ipns record for %s is valid",r.value)}async function nn(t,e){if(e.byteLength>ip)throw new zn("The record is too large");let r=tf(t),n;co(r,0)&&(n=qc(r));let o=Re(e),i=Qu(o)??n;if(i==null)throw new zr("Could not extract public key from IPNS record or routing key");let s=vt(i.toMultihash());if(!ne(s,t))throw new zr("Embedded public key did not match routing key");await sp(i,e)}var af=Do(qn(),1);var ap=Ot("ipns"),cf=300*1e9,cp="/ipns/",Ax=cp.length,uf={v1Compatible:!0,ttlNs:cf};async function lo(t,e,r,n,o=uf){let i=new af.default(Date.now()+Number(n)),s=de.ValidityType.EOL,c=BigInt(o.ttlNs??cf);return up(t,e,r,s,i.toString(),c,o)}var up=async(t,e,r,n,o,i,s=uf)=>{r=BigInt(r);let c=$(o),a=of(e),f=$(a),u=rf(f,n,c,r,i),l=uo(u),g=await t.sign(l),S;if(t.type==="RSA"&&(S=ht(t.publicKey)),s.v1Compatible===!0){let x=await fp(t,f,n,c),T={value:a,signatureV1:x,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:g,data:u};return S!=null&&(T.pubKey=S),T}else{let x={value:a,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:g,data:u};return S!=null&&(x.pubKey=S),x}},fp=async(t,e,r,n)=>{try{let o=ef(e,r,n);return await t.sign(o)}catch(o){throw ap.error("record signature creation failed",o),new Hn("Record signature creation failed")}};var Es=Do(qn(),1);function ho(t,e){let r=e.map((n,o)=>({record:Re(n),index:o}));return r.sort((n,o)=>{let i=n.record.sequence,s=o.record.sequence;if(i>s)return-1;if(i<s)return 1;if(n.record.validityType===de.ValidityType.EOL&&o.record.validityType===de.ValidityType.EOL){let c=Es.default.fromString(n.record.validity).toDate(),a=Es.default.fromString(o.record.validity).toDate();if(c.getTime()>a.getTime())return-1;if(c.getTime()<a.getTime())return 1}return 0}),r[0].index}var dr=BigInt(6e4)*5000000n,ff=5;var po=class extends Error{static name="RecordsFailedValidationError";constructor(e="Records failed validation"){super(e),this.name="RecordsFailedValidationError"}},mo=class extends Error{static name="UnsupportedMultibasePrefixError";constructor(e="Unsupported multibase prefix"){super(e),this.name="UnsupportedMultibasePrefixError"}},yo=class extends Error{static name="UnsupportedMultihashCodecError";constructor(e="Unsupported multihash codec"){super(e),this.name="UnsupportedMultihashCodecError"}},go=class extends Error{static name="InvalidValueError";constructor(e="Invalid value"){super(e),this.name="InvalidValueError"}};var on=class extends Error{static name="RecordNotFoundError";name="RecordNotFoundError"};var ut="/",lf=new TextEncoder().encode(ut),bo=lf[0],hr=class t{_buf;constructor(e,r){if(typeof e=="string")this._buf=$(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==bo)throw new Error("Invalid key")}toString(e="utf8"){return Z(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new t(e.join(ut))}static random(){return new t(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new t(e):typeof e.uint8Array=="function"?new t(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=lf),this._buf[0]!==bo){let e=new Uint8Array(this._buf.byteLength+1);e.fill(bo,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===bo;)this._buf=this._buf.subarray(0,-1)}less(e){let r=this.list(),n=e.list();for(let o=0;o<r.length;o++){if(n.length<o+1)return!1;let i=r[o],s=n[o];if(i<s)return!0;if(i>s)return!1}return r.length<n.length}reverse(){return t.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(ut).slice(1)}type(){return lp(this.baseNamespace())}name(){return dp(this.baseNamespace())}instance(e){return new t(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(ut)||(e+=ut),e+=this.type(),new t(e)}parent(){let e=this.list();return e.length===1?new t(ut):new t(e.slice(0,-1).join(ut))}child(e){return this.toString()===ut?e:e.toString()===ut?this:new t(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return t.withNamespaces([...this.namespaces(),...hp(e.map(r=>r.namespaces()))])}};function lp(t){let e=t.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function dp(t){let e=t.split(":");return e[e.length-1]}function hp(t){return[].concat(...t)}var mp=114,Ss=0,vs=18;function As(t,e){return t.code===e}var xo="/dht/record/",yp="/ipns/metadata/";function sn(t){return new hr(xo+Z(t,"base32"),!1)}function wo(t){return new hr(yp+Z(t,"base32"),!1)}function df(t,e){let r=Date.now(),n=e.getTime()+1728e5,o=new Date(t.validity).getTime();return n-r<864e5||o-r<864e5}function gp(t){return t?.asCID===t}function hf(t){if(!gp(t))return!1;if(t.code!==mp)throw new te(`CID codec ${t.code} was not libp2p-key`);if(t.multihash.code!==Ss&&t.multihash.code!==vs)throw new te(`Multihash algorithm codec ${t.multihash.code} was not Identity or SHA256 hash`);return!0}var pf={[Ne.prefix]:Ne,[X.prefix]:X},pr=class{routers;localStore;log;constructor(e,r){this.log=e.logger.forComponent("helia:ipns"),this.localStore=r.localStore,this.routers=r.routers}async resolve(e,r={}){let n=Us(e)||pn(e)?e.toMultihash():hf(e)?e.multihash:e,o=vt(n),i=await this.#t(o,r);return{...await this.#e(i.value,r),record:i}}async#e(e,r={}){let n=e.split("/");try{let o=n[1];if(o==="ipns"){let i=n[2],s=i.substring(0,1),c;if(s==="1"||s==="Q")c=X.decode(`z${i}`);else if(pf[s]!=null)c=pf[s].decode(i);else throw new mo(`Unsupported multibase prefix "${s}"`);let a;try{a=Zt(c)}catch{a=se.decode(c).multihash}if(!As(a,Ss)&&!As(a,vs))throw new yo(`Unsupported multihash codec "${a.code}"`);let{cid:f}=await this.resolve(a,r),u=n.slice(3).join("/");return{cid:f,path:u===""?void 0:u}}else if(o==="ipfs"){let i=se.parse(n[2]),s=n.slice(3).join("/");return{cid:i,path:s===""?void 0:s}}}catch(o){this.log.error("error parsing ipfs path - %e",o)}throw this.log.error("invalid ipfs path %s",e),new go("Invalid value")}async#t(e,r={}){let n=[];if(await this.localStore.has(e,r))if(this.log("record is present in the cache"),r.nocache!==!0)try{let{record:a,created:f}=await this.localStore.get(e,r);this.log("record retrieved from cache"),await nn(e,a),this.log("record was valid");let u=Re(a),l=Number((u.ttl??dr)/1000000n);if(f.getTime()+l>Date.now())return this.log("record TTL was valid"),u;if(r.offline===!0)return this.log("record TTL has been reached but we are resolving offline-only, returning record"),u;this.log("record TTL has been reached, searching routing for updates"),n.push(a)}catch(a){this.log("cached record was invalid - %e",a),await this.localStore.delete(e,r)}else this.log("ignoring local cache due to nocache=true option");if(r.offline===!0)throw new on("Record was not present in the cache or has expired");this.log("did not have record locally");let i=0,s=[];if(await Promise.all(this.routers.map(async a=>{let f;try{f=await a.get(e,{...r,validate:!1})}catch(u){this.log.error("error finding IPNS record using router %s - %e",a.toString(),u),s.push(u);return}try{await nn(e,f),n.push(f)}catch(u){i++,this.log.error("error validating IPNS record from router %s - %e",a.toString(),u)}})),n.length===0)throw i>0?new po(`${i>1?`${i} records`:"Record"} found for routing key ${i>1?"were":"was"} invalid`):new on("Could not find record for routing key");let c=n[ho(e,n)];return await this.localStore.put(e,c,r),Re(c)}};var ve=class extends Event{type;detail;constructor(e,r){super(e),this.type=e,this.detail=r}};var Eo=class{routers;localStore;keychain;constructor(e,r){this.keychain=e.libp2p.services.keychain,this.localStore=r.localStore,this.routers=r.routers}async publish(e,r,n={}){try{let o=await this.#e(e),i=1n,s=vt(o.publicKey.toMultihash());if(await this.localStore.has(s,n)){let{record:l}=await this.localStore.get(s,n);i=Re(l).sequence+1n}pn(r)&&(r=r.toCID());let c=n.ttl!=null?BigInt(n.ttl)*1000000n:dr,a=n.lifetime??1728e5,f=await lo(o,r,i,a,{...n,ttlNs:c}),u=rn(f);return n.offline===!0?await this.localStore.put(s,u,{...n,metadata:{keyName:e,lifetime:a}}):await Promise.all(this.routers.map(async l=>{await l.put(s,u,{...n,metadata:{keyName:e,lifetime:a}})})),{record:f,publicKey:o.publicKey}}catch(o){throw n.onProgress?.(new ve("ipns:publish:error",o)),o}}async#e(e){try{return await this.keychain.exportKey(e)}catch{let n=await Fc("Ed25519");return await this.keychain.importKey(e,n),n}}async unpublish(e,r){let{publicKey:n}=await this.keychain.exportKey(e),o=n.toMultihash(),i=vt(o);await this.localStore.delete(i,r)}};function mr(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var So=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||(e-1&e)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},yr=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new So(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let r=this.head;this.head=r.next=new So(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var Is=class extends Error{type;code;constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function mf(t={}){return xp(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},t)}function xp(t,e){e=e??{};let r=e.onEnd,n=new yr,o,i,s,c=mr(),a=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((E,w)=>{i=B=>{i=null,n.push(B);try{E(t(n))}catch(v){w(v)}return o}}):t(n)}finally{n.isEmpty()&&queueMicrotask(()=>{c.resolve(),c=mr()})}},f=E=>i!=null?i(E):(n.push(E),o),u=E=>(n=new yr,i!=null?i({error:E}):(n.push({error:E}),o)),l=E=>{if(s)return o;if(e?.objectMode!==!0&&E?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return f({done:!1,value:E})},g=E=>s?o:(s=!0,E!=null?u(E):f({done:!0})),S=()=>(n=new yr,g(),{done:!0}),x=E=>(g(E),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:a,return:S,throw:x,push:l,end:g,get readableLength(){return n.size},onEmpty:async E=>{let w=E?.signal;if(w?.throwIfAborted(),n.isEmpty())return;let B,v;w!=null&&(B=new Promise((U,P)=>{v=()=>{P(new Is)},w.addEventListener("abort",v)}));try{await Promise.race([c.promise,B])}finally{v!=null&&w!=null&&w?.removeEventListener("abort",v)}}},r==null)return o;let T=o;return o={[Symbol.asyncIterator](){return this},next(){return T.next()},throw(E){return T.throw(E),r!=null&&(r(E),r=void 0),{done:!0}},return(){return T.return(),r!=null&&(r(),r=void 0),{done:!0}},push:l,end(E){return T.end(E),r!=null&&(r(E),r=void 0),o},get readableLength(){return T.readableLength},onEmpty:E=>T.onEmpty(E)},o}var Ts=class t extends Error{name="TimeoutError";constructor(e,r){super(e,r),Error.captureStackTrace?.(this,t)}},yf=t=>t.reason??new DOMException("This operation was aborted.","AbortError");function Bs(t,e){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout},signal:s}=e,c,a,u=new Promise((l,g)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(s?.aborted){g(yf(s));return}if(s&&(a=()=>{g(yf(s))},s.addEventListener("abort",a,{once:!0})),t.then(l,g),r===Number.POSITIVE_INFINITY)return;let S=new Ts;c=i.setTimeout.call(void 0,()=>{if(n){try{l(n())}catch(x){g(x)}return}typeof t.cancel=="function"&&t.cancel(),o===!1?l():o instanceof Error?g(o):(S.message=o??`Promise timed out after ${r} milliseconds`,g(S))},r)}).finally(()=>{u.clear(),a&&s&&s.removeEventListener("abort",a)});return u.clear=()=>{i.clearTimeout.call(void 0,c),c=void 0},u}var wp=t=>{let e=t.addEventListener||t.on||t.addListener,r=t.removeEventListener||t.off||t.removeListener;if(!e||!r)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(t),removeListener:r.bind(t)}};function Ep(t,e,r){let n,o=new Promise((i,s)=>{if(r={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...r},!(r.count>=0&&(r.count===Number.POSITIVE_INFINITY||Number.isInteger(r.count))))throw new TypeError("The `count` option should be at least 0 or more");r.signal?.throwIfAborted();let c=[e].flat(),a=[],{addListener:f,removeListener:u}=wp(t),l=async(...S)=>{let x=r.multiArgs?S:S[0];if(r.filter)try{if(!await r.filter(x))return}catch(T){n(),s(T);return}a.push(x),r.count===a.length&&(n(),i(a))},g=(...S)=>{n(),s(r.rejectionMultiArgs?S:S[0])};n=()=>{for(let S of c)u(S,l);for(let S of r.rejectionEvents)c.includes(S)||u(S,g)};for(let S of c)f(S,l);for(let S of r.rejectionEvents)c.includes(S)||f(S,g);r.signal&&r.signal.addEventListener("abort",()=>{g(r.signal.reason)},{once:!0}),r.resolveImmediately&&i(a)});if(o.cancel=n,typeof r.timeout=="number"){let i=Bs(o,{milliseconds:r.timeout});return i.cancel=()=>{n(),i.clear()},i}return o}function vo(t,e,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=Ep(t,e,r),o=n.then(i=>i[0]);return o.cancel=n.cancel,o}function an(t,e){let r,n=function(){let o=function(){r=void 0,t()};clearTimeout(r),r=setTimeout(o,e)};return n.start=()=>{},n.stop=()=>{clearTimeout(r)},n}var Ao=class extends Error{static name="QueueFullError";constructor(e="The queue was full"){super(e),this.name="QueueFullError"}};function Sp(t){return t.reason}async function gf(t,e,r){if(e==null)return t;let n=r?.translateError??Sp;if(e.aborted)return t.catch(()=>{}),Promise.reject(n(e));let o;try{return await Promise.race([t,new Promise((i,s)=>{o=()=>{s(n(e))},e.addEventListener("abort",o)})])}finally{o!=null&&e.removeEventListener("abort",o)}}var Io=class{deferred;signal;constructor(e){this.signal=e,this.deferred=mr(),this.onAbort=this.onAbort.bind(this),this.signal?.addEventListener("abort",this.onAbort)}onAbort(){this.deferred.reject(this.signal?.reason??new Je)}cleanup(){this.signal?.removeEventListener("abort",this.onAbort)}};function vp(){return`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`}var To=class{id;fn;options;recipients;status;timeline;controller;constructor(e,r){this.id=vp(),this.status="queued",this.fn=e,this.options=r,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,this.controller.signal,this.onAbort=this.onAbort.bind(this)}abort(e){this.controller.abort(e)}onAbort(){this.recipients.reduce((r,n)=>r&&n.signal?.aborted===!0,!0)&&(this.controller.abort(new Je),this.cleanup())}async join(e={}){let r=new Io(e.signal);return this.recipients.push(r),e.signal?.addEventListener("abort",this.onAbort),r.deferred.promise}async run(){this.status="running",this.timeline.started=Date.now();try{this.controller.signal.throwIfAborted();let e=await gf(this.fn({...this.options??{},signal:this.controller.signal}),this.controller.signal);this.recipients.forEach(r=>{r.deferred.resolve(e)}),this.status="complete"}catch(e){this.recipients.forEach(r=>{r.deferred.reject(e)}),this.status="errored"}finally{this.timeline.finished=Date.now(),this.cleanup()}}cleanup(){this.recipients.forEach(e=>{e.cleanup(),e.signal?.removeEventListener("abort",this.onAbort)})}};var Bo=class extends mn{concurrency;maxSize;queue;pending;sort;paused;constructor(e={}){super(),this.concurrency=e.concurrency??Number.POSITIVE_INFINITY,this.maxSize=e.maxSize??Number.POSITIVE_INFINITY,this.pending=0,this.paused=!1,e.metricName!=null&&e.metrics?.registerMetricGroup(e.metricName,{calculate:()=>({size:this.queue.length,running:this.pending,queued:this.queue.length-this.pending})}),this.sort=e.sort,this.queue=[],this.emitEmpty=an(this.emitEmpty.bind(this),1),this.emitIdle=an(this.emitIdle.bind(this),1)}emitEmpty(){this.size===0&&this.safeDispatchEvent("empty")}emitIdle(){this.running===0&&this.safeDispatchEvent("idle")}pause(){this.paused=!0}resume(){this.paused&&(this.paused=!1,this.tryToStartAnother())}tryToStartAnother(){if(this.paused)return!1;if(this.size===0)return this.emitEmpty(),this.running===0&&this.emitIdle(),!1;if(this.pending<this.concurrency){let e;for(let r of this.queue)if(r.status==="queued"){e=r;break}return e==null?!1:(this.safeDispatchEvent("active"),this.pending++,e.run().finally(()=>{for(let r=0;r<this.queue.length;r++)if(this.queue[r]===e){this.queue.splice(r,1);break}this.pending--,this.tryToStartAnother(),this.safeDispatchEvent("next")}),!0)}return!1}enqueue(e){this.queue.push(e),this.sort!=null&&this.queue.sort(this.sort)}async add(e,r){if(r?.signal?.throwIfAborted(),this.size===this.maxSize)throw new Ao;let n=new To(e,r);return this.enqueue(n),this.safeDispatchEvent("add"),this.tryToStartAnother(),n.join(r).then(o=>(this.safeDispatchEvent("completed",{detail:o}),this.safeDispatchEvent("success",{detail:{job:n,result:o}}),o)).catch(o=>{if(n.status==="queued"){for(let i=0;i<this.queue.length;i++)if(this.queue[i]===n){this.queue.splice(i,1);break}}throw this.safeDispatchEvent("failure",{detail:{job:n,error:o}}),o})}clear(){this.queue.splice(0,this.queue.length)}abort(){this.queue.forEach(e=>{e.abort(new Je)}),this.clear()}async onEmpty(e){this.size!==0&&await vo(this,"empty",e)}async onSizeLessThan(e,r){this.size<e||await vo(this,"next",{...r,filter:()=>this.size<e})}async onIdle(e){this.pending===0&&this.size===0||await vo(this,"idle",e)}get size(){return this.queue.length}get queued(){return this.queue.length-this.pending}get running(){return this.pending}async*toGenerator(e){e?.signal?.throwIfAborted();let r=mf({objectMode:!0}),n=a=>{a!=null?this.abort():this.clear(),r.end(a)},o=a=>{a.detail!=null&&r.push(a.detail)},i=a=>{n(a.detail.error)},s=()=>{n()},c=()=>{n(new Je("Queue aborted"))};this.addEventListener("completed",o),this.addEventListener("failure",i),this.addEventListener("idle",s),e?.signal?.addEventListener("abort",c);try{yield*r}finally{this.removeEventListener("completed",o),this.removeEventListener("failure",i),this.removeEventListener("idle",s),e?.signal?.removeEventListener("abort",c),n()}}};function bf(t){let e=new globalThis.AbortController;function r(){let i=t.filter(s=>s?.aborted===!0).map(s=>s?.reason).pop();e.abort(i);for(let s of t)s?.removeEventListener!=null&&s.removeEventListener("abort",r)}for(let i of t){if(i?.aborted===!0){r();break}i?.addEventListener!=null&&i.addEventListener("abort",r)}function n(){for(let i of t)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}let o=e.signal;return o.clear=n,o}function xf(t,e,r){let n,o,i=!1;function s(){let f={signal:o.signal};if(r?.timeout!=null){let u=bf([o.signal,AbortSignal.timeout(r.timeout)]);f.signal=u}i=!0,Promise.resolve().then(async()=>{await t(f)}).catch(()=>{}).finally(()=>{i=!1,!o.signal.aborted&&(n=setTimeout(s,e))})}let c=an(s,r?.debounce??100),a=!1;return{setInterval:f=>{e!==f&&(e=f,n!=null&&(clearTimeout(n),n=setTimeout(s,e)))},setTimeout:f=>{r??={},r.timeout=f},run:()=>{i||(clearTimeout(n),c())},start:()=>{a||(a=!0,o=new AbortController,o.signal,r?.runImmediately===!0?queueMicrotask(()=>{s()}):n=setTimeout(s,e))},stop:()=>{clearTimeout(n),o?.abort(),a=!1}}}var Co=class{routers;localStore;republishTask;log;keychain;started=!1;republishConcurrency;constructor(e,r){this.log=e.logger.forComponent("helia:ipns"),this.localStore=r.localStore,this.keychain=e.libp2p.services.keychain,this.republishConcurrency=r.republishConcurrency||ff,this.started=e.libp2p.status==="started",this.routers=r.routers??[],this.republishTask=xf(this.#e.bind(this),r.republishInterval??36e5,{runImmediately:!0}),this.started&&this.republishTask.start()}start(){this.started||(this.started=!0,this.republishTask.start())}stop(){this.started&&(this.started=!1,this.republishTask.stop())}async#e(e={}){if(!this.started)return;this.log("starting ipns republish records loop");let r=new Bo({concurrency:this.republishConcurrency});try{let n=[];for await(let{routingKey:o,record:i,metadata:s,created:c}of this.localStore.list(e)){if(s==null){this.log(`no metadata found for record ${o.toString()}, skipping`);continue}let a;try{a=Re(i)}catch(g){this.log.error("error unmarshaling record - %e",g);continue}if(!df(a,c)){this.log.trace(`skipping record ${o.toString()}within republish threshold`);continue}let f=a.sequence+1n,u=a.ttl??dr,l;try{l=await this.keychain.exportKey(s.keyName)}catch(g){this.log.error("missing key %s, skipping republishing record - %e",s.keyName,g);continue}try{let g=await lo(l,a.value,f,s.lifetime,{...e,ttlNs:u});n.push({routingKey:o,record:g})}catch(g){this.log.error("error creating updated IPNS record for %s - %e",o,g);continue}}this.log(`found ${n.length} records to republish`);for(let{routingKey:o,record:i}of n)r.add(async()=>{try{let s=rn(i);await Promise.all(this.routers.map(c=>c.put(o,s,e)))}catch(s){this.log.error("error republishing record - %e",s)}},e)}catch(n){this.log.error("error during republish - %e",n)}await r.onIdle(e)}};var cn;(function(t){let e;t.codec=()=>(e==null&&(e=Ye((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.key!=null&&r.key.byteLength>0&&(n.uint32(10),n.bytes(r.key)),r.value!=null&&r.value.byteLength>0&&(n.uint32(18),n.bytes(r.value)),r.timeReceived!=null&&r.timeReceived!==""&&(n.uint32(42),n.string(r.timeReceived)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={key:Le(0),value:Le(0),timeReceived:""},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.key=r.bytes();break}case 2:{i.value=r.bytes();break}case 5:{i.timeReceived=r.string();break}default:{r.skipType(c&7);break}}}return i})),e),t.encode=r=>Ze(r,t.codec()),t.decode=(r,n)=>je(r,t.codec(),n)})(cn||(cn={}));function wf(t){let e=t.getUTCFullYear(),r=String(t.getUTCMonth()+1).padStart(2,"0"),n=String(t.getUTCDate()).padStart(2,"0"),o=String(t.getUTCHours()).padStart(2,"0"),i=String(t.getUTCMinutes()).padStart(2,"0"),s=String(t.getUTCSeconds()).padStart(2,"0"),c=t.getUTCMilliseconds(),a=String(c*1e3*1e3).padStart(9,"0");return`${e}-${r}-${n}T${o}:${i}:${s}.${a}Z`}function Ef(t){let e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),r=String(t).trim().match(e);if(r==null)throw new Error("Invalid format");let n=parseInt(r[1],10),o=parseInt(r[2],10)-1,i=parseInt(r[3],10),s=parseInt(r[4],10),c=parseInt(r[5],10),a=parseInt(r[6],10),f=parseInt(r[7].slice(0,-6),10);return new Date(Date.UTC(n,o,i,s,c,a,f))}var At=class t{key;value;timeReceived;constructor(e,r,n){if(!(e instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(r instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=e,this.value=r,this.timeReceived=n}serialize(){return cn.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:wf(this.timeReceived)}}static deserialize(e){let r=cn.decode(e);return new t(r.key,r.value,new Date(r.timeReceived))}static fromDeserialized(e){let r=Ef(e.timeReceived);if(e.key==null)throw new Error("key missing from deserialized object");if(e.value==null)throw new Error("value missing from deserialized object");return new t(e.key,e.value,r)}};var Sf;(function(t){t[t.SEND_QUERY=0]="SEND_QUERY",t[t.PEER_RESPONSE=1]="PEER_RESPONSE",t[t.FINAL_PEER=2]="FINAL_PEER",t[t.QUERY_ERROR=3]="QUERY_ERROR",t[t.PROVIDER=4]="PROVIDER",t[t.VALUE=5]="VALUE",t[t.ADD_PEER=6]="ADD_PEER",t[t.DIAL_PEER=7]="DIAL_PEER",t[t.PATH_ENDED=8]="PATH_ENDED"})(Sf||(Sf={}));var un;(function(t){let e;t.codec=()=>(e==null&&(e=Ye((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.keyName!=null&&r.keyName!==""&&(n.uint32(10),n.string(r.keyName)),r.lifetime!=null&&r.lifetime!==0&&(n.uint32(16),n.uint32(r.lifetime)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={keyName:"",lifetime:0},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.keyName=r.string();break}case 2:{i.lifetime=r.uint32();break}default:{r.skipType(c&7);break}}}return i})),e),t.encode=r=>Ze(r,t.codec()),t.decode=(r,n)=>je(r,t.codec(),n)})(un||(un={}));function _o(t,e){return{async put(r,n,o={}){try{let i=sn(r);try{let a=await t.get(i),f=At.deserialize(a);if(ne(f.value,n))return}catch(a){if(a.name!=="NotFoundError")throw a}let s=new At(r,n,new Date);o.onProgress?.(new ve("ipns:routing:datastore:put"));let c=t.batch();c.put(i,s.serialize()),o.metadata!=null&&c.put(wo(r),un.encode(o.metadata)),await c.commit(o)}catch(i){throw o.onProgress?.(new ve("ipns:routing:datastore:error",i)),i}},async get(r,n={}){try{let o=sn(r);n.onProgress?.(new ve("ipns:routing:datastore:get"));let i=await t.get(o,n),s=At.deserialize(i);return{record:s.value,created:s.timeReceived}}catch(o){throw n.onProgress?.(new ve("ipns:routing:datastore:error",o)),o}},async has(r,n={}){let o=sn(r);return t.has(o,n)},async delete(r,n){let o=sn(r),i=t.batch();i.delete(o),i.delete(wo(r)),await i.commit(n)},async*list(r={}){try{r.onProgress?.(new ve("ipns:routing:datastore:list"));for await(let{key:n,value:o}of t.query({prefix:xo},r))try{let i=At.deserialize(o),c=n.toString().substring(xo.length),a=$(c,"base32"),f=wo(a),u;try{let l=await t.get(f,r);u=un.decode(l)}catch(l){e.error("Error deserializing metadata for %s - %e",c,l)}yield{routingKey:a,metadata:u,record:i.value,created:i.timeReceived}}catch(i){e.error("Error deserializing record - %e",i)}}catch(n){throw r.onProgress?.(new ve("ipns:routing:datastore:error",n)),n}}}}var Cs=class{routing;constructor(e){this.routing=e}async put(e,r,n={}){try{await this.routing.put(e,r,n)}catch(o){throw n.onProgress?.(new ve("ipns:routing:helia:error",o)),o}}async get(e,r={}){try{return await this.routing.get(e,r)}catch(n){throw r.onProgress?.(new ve("ipns:routing:helia:error",n)),n}}toString(){return"HeliaRouting()"}};function fn(t){return new Cs(t)}var _s=class{localStore;constructor(e){this.localStore=e}async put(e,r,n){await this.localStore.put(e,r,n)}async get(e,r){let{record:n}=await this.localStore.get(e,r);return n}toString(){return"LocalStoreRouting()"}};function Ro(t){return new _s(t)}var Lo=class{routers;publisher;republisher;resolver;localStore;started;constructor(e,r={}){this.localStore=_o(e.datastore,e.logger.forComponent("helia:ipns:local-store")),this.started=e.libp2p.status==="started",this.routers=[Ro(this.localStore),fn(e.routing),...r.routers??[]],this.publisher=new Eo(e,{...r,routers:this.routers,localStore:this.localStore}),this.republisher=new Co(e,{...r,routers:this.routers,localStore:this.localStore}),this.resolver=new pr(e,{...r,routers:this.routers,localStore:this.localStore}),e.events.addEventListener("start",this.start.bind(this)),e.events.addEventListener("stop",this.stop.bind(this)),this.started&&this.republisher.start()}start(){this.started||(this.started=!0,this.republisher.start())}stop(){this.started&&(this.started=!1,this.republisher.stop())}async publish(e,r,n={}){return this.publisher.publish(e,r,n)}async resolve(e,r={}){return this.resolver.resolve(e,r)}async unpublish(e,r){return this.publisher.unpublish(e,r)}};function Tp(t,e={}){return new Lo(t,e)}function Bp(t,e={}){let r=_o(t.datastore,t.logger.forComponent("helia:ipns:local-store")),n=[Ro(r),fn(t.routing),...e.routers??[]];return new pr(t,{routers:n,localStore:r})}return _f(Cp);})();
13
+ ${e}[Error list was empty]`,r.trim()}return $c(t,e)}Se.formatters.e=t=>t==null?"undefined":jc(t);function ph(t){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=t,e.destroy=()=>!0,e.extend=()=>e,e}function Ot(t,e){let r=ph(`${t}:trace`);return Se.enabled(`${t}:trace`)&&Se.names.map(n=>n.toString()).find(n=>n.includes(":trace"))!=null&&(r=Se(`${t}:trace`,e)),Object.assign(Se(t,e),{error:Se(`${t}:error`,e),trace:r,newScope:n=>Ot(`${t}:${n}`,e)})}function zc(t){if(t!=null&&(t=t.trim(),t.length!==0))return t}var sf=Do(qn(),1);var Hn=class extends Error{static name="SignatureCreationError";constructor(e="Record signature creation failed"){super(e),this.name="SignatureCreationError"}},Me=class extends Error{static name="SignatureVerificationError";constructor(e="Record signature verification failed"){super(e),this.name="SignatureVerificationError"}},$n=class extends Error{static name="RecordExpiredError";constructor(e="Record has expired"){super(e),this.name="RecordExpiredError"}},Mt=class extends Error{static name="UnsupportedValidityError";constructor(e="The validity type is unsupported"){super(e),this.name="UnsupportedValidityError"}},zn=class extends Error{static name="RecordTooLargeError";constructor(e="The record is too large"){super(e),this.name="RecordTooLargeError"}},$r=class extends Error{static name="InvalidValueError";constructor(e="Value must be a valid content path starting with /"){super(e),this.name="InvalidValueError"}},jn=class extends Error{static name="InvalidRecordDataError";constructor(e="Invalid record data"){super(e),this.name="InvalidRecordDataError"}},zr=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(e="Invalid embedded public key"){super(e),this.name="InvalidEmbeddedPublicKeyError"}};var de;(function(t){let e;(function(o){o.EOL="EOL"})(e=t.ValidityType||(t.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),(function(o){o.codec=()=>Fr(r)})(e=t.ValidityType||(t.ValidityType={}));let n;t.codec=()=>(n==null&&(n=Ye((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),t.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let c={},a=i==null?o.len:o.pos+i;for(;o.pos<a;){let f=o.uint32();switch(f>>>3){case 1:{c.value=o.bytes();break}case 2:{c.signatureV1=o.bytes();break}case 3:{c.validityType=t.ValidityType.codec().decode(o);break}case 4:{c.validity=o.bytes();break}case 5:{c.sequence=o.uint64();break}case 6:{c.ttl=o.uint64();break}case 7:{c.pubKey=o.bytes();break}case 8:{c.signatureV2=o.bytes();break}case 9:{c.data=o.bytes();break}default:{o.skipType(f&7);break}}}return c})),n),t.encode=o=>Ze(o,t.codec()),t.decode=(o,i)=>je(o,t.codec(),i)})(de||(de={}));var mh=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function us(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(e==="string"||e==="number"||e==="bigint"||e==="symbol")return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(t instanceof Uint8Array)return"Uint8Array";if(t.constructor===Object)return"Object";let r=yh(t);return r||"Object"}function yh(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(mh.includes(e))return e}var h=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}static equals(e,r){return e===r||e.major===r.major&&e.name===r.name}};h.uint=new h(0,"uint",!0);h.negint=new h(1,"negint",!0);h.bytes=new h(2,"bytes",!0);h.string=new h(3,"string",!0);h.array=new h(4,"array",!1);h.map=new h(5,"map",!1);h.tag=new h(6,"tag",!1);h.float=new h(7,"float",!0);h.false=new h(7,"false",!0);h.true=new h(7,"true",!0);h.null=new h(7,"null",!0);h.undefined=new h(7,"undefined",!0);h.break=new h(7,"break",!0);var D=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var jr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",gh=new TextEncoder;function Zn(t){return jr&&globalThis.Buffer.isBuffer(t)}function Zr(t){return t instanceof Uint8Array?Zn(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var bh=24,xh=200,Yn=jr?t=>t.length>=bh?globalThis.Buffer.from(t):Zc(t):t=>t.length>=xh?gh.encode(t):Zc(t),Xe=t=>Uint8Array.from(t),Yc=jr?(t,e,r)=>Zn(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),Gc=jr?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Zr(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let o of t)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Xc=jr?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function Gn(t,e){if(Zn(t)&&Zn(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function Zc(t){let e=[],r=0;for(let n=0;n<t.length;n++){let o=t.charCodeAt(n);o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&n+1<t.length&&(t.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(t.charCodeAt(++n)&1023),e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128)}return e}var wh=256,Yr=class{constructor(e=wh){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(e,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(r=Xc(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Yc(n,0,this.cursor)}else r=Gc(this.chunks,this.cursor);return e&&this.reset(),r}},Xn=class{constructor(e){this.dest=e,this.cursor=0,this.chunks=[e]}reset(){this.cursor=0}push(e){if(this.cursor+e.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(e,this.cursor),this.cursor+=e.length}toBytes(e=!1){let r=this.dest.subarray(0,this.cursor);return e&&this.reset(),r}};var V="CBOR decode error:",Wn="CBOR encode error:",Gr=[];Gr[23]=1;Gr[24]=2;Gr[25]=3;Gr[26]=5;Gr[27]=9;function ct(t,e,r){if(t.length-e<r)throw new Error(`${V} not enough data for type`)}var ue=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Te(t,e,r){ct(t,e,1);let n=t[e];if(r.strict===!0&&n<ue[0])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);return n}function Be(t,e,r){ct(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<ue[1])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);return n}function Ce(t,e,r){ct(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<ue[2])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);return n}function _e(t,e,r){ct(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],o=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<ue[3])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${V} integers outside of the safe integer range are not supported`)}function Wc(t,e,r,n){return new D(h.uint,Te(t,e+1,n),2)}function Jc(t,e,r,n){return new D(h.uint,Be(t,e+1,n),3)}function Qc(t,e,r,n){return new D(h.uint,Ce(t,e+1,n),5)}function eu(t,e,r,n){return new D(h.uint,_e(t,e+1,n),9)}function De(t,e){return Y(t,0,e.value)}function Y(t,e,r){if(r<ue[0]){let n=Number(r);t.push([e|n])}else if(r<ue[1]){let n=Number(r);t.push([e|24,n])}else if(r<ue[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<ue[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<ue[4]){let o=[e|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,t.push(o)}else throw new Error(`${V} encountered BigInt larger than allowable range`)}}De.encodedSize=function(e){return Y.encodedSize(e.value)};Y.encodedSize=function(e){return e<ue[0]?1:e<ue[1]?2:e<ue[2]?3:e<ue[3]?5:9};De.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};function tu(t,e,r,n){return new D(h.negint,-1-Te(t,e+1,n),2)}function ru(t,e,r,n){return new D(h.negint,-1-Be(t,e+1,n),3)}function nu(t,e,r,n){return new D(h.negint,-1-Ce(t,e+1,n),5)}var fs=BigInt(-1),ou=BigInt(1);function iu(t,e,r,n){let o=_e(t,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new D(h.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${V} integers outside of the safe integer range are not supported`);return new D(h.negint,fs-BigInt(o),9)}function Jn(t,e){let r=e.value,n=typeof r=="bigint"?r*fs-ou:r*-1-1;Y(t,e.type.majorEncoded,n)}Jn.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*fs-ou:r*-1-1;return n<ue[0]?1:n<ue[1]?2:n<ue[2]?3:n<ue[3]?5:9};Jn.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};function Xr(t,e,r,n){ct(t,e,r+n);let o=t.slice(e+r,e+r+n);return new D(h.bytes,o,r+n)}function su(t,e,r,n){return Xr(t,e,1,r)}function au(t,e,r,n){return Xr(t,e,2,Te(t,e+1,n))}function cu(t,e,r,n){return Xr(t,e,3,Be(t,e+1,n))}function uu(t,e,r,n){return Xr(t,e,5,Ce(t,e+1,n))}function fu(t,e,r,n){let o=_e(t,e+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer bytes lengths not supported`);return Xr(t,e,9,o)}function Qn(t){return t.encodedBytes===void 0&&(t.encodedBytes=h.equals(t.type,h.string)?Yn(t.value):t.value),t.encodedBytes}function ar(t,e){let r=Qn(e);Y(t,e.type.majorEncoded,r.length),t.push(r)}ar.encodedSize=function(e){let r=Qn(e);return Y.encodedSize(r.length)+r.length};ar.compareTokens=function(e,r){return Sh(Qn(e),Qn(r))};function Sh(t,e){return t.length<e.length?-1:t.length>e.length?1:Gn(t,e)}var lu=new TextDecoder,Ah=32;function Ih(t,e,r){if(r-e<Ah){let o="";for(let i=e;i<r;i++){let s=t[i];if(s&128)return lu.decode(t.subarray(e,r));o+=String.fromCharCode(s)}return o}return lu.decode(t.subarray(e,r))}function Wr(t,e,r,n,o){let i=r+n;ct(t,e,i);let s=new D(h.string,Ih(t,e+r,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=t.slice(e+r,e+i)),s}function du(t,e,r,n){return Wr(t,e,1,r,n)}function hu(t,e,r,n){return Wr(t,e,2,Te(t,e+1,n),n)}function pu(t,e,r,n){return Wr(t,e,3,Be(t,e+1,n),n)}function mu(t,e,r,n){return Wr(t,e,5,Ce(t,e+1,n),n)}function yu(t,e,r,n){let o=_e(t,e+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer string lengths not supported`);return Wr(t,e,9,o,n)}var gu=ar;function cr(t,e,r,n){return new D(h.array,n,r)}function bu(t,e,r,n){return cr(t,e,1,r)}function xu(t,e,r,n){return cr(t,e,2,Te(t,e+1,n))}function wu(t,e,r,n){return cr(t,e,3,Be(t,e+1,n))}function Eu(t,e,r,n){return cr(t,e,5,Ce(t,e+1,n))}function Su(t,e,r,n){let o=_e(t,e+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer array lengths not supported`);return cr(t,e,9,o)}function vu(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${V} indefinite length items not allowed`);return cr(t,e,1,1/0)}function eo(t,e){Y(t,h.array.majorEncoded,e.value)}eo.compareTokens=De.compareTokens;eo.encodedSize=function(e){return Y.encodedSize(e.value)};function ur(t,e,r,n){return new D(h.map,n,r)}function Au(t,e,r,n){return ur(t,e,1,r)}function Iu(t,e,r,n){return ur(t,e,2,Te(t,e+1,n))}function Tu(t,e,r,n){return ur(t,e,3,Be(t,e+1,n))}function Bu(t,e,r,n){return ur(t,e,5,Ce(t,e+1,n))}function Cu(t,e,r,n){let o=_e(t,e+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer map lengths not supported`);return ur(t,e,9,o)}function _u(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${V} indefinite length items not allowed`);return ur(t,e,1,1/0)}function to(t,e){Y(t,h.map.majorEncoded,e.value)}to.compareTokens=De.compareTokens;to.encodedSize=function(e){return Y.encodedSize(e.value)};function Lu(t,e,r,n){return new D(h.tag,r,1)}function Ru(t,e,r,n){return new D(h.tag,Te(t,e+1,n),2)}function Du(t,e,r,n){return new D(h.tag,Be(t,e+1,n),3)}function Uu(t,e,r,n){return new D(h.tag,Ce(t,e+1,n),5)}function Nu(t,e,r,n){return new D(h.tag,_e(t,e+1,n),9)}function ro(t,e){Y(t,h.tag.majorEncoded,e.value)}ro.compareTokens=De.compareTokens;ro.encodedSize=function(e){return Y.encodedSize(e.value)};var ls=20,ds=21,hs=22,ps=23;function ku(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${V} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new D(h.null,null,1):new D(h.undefined,void 0,1)}function Ku(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${V} indefinite length items not allowed`);return new D(h.break,void 0,1)}function ms(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${V} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${V} Infinity values are not supported`)}return new D(h.float,t,e)}function Pu(t,e,r,n){return ms(ys(t,e+1),3,n)}function Ou(t,e,r,n){return ms(gs(t,e+1),5,n)}function Mu(t,e,r,n){return ms(Hu(t,e+1),9,n)}function Jr(t,e,r){let n=e.value;if(n===!1)t.push([h.float.majorEncoded|ls]);else if(n===!0)t.push([h.float.majorEncoded|ds]);else if(n===null)t.push([h.float.majorEncoded|hs]);else if(n===void 0)t.push([h.float.majorEncoded|ps]);else{let o,i=!1;(!r||r.float64!==!0)&&(Vu(n),o=ys(Fe,1),n===o||Number.isNaN(n)?(Fe[0]=249,t.push(Fe.slice(0,3)),i=!0):(qu(n),o=gs(Fe,1),n===o&&(Fe[0]=250,t.push(Fe.slice(0,5)),i=!0))),i||(Lh(n),o=Hu(Fe,1),Fe[0]=251,t.push(Fe.slice(0,9)))}}Jr.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Vu(n);let o=ys(Fe,1);if(n===o||Number.isNaN(n))return 3;if(qu(n),o=gs(Fe,1),n===o)return 5}return 9};var Fu=new ArrayBuffer(9),Ue=new DataView(Fu,1),Fe=new Uint8Array(Fu,0);function Vu(t){if(t===1/0)Ue.setUint16(0,31744,!1);else if(t===-1/0)Ue.setUint16(0,64512,!1);else if(Number.isNaN(t))Ue.setUint16(0,32256,!1);else{Ue.setFloat32(0,t);let e=Ue.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)Ue.setUint16(0,31744,!1);else if(r===0)Ue.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Ue.setUint16(0,0):o<-14?Ue.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):Ue.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function ys(t,e){if(t.length-e<2)throw new Error(`${V} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function qu(t){Ue.setFloat32(0,t,!1)}function gs(t,e){if(t.length-e<4)throw new Error(`${V} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function Lh(t){Ue.setFloat64(0,t,!1)}function Hu(t,e){if(t.length-e<8)throw new Error(`${V} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}Jr.compareTokens=De.compareTokens;function j(t,e,r){throw new Error(`${V} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function no(t){return()=>{throw new Error(`${V} ${t}`)}}var C=[];for(let t=0;t<=23;t++)C[t]=j;C[24]=Wc;C[25]=Jc;C[26]=Qc;C[27]=eu;C[28]=j;C[29]=j;C[30]=j;C[31]=j;for(let t=32;t<=55;t++)C[t]=j;C[56]=tu;C[57]=ru;C[58]=nu;C[59]=iu;C[60]=j;C[61]=j;C[62]=j;C[63]=j;for(let t=64;t<=87;t++)C[t]=su;C[88]=au;C[89]=cu;C[90]=uu;C[91]=fu;C[92]=j;C[93]=j;C[94]=j;C[95]=no("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)C[t]=du;C[120]=hu;C[121]=pu;C[122]=mu;C[123]=yu;C[124]=j;C[125]=j;C[126]=j;C[127]=no("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)C[t]=bu;C[152]=xu;C[153]=wu;C[154]=Eu;C[155]=Su;C[156]=j;C[157]=j;C[158]=j;C[159]=vu;for(let t=160;t<=183;t++)C[t]=Au;C[184]=Iu;C[185]=Tu;C[186]=Bu;C[187]=Cu;C[188]=j;C[189]=j;C[190]=j;C[191]=_u;for(let t=192;t<=215;t++)C[t]=Lu;C[216]=Ru;C[217]=Du;C[218]=Uu;C[219]=Nu;C[220]=j;C[221]=j;C[222]=j;C[223]=j;for(let t=224;t<=243;t++)C[t]=no("simple values are not supported");C[244]=j;C[245]=j;C[246]=j;C[247]=ku;C[248]=no("simple values are not supported");C[249]=Pu;C[250]=Ou;C[251]=Mu;C[252]=j;C[253]=j;C[254]=j;C[255]=Ku;var Ve=[];for(let t=0;t<24;t++)Ve[t]=new D(h.uint,t,1);for(let t=-1;t>=-24;t--)Ve[31-t]=new D(h.negint,t,1);Ve[64]=new D(h.bytes,new Uint8Array(0),1);Ve[96]=new D(h.string,"",1);Ve[128]=new D(h.array,0,1);Ve[160]=new D(h.map,0,1);Ve[244]=new D(h.false,!1,1);Ve[245]=new D(h.true,!0,1);Ve[246]=new D(h.null,null,1);function bs(t){switch(t.type){case h.false:return Xe([244]);case h.true:return Xe([245]);case h.null:return Xe([246]);case h.bytes:return t.value.length?void 0:Xe([64]);case h.string:return t.value===""?Xe([96]):void 0;case h.array:return t.value===0?Xe([128]):void 0;case h.map:return t.value===0?Xe([160]):void 0;case h.uint:return t.value<24?Xe([Number(t.value)]):void 0;case h.negint:if(t.value>=-24)return Xe([31-Number(t.value)])}}var Dh={float64:!1,mapSorter:kh,quickEncodeToken:bs},Yu=Object.freeze({float64:!0,mapSorter:Kh,quickEncodeToken:bs});function Uh(){let t=[];return t[h.uint.major]=De,t[h.negint.major]=Jn,t[h.bytes.major]=ar,t[h.string.major]=gu,t[h.array.major]=eo,t[h.map.major]=to,t[h.tag.major]=ro,t[h.float.major]=Jr,t}var fr=Uh(),oo=new Yr,en=class t{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${Wn} object contains circular references`);return new t(r,e)}},St={null:new D(h.null,null),undefined:new D(h.undefined,void 0),true:new D(h.true,!0),false:new D(h.false,!1),emptyArray:new D(h.array,0),emptyMap:new D(h.map,0)},We={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new D(h.float,t):t>=0?new D(h.uint,t):new D(h.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new D(h.uint,t):new D(h.negint,t)},Uint8Array(t,e,r,n){return new D(h.bytes,t)},string(t,e,r,n){return new D(h.string,t)},boolean(t,e,r,n){return t?St.true:St.false},null(t,e,r,n){return St.null},undefined(t,e,r,n){return St.undefined},ArrayBuffer(t,e,r,n){return new D(h.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new D(h.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[St.emptyArray,new D(h.break)]:St.emptyArray;n=en.createCheck(n,t);let o=[],i=0;for(let s of t)o[i++]=io(s,r,n);return r.addBreakTokens?[new D(h.array,t.length),o,new D(h.break)]:[new D(h.array,t.length),o]},Object(t,e,r,n){let o=e!=="Object",i=o?t.keys():Object.keys(t),s=o?t.size:i.length,c;if(s){c=new Array(s),n=en.createCheck(n,t);let a=!o&&r.ignoreUndefinedProperties,f=0;for(let u of i){let l=o?t.get(u):t[u];a&&l===void 0||(c[f++]=[io(u,r,n),io(l,r,n)])}f<s&&(c.length=f)}return c?.length?(Nh(c,r),r.addBreakTokens?[new D(h.map,c.length),c,new D(h.break)]:[new D(h.map,c.length),c]):r.addBreakTokens===!0?[St.emptyMap,new D(h.break)]:St.emptyMap}};We.Map=We.Object;We.Buffer=We.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))We[`${t}Array`]=We.DataView;function io(t,e={},r){let n=us(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||We[n];if(typeof o=="function"){let s=o(t,n,e,r);if(s!=null)return s}let i=We[n];if(!i)throw new Error(`${Wn} unsupported type: ${n}`);return i(t,n,e,r)}function Nh(t,e){e.mapSorter&&t.sort(e.mapSorter)}function kh(t,e){let r=Array.isArray(t[0])?t[0][0]:t[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=fr[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Kh(t,e){if(t[0]instanceof D&&e[0]instanceof D){let r=t[0],n=e[0];return r._keyBytes||(r._keyBytes=$u(r.value)),n._keyBytes||(n._keyBytes=$u(n.value)),Gn(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function $u(t){return Xu(t,fr,Yu)}function Qr(t,e,r,n){if(Array.isArray(e))for(let o of e)Qr(t,o,r,n);else r[e.type.major](t,e,n)}var zu=h.uint.majorEncoded,ju=h.negint.majorEncoded,Ph=h.bytes.majorEncoded,Oh=h.string.majorEncoded,Zu=h.array.majorEncoded,Mh=h.float.majorEncoded|ls,Fh=h.float.majorEncoded|ds,Vh=h.float.majorEncoded|hs,qh=h.float.majorEncoded|ps,Hh=BigInt(-1),$h=BigInt(1);function zh(t){return t.addBreakTokens!==!0}function Gu(t,e,r,n){let o=us(e),i=r.typeEncoders&&r.typeEncoders[o];if(i){let s=i(e,o,r,n);if(s!=null){Qr(t,s,fr,r);return}}switch(o){case"null":t.push([Vh]);return;case"undefined":t.push([qh]);return;case"boolean":t.push([e?Fh:Mh]);return;case"number":!Number.isInteger(e)||!Number.isSafeInteger(e)?Jr(t,new D(h.float,e),r):e>=0?Y(t,zu,e):Y(t,ju,e*-1-1);return;case"bigint":e>=BigInt(0)?Y(t,zu,e):Y(t,ju,e*Hh-$h);return;case"string":{let s=Yn(e);Y(t,Oh,s.length),t.push(s);return}case"Uint8Array":Y(t,Ph,e.length),t.push(e);return;case"Array":if(!e.length){t.push([Zu]);return}n=en.createCheck(n,e),Y(t,Zu,e.length);for(let s of e)Gu(t,s,r,n);return;case"Object":case"Map":{let s=We.Object(e,o,r,n);Qr(t,s,fr,r)}return;default:{let s=We[o];if(!s)throw new Error(`${Wn} unsupported type: ${o}`);let c=s(e,o,r,n);Qr(t,c,fr,r)}}}function Xu(t,e,r,n){let o=n instanceof Uint8Array,i=o?new Xn(n):oo,s=io(t,r);if(!Array.isArray(s)&&r.quickEncodeToken){let c=r.quickEncodeToken(s);if(c)return o?(i.push(c),i.toBytes()):c;let a=e[s.type.major];if(a.encodedSize){let f=a.encodedSize(s,r);if(o||(i=new Yr(f)),a(i,s,r),i.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${s} was wrong`);return o?i.toBytes():Zr(i.chunks[0])}}return i.reset(),Qr(i,s,e,r),i.toBytes(!0)}function xs(t,e){return e=Object.assign({},Dh,e),zh(e)?(oo.reset(),Gu(oo,t,e,void 0),oo.toBytes(!0)):Xu(t,fr,e)}var jh={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},so=class{constructor(e,r={}){this._pos=0,this.data=e,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],r=Ve[e];if(r===void 0){let n=C[e];if(!n)throw new Error(`${V} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},tn=Symbol.for("DONE"),ao=Symbol.for("BREAK");function Zh(t,e,r){let n=[];for(let o=0;o<t.value;o++){let i=lr(e,r);if(i===ao){if(t.value===1/0)break;throw new Error(`${V} got unexpected break to lengthed array`)}if(i===tn)throw new Error(`${V} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=i}return n}function Yh(t,e,r){let n=r.useMaps===!0,o=r.rejectDuplicateMapKeys===!0,i=n?void 0:{},s=n?new Map:void 0;for(let c=0;c<t.value;c++){let a=lr(e,r);if(a===ao){if(t.value===1/0)break;throw new Error(`${V} got unexpected break to lengthed map`)}if(a===tn)throw new Error(`${V} found map but not enough entries (got ${c} [no key], expected ${t.value})`);if(!n&&typeof a!="string")throw new Error(`${V} non-string keys not supported (got ${typeof a})`);if(o&&(n&&s.has(a)||!n&&Object.hasOwn(i,a)))throw new Error(`${V} found repeat map key "${a}"`);let f=lr(e,r);if(f===tn)throw new Error(`${V} found map but not enough entries (got ${c} [no value], expected ${t.value})`);n?s.set(a,f):i[a]=f}return n?s:i}function lr(t,e){if(t.done())return tn;let r=t.next();if(h.equals(r.type,h.break))return ao;if(r.type.terminal)return r.value;if(h.equals(r.type,h.array))return Zh(r,t,e);if(h.equals(r.type,h.map))return Yh(r,t,e);if(h.equals(r.type,h.tag)){if(e.tags&&typeof e.tags[r.value]=="function"){let n=lr(t,e);return e.tags[r.value](n)}throw new Error(`${V} tag not supported (${r.value})`)}throw new Error("unsupported")}function Wu(t,e){if(!(t instanceof Uint8Array))throw new Error(`${V} data to decode must be a Uint8Array`);e=Object.assign({},jh,e);let r=Zr(t),n=e.tokenizer||new so(r,e),o=lr(n,e);if(o===tn)throw new Error(`${V} did not find any content to decode`);if(o===ao)throw new Error(`${V} got unexpected break`);return[o,t.subarray(n.pos())]}function ws(t,e){let[r,n]=Wu(t,e);if(n.length>0)throw new Error(`${V} too many terminals, data makes no sense`);return r}var Xh=Ot("ipns:utils"),Ju=$("/ipns/"),Wh=114,Jh=0,Qh=18;function Qu(t){let e;if(t.pubKey!=null)try{e=Vc(t.pubKey)}catch(r){throw Xh.error(r),r}if(e!=null)return e}function ef(t,e,r){let n=$(e);return dt([t,r,n])}function uo(t){let e=$("ipns-signature:");return dt([e,t])}function rn(t){return"signatureV1"in t?de.encode({value:$(t.value),signatureV1:t.signatureV1,validityType:t.validityType,validity:$(t.validity),sequence:t.sequence,ttl:t.ttl,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data}):de.encode({pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data})}function Le(t){let e=de.decode(t);if(e.sequence!=null&&(e.sequence=BigInt(e.sequence)),e.ttl!=null&&(e.ttl=BigInt(e.ttl)),e.signatureV2==null||e.data==null)throw new Me("Missing data or signatureV2");let r=nf(e.data),n=ep(r.Value),o=Z(r.Validity);if(e.value!=null&&e.signatureV1!=null)return tp(e),{value:n,validityType:de.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:e.pubKey,signatureV1:e.signatureV1,signatureV2:e.signatureV2,data:e.data};if(e.signatureV2!=null)return{value:n,validityType:de.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function vt(t){return dt([Ju,t.bytes])}function tf(t){let e=Zt(t.slice(Ju.length));if(!co(e,Jh)&&!co(e,Qh))throw new hn("Multihash in IPNS key was not identity or sha2-256");return e}function rf(t,e,r,n,o){let i;if(e===de.ValidityType.EOL)i=0;else throw new Mt("The validity type is unsupported");return xs({Value:t,Validity:r,ValidityType:i,Sequence:n,TTL:o})}function nf(t){let e=ws(t);if(e.ValidityType===0)e.ValidityType=de.ValidityType.EOL;else throw new Mt("The validity type is unsupported");return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e}function ep(t){let e=Z(t).trim();if(e.startsWith("/"))return e;try{return`/ipfs/${se.decode(t).toV1().toString()}`}catch{}try{return`/ipfs/${se.parse(e).toV1().toString()}`}catch{}throw new $r("Value must be a valid content path starting with /")}function of(t){if(t!=null){let e=op(t);if(e!=null)return e.code===Wh?`/ipns/${e.toString(Ne)}`:`/ipfs/${e.toV1().toString()}`;if(rp(t))return`/ipns/${Ne.encode(t.bytes)}`;let r=t.toString().trim();if(r.startsWith("/")&&r.length>1)return r}throw new $r("Value must be a valid content path starting with /")}function tp(t){if(t.data==null)throw new jn("Record data is missing");let e=nf(t.data);if(!ne(e.Value,t.value??new Uint8Array(0)))throw new Me('Field "value" did not match between protobuf and CBOR');if(!ne(e.Validity,t.validity??new Uint8Array(0)))throw new Me('Field "validity" did not match between protobuf and CBOR');if(e.ValidityType!==t.validityType)throw new Me('Field "validityType" did not match between protobuf and CBOR');if(e.Sequence!==t.sequence)throw new Me('Field "sequence" did not match between protobuf and CBOR');if(e.TTL!==t.ttl)throw new Me('Field "ttl" did not match between protobuf and CBOR')}function rp(t){return t.bytes instanceof Uint8Array}function np(t){return typeof t?.toCID=="function"}function op(t){if(np(t))return t.toCID();try{return se.parse(t)}catch{}return se.asCID(t)}function co(t,e){return t.code===e}var fo=Ot("ipns:validator"),ip=1024*10;async function sp(t,e){let r=Le(e),n;try{let o=uo(r.data);n=await t.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw fo.error("record signature verification failed"),new Me("Record signature verification failed");if(r.validityType===de.ValidityType.EOL){if(sf.default.fromString(r.validity).toDate().getTime()<Date.now())throw fo.error("record has expired"),new $n("record has expired")}else if(r.validityType!=null)throw fo.error("the validity type is unsupported"),new Mt("The validity type is unsupported");fo("ipns record for %s is valid",r.value)}async function nn(t,e){if(e.byteLength>ip)throw new zn("The record is too large");let r=tf(t),n;co(r,0)&&(n=qc(r));let o=Le(e),i=Qu(o)??n;if(i==null)throw new zr("Could not extract public key from IPNS record or routing key");let s=vt(i.toMultihash());if(!ne(s,t))throw new zr("Embedded public key did not match routing key");await sp(i,e)}var af=Do(qn(),1);var ap=Ot("ipns"),cf=300*1e9,cp="/ipns/",Ax=cp.length,uf={v1Compatible:!0,ttlNs:cf};async function lo(t,e,r,n,o=uf){let i=new af.default(Date.now()+Number(n)),s=de.ValidityType.EOL,c=BigInt(o.ttlNs??cf);return up(t,e,r,s,i.toString(),c,o)}var up=async(t,e,r,n,o,i,s=uf)=>{r=BigInt(r);let c=$(o),a=of(e),f=$(a),u=rf(f,n,c,r,i),l=uo(u),g=await t.sign(l),S;if(t.type==="RSA"&&(S=ht(t.publicKey)),s.v1Compatible===!0){let x=await fp(t,f,n,c),T={value:a,signatureV1:x,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:g,data:u};return S!=null&&(T.pubKey=S),T}else{let x={value:a,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:g,data:u};return S!=null&&(x.pubKey=S),x}},fp=async(t,e,r,n)=>{try{let o=ef(e,r,n);return await t.sign(o)}catch(o){throw ap.error("record signature creation failed",o),new Hn("Record signature creation failed")}};var Es=Do(qn(),1);function ho(t,e){let r=e.map((n,o)=>({record:Le(n),index:o}));return r.sort((n,o)=>{let i=n.record.sequence,s=o.record.sequence;if(i>s)return-1;if(i<s)return 1;if(n.record.validityType===de.ValidityType.EOL&&o.record.validityType===de.ValidityType.EOL){let c=Es.default.fromString(n.record.validity).toDate(),a=Es.default.fromString(o.record.validity).toDate();if(c.getTime()>a.getTime())return-1;if(c.getTime()<a.getTime())return 1}return 0}),r[0].index}var dr=BigInt(6e4)*5000000n,ff=5;var po=class extends Error{static name="RecordsFailedValidationError";constructor(e="Records failed validation"){super(e),this.name="RecordsFailedValidationError"}},mo=class extends Error{static name="UnsupportedMultibasePrefixError";constructor(e="Unsupported multibase prefix"){super(e),this.name="UnsupportedMultibasePrefixError"}},yo=class extends Error{static name="UnsupportedMultihashCodecError";constructor(e="Unsupported multihash codec"){super(e),this.name="UnsupportedMultihashCodecError"}},go=class extends Error{static name="InvalidValueError";constructor(e="Invalid value"){super(e),this.name="InvalidValueError"}};var on=class extends Error{static name="RecordNotFoundError";name="RecordNotFoundError"};var ut="/",lf=new TextEncoder().encode(ut),bo=lf[0],hr=class t{_buf;constructor(e,r){if(typeof e=="string")this._buf=$(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==bo)throw new Error("Invalid key")}toString(e="utf8"){return Z(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new t(e.join(ut))}static random(){return new t(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new t(e):typeof e.uint8Array=="function"?new t(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=lf),this._buf[0]!==bo){let e=new Uint8Array(this._buf.byteLength+1);e.fill(bo,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===bo;)this._buf=this._buf.subarray(0,-1)}less(e){let r=this.list(),n=e.list();for(let o=0;o<r.length;o++){if(n.length<o+1)return!1;let i=r[o],s=n[o];if(i<s)return!0;if(i>s)return!1}return r.length<n.length}reverse(){return t.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(ut).slice(1)}type(){return lp(this.baseNamespace())}name(){return dp(this.baseNamespace())}instance(e){return new t(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(ut)||(e+=ut),e+=this.type(),new t(e)}parent(){let e=this.list();return e.length===1?new t(ut):new t(e.slice(0,-1).join(ut))}child(e){return this.toString()===ut?e:e.toString()===ut?this:new t(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return t.withNamespaces([...this.namespaces(),...hp(e.map(r=>r.namespaces()))])}};function lp(t){let e=t.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function dp(t){let e=t.split(":");return e[e.length-1]}function hp(t){return[].concat(...t)}var mp=114,Ss=0,vs=18;function As(t,e){return t.code===e}var xo="/dht/record/",yp="/ipns/metadata/";function sn(t){return new hr(xo+Z(t,"base32"),!1)}function wo(t){return new hr(yp+Z(t,"base32"),!1)}function df(t,e){let r=Date.now(),n=e.getTime()+1728e5,o=new Date(t.validity).getTime();return n-r<864e5||o-r<864e5}function gp(t){return t?.asCID===t}function hf(t){if(!gp(t))return!1;if(t.code!==mp)throw new te(`CID codec ${t.code} was not libp2p-key`);if(t.multihash.code!==Ss&&t.multihash.code!==vs)throw new te(`Multihash algorithm codec ${t.multihash.code} was not Identity or SHA256 hash`);return!0}var pf={[Ne.prefix]:Ne,[X.prefix]:X},pr=class{routers;localStore;log;constructor(e,r){this.log=e.logger.forComponent("helia:ipns"),this.localStore=r.localStore,this.routers=r.routers}async resolve(e,r={}){let n=Us(e)||pn(e)?e.toMultihash():hf(e)?e.multihash:e,o=vt(n),i=await this.#t(o,r);return{...await this.#e(i.value,r),record:i}}async#e(e,r={}){let n=e.split("/");try{let o=n[1];if(o==="ipns"){let i=n[2],s=i.substring(0,1),c;if(s==="1"||s==="Q")c=X.decode(`z${i}`);else if(pf[s]!=null)c=pf[s].decode(i);else throw new mo(`Unsupported multibase prefix "${s}"`);let a;try{a=Zt(c)}catch{a=se.decode(c).multihash}if(!As(a,Ss)&&!As(a,vs))throw new yo(`Unsupported multihash codec "${a.code}"`);let{cid:f}=await this.resolve(a,r),u=n.slice(3).join("/");return{cid:f,path:u===""?void 0:u}}else if(o==="ipfs"){let i=se.parse(n[2]),s=n.slice(3).join("/");return{cid:i,path:s===""?void 0:s}}}catch(o){this.log.error("error parsing ipfs path - %e",o)}throw this.log.error("invalid ipfs path %s",e),new go("Invalid value")}async#t(e,r={}){let n=[];if(await this.localStore.has(e,r))if(this.log("record is present in the cache"),r.nocache!==!0)try{let{record:a,created:f}=await this.localStore.get(e,r);this.log("record retrieved from cache"),await nn(e,a),this.log("record was valid");let u=Le(a),l=Number((u.ttl??dr)/1000000n);if(f.getTime()+l>Date.now())return this.log("record TTL was valid"),u;if(r.offline===!0)return this.log("record TTL has been reached but we are resolving offline-only, returning record"),u;this.log("record TTL has been reached, searching routing for updates"),n.push(a)}catch(a){this.log("cached record was invalid - %e",a),await this.localStore.delete(e,r)}else this.log("ignoring local cache due to nocache=true option");if(r.offline===!0)throw new on("Record was not present in the cache or has expired");this.log("did not have record locally");let i=0,s=[];if(await Promise.all(this.routers.map(async a=>{let f;try{f=await a.get(e,{...r,validate:!1})}catch(u){this.log.error("error finding IPNS record using router %s - %e",a.toString(),u),s.push(u);return}try{await nn(e,f),n.push(f)}catch(u){i++,this.log.error("error validating IPNS record from router %s - %e",a.toString(),u)}})),n.length===0)throw i>0?new po(`${i>1?`${i} records`:"Record"} found for routing key ${i>1?"were":"was"} invalid`):new on("Could not find record for routing key");let c=n[ho(e,n)];return await this.localStore.put(e,c,r),Le(c)}};var ve=class extends Event{type;detail;constructor(e,r){super(e),this.type=e,this.detail=r}};var Eo=class{routers;localStore;keychain;constructor(e,r){this.keychain=e.libp2p.services.keychain,this.localStore=r.localStore,this.routers=r.routers}async publish(e,r,n={}){try{let o=await this.#e(e),i=1n,s=vt(o.publicKey.toMultihash());if(await this.localStore.has(s,n)){let{record:l}=await this.localStore.get(s,n);i=Le(l).sequence+1n}pn(r)&&(r=r.toCID());let c=n.ttl!=null?BigInt(n.ttl)*1000000n:dr,a=n.lifetime??1728e5,f=await lo(o,r,i,a,{...n,ttlNs:c}),u=rn(f);return n.offline===!0?await this.localStore.put(s,u,{...n,metadata:{keyName:e,lifetime:a}}):await Promise.all(this.routers.map(async l=>{await l.put(s,u,{...n,metadata:{keyName:e,lifetime:a}})})),{record:f,publicKey:o.publicKey}}catch(o){throw n.onProgress?.(new ve("ipns:publish:error",o)),o}}async#e(e){try{return await this.keychain.exportKey(e)}catch{let n=await Fc("Ed25519");return await this.keychain.importKey(e,n),n}}async unpublish(e,r){let{publicKey:n}=await this.keychain.exportKey(e),o=n.toMultihash(),i=vt(o);await this.localStore.delete(i,r)}};function mr(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var So=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||(e-1&e)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},yr=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new So(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let r=this.head;this.head=r.next=new So(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var Is=class extends Error{type;code;constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function mf(t={}){return xp(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},t)}function xp(t,e){e=e??{};let r=e.onEnd,n=new yr,o,i,s,c=mr(),a=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((E,w)=>{i=B=>{i=null,n.push(B);try{E(t(n))}catch(v){w(v)}return o}}):t(n)}finally{n.isEmpty()&&queueMicrotask(()=>{c.resolve(),c=mr()})}},f=E=>i!=null?i(E):(n.push(E),o),u=E=>(n=new yr,i!=null?i({error:E}):(n.push({error:E}),o)),l=E=>{if(s)return o;if(e?.objectMode!==!0&&E?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return f({done:!1,value:E})},g=E=>s?o:(s=!0,E!=null?u(E):f({done:!0})),S=()=>(n=new yr,g(),{done:!0}),x=E=>(g(E),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:a,return:S,throw:x,push:l,end:g,get readableLength(){return n.size},onEmpty:async E=>{let w=E?.signal;if(w?.throwIfAborted(),n.isEmpty())return;let B,v;w!=null&&(B=new Promise((U,P)=>{v=()=>{P(new Is)},w.addEventListener("abort",v)}));try{await Promise.race([c.promise,B])}finally{v!=null&&w!=null&&w?.removeEventListener("abort",v)}}},r==null)return o;let T=o;return o={[Symbol.asyncIterator](){return this},next(){return T.next()},throw(E){return T.throw(E),r!=null&&(r(E),r=void 0),{done:!0}},return(){return T.return(),r!=null&&(r(),r=void 0),{done:!0}},push:l,end(E){return T.end(E),r!=null&&(r(E),r=void 0),o},get readableLength(){return T.readableLength},onEmpty:E=>T.onEmpty(E)},o}var Ts=class t extends Error{name="TimeoutError";constructor(e,r){super(e,r),Error.captureStackTrace?.(this,t)}},yf=t=>t.reason??new DOMException("This operation was aborted.","AbortError");function Bs(t,e){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout},signal:s}=e,c,a,u=new Promise((l,g)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(s?.aborted){g(yf(s));return}if(s&&(a=()=>{g(yf(s))},s.addEventListener("abort",a,{once:!0})),t.then(l,g),r===Number.POSITIVE_INFINITY)return;let S=new Ts;c=i.setTimeout.call(void 0,()=>{if(n){try{l(n())}catch(x){g(x)}return}typeof t.cancel=="function"&&t.cancel(),o===!1?l():o instanceof Error?g(o):(S.message=o??`Promise timed out after ${r} milliseconds`,g(S))},r)}).finally(()=>{u.clear(),a&&s&&s.removeEventListener("abort",a)});return u.clear=()=>{i.clearTimeout.call(void 0,c),c=void 0},u}var wp=t=>{let e=t.addEventListener||t.on||t.addListener,r=t.removeEventListener||t.off||t.removeListener;if(!e||!r)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(t),removeListener:r.bind(t)}};function Ep(t,e,r){let n,o=new Promise((i,s)=>{if(r={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...r},!(r.count>=0&&(r.count===Number.POSITIVE_INFINITY||Number.isInteger(r.count))))throw new TypeError("The `count` option should be at least 0 or more");r.signal?.throwIfAborted();let c=[e].flat(),a=[],{addListener:f,removeListener:u}=wp(t),l=async(...S)=>{let x=r.multiArgs?S:S[0];if(r.filter)try{if(!await r.filter(x))return}catch(T){n(),s(T);return}a.push(x),r.count===a.length&&(n(),i(a))},g=(...S)=>{n(),s(r.rejectionMultiArgs?S:S[0])};n=()=>{for(let S of c)u(S,l);for(let S of r.rejectionEvents)c.includes(S)||u(S,g)};for(let S of c)f(S,l);for(let S of r.rejectionEvents)c.includes(S)||f(S,g);r.signal&&r.signal.addEventListener("abort",()=>{g(r.signal.reason)},{once:!0}),r.resolveImmediately&&i(a)});if(o.cancel=n,typeof r.timeout=="number"){let i=Bs(o,{milliseconds:r.timeout});return i.cancel=()=>{n(),i.clear()},i}return o}function vo(t,e,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=Ep(t,e,r),o=n.then(i=>i[0]);return o.cancel=n.cancel,o}function an(t,e){let r,n=function(){let o=function(){r=void 0,t()};clearTimeout(r),r=setTimeout(o,e)};return n.start=()=>{},n.stop=()=>{clearTimeout(r)},n}var Ao=class extends Error{static name="QueueFullError";constructor(e="The queue was full"){super(e),this.name="QueueFullError"}};function Sp(t){return t.reason}async function gf(t,e,r){if(e==null)return t;let n=r?.translateError??Sp;if(e.aborted)return t.catch(()=>{}),Promise.reject(n(e));let o;try{return await Promise.race([t,new Promise((i,s)=>{o=()=>{s(n(e))},e.addEventListener("abort",o)})])}finally{o!=null&&e.removeEventListener("abort",o)}}var Io=class{deferred;signal;constructor(e){this.signal=e,this.deferred=mr(),this.onAbort=this.onAbort.bind(this),this.signal?.addEventListener("abort",this.onAbort)}onAbort(){this.deferred.reject(this.signal?.reason??new Je)}cleanup(){this.signal?.removeEventListener("abort",this.onAbort)}};function vp(){return`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`}var To=class{id;fn;options;recipients;status;timeline;controller;constructor(e,r){this.id=vp(),this.status="queued",this.fn=e,this.options=r,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,this.controller.signal,this.onAbort=this.onAbort.bind(this)}abort(e){this.controller.abort(e)}onAbort(){this.recipients.reduce((r,n)=>r&&n.signal?.aborted===!0,!0)&&(this.controller.abort(new Je),this.cleanup())}async join(e={}){let r=new Io(e.signal);return this.recipients.push(r),e.signal?.addEventListener("abort",this.onAbort),r.deferred.promise}async run(){this.status="running",this.timeline.started=Date.now();try{this.controller.signal.throwIfAborted();let e=await gf(this.fn({...this.options??{},signal:this.controller.signal}),this.controller.signal);this.recipients.forEach(r=>{r.deferred.resolve(e)}),this.status="complete"}catch(e){this.recipients.forEach(r=>{r.deferred.reject(e)}),this.status="errored"}finally{this.timeline.finished=Date.now(),this.cleanup()}}cleanup(){this.recipients.forEach(e=>{e.cleanup(),e.signal?.removeEventListener("abort",this.onAbort)})}};var Bo=class extends mn{concurrency;maxSize;queue;pending;sort;paused;constructor(e={}){super(),this.concurrency=e.concurrency??Number.POSITIVE_INFINITY,this.maxSize=e.maxSize??Number.POSITIVE_INFINITY,this.pending=0,this.paused=!1,e.metricName!=null&&e.metrics?.registerMetricGroup(e.metricName,{calculate:()=>({size:this.queue.length,running:this.pending,queued:this.queue.length-this.pending})}),this.sort=e.sort,this.queue=[],this.emitEmpty=an(this.emitEmpty.bind(this),1),this.emitIdle=an(this.emitIdle.bind(this),1)}emitEmpty(){this.size===0&&this.safeDispatchEvent("empty")}emitIdle(){this.running===0&&this.safeDispatchEvent("idle")}pause(){this.paused=!0}resume(){this.paused&&(this.paused=!1,this.tryToStartAnother())}tryToStartAnother(){if(this.paused)return!1;if(this.size===0)return this.emitEmpty(),this.running===0&&this.emitIdle(),!1;if(this.pending<this.concurrency){let e;for(let r of this.queue)if(r.status==="queued"){e=r;break}return e==null?!1:(this.safeDispatchEvent("active"),this.pending++,e.run().finally(()=>{for(let r=0;r<this.queue.length;r++)if(this.queue[r]===e){this.queue.splice(r,1);break}this.pending--,this.tryToStartAnother(),this.safeDispatchEvent("next")}),!0)}return!1}enqueue(e){this.queue.push(e),this.sort!=null&&this.queue.sort(this.sort)}async add(e,r){if(r?.signal?.throwIfAborted(),this.size===this.maxSize)throw new Ao;let n=new To(e,r);return this.enqueue(n),this.safeDispatchEvent("add"),this.tryToStartAnother(),n.join(r).then(o=>(this.safeDispatchEvent("completed",{detail:o}),this.safeDispatchEvent("success",{detail:{job:n,result:o}}),o)).catch(o=>{if(n.status==="queued"){for(let i=0;i<this.queue.length;i++)if(this.queue[i]===n){this.queue.splice(i,1);break}}throw this.safeDispatchEvent("failure",{detail:{job:n,error:o}}),o})}clear(){this.queue.splice(0,this.queue.length)}abort(){this.queue.forEach(e=>{e.abort(new Je)}),this.clear()}async onEmpty(e){this.size!==0&&await vo(this,"empty",e)}async onSizeLessThan(e,r){this.size<e||await vo(this,"next",{...r,filter:()=>this.size<e})}async onIdle(e){this.pending===0&&this.size===0||await vo(this,"idle",e)}get size(){return this.queue.length}get queued(){return this.queue.length-this.pending}get running(){return this.pending}async*toGenerator(e){e?.signal?.throwIfAborted();let r=mf({objectMode:!0}),n=a=>{a!=null?this.abort():this.clear(),r.end(a)},o=a=>{a.detail!=null&&r.push(a.detail)},i=a=>{n(a.detail.error)},s=()=>{n()},c=()=>{n(new Je("Queue aborted"))};this.addEventListener("completed",o),this.addEventListener("failure",i),this.addEventListener("idle",s),e?.signal?.addEventListener("abort",c);try{yield*r}finally{this.removeEventListener("completed",o),this.removeEventListener("failure",i),this.removeEventListener("idle",s),e?.signal?.removeEventListener("abort",c),n()}}};function bf(t){let e=new globalThis.AbortController;function r(){let i=t.filter(s=>s?.aborted===!0).map(s=>s?.reason).pop();e.abort(i);for(let s of t)s?.removeEventListener!=null&&s.removeEventListener("abort",r)}for(let i of t){if(i?.aborted===!0){r();break}i?.addEventListener!=null&&i.addEventListener("abort",r)}function n(){for(let i of t)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}let o=e.signal;return o.clear=n,o}function xf(t,e,r){let n,o,i=!1;function s(){let f={signal:o.signal},u;r?.timeout!=null&&(u=bf([o.signal,AbortSignal.timeout(r.timeout)]),f.signal=u),i=!0,Promise.resolve().then(async()=>{await t(f)}).catch(()=>{}).finally(()=>{u!=null&&(u.aborted?u.clear():u.addEventListener("abort",()=>{u.clear()},{once:!0})),i=!1,!o.signal.aborted&&(n=setTimeout(s,e))})}let c=an(s,r?.debounce??100),a=!1;return{setInterval:f=>{e!==f&&(e=f,n!=null&&(clearTimeout(n),n=setTimeout(s,e)))},setTimeout:f=>{r??={},r.timeout=f},run:()=>{i||(clearTimeout(n),c())},start:()=>{a||(a=!0,o=new AbortController,o.signal,r?.runImmediately===!0?queueMicrotask(()=>{s()}):n=setTimeout(s,e))},stop:()=>{clearTimeout(n),o?.abort(),a=!1}}}var Co=class{routers;localStore;republishTask;log;keychain;started=!1;republishConcurrency;constructor(e,r){this.log=e.logger.forComponent("helia:ipns"),this.localStore=r.localStore,this.keychain=e.libp2p.services.keychain,this.republishConcurrency=r.republishConcurrency||ff,this.started=e.libp2p.status==="started",this.routers=r.routers??[],this.republishTask=xf(this.#e.bind(this),r.republishInterval??36e5,{runImmediately:!0}),this.started&&this.republishTask.start()}start(){this.started||(this.started=!0,this.republishTask.start())}stop(){this.started&&(this.started=!1,this.republishTask.stop())}async#e(e={}){if(!this.started)return;this.log("starting ipns republish records loop");let r=new Bo({concurrency:this.republishConcurrency});try{let n=[];for await(let{routingKey:o,record:i,metadata:s,created:c}of this.localStore.list(e)){if(s==null){this.log(`no metadata found for record ${o.toString()}, skipping`);continue}let a;try{a=Le(i)}catch(g){this.log.error("error unmarshaling record - %e",g);continue}if(!df(a,c)){this.log.trace(`skipping record ${o.toString()}within republish threshold`);continue}let f=a.sequence+1n,u=a.ttl??dr,l;try{l=await this.keychain.exportKey(s.keyName)}catch(g){this.log.error("missing key %s, skipping republishing record - %e",s.keyName,g);continue}try{let g=await lo(l,a.value,f,s.lifetime,{...e,ttlNs:u});n.push({routingKey:o,record:g})}catch(g){this.log.error("error creating updated IPNS record for %s - %e",o,g);continue}}this.log(`found ${n.length} records to republish`);for(let{routingKey:o,record:i}of n)r.add(async()=>{try{let s=rn(i);await Promise.all(this.routers.map(c=>c.put(o,s,e)))}catch(s){this.log.error("error republishing record - %e",s)}},e)}catch(n){this.log.error("error during republish - %e",n)}await r.onIdle(e)}};var cn;(function(t){let e;t.codec=()=>(e==null&&(e=Ye((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.key!=null&&r.key.byteLength>0&&(n.uint32(10),n.bytes(r.key)),r.value!=null&&r.value.byteLength>0&&(n.uint32(18),n.bytes(r.value)),r.timeReceived!=null&&r.timeReceived!==""&&(n.uint32(42),n.string(r.timeReceived)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={key:Re(0),value:Re(0),timeReceived:""},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.key=r.bytes();break}case 2:{i.value=r.bytes();break}case 5:{i.timeReceived=r.string();break}default:{r.skipType(c&7);break}}}return i})),e),t.encode=r=>Ze(r,t.codec()),t.decode=(r,n)=>je(r,t.codec(),n)})(cn||(cn={}));function wf(t){let e=t.getUTCFullYear(),r=String(t.getUTCMonth()+1).padStart(2,"0"),n=String(t.getUTCDate()).padStart(2,"0"),o=String(t.getUTCHours()).padStart(2,"0"),i=String(t.getUTCMinutes()).padStart(2,"0"),s=String(t.getUTCSeconds()).padStart(2,"0"),c=t.getUTCMilliseconds(),a=String(c*1e3*1e3).padStart(9,"0");return`${e}-${r}-${n}T${o}:${i}:${s}.${a}Z`}function Ef(t){let e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),r=String(t).trim().match(e);if(r==null)throw new Error("Invalid format");let n=parseInt(r[1],10),o=parseInt(r[2],10)-1,i=parseInt(r[3],10),s=parseInt(r[4],10),c=parseInt(r[5],10),a=parseInt(r[6],10),f=parseInt(r[7].slice(0,-6),10);return new Date(Date.UTC(n,o,i,s,c,a,f))}var At=class t{key;value;timeReceived;constructor(e,r,n){if(!(e instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(r instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=e,this.value=r,this.timeReceived=n}serialize(){return cn.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:wf(this.timeReceived)}}static deserialize(e){let r=cn.decode(e);return new t(r.key,r.value,new Date(r.timeReceived))}static fromDeserialized(e){let r=Ef(e.timeReceived);if(e.key==null)throw new Error("key missing from deserialized object");if(e.value==null)throw new Error("value missing from deserialized object");return new t(e.key,e.value,r)}};var Sf;(function(t){t[t.SEND_QUERY=0]="SEND_QUERY",t[t.PEER_RESPONSE=1]="PEER_RESPONSE",t[t.FINAL_PEER=2]="FINAL_PEER",t[t.QUERY_ERROR=3]="QUERY_ERROR",t[t.PROVIDER=4]="PROVIDER",t[t.VALUE=5]="VALUE",t[t.ADD_PEER=6]="ADD_PEER",t[t.DIAL_PEER=7]="DIAL_PEER",t[t.PATH_ENDED=8]="PATH_ENDED"})(Sf||(Sf={}));var un;(function(t){let e;t.codec=()=>(e==null&&(e=Ye((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.keyName!=null&&r.keyName!==""&&(n.uint32(10),n.string(r.keyName)),r.lifetime!=null&&r.lifetime!==0&&(n.uint32(16),n.uint32(r.lifetime)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={keyName:"",lifetime:0},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.keyName=r.string();break}case 2:{i.lifetime=r.uint32();break}default:{r.skipType(c&7);break}}}return i})),e),t.encode=r=>Ze(r,t.codec()),t.decode=(r,n)=>je(r,t.codec(),n)})(un||(un={}));function _o(t,e){return{async put(r,n,o={}){try{let i=sn(r);try{let a=await t.get(i),f=At.deserialize(a);if(ne(f.value,n))return}catch(a){if(a.name!=="NotFoundError")throw a}let s=new At(r,n,new Date);o.onProgress?.(new ve("ipns:routing:datastore:put"));let c=t.batch();c.put(i,s.serialize()),o.metadata!=null&&c.put(wo(r),un.encode(o.metadata)),await c.commit(o)}catch(i){throw o.onProgress?.(new ve("ipns:routing:datastore:error",i)),i}},async get(r,n={}){try{let o=sn(r);n.onProgress?.(new ve("ipns:routing:datastore:get"));let i=await t.get(o,n),s=At.deserialize(i);return{record:s.value,created:s.timeReceived}}catch(o){throw n.onProgress?.(new ve("ipns:routing:datastore:error",o)),o}},async has(r,n={}){let o=sn(r);return t.has(o,n)},async delete(r,n){let o=sn(r),i=t.batch();i.delete(o),i.delete(wo(r)),await i.commit(n)},async*list(r={}){try{r.onProgress?.(new ve("ipns:routing:datastore:list"));for await(let{key:n,value:o}of t.query({prefix:xo},r))try{let i=At.deserialize(o),c=n.toString().substring(xo.length),a=$(c,"base32"),f=wo(a),u;try{let l=await t.get(f,r);u=un.decode(l)}catch(l){e.error("Error deserializing metadata for %s - %e",c,l)}yield{routingKey:a,metadata:u,record:i.value,created:i.timeReceived}}catch(i){e.error("Error deserializing record - %e",i)}}catch(n){throw r.onProgress?.(new ve("ipns:routing:datastore:error",n)),n}}}}var Cs=class{routing;constructor(e){this.routing=e}async put(e,r,n={}){try{await this.routing.put(e,r,n)}catch(o){throw n.onProgress?.(new ve("ipns:routing:helia:error",o)),o}}async get(e,r={}){try{return await this.routing.get(e,r)}catch(n){throw r.onProgress?.(new ve("ipns:routing:helia:error",n)),n}}toString(){return"HeliaRouting()"}};function fn(t){return new Cs(t)}var _s=class{localStore;constructor(e){this.localStore=e}async put(e,r,n){await this.localStore.put(e,r,n)}async get(e,r){let{record:n}=await this.localStore.get(e,r);return n}toString(){return"LocalStoreRouting()"}};function Lo(t){return new _s(t)}var Ro=class{routers;publisher;republisher;resolver;localStore;started;constructor(e,r={}){this.localStore=_o(e.datastore,e.logger.forComponent("helia:ipns:local-store")),this.started=e.libp2p.status==="started",this.routers=[Lo(this.localStore),fn(e.routing),...r.routers??[]],this.publisher=new Eo(e,{...r,routers:this.routers,localStore:this.localStore}),this.republisher=new Co(e,{...r,routers:this.routers,localStore:this.localStore}),this.resolver=new pr(e,{...r,routers:this.routers,localStore:this.localStore}),e.events.addEventListener("start",this.start.bind(this)),e.events.addEventListener("stop",this.stop.bind(this)),this.started&&this.republisher.start()}start(){this.started||(this.started=!0,this.republisher.start())}stop(){this.started&&(this.started=!1,this.republisher.stop())}async publish(e,r,n={}){return this.publisher.publish(e,r,n)}async resolve(e,r={}){return this.resolver.resolve(e,r)}async unpublish(e,r){return this.publisher.unpublish(e,r)}};function Tp(t,e={}){return new Ro(t,e)}function Bp(t,e={}){let r=_o(t.datastore,t.logger.forComponent("helia:ipns:local-store")),n=[Lo(r),fn(t.routing),...e.routers??[]];return new pr(t,{routers:n,localStore:r})}return _f(Cp);})();
14
14
  /*! Bundled license information:
15
15
 
16
16
  @noble/hashes/utils.js: