@helia/ipns 9.1.2 → 9.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +2 -2
- package/package.json +4 -4
package/dist/index.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaIpns = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
2
|
"use strict";var HeliaIpns=(()=>{var hf=Object.create;var cn=Object.defineProperty;var pf=Object.getOwnPropertyDescriptor;var mf=Object.getOwnPropertyNames;var yf=Object.getPrototypeOf,gf=Object.prototype.hasOwnProperty;var bf=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),xt=(e,t)=>{for(var r in t)cn(e,r,{get:t[r],enumerable:!0})},vs=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of mf(t))!gf.call(e,o)&&o!==r&&cn(e,o,{get:()=>t[o],enumerable:!(n=pf(t,o))||n.enumerable});return e};var Io=(e,t,r)=>(r=e!=null?hf(yf(e)):{},vs(t||!e||!e.__esModule?cn(r,"default",{value:e,enumerable:!0}):r,e)),xf=e=>vs(cn({},"__esModule",{value:!0}),e);var On=bf((Kg,rs)=>{var kg=(function(){typeof rs<"u"&&(rs.exports=T);var e=86400,t=3200,r=146097*t/400,n=e*r,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",f=Math.trunc||function(h){var p=h-h%1;return p==0&&(h<0||h===0&&1/h!=1/0)?-0:p},u=T.prototype,l=(T.fromDate=function(h){return new T(+h)},T.fromInt64BE=R(0,1,2,3,0,4),T.fromInt64LE=R(3,2,1,0,4,0),T.fromString=function(L){var p,_=new T,L=(L+="").replace(/^\s*[+\-]?\d+/,function(m){var m=+m,y=1970+(m-1970)%400;return _.year=m-y,y}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(I,m,y){return m<0&&(y*=-1),p=6e4*(60*+m+ +y),""}).replace(/\.\d+$/,function(I){return _.nano=+(I+c).substr(1,9),""}).split(/\D+/);if(1<L.length?L[1]--:L[1]=0,_.time=p=Date.UTC.apply(Date,L)-(p||0),isNaN(p))throw new TypeError("Invalid Date");return E(_)},T.fromTimeT=function(h){return B(h,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(h){return this.nano+=+h||0,this},u.getNano=function(){var h=E(this);return(h.time%1e3*a+ +h.nano+1e9)%1e9},u.getTimeT=function(){var p=E(this),h=Math.floor(p.time/1e3),p=p.year;return p&&(h+=p*r*e/t),h},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return x(E(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(h){var p=this,_=p.toDate(),L={H:function(){return V(_.getUTCHours())},L:function(){return M(_.getUTCMilliseconds(),3)},M:function(){return V(_.getUTCMinutes())},N:function(){return M(p.getNano(),9)},S:function(){return V(_.getUTCSeconds())},Y:function(){var I=p.getYear();return 999999<I?"+"+I:9999<I?"+"+M(I,6):0<=I?M(I,4):-999999<=I?"-"+M(-I,6):I},a:function(){return S[_.getUTCDay()]},b:function(){return b[_.getUTCMonth()]},d:function(){return V(_.getUTCDate())},e:function(){return(function(I){return(9<I?"":" ")+(0|I)})(_.getUTCDate())},m:function(){return V(_.getUTCMonth()+1)}};return(function I(m){return m.replace(/%./g,function(y){var A=y[1],d=w[A],A=L[A];return d?I(d):A?A():y})})(h||l)},u.writeInt64BE=v(0,1,2,3,0,4),u.writeInt64LE=v(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),b=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],S=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],w={"%":"%",F:"%Y-%m-%d",n:`
|
|
3
3
|
`,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return T;function T(h,p,_){var L=this;if(!(L instanceof T))return new T(h,p,_);L.time=+h||0,L.nano=+p||0,L.year=+_||0,E(L)}function E(h){var p,_,L,I=h.year,m=h.time,y=h.nano,d=((y<0||a<=y)&&(y-=(_=Math.floor(y/a))*a,m+=_,_=1),I%t);return(m<-i||i<m||d)&&((p=f(m/o))&&(I+=p*t,m-=p*o),(L=x(m)).setUTCFullYear(d+L.getUTCFullYear()),L=(m=+L)+(p=f((I-=d)/t))*o,p&&-i<=L&&L<=i&&(I-=p*t,m=L),_=1),_&&(h.year=I,h.time=m,h.nano=y),h}function x(h){var p=new Date(0);return p.setTime(h),p}function B(I,L){I=+I||0;var _=f((L=(L|0)*s)/n)+f(I/n),L=L%n+I%n,I=f(L/n);return I&&(_+=I,L-=I*n),new T(1e3*L,0,_*t)}function v(h,p,_,L,I,m){return function(d,A){var U=E(this);d=d||new Array(8),P(d,A|=0);var k=Math.floor(U.time/1e3),U=U.year*(r*e/t),D=f(U/s)+f(k/s),U=U%s+k%s,k=Math.floor(U/s);return k&&(D+=k,U-=k*s),y(d,A+I,D),y(d,A+m,U),d};function y(d,A,D){d[A+h]=D>>24&255,d[A+p]=D>>16&255,d[A+_]=D>>8&255,d[A+L]=255&D}}function R(h,p,_,L,I,m){return function(d,A){P(d,A|=0);var D=y(d,A+I);return B(y(d,A+m),D)};function y(d,A){return 16777216*d[A+h]+(d[A+p]<<16|d[A+_]<<8|d[A+L])}}function P(h,p){if(h=h&&h.length,h==null)throw new TypeError("Invalid Buffer");if(h<p+8)throw new RangeError("Out of range")}function V(h){return(9<h?"":"0")+(0|h)}function M(h,p){return(c+(0|h)).substr(-p)}})()});var h0={};xt(h0,{ipns:()=>l0,ipnsResolver:()=>d0,ipnsSelector:()=>io,ipnsValidator:()=>tn});var Wt=class extends Error{static name="AbortError";constructor(t="The operation was aborted"){super(t),this.name="AbortError"}};var tt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Fe=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}},br=class extends Error{static name="InvalidPrivateKeyError";constructor(t="Invalid private key"){super(t),this.name="InvalidPrivateKeyError"}};var xr=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var un=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var qe=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};function As(e){return e==null?!1:(e.type==="RSA"||e.type==="Ed25519"||e.type==="secp256k1"||e.type==="ECDSA")&&e.raw instanceof Uint8Array&&typeof e.equals=="function"&&typeof e.toMultihash=="function"&&typeof e.toCID=="function"&&typeof e.verify=="function"}var wf=Symbol.for("@libp2p/peer-id");function fn(e){return!!e?.[wf]}var ln=class extends EventTarget{#t=new Map;constructor(){super()}listenerCount(t){let r=this.#t.get(t);return r==null?0:r.length}addEventListener(t,r,n){super.addEventListener(t,r,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:r,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,r,n){super.removeEventListener(t.toString(),r??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:i})=>i!==r),this.#t.set(t,o))}dispatchEvent(t){let r=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),r}safeDispatchEvent(t,r={}){return this.dispatchEvent(new CustomEvent(t,r))}};var Lo={};xt(Lo,{base58btc:()=>j,base58flickr:()=>Bf});var x0=new Uint8Array(0);function Is(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 Ts(e){return new TextEncoder().encode(e)}function Bs(e){return new TextDecoder().decode(e)}function Ef(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),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var T=0,E=0,x=0,B=w.length;x!==B&&w[x]===0;)x++,T++;for(var v=(B-x)*u+1>>>0,R=new Uint8Array(v);x!==B;){for(var P=w[x],V=0,M=v-1;(P!==0||V<E)&&M!==-1;M--,V++)P+=256*R[M]>>>0,R[M]=P%a>>>0,P=P/a>>>0;if(P!==0)throw new Error("Non-zero carry");E=V,x++}for(var h=v-E;h!==v&&R[h]===0;)h++;for(var p=c.repeat(T);h<v;++h)p+=e.charAt(R[h]);return p}function b(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var T=0;if(w[T]!==" "){for(var E=0,x=0;w[T]===c;)E++,T++;for(var B=(w.length-T)*f+1>>>0,v=new Uint8Array(B);w[T];){var R=r[w.charCodeAt(T)];if(R===255)return;for(var P=0,V=B-1;(R!==0||P<x)&&V!==-1;V--,P++)R+=a*v[V]>>>0,v[V]=R%256>>>0,R=R/256>>>0;if(R!==0)throw new Error("Non-zero carry");x=P,T++}if(w[T]!==" "){for(var M=B-x;M!==B&&v[M]===0;)M++;for(var h=new Uint8Array(E+(B-M)),p=E;M!==B;)h[p++]=v[M++];return h}}}function S(w){var T=b(w);if(T)return T;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:b,decode:S}}var Sf=Ef,vf=Sf,_s=vf;var To=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")}},Bo=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 Ls(this,t)}},Co=class{decoders;constructor(t){this.decoders=t}or(t){return Ls(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 Ls(e,t){return new Co({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var _o=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 To(t,r,n),this.decoder=new Bo(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function He({name:e,prefix:t,encode:r,decode:n}){return new _o(e,t,r,n)}function ue({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=_s(r,e);return He({prefix:t,name:e,encode:n,decode:i=>Jt(o(i))})}function Af(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 f=0;f<o;++f){let u=t[e[f]];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)!==0)throw new SyntaxError("Unexpected end of data");return i}function If(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)!==0;)i+="=";return i}function Tf(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function et({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Tf(n);return He({prefix:t,name:e,encode(i){return If(i,n,r)},decode(i){return Af(i,o,r,e)}})}var j=ue({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Bf=ue({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Do={};xt(Do,{base32:()=>fe,base32hex:()=>Df,base32hexpad:()=>Uf,base32hexpadupper:()=>Nf,base32hexupper:()=>Rf,base32pad:()=>_f,base32padupper:()=>Lf,base32upper:()=>Cf,base32z:()=>kf});var fe=et({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Cf=et({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),_f=et({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Lf=et({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Df=et({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Rf=et({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Uf=et({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Nf=et({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),kf=et({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ro={};xt(Ro,{base36:()=>Nt,base36upper:()=>Kf});var Nt=ue({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Kf=ue({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Pf=Us,Ds=128,Of=127,Mf=~Of,Vf=Math.pow(2,31);function Us(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Vf;)t[r++]=e&255|Ds,e/=128;for(;e&Mf;)t[r++]=e&255|Ds,e>>>=7;return t[r]=e|0,Us.bytes=r-n+1,t}var Ff=Uo,qf=128,Rs=127;function Uo(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw Uo.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&Rs)<<o:(s&Rs)*Math.pow(2,o),o+=7}while(s>=qf);return Uo.bytes=i-n,r}var Hf=Math.pow(2,7),$f=Math.pow(2,14),zf=Math.pow(2,21),Zf=Math.pow(2,28),Yf=Math.pow(2,35),Gf=Math.pow(2,42),jf=Math.pow(2,49),Xf=Math.pow(2,56),Wf=Math.pow(2,63),Jf=function(e){return e<Hf?1:e<$f?2:e<zf?3:e<Zf?4:e<Yf?5:e<Gf?6:e<jf?7:e<Xf?8:e<Wf?9:10},Qf={encode:Pf,decode:Ff,encodingLength:Jf},tl=Qf,wr=tl;function Er(e,t=0){return[wr.decode(e,t),wr.decode.bytes]}function $e(e,t,r=0){return wr.encode(e,t,r),t}function ze(e){return wr.encodingLength(e)}function Ht(e,t){let r=t.byteLength,n=ze(e),o=n+ze(r),i=new Uint8Array(o+r);return $e(e,i,0),$e(r,i,n),i.set(t,o),new Ze(e,r,t,i)}function Ye(e){let t=Jt(e),[r,n]=Er(t),[o,i]=Er(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Ze(r,o,s,t)}function Ns(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Is(e.bytes,r.bytes)}}var Ze=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function ks(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return rl(r,No(e),t??j.encoder);default:return nl(r,No(e),t??fe.encoder)}}var Ks=new WeakMap;function No(e){let t=Ks.get(e);if(t==null){let r=new Map;return Ks.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!==Sr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==ol)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=Ht(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&&Ns(t.multihash,n.multihash)}toString(t){return ks(this,t)}toJSON(){return{"/":ks(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??Ps(n,o,i.bytes))}else if(r[il]===!0){let{version:n,multihash:o,code:i}=r,s=Ye(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!==Sr)throw new Error(`Version 0 CID must use dag-pb (code: ${Sr}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Ps(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Sr,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 Ze(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[l,b]=Er(t.subarray(r));return r+=b,l},o=n(),i=Sr;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(),f=r+c,u=f-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(t,r){let[n,o]=el(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 No(i).set(n,t),i}};function el(e,t){switch(e[0]){case"Q":{let r=t??j;return[j.prefix,r.decode(`${j.prefix}${e}`)]}case j.prefix:{let r=t??j;return[j.prefix,r.decode(e)]}case fe.prefix:{let r=t??fe;return[fe.prefix,r.decode(e)]}case Nt.prefix:{let r=t??Nt;return[Nt.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 rl(e,t,r){let{prefix:n}=r;if(n!==j.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 nl(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 Sr=112,ol=18;function Ps(e,t,r){let n=ze(e),o=n+ze(t),i=new Uint8Array(o+r.byteLength);return $e(e,i,0),$e(t,i,n),i.set(r,o),i}var il=Symbol.for("@ipld/js-cid/CID");var ko={};xt(ko,{identity:()=>Te});var Os=0,sl="identity",Ms=Jt;function al(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 Ht(Os,Ms(e))}var Te={code:Os,name:sl,encode:Ms,digest:al};function rt(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 Dt(e=0){return new Uint8Array(e)}function At(e=0){return new Uint8Array(e)}function le(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=At(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var Fs=Symbol.for("@achingbrain/uint8arraylist");function Vs(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 hn(e){return!!e?.[Fs]}var mt=class e{bufs;length;[Fs]=!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(hn(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(hn(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=Vs(this.bufs,t);return r.buf[r.index]}set(t,r){let n=Vs(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(hn(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 le(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:le(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 f=t>=a&&t<c,u=r>a&&r<=c;if(f&&u){if(t===a&&r===c){n.push(s);break}let l=t-a;n.push(s.subarray(l,l+(r-t)));break}if(f){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(!hn(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 l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let a=s,c=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=r;l<=c;l+=u){u=0;for(let b=f;b>=0;b--){let S=this.get(l+b);if(n[b]!==S){u=Math.max(1,b-a[S]);break}}if(u===0)return l}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=At(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=Dt(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=Dt(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=Dt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=At(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=Dt(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=Dt(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=Dt(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=Dt(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=Dt(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(!rt(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 Ko={};xt(Ko,{base10:()=>cl});var cl=ue({prefix:"9",name:"base10",alphabet:"0123456789"});var Po={};xt(Po,{base16:()=>ul,base16upper:()=>fl});var ul=et({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),fl=et({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Oo={};xt(Oo,{base2:()=>ll});var ll=et({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Mo={};xt(Mo,{base256emoji:()=>yl});var qs=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}"),dl=qs.reduce((e,t,r)=>(e[r]=t,e),[]),hl=qs.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function pl(e){return e.reduce((t,r)=>(t+=dl[r],t),"")}function ml(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=hl[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var yl=He({prefix:"\u{1F680}",name:"base256emoji",encode:pl,decode:ml});var Fo={};xt(Fo,{base64:()=>Vo,base64pad:()=>gl,base64url:()=>bl,base64urlpad:()=>xl});var Vo=et({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),gl=et({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),bl=et({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),xl=et({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var qo={};xt(qo,{base8:()=>wl});var wl=et({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ho={};xt(Ho,{identity:()=>El});var El=He({prefix:"\0",name:"identity",encode:e=>Bs(e),decode:e=>Ts(e)});var rp=new TextEncoder,np=new TextDecoder;var Zo={};xt(Zo,{sha256:()=>pn,sha512:()=>Il});var Al=20;function zo({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new $o(e,t,r,n,o)}var $o=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,i){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Al,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?Hs(n,this.code,r?.truncate):n.then(o=>Hs(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Hs(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 Ht(t,e)}function zs(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var pn=zo({name:"sha2-256",code:18,encode:zs("SHA-256")}),Il=zo({name:"sha2-512",code:19,encode:zs("SHA-512")});var Yo={...Ho,...Oo,...qo,...Ko,...Po,...Do,...Ro,...Lo,...Fo,...Mo},mp={...Zo,...ko};function Ys(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Zs=Ys("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Go=Ys("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=At(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Tl={utf8:Zs,"utf-8":Zs,hex:Yo.base16,latin1:Go,ascii:Go,binary:Go,...Yo},mn=Tl;function $(e,t="utf8"){let r=mn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function Y(e,t="utf8"){let r=mn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var Bl=parseInt("11111",2),jo=parseInt("10000000",2),Cl=parseInt("01111111",2),Gs={0:vr,1:vr,2:_l,3:Rl,4:Ul,5:Dl,6:Ll,16:vr,22:vr,48:vr};function Qt(e,t={offset:0}){let r=e[t.offset]&Bl;if(t.offset++,Gs[r]!=null)return Gs[r](e,t);throw new Error("No decoder for tag "+r)}function Ar(e,t){let r=0;if((e[t.offset]&jo)===jo){let n=e[t.offset]&Cl,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 vr(e,t){Ar(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=Qt(e,t);if(n===null)break;r.push(n)}return r}function _l(e,t){let r=Ar(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 Ll(e,t){let r=Ar(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 f=e[t.offset];if(t.offset++,c.push(f&127),f<128){c.reverse();let u=0;for(let l=0;l<c.length;l++)u+=c[l]<<l*7;a+=`.${u}`,c=[]}}return a}function Dl(e,t){return t.offset++,null}function Rl(e,t){let r=Ar(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 Ul(e,t){let r=Ar(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function Nl(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new mt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function yn(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=Nl(e.byteLength);return new mt(Uint8Array.from([t.byteLength|jo]),t)}function yt(e){let t=new mt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new mt(Uint8Array.from([2]),yn(t),t)}function Ir(e){let t=Uint8Array.from([0]),r=new mt(t,e);return new mt(Uint8Array.from([3]),yn(r),r)}function js(e){return new mt(Uint8Array.from([4]),yn(e),e)}function kt(e,t=48){let r=new mt;for(let n of e)r.append(n);return new mt(Uint8Array.from([t]),yn(r),r)}async function Xs(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 Ws(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 Js(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 kl=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Kl=Uint8Array.from([6,5,43,129,4,0,34]),Pl=Uint8Array.from([6,5,43,129,4,0,35]),Ol={ext:!0,kty:"EC",crv:"P-256"},Ml={ext:!0,kty:"EC",crv:"P-384"},Vl={ext:!0,kty:"EC",crv:"P-521"},Xo=32,Wo=48,Jo=66;function Qo(e){let t=Qt(e);return Qs(t)}function Qs(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===Xo*2+1)return n=Y(t.subarray(r,r+Xo),"base64url"),o=Y(t.subarray(r+Xo),"base64url"),new Be({...Ol,key_ops:["verify"],x:n,y:o});if(t.byteLength===Wo*2+1)return n=Y(t.subarray(r,r+Wo),"base64url"),o=Y(t.subarray(r+Wo),"base64url"),new Be({...Ml,key_ops:["verify"],x:n,y:o});if(t.byteLength===Jo*2+1)return n=Y(t.subarray(r,r+Jo),"base64url"),o=Y(t.subarray(r+Jo),"base64url"),new Be({...Vl,key_ops:["verify"],x:n,y:o});throw new tt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function ta(e){return kt([yt(Uint8Array.from([1])),js($(e.d??"","base64url")),kt([ra(e.crv)],160),kt([Ir(new mt(Uint8Array.from([4]),$(e.x??"","base64url"),$(e.y??"","base64url")))],161)]).subarray()}function ea(e){return kt([yt(Uint8Array.from([1])),kt([ra(e.crv)],160),kt([Ir(new mt(Uint8Array.from([4]),$(e.x??"","base64url"),$(e.y??"","base64url")))],161)]).subarray()}function ra(e){if(e==="P-256")return kl;if(e==="P-384")return Kl;if(e==="P-521")return Pl;throw new tt(`Invalid curve ${e}`)}async function na(e="P-256"){let t=await Xs(e);return new gn(t.privateKey)}var Be=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=ea(this.jwk)),this._raw}toMultihash(){return Te.digest(de(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return j.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}async verify(t,r,n){return Js(this.jwk,r,t,n)}},gn=class{type="ECDSA";jwk;publicKey;_raw;constructor(t){this.jwk=t,this.publicKey=new Be({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=ta(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}async sign(t,r){return Ws(this.jwk,t,r)}};function Ce(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function $t(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=Ce(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 bn(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash must wrapped by utils.createHasher");$t(e.outputLen),$t(e.blockLen)}function Ge(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 ia(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 ee(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function xn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Kt(e,t){return e<<32-t|e>>>t}var sa=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Fl=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function re(e){if(H(e),sa)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Fl[e[r]];return t}var te={_0:48,_9:57,A:65,F:70,a:97,f:102};function oa(e){if(e>=te._0&&e<=te._9)return e-te._0;if(e>=te.A&&e<=te.F)return e-(te.A-10);if(e>=te.a&&e<=te.f)return e-(te.a-10)}function ne(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(sa)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=oa(e.charCodeAt(i)),a=oa(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 wt(...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 ti(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 je(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 ei=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function aa(e,t,r){return e&t^~e&r}function ca(e,t,r){return e&t^e&r^t&r}var Tr=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=xn(this.buffer)}update(t){Ge(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=xn(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){Ge(this),ia(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,ee(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let a=xn(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],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()}},oe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ft=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var wn=BigInt(4294967295),ua=BigInt(32);function ql(e,t=!1){return t?{h:Number(e&wn),l:Number(e>>ua&wn)}:{h:Number(e>>ua&wn)|0,l:Number(e&wn)|0}}function fa(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}=ql(e[i],t);[n[i],o[i]]=[s,a]}return[n,o]}var ri=(e,t,r)=>e>>>r,ni=(e,t,r)=>e<<32-r|t>>>r,_e=(e,t,r)=>e>>>r|t<<32-r,Le=(e,t,r)=>e<<32-r|t>>>r,Br=(e,t,r)=>e<<64-r|t>>>r-32,Cr=(e,t,r)=>e>>>r-32|t<<64-r;function zt(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var la=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),da=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,ha=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),pa=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,ma=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),ya=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var $l=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]),he=new Uint32Array(64),oi=class extends Tr{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 l=0;l<16;l++,r+=4)he[l]=t.getUint32(r,!1);for(let l=16;l<64;l++){let b=he[l-15],S=he[l-2],w=Kt(b,7)^Kt(b,18)^b>>>3,T=Kt(S,17)^Kt(S,19)^S>>>10;he[l]=T+he[l-7]+w+he[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let b=Kt(a,6)^Kt(a,11)^Kt(a,25),S=u+b+aa(a,c,f)+$l[l]+he[l]|0,T=(Kt(n,2)^Kt(n,13)^Kt(n,22))+ca(n,o,i)|0;u=f,f=c,c=a,a=s+S|0,s=i,i=o,o=n,n=S+T|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,f,u)}roundClean(){ee(he)}destroy(){this.set(0,0,0,0,0,0,0,0),ee(this.buffer)}},ii=class extends oi{A=oe[0]|0;B=oe[1]|0;C=oe[2]|0;D=oe[3]|0;E=oe[4]|0;F=oe[5]|0;G=oe[6]|0;H=oe[7]|0;constructor(){super(32)}};var ga=fa(["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))),zl=ga[0],Zl=ga[1],pe=new Uint32Array(80),me=new Uint32Array(80),si=class extends Tr{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:f,El:u,Fh:l,Fl:b,Gh:S,Gl:w,Hh:T,Hl:E}=this;return[t,r,n,o,i,s,a,c,f,u,l,b,S,w,T,E]}set(t,r,n,o,i,s,a,c,f,u,l,b,S,w,T,E){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=f|0,this.El=u|0,this.Fh=l|0,this.Fl=b|0,this.Gh=S|0,this.Gl=w|0,this.Hh=T|0,this.Hl=E|0}process(t,r){for(let v=0;v<16;v++,r+=4)pe[v]=t.getUint32(r),me[v]=t.getUint32(r+=4);for(let v=16;v<80;v++){let R=pe[v-15]|0,P=me[v-15]|0,V=_e(R,P,1)^_e(R,P,8)^ri(R,P,7),M=Le(R,P,1)^Le(R,P,8)^ni(R,P,7),h=pe[v-2]|0,p=me[v-2]|0,_=_e(h,p,19)^Br(h,p,61)^ri(h,p,6),L=Le(h,p,19)^Cr(h,p,61)^ni(h,p,6),I=ha(M,L,me[v-7],me[v-16]),m=pa(I,V,_,pe[v-7],pe[v-16]);pe[v]=m|0,me[v]=I|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:b,Fh:S,Fl:w,Gh:T,Gl:E,Hh:x,Hl:B}=this;for(let v=0;v<80;v++){let R=_e(l,b,14)^_e(l,b,18)^Br(l,b,41),P=Le(l,b,14)^Le(l,b,18)^Cr(l,b,41),V=l&S^~l&T,M=b&w^~b&E,h=ma(B,P,M,Zl[v],me[v]),p=ya(h,x,R,V,zl[v],pe[v]),_=h|0,L=_e(n,o,28)^Br(n,o,34)^Br(n,o,39),I=Le(n,o,28)^Cr(n,o,34)^Cr(n,o,39),m=n&i^n&a^i&a,y=o&s^o&c^s&c;x=T|0,B=E|0,T=S|0,E=w|0,S=l|0,w=b|0,{h:l,l:b}=zt(f|0,u|0,p|0,_|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let d=la(_,I,y);n=da(d,p,L,m),o=d|0}({h:n,l:o}=zt(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=zt(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=zt(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=zt(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:b}=zt(this.Eh|0,this.El|0,l|0,b|0),{h:S,l:w}=zt(this.Fh|0,this.Fl|0,S|0,w|0),{h:T,l:E}=zt(this.Gh|0,this.Gl|0,T|0,E|0),{h:x,l:B}=zt(this.Hh|0,this.Hl|0,x|0,B|0),this.set(n,o,i,s,a,c,f,u,l,b,S,w,T,E,x,B)}roundClean(){ee(pe,me)}destroy(){ee(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},ai=class extends si{Ah=ft[0]|0;Al=ft[1]|0;Bh=ft[2]|0;Bl=ft[3]|0;Ch=ft[4]|0;Cl=ft[5]|0;Dh=ft[6]|0;Dl=ft[7]|0;Eh=ft[8]|0;El=ft[9]|0;Fh=ft[10]|0;Fl=ft[11]|0;Gh=ft[12]|0;Gl=ft[13]|0;Hh=ft[14]|0;Hl=ft[15]|0;constructor(){super(64)}};var Xe=ti(()=>new ii,ei(1));var ba=ti(()=>new ai,ei(3));var ui=BigInt(0),ci=BigInt(1);function ie(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function xa(e){if(typeof e=="bigint"){if(!En(e))throw new Error("positive bigint expected, got "+e)}else $t(e);return e}function _r(e){let t=xa(e).toString(16);return t.length&1?"0"+t:t}function wa(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?ui:BigInt("0x"+e)}function We(e){return wa(re(e))}function De(e){return wa(re(vn(H(e)).reverse()))}function Sn(e,t){$t(t),e=xa(e);let r=ne(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function fi(e,t){return Sn(e,t).reverse()}function vn(e){return Uint8Array.from(e)}var En=e=>typeof e=="bigint"&&ui<=e;function Yl(e,t,r){return En(e)&&En(t)&&En(r)&&t<=e&&e<r}function Lr(e,t,r,n){if(!Yl(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function li(e){let t;for(t=0;e>ui;e>>=ci,t+=1);return t}var Dr=e=>(ci<<BigInt(e))-ci;function Ea(e,t,r){if($t(e,"hashLen"),$t(t,"qByteLen"),typeof r!="function")throw new Error("hmacFn must be a function");let n=E=>new Uint8Array(E),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=n(e),f=n(e),u=0,l=()=>{c.fill(1),f.fill(0),u=0},b=(...E)=>r(f,wt(c,...E)),S=(E=o)=>{f=b(i,E),c=b(),E.length!==0&&(f=b(s,E),c=b())},w=()=>{if(u++>=a)throw new Error("drbg: tried max amount of iterations");let E=0,x=[];for(;E<t;){c=b();let B=c.slice();x.push(B),E+=c.length}return wt(...x)};return(E,x)=>{l(),S(E);let B;for(;!(B=x(w()));)S();return l(),B}}function ye(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 f=typeof c;if(f!==s||c===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${f}`)}let o=(i,s)=>Object.entries(i).forEach(([a,c])=>n(a,c,s));o(t,!1),o(r,!0)}function Je(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 gt=BigInt(0),st=BigInt(1),Re=BigInt(2),Aa=BigInt(3),Ia=BigInt(4),Ta=BigInt(5),Gl=BigInt(7),Ba=BigInt(8),jl=BigInt(9),Ca=BigInt(16);function nt(e,t){let r=e%t;return r>=gt?r:t+r}function X(e,t,r){let n=e;for(;t-- >gt;)n*=n,n%=r;return n}function Sa(e,t){if(e===gt)throw new Error("invert: expected non-zero number");if(t<=gt)throw new Error("invert: expected positive modulus, got "+t);let r=nt(e,t),n=t,o=gt,i=st,s=st,a=gt;for(;r!==gt;){let f=n/r,u=n%r,l=o-s*f,b=i-a*f;n=r,r=u,o=s,i=a,s=l,a=b}if(n!==st)throw new Error("invert: does not exist");return nt(o,t)}function hi(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function _a(e,t){let r=(e.ORDER+st)/Ia,n=e.pow(t,r);return hi(e,n,t),n}function Xl(e,t){let r=(e.ORDER-Ta)/Ba,n=e.mul(t,Re),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,Re),o),a=e.mul(i,e.sub(s,e.ONE));return hi(e,a,t),a}function Wl(e){let t=Qe(e),r=La(e),n=r(t,t.neg(t.ONE)),o=r(t,n),i=r(t,t.neg(n)),s=(e+Gl)/Ca;return(a,c)=>{let f=a.pow(c,s),u=a.mul(f,n),l=a.mul(f,o),b=a.mul(f,i),S=a.eql(a.sqr(u),c),w=a.eql(a.sqr(l),c);f=a.cmov(f,u,S),u=a.cmov(b,l,w);let T=a.eql(a.sqr(u),c),E=a.cmov(f,u,T);return hi(a,E,c),E}}function La(e){if(e<Aa)throw new Error("sqrt is not defined for small field");let t=e-st,r=0;for(;t%Re===gt;)t/=Re,r++;let n=Re,o=Qe(e);for(;va(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return _a;let i=o.pow(n,t),s=(t+st)/Re;return function(c,f){if(c.is0(f))return f;if(va(c,f)!==1)throw new Error("Cannot find square root");let u=r,l=c.mul(c.ONE,i),b=c.pow(f,t),S=c.pow(f,s);for(;!c.eql(b,c.ONE);){if(c.is0(b))return c.ZERO;let w=1,T=c.sqr(b);for(;!c.eql(T,c.ONE);)if(w++,T=c.sqr(T),w===u)throw new Error("Cannot find square root");let E=st<<BigInt(u-w-1),x=c.pow(l,E);u=w,l=c.sqr(x),b=c.mul(b,l),S=c.mul(S,x)}return S}}function Jl(e){return e%Ia===Aa?_a:e%Ba===Ta?Xl:e%Ca===jl?Wl(e):La(e)}var Da=(e,t)=>(nt(e,t)&st)===st,Ql=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function pi(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Ql.reduce((n,o)=>(n[o]="function",n),t);return ye(e,r),e}function td(e,t,r){if(r<gt)throw new Error("invalid exponent, negatives unsupported");if(r===gt)return e.ONE;if(r===st)return t;let n=e.ONE,o=t;for(;r>gt;)r&st&&(n=e.mul(n,o)),o=e.sqr(o),r>>=st;return n}function Rr(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 va(e,t){let r=(e.ORDER-st)/Re,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 ed(e,t){t!==void 0&&$t(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var di=class{ORDER;BITS;BYTES;isLE;ZERO=gt;ONE=st;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=gt)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}=ed(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 gt<=t&&t<this.ORDER}is0(t){return t===gt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&st)===st}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 td(this,t,r)}div(t,r){return nt(t*Sa(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 Sa(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=Jl(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?fi(t,this.BYTES):Sn(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 f=new Uint8Array(o);f.set(t,i?0:f.length-t.length),t=f}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let c=i?De(t):We(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 Rr(this,t)}cmov(t,r,n){return n?r:t}};function Qe(e,t={}){return new di(e,t)}function Ra(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 mi(e){let t=Ra(e);return t+Math.ceil(t/2)}function yi(e,t,r=!1){H(e);let n=e.length,o=Ra(t),i=mi(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?De(e):We(e),a=nt(s,t-st)+st;return r?fi(a,o):Sn(a,o)}var tr=BigInt(0),Ue=BigInt(1);function Ur(e,t){let r=t.negate();return e?r:t}function Ne(e,t){let r=Rr(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function Ka(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function gi(e,t){Ka(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=Dr(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Ua(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+=Ue);let f=t*n,u=f+Math.abs(a)-1,l=a===0,b=a<0,S=t%2!==0;return{nextN:c,offset:u,isZero:l,isNeg:b,isNegF:S,offsetF:f}}var bi=new WeakMap,Pa=new WeakMap;function xi(e){return Pa.get(e)||1}function Na(e){if(e!==tr)throw new Error("invalid wNAF")}var er=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>tr;)r&Ue&&(n=n.add(o)),o=o.double(),r>>=Ue;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=gi(r,this.bits),i=[],s=t,a=s;for(let c=0;c<n;c++){a=s,i.push(a);for(let f=1;f<o;f++)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=gi(t,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:f,isZero:u,isNeg:l,isNegF:b,offsetF:S}=Ua(n,a,s);n=c,u?i=i.add(Ur(b,r[S])):o=o.add(Ur(l,r[f]))}return Na(n),{p:o,f:i}}wNAFUnsafe(t,r,n,o=this.ZERO){let i=gi(t,this.bits);for(let s=0;s<i.windows&&n!==tr;s++){let{nextN:a,offset:c,isZero:f,isNeg:u}=Ua(n,s,i);if(n=a,!f){let l=r[c];o=o.add(u?l.negate():l)}}return Na(n),o}getPrecomputes(t,r,n){let o=bi.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),bi.set(r,o))),o}cached(t,r,n){let o=xi(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let i=xi(t);return i===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),r,o)}createCache(t,r){Ka(r,this.bits),Pa.set(t,r),bi.delete(t)}hasCache(t){return xi(t)!==1}};function Oa(e,t,r,n){let o=t,i=e.ZERO,s=e.ZERO;for(;r>tr||n>tr;)r&Ue&&(i=i.add(o)),n&Ue&&(s=s.add(o)),o=o.double(),r>>=Ue,n>>=Ue;return{p1:i,p2:s}}function ka(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return pi(t),t}else return Qe(e,{isLE:r})}function An(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 f=t[c];if(!(typeof f=="bigint"&&f>tr))throw new Error(`CURVE.${c} must be positive bigint`)}let o=ka(t.p,r.Fp,n),i=ka(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 In(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var ge=BigInt(0),at=BigInt(1),wi=BigInt(2),rd=BigInt(8);function nd(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 Ma(e,t={}){let r=An("edwards",e,t,t.FpFnLE),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s}=i;ye(t,{},{uvRatio:"function"});let a=wi<<BigInt(o.BYTES*8)-at,c=E=>n.create(E),f=t.uvRatio||((E,x)=>{try{return{isValid:!0,value:n.sqrt(n.div(E,x))}}catch{return{isValid:!1,value:ge}}});if(!nd(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function u(E,x,B=!1){let v=B?at:ge;return Lr("coordinate "+E,x,v,a),x}function l(E){if(!(E instanceof w))throw new Error("EdwardsPoint expected")}let b=Je((E,x)=>{let{X:B,Y:v,Z:R}=E,P=E.is0();x==null&&(x=P?rd:n.inv(R));let V=c(B*x),M=c(v*x),h=n.mul(R,x);if(P)return{x:ge,y:at};if(h!==at)throw new Error("invZ was invalid");return{x:V,y:M}}),S=Je(E=>{let{a:x,d:B}=i;if(E.is0())throw new Error("bad point: ZERO");let{X:v,Y:R,Z:P,T:V}=E,M=c(v*v),h=c(R*R),p=c(P*P),_=c(p*p),L=c(M*x),I=c(p*c(L+h)),m=c(_+c(B*c(M*h)));if(I!==m)throw new Error("bad point: equation left != right (1)");let y=c(v*R),d=c(P*V);if(y!==d)throw new Error("bad point: equation left != right (2)");return!0});class w{static BASE=new w(i.Gx,i.Gy,at,c(i.Gx*i.Gy));static ZERO=new w(ge,at,at,ge);static Fp=n;static Fn=o;X;Y;Z;T;constructor(x,B,v,R){this.X=u("x",x),this.Y=u("y",B),this.Z=u("z",v,!0),this.T=u("t",R),Object.freeze(this)}static CURVE(){return i}static fromAffine(x){if(x instanceof w)throw new Error("extended point not allowed");let{x:B,y:v}=x||{};return u("x",B),u("y",v),new w(B,v,at,c(B*v))}static fromBytes(x,B=!1){let v=n.BYTES,{a:R,d:P}=i;x=vn(H(x,v,"point")),ie(B,"zip215");let V=vn(x),M=x[v-1];V[v-1]=M&-129;let h=De(V),p=B?a:n.ORDER;Lr("point.y",h,ge,p);let _=c(h*h),L=c(_-at),I=c(P*_-R),{isValid:m,value:y}=f(L,I);if(!m)throw new Error("bad point: invalid y coordinate");let d=(y&at)===at,A=(M&128)!==0;if(!B&&y===ge&&A)throw new Error("bad point: x=0 and x_0=1");return A!==d&&(y=c(-y)),w.fromAffine({x:y,y:h})}static fromHex(x,B=!1){return w.fromBytes(ne(x),B)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(x=8,B=!0){return T.createCache(this,x),B||this.multiply(wi),this}assertValidity(){S(this)}equals(x){l(x);let{X:B,Y:v,Z:R}=this,{X:P,Y:V,Z:M}=x,h=c(B*M),p=c(P*R),_=c(v*M),L=c(V*R);return h===p&&_===L}is0(){return this.equals(w.ZERO)}negate(){return new w(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:x}=i,{X:B,Y:v,Z:R}=this,P=c(B*B),V=c(v*v),M=c(wi*c(R*R)),h=c(x*P),p=B+v,_=c(c(p*p)-P-V),L=h+V,I=L-M,m=h-V,y=c(_*I),d=c(L*m),A=c(_*m),D=c(I*L);return new w(y,d,D,A)}add(x){l(x);let{a:B,d:v}=i,{X:R,Y:P,Z:V,T:M}=this,{X:h,Y:p,Z:_,T:L}=x,I=c(R*h),m=c(P*p),y=c(M*v*L),d=c(V*_),A=c((R+P)*(h+p)-I-m),D=d-y,U=d+y,k=c(m-B*I),K=c(A*D),O=c(U*k),q=c(A*k),W=c(D*U);return new w(K,O,W,q)}subtract(x){return this.add(x.negate())}multiply(x){if(!o.isValidNot0(x))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:B,f:v}=T.cached(this,x,R=>Ne(w,R));return Ne(w,[B,v])[0]}multiplyUnsafe(x,B=w.ZERO){if(!o.isValid(x))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return x===ge?w.ZERO:this.is0()||x===at?this:T.unsafe(this,x,v=>Ne(w,v),B)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return T.unsafe(this,i.n).is0()}toAffine(x){return b(this,x)}clearCofactor(){return s===at?this:this.multiplyUnsafe(s)}toBytes(){let{x,y:B}=this.toAffine(),v=n.toBytes(B);return v[v.length-1]|=x&at?128:0,v}toHex(){return re(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let T=new er(w,o.BITS);return w.BASE.precompute(8),w}function Va(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');ye(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||je,c=r.adjustScalarBytes||(h=>h),f=r.domain||((h,p,_)=>{if(ie(_,"phflag"),p.length||_)throw new Error("Contexts/pre-hash are not supported");return h});function u(h){return s.create(De(h))}function l(h){let p=v.secretKey;H(h,v.secretKey,"secretKey");let _=H(t(h),2*p,"hashedSecretKey"),L=c(_.slice(0,p)),I=_.slice(p,2*p),m=u(L);return{head:L,prefix:I,scalar:m}}function b(h){let{head:p,prefix:_,scalar:L}=l(h),I=o.multiply(L),m=I.toBytes();return{head:p,prefix:_,scalar:L,point:I,pointBytes:m}}function S(h){return b(h).pointBytes}function w(h=Uint8Array.of(),...p){let _=wt(...p);return u(t(f(_,H(h,void 0,"context"),!!n)))}function T(h,p,_={}){h=H(h,void 0,"message"),n&&(h=n(h));let{prefix:L,scalar:I,pointBytes:m}=b(p),y=w(_.context,L,h),d=o.multiply(y).toBytes(),A=w(_.context,d,m,h),D=s.create(y+A*I);if(!s.isValid(D))throw new Error("sign failed: invalid s");let U=wt(d,s.toBytes(D));return H(U,v.signature,"result")}let E={zip215:!0};function x(h,p,_,L=E){let{context:I,zip215:m}=L,y=v.signature;h=H(h,y,"signature"),p=H(p,void 0,"message"),_=H(_,v.publicKey,"publicKey"),m!==void 0&&ie(m,"zip215"),n&&(p=n(p));let d=y/2,A=h.subarray(0,d),D=De(h.subarray(d,y)),U,k,K;try{U=e.fromBytes(_,m),k=e.fromBytes(A,m),K=o.multiplyUnsafe(D)}catch{return!1}if(!m&&U.isSmallOrder())return!1;let O=w(I,k.toBytes(),U.toBytes(),p);return k.add(U.multiplyUnsafe(O)).subtract(K).clearCofactor().is0()}let B=i.BYTES,v={secretKey:B,publicKey:B,signature:2*B,seed:B};function R(h=a(v.seed)){return H(h,v.seed,"seed")}function P(h){return Ce(h)&&h.length===s.BYTES}function V(h,p){try{return!!e.fromBytes(h,p)}catch{return!1}}let M={getExtendedPublicKey:b,randomSecretKey:R,isValidSecretKey:P,isValidPublicKey:V,toMontgomery(h){let{y:p}=e.fromBytes(h),_=v.publicKey,L=_===32;if(!L&&_!==57)throw new Error("only defined for 25519 and 448");let I=L?i.div(at+p,at-p):i.div(p-at,p+at);return i.toBytes(I)},toMontgomerySecret(h){let p=v.secretKey;H(h,p);let _=t(h.subarray(0,p));return c(_).subarray(0,p)}};return Object.freeze({keygen:In(R,S),getPublicKey:S,sign:T,verify:x,utils:M,Point:e,lengths:v})}var od=BigInt(1),Fa=BigInt(2);var id=BigInt(5),sd=BigInt(8),Ei=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),ad={p:Ei,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:sd,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function cd(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=Ei,a=e*e%i*e%i,c=X(a,Fa,i)*a%i,f=X(c,od,i)*e%i,u=X(f,id,i)*f%i,l=X(u,t,i)*u%i,b=X(l,r,i)*l%i,S=X(b,n,i)*b%i,w=X(S,o,i)*S%i,T=X(w,o,i)*S%i,E=X(T,t,i)*u%i;return{pow_p_5_8:X(E,Fa,i)*e%i,b2:a}}function ud(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var qa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function fd(e,t){let r=Ei,n=nt(t*t*t,r),o=nt(n*n*t,r),i=cd(e*o).pow_p_5_8,s=nt(e*n*i,r),a=nt(t*s*s,r),c=s,f=nt(s*qa,r),u=a===e,l=a===nt(-e,r),b=a===nt(-e*qa,r);return u&&(s=c),(l||b)&&(s=f),Da(s,r)&&(s=nt(-s,r)),{isValid:u||l,value:s}}var ld=Ma(ad,{uvRatio:fd});function dd(e){return Va(ld,ba,Object.assign({adjustScalarBytes:ud},e))}var Nr=dd({});var kr=class extends Error{constructor(t="An error occurred while signing a message"){super(t),this.name="SigningError"}},Kr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Tn=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Ha={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Tn("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 Et=Ha;var Bn=32,Pr=64,Si=32;var rr,$a=(async()=>{try{return await Et.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();function za(){let e=Nr.utils.randomSecretKey(),t=Nr.getPublicKey(e);return{privateKey:gd(e,t),publicKey:t}}async function hd(e,t){let r;e.length===Pr?r=e.subarray(0,32):r=e;let n={crv:"Ed25519",kty:"OKP",x:Y(e.subarray(32),"base64url"),d:Y(r,"base64url"),ext:!0,key_ops:["sign"]},o=await Et.get().subtle.importKey("jwk",n,{name:"Ed25519"},!0,["sign"]),i=await Et.get().subtle.sign({name:"Ed25519"},o,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(i,0,i.byteLength)}function pd(e,t){let r=e.subarray(0,Si);return Nr.sign(t instanceof Uint8Array?t:t.subarray(),r)}async function Za(e,t){return rr==null&&(rr=await $a),rr?hd(e,t):pd(e,t)}async function md(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await Et.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await Et.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 yd(e,t,r){return Nr.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function Ya(e,t,r){return rr==null&&(rr=await $a),rr?md(e,t,r):yd(e,t,r)}function gd(e,t){let r=new Uint8Array(Pr);for(let n=0;n<Si;n++)r[n]=e[n],r[Si+n]=t[n];return r}function nr(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var Or=class{type="Ed25519";raw;constructor(t){this.raw=_n(t,Bn)}toMultihash(){return Te.digest(de(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return j.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=Ya(this.raw,r,t);return nr(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}},Cn=class{type="Ed25519";raw;publicKey;constructor(t,r){this.raw=_n(t,Pr),this.publicKey=new Or(r)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}sign(t,r){r?.signal?.throwIfAborted();let n=Za(this.raw,t);return nr(n)?n.then(o=>(r?.signal?.throwIfAborted(),o)):(r?.signal?.throwIfAborted(),n)}};function vi(e){return e=_n(e,Bn),new Or(e)}async function ja(){let{privateKey:e,publicKey:t}=za();return new Cn(e,t)}function _n(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new tt(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var bd=Math.pow(2,7),xd=Math.pow(2,14),wd=Math.pow(2,21),Xa=Math.pow(2,28),Wa=Math.pow(2,35),Ja=Math.pow(2,42),Qa=Math.pow(2,49),bt=128,be=127;function Mr(e){if(e<bd)return 1;if(e<xd)return 2;if(e<wd)return 3;if(e<Xa)return 4;if(e<Wa)return 5;if(e<Ja)return 6;if(e<Qa)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function tc(e,t,r=0){switch(Mr(e)){case 8:t[r++]=e&255|bt,e/=128;case 7:t[r++]=e&255|bt,e/=128;case 6:t[r++]=e&255|bt,e/=128;case 5:t[r++]=e&255|bt,e/=128;case 4:t[r++]=e&255|bt,e>>>=7;case 3:t[r++]=e&255|bt,e>>>=7;case 2:t[r++]=e&255|bt,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function ec(e,t){let r=e[t],n=0;if(n+=r&be,r<bt||(r=e[t+1],n+=(r&be)<<7,r<bt)||(r=e[t+2],n+=(r&be)<<14,r<bt)||(r=e[t+3],n+=(r&be)<<21,r<bt)||(r=e[t+4],n+=(r&be)*Xa,r<bt)||(r=e[t+5],n+=(r&be)*Wa,r<bt)||(r=e[t+6],n+=(r&be)*Ja,r<bt)||(r=e[t+7],n+=(r&be)*Qa,r<bt))return n;throw new RangeError("Could not decode varint")}var Ai=new Float32Array([-0]),xe=new Uint8Array(Ai.buffer);function rc(e,t,r){Ai[0]=e,t[r]=xe[0],t[r+1]=xe[1],t[r+2]=xe[2],t[r+3]=xe[3]}function nc(e,t){return xe[0]=e[t],xe[1]=e[t+1],xe[2]=e[t+2],xe[3]=e[t+3],Ai[0]}var Ii=new Float64Array([-0]),pt=new Uint8Array(Ii.buffer);function oc(e,t,r){Ii[0]=e,t[r]=pt[0],t[r+1]=pt[1],t[r+2]=pt[2],t[r+3]=pt[3],t[r+4]=pt[4],t[r+5]=pt[5],t[r+6]=pt[6],t[r+7]=pt[7]}function ic(e,t){return pt[0]=e[t],pt[1]=e[t+1],pt[2]=e[t+2],pt[3]=e[t+3],pt[4]=e[t+4],pt[5]=e[t+5],pt[6]=e[t+6],pt[7]=e[t+7],Ii[0]}var Ed=BigInt(Number.MAX_SAFE_INTEGER),Sd=BigInt(Number.MIN_SAFE_INTEGER),It=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 ke;if(t<Ed&&t>Sd)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>sc&&(o=0n,++n>sc&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return ke;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):ke}},ke=new It(0,0);ke.toBigInt=function(){return 0n};ke.zzEncode=ke.zzDecode=function(){return this};ke.length=function(){return 1};var sc=4294967296n;function ac(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 cc(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 Ti(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 Pt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Ln(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Bi=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,Pt(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 Pt(this,4);return Ln(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Pt(this,4);return Ln(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Pt(this,4);let t=nc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Pt(this,4);let t=ic(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 Pt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return cc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Pt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Pt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new It(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 Pt(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 Pt(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 Pt(this,8);let t=Ln(this.buf,this.pos+=4),r=Ln(this.buf,this.pos+=4);return new It(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=ec(this.buf,this.pos);return this.pos+=Mr(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 Ci(e){return new Bi(e instanceof Uint8Array?e:e.subarray())}function Zt(e,t,r){let n=Ci(e);return t.decode(n,void 0,r)}function _i(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return At(s);o+s>t&&(n=At(t),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var Ke=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Li(){}var Ri=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},vd=_i();function Ad(e){return globalThis.Buffer!=null?At(e):vd(e)}var Fr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Ke(Li,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new Ke(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Ui((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(Dn,10,It.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=It.fromBigInt(t);return this._push(Dn,r.length(),r)}uint64Number(t){return this._push(tc,Mr(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=It.fromBigInt(t).zzEncode();return this._push(Dn,r.length(),r)}sint64Number(t){let r=It.fromNumber(t).zzEncode();return this._push(Dn,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Di,1,t?1:0)}fixed32(t){return this._push(Vr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=It.fromBigInt(t);return this._push(Vr,4,r.lo)._push(Vr,4,r.hi)}fixed64Number(t){let r=It.fromNumber(t);return this._push(Vr,4,r.lo)._push(Vr,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(rc,4,t)}double(t){return this._push(oc,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(Di,1,0):this.uint32(r)._push(Td,r,t)}string(t){let r=ac(t);return r!==0?this.uint32(r)._push(Ti,r,t):this._push(Di,1,0)}fork(){return this.states=new Ri(this),this.head=this.tail=new Ke(Li,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 Ke(Li,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=Ad(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function Di(e,t,r){t[r]=e&255}function Id(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Ui=class extends Ke{next;constructor(t,r){super(Id,t,r),this.next=void 0}};function Dn(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 Vr(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 Td(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(Fr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(Bd,t,e),this},Fr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Cd,t,e),this});function Bd(e,t,r){t.set(e,r)}function Cd(e,t,r){e.length<40?Ti(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set($(e),r)}function Ni(){return new Fr}function Yt(e,t){let r=Ni();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var or;(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"})(or||(or={}));function Rn(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function qr(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 Rn("enum",or.VARINT,r,n)}function Gt(e,t){return Rn("message",or.LENGTH_DELIMITED,e,t)}var ot;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(ot||(ot={}));var ki;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(ki||(ki={}));(function(e){e.codec=()=>qr(ki)})(ot||(ot={}));var jt;(function(e){let t;e.codec=()=>(t==null&&(t=Gt((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ot.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=ot.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>Yt(r,e.codec()),e.decode=(r,n)=>Zt(r,e.codec(),n)})(jt||(jt={}));var Ki;(function(e){let t;e.codec=()=>(t==null&&(t=Gt((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ot.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=ot.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>Yt(r,e.codec()),e.decode=(r,n)=>Zt(r,e.codec(),n)})(Ki||(Ki={}));var $r={};xt($r,{MAX_RSA_KEY_SIZE:()=>Pi,generateRSAKeyPair:()=>Zi,jwkToJWKKeyPair:()=>pc,jwkToPkcs1:()=>Rd,jwkToPkix:()=>Fi,jwkToRSAPrivateKey:()=>zi,pkcs1MessageToJwk:()=>Mi,pkcs1MessageToRSAPrivateKey:()=>qi,pkcs1ToJwk:()=>Dd,pkcs1ToRSAPrivateKey:()=>hc,pkixMessageToJwk:()=>Vi,pkixMessageToRSAPublicKey:()=>$i,pkixToJwk:()=>Ud,pkixToRSAPublicKey:()=>Hi});var ir=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=$r.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return it.createV1(114,this._multihash)}toString(){return j.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}verify(t,r,n){return dc(this.jwk,r,t,n)}},Hr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=$r.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}sign(t,r){return lc(this.jwk,t,r)}};var Pi=8192,Oi=18,_d=1062,Ld=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Dd(e){let t=Qt(e);return Mi(t)}function Mi(e){return{n:Y(e[1],"base64url"),e:Y(e[2],"base64url"),d:Y(e[3],"base64url"),p:Y(e[4],"base64url"),q:Y(e[5],"base64url"),dp:Y(e[6],"base64url"),dq:Y(e[7],"base64url"),qi:Y(e[8],"base64url"),kty:"RSA"}}function Rd(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 tt("JWK was missing components");return kt([yt(Uint8Array.from([0])),yt($(e.n,"base64url")),yt($(e.e,"base64url")),yt($(e.d,"base64url")),yt($(e.p,"base64url")),yt($(e.q,"base64url")),yt($(e.dp,"base64url")),yt($(e.dq,"base64url")),yt($(e.qi,"base64url"))]).subarray()}function Ud(e){let t=Qt(e,{offset:0});return Vi(t)}function Vi(e){let t=Qt(e[1],{offset:0});return{kty:"RSA",n:Y(t[0],"base64url"),e:Y(t[1],"base64url")}}function Fi(e){if(e.n==null||e.e==null)throw new tt("JWK was missing components");return kt([Ld,Ir(kt([yt($(e.n,"base64url")),yt($(e.e,"base64url"))]))]).subarray()}function hc(e){let t=Qt(e);return qi(t)}function qi(e){let t=Mi(e);return zi(t)}function Hi(e,t){if(e.byteLength>=_d)throw new Fe("Key size is too large");let r=Qt(e,{offset:0});return $i(r,e,t)}function $i(e,t,r){let n=Vi(e);if(r==null){let o=Xe(jt.encode({Type:ot.RSA,Data:t}));r=Ht(Oi,o)}return new ir(n,r)}function zi(e){if(yc(e)>Pi)throw new tt("Key size is too large");let t=pc(e),r=Xe(jt.encode({Type:ot.RSA,Data:Fi(t.publicKey)})),n=Ht(Oi,r);return new Hr(t.privateKey,new ir(t.publicKey,n))}async function Zi(e){if(e>Pi)throw new tt("Key size is too large");let t=await mc(e),r=Xe(jt.encode({Type:ot.RSA,Data:Fi(t.publicKey)})),n=Ht(Oi,r);return new Hr(t.privateKey,new ir(t.publicKey,n))}function pc(e){if(e==null)throw new tt("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function mc(e,t){let r=await Et.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 Nd(r,t);return{privateKey:n[0],publicKey:n[1]}}async function lc(e,t,r){let n=await Et.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await Et.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 dc(e,t,r,n){let o=await Et.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await Et.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,t,r instanceof Uint8Array?r:r.subarray());return n?.signal?.throwIfAborted(),i}async function Nd(e,t){if(e.privateKey==null||e.publicKey==null)throw new tt("Private and public key are required");let r=await Promise.all([Et.get().subtle.exportKey("jwk",e.privateKey),Et.get().subtle.exportKey("jwk",e.publicKey)]);return t?.signal?.throwIfAborted(),r}function yc(e){if(e.kty!=="RSA")throw new tt("invalid key type");if(e.n==null)throw new tt("invalid key modulus");return $(e.n,"base64url").length*8}var Un=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(t,r){if(bn(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),ee(o)}update(t){return Ge(this),this.iHash.update(t),this}digestInto(t){Ge(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()}},Yi=(e,t,r)=>new Un(e,t).update(r).digest();Yi.create=(e,t)=>new Un(e,t);var gc=(e,t)=>(e+(e>=0?t:-t)/bc)/t;function kd(e,t,r){let[[n,o],[i,s]]=t,a=gc(s*e,r),c=gc(-o*e,r),f=e-a*n-c*i,u=-a*o-c*s,l=f<se,b=u<se;l&&(f=-f),b&&(u=-u);let S=Dr(Math.ceil(li(r)/2))+sr;if(f<se||f>=S||u<se||u>=S)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:l,k1:f,k2neg:b,k2:u}}function ji(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Gi(e,t){let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return ie(r.lowS,"lowS"),ie(r.prehash,"prehash"),r.format!==void 0&&ji(r.format),r}var Xi=class extends Error{constructor(t=""){super(t)}},we={Err:Xi,_tlv:{encode:(e,t)=>{let{Err:r}=we;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=_r(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?_r(o.length/2|128):"";return _r(e)+i+o+t},decode(e,t){let{Err:r}=we,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 f=t.subarray(n,n+c);if(f.length!==c)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(n+=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}=we;if(e<se)throw new t("integer: negative integers are not allowed");let r=_r(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}=we;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 We(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=we,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:f,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(f)}},hexFromSig(e){let{_tlv:t,_int:r}=we,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},se=BigInt(0),sr=BigInt(1),bc=BigInt(2),Nn=BigInt(3),Kd=BigInt(4);function xc(e,t={}){let r=An("weierstrass",e,t),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s,n:a}=i;ye(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 f=Ec(n,o);function u(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(I,m,y){let{x:d,y:A}=m.toAffine(),D=n.toBytes(d);if(ie(y,"isCompressed"),y){u();let U=!n.isOdd(A);return wt(wc(U),D)}else return wt(Uint8Array.of(4),D,n.toBytes(A))}function b(I){H(I,void 0,"Point");let{publicKey:m,publicKeyUncompressed:y}=f,d=I.length,A=I[0],D=I.subarray(1);if(d===m&&(A===2||A===3)){let U=n.fromBytes(D);if(!n.isValid(U))throw new Error("bad point: is not on curve, wrong x");let k=T(U),K;try{K=n.sqrt(k)}catch(W){let G=W instanceof Error?": "+W.message:"";throw new Error("bad point: is not on curve, sqrt error"+G)}u();let O=n.isOdd(K);return(A&1)===1!==O&&(K=n.neg(K)),{x:U,y:K}}else if(d===y&&A===4){let U=n.BYTES,k=n.fromBytes(D.subarray(0,U)),K=n.fromBytes(D.subarray(U,U*2));if(!E(k,K))throw new Error("bad point: is not on curve");return{x:k,y:K}}else throw new Error(`bad point: got length ${d}, expected compressed=${m} or uncompressed=${y}`)}let S=t.toBytes||l,w=t.fromBytes||b;function T(I){let m=n.sqr(I),y=n.mul(m,I);return n.add(n.add(y,n.mul(I,i.a)),i.b)}function E(I,m){let y=n.sqr(m),d=T(I);return n.eql(y,d)}if(!E(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let x=n.mul(n.pow(i.a,Nn),Kd),B=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(x,B)))throw new Error("bad curve params: a or b");function v(I,m,y=!1){if(!n.isValid(m)||y&&n.is0(m))throw new Error(`bad point coordinate ${I}`);return m}function R(I){if(!(I instanceof p))throw new Error("Weierstrass Point expected")}function P(I){if(!c||!c.basises)throw new Error("no endo");return kd(I,c.basises,o.ORDER)}let V=Je((I,m)=>{let{X:y,Y:d,Z:A}=I;if(n.eql(A,n.ONE))return{x:y,y:d};let D=I.is0();m==null&&(m=D?n.ONE:n.inv(A));let U=n.mul(y,m),k=n.mul(d,m),K=n.mul(A,m);if(D)return{x:n.ZERO,y:n.ZERO};if(!n.eql(K,n.ONE))throw new Error("invZ was invalid");return{x:U,y:k}}),M=Je(I=>{if(I.is0()){if(t.allowInfinityPoint&&!n.is0(I.Y))return;throw new Error("bad point: ZERO")}let{x:m,y}=I.toAffine();if(!n.isValid(m)||!n.isValid(y))throw new Error("bad point: x or y not field elements");if(!E(m,y))throw new Error("bad point: equation left != right");if(!I.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function h(I,m,y,d,A){return y=new p(n.mul(y.X,I),y.Y,y.Z),m=Ur(d,m),y=Ur(A,y),m.add(y)}class p{static BASE=new p(i.Gx,i.Gy,n.ONE);static ZERO=new p(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(m,y,d){this.X=v("x",m),this.Y=v("y",y,!0),this.Z=v("z",d),Object.freeze(this)}static CURVE(){return i}static fromAffine(m){let{x:y,y:d}=m||{};if(!m||!n.isValid(y)||!n.isValid(d))throw new Error("invalid affine point");if(m instanceof p)throw new Error("projective point not allowed");return n.is0(y)&&n.is0(d)?p.ZERO:new p(y,d,n.ONE)}static fromBytes(m){let y=p.fromAffine(w(H(m,void 0,"point")));return y.assertValidity(),y}static fromHex(m){return p.fromBytes(ne(m))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(m=8,y=!0){return L.createCache(this,m),y||this.multiply(Nn),this}assertValidity(){M(this)}hasEvenY(){let{y:m}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(m)}equals(m){R(m);let{X:y,Y:d,Z:A}=this,{X:D,Y:U,Z:k}=m,K=n.eql(n.mul(y,k),n.mul(D,A)),O=n.eql(n.mul(d,k),n.mul(U,A));return K&&O}negate(){return new p(this.X,n.neg(this.Y),this.Z)}double(){let{a:m,b:y}=i,d=n.mul(y,Nn),{X:A,Y:D,Z:U}=this,k=n.ZERO,K=n.ZERO,O=n.ZERO,q=n.mul(A,A),W=n.mul(D,D),G=n.mul(U,U),z=n.mul(A,D);return z=n.add(z,z),O=n.mul(A,U),O=n.add(O,O),k=n.mul(m,O),K=n.mul(d,G),K=n.add(k,K),k=n.sub(W,K),K=n.add(W,K),K=n.mul(k,K),k=n.mul(z,k),O=n.mul(d,O),G=n.mul(m,G),z=n.sub(q,G),z=n.mul(m,z),z=n.add(z,O),O=n.add(q,q),q=n.add(O,q),q=n.add(q,G),q=n.mul(q,z),K=n.add(K,q),G=n.mul(D,U),G=n.add(G,G),q=n.mul(G,z),k=n.sub(k,q),O=n.mul(G,W),O=n.add(O,O),O=n.add(O,O),new p(k,K,O)}add(m){R(m);let{X:y,Y:d,Z:A}=this,{X:D,Y:U,Z:k}=m,K=n.ZERO,O=n.ZERO,q=n.ZERO,W=i.a,G=n.mul(i.b,Nn),z=n.mul(y,D),J=n.mul(d,U),ut=n.mul(A,k),qt=n.add(y,d),Q=n.add(D,U);qt=n.mul(qt,Q),Q=n.add(z,J),qt=n.sub(qt,Q),Q=n.add(y,A);let ht=n.add(D,k);return Q=n.mul(Q,ht),ht=n.add(z,ut),Q=n.sub(Q,ht),ht=n.add(d,A),K=n.add(U,k),ht=n.mul(ht,K),K=n.add(J,ut),ht=n.sub(ht,K),q=n.mul(W,Q),K=n.mul(G,ut),q=n.add(K,q),K=n.sub(J,q),q=n.add(J,q),O=n.mul(K,q),J=n.add(z,z),J=n.add(J,z),ut=n.mul(W,ut),Q=n.mul(G,Q),J=n.add(J,ut),ut=n.sub(z,ut),ut=n.mul(W,ut),Q=n.add(Q,ut),z=n.mul(J,Q),O=n.add(O,z),z=n.mul(ht,Q),K=n.mul(qt,K),K=n.sub(K,z),z=n.mul(qt,J),q=n.mul(ht,q),q=n.add(q,z),new p(K,O,q)}subtract(m){return this.add(m.negate())}is0(){return this.equals(p.ZERO)}multiply(m){let{endo:y}=t;if(!o.isValidNot0(m))throw new Error("invalid scalar: out of range");let d,A,D=U=>L.cached(this,U,k=>Ne(p,k));if(y){let{k1neg:U,k1:k,k2neg:K,k2:O}=P(m),{p:q,f:W}=D(k),{p:G,f:z}=D(O);A=W.add(z),d=h(y.beta,q,G,U,K)}else{let{p:U,f:k}=D(m);d=U,A=k}return Ne(p,[d,A])[0]}multiplyUnsafe(m){let{endo:y}=t,d=this;if(!o.isValid(m))throw new Error("invalid scalar: out of range");if(m===se||d.is0())return p.ZERO;if(m===sr)return d;if(L.hasCache(this))return this.multiply(m);if(y){let{k1neg:A,k1:D,k2neg:U,k2:k}=P(m),{p1:K,p2:O}=Oa(p,d,D,k);return h(y.beta,K,O,A,U)}else return L.unsafe(d,m)}toAffine(m){return V(this,m)}isTorsionFree(){let{isTorsionFree:m}=t;return s===sr?!0:m?m(p,this):L.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:m}=t;return s===sr?this:m?m(p,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(m=!0){return ie(m,"isCompressed"),this.assertValidity(),S(p,this,m)}toHex(m=!0){return re(this.toBytes(m))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let _=o.BITS,L=new er(p,t.endo?Math.ceil(_/2):_);return p.BASE.precompute(8),p}function wc(e){return Uint8Array.of(e?2:3)}function Ec(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Pd(e,t={}){let{Fn:r}=e,n=t.randomBytes||je,o=Object.assign(Ec(e.Fp,r),{seed:mi(r.ORDER)});function i(S){try{let w=r.fromBytes(S);return r.isValidNot0(w)}catch{return!1}}function s(S,w){let{publicKey:T,publicKeyUncompressed:E}=o;try{let x=S.length;return w===!0&&x!==T||w===!1&&x!==E?!1:!!e.fromBytes(S)}catch{return!1}}function a(S=n(o.seed)){return yi(H(S,o.seed,"seed"),r.ORDER)}function c(S,w=!0){return e.BASE.multiply(r.fromBytes(S)).toBytes(w)}function f(S){let{secretKey:w,publicKey:T,publicKeyUncompressed:E}=o;if(!Ce(S)||"_lengths"in r&&r._lengths||w===T)return;let x=H(S,void 0,"key").length;return x===T||x===E}function u(S,w,T=!0){if(f(S)===!0)throw new Error("first arg must be private key");if(f(w)===!1)throw new Error("second arg must be public key");let E=r.fromBytes(S);return e.fromBytes(w).multiply(E).toBytes(T)}let l={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},b=In(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:b,Point:e,utils:l,lengths:o})}function Sc(e,t,r={}){bn(t),ye(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||je,o=r.hmac||((y,d)=>Yi(t,y,d)),{Fp:i,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:f,getPublicKey:u,getSharedSecret:l,utils:b,lengths:S}=Pd(e,r),w={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},T=a*bc<i.ORDER;function E(y){let d=a>>sr;return y>d}function x(y,d){if(!s.isValidNot0(d))throw new Error(`invalid signature ${y}: out of range 1..Point.Fn.ORDER`);return d}function B(){if(T)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function v(y,d){ji(d);let A=S.signature,D=d==="compact"?A:d==="recovered"?A+1:void 0;return H(y,D)}class R{r;s;recovery;constructor(d,A,D){if(this.r=x("r",d),this.s=x("s",A),D!=null){if(B(),![0,1,2,3].includes(D))throw new Error("invalid recovery id");this.recovery=D}Object.freeze(this)}static fromBytes(d,A=w.format){v(d,A);let D;if(A==="der"){let{r:O,s:q}=we.toSig(H(d));return new R(O,q)}A==="recovered"&&(D=d[0],A="compact",d=d.subarray(1));let U=S.signature/2,k=d.subarray(0,U),K=d.subarray(U,U*2);return new R(s.fromBytes(k),s.fromBytes(K),D)}static fromHex(d,A){return this.fromBytes(ne(d),A)}assertRecovery(){let{recovery:d}=this;if(d==null)throw new Error("invalid recovery id: must be present");return d}addRecoveryBit(d){return new R(this.r,this.s,d)}recoverPublicKey(d){let{r:A,s:D}=this,U=this.assertRecovery(),k=U===2||U===3?A+a:A;if(!i.isValid(k))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let K=i.toBytes(k),O=e.fromBytes(wt(wc((U&1)===0),K)),q=s.inv(k),W=V(H(d,void 0,"msgHash")),G=s.create(-W*q),z=s.create(D*q),J=e.BASE.multiplyUnsafe(G).add(O.multiplyUnsafe(z));if(J.is0())throw new Error("invalid recovery: point at infinify");return J.assertValidity(),J}hasHighS(){return E(this.s)}toBytes(d=w.format){if(ji(d),d==="der")return ne(we.hexFromSig(this));let{r:A,s:D}=this,U=s.toBytes(A),k=s.toBytes(D);return d==="recovered"?(B(),wt(Uint8Array.of(this.assertRecovery()),U,k)):wt(U,k)}toHex(d){return re(this.toBytes(d))}}let P=r.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");let A=We(d),D=d.length*8-c;return D>0?A>>BigInt(D):A},V=r.bits2int_modN||function(d){return s.create(P(d))},M=Dr(c);function h(y){return Lr("num < 2^"+c,y,se,M),s.toBytes(y)}function p(y,d){return H(y,void 0,"message"),d?H(t(y),void 0,"prehashed message"):y}function _(y,d,A){let{lowS:D,prehash:U,extraEntropy:k}=Gi(A,w);y=p(y,U);let K=V(y),O=s.fromBytes(d);if(!s.isValidNot0(O))throw new Error("invalid private key");let q=[h(O),h(K)];if(k!=null&&k!==!1){let J=k===!0?n(S.secretKey):k;q.push(H(J,void 0,"extraEntropy"))}let W=wt(...q),G=K;function z(J){let ut=P(J);if(!s.isValidNot0(ut))return;let qt=s.inv(ut),Q=e.BASE.multiply(ut).toAffine(),ht=s.create(Q.x);if(ht===se)return;let an=s.create(qt*s.create(G+ht*O));if(an===se)return;let Es=(Q.x===ht?0:2)|Number(Q.y&sr),Ss=an;return D&&E(an)&&(Ss=s.neg(an),Es^=1),new R(ht,Ss,T?void 0:Es)}return{seed:W,k2sig:z}}function L(y,d,A={}){let{seed:D,k2sig:U}=_(y,d,A);return Ea(t.outputLen,s.BYTES,o)(D,U).toBytes(A.format)}function I(y,d,A,D={}){let{lowS:U,prehash:k,format:K}=Gi(D,w);if(A=H(A,void 0,"publicKey"),d=p(d,k),!Ce(y)){let O=y instanceof R?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+O)}v(y,K);try{let O=R.fromBytes(y,K),q=e.fromBytes(A);if(U&&O.hasHighS())return!1;let{r:W,s:G}=O,z=V(d),J=s.inv(G),ut=s.create(z*J),qt=s.create(W*J),Q=e.BASE.multiplyUnsafe(ut).add(q.multiplyUnsafe(qt));return Q.is0()?!1:s.create(Q.x)===W}catch{return!1}}function m(y,d,A={}){let{prehash:D}=Gi(A,w);return d=p(d,D),R.fromBytes(y,"recovered").recoverPublicKey(d).toBytes()}return Object.freeze({keygen:f,getPublicKey:u,getSharedSecret:l,utils:b,lengths:S,Point:e,sign:L,verify:I,recoverPublicKey:m,Signature:R,hash:t})}var Ji={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Od={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var vc=BigInt(2);function Md(e){let t=Ji.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=e*e*e%t,u=f*f*e%t,l=X(u,r,t)*u%t,b=X(l,r,t)*u%t,S=X(b,vc,t)*f%t,w=X(S,o,t)*S%t,T=X(w,i,t)*w%t,E=X(T,a,t)*T%t,x=X(E,c,t)*E%t,B=X(x,a,t)*T%t,v=X(B,r,t)*u%t,R=X(v,s,t)*w%t,P=X(R,n,t)*f%t,V=X(P,vc,t);if(!Wi.eql(Wi.sqr(V),e))throw new Error("Cannot find square root");return V}var Wi=Qe(Ji.p,{sqrt:Md}),Vd=xc(Ji,{Fp:Wi,endo:Od}),Ot=Sc(Vd,Xe);function Ac(e,t,r){let n=pn.digest(t instanceof Uint8Array?t:t.subarray());if(nr(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 kr(String(o))});try{return Ot.sign(n.digest,e,{prehash:!1,format:"der"})}catch(o){throw new kr(String(o))}}function Ic(e,t,r,n){let o=pn.digest(r instanceof Uint8Array?r:r.subarray());if(nr(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 Kr(String(i))});try{return n?.signal?.throwIfAborted(),Ot.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(i){throw new Kr(String(i))}}var zr=class{type="secp256k1";raw;_key;constructor(t){this._key=Cc(t),this.raw=Tc(this._key)}toMultihash(){return Te.digest(de(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return j.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}verify(t,r,n){return Ic(this._key,r,t,n)}},kn=class{type="secp256k1";raw;publicKey;constructor(t,r){this.raw=Bc(t),this.publicKey=new zr(r??_c(t))}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}sign(t,r){return Ac(this.raw,t,r)}};function Qi(e){return new zr(e)}async function Lc(){let e=Fd();return new kn(e)}function Tc(e){return Ot.Point.fromBytes(e).toBytes()}function Bc(e){try{return Ot.getPublicKey(e,!0),e}catch(t){throw new br(String(t))}}function Cc(e){try{return Ot.Point.fromBytes(e),e}catch(t){throw new Fe(String(t))}}function _c(e){try{return Ot.getPublicKey(e,!0)}catch(t){throw new br(String(t))}}function Fd(){return Ot.utils.randomSecretKey()}async function Dc(e,t){if(e==="Ed25519")return ja();if(e==="secp256k1")return Lc();if(e==="RSA")return Zi(qd(t));if(e==="ECDSA")return na(Hd(t));throw new qe}function Rc(e,t){let{Type:r,Data:n}=jt.decode(e),o=n??new Uint8Array;switch(r){case ot.RSA:return Hi(o,t);case ot.Ed25519:return vi(o);case ot.secp256k1:return Qi(o);case ot.ECDSA:return Qo(o);default:throw new qe}}function Uc(e){let{Type:t,Data:r}=jt.decode(e.digest),n=r??new Uint8Array;switch(t){case ot.Ed25519:return vi(n);case ot.secp256k1:return Qi(n);case ot.ECDSA:return Qo(n);default:throw new qe}}function de(e){return jt.encode({Type:ot[e.type],Data:e.raw})}function qd(e){return e==null?2048:parseInt(e,10)}function Hd(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 tt("Unsupported curve, should be P-256, P-384 or P-521")}function $d(e,t){if(typeof e=="string")return zd(e);if(typeof e=="number")return Gd(e,t);throw Error(`Value provided to ms() must be a string or number. value=${JSON.stringify(e)}`)}var Kn=$d;function zd(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 Zd(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 Yd(e){let t=Math.abs(e);return t>=315576e5?Pe(e,t,315576e5,"year"):t>=26298e5?Pe(e,t,26298e5,"month"):t>=6048e5?Pe(e,t,6048e5,"week"):t>=864e5?Pe(e,t,864e5,"day"):t>=36e5?Pe(e,t,36e5,"hour"):t>=6e4?Pe(e,t,6e4,"minute"):t>=1e3?Pe(e,t,1e3,"second"):`${e} ms`}function Gd(e,t){if(typeof e!="number"||!Number.isFinite(e))throw Error("Value provided to ms.format() must be of type number.");return t?.long?Yd(e):Zd(e)}function Pe(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function ts(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=Kn,r.destroy=f,Object.keys(e).forEach(u=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let l=0;for(let b=0;b<u.length;b++)l=(l<<5)-l+u.charCodeAt(b),l|=0;return r.colors[Math.abs(l)%r.colors.length]}r.selectColor=t;function r(u,l){let b,S=null,w,T;function E(...x){if(!E.enabled)return;let B=E,v=Number(new Date),R=v-(b||v);B.diff=R,B.prev=b,B.curr=v,b=v,x[0]=r.coerce(x[0]),typeof x[0]!="string"&&x.unshift("%O");let P=0;x[0]=x[0].replace(/%([a-zA-Z%])/g,(M,h)=>{if(M==="%%")return"%";P++;let p=r.formatters[h];if(typeof p=="function"){let _=x[P];M=p.call(B,_),x.splice(P,1),P--}return M}),r.formatArgs.call(B,x),l?.onLog!=null&&l.onLog(...x),(B.log||r.log).apply(B,x)}return E.namespace=u,E.useColors=r.useColors(),E.color=r.selectColor(u),E.extend=n,E.destroy=r.destroy,Object.defineProperty(E,"enabled",{enumerable:!0,configurable:!1,get:()=>S!==null?S:(w!==r.namespaces&&(w=r.namespaces,T=r.enabled(u)),T),set:x=>{S=x}}),typeof r.init=="function"&&r.init(E),E}function n(u,l){let b=r(this.namespace+(typeof l>"u"?":":l)+u);return b.log=this.log,b}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let l,b=(typeof u=="string"?u:"").split(/[\s,]+/),S=b.length;for(l=0;l<S;l++)b[l]&&(u=b[l].replace(/\*/g,".*?"),u[0]==="-"?r.skips.push(new RegExp("^"+u.substr(1)+"$")):r.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...r.names.map(a),...r.skips.map(a).map(l=>"-"+l)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,b;for(l=0,b=r.skips.length;l<b;l++)if(r.skips[l].test(u))return!1;for(l=0,b=r.names.length;l<b;l++)if(r.names[l].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 f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.setupFormatters(r.formatters),r.enable(r.load()),r}var Pn=eh(),jd=["#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 Xd(){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 Wd(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Kn(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 Jd=console.debug??console.log??(()=>{});function Qd(e){try{e?Pn?.setItem("debug",e):Pn?.removeItem("debug")}catch{}}function th(){let e;try{e=Pn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function eh(){try{return localStorage}catch{}}function rh(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var Nc=ts({formatArgs:Wd,save:Qd,load:th,useColors:Xd,setupFormatters:rh,colors:jd,storage:Pn,log:Jd});var St=Nc;St.formatters.b=e=>e==null?"undefined":j.baseEncode(e);St.formatters.t=e=>e==null?"undefined":fe.baseEncode(e);St.formatters.m=e=>e==null?"undefined":Vo.baseEncode(e);St.formatters.p=e=>e==null?"undefined":e.toString();St.formatters.c=e=>e==null?"undefined":e.toString();St.formatters.k=e=>e==null?"undefined":e.toString();St.formatters.a=e=>e==null?"undefined":e.toString();function es(e){let t=kc(e.message),r=kc(e.stack);return t!=null&&r!=null?r.includes(t)?r:`${t}
|
|
4
|
-
${r}`:r??t??e.toString()}function nh(e){return e?.name==="AggregateError"}St.formatters.e=e=>{if(e==null)return"undefined";if(nh(e)){let t=" ",r=es(e);return e.errors.length>0?r+=`
|
|
4
|
+
${r}`:r??t??e.toString()}function nh(e){return e instanceof AggregateError||e?.name==="AggregateError"&&Array.isArray(e.errors)}St.formatters.e=e=>{if(e==null)return"undefined";if(nh(e)){let t=" ",r=es(e);return e.errors.length>0?r+=`
|
|
5
5
|
${t}${e.errors.map(n=>` ${es(n).split(`
|
|
6
6
|
`).join(`
|
|
7
7
|
${t}`)}`).join(`
|