@helia/ipns 8.1.0 → 8.2.0-313e2c1
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/README.md +23 -0
- package/dist/index.min.js +2 -72
- package/dist/src/index.d.ts +41 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +68 -4
- package/dist/src/index.js.map +1 -1
- package/dist/src/utils.d.ts +1 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +1 -0
- package/dist/src/utils.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +91 -7
- package/src/utils.ts +2 -0
- package/dist/typedoc-urls.json +0 -46
package/dist/index.min.js
CHANGED
|
@@ -1,38 +1,8 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaIpns = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var HeliaIpns=(()=>{var
|
|
3
|
-
`,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return y;function y(w,b,M){var _=this;if(!(_ instanceof y))return new y(w,b,M);_.time=+w||0,_.nano=+b||0,_.year=+M||0,d(_)}function d(w){var b,M,_,I=w.year,K=w.time,S=w.nano,k=((S<0||a<=S)&&(S-=(M=Math.floor(S/a))*a,K+=M,M=1),I%e);return(K<-i||i<K||k)&&((b=l(K/o))&&(I+=b*e,K-=b*o),(_=A(K)).setUTCFullYear(k+_.getUTCFullYear()),_=(K=+_)+(b=l((I-=k)/e))*o,b&&-i<=_&&_<=i&&(I-=b*e,K=_),M=1),M&&(w.year=I,w.time=K,w.nano=S),w}function A(w){var b=new Date(0);return b.setTime(w),b}function T(I,_){I=+I||0;var M=l((_=(_|0)*s)/n)+l(I/n),_=_%n+I%n,I=l(_/n);return I&&(M+=I,_-=I*n),new y(1e3*_,0,M*e)}function x(w,b,M,_,I,K){return function(k,m){var B=d(this);k=k||new Array(8),F(k,m|=0);var N=Math.floor(B.time/1e3),B=B.year*(r*t/e),p=l(B/s)+l(N/s),B=B%s+N%s,N=Math.floor(B/s);return N&&(p+=N,B-=N*s),S(k,m+I,p),S(k,m+K,B),k};function S(k,m,p){k[m+w]=p>>24&255,k[m+b]=p>>16&255,k[m+M]=p>>8&255,k[m+_]=255&p}}function U(w,b,M,_,I,K){return function(k,m){F(k,m|=0);var p=S(k,m+I);return T(S(k,m+K),p)};function S(k,m){return 16777216*k[m+w]+(k[m+b]<<16|k[m+M]<<8|k[m+_])}}function F(w,b){if(w=w&&w.length,w==null)throw new TypeError("Invalid Buffer");if(w<b+8)throw new RangeError("Out of range")}function D(w){return(9<w?"":"0")+(0|w)}function R(w,b){return(c+(0|w)).substr(-b)}}()});var Yl=xi((g1,jl)=>{jl.exports=function(t){if(!t)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,r=Object.create(null),n=Object.create(null);function o(i,s){r[i]=s,e++,e>=t&&(e=0,n=r,r=Object.create(null))}return{has:function(i){return r[i]!==void 0||n[i]!==void 0},remove:function(i){r[i]!==void 0&&(r[i]=void 0),n[i]!==void 0&&(n[i]=void 0)},get:function(i){var s=r[i];if(s!==void 0)return s;if((s=n[i])!==void 0)return o(i,s),s},set:function(i,s){r[i]!==void 0?r[i]=s:o(i,s)},clear:function(){r=Object.create(null),n=Object.create(null)}}}});var _p={};Ee(_p,{ipns:()=>Rp,ipnsSelector:()=>oi,ipnsValidator:()=>si});function ua(t){return t==null?!1:(t.type==="RSA"||t.type==="Ed25519"||t.type==="secp256k1")&&t.raw instanceof Uint8Array&&typeof t.equals=="function"&&typeof t.toMultihash=="function"&&typeof t.toCID=="function"&&typeof t.verify=="function"}var wi=Symbol.for("@libp2p/peer-id");var xe=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},sr=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var Dr=class extends Error{static name="NotFoundError";constructor(e="Not found"){super(e),this.name="NotFoundError"}};var bn=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},ar=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var cr=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var Ai={};Ee(Ai,{base32:()=>kt,base32hex:()=>If,base32hexpad:()=>Uf,base32hexpadupper:()=>Rf,base32hexupper:()=>Nf,base32pad:()=>Cf,base32padupper:()=>Tf,base32upper:()=>kf,base32z:()=>_f});var Mp=new Uint8Array(0);function la(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function st(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function fa(t){return new TextEncoder().encode(t)}function ha(t){return new TextDecoder().decode(t)}function vf(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=t.length,c=t.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function f(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var y=0,d=0,A=0,T=E.length;A!==T&&E[A]===0;)A++,y++;for(var x=(T-A)*u+1>>>0,U=new Uint8Array(x);A!==T;){for(var F=E[A],D=0,R=x-1;(F!==0||D<d)&&R!==-1;R--,D++)F+=256*U[R]>>>0,U[R]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");d=D,A++}for(var w=x-d;w!==x&&U[w]===0;)w++;for(var b=c.repeat(y);w<x;++w)b+=t.charAt(U[w]);return b}function h(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var y=0;if(E[y]!==" "){for(var d=0,A=0;E[y]===c;)d++,y++;for(var T=(E.length-y)*l+1>>>0,x=new Uint8Array(T);E[y];){var U=r[E.charCodeAt(y)];if(U===255)return;for(var F=0,D=T-1;(U!==0||F<A)&&D!==-1;D--,F++)U+=a*x[D]>>>0,x[D]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");A=F,y++}if(E[y]!==" "){for(var R=T-A;R!==T&&x[R]===0;)R++;for(var w=new Uint8Array(d+(T-R)),b=d;R!==T;)w[b++]=x[R++];return w}}}function v(E){var y=h(E);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:h,decode:v}}var Ef=vf,Bf=Ef,pa=Bf;var bi=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},vi=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return ga(this,e)}},Ei=class{decoders;constructor(e){this.decoders=e}or(e){return ga(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function ga(t,e){return new Ei({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var Bi=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new bi(e,r,n),this.decoder=new vi(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function ur({name:t,prefix:e,encode:r,decode:n}){return new Bi(t,e,r,n)}function St({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=pa(r,t);return ur({prefix:e,name:t,encode:n,decode:i=>st(o(i))})}function Af(t,e,r,n){let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let i=t.length;for(;t[i-1]==="=";)--i;let s=new Uint8Array(i*r/8|0),a=0,c=0,l=0;for(let u=0;u<i;++u){let f=o[t[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|f,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function Sf(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],s+=8;s>r;)s-=r,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<r-s]),n)for(;i.length*r&7;)i+="=";return i}function oe({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return ur({prefix:e,name:t,encode(o){return Sf(o,n,r)},decode(o){return Af(o,n,r,t)}})}var kt=oe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),kf=oe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Cf=oe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Tf=oe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),If=oe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Nf=oe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Uf=oe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Rf=oe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),_f=oe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Si={};Ee(Si,{base58btc:()=>Q,base58flickr:()=>Lf});var Q=St({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Lf=St({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ci={};Ee(Ci,{base64:()=>ki,base64pad:()=>Vf,base64url:()=>Df,base64urlpad:()=>Ff});var ki=oe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Vf=oe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Df=oe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ff=oe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Mf(t,e){try{if(typeof t=="string"&&t.length>0)return Of(t);if(typeof t=="number"&&isFinite(t))return e?.long?Pf(t):Hf(t);throw new Error("Value is not a string or number.")}catch(r){let n=Kf(r)?`${r.message}. value=${JSON.stringify(t)}`:"An unknown error has occured.";throw new Error(n)}}function Of(t){if(t=String(t),t.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(!e)return NaN;let r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*315576e5;case"weeks":case"week":case"w":return r*6048e5;case"days":case"day":case"d":return r*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return r*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return r*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return r*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var En=Mf;function Hf(t){let e=Math.abs(t);return e>=864e5?`${Math.round(t/864e5)}d`:e>=36e5?`${Math.round(t/36e5)}h`:e>=6e4?`${Math.round(t/6e4)}m`:e>=1e3?`${Math.round(t/1e3)}s`:`${t}ms`}function Pf(t){let e=Math.abs(t);return e>=864e5?vn(t,e,864e5,"day"):e>=36e5?vn(t,e,36e5,"hour"):e>=6e4?vn(t,e,6e4,"minute"):e>=1e3?vn(t,e,1e3,"second"):`${t} ms`}function vn(t,e,r,n){let o=e>=r*1.5;return`${Math.round(t/r)} ${n}${o?"s":""}`}function Kf(t){return typeof t=="object"&&t!==null&&"message"in t}function Ti(t){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=En,r.destroy=l,Object.keys(t).forEach(u=>{r[u]=t[u]}),r.names=[],r.skips=[],r.formatters={};function e(u){let f=0;for(let h=0;h<u.length;h++)f=(f<<5)-f+u.charCodeAt(h),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=e;function r(u){let f,h=null,v,E;function y(...d){if(!y.enabled)return;let A=y,T=Number(new Date),x=T-(f||T);A.diff=x,A.prev=f,A.curr=T,f=T,d[0]=r.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let U=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(D,R)=>{if(D==="%%")return"%";U++;let w=r.formatters[R];if(typeof w=="function"){let b=d[U];D=w.call(A,b),d.splice(U,1),U--}return D}),r.formatArgs.call(A,d),(A.log||r.log).apply(A,d)}return y.namespace=u,y.useColors=r.useColors(),y.color=r.selectColor(u),y.extend=n,y.destroy=r.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(v!==r.namespaces&&(v=r.namespaces,E=r.enabled(u)),E),set:d=>{h=d}}),typeof r.init=="function"&&r.init(y),y}function n(u,f){let h=r(this.namespace+(typeof f>"u"?":":f)+u);return h.log=this.log,h}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let f,h=(typeof u=="string"?u:"").split(/[\s,]+/),v=h.length;for(f=0;f<v;f++)h[f]&&(u=h[f].replace(/\*/g,".*?"),u[0]==="-"?r.skips.push(new RegExp("^"+u.substr(1)+"$")):r.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...r.names.map(a),...r.skips.map(a).map(f=>"-"+f)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let f,h;for(f=0,h=r.skips.length;f<h;f++)if(r.skips[f].test(u))return!1;for(f=0,h=r.names.length;f<h;f++)if(r.names[f].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.setupFormatters(r.formatters),r.enable(r.load()),r}var Bn=jf(),$f=["#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 qf(){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 zf(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+En(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}var Gf=console.debug??console.log??(()=>{});function Zf(t){try{t?Bn?.setItem("debug",t):Bn?.removeItem("debug")}catch{}}function Wf(){let t;try{t=Bn?.getItem("debug")}catch{}return!t&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(t=globalThis.process.env.DEBUG),t}function jf(){try{return localStorage}catch{}}function Yf(t){t.j=function(e){try{return JSON.stringify(e)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var ma=Ti({formatArgs:zf,save:Zf,load:Wf,useColors:qf,setupFormatters:Yf,colors:$f,storage:Bn,log:Gf});var Te=ma;Te.formatters.b=t=>t==null?"undefined":Q.baseEncode(t);Te.formatters.t=t=>t==null?"undefined":kt.baseEncode(t);Te.formatters.m=t=>t==null?"undefined":ki.baseEncode(t);Te.formatters.p=t=>t==null?"undefined":t.toString();Te.formatters.c=t=>t==null?"undefined":t.toString();Te.formatters.k=t=>t==null?"undefined":t.toString();Te.formatters.a=t=>t==null?"undefined":t.toString();Te.formatters.e=t=>t==null?"undefined":ya(t.stack)??ya(t.message)??t.toString();function Jf(t){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=t,e.destroy=()=>!0,e.extend=()=>e,e}function Ct(t){let e=Jf(`${t}:trace`);return Te.enabled(`${t}:trace`)&&Te.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(e=Te(`${t}:trace`)),Object.assign(Te(t),{error:Te(`${t}:error`),trace:e})}function ya(t){if(t!=null&&(t=t.trim(),t.length!==0))return t}var Ii={};Ee(Ii,{base36:()=>He,base36upper:()=>Xf});var He=St({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Xf=St({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Qf=ba,xa=128,eh=127,th=~eh,rh=Math.pow(2,31);function ba(t,e,r){e=e||[],r=r||0;for(var n=r;t>=rh;)e[r++]=t&255|xa,t/=128;for(;t&th;)e[r++]=t&255|xa,t>>>=7;return e[r]=t|0,ba.bytes=r-n+1,e}var nh=Ni,oh=128,wa=127;function Ni(t,n){var r=0,n=n||0,o=0,i=n,s,a=t.length;do{if(i>=a)throw Ni.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&wa)<<o:(s&wa)*Math.pow(2,o),o+=7}while(s>=oh);return Ni.bytes=i-n,r}var ih=Math.pow(2,7),sh=Math.pow(2,14),ah=Math.pow(2,21),ch=Math.pow(2,28),uh=Math.pow(2,35),lh=Math.pow(2,42),fh=Math.pow(2,49),hh=Math.pow(2,56),dh=Math.pow(2,63),ph=function(t){return t<ih?1:t<sh?2:t<ah?3:t<ch?4:t<uh?5:t<lh?6:t<fh?7:t<hh?8:t<dh?9:10},gh={encode:Qf,decode:nh,encodingLength:ph},mh=gh,Fr=mh;function Mr(t,e=0){return[Fr.decode(t,e),Fr.decode.bytes]}function lr(t,e,r=0){return Fr.encode(t,e,r),e}function fr(t){return Fr.encodingLength(t)}function Pe(t,e){let r=e.byteLength,n=fr(t),o=n+fr(r),i=new Uint8Array(o+r);return lr(t,i,0),lr(r,i,n),i.set(e,o),new hr(t,r,e,i)}function at(t){let e=st(t),[r,n]=Mr(e),[o,i]=Mr(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new hr(r,o,s,e)}function va(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&la(t.bytes,r.bytes)}}var hr=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function Ea(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return xh(r,Ui(t),e??Q.encoder);default:return wh(r,Ui(t),e??kt.encoder)}}var Ba=new WeakMap;function Ui(t){let e=Ba.get(t);if(e==null){let r=new Map;return Ba.set(t,r),r}return e}var ee=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==Or)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==bh)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Pe(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&va(e.multihash,n.multihash)}toString(e){return Ea(this,e)}toJSON(){return{"/":Ea(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new t(n,o,i,s??Aa(n,o,i.bytes))}else if(r[vh]===!0){let{version:n,multihash:o,code:i}=r,s=at(o);return t.create(n,i,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==Or)throw new Error(`Version 0 CID must use dag-pb (code: ${Or}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Aa(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Or,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=st(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new hr(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[f,h]=Mr(e.subarray(r));return r+=h,f},o=n(),i=Or;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),l=r+c,u=l-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:l}}static parse(e,r){let[n,o]=yh(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ui(i).set(n,e),i}};function yh(t,e){switch(t[0]){case"Q":{let r=e??Q;return[Q.prefix,r.decode(`${Q.prefix}${t}`)]}case Q.prefix:{let r=e??Q;return[Q.prefix,r.decode(t)]}case kt.prefix:{let r=e??kt;return[kt.prefix,r.decode(t)]}case He.prefix:{let r=e??He;return[He.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function xh(t,e,r){let{prefix:n}=r;if(n!==Q.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o}function wh(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o}var Or=112,bh=18;function Aa(t,e,r){let n=fr(t),o=n+fr(e),i=new Uint8Array(o+r.byteLength);return lr(t,i,0),lr(e,i,n),i.set(r,o),i}var vh=Symbol.for("@ipld/js-cid/CID");var Ri={};Ee(Ri,{identity:()=>ct});var Sa=0,Eh="identity",ka=st;function Bh(t){return Pe(Sa,ka(t))}var ct={code:Sa,name:Eh,encode:ka,digest:Bh};function he(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function Ca(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Ah(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function dr(t,...e){if(!Ah(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Ta(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ca(t.outputLen),Ca(t.blockLen)}function pr(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ia(t,e){dr(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}var Zt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Sn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ke(t,e){return t<<32-e|t>>>e}function Na(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Hr(t){return typeof t=="string"&&(t=Na(t)),dr(t),t}function _i(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];dr(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}var gr=class{clone(){return this._cloneInto()}};function kn(t){let e=n=>t().update(Hr(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Cn(t=32){if(Zt&&typeof Zt.getRandomValues=="function")return Zt.getRandomValues(new Uint8Array(t));if(Zt&&typeof Zt.randomBytes=="function")return Zt.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function Sh(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,l=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+l,a,n)}function Ua(t,e,r){return t&e^~t&r}function Ra(t,e,r){return t&e^t&r^e&r}var mr=class extends gr{constructor(e,r,n,o){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Sn(this.buffer)}update(e){pr(this);let{view:r,buffer:n,blockLen:o}=this;e=Hr(e);let i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Sn(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){pr(this),Ia(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let f=s;f<o;f++)r[f]=0;Sh(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Sn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,u[f],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.length=o,e.pos=a,e.finished=i,e.destroyed=s,o%r&&e.buffer.set(n),e}};var Tn=BigInt(4294967295),Li=BigInt(32);function _a(t,e=!1){return e?{h:Number(t&Tn),l:Number(t>>Li&Tn)}:{h:Number(t>>Li&Tn)|0,l:Number(t&Tn)|0}}function kh(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let o=0;o<t.length;o++){let{h:i,l:s}=_a(t[o],e);[r[o],n[o]]=[i,s]}return[r,n]}var Ch=(t,e)=>BigInt(t>>>0)<<Li|BigInt(e>>>0),Th=(t,e,r)=>t>>>r,Ih=(t,e,r)=>t<<32-r|e>>>r,Nh=(t,e,r)=>t>>>r|e<<32-r,Uh=(t,e,r)=>t<<32-r|e>>>r,Rh=(t,e,r)=>t<<64-r|e>>>r-32,_h=(t,e,r)=>t>>>r-32|e<<64-r,Lh=(t,e)=>e,Vh=(t,e)=>t,Dh=(t,e,r)=>t<<r|e>>>32-r,Fh=(t,e,r)=>e<<r|t>>>32-r,Mh=(t,e,r)=>e<<r-32|t>>>64-r,Oh=(t,e,r)=>t<<r-32|e>>>64-r;function Hh(t,e,r,n){let o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:o|0}}var Ph=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Kh=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,$h=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),qh=(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,zh=(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Gh=(t,e,r,n,o,i)=>e+r+n+o+i+(t/2**32|0)|0;var Zh={fromBig:_a,split:kh,toBig:Ch,shrSH:Th,shrSL:Ih,rotrSH:Nh,rotrSL:Uh,rotrBH:Rh,rotrBL:_h,rotr32H:Lh,rotr32L:Vh,rotlSH:Dh,rotlSL:Fh,rotlBH:Mh,rotlBL:Oh,add:Hh,add3L:Ph,add3H:Kh,add4L:$h,add4H:qh,add5H:Gh,add5L:zh},q=Zh;var[Wh,jh]=q.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),It=new Uint32Array(80),Nt=new Uint32Array(80),Vi=class extends mr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:l,El:u,Fh:f,Fl:h,Gh:v,Gl:E,Hh:y,Hl:d}=this;return[e,r,n,o,i,s,a,c,l,u,f,h,v,E,y,d]}set(e,r,n,o,i,s,a,c,l,u,f,h,v,E,y,d){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=h|0,this.Gh=v|0,this.Gl=E|0,this.Hh=y|0,this.Hl=d|0}process(e,r){for(let x=0;x<16;x++,r+=4)It[x]=e.getUint32(r),Nt[x]=e.getUint32(r+=4);for(let x=16;x<80;x++){let U=It[x-15]|0,F=Nt[x-15]|0,D=q.rotrSH(U,F,1)^q.rotrSH(U,F,8)^q.shrSH(U,F,7),R=q.rotrSL(U,F,1)^q.rotrSL(U,F,8)^q.shrSL(U,F,7),w=It[x-2]|0,b=Nt[x-2]|0,M=q.rotrSH(w,b,19)^q.rotrBH(w,b,61)^q.shrSH(w,b,6),_=q.rotrSL(w,b,19)^q.rotrBL(w,b,61)^q.shrSL(w,b,6),I=q.add4L(R,_,Nt[x-7],Nt[x-16]),K=q.add4H(I,D,M,It[x-7],It[x-16]);It[x]=K|0,Nt[x]=I|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:l,Dl:u,Eh:f,El:h,Fh:v,Fl:E,Gh:y,Gl:d,Hh:A,Hl:T}=this;for(let x=0;x<80;x++){let U=q.rotrSH(f,h,14)^q.rotrSH(f,h,18)^q.rotrBH(f,h,41),F=q.rotrSL(f,h,14)^q.rotrSL(f,h,18)^q.rotrBL(f,h,41),D=f&v^~f&y,R=h&E^~h&d,w=q.add5L(T,F,R,jh[x],Nt[x]),b=q.add5H(w,A,U,D,Wh[x],It[x]),M=w|0,_=q.rotrSH(n,o,28)^q.rotrBH(n,o,34)^q.rotrBH(n,o,39),I=q.rotrSL(n,o,28)^q.rotrBL(n,o,34)^q.rotrBL(n,o,39),K=n&i^n&a^i&a,S=o&s^o&c^s&c;A=y|0,T=d|0,y=v|0,d=E|0,v=f|0,E=h|0,{h:f,l:h}=q.add(l|0,u|0,b|0,M|0),l=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let k=q.add3L(M,I,S);n=q.add3H(k,b,_,K),o=k|0}({h:n,l:o}=q.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=q.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=q.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=q.add(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:h}=q.add(this.Eh|0,this.El|0,f|0,h|0),{h:v,l:E}=q.add(this.Fh|0,this.Fl|0,v|0,E|0),{h:y,l:d}=q.add(this.Gh|0,this.Gl|0,y|0,d|0),{h:A,l:T}=q.add(this.Hh|0,this.Hl|0,A|0,T|0),this.set(n,o,i,s,a,c,l,u,f,h,v,E,y,d,A,T)}roundClean(){It.fill(0),Nt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var La=kn(()=>new Vi);var Un={};Ee(Un,{aInRange:()=>Ie,abool:()=>$e,abytes:()=>yr,bitGet:()=>td,bitLen:()=>Oi,bitMask:()=>Kr,bitSet:()=>rd,bytesToHex:()=>lt,bytesToNumberBE:()=>ft,bytesToNumberLE:()=>Rt,concatBytes:()=>ht,createHmacDrbg:()=>Hi,ensureBytes:()=>ne,equalBytes:()=>Qh,hexToBytes:()=>jt,hexToNumber:()=>Mi,inRange:()=>Pr,isBytes:()=>Ut,memoized:()=>Jt,notImplemented:()=>od,numberToBytesBE:()=>_t,numberToBytesLE:()=>Yt,numberToHexUnpadded:()=>Wt,numberToVarBytesBE:()=>Xh,utf8ToBytes:()=>ed,validateObject:()=>Je});var In=BigInt(0),Nn=BigInt(1),Yh=BigInt(2);function Ut(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function yr(t){if(!Ut(t))throw new Error("Uint8Array expected")}function $e(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}var Jh=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function lt(t){yr(t);let e="";for(let r=0;r<t.length;r++)e+=Jh[t[r]];return e}function Wt(t){let e=t.toString(16);return e.length&1?"0"+e:e}function Mi(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?In:BigInt("0x"+t)}var ut={_0:48,_9:57,A:65,F:70,a:97,f:102};function Va(t){if(t>=ut._0&&t<=ut._9)return t-ut._0;if(t>=ut.A&&t<=ut.F)return t-(ut.A-10);if(t>=ut.a&&t<=ut.f)return t-(ut.a-10)}function jt(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=Va(t.charCodeAt(i)),a=Va(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function ft(t){return Mi(lt(t))}function Rt(t){return yr(t),Mi(lt(Uint8Array.from(t).reverse()))}function _t(t,e){return jt(t.toString(16).padStart(e*2,"0"))}function Yt(t,e){return _t(t,e).reverse()}function Xh(t){return jt(Wt(t))}function ne(t,e,r){let n;if(typeof e=="string")try{n=jt(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(Ut(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(t+" of length "+r+" expected, got "+o);return n}function ht(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];yr(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}function Qh(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function ed(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}var Di=t=>typeof t=="bigint"&&In<=t;function Pr(t,e,r){return Di(t)&&Di(e)&&Di(r)&&e<=t&&t<r}function Ie(t,e,r,n){if(!Pr(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Oi(t){let e;for(e=0;t>In;t>>=Nn,e+=1);return e}function td(t,e){return t>>BigInt(e)&Nn}function rd(t,e,r){return t|(r?Nn:In)<<BigInt(e)}var Kr=t=>(Yh<<BigInt(t-1))-Nn,Fi=t=>new Uint8Array(t),Da=t=>Uint8Array.from(t);function Hi(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=Fi(t),o=Fi(t),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...f)=>r(o,n,...f),c=(f=Fi())=>{o=a(Da([0]),f),n=a(),f.length!==0&&(o=a(Da([1]),f),n=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,h=[];for(;f<e;){n=a();let v=n.slice();h.push(v),f+=n.length}return ht(...h)};return(f,h)=>{s(),c(f);let v;for(;!(v=h(l()));)c();return s(),v}}var nd={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Ut(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Je(t,e,r={}){let n=(o,i,s)=>{let a=nd[i];if(typeof a!="function")throw new Error("invalid validator function");let c=t[o];if(!(s&&c===void 0)&&!a(c,t))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+c)};for(let[o,i]of Object.entries(e))n(o,i,!1);for(let[o,i]of Object.entries(r))n(o,i,!0);return t}var od=()=>{throw new Error("not implemented")};function Jt(t){let e=new WeakMap;return(r,...n)=>{let o=e.get(r);if(o!==void 0)return o;let i=t(r,...n);return e.set(r,i),i}}var ie=BigInt(0),te=BigInt(1),Xt=BigInt(2),id=BigInt(3),Pi=BigInt(4),Fa=BigInt(5),Ma=BigInt(8),sd=BigInt(9),ad=BigInt(16);function J(t,e){let r=t%e;return r>=ie?r:e+r}function cd(t,e,r){if(e<ie)throw new Error("invalid exponent, negatives unsupported");if(r<=ie)throw new Error("invalid modulus");if(r===te)return ie;let n=te;for(;e>ie;)e&te&&(n=n*t%r),t=t*t%r,e>>=te;return n}function re(t,e,r){let n=t;for(;e-- >ie;)n*=n,n%=r;return n}function Rn(t,e){if(t===ie)throw new Error("invert: expected non-zero number");if(e<=ie)throw new Error("invert: expected positive modulus, got "+e);let r=J(t,e),n=e,o=ie,i=te,s=te,a=ie;for(;r!==ie;){let l=n/r,u=n%r,f=o-s*l,h=i-a*l;n=r,r=u,o=s,i=a,s=f,a=h}if(n!==te)throw new Error("invert: does not exist");return J(o,e)}function ud(t){let e=(t-te)/Xt,r,n,o;for(r=t-te,n=0;r%Xt===ie;r/=Xt,n++);for(o=Xt;o<t&&cd(o,e,t)!==t-te;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(t+te)/Pi;return function(c,l){let u=c.pow(l,s);if(!c.eql(c.sqr(u),l))throw new Error("Cannot find square root");return u}}let i=(r+te)/Xt;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,u=a.pow(a.mul(a.ONE,o),r),f=a.pow(c,i),h=a.pow(c,r);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let v=1;for(let y=a.sqr(h);v<l&&!a.eql(y,a.ONE);v++)y=a.sqr(y);let E=a.pow(u,te<<BigInt(l-v-1));u=a.sqr(E),f=a.mul(f,E),h=a.mul(h,u),l=v}return f}}function ld(t){if(t%Pi===id){let e=(t+te)/Pi;return function(n,o){let i=n.pow(o,e);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(t%Ma===Fa){let e=(t-Fa)/Ma;return function(n,o){let i=n.mul(o,Xt),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,Xt),s),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),o))throw new Error("Cannot find square root");return l}}return t%ad,ud(t)}var Oa=(t,e)=>(J(t,e)&te)===te,fd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ki(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=fd.reduce((n,o)=>(n[o]="function",n),e);return Je(t,r)}function hd(t,e,r){if(r<ie)throw new Error("invalid exponent, negatives unsupported");if(r===ie)return t.ONE;if(r===te)return e;let n=t.ONE,o=e;for(;r>ie;)r&te&&(n=t.mul(n,o)),o=t.sqr(o),r>>=te;return n}function dd(t,e){let r=new Array(e.length),n=e.reduce((i,s,a)=>t.is0(s)?i:(r[a]=i,t.mul(i,s)),t.ONE),o=t.inv(n);return e.reduceRight((i,s,a)=>t.is0(s)?i:(r[a]=t.mul(i,r[a]),t.mul(i,s)),o),r}function $i(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Lt(t,e,r=!1,n={}){if(t<=ie)throw new Error("invalid field: expected ORDER > 0, got "+t);let{nBitLength:o,nByteLength:i}=$i(t,e);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,a=Object.freeze({ORDER:t,isLE:r,BITS:o,BYTES:i,MASK:Kr(o),ZERO:ie,ONE:te,create:c=>J(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ie<=c&&c<t},is0:c=>c===ie,isOdd:c=>(c&te)===te,neg:c=>J(-c,t),eql:(c,l)=>c===l,sqr:c=>J(c*c,t),add:(c,l)=>J(c+l,t),sub:(c,l)=>J(c-l,t),mul:(c,l)=>J(c*l,t),pow:(c,l)=>hd(a,c,l),div:(c,l)=>J(c*Rn(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Rn(c,t),sqrt:n.sqrt||(c=>(s||(s=ld(t)),s(a,c))),invertBatch:c=>dd(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>r?Yt(c,i):_t(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return r?Rt(c):ft(c)}});return Object.freeze(a)}function Ha(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function qi(t){let e=Ha(t);return e+Math.ceil(e/2)}function Pa(t,e,r=!1){let n=t.length,o=Ha(e),i=qi(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Rt(t):ft(t),a=J(s,e-te)+te;return r?Yt(a,o):_t(a,o)}var Ka=BigInt(0),_n=BigInt(1);function zi(t,e){let r=e.negate();return t?r:e}function $a(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Gi(t,e){$a(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1);return{windows:r,windowSize:n}}function pd(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,n)=>{if(!(r instanceof e))throw new Error("invalid point at index "+n)})}function gd(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,n)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+n)})}var Zi=new WeakMap,qa=new WeakMap;function Wi(t){return qa.get(t)||1}function Ln(t,e){return{constTimeNegate:zi,hasPrecomputes(r){return Wi(r)!==1},unsafeLadder(r,n,o=t.ZERO){let i=r;for(;n>Ka;)n&_n&&(o=o.add(i)),i=i.double(),n>>=_n;return o},precomputeWindow(r,n){let{windows:o,windowSize:i}=Gi(n,e),s=[],a=r,c=a;for(let l=0;l<o;l++){c=a,s.push(c);for(let u=1;u<i;u++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(r,n,o){let{windows:i,windowSize:s}=Gi(r,e),a=t.ZERO,c=t.BASE,l=BigInt(2**r-1),u=2**r,f=BigInt(r);for(let h=0;h<i;h++){let v=h*s,E=Number(o&l);o>>=f,E>s&&(E-=u,o+=_n);let y=v,d=v+Math.abs(E)-1,A=h%2!==0,T=E<0;E===0?c=c.add(zi(A,n[y])):a=a.add(zi(T,n[d]))}return{p:a,f:c}},wNAFUnsafe(r,n,o,i=t.ZERO){let{windows:s,windowSize:a}=Gi(r,e),c=BigInt(2**r-1),l=2**r,u=BigInt(r);for(let f=0;f<s;f++){let h=f*a;if(o===Ka)break;let v=Number(o&c);if(o>>=u,v>a&&(v-=l,o+=_n),v===0)continue;let E=n[h+Math.abs(v)-1];v<0&&(E=E.negate()),i=i.add(E)}return i},getPrecomputes(r,n,o){let i=Zi.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&Zi.set(n,o(i))),i},wNAFCached(r,n,o){let i=Wi(r);return this.wNAF(i,this.getPrecomputes(i,r,o),n)},wNAFCachedUnsafe(r,n,o,i){let s=Wi(r);return s===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,r,o),n,i)},setWindowSize(r,n){$a(n,e),qa.set(r,n),Zi.delete(r)}}}function Vn(t,e,r,n){if(pd(r,t),gd(n,e),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=t.ZERO,i=Oi(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=(1<<s)-1,c=new Array(a+1).fill(o),l=Math.floor((e.BITS-1)/s)*s,u=o;for(let f=l;f>=0;f-=s){c.fill(o);for(let v=0;v<n.length;v++){let E=n[v],y=Number(E>>BigInt(f)&BigInt(a));c[y]=c[y].add(r[v])}let h=o;for(let v=c.length-1,E=o;v>0;v--)E=E.add(c[v]),h=h.add(E);if(u=u.add(h),f!==0)for(let v=0;v<s;v++)u=u.double()}return u}function $r(t){return Ki(t.Fp),Je(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...$i(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}var qe=BigInt(0),Ne=BigInt(1),Dn=BigInt(2),md=BigInt(8),yd={zip215:!0};function xd(t){let e=$r(t);return Je(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function za(t){let e=xd(t),{Fp:r,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=e,l=Dn<<BigInt(a*8)-Ne,u=r.create,f=Lt(e.n,e.nBitLength),h=e.uvRatio||((m,p)=>{try{return{isValid:!0,value:r.sqrt(m*r.inv(p))}}catch{return{isValid:!1,value:qe}}}),v=e.adjustScalarBytes||(m=>m),E=e.domain||((m,p,B)=>{if($e("phflag",B),p.length||B)throw new Error("Contexts/pre-hash are not supported");return m});function y(m,p){Ie("coordinate "+m,p,qe,l)}function d(m){if(!(m instanceof x))throw new Error("ExtendedPoint expected")}let A=Jt((m,p)=>{let{ex:B,ey:N,ez:O}=m,H=m.is0();p==null&&(p=H?md:r.inv(O));let z=u(B*p),Z=u(N*p),$=u(O*p);if(H)return{x:qe,y:Ne};if($!==Ne)throw new Error("invZ was invalid");return{x:z,y:Z}}),T=Jt(m=>{let{a:p,d:B}=e;if(m.is0())throw new Error("bad point: ZERO");let{ex:N,ey:O,ez:H,et:z}=m,Z=u(N*N),$=u(O*O),j=u(H*H),X=u(j*j),ae=u(Z*p),ce=u(j*u(ae+$)),fe=u(X+u(B*u(Z*$)));if(ce!==fe)throw new Error("bad point: equation left != right (1)");let ye=u(N*O),Ce=u(H*z);if(ye!==Ce)throw new Error("bad point: equation left != right (2)");return!0});class x{constructor(p,B,N,O){this.ex=p,this.ey=B,this.ez=N,this.et=O,y("x",p),y("y",B),y("z",N),y("t",O),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof x)throw new Error("extended point not allowed");let{x:B,y:N}=p||{};return y("x",B),y("y",N),new x(B,N,Ne,u(B*N))}static normalizeZ(p){let B=r.invertBatch(p.map(N=>N.ez));return p.map((N,O)=>N.toAffine(B[O])).map(x.fromAffine)}static msm(p,B){return Vn(x,f,p,B)}_setWindowSize(p){D.setWindowSize(this,p)}assertValidity(){T(this)}equals(p){d(p);let{ex:B,ey:N,ez:O}=this,{ex:H,ey:z,ez:Z}=p,$=u(B*Z),j=u(H*O),X=u(N*Z),ae=u(z*O);return $===j&&X===ae}is0(){return this.equals(x.ZERO)}negate(){return new x(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=e,{ex:B,ey:N,ez:O}=this,H=u(B*B),z=u(N*N),Z=u(Dn*u(O*O)),$=u(p*H),j=B+N,X=u(u(j*j)-H-z),ae=$+z,ce=ae-Z,fe=$-z,ye=u(X*ce),Ce=u(ae*fe),ve=u(X*fe),Ye=u(ce*ae);return new x(ye,Ce,Ye,ve)}add(p){d(p);let{a:B,d:N}=e,{ex:O,ey:H,ez:z,et:Z}=this,{ex:$,ey:j,ez:X,et:ae}=p;if(B===BigInt(-1)){let ta=u((H-O)*(j+$)),ra=u((H+O)*(j-$)),yi=u(ra-ta);if(yi===qe)return this.double();let na=u(z*Dn*ae),oa=u(Z*Dn*X),ia=oa+na,sa=ra+ta,aa=oa-na,ff=u(ia*yi),hf=u(sa*aa),df=u(ia*aa),pf=u(yi*sa);return new x(ff,hf,pf,df)}let ce=u(O*$),fe=u(H*j),ye=u(Z*N*ae),Ce=u(z*X),ve=u((O+H)*($+j)-ce-fe),Ye=Ce-ye,it=Ce+ye,Lr=u(fe-B*ce),af=u(ve*Ye),cf=u(it*Lr),uf=u(ve*Lr),lf=u(Ye*it);return new x(af,cf,lf,uf)}subtract(p){return this.add(p.negate())}wNAF(p){return D.wNAFCached(this,p,x.normalizeZ)}multiply(p){let B=p;Ie("scalar",B,Ne,n);let{p:N,f:O}=this.wNAF(B);return x.normalizeZ([N,O])[0]}multiplyUnsafe(p,B=x.ZERO){let N=p;return Ie("scalar",N,qe,n),N===qe?F:this.is0()||N===Ne?this:D.wNAFCachedUnsafe(this,N,x.normalizeZ,B)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return D.unsafeLadder(this,n).is0()}toAffine(p){return A(this,p)}clearCofactor(){let{h:p}=e;return p===Ne?this:this.multiplyUnsafe(p)}static fromHex(p,B=!1){let{d:N,a:O}=e,H=r.BYTES;p=ne("pointHex",p,H),$e("zip215",B);let z=p.slice(),Z=p[H-1];z[H-1]=Z&-129;let $=Rt(z),j=B?l:r.ORDER;Ie("pointHex.y",$,qe,j);let X=u($*$),ae=u(X-Ne),ce=u(N*X-O),{isValid:fe,value:ye}=h(ae,ce);if(!fe)throw new Error("Point.fromHex: invalid y coordinate");let Ce=(ye&Ne)===Ne,ve=(Z&128)!==0;if(!B&&ye===qe&&ve)throw new Error("Point.fromHex: x=0 and x_0=1");return ve!==Ce&&(ye=u(-ye)),x.fromAffine({x:ye,y:$})}static fromPrivateKey(p){return b(p).point}toRawBytes(){let{x:p,y:B}=this.toAffine(),N=Yt(B,r.BYTES);return N[N.length-1]|=p&Ne?128:0,N}toHex(){return lt(this.toRawBytes())}}x.BASE=new x(e.Gx,e.Gy,Ne,u(e.Gx*e.Gy)),x.ZERO=new x(qe,Ne,Ne,qe);let{BASE:U,ZERO:F}=x,D=Ln(x,a*8);function R(m){return J(m,n)}function w(m){return R(Rt(m))}function b(m){let p=r.BYTES;m=ne("private key",m,p);let B=ne("hashed private key",i(m),2*p),N=v(B.slice(0,p)),O=B.slice(p,2*p),H=w(N),z=U.multiply(H),Z=z.toRawBytes();return{head:N,prefix:O,scalar:H,point:z,pointBytes:Z}}function M(m){return b(m).pointBytes}function _(m=new Uint8Array,...p){let B=ht(...p);return w(i(E(B,ne("context",m),!!o)))}function I(m,p,B={}){m=ne("message",m),o&&(m=o(m));let{prefix:N,scalar:O,pointBytes:H}=b(p),z=_(B.context,N,m),Z=U.multiply(z).toRawBytes(),$=_(B.context,Z,H,m),j=R(z+$*O);Ie("signature.s",j,qe,n);let X=ht(Z,Yt(j,r.BYTES));return ne("result",X,r.BYTES*2)}let K=yd;function S(m,p,B,N=K){let{context:O,zip215:H}=N,z=r.BYTES;m=ne("signature",m,2*z),p=ne("message",p),B=ne("publicKey",B,z),H!==void 0&&$e("zip215",H),o&&(p=o(p));let Z=Rt(m.slice(z,2*z)),$,j,X;try{$=x.fromHex(B,H),j=x.fromHex(m.slice(0,z),H),X=U.multiplyUnsafe(Z)}catch{return!1}if(!H&&$.isSmallOrder())return!1;let ae=_(O,j.toRawBytes(),$.toRawBytes(),p);return j.add($.multiplyUnsafe(ae)).subtract(X).clearCofactor().equals(x.ZERO)}return U._setWindowSize(8),{CURVE:e,getPublicKey:M,sign:I,verify:S,ExtendedPoint:x,utils:{getExtendedPublicKey:b,randomPrivateKey:()=>s(r.BYTES),precompute(m=8,p=x.BASE){return p._setWindowSize(m),p.multiply(BigInt(3)),p}}}}var ji=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ga=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),qg=BigInt(0),wd=BigInt(1),Za=BigInt(2),zg=BigInt(3),bd=BigInt(5),vd=BigInt(8);function Ed(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=ji,a=t*t%i*t%i,c=re(a,Za,i)*a%i,l=re(c,wd,i)*t%i,u=re(l,bd,i)*l%i,f=re(u,e,i)*u%i,h=re(f,r,i)*f%i,v=re(h,n,i)*h%i,E=re(v,o,i)*v%i,y=re(E,o,i)*v%i,d=re(y,e,i)*u%i;return{pow_p_5_8:re(d,Za,i)*t%i,b2:a}}function Bd(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function Ad(t,e){let r=ji,n=J(e*e*e,r),o=J(n*n*e,r),i=Ed(t*o).pow_p_5_8,s=J(t*n*i,r),a=J(e*s*s,r),c=s,l=J(s*Ga,r),u=a===t,f=a===J(-t,r),h=a===J(-t*Ga,r);return u&&(s=c),(f||h)&&(s=l),Oa(s,r)&&(s=J(-s,r)),{isValid:u||f,value:s}}var Sd=Lt(ji,void 0,!0),kd={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Sd,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:vd,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:La,randomBytes:Cn,adjustScalarBytes:Bd,uvRatio:Ad},Wa=za(kd);var Fn=32;function ja(t,e,r){return Wa.verify(e,r instanceof Uint8Array?r:r.subarray(),t)}var Mn=class{type="Ed25519";raw;constructor(e){this.raw=Yi(e,Fn)}toMultihash(){return ct.digest(xr(this))}toCID(){return ee.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}verify(e,r){return ja(this.raw,r,e)}};function Ji(t){return t=Yi(t,Fn),new Mn(t)}function Yi(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new xe(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}function Xi(t=0){return new Uint8Array(t)}function Xe(t=0){return new Uint8Array(t)}var Td=Math.pow(2,7),Id=Math.pow(2,14),Nd=Math.pow(2,21),Ja=Math.pow(2,28),Xa=Math.pow(2,35),Qa=Math.pow(2,42),ec=Math.pow(2,49),Be=128,Vt=127;function qr(t){if(t<Td)return 1;if(t<Id)return 2;if(t<Nd)return 3;if(t<Ja)return 4;if(t<Xa)return 5;if(t<Qa)return 6;if(t<ec)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function tc(t,e,r=0){switch(qr(t)){case 8:e[r++]=t&255|Be,t/=128;case 7:e[r++]=t&255|Be,t/=128;case 6:e[r++]=t&255|Be,t/=128;case 5:e[r++]=t&255|Be,t/=128;case 4:e[r++]=t&255|Be,t>>>=7;case 3:e[r++]=t&255|Be,t>>>=7;case 2:e[r++]=t&255|Be,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function rc(t,e){let r=t[e],n=0;if(n+=r&Vt,r<Be||(r=t[e+1],n+=(r&Vt)<<7,r<Be)||(r=t[e+2],n+=(r&Vt)<<14,r<Be)||(r=t[e+3],n+=(r&Vt)<<21,r<Be)||(r=t[e+4],n+=(r&Vt)*Ja,r<Be)||(r=t[e+5],n+=(r&Vt)*Xa,r<Be)||(r=t[e+6],n+=(r&Vt)*Qa,r<Be)||(r=t[e+7],n+=(r&Vt)*ec,r<Be))return n;throw new RangeError("Could not decode varint")}var Qi=new Float32Array([-0]),Dt=new Uint8Array(Qi.buffer);function nc(t,e,r){Qi[0]=t,e[r]=Dt[0],e[r+1]=Dt[1],e[r+2]=Dt[2],e[r+3]=Dt[3]}function oc(t,e){return Dt[0]=t[e],Dt[1]=t[e+1],Dt[2]=t[e+2],Dt[3]=t[e+3],Qi[0]}var es=new Float64Array([-0]),we=new Uint8Array(es.buffer);function ic(t,e,r){es[0]=t,e[r]=we[0],e[r+1]=we[1],e[r+2]=we[2],e[r+3]=we[3],e[r+4]=we[4],e[r+5]=we[5],e[r+6]=we[6],e[r+7]=we[7]}function sc(t,e){return we[0]=t[e],we[1]=t[e+1],we[2]=t[e+2],we[3]=t[e+3],we[4]=t[e+4],we[5]=t[e+5],we[6]=t[e+6],we[7]=t[e+7],es[0]}var Ud=BigInt(Number.MAX_SAFE_INTEGER),Rd=BigInt(Number.MIN_SAFE_INTEGER),Re=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Qt;if(e<Ud&&e>Rd)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>ac&&(o=0n,++n>ac&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return Qt;let r=e<0;r&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new t(n,o)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):Qt}},Qt=new Re(0,0);Qt.toBigInt=function(){return 0n};Qt.zzEncode=Qt.zzDecode=function(){return this};Qt.length=function(){return 1};var ac=4294967296n;function cc(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function uc(t,e,r){if(r-e<1)return"";let o,i=[],s=0,a;for(;e<r;)a=t[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function ts(t,e,r){let n=r,o,i;for(let s=0;s<t.length;++s)o=t.charCodeAt(s),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((i=t.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-n}function ze(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function On(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var rs=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,ze(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw ze(this,4);return On(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw ze(this,4);return On(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw ze(this,4);let e=oc(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw ze(this,4);let e=sc(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw ze(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return uc(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw ze(this,e);this.pos+=e}else do if(this.pos>=this.len)throw ze(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Re(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw ze(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw ze(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw ze(this,8);let e=On(this.buf,this.pos+=4),r=On(this.buf,this.pos+=4);return new Re(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=rc(this.buf,this.pos);return this.pos+=qr(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function ns(t){return new rs(t instanceof Uint8Array?t:t.subarray())}function Ft(t,e,r){let n=ns(t);return e.decode(n,void 0,r)}var os={};Ee(os,{base10:()=>_d});var _d=St({prefix:"9",name:"base10",alphabet:"0123456789"});var is={};Ee(is,{base16:()=>Ld,base16upper:()=>Vd});var Ld=oe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Vd=oe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ss={};Ee(ss,{base2:()=>Dd});var Dd=oe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var as={};Ee(as,{base256emoji:()=>Pd});var fc=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}"),Fd=fc.reduce((t,e,r)=>(t[r]=e,t),[]),Md=fc.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function Od(t){return t.reduce((e,r)=>(e+=Fd[r],e),"")}function Hd(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Md[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Pd=ur({prefix:"\u{1F680}",name:"base256emoji",encode:Od,decode:Hd});var cs={};Ee(cs,{base8:()=>Kd});var Kd=oe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var us={};Ee(us,{identity:()=>$d});var $d=ur({prefix:"\0",name:"identity",encode:t=>ha(t),decode:t=>fa(t)});var Cm=new TextEncoder,Tm=new TextDecoder;var hs={};Ee(hs,{sha256:()=>zr,sha512:()=>Gd});function fs({name:t,code:e,encode:r}){return new ls(t,e,r)}var ls=class{name;code;encode;constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?Pe(this.code,r):r.then(n=>Pe(this.code,n))}else throw Error("Unknown type, must be binary type")}};function dc(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var zr=fs({name:"sha2-256",code:18,encode:dc("SHA-256")}),Gd=fs({name:"sha2-512",code:19,encode:dc("SHA-512")});var ds={...us,...ss,...cs,...os,...is,...Ai,...Ii,...Si,...Ci,...as},Hm={...hs,...Ri};function gc(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var pc=gc("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),ps=gc("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Xe(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Zd={utf8:pc,"utf-8":pc,hex:ds.base16,latin1:ps,ascii:ps,binary:ps,...ds},Hn=Zd;function Y(t,e="utf8"){let r=Hn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}function gs(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return Xe(s);o+s>e&&(n=Xe(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var er=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function ms(){}var xs=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Wd=gs();function jd(t){return globalThis.Buffer!=null?Xe(t):Wd(t)}var Zr=class{len;head;tail;states;constructor(){this.len=0,this.head=new er(ms,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new er(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new ws((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Pn,10,Re.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=Re.fromBigInt(e);return this._push(Pn,r.length(),r)}uint64Number(e){return this._push(tc,qr(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=Re.fromBigInt(e).zzEncode();return this._push(Pn,r.length(),r)}sint64Number(e){let r=Re.fromNumber(e).zzEncode();return this._push(Pn,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(ys,1,e?1:0)}fixed32(e){return this._push(Gr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=Re.fromBigInt(e);return this._push(Gr,4,r.lo)._push(Gr,4,r.hi)}fixed64Number(e){let r=Re.fromNumber(e);return this._push(Gr,4,r.lo)._push(Gr,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(nc,4,e)}double(e){return this._push(ic,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(ys,1,0):this.uint32(r)._push(Jd,r,e)}string(e){let r=cc(e);return r!==0?this.uint32(r)._push(ts,r,e):this._push(ys,1,0)}fork(){return this.states=new xs(this),this.head=this.tail=new er(ms,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 er(ms,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=jd(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function ys(t,e,r){e[r]=t&255}function Yd(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var ws=class extends er{next;constructor(e,r){super(Yd,e,r),this.next=void 0}};function Pn(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function Gr(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function Jd(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(Zr.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(Xd,e,t),this},Zr.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(Qd,e,t),this});function Xd(t,e,r){e.set(t,r)}function Qd(t,e,r){t.length<40?ts(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(Y(t),r)}function bs(){return new Zr}function Mt(t,e){let r=bs();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var wr;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(wr||(wr={}));function Kn(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function Wr(t){function e(o){if(t[o.toString()]==null)throw new Error("Invalid enum value");return t[o]}let r=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return Kn("enum",wr.VARINT,r,n)}function Ot(t,e){return Kn("message",wr.LENGTH_DELIMITED,t,e)}var se;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1"})(se||(se={}));var vs;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1"})(vs||(vs={}));(function(t){t.codec=()=>Wr(vs)})(se||(se={}));var Qe;(function(t){let e;t.codec=()=>(e==null&&(e=Ot((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),se.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=se.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Mt(r,t.codec()),t.decode=(r,n)=>Ft(r,t.codec(),n)})(Qe||(Qe={}));var Es;(function(t){let e;t.codec=()=>(e==null&&(e=Ot((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),se.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=se.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Mt(r,t.codec()),t.decode=(r,n)=>Ft(r,t.codec(),n)})(Es||(Es={}));var on={};Ee(on,{MAX_RSA_KEY_SIZE:()=>Lo,generateRSAKeyPair:()=>hu,jwkToJWKKeyPair:()=>du,jwkToPkcs1:()=>g0,jwkToPkix:()=>Us,jwkToRSAPrivateKey:()=>fu,pkcs1ToJwk:()=>cu,pkcs1ToRSAPrivateKey:()=>lu,pkixToJwk:()=>uu,pkixToRSAPublicKey:()=>Rs});var e0=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ht=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pt=new Uint32Array(64),Bs=class extends mr{constructor(){super(64,32,8,!1),this.A=Ht[0]|0,this.B=Ht[1]|0,this.C=Ht[2]|0,this.D=Ht[3]|0,this.E=Ht[4]|0,this.F=Ht[5]|0,this.G=Ht[6]|0,this.H=Ht[7]|0}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,r,n,o,i,s,a,c]}set(e,r,n,o,i,s,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,r){for(let f=0;f<16;f++,r+=4)Pt[f]=e.getUint32(r,!1);for(let f=16;f<64;f++){let h=Pt[f-15],v=Pt[f-2],E=Ke(h,7)^Ke(h,18)^h>>>3,y=Ke(v,17)^Ke(v,19)^v>>>10;Pt[f]=y+Pt[f-7]+E+Pt[f-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:l,H:u}=this;for(let f=0;f<64;f++){let h=Ke(a,6)^Ke(a,11)^Ke(a,25),v=u+h+Ua(a,c,l)+e0[f]+Pt[f]|0,y=(Ke(n,2)^Ke(n,13)^Ke(n,22))+Ra(n,o,i)|0;u=l,l=c,c=a,a=s+v|0,s=i,i=o,o=n,n=v+y|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,l,u)}roundClean(){Pt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var br=kn(()=>new Bs);var G=Vr(yc());function tr(t,e){let r=0;if(t.length===1)return t[0];for(let n=t.length-1;n>=0;n--)r+=t[t.length-1-n]*Math.pow(2,e*n);return r}function Kt(t,e,r=-1){let n=r,o=t,i=0,s=Math.pow(2,e);for(let a=1;a<8;a++){if(t<s){let c;if(n<0)c=new ArrayBuffer(a),i=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),i=n}let l=new Uint8Array(c);for(let u=a-1;u>=0;u--){let f=Math.pow(2,u*e);l[i-u-1]=Math.floor(o/f),o-=l[i-u-1]*f}return c}s*=Math.pow(2,e)}return new ArrayBuffer(0)}function zn(...t){let e=0,r=0;for(let i of t)e+=i.length;let n=new ArrayBuffer(e),o=new Uint8Array(n);for(let i of t)o.set(i,r),r+=i.length;return o}function Ss(){let t=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=t[0]===255&&t[1]&128,c=t[0]===0&&(t[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),r=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)r[a]=0;r[0]=t[0]&128;let n=tr(r,8),o=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(o);for(let a=0;a<this.valueHex.byteLength;a++)i[a]=t[a];return i[0]&=127,tr(i,8)-n}function xc(t){let e=t<0?t*-1:t,r=128;for(let n=1;n<8;n++){if(e<=r){if(t<0){let s=r-e,a=Kt(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=Kt(e,8,n),i=new Uint8Array(o);if(i[0]&128){let s=o.slice(0),a=new Uint8Array(s);o=new ArrayBuffer(o.byteLength+1),i=new Uint8Array(o);for(let c=0;c<s.byteLength;c++)i[c+1]=a[c];i[0]=0}return o}r*=Math.pow(2,8)}return new ArrayBuffer(0)}function wc(t,e){if(t.byteLength!==e.byteLength)return!1;let r=new Uint8Array(t),n=new Uint8Array(e);for(let o=0;o<r.length;o++)if(r[o]!==n[o])return!1;return!0}function Ue(t,e){let r=t.toString(10);if(e<r.length)return"";let n=e-r.length,o=new Array(n);for(let s=0;s<n;s++)o[s]="0";return o.join("").concat(r)}var vy=Math.log(2);function Gn(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function ks(t){let e=0,r=0;for(let o=0;o<t.length;o++){let i=t[o];e+=i.byteLength}let n=new Uint8Array(e);for(let o=0;o<t.length;o++){let i=t[o];n.set(new Uint8Array(i),r),r+=i.byteLength}return n.buffer}function yt(t,e,r,n){return e instanceof Uint8Array?e.byteLength?r<0?(t.error="Wrong parameter: inputOffset less than zero",!1):n<0?(t.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-r-n<0?(t.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(t.error="Wrong parameter: inputBuffer has zero length",!1):(t.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var Yr=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return ks(this.items)}},jr=[new Uint8Array([1])],bc="0123456789";var Sr="",Ge=new ArrayBuffer(0),Cs=new Uint8Array(0),Jr="EndOfContent",Ec="OCTET STRING",Bc="BIT STRING";function xt(t){var e;return e=class extends t{constructor(...n){var o;super(...n);let i=n[0]||{};this.isHexOnly=(o=i.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=i.valueHex?G.BufferSourceConverter.toUint8Array(i.valueHex):Cs}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,o,i){let s=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!yt(this,s,o,i))return-1;let a=o+i;return this.valueHexView=s.subarray(o,a),this.valueHexView.length?(this.blockLength=i,a):(this.warnings.push("Zero buffer length"),o)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",Ge)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:G.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var pt=class{constructor({blockLength:e=0,error:r=Sr,warnings:n=[],valueBeforeDecode:o=Cs}={}){this.blockLength=e,this.error=r,this.warnings=n,this.valueBeforeDecodeView=G.BufferSourceConverter.toUint8Array(o)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:G.Convert.ToHex(this.valueBeforeDecodeView)}}};pt.NAME="baseBlock";var be=class extends pt{fromBER(e,r,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,r){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};be.NAME="valueBlock";var Zn=class extends xt(pt){constructor({idBlock:e={}}={}){var r,n,o,i;super(),e?(this.isHexOnly=(r=e.isHexOnly)!==null&&r!==void 0?r:!1,this.valueHexView=e.valueHex?G.BufferSourceConverter.toUint8Array(e.valueHex):Cs,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(o=e.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(i=e.isConstructed)!==null&&i!==void 0?i:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let r=0;switch(this.tagClass){case 1:r|=0;break;case 2:r|=64;break;case 3:r|=128;break;case 4:r|=192;break;default:return this.error="Unknown tag class",Ge}if(this.isConstructed&&(r|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!e){let i=this.tagNumber;i&=31,r|=i,o[0]=r}return o.buffer}if(!this.isHexOnly){let o=Kt(this.tagNumber,7),i=new Uint8Array(o),s=o.byteLength,a=new Uint8Array(s+1);if(a[0]=r|31,!e){for(let c=0;c<s-1;c++)a[c+1]=i[c]|128;a[s]=i[s-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=r|31,!e){let o=this.valueHexView;for(let i=0;i<o.length-1;i++)n[i+1]=o[i]|128;n[this.valueHexView.byteLength]=o[o.length-1]}return n.buffer}fromBER(e,r,n){let o=G.BufferSourceConverter.toUint8Array(e);if(!yt(this,o,r,n))return-1;let i=o.subarray(r,r+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;let a=i[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,l=this.valueHexView=new Uint8Array(255),u=255;for(;i[c]&128;){if(l[c-1]=i[c]&127,c++,c>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let h=new Uint8Array(u);for(let v=0;v<l.length;v++)h[v]=l[v];l=this.valueHexView=new Uint8Array(u)}}this.blockLength=c+1,l[c-1]=i[c]&127;let f=new Uint8Array(c);for(let h=0;h<c;h++)f[h]=l[h];l=this.valueHexView=new Uint8Array(c),l.set(f),this.blockLength<=9?this.tagNumber=tr(l,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return r+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};Zn.NAME="identificationBlock";var Wn=class extends pt{constructor({lenBlock:e={}}={}){var r,n,o;super(),this.isIndefiniteForm=(r=e.isIndefiniteForm)!==null&&r!==void 0?r:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(o=e.length)!==null&&o!==void 0?o:0}fromBER(e,r,n){let o=G.BufferSourceConverter.toUint8Array(e);if(!yt(this,o,r,n))return-1;let i=o.subarray(r,r+n);if(i.length===0)return this.error="Zero buffer length",-1;if(i[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,r+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,r+this.blockLength;let s=i[0]&127;if(s>8)return this.error="Too big integer",-1;if(s+1>i.length)return this.error="End of input reached before message was fully decoded",-1;let a=r+1,c=o.subarray(a,a+s);return c[s-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=tr(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,r+this.blockLength}toBER(e=!1){let r,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return r=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(r),n[0]=128),r;if(this.longFormUsed){let o=Kt(this.length,8);if(o.byteLength>127)return this.error="Too big length",Ge;if(r=new ArrayBuffer(o.byteLength+1),e)return r;let i=new Uint8Array(o);n=new Uint8Array(r),n[0]=o.byteLength|128;for(let s=0;s<o.byteLength;s++)n[s+1]=i[s];return r}return r=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(r),n[0]=this.length),r}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};Wn.NAME="lengthBlock";var L={},de=class extends pt{constructor({name:e=Sr,optional:r=!1,primitiveSchema:n,...o}={},i){super(o),this.name=e,this.optional=r,n&&(this.primitiveSchema=n),this.idBlock=new Zn(o),this.lenBlock=new Wn(o),this.valueBlock=i?new i(o):new be(o)}fromBER(e,r,n){let o=this.valueBlock.fromBER(e,r,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}toBER(e,r){let n=r||new Yr;r||Ac(this);let o=this.idBlock.toBER(e);if(n.write(o),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let i=this.valueBlock.toBER(e);this.lenBlock.length=i.byteLength;let s=this.lenBlock.toBER(e);n.write(s),n.write(i)}return r?Ge:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():G.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${G.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let r=this.toBER(),n=e.toBER();return wc(r,n)}};de.NAME="BaseBlock";function Ac(t){if(t instanceof L.Constructed)for(let e of t.valueBlock.value)Ac(e)&&(t.lenBlock.isIndefiniteForm=!0);return!!t.lenBlock.isIndefiniteForm}var jn=class extends de{constructor({value:e=Sr,...r}={},n){super(r,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,r,n){let o=this.valueBlock.fromBER(e,r,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};jn.NAME="BaseStringBlock";var Yn=class extends xt(be){constructor({isHexOnly:e=!0,...r}={}){super(r),this.isHexOnly=e}};Yn.NAME="PrimitiveValueBlock";var Sc,Jn=class extends de{constructor(e={}){super(e,Yn),this.idBlock.isConstructed=!1}};Sc=Jn;L.Primitive=Sc;Jn.NAME="PRIMITIVE";function u0(t,e){if(t instanceof e)return t;let r=new e;return r.idBlock=t.idBlock,r.lenBlock=t.lenBlock,r.warnings=t.warnings,r.valueBeforeDecodeView=t.valueBeforeDecodeView,r}function Ro(t,e=0,r=t.length){let n=e,o=new de({},be),i=new pt;if(!yt(i,t,e,r))return o.error=i.error,{offset:-1,result:o};if(!t.subarray(e,e+r).length)return o.error="Zero buffer length",{offset:-1,result:o};let a=o.idBlock.fromBER(t,e,r);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),a===-1)return o.error=o.idBlock.error,{offset:-1,result:o};if(e=a,r-=o.idBlock.blockLength,a=o.lenBlock.fromBER(t,e,r),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),a===-1)return o.error=o.lenBlock.error,{offset:-1,result:o};if(e=a,r-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};let c=de;switch(o.idBlock.tagClass){case 1:if(o.idBlock.tagNumber>=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};c=L.EndOfContent;break;case 1:c=L.Boolean;break;case 2:c=L.Integer;break;case 3:c=L.BitString;break;case 4:c=L.OctetString;break;case 5:c=L.Null;break;case 6:c=L.ObjectIdentifier;break;case 10:c=L.Enumerated;break;case 12:c=L.Utf8String;break;case 13:c=L.RelativeObjectIdentifier;break;case 14:c=L.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=L.Sequence;break;case 17:c=L.Set;break;case 18:c=L.NumericString;break;case 19:c=L.PrintableString;break;case 20:c=L.TeletexString;break;case 21:c=L.VideotexString;break;case 22:c=L.IA5String;break;case 23:c=L.UTCTime;break;case 24:c=L.GeneralizedTime;break;case 25:c=L.GraphicString;break;case 26:c=L.VisibleString;break;case 27:c=L.GeneralString;break;case 28:c=L.UniversalString;break;case 29:c=L.CharacterString;break;case 30:c=L.BmpString;break;case 31:c=L.DATE;break;case 32:c=L.TimeOfDay;break;case 33:c=L.DateTime;break;case 34:c=L.Duration;break;default:{let l=o.idBlock.isConstructed?new L.Constructed:new L.Primitive;l.idBlock=o.idBlock,l.lenBlock=o.lenBlock,l.warnings=o.warnings,o=l}}break;case 2:case 3:case 4:default:c=o.idBlock.isConstructed?L.Constructed:L.Primitive}return o=u0(o,c),a=o.fromBER(t,e,o.lenBlock.isIndefiniteForm?r:o.lenBlock.length),o.valueBeforeDecodeView=t.subarray(n,n+o.blockLength),{offset:a,result:o}}function Ts(t){if(!t.byteLength){let e=new de({},be);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Ro(G.BufferSourceConverter.toUint8Array(t).slice(),0,t.byteLength)}function l0(t,e){return t?1:e}var et=class extends be{constructor({value:e=[],isIndefiniteForm:r=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=r}fromBER(e,r,n){let o=G.BufferSourceConverter.toUint8Array(e);if(!yt(this,o,r,n))return-1;if(this.valueBeforeDecodeView=o.subarray(r,r+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),r;let i=r;for(;l0(this.isIndefiniteForm,n)>0;){let s=Ro(o,i,n);if(s.offset===-1)return this.error=s.result.error,this.warnings.concat(s.result.warnings),-1;if(i=s.offset,this.blockLength+=s.result.blockLength,n-=s.result.blockLength,this.value.push(s.result),this.isIndefiniteForm&&s.result.constructor.NAME===Jr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Jr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,r){let n=r||new Yr;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return r?Ge:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let r of this.value)e.value.push(r.toJSON());return e}};et.NAME="ConstructedValueBlock";var kc,$t=class extends de{constructor(e={}){super(e,et),this.idBlock.isConstructed=!0}fromBER(e,r,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let o=this.valueBlock.fromBER(e,r,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
|
|
4
|
-
`).map(o=>` ${o}`).join(`
|
|
5
|
-
`));let r=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${r} :
|
|
6
|
-
${e.join(`
|
|
7
|
-
`)}`:`${r} :`}};kc=$t;L.Constructed=kc;$t.NAME="CONSTRUCTED";var Xn=class extends be{fromBER(e,r,n){return r}toBER(e){return Ge}};Xn.override="EndOfContentValueBlock";var Cc,Qn=class extends de{constructor(e={}){super(e,Xn),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Cc=Qn;L.EndOfContent=Cc;Qn.NAME=Jr;var Tc,Er=class extends de{constructor(e={}){super(e,be),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,r,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,r+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):r+n}toBER(e,r){let n=new ArrayBuffer(2);if(!e){let o=new Uint8Array(n);o[0]=5,o[1]=0}return r&&r.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Tc=Er;L.Null=Tc;Er.NAME="NULL";var eo=class extends xt(be){constructor({value:e,...r}={}){super(r),r.valueHex?this.valueHexView=G.BufferSourceConverter.toUint8Array(r.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,r,n){let o=G.BufferSourceConverter.toUint8Array(e);return yt(this,o,r,n)?(this.valueHexView=o.subarray(r,r+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Ss.call(this),this.blockLength=n,r+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};eo.NAME="BooleanValueBlock";var Ic,to=class extends de{constructor(e={}){super(e,eo),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Ic=to;L.Boolean=Ic;to.NAME="BOOLEAN";var ro=class extends xt(et){constructor({isConstructed:e=!1,...r}={}){super(r),this.isConstructed=e}fromBER(e,r,n){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=et.prototype.fromBER.call(this,e,r,n),o===-1)return o;for(let i=0;i<this.value.length;i++){let s=this.value[i].constructor.NAME;if(s===Jr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==Ec)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=super.fromBER(e,r,n),this.blockLength=n;return o}toBER(e,r){return this.isConstructed?et.prototype.toBER.call(this,e,r):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};ro.NAME="OctetStringValueBlock";var Nc,no=class t extends de{constructor({idBlock:e={},lenBlock:r={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...r,isIndefiniteForm:!!n.isIndefiniteForm},...n},ro),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,r,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),r;if(!this.valueBlock.isConstructed){let i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(r,r+n);try{if(i.byteLength){let s=Ro(i,0,i.byteLength);s.offset!==-1&&s.offset===n&&(this.valueBlock.value=[s.result])}}catch{}}return super.fromBER(e,r,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?$t.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${G.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let r of this.valueBlock.value)r instanceof t&&e.push(r.valueBlock.valueHexView);return G.BufferSourceConverter.concat(e)}};Nc=no;L.OctetString=Nc;no.NAME=Ec;var oo=class extends xt(et){constructor({unusedBits:e=0,isConstructed:r=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=r,this.blockLength=this.valueHexView.byteLength}fromBER(e,r,n){if(!n)return r;let o=-1;if(this.isConstructed){if(o=et.prototype.fromBER.call(this,e,r,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===Jr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Bc)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let l=a.valueBlock;if(this.unusedBits>0&&l.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=l.unusedBits}return o}let i=G.BufferSourceConverter.toUint8Array(e);if(!yt(this,i,r,n))return-1;let s=i.subarray(r,r+n);if(this.unusedBits=s[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=s.subarray(1);try{if(a.byteLength){let c=Ro(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,r+n}toBER(e,r){if(this.isConstructed)return et.prototype.toBER.call(this,e,r);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Ge;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};oo.NAME="BitStringValueBlock";var Uc,Br=class extends de{constructor({idBlock:e={},lenBlock:r={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...r,isIndefiniteForm:!!n.isIndefiniteForm},...n},oo),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,r,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,r,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return $t.prototype.onAsciiEncoding.call(this);{let e=[],r=this.valueBlock.valueHexView;for(let o of r)e.push(o.toString(2).padStart(8,"0"));let n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};Uc=Br;L.BitString=Uc;Br.NAME=Bc;var Rc;function f0(t,e){let r=new Uint8Array([0]),n=new Uint8Array(t),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,l=0,u=c<s?s:c,f=0;for(let h=u;h>=0;h--,f++){switch(!0){case f<a.length:l=i[s-f]+a[c-f]+r[0];break;default:l=i[s-f]+r[0]}switch(r[0]=l/10,!0){case f>=i.length:i=zn(new Uint8Array([l%10]),i);break;default:i[s-f]=l%10}}return r[0]>0&&(i=zn(r,i)),i}function vc(t){if(t>=jr.length)for(let e=jr.length;e<=t;e++){let r=new Uint8Array([0]),n=jr[e-1].slice(0);for(let o=n.length-1;o>=0;o--){let i=new Uint8Array([(n[o]<<1)+r[0]]);r[0]=i[0]/10,n[o]=i[0]%10}r[0]>0&&(n=zn(r,n)),jr.push(n)}return jr[t]}function h0(t,e){let r=0,n=new Uint8Array(t),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,l,u=0;for(let f=c;f>=0;f--,u++)switch(l=i[s-u]-a[c-u]-r,!0){case l<0:r=1,i[s-u]=l+10;break;default:r=0,i[s-u]=l}if(r>0)for(let f=s-c+1;f>=0;f--,u++)if(l=i[s-u]-r,l<0)r=1,i[s-u]=l+10;else{r=0,i[s-u]=l;break}return i.slice()}var Xr=class extends xt(be){constructor({value:e,...r}={}){super(r),this._valueDec=0,r.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=Ss.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(xc(e))}get valueDec(){return this._valueDec}fromDER(e,r,n,o=0){let i=this.fromBER(e,r,n);if(i===-1)return i;let s=this.valueHexView;return s[0]===0&&s[1]&128?this.valueHexView=s.subarray(1):o!==0&&s.length<o&&(o-s.length>1&&(o=s.length+1),this.valueHexView=s.subarray(o-s.length)),i}toDER(e=!1){let r=this.valueHexView;switch(!0){case(r[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(r,1),this.valueHexView=n}break;case(r[0]===0&&(r[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,r,n){let o=super.fromBER(e,r,n);return o===-1||this.setValueHex(),o}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,r=new Uint8Array(this.valueHexView.length*8/3),n=0,o,i=this.valueHexView,s="",a=!1;for(let c=i.byteLength-1;c>=0;c--){o=i[c];for(let l=0;l<8;l++){if((o&1)===1)switch(n){case e:r=h0(vc(n),r),s="-";break;default:r=f0(r,vc(n))}n++,o>>=1}}for(let c=0;c<r.length;c++)r[c]&&(a=!0),a&&(s+=bc.charAt(r[c]));return a===!1&&(s+=bc.charAt(0)),s}};Rc=Xr;Xr.NAME="IntegerValueBlock";Object.defineProperty(Rc.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var _c,pe=class t extends de{constructor(e={}){super(e,Xr),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Gn(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Gn();let r=BigInt(e),n=new Yr,o=r.toString(16).replace(/^-/,""),i=new Uint8Array(G.Convert.FromHex(o));if(r<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let l=BigInt(`0x${G.Convert.ToHex(a)}`)+r,u=G.BufferSourceConverter.toUint8Array(G.Convert.FromHex(l.toString(16)));u[0]|=128,n.write(u)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new t({valueHex:n.final()})}convertToDER(){let e=new t({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new t({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};_c=pe;L.Integer=_c;pe.NAME="INTEGER";var Lc,io=class extends pe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Lc=io;L.Enumerated=Lc;io.NAME="ENUMERATED";var Qr=class extends xt(be){constructor({valueDec:e=-1,isFirstSid:r=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=r}fromBER(e,r,n){if(!n)return r;let o=G.BufferSourceConverter.toUint8Array(e);if(!yt(this,o,r,n))return-1;let i=o.subarray(r,r+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=tr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),r+this.blockLength)}set valueBigInt(e){Gn();let r=BigInt(e).toString(2);for(;r.length%7;)r="0"+r;let n=new Uint8Array(r.length/7);for(let o=0;o<n.length;o++)n[o]=parseInt(r.slice(o*7,o*7+7),2)+(o+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let r=Kt(this.valueDec,7);if(r.byteLength===0)return this.error="Error during encoding SID value",Ge;let n=new Uint8Array(r.byteLength);if(!e){let o=new Uint8Array(r),i=r.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n}toString(){let e="";if(this.isHexOnly)e=G.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let r=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",r-=40):(e="2.",r-=80),e+=r.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};Qr.NAME="sidBlock";var so=class extends be{constructor({value:e=Sr,...r}={}){super(r),this.value=[],e&&this.fromString(e)}fromBER(e,r,n){let o=r;for(;n>0;){let i=new Qr;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.value.length===0&&(i.isFirstSid=!0),this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e){let r=[];for(let n=0;n<this.value.length;n++){let o=this.value[n].toBER(e);if(o.byteLength===0)return this.error=this.value[n].error,Ge;r.push(o)}return ks(r)}fromString(e){this.value=[];let r=0,n=0,o="",i=!1;do if(n=e.indexOf(".",r),n===-1?o=e.substring(r):o=e.substring(r,n),r=n+1,i){let s=this.value[0],a=0;switch(s.valueDec){case 0:break;case 1:a=40;break;case 2:a=80;break;default:this.value=[];return}let c=parseInt(o,10);if(isNaN(c))return;s.valueDec=c+a,i=!1}else{let s=new Qr;if(o>Number.MAX_SAFE_INTEGER){Gn();let a=BigInt(o);s.valueBigInt=a}else if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return;this.value.length||(s.isFirstSid=!0,i=!0),this.value.push(s)}while(n!==-1)}toString(){let e="",r=!1;for(let n=0;n<this.value.length;n++){r=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),r?(o=`{${o}}`,this.value[n].isFirstSid?e=`2.{${o} - 80}`:e+=o):e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let r=0;r<this.value.length;r++)e.sidArray.push(this.value[r].toJSON());return e}};so.NAME="ObjectIdentifierValueBlock";var Vc,Ar=class extends de{constructor(e={}){super(e,so),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Vc=Ar;L.ObjectIdentifier=Vc;Ar.NAME="OBJECT IDENTIFIER";var en=class extends xt(pt){constructor({valueDec:e=0,...r}={}){super(r),this.valueDec=e}fromBER(e,r,n){if(n===0)return r;let o=G.BufferSourceConverter.toUint8Array(e);if(!yt(this,o,r,n))return-1;let i=o.subarray(r,r+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=tr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),r+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let r=Kt(this.valueDec,7);if(r.byteLength===0)return this.error="Error during encoding SID value",Ge;let n=new Uint8Array(r.byteLength);if(!e){let o=new Uint8Array(r),i=r.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n.buffer}toString(){let e="";return this.isHexOnly?e=G.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};en.NAME="relativeSidBlock";var ao=class extends be{constructor({value:e=Sr,...r}={}){super(r),this.value=[],e&&this.fromString(e)}fromBER(e,r,n){let o=r;for(;n>0;){let i=new en;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e,r){let n=[];for(let o=0;o<this.value.length;o++){let i=this.value[o].toBER(e);if(i.byteLength===0)return this.error=this.value[o].error,Ge;n.push(i)}return ks(n)}fromString(e){this.value=[];let r=0,n=0,o="";do{n=e.indexOf(".",r),n===-1?o=e.substring(r):o=e.substring(r,n),r=n+1;let i=new en;if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let e="",r=!1;for(let n=0;n<this.value.length;n++){r=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),r&&(o=`{${o}}`),e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let r=0;r<this.value.length;r++)e.sidArray.push(this.value[r].toJSON());return e}};ao.NAME="RelativeObjectIdentifierValueBlock";var Dc,co=class extends de{constructor(e={}){super(e,ao),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Dc=co;L.RelativeObjectIdentifier=Dc;co.NAME="RelativeObjectIdentifier";var Fc,gt=class extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Fc=gt;L.Sequence=Fc;gt.NAME="SEQUENCE";var Mc,uo=class extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Mc=uo;L.Set=Mc;uo.NAME="SET";var lo=class extends xt(be){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Sr}toJSON(){return{...super.toJSON(),value:this.value}}};lo.NAME="StringValueBlock";var fo=class extends lo{};fo.NAME="SimpleStringValueBlock";var Ae=class extends jn{constructor({...e}={}){super(e,fo)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,G.BufferSourceConverter.toUint8Array(e))}fromString(e){let r=e.length,n=this.valueBlock.valueHexView=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=e.charCodeAt(o);this.valueBlock.value=e}};Ae.NAME="SIMPLE STRING";var ho=class extends Ae{fromBuffer(e){this.valueBlock.valueHexView=G.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=G.Convert.ToUtf8String(e)}catch(r){this.warnings.push(`Error during "decodeURIComponent": ${r}, using raw string`),this.valueBlock.value=G.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(G.Convert.FromUtf8String(e)),this.valueBlock.value=e}};ho.NAME="Utf8StringValueBlock";var Oc,mt=class extends ho{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Oc=mt;L.Utf8String=Oc;mt.NAME="UTF8String";var po=class extends Ae{fromBuffer(e){this.valueBlock.value=G.Convert.ToUtf16String(e),this.valueBlock.valueHexView=G.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(G.Convert.FromUtf16String(e))}};po.NAME="BmpStringValueBlock";var Hc,go=class extends po{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Hc=go;L.BmpString=Hc;go.NAME="BMPString";var mo=class extends Ae{fromBuffer(e){let r=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(r);for(let o=0;o<n.length;o+=4)n[o]=n[o+3],n[o+1]=n[o+2],n[o+2]=0,n[o+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(r))}fromString(e){let r=e.length,n=this.valueBlock.valueHexView=new Uint8Array(r*4);for(let o=0;o<r;o++){let i=Kt(e.charCodeAt(o),8),s=new Uint8Array(i);if(s.length>4)continue;let a=4-s.length;for(let c=s.length-1;c>=0;c--)n[o*4+c+a]=s[c]}this.valueBlock.value=e}};mo.NAME="UniversalStringValueBlock";var Pc,yo=class extends mo{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Pc=yo;L.UniversalString=Pc;yo.NAME="UniversalString";var Kc,xo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Kc=xo;L.NumericString=Kc;xo.NAME="NumericString";var $c,wo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};$c=wo;L.PrintableString=$c;wo.NAME="PrintableString";var qc,bo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};qc=bo;L.TeletexString=qc;bo.NAME="TeletexString";var zc,vo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};zc=vo;L.VideotexString=zc;vo.NAME="VideotexString";var Gc,Eo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Gc=Eo;L.IA5String=Gc;Eo.NAME="IA5String";var Zc,Bo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Zc=Bo;L.GraphicString=Zc;Bo.NAME="GraphicString";var Wc,tn=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Wc=tn;L.VisibleString=Wc;tn.NAME="VisibleString";var jc,Ao=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};jc=Ao;L.GeneralString=jc;Ao.NAME="GeneralString";var Yc,So=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Yc=So;L.CharacterString=Yc;So.NAME="CharacterString";var Jc,rn=class extends tn{constructor({value:e,valueDate:r,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let o=0;o<e.length;o++)this.valueBlock.valueHexView[o]=e.charCodeAt(o)}r&&(this.fromDate(r),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,G.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),r=new ArrayBuffer(e.length),n=new Uint8Array(r);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return r}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}let o=parseInt(n[1],10);o>=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){let r=new Array(7);return r[0]=Ue(this.year<2e3?this.year-1900:this.year-2e3,2),r[1]=Ue(this.month,2),r[2]=Ue(this.day,2),r[3]=Ue(this.hour,2),r[4]=Ue(this.minute,2),r[5]=Ue(this.second,2),r[6]="Z",r.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};Jc=rn;L.UTCTime=Jc;rn.NAME="UTCTime";var Xc,ko=class extends rn{constructor(e={}){var r;super(e),(r=this.millisecond)!==null&&r!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let r=!1,n="",o="",i=0,s,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),r=!0;else{let f=new Number(e[e.length-1]);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(r){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let f=1,h=n.indexOf("+"),v="";if(h===-1&&(h=n.indexOf("-"),f=-1),h!==-1){if(v=n.substring(h+1),n=n.substring(0,h),v.length!==2&&v.length!==4)throw new Error("Wrong input string for conversion");let E=parseInt(v.substring(0,2),10);if(isNaN(E.valueOf()))throw new Error("Wrong input string for conversion");if(a=f*E,v.length===4){if(E=parseInt(v.substring(2,4),10),isNaN(E.valueOf()))throw new Error("Wrong input string for conversion");c=f*E}}}let l=n.indexOf(".");if(l===-1&&(l=n.indexOf(",")),l!==-1){let f=new Number(`0${n.substring(l)}`);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");i=f.valueOf(),o=n.substring(0,l)}else o=n;switch(!0){case o.length===8:if(s=/(\d{4})(\d{2})(\d{2})/ig,l!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=60*i;this.minute=Math.floor(f),f=60*(f-this.minute),this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case o.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=60*i;this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case o.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=1e3*i;this.millisecond=Math.floor(f)}break;default:throw new Error("Wrong input string for conversion")}let u=s.exec(o);if(u===null)throw new Error("Wrong input string for conversion");for(let f=1;f<u.length;f++)switch(f){case 1:this.year=parseInt(u[f],10);break;case 2:this.month=parseInt(u[f],10);break;case 3:this.day=parseInt(u[f],10);break;case 4:this.hour=parseInt(u[f],10)+a;break;case 5:this.minute=parseInt(u[f],10)+c;break;case 6:this.second=parseInt(u[f],10);break;default:throw new Error("Wrong input string for conversion")}if(r===!1){let f=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=f.getUTCFullYear(),this.month=f.getUTCMonth(),this.day=f.getUTCDay(),this.hour=f.getUTCHours(),this.minute=f.getUTCMinutes(),this.second=f.getUTCSeconds(),this.millisecond=f.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){let r=[];return r.push(Ue(this.year,4)),r.push(Ue(this.month,2)),r.push(Ue(this.day,2)),r.push(Ue(this.hour,2)),r.push(Ue(this.minute,2)),r.push(Ue(this.second,2)),this.millisecond!==0&&(r.push("."),r.push(Ue(this.millisecond,3))),r.push("Z"),r.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Xc=ko;L.GeneralizedTime=Xc;ko.NAME="GeneralizedTime";var Qc,Co=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Qc=Co;L.DATE=Qc;Co.NAME="DATE";var eu,To=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};eu=To;L.TimeOfDay=eu;To.NAME="TimeOfDay";var tu,Io=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};tu=Io;L.DateTime=tu;Io.NAME="DateTime";var ru,No=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};ru=No;L.Duration=ru;No.NAME="Duration";var nu,Uo=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};nu=Uo;L.TIME=nu;Uo.NAME="TIME";function Se(t,e="utf8"){let r=Hn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.encoder.encode(t).substring(1)}var nn=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},_o=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var ou={get(t=globalThis){let e=t.crypto;if(e?.subtle==null)throw new _o("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return e}};var qt=ou;async function iu(t){let e=await qt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await p0(e);return{privateKey:r[0],publicKey:r[1]}}async function su(t,e){let r=await qt.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await qt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function au(t,e,r){let n=await qt.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return qt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,r instanceof Uint8Array?r:r.subarray())}async function p0(t){if(t.privateKey==null||t.publicKey==null)throw new xe("Private and public key are required");return Promise.all([qt.get().subtle.exportKey("jwk",t.privateKey),qt.get().subtle.exportKey("jwk",t.publicKey)])}function Is(t){if(t.kty!=="RSA")throw new xe("invalid key type");if(t.n==null)throw new xe("invalid key modulus");return Y(t.n,"base64url").length*8}var kr=class{type="RSA";_key;_raw;_multihash;constructor(e,r){this._key=e,this._multihash=r}get raw(){return this._raw==null&&(this._raw=on.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return ee.createV1(114,this._multihash)}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}verify(e,r){return au(this._key,r,e)}},sn=class{type="RSA";_key;_raw;publicKey;constructor(e,r){this._key=e,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=on.jwkToPkcs1(this._key)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}sign(e){return su(this._key,e)}};var Lo=8192,Ns=18;function cu(t){let{result:e}=Ts(t),r=e.valueBlock.value;return{n:tt(r[1]),e:tt(r[2]),d:tt(r[3]),p:tt(r[4]),q:tt(r[5]),dp:tt(r[6]),dq:tt(r[7]),qi:tt(r[8]),kty:"RSA",alg:"RS256"}}function g0(t){if(t.n==null||t.e==null||t.d==null||t.p==null||t.q==null||t.dp==null||t.dq==null||t.qi==null)throw new xe("JWK was missing components");let r=new gt({value:[new pe({value:0}),pe.fromBigInt(rt(Y(t.n,"base64url"))),pe.fromBigInt(rt(Y(t.e,"base64url"))),pe.fromBigInt(rt(Y(t.d,"base64url"))),pe.fromBigInt(rt(Y(t.p,"base64url"))),pe.fromBigInt(rt(Y(t.q,"base64url"))),pe.fromBigInt(rt(Y(t.dp,"base64url"))),pe.fromBigInt(rt(Y(t.dq,"base64url"))),pe.fromBigInt(rt(Y(t.qi,"base64url")))]}).toBER();return new Uint8Array(r,0,r.byteLength)}function uu(t){let{result:e}=Ts(t),r=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:tt(r[0]),e:tt(r[1])}}function Us(t){if(t.n==null||t.e==null)throw new xe("JWK was missing components");let r=new gt({value:[new gt({value:[new Ar({value:"1.2.840.113549.1.1.1"}),new Er]}),new Br({valueHex:new gt({value:[pe.fromBigInt(rt(Y(t.n,"base64url"))),pe.fromBigInt(rt(Y(t.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(r,0,r.byteLength)}function tt(t){let e=t.valueBlock.valueHexView;for(;e[0]===0;)e=e.subarray(1);return Se(e,"base64url")}function rt(t){let e=[];return t.forEach(function(r){let n=r.toString(16);n.length%2>0&&(n=`0${n}`),e.push(n)}),BigInt("0x"+e.join(""))}function lu(t){let e=cu(t);return fu(e)}function Rs(t){let e=uu(t);if(Is(e)>Lo)throw new sr("Key size is too large");let r=br(Qe.encode({Type:se.RSA,Data:t})),n=Pe(Ns,r);return new kr(e,n)}function fu(t){if(Is(t)>Lo)throw new xe("Key size is too large");let e=du(t),r=br(Qe.encode({Type:se.RSA,Data:Us(e.publicKey)})),n=Pe(Ns,r);return new sn(e.privateKey,new kr(e.publicKey,n))}async function hu(t){if(t>Lo)throw new xe("Key size is too large");let e=await iu(t),r=br(Qe.encode({Type:se.RSA,Data:Us(e.publicKey)})),n=Pe(Ns,r);return new sn(e.privateKey,new kr(e.publicKey,n))}function du(t){if(t==null)throw new xe("Missing key parameter");return{privateKey:t,publicKey:{kty:t.kty,n:t.n,e:t.e}}}var Vo=class extends gr{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Ta(e);let n=Hr(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return pr(this),this.iHash.update(e),this}digestInto(e){pr(this),dr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},_s=(t,e,r)=>new Vo(t,e).update(r).digest();_s.create=(t,e)=>new Vo(t,e);function pu(t){t.lowS!==void 0&&$e("lowS",t.lowS),t.prehash!==void 0&&$e("prehash",t.prehash)}function m0(t){let e=$r(t);Je(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:o}=e;if(r){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:y0,hexToBytes:x0}=Un,Ls=class extends Error{constructor(e=""){super(e)}},wt={Err:Ls,_tlv:{encode:(t,e)=>{let{Err:r}=wt;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=Wt(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Wt(o.length/2|128):"";return Wt(t)+i+o+e},decode(t,e){let{Err:r}=wt,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let l=e.subarray(n,n+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=wt;if(t<bt)throw new e("integer: negative integers are not allowed");let r=Wt(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=wt;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return y0(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=wt,o=typeof t=="string"?x0(t):t;yr(o);let{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:l,l:u}=n.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(t){let{_tlv:e,_int:r}=wt,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}},bt=BigInt(0),ue=BigInt(1),Qy=BigInt(2),gu=BigInt(3),ex=BigInt(4);function w0(t){let e=m0(t),{Fp:r}=e,n=Lt(e.n,e.nBitLength),o=e.toBytes||((y,d,A)=>{let T=d.toAffine();return ht(Uint8Array.from([4]),r.toBytes(T.x),r.toBytes(T.y))}),i=e.fromBytes||(y=>{let d=y.subarray(1),A=r.fromBytes(d.subarray(0,r.BYTES)),T=r.fromBytes(d.subarray(r.BYTES,2*r.BYTES));return{x:A,y:T}});function s(y){let{a:d,b:A}=e,T=r.sqr(y),x=r.mul(T,y);return r.add(r.add(x,r.mul(y,d)),A)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return Pr(y,ue,e.n)}function c(y){let{allowedPrivateKeyLengths:d,nByteLength:A,wrapPrivateKey:T,n:x}=e;if(d&&typeof y!="bigint"){if(Ut(y)&&(y=lt(y)),typeof y!="string"||!d.includes(y.length))throw new Error("invalid private key");y=y.padStart(A*2,"0")}let U;try{U=typeof y=="bigint"?y:ft(ne("private key",y,A))}catch{throw new Error("invalid private key, expected hex or "+A+" bytes, got "+typeof y)}return T&&(U=J(U,x)),Ie("private key",U,ue,x),U}function l(y){if(!(y instanceof h))throw new Error("ProjectivePoint expected")}let u=Jt((y,d)=>{let{px:A,py:T,pz:x}=y;if(r.eql(x,r.ONE))return{x:A,y:T};let U=y.is0();d==null&&(d=U?r.ONE:r.inv(x));let F=r.mul(A,d),D=r.mul(T,d),R=r.mul(x,d);if(U)return{x:r.ZERO,y:r.ZERO};if(!r.eql(R,r.ONE))throw new Error("invZ was invalid");return{x:F,y:D}}),f=Jt(y=>{if(y.is0()){if(e.allowInfinityPoint&&!r.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:d,y:A}=y.toAffine();if(!r.isValid(d)||!r.isValid(A))throw new Error("bad point: x or y not FE");let T=r.sqr(A),x=s(d);if(!r.eql(T,x))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,A,T){if(this.px=d,this.py=A,this.pz=T,d==null||!r.isValid(d))throw new Error("x required");if(A==null||!r.isValid(A))throw new Error("y required");if(T==null||!r.isValid(T))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:A,y:T}=d||{};if(!d||!r.isValid(A)||!r.isValid(T))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let x=U=>r.eql(U,r.ZERO);return x(A)&&x(T)?h.ZERO:new h(A,T,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let A=r.invertBatch(d.map(T=>T.pz));return d.map((T,x)=>T.toAffine(A[x])).map(h.fromAffine)}static fromHex(d){let A=h.fromAffine(i(ne("pointHex",d)));return A.assertValidity(),A}static fromPrivateKey(d){return h.BASE.multiply(c(d))}static msm(d,A){return Vn(h,n,d,A)}_setWindowSize(d){E.setWindowSize(this,d)}assertValidity(){f(this)}hasEvenY(){let{y:d}=this.toAffine();if(r.isOdd)return!r.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){l(d);let{px:A,py:T,pz:x}=this,{px:U,py:F,pz:D}=d,R=r.eql(r.mul(A,D),r.mul(U,x)),w=r.eql(r.mul(T,D),r.mul(F,x));return R&&w}negate(){return new h(this.px,r.neg(this.py),this.pz)}double(){let{a:d,b:A}=e,T=r.mul(A,gu),{px:x,py:U,pz:F}=this,D=r.ZERO,R=r.ZERO,w=r.ZERO,b=r.mul(x,x),M=r.mul(U,U),_=r.mul(F,F),I=r.mul(x,U);return I=r.add(I,I),w=r.mul(x,F),w=r.add(w,w),D=r.mul(d,w),R=r.mul(T,_),R=r.add(D,R),D=r.sub(M,R),R=r.add(M,R),R=r.mul(D,R),D=r.mul(I,D),w=r.mul(T,w),_=r.mul(d,_),I=r.sub(b,_),I=r.mul(d,I),I=r.add(I,w),w=r.add(b,b),b=r.add(w,b),b=r.add(b,_),b=r.mul(b,I),R=r.add(R,b),_=r.mul(U,F),_=r.add(_,_),b=r.mul(_,I),D=r.sub(D,b),w=r.mul(_,M),w=r.add(w,w),w=r.add(w,w),new h(D,R,w)}add(d){l(d);let{px:A,py:T,pz:x}=this,{px:U,py:F,pz:D}=d,R=r.ZERO,w=r.ZERO,b=r.ZERO,M=e.a,_=r.mul(e.b,gu),I=r.mul(A,U),K=r.mul(T,F),S=r.mul(x,D),k=r.add(A,T),m=r.add(U,F);k=r.mul(k,m),m=r.add(I,K),k=r.sub(k,m),m=r.add(A,x);let p=r.add(U,D);return m=r.mul(m,p),p=r.add(I,S),m=r.sub(m,p),p=r.add(T,x),R=r.add(F,D),p=r.mul(p,R),R=r.add(K,S),p=r.sub(p,R),b=r.mul(M,m),R=r.mul(_,S),b=r.add(R,b),R=r.sub(K,b),b=r.add(K,b),w=r.mul(R,b),K=r.add(I,I),K=r.add(K,I),S=r.mul(M,S),m=r.mul(_,m),K=r.add(K,S),S=r.sub(I,S),S=r.mul(M,S),m=r.add(m,S),I=r.mul(K,m),w=r.add(w,I),I=r.mul(p,m),R=r.mul(k,R),R=r.sub(R,I),I=r.mul(k,K),b=r.mul(p,b),b=r.add(b,I),new h(R,w,b)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return E.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){let{endo:A,n:T}=e;Ie("scalar",d,bt,T);let x=h.ZERO;if(d===bt)return x;if(this.is0()||d===ue)return this;if(!A||E.hasPrecomputes(this))return E.wNAFCachedUnsafe(this,d,h.normalizeZ);let{k1neg:U,k1:F,k2neg:D,k2:R}=A.splitScalar(d),w=x,b=x,M=this;for(;F>bt||R>bt;)F&ue&&(w=w.add(M)),R&ue&&(b=b.add(M)),M=M.double(),F>>=ue,R>>=ue;return U&&(w=w.negate()),D&&(b=b.negate()),b=new h(r.mul(b.px,A.beta),b.py,b.pz),w.add(b)}multiply(d){let{endo:A,n:T}=e;Ie("scalar",d,ue,T);let x,U;if(A){let{k1neg:F,k1:D,k2neg:R,k2:w}=A.splitScalar(d),{p:b,f:M}=this.wNAF(D),{p:_,f:I}=this.wNAF(w);b=E.constTimeNegate(F,b),_=E.constTimeNegate(R,_),_=new h(r.mul(_.px,A.beta),_.py,_.pz),x=b.add(_),U=M.add(I)}else{let{p:F,f:D}=this.wNAF(d);x=F,U=D}return h.normalizeZ([x,U])[0]}multiplyAndAddUnsafe(d,A,T){let x=h.BASE,U=(D,R)=>R===bt||R===ue||!D.equals(x)?D.multiplyUnsafe(R):D.multiply(R),F=U(this,A).add(U(d,T));return F.is0()?void 0:F}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:A}=e;if(d===ue)return!0;if(A)return A(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:A}=e;return d===ue?this:A?A(h,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return $e("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return $e("isCompressed",d),lt(this.toRawBytes(d))}}h.BASE=new h(e.Gx,e.Gy,r.ONE),h.ZERO=new h(r.ZERO,r.ONE,r.ZERO);let v=e.nBitLength,E=Ln(h,e.endo?Math.ceil(v/2):v);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function b0(t){let e=$r(t);return Je(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function mu(t){let e=b0(t),{Fp:r,n}=e,o=r.BYTES+1,i=2*r.BYTES+1;function s(S){return J(S,n)}function a(S){return Rn(S,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=w0({...e,toBytes(S,k,m){let p=k.toAffine(),B=r.toBytes(p.x),N=ht;return $e("isCompressed",m),m?N(Uint8Array.from([k.hasEvenY()?2:3]),B):N(Uint8Array.from([4]),B,r.toBytes(p.y))},fromBytes(S){let k=S.length,m=S[0],p=S.subarray(1);if(k===o&&(m===2||m===3)){let B=ft(p);if(!Pr(B,ue,r.ORDER))throw new Error("Point is not on curve");let N=u(B),O;try{O=r.sqrt(N)}catch(Z){let $=Z instanceof Error?": "+Z.message:"";throw new Error("Point is not on curve"+$)}let H=(O&ue)===ue;return(m&1)===1!==H&&(O=r.neg(O)),{x:B,y:O}}else if(k===i&&m===4){let B=r.fromBytes(p.subarray(0,r.BYTES)),N=r.fromBytes(p.subarray(r.BYTES,2*r.BYTES));return{x:B,y:N}}else{let B=o,N=i;throw new Error("invalid Point, expected length of "+B+", or uncompressed "+N+", got "+k)}}}),h=S=>lt(_t(S,e.nByteLength));function v(S){let k=n>>ue;return S>k}function E(S){return v(S)?s(-S):S}let y=(S,k,m)=>ft(S.slice(k,m));class d{constructor(k,m,p){this.r=k,this.s=m,this.recovery=p,this.assertValidity()}static fromCompact(k){let m=e.nByteLength;return k=ne("compactSignature",k,m*2),new d(y(k,0,m),y(k,m,2*m))}static fromDER(k){let{r:m,s:p}=wt.toSig(ne("DER",k));return new d(m,p)}assertValidity(){Ie("r",this.r,ue,n),Ie("s",this.s,ue,n)}addRecoveryBit(k){return new d(this.r,this.s,k)}recoverPublicKey(k){let{r:m,s:p,recovery:B}=this,N=D(ne("msgHash",k));if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");let O=B===2||B===3?m+e.n:m;if(O>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let H=B&1?"03":"02",z=c.fromHex(H+h(O)),Z=a(O),$=s(-N*Z),j=s(p*Z),X=c.BASE.multiplyAndAddUnsafe(z,$,j);if(!X)throw new Error("point at infinify");return X.assertValidity(),X}hasHighS(){return v(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return jt(this.toDERHex())}toDERHex(){return wt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return jt(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let A={isValidPrivateKey(S){try{return l(S),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let S=qi(e.n);return Pa(e.randomBytes(S),e.n)},precompute(S=8,k=c.BASE){return k._setWindowSize(S),k.multiply(BigInt(3)),k}};function T(S,k=!0){return c.fromPrivateKey(S).toRawBytes(k)}function x(S){let k=Ut(S),m=typeof S=="string",p=(k||m)&&S.length;return k?p===o||p===i:m?p===2*o||p===2*i:S instanceof c}function U(S,k,m=!0){if(x(S))throw new Error("first arg must be private key");if(!x(k))throw new Error("second arg must be public key");return c.fromHex(k).multiply(l(S)).toRawBytes(m)}let F=e.bits2int||function(S){if(S.length>8192)throw new Error("input is too large");let k=ft(S),m=S.length*8-e.nBitLength;return m>0?k>>BigInt(m):k},D=e.bits2int_modN||function(S){return s(F(S))},R=Kr(e.nBitLength);function w(S){return Ie("num < 2^"+e.nBitLength,S,bt,R),_t(S,e.nByteLength)}function b(S,k,m=M){if(["recovered","canonical"].some(ce=>ce in m))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:B}=e,{lowS:N,prehash:O,extraEntropy:H}=m;N==null&&(N=!0),S=ne("msgHash",S),pu(m),O&&(S=ne("prehashed msgHash",p(S)));let z=D(S),Z=l(k),$=[w(Z),w(z)];if(H!=null&&H!==!1){let ce=H===!0?B(r.BYTES):H;$.push(ne("extraEntropy",ce))}let j=ht(...$),X=z;function ae(ce){let fe=F(ce);if(!f(fe))return;let ye=a(fe),Ce=c.BASE.multiply(fe).toAffine(),ve=s(Ce.x);if(ve===bt)return;let Ye=s(ye*s(X+ve*Z));if(Ye===bt)return;let it=(Ce.x===ve?0:2)|Number(Ce.y&ue),Lr=Ye;return N&&v(Ye)&&(Lr=E(Ye),it^=1),new d(ve,Lr,it)}return{seed:j,k2sig:ae}}let M={lowS:e.lowS,prehash:!1},_={lowS:e.lowS,prehash:!1};function I(S,k,m=M){let{seed:p,k2sig:B}=b(S,k,m),N=e;return Hi(N.hash.outputLen,N.nByteLength,N.hmac)(p,B)}c.BASE._setWindowSize(8);function K(S,k,m,p=_){let B=S;k=ne("msgHash",k),m=ne("publicKey",m);let{lowS:N,prehash:O,format:H}=p;if(pu(p),"strict"in p)throw new Error("options.strict was renamed to lowS");if(H!==void 0&&H!=="compact"&&H!=="der")throw new Error("format must be compact or der");let z=typeof B=="string"||Ut(B),Z=!z&&!H&&typeof B=="object"&&B!==null&&typeof B.r=="bigint"&&typeof B.s=="bigint";if(!z&&!Z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let $,j;try{if(Z&&($=new d(B.r,B.s)),z){try{H!=="compact"&&($=d.fromDER(B))}catch(it){if(!(it instanceof wt.Err))throw it}!$&&H!=="der"&&($=d.fromCompact(B))}j=c.fromHex(m)}catch{return!1}if(!$||N&&$.hasHighS())return!1;O&&(k=e.hash(k));let{r:X,s:ae}=$,ce=D(k),fe=a(ae),ye=s(ce*fe),Ce=s(X*fe),ve=c.BASE.multiplyAndAddUnsafe(j,ye,Ce)?.toAffine();return ve?s(ve.x)===X:!1}return{CURVE:e,getPublicKey:T,getSharedSecret:U,sign:I,verify:K,ProjectivePoint:c,Signature:d,utils:A}}function v0(t){return{hash:t,hmac:(e,...r)=>_s(t,e,_i(...r)),randomBytes:Cn}}function yu(t,e){let r=n=>mu({...t,...v0(n)});return{...r(e),create:r}}var bu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),xu=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),E0=BigInt(1),Vs=BigInt(2),wu=(t,e)=>(t+e/Vs)/e;function B0(t){let e=bu,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=t*t*t%e,u=l*l*t%e,f=re(u,r,e)*u%e,h=re(f,r,e)*u%e,v=re(h,Vs,e)*l%e,E=re(v,o,e)*v%e,y=re(E,i,e)*E%e,d=re(y,a,e)*y%e,A=re(d,c,e)*d%e,T=re(A,a,e)*y%e,x=re(T,r,e)*u%e,U=re(x,s,e)*E%e,F=re(U,n,e)*l%e,D=re(F,Vs,e);if(!Ds.eql(Ds.sqr(D),t))throw new Error("Cannot find square root");return D}var Ds=Lt(bu,void 0,void 0,{sqrt:B0}),rr=yu({a:BigInt(0),b:BigInt(7),Fp:Ds,n:xu,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=xu,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-E0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=wu(i*t,e),c=wu(-n*t,e),l=J(t-a*r-c*o,e),u=J(-a*n-c*i,e),f=l>s,h=u>s;if(f&&(l=e-l),h&&(u=e-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:f,k1:l,k2neg:h,k2:u}}}},br),ux=BigInt(0);var lx=rr.ProjectivePoint;function an(t,e){e==null&&(e=t.reduce((o,i)=>o+i.length,0));let r=Xe(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}function vu(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}function Eu(t,e,r){let n=zr.digest(r instanceof Uint8Array?r:r.subarray());if(vu(n))return n.then(({digest:o})=>rr.verify(e,o,t)).catch(o=>{throw new nn(String(o))});try{return rr.verify(e,n.digest,t)}catch(o){throw new nn(String(o))}}var Do=class{type="secp256k1";raw;_key;constructor(e){this._key=Au(e),this.raw=Bu(this._key)}toMultihash(){return ct.digest(xr(this))}toCID(){return ee.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}verify(e,r){return Eu(this._key,r,e)}};function Fs(t){return new Do(t)}function Bu(t){return rr.ProjectivePoint.fromHex(t).toRawBytes(!0)}function Au(t){try{return rr.ProjectivePoint.fromHex(t),t}catch(e){throw new sr(String(e))}}function Su(t){let{Type:e,Data:r}=Qe.decode(t),n=r??new Uint8Array;switch(e){case se.RSA:return Rs(n);case se.Ed25519:return Ji(n);case se.secp256k1:return Fs(n);default:throw new cr}}function Fo(t){let{Type:e,Data:r}=Qe.decode(t.digest),n=r??new Uint8Array;switch(e){case se.Ed25519:return Ji(n);case se.secp256k1:return Fs(n);default:throw new cr}}function xr(t){return Qe.encode({Type:se[t.type],Data:t.raw})}var vt="/",ku=new TextEncoder().encode(vt),Mo=ku[0],cn=class t{_buf;constructor(e,r){if(typeof e=="string")this._buf=Y(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==Mo)throw new Error("Invalid key")}toString(e="utf8"){return Se(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new t(e.join(vt))}static random(){return new t(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new t(e):typeof e.uint8Array=="function"?new t(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=ku),this._buf[0]!==Mo){let e=new Uint8Array(this._buf.byteLength+1);e.fill(Mo,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Mo;)this._buf=this._buf.subarray(0,-1)}less(e){let r=this.list(),n=e.list();for(let o=0;o<r.length;o++){if(n.length<o+1)return!1;let i=r[o],s=n[o];if(i<s)return!0;if(i>s)return!1}return r.length<n.length}reverse(){return t.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(vt).slice(1)}type(){return A0(this.baseNamespace())}name(){return S0(this.baseNamespace())}instance(e){return new t(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(vt)||(e+=vt),e+=this.type(),new t(e)}parent(){let e=this.list();return e.length===1?new t(vt):new t(e.slice(0,-1).join(vt))}child(e){return this.toString()===vt?e:e.toString()===vt?this:new t(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return t.withNamespaces([...this.namespaces(),...k0(e.map(r=>r.namespaces()))])}};function A0(t){let e=t.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function S0(t){let e=t.split(":");return e[e.length-1]}function k0(t){return[].concat(...t)}var Ol=Vr(Oo(),1);var Ho=class extends Error{static name="SignatureCreationError";constructor(e="Record signature creation failed"){super(e),this.name="SignatureCreationError"}},Ze=class extends Error{static name="SignatureVerificationError";constructor(e="Record signature verification failed"){super(e),this.name="SignatureVerificationError"}},Po=class extends Error{static name="RecordExpiredError";constructor(e="Record has expired"){super(e),this.name="RecordExpiredError"}},nr=class extends Error{static name="UnsupportedValidityError";constructor(e="The validity type is unsupported"){super(e),this.name="UnsupportedValidityError"}},Ko=class extends Error{static name="RecordTooLargeError";constructor(e="The record is too large"){super(e),this.name="RecordTooLargeError"}},un=class extends Error{static name="InvalidValueError";constructor(e="Value must be a valid content path starting with /"){super(e),this.name="InvalidValueError"}},$o=class extends Error{static name="InvalidRecordDataError";constructor(e="Invalid record data"){super(e),this.name="InvalidRecordDataError"}},ln=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(e="Invalid embedded public key"){super(e),this.name="InvalidEmbeddedPublicKeyError"}};var ge;(function(t){let e;(function(o){o.EOL="EOL"})(e=t.ValidityType||(t.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),function(o){o.codec=()=>Wr(r)}(e=t.ValidityType||(t.ValidityType={}));let n;t.codec=()=>(n==null&&(n=Ot((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),t.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let l=o.uint32();switch(l>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=t.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(l&7);break}}}return a})),n),t.encode=o=>Mt(o,t.codec()),t.decode=(o,i)=>Ft(o,t.codec(),i)})(ge||(ge={}));var C0=["string","number","bigint","symbol"],T0=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Cu(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(C0.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(I0(t))return"Buffer";let r=N0(t);return r||"Object"}function I0(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function N0(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(T0.includes(e))return e}var g=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};g.uint=new g(0,"uint",!0);g.negint=new g(1,"negint",!0);g.bytes=new g(2,"bytes",!0);g.string=new g(3,"string",!0);g.array=new g(4,"array",!1);g.map=new g(5,"map",!1);g.tag=new g(6,"tag",!1);g.float=new g(7,"float",!0);g.false=new g(7,"false",!0);g.true=new g(7,"true",!0);g.null=new g(7,"null",!0);g.undefined=new g(7,"undefined",!0);g.break=new g(7,"break",!0);var V=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Cr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",U0=new TextDecoder,R0=new TextEncoder;function qo(t){return Cr&&globalThis.Buffer.isBuffer(t)}function Os(t){return t instanceof Uint8Array?qo(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var Uu=Cr?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):Iu(t,e,r):(t,e,r)=>r-e>64?U0.decode(t.subarray(e,r)):Iu(t,e,r),Ru=Cr?t=>t.length>64?globalThis.Buffer.from(t):Tu(t):t=>t.length>64?R0.encode(t):Tu(t),nt=t=>Uint8Array.from(t),Tr=Cr?(t,e,r)=>qo(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),_u=Cr?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Os(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let o of t)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Lu=Cr?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function Vu(t,e){if(qo(t)&&qo(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function Tu(t){let e=[],r=0;for(let n=0;n<t.length;n++){let o=t.charCodeAt(n);o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&n+1<t.length&&(t.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(t.charCodeAt(++n)&1023),e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128)}return e}function Iu(t,e,r){let n=[];for(;e<r;){let o=t[e],i=null,s=o>239?4:o>223?3:o>191?2:1;if(e+s<=r){let a,c,l,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=t[e+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=t[e+1],c=t[e+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=t[e+1],c=t[e+2],l=t[e+3],(a&192)===128&&(c&192)===128&&(l&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|l&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),e+=s}return _0(n)}var Nu=4096;function _0(t){let e=t.length;if(e<=Nu)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Nu));return r}var L0=256,fn=class{constructor(e=L0){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(e,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(r=Lu(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Tr(n,0,this.cursor)}else r=_u(this.chunks,this.cursor);return e&&this.reset(),r}};var P="CBOR decode error:",Hs="CBOR encode error:",hn=[];hn[23]=1;hn[24]=2;hn[25]=3;hn[26]=5;hn[27]=9;function Et(t,e,r){if(t.length-e<r)throw new Error(`${P} not enough data for type`)}var le=[24,256,65536,4294967296,BigInt("18446744073709551616")];function _e(t,e,r){Et(t,e,1);let n=t[e];if(r.strict===!0&&n<le[0])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return n}function Le(t,e,r){Et(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<le[1])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return n}function Ve(t,e,r){Et(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<le[2])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return n}function De(t,e,r){Et(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],o=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<le[3])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${P} integers outside of the safe integer range are not supported`)}function Du(t,e,r,n){return new V(g.uint,_e(t,e+1,n),2)}function Fu(t,e,r,n){return new V(g.uint,Le(t,e+1,n),3)}function Mu(t,e,r,n){return new V(g.uint,Ve(t,e+1,n),5)}function Ou(t,e,r,n){return new V(g.uint,De(t,e+1,n),9)}function Me(t,e){return me(t,0,e.value)}function me(t,e,r){if(r<le[0]){let n=Number(r);t.push([e|n])}else if(r<le[1]){let n=Number(r);t.push([e|24,n])}else if(r<le[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<le[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<le[4]){let o=[e|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,t.push(o)}else throw new Error(`${P} encountered BigInt larger than allowable range`)}}Me.encodedSize=function(e){return me.encodedSize(e.value)};me.encodedSize=function(e){return e<le[0]?1:e<le[1]?2:e<le[2]?3:e<le[3]?5:9};Me.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};function Hu(t,e,r,n){return new V(g.negint,-1-_e(t,e+1,n),2)}function Pu(t,e,r,n){return new V(g.negint,-1-Le(t,e+1,n),3)}function Ku(t,e,r,n){return new V(g.negint,-1-Ve(t,e+1,n),5)}var Ps=BigInt(-1),$u=BigInt(1);function qu(t,e,r,n){let o=De(t,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new V(g.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${P} integers outside of the safe integer range are not supported`);return new V(g.negint,Ps-BigInt(o),9)}function zo(t,e){let r=e.value,n=typeof r=="bigint"?r*Ps-$u:r*-1-1;me(t,e.type.majorEncoded,n)}zo.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*Ps-$u:r*-1-1;return n<le[0]?1:n<le[1]?2:n<le[2]?3:n<le[3]?5:9};zo.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};function dn(t,e,r,n){Et(t,e,r+n);let o=Tr(t,e+r,e+r+n);return new V(g.bytes,o,r+n)}function zu(t,e,r,n){return dn(t,e,1,r)}function Gu(t,e,r,n){return dn(t,e,2,_e(t,e+1,n))}function Zu(t,e,r,n){return dn(t,e,3,Le(t,e+1,n))}function Wu(t,e,r,n){return dn(t,e,5,Ve(t,e+1,n))}function ju(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer bytes lengths not supported`);return dn(t,e,9,o)}function Go(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===g.string?Ru(t.value):t.value),t.encodedBytes}function Ir(t,e){let r=Go(e);me(t,e.type.majorEncoded,r.length),t.push(r)}Ir.encodedSize=function(e){let r=Go(e);return me.encodedSize(r.length)+r.length};Ir.compareTokens=function(e,r){return D0(Go(e),Go(r))};function D0(t,e){return t.length<e.length?-1:t.length>e.length?1:Vu(t,e)}function pn(t,e,r,n,o){let i=r+n;Et(t,e,i);let s=new V(g.string,Uu(t,e+r,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Tr(t,e+r,e+i)),s}function Yu(t,e,r,n){return pn(t,e,1,r,n)}function Ju(t,e,r,n){return pn(t,e,2,_e(t,e+1,n),n)}function Xu(t,e,r,n){return pn(t,e,3,Le(t,e+1,n),n)}function Qu(t,e,r,n){return pn(t,e,5,Ve(t,e+1,n),n)}function el(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer string lengths not supported`);return pn(t,e,9,o,n)}var tl=Ir;function Nr(t,e,r,n){return new V(g.array,n,r)}function rl(t,e,r,n){return Nr(t,e,1,r)}function nl(t,e,r,n){return Nr(t,e,2,_e(t,e+1,n))}function ol(t,e,r,n){return Nr(t,e,3,Le(t,e+1,n))}function il(t,e,r,n){return Nr(t,e,5,Ve(t,e+1,n))}function sl(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer array lengths not supported`);return Nr(t,e,9,o)}function al(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${P} indefinite length items not allowed`);return Nr(t,e,1,1/0)}function Zo(t,e){me(t,g.array.majorEncoded,e.value)}Zo.compareTokens=Me.compareTokens;Zo.encodedSize=function(e){return me.encodedSize(e.value)};function Ur(t,e,r,n){return new V(g.map,n,r)}function cl(t,e,r,n){return Ur(t,e,1,r)}function ul(t,e,r,n){return Ur(t,e,2,_e(t,e+1,n))}function ll(t,e,r,n){return Ur(t,e,3,Le(t,e+1,n))}function fl(t,e,r,n){return Ur(t,e,5,Ve(t,e+1,n))}function hl(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer map lengths not supported`);return Ur(t,e,9,o)}function dl(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${P} indefinite length items not allowed`);return Ur(t,e,1,1/0)}function Wo(t,e){me(t,g.map.majorEncoded,e.value)}Wo.compareTokens=Me.compareTokens;Wo.encodedSize=function(e){return me.encodedSize(e.value)};function pl(t,e,r,n){return new V(g.tag,r,1)}function gl(t,e,r,n){return new V(g.tag,_e(t,e+1,n),2)}function ml(t,e,r,n){return new V(g.tag,Le(t,e+1,n),3)}function yl(t,e,r,n){return new V(g.tag,Ve(t,e+1,n),5)}function xl(t,e,r,n){return new V(g.tag,De(t,e+1,n),9)}function jo(t,e){me(t,g.tag.majorEncoded,e.value)}jo.compareTokens=Me.compareTokens;jo.encodedSize=function(e){return me.encodedSize(e.value)};var K0=20,$0=21,q0=22,z0=23;function wl(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${P} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new V(g.null,null,1):new V(g.undefined,void 0,1)}function bl(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${P} indefinite length items not allowed`);return new V(g.break,void 0,1)}function Ks(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${P} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${P} Infinity values are not supported`)}return new V(g.float,t,e)}function vl(t,e,r,n){return Ks($s(t,e+1),3,n)}function El(t,e,r,n){return Ks(qs(t,e+1),5,n)}function Bl(t,e,r,n){return Ks(Cl(t,e+1),9,n)}function Yo(t,e,r){let n=e.value;if(n===!1)t.push([g.float.majorEncoded|K0]);else if(n===!0)t.push([g.float.majorEncoded|$0]);else if(n===null)t.push([g.float.majorEncoded|q0]);else if(n===void 0)t.push([g.float.majorEncoded|z0]);else{let o,i=!1;(!r||r.float64!==!0)&&(Sl(n),o=$s(We,1),n===o||Number.isNaN(n)?(We[0]=249,t.push(We.slice(0,3)),i=!0):(kl(n),o=qs(We,1),n===o&&(We[0]=250,t.push(We.slice(0,5)),i=!0))),i||(G0(n),o=Cl(We,1),We[0]=251,t.push(We.slice(0,9)))}}Yo.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Sl(n);let o=$s(We,1);if(n===o||Number.isNaN(n))return 3;if(kl(n),o=qs(We,1),n===o)return 5}return 9};var Al=new ArrayBuffer(9),Oe=new DataView(Al,1),We=new Uint8Array(Al,0);function Sl(t){if(t===1/0)Oe.setUint16(0,31744,!1);else if(t===-1/0)Oe.setUint16(0,64512,!1);else if(Number.isNaN(t))Oe.setUint16(0,32256,!1);else{Oe.setFloat32(0,t);let e=Oe.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)Oe.setUint16(0,31744,!1);else if(r===0)Oe.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Oe.setUint16(0,0):o<-14?Oe.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):Oe.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function $s(t,e){if(t.length-e<2)throw new Error(`${P} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function kl(t){Oe.setFloat32(0,t,!1)}function qs(t,e){if(t.length-e<4)throw new Error(`${P} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function G0(t){Oe.setFloat64(0,t,!1)}function Cl(t,e){if(t.length-e<8)throw new Error(`${P} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}Yo.compareTokens=Me.compareTokens;function W(t,e,r){throw new Error(`${P} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function Jo(t){return()=>{throw new Error(`${P} ${t}`)}}var C=[];for(let t=0;t<=23;t++)C[t]=W;C[24]=Du;C[25]=Fu;C[26]=Mu;C[27]=Ou;C[28]=W;C[29]=W;C[30]=W;C[31]=W;for(let t=32;t<=55;t++)C[t]=W;C[56]=Hu;C[57]=Pu;C[58]=Ku;C[59]=qu;C[60]=W;C[61]=W;C[62]=W;C[63]=W;for(let t=64;t<=87;t++)C[t]=zu;C[88]=Gu;C[89]=Zu;C[90]=Wu;C[91]=ju;C[92]=W;C[93]=W;C[94]=W;C[95]=Jo("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)C[t]=Yu;C[120]=Ju;C[121]=Xu;C[122]=Qu;C[123]=el;C[124]=W;C[125]=W;C[126]=W;C[127]=Jo("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)C[t]=rl;C[152]=nl;C[153]=ol;C[154]=il;C[155]=sl;C[156]=W;C[157]=W;C[158]=W;C[159]=al;for(let t=160;t<=183;t++)C[t]=cl;C[184]=ul;C[185]=ll;C[186]=fl;C[187]=hl;C[188]=W;C[189]=W;C[190]=W;C[191]=dl;for(let t=192;t<=215;t++)C[t]=pl;C[216]=gl;C[217]=ml;C[218]=yl;C[219]=xl;C[220]=W;C[221]=W;C[222]=W;C[223]=W;for(let t=224;t<=243;t++)C[t]=Jo("simple values are not supported");C[244]=W;C[245]=W;C[246]=W;C[247]=wl;C[248]=Jo("simple values are not supported");C[249]=vl;C[250]=El;C[251]=Bl;C[252]=W;C[253]=W;C[254]=W;C[255]=bl;var je=[];for(let t=0;t<24;t++)je[t]=new V(g.uint,t,1);for(let t=-1;t>=-24;t--)je[31-t]=new V(g.negint,t,1);je[64]=new V(g.bytes,new Uint8Array(0),1);je[96]=new V(g.string,"",1);je[128]=new V(g.array,0,1);je[160]=new V(g.map,0,1);je[244]=new V(g.false,!1,1);je[245]=new V(g.true,!0,1);je[246]=new V(g.null,null,1);function Tl(t){switch(t.type){case g.false:return nt([244]);case g.true:return nt([245]);case g.null:return nt([246]);case g.bytes:return t.value.length?void 0:nt([64]);case g.string:return t.value===""?nt([96]):void 0;case g.array:return t.value===0?nt([128]):void 0;case g.map:return t.value===0?nt([160]):void 0;case g.uint:return t.value<24?nt([Number(t.value)]):void 0;case g.negint:if(t.value>=-24)return nt([31-Number(t.value)])}}var W0={float64:!1,mapSorter:J0,quickEncodeToken:Tl};function j0(){let t=[];return t[g.uint.major]=Me,t[g.negint.major]=zo,t[g.bytes.major]=Ir,t[g.string.major]=tl,t[g.array.major]=Zo,t[g.map.major]=Wo,t[g.tag.major]=jo,t[g.float.major]=Yo,t}var Il=j0(),zs=new fn,Qo=class t{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${Hs} object contains circular references`);return new t(r,e)}},zt={null:new V(g.null,null),undefined:new V(g.undefined,void 0),true:new V(g.true,!0),false:new V(g.false,!1),emptyArray:new V(g.array,0),emptyMap:new V(g.map,0)},Gt={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new V(g.float,t):t>=0?new V(g.uint,t):new V(g.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new V(g.uint,t):new V(g.negint,t)},Uint8Array(t,e,r,n){return new V(g.bytes,t)},string(t,e,r,n){return new V(g.string,t)},boolean(t,e,r,n){return t?zt.true:zt.false},null(t,e,r,n){return zt.null},undefined(t,e,r,n){return zt.undefined},ArrayBuffer(t,e,r,n){return new V(g.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new V(g.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[zt.emptyArray,new V(g.break)]:zt.emptyArray;n=Qo.createCheck(n,t);let o=[],i=0;for(let s of t)o[i++]=Xo(s,r,n);return r.addBreakTokens?[new V(g.array,t.length),o,new V(g.break)]:[new V(g.array,t.length),o]},Object(t,e,r,n){let o=e!=="Object",i=o?t.keys():Object.keys(t),s=o?t.size:i.length;if(!s)return r.addBreakTokens===!0?[zt.emptyMap,new V(g.break)]:zt.emptyMap;n=Qo.createCheck(n,t);let a=[],c=0;for(let l of i)a[c++]=[Xo(l,r,n),Xo(o?t.get(l):t[l],r,n)];return Y0(a,r),r.addBreakTokens?[new V(g.map,s),a,new V(g.break)]:[new V(g.map,s),a]}};Gt.Map=Gt.Object;Gt.Buffer=Gt.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Gt[`${t}Array`]=Gt.DataView;function Xo(t,e={},r){let n=Cu(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||Gt[n];if(typeof o=="function"){let s=o(t,n,e,r);if(s!=null)return s}let i=Gt[n];if(!i)throw new Error(`${Hs} unsupported type: ${n}`);return i(t,n,e,r)}function Y0(t,e){e.mapSorter&&t.sort(e.mapSorter)}function J0(t,e){let r=Array.isArray(t[0])?t[0][0]:t[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=Il[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Nl(t,e,r,n){if(Array.isArray(e))for(let o of e)Nl(t,o,r,n);else r[e.type.major](t,e,n)}function X0(t,e,r){let n=Xo(t,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=e[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,r),a=new fn(s);if(i(a,n,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Os(a.chunks[0])}}return zs.reset(),Nl(zs,n,e,r),zs.toBytes(!0)}function Gs(t,e){return e=Object.assign({},W0,e),X0(t,Il,e)}var Q0={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},ei=class{constructor(e,r={}){this._pos=0,this.data=e,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],r=je[e];if(r===void 0){let n=C[e];if(!n)throw new Error(`${P} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},gn=Symbol.for("DONE"),ti=Symbol.for("BREAK");function ep(t,e,r){let n=[];for(let o=0;o<t.value;o++){let i=Rr(e,r);if(i===ti){if(t.value===1/0)break;throw new Error(`${P} got unexpected break to lengthed array`)}if(i===gn)throw new Error(`${P} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=i}return n}function tp(t,e,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<t.value;s++){let a=Rr(e,r);if(a===ti){if(t.value===1/0)break;throw new Error(`${P} got unexpected break to lengthed map`)}if(a===gn)throw new Error(`${P} found map but not enough entries (got ${s} [no key], expected ${t.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${P} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${P} found repeat map key "${a}"`);let c=Rr(e,r);if(c===gn)throw new Error(`${P} found map but not enough entries (got ${s} [no value], expected ${t.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function Rr(t,e){if(t.done())return gn;let r=t.next();if(r.type===g.break)return ti;if(r.type.terminal)return r.value;if(r.type===g.array)return ep(r,t,e);if(r.type===g.map)return tp(r,t,e);if(r.type===g.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=Rr(t,e);return e.tags[r.value](n)}throw new Error(`${P} tag not supported (${r.value})`)}throw new Error("unsupported")}function Ul(t,e){if(!(t instanceof Uint8Array))throw new Error(`${P} data to decode must be a Uint8Array`);e=Object.assign({},Q0,e);let r=e.tokenizer||new ei(t,e),n=Rr(r,e);if(n===gn)throw new Error(`${P} did not find any content to decode`);if(n===ti)throw new Error(`${P} got unexpected break`);return[n,t.subarray(r.pos())]}function Zs(t,e){let[r,n]=Ul(t,e);if(n.length>0)throw new Error(`${P} too many terminals, data makes no sense`);return r}var np=Ct("ipns:utils"),Rl=Y("/ipns/"),op=114,ip=0,sp=18;function _l(t){let e;if(t.pubKey!=null)try{e=Su(t.pubKey)}catch(r){throw np.error(r),r}if(e!=null)return e}function Ll(t,e,r){let n=Y(e);return an([t,r,n])}function ni(t){let e=Y("ipns-signature:");return an([e,t])}function Ws(t){return"signatureV1"in t?ge.encode({value:Y(t.value),signatureV1:t.signatureV1,validityType:t.validityType,validity:Y(t.validity),sequence:t.sequence,ttl:t.ttl,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data}):ge.encode({pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data})}function ot(t){let e=ge.decode(t);if(e.sequence!=null&&(e.sequence=BigInt(e.sequence)),e.ttl!=null&&(e.ttl=BigInt(e.ttl)),e.signatureV2==null||e.data==null)throw new Ze("Missing data or signatureV2");let r=Fl(e.data),n=ap(r.Value),o=Se(r.Validity);if(e.value!=null&&e.signatureV1!=null)return cp(e),{value:n,validityType:ge.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:e.pubKey,signatureV1:e.signatureV1,signatureV2:e.signatureV2,data:e.data};if(e.signatureV2!=null)return{value:n,validityType:ge.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function _r(t){return an([Rl,t.bytes])}function Vl(t){let e=at(t.slice(Rl.length));if(!ri(e,ip)&&!ri(e,sp))throw new ar("Multihash in IPNS key was not identity or sha2-256");return e}function Dl(t,e,r,n,o){let i;if(e===ge.ValidityType.EOL)i=0;else throw new nr("The validity type is unsupported");return Gs({Value:t,Validity:r,ValidityType:i,Sequence:n,TTL:o})}function Fl(t){let e=Zs(t);if(e.ValidityType===0)e.ValidityType=ge.ValidityType.EOL;else throw new nr("The validity type is unsupported");return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e}function ap(t){let e=Se(t).trim();if(e.startsWith("/"))return e;try{return`/ipfs/${ee.decode(t).toV1().toString()}`}catch{}try{return`/ipfs/${ee.parse(e).toV1().toString()}`}catch{}throw new un("Value must be a valid content path starting with /")}function Ml(t){if(t!=null){let e=fp(t);if(e!=null)return e.code===op?`/ipns/${e.toString(He)}`:`/ipfs/${e.toV1().toString()}`;if(up(t))return`/ipns/${He.encode(t.bytes)}`;let r=t.toString().trim();if(r.startsWith("/")&&r.length>1)return r}throw new un("Value must be a valid content path starting with /")}function cp(t){if(t.data==null)throw new $o("Record data is missing");let e=Fl(t.data);if(!he(e.Value,t.value??new Uint8Array(0)))throw new Ze('Field "value" did not match between protobuf and CBOR');if(!he(e.Validity,t.validity??new Uint8Array(0)))throw new Ze('Field "validity" did not match between protobuf and CBOR');if(e.ValidityType!==t.validityType)throw new Ze('Field "validityType" did not match between protobuf and CBOR');if(e.Sequence!==t.sequence)throw new Ze('Field "sequence" did not match between protobuf and CBOR');if(e.TTL!==t.ttl)throw new Ze('Field "ttl" did not match between protobuf and CBOR')}function up(t){return t.bytes instanceof Uint8Array}function lp(t){return typeof t?.toCID=="function"}function fp(t){if(lp(t))return t.toCID();try{return ee.parse(t)}catch{}return ee.asCID(t)}function ri(t,e){return t.code===e}var hp=Ct("ipns"),Hl=60*60*1e9,dp="/ipns/",Bb=dp.length,Pl={v1Compatible:!0,ttlNs:Hl};async function Kl(t,e,r,n,o=Pl){let i=new Ol.default(Date.now()+Number(n)),s=ge.ValidityType.EOL,a=BigInt(o.ttlNs??Hl);return pp(t,e,r,s,i.toString(),a,o)}var pp=async(t,e,r,n,o,i,s=Pl)=>{r=BigInt(r);let a=Y(o),c=Ml(e),l=Y(c),u=Dl(l,n,a,r,i),f=ni(u),h=await t.sign(f),v;if(t.type==="RSA"&&(v=xr(t.publicKey)),s.v1Compatible===!0){let E=await gp(t,l,n,a),y={value:c,signatureV1:E,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:h,data:u};return v!=null&&(y.pubKey=v),y}else{let E={value:c,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:h,data:u};return v!=null&&(E.pubKey=v),E}},gp=async(t,e,r,n)=>{try{let o=Ll(e,r,n);return await t.sign(o)}catch(o){throw hp.error("record signature creation failed",o),new Ho("Record signature creation failed")}};var js=Vr(Oo(),1);function oi(t,e){let r=e.map((n,o)=>({record:ot(n),index:o}));return r.sort((n,o)=>{let i=n.record.sequence,s=o.record.sequence;if(i>s)return-1;if(i<s)return 1;if(n.record.validityType===ge.ValidityType.EOL&&o.record.validityType===ge.ValidityType.EOL){let a=js.default.fromString(n.record.validity).toDate(),c=js.default.fromString(o.record.validity).toDate();if(a.getTime()>c.getTime())return-1;if(a.getTime()<c.getTime())return 1}return 0}),r[0].index}var $l=Vr(Oo(),1);var ii=Ct("ipns:validator"),mp=1024*10,yp=async(t,e)=>{let r=ot(e),n;try{let o=ni(r.data);n=await t.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw ii.error("record signature verification failed"),new Ze("Record signature verification failed");if(r.validityType===ge.ValidityType.EOL){if($l.default.fromString(r.validity).toDate().getTime()<Date.now())throw ii.error("record has expired"),new Po("record has expired")}else if(r.validityType!=null)throw ii.error("the validity type is unsupported"),new nr("The validity type is unsupported");ii("ipns record for %s is valid",r.value)};async function si(t,e){if(e.byteLength>mp)throw new Ko("The record is too large");let r=Vl(t),n;ri(r,0)&&(n=Fo(r));let o=ot(e),i=_l(o)??n;if(i==null)throw new ln("Could not extract public key from IPNS record or routing key");let s=_r(i.toMultihash());if(!he(t,s))throw new ln("Embedded public key did not match routing key");await yp(i,e)}var ke=class extends Event{type;detail;constructor(e,r){super(e),this.type=e,this.detail=r}};var ql=Symbol.for("nodejs.util.inspect.custom"),xp=114,mn=class{type;multihash;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[wi]=!0;toString(){return this.string==null&&(this.string=Q.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ee.createV1(xp,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return he(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return he(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[ql](){return`PeerId(${this.toString()})`}},ai=class extends mn{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},ci=class extends mn{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},ui=class extends mn{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},wp=2336,yn=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=ct.digest(Y(this.url))}[ql](){return`PeerId(${this.url})`}[wi]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ee.createV1(wp,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=Se(e)),e.toString()===this.toString())}};var bp=114,zl=2336;function Gl(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=at(Q.decode(`z${t}`));else{if(e==null)throw new xe('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=at(e.decode(t))}return Zl(r)}function Zl(t){if(Ep(t))return new ai({multihash:t});if(vp(t))try{let e=Fo(t);if(e.type==="Ed25519")return new ci({multihash:t,publicKey:e});if(e.type==="secp256k1")return new ui({multihash:t,publicKey:e})}catch{let r=Se(t.digest);return new yn(new URL(r))}throw new ar("Supplied PeerID Multihash is invalid")}function Wl(t){if(t?.multihash==null||t.version==null||t.version===1&&t.code!==bp&&t.code!==zl)throw new bn("Supplied PeerID CID is invalid");if(t.code===zl){let e=Se(t.multihash.digest);return new yn(new URL(e))}return Zl(t.multihash)}function vp(t){return t.code===ct.code}function Ep(t){return t.code===zr.code}var Sp=Vr(Yl(),1);var Bt;(function(t){t[t.A=1]="A",t[t.CNAME=5]="CNAME",t[t.TXT=16]="TXT",t[t.AAAA=28]="AAAA"})(Bt||(Bt={}));var li=class extends Error{static name="DNSLinkNotFoundError";constructor(e="DNSLink not found"){super(e),this.name="DNSLinkNotFoundError"}},fi=class extends Error{static name="RecordsFailedValidationError";constructor(e="Records failed validation"){super(e),this.name="RecordsFailedValidationError"}},hi=class extends Error{static name="UnsupportedMultibasePrefixError";constructor(e="Unsupported multibase prefix"){super(e),this.name="UnsupportedMultibasePrefixError"}},di=class extends Error{static name="UnsupportedMultihashCodecError";constructor(e="Unsupported multihash codec"){super(e),this.name="UnsupportedMultihashCodecError"}},pi=class extends Error{static name="InvalidValueError";constructor(e="Invalid value"){super(e),this.name="InvalidValueError"}};var kp=32;async function Jl(t,e,r,n,o={}){if(e===0)throw new Error("recursion limit exceeded");n("query %s for TXT and CNAME records",t);let s=((await r.query(t,{...o,types:[Bt.TXT]}))?.Answer??[]).sort((l,u)=>l.data.localeCompare(u.data));n("found %d TXT records for %s",s.length,t);for(let l of s)try{let u=l.data;if(u.startsWith('"')&&u.endsWith('"')&&(u=u.substring(1,u.length-1)),!u.startsWith("dnslink="))continue;n("%s TXT %s",l.name,u),u=u.replace("dnslink=","");let[,f,h,...v]=u.split("/");if(f==="ipfs")try{return{value:`/ipfs/${ee.parse(h)}${v.length>0?`/${v.join("/")}`:""}`,answer:l}}catch{}else if(f==="ipns"){try{let E;return h.charAt(0)==="1"||h.charAt(0)==="Q"?E=Gl(h):E=Wl(ee.parse(h)),{value:`/ipns/${E}${v.length>0?`/${v.join("/")}`:""}`,answer:l}}catch{}return await gi(h,e-1,r,n,o)}else{if(f==="dnslink")return await gi(h,e-1,r,n,o);n('unknown protocol "%s" in DNSLink record for domain: %s',f,t);continue}}catch(u){n.error("could not parse DNS link record for domain %s, %s",t,l.data,u)}n("no DNSLink records found for %s, falling back to CNAME",t);let c=((await r.query(t,{...o,types:[Bt.CNAME]}))?.Answer??[]).sort((l,u)=>l.data.localeCompare(u.data));n("found %d CNAME records for %s",c.length,t);for(let l of c)try{return await gi(l.data,e-1,r,n,o)}catch(u){n.error("domain %s cname %s had no DNSLink records",t,l.data,u)}throw new li(`No DNSLink records found for domain: ${t}`)}async function gi(t,e,r,n,o={}){if(e===0)throw new Error("recursion limit exceeded");t.startsWith("_dnslink.")||(t=`_dnslink.${t}`);try{return await Jl(t,e,r,n,o)}catch(i){if(i.code!=="ENOTFOUND"&&i.code!=="ENODATA"&&i.name!=="DNSLinkNotFoundError"&&i.name!=="NotFoundError")throw i;return t.startsWith("_dnslink.")?t=t.replace("_dnslink.",""):t=`_dnslink.${t}`,Jl(t,e,r,n,o)}}async function Xl(t,e,r,n={}){return gi(t,n.maxRecursiveDepth??kp,e,r,n)}var Ys=class{routing;constructor(e){this.routing=e}async put(e,r,n={}){try{await this.routing.put(e,r,n)}catch(o){n.onProgress?.(new ke("ipns:routing:helia:error",o))}}async get(e,r={}){try{return await this.routing.get(e,r)}catch(n){r.onProgress?.(new ke("ipns:routing:helia:error",n))}throw new Error("Not found")}};function Ql(t){return new Ys(t)}var xn;(function(t){let e;t.codec=()=>(e==null&&(e=Ot((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.key!=null&&r.key.byteLength>0&&(n.uint32(10),n.bytes(r.key)),r.value!=null&&r.value.byteLength>0&&(n.uint32(18),n.bytes(r.value)),r.timeReceived!=null&&r.timeReceived!==""&&(n.uint32(42),n.string(r.timeReceived)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={key:Xi(0),value:Xi(0),timeReceived:""},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.key=r.bytes();break}case 2:{i.value=r.bytes();break}case 5:{i.timeReceived=r.string();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Mt(r,t.codec()),t.decode=(r,n)=>Ft(r,t.codec(),n)})(xn||(xn={}));function ef(t){let e=t.getUTCFullYear(),r=String(t.getUTCMonth()+1).padStart(2,"0"),n=String(t.getUTCDate()).padStart(2,"0"),o=String(t.getUTCHours()).padStart(2,"0"),i=String(t.getUTCMinutes()).padStart(2,"0"),s=String(t.getUTCSeconds()).padStart(2,"0"),a=t.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${e}-${r}-${n}T${o}:${i}:${s}.${c}Z`}function tf(t){let e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),r=String(t).trim().match(e);if(r==null)throw new Error("Invalid format");let n=parseInt(r[1],10),o=parseInt(r[2],10)-1,i=parseInt(r[3],10),s=parseInt(r[4],10),a=parseInt(r[5],10),c=parseInt(r[6],10),l=parseInt(r[7].slice(0,-6),10);return new Date(Date.UTC(n,o,i,s,a,c,l))}var ir=class t{key;value;timeReceived;constructor(e,r,n){if(!(e instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(r instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=e,this.value=r,this.timeReceived=n}serialize(){return xn.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:ef(this.timeReceived)}}static deserialize(e){let r=xn.decode(e);return new t(r.key,r.value,new Date(r.timeReceived))}static fromDeserialized(e){let r=tf(e.timeReceived);if(e.key==null)throw new Error("key missing from deserialized object");if(e.value==null)throw new Error("value missing from deserialized object");return new t(e.key,e.value,r)}};var rf;(function(t){t[t.SEND_QUERY=0]="SEND_QUERY",t[t.PEER_RESPONSE=1]="PEER_RESPONSE",t[t.FINAL_PEER=2]="FINAL_PEER",t[t.QUERY_ERROR=3]="QUERY_ERROR",t[t.PROVIDER=4]="PROVIDER",t[t.VALUE=5]="VALUE",t[t.ADD_PEER=6]="ADD_PEER",t[t.DIAL_PEER=7]="DIAL_PEER"})(rf||(rf={}));function mi(t){return new cn("/dht/record/"+Se(t,"base32"),!1)}function nf(t){return{async put(e,r,n={}){try{let o=mi(e);try{let s=await t.get(o),a=ir.deserialize(s);if(he(a.value,r))return}catch(s){if(s.name!=="NotFoundError")throw s}let i=new ir(e,r,new Date);n.onProgress?.(new ke("ipns:routing:datastore:put")),await t.put(o,i.serialize(),n)}catch(o){throw n.onProgress?.(new ke("ipns:routing:datastore:error",o)),o}},async get(e,r={}){try{let n=mi(e);r.onProgress?.(new ke("ipns:routing:datastore:get"));let o=await t.get(n,r),i=ir.deserialize(o);return{record:i.value,created:i.timeReceived}}catch(n){throw r.onProgress?.(new ke("ipns:routing:datastore:error",n)),n}},async has(e,r={}){let n=mi(e);return t.has(n,r)},async delete(e,r){let n=mi(e);return t.delete(n,r)}}}function Js(t,e){return t.code===e}var At=Ct("helia:ipns"),Np=60*1e3,ea=60*Np,Up=24*ea,Xs=23*ea,of=BigInt(ea)*1000000n,sf={[He.prefix]:He,[Q.prefix]:Q},Qs=class{routers;localStore;timeout;dns;log;constructor(e,r=[]){this.routers=[Ql(e.routing),...r],this.localStore=nf(e.datastore),this.dns=e.dns,this.log=e.logger.forComponent("helia:ipns")}async publish(e,r,n={}){try{let o=1n,i=_r(e.publicKey.toMultihash());if(await this.localStore.has(i,n)){let{record:l}=await this.localStore.get(i,n);o=ot(l).sequence+1n}let s=n.ttl!=null?BigInt(n.ttl)*1000000n:of,a=await Kl(e,r,o,n.lifetime??Up,{...n,ttlNs:s}),c=Ws(a);return await this.localStore.put(i,c,n),n.offline!==!0&&await Promise.all(this.routers.map(async l=>{await l.put(i,c,n)})),a}catch(o){throw n.onProgress?.(new ke("ipns:publish:error",o)),o}}async resolve(e,r={}){let n=ua(e)?e.toMultihash():e,o=_r(n),i=await this.#t(o,r);return{...await this.#e(i.value,r),record:i}}async resolveDNSLink(e,r={}){let n=await Xl(e,this.dns,this.log,r);return{...await this.#e(n.value,r),answer:n.answer}}republish(e={}){if(this.timeout!=null)throw new Error("Republish is already running");e.signal?.addEventListener("abort",()=>{clearTimeout(this.timeout)});async function r(){let n=Date.now();e.onProgress?.(new ke("ipns:republish:start"));let i=Date.now()-n,s=Xs-i;s<0&&(s=e.interval??Xs),setTimeout(()=>{r().catch(a=>{At.error("error republishing",a)})},s)}this.timeout=setTimeout(()=>{r().catch(n=>{At.error("error republishing",n)})},e.interval??Xs)}async#e(e,r={}){let n=e.split("/");try{let o=n[1];if(o==="ipns"){let i=n[2],s=i.substring(0,1),a;if(s==="1"||s==="Q")a=Q.decode(`z${i}`);else if(sf[s]!=null)a=sf[s].decode(i);else throw new hi(`Unsupported multibase prefix "${s}"`);let c;try{c=at(a)}catch{c=ee.decode(a).multihash}if(!Js(c,0)&&!Js(c,18))throw new di(`Unsupported multihash codec "${c.code}"`);let{cid:l}=await this.resolve(c,r),u=n.slice(3).join("/");return{cid:l,path:u}}else if(o==="ipfs"){let i=ee.parse(n[2]),s=n.slice(3).join("/");return{cid:i,path:s}}}catch(o){At.error("error parsing ipfs path",o)}throw At.error("invalid ipfs path %s",e),new pi("Invalid value")}async#t(e,r={}){let n=[];if(await this.localStore.has(e,r))if(At("record is present in the cache"),r.nocache!==!0)try{let{record:a,created:c}=await this.localStore.get(e,r);this.log("record retrieved from cache"),await si(e,a),this.log("record was valid");let l=ot(a),u=Number((l.ttl??of)/1000000n);if(c.getTime()+u>Date.now())return this.log("record TTL was valid"),l;if(r.offline===!0)return this.log("record TTL has been reached but we are resolving offline-only, returning record"),l;this.log("record TTL has been reached, searching routing for updates"),n.push(a)}catch(a){this.log("cached record was invalid",a),await this.localStore.delete(e,r)}else At("ignoring local cache due to nocache=true option");if(r.offline===!0)throw new Dr("Record was not present in the cache or has expired");At("did not have record locally");let i=0;if(await Promise.all(this.routers.map(async a=>{let c;try{c=await a.get(e,{...r,validate:!1})}catch(l){At.error("error finding IPNS record",l);return}try{await si(e,c),n.push(c)}catch(l){i++,At.error("error finding IPNS record",l)}})),n.length===0)throw i>0?new fi(`${i>1?`${i} records`:"Record"} found for routing key ${i>1?"were":"was"} invalid`):new Dr("Could not find record for routing key");let s=n[oi(e,n)];return await this.localStore.put(e,s,r),ot(s)}};function Rp(t,{routers:e=[]}={}){return new Qs(t,e)}return bf(_p);})();
|
|
2
|
+
"use strict";var HeliaIpns=(()=>{var mu=Object.create;var $r=Object.defineProperty;var yu=Object.getOwnPropertyDescriptor;var gu=Object.getOwnPropertyNames;var xu=Object.getPrototypeOf,wu=Object.prototype.hasOwnProperty;var zi=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),St=(e,t)=>{for(var r in t)$r(e,r,{get:t[r],enumerable:!0})},$i=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of gu(t))!wu.call(e,o)&&o!==r&&$r(e,o,{get:()=>t[o],enumerable:!(n=yu(t,o))||n.enumerable});return e};var Gr=(e,t,r)=>(r=e!=null?mu(xu(e)):{},$i(t||!e||!e.__esModule?$r(r,"default",{value:e,enumerable:!0}):r,e)),bu=e=>$i($r({},"__esModule",{value:!0}),e);var vn=zi((Qg,Bi)=>{var Jg=function(){typeof Bi<"u"&&(Bi.exports=y);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(x){var w=x-x%1;return w==0&&(x<0||x===0&&1/x!=1/0)?-0:w},u=y.prototype,l=(y.fromDate=function(x){return new y(+x)},y.fromInt64BE=D(0,1,2,3,0,4),y.fromInt64LE=D(3,2,1,0,4,0),y.fromString=function(L){var w,K=new y,L=(L+="").replace(/^\s*[+\-]?\d+/,function(V){var V=+V,E=1970+(V-1970)%400;return K.year=V-E,E}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(_,V,E){return V<0&&(E*=-1),w=6e4*(60*+V+ +E),""}).replace(/\.\d+$/,function(_){return K.nano=+(_+c).substr(1,9),""}).split(/\D+/);if(1<L.length?L[1]--:L[1]=0,K.time=w=Date.UTC.apply(Date,L)-(w||0),isNaN(w))throw new TypeError("Invalid Date");return h(K)},y.fromTimeT=function(x){return U(x,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(x){return this.nano+=+x||0,this},u.getNano=function(){var x=h(this);return(x.time%1e3*a+ +x.nano+1e9)%1e9},u.getTimeT=function(){var w=h(this),x=Math.floor(w.time/1e3),w=w.year;return w&&(x+=w*r*e/t),x},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return A(h(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(x){var w=this,K=w.toDate(),L={H:function(){return k(K.getUTCHours())},L:function(){return R(K.getUTCMilliseconds(),3)},M:function(){return k(K.getUTCMinutes())},N:function(){return R(w.getNano(),9)},S:function(){return k(K.getUTCSeconds())},Y:function(){var _=w.getYear();return 999999<_?"+"+_:9999<_?"+"+R(_,6):0<=_?R(_,4):-999999<=_?"-"+R(-_,6):_},a:function(){return T[K.getUTCDay()]},b:function(){return d[K.getUTCMonth()]},d:function(){return k(K.getUTCDate())},e:function(){return function(_){return(9<_?"":" ")+(0|_)}(K.getUTCDate())},m:function(){return k(K.getUTCMonth()+1)}};return function _(V){return V.replace(/%./g,function(E){var B=E[1],S=v[B],B=L[B];return S?_(S):B?B():E})}(x||l)},u.writeInt64BE=g(0,1,2,3,0,4),u.writeInt64LE=g(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),d=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],T=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],v={"%":"%",F:"%Y-%m-%d",n:`
|
|
3
|
+
`,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return y;function y(x,w,K){var L=this;if(!(L instanceof y))return new y(x,w,K);L.time=+x||0,L.nano=+w||0,L.year=+K||0,h(L)}function h(x){var w,K,L,_=x.year,V=x.time,E=x.nano,S=((E<0||a<=E)&&(E-=(K=Math.floor(E/a))*a,V+=K,K=1),_%t);return(V<-i||i<V||S)&&((w=f(V/o))&&(_+=w*t,V-=w*o),(L=A(V)).setUTCFullYear(S+L.getUTCFullYear()),L=(V=+L)+(w=f((_-=S)/t))*o,w&&-i<=L&&L<=i&&(_-=w*t,V=L),K=1),K&&(x.year=_,x.time=V,x.nano=E),x}function A(x){var w=new Date(0);return w.setTime(x),w}function U(_,L){_=+_||0;var K=f((L=(L|0)*s)/n)+f(_/n),L=L%n+_%n,_=f(L/n);return _&&(K+=_,L-=_*n),new y(1e3*L,0,K*t)}function g(x,w,K,L,_,V){return function(S,B){var m=h(this);S=S||new Array(8),O(S,B|=0);var C=Math.floor(m.time/1e3),m=m.year*(r*e/t),b=f(m/s)+f(C/s),m=m%s+C%s,C=Math.floor(m/s);return C&&(b+=C,m-=C*s),E(S,B+_,b),E(S,B+V,m),S};function E(S,B,b){S[B+x]=b>>24&255,S[B+w]=b>>16&255,S[B+K]=b>>8&255,S[B+L]=255&b}}function D(x,w,K,L,_,V){return function(S,B){O(S,B|=0);var b=E(S,B+_);return U(E(S,B+V),b)};function E(S,B){return 16777216*S[B+x]+(S[B+w]<<16|S[B+K]<<8|S[B+L])}}function O(x,w){if(x=x&&x.length,x==null)throw new TypeError("Invalid Buffer");if(x<w+8)throw new RangeError("Out of range")}function k(x){return(9<x?"":"0")+(0|x)}function R(x,w){return(c+(0|x)).substr(-w)}}()});var Qc=zi((Yw,Jc)=>{Jc.exports=function(e){if(!e)throw Error("hashlru must have a max value, of type number, greater than 0");var t=0,r=Object.create(null),n=Object.create(null);function o(i,s){r[i]=s,t++,t>=e&&(t=0,n=r,r=Object.create(null))}return{has:function(i){return r[i]!==void 0||n[i]!==void 0},remove:function(i){r[i]!==void 0&&(r[i]=void 0),n[i]!==void 0&&(n[i]=void 0)},get:function(i){var s=r[i];if(s!==void 0)return s;if((s=n[i])!==void 0)return o(i,s),s},set:function(i,s){r[i]!==void 0?r[i]=s:o(i,s)},clear:function(){r=Object.create(null),n=Object.create(null)}}}});var _h={};St(_h,{ipns:()=>Ih,ipnsSelector:()=>zn,ipnsValidator:()=>Hr});function Gi(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 Qn=Symbol.for("@libp2p/peer-id");var ct=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},$e=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var pr=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var Zr=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Ge=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Ze=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var oo={};St(oo,{base32:()=>fe,base32hex:()=>_u,base32hexpad:()=>Du,base32hexpadupper:()=>Ru,base32hexupper:()=>Uu,base32pad:()=>Bu,base32padupper:()=>Iu,base32upper:()=>Tu,base32z:()=>Nu});var Lh=new Uint8Array(0);function Zi(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Xt(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function ji(e){return new TextEncoder().encode(e)}function Yi(e){return new TextDecoder().decode(e)}function Eu(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(v){if(v instanceof Uint8Array||(ArrayBuffer.isView(v)?v=new Uint8Array(v.buffer,v.byteOffset,v.byteLength):Array.isArray(v)&&(v=Uint8Array.from(v))),!(v instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(v.length===0)return"";for(var y=0,h=0,A=0,U=v.length;A!==U&&v[A]===0;)A++,y++;for(var g=(U-A)*u+1>>>0,D=new Uint8Array(g);A!==U;){for(var O=v[A],k=0,R=g-1;(O!==0||k<h)&&R!==-1;R--,k++)O+=256*D[R]>>>0,D[R]=O%a>>>0,O=O/a>>>0;if(O!==0)throw new Error("Non-zero carry");h=k,A++}for(var x=g-h;x!==g&&D[x]===0;)x++;for(var w=c.repeat(y);x<g;++x)w+=e.charAt(D[x]);return w}function d(v){if(typeof v!="string")throw new TypeError("Expected String");if(v.length===0)return new Uint8Array;var y=0;if(v[y]!==" "){for(var h=0,A=0;v[y]===c;)h++,y++;for(var U=(v.length-y)*f+1>>>0,g=new Uint8Array(U);v[y];){var D=r[v.charCodeAt(y)];if(D===255)return;for(var O=0,k=U-1;(D!==0||O<A)&&k!==-1;k--,O++)D+=a*g[k]>>>0,g[k]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");A=O,y++}if(v[y]!==" "){for(var R=U-A;R!==U&&g[R]===0;)R++;for(var x=new Uint8Array(h+(U-R)),w=h;R!==U;)x[w++]=g[R++];return x}}}function T(v){var y=d(v);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:d,decode:T}}var Su=Eu,Au=Su,Xi=Au;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")}},eo=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 Ji(this,t)}},ro=class{decoders;constructor(t){this.decoders=t}or(t){return Ji(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 Ji(e,t){return new ro({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var no=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 eo(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function je({name:e,prefix:t,encode:r,decode:n}){return new no(e,t,r,n)}function ue({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Xi(r,e);return je({prefix:t,name:e,encode:n,decode:i=>Xt(o(i))})}function vu(e,t,r,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let i=e.length;for(;e[i-1]==="=";)--i;let s=new Uint8Array(i*r/8|0),a=0,c=0,f=0;for(let u=0;u<i;++u){let l=o[e[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|l,a+=r,a>=8&&(a-=8,s[f++]=255&c>>a)}if(a>=r||(255&c<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return s}function Cu(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 nt({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return je({prefix:t,name:e,encode(o){return Cu(o,n,r)},decode(o){return vu(o,n,r,e)}})}var fe=nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Tu=nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Bu=nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Iu=nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_u=nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Uu=nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Du=nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ru=nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Nu=nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var io={};St(io,{base58btc:()=>X,base58flickr:()=>Lu});var X=ue({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Lu=ue({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ao={};St(ao,{base64:()=>so,base64pad:()=>Pu,base64url:()=>ku,base64urlpad:()=>Ku});var so=nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Pu=nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ku=nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ku=nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Ou(e,t){try{if(typeof e=="string"&&e.length>0)return Fu(e);if(typeof e=="number"&&isFinite(e))return t?.long?Vu(e):Mu(e);throw new Error("Value is not a string or number.")}catch(r){let n=qu(r)?`${r.message}. value=${JSON.stringify(e)}`:"An unknown error has occured.";throw new Error(n)}}function Fu(e){if(e=String(e),e.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return NaN;let r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*315576e5;case"weeks":case"week":case"w":return r*6048e5;case"days":case"day":case"d":return r*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return r*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return r*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return r*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var Yr=Ou;function Mu(e){let t=Math.abs(e);return 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 Vu(e){let t=Math.abs(e);return t>=864e5?jr(e,t,864e5,"day"):t>=36e5?jr(e,t,36e5,"hour"):t>=6e4?jr(e,t,6e4,"minute"):t>=1e3?jr(e,t,1e3,"second"):`${e} ms`}function jr(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function qu(e){return typeof e=="object"&&e!==null&&"message"in e}function co(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=Yr,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 d=0;d<u.length;d++)l=(l<<5)-l+u.charCodeAt(d),l|=0;return r.colors[Math.abs(l)%r.colors.length]}r.selectColor=t;function r(u){let l,d=null,T,v;function y(...h){if(!y.enabled)return;let A=y,U=Number(new Date),g=U-(l||U);A.diff=g,A.prev=l,A.curr=U,l=U,h[0]=r.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let D=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(k,R)=>{if(k==="%%")return"%";D++;let x=r.formatters[R];if(typeof x=="function"){let w=h[D];k=x.call(A,w),h.splice(D,1),D--}return k}),r.formatArgs.call(A,h),(A.log||r.log).apply(A,h)}return y.namespace=u,y.useColors=r.useColors(),y.color=r.selectColor(u),y.extend=n,y.destroy=r.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(T!==r.namespaces&&(T=r.namespaces,v=r.enabled(u)),v),set:h=>{d=h}}),typeof r.init=="function"&&r.init(y),y}function n(u,l){let d=r(this.namespace+(typeof l>"u"?":":l)+u);return d.log=this.log,d}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let l,d=(typeof u=="string"?u:"").split(/[\s,]+/),T=d.length;for(l=0;l<T;l++)d[l]&&(u=d[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,d;for(l=0,d=r.skips.length;l<d;l++)if(r.skips[l].test(u))return!1;for(l=0,d=r.names.length;l<d;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 Wr=Yu(),Hu=["#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 zu(){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 $u(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Yr(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 Gu=console.debug??console.log??(()=>{});function Zu(e){try{e?Wr?.setItem("debug",e):Wr?.removeItem("debug")}catch{}}function ju(){let e;try{e=Wr?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function Yu(){try{return localStorage}catch{}}function Wu(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var Qi=co({formatArgs:$u,save:Zu,load:ju,useColors:zu,setupFormatters:Wu,colors:Hu,storage:Wr,log:Gu});var At=Qi;At.formatters.b=e=>e==null?"undefined":X.baseEncode(e);At.formatters.t=e=>e==null?"undefined":fe.baseEncode(e);At.formatters.m=e=>e==null?"undefined":so.baseEncode(e);At.formatters.p=e=>e==null?"undefined":e.toString();At.formatters.c=e=>e==null?"undefined":e.toString();At.formatters.k=e=>e==null?"undefined":e.toString();At.formatters.a=e=>e==null?"undefined":e.toString();At.formatters.e=e=>e==null?"undefined":ts(e.stack)??ts(e.message)??e.toString();function Xu(e){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}function le(e){let t=Xu(`${e}:trace`);return At.enabled(`${e}:trace`)&&At.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=At(`${e}:trace`)),Object.assign(At(e),{error:At(`${e}:error`),trace:t})}function ts(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var uo={};St(uo,{base36:()=>Ot,base36upper:()=>Ju});var Ot=ue({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ju=ue({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Qu=ns,es=128,tf=127,ef=~tf,rf=Math.pow(2,31);function ns(e,t,r){t=t||[],r=r||0;for(var n=r;e>=rf;)t[r++]=e&255|es,e/=128;for(;e&ef;)t[r++]=e&255|es,e>>>=7;return t[r]=e|0,ns.bytes=r-n+1,t}var nf=fo,of=128,rs=127;function fo(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw fo.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>=of);return fo.bytes=i-n,r}var sf=Math.pow(2,7),af=Math.pow(2,14),cf=Math.pow(2,21),uf=Math.pow(2,28),ff=Math.pow(2,35),lf=Math.pow(2,42),df=Math.pow(2,49),hf=Math.pow(2,56),pf=Math.pow(2,63),mf=function(e){return e<sf?1:e<af?2:e<cf?3:e<uf?4:e<ff?5:e<lf?6:e<df?7:e<hf?8:e<pf?9:10},yf={encode:Qu,decode:nf,encodingLength:mf},gf=yf,mr=gf;function yr(e,t=0){return[mr.decode(e,t),mr.decode.bytes]}function Ye(e,t,r=0){return mr.encode(e,t,r),t}function We(e){return mr.encodingLength(e)}function Ft(e,t){let r=t.byteLength,n=We(e),o=n+We(r),i=new Uint8Array(o+r);return Ye(e,i,0),Ye(r,i,n),i.set(t,o),new Xe(e,r,t,i)}function Jt(e){let t=Xt(e),[r,n]=yr(t),[o,i]=yr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Xe(r,o,s,t)}function os(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Zi(e.bytes,r.bytes)}}var Xe=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function is(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return wf(r,lo(e),t??X.encoder);default:return bf(r,lo(e),t??fe.encoder)}}var ss=new WeakMap;function lo(e){let t=ss.get(e);if(t==null){let r=new Map;return ss.set(e,r),r}return t}var J=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==gr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Ef)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=Ft(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&&os(t.multihash,n.multihash)}toString(t){return is(this,t)}toJSON(){return{"/":is(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??as(n,o,i.bytes))}else if(r[Sf]===!0){let{version:n,multihash:o,code:i}=r,s=Jt(o);return e.create(n,i,s)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==gr)throw new Error(`Version 0 CID must use dag-pb (code: ${gr}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=as(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,gr,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=Xt(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 Xe(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,d]=yr(t.subarray(r));return r+=d,l},o=n(),i=gr;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),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]=xf(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 lo(i).set(n,t),i}};function xf(e,t){switch(e[0]){case"Q":{let r=t??X;return[X.prefix,r.decode(`${X.prefix}${e}`)]}case X.prefix:{let r=t??X;return[X.prefix,r.decode(e)]}case fe.prefix:{let r=t??fe;return[fe.prefix,r.decode(e)]}case Ot.prefix:{let r=t??Ot;return[Ot.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 wf(e,t,r){let{prefix:n}=r;if(n!==X.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 bf(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o}var gr=112,Ef=18;function as(e,t,r){let n=We(e),o=n+We(t),i=new Uint8Array(o+r.byteLength);return Ye(e,i,0),Ye(t,i,n),i.set(r,o),i}var Sf=Symbol.for("@ipld/js-cid/CID");var ho={};St(ho,{identity:()=>Mt});var cs=0,Af="identity",us=Xt;function vf(e){return Ft(cs,us(e))}var Mt={code:cs,name:Af,encode:us,digest:vf};function it(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 Lt(e=0){return new Uint8Array(e)}function Tt(e=0){return new Uint8Array(e)}function he(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=Tt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var ls=Symbol.for("@achingbrain/uint8arraylist");function fs(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 Jr(e){return!!e?.[ls]}var Bt=class e{bufs;length;[ls]=!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(Jr(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(Jr(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=fs(this.bufs,t);return r.buf[r.index]}set(t,r){let n=fs(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(Jr(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 he(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:he(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(!Jr(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 d=f;d>=0;d--){let T=this.get(l+d);if(n[d]!==T){u=Math.max(1,d-a[T]);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=Tt(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=Lt(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=Lt(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=Lt(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=Tt(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=Lt(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=Lt(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=Lt(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=Lt(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=Lt(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(!it(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 po={};St(po,{base10:()=>Cf});var Cf=ue({prefix:"9",name:"base10",alphabet:"0123456789"});var mo={};St(mo,{base16:()=>Tf,base16upper:()=>Bf});var Tf=nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Bf=nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var yo={};St(yo,{base2:()=>If});var If=nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var go={};St(go,{base256emoji:()=>Nf});var ds=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}"),_f=ds.reduce((e,t,r)=>(e[r]=t,e),[]),Uf=ds.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Df(e){return e.reduce((t,r)=>(t+=_f[r],t),"")}function Rf(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Uf[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var Nf=je({prefix:"\u{1F680}",name:"base256emoji",encode:Df,decode:Rf});var xo={};St(xo,{base8:()=>Lf});var Lf=nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var wo={};St(wo,{identity:()=>Pf});var Pf=je({prefix:"\0",name:"identity",encode:e=>Yi(e),decode:e=>ji(e)});var U0=new TextEncoder,D0=new TextDecoder;var So={};St(So,{sha256:()=>xr,sha512:()=>Of});function Eo({name:e,code:t,encode:r}){return new bo(e,t,r)}var bo=class{name;code;encode;constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?Ft(this.code,r):r.then(n=>Ft(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ps(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var xr=Eo({name:"sha2-256",code:18,encode:ps("SHA-256")}),Of=Eo({name:"sha2-512",code:19,encode:ps("SHA-512")});var Ao={...wo,...yo,...xo,...po,...mo,...oo,...uo,...io,...ao,...go},H0={...So,...ho};function ys(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var ms=ys("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),vo=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=Tt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Ff={utf8:ms,"utf-8":ms,hex:Ao.base16,latin1:vo,ascii:vo,binary:vo,...Ao},Qr=Ff;function G(e,t="utf8"){let r=Qr[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function Y(e,t="utf8"){let r=Qr[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var Mf=parseInt("11111",2),Co=parseInt("10000000",2),Vf=parseInt("01111111",2),gs={0:wr,1:wr,2:qf,3:$f,4:Gf,5:zf,6:Hf,16:wr,22:wr,48:wr};function Qt(e,t={offset:0}){let r=e[t.offset]&Mf;if(t.offset++,gs[r]!=null)return gs[r](e,t);throw new Error("No decoder for tag "+r)}function br(e,t){let r=0;if((e[t.offset]&Co)===Co){let n=e[t.offset]&Vf,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 wr(e,t){br(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=Qt(e,t);if(n===null)break;r.push(n)}return r}function qf(e,t){let r=br(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 Hf(e,t){let r=br(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 zf(e,t){return t.offset++,null}function $f(e,t){let r=br(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 Gf(e,t){let r=br(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function Zf(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new Bt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function To(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=Zf(e.byteLength);return new Bt(Uint8Array.from([t.byteLength|Co]),t)}function vt(e){let t=new Bt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new Bt(Uint8Array.from([2]),To(t),t)}function tn(e){let t=Uint8Array.from([0]),r=new Bt(t,e);return new Bt(Uint8Array.from([3]),To(r),r)}function pe(e,t=48){let r=new Bt;for(let n of e)r.append(n);return new Bt(Uint8Array.from([t]),To(r),r)}async function xs(e,t,r){let n=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,r.subarray())}var jf=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Yf=Uint8Array.from([6,5,43,129,4,0,34]),Wf=Uint8Array.from([6,5,43,129,4,0,35]),Xf={ext:!0,kty:"EC",crv:"P-256"},Jf={ext:!0,kty:"EC",crv:"P-384"},Qf={ext:!0,kty:"EC",crv:"P-521"},Bo=32,Io=48,_o=66;function Uo(e){let t=Qt(e);return ws(t)}function ws(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===Bo*2+1)return n=Y(t.subarray(r,r+Bo),"base64url"),o=Y(t.subarray(r+Bo),"base64url"),new Je({...Xf,key_ops:["verify"],x:n,y:o});if(t.byteLength===Io*2+1)return n=Y(t.subarray(r,r+Io),"base64url"),o=Y(t.subarray(r+Io),"base64url"),new Je({...Jf,key_ops:["verify"],x:n,y:o});if(t.byteLength===_o*2+1)return n=Y(t.subarray(r,r+_o),"base64url"),o=Y(t.subarray(r+_o),"base64url"),new Je({...Qf,key_ops:["verify"],x:n,y:o});throw new ct(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function bs(e){return pe([vt(Uint8Array.from([1])),pe([tl(e.crv)],160),pe([tn(new Bt(Uint8Array.from([4]),G(e.x??"","base64url"),G(e.y??"","base64url")))],161)]).subarray()}function tl(e){if(e==="P-256")return jf;if(e==="P-384")return Yf;if(e==="P-521")return Wf;throw new ct(`Invalid curve ${e}`)}var Je=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=bs(this.jwk)),this._raw}toMultihash(){return Mt.digest(me(this))}toCID(){return J.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:it(this.raw,t.raw)}async verify(t,r){return xs(this.jwk,r,t)}};function Es(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function el(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Qe(e,...t){if(!el(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ss(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Es(e.outputLen),Es(e.blockLen)}function tr(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 As(e,t){Qe(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}var De=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function en(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Vt(e,t){return e<<32-t|e>>>t}var vp=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function";function vs(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function Er(e){return typeof e=="string"&&(e=vs(e)),Qe(e),e}function Do(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];Qe(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}var er=class{clone(){return this._cloneInto()}};function rn(e){let t=n=>e().update(Er(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function nn(e=32){if(De&&typeof De.getRandomValues=="function")return De.getRandomValues(new Uint8Array(e));if(De&&typeof De.randomBytes=="function")return Uint8Array.from(De.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function rl(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,f=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+f,a,n)}function Cs(e,t,r){return e&t^~e&r}function Ts(e,t,r){return e&t^e&r^t&r}var rr=class extends er{constructor(t,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=en(this.buffer)}update(t){tr(this);let{view:r,buffer:n,blockLen:o}=this;t=Er(t);let i=t.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=en(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){tr(this),As(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;rl(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=en(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should 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||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return t.length=o,t.pos=a,t.finished=i,t.destroyed=s,o%r&&t.buffer.set(n),t}};var nl=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ye=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ge=new Uint32Array(64),Ro=class extends rr{constructor(t=32){super(64,t,8,!1),this.A=ye[0]|0,this.B=ye[1]|0,this.C=ye[2]|0,this.D=ye[3]|0,this.E=ye[4]|0,this.F=ye[5]|0,this.G=ye[6]|0,this.H=ye[7]|0}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)ge[l]=t.getUint32(r,!1);for(let l=16;l<64;l++){let d=ge[l-15],T=ge[l-2],v=Vt(d,7)^Vt(d,18)^d>>>3,y=Vt(T,17)^Vt(T,19)^T>>>10;ge[l]=y+ge[l-7]+v+ge[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 d=Vt(a,6)^Vt(a,11)^Vt(a,25),T=u+d+Cs(a,c,f)+nl[l]+ge[l]|0,y=(Vt(n,2)^Vt(n,13)^Vt(n,22))+Ts(n,o,i)|0;u=f,f=c,c=a,a=s+T|0,s=i,i=o,o=n,n=T+y|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(){ge.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Re=rn(()=>new Ro);var on=BigInt(4294967295),No=BigInt(32);function Bs(e,t=!1){return t?{h:Number(e&on),l:Number(e>>No&on)}:{h:Number(e>>No&on)|0,l:Number(e&on)|0}}function ol(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let o=0;o<e.length;o++){let{h:i,l:s}=Bs(e[o],t);[r[o],n[o]]=[i,s]}return[r,n]}var il=(e,t)=>BigInt(e>>>0)<<No|BigInt(t>>>0),sl=(e,t,r)=>e>>>r,al=(e,t,r)=>e<<32-r|t>>>r,cl=(e,t,r)=>e>>>r|t<<32-r,ul=(e,t,r)=>e<<32-r|t>>>r,fl=(e,t,r)=>e<<64-r|t>>>r-32,ll=(e,t,r)=>e>>>r-32|t<<64-r,dl=(e,t)=>t,hl=(e,t)=>e,pl=(e,t,r)=>e<<r|t>>>32-r,ml=(e,t,r)=>t<<r|e>>>32-r,yl=(e,t,r)=>t<<r-32|e>>>64-r,gl=(e,t,r)=>e<<r-32|t>>>64-r;function xl(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var wl=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),bl=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,El=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Sl=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Al=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),vl=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var Cl={fromBig:Bs,split:ol,toBig:il,shrSH:sl,shrSL:al,rotrSH:cl,rotrSL:ul,rotrBH:fl,rotrBL:ll,rotr32H:dl,rotr32L:hl,rotlSH:pl,rotlSL:ml,rotlBH:yl,rotlBL:gl,add:xl,add3L:wl,add3H:bl,add4L:El,add4H:Sl,add5H:vl,add5L:Al},q=Cl;var[Tl,Bl]=q.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),xe=new Uint32Array(80),we=new Uint32Array(80),Lo=class extends rr{constructor(t=64){super(128,t,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:d,Gh:T,Gl:v,Hh:y,Hl:h}=this;return[t,r,n,o,i,s,a,c,f,u,l,d,T,v,y,h]}set(t,r,n,o,i,s,a,c,f,u,l,d,T,v,y,h){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=d|0,this.Gh=T|0,this.Gl=v|0,this.Hh=y|0,this.Hl=h|0}process(t,r){for(let g=0;g<16;g++,r+=4)xe[g]=t.getUint32(r),we[g]=t.getUint32(r+=4);for(let g=16;g<80;g++){let D=xe[g-15]|0,O=we[g-15]|0,k=q.rotrSH(D,O,1)^q.rotrSH(D,O,8)^q.shrSH(D,O,7),R=q.rotrSL(D,O,1)^q.rotrSL(D,O,8)^q.shrSL(D,O,7),x=xe[g-2]|0,w=we[g-2]|0,K=q.rotrSH(x,w,19)^q.rotrBH(x,w,61)^q.shrSH(x,w,6),L=q.rotrSL(x,w,19)^q.rotrBL(x,w,61)^q.shrSL(x,w,6),_=q.add4L(R,L,we[g-7],we[g-16]),V=q.add4H(_,k,K,xe[g-7],xe[g-16]);xe[g]=V|0,we[g]=_|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:d,Fh:T,Fl:v,Gh:y,Gl:h,Hh:A,Hl:U}=this;for(let g=0;g<80;g++){let D=q.rotrSH(l,d,14)^q.rotrSH(l,d,18)^q.rotrBH(l,d,41),O=q.rotrSL(l,d,14)^q.rotrSL(l,d,18)^q.rotrBL(l,d,41),k=l&T^~l&y,R=d&v^~d&h,x=q.add5L(U,O,R,Bl[g],we[g]),w=q.add5H(x,A,D,k,Tl[g],xe[g]),K=x|0,L=q.rotrSH(n,o,28)^q.rotrBH(n,o,34)^q.rotrBH(n,o,39),_=q.rotrSL(n,o,28)^q.rotrBL(n,o,34)^q.rotrBL(n,o,39),V=n&i^n&a^i&a,E=o&s^o&c^s&c;A=y|0,U=h|0,y=T|0,h=v|0,T=l|0,v=d|0,{h:l,l:d}=q.add(f|0,u|0,w|0,K|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let S=q.add3L(K,_,E);n=q.add3H(S,w,L,V),o=S|0}({h:n,l:o}=q.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=q.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=q.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=q.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:d}=q.add(this.Eh|0,this.El|0,l|0,d|0),{h:T,l:v}=q.add(this.Fh|0,this.Fl|0,T|0,v|0),{h:y,l:h}=q.add(this.Gh|0,this.Gl|0,y|0,h|0),{h:A,l:U}=q.add(this.Hh|0,this.Hl|0,A|0,U|0),this.set(n,o,i,s,a,c,f,u,l,d,T,v,y,h,A,U)}roundClean(){xe.fill(0),we.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Po=rn(()=>new Lo);var Fo=BigInt(0),Oo=BigInt(1);function Ne(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Mo(e){if(!Ne(e))throw new Error("Uint8Array expected")}function Gt(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function Sr(e){let t=e.toString(16);return t.length&1?"0"+t:t}function Us(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?Fo:BigInt("0x"+e)}var Ds=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Il=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function be(e){if(Mo(e),Ds)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Il[e[r]];return t}var te={_0:48,_9:57,A:65,F:70,a:97,f:102};function Is(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 Ar(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Ds)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=Is(e.charCodeAt(i)),a=Is(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 ee(e){return Us(be(e))}function Le(e){return Mo(e),Us(be(Uint8Array.from(e).reverse()))}function Pe(e,t){return Ar(e.toString(16).padStart(t*2,"0"))}function nr(e,t){return Pe(e,t).reverse()}function rt(e,t,r){let n;if(typeof t=="string")try{n=Ar(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(Ne(t))n=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(e+" of length "+r+" expected, got "+o);return n}function Ee(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];Mo(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}var ko=e=>typeof e=="bigint"&&Fo<=e;function sn(e,t,r){return ko(e)&&ko(t)&&ko(r)&&t<=e&&e<r}function It(e,t,r,n){if(!sn(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Rs(e){let t;for(t=0;e>Fo;e>>=Oo,t+=1);return t}var ke=e=>(Oo<<BigInt(e))-Oo,Ko=e=>new Uint8Array(e),_s=e=>Uint8Array.from(e);function Ns(e,t,r){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=Ko(e),o=Ko(e),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>r(o,n,...l),c=(l=Ko(0))=>{o=a(_s([0]),l),n=a(),l.length!==0&&(o=a(_s([1]),l),n=a())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,d=[];for(;l<t;){n=a();let T=n.slice();d.push(T),l+=n.length}return Ee(...d)};return(l,d)=>{s(),c(l);let T;for(;!(T=d(f()));)c();return s(),T}}var _l={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||Ne(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function re(e,t,r={}){let n=(o,i,s)=>{let a=_l[i];if(typeof a!="function")throw new Error("invalid validator function");let c=e[o];if(!(s&&c===void 0)&&!a(c,e))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+c)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(r))n(o,i,!0);return e}function or(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 ut=BigInt(0),tt=BigInt(1),Ke=BigInt(2),Ul=BigInt(3),Vo=BigInt(4),Ls=BigInt(5),Ps=BigInt(8),Dl=BigInt(9),Rl=BigInt(16);function Q(e,t){let r=e%t;return r>=ut?r:t+r}function Nl(e,t,r){if(t<ut)throw new Error("invalid exponent, negatives unsupported");if(r<=ut)throw new Error("invalid modulus");if(r===tt)return ut;let n=tt;for(;t>ut;)t&tt&&(n=n*e%r),e=e*e%r,t>>=tt;return n}function et(e,t,r){let n=e;for(;t-- >ut;)n*=n,n%=r;return n}function an(e,t){if(e===ut)throw new Error("invert: expected non-zero number");if(t<=ut)throw new Error("invert: expected positive modulus, got "+t);let r=Q(e,t),n=t,o=ut,i=tt,s=tt,a=ut;for(;r!==ut;){let f=n/r,u=n%r,l=o-s*f,d=i-a*f;n=r,r=u,o=s,i=a,s=l,a=d}if(n!==tt)throw new Error("invert: does not exist");return Q(o,t)}function Ll(e){let t=(e-tt)/Ke,r,n,o;for(r=e-tt,n=0;r%Ke===ut;r/=Ke,n++);for(o=Ke;o<e&&Nl(o,t,e)!==e-tt;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(e+tt)/Vo;return function(c,f){let u=c.pow(f,s);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let i=(r+tt)/Ke;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,u=a.pow(a.mul(a.ONE,o),r),l=a.pow(c,i),d=a.pow(c,r);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let T=1;for(let y=a.sqr(d);T<f&&!a.eql(y,a.ONE);T++)y=a.sqr(y);let v=a.pow(u,tt<<BigInt(f-T-1));u=a.sqr(v),l=a.mul(l,v),d=a.mul(d,u),f=T}return l}}function Pl(e){if(e%Vo===Ul){let t=(e+tt)/Vo;return function(n,o){let i=n.pow(o,t);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(e%Ps===Ls){let t=(e-Ls)/Ps;return function(n,o){let i=n.mul(o,Ke),s=n.pow(i,t),a=n.mul(o,s),c=n.mul(n.mul(a,Ke),s),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return e%Rl,Ll(e)}var ks=(e,t)=>(Q(e,t)&tt)===tt,kl=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function qo(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=kl.reduce((n,o)=>(n[o]="function",n),t);return re(e,r)}function Kl(e,t,r){if(r<ut)throw new Error("invalid exponent, negatives unsupported");if(r===ut)return e.ONE;if(r===tt)return t;let n=e.ONE,o=t;for(;r>ut;)r&tt&&(n=e.mul(n,o)),o=e.sqr(o),r>>=tt;return n}function Ol(e,t){let r=new Array(t.length),n=t.reduce((i,s,a)=>e.is0(s)?i:(r[a]=i,e.mul(i,s)),e.ONE),o=e.inv(n);return t.reduceRight((i,s,a)=>e.is0(s)?i:(r[a]=e.mul(i,r[a]),e.mul(i,s)),o),r}function Ho(e,t){let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Se(e,t,r=!1,n={}){if(e<=ut)throw new Error("invalid field: expected ORDER > 0, got "+e);let{nBitLength:o,nByteLength:i}=Ho(e,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,a=Object.freeze({ORDER:e,isLE:r,BITS:o,BYTES:i,MASK:ke(o),ZERO:ut,ONE:tt,create:c=>Q(c,e),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ut<=c&&c<e},is0:c=>c===ut,isOdd:c=>(c&tt)===tt,neg:c=>Q(-c,e),eql:(c,f)=>c===f,sqr:c=>Q(c*c,e),add:(c,f)=>Q(c+f,e),sub:(c,f)=>Q(c-f,e),mul:(c,f)=>Q(c*f,e),pow:(c,f)=>Kl(a,c,f),div:(c,f)=>Q(c*an(f,e),e),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>an(c,e),sqrt:n.sqrt||(c=>(s||(s=Pl(e)),s(a,c))),invertBatch:c=>Ol(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>r?nr(c,i):Pe(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return r?Le(c):ee(c)}});return Object.freeze(a)}function Ks(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 zo(e){let t=Ks(e);return t+Math.ceil(t/2)}function Os(e,t,r=!1){let n=e.length,o=Ks(t),i=zo(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Le(e):ee(e),a=Q(s,t-tt)+tt;return r?nr(a,o):Pe(a,o)}var Fs=BigInt(0),Yo=BigInt(1);function $o(e,t){let r=t.negate();return e?r:t}function Vs(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Go(e,t){Vs(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=ke(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Ms(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+=Yo);let f=t*n,u=f+Math.abs(a)-1,l=a===0,d=a<0,T=t%2!==0;return{nextN:c,offset:u,isZero:l,isNeg:d,isNegF:T,offsetF:f}}function Fl(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function Ml(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((r,n)=>{if(!t.isValid(r))throw new Error("invalid scalar at index "+n)})}var Zo=new WeakMap,qs=new WeakMap;function jo(e){return qs.get(e)||1}function cn(e,t){return{constTimeNegate:$o,hasPrecomputes(r){return jo(r)!==1},unsafeLadder(r,n,o=e.ZERO){let i=r;for(;n>Fs;)n&Yo&&(o=o.add(i)),i=i.double(),n>>=Yo;return o},precomputeWindow(r,n){let{windows:o,windowSize:i}=Go(n,t),s=[],a=r,c=a;for(let f=0;f<o;f++){c=a,s.push(c);for(let u=1;u<i;u++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(r,n,o){let i=e.ZERO,s=e.BASE,a=Go(r,t);for(let c=0;c<a.windows;c++){let{nextN:f,offset:u,isZero:l,isNeg:d,isNegF:T,offsetF:v}=Ms(o,c,a);o=f,l?s=s.add($o(T,n[v])):i=i.add($o(d,n[u]))}return{p:i,f:s}},wNAFUnsafe(r,n,o,i=e.ZERO){let s=Go(r,t);for(let a=0;a<s.windows&&o!==Fs;a++){let{nextN:c,offset:f,isZero:u,isNeg:l}=Ms(o,a,s);if(o=c,!u){let d=n[f];i=i.add(l?d.negate():d)}}return i},getPrecomputes(r,n,o){let i=Zo.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&Zo.set(n,o(i))),i},wNAFCached(r,n,o){let i=jo(r);return this.wNAF(i,this.getPrecomputes(i,r,o),n)},wNAFCachedUnsafe(r,n,o,i){let s=jo(r);return s===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,r,o),n,i)},setWindowSize(r,n){Vs(n,t),qs.set(r,n),Zo.delete(r)}}}function un(e,t,r,n){if(Fl(r,e),Ml(n,t),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=e.ZERO,i=Rs(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=ke(s),c=new Array(Number(a)+1).fill(o),f=Math.floor((t.BITS-1)/s)*s,u=o;for(let l=f;l>=0;l-=s){c.fill(o);for(let T=0;T<n.length;T++){let v=n[T],y=Number(v>>BigInt(l)&a);c[y]=c[y].add(r[T])}let d=o;for(let T=c.length-1,v=o;T>0;T--)v=v.add(c[T]),d=d.add(v);if(u=u.add(d),l!==0)for(let T=0;T<s;T++)u=u.double()}return u}function vr(e){return qo(e.Fp),re(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ho(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}var Zt=BigInt(0),wt=BigInt(1),Hs=BigInt(2),Vl=BigInt(8),ql={zip215:!0};function Hl(e){let t=vr(e);return re(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function zs(e){let t=Hl(e),{Fp:r,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=t,f=Hs<<BigInt(a*8)-wt,u=r.create,l=Se(t.n,t.nBitLength),d=t.uvRatio||((b,m)=>{try{return{isValid:!0,value:r.sqrt(b*r.inv(m))}}catch{return{isValid:!1,value:Zt}}}),T=t.adjustScalarBytes||(b=>b),v=t.domain||((b,m,C)=>{if(Gt("phflag",C),m.length||C)throw new Error("Contexts/pre-hash are not supported");return b});function y(b,m,C=!1){let P=C?wt:Zt;It("coordinate "+b,m,P,f)}function h(b){if(!(b instanceof g))throw new Error("ExtendedPoint expected")}let A=or((b,m)=>{let{ex:C,ey:P,ez:F}=b,H=b.is0();m==null&&(m=H?Vl:r.inv(F));let z=u(C*m),$=u(P*m),j=u(F*m);if(H)return{x:Zt,y:wt};if(j!==wt)throw new Error("invZ was invalid");return{x:z,y:$}}),U=or(b=>{let{a:m,d:C}=t;if(b.is0())throw new Error("bad point: ZERO");let{ex:P,ey:F,ez:H,et:z}=b,$=u(P*P),j=u(F*F),W=u(H*H),at=u(W*W),ot=u($*m),ht=u(W*u(ot+j)),Et=u(at+u(C*u($*j)));if(ht!==Et)throw new Error("bad point: equation left != right (1)");let ft=u(P*F),yt=u(H*z);if(ft!==yt)throw new Error("bad point: equation left != right (2)");return!0});class g{constructor(m,C,P,F){y("x",m),y("y",C),y("z",P,!0),y("t",F),this.ex=m,this.ey=C,this.ez=P,this.et=F,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(m){if(m instanceof g)throw new Error("extended point not allowed");let{x:C,y:P}=m||{};return y("x",C),y("y",P),new g(C,P,wt,u(C*P))}static normalizeZ(m){let C=r.invertBatch(m.map(P=>P.ez));return m.map((P,F)=>P.toAffine(C[F])).map(g.fromAffine)}static msm(m,C){return un(g,l,m,C)}_setWindowSize(m){k.setWindowSize(this,m)}assertValidity(){U(this)}equals(m){h(m);let{ex:C,ey:P,ez:F}=this,{ex:H,ey:z,ez:$}=m,j=u(C*$),W=u(H*F),at=u(P*$),ot=u(z*F);return j===W&&at===ot}is0(){return this.equals(g.ZERO)}negate(){return new g(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:m}=t,{ex:C,ey:P,ez:F}=this,H=u(C*C),z=u(P*P),$=u(Hs*u(F*F)),j=u(m*H),W=C+P,at=u(u(W*W)-H-z),ot=j+z,ht=ot-$,Et=j-z,ft=u(at*ht),yt=u(ot*Et),Ct=u(at*Et),Kt=u(ht*ot);return new g(ft,yt,Kt,Ct)}add(m){h(m);let{a:C,d:P}=t,{ex:F,ey:H,ez:z,et:$}=this,{ex:j,ey:W,ez:at,et:ot}=m,ht=u(F*j),Et=u(H*W),ft=u($*P*ot),yt=u(z*at),Ct=u((F+H)*(j+W)-ht-Et),Kt=yt-ft,hr=yt+ft,Hi=u(Et-C*ht),lu=u(Ct*Kt),du=u(hr*Hi),hu=u(Ct*Hi),pu=u(Kt*hr);return new g(lu,du,pu,hu)}subtract(m){return this.add(m.negate())}wNAF(m){return k.wNAFCached(this,m,g.normalizeZ)}multiply(m){let C=m;It("scalar",C,wt,n);let{p:P,f:F}=this.wNAF(C);return g.normalizeZ([P,F])[0]}multiplyUnsafe(m,C=g.ZERO){let P=m;return It("scalar",P,Zt,n),P===Zt?O:this.is0()||P===wt?this:k.wNAFCachedUnsafe(this,P,g.normalizeZ,C)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return k.unsafeLadder(this,n).is0()}toAffine(m){return A(this,m)}clearCofactor(){let{h:m}=t;return m===wt?this:this.multiplyUnsafe(m)}static fromHex(m,C=!1){let{d:P,a:F}=t,H=r.BYTES;m=rt("pointHex",m,H),Gt("zip215",C);let z=m.slice(),$=m[H-1];z[H-1]=$&-129;let j=Le(z),W=C?f:r.ORDER;It("pointHex.y",j,Zt,W);let at=u(j*j),ot=u(at-wt),ht=u(P*at-F),{isValid:Et,value:ft}=d(ot,ht);if(!Et)throw new Error("Point.fromHex: invalid y coordinate");let yt=(ft&wt)===wt,Ct=($&128)!==0;if(!C&&ft===Zt&&Ct)throw new Error("Point.fromHex: x=0 and x_0=1");return Ct!==yt&&(ft=u(-ft)),g.fromAffine({x:ft,y:j})}static fromPrivateKey(m){let{scalar:C}=w(m);return D.multiply(C)}toRawBytes(){let{x:m,y:C}=this.toAffine(),P=nr(C,r.BYTES);return P[P.length-1]|=m&wt?128:0,P}toHex(){return be(this.toRawBytes())}}g.BASE=new g(t.Gx,t.Gy,wt,u(t.Gx*t.Gy)),g.ZERO=new g(Zt,wt,wt,Zt);let{BASE:D,ZERO:O}=g,k=cn(g,a*8);function R(b){return Q(b,n)}function x(b){return R(Le(b))}function w(b){let m=r.BYTES;b=rt("private key",b,m);let C=rt("hashed private key",i(b),2*m),P=T(C.slice(0,m)),F=C.slice(m,2*m),H=x(P);return{head:P,prefix:F,scalar:H}}function K(b){let{head:m,prefix:C,scalar:P}=w(b),F=D.multiply(P),H=F.toRawBytes();return{head:m,prefix:C,scalar:P,point:F,pointBytes:H}}function L(b){return K(b).pointBytes}function _(b=new Uint8Array,...m){let C=Ee(...m);return x(i(v(C,rt("context",b),!!o)))}function V(b,m,C={}){b=rt("message",b),o&&(b=o(b));let{prefix:P,scalar:F,pointBytes:H}=K(m),z=_(C.context,P,b),$=D.multiply(z).toRawBytes(),j=_(C.context,$,H,b),W=R(z+j*F);It("signature.s",W,Zt,n);let at=Ee($,nr(W,r.BYTES));return rt("result",at,r.BYTES*2)}let E=ql;function S(b,m,C,P=E){let{context:F,zip215:H}=P,z=r.BYTES;b=rt("signature",b,2*z),m=rt("message",m),C=rt("publicKey",C,z),H!==void 0&&Gt("zip215",H),o&&(m=o(m));let $=Le(b.slice(z,2*z)),j,W,at;try{j=g.fromHex(C,H),W=g.fromHex(b.slice(0,z),H),at=D.multiplyUnsafe($)}catch{return!1}if(!H&&j.isSmallOrder())return!1;let ot=_(F,W.toRawBytes(),j.toRawBytes(),m);return W.add(j.multiplyUnsafe(ot)).subtract(at).clearCofactor().equals(g.ZERO)}return D._setWindowSize(8),{CURVE:t,getPublicKey:L,sign:V,verify:S,ExtendedPoint:g,utils:{getExtendedPublicKey:K,randomPrivateKey:()=>s(r.BYTES),precompute(b=8,m=g.BASE){return m._setWindowSize(b),m.multiply(BigInt(3)),m}}}}var Wo=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),$s=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),im=BigInt(0),zl=BigInt(1),Gs=BigInt(2),sm=BigInt(3),$l=BigInt(5),Gl=BigInt(8);function Zl(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=Wo,a=e*e%i*e%i,c=et(a,Gs,i)*a%i,f=et(c,zl,i)*e%i,u=et(f,$l,i)*f%i,l=et(u,t,i)*u%i,d=et(l,r,i)*l%i,T=et(d,n,i)*d%i,v=et(T,o,i)*T%i,y=et(v,o,i)*T%i,h=et(y,t,i)*u%i;return{pow_p_5_8:et(h,Gs,i)*e%i,b2:a}}function jl(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function Yl(e,t){let r=Wo,n=Q(t*t*t,r),o=Q(n*n*t,r),i=Zl(e*o).pow_p_5_8,s=Q(e*n*i,r),a=Q(t*s*s,r),c=s,f=Q(s*$s,r),u=a===e,l=a===Q(-e,r),d=a===Q(-e*$s,r);return u&&(s=c),(l||d)&&(s=f),ks(s,r)&&(s=Q(-s,r)),{isValid:u||l,value:s}}var Zs=Se(Wo,void 0,!0),Wl={a:Zs.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Zs,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Gl,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Po,randomBytes:nn,adjustScalarBytes:jl,uvRatio:Yl},js=zs(Wl);var fn=32;function Ys(e,t,r){return js.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}var ln=class{type="Ed25519";raw;constructor(t){this.raw=Xo(t,fn)}toMultihash(){return Mt.digest(me(this))}toCID(){return J.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:it(this.raw,t.raw)}verify(t,r){return Ys(this.raw,r,t)}};function Jo(e){return e=Xo(e,fn),new ln(e)}function Xo(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new ct(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var Jl=Math.pow(2,7),Ql=Math.pow(2,14),td=Math.pow(2,21),Xs=Math.pow(2,28),Js=Math.pow(2,35),Qs=Math.pow(2,42),ta=Math.pow(2,49),bt=128,Ae=127;function Cr(e){if(e<Jl)return 1;if(e<Ql)return 2;if(e<td)return 3;if(e<Xs)return 4;if(e<Js)return 5;if(e<Qs)return 6;if(e<ta)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ea(e,t,r=0){switch(Cr(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 ra(e,t){let r=e[t],n=0;if(n+=r&Ae,r<bt||(r=e[t+1],n+=(r&Ae)<<7,r<bt)||(r=e[t+2],n+=(r&Ae)<<14,r<bt)||(r=e[t+3],n+=(r&Ae)<<21,r<bt)||(r=e[t+4],n+=(r&Ae)*Xs,r<bt)||(r=e[t+5],n+=(r&Ae)*Js,r<bt)||(r=e[t+6],n+=(r&Ae)*Qs,r<bt)||(r=e[t+7],n+=(r&Ae)*ta,r<bt))return n;throw new RangeError("Could not decode varint")}var Qo=new Float32Array([-0]),ve=new Uint8Array(Qo.buffer);function na(e,t,r){Qo[0]=e,t[r]=ve[0],t[r+1]=ve[1],t[r+2]=ve[2],t[r+3]=ve[3]}function oa(e,t){return ve[0]=e[t],ve[1]=e[t+1],ve[2]=e[t+2],ve[3]=e[t+3],Qo[0]}var ti=new Float64Array([-0]),gt=new Uint8Array(ti.buffer);function ia(e,t,r){ti[0]=e,t[r]=gt[0],t[r+1]=gt[1],t[r+2]=gt[2],t[r+3]=gt[3],t[r+4]=gt[4],t[r+5]=gt[5],t[r+6]=gt[6],t[r+7]=gt[7]}function sa(e,t){return gt[0]=e[t],gt[1]=e[t+1],gt[2]=e[t+2],gt[3]=e[t+3],gt[4]=e[t+4],gt[5]=e[t+5],gt[6]=e[t+6],gt[7]=e[t+7],ti[0]}var ed=BigInt(Number.MAX_SAFE_INTEGER),rd=BigInt(Number.MIN_SAFE_INTEGER),_t=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 Oe;if(t<ed&&t>rd)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>aa&&(o=0n,++n>aa&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Oe;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):Oe}},Oe=new _t(0,0);Oe.toBigInt=function(){return 0n};Oe.zzEncode=Oe.zzDecode=function(){return this};Oe.length=function(){return 1};var aa=4294967296n;function ca(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 ua(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 ei(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 qt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function dn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var ri=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,qt(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 qt(this,4);return dn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw qt(this,4);return dn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw qt(this,4);let t=oa(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw qt(this,4);let t=sa(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 qt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return ua(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw qt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw qt(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 _t(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 qt(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 qt(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 qt(this,8);let t=dn(this.buf,this.pos+=4),r=dn(this.buf,this.pos+=4);return new _t(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=ra(this.buf,this.pos);return this.pos+=Cr(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 ni(e){return new ri(e instanceof Uint8Array?e:e.subarray())}function Ce(e,t,r){let n=ni(e);return t.decode(n,void 0,r)}function oi(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return Tt(s);o+s>t&&(n=Tt(t),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var Fe=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function ii(){}var ai=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},nd=oi();function od(e){return globalThis.Buffer!=null?Tt(e):nd(e)}var Br=class{len;head;tail;states;constructor(){this.len=0,this.head=new Fe(ii,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new Fe(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new ci((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(hn,10,_t.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=_t.fromBigInt(t);return this._push(hn,r.length(),r)}uint64Number(t){return this._push(ea,Cr(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=_t.fromBigInt(t).zzEncode();return this._push(hn,r.length(),r)}sint64Number(t){let r=_t.fromNumber(t).zzEncode();return this._push(hn,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(si,1,t?1:0)}fixed32(t){return this._push(Tr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=_t.fromBigInt(t);return this._push(Tr,4,r.lo)._push(Tr,4,r.hi)}fixed64Number(t){let r=_t.fromNumber(t);return this._push(Tr,4,r.lo)._push(Tr,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(na,4,t)}double(t){return this._push(ia,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(si,1,0):this.uint32(r)._push(sd,r,t)}string(t){let r=ca(t);return r!==0?this.uint32(r)._push(ei,r,t):this._push(si,1,0)}fork(){return this.states=new ai(this),this.head=this.tail=new Fe(ii,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 Fe(ii,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=od(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function si(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 ci=class extends Fe{next;constructor(t,r){super(id,t,r),this.next=void 0}};function hn(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 Tr(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 sd(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(Br.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(ad,t,e),this},Br.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(cd,t,e),this});function ad(e,t,r){t.set(e,r)}function cd(e,t,r){e.length<40?ei(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(G(e),r)}function ui(){return new Br}function Te(e,t){let r=ui();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var ir;(function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"})(ir||(ir={}));function pn(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Ir(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 pn("enum",ir.VARINT,r,n)}function Be(e,t){return pn("message",ir.LENGTH_DELIMITED,e,t)}var st;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(st||(st={}));var fi;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(fi||(fi={}));(function(e){e.codec=()=>Ir(fi)})(st||(st={}));var jt;(function(e){let t;e.codec=()=>(t==null&&(t=Be((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),st.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=st.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>Te(r,e.codec()),e.decode=(r,n)=>Ce(r,e.codec(),n)})(jt||(jt={}));var li;(function(e){let t;e.codec=()=>(t==null&&(t=Be((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),st.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=st.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>Te(r,e.codec()),e.decode=(r,n)=>Ce(r,e.codec(),n)})(li||(li={}));var _r=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},mn=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var da={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new mn("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 Ie=da;var Dr={};St(Dr,{MAX_RSA_KEY_SIZE:()=>di,generateRSAKeyPair:()=>ya,jwkToJWKKeyPair:()=>ga,jwkToPkcs1:()=>dd,jwkToPkix:()=>yi,jwkToRSAPrivateKey:()=>bi,pkcs1MessageToJwk:()=>pi,pkcs1MessageToRSAPrivateKey:()=>gi,pkcs1ToJwk:()=>ld,pkcs1ToRSAPrivateKey:()=>ma,pkixMessageToJwk:()=>mi,pkixMessageToRSAPublicKey:()=>wi,pkixToJwk:()=>hd,pkixToRSAPublicKey:()=>xi});var sr=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=Dr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return J.createV1(114,this._multihash)}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:it(this.raw,t.raw)}verify(t,r){return pa(this.jwk,r,t)}},Ur=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=Dr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:it(this.raw,t.raw)}sign(t){return ha(this.jwk,t)}};var di=8192,hi=18,ud=1062,fd=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function ld(e){let t=Qt(e);return pi(t)}function pi(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 dd(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 ct("JWK was missing components");return pe([vt(Uint8Array.from([0])),vt(G(e.n,"base64url")),vt(G(e.e,"base64url")),vt(G(e.d,"base64url")),vt(G(e.p,"base64url")),vt(G(e.q,"base64url")),vt(G(e.dp,"base64url")),vt(G(e.dq,"base64url")),vt(G(e.qi,"base64url"))]).subarray()}function hd(e){let t=Qt(e,{offset:0});return mi(t)}function mi(e){let t=Qt(e[1],{offset:0});return{kty:"RSA",n:Y(t[0],"base64url"),e:Y(t[1],"base64url")}}function yi(e){if(e.n==null||e.e==null)throw new ct("JWK was missing components");return pe([fd,tn(pe([vt(G(e.n,"base64url")),vt(G(e.e,"base64url"))]))]).subarray()}function ma(e){let t=Qt(e);return gi(t)}function gi(e){let t=pi(e);return bi(t)}function xi(e,t){if(e.byteLength>=ud)throw new $e("Key size is too large");let r=Qt(e,{offset:0});return wi(r,e,t)}function wi(e,t,r){let n=mi(e);if(r==null){let o=Re(jt.encode({Type:st.RSA,Data:t}));r=Ft(hi,o)}return new sr(n,r)}function bi(e){if(wa(e)>di)throw new ct("Key size is too large");let t=ga(e),r=Re(jt.encode({Type:st.RSA,Data:yi(t.publicKey)})),n=Ft(hi,r);return new Ur(t.privateKey,new sr(t.publicKey,n))}async function ya(e){if(e>di)throw new ct("Key size is too large");let t=await xa(e),r=Re(jt.encode({Type:st.RSA,Data:yi(t.publicKey)})),n=Ft(hi,r);return new Ur(t.privateKey,new sr(t.publicKey,n))}function ga(e){if(e==null)throw new ct("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function xa(e){let t=await Ie.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await pd(t);return{privateKey:r[0],publicKey:r[1]}}async function ha(e,t){let r=await Ie.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Ie.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function pa(e,t,r){let n=await Ie.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Ie.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}async function pd(e){if(e.privateKey==null||e.publicKey==null)throw new ct("Private and public key are required");return Promise.all([Ie.get().subtle.exportKey("jwk",e.privateKey),Ie.get().subtle.exportKey("jwk",e.publicKey)])}function wa(e){if(e.kty!=="RSA")throw new ct("invalid key type");if(e.n==null)throw new ct("invalid key modulus");return G(e.n,"base64url").length*8}var yn=class extends er{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,Ss(t);let n=Er(r);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?t.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(t){return tr(this),this.iHash.update(t),this}digestInto(t){tr(this),Qe(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash: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}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ei=(e,t,r)=>new yn(e,t).update(r).digest();Ei.create=(e,t)=>new yn(e,t);function ba(e){e.lowS!==void 0&&Gt("lowS",e.lowS),e.prehash!==void 0&&Gt("prehash",e.prehash)}function md(e){let t=vr(e);re(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:o}=t;if(r){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var Si=class extends Error{constructor(t=""){super(t)}},ne={Err:Si,_tlv:{encode:(e,t)=>{let{Err:r}=ne;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=Sr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Sr(o.length/2|128):"";return Sr(e)+i+o+t},decode(e,t){let{Err:r}=ne,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}=ne;if(e<oe)throw new t("integer: negative integers are not allowed");let r=Sr(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}=ne;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 ee(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=ne,o=rt("signature",e),{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}=ne,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},oe=BigInt(0),lt=BigInt(1),Ny=BigInt(2),Ea=BigInt(3),Ly=BigInt(4);function yd(e){let t=md(e),{Fp:r}=t,n=Se(t.n,t.nBitLength),o=t.toBytes||((y,h,A)=>{let U=h.toAffine();return Ee(Uint8Array.from([4]),r.toBytes(U.x),r.toBytes(U.y))}),i=t.fromBytes||(y=>{let h=y.subarray(1),A=r.fromBytes(h.subarray(0,r.BYTES)),U=r.fromBytes(h.subarray(r.BYTES,2*r.BYTES));return{x:A,y:U}});function s(y){let{a:h,b:A}=t,U=r.sqr(y),g=r.mul(U,y);return r.add(r.add(g,r.mul(y,h)),A)}if(!r.eql(r.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return sn(y,lt,t.n)}function c(y){let{allowedPrivateKeyLengths:h,nByteLength:A,wrapPrivateKey:U,n:g}=t;if(h&&typeof y!="bigint"){if(Ne(y)&&(y=be(y)),typeof y!="string"||!h.includes(y.length))throw new Error("invalid private key");y=y.padStart(A*2,"0")}let D;try{D=typeof y=="bigint"?y:ee(rt("private key",y,A))}catch{throw new Error("invalid private key, expected hex or "+A+" bytes, got "+typeof y)}return U&&(D=Q(D,g)),It("private key",D,lt,g),D}function f(y){if(!(y instanceof d))throw new Error("ProjectivePoint expected")}let u=or((y,h)=>{let{px:A,py:U,pz:g}=y;if(r.eql(g,r.ONE))return{x:A,y:U};let D=y.is0();h==null&&(h=D?r.ONE:r.inv(g));let O=r.mul(A,h),k=r.mul(U,h),R=r.mul(g,h);if(D)return{x:r.ZERO,y:r.ZERO};if(!r.eql(R,r.ONE))throw new Error("invZ was invalid");return{x:O,y:k}}),l=or(y=>{if(y.is0()){if(t.allowInfinityPoint&&!r.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:h,y:A}=y.toAffine();if(!r.isValid(h)||!r.isValid(A))throw new Error("bad point: x or y not FE");let U=r.sqr(A),g=s(h);if(!r.eql(U,g))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(h,A,U){if(h==null||!r.isValid(h))throw new Error("x required");if(A==null||!r.isValid(A))throw new Error("y required");if(U==null||!r.isValid(U))throw new Error("z required");this.px=h,this.py=A,this.pz=U,Object.freeze(this)}static fromAffine(h){let{x:A,y:U}=h||{};if(!h||!r.isValid(A)||!r.isValid(U))throw new Error("invalid affine point");if(h instanceof d)throw new Error("projective point not allowed");let g=D=>r.eql(D,r.ZERO);return g(A)&&g(U)?d.ZERO:new d(A,U,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let A=r.invertBatch(h.map(U=>U.pz));return h.map((U,g)=>U.toAffine(A[g])).map(d.fromAffine)}static fromHex(h){let A=d.fromAffine(i(rt("pointHex",h)));return A.assertValidity(),A}static fromPrivateKey(h){return d.BASE.multiply(c(h))}static msm(h,A){return un(d,n,h,A)}_setWindowSize(h){v.setWindowSize(this,h)}assertValidity(){l(this)}hasEvenY(){let{y:h}=this.toAffine();if(r.isOdd)return!r.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){f(h);let{px:A,py:U,pz:g}=this,{px:D,py:O,pz:k}=h,R=r.eql(r.mul(A,k),r.mul(D,g)),x=r.eql(r.mul(U,k),r.mul(O,g));return R&&x}negate(){return new d(this.px,r.neg(this.py),this.pz)}double(){let{a:h,b:A}=t,U=r.mul(A,Ea),{px:g,py:D,pz:O}=this,k=r.ZERO,R=r.ZERO,x=r.ZERO,w=r.mul(g,g),K=r.mul(D,D),L=r.mul(O,O),_=r.mul(g,D);return _=r.add(_,_),x=r.mul(g,O),x=r.add(x,x),k=r.mul(h,x),R=r.mul(U,L),R=r.add(k,R),k=r.sub(K,R),R=r.add(K,R),R=r.mul(k,R),k=r.mul(_,k),x=r.mul(U,x),L=r.mul(h,L),_=r.sub(w,L),_=r.mul(h,_),_=r.add(_,x),x=r.add(w,w),w=r.add(x,w),w=r.add(w,L),w=r.mul(w,_),R=r.add(R,w),L=r.mul(D,O),L=r.add(L,L),w=r.mul(L,_),k=r.sub(k,w),x=r.mul(L,K),x=r.add(x,x),x=r.add(x,x),new d(k,R,x)}add(h){f(h);let{px:A,py:U,pz:g}=this,{px:D,py:O,pz:k}=h,R=r.ZERO,x=r.ZERO,w=r.ZERO,K=t.a,L=r.mul(t.b,Ea),_=r.mul(A,D),V=r.mul(U,O),E=r.mul(g,k),S=r.add(A,U),B=r.add(D,O);S=r.mul(S,B),B=r.add(_,V),S=r.sub(S,B),B=r.add(A,g);let b=r.add(D,k);return B=r.mul(B,b),b=r.add(_,E),B=r.sub(B,b),b=r.add(U,g),R=r.add(O,k),b=r.mul(b,R),R=r.add(V,E),b=r.sub(b,R),w=r.mul(K,B),R=r.mul(L,E),w=r.add(R,w),R=r.sub(V,w),w=r.add(V,w),x=r.mul(R,w),V=r.add(_,_),V=r.add(V,_),E=r.mul(K,E),B=r.mul(L,B),V=r.add(V,E),E=r.sub(_,E),E=r.mul(K,E),B=r.add(B,E),_=r.mul(V,B),x=r.add(x,_),_=r.mul(b,B),R=r.mul(S,R),R=r.sub(R,_),_=r.mul(S,V),w=r.mul(b,w),w=r.add(w,_),new d(R,x,w)}subtract(h){return this.add(h.negate())}is0(){return this.equals(d.ZERO)}wNAF(h){return v.wNAFCached(this,h,d.normalizeZ)}multiplyUnsafe(h){let{endo:A,n:U}=t;It("scalar",h,oe,U);let g=d.ZERO;if(h===oe)return g;if(this.is0()||h===lt)return this;if(!A||v.hasPrecomputes(this))return v.wNAFCachedUnsafe(this,h,d.normalizeZ);let{k1neg:D,k1:O,k2neg:k,k2:R}=A.splitScalar(h),x=g,w=g,K=this;for(;O>oe||R>oe;)O<&&(x=x.add(K)),R<&&(w=w.add(K)),K=K.double(),O>>=lt,R>>=lt;return D&&(x=x.negate()),k&&(w=w.negate()),w=new d(r.mul(w.px,A.beta),w.py,w.pz),x.add(w)}multiply(h){let{endo:A,n:U}=t;It("scalar",h,lt,U);let g,D;if(A){let{k1neg:O,k1:k,k2neg:R,k2:x}=A.splitScalar(h),{p:w,f:K}=this.wNAF(k),{p:L,f:_}=this.wNAF(x);w=v.constTimeNegate(O,w),L=v.constTimeNegate(R,L),L=new d(r.mul(L.px,A.beta),L.py,L.pz),g=w.add(L),D=K.add(_)}else{let{p:O,f:k}=this.wNAF(h);g=O,D=k}return d.normalizeZ([g,D])[0]}multiplyAndAddUnsafe(h,A,U){let g=d.BASE,D=(k,R)=>R===oe||R===lt||!k.equals(g)?k.multiplyUnsafe(R):k.multiply(R),O=D(this,A).add(D(h,U));return O.is0()?void 0:O}toAffine(h){return u(this,h)}isTorsionFree(){let{h,isTorsionFree:A}=t;if(h===lt)return!0;if(A)return A(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:A}=t;return h===lt?this:A?A(d,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return Gt("isCompressed",h),this.assertValidity(),o(d,this,h)}toHex(h=!0){return Gt("isCompressed",h),be(this.toRawBytes(h))}}d.BASE=new d(t.Gx,t.Gy,r.ONE),d.ZERO=new d(r.ZERO,r.ONE,r.ZERO);let T=t.nBitLength,v=cn(d,t.endo?Math.ceil(T/2):T);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function gd(e){let t=vr(e);return re(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Sa(e){let t=gd(e),{Fp:r,n}=t,o=r.BYTES+1,i=2*r.BYTES+1;function s(E){return Q(E,n)}function a(E){return an(E,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=yd({...t,toBytes(E,S,B){let b=S.toAffine(),m=r.toBytes(b.x),C=Ee;return Gt("isCompressed",B),B?C(Uint8Array.from([S.hasEvenY()?2:3]),m):C(Uint8Array.from([4]),m,r.toBytes(b.y))},fromBytes(E){let S=E.length,B=E[0],b=E.subarray(1);if(S===o&&(B===2||B===3)){let m=ee(b);if(!sn(m,lt,r.ORDER))throw new Error("Point is not on curve");let C=u(m),P;try{P=r.sqrt(C)}catch(z){let $=z instanceof Error?": "+z.message:"";throw new Error("Point is not on curve"+$)}let F=(P<)===lt;return(B&1)===1!==F&&(P=r.neg(P)),{x:m,y:P}}else if(S===i&&B===4){let m=r.fromBytes(b.subarray(0,r.BYTES)),C=r.fromBytes(b.subarray(r.BYTES,2*r.BYTES));return{x:m,y:C}}else{let m=o,C=i;throw new Error("invalid Point, expected length of "+m+", or uncompressed "+C+", got "+S)}}}),d=E=>be(Pe(E,t.nByteLength));function T(E){let S=n>>lt;return E>S}function v(E){return T(E)?s(-E):E}let y=(E,S,B)=>ee(E.slice(S,B));class h{constructor(S,B,b){It("r",S,lt,n),It("s",B,lt,n),this.r=S,this.s=B,b!=null&&(this.recovery=b),Object.freeze(this)}static fromCompact(S){let B=t.nByteLength;return S=rt("compactSignature",S,B*2),new h(y(S,0,B),y(S,B,2*B))}static fromDER(S){let{r:B,s:b}=ne.toSig(rt("DER",S));return new h(B,b)}assertValidity(){}addRecoveryBit(S){return new h(this.r,this.s,S)}recoverPublicKey(S){let{r:B,s:b,recovery:m}=this,C=k(rt("msgHash",S));if(m==null||![0,1,2,3].includes(m))throw new Error("recovery id invalid");let P=m===2||m===3?B+t.n:B;if(P>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let F=(m&1)===0?"02":"03",H=c.fromHex(F+d(P)),z=a(P),$=s(-C*z),j=s(b*z),W=c.BASE.multiplyAndAddUnsafe(H,$,j);if(!W)throw new Error("point at infinify");return W.assertValidity(),W}hasHighS(){return T(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Ar(this.toDERHex())}toDERHex(){return ne.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ar(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}let A={isValidPrivateKey(E){try{return f(E),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let E=zo(t.n);return Os(t.randomBytes(E),t.n)},precompute(E=8,S=c.BASE){return S._setWindowSize(E),S.multiply(BigInt(3)),S}};function U(E,S=!0){return c.fromPrivateKey(E).toRawBytes(S)}function g(E){let S=Ne(E),B=typeof E=="string",b=(S||B)&&E.length;return S?b===o||b===i:B?b===2*o||b===2*i:E instanceof c}function D(E,S,B=!0){if(g(E))throw new Error("first arg must be private key");if(!g(S))throw new Error("second arg must be public key");return c.fromHex(S).multiply(f(E)).toRawBytes(B)}let O=t.bits2int||function(E){if(E.length>8192)throw new Error("input is too large");let S=ee(E),B=E.length*8-t.nBitLength;return B>0?S>>BigInt(B):S},k=t.bits2int_modN||function(E){return s(O(E))},R=ke(t.nBitLength);function x(E){return It("num < 2^"+t.nBitLength,E,oe,R),Pe(E,t.nByteLength)}function w(E,S,B=K){if(["recovered","canonical"].some(ot=>ot in B))throw new Error("sign() legacy options not supported");let{hash:b,randomBytes:m}=t,{lowS:C,prehash:P,extraEntropy:F}=B;C==null&&(C=!0),E=rt("msgHash",E),ba(B),P&&(E=rt("prehashed msgHash",b(E)));let H=k(E),z=f(S),$=[x(z),x(H)];if(F!=null&&F!==!1){let ot=F===!0?m(r.BYTES):F;$.push(rt("extraEntropy",ot))}let j=Ee(...$),W=H;function at(ot){let ht=O(ot);if(!l(ht))return;let Et=a(ht),ft=c.BASE.multiply(ht).toAffine(),yt=s(ft.x);if(yt===oe)return;let Ct=s(Et*s(W+yt*z));if(Ct===oe)return;let Kt=(ft.x===yt?0:2)|Number(ft.y<),hr=Ct;return C&&T(Ct)&&(hr=v(Ct),Kt^=1),new h(yt,hr,Kt)}return{seed:j,k2sig:at}}let K={lowS:t.lowS,prehash:!1},L={lowS:t.lowS,prehash:!1};function _(E,S,B=K){let{seed:b,k2sig:m}=w(E,S,B),C=t;return Ns(C.hash.outputLen,C.nByteLength,C.hmac)(b,m)}c.BASE._setWindowSize(8);function V(E,S,B,b=L){let m=E;S=rt("msgHash",S),B=rt("publicKey",B);let{lowS:C,prehash:P,format:F}=b;if(ba(b),"strict"in b)throw new Error("options.strict was renamed to lowS");if(F!==void 0&&F!=="compact"&&F!=="der")throw new Error("format must be compact or der");let H=typeof m=="string"||Ne(m),z=!H&&!F&&typeof m=="object"&&m!==null&&typeof m.r=="bigint"&&typeof m.s=="bigint";if(!H&&!z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let $,j;try{if(z&&($=new h(m.r,m.s)),H){try{F!=="compact"&&($=h.fromDER(m))}catch(Kt){if(!(Kt instanceof ne.Err))throw Kt}!$&&F!=="der"&&($=h.fromCompact(m))}j=c.fromHex(B)}catch{return!1}if(!$||C&&$.hasHighS())return!1;P&&(S=t.hash(S));let{r:W,s:at}=$,ot=k(S),ht=a(at),Et=s(ot*ht),ft=s(W*ht),yt=c.BASE.multiplyAndAddUnsafe(j,Et,ft)?.toAffine();return yt?s(yt.x)===W:!1}return{CURVE:t,getPublicKey:U,getSharedSecret:D,sign:_,verify:V,ProjectivePoint:c,Signature:h,utils:A}}function xd(e){return{hash:e,hmac:(t,...r)=>Ei(e,t,Do(...r)),randomBytes:nn}}function Aa(e,t){let r=n=>Sa({...e,...xd(n)});return{...r(t),create:r}}var Ta=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),va=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),wd=BigInt(1),Ai=BigInt(2),Ca=(e,t)=>(e+t/Ai)/t;function bd(e){let t=Ta,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=et(u,r,t)*u%t,d=et(l,r,t)*u%t,T=et(d,Ai,t)*f%t,v=et(T,o,t)*T%t,y=et(v,i,t)*v%t,h=et(y,a,t)*y%t,A=et(h,c,t)*h%t,U=et(A,a,t)*y%t,g=et(U,r,t)*u%t,D=et(g,s,t)*v%t,O=et(D,n,t)*f%t,k=et(O,Ai,t);if(!vi.eql(vi.sqr(k),e))throw new Error("Cannot find square root");return k}var vi=Se(Ta,void 0,void 0,{sqrt:bd}),Me=Aa({a:BigInt(0),b:BigInt(7),Fp:vi,n:va,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{let t=va,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-wd*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=Ca(i*e,t),c=Ca(-n*e,t),f=Q(e-a*r-c*o,t),u=Q(-a*n-c*i,t),l=f>s,d=u>s;if(l&&(f=t-f),d&&(u=t-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:l,k1:f,k2neg:d,k2:u}}}},Re),Hy=BigInt(0);var zy=Me.ProjectivePoint;function Ba(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}function Ia(e,t,r){let n=xr.digest(r instanceof Uint8Array?r:r.subarray());if(Ba(n))return n.then(({digest:o})=>Me.verify(t,o,e)).catch(o=>{throw new _r(String(o))});try{return Me.verify(t,n.digest,e)}catch(o){throw new _r(String(o))}}var gn=class{type="secp256k1";raw;_key;constructor(t){this._key=Ua(t),this.raw=_a(this._key)}toMultihash(){return Mt.digest(me(this))}toCID(){return J.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:it(this.raw,t.raw)}verify(t,r){return Ia(this._key,r,t)}};function Ci(e){return new gn(e)}function _a(e){return Me.ProjectivePoint.fromHex(e).toRawBytes(!0)}function Ua(e){try{return Me.ProjectivePoint.fromHex(e),e}catch(t){throw new $e(String(t))}}function Da(e,t){let{Type:r,Data:n}=jt.decode(e),o=n??new Uint8Array;switch(r){case st.RSA:return xi(o,t);case st.Ed25519:return Jo(o);case st.secp256k1:return Ci(o);case st.ECDSA:return Uo(o);default:throw new Ze}}function xn(e){let{Type:t,Data:r}=jt.decode(e.digest),n=r??new Uint8Array;switch(t){case st.Ed25519:return Jo(n);case st.secp256k1:return Ci(n);case st.ECDSA:return Uo(n);default:throw new Ze}}function me(e){return jt.encode({Type:st[e.type],Data:e.raw})}var Ra=Symbol.for("nodejs.util.inspect.custom"),Ed=114,Rr=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Qn]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return J.createV1(Ed,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return it(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return it(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Ra](){return`PeerId(${this.toString()})`}},wn=class extends Rr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},bn=class extends Rr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},En=class extends Rr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Sd=2336,Nr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Mt.digest(G(this.url))}[Ra](){return`PeerId(${this.url})`}[Qn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return J.createV1(Sd,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=Y(t)),t.toString()===this.toString())}};var Ad=114,Na=2336;function Sn(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=Jt(X.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return Ti(J.parse(e));if(t==null)throw new ct('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=Jt(t.decode(e))}return La(r)}function La(e){if(Cd(e))return new wn({multihash:e});if(vd(e))try{let t=xn(e);if(t.type==="Ed25519")return new bn({multihash:e,publicKey:t});if(t.type==="secp256k1")return new En({multihash:e,publicKey:t})}catch{let r=Y(e.digest);return new Nr(new URL(r))}throw new Ge("Supplied PeerID Multihash is invalid")}function Ti(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==Ad&&e.code!==Na)throw new Zr("Supplied PeerID CID is invalid");if(e.code===Na){let t=Y(e.multihash.digest);return new Nr(new URL(t))}return La(e.multihash)}function vd(e){return e.code===Mt.code}function Cd(e){return e.code===xr.code}var ie="/",Pa=new TextEncoder().encode(ie),An=Pa[0],Lr=class e{_buf;constructor(t,r){if(typeof t=="string")this._buf=G(t);else if(t instanceof Uint8Array)this._buf=t;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==An)throw new Error("Invalid key")}toString(t="utf8"){return Y(this._buf,t)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(t){return new e(t.join(ie))}static random(){return new e(Math.random().toString().substring(2))}static asKey(t){return t instanceof Uint8Array||typeof t=="string"?new e(t):typeof t.uint8Array=="function"?new e(t.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=Pa),this._buf[0]!==An){let t=new Uint8Array(this._buf.byteLength+1);t.fill(An,0,1),t.set(this._buf,1),this._buf=t}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===An;)this._buf=this._buf.subarray(0,-1)}less(t){let r=this.list(),n=t.list();for(let o=0;o<r.length;o++){if(n.length<o+1)return!1;let i=r[o],s=n[o];if(i<s)return!0;if(i>s)return!1}return r.length<n.length}reverse(){return e.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let t=this.namespaces();return t[t.length-1]}list(){return this.toString().split(ie).slice(1)}type(){return Td(this.baseNamespace())}name(){return Bd(this.baseNamespace())}instance(t){return new e(this.toString()+":"+t)}path(){let t=this.parent().toString();return t.endsWith(ie)||(t+=ie),t+=this.type(),new e(t)}parent(){let t=this.list();return t.length===1?new e(ie):new e(t.slice(0,-1).join(ie))}child(t){return this.toString()===ie?t:t.toString()===ie?this:new e(this.toString()+t.toString(),!1)}isAncestorOf(t){return t.toString()===this.toString()?!1:t.toString().startsWith(this.toString())}isDecendantOf(t){return t.toString()===this.toString()?!1:this.toString().startsWith(t.toString())}isTopLevel(){return this.list().length===1}concat(...t){return e.withNamespaces([...this.namespaces(),...Id(t.map(r=>r.namespaces()))])}};function Td(e){let t=e.split(":");return t.length<2?"":t.slice(0,-1).join(":")}function Bd(e){let t=e.split(":");return t[t.length-1]}function Id(e){return[].concat(...e)}var Zc=Gr(vn(),1);var Cn=class extends Error{static name="SignatureCreationError";constructor(t="Record signature creation failed"){super(t),this.name="SignatureCreationError"}},Ht=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},Tn=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},Ve=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},Bn=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},Pr=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},In=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},kr=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var pt;(function(e){let t;(function(o){o.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),function(o){o.codec=()=>Ir(r)}(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=Be((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),e.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let f=o.uint32();switch(f>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=e.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(f&7);break}}}return a})),n),e.encode=o=>Te(o,e.codec()),e.decode=(o,i)=>Ce(o,e.codec(),i)})(pt||(pt={}));var _d=["string","number","bigint","symbol"],Ud=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function ka(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(_d.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Dd(e))return"Buffer";let r=Rd(e);return r||"Object"}function Dd(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Rd(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Ud.includes(t))return t}var p=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};p.uint=new p(0,"uint",!0);p.negint=new p(1,"negint",!0);p.bytes=new p(2,"bytes",!0);p.string=new p(3,"string",!0);p.array=new p(4,"array",!1);p.map=new p(5,"map",!1);p.tag=new p(6,"tag",!1);p.float=new p(7,"float",!0);p.false=new p(7,"false",!0);p.true=new p(7,"true",!0);p.null=new p(7,"null",!0);p.undefined=new p(7,"undefined",!0);p.break=new p(7,"break",!0);var N=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var ar=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Nd=new TextDecoder,Ld=new TextEncoder;function _n(e){return ar&&globalThis.Buffer.isBuffer(e)}function Ii(e){return e instanceof Uint8Array?_n(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Ma=ar?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Oa(e,t,r):(e,t,r)=>r-t>64?Nd.decode(e.subarray(t,r)):Oa(e,t,r),Va=ar?e=>e.length>64?globalThis.Buffer.from(e):Ka(e):e=>e.length>64?Ld.encode(e):Ka(e),Yt=e=>Uint8Array.from(e),cr=ar?(e,t,r)=>_n(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),qa=ar?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Ii(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Ha=ar?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function za(e,t){if(_n(e)&&_n(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Ka(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function Oa(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,s=o>239?4:o>223?3:o>191?2:1;if(t+s<=r){let a,c,f,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=e[t+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=e[t+1],c=e[t+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=e[t+1],c=e[t+2],f=e[t+3],(a&192)===128&&(c&192)===128&&(f&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|f&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=s}return Pd(n)}var Fa=4096;function Pd(e){let t=e.length;if(t<=Fa)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Fa));return r}var kd=256,Kr=class{constructor(t=kd){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=Ha(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=cr(n,0,this.cursor)}else r=qa(this.chunks,this.cursor);return t&&this.reset(),r}};var M="CBOR decode error:",_i="CBOR encode error:",Or=[];Or[23]=1;Or[24]=2;Or[25]=3;Or[26]=5;Or[27]=9;function se(e,t,r){if(e.length-t<r)throw new Error(`${M} not enough data for type`)}var dt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Ut(e,t,r){se(e,t,1);let n=e[t];if(r.strict===!0&&n<dt[0])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Dt(e,t,r){se(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<dt[1])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Rt(e,t,r){se(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<dt[2])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Nt(e,t,r){se(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<dt[3])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${M} integers outside of the safe integer range are not supported`)}function $a(e,t,r,n){return new N(p.uint,Ut(e,t+1,n),2)}function Ga(e,t,r,n){return new N(p.uint,Dt(e,t+1,n),3)}function Za(e,t,r,n){return new N(p.uint,Rt(e,t+1,n),5)}function ja(e,t,r,n){return new N(p.uint,Nt(e,t+1,n),9)}function Pt(e,t){return mt(e,0,t.value)}function mt(e,t,r){if(r<dt[0]){let n=Number(r);e.push([t|n])}else if(r<dt[1]){let n=Number(r);e.push([t|24,n])}else if(r<dt[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<dt[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<dt[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${M} encountered BigInt larger than allowable range`)}}Pt.encodedSize=function(t){return mt.encodedSize(t.value)};mt.encodedSize=function(t){return t<dt[0]?1:t<dt[1]?2:t<dt[2]?3:t<dt[3]?5:9};Pt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Ya(e,t,r,n){return new N(p.negint,-1-Ut(e,t+1,n),2)}function Wa(e,t,r,n){return new N(p.negint,-1-Dt(e,t+1,n),3)}function Xa(e,t,r,n){return new N(p.negint,-1-Rt(e,t+1,n),5)}var Ui=BigInt(-1),Ja=BigInt(1);function Qa(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new N(p.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${M} integers outside of the safe integer range are not supported`);return new N(p.negint,Ui-BigInt(o),9)}function Un(e,t){let r=t.value,n=typeof r=="bigint"?r*Ui-Ja:r*-1-1;mt(e,t.type.majorEncoded,n)}Un.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Ui-Ja:r*-1-1;return n<dt[0]?1:n<dt[1]?2:n<dt[2]?3:n<dt[3]?5:9};Un.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function Fr(e,t,r,n){se(e,t,r+n);let o=cr(e,t+r,t+r+n);return new N(p.bytes,o,r+n)}function tc(e,t,r,n){return Fr(e,t,1,r)}function ec(e,t,r,n){return Fr(e,t,2,Ut(e,t+1,n))}function rc(e,t,r,n){return Fr(e,t,3,Dt(e,t+1,n))}function nc(e,t,r,n){return Fr(e,t,5,Rt(e,t+1,n))}function oc(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer bytes lengths not supported`);return Fr(e,t,9,o)}function Dn(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===p.string?Va(e.value):e.value),e.encodedBytes}function ur(e,t){let r=Dn(t);mt(e,t.type.majorEncoded,r.length),e.push(r)}ur.encodedSize=function(t){let r=Dn(t);return mt.encodedSize(r.length)+r.length};ur.compareTokens=function(t,r){return Od(Dn(t),Dn(r))};function Od(e,t){return e.length<t.length?-1:e.length>t.length?1:za(e,t)}function Mr(e,t,r,n,o){let i=r+n;se(e,t,i);let s=new N(p.string,Ma(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=cr(e,t+r,t+i)),s}function ic(e,t,r,n){return Mr(e,t,1,r,n)}function sc(e,t,r,n){return Mr(e,t,2,Ut(e,t+1,n),n)}function ac(e,t,r,n){return Mr(e,t,3,Dt(e,t+1,n),n)}function cc(e,t,r,n){return Mr(e,t,5,Rt(e,t+1,n),n)}function uc(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer string lengths not supported`);return Mr(e,t,9,o,n)}var fc=ur;function fr(e,t,r,n){return new N(p.array,n,r)}function lc(e,t,r,n){return fr(e,t,1,r)}function dc(e,t,r,n){return fr(e,t,2,Ut(e,t+1,n))}function hc(e,t,r,n){return fr(e,t,3,Dt(e,t+1,n))}function pc(e,t,r,n){return fr(e,t,5,Rt(e,t+1,n))}function mc(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer array lengths not supported`);return fr(e,t,9,o)}function yc(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return fr(e,t,1,1/0)}function Rn(e,t){mt(e,p.array.majorEncoded,t.value)}Rn.compareTokens=Pt.compareTokens;Rn.encodedSize=function(t){return mt.encodedSize(t.value)};function lr(e,t,r,n){return new N(p.map,n,r)}function gc(e,t,r,n){return lr(e,t,1,r)}function xc(e,t,r,n){return lr(e,t,2,Ut(e,t+1,n))}function wc(e,t,r,n){return lr(e,t,3,Dt(e,t+1,n))}function bc(e,t,r,n){return lr(e,t,5,Rt(e,t+1,n))}function Ec(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer map lengths not supported`);return lr(e,t,9,o)}function Sc(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return lr(e,t,1,1/0)}function Nn(e,t){mt(e,p.map.majorEncoded,t.value)}Nn.compareTokens=Pt.compareTokens;Nn.encodedSize=function(t){return mt.encodedSize(t.value)};function Ac(e,t,r,n){return new N(p.tag,r,1)}function vc(e,t,r,n){return new N(p.tag,Ut(e,t+1,n),2)}function Cc(e,t,r,n){return new N(p.tag,Dt(e,t+1,n),3)}function Tc(e,t,r,n){return new N(p.tag,Rt(e,t+1,n),5)}function Bc(e,t,r,n){return new N(p.tag,Nt(e,t+1,n),9)}function Ln(e,t){mt(e,p.tag.majorEncoded,t.value)}Ln.compareTokens=Pt.compareTokens;Ln.encodedSize=function(t){return mt.encodedSize(t.value)};var zd=20,$d=21,Gd=22,Zd=23;function Ic(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${M} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new N(p.null,null,1):new N(p.undefined,void 0,1)}function _c(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return new N(p.break,void 0,1)}function Di(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${M} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${M} Infinity values are not supported`)}return new N(p.float,e,t)}function Uc(e,t,r,n){return Di(Ri(e,t+1),3,n)}function Dc(e,t,r,n){return Di(Ni(e,t+1),5,n)}function Rc(e,t,r,n){return Di(kc(e,t+1),9,n)}function Pn(e,t,r){let n=t.value;if(n===!1)e.push([p.float.majorEncoded|zd]);else if(n===!0)e.push([p.float.majorEncoded|$d]);else if(n===null)e.push([p.float.majorEncoded|Gd]);else if(n===void 0)e.push([p.float.majorEncoded|Zd]);else{let o,i=!1;(!r||r.float64!==!0)&&(Lc(n),o=Ri(zt,1),n===o||Number.isNaN(n)?(zt[0]=249,e.push(zt.slice(0,3)),i=!0):(Pc(n),o=Ni(zt,1),n===o&&(zt[0]=250,e.push(zt.slice(0,5)),i=!0))),i||(jd(n),o=kc(zt,1),zt[0]=251,e.push(zt.slice(0,9)))}}Pn.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Lc(n);let o=Ri(zt,1);if(n===o||Number.isNaN(n))return 3;if(Pc(n),o=Ni(zt,1),n===o)return 5}return 9};var Nc=new ArrayBuffer(9),kt=new DataView(Nc,1),zt=new Uint8Array(Nc,0);function Lc(e){if(e===1/0)kt.setUint16(0,31744,!1);else if(e===-1/0)kt.setUint16(0,64512,!1);else if(Number.isNaN(e))kt.setUint16(0,32256,!1);else{kt.setFloat32(0,e);let t=kt.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)kt.setUint16(0,31744,!1);else if(r===0)kt.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?kt.setUint16(0,0):o<-14?kt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):kt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Ri(e,t){if(e.length-t<2)throw new Error(`${M} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function Pc(e){kt.setFloat32(0,e,!1)}function Ni(e,t){if(e.length-t<4)throw new Error(`${M} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function jd(e){kt.setFloat64(0,e,!1)}function kc(e,t){if(e.length-t<8)throw new Error(`${M} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Pn.compareTokens=Pt.compareTokens;function Z(e,t,r){throw new Error(`${M} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function kn(e){return()=>{throw new Error(`${M} ${e}`)}}var I=[];for(let e=0;e<=23;e++)I[e]=Z;I[24]=$a;I[25]=Ga;I[26]=Za;I[27]=ja;I[28]=Z;I[29]=Z;I[30]=Z;I[31]=Z;for(let e=32;e<=55;e++)I[e]=Z;I[56]=Ya;I[57]=Wa;I[58]=Xa;I[59]=Qa;I[60]=Z;I[61]=Z;I[62]=Z;I[63]=Z;for(let e=64;e<=87;e++)I[e]=tc;I[88]=ec;I[89]=rc;I[90]=nc;I[91]=oc;I[92]=Z;I[93]=Z;I[94]=Z;I[95]=kn("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)I[e]=ic;I[120]=sc;I[121]=ac;I[122]=cc;I[123]=uc;I[124]=Z;I[125]=Z;I[126]=Z;I[127]=kn("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)I[e]=lc;I[152]=dc;I[153]=hc;I[154]=pc;I[155]=mc;I[156]=Z;I[157]=Z;I[158]=Z;I[159]=yc;for(let e=160;e<=183;e++)I[e]=gc;I[184]=xc;I[185]=wc;I[186]=bc;I[187]=Ec;I[188]=Z;I[189]=Z;I[190]=Z;I[191]=Sc;for(let e=192;e<=215;e++)I[e]=Ac;I[216]=vc;I[217]=Cc;I[218]=Tc;I[219]=Bc;I[220]=Z;I[221]=Z;I[222]=Z;I[223]=Z;for(let e=224;e<=243;e++)I[e]=kn("simple values are not supported");I[244]=Z;I[245]=Z;I[246]=Z;I[247]=Ic;I[248]=kn("simple values are not supported");I[249]=Uc;I[250]=Dc;I[251]=Rc;I[252]=Z;I[253]=Z;I[254]=Z;I[255]=_c;var $t=[];for(let e=0;e<24;e++)$t[e]=new N(p.uint,e,1);for(let e=-1;e>=-24;e--)$t[31-e]=new N(p.negint,e,1);$t[64]=new N(p.bytes,new Uint8Array(0),1);$t[96]=new N(p.string,"",1);$t[128]=new N(p.array,0,1);$t[160]=new N(p.map,0,1);$t[244]=new N(p.false,!1,1);$t[245]=new N(p.true,!0,1);$t[246]=new N(p.null,null,1);function Kc(e){switch(e.type){case p.false:return Yt([244]);case p.true:return Yt([245]);case p.null:return Yt([246]);case p.bytes:return e.value.length?void 0:Yt([64]);case p.string:return e.value===""?Yt([96]):void 0;case p.array:return e.value===0?Yt([128]):void 0;case p.map:return e.value===0?Yt([160]):void 0;case p.uint:return e.value<24?Yt([Number(e.value)]):void 0;case p.negint:if(e.value>=-24)return Yt([31-Number(e.value)])}}var Wd={float64:!1,mapSorter:Qd,quickEncodeToken:Kc};function Xd(){let e=[];return e[p.uint.major]=Pt,e[p.negint.major]=Un,e[p.bytes.major]=ur,e[p.string.major]=fc,e[p.array.major]=Rn,e[p.map.major]=Nn,e[p.tag.major]=Ln,e[p.float.major]=Pn,e}var Oc=Xd(),Li=new Kr,On=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${_i} object contains circular references`);return new e(r,t)}},_e={null:new N(p.null,null),undefined:new N(p.undefined,void 0),true:new N(p.true,!0),false:new N(p.false,!1),emptyArray:new N(p.array,0),emptyMap:new N(p.map,0)},Ue={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new N(p.float,e):e>=0?new N(p.uint,e):new N(p.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new N(p.uint,e):new N(p.negint,e)},Uint8Array(e,t,r,n){return new N(p.bytes,e)},string(e,t,r,n){return new N(p.string,e)},boolean(e,t,r,n){return e?_e.true:_e.false},null(e,t,r,n){return _e.null},undefined(e,t,r,n){return _e.undefined},ArrayBuffer(e,t,r,n){return new N(p.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new N(p.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[_e.emptyArray,new N(p.break)]:_e.emptyArray;n=On.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=Kn(s,r,n);return r.addBreakTokens?[new N(p.array,e.length),o,new N(p.break)]:[new N(p.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),s=o?e.size:i.length;if(!s)return r.addBreakTokens===!0?[_e.emptyMap,new N(p.break)]:_e.emptyMap;n=On.createCheck(n,e);let a=[],c=0;for(let f of i)a[c++]=[Kn(f,r,n),Kn(o?e.get(f):e[f],r,n)];return Jd(a,r),r.addBreakTokens?[new N(p.map,s),a,new N(p.break)]:[new N(p.map,s),a]}};Ue.Map=Ue.Object;Ue.Buffer=Ue.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Ue[`${e}Array`]=Ue.DataView;function Kn(e,t={},r){let n=ka(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Ue[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Ue[n];if(!i)throw new Error(`${_i} unsupported type: ${n}`);return i(e,n,t,r)}function Jd(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Qd(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=Oc[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Fc(e,t,r,n){if(Array.isArray(t))for(let o of t)Fc(e,o,r,n);else r[t.type.major](e,t,n)}function th(e,t,r){let n=Kn(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,r),a=new Kr(s);if(i(a,n,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Ii(a.chunks[0])}}return Li.reset(),Fc(Li,n,t,r),Li.toBytes(!0)}function Pi(e,t){return t=Object.assign({},Wd,t),th(e,Oc,t)}var eh={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Fn=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=$t[t];if(r===void 0){let n=I[t];if(!n)throw new Error(`${M} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},Vr=Symbol.for("DONE"),Mn=Symbol.for("BREAK");function rh(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=dr(t,r);if(i===Mn){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed array`)}if(i===Vr)throw new Error(`${M} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function nh(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<e.value;s++){let a=dr(t,r);if(a===Mn){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed map`)}if(a===Vr)throw new Error(`${M} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${M} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${M} found repeat map key "${a}"`);let c=dr(t,r);if(c===Vr)throw new Error(`${M} found map but not enough entries (got ${s} [no value], expected ${e.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function dr(e,t){if(e.done())return Vr;let r=e.next();if(r.type===p.break)return Mn;if(r.type.terminal)return r.value;if(r.type===p.array)return rh(r,e,t);if(r.type===p.map)return nh(r,e,t);if(r.type===p.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=dr(e,t);return t.tags[r.value](n)}throw new Error(`${M} tag not supported (${r.value})`)}throw new Error("unsupported")}function Mc(e,t){if(!(e instanceof Uint8Array))throw new Error(`${M} data to decode must be a Uint8Array`);t=Object.assign({},eh,t);let r=t.tokenizer||new Fn(e,t),n=dr(r,t);if(n===Vr)throw new Error(`${M} did not find any content to decode`);if(n===Mn)throw new Error(`${M} got unexpected break`);return[n,e.subarray(r.pos())]}function ki(e,t){let[r,n]=Mc(e,t);if(n.length>0)throw new Error(`${M} too many terminals, data makes no sense`);return r}var ih=le("ipns:utils"),Vc=G("/ipns/"),sh=114,ah=0,ch=18;function qr(e){let t;if(e.pubKey!=null)try{t=Da(e.pubKey)}catch(r){throw ih.error(r),r}if(t!=null)return t}function qc(e,t,r){let n=G(t);return he([e,r,n])}function qn(e){let t=G("ipns-signature:");return he([t,e])}function Hn(e){return"signatureV1"in e?pt.encode({value:G(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:G(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):pt.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function Wt(e){let t=pt.decode(e);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new Ht("Missing data or signatureV2");let r=$c(t.data),n=uh(r.Value),o=Y(r.Validity);if(t.value!=null&&t.signatureV1!=null)return fh(t),{value:n,validityType:pt.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV1:t.signatureV1,signatureV2:t.signatureV2,data:t.data};if(t.signatureV2!=null)return{value:n,validityType:pt.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function He(e){return he([Vc,e.bytes])}function Hc(e){let t=Jt(e.slice(Vc.length));if(!Vn(t,ah)&&!Vn(t,ch))throw new Ge("Multihash in IPNS key was not identity or sha2-256");return t}function zc(e,t,r,n,o){let i;if(t===pt.ValidityType.EOL)i=0;else throw new Ve("The validity type is unsupported");return Pi({Value:e,Validity:r,ValidityType:i,Sequence:n,TTL:o})}function $c(e){let t=ki(e);if(t.ValidityType===0)t.ValidityType=pt.ValidityType.EOL;else throw new Ve("The validity type is unsupported");return Number.isInteger(t.Sequence)&&(t.Sequence=BigInt(t.Sequence)),Number.isInteger(t.TTL)&&(t.TTL=BigInt(t.TTL)),t}function uh(e){let t=Y(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${J.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${J.parse(t).toV1().toString()}`}catch{}throw new Pr("Value must be a valid content path starting with /")}function Gc(e){if(e!=null){let t=hh(e);if(t!=null)return t.code===sh?`/ipns/${t.toString(Ot)}`:`/ipfs/${t.toV1().toString()}`;if(lh(e))return`/ipns/${Ot.encode(e.bytes)}`;let r=e.toString().trim();if(r.startsWith("/")&&r.length>1)return r}throw new Pr("Value must be a valid content path starting with /")}function fh(e){if(e.data==null)throw new In("Record data is missing");let t=$c(e.data);if(!it(t.Value,e.value??new Uint8Array(0)))throw new Ht('Field "value" did not match between protobuf and CBOR');if(!it(t.Validity,e.validity??new Uint8Array(0)))throw new Ht('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Ht('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Ht('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Ht('Field "ttl" did not match between protobuf and CBOR')}function lh(e){return e.bytes instanceof Uint8Array}function dh(e){return typeof e?.toCID=="function"}function hh(e){if(dh(e))return e.toCID();try{return J.parse(e)}catch{}return J.asCID(e)}function Vn(e,t){return e.code===t}var ph=le("ipns"),jc=5*60*1e9,mh="/ipns/",ww=mh.length,Yc={v1Compatible:!0,ttlNs:jc};async function Wc(e,t,r,n,o=Yc){let i=new Zc.default(Date.now()+Number(n)),s=pt.ValidityType.EOL,a=BigInt(o.ttlNs??jc);return yh(e,t,r,s,i.toString(),a,o)}var yh=async(e,t,r,n,o,i,s=Yc)=>{r=BigInt(r);let a=G(o),c=Gc(t),f=G(c),u=zc(f,n,a,r,i),l=qn(u),d=await e.sign(l),T;if(e.type==="RSA"&&(T=me(e.publicKey)),s.v1Compatible===!0){let v=await gh(e,f,n,a),y={value:c,signatureV1:v,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:d,data:u};return T!=null&&(y.pubKey=T),y}else{let v={value:c,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:d,data:u};return T!=null&&(v.pubKey=T),v}},gh=async(e,t,r,n)=>{try{let o=qc(t,r,n);return await e.sign(o)}catch(o){throw ph.error("record signature creation failed",o),new Cn("Record signature creation failed")}};var Ki=Gr(vn(),1);function zn(e,t){let r=t.map((n,o)=>({record:Wt(n),index:o}));return r.sort((n,o)=>{let i=n.record.sequence,s=o.record.sequence;if(i>s)return-1;if(i<s)return 1;if(n.record.validityType===pt.ValidityType.EOL&&o.record.validityType===pt.ValidityType.EOL){let a=Ki.default.fromString(n.record.validity).toDate(),c=Ki.default.fromString(o.record.validity).toDate();if(a.getTime()>c.getTime())return-1;if(a.getTime()<c.getTime())return 1}return 0}),r[0].index}var Xc=Gr(vn(),1);var $n=le("ipns:validator"),xh=1024*10,wh=async(e,t)=>{let r=Wt(t),n;try{let o=qn(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw $n.error("record signature verification failed"),new Ht("Record signature verification failed");if(r.validityType===pt.ValidityType.EOL){if(Xc.default.fromString(r.validity).toDate().getTime()<Date.now())throw $n.error("record has expired"),new Tn("record has expired")}else if(r.validityType!=null)throw $n.error("the validity type is unsupported"),new Ve("The validity type is unsupported");$n("ipns record for %s is valid",r.value)};async function Hr(e,t){if(t.byteLength>xh)throw new Bn("The record is too large");let r=Hc(e),n;Vn(r,0)&&(n=xn(r));let o=Wt(t),i=qr(o)??n;if(i==null)throw new kr("Could not extract public key from IPNS record or routing key");let s=He(i.toMultihash());if(!it(s,e))throw new kr("Embedded public key did not match routing key");await wh(i,t)}var xt=class extends Event{type;detail;constructor(t,r){super(t),this.type=t,this.detail=r}};var Sh=Gr(Qc(),1);var ae;(function(e){e[e.A=1]="A",e[e.CNAME=5]="CNAME",e[e.TXT=16]="TXT",e[e.AAAA=28]="AAAA"})(ae||(ae={}));var Gn=class extends Error{static name="DNSLinkNotFoundError";constructor(t="DNSLink not found"){super(t),this.name="DNSLinkNotFoundError"}},Zn=class extends Error{static name="RecordsFailedValidationError";constructor(t="Records failed validation"){super(t),this.name="RecordsFailedValidationError"}},jn=class extends Error{static name="UnsupportedMultibasePrefixError";constructor(t="Unsupported multibase prefix"){super(t),this.name="UnsupportedMultibasePrefixError"}},Yn=class extends Error{static name="UnsupportedMultihashCodecError";constructor(t="Unsupported multihash codec"){super(t),this.name="UnsupportedMultihashCodecError"}},Wn=class extends Error{static name="InvalidValueError";constructor(t="Invalid value"){super(t),this.name="InvalidValueError"}};var Ah=32;async function tu(e,t,r,n,o={}){if(t===0)throw new Error("recursion limit exceeded");n("query %s for TXT and CNAME records",e);let s=((await r.query(e,{...o,types:[ae.TXT]}))?.Answer??[]).sort((f,u)=>f.data.localeCompare(u.data));n("found %d TXT records for %s",s.length,e);for(let f of s)try{let u=f.data;if(u.startsWith('"')&&u.endsWith('"')&&(u=u.substring(1,u.length-1)),!u.startsWith("dnslink="))continue;n("%s TXT %s",f.name,u),u=u.replace("dnslink=","");let[,l,d,...T]=u.split("/");if(l==="ipfs")try{return{value:`/ipfs/${J.parse(d)}${T.length>0?`/${T.join("/")}`:""}`,answer:f}}catch{}else if(l==="ipns"){try{let v;return d.charAt(0)==="1"||d.charAt(0)==="Q"?v=Sn(d):v=Ti(J.parse(d)),{value:`/ipns/${v}${T.length>0?`/${T.join("/")}`:""}`,answer:f}}catch{}return await Xn(d,t-1,r,n,o)}else{if(l==="dnslink")return await Xn(d,t-1,r,n,o);n('unknown protocol "%s" in DNSLink record for domain: %s',l,e);continue}}catch(u){n.error("could not parse DNS link record for domain %s, %s",e,f.data,u)}n("no DNSLink records found for %s, falling back to CNAME",e);let c=((await r.query(e,{...o,types:[ae.CNAME]}))?.Answer??[]).sort((f,u)=>f.data.localeCompare(u.data));n("found %d CNAME records for %s",c.length,e);for(let f of c)try{return await Xn(f.data,t-1,r,n,o)}catch(u){n.error("domain %s cname %s had no DNSLink records",e,f.data,u)}throw new Gn(`No DNSLink records found for domain: ${e}`)}async function Xn(e,t,r,n,o={}){if(t===0)throw new Error("recursion limit exceeded");e.startsWith("_dnslink.")||(e=`_dnslink.${e}`);try{return await tu(e,t,r,n,o)}catch(i){if(i.code!=="ENOTFOUND"&&i.code!=="ENODATA"&&i.name!=="DNSLinkNotFoundError"&&i.name!=="NotFoundError")throw i;return e.startsWith("_dnslink.")?e=e.replace("_dnslink.",""):e=`_dnslink.${e}`,tu(e,t,r,n,o)}}async function eu(e,t,r,n={}){return Xn(e,n.maxRecursiveDepth??Ah,t,r,n)}var Oi=class{routing;constructor(t){this.routing=t}async put(t,r,n={}){try{await this.routing.put(t,r,n)}catch(o){n.onProgress?.(new xt("ipns:routing:helia:error",o))}}async get(t,r={}){try{return await this.routing.get(t,r)}catch(n){r.onProgress?.(new xt("ipns:routing:helia:error",n))}throw new Error("Not found")}};function ru(e){return new Oi(e)}var zr;(function(e){let t;e.codec=()=>(t==null&&(t=Be((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.key!=null&&r.key.byteLength>0&&(n.uint32(10),n.bytes(r.key)),r.value!=null&&r.value.byteLength>0&&(n.uint32(18),n.bytes(r.value)),r.timeReceived!=null&&r.timeReceived!==""&&(n.uint32(42),n.string(r.timeReceived)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={key:Lt(0),value:Lt(0),timeReceived:""},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.key=r.bytes();break}case 2:{i.value=r.bytes();break}case 5:{i.timeReceived=r.string();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>Te(r,e.codec()),e.decode=(r,n)=>Ce(r,e.codec(),n)})(zr||(zr={}));function nu(e){let t=e.getUTCFullYear(),r=String(e.getUTCMonth()+1).padStart(2,"0"),n=String(e.getUTCDate()).padStart(2,"0"),o=String(e.getUTCHours()).padStart(2,"0"),i=String(e.getUTCMinutes()).padStart(2,"0"),s=String(e.getUTCSeconds()).padStart(2,"0"),a=e.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${t}-${r}-${n}T${o}:${i}:${s}.${c}Z`}function ou(e){let t=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),r=String(e).trim().match(t);if(r==null)throw new Error("Invalid format");let n=parseInt(r[1],10),o=parseInt(r[2],10)-1,i=parseInt(r[3],10),s=parseInt(r[4],10),a=parseInt(r[5],10),c=parseInt(r[6],10),f=parseInt(r[7].slice(0,-6),10);return new Date(Date.UTC(n,o,i,s,a,c,f))}var ze=class e{key;value;timeReceived;constructor(t,r,n){if(!(t instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(r instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=t,this.value=r,this.timeReceived=n}serialize(){return zr.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:nu(this.timeReceived)}}static deserialize(t){let r=zr.decode(t);return new e(r.key,r.value,new Date(r.timeReceived))}static fromDeserialized(t){let r=ou(t.timeReceived);if(t.key==null)throw new Error("key missing from deserialized object");if(t.value==null)throw new Error("value missing from deserialized object");return new e(t.key,t.value,r)}};var iu;(function(e){e[e.SEND_QUERY=0]="SEND_QUERY",e[e.PEER_RESPONSE=1]="PEER_RESPONSE",e[e.FINAL_PEER=2]="FINAL_PEER",e[e.QUERY_ERROR=3]="QUERY_ERROR",e[e.PROVIDER=4]="PROVIDER",e[e.VALUE=5]="VALUE",e[e.ADD_PEER=6]="ADD_PEER",e[e.DIAL_PEER=7]="DIAL_PEER"})(iu||(iu={}));function Jn(e){return new Lr("/dht/record/"+Y(e,"base32"),!1)}function su(e){return{async put(t,r,n={}){try{let o=Jn(t);try{let s=await e.get(o),a=ze.deserialize(s);if(it(a.value,r))return}catch(s){if(s.name!=="NotFoundError")throw s}let i=new ze(t,r,new Date);n.onProgress?.(new xt("ipns:routing:datastore:put")),await e.put(o,i.serialize(),n)}catch(o){throw n.onProgress?.(new xt("ipns:routing:datastore:error",o)),o}},async get(t,r={}){try{let n=Jn(t);r.onProgress?.(new xt("ipns:routing:datastore:get"));let o=await e.get(n,r),i=ze.deserialize(o);return{record:i.value,created:i.timeReceived}}catch(n){throw r.onProgress?.(new xt("ipns:routing:datastore:error",n)),n}},async has(t,r={}){let n=Jn(t);return e.has(n,r)},async delete(t,r){let n=Jn(t);return e.delete(n,r)}}}var Fi="/ipns/";function Mi(e,t){return e.code===t}var ce=le("helia:ipns"),uu=60*1e3,fu=60*uu,Bh=48*fu,Vi=23*fu,au=BigInt(uu)*5000000n,cu={[Ot.prefix]:Ot,[X.prefix]:X},qi=class{routers;localStore;timeout;dns;log;constructor(t,r=[]){this.routers=[ru(t.routing),...r],this.localStore=su(t.datastore),this.dns=t.dns,this.log=t.logger.forComponent("helia:ipns")}async publish(t,r,n={}){try{let o=1n,i=He(t.publicKey.toMultihash());if(await this.localStore.has(i,n)){let{record:f}=await this.localStore.get(i,n);o=Wt(f).sequence+1n}let s=n.ttl!=null?BigInt(n.ttl)*1000000n:au,a=await Wc(t,r,o,n.lifetime??Bh,{...n,ttlNs:s}),c=Hn(a);return await this.localStore.put(i,c,n),n.offline!==!0&&await Promise.all(this.routers.map(async f=>{await f.put(i,c,n)})),a}catch(o){throw n.onProgress?.(new xt("ipns:publish:error",o)),o}}async resolve(t,r={}){let n=Gi(t)?t.toMultihash():t,o=He(n),i=await this.#e(o,r);return{...await this.#t(i.value,r),record:i}}async resolveDNSLink(t,r={}){let n=await eu(t,this.dns,this.log,r);return{...await this.#t(n.value,r),answer:n.answer}}republish(t={}){if(this.timeout!=null)throw new Error("Republish is already running");t.signal?.addEventListener("abort",()=>{clearTimeout(this.timeout)});async function r(){let n=Date.now();t.onProgress?.(new xt("ipns:republish:start"));let i=Date.now()-n,s=Vi-i;s<0&&(s=t.interval??Vi),setTimeout(()=>{r().catch(a=>{ce.error("error republishing",a)})},s)}this.timeout=setTimeout(()=>{r().catch(n=>{ce.error("error republishing",n)})},t.interval??Vi)}async#t(t,r={}){let n=t.split("/");try{let o=n[1];if(o==="ipns"){let i=n[2],s=i.substring(0,1),a;if(s==="1"||s==="Q")a=X.decode(`z${i}`);else if(cu[s]!=null)a=cu[s].decode(i);else throw new jn(`Unsupported multibase prefix "${s}"`);let c;try{c=Jt(a)}catch{c=J.decode(a).multihash}if(!Mi(c,0)&&!Mi(c,18))throw new Yn(`Unsupported multihash codec "${c.code}"`);let{cid:f}=await this.resolve(c,r),u=n.slice(3).join("/");return{cid:f,path:u}}else if(o==="ipfs"){let i=J.parse(n[2]),s=n.slice(3).join("/");return{cid:i,path:s}}}catch(o){ce.error("error parsing ipfs path",o)}throw ce.error("invalid ipfs path %s",t),new Wn("Invalid value")}async#e(t,r={}){let n=[];if(await this.localStore.has(t,r))if(ce("record is present in the cache"),r.nocache!==!0)try{let{record:a,created:c}=await this.localStore.get(t,r);this.log("record retrieved from cache"),await Hr(t,a),this.log("record was valid");let f=Wt(a),u=Number((f.ttl??au)/1000000n);if(c.getTime()+u>Date.now())return this.log("record TTL was valid"),f;if(r.offline===!0)return this.log("record TTL has been reached but we are resolving offline-only, returning record"),f;this.log("record TTL has been reached, searching routing for updates"),n.push(a)}catch(a){this.log("cached record was invalid",a),await this.localStore.delete(t,r)}else ce("ignoring local cache due to nocache=true option");if(r.offline===!0)throw new pr("Record was not present in the cache or has expired");ce("did not have record locally");let i=0;if(await Promise.all(this.routers.map(async a=>{let c;try{c=await a.get(t,{...r,validate:!1})}catch(f){ce.error("error finding IPNS record",f);return}try{await Hr(t,c),n.push(c)}catch(f){i++,ce.error("error finding IPNS record",f)}})),n.length===0)throw i>0?new Zn(`${i>1?`${i} records`:"Record"} found for routing key ${i>1?"were":"was"} invalid`):new pr("Could not find record for routing key");let s=n[zn(t,n)];return await this.localStore.put(t,s,r),Wt(s)}async republishRecord(t,r,n={}){let o;try{if(o=qr(r)?.toMultihash(),o==null)if(typeof t=="string"){t.startsWith(Fi)&&(t=t.slice(Fi.length));try{o=Sn(t).toMultihash()}catch(a){throw new Error(`Invalid string key: ${a.message}`)}}else o=t;if(o==null)throw new Error("No public key multihash found to determine the routing key");let i=He(o),s=Hn(r);await Hr(i,s),await this.localStore.put(i,s,n),n.offline!==!0&&await Promise.all(this.routers.map(async a=>{await a.put(i,s,n)}))}catch(i){throw n.onProgress?.(new xt("ipns:republish:error",{key:o,record:r,err:i})),i}}};function Ih(e,{routers:t=[]}={}){return new qi(e,t)}return bu(_h);})();
|
|
8
4
|
/*! Bundled license information:
|
|
9
5
|
|
|
10
|
-
pvtsutils/build/index.js:
|
|
11
|
-
(*!
|
|
12
|
-
* MIT License
|
|
13
|
-
*
|
|
14
|
-
* Copyright (c) 2017-2024 Peculiar Ventures, LLC
|
|
15
|
-
*
|
|
16
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
17
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
18
|
-
* in the Software without restriction, including without limitation the rights
|
|
19
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
20
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
21
|
-
* furnished to do so, subject to the following conditions:
|
|
22
|
-
*
|
|
23
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
24
|
-
* copies or substantial portions of the Software.
|
|
25
|
-
*
|
|
26
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
27
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
28
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
29
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
30
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
31
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
32
|
-
* SOFTWARE.
|
|
33
|
-
*
|
|
34
|
-
*)
|
|
35
|
-
|
|
36
6
|
@noble/hashes/esm/utils.js:
|
|
37
7
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
38
8
|
|
|
@@ -51,46 +21,6 @@ pvtsutils/build/index.js:
|
|
|
51
21
|
@noble/curves/esm/ed25519.js:
|
|
52
22
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
53
23
|
|
|
54
|
-
pvutils/build/utils.es.js:
|
|
55
|
-
(*!
|
|
56
|
-
Copyright (c) Peculiar Ventures, LLC
|
|
57
|
-
*)
|
|
58
|
-
|
|
59
|
-
asn1js/build/index.es.js:
|
|
60
|
-
(*!
|
|
61
|
-
* Copyright (c) 2014, GMO GlobalSign
|
|
62
|
-
* Copyright (c) 2015-2022, Peculiar Ventures
|
|
63
|
-
* All rights reserved.
|
|
64
|
-
*
|
|
65
|
-
* Author 2014-2019, Yury Strozhevsky
|
|
66
|
-
*
|
|
67
|
-
* Redistribution and use in source and binary forms, with or without modification,
|
|
68
|
-
* are permitted provided that the following conditions are met:
|
|
69
|
-
*
|
|
70
|
-
* * Redistributions of source code must retain the above copyright notice, this
|
|
71
|
-
* list of conditions and the following disclaimer.
|
|
72
|
-
*
|
|
73
|
-
* * Redistributions in binary form must reproduce the above copyright notice, this
|
|
74
|
-
* list of conditions and the following disclaimer in the documentation and/or
|
|
75
|
-
* other materials provided with the distribution.
|
|
76
|
-
*
|
|
77
|
-
* * Neither the name of the copyright holder nor the names of its
|
|
78
|
-
* contributors may be used to endorse or promote products derived from
|
|
79
|
-
* this software without specific prior written permission.
|
|
80
|
-
*
|
|
81
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
82
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
83
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
84
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
85
|
-
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
86
|
-
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
87
|
-
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
88
|
-
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
89
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
90
|
-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
91
|
-
*
|
|
92
|
-
*)
|
|
93
|
-
|
|
94
24
|
@noble/curves/esm/abstract/weierstrass.js:
|
|
95
25
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
96
26
|
|