@helia/routers 3.0.1-daaa511 → 3.1.0-d43efc7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js
CHANGED
|
@@ -1,44 +1,31 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaRouters = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var HeliaRouters=(()=>{var
|
|
3
|
-
`,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return x;function x(g,b,K){var L=this;if(!(L instanceof x))return new x(g,b,K);L.time=+g||0,L.nano=+b||0,L.year=+K||0,h(L)}function h(g){var b,K,L,P=g.year,V=g.time,S=g.nano,v=((S<0||a<=S)&&(S-=(K=Math.floor(S/a))*a,V+=K,K=1),P%t);return(V<-i||i<V||v)&&((b=l(V/o))&&(P+=b*t,V-=b*o),(L=A(V)).setUTCFullYear(v+L.getUTCFullYear()),L=(V=+L)+(b=l((P-=v)/t))*o,b&&-i<=L&&L<=i&&(P-=b*t,V=L),K=1),K&&(g.year=P,g.time=V,g.nano=S),g}function A(g){var b=new Date(0);return b.setTime(g),b}function _(P,L){P=+P||0;var K=l((L=(L|0)*s)/n)+l(P/n),L=L%n+P%n,P=l(L/n);return P&&(K+=P,L-=P*n),new x(1e3*L,0,K*t)}function y(g,b,K,L,P,V){return function(v,T){var p=h(this);v=v||new Array(8),F(v,T|=0);var I=Math.floor(p.time/1e3),p=p.year*(r*e/t),E=l(p/s)+l(I/s),p=p%s+I%s,I=Math.floor(p/s);return I&&(E+=I,p-=I*s),S(v,T+P,E),S(v,T+V,p),v};function S(v,T,E){v[T+g]=E>>24&255,v[T+b]=E>>16&255,v[T+K]=E>>8&255,v[T+L]=255&E}}function U(g,b,K,L,P,V){return function(v,T){F(v,T|=0);var E=S(v,T+P);return _(S(v,T+V),E)};function S(v,T){return 16777216*v[T+g]+(v[T+b]<<16|v[T+K]<<8|v[T+L])}}function F(g,b){if(g=g&&g.length,g==null)throw new TypeError("Invalid Buffer");if(g<b+8)throw new RangeError("Out of range")}function k(g){return(9<g?"":"0")+(0|g)}function N(g,b){return(c+(0|g)).substr(-b)}}()});var Hu=Rs((M2,gs)=>{"use strict";var Np=Object.prototype.hasOwnProperty,It="~";function tn(){}Object.create&&(tn.prototype=Object.create(null),new tn().__proto__||(It=!1));function Rp(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function zu(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new Rp(r,n||e,o),s=It?It+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],i]:e._events[s].push(i):(e._events[s]=i,e._eventsCount++),e}function io(e,t){--e._eventsCount===0?e._events=new tn:delete e._events[t]}function vt(){this._events=new tn,this._eventsCount=0}vt.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)Np.call(r,n)&&t.push(It?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};vt.prototype.listeners=function(t){var r=It?It+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};vt.prototype.listenerCount=function(t){var r=It?It+t:t,n=this._events[r];return n?n.fn?1:n.length:0};vt.prototype.emit=function(t,r,n,o,i,s){var a=It?It+t:t;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,u,f;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,o),!0;case 5:return c.fn.call(c.context,r,n,o,i),!0;case 6:return c.fn.call(c.context,r,n,o,i,s),!0}for(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var d=c.length,w;for(f=0;f<d;f++)switch(c[f].once&&this.removeListener(t,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,r);break;case 3:c[f].fn.call(c[f].context,r,n);break;case 4:c[f].fn.call(c[f].context,r,n,o);break;default:if(!u)for(w=1,u=new Array(l-1);w<l;w++)u[w-1]=arguments[w];c[f].fn.apply(c[f].context,u)}}return!0};vt.prototype.on=function(t,r,n){return zu(this,t,r,n,!1)};vt.prototype.once=function(t,r,n){return zu(this,t,r,n,!0)};vt.prototype.removeListener=function(t,r,n,o){var i=It?It+t:t;if(!this._events[i])return this;if(!r)return io(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&io(this,i);else{for(var a=0,c=[],l=s.length;a<l;a++)(s[a].fn!==r||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:io(this,i)}return this};vt.prototype.removeAllListeners=function(t){var r;return t?(r=It?It+t:t,this._events[r]&&io(this,r)):(this._events=new tn,this._eventsCount=0),this};vt.prototype.off=vt.prototype.removeListener;vt.prototype.addListener=vt.prototype.on;vt.prefixed=It;vt.EventEmitter=vt;typeof gs<"u"&&(gs.exports=vt)});var e0={};Ct(e0,{delegatedHTTPRouting:()=>tf,delegatedHTTPRoutingDefaults:()=>ho,httpGatewayRouting:()=>uf,libp2pRouting:()=>ff});var Ds=Symbol.for("@libp2p/content-routing");var yo=Symbol.for("@libp2p/peer-id");var ks=Symbol.for("@libp2p/peer-routing");var ft=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Ge=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Bt=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var sn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Ze=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var We=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Eo={};Ct(Eo,{base32:()=>Ht,base32hex:()=>Pf,base32hexpad:()=>Uf,base32hexpadupper:()=>Nf,base32hexupper:()=>_f,base32pad:()=>Cf,base32padupper:()=>Bf,base32upper:()=>Tf,base32z:()=>Rf});var a0=new Uint8Array(0);function Ks(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 se(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 Fs(e){return new TextEncoder().encode(e)}function Os(e){return new TextDecoder().decode(e)}function Ef(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function f(C){if(C instanceof Uint8Array||(ArrayBuffer.isView(C)?C=new Uint8Array(C.buffer,C.byteOffset,C.byteLength):Array.isArray(C)&&(C=Uint8Array.from(C))),!(C instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(C.length===0)return"";for(var x=0,h=0,A=0,_=C.length;A!==_&&C[A]===0;)A++,x++;for(var y=(_-A)*u+1>>>0,U=new Uint8Array(y);A!==_;){for(var F=C[A],k=0,N=y-1;(F!==0||k<h)&&N!==-1;N--,k++)F+=256*U[N]>>>0,U[N]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");h=k,A++}for(var g=y-h;g!==y&&U[g]===0;)g++;for(var b=c.repeat(x);g<y;++g)b+=e.charAt(U[g]);return b}function d(C){if(typeof C!="string")throw new TypeError("Expected String");if(C.length===0)return new Uint8Array;var x=0;if(C[x]!==" "){for(var h=0,A=0;C[x]===c;)h++,x++;for(var _=(C.length-x)*l+1>>>0,y=new Uint8Array(_);C[x];){var U=r[C.charCodeAt(x)];if(U===255)return;for(var F=0,k=_-1;(U!==0||F<A)&&k!==-1;k--,F++)U+=a*y[k]>>>0,y[k]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");A=F,x++}if(C[x]!==" "){for(var N=_-A;N!==_&&y[N]===0;)N++;for(var g=new Uint8Array(h+(_-N)),b=h;N!==_;)g[b++]=y[N++];return g}}}function w(C){var x=d(C);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:d,decode:w}}var Sf=Ef,vf=Sf,Vs=vf;var go=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")}},xo=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 qs(this,t)}},wo=class{decoders;constructor(t){this.decoders=t}or(t){return qs(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 qs(e,t){return new wo({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var bo=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 go(t,r,n),this.decoder=new xo(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Ye({name:e,prefix:t,encode:r,decode:n}){return new bo(e,t,r,n)}function ge({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Vs(r,e);return Ye({prefix:t,name:e,encode:n,decode:i=>se(o(i))})}function Af(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,l=0;for(let u=0;u<i;++u){let f=o[e[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)!==0)throw new SyntaxError("Unexpected end of data");return s}function If(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function st({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return Ye({prefix:t,name:e,encode(o){return If(o,n,r)},decode(o){return Af(o,n,r,e)}})}var Ht=st({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Tf=st({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Cf=st({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Bf=st({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Pf=st({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),_f=st({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Uf=st({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Nf=st({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Rf=st({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var So={};Ct(So,{base58btc:()=>Q,base58flickr:()=>Lf});var Q=ge({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Lf=ge({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ao={};Ct(Ao,{base64:()=>vo,base64pad:()=>Df,base64url:()=>kf,base64urlpad:()=>Kf});var vo=st({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Df=st({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),kf=st({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Kf=st({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Ff(e,t){try{if(typeof e=="string"&&e.length>0)return Of(e);if(typeof e=="number"&&isFinite(e))return t?.long?Vf(e):Mf(e);throw new Error("Value is not a string or number.")}catch(r){let n=qf(r)?`${r.message}. value=${JSON.stringify(e)}`:"An unknown error has occured.";throw new Error(n)}}function Of(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 cn=Ff;function Mf(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 Vf(e){let t=Math.abs(e);return t>=864e5?an(e,t,864e5,"day"):t>=36e5?an(e,t,36e5,"hour"):t>=6e4?an(e,t,6e4,"minute"):t>=1e3?an(e,t,1e3,"second"):`${e} ms`}function an(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function qf(e){return typeof e=="object"&&e!==null&&"message"in e}function Io(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=cn,r.destroy=l,Object.keys(e).forEach(u=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let f=0;for(let d=0;d<u.length;d++)f=(f<<5)-f+u.charCodeAt(d),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=t;function r(u){let f,d=null,w,C;function x(...h){if(!x.enabled)return;let A=x,_=Number(new Date),y=_-(f||_);A.diff=y,A.prev=f,A.curr=_,f=_,h[0]=r.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let U=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(k,N)=>{if(k==="%%")return"%";U++;let g=r.formatters[N];if(typeof g=="function"){let b=h[U];k=g.call(A,b),h.splice(U,1),U--}return k}),r.formatArgs.call(A,h),(A.log||r.log).apply(A,h)}return x.namespace=u,x.useColors=r.useColors(),x.color=r.selectColor(u),x.extend=n,x.destroy=r.destroy,Object.defineProperty(x,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(w!==r.namespaces&&(w=r.namespaces,C=r.enabled(u)),C),set:h=>{d=h}}),typeof r.init=="function"&&r.init(x),x}function n(u,f){let d=r(this.namespace+(typeof f>"u"?":":f)+u);return d.log=this.log,d}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let f,d=(typeof u=="string"?u:"").split(/[\s,]+/),w=d.length;for(f=0;f<w;f++)d[f]&&(u=d[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,d;for(f=0,d=r.skips.length;f<d;f++)if(r.skips[f].test(u))return!1;for(f=0,d=r.names.length;f<d;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 un=Wf(),$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 zf(){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 Hf(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+cn(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 jf=console.debug??console.log??(()=>{});function Gf(e){try{e?un?.setItem("debug",e):un?.removeItem("debug")}catch{}}function Zf(){let e;try{e=un?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function Wf(){try{return localStorage}catch{}}function Yf(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var $s=Io({formatArgs:Hf,save:Gf,load:Zf,useColors:zf,setupFormatters:Yf,colors:$f,storage:un,log:jf});var Pt=$s;Pt.formatters.b=e=>e==null?"undefined":Q.baseEncode(e);Pt.formatters.t=e=>e==null?"undefined":Ht.baseEncode(e);Pt.formatters.m=e=>e==null?"undefined":vo.baseEncode(e);Pt.formatters.p=e=>e==null?"undefined":e.toString();Pt.formatters.c=e=>e==null?"undefined":e.toString();Pt.formatters.k=e=>e==null?"undefined":e.toString();Pt.formatters.a=e=>e==null?"undefined":e.toString();Pt.formatters.e=e=>e==null?"undefined":zs(e.stack)??zs(e.message)??e.toString();function Xf(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 xe(e){let t=Xf(`${e}:trace`);return Pt.enabled(`${e}:trace`)&&Pt.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=Pt(`${e}:trace`)),Object.assign(Pt(e),{error:Pt(`${e}:error`),trace:t})}function zs(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var To={};Ct(To,{base36:()=>Xe,base36upper:()=>Jf});var Xe=ge({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Jf=ge({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Qf=Gs,Hs=128,tl=127,el=~tl,rl=Math.pow(2,31);function Gs(e,t,r){t=t||[],r=r||0;for(var n=r;e>=rl;)t[r++]=e&255|Hs,e/=128;for(;e⪙)t[r++]=e&255|Hs,e>>>=7;return t[r]=e|0,Gs.bytes=r-n+1,t}var nl=Co,ol=128,js=127;function Co(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw Co.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&js)<<o:(s&js)*Math.pow(2,o),o+=7}while(s>=ol);return Co.bytes=i-n,r}var il=Math.pow(2,7),sl=Math.pow(2,14),al=Math.pow(2,21),cl=Math.pow(2,28),ul=Math.pow(2,35),fl=Math.pow(2,42),ll=Math.pow(2,49),dl=Math.pow(2,56),hl=Math.pow(2,63),pl=function(e){return e<il?1:e<sl?2:e<al?3:e<cl?4:e<ul?5:e<fl?6:e<ll?7:e<dl?8:e<hl?9:10},ml={encode:Qf,decode:nl,encodingLength:pl},yl=ml,Cr=yl;function Br(e,t=0){return[Cr.decode(e,t),Cr.decode.bytes]}function Je(e,t,r=0){return Cr.encode(e,t,r),t}function Qe(e){return Cr.encodingLength(e)}function jt(e,t){let r=t.byteLength,n=Qe(e),o=n+Qe(r),i=new Uint8Array(o+r);return Je(e,i,0),Je(r,i,n),i.set(t,o),new tr(e,r,t,i)}function ae(e){let t=se(e),[r,n]=Br(t),[o,i]=Br(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new tr(r,o,s,t)}function Zs(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Ks(e.bytes,r.bytes)}}var tr=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Ws(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return xl(r,Bo(e),t??Q.encoder);default:return wl(r,Bo(e),t??Ht.encoder)}}var Ys=new WeakMap;function Bo(e){let t=Ys.get(e);if(t==null){let r=new Map;return Ys.set(e,r),r}return t}var Z=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!==Pr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==bl)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=jt(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&&Zs(t.multihash,n.multihash)}toString(t){return Ws(this,t)}toJSON(){return{"/":Ws(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??Xs(n,o,i.bytes))}else if(r[El]===!0){let{version:n,multihash:o,code:i}=r,s=ae(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!==Pr)throw new Error(`Version 0 CID must use dag-pb (code: ${Pr}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Xs(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Pr,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=se(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 tr(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[f,d]=Br(t.subarray(r));return r+=d,f},o=n(),i=Pr;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),l=r+c,u=l-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:l}}static parse(t,r){let[n,o]=gl(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 Bo(i).set(n,t),i}};function gl(e,t){switch(e[0]){case"Q":{let r=t??Q;return[Q.prefix,r.decode(`${Q.prefix}${e}`)]}case Q.prefix:{let r=t??Q;return[Q.prefix,r.decode(e)]}case Ht.prefix:{let r=t??Ht;return[Ht.prefix,r.decode(e)]}case Xe.prefix:{let r=t??Xe;return[Xe.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 xl(e,t,r){let{prefix:n}=r;if(n!==Q.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 wl(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 Pr=112,bl=18;function Xs(e,t,r){let n=Qe(e),o=n+Qe(t),i=new Uint8Array(o+r.byteLength);return Je(e,i,0),Je(t,i,n),i.set(r,o),i}var El=Symbol.for("@ipld/js-cid/CID");var Po={};Ct(Po,{identity:()=>Lt});var Js=0,Sl="identity",Qs=se;function vl(e){return jt(Js,Qs(e))}var Lt={code:Js,name:Sl,encode:Qs,digest:vl};function rt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function ce(e=0){return new Uint8Array(e)}function _t(e=0){return new Uint8Array(e)}function bt(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=_t(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var ea=Symbol.for("@achingbrain/uint8arraylist");function ta(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 er(e){return!!e?.[ea]}var Dt=class e{bufs;length;[ea]=!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(er(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(er(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=ta(this.bufs,t);return r.buf[r.index]}set(t,r){let n=ta(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(er(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 bt(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:bt(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),i=new e;return i.length=o,i.bufs=[...n],i}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,t>=c)continue;let l=t>=a&&t<c,u=r>a&&r<=c;if(l&&u){if(t===a&&r===c){n.push(s);break}let f=t-a;n.push(s.subarray(f,f+(r-t)));break}if(l){if(t===0){n.push(s);continue}n.push(s.subarray(t-a));continue}if(u){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!er(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let f=0;f<i;f++)s[f]=-1;for(let f=0;f<o;f++)s[n[f]]=f;let a=s,c=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=r;f<=c;f+=u){u=0;for(let d=l;d>=0;d--){let w=this.get(f+d);if(n[d]!==w){u=Math.max(1,d-a[w]);break}}if(u===0)return f}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=_t(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=ce(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=ce(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=ce(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=_t(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=ce(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=ce(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=ce(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=ce(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=ce(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!rt(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var _o={};Ct(_o,{base10:()=>Al});var Al=ge({prefix:"9",name:"base10",alphabet:"0123456789"});var Uo={};Ct(Uo,{base16:()=>Il,base16upper:()=>Tl});var Il=st({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Tl=st({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var No={};Ct(No,{base2:()=>Cl});var Cl=st({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ro={};Ct(Ro,{base256emoji:()=>Nl});var ra=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}"),Bl=ra.reduce((e,t,r)=>(e[r]=t,e),[]),Pl=ra.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function _l(e){return e.reduce((t,r)=>(t+=Bl[r],t),"")}function Ul(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Pl[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var Nl=Ye({prefix:"\u{1F680}",name:"base256emoji",encode:_l,decode:Ul});var Lo={};Ct(Lo,{base8:()=>Rl});var Rl=st({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Do={};Ct(Do,{identity:()=>Ll});var Ll=Ye({prefix:"\0",name:"identity",encode:e=>Os(e),decode:e=>Fs(e)});var nm=new TextEncoder,om=new TextDecoder;var Fo={};Ct(Fo,{sha256:()=>_r,sha512:()=>Kl});function Ko({name:e,code:t,encode:r}){return new ko(e,t,r)}var ko=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?jt(this.code,r):r.then(n=>jt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function oa(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var _r=Ko({name:"sha2-256",code:18,encode:oa("SHA-256")}),Kl=Ko({name:"sha2-512",code:19,encode:oa("SHA-512")});var Ur={...Do,...No,...Lo,..._o,...Uo,...Eo,...To,...So,...Ao,...Ro},ym={...Fo,...Po};function sa(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var ia=sa("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Oo=sa("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=_t(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Fl={utf8:ia,"utf-8":ia,hex:Ur.base16,latin1:Oo,ascii:Oo,binary:Oo,...Ur},ln=Fl;function H(e,t="utf8"){let r=ln[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function q(e,t="utf8"){let r=ln[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var Ol=parseInt("11111",2),Mo=parseInt("10000000",2),Ml=parseInt("01111111",2),aa={0:Nr,1:Nr,2:Vl,3:zl,4:Hl,5:$l,6:ql,16:Nr,22:Nr,48:Nr};function ue(e,t={offset:0}){let r=e[t.offset]&Ol;if(t.offset++,aa[r]!=null)return aa[r](e,t);throw new Error("No decoder for tag "+r)}function Rr(e,t){let r=0;if((e[t.offset]&Mo)===Mo){let n=e[t.offset]&Ml,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 Nr(e,t){Rr(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=ue(e,t);if(n===null)break;r.push(n)}return r}function Vl(e,t){let r=Rr(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 ql(e,t){let r=Rr(e,t),n=t.offset+r,o=e[t.offset];t.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,c=[];for(;t.offset<n;){let l=e[t.offset];if(t.offset++,c.push(l&127),l<128){c.reverse();let u=0;for(let f=0;f<c.length;f++)u+=c[f]<<f*7;a+=`.${u}`,c=[]}}return a}function $l(e,t){return t.offset++,null}function zl(e,t){let r=Rr(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 Hl(e,t){let r=Rr(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function jl(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new Dt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Vo(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=jl(e.byteLength);return new Dt(Uint8Array.from([t.byteLength|Mo]),t)}function Ut(e){let t=new Dt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new Dt(Uint8Array.from([2]),Vo(t),t)}function dn(e){let t=Uint8Array.from([0]),r=new Dt(t,e);return new Dt(Uint8Array.from([3]),Vo(r),r)}function be(e,t=48){let r=new Dt;for(let n of e)r.append(n);return new Dt(Uint8Array.from([t]),Vo(r),r)}async function ca(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 Gl=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Zl=Uint8Array.from([6,5,43,129,4,0,34]),Wl=Uint8Array.from([6,5,43,129,4,0,35]),Yl={ext:!0,kty:"EC",crv:"P-256"},Xl={ext:!0,kty:"EC",crv:"P-384"},Jl={ext:!0,kty:"EC",crv:"P-521"},qo=32,$o=48,zo=66;function Ho(e){let t=ue(e);return ua(t)}function ua(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===qo*2+1)return n=q(t.subarray(r,r+qo),"base64url"),o=q(t.subarray(r+qo),"base64url"),new rr({...Yl,key_ops:["verify"],x:n,y:o});if(t.byteLength===$o*2+1)return n=q(t.subarray(r,r+$o),"base64url"),o=q(t.subarray(r+$o),"base64url"),new rr({...Xl,key_ops:["verify"],x:n,y:o});if(t.byteLength===zo*2+1)return n=q(t.subarray(r,r+zo),"base64url"),o=q(t.subarray(r+zo),"base64url"),new rr({...Jl,key_ops:["verify"],x:n,y:o});throw new ft(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function fa(e){return be([Ut(Uint8Array.from([1])),be([Ql(e.crv)],160),be([dn(new Dt(Uint8Array.from([4]),H(e.x??"","base64url"),H(e.y??"","base64url")))],161)]).subarray()}function Ql(e){if(e==="P-256")return Gl;if(e==="P-384")return Zl;if(e==="P-521")return Wl;throw new ft(`Invalid curve ${e}`)}var rr=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=fa(this.jwk)),this._raw}toMultihash(){return Lt.digest(nr(this))}toCID(){return Z.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}async verify(t,r){return ca(this.jwk,r,t)}};function la(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function td(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function or(e,...t){if(!td(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 da(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");la(e.outputLen),la(e.blockLen)}function ir(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 ha(e,t){or(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}var Re=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function hn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Gt(e,t){return e<<32-t|e>>>t}var Xm=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function";function pa(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function Lr(e){return typeof e=="string"&&(e=pa(e)),or(e),e}function jo(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];or(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 sr=class{clone(){return this._cloneInto()}};function pn(e){let t=n=>e().update(Lr(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function mn(e=32){if(Re&&typeof Re.getRandomValues=="function")return Re.getRandomValues(new Uint8Array(e));if(Re&&typeof Re.randomBytes=="function")return Uint8Array.from(Re.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function ed(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,l=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+l,a,n)}function ma(e,t,r){return e&t^~e&r}function ya(e,t,r){return e&t^e&r^t&r}var ar=class extends sr{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=hn(this.buffer)}update(t){ir(this);let{view:r,buffer:n,blockLen:o}=this;t=Lr(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=hn(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){ir(this),ha(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 f=s;f<o;f++)r[f]=0;ed(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=hn(t),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: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 rd=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]),Ee=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Se=new Uint32Array(64),Go=class extends ar{constructor(t=32){super(64,t,8,!1),this.A=Ee[0]|0,this.B=Ee[1]|0,this.C=Ee[2]|0,this.D=Ee[3]|0,this.E=Ee[4]|0,this.F=Ee[5]|0,this.G=Ee[6]|0,this.H=Ee[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 f=0;f<16;f++,r+=4)Se[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let d=Se[f-15],w=Se[f-2],C=Gt(d,7)^Gt(d,18)^d>>>3,x=Gt(w,17)^Gt(w,19)^w>>>10;Se[f]=x+Se[f-7]+C+Se[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 d=Gt(a,6)^Gt(a,11)^Gt(a,25),w=u+d+ma(a,c,l)+rd[f]+Se[f]|0,x=(Gt(n,2)^Gt(n,13)^Gt(n,22))+ya(n,o,i)|0;u=l,l=c,c=a,a=s+w|0,s=i,i=o,o=n,n=w+x|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(){Se.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Le=pn(()=>new Go);var yn=BigInt(4294967295),Zo=BigInt(32);function ga(e,t=!1){return t?{h:Number(e&yn),l:Number(e>>Zo&yn)}:{h:Number(e>>Zo&yn)|0,l:Number(e&yn)|0}}function nd(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}=ga(e[o],t);[r[o],n[o]]=[i,s]}return[r,n]}var od=(e,t)=>BigInt(e>>>0)<<Zo|BigInt(t>>>0),id=(e,t,r)=>e>>>r,sd=(e,t,r)=>e<<32-r|t>>>r,ad=(e,t,r)=>e>>>r|t<<32-r,cd=(e,t,r)=>e<<32-r|t>>>r,ud=(e,t,r)=>e<<64-r|t>>>r-32,fd=(e,t,r)=>e>>>r-32|t<<64-r,ld=(e,t)=>t,dd=(e,t)=>e,hd=(e,t,r)=>e<<r|t>>>32-r,pd=(e,t,r)=>t<<r|e>>>32-r,md=(e,t,r)=>t<<r-32|e>>>64-r,yd=(e,t,r)=>e<<r-32|t>>>64-r;function gd(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var xd=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),wd=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,bd=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Ed=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Sd=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),vd=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var Ad={fromBig:ga,split:nd,toBig:od,shrSH:id,shrSL:sd,rotrSH:ad,rotrSL:cd,rotrBH:ud,rotrBL:fd,rotr32H:ld,rotr32L:dd,rotlSH:hd,rotlSL:pd,rotlBH:md,rotlBL:yd,add:gd,add3L:xd,add3H:wd,add4L:bd,add4H:Ed,add5H:vd,add5L:Sd},$=Ad;var[Id,Td]=$.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))),ve=new Uint32Array(80),Ae=new Uint32Array(80),Wo=class extends ar{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:l,El:u,Fh:f,Fl:d,Gh:w,Gl:C,Hh:x,Hl:h}=this;return[t,r,n,o,i,s,a,c,l,u,f,d,w,C,x,h]}set(t,r,n,o,i,s,a,c,l,u,f,d,w,C,x,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=l|0,this.El=u|0,this.Fh=f|0,this.Fl=d|0,this.Gh=w|0,this.Gl=C|0,this.Hh=x|0,this.Hl=h|0}process(t,r){for(let y=0;y<16;y++,r+=4)ve[y]=t.getUint32(r),Ae[y]=t.getUint32(r+=4);for(let y=16;y<80;y++){let U=ve[y-15]|0,F=Ae[y-15]|0,k=$.rotrSH(U,F,1)^$.rotrSH(U,F,8)^$.shrSH(U,F,7),N=$.rotrSL(U,F,1)^$.rotrSL(U,F,8)^$.shrSL(U,F,7),g=ve[y-2]|0,b=Ae[y-2]|0,K=$.rotrSH(g,b,19)^$.rotrBH(g,b,61)^$.shrSH(g,b,6),L=$.rotrSL(g,b,19)^$.rotrBL(g,b,61)^$.shrSL(g,b,6),P=$.add4L(N,L,Ae[y-7],Ae[y-16]),V=$.add4H(P,k,K,ve[y-7],ve[y-16]);ve[y]=V|0,Ae[y]=P|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:l,Dl:u,Eh:f,El:d,Fh:w,Fl:C,Gh:x,Gl:h,Hh:A,Hl:_}=this;for(let y=0;y<80;y++){let U=$.rotrSH(f,d,14)^$.rotrSH(f,d,18)^$.rotrBH(f,d,41),F=$.rotrSL(f,d,14)^$.rotrSL(f,d,18)^$.rotrBL(f,d,41),k=f&w^~f&x,N=d&C^~d&h,g=$.add5L(_,F,N,Td[y],Ae[y]),b=$.add5H(g,A,U,k,Id[y],ve[y]),K=g|0,L=$.rotrSH(n,o,28)^$.rotrBH(n,o,34)^$.rotrBH(n,o,39),P=$.rotrSL(n,o,28)^$.rotrBL(n,o,34)^$.rotrBL(n,o,39),V=n&i^n&a^i&a,S=o&s^o&c^s&c;A=x|0,_=h|0,x=w|0,h=C|0,w=f|0,C=d|0,{h:f,l:d}=$.add(l|0,u|0,b|0,K|0),l=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let v=$.add3L(K,P,S);n=$.add3H(v,b,L,V),o=v|0}({h:n,l:o}=$.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=$.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=$.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=$.add(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:d}=$.add(this.Eh|0,this.El|0,f|0,d|0),{h:w,l:C}=$.add(this.Fh|0,this.Fl|0,w|0,C|0),{h:x,l:h}=$.add(this.Gh|0,this.Gl|0,x|0,h|0),{h:A,l:_}=$.add(this.Hh|0,this.Hl|0,A|0,_|0),this.set(n,o,i,s,a,c,l,u,f,d,w,C,x,h,A,_)}roundClean(){ve.fill(0),Ae.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 Yo=pn(()=>new Wo);var ti=BigInt(0),Qo=BigInt(1);function De(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ei(e){if(!De(e))throw new Error("Uint8Array expected")}function ee(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function Dr(e){let t=e.toString(16);return t.length&1?"0"+t:t}function ba(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?ti:BigInt("0x"+e)}var Ea=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Cd=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ie(e){if(ei(e),Ea)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Cd[e[r]];return t}var fe={_0:48,_9:57,A:65,F:70,a:97,f:102};function xa(e){if(e>=fe._0&&e<=fe._9)return e-fe._0;if(e>=fe.A&&e<=fe.F)return e-(fe.A-10);if(e>=fe.a&&e<=fe.f)return e-(fe.a-10)}function kr(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Ea)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=xa(e.charCodeAt(i)),a=xa(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 le(e){return ba(Ie(e))}function ke(e){return ei(e),ba(Ie(Uint8Array.from(e).reverse()))}function Ke(e,t){return kr(e.toString(16).padStart(t*2,"0"))}function cr(e,t){return Ke(e,t).reverse()}function it(e,t,r){let n;if(typeof t=="string")try{n=kr(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(De(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 Te(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];ei(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 Xo=e=>typeof e=="bigint"&&ti<=e;function gn(e,t,r){return Xo(e)&&Xo(t)&&Xo(r)&&t<=e&&e<r}function kt(e,t,r,n){if(!gn(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Sa(e){let t;for(t=0;e>ti;e>>=Qo,t+=1);return t}var Fe=e=>(Qo<<BigInt(e))-Qo,Jo=e=>new Uint8Array(e),wa=e=>Uint8Array.from(e);function va(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=Jo(e),o=Jo(e),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...f)=>r(o,n,...f),c=(f=Jo(0))=>{o=a(wa([0]),f),n=a(),f.length!==0&&(o=a(wa([1]),f),n=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,d=[];for(;f<t;){n=a();let w=n.slice();d.push(w),f+=n.length}return Te(...d)};return(f,d)=>{s(),c(f);let w;for(;!(w=d(l()));)c();return s(),w}}var Bd={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"||De(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 de(e,t,r={}){let n=(o,i,s)=>{let a=Bd[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 ur(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 dt=BigInt(0),nt=BigInt(1),Oe=BigInt(2),Pd=BigInt(3),ri=BigInt(4),Aa=BigInt(5),Ia=BigInt(8),_d=BigInt(9),Ud=BigInt(16);function tt(e,t){let r=e%t;return r>=dt?r:t+r}function Nd(e,t,r){if(t<dt)throw new Error("invalid exponent, negatives unsupported");if(r<=dt)throw new Error("invalid modulus");if(r===nt)return dt;let n=nt;for(;t>dt;)t&nt&&(n=n*e%r),e=e*e%r,t>>=nt;return n}function ot(e,t,r){let n=e;for(;t-- >dt;)n*=n,n%=r;return n}function xn(e,t){if(e===dt)throw new Error("invert: expected non-zero number");if(t<=dt)throw new Error("invert: expected positive modulus, got "+t);let r=tt(e,t),n=t,o=dt,i=nt,s=nt,a=dt;for(;r!==dt;){let l=n/r,u=n%r,f=o-s*l,d=i-a*l;n=r,r=u,o=s,i=a,s=f,a=d}if(n!==nt)throw new Error("invert: does not exist");return tt(o,t)}function Rd(e){let t=(e-nt)/Oe,r,n,o;for(r=e-nt,n=0;r%Oe===dt;r/=Oe,n++);for(o=Oe;o<e&&Nd(o,t,e)!==e-nt;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(e+nt)/ri;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+nt)/Oe;return function(a,c){if(a.pow(c,t)===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),d=a.pow(c,r);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let w=1;for(let x=a.sqr(d);w<l&&!a.eql(x,a.ONE);w++)x=a.sqr(x);let C=a.pow(u,nt<<BigInt(l-w-1));u=a.sqr(C),f=a.mul(f,C),d=a.mul(d,u),l=w}return f}}function Ld(e){if(e%ri===Pd){let t=(e+nt)/ri;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%Ia===Aa){let t=(e-Aa)/Ia;return function(n,o){let i=n.mul(o,Oe),s=n.pow(i,t),a=n.mul(o,s),c=n.mul(n.mul(a,Oe),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 e%Ud,Rd(e)}var Ta=(e,t)=>(tt(e,t)&nt)===nt,Dd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ni(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Dd.reduce((n,o)=>(n[o]="function",n),t);return de(e,r)}function kd(e,t,r){if(r<dt)throw new Error("invalid exponent, negatives unsupported");if(r===dt)return e.ONE;if(r===nt)return t;let n=e.ONE,o=t;for(;r>dt;)r&nt&&(n=e.mul(n,o)),o=e.sqr(o),r>>=nt;return n}function Kd(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 oi(e,t){let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Ce(e,t,r=!1,n={}){if(e<=dt)throw new Error("invalid field: expected ORDER > 0, got "+e);let{nBitLength:o,nByteLength:i}=oi(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:Fe(o),ZERO:dt,ONE:nt,create:c=>tt(c,e),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return dt<=c&&c<e},is0:c=>c===dt,isOdd:c=>(c&nt)===nt,neg:c=>tt(-c,e),eql:(c,l)=>c===l,sqr:c=>tt(c*c,e),add:(c,l)=>tt(c+l,e),sub:(c,l)=>tt(c-l,e),mul:(c,l)=>tt(c*l,e),pow:(c,l)=>kd(a,c,l),div:(c,l)=>tt(c*xn(l,e),e),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>xn(c,e),sqrt:n.sqrt||(c=>(s||(s=Ld(e)),s(a,c))),invertBatch:c=>Kd(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>r?cr(c,i):Ke(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return r?ke(c):le(c)}});return Object.freeze(a)}function Ca(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 ii(e){let t=Ca(e);return t+Math.ceil(t/2)}function Ba(e,t,r=!1){let n=e.length,o=Ca(t),i=ii(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?ke(e):le(e),a=tt(s,t-nt)+nt;return r?cr(a,o):Ke(a,o)}var Pa=BigInt(0),fi=BigInt(1);function si(e,t){let r=t.negate();return e?r:t}function Ua(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function ai(e,t){Ua(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=Fe(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function _a(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+=fi);let l=t*n,u=l+Math.abs(a)-1,f=a===0,d=a<0,w=t%2!==0;return{nextN:c,offset:u,isZero:f,isNeg:d,isNegF:w,offsetF:l}}function Fd(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 Od(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 ci=new WeakMap,Na=new WeakMap;function ui(e){return Na.get(e)||1}function wn(e,t){return{constTimeNegate:si,hasPrecomputes(r){return ui(r)!==1},unsafeLadder(r,n,o=e.ZERO){let i=r;for(;n>Pa;)n&fi&&(o=o.add(i)),i=i.double(),n>>=fi;return o},precomputeWindow(r,n){let{windows:o,windowSize:i}=ai(n,t),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 i=e.ZERO,s=e.BASE,a=ai(r,t);for(let c=0;c<a.windows;c++){let{nextN:l,offset:u,isZero:f,isNeg:d,isNegF:w,offsetF:C}=_a(o,c,a);o=l,f?s=s.add(si(w,n[C])):i=i.add(si(d,n[u]))}return{p:i,f:s}},wNAFUnsafe(r,n,o,i=e.ZERO){let s=ai(r,t);for(let a=0;a<s.windows&&o!==Pa;a++){let{nextN:c,offset:l,isZero:u,isNeg:f}=_a(o,a,s);if(o=c,!u){let d=n[l];i=i.add(f?d.negate():d)}}return i},getPrecomputes(r,n,o){let i=ci.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&ci.set(n,o(i))),i},wNAFCached(r,n,o){let i=ui(r);return this.wNAF(i,this.getPrecomputes(i,r,o),n)},wNAFCachedUnsafe(r,n,o,i){let s=ui(r);return s===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,r,o),n,i)},setWindowSize(r,n){Ua(n,t),Na.set(r,n),ci.delete(r)}}}function bn(e,t,r,n){if(Fd(r,e),Od(n,t),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=e.ZERO,i=Sa(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=Fe(s),c=new Array(Number(a)+1).fill(o),l=Math.floor((t.BITS-1)/s)*s,u=o;for(let f=l;f>=0;f-=s){c.fill(o);for(let w=0;w<n.length;w++){let C=n[w],x=Number(C>>BigInt(f)&a);c[x]=c[x].add(r[w])}let d=o;for(let w=c.length-1,C=o;w>0;w--)C=C.add(c[w]),d=d.add(C);if(u=u.add(d),f!==0)for(let w=0;w<s;w++)u=u.double()}return u}function Kr(e){return ni(e.Fp),de(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...oi(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}var re=BigInt(0),At=BigInt(1),Ra=BigInt(2),Md=BigInt(8),Vd={zip215:!0};function qd(e){let t=Kr(e);return de(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function La(e){let t=qd(e),{Fp:r,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=t,l=Ra<<BigInt(a*8)-At,u=r.create,f=Ce(t.n,t.nBitLength),d=t.uvRatio||((E,p)=>{try{return{isValid:!0,value:r.sqrt(E*r.inv(p))}}catch{return{isValid:!1,value:re}}}),w=t.adjustScalarBytes||(E=>E),C=t.domain||((E,p,I)=>{if(ee("phflag",I),p.length||I)throw new Error("Contexts/pre-hash are not supported");return E});function x(E,p,I=!1){let D=I?At:re;kt("coordinate "+E,p,D,l)}function h(E){if(!(E instanceof y))throw new Error("ExtendedPoint expected")}let A=ur((E,p)=>{let{ex:I,ey:D,ez:O}=E,z=E.is0();p==null&&(p=z?Md:r.inv(O));let j=u(I*p),G=u(D*p),Y=u(O*p);if(z)return{x:re,y:At};if(Y!==At)throw new Error("invZ was invalid");return{x:j,y:G}}),_=ur(E=>{let{a:p,d:I}=t;if(E.is0())throw new Error("bad point: ZERO");let{ex:D,ey:O,ez:z,et:j}=E,G=u(D*D),Y=u(O*O),J=u(z*z),ut=u(J*J),at=u(G*p),gt=u(J*u(at+Y)),Tt=u(ut+u(I*u(G*Y)));if(gt!==Tt)throw new Error("bad point: equation left != right (1)");let ht=u(D*O),wt=u(z*j);if(ht!==wt)throw new Error("bad point: equation left != right (2)");return!0});class y{constructor(p,I,D,O){x("x",p),x("y",I),x("z",D,!0),x("t",O),this.ex=p,this.ey=I,this.ez=D,this.et=O,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof y)throw new Error("extended point not allowed");let{x:I,y:D}=p||{};return x("x",I),x("y",D),new y(I,D,At,u(I*D))}static normalizeZ(p){let I=r.invertBatch(p.map(D=>D.ez));return p.map((D,O)=>D.toAffine(I[O])).map(y.fromAffine)}static msm(p,I){return bn(y,f,p,I)}_setWindowSize(p){k.setWindowSize(this,p)}assertValidity(){_(this)}equals(p){h(p);let{ex:I,ey:D,ez:O}=this,{ex:z,ey:j,ez:G}=p,Y=u(I*G),J=u(z*O),ut=u(D*G),at=u(j*O);return Y===J&&ut===at}is0(){return this.equals(y.ZERO)}negate(){return new y(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=t,{ex:I,ey:D,ez:O}=this,z=u(I*I),j=u(D*D),G=u(Ra*u(O*O)),Y=u(p*z),J=I+D,ut=u(u(J*J)-z-j),at=Y+j,gt=at-G,Tt=Y-j,ht=u(ut*gt),wt=u(at*Tt),Rt=u(ut*Tt),zt=u(gt*at);return new y(ht,wt,zt,Rt)}add(p){h(p);let{a:I,d:D}=t,{ex:O,ey:z,ez:j,et:G}=this,{ex:Y,ey:J,ez:ut,et:at}=p,gt=u(O*Y),Tt=u(z*J),ht=u(G*D*at),wt=u(j*ut),Rt=u((O+z)*(Y+J)-gt-Tt),zt=wt-ht,Tr=wt+ht,Ns=u(Tt-I*gt),lf=u(Rt*zt),df=u(Tr*Ns),hf=u(Rt*Ns),pf=u(zt*Tr);return new y(lf,df,pf,hf)}subtract(p){return this.add(p.negate())}wNAF(p){return k.wNAFCached(this,p,y.normalizeZ)}multiply(p){let I=p;kt("scalar",I,At,n);let{p:D,f:O}=this.wNAF(I);return y.normalizeZ([D,O])[0]}multiplyUnsafe(p,I=y.ZERO){let D=p;return kt("scalar",D,re,n),D===re?F:this.is0()||D===At?this:k.wNAFCachedUnsafe(this,D,y.normalizeZ,I)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return k.unsafeLadder(this,n).is0()}toAffine(p){return A(this,p)}clearCofactor(){let{h:p}=t;return p===At?this:this.multiplyUnsafe(p)}static fromHex(p,I=!1){let{d:D,a:O}=t,z=r.BYTES;p=it("pointHex",p,z),ee("zip215",I);let j=p.slice(),G=p[z-1];j[z-1]=G&-129;let Y=ke(j),J=I?l:r.ORDER;kt("pointHex.y",Y,re,J);let ut=u(Y*Y),at=u(ut-At),gt=u(D*ut-O),{isValid:Tt,value:ht}=d(at,gt);if(!Tt)throw new Error("Point.fromHex: invalid y coordinate");let wt=(ht&At)===At,Rt=(G&128)!==0;if(!I&&ht===re&&Rt)throw new Error("Point.fromHex: x=0 and x_0=1");return Rt!==wt&&(ht=u(-ht)),y.fromAffine({x:ht,y:Y})}static fromPrivateKey(p){let{scalar:I}=b(p);return U.multiply(I)}toRawBytes(){let{x:p,y:I}=this.toAffine(),D=cr(I,r.BYTES);return D[D.length-1]|=p&At?128:0,D}toHex(){return Ie(this.toRawBytes())}}y.BASE=new y(t.Gx,t.Gy,At,u(t.Gx*t.Gy)),y.ZERO=new y(re,At,At,re);let{BASE:U,ZERO:F}=y,k=wn(y,a*8);function N(E){return tt(E,n)}function g(E){return N(ke(E))}function b(E){let p=r.BYTES;E=it("private key",E,p);let I=it("hashed private key",i(E),2*p),D=w(I.slice(0,p)),O=I.slice(p,2*p),z=g(D);return{head:D,prefix:O,scalar:z}}function K(E){let{head:p,prefix:I,scalar:D}=b(E),O=U.multiply(D),z=O.toRawBytes();return{head:p,prefix:I,scalar:D,point:O,pointBytes:z}}function L(E){return K(E).pointBytes}function P(E=new Uint8Array,...p){let I=Te(...p);return g(i(C(I,it("context",E),!!o)))}function V(E,p,I={}){E=it("message",E),o&&(E=o(E));let{prefix:D,scalar:O,pointBytes:z}=K(p),j=P(I.context,D,E),G=U.multiply(j).toRawBytes(),Y=P(I.context,G,z,E),J=N(j+Y*O);kt("signature.s",J,re,n);let ut=Te(G,cr(J,r.BYTES));return it("result",ut,r.BYTES*2)}let S=Vd;function v(E,p,I,D=S){let{context:O,zip215:z}=D,j=r.BYTES;E=it("signature",E,2*j),p=it("message",p),I=it("publicKey",I,j),z!==void 0&&ee("zip215",z),o&&(p=o(p));let G=ke(E.slice(j,2*j)),Y,J,ut;try{Y=y.fromHex(I,z),J=y.fromHex(E.slice(0,j),z),ut=U.multiplyUnsafe(G)}catch{return!1}if(!z&&Y.isSmallOrder())return!1;let at=P(O,J.toRawBytes(),Y.toRawBytes(),p);return J.add(Y.multiplyUnsafe(at)).subtract(ut).clearCofactor().equals(y.ZERO)}return U._setWindowSize(8),{CURVE:t,getPublicKey:L,sign:V,verify:v,ExtendedPoint:y,utils:{getExtendedPublicKey:K,randomPrivateKey:()=>s(r.BYTES),precompute(E=8,p=y.BASE){return p._setWindowSize(E),p.multiply(BigInt(3)),p}}}}var li=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Da=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Ny=BigInt(0),$d=BigInt(1),ka=BigInt(2),Ry=BigInt(3),zd=BigInt(5),Hd=BigInt(8);function jd(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=li,a=e*e%i*e%i,c=ot(a,ka,i)*a%i,l=ot(c,$d,i)*e%i,u=ot(l,zd,i)*l%i,f=ot(u,t,i)*u%i,d=ot(f,r,i)*f%i,w=ot(d,n,i)*d%i,C=ot(w,o,i)*w%i,x=ot(C,o,i)*w%i,h=ot(x,t,i)*u%i;return{pow_p_5_8:ot(h,ka,i)*e%i,b2:a}}function Gd(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function Zd(e,t){let r=li,n=tt(t*t*t,r),o=tt(n*n*t,r),i=jd(e*o).pow_p_5_8,s=tt(e*n*i,r),a=tt(t*s*s,r),c=s,l=tt(s*Da,r),u=a===e,f=a===tt(-e,r),d=a===tt(-e*Da,r);return u&&(s=c),(f||d)&&(s=l),Ta(s,r)&&(s=tt(-s,r)),{isValid:u||f,value:s}}var Ka=Ce(li,void 0,!0),Wd={a:Ka.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ka,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Hd,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Yo,randomBytes:mn,adjustScalarBytes:Gd,uvRatio:Zd},Fa=La(Wd);var En=32;function Oa(e,t,r){return Fa.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}var Sn=class{type="Ed25519";raw;constructor(t){this.raw=di(t,En)}toMultihash(){return Lt.digest(nr(this))}toCID(){return Z.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}verify(t,r){return Oa(this.raw,r,t)}};function hi(e){return e=di(e,En),new Sn(e)}function di(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new ft(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var Xd=Math.pow(2,7),Jd=Math.pow(2,14),Qd=Math.pow(2,21),pi=Math.pow(2,28),mi=Math.pow(2,35),yi=Math.pow(2,42),gi=Math.pow(2,49),X=128,Et=127;function Nt(e){if(e<Xd)return 1;if(e<Jd)return 2;if(e<Qd)return 3;if(e<pi)return 4;if(e<mi)return 5;if(e<yi)return 6;if(e<gi)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function xi(e,t,r=0){switch(Nt(e)){case 8:t[r++]=e&255|X,e/=128;case 7:t[r++]=e&255|X,e/=128;case 6:t[r++]=e&255|X,e/=128;case 5:t[r++]=e&255|X,e/=128;case 4:t[r++]=e&255|X,e>>>=7;case 3:t[r++]=e&255|X,e>>>=7;case 2:t[r++]=e&255|X,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function th(e,t,r=0){switch(Nt(e)){case 8:t.set(r++,e&255|X),e/=128;case 7:t.set(r++,e&255|X),e/=128;case 6:t.set(r++,e&255|X),e/=128;case 5:t.set(r++,e&255|X),e/=128;case 4:t.set(r++,e&255|X),e>>>=7;case 3:t.set(r++,e&255|X),e>>>=7;case 2:t.set(r++,e&255|X),e>>>=7;case 1:{t.set(r++,e&255),e>>>=7;break}default:throw new Error("unreachable")}return t}function wi(e,t){let r=e[t],n=0;if(n+=r&Et,r<X||(r=e[t+1],n+=(r&Et)<<7,r<X)||(r=e[t+2],n+=(r&Et)<<14,r<X)||(r=e[t+3],n+=(r&Et)<<21,r<X)||(r=e[t+4],n+=(r&Et)*pi,r<X)||(r=e[t+5],n+=(r&Et)*mi,r<X)||(r=e[t+6],n+=(r&Et)*yi,r<X)||(r=e[t+7],n+=(r&Et)*gi,r<X))return n;throw new RangeError("Could not decode varint")}function eh(e,t){let r=e.get(t),n=0;if(n+=r&Et,r<X||(r=e.get(t+1),n+=(r&Et)<<7,r<X)||(r=e.get(t+2),n+=(r&Et)<<14,r<X)||(r=e.get(t+3),n+=(r&Et)<<21,r<X)||(r=e.get(t+4),n+=(r&Et)*pi,r<X)||(r=e.get(t+5),n+=(r&Et)*mi,r<X)||(r=e.get(t+6),n+=(r&Et)*yi,r<X)||(r=e.get(t+7),n+=(r&Et)*gi,r<X))return n;throw new RangeError("Could not decode varint")}function fr(e,t,r=0){return t==null&&(t=_t(Nt(e))),t instanceof Uint8Array?xi(e,t,r):th(e,t,r)}function Me(e,t=0){return e instanceof Uint8Array?wi(e,t):eh(e,t)}var bi=new Float32Array([-0]),Be=new Uint8Array(bi.buffer);function qa(e,t,r){bi[0]=e,t[r]=Be[0],t[r+1]=Be[1],t[r+2]=Be[2],t[r+3]=Be[3]}function $a(e,t){return Be[0]=e[t],Be[1]=e[t+1],Be[2]=e[t+2],Be[3]=e[t+3],bi[0]}var Ei=new Float64Array([-0]),St=new Uint8Array(Ei.buffer);function za(e,t,r){Ei[0]=e,t[r]=St[0],t[r+1]=St[1],t[r+2]=St[2],t[r+3]=St[3],t[r+4]=St[4],t[r+5]=St[5],t[r+6]=St[6],t[r+7]=St[7]}function Ha(e,t){return St[0]=e[t],St[1]=e[t+1],St[2]=e[t+2],St[3]=e[t+3],St[4]=e[t+4],St[5]=e[t+5],St[6]=e[t+6],St[7]=e[t+7],Ei[0]}var rh=BigInt(Number.MAX_SAFE_INTEGER),nh=BigInt(Number.MIN_SAFE_INTEGER),Kt=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 Ve;if(t<rh&&t>nh)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>ja&&(o=0n,++n>ja&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Ve;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):Ve}},Ve=new Kt(0,0);Ve.toBigInt=function(){return 0n};Ve.zzEncode=Ve.zzDecode=function(){return this};Ve.length=function(){return 1};var ja=4294967296n;function Ga(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 Za(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 Si(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 Zt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function vn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var vi=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,Zt(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 Zt(this,4);return vn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Zt(this,4);return vn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Zt(this,4);let t=$a(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Zt(this,4);let t=Ha(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 Zt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Za(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Zt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Zt(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 Kt(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 Zt(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 Zt(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 Zt(this,8);let t=vn(this.buf,this.pos+=4),r=vn(this.buf,this.pos+=4);return new Kt(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=wi(this.buf,this.pos);return this.pos+=Nt(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 Ai(e){return new vi(e instanceof Uint8Array?e:e.subarray())}function lr(e,t,r){let n=Ai(e);return t.decode(n,void 0,r)}function Ii(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return _t(s);o+s>t&&(n=_t(t),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var qe=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Ti(){}var Bi=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},oh=Ii();function ih(e){return globalThis.Buffer!=null?_t(e):oh(e)}var Or=class{len;head;tail;states;constructor(){this.len=0,this.head=new qe(Ti,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new qe(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Pi((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(An,10,Kt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Kt.fromBigInt(t);return this._push(An,r.length(),r)}uint64Number(t){return this._push(xi,Nt(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=Kt.fromBigInt(t).zzEncode();return this._push(An,r.length(),r)}sint64Number(t){let r=Kt.fromNumber(t).zzEncode();return this._push(An,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Ci,1,t?1:0)}fixed32(t){return this._push(Fr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Kt.fromBigInt(t);return this._push(Fr,4,r.lo)._push(Fr,4,r.hi)}fixed64Number(t){let r=Kt.fromNumber(t);return this._push(Fr,4,r.lo)._push(Fr,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(qa,4,t)}double(t){return this._push(za,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(Ci,1,0):this.uint32(r)._push(ah,r,t)}string(t){let r=Ga(t);return r!==0?this.uint32(r)._push(Si,r,t):this._push(Ci,1,0)}fork(){return this.states=new Bi(this),this.head=this.tail=new qe(Ti,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 qe(Ti,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=ih(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function Ci(e,t,r){t[r]=e&255}function sh(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Pi=class extends qe{next;constructor(t,r){super(sh,t,r),this.next=void 0}};function An(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 Fr(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 ah(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(Or.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(ch,t,e),this},Or.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(uh,t,e),this});function ch(e,t,r){t.set(e,r)}function uh(e,t,r){e.length<40?Si(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(H(e),r)}function _i(){return new Or}function dr(e,t){let r=_i();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var hr;(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"})(hr||(hr={}));function In(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Mr(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 In("enum",hr.VARINT,r,n)}function pr(e,t){return In("message",hr.LENGTH_DELIMITED,e,t)}var ct;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(ct||(ct={}));var Ui;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(Ui||(Ui={}));(function(e){e.codec=()=>Mr(Ui)})(ct||(ct={}));var ne;(function(e){let t;e.codec=()=>(t==null&&(t=pr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ct.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=ct.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>dr(r,e.codec()),e.decode=(r,n)=>lr(r,e.codec(),n)})(ne||(ne={}));var Ni;(function(e){let t;e.codec=()=>(t==null&&(t=pr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ct.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=ct.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>dr(r,e.codec()),e.decode=(r,n)=>lr(r,e.codec(),n)})(Ni||(Ni={}));var Vr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Tn=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Xa={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Tn("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var Pe=Xa;var $r={};Ct($r,{MAX_RSA_KEY_SIZE:()=>Ri,generateRSAKeyPair:()=>ec,jwkToJWKKeyPair:()=>rc,jwkToPkcs1:()=>hh,jwkToPkix:()=>Ki,jwkToRSAPrivateKey:()=>Vi,pkcs1MessageToJwk:()=>Di,pkcs1MessageToRSAPrivateKey:()=>Fi,pkcs1ToJwk:()=>dh,pkcs1ToRSAPrivateKey:()=>tc,pkixMessageToJwk:()=>ki,pkixMessageToRSAPublicKey:()=>Mi,pkixToJwk:()=>ph,pkixToRSAPublicKey:()=>Oi});var mr=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=$r.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return Z.createV1(114,this._multihash)}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}verify(t,r){return Qa(this.jwk,r,t)}},qr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=$r.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}sign(t){return Ja(this.jwk,t)}};var Ri=8192,Li=18,fh=1062,lh=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function dh(e){let t=ue(e);return Di(t)}function Di(e){return{n:q(e[1],"base64url"),e:q(e[2],"base64url"),d:q(e[3],"base64url"),p:q(e[4],"base64url"),q:q(e[5],"base64url"),dp:q(e[6],"base64url"),dq:q(e[7],"base64url"),qi:q(e[8],"base64url"),kty:"RSA"}}function hh(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 ft("JWK was missing components");return be([Ut(Uint8Array.from([0])),Ut(H(e.n,"base64url")),Ut(H(e.e,"base64url")),Ut(H(e.d,"base64url")),Ut(H(e.p,"base64url")),Ut(H(e.q,"base64url")),Ut(H(e.dp,"base64url")),Ut(H(e.dq,"base64url")),Ut(H(e.qi,"base64url"))]).subarray()}function ph(e){let t=ue(e,{offset:0});return ki(t)}function ki(e){let t=ue(e[1],{offset:0});return{kty:"RSA",n:q(t[0],"base64url"),e:q(t[1],"base64url")}}function Ki(e){if(e.n==null||e.e==null)throw new ft("JWK was missing components");return be([lh,dn(be([Ut(H(e.n,"base64url")),Ut(H(e.e,"base64url"))]))]).subarray()}function tc(e){let t=ue(e);return Fi(t)}function Fi(e){let t=Di(e);return Vi(t)}function Oi(e,t){if(e.byteLength>=fh)throw new Ge("Key size is too large");let r=ue(e,{offset:0});return Mi(r,e,t)}function Mi(e,t,r){let n=ki(e);if(r==null){let o=Le(ne.encode({Type:ct.RSA,Data:t}));r=jt(Li,o)}return new mr(n,r)}function Vi(e){if(oc(e)>Ri)throw new ft("Key size is too large");let t=rc(e),r=Le(ne.encode({Type:ct.RSA,Data:Ki(t.publicKey)})),n=jt(Li,r);return new qr(t.privateKey,new mr(t.publicKey,n))}async function ec(e){if(e>Ri)throw new ft("Key size is too large");let t=await nc(e),r=Le(ne.encode({Type:ct.RSA,Data:Ki(t.publicKey)})),n=jt(Li,r);return new qr(t.privateKey,new mr(t.publicKey,n))}function rc(e){if(e==null)throw new ft("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function nc(e){let t=await Pe.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 mh(t);return{privateKey:r[0],publicKey:r[1]}}async function Ja(e,t){let r=await Pe.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Pe.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function Qa(e,t,r){let n=await Pe.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Pe.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}async function mh(e){if(e.privateKey==null||e.publicKey==null)throw new ft("Private and public key are required");return Promise.all([Pe.get().subtle.exportKey("jwk",e.privateKey),Pe.get().subtle.exportKey("jwk",e.publicKey)])}function oc(e){if(e.kty!=="RSA")throw new ft("invalid key type");if(e.n==null)throw new ft("invalid key modulus");return H(e.n,"base64url").length*8}var Cn=class extends sr{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,da(t);let n=Lr(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 ir(this),this.iHash.update(t),this}digestInto(t){ir(this),or(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()}},qi=(e,t,r)=>new Cn(e,t).update(r).digest();qi.create=(e,t)=>new Cn(e,t);function ic(e){e.lowS!==void 0&&ee("lowS",e.lowS),e.prehash!==void 0&&ee("prehash",e.prehash)}function yh(e){let t=Kr(e);de(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 $i=class extends Error{constructor(t=""){super(t)}},he={Err:$i,_tlv:{encode:(e,t)=>{let{Err:r}=he;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=Dr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Dr(o.length/2|128):"";return Dr(e)+i+o+t},decode(e,t){let{Err:r}=he,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=he;if(e<pe)throw new t("integer: negative integers are not allowed");let r=Dr(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}=he;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 le(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=he,o=it("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:l,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=he,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},pe=BigInt(0),pt=BigInt(1),ix=BigInt(2),sc=BigInt(3),sx=BigInt(4);function gh(e){let t=yh(e),{Fp:r}=t,n=Ce(t.n,t.nBitLength),o=t.toBytes||((x,h,A)=>{let _=h.toAffine();return Te(Uint8Array.from([4]),r.toBytes(_.x),r.toBytes(_.y))}),i=t.fromBytes||(x=>{let h=x.subarray(1),A=r.fromBytes(h.subarray(0,r.BYTES)),_=r.fromBytes(h.subarray(r.BYTES,2*r.BYTES));return{x:A,y:_}});function s(x){let{a:h,b:A}=t,_=r.sqr(x),y=r.mul(_,x);return r.add(r.add(y,r.mul(x,h)),A)}if(!r.eql(r.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function a(x){return gn(x,pt,t.n)}function c(x){let{allowedPrivateKeyLengths:h,nByteLength:A,wrapPrivateKey:_,n:y}=t;if(h&&typeof x!="bigint"){if(De(x)&&(x=Ie(x)),typeof x!="string"||!h.includes(x.length))throw new Error("invalid private key");x=x.padStart(A*2,"0")}let U;try{U=typeof x=="bigint"?x:le(it("private key",x,A))}catch{throw new Error("invalid private key, expected hex or "+A+" bytes, got "+typeof x)}return _&&(U=tt(U,y)),kt("private key",U,pt,y),U}function l(x){if(!(x instanceof d))throw new Error("ProjectivePoint expected")}let u=ur((x,h)=>{let{px:A,py:_,pz:y}=x;if(r.eql(y,r.ONE))return{x:A,y:_};let U=x.is0();h==null&&(h=U?r.ONE:r.inv(y));let F=r.mul(A,h),k=r.mul(_,h),N=r.mul(y,h);if(U)return{x:r.ZERO,y:r.ZERO};if(!r.eql(N,r.ONE))throw new Error("invZ was invalid");return{x:F,y:k}}),f=ur(x=>{if(x.is0()){if(t.allowInfinityPoint&&!r.is0(x.py))return;throw new Error("bad point: ZERO")}let{x:h,y:A}=x.toAffine();if(!r.isValid(h)||!r.isValid(A))throw new Error("bad point: x or y not FE");let _=r.sqr(A),y=s(h);if(!r.eql(_,y))throw new Error("bad point: equation left != right");if(!x.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(h,A,_){if(h==null||!r.isValid(h))throw new Error("x required");if(A==null||!r.isValid(A))throw new Error("y required");if(_==null||!r.isValid(_))throw new Error("z required");this.px=h,this.py=A,this.pz=_,Object.freeze(this)}static fromAffine(h){let{x:A,y:_}=h||{};if(!h||!r.isValid(A)||!r.isValid(_))throw new Error("invalid affine point");if(h instanceof d)throw new Error("projective point not allowed");let y=U=>r.eql(U,r.ZERO);return y(A)&&y(_)?d.ZERO:new d(A,_,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let A=r.invertBatch(h.map(_=>_.pz));return h.map((_,y)=>_.toAffine(A[y])).map(d.fromAffine)}static fromHex(h){let A=d.fromAffine(i(it("pointHex",h)));return A.assertValidity(),A}static fromPrivateKey(h){return d.BASE.multiply(c(h))}static msm(h,A){return bn(d,n,h,A)}_setWindowSize(h){C.setWindowSize(this,h)}assertValidity(){f(this)}hasEvenY(){let{y:h}=this.toAffine();if(r.isOdd)return!r.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){l(h);let{px:A,py:_,pz:y}=this,{px:U,py:F,pz:k}=h,N=r.eql(r.mul(A,k),r.mul(U,y)),g=r.eql(r.mul(_,k),r.mul(F,y));return N&&g}negate(){return new d(this.px,r.neg(this.py),this.pz)}double(){let{a:h,b:A}=t,_=r.mul(A,sc),{px:y,py:U,pz:F}=this,k=r.ZERO,N=r.ZERO,g=r.ZERO,b=r.mul(y,y),K=r.mul(U,U),L=r.mul(F,F),P=r.mul(y,U);return P=r.add(P,P),g=r.mul(y,F),g=r.add(g,g),k=r.mul(h,g),N=r.mul(_,L),N=r.add(k,N),k=r.sub(K,N),N=r.add(K,N),N=r.mul(k,N),k=r.mul(P,k),g=r.mul(_,g),L=r.mul(h,L),P=r.sub(b,L),P=r.mul(h,P),P=r.add(P,g),g=r.add(b,b),b=r.add(g,b),b=r.add(b,L),b=r.mul(b,P),N=r.add(N,b),L=r.mul(U,F),L=r.add(L,L),b=r.mul(L,P),k=r.sub(k,b),g=r.mul(L,K),g=r.add(g,g),g=r.add(g,g),new d(k,N,g)}add(h){l(h);let{px:A,py:_,pz:y}=this,{px:U,py:F,pz:k}=h,N=r.ZERO,g=r.ZERO,b=r.ZERO,K=t.a,L=r.mul(t.b,sc),P=r.mul(A,U),V=r.mul(_,F),S=r.mul(y,k),v=r.add(A,_),T=r.add(U,F);v=r.mul(v,T),T=r.add(P,V),v=r.sub(v,T),T=r.add(A,y);let E=r.add(U,k);return T=r.mul(T,E),E=r.add(P,S),T=r.sub(T,E),E=r.add(_,y),N=r.add(F,k),E=r.mul(E,N),N=r.add(V,S),E=r.sub(E,N),b=r.mul(K,T),N=r.mul(L,S),b=r.add(N,b),N=r.sub(V,b),b=r.add(V,b),g=r.mul(N,b),V=r.add(P,P),V=r.add(V,P),S=r.mul(K,S),T=r.mul(L,T),V=r.add(V,S),S=r.sub(P,S),S=r.mul(K,S),T=r.add(T,S),P=r.mul(V,T),g=r.add(g,P),P=r.mul(E,T),N=r.mul(v,N),N=r.sub(N,P),P=r.mul(v,V),b=r.mul(E,b),b=r.add(b,P),new d(N,g,b)}subtract(h){return this.add(h.negate())}is0(){return this.equals(d.ZERO)}wNAF(h){return C.wNAFCached(this,h,d.normalizeZ)}multiplyUnsafe(h){let{endo:A,n:_}=t;kt("scalar",h,pe,_);let y=d.ZERO;if(h===pe)return y;if(this.is0()||h===pt)return this;if(!A||C.hasPrecomputes(this))return C.wNAFCachedUnsafe(this,h,d.normalizeZ);let{k1neg:U,k1:F,k2neg:k,k2:N}=A.splitScalar(h),g=y,b=y,K=this;for(;F>pe||N>pe;)F&pt&&(g=g.add(K)),N&pt&&(b=b.add(K)),K=K.double(),F>>=pt,N>>=pt;return U&&(g=g.negate()),k&&(b=b.negate()),b=new d(r.mul(b.px,A.beta),b.py,b.pz),g.add(b)}multiply(h){let{endo:A,n:_}=t;kt("scalar",h,pt,_);let y,U;if(A){let{k1neg:F,k1:k,k2neg:N,k2:g}=A.splitScalar(h),{p:b,f:K}=this.wNAF(k),{p:L,f:P}=this.wNAF(g);b=C.constTimeNegate(F,b),L=C.constTimeNegate(N,L),L=new d(r.mul(L.px,A.beta),L.py,L.pz),y=b.add(L),U=K.add(P)}else{let{p:F,f:k}=this.wNAF(h);y=F,U=k}return d.normalizeZ([y,U])[0]}multiplyAndAddUnsafe(h,A,_){let y=d.BASE,U=(k,N)=>N===pe||N===pt||!k.equals(y)?k.multiplyUnsafe(N):k.multiply(N),F=U(this,A).add(U(h,_));return F.is0()?void 0:F}toAffine(h){return u(this,h)}isTorsionFree(){let{h,isTorsionFree:A}=t;if(h===pt)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===pt?this:A?A(d,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return ee("isCompressed",h),this.assertValidity(),o(d,this,h)}toHex(h=!0){return ee("isCompressed",h),Ie(this.toRawBytes(h))}}d.BASE=new d(t.Gx,t.Gy,r.ONE),d.ZERO=new d(r.ZERO,r.ONE,r.ZERO);let w=t.nBitLength,C=wn(d,t.endo?Math.ceil(w/2):w);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function xh(e){let t=Kr(e);return de(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function ac(e){let t=xh(e),{Fp:r,n}=t,o=r.BYTES+1,i=2*r.BYTES+1;function s(S){return tt(S,n)}function a(S){return xn(S,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=gh({...t,toBytes(S,v,T){let E=v.toAffine(),p=r.toBytes(E.x),I=Te;return ee("isCompressed",T),T?I(Uint8Array.from([v.hasEvenY()?2:3]),p):I(Uint8Array.from([4]),p,r.toBytes(E.y))},fromBytes(S){let v=S.length,T=S[0],E=S.subarray(1);if(v===o&&(T===2||T===3)){let p=le(E);if(!gn(p,pt,r.ORDER))throw new Error("Point is not on curve");let I=u(p),D;try{D=r.sqrt(I)}catch(j){let G=j instanceof Error?": "+j.message:"";throw new Error("Point is not on curve"+G)}let O=(D&pt)===pt;return(T&1)===1!==O&&(D=r.neg(D)),{x:p,y:D}}else if(v===i&&T===4){let p=r.fromBytes(E.subarray(0,r.BYTES)),I=r.fromBytes(E.subarray(r.BYTES,2*r.BYTES));return{x:p,y:I}}else{let p=o,I=i;throw new Error("invalid Point, expected length of "+p+", or uncompressed "+I+", got "+v)}}}),d=S=>Ie(Ke(S,t.nByteLength));function w(S){let v=n>>pt;return S>v}function C(S){return w(S)?s(-S):S}let x=(S,v,T)=>le(S.slice(v,T));class h{constructor(v,T,E){kt("r",v,pt,n),kt("s",T,pt,n),this.r=v,this.s=T,E!=null&&(this.recovery=E),Object.freeze(this)}static fromCompact(v){let T=t.nByteLength;return v=it("compactSignature",v,T*2),new h(x(v,0,T),x(v,T,2*T))}static fromDER(v){let{r:T,s:E}=he.toSig(it("DER",v));return new h(T,E)}assertValidity(){}addRecoveryBit(v){return new h(this.r,this.s,v)}recoverPublicKey(v){let{r:T,s:E,recovery:p}=this,I=k(it("msgHash",v));if(p==null||![0,1,2,3].includes(p))throw new Error("recovery id invalid");let D=p===2||p===3?T+t.n:T;if(D>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let O=(p&1)===0?"02":"03",z=c.fromHex(O+d(D)),j=a(D),G=s(-I*j),Y=s(E*j),J=c.BASE.multiplyAndAddUnsafe(z,G,Y);if(!J)throw new Error("point at infinify");return J.assertValidity(),J}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return kr(this.toDERHex())}toDERHex(){return he.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return kr(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}let A={isValidPrivateKey(S){try{return l(S),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let S=ii(t.n);return Ba(t.randomBytes(S),t.n)},precompute(S=8,v=c.BASE){return v._setWindowSize(S),v.multiply(BigInt(3)),v}};function _(S,v=!0){return c.fromPrivateKey(S).toRawBytes(v)}function y(S){let v=De(S),T=typeof S=="string",E=(v||T)&&S.length;return v?E===o||E===i:T?E===2*o||E===2*i:S instanceof c}function U(S,v,T=!0){if(y(S))throw new Error("first arg must be private key");if(!y(v))throw new Error("second arg must be public key");return c.fromHex(v).multiply(l(S)).toRawBytes(T)}let F=t.bits2int||function(S){if(S.length>8192)throw new Error("input is too large");let v=le(S),T=S.length*8-t.nBitLength;return T>0?v>>BigInt(T):v},k=t.bits2int_modN||function(S){return s(F(S))},N=Fe(t.nBitLength);function g(S){return kt("num < 2^"+t.nBitLength,S,pe,N),Ke(S,t.nByteLength)}function b(S,v,T=K){if(["recovered","canonical"].some(at=>at in T))throw new Error("sign() legacy options not supported");let{hash:E,randomBytes:p}=t,{lowS:I,prehash:D,extraEntropy:O}=T;I==null&&(I=!0),S=it("msgHash",S),ic(T),D&&(S=it("prehashed msgHash",E(S)));let z=k(S),j=l(v),G=[g(j),g(z)];if(O!=null&&O!==!1){let at=O===!0?p(r.BYTES):O;G.push(it("extraEntropy",at))}let Y=Te(...G),J=z;function ut(at){let gt=F(at);if(!f(gt))return;let Tt=a(gt),ht=c.BASE.multiply(gt).toAffine(),wt=s(ht.x);if(wt===pe)return;let Rt=s(Tt*s(J+wt*j));if(Rt===pe)return;let zt=(ht.x===wt?0:2)|Number(ht.y&pt),Tr=Rt;return I&&w(Rt)&&(Tr=C(Rt),zt^=1),new h(wt,Tr,zt)}return{seed:Y,k2sig:ut}}let K={lowS:t.lowS,prehash:!1},L={lowS:t.lowS,prehash:!1};function P(S,v,T=K){let{seed:E,k2sig:p}=b(S,v,T),I=t;return va(I.hash.outputLen,I.nByteLength,I.hmac)(E,p)}c.BASE._setWindowSize(8);function V(S,v,T,E=L){let p=S;v=it("msgHash",v),T=it("publicKey",T);let{lowS:I,prehash:D,format:O}=E;if(ic(E),"strict"in E)throw new Error("options.strict was renamed to lowS");if(O!==void 0&&O!=="compact"&&O!=="der")throw new Error("format must be compact or der");let z=typeof p=="string"||De(p),j=!z&&!O&&typeof p=="object"&&p!==null&&typeof p.r=="bigint"&&typeof p.s=="bigint";if(!z&&!j)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let G,Y;try{if(j&&(G=new h(p.r,p.s)),z){try{O!=="compact"&&(G=h.fromDER(p))}catch(zt){if(!(zt instanceof he.Err))throw zt}!G&&O!=="der"&&(G=h.fromCompact(p))}Y=c.fromHex(T)}catch{return!1}if(!G||I&&G.hasHighS())return!1;D&&(v=t.hash(v));let{r:J,s:ut}=G,at=k(v),gt=a(ut),Tt=s(at*gt),ht=s(J*gt),wt=c.BASE.multiplyAndAddUnsafe(Y,Tt,ht)?.toAffine();return wt?s(wt.x)===J:!1}return{CURVE:t,getPublicKey:_,getSharedSecret:U,sign:P,verify:V,ProjectivePoint:c,Signature:h,utils:A}}function wh(e){return{hash:e,hmac:(t,...r)=>qi(e,t,jo(...r)),randomBytes:mn}}function cc(e,t){let r=n=>ac({...e,...wh(n)});return{...r(t),create:r}}var lc=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),uc=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),bh=BigInt(1),zi=BigInt(2),fc=(e,t)=>(e+t/zi)/t;function Eh(e){let t=lc,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,f=ot(u,r,t)*u%t,d=ot(f,r,t)*u%t,w=ot(d,zi,t)*l%t,C=ot(w,o,t)*w%t,x=ot(C,i,t)*C%t,h=ot(x,a,t)*x%t,A=ot(h,c,t)*h%t,_=ot(A,a,t)*x%t,y=ot(_,r,t)*u%t,U=ot(y,s,t)*C%t,F=ot(U,n,t)*l%t,k=ot(F,zi,t);if(!Hi.eql(Hi.sqr(k),e))throw new Error("Cannot find square root");return k}var Hi=Ce(lc,void 0,void 0,{sqrt:Eh}),$e=cc({a:BigInt(0),b:BigInt(7),Fp:Hi,n:uc,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{let t=uc,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-bh*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=fc(i*e,t),c=fc(-n*e,t),l=tt(e-a*r-c*o,t),u=tt(-a*n-c*i,t),f=l>s,d=u>s;if(f&&(l=t-l),d&&(u=t-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:f,k1:l,k2neg:d,k2:u}}}},Le),mx=BigInt(0);var yx=$e.ProjectivePoint;function dc(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}function hc(e,t,r){let n=_r.digest(r instanceof Uint8Array?r:r.subarray());if(dc(n))return n.then(({digest:o})=>$e.verify(t,o,e)).catch(o=>{throw new Vr(String(o))});try{return $e.verify(t,n.digest,e)}catch(o){throw new Vr(String(o))}}var Bn=class{type="secp256k1";raw;_key;constructor(t){this._key=mc(t),this.raw=pc(this._key)}toMultihash(){return Lt.digest(nr(this))}toCID(){return Z.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}verify(t,r){return hc(this._key,r,t)}};function ji(e){return new Bn(e)}function pc(e){return $e.ProjectivePoint.fromHex(e).toRawBytes(!0)}function mc(e){try{return $e.ProjectivePoint.fromHex(e),e}catch(t){throw new Ge(String(t))}}function yc(e,t){let{Type:r,Data:n}=ne.decode(e),o=n??new Uint8Array;switch(r){case ct.RSA:return Oi(o,t);case ct.Ed25519:return hi(o);case ct.secp256k1:return ji(o);case ct.ECDSA:return Ho(o);default:throw new We}}function Pn(e){let{Type:t,Data:r}=ne.decode(e.digest),n=r??new Uint8Array;switch(t){case ct.Ed25519:return hi(n);case ct.secp256k1:return ji(n);case ct.ECDSA:return Ho(n);default:throw new We}}function nr(e){return ne.encode({Type:ct[e.type],Data:e.raw})}var gc=Symbol.for("nodejs.util.inspect.custom"),Sh=114,zr=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()})`}[yo]=!0;toString(){return this.string==null&&(this.string=Q.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return Z.createV1(Sh,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return rt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return rt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[gc](){return`PeerId(${this.toString()})`}},_n=class extends zr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Un=class extends zr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Nn=class extends zr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},vh=2336,Hr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Lt.digest(H(this.url))}[gc](){return`PeerId(${this.url})`}[yo]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return Z.createV1(vh,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=q(t)),t.toString()===this.toString())}};var Ah=114,xc=2336;function wc(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=ae(Q.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return Gi(Z.parse(e));if(t==null)throw new ft('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=ae(t.decode(e))}return bc(r)}function bc(e){if(Th(e))return new _n({multihash:e});if(Ih(e))try{let t=Pn(e);if(t.type==="Ed25519")return new Un({multihash:e,publicKey:t});if(t.type==="secp256k1")return new Nn({multihash:e,publicKey:t})}catch{let r=q(e.digest);return new Hr(new URL(r))}throw new Ze("Supplied PeerID Multihash is invalid")}function Gi(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==Ah&&e.code!==xc)throw new sn("Supplied PeerID CID is invalid");if(e.code===xc){let t=q(e.multihash.digest);return new Hr(new URL(t))}return bc(e.multihash)}function Ih(e){return e.code===Lt.code}function Th(e){return e.code===_r.code}var Rn=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let d=Number.parseInt(f,t);if(!Number.isNaN(d))return d});if(u===void 0)break;if(i*=t,i+=u,i>l||(s+=1,r!==void 0&&s>r))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return r[o]=s[0],r[o+1]=s[1],r[o+2]=s[2],r[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];r[o]=i>>8,r[o+1]=i&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=t(i.subarray(0,s));return r.set(i.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Ec=45,Ch=15,yr=new Rn;function Zi(e){if(!(e.length>Ch))return yr.new(e).parseWith(()=>yr.readIPv4Addr())}function Wi(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Ec))return yr.new(e).parseWith(()=>yr.readIPv6Addr())}function Ln(e,t=!1){if(e.includes("%")&&(e=e.split("%")[0]),e.length>Ec)return;let r=yr.new(e).parseWith(()=>yr.readIPAddr());if(r)return t&&r.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,r[0],r[1],r[2],r[3]]):r}var _w=parseInt("0xFFFF",16),Uw=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Ac(e){return!!Zi(e)}function Ic(e){return!!Wi(e)}function Dn(e){return!!Ln(e)}var Tc=Ac,Nh=Ic,Yi=function(e){let t=0;if(e=e.toString().trim(),Tc(e)){let r=new Uint8Array(t+4);return e.split(/\./g).forEach(n=>{r[t++]=parseInt(n,10)&255}),r}if(Nh(e)){let r=e.split(":",8),n;for(n=0;n<r.length;n++){let i=Tc(r[n]),s;i&&(s=Yi(r[n]),r[n]=q(s.slice(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,q(s.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let i=[n,1];for(n=9-r.length;n>0;n--)i.push("0");r.splice.apply(r,i)}let o=new Uint8Array(t+16);for(n=0;n<r.length;n++){let i=parseInt(r[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},Cc=function(e,t=0,r){t=~~t,r=r??e.length-t;let n=new DataView(e.buffer);if(r===4){let o=[];for(let i=0;i<r;i++)o.push(e[t+i]);return o.join(".")}if(r===16){let o=[];for(let i=0;i<r;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var gr={},Xi={},Lh=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];Lh.forEach(e=>{let t=Dh(...e);Xi[t.code]=t,gr[t.name]=t});function Dh(e,t,r,n,o){return{code:e,size:t,name:r,resolvable:!!n,path:!!o}}function et(e){if(typeof e=="number"){if(Xi[e]!=null)return Xi[e];throw new Error(`no protocol with code: ${e}`)}else if(typeof e=="string"){if(gr[e]!=null)return gr[e];throw new Error(`no protocol with name: ${e}`)}throw new Error(`invalid protocol id type: ${typeof e}`)}var pb=et("ip4"),mb=et("ip6"),yb=et("ipcidr");function es(e,t){switch(et(e).code){case 4:case 41:return Kh(t);case 42:return ts(t);case 43:return q(t,"base10");case 6:case 273:case 33:case 132:return _c(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ts(t);case 421:return Vh(t);case 444:return Pc(t);case 445:return Pc(t);case 466:return Mh(t);case 481:return globalThis.encodeURIComponent(ts(t));default:return q(t,"base16")}}function rs(e,t){switch(et(e).code){case 4:return Bc(t);case 41:return Bc(t);case 42:return Qi(t);case 43:return H(t,"base10");case 6:case 273:case 33:case 132:return ns(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Qi(t);case 421:return Fh(t);case 444:return qh(t);case 445:return $h(t);case 466:return Oh(t);case 481:return Qi(globalThis.decodeURIComponent(t));default:return H(t,"base16")}}var Ji=Object.values(Ur).map(e=>e.decoder),kh=function(){let e=Ji[0].or(Ji[1]);return Ji.slice(2).forEach(t=>e=e.or(t)),e}();function Bc(e){if(!Dn(e))throw new Error("invalid ip address");return Yi(e)}function Kh(e){let t=Cc(e,0,e.length);if(t==null)throw new Error("ipBuff is required");if(!Dn(t))throw new Error("invalid ip address");return t}function ns(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function _c(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function Qi(e){let t=H(e),r=Uint8Array.from(fr(t.length));return bt([r,t],r.length+t.length)}function ts(e){let t=Me(e);if(e=e.slice(Nt(t)),e.length!==t)throw new Error("inconsistent lengths");return q(e)}function Fh(e){let t;e[0]==="Q"||e[0]==="1"?t=ae(Q.decode(`z${e}`)).bytes:t=Z.parse(e).multihash.bytes;let r=Uint8Array.from(fr(t.length));return bt([r,t],r.length+t.length)}function Oh(e){let t=kh.decode(e),r=Uint8Array.from(fr(t.length));return bt([r,t],r.length+t.length)}function Mh(e){let t=Me(e),r=e.slice(Nt(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+q(r,"base64url")}function Vh(e){let t=Me(e),r=e.slice(Nt(t));if(r.length!==t)throw new Error("inconsistent lengths");return q(r,"base58btc")}function qh(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let r=Ht.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ns(n);return bt([r,o],r.length+o.length)}function $h(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let r=Ht.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ns(n);return bt([r,o],r.length+o.length)}function Pc(e){let t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=q(t,"base32"),o=_c(r);return`${n}:${o}`}function Uc(e){e=os(e);let t=[],r=[],n=null,o=e.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let s=o[i],a=et(s);if(a.size===0){t.push([a.code]),r.push([a.code]);continue}if(i++,i>=o.length)throw new kn("invalid address: "+e);if(a.path===!0){n=os(o.slice(i).join("/")),t.push([a.code,rs(a.code,n)]),r.push([a.code,n]);break}let c=rs(a.code,o[i]);t.push([a.code,c]),r.push([a.code,es(a.code,c)])}return{string:Nc(r),bytes:Kn(t),tuples:t,stringTuples:r,path:n}}function is(e){let t=[],r=[],n=null,o=0;for(;o<e.length;){let i=Me(e,o),s=Nt(i),a=et(i),c=zh(a,e.slice(o+s));if(c===0){t.push([i]),r.push([i]),o+=s;continue}let l=e.slice(o+s,o+s+c);if(o+=c+s,o>e.length)throw new kn("Invalid address Uint8Array: "+q(e,"base16"));t.push([i,l]);let u=es(i,l);if(r.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(e),string:Nc(r),tuples:t,stringTuples:r,path:n}}function Nc(e){let t=[];return e.map(r=>{let n=et(r[0]);return t.push(n.name),r.length>1&&r[1]!=null&&t.push(r[1]),null}),os(t.join("/"))}function Kn(e){return bt(e.map(t=>{let r=et(t[0]),n=Uint8Array.from(fr(r.code));return t.length>1&&t[1]!=null&&(n=bt([n,t[1]])),n}))}function zh(e,t){if(e.size>0)return e.size/8;if(e.size===0)return 0;{let r=Me(t instanceof Uint8Array?t:Uint8Array.from(t));return r+Nt(r)}}function os(e){return"/"+e.trim().split("/").filter(t=>t).join("/")}var kn=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var Hh=Symbol.for("nodejs.util.inspect.custom"),as=Symbol.for("@multiformats/js-multiaddr/multiaddr"),jh=[et("dns").code,et("dns4").code,et("dns6").code,et("dnsaddr").code],ss=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Fn=class e{bytes;#t;#r;#e;#a;[as]=!0;constructor(t){t==null&&(t="");let r;if(t instanceof Uint8Array)r=is(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);r=Uc(t)}else if(Lc(t))r=is(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.bytes,this.#t=r.string,this.#r=r.tuples,this.#e=r.stringTuples,this.#a=r.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,r,n,o,i="",s=et("tcp"),a=et("udp"),c=et("ip4"),l=et("ip6"),u=et("dns6"),f=et("ip6zone");for(let[w,C]of this.stringTuples())w===f.code&&(i=`%${C??""}`),jh.includes(w)&&(r=s.name==="tcp"?"tcp":"udp",o=443,n=`${C??""}${i}`,t=w===u.code?6:4),(w===s.code||w===a.code)&&(r=et(w).name==="tcp"?"tcp":"udp",o=parseInt(C??"")),(w===c.code||w===l.code)&&(r=et(w).name==="tcp"?"tcp":"udp",n=`${C??""}${i}`,t=w===l.code?6:4);if(t==null||r==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:r,port:o}}protos(){return this.#r.map(([t])=>Object.assign({},et(t)))}protoCodes(){return this.#r.map(([t])=>t)}protoNames(){return this.#r.map(([t])=>et(t).name)}tuples(){return this.#r.map(([t,r])=>r==null?[t]:[t,r])}stringTuples(){return this.#e.map(([t,r])=>r==null?[t]:[t,r])}encapsulate(t){return t=new e(t),new e(this.toString()+t.toString())}decapsulate(t){let r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new e(n.slice(0,o))}decapsulateCode(t){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===t)return new e(Kn(r.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===gr.p2p.code&&t.push([n,o]),n===gr["p2p-circuit"].code&&(t=[])});let r=t.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?q(Q.decode(`z${n}`),"base58btc"):q(Z.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(t){return rt(this.bytes,t.bytes)}async resolve(t){let r=this.protos().find(i=>i.resolvable);if(r==null)return[this];let n=Rc.get(r.name);if(n==null)throw new ss(`no available resolver for ${r.name}`);return(await n(this,t)).map(i=>ze(i))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let r=(t??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[Hh](){return`Multiaddr(${this.#t})`}};var Rc=new Map;function Lc(e){return!!e?.[as]}function ze(e){return new Fn(e)}function jr(e){let t=new globalThis.AbortController;function r(){t.abort();for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}for(let i of e){if(i?.aborted===!0){r();break}i?.addEventListener!=null&&i.addEventListener("abort",r)}function n(){for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}let o=t.signal;return o.clear=n,o}async function*On(e,t={}){let r=e.getReader();try{for(;;){let n=await r.read();if(n.done)return;yield n.value}}finally{t.preventCancel!==!0&&await r.cancel(),r.releaseLock()}}var Gh="/",Zh=new TextEncoder().encode(Gh),jb=Zh[0];var Bp=mo(us(),1);var Wt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},Mn=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},xr=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},Vn=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},qn=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},$n=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},Gr=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var Yt;(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=()=>Mr(r)}(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=pr((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),e.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let l=o.uint32();switch(l>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=e.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(l&7);break}}}return a})),n),e.encode=o=>dr(o,e.codec()),e.decode=(o,i)=>lr(o,e.codec(),i)})(Yt||(Yt={}));var Wh=["string","number","bigint","symbol"],Yh=["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 Dc(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(Wh.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Xh(e))return"Buffer";let r=Jh(e);return r||"Object"}function Xh(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Jh(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Yh.includes(t))return t}var m=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}};m.uint=new m(0,"uint",!0);m.negint=new m(1,"negint",!0);m.bytes=new m(2,"bytes",!0);m.string=new m(3,"string",!0);m.array=new m(4,"array",!1);m.map=new m(5,"map",!1);m.tag=new m(6,"tag",!1);m.float=new m(7,"float",!0);m.false=new m(7,"false",!0);m.true=new m(7,"true",!0);m.null=new m(7,"null",!0);m.undefined=new m(7,"undefined",!0);m.break=new m(7,"break",!0);var R=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 wr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Qh=new TextDecoder,tp=new TextEncoder;function zn(e){return wr&&globalThis.Buffer.isBuffer(e)}function Oc(e){return e instanceof Uint8Array?zn(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Mc=wr?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Kc(e,t,r):(e,t,r)=>r-t>64?Qh.decode(e.subarray(t,r)):Kc(e,t,r),Vc=wr?e=>e.length>64?globalThis.Buffer.from(e):kc(e):e=>e.length>64?tp.encode(e):kc(e);var br=wr?(e,t,r)=>zn(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),qc=wr?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Oc(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},$c=wr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function zc(e,t){if(zn(e)&&zn(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 kc(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 Kc(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,l,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],l=e[t+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),t+=s}return ep(n)}var Fc=4096;function ep(e){let t=e.length;if(t<=Fc)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Fc));return r}var rp=256,Hn=class{constructor(t=rp){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=$c(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=br(n,0,this.cursor)}else r=qc(this.chunks,this.cursor);return t&&this.reset(),r}};var M="CBOR decode error:",fs="CBOR encode error:",Zr=[];Zr[23]=1;Zr[24]=2;Zr[25]=3;Zr[26]=5;Zr[27]=9;function me(e,t,r){if(e.length-t<r)throw new Error(`${M} not enough data for type`)}var mt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Ft(e,t,r){me(e,t,1);let n=e[t];if(r.strict===!0&&n<mt[0])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Ot(e,t,r){me(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<mt[1])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Mt(e,t,r){me(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<mt[2])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Vt(e,t,r){me(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<mt[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 Hc(e,t,r,n){return new R(m.uint,Ft(e,t+1,n),2)}function jc(e,t,r,n){return new R(m.uint,Ot(e,t+1,n),3)}function Gc(e,t,r,n){return new R(m.uint,Mt(e,t+1,n),5)}function Zc(e,t,r,n){return new R(m.uint,Vt(e,t+1,n),9)}function qt(e,t){return xt(e,0,t.value)}function xt(e,t,r){if(r<mt[0]){let n=Number(r);e.push([t|n])}else if(r<mt[1]){let n=Number(r);e.push([t|24,n])}else if(r<mt[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<mt[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<mt[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`)}}qt.encodedSize=function(t){return xt.encodedSize(t.value)};xt.encodedSize=function(t){return t<mt[0]?1:t<mt[1]?2:t<mt[2]?3:t<mt[3]?5:9};qt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Wc(e,t,r,n){return new R(m.negint,-1-Ft(e,t+1,n),2)}function Yc(e,t,r,n){return new R(m.negint,-1-Ot(e,t+1,n),3)}function Xc(e,t,r,n){return new R(m.negint,-1-Mt(e,t+1,n),5)}var ls=BigInt(-1),Jc=BigInt(1);function Qc(e,t,r,n){let o=Vt(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new R(m.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${M} integers outside of the safe integer range are not supported`);return new R(m.negint,ls-BigInt(o),9)}function jn(e,t){let r=t.value,n=typeof r=="bigint"?r*ls-Jc:r*-1-1;xt(e,t.type.majorEncoded,n)}jn.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*ls-Jc:r*-1-1;return n<mt[0]?1:n<mt[1]?2:n<mt[2]?3:n<mt[3]?5:9};jn.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function Wr(e,t,r,n){me(e,t,r+n);let o=br(e,t+r,t+r+n);return new R(m.bytes,o,r+n)}function tu(e,t,r,n){return Wr(e,t,1,r)}function eu(e,t,r,n){return Wr(e,t,2,Ft(e,t+1,n))}function ru(e,t,r,n){return Wr(e,t,3,Ot(e,t+1,n))}function nu(e,t,r,n){return Wr(e,t,5,Mt(e,t+1,n))}function ou(e,t,r,n){let o=Vt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer bytes lengths not supported`);return Wr(e,t,9,o)}function Gn(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===m.string?Vc(e.value):e.value),e.encodedBytes}function Er(e,t){let r=Gn(t);xt(e,t.type.majorEncoded,r.length),e.push(r)}Er.encodedSize=function(t){let r=Gn(t);return xt.encodedSize(r.length)+r.length};Er.compareTokens=function(t,r){return op(Gn(t),Gn(r))};function op(e,t){return e.length<t.length?-1:e.length>t.length?1:zc(e,t)}function Yr(e,t,r,n,o){let i=r+n;me(e,t,i);let s=new R(m.string,Mc(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=br(e,t+r,t+i)),s}function iu(e,t,r,n){return Yr(e,t,1,r,n)}function su(e,t,r,n){return Yr(e,t,2,Ft(e,t+1,n),n)}function au(e,t,r,n){return Yr(e,t,3,Ot(e,t+1,n),n)}function cu(e,t,r,n){return Yr(e,t,5,Mt(e,t+1,n),n)}function uu(e,t,r,n){let o=Vt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer string lengths not supported`);return Yr(e,t,9,o,n)}var fu=Er;function Sr(e,t,r,n){return new R(m.array,n,r)}function lu(e,t,r,n){return Sr(e,t,1,r)}function du(e,t,r,n){return Sr(e,t,2,Ft(e,t+1,n))}function hu(e,t,r,n){return Sr(e,t,3,Ot(e,t+1,n))}function pu(e,t,r,n){return Sr(e,t,5,Mt(e,t+1,n))}function mu(e,t,r,n){let o=Vt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer array lengths not supported`);return Sr(e,t,9,o)}function yu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return Sr(e,t,1,1/0)}function Zn(e,t){xt(e,m.array.majorEncoded,t.value)}Zn.compareTokens=qt.compareTokens;Zn.encodedSize=function(t){return xt.encodedSize(t.value)};function vr(e,t,r,n){return new R(m.map,n,r)}function gu(e,t,r,n){return vr(e,t,1,r)}function xu(e,t,r,n){return vr(e,t,2,Ft(e,t+1,n))}function wu(e,t,r,n){return vr(e,t,3,Ot(e,t+1,n))}function bu(e,t,r,n){return vr(e,t,5,Mt(e,t+1,n))}function Eu(e,t,r,n){let o=Vt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer map lengths not supported`);return vr(e,t,9,o)}function Su(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return vr(e,t,1,1/0)}function Wn(e,t){xt(e,m.map.majorEncoded,t.value)}Wn.compareTokens=qt.compareTokens;Wn.encodedSize=function(t){return xt.encodedSize(t.value)};function vu(e,t,r,n){return new R(m.tag,r,1)}function Au(e,t,r,n){return new R(m.tag,Ft(e,t+1,n),2)}function Iu(e,t,r,n){return new R(m.tag,Ot(e,t+1,n),3)}function Tu(e,t,r,n){return new R(m.tag,Mt(e,t+1,n),5)}function Cu(e,t,r,n){return new R(m.tag,Vt(e,t+1,n),9)}function Yn(e,t){xt(e,m.tag.majorEncoded,t.value)}Yn.compareTokens=qt.compareTokens;Yn.encodedSize=function(t){return xt.encodedSize(t.value)};var fp=20,lp=21,dp=22,hp=23;function Bu(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${M} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new R(m.null,null,1):new R(m.undefined,void 0,1)}function Pu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return new R(m.break,void 0,1)}function ds(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 R(m.float,e,t)}function _u(e,t,r,n){return ds(hs(e,t+1),3,n)}function Uu(e,t,r,n){return ds(ps(e,t+1),5,n)}function Nu(e,t,r,n){return ds(ku(e,t+1),9,n)}function Xn(e,t,r){let n=t.value;if(n===!1)e.push([m.float.majorEncoded|fp]);else if(n===!0)e.push([m.float.majorEncoded|lp]);else if(n===null)e.push([m.float.majorEncoded|dp]);else if(n===void 0)e.push([m.float.majorEncoded|hp]);else{let o,i=!1;(!r||r.float64!==!0)&&(Lu(n),o=hs(Xt,1),n===o||Number.isNaN(n)?(Xt[0]=249,e.push(Xt.slice(0,3)),i=!0):(Du(n),o=ps(Xt,1),n===o&&(Xt[0]=250,e.push(Xt.slice(0,5)),i=!0))),i||(pp(n),o=ku(Xt,1),Xt[0]=251,e.push(Xt.slice(0,9)))}}Xn.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){Lu(n);let o=hs(Xt,1);if(n===o||Number.isNaN(n))return 3;if(Du(n),o=ps(Xt,1),n===o)return 5}return 9};var Ru=new ArrayBuffer(9),$t=new DataView(Ru,1),Xt=new Uint8Array(Ru,0);function Lu(e){if(e===1/0)$t.setUint16(0,31744,!1);else if(e===-1/0)$t.setUint16(0,64512,!1);else if(Number.isNaN(e))$t.setUint16(0,32256,!1);else{$t.setFloat32(0,e);let t=$t.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)$t.setUint16(0,31744,!1);else if(r===0)$t.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?$t.setUint16(0,0):o<-14?$t.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):$t.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function hs(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 Du(e){$t.setFloat32(0,e,!1)}function ps(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 pp(e){$t.setFloat64(0,e,!1)}function ku(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)}Xn.compareTokens=qt.compareTokens;function W(e,t,r){throw new Error(`${M} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Jn(e){return()=>{throw new Error(`${M} ${e}`)}}var B=[];for(let e=0;e<=23;e++)B[e]=W;B[24]=Hc;B[25]=jc;B[26]=Gc;B[27]=Zc;B[28]=W;B[29]=W;B[30]=W;B[31]=W;for(let e=32;e<=55;e++)B[e]=W;B[56]=Wc;B[57]=Yc;B[58]=Xc;B[59]=Qc;B[60]=W;B[61]=W;B[62]=W;B[63]=W;for(let e=64;e<=87;e++)B[e]=tu;B[88]=eu;B[89]=ru;B[90]=nu;B[91]=ou;B[92]=W;B[93]=W;B[94]=W;B[95]=Jn("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)B[e]=iu;B[120]=su;B[121]=au;B[122]=cu;B[123]=uu;B[124]=W;B[125]=W;B[126]=W;B[127]=Jn("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)B[e]=lu;B[152]=du;B[153]=hu;B[154]=pu;B[155]=mu;B[156]=W;B[157]=W;B[158]=W;B[159]=yu;for(let e=160;e<=183;e++)B[e]=gu;B[184]=xu;B[185]=wu;B[186]=bu;B[187]=Eu;B[188]=W;B[189]=W;B[190]=W;B[191]=Su;for(let e=192;e<=215;e++)B[e]=vu;B[216]=Au;B[217]=Iu;B[218]=Tu;B[219]=Cu;B[220]=W;B[221]=W;B[222]=W;B[223]=W;for(let e=224;e<=243;e++)B[e]=Jn("simple values are not supported");B[244]=W;B[245]=W;B[246]=W;B[247]=Bu;B[248]=Jn("simple values are not supported");B[249]=_u;B[250]=Uu;B[251]=Nu;B[252]=W;B[253]=W;B[254]=W;B[255]=Pu;var Jt=[];for(let e=0;e<24;e++)Jt[e]=new R(m.uint,e,1);for(let e=-1;e>=-24;e--)Jt[31-e]=new R(m.negint,e,1);Jt[64]=new R(m.bytes,new Uint8Array(0),1);Jt[96]=new R(m.string,"",1);Jt[128]=new R(m.array,0,1);Jt[160]=new R(m.map,0,1);Jt[244]=new R(m.false,!1,1);Jt[245]=new R(m.true,!0,1);Jt[246]=new R(m.null,null,1);function yp(){let e=[];return e[m.uint.major]=qt,e[m.negint.major]=jn,e[m.bytes.major]=Er,e[m.string.major]=fu,e[m.array.major]=Zn,e[m.map.major]=Wn,e[m.tag.major]=Yn,e[m.float.major]=Xn,e}var z1=yp(),H1=new Hn,Qn=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(`${fs} object contains circular references`);return new e(r,t)}},_e={null:new R(m.null,null),undefined:new R(m.undefined,void 0),true:new R(m.true,!0),false:new R(m.false,!1),emptyArray:new R(m.array,0),emptyMap:new R(m.map,0)},Ue={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new R(m.float,e):e>=0?new R(m.uint,e):new R(m.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new R(m.uint,e):new R(m.negint,e)},Uint8Array(e,t,r,n){return new R(m.bytes,e)},string(e,t,r,n){return new R(m.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 R(m.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new R(m.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[_e.emptyArray,new R(m.break)]:_e.emptyArray;n=Qn.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=ms(s,r,n);return r.addBreakTokens?[new R(m.array,e.length),o,new R(m.break)]:[new R(m.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 R(m.break)]:_e.emptyMap;n=Qn.createCheck(n,e);let a=[],c=0;for(let l of i)a[c++]=[ms(l,r,n),ms(o?e.get(l):e[l],r,n)];return gp(a,r),r.addBreakTokens?[new R(m.map,s),a,new R(m.break)]:[new R(m.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 ms(e,t={},r){let n=Dc(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(`${fs} unsupported type: ${n}`);return i(e,n,t,r)}function gp(e,t){t.mapSorter&&e.sort(t.mapSorter)}var xp={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},to=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=Jt[t];if(r===void 0){let n=B[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}},Xr=Symbol.for("DONE"),eo=Symbol.for("BREAK");function wp(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=Ar(t,r);if(i===eo){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed array`)}if(i===Xr)throw new Error(`${M} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function bp(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=Ar(t,r);if(a===eo){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed map`)}if(a===Xr)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=Ar(t,r);if(c===Xr)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 Ar(e,t){if(e.done())return Xr;let r=e.next();if(r.type===m.break)return eo;if(r.type.terminal)return r.value;if(r.type===m.array)return wp(r,e,t);if(r.type===m.map)return bp(r,e,t);if(r.type===m.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=Ar(e,t);return t.tags[r.value](n)}throw new Error(`${M} tag not supported (${r.value})`)}throw new Error("unsupported")}function Ku(e,t){if(!(e instanceof Uint8Array))throw new Error(`${M} data to decode must be a Uint8Array`);t=Object.assign({},xp,t);let r=t.tokenizer||new to(e,t),n=Ar(r,t);if(n===Xr)throw new Error(`${M} did not find any content to decode`);if(n===eo)throw new Error(`${M} got unexpected break`);return[n,e.subarray(r.pos())]}function ys(e,t){let[r,n]=Ku(e,t);if(n.length>0)throw new Error(`${M} too many terminals, data makes no sense`);return r}var vp=xe("ipns:utils"),Fu=H("/ipns/");var Ap=0,Ip=18;function Ou(e){let t;if(e.pubKey!=null)try{t=yc(e.pubKey)}catch(r){throw vp.error(r),r}if(t!=null)return t}function Mu(e){let t=H("ipns-signature:");return bt([t,e])}function je(e){return"signatureV1"in e?Yt.encode({value:H(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:H(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):Yt.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function oe(e){let t=Yt.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 Wt("Missing data or signatureV2");let r=Vu(t.data),n=Tp(r.Value),o=q(r.Validity);if(t.value!=null&&t.signatureV1!=null)return Cp(t),{value:n,validityType:Yt.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:Yt.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 Jr(e){return bt([Fu,e.bytes])}function ye(e){let t=ae(e.slice(Fu.length));if(!ro(t,Ap)&&!ro(t,Ip))throw new Ze("Multihash in IPNS key was not identity or sha2-256");return t}function Vu(e){let t=ys(e);if(t.ValidityType===0)t.ValidityType=Yt.ValidityType.EOL;else throw new xr("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 Tp(e){let t=q(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${Z.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${Z.parse(t).toV1().toString()}`}catch{}throw new qn("Value must be a valid content path starting with /")}function Cp(e){if(e.data==null)throw new $n("Record data is missing");let t=Vu(e.data);if(!rt(t.Value,e.value??new Uint8Array(0)))throw new Wt('Field "value" did not match between protobuf and CBOR');if(!rt(t.Validity,e.validity??new Uint8Array(0)))throw new Wt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Wt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Wt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Wt('Field "ttl" did not match between protobuf and CBOR')}function ro(e,t){return e.code===t}var m2=xe("ipns"),y2=5*60*1e9,Pp="/ipns/",g2=Pp.length;var qu=mo(us(),1);var no=xe("ipns:validator"),_p=1024*10,Up=async(e,t)=>{let r=oe(t),n;try{let o=Mu(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw no.error("record signature verification failed"),new Wt("Record signature verification failed");if(r.validityType===Yt.ValidityType.EOL){if(qu.default.fromString(r.validity).toDate().getTime()<Date.now())throw no.error("record has expired"),new Mn("record has expired")}else if(r.validityType!=null)throw no.error("the validity type is unsupported"),new xr("The validity type is unsupported");no("ipns record for %s is valid",r.value)};async function $u(e,t){if(t.byteLength>_p)throw new Vn("The record is too large");let r=ye(e),n;ro(r,0)&&(n=Pn(r));let o=oe(t),i=Ou(o)??n;if(i==null)throw new Gr("Could not extract public key from IPNS record or routing key");let s=Jr(i.toMultihash());if(!rt(s,e))throw new Gr("Embedded public key did not match routing key");await Up(i,t)}var oo=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*Qr(e,t={}){let r=/\r?\n/,n=new TextDecoder("utf8"),o="";for await(let i of e){if(typeof i=="string"&&(i=new TextEncoder().encode(i)),er(i)&&(i=i.subarray()),o+=n.decode(i,{stream:!0}),o.length>(t?.maxMessageLength??o.length))throw new oo("Incoming message too long");let s=o.split(r);o=s.pop()??"";for(let a=0;a<s.length;a++)yield JSON.parse(s[a])}o+=n.decode(),o!==""&&(yield JSON.parse(o))}function ie(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var xs=mo(Hu(),1);var en=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},ws=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},ju=e=>globalThis.DOMException===void 0?new ws(e):new DOMException(e),Gu=e=>{let t=e.reason===void 0?ju("This operation was aborted."):e.reason;return t instanceof Error?t:ju(t)};function bs(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,s,a,l=new Promise((u,f)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:w}=t;w.aborted&&f(Gu(w)),a=()=>{f(Gu(w))},w.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){e.then(u,f);return}let d=new en;s=i.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(w){f(w)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?u():o instanceof Error?f(o):(d.message=o??`Promise timed out after ${r} milliseconds`,f(d))},r),(async()=>{try{u(await e)}catch(w){f(w)}})()}).finally(()=>{l.clear(),a&&t.signal&&t.signal.removeEventListener("abort",a)});return l.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},l}function Es(e,t,r){let n=0,o=e.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;r(e[s],t)<=0?(n=++s,o-=i+1):o=i}return n}var rn=class{#t=[];enqueue(t,r){r={priority:0,...r};let n={priority:r.priority,id:r.id,run:t};if(this.size===0||this.#t[this.size-1].priority>=r.priority){this.#t.push(n);return}let o=Es(this.#t,n,(i,s)=>s.priority-i.priority);this.#t.splice(o,0,n)}setPriority(t,r){let n=this.#t.findIndex(i=>i.id===t);if(n===-1)throw new ReferenceError(`No promise function with the id "${t}" exists in the queue.`);let[o]=this.#t.splice(n,1);this.enqueue(o.run,{priority:r,id:t})}dequeue(){return this.#t.shift()?.run}filter(t){return this.#t.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this.#t.length}};var nn=class extends xs.default{#t;#r;#e=0;#a;#c;#p=0;#o;#u;#n;#m;#i=0;#f;#s;#y;#w=1n;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:rn,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#t=t.carryoverConcurrencyCount,this.#r=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#a=t.intervalCap,this.#c=t.interval,this.#n=new t.queueClass,this.#m=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#y=t.throwOnTimeout===!0,this.#s=t.autoStart===!1}get#b(){return this.#r||this.#e<this.#a}get#E(){return this.#i<this.#f}#S(){this.#i--,this.#l(),this.emit("next")}#v(){this.#x(),this.#g(),this.#u=void 0}get#A(){let t=Date.now();if(this.#o===void 0){let r=this.#p-t;if(r<0)this.#e=this.#t?this.#i:0;else return this.#u===void 0&&(this.#u=setTimeout(()=>{this.#v()},r)),!0}return!1}#l(){if(this.#n.size===0)return this.#o&&clearInterval(this.#o),this.#o=void 0,this.emit("empty"),this.#i===0&&this.emit("idle"),!1;if(!this.#s){let t=!this.#A;if(this.#b&&this.#E){let r=this.#n.dequeue();return r?(this.emit("active"),r(),t&&this.#g(),!0):!1}}return!1}#g(){this.#r||this.#o!==void 0||(this.#o=setInterval(()=>{this.#x()},this.#c),this.#p=Date.now()+this.#c)}#x(){this.#e===0&&this.#i===0&&this.#o&&(clearInterval(this.#o),this.#o=void 0),this.#e=this.#t?this.#i:0,this.#d()}#d(){for(;this.#l(););}get concurrency(){return this.#f}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#f=t,this.#d()}async#I(t){return new Promise((r,n)=>{t.addEventListener("abort",()=>{n(t.reason)},{once:!0})})}setPriority(t,r){this.#n.setPriority(t,r)}async add(t,r={}){return r.id??=(this.#w++).toString(),r={timeout:this.timeout,throwOnTimeout:this.#y,...r},new Promise((n,o)=>{this.#n.enqueue(async()=>{this.#i++,this.#e++;try{r.signal?.throwIfAborted();let i=t({signal:r.signal});r.timeout&&(i=bs(Promise.resolve(i),{milliseconds:r.timeout})),r.signal&&(i=Promise.race([i,this.#I(r.signal)]));let s=await i;n(s),this.emit("completed",s)}catch(i){if(i instanceof en&&!r.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#S()}},r),this.emit("add"),this.#l()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#s?(this.#s=!1,this.#d(),this):this}pause(){this.#s=!0}clear(){this.#n=new this.#m}async onEmpty(){this.#n.size!==0&&await this.#h("empty")}async onSizeLessThan(t){this.#n.size<t||await this.#h("next",()=>this.#n.size<t)}async onIdle(){this.#i===0&&this.#n.size===0||await this.#h("idle")}async#h(t,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#n.size}sizeBy(t){return this.#n.filter(t).length}get pending(){return this.#i}get isPaused(){return this.#s}};var Ir=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},Qt=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function Lp(e){return e[Symbol.asyncIterator]!=null}function Dp(e){if(Lp(e))return(async()=>{for await(let t of e)return t})();for(let t of e)return t}var so=Dp;function kp(e){let[t,r]=e[Symbol.asyncIterator]!=null?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[r](){return this}}}var Zu=kp;function Kp(e){return e[Symbol.asyncIterator]!=null}function Fp(e,t){let r=0;if(Kp(e))return async function*(){for await(let c of e)yield t(c,r++)}();let n=Zu(e),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let s=t(o,r++);if(typeof s.then=="function")return async function*(){yield await s;for await(let c of n)yield t(c,r++)}();let a=t;return function*(){yield s;for(let c of n)yield a(c,r++)}()}var ao=Fp;var Wu=H("/ipns/");function Yu(e){return rt(e.subarray(0,Wu.byteLength),Wu)}var co=class{client;constructor(t){this.client=t}async*findProviders(t,r={}){yield*ao(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async cancelReprovide(){}async put(t,r,n){if(!Yu(t))return;let o=ye(t),i=Z.createV1(114,o),s=oe(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!Yu(t))throw new Bt("Not found");let n=ye(t),o=Z.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return je(i)}catch(i){throw i.name==="BadResponseError"?new Bt("Not found"):i}}},uo=class{client;constructor(t){this.client=t}async findPeer(t,r={}){let n=await so(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Bt("Not found")}async*getClosestPeers(t,r={}){}};var yt=xe("delegated-routing-v1-http-api-client"),fo={concurrentRequests:4,timeout:3e4,cacheTTL:5*60*1e3,cacheName:"delegated-routing-v1-cache"},lo=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;filterAddrs;filterProtocols;inFlightRequests;cacheName;cache;cacheTTL;constructor(t,r={}){this.started=!1,this.shutDownController=new AbortController,this.shutDownController.signal,this.httpQueue=new nn({concurrency:r.concurrentRequests??fo.concurrentRequests}),this.inFlightRequests=new Map,this.clientUrl=t instanceof URL?t:new URL(t),this.timeout=r.timeout??fo.timeout,this.filterAddrs=r.filterAddrs,this.filterProtocols=r.filterProtocols,this.contentRouting=new co(this),this.peerRouting=new uo(this),this.cacheName=r.cacheName??fo.cacheName,this.cacheTTL=r.cacheTTL??fo.cacheTTL}get[Ds](){return this.contentRouting}get[ks](){return this.peerRouting}isStarted(){return this.started}async start(){this.started||(this.started=!0,this.cacheTTL>0&&(this.cache=await globalThis.caches?.open(this.cacheName),this.cache!=null&&yt("cache enabled with ttl %d",this.cacheTTL)))}async stop(){this.httpQueue.clear(),this.shutDownController.abort(),await globalThis.caches?.delete(this.cacheName),this.started=!1}async*getProviders(t,r={}){yt("getProviders starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=jr([this.shutDownController.signal,n,r.signal]);let i=ie(),s=ie();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/providers/${t.toString()}`);this.#r(a,r.filterAddrs,r.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},l=await this.#e(a.toString(),c);if(l==null)throw new Qt("No response received");if(!l.ok)throw l.status===404?new Bt("No matching records found"):l.status===422?new Ir("Request does not conform to schema or semantic constraints"):new Qt(`Unexpected status code: ${l.status}`);if(l.body==null)throw new Qt("Routing response had no body");let u=l.headers.get("Content-Type");if(u==null)throw new Qt("No Content-Type header received");if(u?.startsWith("application/json")){let f=await l.json();for(let d of f.Providers){let w=this.#t(d);w!=null&&(yield w)}}else if(u.includes("application/x-ndjson"))for await(let f of Qr(On(l.body))){let d=this.#t(f);d!=null&&(yield d)}else throw new Qt(`Unsupported Content-Type: ${u}`)}catch(a){yt.error("getProviders errored:",a)}finally{o.clear(),s.resolve(),yt("getProviders finished: %c",t)}}async*getPeers(t,r={}){yt("getPeers starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=jr([this.shutDownController.signal,n,r.signal]);let i=ie(),s=ie();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/peers/${t.toCID().toString()}`);this.#r(a,r.filterAddrs,r.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},l=await this.#e(a.toString(),c);if(l.status===404)throw new Bt("No matching records found");if(l.status===422)throw new Ir("Request does not conform to schema or semantic constraints");if(l.body==null)throw new Qt("Routing response had no body");if(l.headers.get("Content-Type")==="application/json"){let f=await l.json();for(let d of f.Peers){let w=this.#t(d);w!=null&&(yield w)}}else for await(let f of Qr(On(l.body))){let d=this.#t(f);d!=null&&(yield d)}}catch(a){yt.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),yt("getPeers finished: %c",t)}}async getIPNS(t,r={}){yt("getIPNS starts: %s",t);let n=AbortSignal.timeout(this.timeout),o=jr([this.shutDownController.signal,n,r.signal]);let i=ie(),s=ie();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.clientUrl}routing/v1/ipns/${t}`;try{await i.promise;let c={headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o},l=await this.#e(a,c);if(yt("getIPNS GET %s %d",a,l.status),l.status===404)throw new Bt("No matching records found");if(l.status===422)throw new Ir("Request does not conform to schema or semantic constraints");if(l.body==null)throw new Qt("GET ipns response had no body");let u=await l.arrayBuffer(),f=new Uint8Array(u,0,u.byteLength);return r.validate!==!1&&await $u(Jr(t.multihash),f),oe(f)}catch(c){throw yt.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),yt("getIPNS finished: %s",t)}}async putIPNS(t,r,n={}){yt("putIPNS starts: %c",t);let o=AbortSignal.timeout(this.timeout),i=jr([this.shutDownController.signal,o,n.signal]);let s=ie(),a=ie();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${t}`;try{await s.promise;let l=je(r),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:l,signal:i},f=await this.#e(c,u);if(yt("putIPNS PUT %s %d",c,f.status),f.status!==200)throw new Qt("PUT ipns response had status other than 200")}catch(l){throw yt.error("putIPNS PUT %s error:",c,l.stack),l}finally{i.clear(),a.resolve(),yt("putIPNS finished: %c",t)}}#t(t){try{let r=[],n=t.Addrs?.map(ze)??[];return t.Protocols!=null&&r.push(...t.Protocols),t.Protocol!=null&&(r.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:wc(t.ID),Addrs:n,Protocols:r}}catch(r){yt.error("could not conform record to peer schema",r)}}#r(t,r,n){if(r!=null||this.filterAddrs!=null){let o=r?.join(",")??this.filterAddrs?.join(",")??"";o!==""&&t.searchParams.set("filter-addrs",o)}if(n!=null||this.filterProtocols!=null){let o=n?.join(",")??this.filterProtocols?.join(",")??"";o!==""&&t.searchParams.set("filter-protocols",o)}}async#e(t,r){let n=r.method??"GET",o=`${n}-${t}`;if(n==="GET"){let c=await this.cache?.match(t);if(c!=null){if(parseInt(c.headers.get("x-cache-expires")??"0",10)>Date.now())return yt("returning cached response for %s",o),c;await this.cache?.delete(t)}}let i=this.inFlightRequests.get(o);if(i!=null){let c=await i;return yt("deduplicating outgoing request for %s",o),c.clone()}let s=fetch(t,r).then(async c=>{if(this.cache!=null&&c.ok&&n==="GET"){let l=Date.now()+this.cacheTTL,u=new Headers(c.headers);u.set("x-cache-expires",l.toString());let f=new Response(c.clone().body,{status:c.status,statusText:c.statusText,headers:u});await this.cache.put(t,f)}return c}).finally(()=>{this.inFlightRequests.delete(o)});return this.inFlightRequests.set(o,s),await s}};function Xu(e,t={}){return new lo(new URL(e),t)}function ho(){return{filterProtocols:["unknown","transport-bitswap","transport-ipfs-gateway-http"],filterAddrs:["https","webtransport","webrtc","webrtc-direct","wss","tls"]}}var Ju=H("/ipns/");function Qu(e){return rt(e.subarray(0,Ju.byteLength),Ju)}var Ss=class{client;constructor(t,r={}){this.client=Xu(t,r)}async provide(t,r){}async cancelReprovide(t,r){}async*findProviders(t,r){yield*ao(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs,protocols:n.Protocols}))}async put(t,r,n){if(!Qu(t))return;let o=ye(t),i=Z.createV1(114,o),s=oe(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!Qu(t))throw new Bt("Not found");let n=ye(t),o=Z.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return je(i)}catch(i){throw i.name==="BadResponseError"?new Bt("Not found"):i}}async findPeer(t,r){let n=await so(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Bt("Not found")}async*getClosestPeers(t,r){}};function tf(e,t){let r=t??ho();return new Ss(new URL(e),r)}var ef="[a-fA-F\\d:]",Ne=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${ef})|(?<=${ef})(?=\\s|$))`:"",te="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",lt="[a-fA-F\\d]{1,4}",po=`
|
|
2
|
+
"use strict";var HeliaRouters=(()=>{var Rf=Object.create;var ln=Object.defineProperty;var Lf=Object.getOwnPropertyDescriptor;var Df=Object.getOwnPropertyNames;var kf=Object.getPrototypeOf,Kf=Object.prototype.hasOwnProperty;var qs=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ct=(e,t)=>{for(var r in t)ln(e,r,{get:t[r],enumerable:!0})},$s=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Df(t))!Kf.call(e,o)&&o!==r&&ln(e,o,{get:()=>t[o],enumerable:!(n=Lf(t,o))||n.enumerable});return e};var Ao=(e,t,r)=>(r=e!=null?Rf(kf(e)):{},$s(t||!e||!e.__esModule?ln(r,"default",{value:e,enumerable:!0}):r,e)),Of=e=>$s(ln({},"__esModule",{value:!0}),e);var xs=qs((kb,gs)=>{var Db=function(){typeof gs<"u"&&(gs.exports=x);var e=86400,t=3200,r=146097*t/400,n=e*r,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",l=Math.trunc||function(g){var b=g-g%1;return b==0&&(g<0||g===0&&1/g!=1/0)?-0:b},u=x.prototype,f=(x.fromDate=function(g){return new x(+g)},x.fromInt64BE=U(0,1,2,3,0,4),x.fromInt64LE=U(3,2,1,0,4,0),x.fromString=function(L){var b,K=new x,L=(L+="").replace(/^\s*[+\-]?\d+/,function(V){var V=+V,v=1970+(V-1970)%400;return K.year=V-v,v}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(P,V,v){return V<0&&(v*=-1),b=6e4*(60*+V+ +v),""}).replace(/\.\d+$/,function(P){return K.nano=+(P+c).substr(1,9),""}).split(/\D+/);if(1<L.length?L[1]--:L[1]=0,K.time=b=Date.UTC.apply(Date,L)-(b||0),isNaN(b))throw new TypeError("Invalid Date");return h(K)},x.fromTimeT=function(g){return _(g,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(g){return this.nano+=+g||0,this},u.getNano=function(){var g=h(this);return(g.time%1e3*a+ +g.nano+1e9)%1e9},u.getTimeT=function(){var b=h(this),g=Math.floor(b.time/1e3),b=b.year;return b&&(g+=b*r*e/t),g},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return S(h(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(g){var b=this,K=b.toDate(),L={H:function(){return k(K.getUTCHours())},L:function(){return N(K.getUTCMilliseconds(),3)},M:function(){return k(K.getUTCMinutes())},N:function(){return N(b.getNano(),9)},S:function(){return k(K.getUTCSeconds())},Y:function(){var P=b.getYear();return 999999<P?"+"+P:9999<P?"+"+N(P,6):0<=P?N(P,4):-999999<=P?"-"+N(-P,6):P},a:function(){return w[K.getUTCDay()]},b:function(){return d[K.getUTCMonth()]},d:function(){return k(K.getUTCDate())},e:function(){return function(P){return(9<P?"":" ")+(0|P)}(K.getUTCDate())},m:function(){return k(K.getUTCMonth()+1)}};return function P(V){return V.replace(/%./g,function(v){var T=v[1],A=C[T],T=L[T];return A?P(A):T?T():v})}(g||f)},u.writeInt64BE=y(0,1,2,3,0,4),u.writeInt64LE=y(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"],w=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],C={"%":"%",F:"%Y-%m-%d",n:`
|
|
3
|
+
`,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return x;function x(g,b,K){var L=this;if(!(L instanceof x))return new x(g,b,K);L.time=+g||0,L.nano=+b||0,L.year=+K||0,h(L)}function h(g){var b,K,L,P=g.year,V=g.time,v=g.nano,A=((v<0||a<=v)&&(v-=(K=Math.floor(v/a))*a,V+=K,K=1),P%t);return(V<-i||i<V||A)&&((b=l(V/o))&&(P+=b*t,V-=b*o),(L=S(V)).setUTCFullYear(A+L.getUTCFullYear()),L=(V=+L)+(b=l((P-=A)/t))*o,b&&-i<=L&&L<=i&&(P-=b*t,V=L),K=1),K&&(g.year=P,g.time=V,g.nano=v),g}function S(g){var b=new Date(0);return b.setTime(g),b}function _(P,L){P=+P||0;var K=l((L=(L|0)*s)/n)+l(P/n),L=L%n+P%n,P=l(L/n);return P&&(K+=P,L-=P*n),new x(1e3*L,0,K*t)}function y(g,b,K,L,P,V){return function(A,T){var p=h(this);A=A||new Array(8),O(A,T|=0);var I=Math.floor(p.time/1e3),p=p.year*(r*e/t),E=l(p/s)+l(I/s),p=p%s+I%s,I=Math.floor(p/s);return I&&(E+=I,p-=I*s),v(A,T+P,E),v(A,T+V,p),A};function v(A,T,E){A[T+g]=E>>24&255,A[T+b]=E>>16&255,A[T+K]=E>>8&255,A[T+L]=255&E}}function U(g,b,K,L,P,V){return function(A,T){O(A,T|=0);var E=v(A,T+P);return _(v(A,T+V),E)};function v(A,T){return 16777216*A[T+g]+(A[T+b]<<16|A[T+K]<<8|A[T+L])}}function O(g,b){if(g=g&&g.length,g==null)throw new TypeError("Invalid Buffer");if(g<b+8)throw new RangeError("Out of range")}function k(g){return(9<g?"":"0")+(0|g)}function N(g,b){return(c+(0|g)).substr(-b)}}()});var ff=qs((C2,Ts)=>{"use strict";var Pp=Object.prototype.hasOwnProperty,It="~";function an(){}Object.create&&(an.prototype=Object.create(null),new an().__proto__||(It=!1));function _p(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function uf(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new _p(r,n||e,o),s=It?It+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],i]:e._events[s].push(i):(e._events[s]=i,e._eventsCount++),e}function mo(e,t){--e._eventsCount===0?e._events=new an:delete e._events[t]}function St(){this._events=new an,this._eventsCount=0}St.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)Pp.call(r,n)&&t.push(It?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};St.prototype.listeners=function(t){var r=It?It+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};St.prototype.listenerCount=function(t){var r=It?It+t:t,n=this._events[r];return n?n.fn?1:n.length:0};St.prototype.emit=function(t,r,n,o,i,s){var a=It?It+t:t;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,u,f;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,o),!0;case 5:return c.fn.call(c.context,r,n,o,i),!0;case 6:return c.fn.call(c.context,r,n,o,i,s),!0}for(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var d=c.length,w;for(f=0;f<d;f++)switch(c[f].once&&this.removeListener(t,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,r);break;case 3:c[f].fn.call(c[f].context,r,n);break;case 4:c[f].fn.call(c[f].context,r,n,o);break;default:if(!u)for(w=1,u=new Array(l-1);w<l;w++)u[w-1]=arguments[w];c[f].fn.apply(c[f].context,u)}}return!0};St.prototype.on=function(t,r,n){return uf(this,t,r,n,!1)};St.prototype.once=function(t,r,n){return uf(this,t,r,n,!0)};St.prototype.removeListener=function(t,r,n,o){var i=It?It+t:t;if(!this._events[i])return this;if(!r)return mo(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&mo(this,i);else{for(var a=0,c=[],l=s.length;a<l;a++)(s[a].fn!==r||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:mo(this,i)}return this};St.prototype.removeAllListeners=function(t){var r;return t?(r=It?It+t:t,this._events[r]&&mo(this,r)):(this._events=new an,this._eventsCount=0),this};St.prototype.off=St.prototype.removeListener;St.prototype.addListener=St.prototype.on;St.prefixed=It;St.EventEmitter=St;typeof Ts<"u"&&(Ts.exports=St)});var Jp={};Ct(Jp,{delegatedHTTPRouting:()=>wf,delegatedHTTPRoutingDefaults:()=>So,httpGatewayRouting:()=>Cf,libp2pRouting:()=>Bf});var Hs=Symbol.for("@libp2p/content-routing");var Io=Symbol.for("@libp2p/peer-id");var zs=Symbol.for("@libp2p/peer-routing");var ct=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Xe=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Bt=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var dn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Je=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Qe=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var _o={};Ct(_o,{base32:()=>zt,base32hex:()=>Gf,base32hexpad:()=>Wf,base32hexpadupper:()=>Yf,base32hexupper:()=>Zf,base32pad:()=>zf,base32padupper:()=>jf,base32upper:()=>Hf,base32z:()=>Xf});var o0=new Uint8Array(0);function js(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 ae(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 Gs(e){return new TextEncoder().encode(e)}function Zs(e){return new TextDecoder().decode(e)}function Ff(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function f(C){if(C instanceof Uint8Array||(ArrayBuffer.isView(C)?C=new Uint8Array(C.buffer,C.byteOffset,C.byteLength):Array.isArray(C)&&(C=Uint8Array.from(C))),!(C instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(C.length===0)return"";for(var x=0,h=0,S=0,_=C.length;S!==_&&C[S]===0;)S++,x++;for(var y=(_-S)*u+1>>>0,U=new Uint8Array(y);S!==_;){for(var O=C[S],k=0,N=y-1;(O!==0||k<h)&&N!==-1;N--,k++)O+=256*U[N]>>>0,U[N]=O%a>>>0,O=O/a>>>0;if(O!==0)throw new Error("Non-zero carry");h=k,S++}for(var g=y-h;g!==y&&U[g]===0;)g++;for(var b=c.repeat(x);g<y;++g)b+=e.charAt(U[g]);return b}function d(C){if(typeof C!="string")throw new TypeError("Expected String");if(C.length===0)return new Uint8Array;var x=0;if(C[x]!==" "){for(var h=0,S=0;C[x]===c;)h++,x++;for(var _=(C.length-x)*l+1>>>0,y=new Uint8Array(_);C[x];){var U=r[C.charCodeAt(x)];if(U===255)return;for(var O=0,k=_-1;(U!==0||O<S)&&k!==-1;k--,O++)U+=a*y[k]>>>0,y[k]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");S=O,x++}if(C[x]!==" "){for(var N=_-S;N!==_&&y[N]===0;)N++;for(var g=new Uint8Array(h+(_-N)),b=h;N!==_;)g[b++]=y[N++];return g}}}function w(C){var x=d(C);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:d,decode:w}}var Mf=Ff,Vf=Mf,Ys=Vf;var To=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Co=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 Xs(this,t)}},Bo=class{decoders;constructor(t){this.decoders=t}or(t){return Xs(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 Xs(e,t){return new Bo({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Po=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 Co(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function tr({name:e,prefix:t,encode:r,decode:n}){return new Po(e,t,r,n)}function Ee({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Ys(r,e);return tr({prefix:t,name:e,encode:n,decode:i=>ae(o(i))})}function qf(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,l=0;for(let u=0;u<i;++u){let f=o[e[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)!==0)throw new SyntaxError("Unexpected end of data");return s}function $f(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 ot({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return tr({prefix:t,name:e,encode(o){return $f(o,n,r)},decode(o){return qf(o,n,r,e)}})}var zt=ot({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Hf=ot({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),zf=ot({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),jf=ot({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Gf=ot({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Zf=ot({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Wf=ot({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Yf=ot({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Xf=ot({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Uo={};Ct(Uo,{base58btc:()=>J,base58flickr:()=>Jf});var J=Ee({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Jf=Ee({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ro={};Ct(Ro,{base64:()=>No,base64pad:()=>Qf,base64url:()=>tl,base64urlpad:()=>el});var No=ot({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Qf=ot({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),tl=ot({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),el=ot({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function rl(e,t){try{if(typeof e=="string"&&e.length>0)return nl(e);if(typeof e=="number"&&isFinite(e))return t?.long?il(e):ol(e);throw new Error("Value is not a string or number.")}catch(r){let n=sl(r)?`${r.message}. value=${JSON.stringify(e)}`:"An unknown error has occured.";throw new Error(n)}}function nl(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 pn=rl;function ol(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 il(e){let t=Math.abs(e);return t>=864e5?hn(e,t,864e5,"day"):t>=36e5?hn(e,t,36e5,"hour"):t>=6e4?hn(e,t,6e4,"minute"):t>=1e3?hn(e,t,1e3,"second"):`${e} ms`}function hn(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function sl(e){return typeof e=="object"&&e!==null&&"message"in e}function Lo(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=pn,r.destroy=l,Object.keys(e).forEach(u=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let f=0;for(let d=0;d<u.length;d++)f=(f<<5)-f+u.charCodeAt(d),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=t;function r(u){let f,d=null,w,C;function x(...h){if(!x.enabled)return;let S=x,_=Number(new Date),y=_-(f||_);S.diff=y,S.prev=f,S.curr=_,f=_,h[0]=r.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let U=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(k,N)=>{if(k==="%%")return"%";U++;let g=r.formatters[N];if(typeof g=="function"){let b=h[U];k=g.call(S,b),h.splice(U,1),U--}return k}),r.formatArgs.call(S,h),(S.log||r.log).apply(S,h)}return x.namespace=u,x.useColors=r.useColors(),x.color=r.selectColor(u),x.extend=n,x.destroy=r.destroy,Object.defineProperty(x,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(w!==r.namespaces&&(w=r.namespaces,C=r.enabled(u)),C),set:h=>{d=h}}),typeof r.init=="function"&&r.init(x),x}function n(u,f){let d=r(this.namespace+(typeof f>"u"?":":f)+u);return d.log=this.log,d}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let f,d=(typeof u=="string"?u:"").split(/[\s,]+/),w=d.length;for(f=0;f<w;f++)d[f]&&(u=d[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,d;for(f=0,d=r.skips.length;f<d;f++)if(r.skips[f].test(u))return!1;for(f=0,d=r.names.length;f<d;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 mn=hl(),al=["#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 cl(){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 ul(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+pn(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 fl=console.debug??console.log??(()=>{});function ll(e){try{e?mn?.setItem("debug",e):mn?.removeItem("debug")}catch{}}function dl(){let e;try{e=mn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function hl(){try{return localStorage}catch{}}function pl(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var Js=Lo({formatArgs:ul,save:ll,load:dl,useColors:cl,setupFormatters:pl,colors:al,storage:mn,log:fl});var Pt=Js;Pt.formatters.b=e=>e==null?"undefined":J.baseEncode(e);Pt.formatters.t=e=>e==null?"undefined":zt.baseEncode(e);Pt.formatters.m=e=>e==null?"undefined":No.baseEncode(e);Pt.formatters.p=e=>e==null?"undefined":e.toString();Pt.formatters.c=e=>e==null?"undefined":e.toString();Pt.formatters.k=e=>e==null?"undefined":e.toString();Pt.formatters.a=e=>e==null?"undefined":e.toString();Pt.formatters.e=e=>e==null?"undefined":Qs(e.stack)??Qs(e.message)??e.toString();function ml(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 Se(e){let t=ml(`${e}:trace`);return Pt.enabled(`${e}:trace`)&&Pt.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=Pt(`${e}:trace`)),Object.assign(Pt(e),{error:Pt(`${e}:error`),trace:t})}function Qs(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var Do={};Ct(Do,{base36:()=>er,base36upper:()=>yl});var er=Ee({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),yl=Ee({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var gl=ra,ta=128,xl=127,wl=~xl,bl=Math.pow(2,31);function ra(e,t,r){t=t||[],r=r||0;for(var n=r;e>=bl;)t[r++]=e&255|ta,e/=128;for(;e&wl;)t[r++]=e&255|ta,e>>>=7;return t[r]=e|0,ra.bytes=r-n+1,t}var El=ko,Sl=128,ea=127;function ko(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw ko.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&ea)<<o:(s&ea)*Math.pow(2,o),o+=7}while(s>=Sl);return ko.bytes=i-n,r}var vl=Math.pow(2,7),Al=Math.pow(2,14),Il=Math.pow(2,21),Tl=Math.pow(2,28),Cl=Math.pow(2,35),Bl=Math.pow(2,42),Pl=Math.pow(2,49),_l=Math.pow(2,56),Ul=Math.pow(2,63),Nl=function(e){return e<vl?1:e<Al?2:e<Il?3:e<Tl?4:e<Cl?5:e<Bl?6:e<Pl?7:e<_l?8:e<Ul?9:10},Rl={encode:gl,decode:El,encodingLength:Nl},Ll=Rl,_r=Ll;function Ur(e,t=0){return[_r.decode(e,t),_r.decode.bytes]}function rr(e,t,r=0){return _r.encode(e,t,r),t}function nr(e){return _r.encodingLength(e)}function jt(e,t){let r=t.byteLength,n=nr(e),o=n+nr(r),i=new Uint8Array(o+r);return rr(e,i,0),rr(r,i,n),i.set(t,o),new or(e,r,t,i)}function ce(e){let t=ae(e),[r,n]=Ur(t),[o,i]=Ur(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new or(r,o,s,t)}function na(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&js(e.bytes,r.bytes)}}var or=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function oa(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return kl(r,Ko(e),t??J.encoder);default:return Kl(r,Ko(e),t??zt.encoder)}}var ia=new WeakMap;function Ko(e){let t=ia.get(e);if(t==null){let r=new Map;return ia.set(e,r),r}return t}var G=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!==Nr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Ol)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=jt(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&&na(t.multihash,n.multihash)}toString(t){return oa(this,t)}toJSON(){return{"/":oa(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??sa(n,o,i.bytes))}else if(r[Fl]===!0){let{version:n,multihash:o,code:i}=r,s=ce(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!==Nr)throw new Error(`Version 0 CID must use dag-pb (code: ${Nr}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=sa(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Nr,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=ae(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 or(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[f,d]=Ur(t.subarray(r));return r+=d,f},o=n(),i=Nr;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),l=r+c,u=l-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:l}}static parse(t,r){let[n,o]=Dl(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 Ko(i).set(n,t),i}};function Dl(e,t){switch(e[0]){case"Q":{let r=t??J;return[J.prefix,r.decode(`${J.prefix}${e}`)]}case J.prefix:{let r=t??J;return[J.prefix,r.decode(e)]}case zt.prefix:{let r=t??zt;return[zt.prefix,r.decode(e)]}case er.prefix:{let r=t??er;return[er.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 kl(e,t,r){let{prefix:n}=r;if(n!==J.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o}function Kl(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 Nr=112,Ol=18;function sa(e,t,r){let n=nr(e),o=n+nr(t),i=new Uint8Array(o+r.byteLength);return rr(e,i,0),rr(t,i,n),i.set(r,o),i}var Fl=Symbol.for("@ipld/js-cid/CID");var Oo={};Ct(Oo,{identity:()=>Lt});var aa=0,Ml="identity",ca=ae;function Vl(e){return jt(aa,ca(e))}var Lt={code:aa,name:Ml,encode:ca,digest:Vl};function et(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 ue(e=0){return new Uint8Array(e)}function _t(e=0){return new Uint8Array(e)}function wt(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=_t(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var fa=Symbol.for("@achingbrain/uint8arraylist");function ua(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 ir(e){return!!e?.[fa]}var Dt=class e{bufs;length;[fa]=!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(ir(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(ir(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=ua(this.bufs,t);return r.buf[r.index]}set(t,r){let n=ua(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(ir(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 wt(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:wt(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),i=new e;return i.length=o,i.bufs=[...n],i}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,t>=c)continue;let l=t>=a&&t<c,u=r>a&&r<=c;if(l&&u){if(t===a&&r===c){n.push(s);break}let f=t-a;n.push(s.subarray(f,f+(r-t)));break}if(l){if(t===0){n.push(s);continue}n.push(s.subarray(t-a));continue}if(u){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!ir(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let f=0;f<i;f++)s[f]=-1;for(let f=0;f<o;f++)s[n[f]]=f;let a=s,c=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=r;f<=c;f+=u){u=0;for(let d=l;d>=0;d--){let w=this.get(f+d);if(n[d]!==w){u=Math.max(1,d-a[w]);break}}if(u===0)return f}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=_t(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=ue(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=ue(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=ue(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=_t(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=ue(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=ue(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=ue(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=ue(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=ue(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(!et(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 Fo={};Ct(Fo,{base10:()=>ql});var ql=Ee({prefix:"9",name:"base10",alphabet:"0123456789"});var Mo={};Ct(Mo,{base16:()=>$l,base16upper:()=>Hl});var $l=ot({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Hl=ot({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Vo={};Ct(Vo,{base2:()=>zl});var zl=ot({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var qo={};Ct(qo,{base256emoji:()=>Yl});var la=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}"),jl=la.reduce((e,t,r)=>(e[r]=t,e),[]),Gl=la.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Zl(e){return e.reduce((t,r)=>(t+=jl[r],t),"")}function Wl(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Gl[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var Yl=tr({prefix:"\u{1F680}",name:"base256emoji",encode:Zl,decode:Wl});var $o={};Ct($o,{base8:()=>Xl});var Xl=ot({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ho={};Ct(Ho,{identity:()=>Jl});var Jl=tr({prefix:"\0",name:"identity",encode:e=>Zs(e),decode:e=>Gs(e)});var tm=new TextEncoder,em=new TextDecoder;var Go={};Ct(Go,{sha256:()=>Rr,sha512:()=>ed});function jo({name:e,code:t,encode:r}){return new zo(e,t,r)}var zo=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?jt(this.code,r):r.then(n=>jt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ha(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Rr=jo({name:"sha2-256",code:18,encode:ha("SHA-256")}),ed=jo({name:"sha2-512",code:19,encode:ha("SHA-512")});var Lr={...Ho,...Vo,...$o,...Fo,...Mo,..._o,...Do,...Uo,...Ro,...qo},hm={...Go,...Oo};function ma(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var pa=ma("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Zo=ma("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=_t(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),rd={utf8:pa,"utf-8":pa,hex:Lr.base16,latin1:Zo,ascii:Zo,binary:Zo,...Lr},gn=rd;function H(e,t="utf8"){let r=gn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function q(e,t="utf8"){let r=gn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var nd=parseInt("11111",2),Wo=parseInt("10000000",2),od=parseInt("01111111",2),ya={0:Dr,1:Dr,2:id,3:cd,4:ud,5:ad,6:sd,16:Dr,22:Dr,48:Dr};function fe(e,t={offset:0}){let r=e[t.offset]&nd;if(t.offset++,ya[r]!=null)return ya[r](e,t);throw new Error("No decoder for tag "+r)}function kr(e,t){let r=0;if((e[t.offset]&Wo)===Wo){let n=e[t.offset]&od,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 Dr(e,t){kr(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=fe(e,t);if(n===null)break;r.push(n)}return r}function id(e,t){let r=kr(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 sd(e,t){let r=kr(e,t),n=t.offset+r,o=e[t.offset];t.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,c=[];for(;t.offset<n;){let l=e[t.offset];if(t.offset++,c.push(l&127),l<128){c.reverse();let u=0;for(let f=0;f<c.length;f++)u+=c[f]<<f*7;a+=`.${u}`,c=[]}}return a}function ad(e,t){return t.offset++,null}function cd(e,t){let r=kr(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 ud(e,t){let r=kr(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function fd(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new Dt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Yo(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=fd(e.byteLength);return new Dt(Uint8Array.from([t.byteLength|Wo]),t)}function Ut(e){let t=new Dt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new Dt(Uint8Array.from([2]),Yo(t),t)}function xn(e){let t=Uint8Array.from([0]),r=new Dt(t,e);return new Dt(Uint8Array.from([3]),Yo(r),r)}function Ae(e,t=48){let r=new Dt;for(let n of e)r.append(n);return new Dt(Uint8Array.from([t]),Yo(r),r)}async function ga(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 ld=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),dd=Uint8Array.from([6,5,43,129,4,0,34]),hd=Uint8Array.from([6,5,43,129,4,0,35]),pd={ext:!0,kty:"EC",crv:"P-256"},md={ext:!0,kty:"EC",crv:"P-384"},yd={ext:!0,kty:"EC",crv:"P-521"},Xo=32,Jo=48,Qo=66;function ti(e){let t=fe(e);return xa(t)}function xa(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===Xo*2+1)return n=q(t.subarray(r,r+Xo),"base64url"),o=q(t.subarray(r+Xo),"base64url"),new sr({...pd,key_ops:["verify"],x:n,y:o});if(t.byteLength===Jo*2+1)return n=q(t.subarray(r,r+Jo),"base64url"),o=q(t.subarray(r+Jo),"base64url"),new sr({...md,key_ops:["verify"],x:n,y:o});if(t.byteLength===Qo*2+1)return n=q(t.subarray(r,r+Qo),"base64url"),o=q(t.subarray(r+Qo),"base64url"),new sr({...yd,key_ops:["verify"],x:n,y:o});throw new ct(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function wa(e){return Ae([Ut(Uint8Array.from([1])),Ae([gd(e.crv)],160),Ae([xn(new Dt(Uint8Array.from([4]),H(e.x??"","base64url"),H(e.y??"","base64url")))],161)]).subarray()}function gd(e){if(e==="P-256")return ld;if(e==="P-384")return dd;if(e==="P-521")return hd;throw new ct(`Invalid curve ${e}`)}var sr=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=wa(this.jwk)),this._raw}toMultihash(){return Lt.digest(ar(this))}toCID(){return G.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:et(this.raw,t.raw)}async verify(t,r){return ga(this.jwk,r,t)}};var De=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function xd(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function wn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ke(e,...t){if(!xd(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 ba(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");wn(e.outputLen),wn(e.blockLen)}function ur(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 Ea(e,t){ke(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function le(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function bn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Gt(e,t){return e<<32-t|e>>>t}function Sa(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Kr(e){return typeof e=="string"&&(e=Sa(e)),ke(e),e}function ei(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];ke(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 cr=class{};function ri(e){let t=n=>e().update(Kr(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function En(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 wd(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,l=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+l,a,n)}function va(e,t,r){return e&t^~e&r}function Aa(e,t,r){return e&t^e&r^t&r}var Or=class extends cr{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=bn(this.buffer)}update(t){ur(this),t=Kr(t),ke(t);let{view:r,buffer:n,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=bn(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){ur(this),Ea(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,le(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let f=s;f<o;f++)r[f]=0;wd(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=bn(t),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: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.destroyed=s,t.finished=i,t.length=o,t.pos=a,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},de=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var mt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Sn=BigInt(4294967295),Ia=BigInt(32);function bd(e,t=!1){return t?{h:Number(e&Sn),l:Number(e>>Ia&Sn)}:{h:Number(e>>Ia&Sn)|0,l:Number(e&Sn)|0}}function Ta(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=bd(e[i],t);[n[i],o[i]]=[s,a]}return[n,o]}var ni=(e,t,r)=>e>>>r,oi=(e,t,r)=>e<<32-r|t>>>r,Ke=(e,t,r)=>e>>>r|t<<32-r,Oe=(e,t,r)=>e<<32-r|t>>>r,Fr=(e,t,r)=>e<<64-r|t>>>r-32,Mr=(e,t,r)=>e>>>r-32|t<<64-r;function ee(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Ca=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Ba=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Pa=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),_a=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Ua=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Na=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var Sd=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ie=new Uint32Array(64),vn=class extends Or{constructor(t=32){super(64,t,8,!1),this.A=de[0]|0,this.B=de[1]|0,this.C=de[2]|0,this.D=de[3]|0,this.E=de[4]|0,this.F=de[5]|0,this.G=de[6]|0,this.H=de[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 f=0;f<16;f++,r+=4)Ie[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let d=Ie[f-15],w=Ie[f-2],C=Gt(d,7)^Gt(d,18)^d>>>3,x=Gt(w,17)^Gt(w,19)^w>>>10;Ie[f]=x+Ie[f-7]+C+Ie[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 d=Gt(a,6)^Gt(a,11)^Gt(a,25),w=u+d+va(a,c,l)+Sd[f]+Ie[f]|0,x=(Gt(n,2)^Gt(n,13)^Gt(n,22))+Aa(n,o,i)|0;u=l,l=c,c=a,a=s+w|0,s=i,i=o,o=n,n=w+x|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(){le(Ie)}destroy(){this.set(0,0,0,0,0,0,0,0),le(this.buffer)}};var Ra=Ta(["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))),vd=Ra[0],Ad=Ra[1],Te=new Uint32Array(80),Ce=new Uint32Array(80),ii=class extends Or{constructor(t=64){super(128,t,16,!1),this.Ah=mt[0]|0,this.Al=mt[1]|0,this.Bh=mt[2]|0,this.Bl=mt[3]|0,this.Ch=mt[4]|0,this.Cl=mt[5]|0,this.Dh=mt[6]|0,this.Dl=mt[7]|0,this.Eh=mt[8]|0,this.El=mt[9]|0,this.Fh=mt[10]|0,this.Fl=mt[11]|0,this.Gh=mt[12]|0,this.Gl=mt[13]|0,this.Hh=mt[14]|0,this.Hl=mt[15]|0}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:l,El:u,Fh:f,Fl:d,Gh:w,Gl:C,Hh:x,Hl:h}=this;return[t,r,n,o,i,s,a,c,l,u,f,d,w,C,x,h]}set(t,r,n,o,i,s,a,c,l,u,f,d,w,C,x,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=l|0,this.El=u|0,this.Fh=f|0,this.Fl=d|0,this.Gh=w|0,this.Gl=C|0,this.Hh=x|0,this.Hl=h|0}process(t,r){for(let y=0;y<16;y++,r+=4)Te[y]=t.getUint32(r),Ce[y]=t.getUint32(r+=4);for(let y=16;y<80;y++){let U=Te[y-15]|0,O=Ce[y-15]|0,k=Ke(U,O,1)^Ke(U,O,8)^ni(U,O,7),N=Oe(U,O,1)^Oe(U,O,8)^oi(U,O,7),g=Te[y-2]|0,b=Ce[y-2]|0,K=Ke(g,b,19)^Fr(g,b,61)^ni(g,b,6),L=Oe(g,b,19)^Mr(g,b,61)^oi(g,b,6),P=Pa(N,L,Ce[y-7],Ce[y-16]),V=_a(P,k,K,Te[y-7],Te[y-16]);Te[y]=V|0,Ce[y]=P|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:l,Dl:u,Eh:f,El:d,Fh:w,Fl:C,Gh:x,Gl:h,Hh:S,Hl:_}=this;for(let y=0;y<80;y++){let U=Ke(f,d,14)^Ke(f,d,18)^Fr(f,d,41),O=Oe(f,d,14)^Oe(f,d,18)^Mr(f,d,41),k=f&w^~f&x,N=d&C^~d&h,g=Ua(_,O,N,Ad[y],Ce[y]),b=Na(g,S,U,k,vd[y],Te[y]),K=g|0,L=Ke(n,o,28)^Fr(n,o,34)^Fr(n,o,39),P=Oe(n,o,28)^Mr(n,o,34)^Mr(n,o,39),V=n&i^n&a^i&a,v=o&s^o&c^s&c;S=x|0,_=h|0,x=w|0,h=C|0,w=f|0,C=d|0,{h:f,l:d}=ee(l|0,u|0,b|0,K|0),l=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let A=Ca(K,P,v);n=Ba(A,b,L,V),o=A|0}({h:n,l:o}=ee(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=ee(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=ee(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=ee(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:d}=ee(this.Eh|0,this.El|0,f|0,d|0),{h:w,l:C}=ee(this.Fh|0,this.Fl|0,w|0,C|0),{h:x,l:h}=ee(this.Gh|0,this.Gl|0,x|0,h|0),{h:S,l:_}=ee(this.Hh|0,this.Hl|0,S|0,_|0),this.set(n,o,i,s,a,c,l,u,f,d,w,C,x,h,S,_)}roundClean(){le(Te,Ce)}destroy(){le(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var An=ri(()=>new vn);var La=ri(()=>new ii);var ui=BigInt(0),ci=BigInt(1);function Fe(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function fi(e){if(!Fe(e))throw new Error("Uint8Array expected")}function re(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function Vr(e){let t=e.toString(16);return t.length&1?"0"+t:t}function Ka(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?ui:BigInt("0x"+e)}var Oa=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Id=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Be(e){if(fi(e),Oa)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Id[e[r]];return t}var he={_0:48,_9:57,A:65,F:70,a:97,f:102};function Da(e){if(e>=he._0&&e<=he._9)return e-he._0;if(e>=he.A&&e<=he.F)return e-(he.A-10);if(e>=he.a&&e<=he.f)return e-(he.a-10)}function qr(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Oa)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=Da(e.charCodeAt(i)),a=Da(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 pe(e){return Ka(Be(e))}function Me(e){return fi(e),Ka(Be(Uint8Array.from(e).reverse()))}function Ve(e,t){return qr(e.toString(16).padStart(t*2,"0"))}function fr(e,t){return Ve(e,t).reverse()}function nt(e,t,r){let n;if(typeof t=="string")try{n=qr(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(Fe(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 Pe(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];fi(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 si=e=>typeof e=="bigint"&&ui<=e;function In(e,t,r){return si(e)&&si(t)&&si(r)&&t<=e&&e<r}function kt(e,t,r,n){if(!In(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Fa(e){let t;for(t=0;e>ui;e>>=ci,t+=1);return t}var qe=e=>(ci<<BigInt(e))-ci,ai=e=>new Uint8Array(e),ka=e=>Uint8Array.from(e);function Ma(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=ai(e),o=ai(e),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...f)=>r(o,n,...f),c=(f=ai(0))=>{o=a(ka([0]),f),n=a(),f.length!==0&&(o=a(ka([1]),f),n=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,d=[];for(;f<t;){n=a();let w=n.slice();d.push(w),f+=n.length}return Pe(...d)};return(f,d)=>{s(),c(f);let w;for(;!(w=d(l()));)c();return s(),w}}var Td={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"||Fe(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 me(e,t,r={}){let n=(o,i,s)=>{let a=Td[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 lr(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 vt=BigInt(0),ft=BigInt(1),$e=BigInt(2),Cd=BigInt(3),li=BigInt(4),Va=BigInt(5),qa=BigInt(8),Bd=BigInt(9),Pd=BigInt(16);function Q(e,t){let r=e%t;return r>=vt?r:t+r}function rt(e,t,r){let n=e;for(;t-- >vt;)n*=n,n%=r;return n}function Tn(e,t){if(e===vt)throw new Error("invert: expected non-zero number");if(t<=vt)throw new Error("invert: expected positive modulus, got "+t);let r=Q(e,t),n=t,o=vt,i=ft,s=ft,a=vt;for(;r!==vt;){let l=n/r,u=n%r,f=o-s*l,d=i-a*l;n=r,r=u,o=s,i=a,s=f,a=d}if(n!==ft)throw new Error("invert: does not exist");return Q(o,t)}function _d(e){let t=e-ft,r=0;for(;t%$e===vt;)t/=$e,r++;let n=$e,o=ye(e);for(;n<e&&$a(o,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1){let s=(e+ft)/li;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=(t+ft)/$e;return function(a,c){if(!$a(a,c))throw new Error("Cannot find square root");let l=r,u=a.pow(a.mul(a.ONE,n),t),f=a.pow(c,i),d=a.pow(c,t);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let w=1;for(let x=a.sqr(d);w<l&&!a.eql(x,a.ONE);w++)x=a.sqr(x);let C=a.pow(u,ft<<BigInt(l-w-1));u=a.sqr(C),f=a.mul(f,C),d=a.mul(d,u),l=w}return f}}function Ud(e){return e%li===Cd?function(r,n){let o=(e+ft)/li,i=r.pow(n,o);if(!r.eql(r.sqr(i),n))throw new Error("Cannot find square root");return i}:e%qa===Va?function(r,n){let o=r.mul(n,$e),i=(e-Va)/qa,s=r.pow(o,i),a=r.mul(n,s),c=r.mul(r.mul(a,$e),s),l=r.mul(a,r.sub(c,r.ONE));if(!r.eql(r.sqr(l),n))throw new Error("Cannot find square root");return l}:(e%Pd,_d(e))}var Ha=(e,t)=>(Q(e,t)&ft)===ft,Nd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function di(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Nd.reduce((n,o)=>(n[o]="function",n),t);return me(e,r)}function Rd(e,t,r){if(r<vt)throw new Error("invalid exponent, negatives unsupported");if(r===vt)return e.ONE;if(r===ft)return t;let n=e.ONE,o=t;for(;r>vt;)r&ft&&(n=e.mul(n,o)),o=e.sqr(o),r>>=ft;return n}function dr(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((s,a,c)=>e.is0(a)?s:(n[c]=s,e.mul(s,a)),e.ONE),i=e.inv(o);return t.reduceRight((s,a,c)=>e.is0(a)?s:(n[c]=e.mul(s,n[c]),e.mul(s,a)),i),n}function Ld(e,t){let r=(e.ORDER-ft)/$e,n=e.pow(t,r),o=e.eql(n,e.ONE),i=e.eql(n,e.ZERO),s=e.eql(n,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("Cannot find square root: probably non-prime P");return o?1:i?0:-1}function $a(e,t){let r=Ld(e,t);return r===0||r===1}function hi(e,t){t!==void 0&&wn(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function ye(e,t,r=!1,n={}){if(e<=vt)throw new Error("invalid field: expected ORDER > 0, got "+e);let{nBitLength:o,nByteLength:i}=hi(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:qe(o),ZERO:vt,ONE:ft,create:c=>Q(c,e),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return vt<=c&&c<e},is0:c=>c===vt,isOdd:c=>(c&ft)===ft,neg:c=>Q(-c,e),eql:(c,l)=>c===l,sqr:c=>Q(c*c,e),add:(c,l)=>Q(c+l,e),sub:(c,l)=>Q(c-l,e),mul:(c,l)=>Q(c*l,e),pow:(c,l)=>Rd(a,c,l),div:(c,l)=>Q(c*Tn(l,e),e),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Tn(c,e),sqrt:n.sqrt||(c=>(s||(s=Ud(e)),s(a,c))),toBytes:c=>r?fr(c,i):Ve(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return r?Me(c):pe(c)},invertBatch:c=>dr(a,c),cmov:(c,l,u)=>u?l:c});return Object.freeze(a)}function za(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 pi(e){let t=za(e);return t+Math.ceil(t/2)}function ja(e,t,r=!1){let n=e.length,o=za(t),i=pi(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Me(e):pe(e),a=Q(s,t-ft)+ft;return r?fr(a,o):Ve(a,o)}var Ga=BigInt(0),wi=BigInt(1);function mi(e,t){let r=t.negate();return e?r:t}function Wa(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function yi(e,t){Wa(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=qe(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Za(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+=wi);let l=t*n,u=l+Math.abs(a)-1,f=a===0,d=a<0,w=t%2!==0;return{nextN:c,offset:u,isZero:f,isNeg:d,isNegF:w,offsetF:l}}function Dd(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 kd(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 gi=new WeakMap,Ya=new WeakMap;function xi(e){return Ya.get(e)||1}function Cn(e,t){return{constTimeNegate:mi,hasPrecomputes(r){return xi(r)!==1},unsafeLadder(r,n,o=e.ZERO){let i=r;for(;n>Ga;)n&wi&&(o=o.add(i)),i=i.double(),n>>=wi;return o},precomputeWindow(r,n){let{windows:o,windowSize:i}=yi(n,t),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 i=e.ZERO,s=e.BASE,a=yi(r,t);for(let c=0;c<a.windows;c++){let{nextN:l,offset:u,isZero:f,isNeg:d,isNegF:w,offsetF:C}=Za(o,c,a);o=l,f?s=s.add(mi(w,n[C])):i=i.add(mi(d,n[u]))}return{p:i,f:s}},wNAFUnsafe(r,n,o,i=e.ZERO){let s=yi(r,t);for(let a=0;a<s.windows&&o!==Ga;a++){let{nextN:c,offset:l,isZero:u,isNeg:f}=Za(o,a,s);if(o=c,!u){let d=n[l];i=i.add(f?d.negate():d)}}return i},getPrecomputes(r,n,o){let i=gi.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&gi.set(n,o(i))),i},wNAFCached(r,n,o){let i=xi(r);return this.wNAF(i,this.getPrecomputes(i,r,o),n)},wNAFCachedUnsafe(r,n,o,i){let s=xi(r);return s===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,r,o),n,i)},setWindowSize(r,n){Wa(n,t),Ya.set(r,n),gi.delete(r)}}}function Bn(e,t,r,n){if(Dd(r,e),kd(n,t),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=e.ZERO,i=Fa(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=qe(s),c=new Array(Number(a)+1).fill(o),l=Math.floor((t.BITS-1)/s)*s,u=o;for(let f=l;f>=0;f-=s){c.fill(o);for(let w=0;w<n.length;w++){let C=n[w],x=Number(C>>BigInt(f)&a);c[x]=c[x].add(r[w])}let d=o;for(let w=c.length-1,C=o;w>0;w--)C=C.add(c[w]),d=d.add(C);if(u=u.add(d),f!==0)for(let w=0;w<s;w++)u=u.double()}return u}function $r(e){return di(e.Fp),me(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...hi(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}var ne=BigInt(0),At=BigInt(1),Xa=BigInt(2),Kd=BigInt(8),Od={zip215:!0};function Fd(e){let t=$r(e);return me(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Ja(e){let t=Fd(e),{Fp:r,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=t,l=Xa<<BigInt(a*8)-At,u=r.create,f=ye(t.n,t.nBitLength),d=t.uvRatio||((E,p)=>{try{return{isValid:!0,value:r.sqrt(E*r.inv(p))}}catch{return{isValid:!1,value:ne}}}),w=t.adjustScalarBytes||(E=>E),C=t.domain||((E,p,I)=>{if(re("phflag",I),p.length||I)throw new Error("Contexts/pre-hash are not supported");return E});function x(E,p,I=!1){let D=I?At:ne;kt("coordinate "+E,p,D,l)}function h(E){if(!(E instanceof y))throw new Error("ExtendedPoint expected")}let S=lr((E,p)=>{let{ex:I,ey:D,ez:F}=E,$=E.is0();p==null&&(p=$?Kd:r.inv(F));let z=u(I*p),j=u(D*p),W=u(F*p);if($)return{x:ne,y:At};if(W!==At)throw new Error("invZ was invalid");return{x:z,y:j}}),_=lr(E=>{let{a:p,d:I}=t;if(E.is0())throw new Error("bad point: ZERO");let{ex:D,ey:F,ez:$,et:z}=E,j=u(D*D),W=u(F*F),X=u($*$),at=u(X*X),it=u(j*p),pt=u(X*u(it+W)),Tt=u(at+u(I*u(j*W)));if(pt!==Tt)throw new Error("bad point: equation left != right (1)");let lt=u(D*F),xt=u($*z);if(lt!==xt)throw new Error("bad point: equation left != right (2)");return!0});class y{constructor(p,I,D,F){x("x",p),x("y",I),x("z",D,!0),x("t",F),this.ex=p,this.ey=I,this.ez=D,this.et=F,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof y)throw new Error("extended point not allowed");let{x:I,y:D}=p||{};return x("x",I),x("y",D),new y(I,D,At,u(I*D))}static normalizeZ(p){let I=dr(r,p.map(D=>D.ez));return p.map((D,F)=>D.toAffine(I[F])).map(y.fromAffine)}static msm(p,I){return Bn(y,f,p,I)}_setWindowSize(p){k.setWindowSize(this,p)}assertValidity(){_(this)}equals(p){h(p);let{ex:I,ey:D,ez:F}=this,{ex:$,ey:z,ez:j}=p,W=u(I*j),X=u($*F),at=u(D*j),it=u(z*F);return W===X&&at===it}is0(){return this.equals(y.ZERO)}negate(){return new y(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=t,{ex:I,ey:D,ez:F}=this,$=u(I*I),z=u(D*D),j=u(Xa*u(F*F)),W=u(p*$),X=I+D,at=u(u(X*X)-$-z),it=W+z,pt=it-j,Tt=W-z,lt=u(at*pt),xt=u(it*Tt),Rt=u(at*Tt),Ht=u(pt*it);return new y(lt,xt,Ht,Rt)}add(p){h(p);let{a:I,d:D}=t,{ex:F,ey:$,ez:z,et:j}=this,{ex:W,ey:X,ez:at,et:it}=p,pt=u(F*W),Tt=u($*X),lt=u(j*D*it),xt=u(z*at),Rt=u((F+$)*(W+X)-pt-Tt),Ht=xt-lt,Pr=xt+lt,Vs=u(Tt-I*pt),Pf=u(Rt*Ht),_f=u(Pr*Vs),Uf=u(Rt*Vs),Nf=u(Ht*Pr);return new y(Pf,_f,Nf,Uf)}subtract(p){return this.add(p.negate())}wNAF(p){return k.wNAFCached(this,p,y.normalizeZ)}multiply(p){let I=p;kt("scalar",I,At,n);let{p:D,f:F}=this.wNAF(I);return y.normalizeZ([D,F])[0]}multiplyUnsafe(p,I=y.ZERO){let D=p;return kt("scalar",D,ne,n),D===ne?O:this.is0()||D===At?this:k.wNAFCachedUnsafe(this,D,y.normalizeZ,I)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return k.unsafeLadder(this,n).is0()}toAffine(p){return S(this,p)}clearCofactor(){let{h:p}=t;return p===At?this:this.multiplyUnsafe(p)}static fromHex(p,I=!1){let{d:D,a:F}=t,$=r.BYTES;p=nt("pointHex",p,$),re("zip215",I);let z=p.slice(),j=p[$-1];z[$-1]=j&-129;let W=Me(z),X=I?l:r.ORDER;kt("pointHex.y",W,ne,X);let at=u(W*W),it=u(at-At),pt=u(D*at-F),{isValid:Tt,value:lt}=d(it,pt);if(!Tt)throw new Error("Point.fromHex: invalid y coordinate");let xt=(lt&At)===At,Rt=(j&128)!==0;if(!I&<===ne&&Rt)throw new Error("Point.fromHex: x=0 and x_0=1");return Rt!==xt&&(lt=u(-lt)),y.fromAffine({x:lt,y:W})}static fromPrivateKey(p){let{scalar:I}=b(p);return U.multiply(I)}toRawBytes(){let{x:p,y:I}=this.toAffine(),D=fr(I,r.BYTES);return D[D.length-1]|=p&At?128:0,D}toHex(){return Be(this.toRawBytes())}}y.BASE=new y(t.Gx,t.Gy,At,u(t.Gx*t.Gy)),y.ZERO=new y(ne,At,At,ne);let{BASE:U,ZERO:O}=y,k=Cn(y,a*8);function N(E){return Q(E,n)}function g(E){return N(Me(E))}function b(E){let p=r.BYTES;E=nt("private key",E,p);let I=nt("hashed private key",i(E),2*p),D=w(I.slice(0,p)),F=I.slice(p,2*p),$=g(D);return{head:D,prefix:F,scalar:$}}function K(E){let{head:p,prefix:I,scalar:D}=b(E),F=U.multiply(D),$=F.toRawBytes();return{head:p,prefix:I,scalar:D,point:F,pointBytes:$}}function L(E){return K(E).pointBytes}function P(E=Uint8Array.of(),...p){let I=Pe(...p);return g(i(C(I,nt("context",E),!!o)))}function V(E,p,I={}){E=nt("message",E),o&&(E=o(E));let{prefix:D,scalar:F,pointBytes:$}=K(p),z=P(I.context,D,E),j=U.multiply(z).toRawBytes(),W=P(I.context,j,$,E),X=N(z+W*F);kt("signature.s",X,ne,n);let at=Pe(j,fr(X,r.BYTES));return nt("result",at,r.BYTES*2)}let v=Od;function A(E,p,I,D=v){let{context:F,zip215:$}=D,z=r.BYTES;E=nt("signature",E,2*z),p=nt("message",p),I=nt("publicKey",I,z),$!==void 0&&re("zip215",$),o&&(p=o(p));let j=Me(E.slice(z,2*z)),W,X,at;try{W=y.fromHex(I,$),X=y.fromHex(E.slice(0,z),$),at=U.multiplyUnsafe(j)}catch{return!1}if(!$&&W.isSmallOrder())return!1;let it=P(F,X.toRawBytes(),W.toRawBytes(),p);return X.add(W.multiplyUnsafe(it)).subtract(at).clearCofactor().equals(y.ZERO)}return U._setWindowSize(8),{CURVE:t,getPublicKey:L,sign:V,verify:A,ExtendedPoint:y,utils:{getExtendedPublicKey:K,randomPrivateKey:()=>s(r.BYTES),precompute(E=8,p=y.BASE){return p._setWindowSize(E),p.multiply(BigInt(3)),p}}}}var bi=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Qa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),yy=BigInt(0),Md=BigInt(1),tc=BigInt(2),gy=BigInt(3),Vd=BigInt(5),qd=BigInt(8);function $d(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=bi,a=e*e%i*e%i,c=rt(a,tc,i)*a%i,l=rt(c,Md,i)*e%i,u=rt(l,Vd,i)*l%i,f=rt(u,t,i)*u%i,d=rt(f,r,i)*f%i,w=rt(d,n,i)*d%i,C=rt(w,o,i)*w%i,x=rt(C,o,i)*w%i,h=rt(x,t,i)*u%i;return{pow_p_5_8:rt(h,tc,i)*e%i,b2:a}}function Hd(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function zd(e,t){let r=bi,n=Q(t*t*t,r),o=Q(n*n*t,r),i=$d(e*o).pow_p_5_8,s=Q(e*n*i,r),a=Q(t*s*s,r),c=s,l=Q(s*Qa,r),u=a===e,f=a===Q(-e,r),d=a===Q(-e*Qa,r);return u&&(s=c),(f||d)&&(s=l),Ha(s,r)&&(s=Q(-s,r)),{isValid:u||f,value:s}}var ec=ye(bi,void 0,!0),jd={a:ec.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ec,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:qd,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:La,randomBytes:En,adjustScalarBytes:Hd,uvRatio:zd},rc=Ja(jd);var Pn=32;function nc(e,t,r){return rc.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}var _n=class{type="Ed25519";raw;constructor(t){this.raw=Ei(t,Pn)}toMultihash(){return Lt.digest(ar(this))}toCID(){return G.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:et(this.raw,t.raw)}verify(t,r){return nc(this.raw,r,t)}};function Si(e){return e=Ei(e,Pn),new _n(e)}function Ei(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 Zd=Math.pow(2,7),Wd=Math.pow(2,14),Yd=Math.pow(2,21),vi=Math.pow(2,28),Ai=Math.pow(2,35),Ii=Math.pow(2,42),Ti=Math.pow(2,49),Y=128,bt=127;function Nt(e){if(e<Zd)return 1;if(e<Wd)return 2;if(e<Yd)return 3;if(e<vi)return 4;if(e<Ai)return 5;if(e<Ii)return 6;if(e<Ti)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Ci(e,t,r=0){switch(Nt(e)){case 8:t[r++]=e&255|Y,e/=128;case 7:t[r++]=e&255|Y,e/=128;case 6:t[r++]=e&255|Y,e/=128;case 5:t[r++]=e&255|Y,e/=128;case 4:t[r++]=e&255|Y,e>>>=7;case 3:t[r++]=e&255|Y,e>>>=7;case 2:t[r++]=e&255|Y,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Xd(e,t,r=0){switch(Nt(e)){case 8:t.set(r++,e&255|Y),e/=128;case 7:t.set(r++,e&255|Y),e/=128;case 6:t.set(r++,e&255|Y),e/=128;case 5:t.set(r++,e&255|Y),e/=128;case 4:t.set(r++,e&255|Y),e>>>=7;case 3:t.set(r++,e&255|Y),e>>>=7;case 2:t.set(r++,e&255|Y),e>>>=7;case 1:{t.set(r++,e&255),e>>>=7;break}default:throw new Error("unreachable")}return t}function Bi(e,t){let r=e[t],n=0;if(n+=r&bt,r<Y||(r=e[t+1],n+=(r&bt)<<7,r<Y)||(r=e[t+2],n+=(r&bt)<<14,r<Y)||(r=e[t+3],n+=(r&bt)<<21,r<Y)||(r=e[t+4],n+=(r&bt)*vi,r<Y)||(r=e[t+5],n+=(r&bt)*Ai,r<Y)||(r=e[t+6],n+=(r&bt)*Ii,r<Y)||(r=e[t+7],n+=(r&bt)*Ti,r<Y))return n;throw new RangeError("Could not decode varint")}function Jd(e,t){let r=e.get(t),n=0;if(n+=r&bt,r<Y||(r=e.get(t+1),n+=(r&bt)<<7,r<Y)||(r=e.get(t+2),n+=(r&bt)<<14,r<Y)||(r=e.get(t+3),n+=(r&bt)<<21,r<Y)||(r=e.get(t+4),n+=(r&bt)*vi,r<Y)||(r=e.get(t+5),n+=(r&bt)*Ai,r<Y)||(r=e.get(t+6),n+=(r&bt)*Ii,r<Y)||(r=e.get(t+7),n+=(r&bt)*Ti,r<Y))return n;throw new RangeError("Could not decode varint")}function hr(e,t,r=0){return t==null&&(t=_t(Nt(e))),t instanceof Uint8Array?Ci(e,t,r):Xd(e,t,r)}function He(e,t=0){return e instanceof Uint8Array?Bi(e,t):Jd(e,t)}var Pi=new Float32Array([-0]),_e=new Uint8Array(Pi.buffer);function sc(e,t,r){Pi[0]=e,t[r]=_e[0],t[r+1]=_e[1],t[r+2]=_e[2],t[r+3]=_e[3]}function ac(e,t){return _e[0]=e[t],_e[1]=e[t+1],_e[2]=e[t+2],_e[3]=e[t+3],Pi[0]}var _i=new Float64Array([-0]),Et=new Uint8Array(_i.buffer);function cc(e,t,r){_i[0]=e,t[r]=Et[0],t[r+1]=Et[1],t[r+2]=Et[2],t[r+3]=Et[3],t[r+4]=Et[4],t[r+5]=Et[5],t[r+6]=Et[6],t[r+7]=Et[7]}function uc(e,t){return Et[0]=e[t],Et[1]=e[t+1],Et[2]=e[t+2],Et[3]=e[t+3],Et[4]=e[t+4],Et[5]=e[t+5],Et[6]=e[t+6],Et[7]=e[t+7],_i[0]}var Qd=BigInt(Number.MAX_SAFE_INTEGER),th=BigInt(Number.MIN_SAFE_INTEGER),Kt=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 ze;if(t<Qd&&t>th)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>fc&&(o=0n,++n>fc&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return ze;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):ze}},ze=new Kt(0,0);ze.toBigInt=function(){return 0n};ze.zzEncode=ze.zzDecode=function(){return this};ze.length=function(){return 1};var fc=4294967296n;function lc(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 dc(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 Ui(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 Zt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Un(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Ni=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,Zt(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 Zt(this,4);return Un(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Zt(this,4);return Un(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Zt(this,4);let t=ac(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Zt(this,4);let t=uc(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 Zt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return dc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Zt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Zt(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 Kt(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 Zt(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 Zt(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 Zt(this,8);let t=Un(this.buf,this.pos+=4),r=Un(this.buf,this.pos+=4);return new Kt(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=Bi(this.buf,this.pos);return this.pos+=Nt(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 Ri(e){return new Ni(e instanceof Uint8Array?e:e.subarray())}function pr(e,t,r){let n=Ri(e);return t.decode(n,void 0,r)}function Li(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return _t(s);o+s>t&&(n=_t(t),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var je=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Di(){}var Ki=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},eh=Li();function rh(e){return globalThis.Buffer!=null?_t(e):eh(e)}var zr=class{len;head;tail;states;constructor(){this.len=0,this.head=new je(Di,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new je(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Oi((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Nn,10,Kt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Kt.fromBigInt(t);return this._push(Nn,r.length(),r)}uint64Number(t){return this._push(Ci,Nt(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=Kt.fromBigInt(t).zzEncode();return this._push(Nn,r.length(),r)}sint64Number(t){let r=Kt.fromNumber(t).zzEncode();return this._push(Nn,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(ki,1,t?1:0)}fixed32(t){return this._push(Hr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Kt.fromBigInt(t);return this._push(Hr,4,r.lo)._push(Hr,4,r.hi)}fixed64Number(t){let r=Kt.fromNumber(t);return this._push(Hr,4,r.lo)._push(Hr,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(sc,4,t)}double(t){return this._push(cc,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(ki,1,0):this.uint32(r)._push(oh,r,t)}string(t){let r=lc(t);return r!==0?this.uint32(r)._push(Ui,r,t):this._push(ki,1,0)}fork(){return this.states=new Ki(this),this.head=this.tail=new je(Di,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 je(Di,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=rh(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function ki(e,t,r){t[r]=e&255}function nh(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Oi=class extends je{next;constructor(t,r){super(nh,t,r),this.next=void 0}};function Nn(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 Hr(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 oh(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(zr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(ih,t,e),this},zr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(sh,t,e),this});function ih(e,t,r){t.set(e,r)}function sh(e,t,r){e.length<40?Ui(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(H(e),r)}function Fi(){return new zr}function mr(e,t){let r=Fi();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var yr;(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"})(yr||(yr={}));function Rn(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function jr(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(i,s){let a=t(i);s.int32(a)},n=function(i){let s=i.int32();return t(s)};return Rn("enum",yr.VARINT,r,n)}function gr(e,t){return Rn("message",yr.LENGTH_DELIMITED,e,t)}var st;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(st||(st={}));var Mi;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(Mi||(Mi={}));(function(e){e.codec=()=>jr(Mi)})(st||(st={}));var oe;(function(e){let t;e.codec=()=>(t==null&&(t=gr((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=>mr(r,e.codec()),e.decode=(r,n)=>pr(r,e.codec(),n)})(oe||(oe={}));var Vi;(function(e){let t;e.codec=()=>(t==null&&(t=gr((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=>mr(r,e.codec()),e.decode=(r,n)=>pr(r,e.codec(),n)})(Vi||(Vi={}));var Gr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Ln=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var mc={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Ln("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var Ue=mc;var Wr={};Ct(Wr,{MAX_RSA_KEY_SIZE:()=>qi,generateRSAKeyPair:()=>wc,jwkToJWKKeyPair:()=>bc,jwkToPkcs1:()=>fh,jwkToPkix:()=>ji,jwkToRSAPrivateKey:()=>Yi,pkcs1MessageToJwk:()=>Hi,pkcs1MessageToRSAPrivateKey:()=>Gi,pkcs1ToJwk:()=>uh,pkcs1ToRSAPrivateKey:()=>xc,pkixMessageToJwk:()=>zi,pkixMessageToRSAPublicKey:()=>Wi,pkixToJwk:()=>lh,pkixToRSAPublicKey:()=>Zi});var Dn=An;var xr=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=Wr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return G.createV1(114,this._multihash)}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:et(this.raw,t.raw)}verify(t,r){return gc(this.jwk,r,t)}},Zr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=Wr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:et(this.raw,t.raw)}sign(t){return yc(this.jwk,t)}};var qi=8192,$i=18,ah=1062,ch=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function uh(e){let t=fe(e);return Hi(t)}function Hi(e){return{n:q(e[1],"base64url"),e:q(e[2],"base64url"),d:q(e[3],"base64url"),p:q(e[4],"base64url"),q:q(e[5],"base64url"),dp:q(e[6],"base64url"),dq:q(e[7],"base64url"),qi:q(e[8],"base64url"),kty:"RSA"}}function fh(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 Ae([Ut(Uint8Array.from([0])),Ut(H(e.n,"base64url")),Ut(H(e.e,"base64url")),Ut(H(e.d,"base64url")),Ut(H(e.p,"base64url")),Ut(H(e.q,"base64url")),Ut(H(e.dp,"base64url")),Ut(H(e.dq,"base64url")),Ut(H(e.qi,"base64url"))]).subarray()}function lh(e){let t=fe(e,{offset:0});return zi(t)}function zi(e){let t=fe(e[1],{offset:0});return{kty:"RSA",n:q(t[0],"base64url"),e:q(t[1],"base64url")}}function ji(e){if(e.n==null||e.e==null)throw new ct("JWK was missing components");return Ae([ch,xn(Ae([Ut(H(e.n,"base64url")),Ut(H(e.e,"base64url"))]))]).subarray()}function xc(e){let t=fe(e);return Gi(t)}function Gi(e){let t=Hi(e);return Yi(t)}function Zi(e,t){if(e.byteLength>=ah)throw new Xe("Key size is too large");let r=fe(e,{offset:0});return Wi(r,e,t)}function Wi(e,t,r){let n=zi(e);if(r==null){let o=Dn(oe.encode({Type:st.RSA,Data:t}));r=jt($i,o)}return new xr(n,r)}function Yi(e){if(Sc(e)>qi)throw new ct("Key size is too large");let t=bc(e),r=Dn(oe.encode({Type:st.RSA,Data:ji(t.publicKey)})),n=jt($i,r);return new Zr(t.privateKey,new xr(t.publicKey,n))}async function wc(e){if(e>qi)throw new ct("Key size is too large");let t=await Ec(e),r=Dn(oe.encode({Type:st.RSA,Data:ji(t.publicKey)})),n=jt($i,r);return new Zr(t.privateKey,new xr(t.publicKey,n))}function bc(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 Ec(e){let t=await Ue.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 dh(t);return{privateKey:r[0],publicKey:r[1]}}async function yc(e,t){let r=await Ue.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Ue.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function gc(e,t,r){let n=await Ue.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Ue.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}async function dh(e){if(e.privateKey==null||e.publicKey==null)throw new ct("Private and public key are required");return Promise.all([Ue.get().subtle.exportKey("jwk",e.privateKey),Ue.get().subtle.exportKey("jwk",e.publicKey)])}function Sc(e){if(e.kty!=="RSA")throw new ct("invalid key type");if(e.n==null)throw new ct("invalid key modulus");return H(e.n,"base64url").length*8}var kn=class extends cr{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,ba(t);let n=Kr(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),le(i)}update(t){return ur(this),this.iHash.update(t),this}digestInto(t){ur(this),ke(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}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Xi=(e,t,r)=>new kn(e,t).update(r).digest();Xi.create=(e,t)=>new kn(e,t);function vc(e){e.lowS!==void 0&&re("lowS",e.lowS),e.prehash!==void 0&&re("prehash",e.prehash)}function hh(e){let t=$r(e);me(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 Ji=class extends Error{constructor(t=""){super(t)}},ge={Err:Ji,_tlv:{encode:(e,t)=>{let{Err:r}=ge;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=Vr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Vr(o.length/2|128):"";return Vr(e)+i+o+t},decode(e,t){let{Err:r}=ge,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=ge;if(e<xe)throw new t("integer: negative integers are not allowed");let r=Vr(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}=ge;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 pe(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=ge,o=nt("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:l,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=ge,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},xe=BigInt(0),dt=BigInt(1),jg=BigInt(2),Ac=BigInt(3),Gg=BigInt(4);function ph(e){let t=hh(e),{Fp:r}=t,n=ye(t.n,t.nBitLength),o=t.toBytes||((x,h,S)=>{let _=h.toAffine();return Pe(Uint8Array.from([4]),r.toBytes(_.x),r.toBytes(_.y))}),i=t.fromBytes||(x=>{let h=x.subarray(1),S=r.fromBytes(h.subarray(0,r.BYTES)),_=r.fromBytes(h.subarray(r.BYTES,2*r.BYTES));return{x:S,y:_}});function s(x){let{a:h,b:S}=t,_=r.sqr(x),y=r.mul(_,x);return r.add(r.add(y,r.mul(x,h)),S)}if(!r.eql(r.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function a(x){return In(x,dt,t.n)}function c(x){let{allowedPrivateKeyLengths:h,nByteLength:S,wrapPrivateKey:_,n:y}=t;if(h&&typeof x!="bigint"){if(Fe(x)&&(x=Be(x)),typeof x!="string"||!h.includes(x.length))throw new Error("invalid private key");x=x.padStart(S*2,"0")}let U;try{U=typeof x=="bigint"?x:pe(nt("private key",x,S))}catch{throw new Error("invalid private key, expected hex or "+S+" bytes, got "+typeof x)}return _&&(U=Q(U,y)),kt("private key",U,dt,y),U}function l(x){if(!(x instanceof d))throw new Error("ProjectivePoint expected")}let u=lr((x,h)=>{let{px:S,py:_,pz:y}=x;if(r.eql(y,r.ONE))return{x:S,y:_};let U=x.is0();h==null&&(h=U?r.ONE:r.inv(y));let O=r.mul(S,h),k=r.mul(_,h),N=r.mul(y,h);if(U)return{x:r.ZERO,y:r.ZERO};if(!r.eql(N,r.ONE))throw new Error("invZ was invalid");return{x:O,y:k}}),f=lr(x=>{if(x.is0()){if(t.allowInfinityPoint&&!r.is0(x.py))return;throw new Error("bad point: ZERO")}let{x:h,y:S}=x.toAffine();if(!r.isValid(h)||!r.isValid(S))throw new Error("bad point: x or y not FE");let _=r.sqr(S),y=s(h);if(!r.eql(_,y))throw new Error("bad point: equation left != right");if(!x.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(h,S,_){if(h==null||!r.isValid(h))throw new Error("x required");if(S==null||!r.isValid(S)||r.is0(S))throw new Error("y required");if(_==null||!r.isValid(_))throw new Error("z required");this.px=h,this.py=S,this.pz=_,Object.freeze(this)}static fromAffine(h){let{x:S,y:_}=h||{};if(!h||!r.isValid(S)||!r.isValid(_))throw new Error("invalid affine point");if(h instanceof d)throw new Error("projective point not allowed");let y=U=>r.eql(U,r.ZERO);return y(S)&&y(_)?d.ZERO:new d(S,_,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let S=dr(r,h.map(_=>_.pz));return h.map((_,y)=>_.toAffine(S[y])).map(d.fromAffine)}static fromHex(h){let S=d.fromAffine(i(nt("pointHex",h)));return S.assertValidity(),S}static fromPrivateKey(h){return d.BASE.multiply(c(h))}static msm(h,S){return Bn(d,n,h,S)}_setWindowSize(h){C.setWindowSize(this,h)}assertValidity(){f(this)}hasEvenY(){let{y:h}=this.toAffine();if(r.isOdd)return!r.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){l(h);let{px:S,py:_,pz:y}=this,{px:U,py:O,pz:k}=h,N=r.eql(r.mul(S,k),r.mul(U,y)),g=r.eql(r.mul(_,k),r.mul(O,y));return N&&g}negate(){return new d(this.px,r.neg(this.py),this.pz)}double(){let{a:h,b:S}=t,_=r.mul(S,Ac),{px:y,py:U,pz:O}=this,k=r.ZERO,N=r.ZERO,g=r.ZERO,b=r.mul(y,y),K=r.mul(U,U),L=r.mul(O,O),P=r.mul(y,U);return P=r.add(P,P),g=r.mul(y,O),g=r.add(g,g),k=r.mul(h,g),N=r.mul(_,L),N=r.add(k,N),k=r.sub(K,N),N=r.add(K,N),N=r.mul(k,N),k=r.mul(P,k),g=r.mul(_,g),L=r.mul(h,L),P=r.sub(b,L),P=r.mul(h,P),P=r.add(P,g),g=r.add(b,b),b=r.add(g,b),b=r.add(b,L),b=r.mul(b,P),N=r.add(N,b),L=r.mul(U,O),L=r.add(L,L),b=r.mul(L,P),k=r.sub(k,b),g=r.mul(L,K),g=r.add(g,g),g=r.add(g,g),new d(k,N,g)}add(h){l(h);let{px:S,py:_,pz:y}=this,{px:U,py:O,pz:k}=h,N=r.ZERO,g=r.ZERO,b=r.ZERO,K=t.a,L=r.mul(t.b,Ac),P=r.mul(S,U),V=r.mul(_,O),v=r.mul(y,k),A=r.add(S,_),T=r.add(U,O);A=r.mul(A,T),T=r.add(P,V),A=r.sub(A,T),T=r.add(S,y);let E=r.add(U,k);return T=r.mul(T,E),E=r.add(P,v),T=r.sub(T,E),E=r.add(_,y),N=r.add(O,k),E=r.mul(E,N),N=r.add(V,v),E=r.sub(E,N),b=r.mul(K,T),N=r.mul(L,v),b=r.add(N,b),N=r.sub(V,b),b=r.add(V,b),g=r.mul(N,b),V=r.add(P,P),V=r.add(V,P),v=r.mul(K,v),T=r.mul(L,T),V=r.add(V,v),v=r.sub(P,v),v=r.mul(K,v),T=r.add(T,v),P=r.mul(V,T),g=r.add(g,P),P=r.mul(E,T),N=r.mul(A,N),N=r.sub(N,P),P=r.mul(A,V),b=r.mul(E,b),b=r.add(b,P),new d(N,g,b)}subtract(h){return this.add(h.negate())}is0(){return this.equals(d.ZERO)}wNAF(h){return C.wNAFCached(this,h,d.normalizeZ)}multiplyUnsafe(h){let{endo:S,n:_}=t;kt("scalar",h,xe,_);let y=d.ZERO;if(h===xe)return y;if(this.is0()||h===dt)return this;if(!S||C.hasPrecomputes(this))return C.wNAFCachedUnsafe(this,h,d.normalizeZ);let{k1neg:U,k1:O,k2neg:k,k2:N}=S.splitScalar(h),g=y,b=y,K=this;for(;O>xe||N>xe;)O&dt&&(g=g.add(K)),N&dt&&(b=b.add(K)),K=K.double(),O>>=dt,N>>=dt;return U&&(g=g.negate()),k&&(b=b.negate()),b=new d(r.mul(b.px,S.beta),b.py,b.pz),g.add(b)}multiply(h){let{endo:S,n:_}=t;kt("scalar",h,dt,_);let y,U;if(S){let{k1neg:O,k1:k,k2neg:N,k2:g}=S.splitScalar(h),{p:b,f:K}=this.wNAF(k),{p:L,f:P}=this.wNAF(g);b=C.constTimeNegate(O,b),L=C.constTimeNegate(N,L),L=new d(r.mul(L.px,S.beta),L.py,L.pz),y=b.add(L),U=K.add(P)}else{let{p:O,f:k}=this.wNAF(h);y=O,U=k}return d.normalizeZ([y,U])[0]}multiplyAndAddUnsafe(h,S,_){let y=d.BASE,U=(k,N)=>N===xe||N===dt||!k.equals(y)?k.multiplyUnsafe(N):k.multiply(N),O=U(this,S).add(U(h,_));return O.is0()?void 0:O}toAffine(h){return u(this,h)}isTorsionFree(){let{h,isTorsionFree:S}=t;if(h===dt)return!0;if(S)return S(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:S}=t;return h===dt?this:S?S(d,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return re("isCompressed",h),this.assertValidity(),o(d,this,h)}toHex(h=!0){return re("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 w=t.nBitLength,C=Cn(d,t.endo?Math.ceil(w/2):w);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function mh(e){let t=$r(e);return me(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Ic(e){let t=mh(e),{Fp:r,n}=t,o=r.BYTES+1,i=2*r.BYTES+1;function s(v){return Q(v,n)}function a(v){return Tn(v,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=ph({...t,toBytes(v,A,T){let E=A.toAffine(),p=r.toBytes(E.x),I=Pe;return re("isCompressed",T),T?I(Uint8Array.from([A.hasEvenY()?2:3]),p):I(Uint8Array.from([4]),p,r.toBytes(E.y))},fromBytes(v){let A=v.length,T=v[0],E=v.subarray(1);if(A===o&&(T===2||T===3)){let p=pe(E);if(!In(p,dt,r.ORDER))throw new Error("Point is not on curve");let I=u(p),D;try{D=r.sqrt(I)}catch(z){let j=z instanceof Error?": "+z.message:"";throw new Error("Point is not on curve"+j)}let F=(D&dt)===dt;return(T&1)===1!==F&&(D=r.neg(D)),{x:p,y:D}}else if(A===i&&T===4){let p=r.fromBytes(E.subarray(0,r.BYTES)),I=r.fromBytes(E.subarray(r.BYTES,2*r.BYTES));return{x:p,y:I}}else{let p=o,I=i;throw new Error("invalid Point, expected length of "+p+", or uncompressed "+I+", got "+A)}}}),d=v=>Be(Ve(v,t.nByteLength));function w(v){let A=n>>dt;return v>A}function C(v){return w(v)?s(-v):v}let x=(v,A,T)=>pe(v.slice(A,T));class h{constructor(A,T,E){kt("r",A,dt,n),kt("s",T,dt,n),this.r=A,this.s=T,E!=null&&(this.recovery=E),Object.freeze(this)}static fromCompact(A){let T=t.nByteLength;return A=nt("compactSignature",A,T*2),new h(x(A,0,T),x(A,T,2*T))}static fromDER(A){let{r:T,s:E}=ge.toSig(nt("DER",A));return new h(T,E)}assertValidity(){}addRecoveryBit(A){return new h(this.r,this.s,A)}recoverPublicKey(A){let{r:T,s:E,recovery:p}=this,I=k(nt("msgHash",A));if(p==null||![0,1,2,3].includes(p))throw new Error("recovery id invalid");let D=p===2||p===3?T+t.n:T;if(D>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let F=(p&1)===0?"02":"03",$=c.fromHex(F+d(D)),z=a(D),j=s(-I*z),W=s(E*z),X=c.BASE.multiplyAndAddUnsafe($,j,W);if(!X)throw new Error("point at infinify");return X.assertValidity(),X}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return qr(this.toDERHex())}toDERHex(){return ge.hexFromSig(this)}toCompactRawBytes(){return qr(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}let S={isValidPrivateKey(v){try{return l(v),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let v=pi(t.n);return ja(t.randomBytes(v),t.n)},precompute(v=8,A=c.BASE){return A._setWindowSize(v),A.multiply(BigInt(3)),A}};function _(v,A=!0){return c.fromPrivateKey(v).toRawBytes(A)}function y(v){let A=Fe(v),T=typeof v=="string",E=(A||T)&&v.length;return A?E===o||E===i:T?E===2*o||E===2*i:v instanceof c}function U(v,A,T=!0){if(y(v))throw new Error("first arg must be private key");if(!y(A))throw new Error("second arg must be public key");return c.fromHex(A).multiply(l(v)).toRawBytes(T)}let O=t.bits2int||function(v){if(v.length>8192)throw new Error("input is too large");let A=pe(v),T=v.length*8-t.nBitLength;return T>0?A>>BigInt(T):A},k=t.bits2int_modN||function(v){return s(O(v))},N=qe(t.nBitLength);function g(v){return kt("num < 2^"+t.nBitLength,v,xe,N),Ve(v,t.nByteLength)}function b(v,A,T=K){if(["recovered","canonical"].some(it=>it in T))throw new Error("sign() legacy options not supported");let{hash:E,randomBytes:p}=t,{lowS:I,prehash:D,extraEntropy:F}=T;I==null&&(I=!0),v=nt("msgHash",v),vc(T),D&&(v=nt("prehashed msgHash",E(v)));let $=k(v),z=l(A),j=[g(z),g($)];if(F!=null&&F!==!1){let it=F===!0?p(r.BYTES):F;j.push(nt("extraEntropy",it))}let W=Pe(...j),X=$;function at(it){let pt=O(it);if(!f(pt))return;let Tt=a(pt),lt=c.BASE.multiply(pt).toAffine(),xt=s(lt.x);if(xt===xe)return;let Rt=s(Tt*s(X+xt*z));if(Rt===xe)return;let Ht=(lt.x===xt?0:2)|Number(lt.y&dt),Pr=Rt;return I&&w(Rt)&&(Pr=C(Rt),Ht^=1),new h(xt,Pr,Ht)}return{seed:W,k2sig:at}}let K={lowS:t.lowS,prehash:!1},L={lowS:t.lowS,prehash:!1};function P(v,A,T=K){let{seed:E,k2sig:p}=b(v,A,T),I=t;return Ma(I.hash.outputLen,I.nByteLength,I.hmac)(E,p)}c.BASE._setWindowSize(8);function V(v,A,T,E=L){let p=v;A=nt("msgHash",A),T=nt("publicKey",T);let{lowS:I,prehash:D,format:F}=E;if(vc(E),"strict"in E)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 $=typeof p=="string"||Fe(p),z=!$&&!F&&typeof p=="object"&&p!==null&&typeof p.r=="bigint"&&typeof p.s=="bigint";if(!$&&!z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let j,W;try{if(z&&(j=new h(p.r,p.s)),$){try{F!=="compact"&&(j=h.fromDER(p))}catch(Ht){if(!(Ht instanceof ge.Err))throw Ht}!j&&F!=="der"&&(j=h.fromCompact(p))}W=c.fromHex(T)}catch{return!1}if(!j||I&&j.hasHighS())return!1;D&&(A=t.hash(A));let{r:X,s:at}=j,it=k(A),pt=a(at),Tt=s(it*pt),lt=s(X*pt),xt=c.BASE.multiplyAndAddUnsafe(W,Tt,lt)?.toAffine();return xt?s(xt.x)===X:!1}return{CURVE:t,getPublicKey:_,getSharedSecret:U,sign:P,verify:V,ProjectivePoint:c,Signature:h,utils:S}}function yh(e){return{hash:e,hmac:(t,...r)=>Xi(e,t,ei(...r)),randomBytes:En}}function Tc(e,t){let r=n=>Ic({...e,...yh(n)});return{...r(t),create:r}}var Pc=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Cc=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),gh=BigInt(1),Qi=BigInt(2),Bc=(e,t)=>(e+t/Qi)/t;function xh(e){let t=Pc,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,f=rt(u,r,t)*u%t,d=rt(f,r,t)*u%t,w=rt(d,Qi,t)*l%t,C=rt(w,o,t)*w%t,x=rt(C,i,t)*C%t,h=rt(x,a,t)*x%t,S=rt(h,c,t)*h%t,_=rt(S,a,t)*x%t,y=rt(_,r,t)*u%t,U=rt(y,s,t)*C%t,O=rt(U,n,t)*l%t,k=rt(O,Qi,t);if(!ts.eql(ts.sqr(k),e))throw new Error("Cannot find square root");return k}var ts=ye(Pc,void 0,void 0,{sqrt:xh}),Ge=Tc({a:BigInt(0),b:BigInt(7),Fp:ts,n:Cc,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{let t=Cc,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-gh*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=Bc(i*e,t),c=Bc(-n*e,t),l=Q(e-a*r-c*o,t),u=Q(-a*n-c*i,t),f=l>s,d=u>s;if(f&&(l=t-l),d&&(u=t-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:f,k1:l,k2neg:d,k2:u}}}},An),rx=BigInt(0);var nx=Ge.ProjectivePoint;function _c(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}function Uc(e,t,r){let n=Rr.digest(r instanceof Uint8Array?r:r.subarray());if(_c(n))return n.then(({digest:o})=>Ge.verify(t,o,e)).catch(o=>{throw new Gr(String(o))});try{return Ge.verify(t,n.digest,e)}catch(o){throw new Gr(String(o))}}var Kn=class{type="secp256k1";raw;_key;constructor(t){this._key=Rc(t),this.raw=Nc(this._key)}toMultihash(){return Lt.digest(ar(this))}toCID(){return G.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:et(this.raw,t.raw)}verify(t,r){return Uc(this._key,r,t)}};function es(e){return new Kn(e)}function Nc(e){return Ge.ProjectivePoint.fromHex(e).toRawBytes(!0)}function Rc(e){try{return Ge.ProjectivePoint.fromHex(e),e}catch(t){throw new Xe(String(t))}}function Lc(e,t){let{Type:r,Data:n}=oe.decode(e),o=n??new Uint8Array;switch(r){case st.RSA:return Zi(o,t);case st.Ed25519:return Si(o);case st.secp256k1:return es(o);case st.ECDSA:return ti(o);default:throw new Qe}}function On(e){let{Type:t,Data:r}=oe.decode(e.digest),n=r??new Uint8Array;switch(t){case st.Ed25519:return Si(n);case st.secp256k1:return es(n);case st.ECDSA:return ti(n);default:throw new Qe}}function ar(e){return oe.encode({Type:st[e.type],Data:e.raw})}var Dc=Symbol.for("nodejs.util.inspect.custom"),wh=114,Yr=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()})`}[Io]=!0;toString(){return this.string==null&&(this.string=J.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return G.createV1(wh,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return et(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return et(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Dc](){return`PeerId(${this.toString()})`}},Fn=class extends Yr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Mn=class extends Yr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Vn=class extends Yr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},bh=2336,Xr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Lt.digest(H(this.url))}[Dc](){return`PeerId(${this.url})`}[Io]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return G.createV1(bh,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=q(t)),t.toString()===this.toString())}};var Eh=114,kc=2336;function Kc(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=ce(J.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return rs(G.parse(e));if(t==null)throw new ct('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=ce(t.decode(e))}return Oc(r)}function Oc(e){if(vh(e))return new Fn({multihash:e});if(Sh(e))try{let t=On(e);if(t.type==="Ed25519")return new Mn({multihash:e,publicKey:t});if(t.type==="secp256k1")return new Vn({multihash:e,publicKey:t})}catch{let r=q(e.digest);return new Xr(new URL(r))}throw new Je("Supplied PeerID Multihash is invalid")}function rs(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==Eh&&e.code!==kc)throw new dn("Supplied PeerID CID is invalid");if(e.code===kc){let t=q(e.multihash.digest);return new Xr(new URL(t))}return Oc(e.multihash)}function Sh(e){return e.code===Lt.code}function vh(e){return e.code===Rr.code}var qn=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let d=Number.parseInt(f,t);if(!Number.isNaN(d))return d});if(u===void 0)break;if(i*=t,i+=u,i>l||(s+=1,r!==void 0&&s>r))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return r[o]=s[0],r[o+1]=s[1],r[o+2]=s[2],r[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];r[o]=i>>8,r[o+1]=i&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=t(i.subarray(0,s));return r.set(i.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Fc=45,Ah=15,wr=new qn;function ns(e){if(!(e.length>Ah))return wr.new(e).parseWith(()=>wr.readIPv4Addr())}function os(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Fc))return wr.new(e).parseWith(()=>wr.readIPv6Addr())}function $n(e,t=!1){if(e.includes("%")&&(e=e.split("%")[0]),e.length>Fc)return;let r=wr.new(e).parseWith(()=>wr.readIPAddr());if(r)return t&&r.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,r[0],r[1],r[2],r[3]]):r}var gw=parseInt("0xFFFF",16),xw=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function qc(e){return!!ns(e)}function $c(e){return!!os(e)}function Hn(e){return!!$n(e)}var Hc=qc,Ph=$c,is=function(e){let t=0;if(e=e.toString().trim(),Hc(e)){let r=new Uint8Array(t+4);return e.split(/\./g).forEach(n=>{r[t++]=parseInt(n,10)&255}),r}if(Ph(e)){let r=e.split(":",8),n;for(n=0;n<r.length;n++){let i=Hc(r[n]),s;i&&(s=is(r[n]),r[n]=q(s.slice(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,q(s.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let i=[n,1];for(n=9-r.length;n>0;n--)i.push("0");r.splice.apply(r,i)}let o=new Uint8Array(t+16);for(n=0;n<r.length;n++){let i=parseInt(r[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},zc=function(e,t=0,r){t=~~t,r=r??e.length-t;let n=new DataView(e.buffer);if(r===4){let o=[];for(let i=0;i<r;i++)o.push(e[t+i]);return o.join(".")}if(r===16){let o=[];for(let i=0;i<r;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var br={},ss={},Uh=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];Uh.forEach(e=>{let t=Nh(...e);ss[t.code]=t,br[t.name]=t});function Nh(e,t,r,n,o){return{code:e,size:t,name:r,resolvable:!!n,path:!!o}}function tt(e){if(typeof e=="number"){if(ss[e]!=null)return ss[e];throw new Error(`no protocol with code: ${e}`)}else if(typeof e=="string"){if(br[e]!=null)return br[e];throw new Error(`no protocol with name: ${e}`)}throw new Error(`invalid protocol id type: ${typeof e}`)}var eb=tt("ip4"),rb=tt("ip6"),nb=tt("ipcidr");function fs(e,t){switch(tt(e).code){case 4:case 41:return Lh(t);case 42:return us(t);case 43:return q(t,"base10");case 6:case 273:case 33:case 132:return Zc(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return us(t);case 421:return Oh(t);case 444:return Gc(t);case 445:return Gc(t);case 466:return Kh(t);case 481:return globalThis.encodeURIComponent(us(t));default:return q(t,"base16")}}function ls(e,t){switch(tt(e).code){case 4:return jc(t);case 41:return jc(t);case 42:return cs(t);case 43:return H(t,"base10");case 6:case 273:case 33:case 132:return ds(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return cs(t);case 421:return Dh(t);case 444:return Fh(t);case 445:return Mh(t);case 466:return kh(t);case 481:return cs(globalThis.decodeURIComponent(t));default:return H(t,"base16")}}var as=Object.values(Lr).map(e=>e.decoder),Rh=function(){let e=as[0].or(as[1]);return as.slice(2).forEach(t=>e=e.or(t)),e}();function jc(e){if(!Hn(e))throw new Error("invalid ip address");return is(e)}function Lh(e){let t=zc(e,0,e.length);if(t==null)throw new Error("ipBuff is required");if(!Hn(t))throw new Error("invalid ip address");return t}function ds(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function Zc(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function cs(e){let t=H(e),r=Uint8Array.from(hr(t.length));return wt([r,t],r.length+t.length)}function us(e){let t=He(e);if(e=e.slice(Nt(t)),e.length!==t)throw new Error("inconsistent lengths");return q(e)}function Dh(e){let t;e[0]==="Q"||e[0]==="1"?t=ce(J.decode(`z${e}`)).bytes:t=G.parse(e).multihash.bytes;let r=Uint8Array.from(hr(t.length));return wt([r,t],r.length+t.length)}function kh(e){let t=Rh.decode(e),r=Uint8Array.from(hr(t.length));return wt([r,t],r.length+t.length)}function Kh(e){let t=He(e),r=e.slice(Nt(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+q(r,"base64url")}function Oh(e){let t=He(e),r=e.slice(Nt(t));if(r.length!==t)throw new Error("inconsistent lengths");return q(r,"base58btc")}function Fh(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let r=zt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ds(n);return wt([r,o],r.length+o.length)}function Mh(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let r=zt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ds(n);return wt([r,o],r.length+o.length)}function Gc(e){let t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=q(t,"base32"),o=Zc(r);return`${n}:${o}`}function Wc(e){e=hs(e);let t=[],r=[],n=null,o=e.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let s=o[i],a=tt(s);if(a.size===0){t.push([a.code]),r.push([a.code]);continue}if(i++,i>=o.length)throw new zn("invalid address: "+e);if(a.path===!0){n=hs(o.slice(i).join("/")),t.push([a.code,ls(a.code,n)]),r.push([a.code,n]);break}let c=ls(a.code,o[i]);t.push([a.code,c]),r.push([a.code,fs(a.code,c)])}return{string:Yc(r),bytes:jn(t),tuples:t,stringTuples:r,path:n}}function ps(e){let t=[],r=[],n=null,o=0;for(;o<e.length;){let i=He(e,o),s=Nt(i),a=tt(i),c=Vh(a,e.slice(o+s));if(c===0){t.push([i]),r.push([i]),o+=s;continue}let l=e.slice(o+s,o+s+c);if(o+=c+s,o>e.length)throw new zn("Invalid address Uint8Array: "+q(e,"base16"));t.push([i,l]);let u=fs(i,l);if(r.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(e),string:Yc(r),tuples:t,stringTuples:r,path:n}}function Yc(e){let t=[];return e.map(r=>{let n=tt(r[0]);return t.push(n.name),r.length>1&&r[1]!=null&&t.push(r[1]),null}),hs(t.join("/"))}function jn(e){return wt(e.map(t=>{let r=tt(t[0]),n=Uint8Array.from(hr(r.code));return t.length>1&&t[1]!=null&&(n=wt([n,t[1]])),n}))}function Vh(e,t){if(e.size>0)return e.size/8;if(e.size===0)return 0;{let r=He(t instanceof Uint8Array?t:Uint8Array.from(t));return r+Nt(r)}}function hs(e){return"/"+e.trim().split("/").filter(t=>t).join("/")}var zn=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var qh=Symbol.for("nodejs.util.inspect.custom"),ys=Symbol.for("@multiformats/js-multiaddr/multiaddr"),$h=[tt("dns").code,tt("dns4").code,tt("dns6").code,tt("dnsaddr").code],ms=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Gn=class e{bytes;#t;#r;#e;#a;[ys]=!0;constructor(t){t==null&&(t="");let r;if(t instanceof Uint8Array)r=ps(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);r=Wc(t)}else if(Jc(t))r=ps(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.bytes,this.#t=r.string,this.#r=r.tuples,this.#e=r.stringTuples,this.#a=r.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,r,n,o,i="",s=tt("tcp"),a=tt("udp"),c=tt("ip4"),l=tt("ip6"),u=tt("dns6"),f=tt("ip6zone");for(let[w,C]of this.stringTuples())w===f.code&&(i=`%${C??""}`),$h.includes(w)&&(r=s.name==="tcp"?"tcp":"udp",o=443,n=`${C??""}${i}`,t=w===u.code?6:4),(w===s.code||w===a.code)&&(r=tt(w).name==="tcp"?"tcp":"udp",o=parseInt(C??"")),(w===c.code||w===l.code)&&(r=tt(w).name==="tcp"?"tcp":"udp",n=`${C??""}${i}`,t=w===l.code?6:4);if(t==null||r==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:r,port:o}}protos(){return this.#r.map(([t])=>Object.assign({},tt(t)))}protoCodes(){return this.#r.map(([t])=>t)}protoNames(){return this.#r.map(([t])=>tt(t).name)}tuples(){return this.#r.map(([t,r])=>r==null?[t]:[t,r])}stringTuples(){return this.#e.map(([t,r])=>r==null?[t]:[t,r])}encapsulate(t){return t=new e(t),new e(this.toString()+t.toString())}decapsulate(t){let r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new e(n.slice(0,o))}decapsulateCode(t){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===t)return new e(jn(r.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===br.p2p.code&&t.push([n,o]),n===br["p2p-circuit"].code&&(t=[])});let r=t.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?q(J.decode(`z${n}`),"base58btc"):q(G.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(t){return et(this.bytes,t.bytes)}async resolve(t){let r=this.protos().find(i=>i.resolvable);if(r==null)return[this];let n=Xc.get(r.name);if(n==null)throw new ms(`no available resolver for ${r.name}`);return(await n(this,t)).map(i=>Ze(i))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let r=(t??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[qh](){return`Multiaddr(${this.#t})`}};var Xc=new Map;function Jc(e){return!!e?.[ys]}function Ze(e){return new Gn(e)}function Jr(e){let t=new globalThis.AbortController;function r(){t.abort();for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}for(let i of e){if(i?.aborted===!0){r();break}i?.addEventListener!=null&&i.addEventListener("abort",r)}function n(){for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}let o=t.signal;return o.clear=n,o}async function*Zn(e,t={}){let r=e.getReader();try{for(;;){let n=await r.read();if(n.done)return;yield n.value}}finally{t.preventCancel!==!0&&await r.cancel(),r.releaseLock()}}var Hh="/",zh=new TextEncoder().encode(Hh),Rb=zh[0];var Ip=Ao(xs(),1);var Wt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},Wn=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},Er=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},Yn=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},Xn=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},Jn=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},Qr=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var Yt;(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=()=>jr(r)}(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=gr((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),e.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let l=o.uint32();switch(l>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=e.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(l&7);break}}}return a})),n),e.encode=o=>mr(o,e.codec()),e.decode=(o,i)=>pr(o,e.codec(),i)})(Yt||(Yt={}));var jh=["string","number","bigint","symbol"],Gh=["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 Qc(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(jh.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Zh(e))return"Buffer";let r=Wh(e);return r||"Object"}function Zh(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Wh(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Gh.includes(t))return t}var m=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}};m.uint=new m(0,"uint",!0);m.negint=new m(1,"negint",!0);m.bytes=new m(2,"bytes",!0);m.string=new m(3,"string",!0);m.array=new m(4,"array",!1);m.map=new m(5,"map",!1);m.tag=new m(6,"tag",!1);m.float=new m(7,"float",!0);m.false=new m(7,"false",!0);m.true=new m(7,"true",!0);m.null=new m(7,"null",!0);m.undefined=new m(7,"undefined",!0);m.break=new m(7,"break",!0);var R=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 Sr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Yh=new TextDecoder,Xh=new TextEncoder;function Qn(e){return Sr&&globalThis.Buffer.isBuffer(e)}function nu(e){return e instanceof Uint8Array?Qn(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var ou=Sr?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):eu(e,t,r):(e,t,r)=>r-t>64?Yh.decode(e.subarray(t,r)):eu(e,t,r),iu=Sr?e=>e.length>64?globalThis.Buffer.from(e):tu(e):e=>e.length>64?Xh.encode(e):tu(e);var vr=Sr?(e,t,r)=>Qn(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),su=Sr?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),nu(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},au=Sr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function cu(e,t){if(Qn(e)&&Qn(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 tu(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 eu(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,l,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],l=e[t+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),t+=s}return Jh(n)}var ru=4096;function Jh(e){let t=e.length;if(t<=ru)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=ru));return r}var Qh=256,to=class{constructor(t=Qh){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=au(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=vr(n,0,this.cursor)}else r=su(this.chunks,this.cursor);return t&&this.reset(),r}};var M="CBOR decode error:",ws="CBOR encode error:",tn=[];tn[23]=1;tn[24]=2;tn[25]=3;tn[26]=5;tn[27]=9;function we(e,t,r){if(e.length-t<r)throw new Error(`${M} not enough data for type`)}var ht=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Ot(e,t,r){we(e,t,1);let n=e[t];if(r.strict===!0&&n<ht[0])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Ft(e,t,r){we(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<ht[1])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Mt(e,t,r){we(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<ht[2])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Vt(e,t,r){we(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<ht[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 uu(e,t,r,n){return new R(m.uint,Ot(e,t+1,n),2)}function fu(e,t,r,n){return new R(m.uint,Ft(e,t+1,n),3)}function lu(e,t,r,n){return new R(m.uint,Mt(e,t+1,n),5)}function du(e,t,r,n){return new R(m.uint,Vt(e,t+1,n),9)}function qt(e,t){return yt(e,0,t.value)}function yt(e,t,r){if(r<ht[0]){let n=Number(r);e.push([t|n])}else if(r<ht[1]){let n=Number(r);e.push([t|24,n])}else if(r<ht[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<ht[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<ht[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`)}}qt.encodedSize=function(t){return yt.encodedSize(t.value)};yt.encodedSize=function(t){return t<ht[0]?1:t<ht[1]?2:t<ht[2]?3:t<ht[3]?5:9};qt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function hu(e,t,r,n){return new R(m.negint,-1-Ot(e,t+1,n),2)}function pu(e,t,r,n){return new R(m.negint,-1-Ft(e,t+1,n),3)}function mu(e,t,r,n){return new R(m.negint,-1-Mt(e,t+1,n),5)}var bs=BigInt(-1),yu=BigInt(1);function gu(e,t,r,n){let o=Vt(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new R(m.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${M} integers outside of the safe integer range are not supported`);return new R(m.negint,bs-BigInt(o),9)}function eo(e,t){let r=t.value,n=typeof r=="bigint"?r*bs-yu:r*-1-1;yt(e,t.type.majorEncoded,n)}eo.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*bs-yu:r*-1-1;return n<ht[0]?1:n<ht[1]?2:n<ht[2]?3:n<ht[3]?5:9};eo.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function en(e,t,r,n){we(e,t,r+n);let o=vr(e,t+r,t+r+n);return new R(m.bytes,o,r+n)}function xu(e,t,r,n){return en(e,t,1,r)}function wu(e,t,r,n){return en(e,t,2,Ot(e,t+1,n))}function bu(e,t,r,n){return en(e,t,3,Ft(e,t+1,n))}function Eu(e,t,r,n){return en(e,t,5,Mt(e,t+1,n))}function Su(e,t,r,n){let o=Vt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer bytes lengths not supported`);return en(e,t,9,o)}function ro(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===m.string?iu(e.value):e.value),e.encodedBytes}function Ar(e,t){let r=ro(t);yt(e,t.type.majorEncoded,r.length),e.push(r)}Ar.encodedSize=function(t){let r=ro(t);return yt.encodedSize(r.length)+r.length};Ar.compareTokens=function(t,r){return ep(ro(t),ro(r))};function ep(e,t){return e.length<t.length?-1:e.length>t.length?1:cu(e,t)}function rn(e,t,r,n,o){let i=r+n;we(e,t,i);let s=new R(m.string,ou(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=vr(e,t+r,t+i)),s}function vu(e,t,r,n){return rn(e,t,1,r,n)}function Au(e,t,r,n){return rn(e,t,2,Ot(e,t+1,n),n)}function Iu(e,t,r,n){return rn(e,t,3,Ft(e,t+1,n),n)}function Tu(e,t,r,n){return rn(e,t,5,Mt(e,t+1,n),n)}function Cu(e,t,r,n){let o=Vt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer string lengths not supported`);return rn(e,t,9,o,n)}var Bu=Ar;function Ir(e,t,r,n){return new R(m.array,n,r)}function Pu(e,t,r,n){return Ir(e,t,1,r)}function _u(e,t,r,n){return Ir(e,t,2,Ot(e,t+1,n))}function Uu(e,t,r,n){return Ir(e,t,3,Ft(e,t+1,n))}function Nu(e,t,r,n){return Ir(e,t,5,Mt(e,t+1,n))}function Ru(e,t,r,n){let o=Vt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer array lengths not supported`);return Ir(e,t,9,o)}function Lu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return Ir(e,t,1,1/0)}function no(e,t){yt(e,m.array.majorEncoded,t.value)}no.compareTokens=qt.compareTokens;no.encodedSize=function(t){return yt.encodedSize(t.value)};function Tr(e,t,r,n){return new R(m.map,n,r)}function Du(e,t,r,n){return Tr(e,t,1,r)}function ku(e,t,r,n){return Tr(e,t,2,Ot(e,t+1,n))}function Ku(e,t,r,n){return Tr(e,t,3,Ft(e,t+1,n))}function Ou(e,t,r,n){return Tr(e,t,5,Mt(e,t+1,n))}function Fu(e,t,r,n){let o=Vt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer map lengths not supported`);return Tr(e,t,9,o)}function Mu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return Tr(e,t,1,1/0)}function oo(e,t){yt(e,m.map.majorEncoded,t.value)}oo.compareTokens=qt.compareTokens;oo.encodedSize=function(t){return yt.encodedSize(t.value)};function Vu(e,t,r,n){return new R(m.tag,r,1)}function qu(e,t,r,n){return new R(m.tag,Ot(e,t+1,n),2)}function $u(e,t,r,n){return new R(m.tag,Ft(e,t+1,n),3)}function Hu(e,t,r,n){return new R(m.tag,Mt(e,t+1,n),5)}function zu(e,t,r,n){return new R(m.tag,Vt(e,t+1,n),9)}function io(e,t){yt(e,m.tag.majorEncoded,t.value)}io.compareTokens=qt.compareTokens;io.encodedSize=function(t){return yt.encodedSize(t.value)};var ap=20,cp=21,up=22,fp=23;function ju(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${M} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new R(m.null,null,1):new R(m.undefined,void 0,1)}function Gu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return new R(m.break,void 0,1)}function Es(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 R(m.float,e,t)}function Zu(e,t,r,n){return Es(Ss(e,t+1),3,n)}function Wu(e,t,r,n){return Es(vs(e,t+1),5,n)}function Yu(e,t,r,n){return Es(tf(e,t+1),9,n)}function so(e,t,r){let n=t.value;if(n===!1)e.push([m.float.majorEncoded|ap]);else if(n===!0)e.push([m.float.majorEncoded|cp]);else if(n===null)e.push([m.float.majorEncoded|up]);else if(n===void 0)e.push([m.float.majorEncoded|fp]);else{let o,i=!1;(!r||r.float64!==!0)&&(Ju(n),o=Ss(Xt,1),n===o||Number.isNaN(n)?(Xt[0]=249,e.push(Xt.slice(0,3)),i=!0):(Qu(n),o=vs(Xt,1),n===o&&(Xt[0]=250,e.push(Xt.slice(0,5)),i=!0))),i||(lp(n),o=tf(Xt,1),Xt[0]=251,e.push(Xt.slice(0,9)))}}so.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){Ju(n);let o=Ss(Xt,1);if(n===o||Number.isNaN(n))return 3;if(Qu(n),o=vs(Xt,1),n===o)return 5}return 9};var Xu=new ArrayBuffer(9),$t=new DataView(Xu,1),Xt=new Uint8Array(Xu,0);function Ju(e){if(e===1/0)$t.setUint16(0,31744,!1);else if(e===-1/0)$t.setUint16(0,64512,!1);else if(Number.isNaN(e))$t.setUint16(0,32256,!1);else{$t.setFloat32(0,e);let t=$t.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)$t.setUint16(0,31744,!1);else if(r===0)$t.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?$t.setUint16(0,0):o<-14?$t.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):$t.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Ss(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 Qu(e){$t.setFloat32(0,e,!1)}function vs(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 lp(e){$t.setFloat64(0,e,!1)}function tf(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)}so.compareTokens=qt.compareTokens;function Z(e,t,r){throw new Error(`${M} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function ao(e){return()=>{throw new Error(`${M} ${e}`)}}var B=[];for(let e=0;e<=23;e++)B[e]=Z;B[24]=uu;B[25]=fu;B[26]=lu;B[27]=du;B[28]=Z;B[29]=Z;B[30]=Z;B[31]=Z;for(let e=32;e<=55;e++)B[e]=Z;B[56]=hu;B[57]=pu;B[58]=mu;B[59]=gu;B[60]=Z;B[61]=Z;B[62]=Z;B[63]=Z;for(let e=64;e<=87;e++)B[e]=xu;B[88]=wu;B[89]=bu;B[90]=Eu;B[91]=Su;B[92]=Z;B[93]=Z;B[94]=Z;B[95]=ao("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)B[e]=vu;B[120]=Au;B[121]=Iu;B[122]=Tu;B[123]=Cu;B[124]=Z;B[125]=Z;B[126]=Z;B[127]=ao("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)B[e]=Pu;B[152]=_u;B[153]=Uu;B[154]=Nu;B[155]=Ru;B[156]=Z;B[157]=Z;B[158]=Z;B[159]=Lu;for(let e=160;e<=183;e++)B[e]=Du;B[184]=ku;B[185]=Ku;B[186]=Ou;B[187]=Fu;B[188]=Z;B[189]=Z;B[190]=Z;B[191]=Mu;for(let e=192;e<=215;e++)B[e]=Vu;B[216]=qu;B[217]=$u;B[218]=Hu;B[219]=zu;B[220]=Z;B[221]=Z;B[222]=Z;B[223]=Z;for(let e=224;e<=243;e++)B[e]=ao("simple values are not supported");B[244]=Z;B[245]=Z;B[246]=Z;B[247]=ju;B[248]=ao("simple values are not supported");B[249]=Zu;B[250]=Wu;B[251]=Yu;B[252]=Z;B[253]=Z;B[254]=Z;B[255]=Gu;var Jt=[];for(let e=0;e<24;e++)Jt[e]=new R(m.uint,e,1);for(let e=-1;e>=-24;e--)Jt[31-e]=new R(m.negint,e,1);Jt[64]=new R(m.bytes,new Uint8Array(0),1);Jt[96]=new R(m.string,"",1);Jt[128]=new R(m.array,0,1);Jt[160]=new R(m.map,0,1);Jt[244]=new R(m.false,!1,1);Jt[245]=new R(m.true,!0,1);Jt[246]=new R(m.null,null,1);function hp(){let e=[];return e[m.uint.major]=qt,e[m.negint.major]=eo,e[m.bytes.major]=Ar,e[m.string.major]=Bu,e[m.array.major]=no,e[m.map.major]=oo,e[m.tag.major]=io,e[m.float.major]=so,e}var U1=hp(),N1=new to,co=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(`${ws} object contains circular references`);return new e(r,t)}},Ne={null:new R(m.null,null),undefined:new R(m.undefined,void 0),true:new R(m.true,!0),false:new R(m.false,!1),emptyArray:new R(m.array,0),emptyMap:new R(m.map,0)},Re={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new R(m.float,e):e>=0?new R(m.uint,e):new R(m.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new R(m.uint,e):new R(m.negint,e)},Uint8Array(e,t,r,n){return new R(m.bytes,e)},string(e,t,r,n){return new R(m.string,e)},boolean(e,t,r,n){return e?Ne.true:Ne.false},null(e,t,r,n){return Ne.null},undefined(e,t,r,n){return Ne.undefined},ArrayBuffer(e,t,r,n){return new R(m.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new R(m.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[Ne.emptyArray,new R(m.break)]:Ne.emptyArray;n=co.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=As(s,r,n);return r.addBreakTokens?[new R(m.array,e.length),o,new R(m.break)]:[new R(m.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?[Ne.emptyMap,new R(m.break)]:Ne.emptyMap;n=co.createCheck(n,e);let a=[],c=0;for(let l of i)a[c++]=[As(l,r,n),As(o?e.get(l):e[l],r,n)];return pp(a,r),r.addBreakTokens?[new R(m.map,s),a,new R(m.break)]:[new R(m.map,s),a]}};Re.Map=Re.Object;Re.Buffer=Re.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Re[`${e}Array`]=Re.DataView;function As(e,t={},r){let n=Qc(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Re[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Re[n];if(!i)throw new Error(`${ws} unsupported type: ${n}`);return i(e,n,t,r)}function pp(e,t){t.mapSorter&&e.sort(t.mapSorter)}var mp={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},uo=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=Jt[t];if(r===void 0){let n=B[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}},nn=Symbol.for("DONE"),fo=Symbol.for("BREAK");function yp(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=Cr(t,r);if(i===fo){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed array`)}if(i===nn)throw new Error(`${M} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function gp(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=Cr(t,r);if(a===fo){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed map`)}if(a===nn)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=Cr(t,r);if(c===nn)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 Cr(e,t){if(e.done())return nn;let r=e.next();if(r.type===m.break)return fo;if(r.type.terminal)return r.value;if(r.type===m.array)return yp(r,e,t);if(r.type===m.map)return gp(r,e,t);if(r.type===m.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=Cr(e,t);return t.tags[r.value](n)}throw new Error(`${M} tag not supported (${r.value})`)}throw new Error("unsupported")}function ef(e,t){if(!(e instanceof Uint8Array))throw new Error(`${M} data to decode must be a Uint8Array`);t=Object.assign({},mp,t);let r=t.tokenizer||new uo(e,t),n=Cr(r,t);if(n===nn)throw new Error(`${M} did not find any content to decode`);if(n===fo)throw new Error(`${M} got unexpected break`);return[n,e.subarray(r.pos())]}function Is(e,t){let[r,n]=ef(e,t);if(n.length>0)throw new Error(`${M} too many terminals, data makes no sense`);return r}var bp=Se("ipns:utils"),rf=H("/ipns/");var Ep=0,Sp=18;function nf(e){let t;if(e.pubKey!=null)try{t=Lc(e.pubKey)}catch(r){throw bp.error(r),r}if(t!=null)return t}function of(e){let t=H("ipns-signature:");return wt([t,e])}function Ye(e){return"signatureV1"in e?Yt.encode({value:H(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:H(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):Yt.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function ie(e){let t=Yt.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 Wt("Missing data or signatureV2");let r=sf(t.data),n=vp(r.Value),o=q(r.Validity);if(t.value!=null&&t.signatureV1!=null)return Ap(t),{value:n,validityType:Yt.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:Yt.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 on(e){return wt([rf,e.bytes])}function be(e){let t=ce(e.slice(rf.length));if(!lo(t,Ep)&&!lo(t,Sp))throw new Je("Multihash in IPNS key was not identity or sha2-256");return t}function sf(e){let t=Is(e);if(t.ValidityType===0)t.ValidityType=Yt.ValidityType.EOL;else throw new Er("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 vp(e){let t=q(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${G.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${G.parse(t).toV1().toString()}`}catch{}throw new Xn("Value must be a valid content path starting with /")}function Ap(e){if(e.data==null)throw new Jn("Record data is missing");let t=sf(e.data);if(!et(t.Value,e.value??new Uint8Array(0)))throw new Wt('Field "value" did not match between protobuf and CBOR');if(!et(t.Validity,e.validity??new Uint8Array(0)))throw new Wt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Wt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Wt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Wt('Field "ttl" did not match between protobuf and CBOR')}function lo(e,t){return e.code===t}var r2=Se("ipns"),n2=5*60*1e9,Tp="/ipns/",o2=Tp.length;var af=Ao(xs(),1);var ho=Se("ipns:validator"),Cp=1024*10,Bp=async(e,t)=>{let r=ie(t),n;try{let o=of(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw ho.error("record signature verification failed"),new Wt("Record signature verification failed");if(r.validityType===Yt.ValidityType.EOL){if(af.default.fromString(r.validity).toDate().getTime()<Date.now())throw ho.error("record has expired"),new Wn("record has expired")}else if(r.validityType!=null)throw ho.error("the validity type is unsupported"),new Er("The validity type is unsupported");ho("ipns record for %s is valid",r.value)};async function cf(e,t){if(t.byteLength>Cp)throw new Yn("The record is too large");let r=be(e),n;lo(r,0)&&(n=On(r));let o=ie(t),i=nf(o)??n;if(i==null)throw new Qr("Could not extract public key from IPNS record or routing key");let s=on(i.toMultihash());if(!et(s,e))throw new Qr("Embedded public key did not match routing key");await Bp(i,t)}var po=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*sn(e,t={}){let r=/\r?\n/,n=new TextDecoder("utf8"),o="";for await(let i of e){if(typeof i=="string"&&(i=new TextEncoder().encode(i)),ir(i)&&(i=i.subarray()),o+=n.decode(i,{stream:!0}),o.length>(t?.maxMessageLength??o.length))throw new po("Incoming message too long");let s=o.split(r);o=s.pop()??"";for(let a=0;a<s.length;a++)yield JSON.parse(s[a])}o+=n.decode(),o!==""&&(yield JSON.parse(o))}function se(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var Cs=Ao(ff(),1);var cn=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},Bs=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},lf=e=>globalThis.DOMException===void 0?new Bs(e):new DOMException(e),df=e=>{let t=e.reason===void 0?lf("This operation was aborted."):e.reason;return t instanceof Error?t:lf(t)};function Ps(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,s,a,l=new Promise((u,f)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:w}=t;w.aborted&&f(df(w)),a=()=>{f(df(w))},w.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){e.then(u,f);return}let d=new cn;s=i.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(w){f(w)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?u():o instanceof Error?f(o):(d.message=o??`Promise timed out after ${r} milliseconds`,f(d))},r),(async()=>{try{u(await e)}catch(w){f(w)}})()}).finally(()=>{l.clear(),a&&t.signal&&t.signal.removeEventListener("abort",a)});return l.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},l}function _s(e,t,r){let n=0,o=e.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;r(e[s],t)<=0?(n=++s,o-=i+1):o=i}return n}var un=class{#t=[];enqueue(t,r){r={priority:0,...r};let n={priority:r.priority,id:r.id,run:t};if(this.size===0||this.#t[this.size-1].priority>=r.priority){this.#t.push(n);return}let o=_s(this.#t,n,(i,s)=>s.priority-i.priority);this.#t.splice(o,0,n)}setPriority(t,r){let n=this.#t.findIndex(i=>i.id===t);if(n===-1)throw new ReferenceError(`No promise function with the id "${t}" exists in the queue.`);let[o]=this.#t.splice(n,1);this.enqueue(o.run,{priority:r,id:t})}dequeue(){return this.#t.shift()?.run}filter(t){return this.#t.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this.#t.length}};var fn=class extends Cs.default{#t;#r;#e=0;#a;#c;#p=0;#o;#u;#n;#m;#i=0;#f;#s;#y;#w=1n;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:un,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#t=t.carryoverConcurrencyCount,this.#r=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#a=t.intervalCap,this.#c=t.interval,this.#n=new t.queueClass,this.#m=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#y=t.throwOnTimeout===!0,this.#s=t.autoStart===!1}get#b(){return this.#r||this.#e<this.#a}get#E(){return this.#i<this.#f}#S(){this.#i--,this.#l(),this.emit("next")}#v(){this.#x(),this.#g(),this.#u=void 0}get#A(){let t=Date.now();if(this.#o===void 0){let r=this.#p-t;if(r<0)this.#e=this.#t?this.#i:0;else return this.#u===void 0&&(this.#u=setTimeout(()=>{this.#v()},r)),!0}return!1}#l(){if(this.#n.size===0)return this.#o&&clearInterval(this.#o),this.#o=void 0,this.emit("empty"),this.#i===0&&this.emit("idle"),!1;if(!this.#s){let t=!this.#A;if(this.#b&&this.#E){let r=this.#n.dequeue();return r?(this.emit("active"),r(),t&&this.#g(),!0):!1}}return!1}#g(){this.#r||this.#o!==void 0||(this.#o=setInterval(()=>{this.#x()},this.#c),this.#p=Date.now()+this.#c)}#x(){this.#e===0&&this.#i===0&&this.#o&&(clearInterval(this.#o),this.#o=void 0),this.#e=this.#t?this.#i:0,this.#d()}#d(){for(;this.#l(););}get concurrency(){return this.#f}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#f=t,this.#d()}async#I(t){return new Promise((r,n)=>{t.addEventListener("abort",()=>{n(t.reason)},{once:!0})})}setPriority(t,r){this.#n.setPriority(t,r)}async add(t,r={}){return r.id??=(this.#w++).toString(),r={timeout:this.timeout,throwOnTimeout:this.#y,...r},new Promise((n,o)=>{this.#n.enqueue(async()=>{this.#i++,this.#e++;try{r.signal?.throwIfAborted();let i=t({signal:r.signal});r.timeout&&(i=Ps(Promise.resolve(i),{milliseconds:r.timeout})),r.signal&&(i=Promise.race([i,this.#I(r.signal)]));let s=await i;n(s),this.emit("completed",s)}catch(i){if(i instanceof cn&&!r.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#S()}},r),this.emit("add"),this.#l()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#s?(this.#s=!1,this.#d(),this):this}pause(){this.#s=!0}clear(){this.#n=new this.#m}async onEmpty(){this.#n.size!==0&&await this.#h("empty")}async onSizeLessThan(t){this.#n.size<t||await this.#h("next",()=>this.#n.size<t)}async onIdle(){this.#i===0&&this.#n.size===0||await this.#h("idle")}async#h(t,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#n.size}sizeBy(t){return this.#n.filter(t).length}get pending(){return this.#i}get isPaused(){return this.#s}};var Br=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},Qt=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function Up(e){return e[Symbol.asyncIterator]!=null}function Np(e){if(Up(e))return(async()=>{for await(let t of e)return t})();for(let t of e)return t}var yo=Np;function Rp(e){let[t,r]=e[Symbol.asyncIterator]!=null?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[r](){return this}}}var hf=Rp;function Lp(e){return e[Symbol.asyncIterator]!=null}function Dp(e,t){let r=0;if(Lp(e))return async function*(){for await(let c of e)yield t(c,r++)}();let n=hf(e),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let s=t(o,r++);if(typeof s.then=="function")return async function*(){yield await s;for await(let c of n)yield t(c,r++)}();let a=t;return function*(){yield s;for(let c of n)yield a(c,r++)}()}var go=Dp;var pf=H("/ipns/");function mf(e){return et(e.subarray(0,pf.byteLength),pf)}var xo=class{client;constructor(t){this.client=t}async*findProviders(t,r={}){yield*go(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async cancelReprovide(){}async put(t,r,n){if(!mf(t))return;let o=be(t),i=G.createV1(114,o),s=ie(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!mf(t))throw new Bt("Not found");let n=be(t),o=G.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return Ye(i)}catch(i){throw i.name==="BadResponseError"?new Bt("Not found"):i}}},wo=class{client;constructor(t){this.client=t}async findPeer(t,r={}){let n=await yo(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Bt("Not found")}async*getClosestPeers(t,r={}){}};var gt=Se("delegated-routing-v1-http-api-client"),bo={concurrentRequests:4,timeout:3e4,cacheTTL:5*60*1e3,cacheName:"delegated-routing-v1-cache"},Eo=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;filterAddrs;filterProtocols;inFlightRequests;cacheName;cache;cacheTTL;constructor(t,r={}){this.started=!1,this.shutDownController=new AbortController,this.shutDownController.signal,this.httpQueue=new fn({concurrency:r.concurrentRequests??bo.concurrentRequests}),this.inFlightRequests=new Map,this.clientUrl=t instanceof URL?t:new URL(t),this.timeout=r.timeout??bo.timeout,this.filterAddrs=r.filterAddrs,this.filterProtocols=r.filterProtocols,this.contentRouting=new xo(this),this.peerRouting=new wo(this),this.cacheName=r.cacheName??bo.cacheName,this.cacheTTL=r.cacheTTL??bo.cacheTTL}get[Hs](){return this.contentRouting}get[zs](){return this.peerRouting}isStarted(){return this.started}async start(){this.started||(this.started=!0,this.cacheTTL>0&&(this.cache=await globalThis.caches?.open(this.cacheName),this.cache!=null&>("cache enabled with ttl %d",this.cacheTTL)))}async stop(){this.httpQueue.clear(),this.shutDownController.abort(),await globalThis.caches?.delete(this.cacheName),this.started=!1}async*getProviders(t,r={}){gt("getProviders starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=Jr([this.shutDownController.signal,n,r.signal]);let i=se(),s=se();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/providers/${t.toString()}`);this.#r(a,r.filterAddrs,r.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},l=await this.#e(a.toString(),c);if(l==null)throw new Qt("No response received");if(!l.ok)throw l.status===404?new Bt("No matching records found"):l.status===422?new Br("Request does not conform to schema or semantic constraints"):new Qt(`Unexpected status code: ${l.status}`);if(l.body==null)throw new Qt("Routing response had no body");let u=l.headers.get("Content-Type");if(u==null)throw new Qt("No Content-Type header received");if(u?.startsWith("application/json")){let f=await l.json();for(let d of f.Providers){let w=this.#t(d);w!=null&&(yield w)}}else if(u.includes("application/x-ndjson"))for await(let f of sn(Zn(l.body))){let d=this.#t(f);d!=null&&(yield d)}else throw new Qt(`Unsupported Content-Type: ${u}`)}finally{o.clear(),s.resolve(),gt("getProviders finished: %c",t)}}async*getPeers(t,r={}){gt("getPeers starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=Jr([this.shutDownController.signal,n,r.signal]);let i=se(),s=se();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/peers/${t.toCID().toString()}`);this.#r(a,r.filterAddrs,r.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},l=await this.#e(a.toString(),c);if(l.status===404)throw new Bt("No matching records found");if(l.status===422)throw new Br("Request does not conform to schema or semantic constraints");if(l.body==null)throw new Qt("Routing response had no body");if(l.headers.get("Content-Type")==="application/json"){let f=await l.json();for(let d of f.Peers){let w=this.#t(d);w!=null&&(yield w)}}else for await(let f of sn(Zn(l.body))){let d=this.#t(f);d!=null&&(yield d)}}catch(a){gt.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),gt("getPeers finished: %c",t)}}async getIPNS(t,r={}){gt("getIPNS starts: %s",t);let n=AbortSignal.timeout(this.timeout),o=Jr([this.shutDownController.signal,n,r.signal]);let i=se(),s=se();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.clientUrl}routing/v1/ipns/${t}`;try{await i.promise;let c={headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o},l=await this.#e(a,c);if(gt("getIPNS GET %s %d",a,l.status),l.status===404)throw new Bt("No matching records found");if(l.status===422)throw new Br("Request does not conform to schema or semantic constraints");if(l.body==null)throw new Qt("GET ipns response had no body");let u=await l.arrayBuffer(),f=new Uint8Array(u,0,u.byteLength);return r.validate!==!1&&await cf(on(t.multihash),f),ie(f)}catch(c){throw gt.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),gt("getIPNS finished: %s",t)}}async putIPNS(t,r,n={}){gt("putIPNS starts: %c",t);let o=AbortSignal.timeout(this.timeout),i=Jr([this.shutDownController.signal,o,n.signal]);let s=se(),a=se();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${t}`;try{await s.promise;let l=Ye(r),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:l,signal:i},f=await this.#e(c,u);if(gt("putIPNS PUT %s %d",c,f.status),f.status!==200)throw new Qt("PUT ipns response had status other than 200")}catch(l){throw gt.error("putIPNS PUT %s error:",c,l.stack),l}finally{i.clear(),a.resolve(),gt("putIPNS finished: %c",t)}}#t(t){try{let r=[],n=t.Addrs?.map(Ze)??[];return t.Protocols!=null&&r.push(...t.Protocols),t.Protocol!=null&&(r.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:Kc(t.ID),Addrs:n,Protocols:r}}catch(r){gt.error("could not conform record to peer schema",r)}}#r(t,r,n){if(r!=null||this.filterAddrs!=null){let o=r?.join(",")??this.filterAddrs?.join(",")??"";o!==""&&t.searchParams.set("filter-addrs",o)}if(n!=null||this.filterProtocols!=null){let o=n?.join(",")??this.filterProtocols?.join(",")??"";o!==""&&t.searchParams.set("filter-protocols",o)}}async#e(t,r){let n=r.method??"GET",o=`${n}-${t}`;if(n==="GET"){let c=await this.cache?.match(t);if(c!=null){if(parseInt(c.headers.get("x-cache-expires")??"0",10)>Date.now())return gt("returning cached response for %s",o),c;await this.cache?.delete(t)}}let i=this.inFlightRequests.get(o);if(i!=null){let c=await i;return gt("deduplicating outgoing request for %s",o),c.clone()}let s=fetch(t,r).then(async c=>{if(this.cache!=null&&c.ok&&n==="GET"){let l=Date.now()+this.cacheTTL,u=new Headers(c.headers);u.set("x-cache-expires",l.toString());let f=new Response(c.clone().body,{status:c.status,statusText:c.statusText,headers:u});await this.cache.put(t,f)}return c}).finally(()=>{this.inFlightRequests.delete(o)});return this.inFlightRequests.set(o,s),await s}};function yf(e,t={}){return new Eo(new URL(e),t)}function So(){return{filterProtocols:["unknown","transport-bitswap","transport-ipfs-gateway-http"],filterAddrs:["https","webtransport","webrtc","webrtc-direct","wss","tls"]}}var gf=H("/ipns/");function xf(e){return et(e.subarray(0,gf.byteLength),gf)}var Us=class{client;constructor(t,r={}){this.client=yf(t,r)}async provide(t,r){}async cancelReprovide(t,r){}async*findProviders(t,r){yield*go(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs,protocols:n.Protocols}))}async put(t,r,n){if(!xf(t))return;let o=be(t),i=G.createV1(114,o),s=ie(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!xf(t))throw new Bt("Not found");let n=be(t),o=G.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return Ye(i)}catch(i){throw i.name==="BadResponseError"?new Bt("Not found"):i}}async findPeer(t,r){let n=await yo(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Bt("Not found")}async*getClosestPeers(t,r){}};function wf(e,t){let r=t??So();return new Us(new URL(e),r)}var bf="[a-fA-F\\d:]",Le=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${bf})|(?<=${bf})(?=\\s|$))`:"",te="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",ut="[a-fA-F\\d]{1,4}",vo=`
|
|
4
4
|
(?:
|
|
5
|
-
(?:${
|
|
6
|
-
(?:${
|
|
7
|
-
(?:${
|
|
8
|
-
(?:${
|
|
9
|
-
(?:${
|
|
10
|
-
(?:${
|
|
11
|
-
(?:${
|
|
12
|
-
(?::(?:(?::${
|
|
5
|
+
(?:${ut}:){7}(?:${ut}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
|
|
6
|
+
(?:${ut}:){6}(?:${te}|:${ut}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
|
|
7
|
+
(?:${ut}:){5}(?::${te}|(?::${ut}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
|
|
8
|
+
(?:${ut}:){4}(?:(?::${ut}){0,1}:${te}|(?::${ut}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
|
|
9
|
+
(?:${ut}:){3}(?:(?::${ut}){0,2}:${te}|(?::${ut}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
|
|
10
|
+
(?:${ut}:){2}(?:(?::${ut}){0,3}:${te}|(?::${ut}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
|
|
11
|
+
(?:${ut}:){1}(?:(?::${ut}){0,4}:${te}|(?::${ut}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
|
|
12
|
+
(?::(?:(?::${ut}){0,5}:${te}|(?::${ut}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
|
|
13
13
|
)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
|
|
14
|
-
`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),
|
|
14
|
+
`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),kp=new RegExp(`(?:^${te}$)|(?:^${vo}$)`),Kp=new RegExp(`^${te}$`),Op=new RegExp(`^${vo}$`),Ns=e=>e&&e.exact?kp:new RegExp(`(?:${Le(e)}${te}${Le(e)})|(?:${Le(e)}${vo}${Le(e)})`,"g");Ns.v4=e=>e&&e.exact?Kp:new RegExp(`${Le(e)}${te}${Le(e)}`,"g");Ns.v6=e=>e&&e.exact?Op:new RegExp(`${Le(e)}${vo}${Le(e)}`,"g");var Rs=Ns;function Ls(e){let t=(...r)=>e(...r);return Object.defineProperty(t,"name",{value:`functionTimeout(${e.name||"<anonymous>"})`,configurable:!0}),t}function Ef(){return!1}var{toString:Fp}=Object.prototype;function Ds(e){return Fp.call(e)==="[object RegExp]"}var Sf={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function ks(e,t={}){if(!Ds(e))throw new TypeError("Expected a RegExp instance");let r=Object.keys(Sf).map(o=>(typeof t[o]=="boolean"?t[o]:e[o])?Sf[o]:"").join(""),n=new RegExp(t.source||e.source,r);return n.lastIndex=typeof t.lastIndex=="number"?t.lastIndex:e.lastIndex,n}function Ks(e,t,{timeout:r}={}){try{return Ls(()=>ks(e).test(t),{timeout:r})()}catch(n){if(Ef(n))return!1;throw n}}var Mp=15,Vp=45,vf={timeout:400};function Os(e){return e.length>Vp?!1:Ks(Rs.v6({exact:!0}),e,vf)}function Af(e){return e.length>Mp?!1:Ks(Rs.v4({exact:!0}),e,vf)}var If={http:"80",https:"443",ws:"80",wss:"443"},qp=["http","https","ws","wss"];function Tf(e,t){t=t??{};let r=t.defaultDnsType??"dns",{scheme:n,hostname:o,port:i,path:s}=$p(e),a=[Hp(o,r),zp(i,n),jp(n)];s!=null&&a.push(Gp(s));let c="/"+a.filter(l=>!!l).reduce((l,u)=>l.concat(u),[]).join("/");return Ze(c)}function $p(e){let[t]=e.split(":");qp.includes(t)||(e="http"+e.substring(t.length));let{protocol:r,hostname:n,port:o,pathname:i,search:s}=new URL(e);if(o==null||o===""){let c=Zp(t);c!=null&&(o=c),c==null&&r==="http:"&&(o="80")}let a;return i!=null&&i!==""&&i!=="/"&&(i.startsWith("/")&&(i=i.substring(1)),a=i),s!=null&&s!==""&&(a=a??"",a+=s),{scheme:t,hostname:n,port:o,path:a}}function Hp(e,t){if(!(e==null||e==="")){if(Af(e))return["ip4",e];if(Os(e))return["ip6",e];if(e[0]==="["){let r=e.substring(1,e.length-1);if(Os(r))return["ip6",r]}return[t,e]}}function zp(e,t){if(!(e==null||e===""))return t==="udp"?["udp",e]:["tcp",e]}function jp(e){if(e.match(/^tcp$|^udp$/)==null)return e==="https"?["/tls/http"]:e==="wss"?["/tls/ws"]:[e]}function Gp(e){if(!(e==null||e===""))return["http-path",encodeURIComponent(e)]}function Zp(e){if(!(e==null||e===""||If[e]==null))return If[e]}var Wp=["https://trustless-gateway.link","https://4everland.io"],Yp=2336;function Xp(e){return e=e.toString(),{id:rs(G.createV1(Yp,Lt.digest(H(e)))),multiaddrs:[Tf(e)]}}var Fs=class{gateways;shuffle;constructor(t={}){this.gateways=(t.gateways??Wp).map(r=>Xp(r)),this.shuffle=t.shuffle??!0}async*findProviders(t,r){yield*(this.shuffle?this.gateways.toSorted(()=>Math.random()>.5?1:-1):this.gateways).map(n=>({...n,protocols:["transport-ipfs-gateway-http"]}))}};function Cf(e={}){return new Fs(e)}var Ms=class{libp2p;constructor(t){this.libp2p=t}async provide(t,r){await this.libp2p.contentRouting.provide(t,r)}async cancelReprovide(t,r){await this.libp2p.contentRouting.cancelReprovide(t,r)}async*findProviders(t,r){yield*this.libp2p.contentRouting.findProviders(t,r)}async put(t,r,n){await this.libp2p.contentRouting.put(t,r,n)}async get(t,r){return this.libp2p.contentRouting.get(t,r)}async findPeer(t,r){return this.libp2p.peerRouting.findPeer(t,r)}async*getClosestPeers(t,r){yield*this.libp2p.peerRouting.getClosestPeers(t,r)}};function Bf(e){return new Ms(e)}return Of(Jp);})();
|
|
15
15
|
/*! Bundled license information:
|
|
16
16
|
|
|
17
17
|
@noble/hashes/esm/utils.js:
|
|
18
18
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
19
19
|
|
|
20
20
|
@noble/curves/esm/abstract/utils.js:
|
|
21
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
22
|
-
|
|
23
21
|
@noble/curves/esm/abstract/modular.js:
|
|
24
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
25
|
-
|
|
26
22
|
@noble/curves/esm/abstract/curve.js:
|
|
27
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
28
|
-
|
|
29
23
|
@noble/curves/esm/abstract/edwards.js:
|
|
30
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
31
|
-
|
|
32
24
|
@noble/curves/esm/ed25519.js:
|
|
33
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
34
|
-
|
|
35
25
|
@noble/curves/esm/abstract/weierstrass.js:
|
|
36
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
37
|
-
|
|
38
26
|
@noble/curves/esm/_shortw_utils.js:
|
|
39
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
40
|
-
|
|
41
27
|
@noble/curves/esm/secp256k1.js:
|
|
42
28
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
43
29
|
*/
|
|
44
30
|
return HeliaRouters}));
|
|
31
|
+
//# sourceMappingURL=index.min.js.map
|