@wovin/connect-web3storage 0.1.21 → 0.1.22
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as Jn}from"./chunk-L7VH6KZJ.min.js";import{a as Mu,b as St,c as zi}from"./chunk-D2SZILOK.min.js";var Ti=Mu((
|
|
2
|
-
`,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return A;function A(p,m,C){var R=this;if(!(R instanceof A))return new A(p,m,C);R.time=+p||0,R.nano=+m||0,R.year=+C||0,B(R)}function B(p){var m,C,R,I=p.year,y=p.time,g=p.nano,d=((g<0||a<=g)&&(g-=(C=Math.floor(g/a))*a,y+=C,C=1),I%t);return(y<-i||i<y||d)&&((m=l(y/o))&&(I+=m*t,y-=m*o),(R=w(y)).setUTCFullYear(d+R.getUTCFullYear()),R=(y=+R)+(m=l((I-=d)/t))*o,m&&-i<=R&&R<=i&&(I-=m*t,y=R),C=1),C&&(p.year=I,p.time=y,p.nano=g),p}function w(p){var m=new Date(0);return m.setTime(p),m}function T(I,R){I=+I||0;var C=l((R=(R|0)*s)/n)+l(I/n),R=R%n+I%n,I=l(R/n);return I&&(C+=I,R-=I*n),new A(1e3*R,0,C*t)}function E(p,m,C,R,I,y){return function(d,S){var N=B(this);d=d||new Array(8),K(d,S|=0);var k=Math.floor(N.time/1e3),N=N.year*(r*e/t),D=l(N/s)+l(k/s),N=N%s+k%s,k=Math.floor(N/s);return k&&(D+=k,N-=k*s),g(d,S+I,D),g(d,S+y,N),d};function g(d,S,D){d[S+p]=D>>24&255,d[S+m]=D>>16&255,d[S+C]=D>>8&255,d[S+R]=255&D}}function U(p,m,C,R,I,y){return function(d,S){K(d,S|=0);var D=g(d,S+I);return T(g(d,S+y),D)};function g(d,S){return 16777216*d[S+p]+(d[S+m]<<16|d[S+C]<<8|d[S+R])}}function K(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 M(p){return(9<p?"":"0")+(0|p)}function F(p,m){return(c+(0|p)).substr(-m)}}()});var rt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},ke=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}},pr=class extends Error{static name="InvalidPrivateKeyError";constructor(t="Invalid private key"){super(t),this.name="InvalidPrivateKeyError"}};var Ke=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var no={};St(no,{base58btc:()=>ot,base58flickr:()=>zu});var mh=new Uint8Array(0);function Zi(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function jt(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function ji(e){return new TextEncoder().encode(e)}function Gi(e){return new TextDecoder().decode(e)}function Pu(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function f(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var A=0,B=0,w=0,T=b.length;w!==T&&b[w]===0;)w++,A++;for(var E=(T-w)*u+1>>>0,U=new Uint8Array(E);w!==T;){for(var K=b[w],M=0,F=E-1;(K!==0||M<B)&&F!==-1;F--,M++)K+=256*U[F]>>>0,U[F]=K%a>>>0,K=K/a>>>0;if(K!==0)throw new Error("Non-zero carry");B=M,w++}for(var p=E-B;p!==E&&U[p]===0;)p++;for(var m=c.repeat(A);p<E;++p)m+=e.charAt(U[p]);return m}function x(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var A=0;if(b[A]!==" "){for(var B=0,w=0;b[A]===c;)B++,A++;for(var T=(b.length-A)*l+1>>>0,E=new Uint8Array(T);b[A];){var U=r[b.charCodeAt(A)];if(U===255)return;for(var K=0,M=T-1;(U!==0||K<w)&&M!==-1;M--,K++)U+=a*E[M]>>>0,E[M]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");w=K,A++}if(b[A]!==" "){for(var F=T-w;F!==T&&E[F]===0;)F++;for(var p=new Uint8Array(B+(T-F)),m=B;F!==T;)p[m++]=E[F++];return p}}}function v(b){var A=x(b);if(A)return A;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:x,decode:v}}var Fu=Pu,Vu=Fu,Wi=Vu;var Qn=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},to=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Xi(this,t)}},eo=class{decoders;constructor(t){this.decoders=t}or(t){return Xi(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Xi(e,t){return new eo({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var ro=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Qn(t,r,n),this.decoder=new to(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Oe({name:e,prefix:t,encode:r,decode:n}){return new ro(e,t,r,n)}function oe({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Wi(r,e);return Oe({prefix:t,name:e,encode:n,decode:i=>jt(o(i))})}function qu(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let l=0;l<o;++l){let u=t[e[l]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|u,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||255&a<<8-s)throw new SyntaxError("Unexpected end of data");return i}function Hu(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<r-s]),n)for(;i.length*r&7;)i+="=";return i}function $u(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function tt({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=$u(n);return Oe({prefix:t,name:e,encode(i){return Hu(i,n,r)},decode(i){return qu(i,o,r,e)}})}var ot=oe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),zu=oe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var oo={};St(oo,{base32:()=>ie,base32hex:()=>Yu,base32hexpad:()=>Xu,base32hexpadupper:()=>Ju,base32hexupper:()=>Wu,base32pad:()=>ju,base32padupper:()=>Gu,base32upper:()=>Zu,base32z:()=>Qu});var ie=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Zu=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ju=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Gu=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Yu=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Wu=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Xu=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ju=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Qu=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var io={};St(io,{base36:()=>Lt,base36upper:()=>tf});var Lt=oe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),tf=oe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ef=ts,Ji=128,rf=127,nf=~rf,of=Math.pow(2,31);function ts(e,t,r){t=t||[],r=r||0;for(var n=r;e>=of;)t[r++]=e&255|Ji,e/=128;for(;e&nf;)t[r++]=e&255|Ji,e>>>=7;return t[r]=e|0,ts.bytes=r-n+1,t}var sf=so,af=128,Qi=127;function so(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw so.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&Qi)<<o:(s&Qi)*Math.pow(2,o),o+=7}while(s>=af);return so.bytes=i-n,r}var cf=Math.pow(2,7),uf=Math.pow(2,14),ff=Math.pow(2,21),lf=Math.pow(2,28),df=Math.pow(2,35),hf=Math.pow(2,42),pf=Math.pow(2,49),mf=Math.pow(2,56),yf=Math.pow(2,63),gf=function(e){return e<cf?1:e<uf?2:e<ff?3:e<lf?4:e<df?5:e<hf?6:e<pf?7:e<mf?8:e<yf?9:10},bf={encode:ef,decode:sf,encodingLength:gf},xf=bf,mr=xf;function yr(e,t=0){return[mr.decode(e,t),mr.decode.bytes]}function Me(e,t,r=0){return mr.encode(e,t,r),t}function Pe(e){return mr.encodingLength(e)}function qt(e,t){let r=t.byteLength,n=Pe(e),o=n+Pe(r),i=new Uint8Array(o+r);return Me(e,i,0),Me(r,i,n),i.set(t,o),new Fe(e,r,t,i)}function Ve(e){let t=jt(e),[r,n]=yr(t),[o,i]=yr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Fe(r,o,s,t)}function es(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Zi(e.bytes,r.bytes)}}var Fe=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function rs(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Ef(r,ao(e),t??ot.encoder);default:return Sf(r,ao(e),t??ie.encoder)}}var ns=new WeakMap;function ao(e){let t=ns.get(e);if(t==null){let r=new Map;return ns.set(e,r),r}return t}var it=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==gr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==vf)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=qt(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&es(t.multihash,n.multihash)}toString(t){return rs(this,t)}toJSON(){return{"/":rs(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new e(n,o,i,s??os(n,o,i.bytes))}else if(r[Af]===!0){let{version:n,multihash:o,code:i}=r,s=Ve(o);return e.create(n,i,s)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==gr)throw new Error(`Version 0 CID must use dag-pb (code: ${gr}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=os(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,gr,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=jt(t.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 Fe(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[f,x]=yr(t.subarray(r));return r+=x,f},o=n(),i=gr;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),l=r+c,u=l-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:l}}static parse(t,r){let[n,o]=wf(t,r),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ao(i).set(n,t),i}};function wf(e,t){switch(e[0]){case"Q":{let r=t??ot;return[ot.prefix,r.decode(`${ot.prefix}${e}`)]}case ot.prefix:{let r=t??ot;return[ot.prefix,r.decode(e)]}case ie.prefix:{let r=t??ie;return[ie.prefix,r.decode(e)]}case Lt.prefix:{let r=t??Lt;return[Lt.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Ef(e,t,r){let{prefix:n}=r;if(n!==ot.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o}function Sf(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o}var gr=112,vf=18;function os(e,t,r){let n=Pe(e),o=n+Pe(t),i=new Uint8Array(o+r.byteLength);return Me(e,i,0),Me(t,i,n),i.set(r,o),i}var Af=Symbol.for("@ipld/js-cid/CID");var co={};St(co,{identity:()=>ge});var is=0,Bf="identity",ss=jt;function If(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return qt(is,ss(e))}var ge={code:is,name:Bf,encode:ss,digest:If};function st(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Gt(e=0){return new Uint8Array(e)}function vt(e=0){return new Uint8Array(e)}function be(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=vt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var cs=Symbol.for("@achingbrain/uint8arraylist");function as(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function on(e){return!!e?.[cs]}var pt=class e{bufs;length;[cs]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(on(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(on(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=as(this.bufs,t);return r.buf[r.index]}set(t,r){let n=as(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(on(t))for(let n=0;n<t.length;n++)this.set(r+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,r){let{bufs:n,length:o}=this._subList(t,r);return be(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:be(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),i=new e;return i.length=o,i.bufs=[...n],i}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,t>=c)continue;let l=t>=a&&t<c,u=r>a&&r<=c;if(l&&u){if(t===a&&r===c){n.push(s);break}let f=t-a;n.push(s.subarray(f,f+(r-t)));break}if(l){if(t===0){n.push(s);continue}n.push(s.subarray(t-a));continue}if(u){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!on(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let f=0;f<i;f++)s[f]=-1;for(let f=0;f<o;f++)s[n[f]]=f;let a=s,c=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=r;f<=c;f+=u){u=0;for(let x=l;x>=0;x--){let v=this.get(f+x);if(n[x]!==v){u=Math.max(1,x-a[v]);break}}if(u===0)return f}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=vt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=Gt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=Gt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=Gt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=vt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=Gt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=Gt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=Gt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=Gt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=Gt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!st(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var uo={};St(uo,{base10:()=>Tf});var Tf=oe({prefix:"9",name:"base10",alphabet:"0123456789"});var fo={};St(fo,{base16:()=>_f,base16upper:()=>Cf});var _f=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Cf=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var lo={};St(lo,{base2:()=>Uf});var Uf=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ho={};St(ho,{base256emoji:()=>kf});var us=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}"),Rf=us.reduce((e,t,r)=>(e[r]=t,e),[]),Df=us.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Lf(e){return e.reduce((t,r)=>(t+=Rf[r],t),"")}function Nf(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Df[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var kf=Oe({prefix:"\u{1F680}",name:"base256emoji",encode:Lf,decode:Nf});var mo={};St(mo,{base64:()=>po,base64pad:()=>sn,base64url:()=>Kf,base64urlpad:()=>Of});var po=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),sn=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Kf=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Of=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var yo={};St(yo,{base8:()=>Mf});var Mf=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var go={};St(go,{identity:()=>Pf});var Pf=Oe({prefix:"\0",name:"identity",encode:e=>Gi(e),decode:e=>ji(e)});var Jh=new TextEncoder,Qh=new TextDecoder;var wo={};St(wo,{sha256:()=>an,sha512:()=>Hf});var qf=20;function xo({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new bo(e,t,r,n,o)}var bo=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,i){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??qf,this.maxDigestLength=i}digest(t,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(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?fs(n,this.code,r?.truncate):n.then(o=>fs(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function fs(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return qt(t,e)}function ds(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var an=xo({name:"sha2-256",code:18,encode:ds("SHA-256")}),Hf=xo({name:"sha2-512",code:19,encode:ds("SHA-512")});var Eo={...go,...lo,...yo,...uo,...fo,...oo,...io,...no,...mo,...ho},l0={...wo,...co};function ps(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var hs=ps("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),So=ps("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=vt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),$f={utf8:hs,"utf-8":hs,hex:Eo.base16,latin1:So,ascii:So,binary:So,...Eo},cn=$f;function Z(e,t="utf8"){let r=cn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function j(e,t="utf8"){let r=cn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var zf=parseInt("11111",2),vo=parseInt("10000000",2),Zf=parseInt("01111111",2),ms={0:br,1:br,2:jf,3:Wf,4:Xf,5:Yf,6:Gf,16:br,22:br,48:br};function Ut(e,t={offset:0}){let r=e[t.offset]&zf;if(t.offset++,ms[r]!=null)return ms[r](e,t);throw new Error("No decoder for tag "+r)}function xr(e,t){let r=0;if((e[t.offset]&vo)===vo){let n=e[t.offset]&Zf,o="0x";t.offset++;for(let i=0;i<n;i++,t.offset++)o+=e[t.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=e[t.offset],t.offset++;return r}function br(e,t){xr(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=Ut(e,t);if(n===null)break;r.push(n)}return r}function jf(e,t){let r=xr(e,t),n=t.offset,o=t.offset+r,i=[];for(let s=n;s<o;s++)s===n&&e[s]===0||i.push(e[s]);return t.offset+=r,Uint8Array.from(i)}function Gf(e,t){let r=xr(e,t),n=t.offset+r,o=e[t.offset];t.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 a=`${i}.${s}`,c=[];for(;t.offset<n;){let l=e[t.offset];if(t.offset++,c.push(l&127),l<128){c.reverse();let u=0;for(let f=0;f<c.length;f++)u+=c[f]<<f*7;a+=`.${u}`,c=[]}}return a}function Yf(e,t){return t.offset++,null}function Wf(e,t){let r=xr(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Xf(e,t){let r=xr(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function Jf(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new pt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function un(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=Jf(e.byteLength);return new pt(Uint8Array.from([t.byteLength|vo]),t)}function mt(e){let t=new pt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new pt(Uint8Array.from([2]),un(t),t)}function wr(e){let t=Uint8Array.from([0]),r=new pt(t,e);return new pt(Uint8Array.from([3]),un(r),r)}function ys(e){return new pt(Uint8Array.from([4]),un(e),e)}function Nt(e,t=48){let r=new pt;for(let n of e)r.append(n);return new pt(Uint8Array.from([t]),un(r),r)}var gs="1.2.840.10045.3.1.7",bs="1.3.132.0.34",xs="1.3.132.0.35";async function ws(e="P-256"){let t=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:e},!0,["sign","verify"]);return{publicKey:await crypto.subtle.exportKey("jwk",t.publicKey),privateKey:await crypto.subtle.exportKey("jwk",t.privateKey)}}async function Es(e,t,r){let n=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["sign"]);r?.signal?.throwIfAborted();let o=await crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},n,t.subarray());return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function Ss(e,t,r,n){let o=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,t,r.subarray());return n?.signal?.throwIfAborted(),i}var Qf=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),tl=Uint8Array.from([6,5,43,129,4,0,34]),el=Uint8Array.from([6,5,43,129,4,0,35]),vs={ext:!0,kty:"EC",crv:"P-256"},As={ext:!0,kty:"EC",crv:"P-384"},Bs={ext:!0,kty:"EC",crv:"P-521"},qe=32,He=48,$e=66;function Is(e){let t=Ut(e);return Ao(t)}function Ao(e){let t=e[1],r=j(t,"base64url"),n=e[2][1][0],o=1,i,s;if(t.byteLength===qe)return i=j(n.subarray(o,o+qe),"base64url"),s=j(n.subarray(o+qe),"base64url"),new we({...vs,key_ops:["sign"],d:r,x:i,y:s});if(t.byteLength===He)return i=j(n.subarray(o,o+He),"base64url"),s=j(n.subarray(o+He),"base64url"),new we({...As,key_ops:["sign"],d:r,x:i,y:s});if(t.byteLength===$e)return i=j(n.subarray(o,o+$e),"base64url"),s=j(n.subarray(o+$e),"base64url"),new we({...Bs,key_ops:["sign"],d:r,x:i,y:s});throw new rt(`Private key length was wrong length, got ${t.byteLength}, expected 32, 48 or 66`)}function Ts(e){let t=Ut(e);return _s(t)}function _s(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===qe*2+1)return n=j(t.subarray(r,r+qe),"base64url"),o=j(t.subarray(r+qe),"base64url"),new xe({...vs,key_ops:["verify"],x:n,y:o});if(t.byteLength===He*2+1)return n=j(t.subarray(r,r+He),"base64url"),o=j(t.subarray(r+He),"base64url"),new xe({...As,key_ops:["verify"],x:n,y:o});if(t.byteLength===$e*2+1)return n=j(t.subarray(r,r+$e),"base64url"),o=j(t.subarray(r+$e),"base64url"),new xe({...Bs,key_ops:["verify"],x:n,y:o});throw new rt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Cs(e){return Nt([mt(Uint8Array.from([1])),ys(Z(e.d??"","base64url")),Nt([Rs(e.crv)],160),Nt([wr(new pt(Uint8Array.from([4]),Z(e.x??"","base64url"),Z(e.y??"","base64url")))],161)]).subarray()}function Us(e){return Nt([mt(Uint8Array.from([1])),Nt([Rs(e.crv)],160),Nt([wr(new pt(Uint8Array.from([4]),Z(e.x??"","base64url"),Z(e.y??"","base64url")))],161)]).subarray()}function Rs(e){if(e==="P-256")return Qf;if(e==="P-384")return tl;if(e==="P-521")return el;throw new rt(`Invalid curve ${e}`)}async function Ds(e="P-256"){let t=await ws(e);return new we(t.privateKey)}var xe=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Us(this.jwk)),this._raw}toMultihash(){return ge.digest(se(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return ot.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}async verify(t,r,n){return Ss(this.jwk,r,t,n)}},we=class{type="ECDSA";jwk;publicKey;_raw;constructor(t){this.jwk=t,this.publicKey=new xe({crv:t.crv,ext:t.ext,key_ops:["verify"],kty:"EC",x:t.x,y:t.y})}get raw(){return this._raw==null&&(this._raw=Cs(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}async sign(t,r){return Es(this.jwk,t,r)}};function Ee(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ht(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new Error(`${r}expected integer >= 0, got ${e}`)}}function H(e,t,r=""){let n=Ee(e),o=e?.length,i=t!==void 0;if(!n||i&&o!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=n?`length=${o}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+a+", got "+c)}return e}function fn(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash must wrapped by utils.createHasher");Ht(e.outputLen),Ht(e.blockLen)}function ze(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Ns(e,t){H(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function Wt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ln(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function kt(e,t){return e<<32-t|e>>>t}var ks=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",rl=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Xt(e){if(H(e),ks)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=rl[e[r]];return t}var Yt={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ls(e){if(e>=Yt._0&&e<=Yt._9)return e-Yt._0;if(e>=Yt.A&&e<=Yt.F)return e-(Yt.A-10);if(e>=Yt.a&&e<=Yt.f)return e-(Yt.a-10)}function Jt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(ks)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=Ls(e.charCodeAt(i)),a=Ls(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function bt(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];H(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}function Bo(e,t={}){let r=(o,i)=>e(i).update(o).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}function Ze(e=32){let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}var Io=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Ks(e,t,r){return e&t^~e&r}function Os(e,t,r){return e&t^e&r^t&r}var Er=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,o){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=ln(this.buffer)}update(t){ze(this),H(t);let{view:r,buffer:n,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=ln(t);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ze(this),Ns(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,Wt(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let f=s;f<o;f++)r[f]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let a=ln(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,u[f],i)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=a,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Qt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var lt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var dn=BigInt(4294967295),Ms=BigInt(32);function nl(e,t=!1){return t?{h:Number(e&dn),l:Number(e>>Ms&dn)}:{h:Number(e>>Ms&dn)|0,l:Number(e&dn)|0}}function Ps(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=nl(e[i],t);[n[i],o[i]]=[s,a]}return[n,o]}var To=(e,t,r)=>e>>>r,_o=(e,t,r)=>e<<32-r|t>>>r,Se=(e,t,r)=>e>>>r|t<<32-r,ve=(e,t,r)=>e<<32-r|t>>>r,Sr=(e,t,r)=>e<<64-r|t>>>r-32,vr=(e,t,r)=>e>>>r-32|t<<64-r;function $t(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Fs=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Vs=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,qs=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Hs=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,$s=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),zs=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var il=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]),ae=new Uint32Array(64),Co=class extends Er{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[t,r,n,o,i,s,a,c]}set(t,r,n,o,i,s,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,r){for(let f=0;f<16;f++,r+=4)ae[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let x=ae[f-15],v=ae[f-2],b=kt(x,7)^kt(x,18)^x>>>3,A=kt(v,17)^kt(v,19)^v>>>10;ae[f]=A+ae[f-7]+b+ae[f-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:l,H:u}=this;for(let f=0;f<64;f++){let x=kt(a,6)^kt(a,11)^kt(a,25),v=u+x+Ks(a,c,l)+il[f]+ae[f]|0,A=(kt(n,2)^kt(n,13)^kt(n,22))+Os(n,o,i)|0;u=l,l=c,c=a,a=s+v|0,s=i,i=o,o=n,n=v+A|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,l,u)}roundClean(){Wt(ae)}destroy(){this.set(0,0,0,0,0,0,0,0),Wt(this.buffer)}},Uo=class extends Co{A=Qt[0]|0;B=Qt[1]|0;C=Qt[2]|0;D=Qt[3]|0;E=Qt[4]|0;F=Qt[5]|0;G=Qt[6]|0;H=Qt[7]|0;constructor(){super(32)}};var Zs=Ps(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),sl=Zs[0],al=Zs[1],ce=new Uint32Array(80),ue=new Uint32Array(80),Ro=class extends Er{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:l,El:u,Fh:f,Fl:x,Gh:v,Gl:b,Hh:A,Hl:B}=this;return[t,r,n,o,i,s,a,c,l,u,f,x,v,b,A,B]}set(t,r,n,o,i,s,a,c,l,u,f,x,v,b,A,B){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=x|0,this.Gh=v|0,this.Gl=b|0,this.Hh=A|0,this.Hl=B|0}process(t,r){for(let E=0;E<16;E++,r+=4)ce[E]=t.getUint32(r),ue[E]=t.getUint32(r+=4);for(let E=16;E<80;E++){let U=ce[E-15]|0,K=ue[E-15]|0,M=Se(U,K,1)^Se(U,K,8)^To(U,K,7),F=ve(U,K,1)^ve(U,K,8)^_o(U,K,7),p=ce[E-2]|0,m=ue[E-2]|0,C=Se(p,m,19)^Sr(p,m,61)^To(p,m,6),R=ve(p,m,19)^vr(p,m,61)^_o(p,m,6),I=qs(F,R,ue[E-7],ue[E-16]),y=Hs(I,M,C,ce[E-7],ce[E-16]);ce[E]=y|0,ue[E]=I|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:l,Dl:u,Eh:f,El:x,Fh:v,Fl:b,Gh:A,Gl:B,Hh:w,Hl:T}=this;for(let E=0;E<80;E++){let U=Se(f,x,14)^Se(f,x,18)^Sr(f,x,41),K=ve(f,x,14)^ve(f,x,18)^vr(f,x,41),M=f&v^~f&A,F=x&b^~x&B,p=$s(T,K,F,al[E],ue[E]),m=zs(p,w,U,M,sl[E],ce[E]),C=p|0,R=Se(n,o,28)^Sr(n,o,34)^Sr(n,o,39),I=ve(n,o,28)^vr(n,o,34)^vr(n,o,39),y=n&i^n&a^i&a,g=o&s^o&c^s&c;w=A|0,T=B|0,A=v|0,B=b|0,v=f|0,b=x|0,{h:f,l:x}=$t(l|0,u|0,m|0,C|0),l=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let d=Fs(C,I,g);n=Vs(d,m,R,y),o=d|0}({h:n,l:o}=$t(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=$t(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=$t(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=$t(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:x}=$t(this.Eh|0,this.El|0,f|0,x|0),{h:v,l:b}=$t(this.Fh|0,this.Fl|0,v|0,b|0),{h:A,l:B}=$t(this.Gh|0,this.Gl|0,A|0,B|0),{h:w,l:T}=$t(this.Hh|0,this.Hl|0,w|0,T|0),this.set(n,o,i,s,a,c,l,u,f,x,v,b,A,B,w,T)}roundClean(){Wt(ce,ue)}destroy(){Wt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Do=class extends Ro{Ah=lt[0]|0;Al=lt[1]|0;Bh=lt[2]|0;Bl=lt[3]|0;Ch=lt[4]|0;Cl=lt[5]|0;Dh=lt[6]|0;Dl=lt[7]|0;Eh=lt[8]|0;El=lt[9]|0;Fh=lt[10]|0;Fl=lt[11]|0;Gh=lt[12]|0;Gl=lt[13]|0;Hh=lt[14]|0;Hl=lt[15]|0;constructor(){super(64)}};var je=Bo(()=>new Uo,Io(1));var js=Bo(()=>new Do,Io(3));var No=BigInt(0),Lo=BigInt(1);function te(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function Gs(e){if(typeof e=="bigint"){if(!hn(e))throw new Error("positive bigint expected, got "+e)}else Ht(e);return e}function Ar(e){let t=Gs(e).toString(16);return t.length&1?"0"+t:t}function Ys(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?No:BigInt("0x"+e)}function Ge(e){return Ys(Xt(e))}function Ae(e){return Ys(Xt(mn(H(e)).reverse()))}function pn(e,t){Ht(t),e=Gs(e);let r=Jt(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function ko(e,t){return pn(e,t).reverse()}function mn(e){return Uint8Array.from(e)}var hn=e=>typeof e=="bigint"&&No<=e;function cl(e,t,r){return hn(e)&&hn(t)&&hn(r)&&t<=e&&e<r}function Br(e,t,r,n){if(!cl(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Ko(e){let t;for(t=0;e>No;e>>=Lo,t+=1);return t}var Ir=e=>(Lo<<BigInt(e))-Lo;function Ws(e,t,r){if(Ht(e,"hashLen"),Ht(t,"qByteLen"),typeof r!="function")throw new Error("hmacFn must be a function");let n=B=>new Uint8Array(B),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=n(e),l=n(e),u=0,f=()=>{c.fill(1),l.fill(0),u=0},x=(...B)=>r(l,bt(c,...B)),v=(B=o)=>{l=x(i,B),c=x(),B.length!==0&&(l=x(s,B),c=x())},b=()=>{if(u++>=a)throw new Error("drbg: tried max amount of iterations");let B=0,w=[];for(;B<t;){c=x();let T=c.slice();w.push(T),B+=c.length}return bt(...w)};return(B,w)=>{f(),v(B);let T;for(;!(T=w(b()));)v();return f(),T}}function fe(e,t={},r={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function n(i,s,a){let c=e[i];if(a&&c===void 0)return;let l=typeof c;if(l!==s||c===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${l}`)}let o=(i,s)=>Object.entries(i).forEach(([a,c])=>n(a,c,s));o(t,!1),o(r,!0)}function Ye(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let i=e(r,...n);return t.set(r,i),i}}var yt=BigInt(0),at=BigInt(1),Be=BigInt(2),Qs=BigInt(3),ta=BigInt(4),ea=BigInt(5),ul=BigInt(7),ra=BigInt(8),fl=BigInt(9),na=BigInt(16);function nt(e,t){let r=e%t;return r>=yt?r:t+r}function W(e,t,r){let n=e;for(;t-- >yt;)n*=n,n%=r;return n}function Xs(e,t){if(e===yt)throw new Error("invert: expected non-zero number");if(t<=yt)throw new Error("invert: expected positive modulus, got "+t);let r=nt(e,t),n=t,o=yt,i=at,s=at,a=yt;for(;r!==yt;){let l=n/r,u=n%r,f=o-s*l,x=i-a*l;n=r,r=u,o=s,i=a,s=f,a=x}if(n!==at)throw new Error("invert: does not exist");return nt(o,t)}function Mo(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function oa(e,t){let r=(e.ORDER+at)/ta,n=e.pow(t,r);return Mo(e,n,t),n}function ll(e,t){let r=(e.ORDER-ea)/ra,n=e.mul(t,Be),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,Be),o),a=e.mul(i,e.sub(s,e.ONE));return Mo(e,a,t),a}function dl(e){let t=We(e),r=ia(e),n=r(t,t.neg(t.ONE)),o=r(t,n),i=r(t,t.neg(n)),s=(e+ul)/na;return(a,c)=>{let l=a.pow(c,s),u=a.mul(l,n),f=a.mul(l,o),x=a.mul(l,i),v=a.eql(a.sqr(u),c),b=a.eql(a.sqr(f),c);l=a.cmov(l,u,v),u=a.cmov(x,f,b);let A=a.eql(a.sqr(u),c),B=a.cmov(l,u,A);return Mo(a,B,c),B}}function ia(e){if(e<Qs)throw new Error("sqrt is not defined for small field");let t=e-at,r=0;for(;t%Be===yt;)t/=Be,r++;let n=Be,o=We(e);for(;Js(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,t),s=(t+at)/Be;return function(c,l){if(c.is0(l))return l;if(Js(c,l)!==1)throw new Error("Cannot find square root");let u=r,f=c.mul(c.ONE,i),x=c.pow(l,t),v=c.pow(l,s);for(;!c.eql(x,c.ONE);){if(c.is0(x))return c.ZERO;let b=1,A=c.sqr(x);for(;!c.eql(A,c.ONE);)if(b++,A=c.sqr(A),b===u)throw new Error("Cannot find square root");let B=at<<BigInt(u-b-1),w=c.pow(f,B);u=b,f=c.sqr(w),x=c.mul(x,f),v=c.mul(v,w)}return v}}function hl(e){return e%ta===Qs?oa:e%ra===ea?ll:e%na===fl?dl(e):ia(e)}var sa=(e,t)=>(nt(e,t)&at)===at,pl=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Po(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=pl.reduce((n,o)=>(n[o]="function",n),t);return fe(e,r),e}function ml(e,t,r){if(r<yt)throw new Error("invalid exponent, negatives unsupported");if(r===yt)return e.ONE;if(r===at)return t;let n=e.ONE,o=t;for(;r>yt;)r&at&&(n=e.mul(n,o)),o=e.sqr(o),r>>=at;return n}function Tr(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((s,a,c)=>e.is0(a)?s:(n[c]=s,e.mul(s,a)),e.ONE),i=e.inv(o);return t.reduceRight((s,a,c)=>e.is0(a)?s:(n[c]=e.mul(s,n[c]),e.mul(s,a)),i),n}function Js(e,t){let r=(e.ORDER-at)/Be,n=e.pow(t,r),o=e.eql(n,e.ONE),i=e.eql(n,e.ZERO),s=e.eql(n,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function yl(e,t){t!==void 0&&Ht(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var Oo=class{ORDER;BITS;BYTES;isLE;ZERO=yt;ONE=at;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=yt)throw new Error("invalid field: expected ORDER > 0, got "+t);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}=yl(t,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=i,this._sqrt=void 0,Object.preventExtensions(this)}create(t){return nt(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return yt<=t&&t<this.ORDER}is0(t){return t===yt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&at)===at}neg(t){return nt(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return nt(t*t,this.ORDER)}add(t,r){return nt(t+r,this.ORDER)}sub(t,r){return nt(t-r,this.ORDER)}mul(t,r){return nt(t*r,this.ORDER)}pow(t,r){return ml(this,t,r)}div(t,r){return nt(t*Xs(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return Xs(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=hl(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?ko(t,this.BYTES):pn(t,this.BYTES)}fromBytes(t,r=!1){H(t);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:a}=this;if(n){if(!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let l=new Uint8Array(o);l.set(t,i?0:l.length-t.length),t=l}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let c=i?Ae(t):Ge(t);if(a&&(c=nt(c,s)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(t){return Tr(this,t)}cmov(t,r,n){return n?r:t}};function We(e,t={}){return new Oo(e,t)}function aa(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function Fo(e){let t=aa(e);return t+Math.ceil(t/2)}function Vo(e,t,r=!1){H(e);let n=e.length,o=aa(t),i=Fo(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Ae(e):Ge(e),a=nt(s,t-at)+at;return r?ko(a,o):pn(a,o)}var Xe=BigInt(0),Ie=BigInt(1);function _r(e,t){let r=t.negate();return e?r:t}function Te(e,t){let r=Tr(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function la(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function qo(e,t){la(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=Ir(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function ca(e,t,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,a=Number(e&o),c=e>>s;a>n&&(a-=i,c+=Ie);let l=t*n,u=l+Math.abs(a)-1,f=a===0,x=a<0,v=t%2!==0;return{nextN:c,offset:u,isZero:f,isNeg:x,isNegF:v,offsetF:l}}var Ho=new WeakMap,da=new WeakMap;function $o(e){return da.get(e)||1}function ua(e){if(e!==Xe)throw new Error("invalid wNAF")}var Je=class{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let o=t;for(;r>Xe;)r&Ie&&(n=n.add(o)),o=o.double(),r>>=Ie;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=qo(r,this.bits),i=[],s=t,a=s;for(let c=0;c<n;c++){a=s,i.push(a);for(let l=1;l<o;l++)a=a.add(s),i.push(a);s=a.double()}return i}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=qo(t,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:l,isZero:u,isNeg:f,isNegF:x,offsetF:v}=ca(n,a,s);n=c,u?i=i.add(_r(x,r[v])):o=o.add(_r(f,r[l]))}return ua(n),{p:o,f:i}}wNAFUnsafe(t,r,n,o=this.ZERO){let i=qo(t,this.bits);for(let s=0;s<i.windows&&n!==Xe;s++){let{nextN:a,offset:c,isZero:l,isNeg:u}=ca(n,s,i);if(n=a,!l){let f=r[c];o=o.add(u?f.negate():f)}}return ua(n),o}getPrecomputes(t,r,n){let o=Ho.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),Ho.set(r,o))),o}cached(t,r,n){let o=$o(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let i=$o(t);return i===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),r,o)}createCache(t,r){la(r,this.bits),da.set(t,r),Ho.delete(t)}hasCache(t){return $o(t)!==1}};function ha(e,t,r,n){let o=t,i=e.ZERO,s=e.ZERO;for(;r>Xe||n>Xe;)r&Ie&&(i=i.add(o)),n&Ie&&(s=s.add(o)),o=o.double(),r>>=Ie,n>>=Ie;return{p1:i,p2:s}}function fa(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Po(t),t}else return We(e,{isLE:r})}function yn(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let l=t[c];if(!(typeof l=="bigint"&&l>Xe))throw new Error(`CURVE.${c} must be positive bigint`)}let o=fa(t.p,r.Fp,n),i=fa(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:i}}function gn(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var le=BigInt(0),ct=BigInt(1),zo=BigInt(2),gl=BigInt(8);function bl(e,t,r,n){let o=e.sqr(r),i=e.sqr(n),s=e.add(e.mul(t.a,o),i),a=e.add(e.ONE,e.mul(t.d,e.mul(o,i)));return e.eql(s,a)}function pa(e,t={}){let r=yn("edwards",e,t,t.FpFnLE),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s}=i;fe(t,{},{uvRatio:"function"});let a=zo<<BigInt(o.BYTES*8)-ct,c=B=>n.create(B),l=t.uvRatio||((B,w)=>{try{return{isValid:!0,value:n.sqrt(n.div(B,w))}}catch{return{isValid:!1,value:le}}});if(!bl(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function u(B,w,T=!1){let E=T?ct:le;return Br("coordinate "+B,w,E,a),w}function f(B){if(!(B instanceof b))throw new Error("EdwardsPoint expected")}let x=Ye((B,w)=>{let{X:T,Y:E,Z:U}=B,K=B.is0();w==null&&(w=K?gl:n.inv(U));let M=c(T*w),F=c(E*w),p=n.mul(U,w);if(K)return{x:le,y:ct};if(p!==ct)throw new Error("invZ was invalid");return{x:M,y:F}}),v=Ye(B=>{let{a:w,d:T}=i;if(B.is0())throw new Error("bad point: ZERO");let{X:E,Y:U,Z:K,T:M}=B,F=c(E*E),p=c(U*U),m=c(K*K),C=c(m*m),R=c(F*w),I=c(m*c(R+p)),y=c(C+c(T*c(F*p)));if(I!==y)throw new Error("bad point: equation left != right (1)");let g=c(E*U),d=c(K*M);if(g!==d)throw new Error("bad point: equation left != right (2)");return!0});class b{static BASE=new b(i.Gx,i.Gy,ct,c(i.Gx*i.Gy));static ZERO=new b(le,ct,ct,le);static Fp=n;static Fn=o;X;Y;Z;T;constructor(w,T,E,U){this.X=u("x",w),this.Y=u("y",T),this.Z=u("z",E,!0),this.T=u("t",U),Object.freeze(this)}static CURVE(){return i}static fromAffine(w){if(w instanceof b)throw new Error("extended point not allowed");let{x:T,y:E}=w||{};return u("x",T),u("y",E),new b(T,E,ct,c(T*E))}static fromBytes(w,T=!1){let E=n.BYTES,{a:U,d:K}=i;w=mn(H(w,E,"point")),te(T,"zip215");let M=mn(w),F=w[E-1];M[E-1]=F&-129;let p=Ae(M),m=T?a:n.ORDER;Br("point.y",p,le,m);let C=c(p*p),R=c(C-ct),I=c(K*C-U),{isValid:y,value:g}=l(R,I);if(!y)throw new Error("bad point: invalid y coordinate");let d=(g&ct)===ct,S=(F&128)!==0;if(!T&&g===le&&S)throw new Error("bad point: x=0 and x_0=1");return S!==d&&(g=c(-g)),b.fromAffine({x:g,y:p})}static fromHex(w,T=!1){return b.fromBytes(Jt(w),T)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,T=!0){return A.createCache(this,w),T||this.multiply(zo),this}assertValidity(){v(this)}equals(w){f(w);let{X:T,Y:E,Z:U}=this,{X:K,Y:M,Z:F}=w,p=c(T*F),m=c(K*U),C=c(E*F),R=c(M*U);return p===m&&C===R}is0(){return this.equals(b.ZERO)}negate(){return new b(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:w}=i,{X:T,Y:E,Z:U}=this,K=c(T*T),M=c(E*E),F=c(zo*c(U*U)),p=c(w*K),m=T+E,C=c(c(m*m)-K-M),R=p+M,I=R-F,y=p-M,g=c(C*I),d=c(R*y),S=c(C*y),D=c(I*R);return new b(g,d,D,S)}add(w){f(w);let{a:T,d:E}=i,{X:U,Y:K,Z:M,T:F}=this,{X:p,Y:m,Z:C,T:R}=w,I=c(U*p),y=c(K*m),g=c(F*E*R),d=c(M*C),S=c((U+K)*(p+m)-I-y),D=d-g,N=d+g,k=c(y-T*I),O=c(S*D),P=c(N*k),q=c(S*k),X=c(D*N);return new b(O,P,X,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:T,f:E}=A.cached(this,w,U=>Te(b,U));return Te(b,[T,E])[0]}multiplyUnsafe(w,T=b.ZERO){if(!o.isValid(w))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return w===le?b.ZERO:this.is0()||w===ct?this:A.unsafe(this,w,E=>Te(b,E),T)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return A.unsafe(this,i.n).is0()}toAffine(w){return x(this,w)}clearCofactor(){return s===ct?this:this.multiplyUnsafe(s)}toBytes(){let{x:w,y:T}=this.toAffine(),E=n.toBytes(T);return E[E.length-1]|=w&ct?128:0,E}toHex(){return Xt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let A=new Je(b,o.BITS);return b.BASE.precompute(8),b}function ma(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');fe(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:n}=r,{BASE:o,Fp:i,Fn:s}=e,a=r.randomBytes||Ze,c=r.adjustScalarBytes||(p=>p),l=r.domain||((p,m,C)=>{if(te(C,"phflag"),m.length||C)throw new Error("Contexts/pre-hash are not supported");return p});function u(p){return s.create(Ae(p))}function f(p){let m=E.secretKey;H(p,E.secretKey,"secretKey");let C=H(t(p),2*m,"hashedSecretKey"),R=c(C.slice(0,m)),I=C.slice(m,2*m),y=u(R);return{head:R,prefix:I,scalar:y}}function x(p){let{head:m,prefix:C,scalar:R}=f(p),I=o.multiply(R),y=I.toBytes();return{head:m,prefix:C,scalar:R,point:I,pointBytes:y}}function v(p){return x(p).pointBytes}function b(p=Uint8Array.of(),...m){let C=bt(...m);return u(t(l(C,H(p,void 0,"context"),!!n)))}function A(p,m,C={}){p=H(p,void 0,"message"),n&&(p=n(p));let{prefix:R,scalar:I,pointBytes:y}=x(m),g=b(C.context,R,p),d=o.multiply(g).toBytes(),S=b(C.context,d,y,p),D=s.create(g+S*I);if(!s.isValid(D))throw new Error("sign failed: invalid s");let N=bt(d,s.toBytes(D));return H(N,E.signature,"result")}let B={zip215:!0};function w(p,m,C,R=B){let{context:I,zip215:y}=R,g=E.signature;p=H(p,g,"signature"),m=H(m,void 0,"message"),C=H(C,E.publicKey,"publicKey"),y!==void 0&&te(y,"zip215"),n&&(m=n(m));let d=g/2,S=p.subarray(0,d),D=Ae(p.subarray(d,g)),N,k,O;try{N=e.fromBytes(C,y),k=e.fromBytes(S,y),O=o.multiplyUnsafe(D)}catch{return!1}if(!y&&N.isSmallOrder())return!1;let P=b(I,k.toBytes(),N.toBytes(),m);return k.add(N.multiplyUnsafe(P)).subtract(O).clearCofactor().is0()}let T=i.BYTES,E={secretKey:T,publicKey:T,signature:2*T,seed:T};function U(p=a(E.seed)){return H(p,E.seed,"seed")}function K(p){return Ee(p)&&p.length===s.BYTES}function M(p,m){try{return!!e.fromBytes(p,m)}catch{return!1}}let F={getExtendedPublicKey:x,randomSecretKey:U,isValidSecretKey:K,isValidPublicKey:M,toMontgomery(p){let{y:m}=e.fromBytes(p),C=E.publicKey,R=C===32;if(!R&&C!==57)throw new Error("only defined for 25519 and 448");let I=R?i.div(ct+m,ct-m):i.div(m-ct,m+ct);return i.toBytes(I)},toMontgomerySecret(p){let m=E.secretKey;H(p,m);let C=t(p.subarray(0,m));return c(C).subarray(0,m)}};return Object.freeze({keygen:gn(U,v),getPublicKey:v,sign:A,verify:w,utils:F,Point:e,lengths:E})}var xl=BigInt(1),ya=BigInt(2);var wl=BigInt(5),El=BigInt(8),Zo=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Sl={p:Zo,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:El,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function vl(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=Zo,a=e*e%i*e%i,c=W(a,ya,i)*a%i,l=W(c,xl,i)*e%i,u=W(l,wl,i)*l%i,f=W(u,t,i)*u%i,x=W(f,r,i)*f%i,v=W(x,n,i)*x%i,b=W(v,o,i)*v%i,A=W(b,o,i)*v%i,B=W(A,t,i)*u%i;return{pow_p_5_8:W(B,ya,i)*e%i,b2:a}}function Al(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var ga=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Bl(e,t){let r=Zo,n=nt(t*t*t,r),o=nt(n*n*t,r),i=vl(e*o).pow_p_5_8,s=nt(e*n*i,r),a=nt(t*s*s,r),c=s,l=nt(s*ga,r),u=a===e,f=a===nt(-e,r),x=a===nt(-e*ga,r);return u&&(s=c),(f||x)&&(s=l),sa(s,r)&&(s=nt(-s,r)),{isValid:u||f,value:s}}var Il=pa(Sl,{uvRatio:Bl});function Tl(e){return ma(Il,js,Object.assign({adjustScalarBytes:Al},e))}var Cr=Tl({});var Ur=class extends Error{constructor(t="An error occurred while signing a message"){super(t),this.name="SigningError"}},Rr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},bn=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var ba={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new bn("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var xt=ba;var _e=32,At=64,jo=32;var Qe,xa=(async()=>{try{return await xt.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();function wa(){let e=Cr.utils.randomSecretKey(),t=Cr.getPublicKey(e);return{privateKey:Dl(e,t),publicKey:t}}async function _l(e,t){let r;e.length===At?r=e.subarray(0,32):r=e;let n={crv:"Ed25519",kty:"OKP",x:j(e.subarray(32),"base64url"),d:j(r,"base64url"),ext:!0,key_ops:["sign"]},o=await xt.get().subtle.importKey("jwk",n,{name:"Ed25519"},!0,["sign"]),i=await xt.get().subtle.sign({name:"Ed25519"},o,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(i,0,i.byteLength)}function Cl(e,t){let r=e.subarray(0,jo);return Cr.sign(t instanceof Uint8Array?t:t.subarray(),r)}async function Ea(e,t){return Qe==null&&(Qe=await xa),Qe?_l(e,t):Cl(e,t)}async function Ul(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await xt.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await xt.get().subtle.verify({name:"Ed25519"},n,t,r instanceof Uint8Array?r:r.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Rl(e,t,r){return Cr.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function Sa(e,t,r){return Qe==null&&(Qe=await xa),Qe?Ul(e,t,r):Rl(e,t,r)}function Dl(e,t){let r=new Uint8Array(At);for(let n=0;n<jo;n++)r[n]=e[n],r[jo+n]=t[n];return r}function tr(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var Dr=class{type="Ed25519";raw;constructor(t){this.raw=rr(t,_e)}toMultihash(){return ge.digest(se(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return ot.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=Sa(this.raw,r,t);return tr(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}},er=class{type="Ed25519";raw;publicKey;constructor(t,r){this.raw=rr(t,At),this.publicKey=new Dr(r)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}sign(t,r){r?.signal?.throwIfAborted();let n=Ea(this.raw,t);return tr(n)?n.then(o=>(r?.signal?.throwIfAborted(),o)):(r?.signal?.throwIfAborted(),n)}};function Go(e){if(e.length>At){e=rr(e,At+_e);let n=e.subarray(0,At),o=e.subarray(At,e.length);return new er(n,o)}e=rr(e,At);let t=e.subarray(0,At),r=e.subarray(_e);return new er(t,r)}function Aa(e){return e=rr(e,_e),new Dr(e)}async function Ba(){let{privateKey:e,publicKey:t}=wa();return new er(e,t)}function rr(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new rt(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var Ll=Math.pow(2,7),Nl=Math.pow(2,14),kl=Math.pow(2,21),Ia=Math.pow(2,28),Ta=Math.pow(2,35),_a=Math.pow(2,42),Ca=Math.pow(2,49),gt=128,de=127;function Lr(e){if(e<Ll)return 1;if(e<Nl)return 2;if(e<kl)return 3;if(e<Ia)return 4;if(e<Ta)return 5;if(e<_a)return 6;if(e<Ca)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Ua(e,t,r=0){switch(Lr(e)){case 8:t[r++]=e&255|gt,e/=128;case 7:t[r++]=e&255|gt,e/=128;case 6:t[r++]=e&255|gt,e/=128;case 5:t[r++]=e&255|gt,e/=128;case 4:t[r++]=e&255|gt,e>>>=7;case 3:t[r++]=e&255|gt,e>>>=7;case 2:t[r++]=e&255|gt,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Ra(e,t){let r=e[t],n=0;if(n+=r&de,r<gt||(r=e[t+1],n+=(r&de)<<7,r<gt)||(r=e[t+2],n+=(r&de)<<14,r<gt)||(r=e[t+3],n+=(r&de)<<21,r<gt)||(r=e[t+4],n+=(r&de)*Ia,r<gt)||(r=e[t+5],n+=(r&de)*Ta,r<gt)||(r=e[t+6],n+=(r&de)*_a,r<gt)||(r=e[t+7],n+=(r&de)*Ca,r<gt))return n;throw new RangeError("Could not decode varint")}var Yo=new Float32Array([-0]),he=new Uint8Array(Yo.buffer);function Da(e,t,r){Yo[0]=e,t[r]=he[0],t[r+1]=he[1],t[r+2]=he[2],t[r+3]=he[3]}function La(e,t){return he[0]=e[t],he[1]=e[t+1],he[2]=e[t+2],he[3]=e[t+3],Yo[0]}var Wo=new Float64Array([-0]),ht=new Uint8Array(Wo.buffer);function Na(e,t,r){Wo[0]=e,t[r]=ht[0],t[r+1]=ht[1],t[r+2]=ht[2],t[r+3]=ht[3],t[r+4]=ht[4],t[r+5]=ht[5],t[r+6]=ht[6],t[r+7]=ht[7]}function ka(e,t){return ht[0]=e[t],ht[1]=e[t+1],ht[2]=e[t+2],ht[3]=e[t+3],ht[4]=e[t+4],ht[5]=e[t+5],ht[6]=e[t+6],ht[7]=e[t+7],Wo[0]}var Kl=BigInt(Number.MAX_SAFE_INTEGER),Ol=BigInt(Number.MIN_SAFE_INTEGER),Bt=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Ce;if(t<Kl&&t>Ol)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>Ka&&(o=0n,++n>Ka&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Ce;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):Ce}},Ce=new Bt(0,0);Ce.toBigInt=function(){return 0n};Ce.zzEncode=Ce.zzDecode=function(){return this};Ce.length=function(){return 1};var Ka=4294967296n;function Oa(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Ma(e,t,r){if(r-t<1)return"";let o,i=[],s=0,a;for(;t<r;)a=e[t++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|e[t++]&63:a>239&&a<365?(a=((a&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(e[t++]&63)<<6|e[t++]&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 Xo(e,t,r){let n=r,o,i;for(let s=0;s<e.length;++s)o=e.charCodeAt(s),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((i=e.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function Kt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function xn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Jo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Kt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Kt(this,4);return xn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Kt(this,4);return xn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Kt(this,4);let t=La(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Kt(this,4);let t=ka(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw Kt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Ma(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Kt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Kt(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new Bt(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Kt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw Kt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Kt(this,8);let t=xn(this.buf,this.pos+=4),r=xn(this.buf,this.pos+=4);return new Bt(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Ra(this.buf,this.pos);return this.pos+=Lr(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Qo(e){return new Jo(e instanceof Uint8Array?e:e.subarray())}function nr(e,t,r){let n=Qo(e);return t.decode(n,void 0,r)}function ti(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return vt(s);o+s>t&&(n=vt(t),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var Ue=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function ei(){}var ni=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Ml=ti();function Pl(e){return globalThis.Buffer!=null?vt(e):Ml(e)}var kr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Ue(ei,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new Ue(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new oi((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(wn,10,Bt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Bt.fromBigInt(t);return this._push(wn,r.length(),r)}uint64Number(t){return this._push(Ua,Lr(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let r=Bt.fromBigInt(t).zzEncode();return this._push(wn,r.length(),r)}sint64Number(t){let r=Bt.fromNumber(t).zzEncode();return this._push(wn,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(ri,1,t?1:0)}fixed32(t){return this._push(Nr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Bt.fromBigInt(t);return this._push(Nr,4,r.lo)._push(Nr,4,r.hi)}fixed64Number(t){let r=Bt.fromNumber(t);return this._push(Nr,4,r.lo)._push(Nr,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Da,4,t)}double(t){return this._push(Na,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(ri,1,0):this.uint32(r)._push(Vl,r,t)}string(t){let r=Oa(t);return r!==0?this.uint32(r)._push(Xo,r,t):this._push(ri,1,0)}fork(){return this.states=new ni(this),this.head=this.tail=new Ue(ei,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 Ue(ei,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=Pl(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function ri(e,t,r){t[r]=e&255}function Fl(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var oi=class extends Ue{next;constructor(t,r){super(Fl,t,r),this.next=void 0}};function wn(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function Nr(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function Vl(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(kr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(ql,t,e),this},kr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Hl,t,e),this});function ql(e,t,r){t.set(e,r)}function Hl(e,t,r){e.length<40?Xo(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(Z(e),r)}function ii(){return new kr}function or(e,t){let r=ii();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var ir;(function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"})(ir||(ir={}));function En(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Kr(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(i,s){let a=t(i);s.int32(a)},n=function(i){let s=i.int32();return t(s)};return En("enum",ir.VARINT,r,n)}function sr(e,t){return En("message",ir.LENGTH_DELIMITED,e,t)}var et;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(et||(et={}));var si;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(si||(si={}));(function(e){e.codec=()=>Kr(si)})(et||(et={}));var ee;(function(e){let t;e.codec=()=>(t==null&&(t=sr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),et.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 a=r.uint32();switch(a>>>3){case 1:{i.Type=et.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>or(r,e.codec()),e.decode=(r,n)=>nr(r,e.codec(),n)})(ee||(ee={}));var Sn;(function(e){let t;e.codec=()=>(t==null&&(t=sr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),et.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 a=r.uint32();switch(a>>>3){case 1:{i.Type=et.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>or(r,e.codec()),e.decode=(r,n)=>nr(r,e.codec(),n)})(Sn||(Sn={}));var Mr={};St(Mr,{MAX_RSA_KEY_SIZE:()=>ai,generateRSAKeyPair:()=>yi,jwkToJWKKeyPair:()=>Ha,jwkToPkcs1:()=>jl,jwkToPkix:()=>li,jwkToRSAPrivateKey:()=>mi,pkcs1MessageToJwk:()=>ui,pkcs1MessageToRSAPrivateKey:()=>vn,pkcs1ToJwk:()=>Zl,pkcs1ToRSAPrivateKey:()=>di,pkixMessageToJwk:()=>fi,pkixMessageToRSAPublicKey:()=>pi,pkixToJwk:()=>Gl,pkixToRSAPublicKey:()=>hi});var ar=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=Mr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return it.createV1(114,this._multihash)}toString(){return ot.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}verify(t,r,n){return qa(this.jwk,r,t,n)}},Or=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=Mr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}sign(t,r){return Va(this.jwk,t,r)}};var ai=8192,ci=18,$l=1062,zl=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Zl(e){let t=Ut(e);return ui(t)}function ui(e){return{n:j(e[1],"base64url"),e:j(e[2],"base64url"),d:j(e[3],"base64url"),p:j(e[4],"base64url"),q:j(e[5],"base64url"),dp:j(e[6],"base64url"),dq:j(e[7],"base64url"),qi:j(e[8],"base64url"),kty:"RSA"}}function jl(e){if(e.n==null||e.e==null||e.d==null||e.p==null||e.q==null||e.dp==null||e.dq==null||e.qi==null)throw new rt("JWK was missing components");return Nt([mt(Uint8Array.from([0])),mt(Z(e.n,"base64url")),mt(Z(e.e,"base64url")),mt(Z(e.d,"base64url")),mt(Z(e.p,"base64url")),mt(Z(e.q,"base64url")),mt(Z(e.dp,"base64url")),mt(Z(e.dq,"base64url")),mt(Z(e.qi,"base64url"))]).subarray()}function Gl(e){let t=Ut(e,{offset:0});return fi(t)}function fi(e){let t=Ut(e[1],{offset:0});return{kty:"RSA",n:j(t[0],"base64url"),e:j(t[1],"base64url")}}function li(e){if(e.n==null||e.e==null)throw new rt("JWK was missing components");return Nt([zl,wr(Nt([mt(Z(e.n,"base64url")),mt(Z(e.e,"base64url"))]))]).subarray()}function di(e){let t=Ut(e);return vn(t)}function vn(e){let t=ui(e);return mi(t)}function hi(e,t){if(e.byteLength>=$l)throw new ke("Key size is too large");let r=Ut(e,{offset:0});return pi(r,e,t)}function pi(e,t,r){let n=fi(e);if(r==null){let o=je(ee.encode({Type:et.RSA,Data:t}));r=qt(ci,o)}return new ar(n,r)}function mi(e){if(za(e)>ai)throw new rt("Key size is too large");let t=Ha(e),r=je(ee.encode({Type:et.RSA,Data:li(t.publicKey)})),n=qt(ci,r);return new Or(t.privateKey,new ar(t.publicKey,n))}async function yi(e){if(e>ai)throw new rt("Key size is too large");let t=await $a(e),r=je(ee.encode({Type:et.RSA,Data:li(t.publicKey)})),n=qt(ci,r);return new Or(t.privateKey,new ar(t.publicKey,n))}function Ha(e){if(e==null)throw new rt("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function $a(e,t){let r=await xt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);t?.signal?.throwIfAborted();let n=await Yl(r,t);return{privateKey:n[0],publicKey:n[1]}}async function Va(e,t,r){let n=await xt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await xt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,t instanceof Uint8Array?t:t.subarray());return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function qa(e,t,r,n){let o=await xt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await xt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,t,r instanceof Uint8Array?r:r.subarray());return n?.signal?.throwIfAborted(),i}async function Yl(e,t){if(e.privateKey==null||e.publicKey==null)throw new rt("Private and public key are required");let r=await Promise.all([xt.get().subtle.exportKey("jwk",e.privateKey),xt.get().subtle.exportKey("jwk",e.publicKey)]);return t?.signal?.throwIfAborted(),r}function za(e){if(e.kty!=="RSA")throw new rt("invalid key type");if(e.n==null)throw new rt("invalid key modulus");return Z(e.n,"base64url").length*8}var An=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(t,r){if(fn(t),H(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=t.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),Wt(o)}update(t){return ze(this),this.iHash.update(t),this}digestInto(t){ze(this),H(t,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},gi=(e,t,r)=>new An(e,t).update(r).digest();gi.create=(e,t)=>new An(e,t);var Za=(e,t)=>(e+(e>=0?t:-t)/ja)/t;function Wl(e,t,r){let[[n,o],[i,s]]=t,a=Za(s*e,r),c=Za(-o*e,r),l=e-a*n-c*i,u=-a*o-c*s,f=l<re,x=u<re;f&&(l=-l),x&&(u=-u);let v=Ir(Math.ceil(Ko(r)/2))+cr;if(l<re||l>=v||u<re||u>=v)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:l,k2neg:x,k2:u}}function xi(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function bi(e,t){let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return te(r.lowS,"lowS"),te(r.prehash,"prehash"),r.format!==void 0&&xi(r.format),r}var wi=class extends Error{constructor(t=""){super(t)}},pe={Err:wi,_tlv:{encode:(e,t)=>{let{Err:r}=pe;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=Ar(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Ar(o.length/2|128):"";return Ar(e)+i+o+t},decode(e,t){let{Err:r}=pe,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=pe;if(e<re)throw new t("integer: negative integers are not allowed");let r=Ar(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=pe;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Ge(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=pe,o=H(e,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:l,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=pe,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},re=BigInt(0),cr=BigInt(1),ja=BigInt(2),Bn=BigInt(3),Xl=BigInt(4);function Ga(e,t={}){let r=yn("weierstrass",e,t),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s,n:a}=i;fe(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=t;if(c&&(!n.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let l=Wa(n,o);function u(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function f(I,y,g){let{x:d,y:S}=y.toAffine(),D=n.toBytes(d);if(te(g,"isCompressed"),g){u();let N=!n.isOdd(S);return bt(Ya(N),D)}else return bt(Uint8Array.of(4),D,n.toBytes(S))}function x(I){H(I,void 0,"Point");let{publicKey:y,publicKeyUncompressed:g}=l,d=I.length,S=I[0],D=I.subarray(1);if(d===y&&(S===2||S===3)){let N=n.fromBytes(D);if(!n.isValid(N))throw new Error("bad point: is not on curve, wrong x");let k=A(N),O;try{O=n.sqrt(k)}catch(X){let Y=X instanceof Error?": "+X.message:"";throw new Error("bad point: is not on curve, sqrt error"+Y)}u();let P=n.isOdd(O);return(S&1)===1!==P&&(O=n.neg(O)),{x:N,y:O}}else if(d===g&&S===4){let N=n.BYTES,k=n.fromBytes(D.subarray(0,N)),O=n.fromBytes(D.subarray(N,N*2));if(!B(k,O))throw new Error("bad point: is not on curve");return{x:k,y:O}}else throw new Error(`bad point: got length ${d}, expected compressed=${y} or uncompressed=${g}`)}let v=t.toBytes||f,b=t.fromBytes||x;function A(I){let y=n.sqr(I),g=n.mul(y,I);return n.add(n.add(g,n.mul(I,i.a)),i.b)}function B(I,y){let g=n.sqr(y),d=A(I);return n.eql(g,d)}if(!B(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let w=n.mul(n.pow(i.a,Bn),Xl),T=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(w,T)))throw new Error("bad curve params: a or b");function E(I,y,g=!1){if(!n.isValid(y)||g&&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 K(I){if(!c||!c.basises)throw new Error("no endo");return Wl(I,c.basises,o.ORDER)}let M=Ye((I,y)=>{let{X:g,Y:d,Z:S}=I;if(n.eql(S,n.ONE))return{x:g,y:d};let D=I.is0();y==null&&(y=D?n.ONE:n.inv(S));let N=n.mul(g,y),k=n.mul(d,y),O=n.mul(S,y);if(D)return{x:n.ZERO,y:n.ZERO};if(!n.eql(O,n.ONE))throw new Error("invZ was invalid");return{x:N,y:k}}),F=Ye(I=>{if(I.is0()){if(t.allowInfinityPoint&&!n.is0(I.Y))return;throw new Error("bad point: ZERO")}let{x:y,y:g}=I.toAffine();if(!n.isValid(y)||!n.isValid(g))throw new Error("bad point: x or y not field elements");if(!B(y,g))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,g,d,S){return g=new m(n.mul(g.X,I),g.Y,g.Z),y=_r(d,y),g=_r(S,g),y.add(g)}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,g,d){this.X=E("x",y),this.Y=E("y",g,!0),this.Z=E("z",d),Object.freeze(this)}static CURVE(){return i}static fromAffine(y){let{x:g,y:d}=y||{};if(!y||!n.isValid(g)||!n.isValid(d))throw new Error("invalid affine point");if(y instanceof m)throw new Error("projective point not allowed");return n.is0(g)&&n.is0(d)?m.ZERO:new m(g,d,n.ONE)}static fromBytes(y){let g=m.fromAffine(b(H(y,void 0,"point")));return g.assertValidity(),g}static fromHex(y){return m.fromBytes(Jt(y))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,g=!0){return R.createCache(this,y),g||this.multiply(Bn),this}assertValidity(){F(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:g,Y:d,Z:S}=this,{X:D,Y:N,Z:k}=y,O=n.eql(n.mul(g,k),n.mul(D,S)),P=n.eql(n.mul(d,k),n.mul(N,S));return O&&P}negate(){return new m(this.X,n.neg(this.Y),this.Z)}double(){let{a:y,b:g}=i,d=n.mul(g,Bn),{X:S,Y:D,Z:N}=this,k=n.ZERO,O=n.ZERO,P=n.ZERO,q=n.mul(S,S),X=n.mul(D,D),Y=n.mul(N,N),$=n.mul(S,D);return $=n.add($,$),P=n.mul(S,N),P=n.add(P,P),k=n.mul(y,P),O=n.mul(d,Y),O=n.add(k,O),k=n.sub(X,O),O=n.add(X,O),O=n.mul(k,O),k=n.mul($,k),P=n.mul(d,P),Y=n.mul(y,Y),$=n.sub(q,Y),$=n.mul(y,$),$=n.add($,P),P=n.add(q,q),q=n.add(P,q),q=n.add(q,Y),q=n.mul(q,$),O=n.add(O,q),Y=n.mul(D,N),Y=n.add(Y,Y),q=n.mul(Y,$),k=n.sub(k,q),P=n.mul(Y,X),P=n.add(P,P),P=n.add(P,P),new m(k,O,P)}add(y){U(y);let{X:g,Y:d,Z:S}=this,{X:D,Y:N,Z:k}=y,O=n.ZERO,P=n.ZERO,q=n.ZERO,X=i.a,Y=n.mul(i.b,Bn),$=n.mul(g,D),J=n.mul(d,N),ft=n.mul(S,k),Vt=n.add(g,d),Q=n.add(D,N);Vt=n.mul(Vt,Q),Q=n.add($,J),Vt=n.sub(Vt,Q),Q=n.add(g,S);let dt=n.add(D,k);return Q=n.mul(Q,dt),dt=n.add($,ft),Q=n.sub(Q,dt),dt=n.add(d,S),O=n.add(N,k),dt=n.mul(dt,O),O=n.add(J,ft),dt=n.sub(dt,O),q=n.mul(X,Q),O=n.mul(Y,ft),q=n.add(O,q),O=n.sub(J,q),q=n.add(J,q),P=n.mul(O,q),J=n.add($,$),J=n.add(J,$),ft=n.mul(X,ft),Q=n.mul(Y,Q),J=n.add(J,ft),ft=n.sub($,ft),ft=n.mul(X,ft),Q=n.add(Q,ft),$=n.mul(J,Q),P=n.add(P,$),$=n.mul(dt,Q),O=n.mul(Vt,O),O=n.sub(O,$),$=n.mul(Vt,J),q=n.mul(dt,q),q=n.add(q,$),new m(O,P,q)}subtract(y){return this.add(y.negate())}is0(){return this.equals(m.ZERO)}multiply(y){let{endo:g}=t;if(!o.isValidNot0(y))throw new Error("invalid scalar: out of range");let d,S,D=N=>R.cached(this,N,k=>Te(m,k));if(g){let{k1neg:N,k1:k,k2neg:O,k2:P}=K(y),{p:q,f:X}=D(k),{p:Y,f:$}=D(P);S=X.add($),d=p(g.beta,q,Y,N,O)}else{let{p:N,f:k}=D(y);d=N,S=k}return Te(m,[d,S])[0]}multiplyUnsafe(y){let{endo:g}=t,d=this;if(!o.isValid(y))throw new Error("invalid scalar: out of range");if(y===re||d.is0())return m.ZERO;if(y===cr)return d;if(R.hasCache(this))return this.multiply(y);if(g){let{k1neg:S,k1:D,k2neg:N,k2:k}=K(y),{p1:O,p2:P}=ha(m,d,D,k);return p(g.beta,O,P,S,N)}else return R.unsafe(d,y)}toAffine(y){return M(this,y)}isTorsionFree(){let{isTorsionFree:y}=t;return s===cr?!0:y?y(m,this):R.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:y}=t;return s===cr?this:y?y(m,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(y=!0){return te(y,"isCompressed"),this.assertValidity(),v(m,this,y)}toHex(y=!0){return Xt(this.toBytes(y))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let C=o.BITS,R=new Je(m,t.endo?Math.ceil(C/2):C);return m.BASE.precompute(8),m}function Ya(e){return Uint8Array.of(e?2:3)}function Wa(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Jl(e,t={}){let{Fn:r}=e,n=t.randomBytes||Ze,o=Object.assign(Wa(e.Fp,r),{seed:Fo(r.ORDER)});function i(v){try{let b=r.fromBytes(v);return r.isValidNot0(b)}catch{return!1}}function s(v,b){let{publicKey:A,publicKeyUncompressed:B}=o;try{let w=v.length;return b===!0&&w!==A||b===!1&&w!==B?!1:!!e.fromBytes(v)}catch{return!1}}function a(v=n(o.seed)){return Vo(H(v,o.seed,"seed"),r.ORDER)}function c(v,b=!0){return e.BASE.multiply(r.fromBytes(v)).toBytes(b)}function l(v){let{secretKey:b,publicKey:A,publicKeyUncompressed:B}=o;if(!Ee(v)||"_lengths"in r&&r._lengths||b===A)return;let w=H(v,void 0,"key").length;return w===A||w===B}function u(v,b,A=!0){if(l(v)===!0)throw new Error("first arg must be private key");if(l(b)===!1)throw new Error("second arg must be public key");let B=r.fromBytes(v);return e.fromBytes(b).multiply(B).toBytes(A)}let f={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},x=gn(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:x,Point:e,utils:f,lengths:o})}function Xa(e,t,r={}){fn(t),fe(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||Ze,o=r.hmac||((g,d)=>gi(t,g,d)),{Fp:i,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:l,getPublicKey:u,getSharedSecret:f,utils:x,lengths:v}=Jl(e,r),b={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},A=a*ja<i.ORDER;function B(g){let d=a>>cr;return g>d}function w(g,d){if(!s.isValidNot0(d))throw new Error(`invalid signature ${g}: out of range 1..Point.Fn.ORDER`);return d}function T(){if(A)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function E(g,d){xi(d);let S=v.signature,D=d==="compact"?S:d==="recovered"?S+1:void 0;return H(g,D)}class U{r;s;recovery;constructor(d,S,D){if(this.r=w("r",d),this.s=w("s",S),D!=null){if(T(),![0,1,2,3].includes(D))throw new Error("invalid recovery id");this.recovery=D}Object.freeze(this)}static fromBytes(d,S=b.format){E(d,S);let D;if(S==="der"){let{r:P,s:q}=pe.toSig(H(d));return new U(P,q)}S==="recovered"&&(D=d[0],S="compact",d=d.subarray(1));let N=v.signature/2,k=d.subarray(0,N),O=d.subarray(N,N*2);return new U(s.fromBytes(k),s.fromBytes(O),D)}static fromHex(d,S){return this.fromBytes(Jt(d),S)}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:S,s:D}=this,N=this.assertRecovery(),k=N===2||N===3?S+a:S;if(!i.isValid(k))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let O=i.toBytes(k),P=e.fromBytes(bt(Ya((N&1)===0),O)),q=s.inv(k),X=M(H(d,void 0,"msgHash")),Y=s.create(-X*q),$=s.create(D*q),J=e.BASE.multiplyUnsafe(Y).add(P.multiplyUnsafe($));if(J.is0())throw new Error("invalid recovery: point at infinify");return J.assertValidity(),J}hasHighS(){return B(this.s)}toBytes(d=b.format){if(xi(d),d==="der")return Jt(pe.hexFromSig(this));let{r:S,s:D}=this,N=s.toBytes(S),k=s.toBytes(D);return d==="recovered"?(T(),bt(Uint8Array.of(this.assertRecovery()),N,k)):bt(N,k)}toHex(d){return Xt(this.toBytes(d))}}let K=r.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");let S=Ge(d),D=d.length*8-c;return D>0?S>>BigInt(D):S},M=r.bits2int_modN||function(d){return s.create(K(d))},F=Ir(c);function p(g){return Br("num < 2^"+c,g,re,F),s.toBytes(g)}function m(g,d){return H(g,void 0,"message"),d?H(t(g),void 0,"prehashed message"):g}function C(g,d,S){let{lowS:D,prehash:N,extraEntropy:k}=bi(S,b);g=m(g,N);let O=M(g),P=s.fromBytes(d);if(!s.isValidNot0(P))throw new Error("invalid private key");let q=[p(P),p(O)];if(k!=null&&k!==!1){let J=k===!0?n(v.secretKey):k;q.push(H(J,void 0,"extraEntropy"))}let X=bt(...q),Y=O;function $(J){let ft=K(J);if(!s.isValidNot0(ft))return;let Vt=s.inv(ft),Q=e.BASE.multiply(ft).toAffine(),dt=s.create(Q.x);if(dt===re)return;let rn=s.create(Vt*s.create(Y+dt*P));if(rn===re)return;let Hi=(Q.x===dt?0:2)|Number(Q.y&cr),$i=rn;return D&&B(rn)&&($i=s.neg(rn),Hi^=1),new U(dt,$i,A?void 0:Hi)}return{seed:X,k2sig:$}}function R(g,d,S={}){let{seed:D,k2sig:N}=C(g,d,S);return Ws(t.outputLen,s.BYTES,o)(D,N).toBytes(S.format)}function I(g,d,S,D={}){let{lowS:N,prehash:k,format:O}=bi(D,b);if(S=H(S,void 0,"publicKey"),d=m(d,k),!Ee(g)){let P=g instanceof U?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+P)}E(g,O);try{let P=U.fromBytes(g,O),q=e.fromBytes(S);if(N&&P.hasHighS())return!1;let{r:X,s:Y}=P,$=M(d),J=s.inv(Y),ft=s.create($*J),Vt=s.create(X*J),Q=e.BASE.multiplyUnsafe(ft).add(q.multiplyUnsafe(Vt));return Q.is0()?!1:s.create(Q.x)===X}catch{return!1}}function y(g,d,S={}){let{prehash:D}=bi(S,b);return d=m(d,D),U.fromBytes(g,"recovered").recoverPublicKey(d).toBytes()}return Object.freeze({keygen:l,getPublicKey:u,getSharedSecret:f,utils:x,lengths:v,Point:e,sign:R,verify:I,recoverPublicKey:y,Signature:U,hash:t})}var Si={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Ql={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Ja=BigInt(2);function td(e){let t=Si.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,f=W(u,r,t)*u%t,x=W(f,r,t)*u%t,v=W(x,Ja,t)*l%t,b=W(v,o,t)*v%t,A=W(b,i,t)*b%t,B=W(A,a,t)*A%t,w=W(B,c,t)*B%t,T=W(w,a,t)*A%t,E=W(T,r,t)*u%t,U=W(E,s,t)*b%t,K=W(U,n,t)*l%t,M=W(K,Ja,t);if(!Ei.eql(Ei.sqr(M),e))throw new Error("Cannot find square root");return M}var Ei=We(Si.p,{sqrt:td}),ed=Ga(Si,{Fp:Ei,endo:Ql}),Ot=Xa(ed,je);var Qa=32;function tc(e,t,r){let n=an.digest(t instanceof Uint8Array?t:t.subarray());if(tr(n))return n.then(({digest:o})=>(r?.signal?.throwIfAborted(),Ot.sign(o,e,{prehash:!1,format:"der"}))).catch(o=>{throw o.name==="AbortError"?o:new Ur(String(o))});try{return Ot.sign(n.digest,e,{prehash:!1,format:"der"})}catch(o){throw new Ur(String(o))}}function ec(e,t,r,n){let o=an.digest(r instanceof Uint8Array?r:r.subarray());if(tr(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),Ot.verify(t,i,e,{prehash:!1,format:"der"}))).catch(i=>{throw i.name==="AbortError"?i:new Rr(String(i))});try{return n?.signal?.throwIfAborted(),Ot.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(i){throw new Rr(String(i))}}var Pr=class{type="secp256k1";raw;_key;constructor(t){this._key=oc(t),this.raw=rc(this._key)}toMultihash(){return ge.digest(se(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return ot.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}verify(t,r,n){return ec(this._key,r,t,n)}},Fr=class{type="secp256k1";raw;publicKey;constructor(t,r){this.raw=nc(t),this.publicKey=new Pr(r??ic(t))}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}sign(t,r){return tc(this.raw,t,r)}};function vi(e){return new Fr(e)}function sc(e){return new Pr(e)}async function ac(){let e=rd();return new Fr(e)}function rc(e){return Ot.Point.fromBytes(e).toBytes()}function nc(e){try{return Ot.getPublicKey(e,!0),e}catch(t){throw new pr(String(t))}}function oc(e){try{return Ot.Point.fromBytes(e),e}catch(t){throw new ke(String(t))}}function ic(e){try{return Ot.getPublicKey(e,!0)}catch(t){throw new pr(String(t))}}function rd(){return Ot.utils.randomSecretKey()}async function cc(e,t){if(e==="Ed25519")return Ba();if(e==="secp256k1")return ac();if(e==="RSA")return yi(nd(t));if(e==="ECDSA")return Ds(od(t));throw new Ke}function Ai(e,t){let{Type:r,Data:n}=ee.decode(e),o=n??new Uint8Array;switch(r){case et.RSA:return hi(o,t);case et.Ed25519:return Aa(o);case et.secp256k1:return sc(o);case et.ECDSA:return Ts(o);default:throw new Ke}}function se(e){return ee.encode({Type:et[e.type],Data:e.raw})}function uc(e){let t=Sn.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case et.RSA:return di(r);case et.Ed25519:return Go(r);case et.secp256k1:return vi(r);case et.ECDSA:return Is(r);default:throw new Ke}}function fc(e){if(e.byteLength===At)return Go(e);if(e.byteLength===Qa)return vi(e);let t=Ut(e),r=t[2]?.[0];if(r===gs||r===bs||r===xs)return Ao(t);if(t.length>8)return vn(t);throw new rt("Could not extract private key from raw bytes")}function nd(e){return e==null?2048:parseInt(e,10)}function od(e){if(e==="P-256"||e==null)return"P-256";if(e==="P-384")return"P-384";if(e==="P-521")return"P-521";throw new rt("Unsupported curve, should be P-256, P-384 or P-521")}function id(e,t){if(typeof e=="string")return sd(e);if(typeof e=="number")return ud(e,t);throw Error(`Value provided to ms() must be a string or number. value=${JSON.stringify(e)}`)}var In=id;function sd(e){if(typeof e!="string"||e.length===0||e.length>100)throw Error(`Value provided to ms.parse() must be a string with length between 1 and 99. value=${JSON.stringify(e)}`);let t=/^(?<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(e);if(!t?.groups)return NaN;let{value:r,unit:n="ms"}=t.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(e)}`)}}function ad(e){let t=Math.abs(e);return t>=315576e5?`${Math.round(e/315576e5)}y`:t>=26298e5?`${Math.round(e/26298e5)}mo`:t>=6048e5?`${Math.round(e/6048e5)}w`:t>=864e5?`${Math.round(e/864e5)}d`:t>=36e5?`${Math.round(e/36e5)}h`:t>=6e4?`${Math.round(e/6e4)}m`:t>=1e3?`${Math.round(e/1e3)}s`:`${e}ms`}function cd(e){let t=Math.abs(e);return t>=315576e5?Re(e,t,315576e5,"year"):t>=26298e5?Re(e,t,26298e5,"month"):t>=6048e5?Re(e,t,6048e5,"week"):t>=864e5?Re(e,t,864e5,"day"):t>=36e5?Re(e,t,36e5,"hour"):t>=6e4?Re(e,t,6e4,"minute"):t>=1e3?Re(e,t,1e3,"second"):`${e} ms`}function ud(e,t){if(typeof e!="number"||!Number.isFinite(e))throw Error("Value provided to ms.format() must be of type number.");return t?.long?cd(e):ad(e)}function Re(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function Bi(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=In,r.destroy=l,Object.keys(e).forEach(u=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let f=0;for(let x=0;x<u.length;x++)f=(f<<5)-f+u.charCodeAt(x),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=t;function r(u){let f,x=null,v,b;function A(...B){if(!A.enabled)return;let w=A,T=Number(new Date),E=T-(f||T);w.diff=E,w.prev=f,w.curr=T,f=T,B[0]=r.coerce(B[0]),typeof B[0]!="string"&&B.unshift("%O");let U=0;B[0]=B[0].replace(/%([a-zA-Z%])/g,(M,F)=>{if(M==="%%")return"%";U++;let p=r.formatters[F];if(typeof p=="function"){let m=B[U];M=p.call(w,m),B.splice(U,1),U--}return M}),r.formatArgs.call(w,B),(w.log||r.log).apply(w,B)}return A.namespace=u,A.useColors=r.useColors(),A.color=r.selectColor(u),A.extend=n,A.destroy=r.destroy,Object.defineProperty(A,"enabled",{enumerable:!0,configurable:!1,get:()=>x!==null?x:(v!==r.namespaces&&(v=r.namespaces,b=r.enabled(u)),b),set:B=>{x=B}}),typeof r.init=="function"&&r.init(A),A}function n(u,f){let x=r(this.namespace+(typeof f>"u"?":":f)+u);return x.log=this.log,x}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let f,x=(typeof u=="string"?u:"").split(/[\s,]+/),v=x.length;for(f=0;f<v;f++)x[f]&&(u=x[f].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(a),...r.skips.map(a).map(f=>"-"+f)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let f,x;for(f=0,x=r.skips.length;f<x;f++)if(r.skips[f].test(u))return!1;for(f=0,x=r.names.length;f<x;f++)if(r.names[f].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function l(){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 Tn=yd(),fd=["#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 ld(){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 dd(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+In(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}var hd=console.debug??console.log??(()=>{});function pd(e){try{e?Tn?.setItem("debug",e):Tn?.removeItem("debug")}catch{}}function md(){let e;try{e=Tn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function yd(){try{return localStorage}catch{}}function gd(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var lc=Bi({formatArgs:dd,save:pd,load:md,useColors:ld,setupFormatters:gd,colors:fd,storage:Tn,log:hd});var wt=lc;wt.formatters.b=e=>e==null?"undefined":ot.baseEncode(e);wt.formatters.t=e=>e==null?"undefined":ie.baseEncode(e);wt.formatters.m=e=>e==null?"undefined":po.baseEncode(e);wt.formatters.p=e=>e==null?"undefined":e.toString();wt.formatters.c=e=>e==null?"undefined":e.toString();wt.formatters.k=e=>e==null?"undefined":e.toString();wt.formatters.a=e=>e==null?"undefined":e.toString();wt.formatters.e=e=>e==null?"undefined":dc(e.stack)??dc(e.message)??e.toString();function bd(e){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}function De(e){let t=bd(`${e}:trace`);return wt.enabled(`${e}:trace`)&&wt.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=wt(`${e}:trace`)),Object.assign(wt(e),{error:wt(`${e}:error`),trace:t,newScope:r=>De(`${e}:${r}`)})}function dc(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var vu=zi(Ti(),1);var _n=class extends Error{static name="SignatureCreationError";constructor(t="Record signature creation failed"){super(t),this.name="SignatureCreationError"}},Mt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},Cn=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},Le=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}};var Vr=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},Un=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}};var Et;(function(e){let t;(function(o){o.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),function(o){o.codec=()=>Kr(r)}(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=sr((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),e.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 a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let l=o.uint32();switch(l>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=e.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(l&7);break}}}return a})),n),e.encode=o=>or(o,e.codec()),e.decode=(o,i)=>nr(o,e.codec(),i)})(Et||(Et={}));var xd=["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 _i(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(t==="string"||t==="number"||t==="bigint"||t==="symbol")return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(e instanceof Uint8Array)return"Uint8Array";if(e.constructor===Object)return"Object";let r=wd(e);return r||"Object"}function wd(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(xd.includes(t))return t}var h=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}static equals(t,r){return t===r||t.major===r.major&&t.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 L=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var qr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Ed=new TextEncoder;function Rn(e){return qr&&globalThis.Buffer.isBuffer(e)}function Hr(e){return e instanceof Uint8Array?Rn(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Sd=24,vd=200,Dn=qr?e=>e.length>=Sd?globalThis.Buffer.from(e):hc(e):e=>e.length>=vd?Ed.encode(e):hc(e),zt=e=>Uint8Array.from(e),pc=qr?(e,t,r)=>Rn(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),mc=qr?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Hr(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},yc=qr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Ln(e,t){if(Rn(e)&&Rn(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function hc(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}var Ad=256,$r=class{constructor(t=Ad){this.chunkSize=t,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(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,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)}t.length<64&&t.length<this.chunkSize?(r=yc(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=pc(n,0,this.cursor)}else r=mc(this.chunks,this.cursor);return t&&this.reset(),r}},Nn=class{constructor(t){this.dest=t,this.cursor=0,this.chunks=[t]}reset(){this.cursor=0}push(t){if(this.cursor+t.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(t,this.cursor),this.cursor+=t.length}toBytes(t=!1){let r=this.dest.subarray(0,this.cursor);return t&&this.reset(),r}};var V="CBOR decode error:",kn="CBOR encode error:",zr=[];zr[23]=1;zr[24]=2;zr[25]=3;zr[26]=5;zr[27]=9;function ne(e,t,r){if(e.length-t<r)throw new Error(`${V} not enough data for type`)}var ut=[24,256,65536,4294967296,BigInt("18446744073709551616")];function It(e,t,r){ne(e,t,1);let n=e[t];if(r.strict===!0&&n<ut[0])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);return n}function Tt(e,t,r){ne(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<ut[1])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);return n}function _t(e,t,r){ne(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<ut[2])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);return n}function Ct(e,t,r){ne(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<ut[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 gc(e,t,r,n){return new L(h.uint,It(e,t+1,n),2)}function bc(e,t,r,n){return new L(h.uint,Tt(e,t+1,n),3)}function xc(e,t,r,n){return new L(h.uint,_t(e,t+1,n),5)}function wc(e,t,r,n){return new L(h.uint,Ct(e,t+1,n),9)}function Rt(e,t){return G(e,0,t.value)}function G(e,t,r){if(r<ut[0]){let n=Number(r);e.push([t|n])}else if(r<ut[1]){let n=Number(r);e.push([t|24,n])}else if(r<ut[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<ut[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<ut[4]){let o=[t|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,e.push(o)}else throw new Error(`${V} encountered BigInt larger than allowable range`)}}Rt.encodedSize=function(t){return G.encodedSize(t.value)};G.encodedSize=function(t){return t<ut[0]?1:t<ut[1]?2:t<ut[2]?3:t<ut[3]?5:9};Rt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Ec(e,t,r,n){return new L(h.negint,-1-It(e,t+1,n),2)}function Sc(e,t,r,n){return new L(h.negint,-1-Tt(e,t+1,n),3)}function vc(e,t,r,n){return new L(h.negint,-1-_t(e,t+1,n),5)}var Ci=BigInt(-1),Ac=BigInt(1);function Bc(e,t,r,n){let o=Ct(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new L(h.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${V} integers outside of the safe integer range are not supported`);return new L(h.negint,Ci-BigInt(o),9)}function Kn(e,t){let r=t.value,n=typeof r=="bigint"?r*Ci-Ac:r*-1-1;G(e,t.type.majorEncoded,n)}Kn.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Ci-Ac:r*-1-1;return n<ut[0]?1:n<ut[1]?2:n<ut[2]?3:n<ut[3]?5:9};Kn.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function Zr(e,t,r,n){ne(e,t,r+n);let o=e.slice(t+r,t+r+n);return new L(h.bytes,o,r+n)}function Ic(e,t,r,n){return Zr(e,t,1,r)}function Tc(e,t,r,n){return Zr(e,t,2,It(e,t+1,n))}function _c(e,t,r,n){return Zr(e,t,3,Tt(e,t+1,n))}function Cc(e,t,r,n){return Zr(e,t,5,_t(e,t+1,n))}function Uc(e,t,r,n){let o=Ct(e,t+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer bytes lengths not supported`);return Zr(e,t,9,o)}function On(e){return e.encodedBytes===void 0&&(e.encodedBytes=h.equals(e.type,h.string)?Dn(e.value):e.value),e.encodedBytes}function ur(e,t){let r=On(t);G(e,t.type.majorEncoded,r.length),e.push(r)}ur.encodedSize=function(t){let r=On(t);return G.encodedSize(r.length)+r.length};ur.compareTokens=function(t,r){return Id(On(t),On(r))};function Id(e,t){return e.length<t.length?-1:e.length>t.length?1:Ln(e,t)}var Rc=new TextDecoder,_d=32;function Cd(e,t,r){if(r-t<_d){let o="";for(let i=t;i<r;i++){let s=e[i];if(s&128)return Rc.decode(e.subarray(t,r));o+=String.fromCharCode(s)}return o}return Rc.decode(e.subarray(t,r))}function jr(e,t,r,n,o){let i=r+n;ne(e,t,i);let s=new L(h.string,Cd(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=e.slice(t+r,t+i)),s}function Dc(e,t,r,n){return jr(e,t,1,r,n)}function Lc(e,t,r,n){return jr(e,t,2,It(e,t+1,n),n)}function Nc(e,t,r,n){return jr(e,t,3,Tt(e,t+1,n),n)}function kc(e,t,r,n){return jr(e,t,5,_t(e,t+1,n),n)}function Kc(e,t,r,n){let o=Ct(e,t+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer string lengths not supported`);return jr(e,t,9,o,n)}var Oc=ur;function fr(e,t,r,n){return new L(h.array,n,r)}function Mc(e,t,r,n){return fr(e,t,1,r)}function Pc(e,t,r,n){return fr(e,t,2,It(e,t+1,n))}function Fc(e,t,r,n){return fr(e,t,3,Tt(e,t+1,n))}function Vc(e,t,r,n){return fr(e,t,5,_t(e,t+1,n))}function qc(e,t,r,n){let o=Ct(e,t+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer array lengths not supported`);return fr(e,t,9,o)}function Hc(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${V} indefinite length items not allowed`);return fr(e,t,1,1/0)}function Mn(e,t){G(e,h.array.majorEncoded,t.value)}Mn.compareTokens=Rt.compareTokens;Mn.encodedSize=function(t){return G.encodedSize(t.value)};function lr(e,t,r,n){return new L(h.map,n,r)}function $c(e,t,r,n){return lr(e,t,1,r)}function zc(e,t,r,n){return lr(e,t,2,It(e,t+1,n))}function Zc(e,t,r,n){return lr(e,t,3,Tt(e,t+1,n))}function jc(e,t,r,n){return lr(e,t,5,_t(e,t+1,n))}function Gc(e,t,r,n){let o=Ct(e,t+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer map lengths not supported`);return lr(e,t,9,o)}function Yc(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${V} indefinite length items not allowed`);return lr(e,t,1,1/0)}function Pn(e,t){G(e,h.map.majorEncoded,t.value)}Pn.compareTokens=Rt.compareTokens;Pn.encodedSize=function(t){return G.encodedSize(t.value)};function Wc(e,t,r,n){return new L(h.tag,r,1)}function Xc(e,t,r,n){return new L(h.tag,It(e,t+1,n),2)}function Jc(e,t,r,n){return new L(h.tag,Tt(e,t+1,n),3)}function Qc(e,t,r,n){return new L(h.tag,_t(e,t+1,n),5)}function tu(e,t,r,n){return new L(h.tag,Ct(e,t+1,n),9)}function Fn(e,t){G(e,h.tag.majorEncoded,t.value)}Fn.compareTokens=Rt.compareTokens;Fn.encodedSize=function(t){return G.encodedSize(t.value)};var Ui=20,Ri=21,Di=22,Li=23;function eu(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${V} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new L(h.null,null,1):new L(h.undefined,void 0,1)}function ru(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${V} indefinite length items not allowed`);return new L(h.break,void 0,1)}function Ni(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${V} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${V} Infinity values are not supported`)}return new L(h.float,e,t)}function nu(e,t,r,n){return Ni(ki(e,t+1),3,n)}function ou(e,t,r,n){return Ni(Ki(e,t+1),5,n)}function iu(e,t,r,n){return Ni(uu(e,t+1),9,n)}function Gr(e,t,r){let n=t.value;if(n===!1)e.push([h.float.majorEncoded|Ui]);else if(n===!0)e.push([h.float.majorEncoded|Ri]);else if(n===null)e.push([h.float.majorEncoded|Di]);else if(n===void 0)e.push([h.float.majorEncoded|Li]);else{let o,i=!1;(!r||r.float64!==!0)&&(au(n),o=ki(Pt,1),n===o||Number.isNaN(n)?(Pt[0]=249,e.push(Pt.slice(0,3)),i=!0):(cu(n),o=Ki(Pt,1),n===o&&(Pt[0]=250,e.push(Pt.slice(0,5)),i=!0))),i||(Nd(n),o=uu(Pt,1),Pt[0]=251,e.push(Pt.slice(0,9)))}}Gr.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){au(n);let o=ki(Pt,1);if(n===o||Number.isNaN(n))return 3;if(cu(n),o=Ki(Pt,1),n===o)return 5}return 9};var su=new ArrayBuffer(9),Dt=new DataView(su,1),Pt=new Uint8Array(su,0);function au(e){if(e===1/0)Dt.setUint16(0,31744,!1);else if(e===-1/0)Dt.setUint16(0,64512,!1);else if(Number.isNaN(e))Dt.setUint16(0,32256,!1);else{Dt.setFloat32(0,e);let t=Dt.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Dt.setUint16(0,31744,!1);else if(r===0)Dt.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Dt.setUint16(0,0):o<-14?Dt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Dt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function ki(e,t){if(e.length-t<2)throw new Error(`${V} not enough data for float16`);let r=(e[t]<<8)+e[t+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 cu(e){Dt.setFloat32(0,e,!1)}function Ki(e,t){if(e.length-t<4)throw new Error(`${V} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Nd(e){Dt.setFloat64(0,e,!1)}function uu(e,t){if(e.length-t<8)throw new Error(`${V} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Gr.compareTokens=Rt.compareTokens;function z(e,t,r){throw new Error(`${V} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Vn(e){return()=>{throw new Error(`${V} ${e}`)}}var _=[];for(let e=0;e<=23;e++)_[e]=z;_[24]=gc;_[25]=bc;_[26]=xc;_[27]=wc;_[28]=z;_[29]=z;_[30]=z;_[31]=z;for(let e=32;e<=55;e++)_[e]=z;_[56]=Ec;_[57]=Sc;_[58]=vc;_[59]=Bc;_[60]=z;_[61]=z;_[62]=z;_[63]=z;for(let e=64;e<=87;e++)_[e]=Ic;_[88]=Tc;_[89]=_c;_[90]=Cc;_[91]=Uc;_[92]=z;_[93]=z;_[94]=z;_[95]=Vn("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)_[e]=Dc;_[120]=Lc;_[121]=Nc;_[122]=kc;_[123]=Kc;_[124]=z;_[125]=z;_[126]=z;_[127]=Vn("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)_[e]=Mc;_[152]=Pc;_[153]=Fc;_[154]=Vc;_[155]=qc;_[156]=z;_[157]=z;_[158]=z;_[159]=Hc;for(let e=160;e<=183;e++)_[e]=$c;_[184]=zc;_[185]=Zc;_[186]=jc;_[187]=Gc;_[188]=z;_[189]=z;_[190]=z;_[191]=Yc;for(let e=192;e<=215;e++)_[e]=Wc;_[216]=Xc;_[217]=Jc;_[218]=Qc;_[219]=tu;_[220]=z;_[221]=z;_[222]=z;_[223]=z;for(let e=224;e<=243;e++)_[e]=Vn("simple values are not supported");_[244]=z;_[245]=z;_[246]=z;_[247]=eu;_[248]=Vn("simple values are not supported");_[249]=nu;_[250]=ou;_[251]=iu;_[252]=z;_[253]=z;_[254]=z;_[255]=ru;var Ft=[];for(let e=0;e<24;e++)Ft[e]=new L(h.uint,e,1);for(let e=-1;e>=-24;e--)Ft[31-e]=new L(h.negint,e,1);Ft[64]=new L(h.bytes,new Uint8Array(0),1);Ft[96]=new L(h.string,"",1);Ft[128]=new L(h.array,0,1);Ft[160]=new L(h.map,0,1);Ft[244]=new L(h.false,!1,1);Ft[245]=new L(h.true,!0,1);Ft[246]=new L(h.null,null,1);function Oi(e){switch(e.type){case h.false:return zt([244]);case h.true:return zt([245]);case h.null:return zt([246]);case h.bytes:return e.value.length?void 0:zt([64]);case h.string:return e.value===""?zt([96]):void 0;case h.array:return e.value===0?zt([128]):void 0;case h.map:return e.value===0?zt([160]):void 0;case h.uint:return e.value<24?zt([Number(e.value)]):void 0;case h.negint:if(e.value>=-24)return zt([31-Number(e.value)])}}var Kd={float64:!1,mapSorter:Pd,quickEncodeToken:Oi},pu=Object.freeze({float64:!0,mapSorter:Fd,quickEncodeToken:Oi});function Od(){let e=[];return e[h.uint.major]=Rt,e[h.negint.major]=Kn,e[h.bytes.major]=ur,e[h.string.major]=Oc,e[h.array.major]=Mn,e[h.map.major]=Pn,e[h.tag.major]=Fn,e[h.float.major]=Gr,e}var dr=Od(),qn=new $r,Wr=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${kn} object contains circular references`);return new e(r,t)}},me={null:new L(h.null,null),undefined:new L(h.undefined,void 0),true:new L(h.true,!0),false:new L(h.false,!1),emptyArray:new L(h.array,0),emptyMap:new L(h.map,0)},Zt={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new L(h.float,e):e>=0?new L(h.uint,e):new L(h.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new L(h.uint,e):new L(h.negint,e)},Uint8Array(e,t,r,n){return new L(h.bytes,e)},string(e,t,r,n){return new L(h.string,e)},boolean(e,t,r,n){return e?me.true:me.false},null(e,t,r,n){return me.null},undefined(e,t,r,n){return me.undefined},ArrayBuffer(e,t,r,n){return new L(h.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new L(h.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[me.emptyArray,new L(h.break)]:me.emptyArray;n=Wr.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=Hn(s,r,n);return r.addBreakTokens?[new L(h.array,e.length),o,new L(h.break)]:[new L(h.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),s=o?e.size:i.length,a;if(s){a=new Array(s),n=Wr.createCheck(n,e);let c=!o&&r.ignoreUndefinedProperties,l=0;for(let u of i){let f=o?e.get(u):e[u];c&&f===void 0||(a[l++]=[Hn(u,r,n),Hn(f,r,n)])}l<s&&(a.length=l)}return a?.length?(Md(a,r),r.addBreakTokens?[new L(h.map,a.length),a,new L(h.break)]:[new L(h.map,a.length),a]):r.addBreakTokens===!0?[me.emptyMap,new L(h.break)]:me.emptyMap}};Zt.Map=Zt.Object;Zt.Buffer=Zt.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Zt[`${e}Array`]=Zt.DataView;function Hn(e,t={},r){let n=_i(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Zt[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Zt[n];if(!i)throw new Error(`${kn} unsupported type: ${n}`);return i(e,n,t,r)}function Md(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Pd(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=dr[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Fd(e,t){if(e[0]instanceof L&&t[0]instanceof L){let r=e[0],n=t[0];return r._keyBytes||(r._keyBytes=fu(r.value)),n._keyBytes||(n._keyBytes=fu(n.value)),Ln(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function fu(e){return yu(e,dr,pu)}function Yr(e,t,r,n){if(Array.isArray(t))for(let o of t)Yr(e,o,r,n);else r[t.type.major](e,t,n)}var lu=h.uint.majorEncoded,du=h.negint.majorEncoded,Vd=h.bytes.majorEncoded,qd=h.string.majorEncoded,hu=h.array.majorEncoded,Hd=h.float.majorEncoded|Ui,$d=h.float.majorEncoded|Ri,zd=h.float.majorEncoded|Di,Zd=h.float.majorEncoded|Li,jd=BigInt(-1),Gd=BigInt(1);function Yd(e){return e.addBreakTokens!==!0}function mu(e,t,r,n){let o=_i(t),i=r.typeEncoders&&r.typeEncoders[o];if(i){let s=i(t,o,r,n);if(s!=null){Yr(e,s,dr,r);return}}switch(o){case"null":e.push([zd]);return;case"undefined":e.push([Zd]);return;case"boolean":e.push([t?$d:Hd]);return;case"number":!Number.isInteger(t)||!Number.isSafeInteger(t)?Gr(e,new L(h.float,t),r):t>=0?G(e,lu,t):G(e,du,t*-1-1);return;case"bigint":t>=BigInt(0)?G(e,lu,t):G(e,du,t*jd-Gd);return;case"string":{let s=Dn(t);G(e,qd,s.length),e.push(s);return}case"Uint8Array":G(e,Vd,t.length),e.push(t);return;case"Array":if(!t.length){e.push([hu]);return}n=Wr.createCheck(n,t),G(e,hu,t.length);for(let s of t)mu(e,s,r,n);return;case"Object":case"Map":{let s=Zt.Object(t,o,r,n);Yr(e,s,dr,r)}return;default:{let s=Zt[o];if(!s)throw new Error(`${kn} unsupported type: ${o}`);let a=s(t,o,r,n);Yr(e,a,dr,r)}}}function yu(e,t,r,n){let o=n instanceof Uint8Array,i=o?new Nn(n):qn,s=Hn(e,r);if(!Array.isArray(s)&&r.quickEncodeToken){let a=r.quickEncodeToken(s);if(a)return o?(i.push(a),i.toBytes()):a;let c=t[s.type.major];if(c.encodedSize){let l=c.encodedSize(s,r);if(o||(i=new $r(l)),c(i,s,r),i.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${s} was wrong`);return o?i.toBytes():Hr(i.chunks[0])}}return i.reset(),Yr(i,s,t,r),i.toBytes(!0)}function Xr(e,t){return t=Object.assign({},Kd,t),Yd(t)?(qn.reset(),mu(qn,e,t,void 0),qn.toBytes(!0)):yu(e,dr,t)}var Wd={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},$n=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=Ft[t];if(r===void 0){let n=_[t];if(!n)throw new Error(`${V} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},Jr=Symbol.for("DONE"),zn=Symbol.for("BREAK");function Xd(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=hr(t,r);if(i===zn){if(e.value===1/0)break;throw new Error(`${V} got unexpected break to lengthed array`)}if(i===Jr)throw new Error(`${V} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function Jd(e,t,r){let n=r.useMaps===!0,o=r.rejectDuplicateMapKeys===!0,i=n?void 0:{},s=n?new Map:void 0;for(let a=0;a<e.value;a++){let c=hr(t,r);if(c===zn){if(e.value===1/0)break;throw new Error(`${V} got unexpected break to lengthed map`)}if(c===Jr)throw new Error(`${V} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(!n&&typeof c!="string")throw new Error(`${V} non-string keys not supported (got ${typeof c})`);if(o&&(n&&s.has(c)||!n&&Object.hasOwn(i,c)))throw new Error(`${V} found repeat map key "${c}"`);let l=hr(t,r);if(l===Jr)throw new Error(`${V} found map but not enough entries (got ${a} [no value], expected ${e.value})`);n?s.set(c,l):i[c]=l}return n?s:i}function hr(e,t){if(e.done())return Jr;let r=e.next();if(h.equals(r.type,h.break))return zn;if(r.type.terminal)return r.value;if(h.equals(r.type,h.array))return Xd(r,e,t);if(h.equals(r.type,h.map))return Jd(r,e,t);if(h.equals(r.type,h.tag)){if(t.tags&&typeof t.tags[r.value]=="function"){let n=hr(e,t);return t.tags[r.value](n)}throw new Error(`${V} tag not supported (${r.value})`)}throw new Error("unsupported")}function gu(e,t){if(!(e instanceof Uint8Array))throw new Error(`${V} data to decode must be a Uint8Array`);t=Object.assign({},Wd,t);let r=Hr(e),n=t.tokenizer||new $n(r,t),o=hr(n,t);if(o===Jr)throw new Error(`${V} did not find any content to decode`);if(o===zn)throw new Error(`${V} got unexpected break`);return[o,e.subarray(n.pos())]}function Qr(e,t){let[r,n]=gu(e,t);if(n.length>0)throw new Error(`${V} too many terminals, data makes no sense`);return r}var $g=De("ipns:utils"),zg=Z("/ipns/"),Qd=114;function xu(e,t,r){let n=Z(t);return be([e,r,n])}function Zn(e){let t=Z("ipns-signature:");return be([t,e])}function Mi(e){return"signatureV1"in e?Et.encode({value:Z(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:Z(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):Et.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function tn(e){let t=Et.decode(e);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new Mt("Missing data or signatureV2");let r=Eu(t.data),n=th(r.Value),o=j(r.Validity);if(t.value!=null&&t.signatureV1!=null)return eh(t),{value:n,validityType:Et.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV1:t.signatureV1,signatureV2:t.signatureV2,data:t.data};if(t.signatureV2!=null)return{value:n,validityType:Et.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function wu(e,t,r,n,o){let i;if(t===Et.ValidityType.EOL)i=0;else throw new Le("The validity type is unsupported");return Xr({Value:e,Validity:r,ValidityType:i,Sequence:n,TTL:o})}function Eu(e){let t=Qr(e);if(t.ValidityType===0)t.ValidityType=Et.ValidityType.EOL;else throw new Le("The validity type is unsupported");return Number.isInteger(t.Sequence)&&(t.Sequence=BigInt(t.Sequence)),Number.isInteger(t.TTL)&&(t.TTL=BigInt(t.TTL)),t}function th(e){let t=j(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${it.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${it.parse(t).toV1().toString()}`}catch{}throw new Vr("Value must be a valid content path starting with /")}function Su(e){if(e!=null){let t=oh(e);if(t!=null)return t.code===Qd?`/ipns/${t.toString(Lt)}`:`/ipfs/${t.toV1().toString()}`;if(rh(e))return`/ipns/${Lt.encode(e.bytes)}`;let r=e.toString().trim();if(r.startsWith("/")&&r.length>1)return r}throw new Vr("Value must be a valid content path starting with /")}function eh(e){if(e.data==null)throw new Un("Record data is missing");let t=Eu(e.data);if(!st(t.Value,e.value??new Uint8Array(0)))throw new Mt('Field "value" did not match between protobuf and CBOR');if(!st(t.Validity,e.validity??new Uint8Array(0)))throw new Mt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Mt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Mt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Mt('Field "ttl" did not match between protobuf and CBOR')}function rh(e){return e.bytes instanceof Uint8Array}function nh(e){return typeof e?.toCID=="function"}function oh(e){if(nh(e))return e.toCID();try{return it.parse(e)}catch{}return it.asCID(e)}var ih=De("ipns"),Au=5*60*1e9,sh="/ipns/",Qg=sh.length,Bu={v1Compatible:!0,ttlNs:Au};async function Iu(e,t,r,n,o=Bu){let i=new vu.default(Date.now()+Number(n)),s=Et.ValidityType.EOL,a=BigInt(o.ttlNs??Au);return ah(e,t,r,s,i.toString(),a,o)}var ah=async(e,t,r,n,o,i,s=Bu)=>{r=BigInt(r);let a=Z(o),c=Su(t),l=Z(c),u=wu(l,n,a,r,i),f=Zn(u),x=await e.sign(f),v;if(e.type==="RSA"&&(v=se(e.publicKey)),s.v1Compatible===!0){let b=await ch(e,l,n,a),A={value:c,signatureV1:b,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:x,data:u};return v!=null&&(A.pubKey=v),A}else{let b={value:c,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:x,data:u};return v!=null&&(b.pubKey=v),b}},ch=async(e,t,r,n)=>{try{let o=xu(t,r,n);return await e.sign(o)}catch(o){throw ih.error("record signature creation failed",o),new _n("Record signature creation failed")}};var Tu=zi(Ti(),1);var jn=De("ipns:validator"),hb=1024*10;async function _u(e,t){let r=tn(t),n;try{let o=Zn(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw jn.error("record signature verification failed"),new Mt("Record signature verification failed");if(r.validityType===Et.ValidityType.EOL){if(Tu.default.fromString(r.validity).toDate().getTime()<Date.now())throw jn.error("record has expired"),new Cn("record has expired")}else if(r.validityType!=null)throw jn.error("the validity type is unsupported"),new Le("The validity type is unsupported");jn("ipns record for %s is valid",r.value)}var Fi=class extends Error{constructor(t={}){var r;super((r=t.message)!==null&&r!==void 0?r:"Maximum retry limit reached."),this.options=t}},Pi=Symbol("internal_state");function Vi(e={}){let{interval:t=0,maxPerInterval:r=1/0,evenlySpaced:n=!1,maxRetries:o=30,maxRetriesWithPauses:i=30}=e;if(r<1)throw new Error('"maxPerInterval" must be a positive integer.');if(t<0)throw new Error('"interval" cannot be negative.');if(o<0)throw new Error('"maxRetries" cannot be negative.');if(i<0)throw new Error('"maxRetriesWithPauses" cannot be negative.');if(n)return Vi({...e,interval:Math.ceil(t/r),maxPerInterval:1,evenlySpaced:!1});let s=[],a=0,c=0,l,u=()=>{l=void 0;let x=a+t,v=Date.now();if(v<x){l=setTimeout(u,x-v);return}a=v,c=0;for(let b of s.splice(0,r))c++,b();s.length&&(l=setTimeout(u,t))},f=(x,v)=>new Promise((b,A)=>{v||(v={}),Pi in v||Object.assign(v,{[Pi]:{maxRetries:o,maxRetriesWithPauses:i}});let B=async()=>{var E,U;try{return await x({intervalStart:a,state:v})}catch(K){if(K instanceof Fi){let M=v[Pi];if(K.options.pauseQueue){if(M.maxRetriesWithPauses--<=0)throw K;c=r,l!==void 0&&clearTimeout(l),l=setTimeout(u,(U=(E=K.options.retryAfter)!==null&&E!==void 0?E:e.interval)!==null&&U!==void 0?U:500)}else{if(M.maxRetries--<=0)throw K;await new Promise(F=>{var p,m;return setTimeout(F,(m=(p=K.options.retryAfter)!==null&&p!==void 0?p:e.interval)!==null&&m!==void 0?m:500)})}return f(x,v)}throw K}},w=()=>{Promise.resolve().then(B).then(b).catch(A)},T=Date.now();l===void 0&&t&&T-a>t&&(a=T,c=0),c++<r?w():(s.push(w),l===void 0&&(l=setTimeout(u,a+t-T)))});return f}var Gn=class{endpoint;waitForRateLimit;constructor(t=new URL("https://name.web3.storage/"),r=function(){let n=Vi({maxPerInterval:30,interval:1e4});return async()=>await n(()=>{})}()){this.endpoint=t,this.waitForRateLimit=r}};var Cu=()=>new Date(Date.now()+31536e6).toISOString(),fh=5n*60n*1000n*1000000n,Uu=new Gn,Yn=class{_pubKey;_cid;constructor(t){this._pubKey=t,this._cid=t.toCID()}get bytes(){return this._cid.bytes}toString(){return this._cid.toString(Lt)}},Wn=class extends Yn{_privKey;constructor(t){super(t.publicKey),this._privKey=t}get key(){return this._privKey}};async function Ru(){let e=await cc("Ed25519",2048);return new Wn(e)}function lh(e){let t=it.parse(e,Lt);if(t.code!==114)throw new Error(`Invalid key, expected 114 codec code but got ${t.code}`);let r=Ai(Ve(t.multihash.bytes).bytes);return new Yn(r)}async function qi(e){let t;try{t=fc(e)}catch{t=uc(e)}return new Wn(t)}async function Du(e,t){return new en(e,t,0n,Cu())}async function Lu(e,t){let r=e.sequence+1n;return new en(e.name,t,r,Cu())}var en=class e{_name;_value;_sequence;_validity;_ttl;constructor(t,r,n,o,i){if(this._name=t,typeof r!="string")throw new Error("invalid value");if(this._value=r,typeof n!="bigint")throw new Error("invalid sequence number");if(this._sequence=n,typeof o!="string"||Number.isNaN(new Date(o).getTime()))throw new Error("invalid validity");this._validity=o;let s=i?.ttl??fh;if(typeof s!="bigint")throw new Error("invalid TTL");this._ttl=s}get name(){return this._name}get value(){return this._value}get sequence(){return this._sequence}get validity(){return this._validity}get ttl(){return this._ttl}static encode(t){return Xr({name:t._name.toString(),value:t._value,sequence:t._sequence,validity:t._validity,...t._ttl!=null?{ttl:t._ttl}:{}})}static decode(t){let r=Qr(t),n=lh(r.name);return new e(n,r.value,BigInt(r.sequence),r.validity,{ttl:r.ttl!=null?BigInt(r.ttl):void 0})}};async function Nu(e,t,r=Uu){let n=new URL(`name/${e.name.toString()}`,r.endpoint),o=await Iu(t,e.value,e.sequence,new Date(e.validity).getTime()-Date.now(),{ttlNs:e.ttl});await r.waitForRateLimit(),await Ku(fetch(n.toString(),{method:"POST",body:sn.baseEncode(Mi(o))}))}async function ku(e,t=Uu){let r=new URL(`name/${e.toString()}`,t.endpoint);await t.waitForRateLimit();let n=await Ku(fetch(r.toString())),{record:o}=await n.json(),i=sn.baseDecode(o),s=tn(i),a=it.decode(e.bytes),c=Ai(Ve(a.multihash.bytes).bytes);return await _u(c,i),new en(e,s.value,s.sequence,s.validity,{ttl:s.ttl})}async function Ku(e){let t=await e;if(t.ok)return t;let r;try{let n=await t.json();r=new Error(n.message)}catch{r=new Error(`unexpected response from API, cannot parse error response. Received status: ${t.status}`)}throw r}var{WARN:Bb,LOG:Ib,DEBUG:Xn,ERROR:Ou}=Jn.setup(Jn.INFO);async function hh(e){let t=`https://name.web3.storage/name/${e.toString()}`,r;try{r=await fetch(t)}catch(o){throw Ou("[w3name] Network error resolving IPNS:",o)}if(r.status===404)return Xn("[w3name] IPNS record not found (never published):",e.toString()),null;if(!r.ok)throw Ou(`[w3name] HTTP ${r.status} resolving IPNS:`,r.statusText);return await ku(e)}async function Tb(e,t){let r=`/ipfs/${t}`,n=await qi(e),o,i=await hh(n);return i?(o=await Lu(i,r),Xn("[w3name] incrementing revision for",n.toString())):(o=await Du(n,r),Xn("[w3name] creating initial revision for",n.toString())),await Nu(o,n.key),Xn("[w3name] published",t.toString(),"to",n.toString()),o}async function _b(){return Ru()}async function Cb(e){return(await qi(e)).toString()}export{Tb as a,_b as b,Cb as c};
|
|
1
|
+
import{a as Jn}from"./chunk-L7VH6KZJ.min.js";import{a as Mu,b as St,c as zi}from"./chunk-D2SZILOK.min.js";var Ti=Mu((Ny,Ii)=>{"use strict";var Ly=function(){typeof Ii<"u"&&(Ii.exports=A);var e=86400,t=3200,r=146097*t/400,n=e*r,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",l=Math.trunc||function(p){var m=p-p%1;return m==0&&(p<0||p===0&&1/p!=1/0)?-0:m},u=A.prototype,f=(A.fromDate=function(p){return new A(+p)},A.fromInt64BE=U(0,1,2,3,0,4),A.fromInt64LE=U(3,2,1,0,4,0),A.fromString=function(R){var m,C=new A,R=(R+="").replace(/^\s*[+\-]?\d+/,function(y){var y=+y,g=1970+(y-1970)%400;return C.year=y-g,g}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(I,y,g){return y<0&&(g*=-1),m=6e4*(60*+y+ +g),""}).replace(/\.\d+$/,function(I){return C.nano=+(I+c).substr(1,9),""}).split(/\D+/);if(1<R.length?R[1]--:R[1]=0,C.time=m=Date.UTC.apply(Date,R)-(m||0),isNaN(m))throw new TypeError("Invalid Date");return B(C)},A.fromTimeT=function(p){return T(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=B(this);return(p.time%1e3*a+ +p.nano+1e9)%1e9},u.getTimeT=function(){var m=B(this),p=Math.floor(m.time/1e3),m=m.year;return m&&(p+=m*r*e/t),p},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return w(B(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(p){var m=this,C=m.toDate(),R={H:function(){return M(C.getUTCHours())},L:function(){return F(C.getUTCMilliseconds(),3)},M:function(){return M(C.getUTCMinutes())},N:function(){return F(m.getNano(),9)},S:function(){return M(C.getUTCSeconds())},Y:function(){var I=m.getYear();return 999999<I?"+"+I:9999<I?"+"+F(I,6):0<=I?F(I,4):-999999<=I?"-"+F(-I,6):I},a:function(){return v[C.getUTCDay()]},b:function(){return x[C.getUTCMonth()]},d:function(){return M(C.getUTCDate())},e:function(){return function(I){return(9<I?"":" ")+(0|I)}(C.getUTCDate())},m:function(){return M(C.getUTCMonth()+1)}};return function I(y){return y.replace(/%./g,function(g){var S=g[1],d=b[S],S=R[S];return d?I(d):S?S():g})}(p||f)},u.writeInt64BE=E(0,1,2,3,0,4),u.writeInt64LE=E(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],v=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],b={"%":"%",F:"%Y-%m-%d",n:`
|
|
2
|
+
`,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return A;function A(p,m,C){var R=this;if(!(R instanceof A))return new A(p,m,C);R.time=+p||0,R.nano=+m||0,R.year=+C||0,B(R)}function B(p){var m,C,R,I=p.year,y=p.time,g=p.nano,d=((g<0||a<=g)&&(g-=(C=Math.floor(g/a))*a,y+=C,C=1),I%t);return(y<-i||i<y||d)&&((m=l(y/o))&&(I+=m*t,y-=m*o),(R=w(y)).setUTCFullYear(d+R.getUTCFullYear()),R=(y=+R)+(m=l((I-=d)/t))*o,m&&-i<=R&&R<=i&&(I-=m*t,y=R),C=1),C&&(p.year=I,p.time=y,p.nano=g),p}function w(p){var m=new Date(0);return m.setTime(p),m}function T(I,R){I=+I||0;var C=l((R=(R|0)*s)/n)+l(I/n),R=R%n+I%n,I=l(R/n);return I&&(C+=I,R-=I*n),new A(1e3*R,0,C*t)}function E(p,m,C,R,I,y){return function(d,S){var N=B(this);d=d||new Array(8),K(d,S|=0);var k=Math.floor(N.time/1e3),N=N.year*(r*e/t),D=l(N/s)+l(k/s),N=N%s+k%s,k=Math.floor(N/s);return k&&(D+=k,N-=k*s),g(d,S+I,D),g(d,S+y,N),d};function g(d,S,D){d[S+p]=D>>24&255,d[S+m]=D>>16&255,d[S+C]=D>>8&255,d[S+R]=255&D}}function U(p,m,C,R,I,y){return function(d,S){K(d,S|=0);var D=g(d,S+I);return T(g(d,S+y),D)};function g(d,S){return 16777216*d[S+p]+(d[S+m]<<16|d[S+C]<<8|d[S+R])}}function K(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 M(p){return(9<p?"":"0")+(0|p)}function F(p,m){return(c+(0|p)).substr(-m)}}()});var rt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},ke=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}},pr=class extends Error{static name="InvalidPrivateKeyError";constructor(t="Invalid private key"){super(t),this.name="InvalidPrivateKeyError"}};var Ke=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var no={};St(no,{base58btc:()=>ot,base58flickr:()=>zu});var yh=new Uint8Array(0);function Zi(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function jt(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function ji(e){return new TextEncoder().encode(e)}function Gi(e){return new TextDecoder().decode(e)}function Pu(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function f(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var A=0,B=0,w=0,T=b.length;w!==T&&b[w]===0;)w++,A++;for(var E=(T-w)*u+1>>>0,U=new Uint8Array(E);w!==T;){for(var K=b[w],M=0,F=E-1;(K!==0||M<B)&&F!==-1;F--,M++)K+=256*U[F]>>>0,U[F]=K%a>>>0,K=K/a>>>0;if(K!==0)throw new Error("Non-zero carry");B=M,w++}for(var p=E-B;p!==E&&U[p]===0;)p++;for(var m=c.repeat(A);p<E;++p)m+=e.charAt(U[p]);return m}function x(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var A=0;if(b[A]!==" "){for(var B=0,w=0;b[A]===c;)B++,A++;for(var T=(b.length-A)*l+1>>>0,E=new Uint8Array(T);b[A];){var U=r[b.charCodeAt(A)];if(U===255)return;for(var K=0,M=T-1;(U!==0||K<w)&&M!==-1;M--,K++)U+=a*E[M]>>>0,E[M]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");w=K,A++}if(b[A]!==" "){for(var F=T-w;F!==T&&E[F]===0;)F++;for(var p=new Uint8Array(B+(T-F)),m=B;F!==T;)p[m++]=E[F++];return p}}}function v(b){var A=x(b);if(A)return A;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:x,decode:v}}var Fu=Pu,Vu=Fu,Wi=Vu;var Qn=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},to=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Xi(this,t)}},eo=class{decoders;constructor(t){this.decoders=t}or(t){return Xi(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Xi(e,t){return new eo({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var ro=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Qn(t,r,n),this.decoder=new to(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Oe({name:e,prefix:t,encode:r,decode:n}){return new ro(e,t,r,n)}function oe({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Wi(r,e);return Oe({prefix:t,name:e,encode:n,decode:i=>jt(o(i))})}function qu(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let l=0;l<o;++l){let u=t[e[l]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|u,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||255&a<<8-s)throw new SyntaxError("Unexpected end of data");return i}function Hu(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<r-s]),n)for(;i.length*r&7;)i+="=";return i}function $u(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function tt({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=$u(n);return Oe({prefix:t,name:e,encode(i){return Hu(i,n,r)},decode(i){return qu(i,o,r,e)}})}var ot=oe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),zu=oe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var oo={};St(oo,{base32:()=>ie,base32hex:()=>Yu,base32hexpad:()=>Xu,base32hexpadupper:()=>Ju,base32hexupper:()=>Wu,base32pad:()=>ju,base32padupper:()=>Gu,base32upper:()=>Zu,base32z:()=>Qu});var ie=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Zu=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ju=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Gu=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Yu=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Wu=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Xu=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ju=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Qu=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var io={};St(io,{base36:()=>Lt,base36upper:()=>tf});var Lt=oe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),tf=oe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ef=ts,Ji=128,rf=127,nf=~rf,of=Math.pow(2,31);function ts(e,t,r){t=t||[],r=r||0;for(var n=r;e>=of;)t[r++]=e&255|Ji,e/=128;for(;e&nf;)t[r++]=e&255|Ji,e>>>=7;return t[r]=e|0,ts.bytes=r-n+1,t}var sf=so,af=128,Qi=127;function so(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw so.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&Qi)<<o:(s&Qi)*Math.pow(2,o),o+=7}while(s>=af);return so.bytes=i-n,r}var cf=Math.pow(2,7),uf=Math.pow(2,14),ff=Math.pow(2,21),lf=Math.pow(2,28),df=Math.pow(2,35),hf=Math.pow(2,42),pf=Math.pow(2,49),mf=Math.pow(2,56),yf=Math.pow(2,63),gf=function(e){return e<cf?1:e<uf?2:e<ff?3:e<lf?4:e<df?5:e<hf?6:e<pf?7:e<mf?8:e<yf?9:10},bf={encode:ef,decode:sf,encodingLength:gf},xf=bf,mr=xf;function yr(e,t=0){return[mr.decode(e,t),mr.decode.bytes]}function Me(e,t,r=0){return mr.encode(e,t,r),t}function Pe(e){return mr.encodingLength(e)}function qt(e,t){let r=t.byteLength,n=Pe(e),o=n+Pe(r),i=new Uint8Array(o+r);return Me(e,i,0),Me(r,i,n),i.set(t,o),new Fe(e,r,t,i)}function Ve(e){let t=jt(e),[r,n]=yr(t),[o,i]=yr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Fe(r,o,s,t)}function es(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Zi(e.bytes,r.bytes)}}var Fe=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function rs(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Ef(r,ao(e),t??ot.encoder);default:return Sf(r,ao(e),t??ie.encoder)}}var ns=new WeakMap;function ao(e){let t=ns.get(e);if(t==null){let r=new Map;return ns.set(e,r),r}return t}var it=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==gr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==vf)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=qt(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&es(t.multihash,n.multihash)}toString(t){return rs(this,t)}toJSON(){return{"/":rs(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new e(n,o,i,s??os(n,o,i.bytes))}else if(r[Af]===!0){let{version:n,multihash:o,code:i}=r,s=Ve(o);return e.create(n,i,s)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==gr)throw new Error(`Version 0 CID must use dag-pb (code: ${gr}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=os(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,gr,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=jt(t.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 Fe(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[f,x]=yr(t.subarray(r));return r+=x,f},o=n(),i=gr;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),l=r+c,u=l-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:l}}static parse(t,r){let[n,o]=wf(t,r),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ao(i).set(n,t),i}};function wf(e,t){switch(e[0]){case"Q":{let r=t??ot;return[ot.prefix,r.decode(`${ot.prefix}${e}`)]}case ot.prefix:{let r=t??ot;return[ot.prefix,r.decode(e)]}case ie.prefix:{let r=t??ie;return[ie.prefix,r.decode(e)]}case Lt.prefix:{let r=t??Lt;return[Lt.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Ef(e,t,r){let{prefix:n}=r;if(n!==ot.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o}function Sf(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o}var gr=112,vf=18;function os(e,t,r){let n=Pe(e),o=n+Pe(t),i=new Uint8Array(o+r.byteLength);return Me(e,i,0),Me(t,i,n),i.set(r,o),i}var Af=Symbol.for("@ipld/js-cid/CID");var co={};St(co,{identity:()=>ge});var is=0,Bf="identity",ss=jt;function If(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return qt(is,ss(e))}var ge={code:is,name:Bf,encode:ss,digest:If};function st(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Gt(e=0){return new Uint8Array(e)}function vt(e=0){return new Uint8Array(e)}function be(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=vt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var cs=Symbol.for("@achingbrain/uint8arraylist");function as(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function on(e){return!!e?.[cs]}var pt=class e{bufs;length;[cs]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(on(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(on(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=as(this.bufs,t);return r.buf[r.index]}set(t,r){let n=as(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(on(t))for(let n=0;n<t.length;n++)this.set(r+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,r){let{bufs:n,length:o}=this._subList(t,r);return be(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:be(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),i=new e;return i.length=o,i.bufs=[...n],i}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,t>=c)continue;let l=t>=a&&t<c,u=r>a&&r<=c;if(l&&u){if(t===a&&r===c){n.push(s);break}let f=t-a;n.push(s.subarray(f,f+(r-t)));break}if(l){if(t===0){n.push(s);continue}n.push(s.subarray(t-a));continue}if(u){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!on(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let f=0;f<i;f++)s[f]=-1;for(let f=0;f<o;f++)s[n[f]]=f;let a=s,c=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=r;f<=c;f+=u){u=0;for(let x=l;x>=0;x--){let v=this.get(f+x);if(n[x]!==v){u=Math.max(1,x-a[v]);break}}if(u===0)return f}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=vt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=Gt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=Gt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=Gt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=vt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=Gt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=Gt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=Gt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=Gt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=Gt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!st(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var uo={};St(uo,{base10:()=>Tf});var Tf=oe({prefix:"9",name:"base10",alphabet:"0123456789"});var fo={};St(fo,{base16:()=>_f,base16upper:()=>Cf});var _f=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Cf=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var lo={};St(lo,{base2:()=>Uf});var Uf=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ho={};St(ho,{base256emoji:()=>kf});var us=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}"),Rf=us.reduce((e,t,r)=>(e[r]=t,e),[]),Df=us.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Lf(e){return e.reduce((t,r)=>(t+=Rf[r],t),"")}function Nf(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Df[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var kf=Oe({prefix:"\u{1F680}",name:"base256emoji",encode:Lf,decode:Nf});var mo={};St(mo,{base64:()=>po,base64pad:()=>sn,base64url:()=>Kf,base64urlpad:()=>Of});var po=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),sn=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Kf=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Of=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var yo={};St(yo,{base8:()=>Mf});var Mf=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var go={};St(go,{identity:()=>Pf});var Pf=Oe({prefix:"\0",name:"identity",encode:e=>Gi(e),decode:e=>ji(e)});var Qh=new TextEncoder,t0=new TextDecoder;var wo={};St(wo,{sha256:()=>an,sha512:()=>Hf});var qf=20;function xo({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new bo(e,t,r,n,o)}var bo=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,i){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??qf,this.maxDigestLength=i}digest(t,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(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?fs(n,this.code,r?.truncate):n.then(o=>fs(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function fs(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return qt(t,e)}function ds(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var an=xo({name:"sha2-256",code:18,encode:ds("SHA-256")}),Hf=xo({name:"sha2-512",code:19,encode:ds("SHA-512")});var Eo={...go,...lo,...yo,...uo,...fo,...oo,...io,...no,...mo,...ho},d0={...wo,...co};function ps(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var hs=ps("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),So=ps("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=vt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),$f={utf8:hs,"utf-8":hs,hex:Eo.base16,latin1:So,ascii:So,binary:So,...Eo},cn=$f;function Z(e,t="utf8"){let r=cn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function j(e,t="utf8"){let r=cn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var zf=parseInt("11111",2),vo=parseInt("10000000",2),Zf=parseInt("01111111",2),ms={0:br,1:br,2:jf,3:Wf,4:Xf,5:Yf,6:Gf,16:br,22:br,48:br};function Ut(e,t={offset:0}){let r=e[t.offset]&zf;if(t.offset++,ms[r]!=null)return ms[r](e,t);throw new Error("No decoder for tag "+r)}function xr(e,t){let r=0;if((e[t.offset]&vo)===vo){let n=e[t.offset]&Zf,o="0x";t.offset++;for(let i=0;i<n;i++,t.offset++)o+=e[t.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=e[t.offset],t.offset++;return r}function br(e,t){xr(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=Ut(e,t);if(n===null)break;r.push(n)}return r}function jf(e,t){let r=xr(e,t),n=t.offset,o=t.offset+r,i=[];for(let s=n;s<o;s++)s===n&&e[s]===0||i.push(e[s]);return t.offset+=r,Uint8Array.from(i)}function Gf(e,t){let r=xr(e,t),n=t.offset+r,o=e[t.offset];t.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 a=`${i}.${s}`,c=[];for(;t.offset<n;){let l=e[t.offset];if(t.offset++,c.push(l&127),l<128){c.reverse();let u=0;for(let f=0;f<c.length;f++)u+=c[f]<<f*7;a+=`.${u}`,c=[]}}return a}function Yf(e,t){return t.offset++,null}function Wf(e,t){let r=xr(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Xf(e,t){let r=xr(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function Jf(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new pt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function un(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=Jf(e.byteLength);return new pt(Uint8Array.from([t.byteLength|vo]),t)}function mt(e){let t=new pt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new pt(Uint8Array.from([2]),un(t),t)}function wr(e){let t=Uint8Array.from([0]),r=new pt(t,e);return new pt(Uint8Array.from([3]),un(r),r)}function ys(e){return new pt(Uint8Array.from([4]),un(e),e)}function Nt(e,t=48){let r=new pt;for(let n of e)r.append(n);return new pt(Uint8Array.from([t]),un(r),r)}var gs="1.2.840.10045.3.1.7",bs="1.3.132.0.34",xs="1.3.132.0.35";async function ws(e="P-256"){let t=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:e},!0,["sign","verify"]);return{publicKey:await crypto.subtle.exportKey("jwk",t.publicKey),privateKey:await crypto.subtle.exportKey("jwk",t.privateKey)}}async function Es(e,t,r){let n=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["sign"]);r?.signal?.throwIfAborted();let o=await crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},n,t.subarray());return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function Ss(e,t,r,n){let o=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,t,r.subarray());return n?.signal?.throwIfAborted(),i}var Qf=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),tl=Uint8Array.from([6,5,43,129,4,0,34]),el=Uint8Array.from([6,5,43,129,4,0,35]),vs={ext:!0,kty:"EC",crv:"P-256"},As={ext:!0,kty:"EC",crv:"P-384"},Bs={ext:!0,kty:"EC",crv:"P-521"},qe=32,He=48,$e=66;function Is(e){let t=Ut(e);return Ao(t)}function Ao(e){let t=e[1],r=j(t,"base64url"),n=e[2][1][0],o=1,i,s;if(t.byteLength===qe)return i=j(n.subarray(o,o+qe),"base64url"),s=j(n.subarray(o+qe),"base64url"),new we({...vs,key_ops:["sign"],d:r,x:i,y:s});if(t.byteLength===He)return i=j(n.subarray(o,o+He),"base64url"),s=j(n.subarray(o+He),"base64url"),new we({...As,key_ops:["sign"],d:r,x:i,y:s});if(t.byteLength===$e)return i=j(n.subarray(o,o+$e),"base64url"),s=j(n.subarray(o+$e),"base64url"),new we({...Bs,key_ops:["sign"],d:r,x:i,y:s});throw new rt(`Private key length was wrong length, got ${t.byteLength}, expected 32, 48 or 66`)}function Ts(e){let t=Ut(e);return _s(t)}function _s(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===qe*2+1)return n=j(t.subarray(r,r+qe),"base64url"),o=j(t.subarray(r+qe),"base64url"),new xe({...vs,key_ops:["verify"],x:n,y:o});if(t.byteLength===He*2+1)return n=j(t.subarray(r,r+He),"base64url"),o=j(t.subarray(r+He),"base64url"),new xe({...As,key_ops:["verify"],x:n,y:o});if(t.byteLength===$e*2+1)return n=j(t.subarray(r,r+$e),"base64url"),o=j(t.subarray(r+$e),"base64url"),new xe({...Bs,key_ops:["verify"],x:n,y:o});throw new rt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Cs(e){return Nt([mt(Uint8Array.from([1])),ys(Z(e.d??"","base64url")),Nt([Rs(e.crv)],160),Nt([wr(new pt(Uint8Array.from([4]),Z(e.x??"","base64url"),Z(e.y??"","base64url")))],161)]).subarray()}function Us(e){return Nt([mt(Uint8Array.from([1])),Nt([Rs(e.crv)],160),Nt([wr(new pt(Uint8Array.from([4]),Z(e.x??"","base64url"),Z(e.y??"","base64url")))],161)]).subarray()}function Rs(e){if(e==="P-256")return Qf;if(e==="P-384")return tl;if(e==="P-521")return el;throw new rt(`Invalid curve ${e}`)}async function Ds(e="P-256"){let t=await ws(e);return new we(t.privateKey)}var xe=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Us(this.jwk)),this._raw}toMultihash(){return ge.digest(se(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return ot.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}async verify(t,r,n){return Ss(this.jwk,r,t,n)}},we=class{type="ECDSA";jwk;publicKey;_raw;constructor(t){this.jwk=t,this.publicKey=new xe({crv:t.crv,ext:t.ext,key_ops:["verify"],kty:"EC",x:t.x,y:t.y})}get raw(){return this._raw==null&&(this._raw=Cs(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}async sign(t,r){return Es(this.jwk,t,r)}};function Ee(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ht(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new Error(`${r}expected integer >= 0, got ${e}`)}}function H(e,t,r=""){let n=Ee(e),o=e?.length,i=t!==void 0;if(!n||i&&o!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=n?`length=${o}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+a+", got "+c)}return e}function fn(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash must wrapped by utils.createHasher");Ht(e.outputLen),Ht(e.blockLen)}function ze(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Ns(e,t){H(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function Wt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ln(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function kt(e,t){return e<<32-t|e>>>t}var ks=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",rl=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Xt(e){if(H(e),ks)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=rl[e[r]];return t}var Yt={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ls(e){if(e>=Yt._0&&e<=Yt._9)return e-Yt._0;if(e>=Yt.A&&e<=Yt.F)return e-(Yt.A-10);if(e>=Yt.a&&e<=Yt.f)return e-(Yt.a-10)}function Jt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(ks)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=Ls(e.charCodeAt(i)),a=Ls(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function bt(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];H(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}function Bo(e,t={}){let r=(o,i)=>e(i).update(o).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}function Ze(e=32){let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}var Io=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Ks(e,t,r){return e&t^~e&r}function Os(e,t,r){return e&t^e&r^t&r}var Er=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,o){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=ln(this.buffer)}update(t){ze(this),H(t);let{view:r,buffer:n,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=ln(t);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ze(this),Ns(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,Wt(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let f=s;f<o;f++)r[f]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let a=ln(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,u[f],i)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=a,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Qt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var lt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var dn=BigInt(4294967295),Ms=BigInt(32);function nl(e,t=!1){return t?{h:Number(e&dn),l:Number(e>>Ms&dn)}:{h:Number(e>>Ms&dn)|0,l:Number(e&dn)|0}}function Ps(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=nl(e[i],t);[n[i],o[i]]=[s,a]}return[n,o]}var To=(e,t,r)=>e>>>r,_o=(e,t,r)=>e<<32-r|t>>>r,Se=(e,t,r)=>e>>>r|t<<32-r,ve=(e,t,r)=>e<<32-r|t>>>r,Sr=(e,t,r)=>e<<64-r|t>>>r-32,vr=(e,t,r)=>e>>>r-32|t<<64-r;function $t(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Fs=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Vs=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,qs=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Hs=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,$s=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),zs=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var il=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]),ae=new Uint32Array(64),Co=class extends Er{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[t,r,n,o,i,s,a,c]}set(t,r,n,o,i,s,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,r){for(let f=0;f<16;f++,r+=4)ae[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let x=ae[f-15],v=ae[f-2],b=kt(x,7)^kt(x,18)^x>>>3,A=kt(v,17)^kt(v,19)^v>>>10;ae[f]=A+ae[f-7]+b+ae[f-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:l,H:u}=this;for(let f=0;f<64;f++){let x=kt(a,6)^kt(a,11)^kt(a,25),v=u+x+Ks(a,c,l)+il[f]+ae[f]|0,A=(kt(n,2)^kt(n,13)^kt(n,22))+Os(n,o,i)|0;u=l,l=c,c=a,a=s+v|0,s=i,i=o,o=n,n=v+A|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,l,u)}roundClean(){Wt(ae)}destroy(){this.set(0,0,0,0,0,0,0,0),Wt(this.buffer)}},Uo=class extends Co{A=Qt[0]|0;B=Qt[1]|0;C=Qt[2]|0;D=Qt[3]|0;E=Qt[4]|0;F=Qt[5]|0;G=Qt[6]|0;H=Qt[7]|0;constructor(){super(32)}};var Zs=Ps(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),sl=Zs[0],al=Zs[1],ce=new Uint32Array(80),ue=new Uint32Array(80),Ro=class extends Er{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:l,El:u,Fh:f,Fl:x,Gh:v,Gl:b,Hh:A,Hl:B}=this;return[t,r,n,o,i,s,a,c,l,u,f,x,v,b,A,B]}set(t,r,n,o,i,s,a,c,l,u,f,x,v,b,A,B){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=x|0,this.Gh=v|0,this.Gl=b|0,this.Hh=A|0,this.Hl=B|0}process(t,r){for(let E=0;E<16;E++,r+=4)ce[E]=t.getUint32(r),ue[E]=t.getUint32(r+=4);for(let E=16;E<80;E++){let U=ce[E-15]|0,K=ue[E-15]|0,M=Se(U,K,1)^Se(U,K,8)^To(U,K,7),F=ve(U,K,1)^ve(U,K,8)^_o(U,K,7),p=ce[E-2]|0,m=ue[E-2]|0,C=Se(p,m,19)^Sr(p,m,61)^To(p,m,6),R=ve(p,m,19)^vr(p,m,61)^_o(p,m,6),I=qs(F,R,ue[E-7],ue[E-16]),y=Hs(I,M,C,ce[E-7],ce[E-16]);ce[E]=y|0,ue[E]=I|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:l,Dl:u,Eh:f,El:x,Fh:v,Fl:b,Gh:A,Gl:B,Hh:w,Hl:T}=this;for(let E=0;E<80;E++){let U=Se(f,x,14)^Se(f,x,18)^Sr(f,x,41),K=ve(f,x,14)^ve(f,x,18)^vr(f,x,41),M=f&v^~f&A,F=x&b^~x&B,p=$s(T,K,F,al[E],ue[E]),m=zs(p,w,U,M,sl[E],ce[E]),C=p|0,R=Se(n,o,28)^Sr(n,o,34)^Sr(n,o,39),I=ve(n,o,28)^vr(n,o,34)^vr(n,o,39),y=n&i^n&a^i&a,g=o&s^o&c^s&c;w=A|0,T=B|0,A=v|0,B=b|0,v=f|0,b=x|0,{h:f,l:x}=$t(l|0,u|0,m|0,C|0),l=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let d=Fs(C,I,g);n=Vs(d,m,R,y),o=d|0}({h:n,l:o}=$t(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=$t(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=$t(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=$t(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:x}=$t(this.Eh|0,this.El|0,f|0,x|0),{h:v,l:b}=$t(this.Fh|0,this.Fl|0,v|0,b|0),{h:A,l:B}=$t(this.Gh|0,this.Gl|0,A|0,B|0),{h:w,l:T}=$t(this.Hh|0,this.Hl|0,w|0,T|0),this.set(n,o,i,s,a,c,l,u,f,x,v,b,A,B,w,T)}roundClean(){Wt(ce,ue)}destroy(){Wt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Do=class extends Ro{Ah=lt[0]|0;Al=lt[1]|0;Bh=lt[2]|0;Bl=lt[3]|0;Ch=lt[4]|0;Cl=lt[5]|0;Dh=lt[6]|0;Dl=lt[7]|0;Eh=lt[8]|0;El=lt[9]|0;Fh=lt[10]|0;Fl=lt[11]|0;Gh=lt[12]|0;Gl=lt[13]|0;Hh=lt[14]|0;Hl=lt[15]|0;constructor(){super(64)}};var je=Bo(()=>new Uo,Io(1));var js=Bo(()=>new Do,Io(3));var No=BigInt(0),Lo=BigInt(1);function te(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function Gs(e){if(typeof e=="bigint"){if(!hn(e))throw new Error("positive bigint expected, got "+e)}else Ht(e);return e}function Ar(e){let t=Gs(e).toString(16);return t.length&1?"0"+t:t}function Ys(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?No:BigInt("0x"+e)}function Ge(e){return Ys(Xt(e))}function Ae(e){return Ys(Xt(mn(H(e)).reverse()))}function pn(e,t){Ht(t),e=Gs(e);let r=Jt(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function ko(e,t){return pn(e,t).reverse()}function mn(e){return Uint8Array.from(e)}var hn=e=>typeof e=="bigint"&&No<=e;function cl(e,t,r){return hn(e)&&hn(t)&&hn(r)&&t<=e&&e<r}function Br(e,t,r,n){if(!cl(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Ko(e){let t;for(t=0;e>No;e>>=Lo,t+=1);return t}var Ir=e=>(Lo<<BigInt(e))-Lo;function Ws(e,t,r){if(Ht(e,"hashLen"),Ht(t,"qByteLen"),typeof r!="function")throw new Error("hmacFn must be a function");let n=B=>new Uint8Array(B),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=n(e),l=n(e),u=0,f=()=>{c.fill(1),l.fill(0),u=0},x=(...B)=>r(l,bt(c,...B)),v=(B=o)=>{l=x(i,B),c=x(),B.length!==0&&(l=x(s,B),c=x())},b=()=>{if(u++>=a)throw new Error("drbg: tried max amount of iterations");let B=0,w=[];for(;B<t;){c=x();let T=c.slice();w.push(T),B+=c.length}return bt(...w)};return(B,w)=>{f(),v(B);let T;for(;!(T=w(b()));)v();return f(),T}}function fe(e,t={},r={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function n(i,s,a){let c=e[i];if(a&&c===void 0)return;let l=typeof c;if(l!==s||c===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${l}`)}let o=(i,s)=>Object.entries(i).forEach(([a,c])=>n(a,c,s));o(t,!1),o(r,!0)}function Ye(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let i=e(r,...n);return t.set(r,i),i}}var yt=BigInt(0),at=BigInt(1),Be=BigInt(2),Qs=BigInt(3),ta=BigInt(4),ea=BigInt(5),ul=BigInt(7),ra=BigInt(8),fl=BigInt(9),na=BigInt(16);function nt(e,t){let r=e%t;return r>=yt?r:t+r}function W(e,t,r){let n=e;for(;t-- >yt;)n*=n,n%=r;return n}function Xs(e,t){if(e===yt)throw new Error("invert: expected non-zero number");if(t<=yt)throw new Error("invert: expected positive modulus, got "+t);let r=nt(e,t),n=t,o=yt,i=at,s=at,a=yt;for(;r!==yt;){let l=n/r,u=n%r,f=o-s*l,x=i-a*l;n=r,r=u,o=s,i=a,s=f,a=x}if(n!==at)throw new Error("invert: does not exist");return nt(o,t)}function Mo(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function oa(e,t){let r=(e.ORDER+at)/ta,n=e.pow(t,r);return Mo(e,n,t),n}function ll(e,t){let r=(e.ORDER-ea)/ra,n=e.mul(t,Be),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,Be),o),a=e.mul(i,e.sub(s,e.ONE));return Mo(e,a,t),a}function dl(e){let t=We(e),r=ia(e),n=r(t,t.neg(t.ONE)),o=r(t,n),i=r(t,t.neg(n)),s=(e+ul)/na;return(a,c)=>{let l=a.pow(c,s),u=a.mul(l,n),f=a.mul(l,o),x=a.mul(l,i),v=a.eql(a.sqr(u),c),b=a.eql(a.sqr(f),c);l=a.cmov(l,u,v),u=a.cmov(x,f,b);let A=a.eql(a.sqr(u),c),B=a.cmov(l,u,A);return Mo(a,B,c),B}}function ia(e){if(e<Qs)throw new Error("sqrt is not defined for small field");let t=e-at,r=0;for(;t%Be===yt;)t/=Be,r++;let n=Be,o=We(e);for(;Js(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,t),s=(t+at)/Be;return function(c,l){if(c.is0(l))return l;if(Js(c,l)!==1)throw new Error("Cannot find square root");let u=r,f=c.mul(c.ONE,i),x=c.pow(l,t),v=c.pow(l,s);for(;!c.eql(x,c.ONE);){if(c.is0(x))return c.ZERO;let b=1,A=c.sqr(x);for(;!c.eql(A,c.ONE);)if(b++,A=c.sqr(A),b===u)throw new Error("Cannot find square root");let B=at<<BigInt(u-b-1),w=c.pow(f,B);u=b,f=c.sqr(w),x=c.mul(x,f),v=c.mul(v,w)}return v}}function hl(e){return e%ta===Qs?oa:e%ra===ea?ll:e%na===fl?dl(e):ia(e)}var sa=(e,t)=>(nt(e,t)&at)===at,pl=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Po(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=pl.reduce((n,o)=>(n[o]="function",n),t);return fe(e,r),e}function ml(e,t,r){if(r<yt)throw new Error("invalid exponent, negatives unsupported");if(r===yt)return e.ONE;if(r===at)return t;let n=e.ONE,o=t;for(;r>yt;)r&at&&(n=e.mul(n,o)),o=e.sqr(o),r>>=at;return n}function Tr(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((s,a,c)=>e.is0(a)?s:(n[c]=s,e.mul(s,a)),e.ONE),i=e.inv(o);return t.reduceRight((s,a,c)=>e.is0(a)?s:(n[c]=e.mul(s,n[c]),e.mul(s,a)),i),n}function Js(e,t){let r=(e.ORDER-at)/Be,n=e.pow(t,r),o=e.eql(n,e.ONE),i=e.eql(n,e.ZERO),s=e.eql(n,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function yl(e,t){t!==void 0&&Ht(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var Oo=class{ORDER;BITS;BYTES;isLE;ZERO=yt;ONE=at;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=yt)throw new Error("invalid field: expected ORDER > 0, got "+t);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}=yl(t,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=i,this._sqrt=void 0,Object.preventExtensions(this)}create(t){return nt(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return yt<=t&&t<this.ORDER}is0(t){return t===yt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&at)===at}neg(t){return nt(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return nt(t*t,this.ORDER)}add(t,r){return nt(t+r,this.ORDER)}sub(t,r){return nt(t-r,this.ORDER)}mul(t,r){return nt(t*r,this.ORDER)}pow(t,r){return ml(this,t,r)}div(t,r){return nt(t*Xs(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return Xs(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=hl(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?ko(t,this.BYTES):pn(t,this.BYTES)}fromBytes(t,r=!1){H(t);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:a}=this;if(n){if(!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let l=new Uint8Array(o);l.set(t,i?0:l.length-t.length),t=l}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let c=i?Ae(t):Ge(t);if(a&&(c=nt(c,s)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(t){return Tr(this,t)}cmov(t,r,n){return n?r:t}};function We(e,t={}){return new Oo(e,t)}function aa(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function Fo(e){let t=aa(e);return t+Math.ceil(t/2)}function Vo(e,t,r=!1){H(e);let n=e.length,o=aa(t),i=Fo(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Ae(e):Ge(e),a=nt(s,t-at)+at;return r?ko(a,o):pn(a,o)}var Xe=BigInt(0),Ie=BigInt(1);function _r(e,t){let r=t.negate();return e?r:t}function Te(e,t){let r=Tr(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function la(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function qo(e,t){la(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=Ir(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function ca(e,t,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,a=Number(e&o),c=e>>s;a>n&&(a-=i,c+=Ie);let l=t*n,u=l+Math.abs(a)-1,f=a===0,x=a<0,v=t%2!==0;return{nextN:c,offset:u,isZero:f,isNeg:x,isNegF:v,offsetF:l}}var Ho=new WeakMap,da=new WeakMap;function $o(e){return da.get(e)||1}function ua(e){if(e!==Xe)throw new Error("invalid wNAF")}var Je=class{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let o=t;for(;r>Xe;)r&Ie&&(n=n.add(o)),o=o.double(),r>>=Ie;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=qo(r,this.bits),i=[],s=t,a=s;for(let c=0;c<n;c++){a=s,i.push(a);for(let l=1;l<o;l++)a=a.add(s),i.push(a);s=a.double()}return i}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=qo(t,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:l,isZero:u,isNeg:f,isNegF:x,offsetF:v}=ca(n,a,s);n=c,u?i=i.add(_r(x,r[v])):o=o.add(_r(f,r[l]))}return ua(n),{p:o,f:i}}wNAFUnsafe(t,r,n,o=this.ZERO){let i=qo(t,this.bits);for(let s=0;s<i.windows&&n!==Xe;s++){let{nextN:a,offset:c,isZero:l,isNeg:u}=ca(n,s,i);if(n=a,!l){let f=r[c];o=o.add(u?f.negate():f)}}return ua(n),o}getPrecomputes(t,r,n){let o=Ho.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),Ho.set(r,o))),o}cached(t,r,n){let o=$o(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let i=$o(t);return i===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),r,o)}createCache(t,r){la(r,this.bits),da.set(t,r),Ho.delete(t)}hasCache(t){return $o(t)!==1}};function ha(e,t,r,n){let o=t,i=e.ZERO,s=e.ZERO;for(;r>Xe||n>Xe;)r&Ie&&(i=i.add(o)),n&Ie&&(s=s.add(o)),o=o.double(),r>>=Ie,n>>=Ie;return{p1:i,p2:s}}function fa(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Po(t),t}else return We(e,{isLE:r})}function yn(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let l=t[c];if(!(typeof l=="bigint"&&l>Xe))throw new Error(`CURVE.${c} must be positive bigint`)}let o=fa(t.p,r.Fp,n),i=fa(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:i}}function gn(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var le=BigInt(0),ct=BigInt(1),zo=BigInt(2),gl=BigInt(8);function bl(e,t,r,n){let o=e.sqr(r),i=e.sqr(n),s=e.add(e.mul(t.a,o),i),a=e.add(e.ONE,e.mul(t.d,e.mul(o,i)));return e.eql(s,a)}function pa(e,t={}){let r=yn("edwards",e,t,t.FpFnLE),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s}=i;fe(t,{},{uvRatio:"function"});let a=zo<<BigInt(o.BYTES*8)-ct,c=B=>n.create(B),l=t.uvRatio||((B,w)=>{try{return{isValid:!0,value:n.sqrt(n.div(B,w))}}catch{return{isValid:!1,value:le}}});if(!bl(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function u(B,w,T=!1){let E=T?ct:le;return Br("coordinate "+B,w,E,a),w}function f(B){if(!(B instanceof b))throw new Error("EdwardsPoint expected")}let x=Ye((B,w)=>{let{X:T,Y:E,Z:U}=B,K=B.is0();w==null&&(w=K?gl:n.inv(U));let M=c(T*w),F=c(E*w),p=n.mul(U,w);if(K)return{x:le,y:ct};if(p!==ct)throw new Error("invZ was invalid");return{x:M,y:F}}),v=Ye(B=>{let{a:w,d:T}=i;if(B.is0())throw new Error("bad point: ZERO");let{X:E,Y:U,Z:K,T:M}=B,F=c(E*E),p=c(U*U),m=c(K*K),C=c(m*m),R=c(F*w),I=c(m*c(R+p)),y=c(C+c(T*c(F*p)));if(I!==y)throw new Error("bad point: equation left != right (1)");let g=c(E*U),d=c(K*M);if(g!==d)throw new Error("bad point: equation left != right (2)");return!0});class b{static BASE=new b(i.Gx,i.Gy,ct,c(i.Gx*i.Gy));static ZERO=new b(le,ct,ct,le);static Fp=n;static Fn=o;X;Y;Z;T;constructor(w,T,E,U){this.X=u("x",w),this.Y=u("y",T),this.Z=u("z",E,!0),this.T=u("t",U),Object.freeze(this)}static CURVE(){return i}static fromAffine(w){if(w instanceof b)throw new Error("extended point not allowed");let{x:T,y:E}=w||{};return u("x",T),u("y",E),new b(T,E,ct,c(T*E))}static fromBytes(w,T=!1){let E=n.BYTES,{a:U,d:K}=i;w=mn(H(w,E,"point")),te(T,"zip215");let M=mn(w),F=w[E-1];M[E-1]=F&-129;let p=Ae(M),m=T?a:n.ORDER;Br("point.y",p,le,m);let C=c(p*p),R=c(C-ct),I=c(K*C-U),{isValid:y,value:g}=l(R,I);if(!y)throw new Error("bad point: invalid y coordinate");let d=(g&ct)===ct,S=(F&128)!==0;if(!T&&g===le&&S)throw new Error("bad point: x=0 and x_0=1");return S!==d&&(g=c(-g)),b.fromAffine({x:g,y:p})}static fromHex(w,T=!1){return b.fromBytes(Jt(w),T)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,T=!0){return A.createCache(this,w),T||this.multiply(zo),this}assertValidity(){v(this)}equals(w){f(w);let{X:T,Y:E,Z:U}=this,{X:K,Y:M,Z:F}=w,p=c(T*F),m=c(K*U),C=c(E*F),R=c(M*U);return p===m&&C===R}is0(){return this.equals(b.ZERO)}negate(){return new b(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:w}=i,{X:T,Y:E,Z:U}=this,K=c(T*T),M=c(E*E),F=c(zo*c(U*U)),p=c(w*K),m=T+E,C=c(c(m*m)-K-M),R=p+M,I=R-F,y=p-M,g=c(C*I),d=c(R*y),S=c(C*y),D=c(I*R);return new b(g,d,D,S)}add(w){f(w);let{a:T,d:E}=i,{X:U,Y:K,Z:M,T:F}=this,{X:p,Y:m,Z:C,T:R}=w,I=c(U*p),y=c(K*m),g=c(F*E*R),d=c(M*C),S=c((U+K)*(p+m)-I-y),D=d-g,N=d+g,k=c(y-T*I),O=c(S*D),P=c(N*k),q=c(S*k),X=c(D*N);return new b(O,P,X,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:T,f:E}=A.cached(this,w,U=>Te(b,U));return Te(b,[T,E])[0]}multiplyUnsafe(w,T=b.ZERO){if(!o.isValid(w))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return w===le?b.ZERO:this.is0()||w===ct?this:A.unsafe(this,w,E=>Te(b,E),T)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return A.unsafe(this,i.n).is0()}toAffine(w){return x(this,w)}clearCofactor(){return s===ct?this:this.multiplyUnsafe(s)}toBytes(){let{x:w,y:T}=this.toAffine(),E=n.toBytes(T);return E[E.length-1]|=w&ct?128:0,E}toHex(){return Xt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let A=new Je(b,o.BITS);return b.BASE.precompute(8),b}function ma(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');fe(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:n}=r,{BASE:o,Fp:i,Fn:s}=e,a=r.randomBytes||Ze,c=r.adjustScalarBytes||(p=>p),l=r.domain||((p,m,C)=>{if(te(C,"phflag"),m.length||C)throw new Error("Contexts/pre-hash are not supported");return p});function u(p){return s.create(Ae(p))}function f(p){let m=E.secretKey;H(p,E.secretKey,"secretKey");let C=H(t(p),2*m,"hashedSecretKey"),R=c(C.slice(0,m)),I=C.slice(m,2*m),y=u(R);return{head:R,prefix:I,scalar:y}}function x(p){let{head:m,prefix:C,scalar:R}=f(p),I=o.multiply(R),y=I.toBytes();return{head:m,prefix:C,scalar:R,point:I,pointBytes:y}}function v(p){return x(p).pointBytes}function b(p=Uint8Array.of(),...m){let C=bt(...m);return u(t(l(C,H(p,void 0,"context"),!!n)))}function A(p,m,C={}){p=H(p,void 0,"message"),n&&(p=n(p));let{prefix:R,scalar:I,pointBytes:y}=x(m),g=b(C.context,R,p),d=o.multiply(g).toBytes(),S=b(C.context,d,y,p),D=s.create(g+S*I);if(!s.isValid(D))throw new Error("sign failed: invalid s");let N=bt(d,s.toBytes(D));return H(N,E.signature,"result")}let B={zip215:!0};function w(p,m,C,R=B){let{context:I,zip215:y}=R,g=E.signature;p=H(p,g,"signature"),m=H(m,void 0,"message"),C=H(C,E.publicKey,"publicKey"),y!==void 0&&te(y,"zip215"),n&&(m=n(m));let d=g/2,S=p.subarray(0,d),D=Ae(p.subarray(d,g)),N,k,O;try{N=e.fromBytes(C,y),k=e.fromBytes(S,y),O=o.multiplyUnsafe(D)}catch{return!1}if(!y&&N.isSmallOrder())return!1;let P=b(I,k.toBytes(),N.toBytes(),m);return k.add(N.multiplyUnsafe(P)).subtract(O).clearCofactor().is0()}let T=i.BYTES,E={secretKey:T,publicKey:T,signature:2*T,seed:T};function U(p=a(E.seed)){return H(p,E.seed,"seed")}function K(p){return Ee(p)&&p.length===s.BYTES}function M(p,m){try{return!!e.fromBytes(p,m)}catch{return!1}}let F={getExtendedPublicKey:x,randomSecretKey:U,isValidSecretKey:K,isValidPublicKey:M,toMontgomery(p){let{y:m}=e.fromBytes(p),C=E.publicKey,R=C===32;if(!R&&C!==57)throw new Error("only defined for 25519 and 448");let I=R?i.div(ct+m,ct-m):i.div(m-ct,m+ct);return i.toBytes(I)},toMontgomerySecret(p){let m=E.secretKey;H(p,m);let C=t(p.subarray(0,m));return c(C).subarray(0,m)}};return Object.freeze({keygen:gn(U,v),getPublicKey:v,sign:A,verify:w,utils:F,Point:e,lengths:E})}var xl=BigInt(1),ya=BigInt(2);var wl=BigInt(5),El=BigInt(8),Zo=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Sl={p:Zo,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:El,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function vl(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=Zo,a=e*e%i*e%i,c=W(a,ya,i)*a%i,l=W(c,xl,i)*e%i,u=W(l,wl,i)*l%i,f=W(u,t,i)*u%i,x=W(f,r,i)*f%i,v=W(x,n,i)*x%i,b=W(v,o,i)*v%i,A=W(b,o,i)*v%i,B=W(A,t,i)*u%i;return{pow_p_5_8:W(B,ya,i)*e%i,b2:a}}function Al(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var ga=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Bl(e,t){let r=Zo,n=nt(t*t*t,r),o=nt(n*n*t,r),i=vl(e*o).pow_p_5_8,s=nt(e*n*i,r),a=nt(t*s*s,r),c=s,l=nt(s*ga,r),u=a===e,f=a===nt(-e,r),x=a===nt(-e*ga,r);return u&&(s=c),(f||x)&&(s=l),sa(s,r)&&(s=nt(-s,r)),{isValid:u||f,value:s}}var Il=pa(Sl,{uvRatio:Bl});function Tl(e){return ma(Il,js,Object.assign({adjustScalarBytes:Al},e))}var Cr=Tl({});var Ur=class extends Error{constructor(t="An error occurred while signing a message"){super(t),this.name="SigningError"}},Rr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},bn=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var ba={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new bn("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var xt=ba;var _e=32,At=64,jo=32;var Qe,xa=(async()=>{try{return await xt.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();function wa(){let e=Cr.utils.randomSecretKey(),t=Cr.getPublicKey(e);return{privateKey:Dl(e,t),publicKey:t}}async function _l(e,t){let r;e.length===At?r=e.subarray(0,32):r=e;let n={crv:"Ed25519",kty:"OKP",x:j(e.subarray(32),"base64url"),d:j(r,"base64url"),ext:!0,key_ops:["sign"]},o=await xt.get().subtle.importKey("jwk",n,{name:"Ed25519"},!0,["sign"]),i=await xt.get().subtle.sign({name:"Ed25519"},o,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(i,0,i.byteLength)}function Cl(e,t){let r=e.subarray(0,jo);return Cr.sign(t instanceof Uint8Array?t:t.subarray(),r)}async function Ea(e,t){return Qe==null&&(Qe=await xa),Qe?_l(e,t):Cl(e,t)}async function Ul(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await xt.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await xt.get().subtle.verify({name:"Ed25519"},n,t,r instanceof Uint8Array?r:r.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Rl(e,t,r){return Cr.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function Sa(e,t,r){return Qe==null&&(Qe=await xa),Qe?Ul(e,t,r):Rl(e,t,r)}function Dl(e,t){let r=new Uint8Array(At);for(let n=0;n<jo;n++)r[n]=e[n],r[jo+n]=t[n];return r}function tr(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var Dr=class{type="Ed25519";raw;constructor(t){this.raw=rr(t,_e)}toMultihash(){return ge.digest(se(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return ot.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=Sa(this.raw,r,t);return tr(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}},er=class{type="Ed25519";raw;publicKey;constructor(t,r){this.raw=rr(t,At),this.publicKey=new Dr(r)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}sign(t,r){r?.signal?.throwIfAborted();let n=Ea(this.raw,t);return tr(n)?n.then(o=>(r?.signal?.throwIfAborted(),o)):(r?.signal?.throwIfAborted(),n)}};function Go(e){if(e.length>At){e=rr(e,At+_e);let n=e.subarray(0,At),o=e.subarray(At,e.length);return new er(n,o)}e=rr(e,At);let t=e.subarray(0,At),r=e.subarray(_e);return new er(t,r)}function Aa(e){return e=rr(e,_e),new Dr(e)}async function Ba(){let{privateKey:e,publicKey:t}=wa();return new er(e,t)}function rr(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new rt(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var Ll=Math.pow(2,7),Nl=Math.pow(2,14),kl=Math.pow(2,21),Ia=Math.pow(2,28),Ta=Math.pow(2,35),_a=Math.pow(2,42),Ca=Math.pow(2,49),gt=128,de=127;function Lr(e){if(e<Ll)return 1;if(e<Nl)return 2;if(e<kl)return 3;if(e<Ia)return 4;if(e<Ta)return 5;if(e<_a)return 6;if(e<Ca)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Ua(e,t,r=0){switch(Lr(e)){case 8:t[r++]=e&255|gt,e/=128;case 7:t[r++]=e&255|gt,e/=128;case 6:t[r++]=e&255|gt,e/=128;case 5:t[r++]=e&255|gt,e/=128;case 4:t[r++]=e&255|gt,e>>>=7;case 3:t[r++]=e&255|gt,e>>>=7;case 2:t[r++]=e&255|gt,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Ra(e,t){let r=e[t],n=0;if(n+=r&de,r<gt||(r=e[t+1],n+=(r&de)<<7,r<gt)||(r=e[t+2],n+=(r&de)<<14,r<gt)||(r=e[t+3],n+=(r&de)<<21,r<gt)||(r=e[t+4],n+=(r&de)*Ia,r<gt)||(r=e[t+5],n+=(r&de)*Ta,r<gt)||(r=e[t+6],n+=(r&de)*_a,r<gt)||(r=e[t+7],n+=(r&de)*Ca,r<gt))return n;throw new RangeError("Could not decode varint")}var Yo=new Float32Array([-0]),he=new Uint8Array(Yo.buffer);function Da(e,t,r){Yo[0]=e,t[r]=he[0],t[r+1]=he[1],t[r+2]=he[2],t[r+3]=he[3]}function La(e,t){return he[0]=e[t],he[1]=e[t+1],he[2]=e[t+2],he[3]=e[t+3],Yo[0]}var Wo=new Float64Array([-0]),ht=new Uint8Array(Wo.buffer);function Na(e,t,r){Wo[0]=e,t[r]=ht[0],t[r+1]=ht[1],t[r+2]=ht[2],t[r+3]=ht[3],t[r+4]=ht[4],t[r+5]=ht[5],t[r+6]=ht[6],t[r+7]=ht[7]}function ka(e,t){return ht[0]=e[t],ht[1]=e[t+1],ht[2]=e[t+2],ht[3]=e[t+3],ht[4]=e[t+4],ht[5]=e[t+5],ht[6]=e[t+6],ht[7]=e[t+7],Wo[0]}var Kl=BigInt(Number.MAX_SAFE_INTEGER),Ol=BigInt(Number.MIN_SAFE_INTEGER),Bt=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Ce;if(t<Kl&&t>Ol)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>Ka&&(o=0n,++n>Ka&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Ce;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):Ce}},Ce=new Bt(0,0);Ce.toBigInt=function(){return 0n};Ce.zzEncode=Ce.zzDecode=function(){return this};Ce.length=function(){return 1};var Ka=4294967296n;function Oa(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Ma(e,t,r){if(r-t<1)return"";let o,i=[],s=0,a;for(;t<r;)a=e[t++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|e[t++]&63:a>239&&a<365?(a=((a&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(e[t++]&63)<<6|e[t++]&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 Xo(e,t,r){let n=r,o,i;for(let s=0;s<e.length;++s)o=e.charCodeAt(s),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((i=e.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function Kt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function xn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Jo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Kt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Kt(this,4);return xn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Kt(this,4);return xn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Kt(this,4);let t=La(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Kt(this,4);let t=ka(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw Kt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Ma(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Kt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Kt(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new Bt(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Kt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw Kt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Kt(this,8);let t=xn(this.buf,this.pos+=4),r=xn(this.buf,this.pos+=4);return new Bt(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Ra(this.buf,this.pos);return this.pos+=Lr(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Qo(e){return new Jo(e instanceof Uint8Array?e:e.subarray())}function nr(e,t,r){let n=Qo(e);return t.decode(n,void 0,r)}function ti(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return vt(s);o+s>t&&(n=vt(t),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var Ue=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function ei(){}var ni=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Ml=ti();function Pl(e){return globalThis.Buffer!=null?vt(e):Ml(e)}var kr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Ue(ei,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new Ue(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new oi((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(wn,10,Bt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Bt.fromBigInt(t);return this._push(wn,r.length(),r)}uint64Number(t){return this._push(Ua,Lr(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let r=Bt.fromBigInt(t).zzEncode();return this._push(wn,r.length(),r)}sint64Number(t){let r=Bt.fromNumber(t).zzEncode();return this._push(wn,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(ri,1,t?1:0)}fixed32(t){return this._push(Nr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Bt.fromBigInt(t);return this._push(Nr,4,r.lo)._push(Nr,4,r.hi)}fixed64Number(t){let r=Bt.fromNumber(t);return this._push(Nr,4,r.lo)._push(Nr,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Da,4,t)}double(t){return this._push(Na,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(ri,1,0):this.uint32(r)._push(Vl,r,t)}string(t){let r=Oa(t);return r!==0?this.uint32(r)._push(Xo,r,t):this._push(ri,1,0)}fork(){return this.states=new ni(this),this.head=this.tail=new Ue(ei,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 Ue(ei,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=Pl(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function ri(e,t,r){t[r]=e&255}function Fl(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var oi=class extends Ue{next;constructor(t,r){super(Fl,t,r),this.next=void 0}};function wn(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function Nr(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function Vl(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(kr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(ql,t,e),this},kr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Hl,t,e),this});function ql(e,t,r){t.set(e,r)}function Hl(e,t,r){e.length<40?Xo(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(Z(e),r)}function ii(){return new kr}function or(e,t){let r=ii();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var ir;(function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"})(ir||(ir={}));function En(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Kr(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(i,s){let a=t(i);s.int32(a)},n=function(i){let s=i.int32();return t(s)};return En("enum",ir.VARINT,r,n)}function sr(e,t){return En("message",ir.LENGTH_DELIMITED,e,t)}var et;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(et||(et={}));var si;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(si||(si={}));(function(e){e.codec=()=>Kr(si)})(et||(et={}));var ee;(function(e){let t;e.codec=()=>(t==null&&(t=sr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),et.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 a=r.uint32();switch(a>>>3){case 1:{i.Type=et.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>or(r,e.codec()),e.decode=(r,n)=>nr(r,e.codec(),n)})(ee||(ee={}));var Sn;(function(e){let t;e.codec=()=>(t==null&&(t=sr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),et.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 a=r.uint32();switch(a>>>3){case 1:{i.Type=et.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>or(r,e.codec()),e.decode=(r,n)=>nr(r,e.codec(),n)})(Sn||(Sn={}));var Mr={};St(Mr,{MAX_RSA_KEY_SIZE:()=>ai,generateRSAKeyPair:()=>yi,jwkToJWKKeyPair:()=>Ha,jwkToPkcs1:()=>jl,jwkToPkix:()=>li,jwkToRSAPrivateKey:()=>mi,pkcs1MessageToJwk:()=>ui,pkcs1MessageToRSAPrivateKey:()=>vn,pkcs1ToJwk:()=>Zl,pkcs1ToRSAPrivateKey:()=>di,pkixMessageToJwk:()=>fi,pkixMessageToRSAPublicKey:()=>pi,pkixToJwk:()=>Gl,pkixToRSAPublicKey:()=>hi});var ar=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=Mr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return it.createV1(114,this._multihash)}toString(){return ot.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}verify(t,r,n){return qa(this.jwk,r,t,n)}},Or=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=Mr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}sign(t,r){return Va(this.jwk,t,r)}};var ai=8192,ci=18,$l=1062,zl=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Zl(e){let t=Ut(e);return ui(t)}function ui(e){return{n:j(e[1],"base64url"),e:j(e[2],"base64url"),d:j(e[3],"base64url"),p:j(e[4],"base64url"),q:j(e[5],"base64url"),dp:j(e[6],"base64url"),dq:j(e[7],"base64url"),qi:j(e[8],"base64url"),kty:"RSA"}}function jl(e){if(e.n==null||e.e==null||e.d==null||e.p==null||e.q==null||e.dp==null||e.dq==null||e.qi==null)throw new rt("JWK was missing components");return Nt([mt(Uint8Array.from([0])),mt(Z(e.n,"base64url")),mt(Z(e.e,"base64url")),mt(Z(e.d,"base64url")),mt(Z(e.p,"base64url")),mt(Z(e.q,"base64url")),mt(Z(e.dp,"base64url")),mt(Z(e.dq,"base64url")),mt(Z(e.qi,"base64url"))]).subarray()}function Gl(e){let t=Ut(e,{offset:0});return fi(t)}function fi(e){let t=Ut(e[1],{offset:0});return{kty:"RSA",n:j(t[0],"base64url"),e:j(t[1],"base64url")}}function li(e){if(e.n==null||e.e==null)throw new rt("JWK was missing components");return Nt([zl,wr(Nt([mt(Z(e.n,"base64url")),mt(Z(e.e,"base64url"))]))]).subarray()}function di(e){let t=Ut(e);return vn(t)}function vn(e){let t=ui(e);return mi(t)}function hi(e,t){if(e.byteLength>=$l)throw new ke("Key size is too large");let r=Ut(e,{offset:0});return pi(r,e,t)}function pi(e,t,r){let n=fi(e);if(r==null){let o=je(ee.encode({Type:et.RSA,Data:t}));r=qt(ci,o)}return new ar(n,r)}function mi(e){if(za(e)>ai)throw new rt("Key size is too large");let t=Ha(e),r=je(ee.encode({Type:et.RSA,Data:li(t.publicKey)})),n=qt(ci,r);return new Or(t.privateKey,new ar(t.publicKey,n))}async function yi(e){if(e>ai)throw new rt("Key size is too large");let t=await $a(e),r=je(ee.encode({Type:et.RSA,Data:li(t.publicKey)})),n=qt(ci,r);return new Or(t.privateKey,new ar(t.publicKey,n))}function Ha(e){if(e==null)throw new rt("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function $a(e,t){let r=await xt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);t?.signal?.throwIfAborted();let n=await Yl(r,t);return{privateKey:n[0],publicKey:n[1]}}async function Va(e,t,r){let n=await xt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await xt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,t instanceof Uint8Array?t:t.subarray());return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function qa(e,t,r,n){let o=await xt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await xt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,t,r instanceof Uint8Array?r:r.subarray());return n?.signal?.throwIfAborted(),i}async function Yl(e,t){if(e.privateKey==null||e.publicKey==null)throw new rt("Private and public key are required");let r=await Promise.all([xt.get().subtle.exportKey("jwk",e.privateKey),xt.get().subtle.exportKey("jwk",e.publicKey)]);return t?.signal?.throwIfAborted(),r}function za(e){if(e.kty!=="RSA")throw new rt("invalid key type");if(e.n==null)throw new rt("invalid key modulus");return Z(e.n,"base64url").length*8}var An=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(t,r){if(fn(t),H(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=t.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),Wt(o)}update(t){return ze(this),this.iHash.update(t),this}digestInto(t){ze(this),H(t,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},gi=(e,t,r)=>new An(e,t).update(r).digest();gi.create=(e,t)=>new An(e,t);var Za=(e,t)=>(e+(e>=0?t:-t)/ja)/t;function Wl(e,t,r){let[[n,o],[i,s]]=t,a=Za(s*e,r),c=Za(-o*e,r),l=e-a*n-c*i,u=-a*o-c*s,f=l<re,x=u<re;f&&(l=-l),x&&(u=-u);let v=Ir(Math.ceil(Ko(r)/2))+cr;if(l<re||l>=v||u<re||u>=v)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:l,k2neg:x,k2:u}}function xi(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function bi(e,t){let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return te(r.lowS,"lowS"),te(r.prehash,"prehash"),r.format!==void 0&&xi(r.format),r}var wi=class extends Error{constructor(t=""){super(t)}},pe={Err:wi,_tlv:{encode:(e,t)=>{let{Err:r}=pe;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=Ar(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Ar(o.length/2|128):"";return Ar(e)+i+o+t},decode(e,t){let{Err:r}=pe,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=pe;if(e<re)throw new t("integer: negative integers are not allowed");let r=Ar(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=pe;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Ge(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=pe,o=H(e,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:l,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=pe,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},re=BigInt(0),cr=BigInt(1),ja=BigInt(2),Bn=BigInt(3),Xl=BigInt(4);function Ga(e,t={}){let r=yn("weierstrass",e,t),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s,n:a}=i;fe(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=t;if(c&&(!n.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let l=Wa(n,o);function u(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function f(I,y,g){let{x:d,y:S}=y.toAffine(),D=n.toBytes(d);if(te(g,"isCompressed"),g){u();let N=!n.isOdd(S);return bt(Ya(N),D)}else return bt(Uint8Array.of(4),D,n.toBytes(S))}function x(I){H(I,void 0,"Point");let{publicKey:y,publicKeyUncompressed:g}=l,d=I.length,S=I[0],D=I.subarray(1);if(d===y&&(S===2||S===3)){let N=n.fromBytes(D);if(!n.isValid(N))throw new Error("bad point: is not on curve, wrong x");let k=A(N),O;try{O=n.sqrt(k)}catch(X){let Y=X instanceof Error?": "+X.message:"";throw new Error("bad point: is not on curve, sqrt error"+Y)}u();let P=n.isOdd(O);return(S&1)===1!==P&&(O=n.neg(O)),{x:N,y:O}}else if(d===g&&S===4){let N=n.BYTES,k=n.fromBytes(D.subarray(0,N)),O=n.fromBytes(D.subarray(N,N*2));if(!B(k,O))throw new Error("bad point: is not on curve");return{x:k,y:O}}else throw new Error(`bad point: got length ${d}, expected compressed=${y} or uncompressed=${g}`)}let v=t.toBytes||f,b=t.fromBytes||x;function A(I){let y=n.sqr(I),g=n.mul(y,I);return n.add(n.add(g,n.mul(I,i.a)),i.b)}function B(I,y){let g=n.sqr(y),d=A(I);return n.eql(g,d)}if(!B(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let w=n.mul(n.pow(i.a,Bn),Xl),T=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(w,T)))throw new Error("bad curve params: a or b");function E(I,y,g=!1){if(!n.isValid(y)||g&&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 K(I){if(!c||!c.basises)throw new Error("no endo");return Wl(I,c.basises,o.ORDER)}let M=Ye((I,y)=>{let{X:g,Y:d,Z:S}=I;if(n.eql(S,n.ONE))return{x:g,y:d};let D=I.is0();y==null&&(y=D?n.ONE:n.inv(S));let N=n.mul(g,y),k=n.mul(d,y),O=n.mul(S,y);if(D)return{x:n.ZERO,y:n.ZERO};if(!n.eql(O,n.ONE))throw new Error("invZ was invalid");return{x:N,y:k}}),F=Ye(I=>{if(I.is0()){if(t.allowInfinityPoint&&!n.is0(I.Y))return;throw new Error("bad point: ZERO")}let{x:y,y:g}=I.toAffine();if(!n.isValid(y)||!n.isValid(g))throw new Error("bad point: x or y not field elements");if(!B(y,g))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,g,d,S){return g=new m(n.mul(g.X,I),g.Y,g.Z),y=_r(d,y),g=_r(S,g),y.add(g)}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,g,d){this.X=E("x",y),this.Y=E("y",g,!0),this.Z=E("z",d),Object.freeze(this)}static CURVE(){return i}static fromAffine(y){let{x:g,y:d}=y||{};if(!y||!n.isValid(g)||!n.isValid(d))throw new Error("invalid affine point");if(y instanceof m)throw new Error("projective point not allowed");return n.is0(g)&&n.is0(d)?m.ZERO:new m(g,d,n.ONE)}static fromBytes(y){let g=m.fromAffine(b(H(y,void 0,"point")));return g.assertValidity(),g}static fromHex(y){return m.fromBytes(Jt(y))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,g=!0){return R.createCache(this,y),g||this.multiply(Bn),this}assertValidity(){F(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:g,Y:d,Z:S}=this,{X:D,Y:N,Z:k}=y,O=n.eql(n.mul(g,k),n.mul(D,S)),P=n.eql(n.mul(d,k),n.mul(N,S));return O&&P}negate(){return new m(this.X,n.neg(this.Y),this.Z)}double(){let{a:y,b:g}=i,d=n.mul(g,Bn),{X:S,Y:D,Z:N}=this,k=n.ZERO,O=n.ZERO,P=n.ZERO,q=n.mul(S,S),X=n.mul(D,D),Y=n.mul(N,N),$=n.mul(S,D);return $=n.add($,$),P=n.mul(S,N),P=n.add(P,P),k=n.mul(y,P),O=n.mul(d,Y),O=n.add(k,O),k=n.sub(X,O),O=n.add(X,O),O=n.mul(k,O),k=n.mul($,k),P=n.mul(d,P),Y=n.mul(y,Y),$=n.sub(q,Y),$=n.mul(y,$),$=n.add($,P),P=n.add(q,q),q=n.add(P,q),q=n.add(q,Y),q=n.mul(q,$),O=n.add(O,q),Y=n.mul(D,N),Y=n.add(Y,Y),q=n.mul(Y,$),k=n.sub(k,q),P=n.mul(Y,X),P=n.add(P,P),P=n.add(P,P),new m(k,O,P)}add(y){U(y);let{X:g,Y:d,Z:S}=this,{X:D,Y:N,Z:k}=y,O=n.ZERO,P=n.ZERO,q=n.ZERO,X=i.a,Y=n.mul(i.b,Bn),$=n.mul(g,D),J=n.mul(d,N),ft=n.mul(S,k),Vt=n.add(g,d),Q=n.add(D,N);Vt=n.mul(Vt,Q),Q=n.add($,J),Vt=n.sub(Vt,Q),Q=n.add(g,S);let dt=n.add(D,k);return Q=n.mul(Q,dt),dt=n.add($,ft),Q=n.sub(Q,dt),dt=n.add(d,S),O=n.add(N,k),dt=n.mul(dt,O),O=n.add(J,ft),dt=n.sub(dt,O),q=n.mul(X,Q),O=n.mul(Y,ft),q=n.add(O,q),O=n.sub(J,q),q=n.add(J,q),P=n.mul(O,q),J=n.add($,$),J=n.add(J,$),ft=n.mul(X,ft),Q=n.mul(Y,Q),J=n.add(J,ft),ft=n.sub($,ft),ft=n.mul(X,ft),Q=n.add(Q,ft),$=n.mul(J,Q),P=n.add(P,$),$=n.mul(dt,Q),O=n.mul(Vt,O),O=n.sub(O,$),$=n.mul(Vt,J),q=n.mul(dt,q),q=n.add(q,$),new m(O,P,q)}subtract(y){return this.add(y.negate())}is0(){return this.equals(m.ZERO)}multiply(y){let{endo:g}=t;if(!o.isValidNot0(y))throw new Error("invalid scalar: out of range");let d,S,D=N=>R.cached(this,N,k=>Te(m,k));if(g){let{k1neg:N,k1:k,k2neg:O,k2:P}=K(y),{p:q,f:X}=D(k),{p:Y,f:$}=D(P);S=X.add($),d=p(g.beta,q,Y,N,O)}else{let{p:N,f:k}=D(y);d=N,S=k}return Te(m,[d,S])[0]}multiplyUnsafe(y){let{endo:g}=t,d=this;if(!o.isValid(y))throw new Error("invalid scalar: out of range");if(y===re||d.is0())return m.ZERO;if(y===cr)return d;if(R.hasCache(this))return this.multiply(y);if(g){let{k1neg:S,k1:D,k2neg:N,k2:k}=K(y),{p1:O,p2:P}=ha(m,d,D,k);return p(g.beta,O,P,S,N)}else return R.unsafe(d,y)}toAffine(y){return M(this,y)}isTorsionFree(){let{isTorsionFree:y}=t;return s===cr?!0:y?y(m,this):R.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:y}=t;return s===cr?this:y?y(m,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(y=!0){return te(y,"isCompressed"),this.assertValidity(),v(m,this,y)}toHex(y=!0){return Xt(this.toBytes(y))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let C=o.BITS,R=new Je(m,t.endo?Math.ceil(C/2):C);return m.BASE.precompute(8),m}function Ya(e){return Uint8Array.of(e?2:3)}function Wa(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Jl(e,t={}){let{Fn:r}=e,n=t.randomBytes||Ze,o=Object.assign(Wa(e.Fp,r),{seed:Fo(r.ORDER)});function i(v){try{let b=r.fromBytes(v);return r.isValidNot0(b)}catch{return!1}}function s(v,b){let{publicKey:A,publicKeyUncompressed:B}=o;try{let w=v.length;return b===!0&&w!==A||b===!1&&w!==B?!1:!!e.fromBytes(v)}catch{return!1}}function a(v=n(o.seed)){return Vo(H(v,o.seed,"seed"),r.ORDER)}function c(v,b=!0){return e.BASE.multiply(r.fromBytes(v)).toBytes(b)}function l(v){let{secretKey:b,publicKey:A,publicKeyUncompressed:B}=o;if(!Ee(v)||"_lengths"in r&&r._lengths||b===A)return;let w=H(v,void 0,"key").length;return w===A||w===B}function u(v,b,A=!0){if(l(v)===!0)throw new Error("first arg must be private key");if(l(b)===!1)throw new Error("second arg must be public key");let B=r.fromBytes(v);return e.fromBytes(b).multiply(B).toBytes(A)}let f={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},x=gn(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:x,Point:e,utils:f,lengths:o})}function Xa(e,t,r={}){fn(t),fe(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||Ze,o=r.hmac||((g,d)=>gi(t,g,d)),{Fp:i,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:l,getPublicKey:u,getSharedSecret:f,utils:x,lengths:v}=Jl(e,r),b={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},A=a*ja<i.ORDER;function B(g){let d=a>>cr;return g>d}function w(g,d){if(!s.isValidNot0(d))throw new Error(`invalid signature ${g}: out of range 1..Point.Fn.ORDER`);return d}function T(){if(A)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function E(g,d){xi(d);let S=v.signature,D=d==="compact"?S:d==="recovered"?S+1:void 0;return H(g,D)}class U{r;s;recovery;constructor(d,S,D){if(this.r=w("r",d),this.s=w("s",S),D!=null){if(T(),![0,1,2,3].includes(D))throw new Error("invalid recovery id");this.recovery=D}Object.freeze(this)}static fromBytes(d,S=b.format){E(d,S);let D;if(S==="der"){let{r:P,s:q}=pe.toSig(H(d));return new U(P,q)}S==="recovered"&&(D=d[0],S="compact",d=d.subarray(1));let N=v.signature/2,k=d.subarray(0,N),O=d.subarray(N,N*2);return new U(s.fromBytes(k),s.fromBytes(O),D)}static fromHex(d,S){return this.fromBytes(Jt(d),S)}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:S,s:D}=this,N=this.assertRecovery(),k=N===2||N===3?S+a:S;if(!i.isValid(k))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let O=i.toBytes(k),P=e.fromBytes(bt(Ya((N&1)===0),O)),q=s.inv(k),X=M(H(d,void 0,"msgHash")),Y=s.create(-X*q),$=s.create(D*q),J=e.BASE.multiplyUnsafe(Y).add(P.multiplyUnsafe($));if(J.is0())throw new Error("invalid recovery: point at infinify");return J.assertValidity(),J}hasHighS(){return B(this.s)}toBytes(d=b.format){if(xi(d),d==="der")return Jt(pe.hexFromSig(this));let{r:S,s:D}=this,N=s.toBytes(S),k=s.toBytes(D);return d==="recovered"?(T(),bt(Uint8Array.of(this.assertRecovery()),N,k)):bt(N,k)}toHex(d){return Xt(this.toBytes(d))}}let K=r.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");let S=Ge(d),D=d.length*8-c;return D>0?S>>BigInt(D):S},M=r.bits2int_modN||function(d){return s.create(K(d))},F=Ir(c);function p(g){return Br("num < 2^"+c,g,re,F),s.toBytes(g)}function m(g,d){return H(g,void 0,"message"),d?H(t(g),void 0,"prehashed message"):g}function C(g,d,S){let{lowS:D,prehash:N,extraEntropy:k}=bi(S,b);g=m(g,N);let O=M(g),P=s.fromBytes(d);if(!s.isValidNot0(P))throw new Error("invalid private key");let q=[p(P),p(O)];if(k!=null&&k!==!1){let J=k===!0?n(v.secretKey):k;q.push(H(J,void 0,"extraEntropy"))}let X=bt(...q),Y=O;function $(J){let ft=K(J);if(!s.isValidNot0(ft))return;let Vt=s.inv(ft),Q=e.BASE.multiply(ft).toAffine(),dt=s.create(Q.x);if(dt===re)return;let rn=s.create(Vt*s.create(Y+dt*P));if(rn===re)return;let Hi=(Q.x===dt?0:2)|Number(Q.y&cr),$i=rn;return D&&B(rn)&&($i=s.neg(rn),Hi^=1),new U(dt,$i,A?void 0:Hi)}return{seed:X,k2sig:$}}function R(g,d,S={}){let{seed:D,k2sig:N}=C(g,d,S);return Ws(t.outputLen,s.BYTES,o)(D,N).toBytes(S.format)}function I(g,d,S,D={}){let{lowS:N,prehash:k,format:O}=bi(D,b);if(S=H(S,void 0,"publicKey"),d=m(d,k),!Ee(g)){let P=g instanceof U?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+P)}E(g,O);try{let P=U.fromBytes(g,O),q=e.fromBytes(S);if(N&&P.hasHighS())return!1;let{r:X,s:Y}=P,$=M(d),J=s.inv(Y),ft=s.create($*J),Vt=s.create(X*J),Q=e.BASE.multiplyUnsafe(ft).add(q.multiplyUnsafe(Vt));return Q.is0()?!1:s.create(Q.x)===X}catch{return!1}}function y(g,d,S={}){let{prehash:D}=bi(S,b);return d=m(d,D),U.fromBytes(g,"recovered").recoverPublicKey(d).toBytes()}return Object.freeze({keygen:l,getPublicKey:u,getSharedSecret:f,utils:x,lengths:v,Point:e,sign:R,verify:I,recoverPublicKey:y,Signature:U,hash:t})}var Si={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Ql={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Ja=BigInt(2);function td(e){let t=Si.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,f=W(u,r,t)*u%t,x=W(f,r,t)*u%t,v=W(x,Ja,t)*l%t,b=W(v,o,t)*v%t,A=W(b,i,t)*b%t,B=W(A,a,t)*A%t,w=W(B,c,t)*B%t,T=W(w,a,t)*A%t,E=W(T,r,t)*u%t,U=W(E,s,t)*b%t,K=W(U,n,t)*l%t,M=W(K,Ja,t);if(!Ei.eql(Ei.sqr(M),e))throw new Error("Cannot find square root");return M}var Ei=We(Si.p,{sqrt:td}),ed=Ga(Si,{Fp:Ei,endo:Ql}),Ot=Xa(ed,je);var Qa=32;function tc(e,t,r){let n=an.digest(t instanceof Uint8Array?t:t.subarray());if(tr(n))return n.then(({digest:o})=>(r?.signal?.throwIfAborted(),Ot.sign(o,e,{prehash:!1,format:"der"}))).catch(o=>{throw o.name==="AbortError"?o:new Ur(String(o))});try{return Ot.sign(n.digest,e,{prehash:!1,format:"der"})}catch(o){throw new Ur(String(o))}}function ec(e,t,r,n){let o=an.digest(r instanceof Uint8Array?r:r.subarray());if(tr(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),Ot.verify(t,i,e,{prehash:!1,format:"der"}))).catch(i=>{throw i.name==="AbortError"?i:new Rr(String(i))});try{return n?.signal?.throwIfAborted(),Ot.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(i){throw new Rr(String(i))}}var Pr=class{type="secp256k1";raw;_key;constructor(t){this._key=oc(t),this.raw=rc(this._key)}toMultihash(){return ge.digest(se(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return ot.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}verify(t,r,n){return ec(this._key,r,t,n)}},Fr=class{type="secp256k1";raw;publicKey;constructor(t,r){this.raw=nc(t),this.publicKey=new Pr(r??ic(t))}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}sign(t,r){return tc(this.raw,t,r)}};function vi(e){return new Fr(e)}function sc(e){return new Pr(e)}async function ac(){let e=rd();return new Fr(e)}function rc(e){return Ot.Point.fromBytes(e).toBytes()}function nc(e){try{return Ot.getPublicKey(e,!0),e}catch(t){throw new pr(String(t))}}function oc(e){try{return Ot.Point.fromBytes(e),e}catch(t){throw new ke(String(t))}}function ic(e){try{return Ot.getPublicKey(e,!0)}catch(t){throw new pr(String(t))}}function rd(){return Ot.utils.randomSecretKey()}async function cc(e,t){if(e==="Ed25519")return Ba();if(e==="secp256k1")return ac();if(e==="RSA")return yi(nd(t));if(e==="ECDSA")return Ds(od(t));throw new Ke}function Ai(e,t){let{Type:r,Data:n}=ee.decode(e),o=n??new Uint8Array;switch(r){case et.RSA:return hi(o,t);case et.Ed25519:return Aa(o);case et.secp256k1:return sc(o);case et.ECDSA:return Ts(o);default:throw new Ke}}function se(e){return ee.encode({Type:et[e.type],Data:e.raw})}function uc(e){let t=Sn.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case et.RSA:return di(r);case et.Ed25519:return Go(r);case et.secp256k1:return vi(r);case et.ECDSA:return Is(r);default:throw new Ke}}function fc(e){if(e.byteLength===At)return Go(e);if(e.byteLength===Qa)return vi(e);let t=Ut(e),r=t[2]?.[0];if(r===gs||r===bs||r===xs)return Ao(t);if(t.length>8)return vn(t);throw new rt("Could not extract private key from raw bytes")}function nd(e){return e==null?2048:parseInt(e,10)}function od(e){if(e==="P-256"||e==null)return"P-256";if(e==="P-384")return"P-384";if(e==="P-521")return"P-521";throw new rt("Unsupported curve, should be P-256, P-384 or P-521")}function id(e,t){if(typeof e=="string")return sd(e);if(typeof e=="number")return ud(e,t);throw Error(`Value provided to ms() must be a string or number. value=${JSON.stringify(e)}`)}var In=id;function sd(e){if(typeof e!="string"||e.length===0||e.length>100)throw Error(`Value provided to ms.parse() must be a string with length between 1 and 99. value=${JSON.stringify(e)}`);let t=/^(?<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(e);if(!t?.groups)return NaN;let{value:r,unit:n="ms"}=t.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(e)}`)}}function ad(e){let t=Math.abs(e);return t>=315576e5?`${Math.round(e/315576e5)}y`:t>=26298e5?`${Math.round(e/26298e5)}mo`:t>=6048e5?`${Math.round(e/6048e5)}w`:t>=864e5?`${Math.round(e/864e5)}d`:t>=36e5?`${Math.round(e/36e5)}h`:t>=6e4?`${Math.round(e/6e4)}m`:t>=1e3?`${Math.round(e/1e3)}s`:`${e}ms`}function cd(e){let t=Math.abs(e);return t>=315576e5?Re(e,t,315576e5,"year"):t>=26298e5?Re(e,t,26298e5,"month"):t>=6048e5?Re(e,t,6048e5,"week"):t>=864e5?Re(e,t,864e5,"day"):t>=36e5?Re(e,t,36e5,"hour"):t>=6e4?Re(e,t,6e4,"minute"):t>=1e3?Re(e,t,1e3,"second"):`${e} ms`}function ud(e,t){if(typeof e!="number"||!Number.isFinite(e))throw Error("Value provided to ms.format() must be of type number.");return t?.long?cd(e):ad(e)}function Re(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function Bi(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=In,r.destroy=l,Object.keys(e).forEach(u=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let f=0;for(let x=0;x<u.length;x++)f=(f<<5)-f+u.charCodeAt(x),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=t;function r(u){let f,x=null,v,b;function A(...B){if(!A.enabled)return;let w=A,T=Number(new Date),E=T-(f||T);w.diff=E,w.prev=f,w.curr=T,f=T,B[0]=r.coerce(B[0]),typeof B[0]!="string"&&B.unshift("%O");let U=0;B[0]=B[0].replace(/%([a-zA-Z%])/g,(M,F)=>{if(M==="%%")return"%";U++;let p=r.formatters[F];if(typeof p=="function"){let m=B[U];M=p.call(w,m),B.splice(U,1),U--}return M}),r.formatArgs.call(w,B),(w.log||r.log).apply(w,B)}return A.namespace=u,A.useColors=r.useColors(),A.color=r.selectColor(u),A.extend=n,A.destroy=r.destroy,Object.defineProperty(A,"enabled",{enumerable:!0,configurable:!1,get:()=>x!==null?x:(v!==r.namespaces&&(v=r.namespaces,b=r.enabled(u)),b),set:B=>{x=B}}),typeof r.init=="function"&&r.init(A),A}function n(u,f){let x=r(this.namespace+(typeof f>"u"?":":f)+u);return x.log=this.log,x}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let f,x=(typeof u=="string"?u:"").split(/[\s,]+/),v=x.length;for(f=0;f<v;f++)x[f]&&(u=x[f].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(a),...r.skips.map(a).map(f=>"-"+f)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let f,x;for(f=0,x=r.skips.length;f<x;f++)if(r.skips[f].test(u))return!1;for(f=0,x=r.names.length;f<x;f++)if(r.names[f].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function l(){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 Tn=yd(),fd=["#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 ld(){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 dd(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+In(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}var hd=console.debug??console.log??(()=>{});function pd(e){try{e?Tn?.setItem("debug",e):Tn?.removeItem("debug")}catch{}}function md(){let e;try{e=Tn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function yd(){try{return localStorage}catch{}}function gd(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var lc=Bi({formatArgs:dd,save:pd,load:md,useColors:ld,setupFormatters:gd,colors:fd,storage:Tn,log:hd});var wt=lc;wt.formatters.b=e=>e==null?"undefined":ot.baseEncode(e);wt.formatters.t=e=>e==null?"undefined":ie.baseEncode(e);wt.formatters.m=e=>e==null?"undefined":po.baseEncode(e);wt.formatters.p=e=>e==null?"undefined":e.toString();wt.formatters.c=e=>e==null?"undefined":e.toString();wt.formatters.k=e=>e==null?"undefined":e.toString();wt.formatters.a=e=>e==null?"undefined":e.toString();wt.formatters.e=e=>e==null?"undefined":dc(e.stack)??dc(e.message)??e.toString();function bd(e){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}function De(e){let t=bd(`${e}:trace`);return wt.enabled(`${e}:trace`)&&wt.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=wt(`${e}:trace`)),Object.assign(wt(e),{error:wt(`${e}:error`),trace:t,newScope:r=>De(`${e}:${r}`)})}function dc(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var vu=zi(Ti(),1);var _n=class extends Error{static name="SignatureCreationError";constructor(t="Record signature creation failed"){super(t),this.name="SignatureCreationError"}},Mt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},Cn=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},Le=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}};var Vr=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},Un=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}};var Et;(function(e){let t;(function(o){o.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),function(o){o.codec=()=>Kr(r)}(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=sr((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),e.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 a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let l=o.uint32();switch(l>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=e.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(l&7);break}}}return a})),n),e.encode=o=>or(o,e.codec()),e.decode=(o,i)=>nr(o,e.codec(),i)})(Et||(Et={}));var xd=["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 _i(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(t==="string"||t==="number"||t==="bigint"||t==="symbol")return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(e instanceof Uint8Array)return"Uint8Array";if(e.constructor===Object)return"Object";let r=wd(e);return r||"Object"}function wd(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(xd.includes(t))return t}var h=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}static equals(t,r){return t===r||t.major===r.major&&t.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 L=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var qr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Ed=new TextEncoder;function Rn(e){return qr&&globalThis.Buffer.isBuffer(e)}function Hr(e){return e instanceof Uint8Array?Rn(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Sd=24,vd=200,Dn=qr?e=>e.length>=Sd?globalThis.Buffer.from(e):hc(e):e=>e.length>=vd?Ed.encode(e):hc(e),zt=e=>Uint8Array.from(e),pc=qr?(e,t,r)=>Rn(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),mc=qr?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Hr(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},yc=qr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Ln(e,t){if(Rn(e)&&Rn(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function hc(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}var Ad=256,$r=class{constructor(t=Ad){this.chunkSize=t,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(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,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)}t.length<64&&t.length<this.chunkSize?(r=yc(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=pc(n,0,this.cursor)}else r=mc(this.chunks,this.cursor);return t&&this.reset(),r}},Nn=class{constructor(t){this.dest=t,this.cursor=0,this.chunks=[t]}reset(){this.cursor=0}push(t){if(this.cursor+t.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(t,this.cursor),this.cursor+=t.length}toBytes(t=!1){let r=this.dest.subarray(0,this.cursor);return t&&this.reset(),r}};var V="CBOR decode error:",kn="CBOR encode error:",zr=[];zr[23]=1;zr[24]=2;zr[25]=3;zr[26]=5;zr[27]=9;function ne(e,t,r){if(e.length-t<r)throw new Error(`${V} not enough data for type`)}var ut=[24,256,65536,4294967296,BigInt("18446744073709551616")];function It(e,t,r){ne(e,t,1);let n=e[t];if(r.strict===!0&&n<ut[0])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);return n}function Tt(e,t,r){ne(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<ut[1])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);return n}function _t(e,t,r){ne(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<ut[2])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);return n}function Ct(e,t,r){ne(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<ut[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 gc(e,t,r,n){return new L(h.uint,It(e,t+1,n),2)}function bc(e,t,r,n){return new L(h.uint,Tt(e,t+1,n),3)}function xc(e,t,r,n){return new L(h.uint,_t(e,t+1,n),5)}function wc(e,t,r,n){return new L(h.uint,Ct(e,t+1,n),9)}function Rt(e,t){return G(e,0,t.value)}function G(e,t,r){if(r<ut[0]){let n=Number(r);e.push([t|n])}else if(r<ut[1]){let n=Number(r);e.push([t|24,n])}else if(r<ut[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<ut[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<ut[4]){let o=[t|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,e.push(o)}else throw new Error(`${V} encountered BigInt larger than allowable range`)}}Rt.encodedSize=function(t){return G.encodedSize(t.value)};G.encodedSize=function(t){return t<ut[0]?1:t<ut[1]?2:t<ut[2]?3:t<ut[3]?5:9};Rt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Ec(e,t,r,n){return new L(h.negint,-1-It(e,t+1,n),2)}function Sc(e,t,r,n){return new L(h.negint,-1-Tt(e,t+1,n),3)}function vc(e,t,r,n){return new L(h.negint,-1-_t(e,t+1,n),5)}var Ci=BigInt(-1),Ac=BigInt(1);function Bc(e,t,r,n){let o=Ct(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new L(h.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${V} integers outside of the safe integer range are not supported`);return new L(h.negint,Ci-BigInt(o),9)}function Kn(e,t){let r=t.value,n=typeof r=="bigint"?r*Ci-Ac:r*-1-1;G(e,t.type.majorEncoded,n)}Kn.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Ci-Ac:r*-1-1;return n<ut[0]?1:n<ut[1]?2:n<ut[2]?3:n<ut[3]?5:9};Kn.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function Zr(e,t,r,n){ne(e,t,r+n);let o=e.slice(t+r,t+r+n);return new L(h.bytes,o,r+n)}function Ic(e,t,r,n){return Zr(e,t,1,r)}function Tc(e,t,r,n){return Zr(e,t,2,It(e,t+1,n))}function _c(e,t,r,n){return Zr(e,t,3,Tt(e,t+1,n))}function Cc(e,t,r,n){return Zr(e,t,5,_t(e,t+1,n))}function Uc(e,t,r,n){let o=Ct(e,t+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer bytes lengths not supported`);return Zr(e,t,9,o)}function On(e){return e.encodedBytes===void 0&&(e.encodedBytes=h.equals(e.type,h.string)?Dn(e.value):e.value),e.encodedBytes}function ur(e,t){let r=On(t);G(e,t.type.majorEncoded,r.length),e.push(r)}ur.encodedSize=function(t){let r=On(t);return G.encodedSize(r.length)+r.length};ur.compareTokens=function(t,r){return Id(On(t),On(r))};function Id(e,t){return e.length<t.length?-1:e.length>t.length?1:Ln(e,t)}var Rc=new TextDecoder,_d=32;function Cd(e,t,r){if(r-t<_d){let o="";for(let i=t;i<r;i++){let s=e[i];if(s&128)return Rc.decode(e.subarray(t,r));o+=String.fromCharCode(s)}return o}return Rc.decode(e.subarray(t,r))}function jr(e,t,r,n,o){let i=r+n;ne(e,t,i);let s=new L(h.string,Cd(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=e.slice(t+r,t+i)),s}function Dc(e,t,r,n){return jr(e,t,1,r,n)}function Lc(e,t,r,n){return jr(e,t,2,It(e,t+1,n),n)}function Nc(e,t,r,n){return jr(e,t,3,Tt(e,t+1,n),n)}function kc(e,t,r,n){return jr(e,t,5,_t(e,t+1,n),n)}function Kc(e,t,r,n){let o=Ct(e,t+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer string lengths not supported`);return jr(e,t,9,o,n)}var Oc=ur;function fr(e,t,r,n){return new L(h.array,n,r)}function Mc(e,t,r,n){return fr(e,t,1,r)}function Pc(e,t,r,n){return fr(e,t,2,It(e,t+1,n))}function Fc(e,t,r,n){return fr(e,t,3,Tt(e,t+1,n))}function Vc(e,t,r,n){return fr(e,t,5,_t(e,t+1,n))}function qc(e,t,r,n){let o=Ct(e,t+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer array lengths not supported`);return fr(e,t,9,o)}function Hc(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${V} indefinite length items not allowed`);return fr(e,t,1,1/0)}function Mn(e,t){G(e,h.array.majorEncoded,t.value)}Mn.compareTokens=Rt.compareTokens;Mn.encodedSize=function(t){return G.encodedSize(t.value)};function lr(e,t,r,n){return new L(h.map,n,r)}function $c(e,t,r,n){return lr(e,t,1,r)}function zc(e,t,r,n){return lr(e,t,2,It(e,t+1,n))}function Zc(e,t,r,n){return lr(e,t,3,Tt(e,t+1,n))}function jc(e,t,r,n){return lr(e,t,5,_t(e,t+1,n))}function Gc(e,t,r,n){let o=Ct(e,t+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer map lengths not supported`);return lr(e,t,9,o)}function Yc(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${V} indefinite length items not allowed`);return lr(e,t,1,1/0)}function Pn(e,t){G(e,h.map.majorEncoded,t.value)}Pn.compareTokens=Rt.compareTokens;Pn.encodedSize=function(t){return G.encodedSize(t.value)};function Wc(e,t,r,n){return new L(h.tag,r,1)}function Xc(e,t,r,n){return new L(h.tag,It(e,t+1,n),2)}function Jc(e,t,r,n){return new L(h.tag,Tt(e,t+1,n),3)}function Qc(e,t,r,n){return new L(h.tag,_t(e,t+1,n),5)}function tu(e,t,r,n){return new L(h.tag,Ct(e,t+1,n),9)}function Fn(e,t){G(e,h.tag.majorEncoded,t.value)}Fn.compareTokens=Rt.compareTokens;Fn.encodedSize=function(t){return G.encodedSize(t.value)};var Ui=20,Ri=21,Di=22,Li=23;function eu(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${V} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new L(h.null,null,1):new L(h.undefined,void 0,1)}function ru(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${V} indefinite length items not allowed`);return new L(h.break,void 0,1)}function Ni(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${V} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${V} Infinity values are not supported`)}return new L(h.float,e,t)}function nu(e,t,r,n){return Ni(ki(e,t+1),3,n)}function ou(e,t,r,n){return Ni(Ki(e,t+1),5,n)}function iu(e,t,r,n){return Ni(uu(e,t+1),9,n)}function Gr(e,t,r){let n=t.value;if(n===!1)e.push([h.float.majorEncoded|Ui]);else if(n===!0)e.push([h.float.majorEncoded|Ri]);else if(n===null)e.push([h.float.majorEncoded|Di]);else if(n===void 0)e.push([h.float.majorEncoded|Li]);else{let o,i=!1;(!r||r.float64!==!0)&&(au(n),o=ki(Pt,1),n===o||Number.isNaN(n)?(Pt[0]=249,e.push(Pt.slice(0,3)),i=!0):(cu(n),o=Ki(Pt,1),n===o&&(Pt[0]=250,e.push(Pt.slice(0,5)),i=!0))),i||(Nd(n),o=uu(Pt,1),Pt[0]=251,e.push(Pt.slice(0,9)))}}Gr.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){au(n);let o=ki(Pt,1);if(n===o||Number.isNaN(n))return 3;if(cu(n),o=Ki(Pt,1),n===o)return 5}return 9};var su=new ArrayBuffer(9),Dt=new DataView(su,1),Pt=new Uint8Array(su,0);function au(e){if(e===1/0)Dt.setUint16(0,31744,!1);else if(e===-1/0)Dt.setUint16(0,64512,!1);else if(Number.isNaN(e))Dt.setUint16(0,32256,!1);else{Dt.setFloat32(0,e);let t=Dt.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Dt.setUint16(0,31744,!1);else if(r===0)Dt.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Dt.setUint16(0,0):o<-14?Dt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Dt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function ki(e,t){if(e.length-t<2)throw new Error(`${V} not enough data for float16`);let r=(e[t]<<8)+e[t+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 cu(e){Dt.setFloat32(0,e,!1)}function Ki(e,t){if(e.length-t<4)throw new Error(`${V} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Nd(e){Dt.setFloat64(0,e,!1)}function uu(e,t){if(e.length-t<8)throw new Error(`${V} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Gr.compareTokens=Rt.compareTokens;function z(e,t,r){throw new Error(`${V} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Vn(e){return()=>{throw new Error(`${V} ${e}`)}}var _=[];for(let e=0;e<=23;e++)_[e]=z;_[24]=gc;_[25]=bc;_[26]=xc;_[27]=wc;_[28]=z;_[29]=z;_[30]=z;_[31]=z;for(let e=32;e<=55;e++)_[e]=z;_[56]=Ec;_[57]=Sc;_[58]=vc;_[59]=Bc;_[60]=z;_[61]=z;_[62]=z;_[63]=z;for(let e=64;e<=87;e++)_[e]=Ic;_[88]=Tc;_[89]=_c;_[90]=Cc;_[91]=Uc;_[92]=z;_[93]=z;_[94]=z;_[95]=Vn("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)_[e]=Dc;_[120]=Lc;_[121]=Nc;_[122]=kc;_[123]=Kc;_[124]=z;_[125]=z;_[126]=z;_[127]=Vn("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)_[e]=Mc;_[152]=Pc;_[153]=Fc;_[154]=Vc;_[155]=qc;_[156]=z;_[157]=z;_[158]=z;_[159]=Hc;for(let e=160;e<=183;e++)_[e]=$c;_[184]=zc;_[185]=Zc;_[186]=jc;_[187]=Gc;_[188]=z;_[189]=z;_[190]=z;_[191]=Yc;for(let e=192;e<=215;e++)_[e]=Wc;_[216]=Xc;_[217]=Jc;_[218]=Qc;_[219]=tu;_[220]=z;_[221]=z;_[222]=z;_[223]=z;for(let e=224;e<=243;e++)_[e]=Vn("simple values are not supported");_[244]=z;_[245]=z;_[246]=z;_[247]=eu;_[248]=Vn("simple values are not supported");_[249]=nu;_[250]=ou;_[251]=iu;_[252]=z;_[253]=z;_[254]=z;_[255]=ru;var Ft=[];for(let e=0;e<24;e++)Ft[e]=new L(h.uint,e,1);for(let e=-1;e>=-24;e--)Ft[31-e]=new L(h.negint,e,1);Ft[64]=new L(h.bytes,new Uint8Array(0),1);Ft[96]=new L(h.string,"",1);Ft[128]=new L(h.array,0,1);Ft[160]=new L(h.map,0,1);Ft[244]=new L(h.false,!1,1);Ft[245]=new L(h.true,!0,1);Ft[246]=new L(h.null,null,1);function Oi(e){switch(e.type){case h.false:return zt([244]);case h.true:return zt([245]);case h.null:return zt([246]);case h.bytes:return e.value.length?void 0:zt([64]);case h.string:return e.value===""?zt([96]):void 0;case h.array:return e.value===0?zt([128]):void 0;case h.map:return e.value===0?zt([160]):void 0;case h.uint:return e.value<24?zt([Number(e.value)]):void 0;case h.negint:if(e.value>=-24)return zt([31-Number(e.value)])}}var Kd={float64:!1,mapSorter:Pd,quickEncodeToken:Oi},pu=Object.freeze({float64:!0,mapSorter:Fd,quickEncodeToken:Oi});function Od(){let e=[];return e[h.uint.major]=Rt,e[h.negint.major]=Kn,e[h.bytes.major]=ur,e[h.string.major]=Oc,e[h.array.major]=Mn,e[h.map.major]=Pn,e[h.tag.major]=Fn,e[h.float.major]=Gr,e}var dr=Od(),qn=new $r,Wr=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${kn} object contains circular references`);return new e(r,t)}},me={null:new L(h.null,null),undefined:new L(h.undefined,void 0),true:new L(h.true,!0),false:new L(h.false,!1),emptyArray:new L(h.array,0),emptyMap:new L(h.map,0)},Zt={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new L(h.float,e):e>=0?new L(h.uint,e):new L(h.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new L(h.uint,e):new L(h.negint,e)},Uint8Array(e,t,r,n){return new L(h.bytes,e)},string(e,t,r,n){return new L(h.string,e)},boolean(e,t,r,n){return e?me.true:me.false},null(e,t,r,n){return me.null},undefined(e,t,r,n){return me.undefined},ArrayBuffer(e,t,r,n){return new L(h.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new L(h.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[me.emptyArray,new L(h.break)]:me.emptyArray;n=Wr.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=Hn(s,r,n);return r.addBreakTokens?[new L(h.array,e.length),o,new L(h.break)]:[new L(h.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),s=o?e.size:i.length,a;if(s){a=new Array(s),n=Wr.createCheck(n,e);let c=!o&&r.ignoreUndefinedProperties,l=0;for(let u of i){let f=o?e.get(u):e[u];c&&f===void 0||(a[l++]=[Hn(u,r,n),Hn(f,r,n)])}l<s&&(a.length=l)}return a?.length?(Md(a,r),r.addBreakTokens?[new L(h.map,a.length),a,new L(h.break)]:[new L(h.map,a.length),a]):r.addBreakTokens===!0?[me.emptyMap,new L(h.break)]:me.emptyMap}};Zt.Map=Zt.Object;Zt.Buffer=Zt.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Zt[`${e}Array`]=Zt.DataView;function Hn(e,t={},r){let n=_i(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Zt[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Zt[n];if(!i)throw new Error(`${kn} unsupported type: ${n}`);return i(e,n,t,r)}function Md(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Pd(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=dr[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Fd(e,t){if(e[0]instanceof L&&t[0]instanceof L){let r=e[0],n=t[0];return r._keyBytes||(r._keyBytes=fu(r.value)),n._keyBytes||(n._keyBytes=fu(n.value)),Ln(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function fu(e){return yu(e,dr,pu)}function Yr(e,t,r,n){if(Array.isArray(t))for(let o of t)Yr(e,o,r,n);else r[t.type.major](e,t,n)}var lu=h.uint.majorEncoded,du=h.negint.majorEncoded,Vd=h.bytes.majorEncoded,qd=h.string.majorEncoded,hu=h.array.majorEncoded,Hd=h.float.majorEncoded|Ui,$d=h.float.majorEncoded|Ri,zd=h.float.majorEncoded|Di,Zd=h.float.majorEncoded|Li,jd=BigInt(-1),Gd=BigInt(1);function Yd(e){return e.addBreakTokens!==!0}function mu(e,t,r,n){let o=_i(t),i=r.typeEncoders&&r.typeEncoders[o];if(i){let s=i(t,o,r,n);if(s!=null){Yr(e,s,dr,r);return}}switch(o){case"null":e.push([zd]);return;case"undefined":e.push([Zd]);return;case"boolean":e.push([t?$d:Hd]);return;case"number":!Number.isInteger(t)||!Number.isSafeInteger(t)?Gr(e,new L(h.float,t),r):t>=0?G(e,lu,t):G(e,du,t*-1-1);return;case"bigint":t>=BigInt(0)?G(e,lu,t):G(e,du,t*jd-Gd);return;case"string":{let s=Dn(t);G(e,qd,s.length),e.push(s);return}case"Uint8Array":G(e,Vd,t.length),e.push(t);return;case"Array":if(!t.length){e.push([hu]);return}n=Wr.createCheck(n,t),G(e,hu,t.length);for(let s of t)mu(e,s,r,n);return;case"Object":case"Map":{let s=Zt.Object(t,o,r,n);Yr(e,s,dr,r)}return;default:{let s=Zt[o];if(!s)throw new Error(`${kn} unsupported type: ${o}`);let a=s(t,o,r,n);Yr(e,a,dr,r)}}}function yu(e,t,r,n){let o=n instanceof Uint8Array,i=o?new Nn(n):qn,s=Hn(e,r);if(!Array.isArray(s)&&r.quickEncodeToken){let a=r.quickEncodeToken(s);if(a)return o?(i.push(a),i.toBytes()):a;let c=t[s.type.major];if(c.encodedSize){let l=c.encodedSize(s,r);if(o||(i=new $r(l)),c(i,s,r),i.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${s} was wrong`);return o?i.toBytes():Hr(i.chunks[0])}}return i.reset(),Yr(i,s,t,r),i.toBytes(!0)}function Xr(e,t){return t=Object.assign({},Kd,t),Yd(t)?(qn.reset(),mu(qn,e,t,void 0),qn.toBytes(!0)):yu(e,dr,t)}var Wd={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},$n=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=Ft[t];if(r===void 0){let n=_[t];if(!n)throw new Error(`${V} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},Jr=Symbol.for("DONE"),zn=Symbol.for("BREAK");function Xd(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=hr(t,r);if(i===zn){if(e.value===1/0)break;throw new Error(`${V} got unexpected break to lengthed array`)}if(i===Jr)throw new Error(`${V} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function Jd(e,t,r){let n=r.useMaps===!0,o=r.rejectDuplicateMapKeys===!0,i=n?void 0:{},s=n?new Map:void 0;for(let a=0;a<e.value;a++){let c=hr(t,r);if(c===zn){if(e.value===1/0)break;throw new Error(`${V} got unexpected break to lengthed map`)}if(c===Jr)throw new Error(`${V} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(!n&&typeof c!="string")throw new Error(`${V} non-string keys not supported (got ${typeof c})`);if(o&&(n&&s.has(c)||!n&&Object.hasOwn(i,c)))throw new Error(`${V} found repeat map key "${c}"`);let l=hr(t,r);if(l===Jr)throw new Error(`${V} found map but not enough entries (got ${a} [no value], expected ${e.value})`);n?s.set(c,l):i[c]=l}return n?s:i}function hr(e,t){if(e.done())return Jr;let r=e.next();if(h.equals(r.type,h.break))return zn;if(r.type.terminal)return r.value;if(h.equals(r.type,h.array))return Xd(r,e,t);if(h.equals(r.type,h.map))return Jd(r,e,t);if(h.equals(r.type,h.tag)){if(t.tags&&typeof t.tags[r.value]=="function"){let n=hr(e,t);return t.tags[r.value](n)}throw new Error(`${V} tag not supported (${r.value})`)}throw new Error("unsupported")}function gu(e,t){if(!(e instanceof Uint8Array))throw new Error(`${V} data to decode must be a Uint8Array`);t=Object.assign({},Wd,t);let r=Hr(e),n=t.tokenizer||new $n(r,t),o=hr(n,t);if(o===Jr)throw new Error(`${V} did not find any content to decode`);if(o===zn)throw new Error(`${V} got unexpected break`);return[o,e.subarray(n.pos())]}function Qr(e,t){let[r,n]=gu(e,t);if(n.length>0)throw new Error(`${V} too many terminals, data makes no sense`);return r}var zg=De("ipns:utils"),Zg=Z("/ipns/"),Qd=114;function xu(e,t,r){let n=Z(t);return be([e,r,n])}function Zn(e){let t=Z("ipns-signature:");return be([t,e])}function Mi(e){return"signatureV1"in e?Et.encode({value:Z(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:Z(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):Et.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function tn(e){let t=Et.decode(e);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new Mt("Missing data or signatureV2");let r=Eu(t.data),n=th(r.Value),o=j(r.Validity);if(t.value!=null&&t.signatureV1!=null)return eh(t),{value:n,validityType:Et.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV1:t.signatureV1,signatureV2:t.signatureV2,data:t.data};if(t.signatureV2!=null)return{value:n,validityType:Et.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function wu(e,t,r,n,o){let i;if(t===Et.ValidityType.EOL)i=0;else throw new Le("The validity type is unsupported");return Xr({Value:e,Validity:r,ValidityType:i,Sequence:n,TTL:o})}function Eu(e){let t=Qr(e);if(t.ValidityType===0)t.ValidityType=Et.ValidityType.EOL;else throw new Le("The validity type is unsupported");return Number.isInteger(t.Sequence)&&(t.Sequence=BigInt(t.Sequence)),Number.isInteger(t.TTL)&&(t.TTL=BigInt(t.TTL)),t}function th(e){let t=j(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${it.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${it.parse(t).toV1().toString()}`}catch{}throw new Vr("Value must be a valid content path starting with /")}function Su(e){if(e!=null){let t=oh(e);if(t!=null)return t.code===Qd?`/ipns/${t.toString(Lt)}`:`/ipfs/${t.toV1().toString()}`;if(rh(e))return`/ipns/${Lt.encode(e.bytes)}`;let r=e.toString().trim();if(r.startsWith("/")&&r.length>1)return r}throw new Vr("Value must be a valid content path starting with /")}function eh(e){if(e.data==null)throw new Un("Record data is missing");let t=Eu(e.data);if(!st(t.Value,e.value??new Uint8Array(0)))throw new Mt('Field "value" did not match between protobuf and CBOR');if(!st(t.Validity,e.validity??new Uint8Array(0)))throw new Mt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Mt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Mt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Mt('Field "ttl" did not match between protobuf and CBOR')}function rh(e){return e.bytes instanceof Uint8Array}function nh(e){return typeof e?.toCID=="function"}function oh(e){if(nh(e))return e.toCID();try{return it.parse(e)}catch{}return it.asCID(e)}var ih=De("ipns"),Au=5*60*1e9,sh="/ipns/",tb=sh.length,Bu={v1Compatible:!0,ttlNs:Au};async function Iu(e,t,r,n,o=Bu){let i=new vu.default(Date.now()+Number(n)),s=Et.ValidityType.EOL,a=BigInt(o.ttlNs??Au);return ah(e,t,r,s,i.toString(),a,o)}var ah=async(e,t,r,n,o,i,s=Bu)=>{r=BigInt(r);let a=Z(o),c=Su(t),l=Z(c),u=wu(l,n,a,r,i),f=Zn(u),x=await e.sign(f),v;if(e.type==="RSA"&&(v=se(e.publicKey)),s.v1Compatible===!0){let b=await ch(e,l,n,a),A={value:c,signatureV1:b,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:x,data:u};return v!=null&&(A.pubKey=v),A}else{let b={value:c,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:x,data:u};return v!=null&&(b.pubKey=v),b}},ch=async(e,t,r,n)=>{try{let o=xu(t,r,n);return await e.sign(o)}catch(o){throw ih.error("record signature creation failed",o),new _n("Record signature creation failed")}};var Tu=zi(Ti(),1);var jn=De("ipns:validator"),pb=1024*10;async function _u(e,t){let r=tn(t),n;try{let o=Zn(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw jn.error("record signature verification failed"),new Mt("Record signature verification failed");if(r.validityType===Et.ValidityType.EOL){if(Tu.default.fromString(r.validity).toDate().getTime()<Date.now())throw jn.error("record has expired"),new Cn("record has expired")}else if(r.validityType!=null)throw jn.error("the validity type is unsupported"),new Le("The validity type is unsupported");jn("ipns record for %s is valid",r.value)}var Fi=class extends Error{constructor(t={}){var r;super((r=t.message)!==null&&r!==void 0?r:"Maximum retry limit reached."),this.options=t}},Pi=Symbol("internal_state");function Vi(e={}){let{interval:t=0,maxPerInterval:r=1/0,evenlySpaced:n=!1,maxRetries:o=30,maxRetriesWithPauses:i=30}=e;if(r<1)throw new Error('"maxPerInterval" must be a positive integer.');if(t<0)throw new Error('"interval" cannot be negative.');if(o<0)throw new Error('"maxRetries" cannot be negative.');if(i<0)throw new Error('"maxRetriesWithPauses" cannot be negative.');if(n)return Vi({...e,interval:Math.ceil(t/r),maxPerInterval:1,evenlySpaced:!1});let s=[],a=0,c=0,l,u=()=>{l=void 0;let x=a+t,v=Date.now();if(v<x){l=setTimeout(u,x-v);return}a=v,c=0;for(let b of s.splice(0,r))c++,b();s.length&&(l=setTimeout(u,t))},f=(x,v)=>new Promise((b,A)=>{v||(v={}),Pi in v||Object.assign(v,{[Pi]:{maxRetries:o,maxRetriesWithPauses:i}});let B=async()=>{var E,U;try{return await x({intervalStart:a,state:v})}catch(K){if(K instanceof Fi){let M=v[Pi];if(K.options.pauseQueue){if(M.maxRetriesWithPauses--<=0)throw K;c=r,l!==void 0&&clearTimeout(l),l=setTimeout(u,(U=(E=K.options.retryAfter)!==null&&E!==void 0?E:e.interval)!==null&&U!==void 0?U:500)}else{if(M.maxRetries--<=0)throw K;await new Promise(F=>{var p,m;return setTimeout(F,(m=(p=K.options.retryAfter)!==null&&p!==void 0?p:e.interval)!==null&&m!==void 0?m:500)})}return f(x,v)}throw K}},w=()=>{Promise.resolve().then(B).then(b).catch(A)},T=Date.now();l===void 0&&t&&T-a>t&&(a=T,c=0),c++<r?w():(s.push(w),l===void 0&&(l=setTimeout(u,a+t-T)))});return f}var Gn=class{endpoint;waitForRateLimit;constructor(t=new URL("https://name.web3.storage/"),r=function(){let n=Vi({maxPerInterval:30,interval:1e4});return async()=>await n(()=>{})}()){this.endpoint=t,this.waitForRateLimit=r}};var Cu=()=>new Date(Date.now()+31536e6).toISOString(),fh=5n*60n*1000n*1000000n,Uu=new Gn,Yn=class{_pubKey;_cid;constructor(t){this._pubKey=t,this._cid=t.toCID()}get bytes(){return this._cid.bytes}toString(){return this._cid.toString(Lt)}},Wn=class extends Yn{_privKey;constructor(t){super(t.publicKey),this._privKey=t}get key(){return this._privKey}};async function Ru(){let e=await cc("Ed25519",2048);return new Wn(e)}function lh(e){let t=it.parse(e,Lt);if(t.code!==114)throw new Error(`Invalid key, expected 114 codec code but got ${t.code}`);let r=Ai(Ve(t.multihash.bytes).bytes);return new Yn(r)}async function qi(e){let t;try{t=fc(e)}catch{t=uc(e)}return new Wn(t)}async function Du(e,t){return new en(e,t,0n,Cu())}async function Lu(e,t){let r=e.sequence+1n;return new en(e.name,t,r,Cu())}var en=class e{_name;_value;_sequence;_validity;_ttl;constructor(t,r,n,o,i){if(this._name=t,typeof r!="string")throw new Error("invalid value");if(this._value=r,typeof n!="bigint")throw new Error("invalid sequence number");if(this._sequence=n,typeof o!="string"||Number.isNaN(new Date(o).getTime()))throw new Error("invalid validity");this._validity=o;let s=i?.ttl??fh;if(typeof s!="bigint")throw new Error("invalid TTL");this._ttl=s}get name(){return this._name}get value(){return this._value}get sequence(){return this._sequence}get validity(){return this._validity}get ttl(){return this._ttl}static encode(t){return Xr({name:t._name.toString(),value:t._value,sequence:t._sequence,validity:t._validity,...t._ttl!=null?{ttl:t._ttl}:{}})}static decode(t){let r=Qr(t),n=lh(r.name);return new e(n,r.value,BigInt(r.sequence),r.validity,{ttl:r.ttl!=null?BigInt(r.ttl):void 0})}};async function Nu(e,t,r=Uu){let n=new URL(`name/${e.name.toString()}`,r.endpoint),o=await Iu(t,e.value,e.sequence,new Date(e.validity).getTime()-Date.now(),{ttlNs:e.ttl});await r.waitForRateLimit(),await Ku(fetch(n.toString(),{method:"POST",body:sn.baseEncode(Mi(o))}))}async function ku(e,t=Uu){let r=new URL(`name/${e.toString()}`,t.endpoint);await t.waitForRateLimit();let n=await Ku(fetch(r.toString())),{record:o}=await n.json(),i=sn.baseDecode(o),s=tn(i),a=it.decode(e.bytes),c=Ai(Ve(a.multihash.bytes).bytes);return await _u(c,i),new en(e,s.value,s.sequence,s.validity,{ttl:s.ttl})}async function Ku(e){let t=await e;if(t.ok)return t;let r;try{let n=await t.json();r=new Error(n.message)}catch{r=new Error(`unexpected response from API, cannot parse error response. Received status: ${t.status}`)}throw r}var{WARN:Ib,LOG:Tb,DEBUG:Xn,ERROR:Ou}=Jn.setup(Jn.INFO);async function hh(e){let t=`https://name.web3.storage/name/${e.toString()}`,r;try{r=await fetch(t,{signal:AbortSignal.timeout(3e4)})}catch(o){throw Ou("[w3name] Network error resolving IPNS:",o)}if(r.status===404)return Xn("[w3name] IPNS record not found (never published):",e.toString()),null;if(!r.ok)throw Ou(`[w3name] HTTP ${r.status} resolving IPNS:`,r.statusText);return await ku(e)}async function _b(e,t){let n=new Promise((o,i)=>setTimeout(()=>i(new Error("publishIPNS timed out after 30000ms")),3e4));return Promise.race([ph(e,t),n])}async function ph(e,t){let r=`/ipfs/${t}`,n=await qi(e),o,i=await hh(n);return i?(o=await Lu(i,r),Xn("[w3name] incrementing revision for",n.toString())):(o=await Du(n,r),Xn("[w3name] creating initial revision for",n.toString())),await Nu(o,n.key),Xn("[w3name] published",t.toString(),"to",n.toString()),o}async function Cb(){return Ru()}async function Ub(e){return(await qi(e)).toString()}export{_b as a,Cb as b,Ub as c};
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/hashes/utils.js:
|
|
@@ -26,4 +26,4 @@ import{a as Jn}from"./chunk-L7VH6KZJ.min.js";import{a as Mu,b as St,c as zi}from
|
|
|
26
26
|
@noble/curves/secp256k1.js:
|
|
27
27
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
28
28
|
*/
|
|
29
|
-
//# sourceMappingURL=chunk-
|
|
29
|
+
//# sourceMappingURL=chunk-SGRPHVFH.min.js.map
|