@helia/routers 1.1.1-ac4bdb8 → 1.1.1-e567717

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,11 +1,11 @@
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 Sh=Object.create;var Gn=Object.defineProperty;var Ih=Object.getOwnPropertyDescriptor;var Rh=Object.getOwnPropertyNames;var kh=Object.getPrototypeOf,Th=Object.prototype.hasOwnProperty;var jn=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ge=(r,e)=>{for(var t in e)Gn(r,t,{get:e[t],enumerable:!0})},ec=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Rh(e))!Th.call(r,o)&&o!==t&&Gn(r,o,{get:()=>e[o],enumerable:!(n=Ih(e,o))||n.enumerable});return r};var nr=(r,e,t)=>(t=r!=null?Sh(kh(r)):{},ec(e||!r||!r.__esModule?Gn(t,"default",{value:r,enumerable:!0}):t,r)),Nh=r=>ec(Gn({},"__esModule",{value:!0}),r);var Iu=jn(Gr=>{"use strict";var $p="[object ArrayBuffer]",It=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===$p}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let n=r.toUint8Array(e),o=r.toUint8Array(t);if(n.length!==o.byteLength)return!1;for(let i=0;i<n.length;i++)if(n[i]!==o[i])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(let s of t)n+=s.byteLength;let o=new Uint8Array(n),i=0;for(let s of t){let a=this.toUint8Array(s);o.set(a,i),i+=a.length}return e[e.length-1]instanceof Function?this.toView(o,e[e.length-1]):o.buffer}},oa="string",Hp=/^[0-9a-f]+$/i,Kp=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,qp=/^[a-zA-Z0-9-_]+$/,vo=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n.buffer}static toString(e){let t=It.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}},je=class{static toString(e,t=!1){let n=It.toArrayBuffer(e),o=new DataView(n),i="";for(let s=0;s<n.byteLength;s+=2){let a=o.getUint16(s,t);i+=String.fromCharCode(a)}return i}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),o=new DataView(n);for(let i=0;i<e.length;i++)o.setUint16(i*2,e.charCodeAt(i),t);return n}},Bo=class r{static isHex(e){return typeof e===oa&&Hp.test(e)}static isBase64(e){return typeof e===oa&&Kp.test(e)}static isBase64Url(e){return typeof e===oa&&qp.test(e)}static ToString(e,t="utf8"){let n=It.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return je.toString(n,!0);case"utf16":case"utf16be":return je.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return je.fromString(e,!0);case"utf16":case"utf16be":return je.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=It.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return vo.fromString(e);case"utf16":case"utf16be":return je.fromString(e);case"utf16le":case"usc2":return je.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return vo.toString(e);case"utf16":case"utf16be":return je.toString(e);case"utf16le":case"usc2":return je.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);return n.buffer}static ToBinary(e){let t=It.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=It.toUint8Array(e),n="",o=t.length;for(let i=0;i<o;i++){let s=t[i];s<16&&(n+="0"),n+=s.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);let n=new Uint8Array(t.length/2);for(let o=0;o<t.length;o=o+2){let i=t.slice(o,o+2);n[o/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(e,t=!1){return je.toString(e,t)}static FromUtf16String(e,t=!1){return je.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};Bo.DEFAULT_UTF8_ENCODING="utf8";function zp(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let i in o)t[i]=o[i]}return t}function Gp(...r){let e=r.map(o=>o.byteLength).reduce((o,i)=>o+i),t=new Uint8Array(e),n=0;return r.map(o=>new Uint8Array(o)).forEach(o=>{for(let i of o)t[n++]=i}),t.buffer}function jp(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<r.byteLength;o++)if(t[o]!==n[o])return!1;return!0}Gr.BufferSourceConverter=It;Gr.Convert=Bo;Gr.assign=zp;Gr.combine=Gp;Gr.isEqual=jp});var hi=jn((d2,Ul)=>{"use strict";function _l(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function Rm(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return _l(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),_l(new o,t)}}Ul.exports=Rm});var xa=jn((b2,ba)=>{var w2=function(){typeof ba<"u"&&(ba.exports=h);var r=86400,e=3200,t=146097*e/400,n=r*t,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",f=Math.trunc||function(b){var T=b-b%1;return T==0&&(b<0||b===0&&1/b!=1/0)?-0:T},u=h.prototype,l=(h.fromDate=function(b){return new h(+b)},h.fromInt64BE=O(0,1,2,3,0,4),h.fromInt64LE=O(3,2,1,0,4,0),h.fromString=function(N){var T,V=new h,N=(N+="").replace(/^\s*[+\-]?\d+/,function(H){var H=+H,S=1970+(H-1970)%400;return V.year=H-S,S}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(F,H,S){return H<0&&(S*=-1),T=6e4*(60*+H+ +S),""}).replace(/\.\d+$/,function(F){return V.nano=+(F+c).substr(1,9),""}).split(/\D+/);if(1<N.length?N[1]--:N[1]=0,V.time=T=Date.UTC.apply(Date,N)-(T||0),isNaN(T))throw new TypeError("Invalid Date");return g(V)},h.fromTimeT=function(b){return E(b,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(b){return this.nano+=+b||0,this},u.getNano=function(){var b=g(this);return(b.time%1e3*a+ +b.nano+1e9)%1e9},u.getTimeT=function(){var T=g(this),b=Math.floor(T.time/1e3),T=T.year;return T&&(b+=T*t*r/e),b},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return v(g(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(b){var T=this,V=T.toDate(),N={H:function(){return k(V.getUTCHours())},L:function(){return L(V.getUTCMilliseconds(),3)},M:function(){return k(V.getUTCMinutes())},N:function(){return L(T.getNano(),9)},S:function(){return k(V.getUTCSeconds())},Y:function(){var F=T.getYear();return 999999<F?"+"+F:9999<F?"+"+L(F,6):0<=F?L(F,4):-999999<=F?"-"+L(-F,6):F},a:function(){return x[V.getUTCDay()]},b:function(){return d[V.getUTCMonth()]},d:function(){return k(V.getUTCDate())},e:function(){return function(F){return(9<F?"":" ")+(0|F)}(V.getUTCDate())},m:function(){return k(V.getUTCMonth()+1)}};return function F(H){return H.replace(/%./g,function(S){var p=S[1],m=y[p],p=N[p];return m?F(m):p?p():S})}(b||l)},u.writeInt64BE=B(0,1,2,3,0,4),u.writeInt64LE=B(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"],x=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],y={"%":"%",F:"%Y-%m-%d",n:`
3
- `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return h;function h(b,T,V){var N=this;if(!(N instanceof h))return new h(b,T,V);N.time=+b||0,N.nano=+T||0,N.year=+V||0,g(N)}function g(b){var T,V,N,F=b.year,H=b.time,S=b.nano,m=((S<0||a<=S)&&(S-=(V=Math.floor(S/a))*a,H+=V,V=1),F%e);return(H<-i||i<H||m)&&((T=f(H/o))&&(F+=T*e,H-=T*o),(N=v(H)).setUTCFullYear(m+N.getUTCFullYear()),N=(H=+N)+(T=f((F-=m)/e))*o,T&&-i<=N&&N<=i&&(F-=T*e,H=N),V=1),V&&(b.year=F,b.time=H,b.nano=S),b}function v(b){var T=new Date(0);return T.setTime(b),T}function E(F,N){F=+F||0;var V=f((N=(N|0)*s)/n)+f(F/n),N=N%n+F%n,F=f(N/n);return F&&(V+=F,N-=F*n),new h(1e3*N,0,V*e)}function B(b,T,V,N,F,H){return function(m,p){var R=g(this);m=m||new Array(8),U(m,p|=0);var P=Math.floor(R.time/1e3),R=R.year*(t*r/e),A=f(R/s)+f(P/s),R=R%s+P%s,P=Math.floor(R/s);return P&&(A+=P,R-=P*s),S(m,p+F,A),S(m,p+H,R),m};function S(m,p,A){m[p+b]=A>>24&255,m[p+T]=A>>16&255,m[p+V]=A>>8&255,m[p+N]=255&A}}function O(b,T,V,N,F,H){return function(m,p){U(m,p|=0);var A=S(m,p+F);return E(S(m,p+H),A)};function S(m,p){return 16777216*m[p+b]+(m[p+T]<<16|m[p+V]<<8|m[p+N])}}function U(b,T){if(b=b&&b.length,b==null)throw new TypeError("Invalid Buffer");if(b<T+8)throw new RangeError("Out of range")}function k(b){return(9<b?"":"0")+(0|b)}function L(b,T){return(c+(0|b)).substr(-T)}}()});var Xf=jn((cv,Na)=>{"use strict";var hg=Object.prototype.hasOwnProperty,Ce="~";function $n(){}Object.create&&($n.prototype=Object.create(null),new $n().__proto__||(Ce=!1));function dg(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Jf(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new dg(t,n||r,o),s=Ce?Ce+e:e;return r._events[s]?r._events[s].fn?r._events[s]=[r._events[s],i]:r._events[s].push(i):(r._events[s]=i,r._eventsCount++),r}function Ri(r,e){--r._eventsCount===0?r._events=new $n:delete r._events[e]}function Re(){this._events=new $n,this._eventsCount=0}Re.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)hg.call(t,n)&&e.push(Ce?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Re.prototype.listeners=function(e){var t=Ce?Ce+e:e,n=this._events[t];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};Re.prototype.listenerCount=function(e){var t=Ce?Ce+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Re.prototype.emit=function(e,t,n,o,i,s){var a=Ce?Ce+e:e;if(!this._events[a])return!1;var c=this._events[a],f=arguments.length,u,l;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,o),!0;case 5:return c.fn.call(c.context,t,n,o,i),!0;case 6:return c.fn.call(c.context,t,n,o,i,s),!0}for(l=1,u=new Array(f-1);l<f;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var d=c.length,x;for(l=0;l<d;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),f){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;case 4:c[l].fn.call(c[l].context,t,n,o);break;default:if(!u)for(x=1,u=new Array(f-1);x<f;x++)u[x-1]=arguments[x];c[l].fn.apply(c[l].context,u)}}return!0};Re.prototype.on=function(e,t,n){return Jf(this,e,t,n,!1)};Re.prototype.once=function(e,t,n){return Jf(this,e,t,n,!0)};Re.prototype.removeListener=function(e,t,n,o){var i=Ce?Ce+e:e;if(!this._events[i])return this;if(!t)return Ri(this,i),this;var s=this._events[i];if(s.fn)s.fn===t&&(!o||s.once)&&(!n||s.context===n)&&Ri(this,i);else{for(var a=0,c=[],f=s.length;a<f;a++)(s[a].fn!==t||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:Ri(this,i)}return this};Re.prototype.removeAllListeners=function(e){var t;return e?(t=Ce?Ce+e:e,this._events[t]&&Ri(this,t)):(this._events=new $n,this._eventsCount=0),this};Re.prototype.off=Re.prototype.removeListener;Re.prototype.addListener=Re.prototype.on;Re.prefixed=Ce;Re.EventEmitter=Re;typeof Na<"u"&&(Na.exports=Re)});var Og={};ge(Og,{delegatedHTTPRouting:()=>ch,httpGatewayRouting:()=>gh,libp2pRouting:()=>yh});var tc=Symbol.for("@libp2p/content-routing");var wr=Symbol.for("@libp2p/peer-id");function rc(r){return r!=null&&!!r[wr]}var nc=Symbol.for("@libp2p/peer-routing");var D=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var br=(r,...e)=>{try{[...e]}catch{}};var Fi={};ge(Fi,{base32:()=>Xe,base32hex:()=>Ph,base32hexpad:()=>Mh,base32hexpadupper:()=>$h,base32hexupper:()=>Fh,base32pad:()=>Vh,base32padupper:()=>Dh,base32upper:()=>lc,base32z:()=>Hh});var Hg=new Uint8Array(0);function oc(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function bt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function ic(r){return new TextEncoder().encode(r)}function sc(r){return new TextDecoder().decode(r)}function Ch(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=o}var a=r.length,c=r.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var h=0,g=0,v=0,E=y.length;v!==E&&y[v]===0;)v++,h++;for(var B=(E-v)*u+1>>>0,O=new Uint8Array(B);v!==E;){for(var U=y[v],k=0,L=B-1;(U!==0||k<g)&&L!==-1;L--,k++)U+=256*O[L]>>>0,O[L]=U%a>>>0,U=U/a>>>0;if(U!==0)throw new Error("Non-zero carry");g=k,v++}for(var b=B-g;b!==B&&O[b]===0;)b++;for(var T=c.repeat(h);b<B;++b)T+=r.charAt(O[b]);return T}function d(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;var h=0;if(y[h]!==" "){for(var g=0,v=0;y[h]===c;)g++,h++;for(var E=(y.length-h)*f+1>>>0,B=new Uint8Array(E);y[h];){var O=t[y.charCodeAt(h)];if(O===255)return;for(var U=0,k=E-1;(O!==0||U<v)&&k!==-1;k--,U++)O+=a*B[k]>>>0,B[k]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");v=U,h++}if(y[h]!==" "){for(var L=E-v;L!==E&&B[L]===0;)L++;for(var b=new Uint8Array(g+(E-L)),T=g;L!==E;)b[T++]=B[L++];return b}}}function x(y){var h=d(y);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:d,decode:x}}var _h=Ch,Uh=_h,cc=Uh;var Oi=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Vi=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return uc(this,e)}},Di=class{decoders;constructor(e){this.decoders=e}or(e){return uc(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function uc(r,e){return new Di({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Pi=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Oi(e,t,n),this.decoder=new Vi(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function xr({name:r,prefix:e,encode:t,decode:n}){return new Pi(r,e,t,n)}function Lt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=cc(t,r);return xr({prefix:e,name:r,encode:n,decode:i=>bt(o(i))})}function Lh(r,e,t,n){let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*t/8|0),a=0,c=0,f=0;for(let u=0;u<i;++u){let l=o[r[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|l,a+=t,a>=8&&(a-=8,s[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function Oh(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,i="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>t;)s-=t,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<t-s]),n)for(;i.length*t&7;)i+="=";return i}function ie({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return xr({prefix:e,name:r,encode(o){return Oh(o,n,t)},decode(o){return Lh(o,n,t,r)}})}var Xe=ie({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),lc=ie({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Vh=ie({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Dh=ie({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ph=ie({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Fh=ie({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Mh=ie({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),$h=ie({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Hh=ie({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Mi={};ge(Mi,{base58btc:()=>ce,base58flickr:()=>Kh});var ce=Lt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Kh=Lt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var $i={};ge($i,{base64:()=>sn,base64pad:()=>qh,base64url:()=>zh,base64urlpad:()=>Gh});var sn=ie({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qh=ie({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),zh=ie({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Gh=ie({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function jh(r,e){try{if(typeof r=="string"&&r.length>0)return Yh(r);if(typeof r=="number"&&isFinite(r))return e?.long?Wh(r):Zh(r);throw new Error("Value is not a string or number.")}catch(t){let n=Jh(t)?`${t.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function Yh(r){if(r=String(r),r.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(!e)return NaN;let t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*315576e5;case"weeks":case"week":case"w":return t*6048e5;case"days":case"day":case"d":return t*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return t*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return t*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return t*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var Zn=jh;function Zh(r){let e=Math.abs(r);return e>=864e5?`${Math.round(r/864e5)}d`:e>=36e5?`${Math.round(r/36e5)}h`:e>=6e4?`${Math.round(r/6e4)}m`:e>=1e3?`${Math.round(r/1e3)}s`:`${r}ms`}function Wh(r){let e=Math.abs(r);return e>=864e5?Yn(r,e,864e5,"day"):e>=36e5?Yn(r,e,36e5,"hour"):e>=6e4?Yn(r,e,6e4,"minute"):e>=1e3?Yn(r,e,1e3,"second"):`${r} ms`}function Yn(r,e,t,n){let o=e>=t*1.5;return`${Math.round(r/t)} ${n}${o?"s":""}`}function Jh(r){return typeof r=="object"&&r!==null&&"message"in r}function Hi(r){t.debug=t,t.default=t,t.coerce=c,t.disable=i,t.enable=o,t.enabled=s,t.humanize=Zn,t.destroy=f,Object.keys(r).forEach(u=>{t[u]=r[u]}),t.names=[],t.skips=[],t.formatters={};function e(u){let l=0;for(let d=0;d<u.length;d++)l=(l<<5)-l+u.charCodeAt(d),l|=0;return t.colors[Math.abs(l)%t.colors.length]}t.selectColor=e;function t(u){let l,d=null,x,y;function h(...g){if(!h.enabled)return;let v=h,E=Number(new Date),B=E-(l||E);v.diff=B,v.prev=l,v.curr=E,l=E,g[0]=t.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let O=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(k,L)=>{if(k==="%%")return"%";O++;let b=t.formatters[L];if(typeof b=="function"){let T=g[O];k=b.call(v,T),g.splice(O,1),O--}return k}),t.formatArgs.call(v,g),(v.log||t.log).apply(v,g)}return h.namespace=u,h.useColors=t.useColors(),h.color=t.selectColor(u),h.extend=n,h.destroy=t.destroy,Object.defineProperty(h,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(x!==t.namespaces&&(x=t.namespaces,y=t.enabled(u)),y),set:g=>{d=g}}),typeof t.init=="function"&&t.init(h),h}function n(u,l){let d=t(this.namespace+(typeof l>"u"?":":l)+u);return d.log=this.log,d}function o(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let l,d=(typeof u=="string"?u:"").split(/[\s,]+/),x=d.length;for(l=0;l<x;l++)d[l]&&(u=d[l].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.substr(1)+"$")):t.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...t.names.map(a),...t.skips.map(a).map(l=>"-"+l)].join(",");return t.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,d;for(l=0,d=t.skips.length;l<d;l++)if(t.skips[l].test(u))return!1;for(l=0,d=t.names.length;l<d;l++)if(t.names[l].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.setupFormatters(t.formatters),t.enable(t.load()),t}var Wn=od(),Xh=["#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 Qh(){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 ed(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Zn(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}var td=console.debug??console.log??(()=>{});function rd(r){try{r?Wn?.setItem("debug",r):Wn?.removeItem("debug")}catch{}}function nd(){let r;try{r=Wn?.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function od(){try{return localStorage}catch{}}function id(r){r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}var fc=Hi({formatArgs:ed,save:rd,load:nd,useColors:Qh,setupFormatters:id,colors:Xh,storage:Wn,log:td});var Pe=fc;Pe.formatters.b=r=>r==null?"undefined":ce.baseEncode(r);Pe.formatters.t=r=>r==null?"undefined":Xe.baseEncode(r);Pe.formatters.m=r=>r==null?"undefined":sn.baseEncode(r);Pe.formatters.p=r=>r==null?"undefined":r.toString();Pe.formatters.c=r=>r==null?"undefined":r.toString();Pe.formatters.k=r=>r==null?"undefined":r.toString();Pe.formatters.a=r=>r==null?"undefined":r.toString();function sd(r){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=r,e.destroy=()=>!0,e.extend=()=>e,e}function Ot(r){let e=sd(`${r}:trace`);return Pe.enabled(`${r}:trace`)&&Pe.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=Pe(`${r}:trace`)),Object.assign(Pe(r),{error:Pe(`${r}:error`),trace:e})}var Ki={};ge(Ki,{base10:()=>ad});var ad=Lt({prefix:"9",name:"base10",alphabet:"0123456789"});var qi={};ge(qi,{base16:()=>cd,base16upper:()=>ud});var cd=ie({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ud=ie({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var zi={};ge(zi,{base2:()=>ld});var ld=ie({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Gi={};ge(Gi,{base256emoji:()=>md});var hc=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),fd=hc.reduce((r,e,t)=>(r[t]=e,r),[]),hd=hc.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function dd(r){return r.reduce((e,t)=>(e+=fd[t],e),"")}function pd(r){let e=[];for(let t of r){let n=hd[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var md=xr({prefix:"\u{1F680}",name:"base256emoji",encode:dd,decode:pd});var ji={};ge(ji,{base36:()=>Jn,base36upper:()=>gd});var Jn=Lt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),gd=Lt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Yi={};ge(Yi,{base8:()=>yd});var yd=ie({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Zi={};ge(Zi,{identity:()=>wd});var wd=xr({prefix:"\0",name:"identity",encode:r=>sc(r),decode:r=>ic(r)});var yy=new TextEncoder,wy=new TextDecoder;var Ji={};ge(Ji,{identity:()=>Fe});var Ed=mc,dc=128,vd=127,Bd=~vd,Ad=Math.pow(2,31);function mc(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Ad;)e[t++]=r&255|dc,r/=128;for(;r&Bd;)e[t++]=r&255|dc,r>>>=7;return e[t]=r|0,mc.bytes=t-n+1,e}var Sd=Wi,Id=128,pc=127;function Wi(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw Wi.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&pc)<<o:(s&pc)*Math.pow(2,o),o+=7}while(s>=Id);return Wi.bytes=i-n,t}var Rd=Math.pow(2,7),kd=Math.pow(2,14),Td=Math.pow(2,21),Nd=Math.pow(2,28),Cd=Math.pow(2,35),_d=Math.pow(2,42),Ud=Math.pow(2,49),Ld=Math.pow(2,56),Od=Math.pow(2,63),Vd=function(r){return r<Rd?1:r<kd?2:r<Td?3:r<Nd?4:r<Cd?5:r<_d?6:r<Ud?7:r<Ld?8:r<Od?9:10},Dd={encode:Ed,decode:Sd,encodingLength:Vd},Pd=Dd,an=Pd;function cn(r,e=0){return[an.decode(r,e),an.decode.bytes]}function Er(r,e,t=0){return an.encode(r,e,t),e}function vr(r){return an.encodingLength(r)}function ft(r,e){let t=e.byteLength,n=vr(r),o=n+vr(t),i=new Uint8Array(o+t);return Er(r,i,0),Er(t,i,n),i.set(e,o),new Br(r,t,e,i)}function Vt(r){let e=bt(r),[t,n]=cn(e),[o,i]=cn(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Br(t,o,s,e)}function gc(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&oc(r.bytes,t.bytes)}}var Br=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var yc=0,Fd="identity",wc=bt;function Md(r){return ft(yc,wc(r))}var Fe={code:yc,name:Fd,encode:wc,digest:Md};var es={};ge(es,{sha256:()=>Ee,sha512:()=>$d});function Qi({name:r,code:e,encode:t}){return new Xi(r,e,t)}var Xi=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?ft(this.code,t):t.then(n=>ft(this.code,n))}else throw Error("Unknown type, must be binary type")}};function xc(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Ee=Qi({name:"sha2-256",code:18,encode:xc("SHA-256")}),$d=Qi({name:"sha2-512",code:19,encode:xc("SHA-512")});function Ec(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Kd(t,ts(r),e??ce.encoder);default:return qd(t,ts(r),e??Xe.encoder)}}var vc=new WeakMap;function ts(r){let e=vc.get(r);if(e==null){let t=new Map;return vc.set(r,t),t}return e}var ye=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==un)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==zd)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=ft(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&gc(e.multihash,n.multihash)}toString(e){return Ec(this,e)}toJSON(){return{"/":Ec(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:i,bytes:s}=t;return new r(n,o,i,s??Bc(n,o,i.bytes))}else if(t[Gd]===!0){let{version:n,multihash:o,code:i}=t,s=Vt(o);return r.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==un)throw new Error(`Version 0 CID must use dag-pb (code: ${un}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Bc(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,un,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=bt(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new Br(t.multihashCode,t.digestSize,i,o);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,d]=cn(e.subarray(t));return t+=d,l},o=n(),i=un;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,a=n(),c=n(),f=t+c,u=f-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=Hd(e,t),i=r.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ts(i).set(n,e),i}};function Hd(r,e){switch(r[0]){case"Q":{let t=e??ce;return[ce.prefix,t.decode(`${ce.prefix}${r}`)]}case ce.prefix:{let t=e??ce;return[ce.prefix,t.decode(r)]}case Xe.prefix:{let t=e??Xe;return[Xe.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Kd(r,e,t){let{prefix:n}=t;if(n!==ce.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o}function qd(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o}var un=112,zd=18;function Bc(r,e,t){let n=vr(r),o=n+vr(e),i=new Uint8Array(o+t.byteLength);return Er(r,i,0),Er(e,i,n),i.set(t,o),i}var Gd=Symbol.for("@ipld/js-cid/CID");var Pt={...Zi,...zi,...Yi,...Ki,...qi,...Fi,...ji,...Mi,...$i,...Gi},Fy={...es,...Ji};function se(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function Qe(r=0){return new Uint8Array(r)}function Sc(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Ac=Sc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),rs=Sc("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=Qe(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),jd={utf8:Ac,"utf-8":Ac,hex:Pt.base16,latin1:rs,ascii:rs,binary:rs,...Pt},Qn=jd;function z(r,e="utf8"){let t=Qn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function G(r,e="utf8"){let t=Qn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var Rc=Symbol.for("nodejs.util.inspect.custom"),Ic=Object.values(Pt).map(r=>r.decoder).reduce((r,e)=>r.or(e),Pt.identity.decoder),kc=114,is=36,ss=37,ln=class{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[wr]=!0;toString(){return this.string==null&&(this.string=ce.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return ye.createV1(kc,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return se(this.multihash.bytes,e);if(typeof e=="string")return as(e).equals(this);if(e?.multihash?.bytes!=null)return se(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[Rc](){return`PeerId(${this.toString()})`}},Ar=class extends ln{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Sr=class extends ln{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Ir=class extends ln{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}},ns=2336,os=class{type="url";multihash;privateKey;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Fe.digest(z(this.url))}[Rc](){return`PeerId(${this.url})`}[wr]=!0;toString(){return this.toCID().toString()}toCID(){return ye.createV1(ns,this.multihash)}toBytes(){return this.toCID().bytes}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=G(e)),e.toString()===this.toString())}};function as(r,e){if(e=e??Ic,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=Vt(ce.decode(`z${r}`));return r.startsWith("12D")?new Sr({multihash:t}):r.startsWith("16U")?new Ir({multihash:t}):new Ar({multihash:t})}return fn(Ic.decode(r))}function fn(r){try{let e=Vt(r);if(e.code===Fe.code){if(e.digest.length===is)return new Sr({multihash:e});if(e.digest.length===ss)return new Ir({multihash:e})}if(e.code===Ee.code)return new Ar({multihash:e})}catch{return Yd(ye.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Yd(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==kc&&r.code!==ns)throw new Error("Supplied PeerID CID is invalid");if(r.code===ns){let t=G(r.multihash.digest);return new os(new URL(t))}let e=r.multihash;if(e.code===Ee.code)return new Ar({multihash:r.multihash});if(e.code===Fe.code){if(e.digest.length===is)return new Sr({multihash:r.multihash});if(e.digest.length===ss)return new Ir({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function Tc(r,e){return r.length===is?new Sr({multihash:ft(Fe.code,r),privateKey:e}):r.length===ss?new Ir({multihash:ft(Fe.code,r),privateKey:e}):new Ar({multihash:await Ee.digest(r),publicKey:r,privateKey:e})}var Zd=Math.pow(2,7),Wd=Math.pow(2,14),Jd=Math.pow(2,21),cs=Math.pow(2,28),us=Math.pow(2,35),ls=Math.pow(2,42),fs=Math.pow(2,49),X=128,Ae=127;function Ue(r){if(r<Zd)return 1;if(r<Wd)return 2;if(r<Jd)return 3;if(r<cs)return 4;if(r<us)return 5;if(r<ls)return 6;if(r<fs)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function hs(r,e,t=0){switch(Ue(r)){case 8:e[t++]=r&255|X,r/=128;case 7:e[t++]=r&255|X,r/=128;case 6:e[t++]=r&255|X,r/=128;case 5:e[t++]=r&255|X,r/=128;case 4:e[t++]=r&255|X,r>>>=7;case 3:e[t++]=r&255|X,r>>>=7;case 2:e[t++]=r&255|X,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Xd(r,e,t=0){switch(Ue(r)){case 8:e.set(t++,r&255|X),r/=128;case 7:e.set(t++,r&255|X),r/=128;case 6:e.set(t++,r&255|X),r/=128;case 5:e.set(t++,r&255|X),r/=128;case 4:e.set(t++,r&255|X),r>>>=7;case 3:e.set(t++,r&255|X),r>>>=7;case 2:e.set(t++,r&255|X),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function ds(r,e){let t=r[e],n=0;if(n+=t&Ae,t<X||(t=r[e+1],n+=(t&Ae)<<7,t<X)||(t=r[e+2],n+=(t&Ae)<<14,t<X)||(t=r[e+3],n+=(t&Ae)<<21,t<X)||(t=r[e+4],n+=(t&Ae)*cs,t<X)||(t=r[e+5],n+=(t&Ae)*us,t<X)||(t=r[e+6],n+=(t&Ae)*ls,t<X)||(t=r[e+7],n+=(t&Ae)*fs,t<X))return n;throw new RangeError("Could not decode varint")}function Qd(r,e){let t=r.get(e),n=0;if(n+=t&Ae,t<X||(t=r.get(e+1),n+=(t&Ae)<<7,t<X)||(t=r.get(e+2),n+=(t&Ae)<<14,t<X)||(t=r.get(e+3),n+=(t&Ae)<<21,t<X)||(t=r.get(e+4),n+=(t&Ae)*cs,t<X)||(t=r.get(e+5),n+=(t&Ae)*us,t<X)||(t=r.get(e+6),n+=(t&Ae)*ls,t<X)||(t=r.get(e+7),n+=(t&Ae)*fs,t<X))return n;throw new RangeError("Could not decode varint")}function Rr(r,e,t=0){return e==null&&(e=Qe(Ue(r))),e instanceof Uint8Array?hs(r,e,t):Xd(r,e,t)}function or(r,e=0){return r instanceof Uint8Array?ds(r,e):Qd(r,e)}function ke(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=Qe(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}var eo=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}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(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let d=Number.parseInt(l,e);if(!Number.isNaN(d))return d});if(u===void 0)break;if(i*=e,i+=u,i>f||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2],t[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];t[o]=i>>8,t[o+1]=i&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=e(i.subarray(0,s));return t.set(i.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Cc=45,e0=15,kr=new eo;function ps(r){if(!(r.length>e0))return kr.new(r).parseWith(()=>kr.readIPv4Addr())}function ms(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Cc))return kr.new(r).parseWith(()=>kr.readIPv6Addr())}function to(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Cc))return kr.new(r).parseWith(()=>kr.readIPAddr())}var Ew=parseInt("0xFFFF",16),vw=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Lc(r){return!!ps(r)}function Oc(r){return!!ms(r)}function ro(r){return!!to(r)}var Vc=Lc,i0=Oc,gs=function(r){let e=0;if(r=r.toString().trim(),Vc(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(i0(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=Vc(t[n]),s;i&&(s=gs(t[n]),t[n]=G(s.slice(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,G(s.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let i=[n,1];for(n=9-t.length;n>0;n--)i.push("0");t.splice.apply(t,i)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){let i=parseInt(t[n],16);o[e++]=i>>8&255,o[e++]=i&255}return o}throw new Error("invalid ip address")},Dc=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let i=0;i<t;i++)o.push(r[e+i]);return o.join(".")}if(t===16){let o=[];for(let i=0;i<t;i+=2)o.push(n.getUint16(e+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Tr={},ys={},a0=[[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"]];a0.forEach(r=>{let e=c0(...r);ys[e.code]=e,Tr[e.name]=e});function c0(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function ee(r){if(typeof r=="number"){if(ys[r]!=null)return ys[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Tr[r]!=null)return Tr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var ib=ee("ip4"),sb=ee("ip6"),ab=ee("ipcidr");function Es(r,e){switch(ee(r).code){case 4:case 41:return l0(e);case 42:return xs(e);case 6:case 273:case 33:case 132:return Mc(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return xs(e);case 421:return p0(e);case 444:return Fc(e);case 445:return Fc(e);case 466:return d0(e);case 481:return globalThis.encodeURIComponent(xs(e));default:return G(e,"base16")}}function vs(r,e){switch(ee(r).code){case 4:return Pc(e);case 41:return Pc(e);case 42:return bs(e);case 6:case 273:case 33:case 132:return Bs(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return bs(e);case 421:return f0(e);case 444:return m0(e);case 445:return g0(e);case 466:return h0(e);case 481:return bs(globalThis.decodeURIComponent(e));default:return z(e,"base16")}}var ws=Object.values(Pt).map(r=>r.decoder),u0=function(){let r=ws[0].or(ws[1]);return ws.slice(2).forEach(e=>r=r.or(e)),r}();function Pc(r){if(!ro(r))throw new Error("invalid ip address");return gs(r)}function l0(r){let e=Dc(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!ro(e))throw new Error("invalid ip address");return e}function Bs(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function Mc(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function bs(r){let e=z(r),t=Uint8Array.from(Rr(e.length));return ke([t,e],t.length+e.length)}function xs(r){let e=or(r);if(r=r.slice(Ue(e)),r.length!==e)throw new Error("inconsistent lengths");return G(r)}function f0(r){let e;r[0]==="Q"||r[0]==="1"?e=Vt(ce.decode(`z${r}`)).bytes:e=ye.parse(r).multihash.bytes;let t=Uint8Array.from(Rr(e.length));return ke([t,e],t.length+e.length)}function h0(r){let e=u0.decode(r),t=Uint8Array.from(Rr(e.length));return ke([t,e],t.length+e.length)}function d0(r){let e=or(r),t=r.slice(Ue(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+G(t,"base64url")}function p0(r){let e=or(r),t=r.slice(Ue(e));if(t.length!==e)throw new Error("inconsistent lengths");return G(t,"base58btc")}function m0(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=Xe.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Bs(n);return ke([t,o],t.length+o.length)}function g0(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=Xe.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Bs(n);return ke([t,o],t.length+o.length)}function Fc(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=G(e,"base32"),o=Mc(t);return`${n}:${o}`}function $c(r){r=As(r);let e=[],t=[],n=null,o=r.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=ee(s);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(i++,i>=o.length)throw Kc("invalid address: "+r);if(a.path===!0){n=As(o.slice(i).join("/")),e.push([a.code,vs(a.code,n)]),t.push([a.code,n]);break}let c=vs(a.code,o[i]);e.push([a.code,c]),t.push([a.code,Es(a.code,c)])}return{string:Hc(t),bytes:Is(e),tuples:e,stringTuples:t,path:n}}function Ss(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let i=or(r,o),s=Ue(i),a=ee(i),c=y0(a,r.slice(o+s));if(c===0){e.push([i]),t.push([i]),o+=s;continue}let f=r.slice(o+s,o+s+c);if(o+=c+s,o>r.length)throw Kc("Invalid address Uint8Array: "+G(r,"base16"));e.push([i,f]);let u=Es(i,f);if(t.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Hc(t),tuples:e,stringTuples:t,path:n}}function Hc(r){let e=[];return r.map(t=>{let n=ee(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),As(e.join("/"))}function Is(r){return ke(r.map(e=>{let t=ee(e[0]),n=Uint8Array.from(Rr(t.code));return e.length>1&&e[1]!=null&&(n=ke([n,e[1]])),n}))}function y0(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=or(e instanceof Uint8Array?e:Uint8Array.from(e));return t+Ue(t)}}function As(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function Kc(r){return new Error("Error parsing address: "+r)}var w0=Symbol.for("nodejs.util.inspect.custom"),Rs=Symbol.for("@multiformats/js-multiaddr/multiaddr"),b0=[ee("dns").code,ee("dns4").code,ee("dns6").code,ee("dnsaddr").code],no=class r{bytes;#e;#r;#i;#a;[Rs]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=Ss(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=$c(e)}else if(zc(e))t=Ss(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#r=t.tuples,this.#i=t.stringTuples,this.#a=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,o,i="",s=ee("tcp"),a=ee("udp"),c=ee("ip4"),f=ee("ip6"),u=ee("dns6"),l=ee("ip6zone");for(let[x,y]of this.stringTuples())x===l.code&&(i=`%${y??""}`),b0.includes(x)&&(t=s.name,o=443,n=`${y??""}${i}`,e=x===u.code?6:4),(x===s.code||x===a.code)&&(t=ee(x).name,o=parseInt(y??"")),(x===c.code||x===f.code)&&(t=ee(x).name,n=`${y??""}${i}`,e=x===f.code?6:4);if(e==null||t==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:e,host:n,transport:t,port:o}}protos(){return this.#r.map(([e])=>Object.assign({},ee(e)))}protoCodes(){return this.#r.map(([e])=>e)}protoNames(){return this.#r.map(([e])=>ee(e).name)}tuples(){return this.#r}stringTuples(){return this.#i}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(Is(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===Tr.p2p.code&&e.push([n,o]),n===Tr["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?G(ce.decode(`z${n}`),"base58btc"):G(ye.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(e){return se(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(i=>i.resolvable);if(t==null)return[this];let n=qc.get(t.name);if(n==null)throw new D(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(i=>ir(i))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[w0](){return`Multiaddr(${this.#e})`}};var qc=new Map;function zc(r){return!!r?.[Rs]}function ir(r){return new no(r)}function hn(r){let e=new globalThis.AbortController;function t(){e.abort();for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}for(let i of r){if(i?.aborted===!0){t();break}i?.addEventListener!=null&&i.addEventListener("abort",t)}function n(){for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}let o=e.signal;return o.clear=n,o}async function*oo(r,e={}){let t=r.getReader();try{for(;;){let n=await t.read();if(n.done)return;yield n.value}}finally{e.preventCancel!==!0&&await t.cancel(),t.releaseLock()}}var ra={};ge(ra,{Ed25519PrivateKey:()=>hr,Ed25519PublicKey:()=>xn,generateKeyPair:()=>Pp,generateKeyPairFromSeed:()=>Su,unmarshalEd25519PrivateKey:()=>Vp,unmarshalEd25519PublicKey:()=>Dp});function Ge(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Nr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function x0(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Cr(r,...e){if(!x0(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${r.length}`)}function io(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Nr(r.outputLen),Nr(r.blockLen)}function _r(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function Gc(r,e){Cr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var so=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Lr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),et=(r,e)=>r<<32-e|r>>>e;var $b=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var E0=async()=>{};async function jc(r,e,t){let n=Date.now();for(let o=0;o<r;o++){t(o);let i=Date.now()-n;i>=0&&i<e||(await E0(),n+=i)}}function Yc(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Ft(r){return typeof r=="string"&&(r=Yc(r)),Cr(r),r}function ks(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];Cr(o),e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let i=r[n];t.set(i,o),o+=i.length}return t}var Ur=class{clone(){return this._cloneInto()}},v0={}.toString;function Zc(r,e){if(e!==void 0&&v0.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function ao(r){let e=n=>r().update(Ft(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Or(r=32){if(so&&typeof so.getRandomValues=="function")return so.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function B0(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(t>>o&i),a=Number(t&i),c=n?4:0,f=n?0:4;r.setUint32(e+c,s,n),r.setUint32(e+f,a,n)}var Wc=(r,e,t)=>r&e^~r&t,Jc=(r,e,t)=>r&e^r&t^e&t,Vr=class extends Ur{constructor(e,t,n,o){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Lr(this.buffer)}update(e){_r(this);let{view:t,buffer:n,blockLen:o}=this;e=Ft(e);let i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Lr(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){_r(this),Gc(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)t[l]=0;B0(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Lr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.length=o,e.pos=a,e.finished=i,e.destroyed=s,o%t&&e.buffer.set(n),e}};var co=BigInt(4294967295),Ts=BigInt(32);function Xc(r,e=!1){return e?{h:Number(r&co),l:Number(r>>Ts&co)}:{h:Number(r>>Ts&co)|0,l:Number(r&co)|0}}function A0(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:i,l:s}=Xc(r[o],e);[t[o],n[o]]=[i,s]}return[t,n]}var S0=(r,e)=>BigInt(r>>>0)<<Ts|BigInt(e>>>0),I0=(r,e,t)=>r>>>t,R0=(r,e,t)=>r<<32-t|e>>>t,k0=(r,e,t)=>r>>>t|e<<32-t,T0=(r,e,t)=>r<<32-t|e>>>t,N0=(r,e,t)=>r<<64-t|e>>>t-32,C0=(r,e,t)=>r>>>t-32|e<<64-t,_0=(r,e)=>e,U0=(r,e)=>r,L0=(r,e,t)=>r<<t|e>>>32-t,O0=(r,e,t)=>e<<t|r>>>32-t,V0=(r,e,t)=>e<<t-32|r>>>64-t,D0=(r,e,t)=>r<<t-32|e>>>64-t;function P0(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var F0=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),M0=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,$0=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),H0=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,K0=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),q0=(r,e,t,n,o,i)=>e+t+n+o+i+(r/2**32|0)|0;var z0={fromBig:Xc,split:A0,toBig:S0,shrSH:I0,shrSL:R0,rotrSH:k0,rotrSL:T0,rotrBH:N0,rotrBL:C0,rotr32H:_0,rotr32L:U0,rotlSH:L0,rotlSL:O0,rotlBH:V0,rotlBL:D0,add:P0,add3L:F0,add3H:M0,add4L:$0,add4H:H0,add5H:q0,add5L:K0},q=z0;var[G0,j0]=q.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Mt=new Uint32Array(80),$t=new Uint32Array(80),Ns=class extends Vr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:d,Gh:x,Gl:y,Hh:h,Hl:g}=this;return[e,t,n,o,i,s,a,c,f,u,l,d,x,y,h,g]}set(e,t,n,o,i,s,a,c,f,u,l,d,x,y,h,g){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=d|0,this.Gh=x|0,this.Gl=y|0,this.Hh=h|0,this.Hl=g|0}process(e,t){for(let B=0;B<16;B++,t+=4)Mt[B]=e.getUint32(t),$t[B]=e.getUint32(t+=4);for(let B=16;B<80;B++){let O=Mt[B-15]|0,U=$t[B-15]|0,k=q.rotrSH(O,U,1)^q.rotrSH(O,U,8)^q.shrSH(O,U,7),L=q.rotrSL(O,U,1)^q.rotrSL(O,U,8)^q.shrSL(O,U,7),b=Mt[B-2]|0,T=$t[B-2]|0,V=q.rotrSH(b,T,19)^q.rotrBH(b,T,61)^q.shrSH(b,T,6),N=q.rotrSL(b,T,19)^q.rotrBL(b,T,61)^q.shrSL(b,T,6),F=q.add4L(L,N,$t[B-7],$t[B-16]),H=q.add4H(F,k,V,Mt[B-7],Mt[B-16]);Mt[B]=H|0,$t[B]=F|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:d,Fh:x,Fl:y,Gh:h,Gl:g,Hh:v,Hl:E}=this;for(let B=0;B<80;B++){let O=q.rotrSH(l,d,14)^q.rotrSH(l,d,18)^q.rotrBH(l,d,41),U=q.rotrSL(l,d,14)^q.rotrSL(l,d,18)^q.rotrBL(l,d,41),k=l&x^~l&h,L=d&y^~d&g,b=q.add5L(E,U,L,j0[B],$t[B]),T=q.add5H(b,v,O,k,G0[B],Mt[B]),V=b|0,N=q.rotrSH(n,o,28)^q.rotrBH(n,o,34)^q.rotrBH(n,o,39),F=q.rotrSL(n,o,28)^q.rotrBL(n,o,34)^q.rotrBL(n,o,39),H=n&i^n&a^i&a,S=o&s^o&c^s&c;v=h|0,E=g|0,h=x|0,g=y|0,x=l|0,y=d|0,{h:l,l:d}=q.add(f|0,u|0,T|0,V|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let m=q.add3L(V,F,S);n=q.add3H(m,T,N,H),o=m|0}({h:n,l:o}=q.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=q.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=q.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=q.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:d}=q.add(this.Eh|0,this.El|0,l|0,d|0),{h:x,l:y}=q.add(this.Fh|0,this.Fl|0,x|0,y|0),{h,l:g}=q.add(this.Gh|0,this.Gl|0,h|0,g|0),{h:v,l:E}=q.add(this.Hh|0,this.Hl|0,v|0,E|0),this.set(n,o,i,s,a,c,f,u,l,d,x,y,h,g,v,E)}roundClean(){Mt.fill(0),$t.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 dn=ao(()=>new Ns);var lo={};ge(lo,{aInRange:()=>Le,abool:()=>tt,abytes:()=>Dr,bitGet:()=>ep,bitLen:()=>Q0,bitMask:()=>mn,bitSet:()=>tp,bytesToHex:()=>Et,bytesToNumberBE:()=>vt,bytesToNumberLE:()=>Kt,concatBytes:()=>Bt,createHmacDrbg:()=>Os,ensureBytes:()=>ae,equalBytes:()=>J0,hexToBytes:()=>sr,hexToNumber:()=>Ls,inRange:()=>pn,isBytes:()=>Ht,memoized:()=>cr,notImplemented:()=>np,numberToBytesBE:()=>qt,numberToBytesLE:()=>ar,numberToHexUnpadded:()=>tu,numberToVarBytesBE:()=>W0,utf8ToBytes:()=>X0,validateObject:()=>ht});var Us=BigInt(0),uo=BigInt(1),Y0=BigInt(2);function Ht(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Dr(r){if(!Ht(r))throw new Error("Uint8Array expected")}function tt(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var Z0=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Et(r){Dr(r);let e="";for(let t=0;t<r.length;t++)e+=Z0[r[t]];return e}function tu(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function Ls(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var xt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Qc(r){if(r>=xt._0&&r<=xt._9)return r-xt._0;if(r>=xt._A&&r<=xt._F)return r-(xt._A-10);if(r>=xt._a&&r<=xt._f)return r-(xt._a-10)}function sr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let o=0,i=0;o<t;o++,i+=2){let s=Qc(r.charCodeAt(i)),a=Qc(r.charCodeAt(i+1));if(s===void 0||a===void 0){let c=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function vt(r){return Ls(Et(r))}function Kt(r){return Dr(r),Ls(Et(Uint8Array.from(r).reverse()))}function qt(r,e){return sr(r.toString(16).padStart(e*2,"0"))}function ar(r,e){return qt(r,e).reverse()}function W0(r){return sr(tu(r))}function ae(r,e,t){let n;if(typeof e=="string")try{n=sr(e)}catch(i){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${i}`)}else if(Ht(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof t=="number"&&o!==t)throw new Error(`${r} expected ${t} bytes, got ${o}`);return n}function Bt(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];Dr(o),e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let i=r[n];t.set(i,o),o+=i.length}return t}function J0(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function X0(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var Cs=r=>typeof r=="bigint"&&Us<=r;function pn(r,e,t){return Cs(r)&&Cs(e)&&Cs(t)&&e<=r&&r<t}function Le(r,e,t,n){if(!pn(e,t,n))throw new Error(`expected valid ${r}: ${t} <= n < ${n}, got ${typeof e} ${e}`)}function Q0(r){let e;for(e=0;r>Us;r>>=uo,e+=1);return e}function ep(r,e){return r>>BigInt(e)&uo}function tp(r,e,t){return r|(t?uo:Us)<<BigInt(e)}var mn=r=>(Y0<<BigInt(r-1))-uo,_s=r=>new Uint8Array(r),eu=r=>Uint8Array.from(r);function Os(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=_s(r),o=_s(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>t(o,n,...l),c=(l=_s())=>{o=a(eu([0]),l),n=a(),l.length!==0&&(o=a(eu([1]),l),n=a())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,d=[];for(;l<e;){n=a();let x=n.slice();d.push(x),l+=n.length}return Bt(...d)};return(l,d)=>{s(),c(l);let x;for(;!(x=d(f()));)c();return s(),x}}var rp={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Ht(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function ht(r,e,t={}){let n=(o,i,s)=>{let a=rp[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);let c=r[o];if(!(s&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${i}`)};for(let[o,i]of Object.entries(e))n(o,i,!1);for(let[o,i]of Object.entries(t))n(o,i,!0);return r}var np=()=>{throw new Error("not implemented")};function cr(r){let e=new WeakMap;return(t,...n)=>{let o=e.get(t);if(o!==void 0)return o;let i=r(t,...n);return e.set(t,i),i}}var de=BigInt(0),te=BigInt(1),ur=BigInt(2),op=BigInt(3),Vs=BigInt(4),ru=BigInt(5),nu=BigInt(8),ip=BigInt(9),sp=BigInt(16);function Q(r,e){let t=r%e;return t>=de?t:e+t}function ap(r,e,t){if(t<=de||e<de)throw new Error("Expected power/modulo > 0");if(t===te)return de;let n=te;for(;e>de;)e&te&&(n=n*r%t),r=r*r%t,e>>=te;return n}function re(r,e,t){let n=r;for(;e-- >de;)n*=n,n%=t;return n}function fo(r,e){if(r===de||e<=de)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Q(r,e),n=e,o=de,i=te,s=te,a=de;for(;t!==de;){let f=n/t,u=n%t,l=o-s*f,d=i-a*f;n=t,t=u,o=s,i=a,s=l,a=d}if(n!==te)throw new Error("invert: does not exist");return Q(o,e)}function cp(r){let e=(r-te)/ur,t,n,o;for(t=r-te,n=0;t%ur===de;t/=ur,n++);for(o=ur;o<r&&ap(o,e,r)!==r-te;o++);if(n===1){let s=(r+te)/Vs;return function(c,f){let u=c.pow(f,s);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let i=(t+te)/ur;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,u=a.pow(a.mul(a.ONE,o),t),l=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 x=1;for(let h=a.sqr(d);x<f&&!a.eql(h,a.ONE);x++)h=a.sqr(h);let y=a.pow(u,te<<BigInt(f-x-1));u=a.sqr(y),l=a.mul(l,y),d=a.mul(d,u),f=x}return l}}function up(r){if(r%Vs===op){let e=(r+te)/Vs;return function(n,o){let i=n.pow(o,e);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(r%nu===ru){let e=(r-ru)/nu;return function(n,o){let i=n.mul(o,ur),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,ur),s),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return r%sp,cp(r)}var ou=(r,e)=>(Q(r,e)&te)===te,lp=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ds(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=lp.reduce((n,o)=>(n[o]="function",n),e);return ht(r,t)}function fp(r,e,t){if(t<de)throw new Error("Expected power > 0");if(t===de)return r.ONE;if(t===te)return e;let n=r.ONE,o=e;for(;t>de;)t&te&&(n=r.mul(n,o)),o=r.sqr(o),t>>=te;return n}function hp(r,e){let t=new Array(e.length),n=e.reduce((i,s,a)=>r.is0(s)?i:(t[a]=i,r.mul(i,s)),r.ONE),o=r.inv(n);return e.reduceRight((i,s,a)=>r.is0(s)?i:(t[a]=r.mul(i,t[a]),r.mul(i,s)),o),t}function Ps(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function ho(r,e,t=!1,n={}){if(r<=de)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:i}=Ps(r,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=up(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:mn(o),ZERO:de,ONE:te,create:c=>Q(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return de<=c&&c<r},is0:c=>c===de,isOdd:c=>(c&te)===te,neg:c=>Q(-c,r),eql:(c,f)=>c===f,sqr:c=>Q(c*c,r),add:(c,f)=>Q(c+f,r),sub:(c,f)=>Q(c-f,r),mul:(c,f)=>Q(c*f,r),pow:(c,f)=>fp(a,c,f),div:(c,f)=>Q(c*fo(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>fo(c,r),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>hp(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>t?ar(c,i):qt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return t?Kt(c):vt(c)}});return Object.freeze(a)}function iu(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function Fs(r){let e=iu(r);return e+Math.ceil(e/2)}function su(r,e,t=!1){let n=r.length,o=iu(e),i=Fs(e);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=t?vt(r):Kt(r),a=Q(s,e-te)+te;return t?ar(a,o):qt(a,o)}var pp=BigInt(0),Ms=BigInt(1),$s=new WeakMap,au=new WeakMap;function po(r,e){let t=(i,s)=>{let a=s.negate();return i?a:s},n=i=>{if(!Number.isSafeInteger(i)||i<=0||i>e)throw new Error(`Wrong window size=${i}, should be [1..${e}]`)},o=i=>{n(i);let s=Math.ceil(e/i)+1,a=2**(i-1);return{windows:s,windowSize:a}};return{constTimeNegate:t,unsafeLadder(i,s){let a=r.ZERO,c=i;for(;s>pp;)s&Ms&&(a=a.add(c)),c=c.double(),s>>=Ms;return a},precomputeWindow(i,s){let{windows:a,windowSize:c}=o(s),f=[],u=i,l=u;for(let d=0;d<a;d++){l=u,f.push(l);for(let x=1;x<c;x++)l=l.add(u),f.push(l);u=l.double()}return f},wNAF(i,s,a){let{windows:c,windowSize:f}=o(i),u=r.ZERO,l=r.BASE,d=BigInt(2**i-1),x=2**i,y=BigInt(i);for(let h=0;h<c;h++){let g=h*f,v=Number(a&d);a>>=y,v>f&&(v-=x,a+=Ms);let E=g,B=g+Math.abs(v)-1,O=h%2!==0,U=v<0;v===0?l=l.add(t(O,s[E])):u=u.add(t(U,s[B]))}return{p:u,f:l}},wNAFCached(i,s,a){let c=au.get(i)||1,f=$s.get(i);return f||(f=this.precomputeWindow(i,c),c!==1&&$s.set(i,a(f))),this.wNAF(c,f,s)},setWindowSize(i,s){n(s),au.set(i,s),$s.delete(i)}}}function gn(r){return Ds(r.Fp),ht(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ps(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var rt=BigInt(0),Oe=BigInt(1),mo=BigInt(2),mp=BigInt(8),gp={zip215:!0};function yp(r){let e=gn(r);return ht(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function cu(r){let e=yp(r),{Fp:t,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=e,f=mo<<BigInt(a*8)-Oe,u=t.create,l=e.uvRatio||((m,p)=>{try{return{isValid:!0,value:t.sqrt(m*t.inv(p))}}catch{return{isValid:!1,value:rt}}}),d=e.adjustScalarBytes||(m=>m),x=e.domain||((m,p,A)=>{if(tt("phflag",A),p.length||A)throw new Error("Contexts/pre-hash are not supported");return m});function y(m,p){Le("coordinate "+m,p,rt,f)}function h(m){if(!(m instanceof E))throw new Error("ExtendedPoint expected")}let g=cr((m,p)=>{let{ex:A,ey:R,ez:P}=m,M=m.is0();p==null&&(p=M?mp:t.inv(P));let K=u(A*p),W=u(R*p),j=u(P*p);if(M)return{x:rt,y:Oe};if(j!==Oe)throw new Error("invZ was invalid");return{x:K,y:W}}),v=cr(m=>{let{a:p,d:A}=e;if(m.is0())throw new Error("bad point: ZERO");let{ex:R,ey:P,ez:M,et:K}=m,W=u(R*R),j=u(P*P),J=u(M*M),ne=u(J*J),oe=u(W*p),_e=u(J*u(oe+j)),pe=u(ne+u(A*u(W*j)));if(_e!==pe)throw new Error("bad point: equation left != right (1)");let he=u(R*P),We=u(M*K);if(he!==We)throw new Error("bad point: equation left != right (2)");return!0});class E{constructor(p,A,R,P){this.ex=p,this.ey=A,this.ez=R,this.et=P,y("x",p),y("y",A),y("z",R),y("t",P),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof E)throw new Error("extended point not allowed");let{x:A,y:R}=p||{};return y("x",A),y("y",R),new E(A,R,Oe,u(A*R))}static normalizeZ(p){let A=t.invertBatch(p.map(R=>R.ez));return p.map((R,P)=>R.toAffine(A[P])).map(E.fromAffine)}_setWindowSize(p){U.setWindowSize(this,p)}assertValidity(){v(this)}equals(p){h(p);let{ex:A,ey:R,ez:P}=this,{ex:M,ey:K,ez:W}=p,j=u(A*W),J=u(M*P),ne=u(R*W),oe=u(K*P);return j===J&&ne===oe}is0(){return this.equals(E.ZERO)}negate(){return new E(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=e,{ex:A,ey:R,ez:P}=this,M=u(A*A),K=u(R*R),W=u(mo*u(P*P)),j=u(p*M),J=A+R,ne=u(u(J*J)-M-K),oe=j+K,_e=oe-W,pe=j-K,he=u(ne*_e),We=u(oe*pe),me=u(ne*pe),Je=u(_e*oe);return new E(he,We,Je,me)}add(p){h(p);let{a:A,d:R}=e,{ex:P,ey:M,ez:K,et:W}=this,{ex:j,ey:J,ez:ne,et:oe}=p;if(A===BigInt(-1)){let ja=u((M-P)*(J+j)),Ya=u((M+P)*(J-j)),Li=u(Ya-ja);if(Li===rt)return this.double();let Za=u(K*mo*oe),Wa=u(W*mo*ne),Ja=Wa+Za,Xa=Ya+ja,Qa=Wa-Za,Eh=u(Ja*Li),vh=u(Xa*Qa),Bh=u(Ja*Qa),Ah=u(Li*Xa);return new E(Eh,vh,Ah,Bh)}let _e=u(P*j),pe=u(M*J),he=u(W*R*oe),We=u(K*ne),me=u((P+M)*(j+J)-_e-pe),Je=We-he,rr=We+he,on=u(pe-A*_e),zn=u(me*Je),wh=u(rr*on),bh=u(me*on),xh=u(Je*rr);return new E(zn,wh,xh,bh)}subtract(p){return this.add(p.negate())}wNAF(p){return U.wNAFCached(this,p,E.normalizeZ)}multiply(p){let A=p;Le("scalar",A,Oe,n);let{p:R,f:P}=this.wNAF(A);return E.normalizeZ([R,P])[0]}multiplyUnsafe(p){let A=p;return Le("scalar",A,rt,n),A===rt?O:this.equals(O)||A===Oe?this:this.equals(B)?this.wNAF(A).p:U.unsafeLadder(this,A)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(p){return g(this,p)}clearCofactor(){let{h:p}=e;return p===Oe?this:this.multiplyUnsafe(p)}static fromHex(p,A=!1){let{d:R,a:P}=e,M=t.BYTES;p=ae("pointHex",p,M),tt("zip215",A);let K=p.slice(),W=p[M-1];K[M-1]=W&-129;let j=Kt(K),J=A?f:t.ORDER;Le("pointHex.y",j,rt,J);let ne=u(j*j),oe=u(ne-Oe),_e=u(R*ne-P),{isValid:pe,value:he}=l(oe,_e);if(!pe)throw new Error("Point.fromHex: invalid y coordinate");let We=(he&Oe)===Oe,me=(W&128)!==0;if(!A&&he===rt&&me)throw new Error("Point.fromHex: x=0 and x_0=1");return me!==We&&(he=u(-he)),E.fromAffine({x:he,y:j})}static fromPrivateKey(p){return b(p).point}toRawBytes(){let{x:p,y:A}=this.toAffine(),R=ar(A,t.BYTES);return R[R.length-1]|=p&Oe?128:0,R}toHex(){return Et(this.toRawBytes())}}E.BASE=new E(e.Gx,e.Gy,Oe,u(e.Gx*e.Gy)),E.ZERO=new E(rt,Oe,Oe,rt);let{BASE:B,ZERO:O}=E,U=po(E,a*8);function k(m){return Q(m,n)}function L(m){return k(Kt(m))}function b(m){let p=a;m=ae("private key",m,p);let A=ae("hashed private key",i(m),2*p),R=d(A.slice(0,p)),P=A.slice(p,2*p),M=L(R),K=B.multiply(M),W=K.toRawBytes();return{head:R,prefix:P,scalar:M,point:K,pointBytes:W}}function T(m){return b(m).pointBytes}function V(m=new Uint8Array,...p){let A=Bt(...p);return L(i(x(A,ae("context",m),!!o)))}function N(m,p,A={}){m=ae("message",m),o&&(m=o(m));let{prefix:R,scalar:P,pointBytes:M}=b(p),K=V(A.context,R,m),W=B.multiply(K).toRawBytes(),j=V(A.context,W,M,m),J=k(K+j*P);Le("signature.s",J,rt,n);let ne=Bt(W,ar(J,t.BYTES));return ae("result",ne,a*2)}let F=gp;function H(m,p,A,R=F){let{context:P,zip215:M}=R,K=t.BYTES;m=ae("signature",m,2*K),p=ae("message",p),M!==void 0&&tt("zip215",M),o&&(p=o(p));let W=Kt(m.slice(K,2*K)),j,J,ne;try{j=E.fromHex(A,M),J=E.fromHex(m.slice(0,K),M),ne=B.multiplyUnsafe(W)}catch{return!1}if(!M&&j.isSmallOrder())return!1;let oe=V(P,J.toRawBytes(),j.toRawBytes(),p);return J.add(j.multiplyUnsafe(oe)).subtract(ne).clearCofactor().equals(E.ZERO)}return B._setWindowSize(8),{CURVE:e,getPublicKey:T,sign:N,verify:H,ExtendedPoint:E,utils:{getExtendedPublicKey:b,randomPrivateKey:()=>s(t.BYTES),precompute(m=8,p=E.BASE){return p._setWindowSize(m),p.multiply(BigInt(3)),p}}}}var Hs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),uu=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),lx=BigInt(0),wp=BigInt(1),lu=BigInt(2),fx=BigInt(3),bp=BigInt(5),xp=BigInt(8);function Ep(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),o=BigInt(80),i=Hs,a=r*r%i*r%i,c=re(a,lu,i)*a%i,f=re(c,wp,i)*r%i,u=re(f,bp,i)*f%i,l=re(u,e,i)*u%i,d=re(l,t,i)*l%i,x=re(d,n,i)*d%i,y=re(x,o,i)*x%i,h=re(y,o,i)*x%i,g=re(h,e,i)*u%i;return{pow_p_5_8:re(g,lu,i)*r%i,b2:a}}function vp(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Bp(r,e){let t=Hs,n=Q(e*e*e,t),o=Q(n*n*e,t),i=Ep(r*o).pow_p_5_8,s=Q(r*n*i,t),a=Q(e*s*s,t),c=s,f=Q(s*uu,t),u=a===r,l=a===Q(-r,t),d=a===Q(-r*uu,t);return u&&(s=c),(l||d)&&(s=f),ou(s,t)&&(s=Q(-s,t)),{isValid:u||l,value:s}}var Ap=ho(Hs,void 0,!0),Sp={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ap,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:xp,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:dn,randomBytes:Or,adjustScalarBytes:vp,uvRatio:Bp},Pr=cu(Sp);var Fr=32,At=64,go=32;function fu(){let r=Pr.utils.randomPrivateKey(),e=Pr.getPublicKey(r);return{privateKey:mu(r,e),publicKey:e}}function hu(r){if(r.length!==go)throw new TypeError('"seed" must be 32 bytes in length.');if(!(r instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let e=r,t=Pr.getPublicKey(e);return{privateKey:mu(e,t),publicKey:t}}function du(r,e){let t=r.subarray(0,go);return Pr.sign(e instanceof Uint8Array?e:e.subarray(),t)}function pu(r,e,t){return Pr.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function mu(r,e){let t=new Uint8Array(At);for(let n=0;n<go;n++)t[n]=r[n],t[go+n]=e[n];return t}var Te={get(r=globalThis){let e=r.crypto;if(e?.subtle==null)throw Object.assign(new Error("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"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}};var Ks={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function gu(r){let e=r?.algorithm??"AES-GCM",t=r?.keyLength??16,n=r?.nonceLength??12,o=r?.digest??"SHA-256",i=r?.saltLength??16,s=r?.iterations??32767,a=Te.get();t*=8;async function c(l,d){let x=a.getRandomValues(new Uint8Array(i)),y=a.getRandomValues(new Uint8Array(n)),h={name:e,iv:y};typeof d=="string"&&(d=z(d));let g;if(d.length===0){g=await a.subtle.importKey("jwk",Ks,{name:"AES-GCM"},!0,["encrypt"]);try{let E={name:"PBKDF2",salt:x,iterations:s,hash:{name:o}},B=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(E,B,{name:e,length:t},!0,["encrypt"])}catch{g=await a.subtle.importKey("jwk",Ks,{name:"AES-GCM"},!0,["encrypt"])}}else{let E={name:"PBKDF2",salt:x,iterations:s,hash:{name:o}},B=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(E,B,{name:e,length:t},!0,["encrypt"])}let v=await a.subtle.encrypt(h,g,l);return ke([x,h.iv,new Uint8Array(v)])}async function f(l,d){let x=l.subarray(0,i),y=l.subarray(i,i+n),h=l.subarray(i+n),g={name:e,iv:y};typeof d=="string"&&(d=z(d));let v;if(d.length===0)try{let B={name:"PBKDF2",salt:x,iterations:s,hash:{name:o}},O=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);v=await a.subtle.deriveKey(B,O,{name:e,length:t},!0,["decrypt"])}catch{v=await a.subtle.importKey("jwk",Ks,{name:"AES-GCM"},!0,["decrypt"])}else{let B={name:"PBKDF2",salt:x,iterations:s,hash:{name:o}},O=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);v=await a.subtle.deriveKey(B,O,{name:e,length:t},!0,["decrypt"])}let E=await a.subtle.decrypt(g,v,h);return new Uint8Array(E)}return{encrypt:c,decrypt:f}}async function Mr(r,e){let n=await gu().encrypt(r,e);return sn.encode(n)}var qs=new Float32Array([-0]),zt=new Uint8Array(qs.buffer);function yu(r,e,t){qs[0]=r,e[t]=zt[0],e[t+1]=zt[1],e[t+2]=zt[2],e[t+3]=zt[3]}function wu(r,e){return zt[0]=r[e],zt[1]=r[e+1],zt[2]=r[e+2],zt[3]=r[e+3],qs[0]}var zs=new Float64Array([-0]),Se=new Uint8Array(zs.buffer);function bu(r,e,t){zs[0]=r,e[t]=Se[0],e[t+1]=Se[1],e[t+2]=Se[2],e[t+3]=Se[3],e[t+4]=Se[4],e[t+5]=Se[5],e[t+6]=Se[6],e[t+7]=Se[7]}function xu(r,e){return Se[0]=r[e],Se[1]=r[e+1],Se[2]=r[e+2],Se[3]=r[e+3],Se[4]=r[e+4],Se[5]=r[e+5],Se[6]=r[e+6],Se[7]=r[e+7],zs[0]}var kp=BigInt(Number.MAX_SAFE_INTEGER),Tp=BigInt(Number.MIN_SAFE_INTEGER),Me=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return lr;if(e<kp&&e>Tp)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,o=e-(n<<32n);return t&&(n=~n|0n,o=~o|0n,++o>Eu&&(o=0n,++n>Eu&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return lr;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):lr}},lr=new Me(0,0);lr.toBigInt=function(){return 0n};lr.zzEncode=lr.zzDecode=function(){return this};lr.length=function(){return 1};var Eu=4294967296n;function vu(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Bu(r,e,t){if(t-e<1)return"";let o,i=[],s=0,a;for(;e<t;)a=r[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function Gs(r,e,t){let n=t,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128);return t-n}function nt(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function yo(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var js=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,nt(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw nt(this,4);return yo(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw nt(this,4);return yo(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw nt(this,4);let e=wu(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw nt(this,4);let e=xu(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw nt(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Bu(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw nt(this,e);this.pos+=e}else do if(this.pos>=this.len)throw nt(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Me(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw nt(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw nt(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw nt(this,8);let e=yo(this.buf,this.pos+=4),t=yo(this.buf,this.pos+=4);return new Me(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=ds(this.buf,this.pos);return this.pos+=Ue(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Ys(r){return new js(r instanceof Uint8Array?r:r.subarray())}function $r(r,e,t){let n=Ys(r);return e.decode(n,void 0,t)}function Zs(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return Qe(s);o+s>e&&(n=Qe(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var fr=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Ws(){}var Xs=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Np=Zs();function Cp(r){return globalThis.Buffer!=null?Qe(r):Np(r)}var wn=class{len;head;tail;states;constructor(){this.len=0,this.head=new fr(Ws,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new fr(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Qs((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(wo,10,Me.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Me.fromBigInt(e);return this._push(wo,t.length(),t)}uint64Number(e){return this._push(hs,Ue(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=Me.fromBigInt(e).zzEncode();return this._push(wo,t.length(),t)}sint64Number(e){let t=Me.fromNumber(e).zzEncode();return this._push(wo,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Js,1,e?1:0)}fixed32(e){return this._push(yn,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Me.fromBigInt(e);return this._push(yn,4,t.lo)._push(yn,4,t.hi)}fixed64Number(e){let t=Me.fromNumber(e);return this._push(yn,4,t.lo)._push(yn,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(yu,4,e)}double(e){return this._push(bu,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Js,1,0):this.uint32(t)._push(Up,t,e)}string(e){let t=vu(e);return t!==0?this.uint32(t)._push(Gs,t,e):this._push(Js,1,0)}fork(){return this.states=new Xs(this),this.head=this.tail=new fr(Ws,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 fr(Ws,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=Cp(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Js(r,e,t){e[t]=r&255}function _p(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Qs=class extends fr{next;constructor(e,t){super(_p,e,t),this.next=void 0}};function wo(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function yn(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function Up(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(wn.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(Lp,e,r),this},wn.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(Op,e,r),this});function Lp(r,e,t){e.set(r,t)}function Op(r,e,t){r.length<40?Gs(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(z(r),t)}function ea(){return new wn}function Hr(r,e){let t=ea();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var Kr;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Kr||(Kr={}));function bo(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function bn(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return bo("enum",Kr.VARINT,t,n)}function qr(r,e){return bo("message",Kr.LENGTH_DELIMITED,r,e)}var ue;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(ue||(ue={}));var ta;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(ta||(ta={}));(function(r){r.codec=()=>bn(ta)})(ue||(ue={}));var dt;(function(r){let e;r.codec=()=>(e==null&&(e=qr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ue.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let o={},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let s=t.uint32();switch(s>>>3){case 1:o.Type=ue.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(s&7);break}}return o})),e),r.encode=t=>Hr(t,r.codec()),r.decode=t=>$r(t,r.codec())})(dt||(dt={}));var St;(function(r){let e;r.codec=()=>(e==null&&(e=qr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ue.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let o={},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let s=t.uint32();switch(s>>>3){case 1:o.Type=ue.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(s&7);break}}return o})),e),r.encode=t=>Hr(t,r.codec()),r.decode=t=>$r(t,r.codec())})(St||(St={}));var xn=class{_key;constructor(e){this._key=zr(e,Fr)}verify(e,t){return pu(this._key,t,e)}marshal(){return this._key}get bytes(){return dt.encode({Type:ue.Ed25519,Data:this.marshal()}).subarray()}equals(e){return se(this.bytes,e.bytes)}hash(){let e=Ee.digest(this.bytes);return Ge(e)?e.then(({bytes:t})=>t):e.bytes}},hr=class{_key;_publicKey;constructor(e,t){this._key=zr(e,At),this._publicKey=zr(t,Fr)}sign(e){return du(this._key,e)}get public(){return new xn(this._publicKey)}marshal(){return this._key}get bytes(){return St.encode({Type:ue.Ed25519,Data:this.marshal()}).subarray()}equals(e){return se(this.bytes,e.bytes)}async hash(){let e=Ee.digest(this.bytes),t;return Ge(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=Fe.digest(this.public.bytes);return ce.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return Mr(this.bytes,e);throw new D(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Vp(r){if(r.length>At){r=zr(r,At+Fr);let n=r.subarray(0,At),o=r.subarray(At,r.length);return new hr(n,o)}r=zr(r,At);let e=r.subarray(0,At),t=r.subarray(Fr);return new hr(e,t)}function Dp(r){return r=zr(r,Fr),new xn(r)}async function Pp(){let{privateKey:r,publicKey:e}=fu();return new hr(r,e)}async function Su(r){let{privateKey:e,publicKey:t}=hu(r);return new hr(e,t)}function zr(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new D(`Key must be a Uint8Array of length ${e}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}var ha={};ge(ha,{MAX_RSA_KEY_SIZE:()=>_n,RsaPrivateKey:()=>Wr,RsaPublicKey:()=>Cn,fromJwk:()=>fm,generateKeyPair:()=>hm,unmarshalRsaPrivateKey:()=>la,unmarshalRsaPublicKey:()=>lm});function dr(r){if(isNaN(r)||r<=0)throw new D("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Or(r)}var Zt={};ge(Zt,{exportToPem:()=>im,importFromPem:()=>sm,jwkToPkcs1:()=>tm,jwkToPkix:()=>nm,pkcs1ToJwk:()=>em,pkixToJwk:()=>rm});var Eo=class extends Ur{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,io(e);let n=Ft(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return _r(this),this.iHash.update(e),this}digestInto(e){_r(this),Cr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},En=(r,e,t)=>new Eo(r,e).update(t).digest();En.create=(r,e)=>new Eo(r,e);function Fp(r,e,t,n){io(r);let o=Zc({dkLen:32,asyncTick:10},n),{c:i,dkLen:s,asyncTick:a}=o;if(Nr(i),Nr(s),Nr(a),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=Ft(e),f=Ft(t),u=new Uint8Array(s),l=En.create(r,c),d=l._cloneInto().update(f);return{c:i,dkLen:s,asyncTick:a,DK:u,PRF:l,PRFSalt:d}}function Mp(r,e,t,n,o){return r.destroy(),e.destroy(),n&&n.destroy(),o.fill(0),t}async function na(r,e,t,n){let{c:o,dkLen:i,asyncTick:s,DK:a,PRF:c,PRFSalt:f}=Fp(r,e,t,n),u,l=new Uint8Array(4),d=Lr(l),x=new Uint8Array(c.outputLen);for(let y=1,h=0;h<i;y++,h+=c.outputLen){let g=a.subarray(h,h+c.outputLen);d.setInt32(0,y,!1),(u=f._cloneInto(u)).update(l).digestInto(x),g.set(x.subarray(0,g.length)),await jc(o-1,s,()=>{c._cloneInto(u).update(x).digestInto(x);for(let v=0;v<g.length;v++)g[v]^=x[v]})}return Mp(c,f,a,u,x)}var Y=nr(Iu());function pr(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function Gt(r,e,t=-1){let n=t,o=r,i=0,s=Math.pow(2,e);for(let a=1;a<8;a++){if(r<s){let c;if(n<0)c=new ArrayBuffer(a),i=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),i=n}let f=new Uint8Array(c);for(let u=a-1;u>=0;u--){let l=Math.pow(2,u*e);f[i-u-1]=Math.floor(o/l),o-=f[i-u-1]*l}return c}s*=Math.pow(2,e)}return new ArrayBuffer(0)}function Ao(...r){let e=0,t=0;for(let i of r)e+=i.length;let n=new ArrayBuffer(e),o=new Uint8Array(n);for(let i of r)o.set(i,t),t+=i.length;return o}function ia(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)t[a]=0;t[0]=r[0]&128;let n=pr(t,8),o=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(o);for(let a=0;a<this.valueHex.byteLength;a++)i[a]=r[a];return i[0]&=127,pr(i,8)-n}function Ru(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let s=t-e,a=Gt(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=Gt(e,8,n),i=new Uint8Array(o);if(i[0]&128){let s=o.slice(0),a=new Uint8Array(s);o=new ArrayBuffer(o.byteLength+1),i=new Uint8Array(o);for(let c=0;c<s.byteLength;c++)i[c+1]=a[c];i[0]=0}return o}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function ku(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<t.length;o++)if(t[o]!==n[o])return!1;return!0}function Ve(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,o=new Array(n);for(let s=0;s<n;s++)o[s]="0";return o.join("").concat(t)}var g1=Math.log(2);function So(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function sa(r){let e=0,t=0;for(let o=0;o<r.length;o++){let i=r[o];e+=i.byteLength}let n=new Uint8Array(e);for(let o=0;o<r.length;o++){let i=r[o];n.set(new Uint8Array(i),t),t+=i.byteLength}return n.buffer}function Nt(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var Bn=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return sa(this.items)}},vn=[new Uint8Array([1])],Tu="0123456789";var Yr="",it=new ArrayBuffer(0),aa=new Uint8Array(0),An="EndOfContent",Cu="OCTET STRING",_u="BIT STRING";function Ct(r){var e;return e=class extends r{constructor(...n){var o;super(...n);let i=n[0]||{};this.isHexOnly=(o=i.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=i.valueHex?Y.BufferSourceConverter.toUint8Array(i.valueHex):aa}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,o,i){let s=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!Nt(this,s,o,i))return-1;let a=o+i;return this.valueHexView=s.subarray(o,a),this.valueHexView.length?(this.blockLength=i,a):(this.warnings.push("Zero buffer length"),o)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",it)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:Y.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var Rt=class{constructor({blockLength:e=0,error:t=Yr,warnings:n=[],valueBeforeDecode:o=aa}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=Y.BufferSourceConverter.toUint8Array(o)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:Y.Convert.ToHex(this.valueBeforeDecodeView)}}};Rt.NAME="baseBlock";var Ie=class extends Rt{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};Ie.NAME="valueBlock";var Io=class extends Ct(Rt){constructor({idBlock:e={}}={}){var t,n,o,i;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?Y.BufferSourceConverter.toUint8Array(e.valueHex):aa,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(o=e.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(i=e.isConstructed)!==null&&i!==void 0?i:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",it}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!e){let i=this.tagNumber;i&=31,t|=i,o[0]=t}return o.buffer}if(!this.isHexOnly){let o=Gt(this.tagNumber,7),i=new Uint8Array(o),s=o.byteLength,a=new Uint8Array(s+1);if(a[0]=t|31,!e){for(let c=0;c<s-1;c++)a[c+1]=i[c]|128;a[s]=i[s-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let o=this.valueHexView;for(let i=0;i<o.length-1;i++)n[i+1]=o[i]|128;n[this.valueHexView.byteLength]=o[o.length-1]}return n.buffer}fromBER(e,t,n){let o=Y.BufferSourceConverter.toUint8Array(e);if(!Nt(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;let a=i[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,f=this.valueHexView=new Uint8Array(255),u=255;for(;i[c]&128;){if(f[c-1]=i[c]&127,c++,c>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let d=new Uint8Array(u);for(let x=0;x<f.length;x++)d[x]=f[x];f=this.valueHexView=new Uint8Array(u)}}this.blockLength=c+1,f[c-1]=i[c]&127;let l=new Uint8Array(c);for(let d=0;d<c;d++)l[d]=f[d];f=this.valueHexView=new Uint8Array(c),f.set(l),this.blockLength<=9?this.tagNumber=pr(f,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};Io.NAME="identificationBlock";var Ro=class extends Rt{constructor({lenBlock:e={}}={}){var t,n,o;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(o=e.length)!==null&&o!==void 0?o:0}fromBER(e,t,n){let o=Y.BufferSourceConverter.toUint8Array(e);if(!Nt(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;if(i[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,t+this.blockLength;let s=i[0]&127;if(s>8)return this.error="Too big integer",-1;if(s+1>i.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=o.subarray(a,a+s);return c[s-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=pr(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let o=Gt(this.length,8);if(o.byteLength>127)return this.error="Too big length",it;if(t=new ArrayBuffer(o.byteLength+1),e)return t;let i=new Uint8Array(o);n=new Uint8Array(t),n[0]=o.byteLength|128;for(let s=0;s<o.byteLength;s++)n[s+1]=i[s];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};Ro.NAME="lengthBlock";var C={},ve=class extends Rt{constructor({name:e=Yr,optional:t=!1,primitiveSchema:n,...o}={},i){super(o),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Io(o),this.lenBlock=new Ro(o),this.valueBlock=i?new i(o):new Ie(o)}fromBER(e,t,n){let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}toBER(e,t){let n=t||new Bn;t||Uu(this);let o=this.idBlock.toBER(e);if(n.write(o),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let i=this.valueBlock.toBER(e);this.lenBlock.length=i.byteLength;let s=this.lenBlock.toBER(e);n.write(s),n.write(i)}return t?it:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():Y.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${Y.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return ku(t,n)}};ve.NAME="BaseBlock";function Uu(r){if(r instanceof C.Constructed)for(let e of r.valueBlock.value)Uu(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var ko=class extends ve{constructor({value:e=Yr,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};ko.NAME="BaseStringBlock";var To=class extends Ct(Ie){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};To.NAME="PrimitiveValueBlock";var Lu,No=class extends ve{constructor(e={}){super(e,To),this.idBlock.isConstructed=!1}};Lu=No;C.Primitive=Lu;No.NAME="PRIMITIVE";function Zp(r,e){if(r instanceof e)return r;let t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function ui(r,e=0,t=r.length){let n=e,o=new ve({},Ie),i=new Rt;if(!Nt(i,r,e,t))return o.error=i.error,{offset:-1,result:o};if(!r.subarray(e,e+t).length)return o.error="Zero buffer length",{offset:-1,result:o};let a=o.idBlock.fromBER(r,e,t);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),a===-1)return o.error=o.idBlock.error,{offset:-1,result:o};if(e=a,t-=o.idBlock.blockLength,a=o.lenBlock.fromBER(r,e,t),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),a===-1)return o.error=o.lenBlock.error,{offset:-1,result:o};if(e=a,t-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};let c=ve;switch(o.idBlock.tagClass){case 1:if(o.idBlock.tagNumber>=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};c=C.EndOfContent;break;case 1:c=C.Boolean;break;case 2:c=C.Integer;break;case 3:c=C.BitString;break;case 4:c=C.OctetString;break;case 5:c=C.Null;break;case 6:c=C.ObjectIdentifier;break;case 10:c=C.Enumerated;break;case 12:c=C.Utf8String;break;case 13:c=C.RelativeObjectIdentifier;break;case 14:c=C.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=C.Sequence;break;case 17:c=C.Set;break;case 18:c=C.NumericString;break;case 19:c=C.PrintableString;break;case 20:c=C.TeletexString;break;case 21:c=C.VideotexString;break;case 22:c=C.IA5String;break;case 23:c=C.UTCTime;break;case 24:c=C.GeneralizedTime;break;case 25:c=C.GraphicString;break;case 26:c=C.VisibleString;break;case 27:c=C.GeneralString;break;case 28:c=C.UniversalString;break;case 29:c=C.CharacterString;break;case 30:c=C.BmpString;break;case 31:c=C.DATE;break;case 32:c=C.TimeOfDay;break;case 33:c=C.DateTime;break;case 34:c=C.Duration;break;default:{let f=o.idBlock.isConstructed?new C.Constructed:new C.Primitive;f.idBlock=o.idBlock,f.lenBlock=o.lenBlock,f.warnings=o.warnings,o=f}}break;case 2:case 3:case 4:default:c=o.idBlock.isConstructed?C.Constructed:C.Primitive}return o=Zp(o,c),a=o.fromBER(r,e,o.lenBlock.isIndefiniteForm?t:o.lenBlock.length),o.valueBeforeDecodeView=r.subarray(n,n+o.blockLength),{offset:a,result:o}}function Zr(r){if(!r.byteLength){let e=new ve({},Ie);return e.error="Input buffer has zero length",{offset:-1,result:e}}return ui(Y.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function Wp(r,e){return r?1:e}var pt=class extends Ie{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let o=Y.BufferSourceConverter.toUint8Array(e);if(!Nt(this,o,t,n))return-1;if(this.valueBeforeDecodeView=o.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let i=t;for(;Wp(this.isIndefiniteForm,n)>0;){let s=ui(o,i,n);if(s.offset===-1)return this.error=s.result.error,this.warnings.concat(s.result.warnings),-1;if(i=s.offset,this.blockLength+=s.result.blockLength,n-=s.result.blockLength,this.value.push(s.result),this.isIndefiniteForm&&s.result.constructor.NAME===An)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===An?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new Bn;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return t?it:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};pt.NAME="ConstructedValueBlock";var Ou,jt=class extends ve{constructor(e={}){super(e,pt),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
2
+ "use strict";var HeliaRouters=(()=>{var Th=Object.create;var Zn=Object.defineProperty;var Nh=Object.getOwnPropertyDescriptor;var Ch=Object.getOwnPropertyNames;var _h=Object.getPrototypeOf,Uh=Object.prototype.hasOwnProperty;var Wn=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ge=(r,e)=>{for(var t in e)Zn(r,t,{get:e[t],enumerable:!0})},oc=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ch(e))!Uh.call(r,o)&&o!==t&&Zn(r,o,{get:()=>e[o],enumerable:!(n=Nh(e,o))||n.enumerable});return r};var ir=(r,e,t)=>(t=r!=null?Th(_h(r)):{},oc(e||!r||!r.__esModule?Zn(t,"default",{value:r,enumerable:!0}):t,r)),Lh=r=>oc(Zn({},"__esModule",{value:!0}),r);var Tu=Wn(Zr=>{"use strict";var qp="[object ArrayBuffer]",Rt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===qp}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let n=r.toUint8Array(e),o=r.toUint8Array(t);if(n.length!==o.byteLength)return!1;for(let i=0;i<n.length;i++)if(n[i]!==o[i])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(let s of t)n+=s.byteLength;let o=new Uint8Array(n),i=0;for(let s of t){let a=this.toUint8Array(s);o.set(a,i),i+=a.length}return e[e.length-1]instanceof Function?this.toView(o,e[e.length-1]):o.buffer}},ca="string",zp=/^[0-9a-f]+$/i,Gp=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,jp=/^[a-zA-Z0-9-_]+$/,Ao=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n.buffer}static toString(e){let t=Rt.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}},Ze=class{static toString(e,t=!1){let n=Rt.toArrayBuffer(e),o=new DataView(n),i="";for(let s=0;s<n.byteLength;s+=2){let a=o.getUint16(s,t);i+=String.fromCharCode(a)}return i}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),o=new DataView(n);for(let i=0;i<e.length;i++)o.setUint16(i*2,e.charCodeAt(i),t);return n}},So=class r{static isHex(e){return typeof e===ca&&zp.test(e)}static isBase64(e){return typeof e===ca&&Gp.test(e)}static isBase64Url(e){return typeof e===ca&&jp.test(e)}static ToString(e,t="utf8"){let n=Rt.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return Ze.toString(n,!0);case"utf16":case"utf16be":return Ze.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return Ze.fromString(e,!0);case"utf16":case"utf16be":return Ze.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=Rt.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return Ao.fromString(e);case"utf16":case"utf16be":return Ze.fromString(e);case"utf16le":case"usc2":return Ze.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return Ao.toString(e);case"utf16":case"utf16be":return Ze.toString(e);case"utf16le":case"usc2":return Ze.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);return n.buffer}static ToBinary(e){let t=Rt.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=Rt.toUint8Array(e),n="",o=t.length;for(let i=0;i<o;i++){let s=t[i];s<16&&(n+="0"),n+=s.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);let n=new Uint8Array(t.length/2);for(let o=0;o<t.length;o=o+2){let i=t.slice(o,o+2);n[o/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(e,t=!1){return Ze.toString(e,t)}static FromUtf16String(e,t=!1){return Ze.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};So.DEFAULT_UTF8_ENCODING="utf8";function Yp(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let i in o)t[i]=o[i]}return t}function Zp(...r){let e=r.map(o=>o.byteLength).reduce((o,i)=>o+i),t=new Uint8Array(e),n=0;return r.map(o=>new Uint8Array(o)).forEach(o=>{for(let i of o)t[n++]=i}),t.buffer}function Wp(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<r.byteLength;o++)if(t[o]!==n[o])return!1;return!0}Zr.BufferSourceConverter=Rt;Zr.Convert=So;Zr.assign=Yp;Zr.combine=Zp;Zr.isEqual=Wp});var pi=Wn((mE,Dl)=>{"use strict";function Ol(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function Nm(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return Ol(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),Ol(new o,t)}}Dl.exports=Nm});var Aa=Wn((EE,Ba)=>{var xE=function(){typeof Ba<"u"&&(Ba.exports=m);var r=86400,e=3200,t=146097*e/400,n=r*t,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",f=Math.trunc||function(b){var v=b-b%1;return v==0&&(b<0||b===0&&1/b!=1/0)?-0:v},u=m.prototype,l=(m.fromDate=function(b){return new m(+b)},m.fromInt64BE=k(0,1,2,3,0,4),m.fromInt64LE=k(3,2,1,0,4,0),m.fromString=function(_){var v,F=new m,_=(_+="").replace(/^\s*[+\-]?\d+/,function(K){var K=+K,S=1970+(K-1970)%400;return F.year=K-S,S}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(N,K,S){return K<0&&(S*=-1),v=6e4*(60*+K+ +S),""}).replace(/\.\d+$/,function(N){return F.nano=+(N+c).substr(1,9),""}).split(/\D+/);if(1<_.length?_[1]--:_[1]=0,F.time=v=Date.UTC.apply(Date,_)-(v||0),isNaN(v))throw new TypeError("Invalid Date");return d(F)},m.fromTimeT=function(b){return R(b,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(b){return this.nano+=+b||0,this},u.getNano=function(){var b=d(this);return(b.time%1e3*a+ +b.nano+1e9)%1e9},u.getTimeT=function(){var v=d(this),b=Math.floor(v.time/1e3),v=v.year;return v&&(b+=v*t*r/e),b},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return E(d(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(b){var v=this,F=v.toDate(),_={H:function(){return O(F.getUTCHours())},L:function(){return C(F.getUTCMilliseconds(),3)},M:function(){return O(F.getUTCMinutes())},N:function(){return C(v.getNano(),9)},S:function(){return O(F.getUTCSeconds())},Y:function(){var N=v.getYear();return 999999<N?"+"+N:9999<N?"+"+C(N,6):0<=N?C(N,4):-999999<=N?"-"+C(-N,6):N},a:function(){return w[F.getUTCDay()]},b:function(){return h[F.getUTCMonth()]},d:function(){return O(F.getUTCDate())},e:function(){return function(N){return(9<N?"":" ")+(0|N)}(F.getUTCDate())},m:function(){return O(F.getUTCMonth()+1)}};return function N(K){return K.replace(/%./g,function(S){var g=S[1],I=B[g],g=_[g];return I?N(I):g?g():S})}(b||l)},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"),h=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],w=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],B={"%":"%",F:"%Y-%m-%d",n:`
3
+ `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return m;function m(b,v,F){var _=this;if(!(_ instanceof m))return new m(b,v,F);_.time=+b||0,_.nano=+v||0,_.year=+F||0,d(_)}function d(b){var v,F,_,N=b.year,K=b.time,S=b.nano,I=((S<0||a<=S)&&(S-=(F=Math.floor(S/a))*a,K+=F,F=1),N%e);return(K<-i||i<K||I)&&((v=f(K/o))&&(N+=v*e,K-=v*o),(_=E(K)).setUTCFullYear(I+_.getUTCFullYear()),_=(K=+_)+(v=f((N-=I)/e))*o,v&&-i<=_&&_<=i&&(N-=v*e,K=_),F=1),F&&(b.year=N,b.time=K,b.nano=S),b}function E(b){var v=new Date(0);return v.setTime(b),v}function R(N,_){N=+N||0;var F=f((_=(_|0)*s)/n)+f(N/n),_=_%n+N%n,N=f(_/n);return N&&(F+=N,_-=N*n),new m(1e3*_,0,F*e)}function y(b,v,F,_,N,K){return function(I,g){var A=d(this);I=I||new Array(8),P(I,g|=0);var D=Math.floor(A.time/1e3),A=A.year*(t*r/e),p=f(A/s)+f(D/s),A=A%s+D%s,D=Math.floor(A/s);return D&&(p+=D,A-=D*s),S(I,g+N,p),S(I,g+K,A),I};function S(I,g,p){I[g+b]=p>>24&255,I[g+v]=p>>16&255,I[g+F]=p>>8&255,I[g+_]=255&p}}function k(b,v,F,_,N,K){return function(I,g){P(I,g|=0);var p=S(I,g+N);return R(S(I,g+K),p)};function S(I,g){return 16777216*I[g+b]+(I[g+v]<<16|I[g+F]<<8|I[g+_])}}function P(b,v){if(b=b&&b.length,b==null)throw new TypeError("Invalid Buffer");if(b<v+8)throw new RangeError("Out of range")}function O(b){return(9<b?"":"0")+(0|b)}function C(b,v){return(c+(0|b)).substr(-v)}}()});var th=Wn((lv,La)=>{"use strict";var mg=Object.prototype.hasOwnProperty,Ue="~";function zn(){}Object.create&&(zn.prototype=Object.create(null),new zn().__proto__||(Ue=!1));function gg(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function eh(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new gg(t,n||r,o),s=Ue?Ue+e:e;return r._events[s]?r._events[s].fn?r._events[s]=[r._events[s],i]:r._events[s].push(i):(r._events[s]=i,r._eventsCount++),r}function Ti(r,e){--r._eventsCount===0?r._events=new zn:delete r._events[e]}function ke(){this._events=new zn,this._eventsCount=0}ke.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)mg.call(t,n)&&e.push(Ue?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};ke.prototype.listeners=function(e){var t=Ue?Ue+e:e,n=this._events[t];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};ke.prototype.listenerCount=function(e){var t=Ue?Ue+e:e,n=this._events[t];return n?n.fn?1:n.length:0};ke.prototype.emit=function(e,t,n,o,i,s){var a=Ue?Ue+e:e;if(!this._events[a])return!1;var c=this._events[a],f=arguments.length,u,l;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,o),!0;case 5:return c.fn.call(c.context,t,n,o,i),!0;case 6:return c.fn.call(c.context,t,n,o,i,s),!0}for(l=1,u=new Array(f-1);l<f;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var h=c.length,w;for(l=0;l<h;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),f){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;case 4:c[l].fn.call(c[l].context,t,n,o);break;default:if(!u)for(w=1,u=new Array(f-1);w<f;w++)u[w-1]=arguments[w];c[l].fn.apply(c[l].context,u)}}return!0};ke.prototype.on=function(e,t,n){return eh(this,e,t,n,!1)};ke.prototype.once=function(e,t,n){return eh(this,e,t,n,!0)};ke.prototype.removeListener=function(e,t,n,o){var i=Ue?Ue+e:e;if(!this._events[i])return this;if(!t)return Ti(this,i),this;var s=this._events[i];if(s.fn)s.fn===t&&(!o||s.once)&&(!n||s.context===n)&&Ti(this,i);else{for(var a=0,c=[],f=s.length;a<f;a++)(s[a].fn!==t||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:Ti(this,i)}return this};ke.prototype.removeAllListeners=function(e){var t;return e?(t=Ue?Ue+e:e,this._events[t]&&Ti(this,t)):(this._events=new zn,this._eventsCount=0),this};ke.prototype.off=ke.prototype.removeListener;ke.prototype.addListener=ke.prototype.on;ke.prefixed=Ue;ke.EventEmitter=ke;typeof La<"u"&&(La.exports=ke)});var Pg={};ge(Pg,{delegatedHTTPRouting:()=>fh,httpGatewayRouting:()=>bh,libp2pRouting:()=>xh});var ic=Symbol.for("@libp2p/content-routing");var Er=Symbol.for("@libp2p/peer-id");function sc(r){return r!=null&&!!r[Er]}var ac=Symbol.for("@libp2p/peer-routing");var V=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var vr=(r,...e)=>{try{[...e]}catch{}};var $i={};ge($i,{base32:()=>Xe,base32hex:()=>Hh,base32hexpad:()=>qh,base32hexpadupper:()=>zh,base32hexupper:()=>Kh,base32pad:()=>Mh,base32padupper:()=>$h,base32upper:()=>pc,base32z:()=>Gh});var zg=new Uint8Array(0);function cc(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function xt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function uc(r){return new TextEncoder().encode(r)}function lc(r){return new TextDecoder().decode(r)}function Oh(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=o}var a=r.length,c=r.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(B){if(B instanceof Uint8Array||(ArrayBuffer.isView(B)?B=new Uint8Array(B.buffer,B.byteOffset,B.byteLength):Array.isArray(B)&&(B=Uint8Array.from(B))),!(B instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(B.length===0)return"";for(var m=0,d=0,E=0,R=B.length;E!==R&&B[E]===0;)E++,m++;for(var y=(R-E)*u+1>>>0,k=new Uint8Array(y);E!==R;){for(var P=B[E],O=0,C=y-1;(P!==0||O<d)&&C!==-1;C--,O++)P+=256*k[C]>>>0,k[C]=P%a>>>0,P=P/a>>>0;if(P!==0)throw new Error("Non-zero carry");d=O,E++}for(var b=y-d;b!==y&&k[b]===0;)b++;for(var v=c.repeat(m);b<y;++b)v+=r.charAt(k[b]);return v}function h(B){if(typeof B!="string")throw new TypeError("Expected String");if(B.length===0)return new Uint8Array;var m=0;if(B[m]!==" "){for(var d=0,E=0;B[m]===c;)d++,m++;for(var R=(B.length-m)*f+1>>>0,y=new Uint8Array(R);B[m];){var k=t[B.charCodeAt(m)];if(k===255)return;for(var P=0,O=R-1;(k!==0||P<E)&&O!==-1;O--,P++)k+=a*y[O]>>>0,y[O]=k%256>>>0,k=k/256>>>0;if(k!==0)throw new Error("Non-zero carry");E=P,m++}if(B[m]!==" "){for(var C=R-E;C!==R&&y[C]===0;)C++;for(var b=new Uint8Array(d+(R-C)),v=d;C!==R;)b[v++]=y[C++];return b}}}function w(B){var m=h(B);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:h,decode:w}}var Dh=Oh,Vh=Dh,hc=Vh;var Vi=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Pi=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return dc(this,e)}},Fi=class{decoders;constructor(e){this.decoders=e}or(e){return dc(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function dc(r,e){return new Fi({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Mi=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Vi(e,t,n),this.decoder=new Pi(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Br({name:r,prefix:e,encode:t,decode:n}){return new Mi(r,e,t,n)}function Vt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=hc(t,r);return Br({prefix:e,name:r,encode:n,decode:i=>xt(o(i))})}function Ph(r,e,t,n){let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*t/8|0),a=0,c=0,f=0;for(let u=0;u<i;++u){let l=o[r[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|l,a+=t,a>=8&&(a-=8,s[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function Fh(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,i="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>t;)s-=t,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<t-s]),n)for(;i.length*t&7;)i+="=";return i}function ie({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Br({prefix:e,name:r,encode(o){return Fh(o,n,t)},decode(o){return Ph(o,n,t,r)}})}var Xe=ie({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pc=ie({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Mh=ie({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),$h=ie({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Hh=ie({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Kh=ie({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),qh=ie({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),zh=ie({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Gh=ie({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Hi={};ge(Hi,{base58btc:()=>ce,base58flickr:()=>jh});var ce=Vt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),jh=Vt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ki={};ge(Ki,{base64:()=>ln,base64pad:()=>Yh,base64url:()=>Zh,base64urlpad:()=>Wh});var ln=ie({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Yh=ie({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Zh=ie({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Wh=ie({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Jh(r,e){try{if(typeof r=="string"&&r.length>0)return Xh(r);if(typeof r=="number"&&isFinite(r))return e?.long?ed(r):Qh(r);throw new Error("Value is not a string or number.")}catch(t){let n=td(t)?`${t.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function Xh(r){if(r=String(r),r.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(!e)return NaN;let t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*315576e5;case"weeks":case"week":case"w":return t*6048e5;case"days":case"day":case"d":return t*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return t*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return t*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return t*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var Xn=Jh;function Qh(r){let e=Math.abs(r);return e>=864e5?`${Math.round(r/864e5)}d`:e>=36e5?`${Math.round(r/36e5)}h`:e>=6e4?`${Math.round(r/6e4)}m`:e>=1e3?`${Math.round(r/1e3)}s`:`${r}ms`}function ed(r){let e=Math.abs(r);return e>=864e5?Jn(r,e,864e5,"day"):e>=36e5?Jn(r,e,36e5,"hour"):e>=6e4?Jn(r,e,6e4,"minute"):e>=1e3?Jn(r,e,1e3,"second"):`${r} ms`}function Jn(r,e,t,n){let o=e>=t*1.5;return`${Math.round(r/t)} ${n}${o?"s":""}`}function td(r){return typeof r=="object"&&r!==null&&"message"in r}function qi(r){t.debug=t,t.default=t,t.coerce=c,t.disable=i,t.enable=o,t.enabled=s,t.humanize=Xn,t.destroy=f,Object.keys(r).forEach(u=>{t[u]=r[u]}),t.names=[],t.skips=[],t.formatters={};function e(u){let l=0;for(let h=0;h<u.length;h++)l=(l<<5)-l+u.charCodeAt(h),l|=0;return t.colors[Math.abs(l)%t.colors.length]}t.selectColor=e;function t(u){let l,h=null,w,B;function m(...d){if(!m.enabled)return;let E=m,R=Number(new Date),y=R-(l||R);E.diff=y,E.prev=l,E.curr=R,l=R,d[0]=t.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let k=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(O,C)=>{if(O==="%%")return"%";k++;let b=t.formatters[C];if(typeof b=="function"){let v=d[k];O=b.call(E,v),d.splice(k,1),k--}return O}),t.formatArgs.call(E,d),(E.log||t.log).apply(E,d)}return m.namespace=u,m.useColors=t.useColors(),m.color=t.selectColor(u),m.extend=n,m.destroy=t.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(w!==t.namespaces&&(w=t.namespaces,B=t.enabled(u)),B),set:d=>{h=d}}),typeof t.init=="function"&&t.init(m),m}function n(u,l){let h=t(this.namespace+(typeof l>"u"?":":l)+u);return h.log=this.log,h}function o(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let l,h=(typeof u=="string"?u:"").split(/[\s,]+/),w=h.length;for(l=0;l<w;l++)h[l]&&(u=h[l].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.substr(1)+"$")):t.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...t.names.map(a),...t.skips.map(a).map(l=>"-"+l)].join(",");return t.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,h;for(l=0,h=t.skips.length;l<h;l++)if(t.skips[l].test(u))return!1;for(l=0,h=t.names.length;l<h;l++)if(t.names[l].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.setupFormatters(t.formatters),t.enable(t.load()),t}var Qn=cd(),rd=["#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 nd(){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 od(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Xn(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}var id=console.debug??console.log??(()=>{});function sd(r){try{r?Qn?.setItem("debug",r):Qn?.removeItem("debug")}catch{}}function ad(){let r;try{r=Qn?.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function cd(){try{return localStorage}catch{}}function ud(r){r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}var mc=qi({formatArgs:od,save:sd,load:ad,useColors:nd,setupFormatters:ud,colors:rd,storage:Qn,log:id});var Me=mc;Me.formatters.b=r=>r==null?"undefined":ce.baseEncode(r);Me.formatters.t=r=>r==null?"undefined":Xe.baseEncode(r);Me.formatters.m=r=>r==null?"undefined":ln.baseEncode(r);Me.formatters.p=r=>r==null?"undefined":r.toString();Me.formatters.c=r=>r==null?"undefined":r.toString();Me.formatters.k=r=>r==null?"undefined":r.toString();Me.formatters.a=r=>r==null?"undefined":r.toString();function ld(r){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=r,e.destroy=()=>!0,e.extend=()=>e,e}function Pt(r){let e=ld(`${r}:trace`);return Me.enabled(`${r}:trace`)&&Me.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=Me(`${r}:trace`)),Object.assign(Me(r),{error:Me(`${r}:error`),trace:e})}var zi={};ge(zi,{base10:()=>fd});var fd=Vt({prefix:"9",name:"base10",alphabet:"0123456789"});var Gi={};ge(Gi,{base16:()=>hd,base16upper:()=>dd});var hd=ie({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),dd=ie({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ji={};ge(ji,{base2:()=>pd});var pd=ie({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Yi={};ge(Yi,{base256emoji:()=>bd});var gc=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}"),md=gc.reduce((r,e,t)=>(r[t]=e,r),[]),gd=gc.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function yd(r){return r.reduce((e,t)=>(e+=md[t],e),"")}function wd(r){let e=[];for(let t of r){let n=gd[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var bd=Br({prefix:"\u{1F680}",name:"base256emoji",encode:yd,decode:wd});var Zi={};ge(Zi,{base36:()=>eo,base36upper:()=>xd});var eo=Vt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),xd=Vt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Wi={};ge(Wi,{base8:()=>Ed});var Ed=ie({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ji={};ge(Ji,{identity:()=>vd});var vd=Br({prefix:"\0",name:"identity",encode:r=>lc(r),decode:r=>uc(r)});var xy=new TextEncoder,Ey=new TextDecoder;var Qi={};ge(Qi,{identity:()=>$e});var Sd=bc,yc=128,Id=127,Rd=~Id,kd=Math.pow(2,31);function bc(r,e,t){e=e||[],t=t||0;for(var n=t;r>=kd;)e[t++]=r&255|yc,r/=128;for(;r&Rd;)e[t++]=r&255|yc,r>>>=7;return e[t]=r|0,bc.bytes=t-n+1,e}var Td=Xi,Nd=128,wc=127;function Xi(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw Xi.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&wc)<<o:(s&wc)*Math.pow(2,o),o+=7}while(s>=Nd);return Xi.bytes=i-n,t}var Cd=Math.pow(2,7),_d=Math.pow(2,14),Ud=Math.pow(2,21),Ld=Math.pow(2,28),Od=Math.pow(2,35),Dd=Math.pow(2,42),Vd=Math.pow(2,49),Pd=Math.pow(2,56),Fd=Math.pow(2,63),Md=function(r){return r<Cd?1:r<_d?2:r<Ud?3:r<Ld?4:r<Od?5:r<Dd?6:r<Vd?7:r<Pd?8:r<Fd?9:10},$d={encode:Sd,decode:Td,encodingLength:Md},Hd=$d,fn=Hd;function hn(r,e=0){return[fn.decode(r,e),fn.decode.bytes]}function Ar(r,e,t=0){return fn.encode(r,e,t),e}function Sr(r){return fn.encodingLength(r)}function ft(r,e){let t=e.byteLength,n=Sr(r),o=n+Sr(t),i=new Uint8Array(o+t);return Ar(r,i,0),Ar(t,i,n),i.set(e,o),new Ir(r,t,e,i)}function Ft(r){let e=xt(r),[t,n]=hn(e),[o,i]=hn(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Ir(t,o,s,e)}function xc(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&cc(r.bytes,t.bytes)}}var Ir=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var Ec=0,Kd="identity",vc=xt;function qd(r){return ft(Ec,vc(r))}var $e={code:Ec,name:Kd,encode:vc,digest:qd};var rs={};ge(rs,{sha256:()=>ve,sha512:()=>zd});function ts({name:r,code:e,encode:t}){return new es(r,e,t)}var es=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?ft(this.code,t):t.then(n=>ft(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Ac(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var ve=ts({name:"sha2-256",code:18,encode:Ac("SHA-256")}),zd=ts({name:"sha2-512",code:19,encode:Ac("SHA-512")});function Sc(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return jd(t,ns(r),e??ce.encoder);default:return Yd(t,ns(r),e??Xe.encoder)}}var Ic=new WeakMap;function ns(r){let e=Ic.get(r);if(e==null){let t=new Map;return Ic.set(r,t),t}return e}var ye=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==dn)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Zd)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=ft(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&xc(e.multihash,n.multihash)}toString(e){return Sc(this,e)}toJSON(){return{"/":Sc(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:i,bytes:s}=t;return new r(n,o,i,s??Rc(n,o,i.bytes))}else if(t[Wd]===!0){let{version:n,multihash:o,code:i}=t,s=Ft(o);return r.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==dn)throw new Error(`Version 0 CID must use dag-pb (code: ${dn}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Rc(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,dn,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=xt(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new Ir(t.multihashCode,t.digestSize,i,o);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,h]=hn(e.subarray(t));return t+=h,l},o=n(),i=dn;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,a=n(),c=n(),f=t+c,u=f-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=Gd(e,t),i=r.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ns(i).set(n,e),i}};function Gd(r,e){switch(r[0]){case"Q":{let t=e??ce;return[ce.prefix,t.decode(`${ce.prefix}${r}`)]}case ce.prefix:{let t=e??ce;return[ce.prefix,t.decode(r)]}case Xe.prefix:{let t=e??Xe;return[Xe.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function jd(r,e,t){let{prefix:n}=t;if(n!==ce.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o}function Yd(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o}var dn=112,Zd=18;function Rc(r,e,t){let n=Sr(r),o=n+Sr(e),i=new Uint8Array(o+t.byteLength);return Ar(r,i,0),Ar(e,i,n),i.set(t,o),i}var Wd=Symbol.for("@ipld/js-cid/CID");var $t={...Ji,...ji,...Wi,...zi,...Gi,...$i,...Zi,...Hi,...Ki,...Yi},Hy={...rs,...Qi};function se(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function Qe(r=0){return new Uint8Array(r)}function Tc(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var kc=Tc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),os=Tc("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=Qe(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Jd={utf8:kc,"utf-8":kc,hex:$t.base16,latin1:os,ascii:os,binary:os,...$t},ro=Jd;function z(r,e="utf8"){let t=ro[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function G(r,e="utf8"){let t=ro[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var Cc=Symbol.for("nodejs.util.inspect.custom"),Nc=Object.values($t).map(r=>r.decoder).reduce((r,e)=>r.or(e),$t.identity.decoder),_c=114,as=36,cs=37,pn=class{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Er]=!0;toString(){return this.string==null&&(this.string=ce.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return ye.createV1(_c,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return se(this.multihash.bytes,e);if(typeof e=="string")return us(e).equals(this);if(e?.multihash?.bytes!=null)return se(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[Cc](){return`PeerId(${this.toString()})`}},Rr=class extends pn{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},kr=class extends pn{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Tr=class extends pn{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}},is=2336,ss=class{type="url";multihash;privateKey;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=$e.digest(z(this.url))}[Cc](){return`PeerId(${this.url})`}[Er]=!0;toString(){return this.toCID().toString()}toCID(){return ye.createV1(is,this.multihash)}toBytes(){return this.toCID().bytes}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=G(e)),e.toString()===this.toString())}};function us(r,e){if(e=e??Nc,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=Ft(ce.decode(`z${r}`));return r.startsWith("12D")?new kr({multihash:t}):r.startsWith("16U")?new Tr({multihash:t}):new Rr({multihash:t})}return mn(Nc.decode(r))}function mn(r){try{let e=Ft(r);if(e.code===$e.code){if(e.digest.length===as)return new kr({multihash:e});if(e.digest.length===cs)return new Tr({multihash:e})}if(e.code===ve.code)return new Rr({multihash:e})}catch{return Xd(ye.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Xd(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==_c&&r.code!==is)throw new Error("Supplied PeerID CID is invalid");if(r.code===is){let t=G(r.multihash.digest);return new ss(new URL(t))}let e=r.multihash;if(e.code===ve.code)return new Rr({multihash:r.multihash});if(e.code===$e.code){if(e.digest.length===as)return new kr({multihash:r.multihash});if(e.digest.length===cs)return new Tr({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function Uc(r,e){return r.length===as?new kr({multihash:ft($e.code,r),privateKey:e}):r.length===cs?new Tr({multihash:ft($e.code,r),privateKey:e}):new Rr({multihash:await ve.digest(r),publicKey:r,privateKey:e})}var Qd=Math.pow(2,7),e0=Math.pow(2,14),t0=Math.pow(2,21),ls=Math.pow(2,28),fs=Math.pow(2,35),hs=Math.pow(2,42),ds=Math.pow(2,49),X=128,Se=127;function De(r){if(r<Qd)return 1;if(r<e0)return 2;if(r<t0)return 3;if(r<ls)return 4;if(r<fs)return 5;if(r<hs)return 6;if(r<ds)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ps(r,e,t=0){switch(De(r)){case 8:e[t++]=r&255|X,r/=128;case 7:e[t++]=r&255|X,r/=128;case 6:e[t++]=r&255|X,r/=128;case 5:e[t++]=r&255|X,r/=128;case 4:e[t++]=r&255|X,r>>>=7;case 3:e[t++]=r&255|X,r>>>=7;case 2:e[t++]=r&255|X,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function r0(r,e,t=0){switch(De(r)){case 8:e.set(t++,r&255|X),r/=128;case 7:e.set(t++,r&255|X),r/=128;case 6:e.set(t++,r&255|X),r/=128;case 5:e.set(t++,r&255|X),r/=128;case 4:e.set(t++,r&255|X),r>>>=7;case 3:e.set(t++,r&255|X),r>>>=7;case 2:e.set(t++,r&255|X),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function ms(r,e){let t=r[e],n=0;if(n+=t&Se,t<X||(t=r[e+1],n+=(t&Se)<<7,t<X)||(t=r[e+2],n+=(t&Se)<<14,t<X)||(t=r[e+3],n+=(t&Se)<<21,t<X)||(t=r[e+4],n+=(t&Se)*ls,t<X)||(t=r[e+5],n+=(t&Se)*fs,t<X)||(t=r[e+6],n+=(t&Se)*hs,t<X)||(t=r[e+7],n+=(t&Se)*ds,t<X))return n;throw new RangeError("Could not decode varint")}function n0(r,e){let t=r.get(e),n=0;if(n+=t&Se,t<X||(t=r.get(e+1),n+=(t&Se)<<7,t<X)||(t=r.get(e+2),n+=(t&Se)<<14,t<X)||(t=r.get(e+3),n+=(t&Se)<<21,t<X)||(t=r.get(e+4),n+=(t&Se)*ls,t<X)||(t=r.get(e+5),n+=(t&Se)*fs,t<X)||(t=r.get(e+6),n+=(t&Se)*hs,t<X)||(t=r.get(e+7),n+=(t&Se)*ds,t<X))return n;throw new RangeError("Could not decode varint")}function Nr(r,e,t=0){return e==null&&(e=Qe(De(r))),e instanceof Uint8Array?ps(r,e,t):r0(r,e,t)}function sr(r,e=0){return r instanceof Uint8Array?ms(r,e):n0(r,e)}function Ne(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=Qe(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}var no=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}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(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let h=Number.parseInt(l,e);if(!Number.isNaN(h))return h});if(u===void 0)break;if(i*=e,i+=u,i>f||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2],t[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];t[o]=i>>8,t[o+1]=i&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=e(i.subarray(0,s));return t.set(i.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Oc=45,o0=15,Cr=new no;function gs(r){if(!(r.length>o0))return Cr.new(r).parseWith(()=>Cr.readIPv4Addr())}function ys(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Oc))return Cr.new(r).parseWith(()=>Cr.readIPv6Addr())}function oo(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Oc))return Cr.new(r).parseWith(()=>Cr.readIPAddr())}var Aw=parseInt("0xFFFF",16),Sw=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Pc(r){return!!gs(r)}function Fc(r){return!!ys(r)}function io(r){return!!oo(r)}var Mc=Pc,u0=Fc,ws=function(r){let e=0;if(r=r.toString().trim(),Mc(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(u0(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=Mc(t[n]),s;i&&(s=ws(t[n]),t[n]=G(s.slice(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,G(s.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let i=[n,1];for(n=9-t.length;n>0;n--)i.push("0");t.splice.apply(t,i)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){let i=parseInt(t[n],16);o[e++]=i>>8&255,o[e++]=i&255}return o}throw new Error("invalid ip address")},$c=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let i=0;i<t;i++)o.push(r[e+i]);return o.join(".")}if(t===16){let o=[];for(let i=0;i<t;i+=2)o.push(n.getUint16(e+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var _r={},bs={},f0=[[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"]];f0.forEach(r=>{let e=h0(...r);bs[e.code]=e,_r[e.name]=e});function h0(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function te(r){if(typeof r=="number"){if(bs[r]!=null)return bs[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(_r[r]!=null)return _r[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var cb=te("ip4"),ub=te("ip6"),lb=te("ipcidr");function Bs(r,e){switch(te(r).code){case 4:case 41:return p0(e);case 42:return vs(e);case 6:case 273:case 33:case 132:return qc(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return vs(e);case 421:return w0(e);case 444:return Kc(e);case 445:return Kc(e);case 466:return y0(e);case 481:return globalThis.encodeURIComponent(vs(e));default:return G(e,"base16")}}function As(r,e){switch(te(r).code){case 4:return Hc(e);case 41:return Hc(e);case 42:return Es(e);case 6:case 273:case 33:case 132:return Ss(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Es(e);case 421:return m0(e);case 444:return b0(e);case 445:return x0(e);case 466:return g0(e);case 481:return Es(globalThis.decodeURIComponent(e));default:return z(e,"base16")}}var xs=Object.values($t).map(r=>r.decoder),d0=function(){let r=xs[0].or(xs[1]);return xs.slice(2).forEach(e=>r=r.or(e)),r}();function Hc(r){if(!io(r))throw new Error("invalid ip address");return ws(r)}function p0(r){let e=$c(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!io(e))throw new Error("invalid ip address");return e}function Ss(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function qc(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Es(r){let e=z(r),t=Uint8Array.from(Nr(e.length));return Ne([t,e],t.length+e.length)}function vs(r){let e=sr(r);if(r=r.slice(De(e)),r.length!==e)throw new Error("inconsistent lengths");return G(r)}function m0(r){let e;r[0]==="Q"||r[0]==="1"?e=Ft(ce.decode(`z${r}`)).bytes:e=ye.parse(r).multihash.bytes;let t=Uint8Array.from(Nr(e.length));return Ne([t,e],t.length+e.length)}function g0(r){let e=d0.decode(r),t=Uint8Array.from(Nr(e.length));return Ne([t,e],t.length+e.length)}function y0(r){let e=sr(r),t=r.slice(De(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+G(t,"base64url")}function w0(r){let e=sr(r),t=r.slice(De(e));if(t.length!==e)throw new Error("inconsistent lengths");return G(t,"base58btc")}function b0(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=Xe.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ss(n);return Ne([t,o],t.length+o.length)}function x0(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=Xe.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ss(n);return Ne([t,o],t.length+o.length)}function Kc(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=G(e,"base32"),o=qc(t);return`${n}:${o}`}function zc(r){r=Is(r);let e=[],t=[],n=null,o=r.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=te(s);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(i++,i>=o.length)throw jc("invalid address: "+r);if(a.path===!0){n=Is(o.slice(i).join("/")),e.push([a.code,As(a.code,n)]),t.push([a.code,n]);break}let c=As(a.code,o[i]);e.push([a.code,c]),t.push([a.code,Bs(a.code,c)])}return{string:Gc(t),bytes:ks(e),tuples:e,stringTuples:t,path:n}}function Rs(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let i=sr(r,o),s=De(i),a=te(i),c=E0(a,r.slice(o+s));if(c===0){e.push([i]),t.push([i]),o+=s;continue}let f=r.slice(o+s,o+s+c);if(o+=c+s,o>r.length)throw jc("Invalid address Uint8Array: "+G(r,"base16"));e.push([i,f]);let u=Bs(i,f);if(t.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Gc(t),tuples:e,stringTuples:t,path:n}}function Gc(r){let e=[];return r.map(t=>{let n=te(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),Is(e.join("/"))}function ks(r){return Ne(r.map(e=>{let t=te(e[0]),n=Uint8Array.from(Nr(t.code));return e.length>1&&e[1]!=null&&(n=Ne([n,e[1]])),n}))}function E0(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=sr(e instanceof Uint8Array?e:Uint8Array.from(e));return t+De(t)}}function Is(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function jc(r){return new Error("Error parsing address: "+r)}var v0=Symbol.for("nodejs.util.inspect.custom"),Ns=Symbol.for("@multiformats/js-multiaddr/multiaddr"),B0=[te("dns").code,te("dns4").code,te("dns6").code,te("dnsaddr").code],Ts=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},so=class r{bytes;#e;#r;#i;#a;[Ns]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=Rs(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=zc(e)}else if(Zc(e))t=Rs(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#r=t.tuples,this.#i=t.stringTuples,this.#a=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,o,i="",s=te("tcp"),a=te("udp"),c=te("ip4"),f=te("ip6"),u=te("dns6"),l=te("ip6zone");for(let[w,B]of this.stringTuples())w===l.code&&(i=`%${B??""}`),B0.includes(w)&&(t=s.name,o=443,n=`${B??""}${i}`,e=w===u.code?6:4),(w===s.code||w===a.code)&&(t=te(w).name,o=parseInt(B??"")),(w===c.code||w===f.code)&&(t=te(w).name,n=`${B??""}${i}`,e=w===f.code?6:4);if(e==null||t==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:e,host:n,transport:t,port:o}}protos(){return this.#r.map(([e])=>Object.assign({},te(e)))}protoCodes(){return this.#r.map(([e])=>e)}protoNames(){return this.#r.map(([e])=>te(e).name)}tuples(){return this.#r}stringTuples(){return this.#i}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(ks(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===_r.p2p.code&&e.push([n,o]),n===_r["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?G(ce.decode(`z${n}`),"base58btc"):G(ye.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(e){return se(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(i=>i.resolvable);if(t==null)return[this];let n=Yc.get(t.name);if(n==null)throw new Ts(`no available resolver for ${t.name}`);return(await n(this,e)).map(i=>ar(i))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[v0](){return`Multiaddr(${this.#e})`}};var Yc=new Map;function Zc(r){return!!r?.[Ns]}function ar(r){return new so(r)}function gn(r){let e=new globalThis.AbortController;function t(){e.abort();for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}for(let i of r){if(i?.aborted===!0){t();break}i?.addEventListener!=null&&i.addEventListener("abort",t)}function n(){for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}let o=e.signal;return o.clear=n,o}async function*ao(r,e={}){let t=r.getReader();try{for(;;){let n=await t.read();if(n.done)return;yield n.value}}finally{e.preventCancel!==!0&&await t.cancel(),t.releaseLock()}}var sa={};ge(sa,{Ed25519PrivateKey:()=>gr,Ed25519PublicKey:()=>An,generateKeyPair:()=>$p,generateKeyPairFromSeed:()=>ku,unmarshalEd25519PrivateKey:()=>Fp,unmarshalEd25519PublicKey:()=>Mp});function Ye(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Ur(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function A0(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Lr(r,...e){if(!A0(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${r.length}`)}function co(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ur(r.outputLen),Ur(r.blockLen)}function Or(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function Wc(r,e){Lr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var cr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Vr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),et=(r,e)=>r<<32-e|r>>>e;var Kb=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var S0=async()=>{};async function Jc(r,e,t){let n=Date.now();for(let o=0;o<r;o++){t(o);let i=Date.now()-n;i>=0&&i<e||(await S0(),n+=i)}}function Xc(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Ht(r){return typeof r=="string"&&(r=Xc(r)),Lr(r),r}function Cs(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];Lr(o),e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let i=r[n];t.set(i,o),o+=i.length}return t}var Dr=class{clone(){return this._cloneInto()}},I0={}.toString;function Qc(r,e){if(e!==void 0&&I0.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function uo(r){let e=n=>r().update(Ht(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Pr(r=32){if(cr&&typeof cr.getRandomValues=="function")return cr.getRandomValues(new Uint8Array(r));if(cr&&typeof cr.randomBytes=="function")return cr.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function R0(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(t>>o&i),a=Number(t&i),c=n?4:0,f=n?0:4;r.setUint32(e+c,s,n),r.setUint32(e+f,a,n)}var eu=(r,e,t)=>r&e^~r&t,tu=(r,e,t)=>r&e^r&t^e&t,Fr=class extends Dr{constructor(e,t,n,o){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Vr(this.buffer)}update(e){Or(this);let{view:t,buffer:n,blockLen:o}=this;e=Ht(e);let i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Vr(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Or(this),Wc(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)t[l]=0;R0(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Vr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.length=o,e.pos=a,e.finished=i,e.destroyed=s,o%t&&e.buffer.set(n),e}};var lo=BigInt(4294967295),_s=BigInt(32);function ru(r,e=!1){return e?{h:Number(r&lo),l:Number(r>>_s&lo)}:{h:Number(r>>_s&lo)|0,l:Number(r&lo)|0}}function k0(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:i,l:s}=ru(r[o],e);[t[o],n[o]]=[i,s]}return[t,n]}var T0=(r,e)=>BigInt(r>>>0)<<_s|BigInt(e>>>0),N0=(r,e,t)=>r>>>t,C0=(r,e,t)=>r<<32-t|e>>>t,_0=(r,e,t)=>r>>>t|e<<32-t,U0=(r,e,t)=>r<<32-t|e>>>t,L0=(r,e,t)=>r<<64-t|e>>>t-32,O0=(r,e,t)=>r>>>t-32|e<<64-t,D0=(r,e)=>e,V0=(r,e)=>r,P0=(r,e,t)=>r<<t|e>>>32-t,F0=(r,e,t)=>e<<t|r>>>32-t,M0=(r,e,t)=>e<<t-32|r>>>64-t,$0=(r,e,t)=>r<<t-32|e>>>64-t;function H0(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var K0=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),q0=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,z0=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),G0=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,j0=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),Y0=(r,e,t,n,o,i)=>e+t+n+o+i+(r/2**32|0)|0;var Z0={fromBig:ru,split:k0,toBig:T0,shrSH:N0,shrSL:C0,rotrSH:_0,rotrSL:U0,rotrBH:L0,rotrBL:O0,rotr32H:D0,rotr32L:V0,rotlSH:P0,rotlSL:F0,rotlBH:M0,rotlBL:$0,add:H0,add3L:K0,add3H:q0,add4L:z0,add4H:G0,add5H:Y0,add5L:j0},q=Z0;var[W0,J0]=q.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Kt=new Uint32Array(80),qt=new Uint32Array(80),Us=class extends Fr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:h,Gh:w,Gl:B,Hh:m,Hl:d}=this;return[e,t,n,o,i,s,a,c,f,u,l,h,w,B,m,d]}set(e,t,n,o,i,s,a,c,f,u,l,h,w,B,m,d){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=h|0,this.Gh=w|0,this.Gl=B|0,this.Hh=m|0,this.Hl=d|0}process(e,t){for(let y=0;y<16;y++,t+=4)Kt[y]=e.getUint32(t),qt[y]=e.getUint32(t+=4);for(let y=16;y<80;y++){let k=Kt[y-15]|0,P=qt[y-15]|0,O=q.rotrSH(k,P,1)^q.rotrSH(k,P,8)^q.shrSH(k,P,7),C=q.rotrSL(k,P,1)^q.rotrSL(k,P,8)^q.shrSL(k,P,7),b=Kt[y-2]|0,v=qt[y-2]|0,F=q.rotrSH(b,v,19)^q.rotrBH(b,v,61)^q.shrSH(b,v,6),_=q.rotrSL(b,v,19)^q.rotrBL(b,v,61)^q.shrSL(b,v,6),N=q.add4L(C,_,qt[y-7],qt[y-16]),K=q.add4H(N,O,F,Kt[y-7],Kt[y-16]);Kt[y]=K|0,qt[y]=N|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:h,Fh:w,Fl:B,Gh:m,Gl:d,Hh:E,Hl:R}=this;for(let y=0;y<80;y++){let k=q.rotrSH(l,h,14)^q.rotrSH(l,h,18)^q.rotrBH(l,h,41),P=q.rotrSL(l,h,14)^q.rotrSL(l,h,18)^q.rotrBL(l,h,41),O=l&w^~l&m,C=h&B^~h&d,b=q.add5L(R,P,C,J0[y],qt[y]),v=q.add5H(b,E,k,O,W0[y],Kt[y]),F=b|0,_=q.rotrSH(n,o,28)^q.rotrBH(n,o,34)^q.rotrBH(n,o,39),N=q.rotrSL(n,o,28)^q.rotrBL(n,o,34)^q.rotrBL(n,o,39),K=n&i^n&a^i&a,S=o&s^o&c^s&c;E=m|0,R=d|0,m=w|0,d=B|0,w=l|0,B=h|0,{h:l,l:h}=q.add(f|0,u|0,v|0,F|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let I=q.add3L(F,N,S);n=q.add3H(I,v,_,K),o=I|0}({h:n,l:o}=q.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=q.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=q.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=q.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:h}=q.add(this.Eh|0,this.El|0,l|0,h|0),{h:w,l:B}=q.add(this.Fh|0,this.Fl|0,w|0,B|0),{h:m,l:d}=q.add(this.Gh|0,this.Gl|0,m|0,d|0),{h:E,l:R}=q.add(this.Hh|0,this.Hl|0,E|0,R|0),this.set(n,o,i,s,a,c,f,u,l,h,w,B,m,d,E,R)}roundClean(){Kt.fill(0),qt.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 yn=uo(()=>new Us);var ho={};ge(ho,{aInRange:()=>Ve,abool:()=>tt,abytes:()=>Mr,bitGet:()=>np,bitLen:()=>Ps,bitMask:()=>bn,bitSet:()=>op,bytesToHex:()=>vt,bytesToNumberBE:()=>Bt,bytesToNumberLE:()=>Gt,concatBytes:()=>At,createHmacDrbg:()=>Fs,ensureBytes:()=>ae,equalBytes:()=>tp,hexToBytes:()=>lr,hexToNumber:()=>Vs,inRange:()=>wn,isBytes:()=>zt,memoized:()=>hr,notImplemented:()=>sp,numberToBytesBE:()=>jt,numberToBytesLE:()=>fr,numberToHexUnpadded:()=>ur,numberToVarBytesBE:()=>ep,utf8ToBytes:()=>rp,validateObject:()=>ht});var Ds=BigInt(0),fo=BigInt(1),X0=BigInt(2);function zt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Mr(r){if(!zt(r))throw new Error("Uint8Array expected")}function tt(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var Q0=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function vt(r){Mr(r);let e="";for(let t=0;t<r.length;t++)e+=Q0[r[t]];return e}function ur(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function Vs(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var Et={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function nu(r){if(r>=Et._0&&r<=Et._9)return r-Et._0;if(r>=Et._A&&r<=Et._F)return r-(Et._A-10);if(r>=Et._a&&r<=Et._f)return r-(Et._a-10)}function lr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let o=0,i=0;o<t;o++,i+=2){let s=nu(r.charCodeAt(i)),a=nu(r.charCodeAt(i+1));if(s===void 0||a===void 0){let c=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function Bt(r){return Vs(vt(r))}function Gt(r){return Mr(r),Vs(vt(Uint8Array.from(r).reverse()))}function jt(r,e){return lr(r.toString(16).padStart(e*2,"0"))}function fr(r,e){return jt(r,e).reverse()}function ep(r){return lr(ur(r))}function ae(r,e,t){let n;if(typeof e=="string")try{n=lr(e)}catch(i){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${i}`)}else if(zt(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof t=="number"&&o!==t)throw new Error(`${r} expected ${t} bytes, got ${o}`);return n}function At(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];Mr(o),e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let i=r[n];t.set(i,o),o+=i.length}return t}function tp(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function rp(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var Ls=r=>typeof r=="bigint"&&Ds<=r;function wn(r,e,t){return Ls(r)&&Ls(e)&&Ls(t)&&e<=r&&r<t}function Ve(r,e,t,n){if(!wn(e,t,n))throw new Error(`expected valid ${r}: ${t} <= n < ${n}, got ${typeof e} ${e}`)}function Ps(r){let e;for(e=0;r>Ds;r>>=fo,e+=1);return e}function np(r,e){return r>>BigInt(e)&fo}function op(r,e,t){return r|(t?fo:Ds)<<BigInt(e)}var bn=r=>(X0<<BigInt(r-1))-fo,Os=r=>new Uint8Array(r),ou=r=>Uint8Array.from(r);function Fs(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=Os(r),o=Os(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>t(o,n,...l),c=(l=Os())=>{o=a(ou([0]),l),n=a(),l.length!==0&&(o=a(ou([1]),l),n=a())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,h=[];for(;l<e;){n=a();let w=n.slice();h.push(w),l+=n.length}return At(...h)};return(l,h)=>{s(),c(l);let w;for(;!(w=h(f()));)c();return s(),w}}var ip={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||zt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function ht(r,e,t={}){let n=(o,i,s)=>{let a=ip[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);let c=r[o];if(!(s&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${i}`)};for(let[o,i]of Object.entries(e))n(o,i,!1);for(let[o,i]of Object.entries(t))n(o,i,!0);return r}var sp=()=>{throw new Error("not implemented")};function hr(r){let e=new WeakMap;return(t,...n)=>{let o=e.get(t);if(o!==void 0)return o;let i=r(t,...n);return e.set(t,i),i}}var de=BigInt(0),ne=BigInt(1),dr=BigInt(2),ap=BigInt(3),Ms=BigInt(4),iu=BigInt(5),su=BigInt(8),cp=BigInt(9),up=BigInt(16);function ee(r,e){let t=r%e;return t>=de?t:e+t}function lp(r,e,t){if(t<=de||e<de)throw new Error("Expected power/modulo > 0");if(t===ne)return de;let n=ne;for(;e>de;)e&ne&&(n=n*r%t),r=r*r%t,e>>=ne;return n}function oe(r,e,t){let n=r;for(;e-- >de;)n*=n,n%=t;return n}function po(r,e){if(r===de||e<=de)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=ee(r,e),n=e,o=de,i=ne,s=ne,a=de;for(;t!==de;){let f=n/t,u=n%t,l=o-s*f,h=i-a*f;n=t,t=u,o=s,i=a,s=l,a=h}if(n!==ne)throw new Error("invert: does not exist");return ee(o,e)}function fp(r){let e=(r-ne)/dr,t,n,o;for(t=r-ne,n=0;t%dr===de;t/=dr,n++);for(o=dr;o<r&&lp(o,e,r)!==r-ne;o++);if(n===1){let s=(r+ne)/Ms;return function(c,f){let u=c.pow(f,s);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let i=(t+ne)/dr;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,u=a.pow(a.mul(a.ONE,o),t),l=a.pow(c,i),h=a.pow(c,t);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let w=1;for(let m=a.sqr(h);w<f&&!a.eql(m,a.ONE);w++)m=a.sqr(m);let B=a.pow(u,ne<<BigInt(f-w-1));u=a.sqr(B),l=a.mul(l,B),h=a.mul(h,u),f=w}return l}}function hp(r){if(r%Ms===ap){let e=(r+ne)/Ms;return function(n,o){let i=n.pow(o,e);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(r%su===iu){let e=(r-iu)/su;return function(n,o){let i=n.mul(o,dr),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,dr),s),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return r%up,fp(r)}var au=(r,e)=>(ee(r,e)&ne)===ne,dp=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function $s(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=dp.reduce((n,o)=>(n[o]="function",n),e);return ht(r,t)}function pp(r,e,t){if(t<de)throw new Error("Expected power > 0");if(t===de)return r.ONE;if(t===ne)return e;let n=r.ONE,o=e;for(;t>de;)t&ne&&(n=r.mul(n,o)),o=r.sqr(o),t>>=ne;return n}function mp(r,e){let t=new Array(e.length),n=e.reduce((i,s,a)=>r.is0(s)?i:(t[a]=i,r.mul(i,s)),r.ONE),o=r.inv(n);return e.reduceRight((i,s,a)=>r.is0(s)?i:(t[a]=r.mul(i,t[a]),r.mul(i,s)),o),t}function Hs(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Yt(r,e,t=!1,n={}){if(r<=de)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:i}=Hs(r,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=hp(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:bn(o),ZERO:de,ONE:ne,create:c=>ee(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return de<=c&&c<r},is0:c=>c===de,isOdd:c=>(c&ne)===ne,neg:c=>ee(-c,r),eql:(c,f)=>c===f,sqr:c=>ee(c*c,r),add:(c,f)=>ee(c+f,r),sub:(c,f)=>ee(c-f,r),mul:(c,f)=>ee(c*f,r),pow:(c,f)=>pp(a,c,f),div:(c,f)=>ee(c*po(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>po(c,r),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>mp(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>t?fr(c,i):jt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return t?Gt(c):Bt(c)}});return Object.freeze(a)}function cu(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function Ks(r){let e=cu(r);return e+Math.ceil(e/2)}function uu(r,e,t=!1){let n=r.length,o=cu(e),i=Ks(e);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=t?Bt(r):Gt(r),a=ee(s,e-ne)+ne;return t?fr(a,o):jt(a,o)}var yp=BigInt(0),qs=BigInt(1),zs=new WeakMap,lu=new WeakMap;function mo(r,e){let t=(i,s)=>{let a=s.negate();return i?a:s},n=i=>{if(!Number.isSafeInteger(i)||i<=0||i>e)throw new Error(`Wrong window size=${i}, should be [1..${e}]`)},o=i=>{n(i);let s=Math.ceil(e/i)+1,a=2**(i-1);return{windows:s,windowSize:a}};return{constTimeNegate:t,unsafeLadder(i,s){let a=r.ZERO,c=i;for(;s>yp;)s&qs&&(a=a.add(c)),c=c.double(),s>>=qs;return a},precomputeWindow(i,s){let{windows:a,windowSize:c}=o(s),f=[],u=i,l=u;for(let h=0;h<a;h++){l=u,f.push(l);for(let w=1;w<c;w++)l=l.add(u),f.push(l);u=l.double()}return f},wNAF(i,s,a){let{windows:c,windowSize:f}=o(i),u=r.ZERO,l=r.BASE,h=BigInt(2**i-1),w=2**i,B=BigInt(i);for(let m=0;m<c;m++){let d=m*f,E=Number(a&h);a>>=B,E>f&&(E-=w,a+=qs);let R=d,y=d+Math.abs(E)-1,k=m%2!==0,P=E<0;E===0?l=l.add(t(k,s[R])):u=u.add(t(P,s[y]))}return{p:u,f:l}},wNAFCached(i,s,a){let c=lu.get(i)||1,f=zs.get(i);return f||(f=this.precomputeWindow(i,c),c!==1&&zs.set(i,a(f))),this.wNAF(c,f,s)},setWindowSize(i,s){n(s),lu.set(i,s),zs.delete(i)}}}function go(r,e,t,n){if(!Array.isArray(t)||!Array.isArray(n)||n.length!==t.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((u,l)=>{if(!e.isValid(u))throw new Error(`wrong scalar at index ${l}`)}),t.forEach((u,l)=>{if(!(u instanceof r))throw new Error(`wrong point at index ${l}`)});let o=Ps(BigInt(t.length)),i=o>12?o-3:o>4?o-2:o?2:1,s=(1<<i)-1,a=new Array(s+1).fill(r.ZERO),c=Math.floor((e.BITS-1)/i)*i,f=r.ZERO;for(let u=c;u>=0;u-=i){a.fill(r.ZERO);for(let h=0;h<n.length;h++){let w=n[h],B=Number(w>>BigInt(u)&BigInt(s));a[B]=a[B].add(t[h])}let l=r.ZERO;for(let h=a.length-1,w=r.ZERO;h>0;h--)w=w.add(a[h]),l=l.add(w);if(f=f.add(l),u!==0)for(let h=0;h<i;h++)f=f.double()}return f}function xn(r){return $s(r.Fp),ht(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Hs(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var rt=BigInt(0),Pe=BigInt(1),yo=BigInt(2),wp=BigInt(8),bp={zip215:!0};function xp(r){let e=xn(r);return ht(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function fu(r){let e=xp(r),{Fp:t,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=e,f=yo<<BigInt(a*8)-Pe,u=t.create,l=Yt(e.n,e.nBitLength),h=e.uvRatio||((g,p)=>{try{return{isValid:!0,value:t.sqrt(g*t.inv(p))}}catch{return{isValid:!1,value:rt}}}),w=e.adjustScalarBytes||(g=>g),B=e.domain||((g,p,A)=>{if(tt("phflag",A),p.length||A)throw new Error("Contexts/pre-hash are not supported");return g});function m(g,p){Ve("coordinate "+g,p,rt,f)}function d(g){if(!(g instanceof y))throw new Error("ExtendedPoint expected")}let E=hr((g,p)=>{let{ex:A,ey:D,ez:M}=g,$=g.is0();p==null&&(p=$?wp:t.inv(M));let j=u(A*p),W=u(D*p),Y=u(M*p);if($)return{x:rt,y:Pe};if(Y!==Pe)throw new Error("invZ was invalid");return{x:j,y:W}}),R=hr(g=>{let{a:p,d:A}=e;if(g.is0())throw new Error("bad point: ZERO");let{ex:D,ey:M,ez:$,et:j}=g,W=u(D*D),Y=u(M*M),Q=u($*$),re=u(Q*Q),pe=u(W*p),me=u(Q*u(pe+Y)),Ee=u(re+u(A*u(W*Y)));if(me!==Ee)throw new Error("bad point: equation left != right (1)");let Te=u(D*M),he=u($*j);if(Te!==he)throw new Error("bad point: equation left != right (2)");return!0});class y{constructor(p,A,D,M){this.ex=p,this.ey=A,this.ez=D,this.et=M,m("x",p),m("y",A),m("z",D),m("t",M),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:A,y:D}=p||{};return m("x",A),m("y",D),new y(A,D,Pe,u(A*D))}static normalizeZ(p){let A=t.invertBatch(p.map(D=>D.ez));return p.map((D,M)=>D.toAffine(A[M])).map(y.fromAffine)}static msm(p,A){return go(y,l,p,A)}_setWindowSize(p){O.setWindowSize(this,p)}assertValidity(){R(this)}equals(p){d(p);let{ex:A,ey:D,ez:M}=this,{ex:$,ey:j,ez:W}=p,Y=u(A*W),Q=u($*M),re=u(D*W),pe=u(j*M);return Y===Q&&re===pe}is0(){return this.equals(y.ZERO)}negate(){return new y(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=e,{ex:A,ey:D,ez:M}=this,$=u(A*A),j=u(D*D),W=u(yo*u(M*M)),Y=u(p*$),Q=A+D,re=u(u(Q*Q)-$-j),pe=Y+j,me=pe-W,Ee=Y-j,Te=u(re*me),he=u(pe*Ee),Oe=u(re*Ee),bt=u(me*pe);return new y(Te,he,bt,Oe)}add(p){d(p);let{a:A,d:D}=e,{ex:M,ey:$,ez:j,et:W}=this,{ex:Y,ey:Q,ez:re,et:pe}=p;if(A===BigInt(-1)){let Ja=u(($-M)*(Q+Y)),Xa=u(($+M)*(Q-Y)),Di=u(Xa-Ja);if(Di===rt)return this.double();let Qa=u(j*yo*pe),ec=u(W*yo*re),tc=ec+Qa,rc=Xa+Ja,nc=ec-Qa,Sh=u(tc*Di),Ih=u(rc*nc),Rh=u(tc*nc),kh=u(Di*rc);return new y(Sh,Ih,kh,Rh)}let me=u(M*Y),Ee=u($*Q),Te=u(W*D*pe),he=u(j*re),Oe=u((M+$)*(Y+Q)-me-Ee),bt=he-Te,cn=he+Te,un=u(Ee-A*me),Eh=u(Oe*bt),vh=u(cn*un),Bh=u(Oe*un),Ah=u(bt*cn);return new y(Eh,vh,Ah,Bh)}subtract(p){return this.add(p.negate())}wNAF(p){return O.wNAFCached(this,p,y.normalizeZ)}multiply(p){let A=p;Ve("scalar",A,Pe,n);let{p:D,f:M}=this.wNAF(A);return y.normalizeZ([D,M])[0]}multiplyUnsafe(p){let A=p;return Ve("scalar",A,rt,n),A===rt?P:this.equals(P)||A===Pe?this:this.equals(k)?this.wNAF(A).p:O.unsafeLadder(this,A)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return O.unsafeLadder(this,n).is0()}toAffine(p){return E(this,p)}clearCofactor(){let{h:p}=e;return p===Pe?this:this.multiplyUnsafe(p)}static fromHex(p,A=!1){let{d:D,a:M}=e,$=t.BYTES;p=ae("pointHex",p,$),tt("zip215",A);let j=p.slice(),W=p[$-1];j[$-1]=W&-129;let Y=Gt(j),Q=A?f:t.ORDER;Ve("pointHex.y",Y,rt,Q);let re=u(Y*Y),pe=u(re-Pe),me=u(D*re-M),{isValid:Ee,value:Te}=h(pe,me);if(!Ee)throw new Error("Point.fromHex: invalid y coordinate");let he=(Te&Pe)===Pe,Oe=(W&128)!==0;if(!A&&Te===rt&&Oe)throw new Error("Point.fromHex: x=0 and x_0=1");return Oe!==he&&(Te=u(-Te)),y.fromAffine({x:Te,y:Y})}static fromPrivateKey(p){return v(p).point}toRawBytes(){let{x:p,y:A}=this.toAffine(),D=fr(A,t.BYTES);return D[D.length-1]|=p&Pe?128:0,D}toHex(){return vt(this.toRawBytes())}}y.BASE=new y(e.Gx,e.Gy,Pe,u(e.Gx*e.Gy)),y.ZERO=new y(rt,Pe,Pe,rt);let{BASE:k,ZERO:P}=y,O=mo(y,a*8);function C(g){return ee(g,n)}function b(g){return C(Gt(g))}function v(g){let p=a;g=ae("private key",g,p);let A=ae("hashed private key",i(g),2*p),D=w(A.slice(0,p)),M=A.slice(p,2*p),$=b(D),j=k.multiply($),W=j.toRawBytes();return{head:D,prefix:M,scalar:$,point:j,pointBytes:W}}function F(g){return v(g).pointBytes}function _(g=new Uint8Array,...p){let A=At(...p);return b(i(B(A,ae("context",g),!!o)))}function N(g,p,A={}){g=ae("message",g),o&&(g=o(g));let{prefix:D,scalar:M,pointBytes:$}=v(p),j=_(A.context,D,g),W=k.multiply(j).toRawBytes(),Y=_(A.context,W,$,g),Q=C(j+Y*M);Ve("signature.s",Q,rt,n);let re=At(W,fr(Q,t.BYTES));return ae("result",re,a*2)}let K=bp;function S(g,p,A,D=K){let{context:M,zip215:$}=D,j=t.BYTES;g=ae("signature",g,2*j),p=ae("message",p),$!==void 0&&tt("zip215",$),o&&(p=o(p));let W=Gt(g.slice(j,2*j)),Y,Q,re;try{Y=y.fromHex(A,$),Q=y.fromHex(g.slice(0,j),$),re=k.multiplyUnsafe(W)}catch{return!1}if(!$&&Y.isSmallOrder())return!1;let pe=_(M,Q.toRawBytes(),Y.toRawBytes(),p);return Q.add(Y.multiplyUnsafe(pe)).subtract(re).clearCofactor().equals(y.ZERO)}return k._setWindowSize(8),{CURVE:e,getPublicKey:F,sign:N,verify:S,ExtendedPoint:y,utils:{getExtendedPublicKey:v,randomPrivateKey:()=>s(t.BYTES),precompute(g=8,p=y.BASE){return p._setWindowSize(g),p.multiply(BigInt(3)),p}}}}var Gs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),hu=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),hx=BigInt(0),Ep=BigInt(1),du=BigInt(2),dx=BigInt(3),vp=BigInt(5),Bp=BigInt(8);function Ap(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),o=BigInt(80),i=Gs,a=r*r%i*r%i,c=oe(a,du,i)*a%i,f=oe(c,Ep,i)*r%i,u=oe(f,vp,i)*f%i,l=oe(u,e,i)*u%i,h=oe(l,t,i)*l%i,w=oe(h,n,i)*h%i,B=oe(w,o,i)*w%i,m=oe(B,o,i)*w%i,d=oe(m,e,i)*u%i;return{pow_p_5_8:oe(d,du,i)*r%i,b2:a}}function Sp(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Ip(r,e){let t=Gs,n=ee(e*e*e,t),o=ee(n*n*e,t),i=Ap(r*o).pow_p_5_8,s=ee(r*n*i,t),a=ee(e*s*s,t),c=s,f=ee(s*hu,t),u=a===r,l=a===ee(-r,t),h=a===ee(-r*hu,t);return u&&(s=c),(l||h)&&(s=f),au(s,t)&&(s=ee(-s,t)),{isValid:u||l,value:s}}var Rp=Yt(Gs,void 0,!0),kp={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Rp,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Bp,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:yn,randomBytes:Pr,adjustScalarBytes:Sp,uvRatio:Ip},$r=fu(kp);var Hr=32,St=64,wo=32;function pu(){let r=$r.utils.randomPrivateKey(),e=$r.getPublicKey(r);return{privateKey:wu(r,e),publicKey:e}}function mu(r){if(r.length!==wo)throw new TypeError('"seed" must be 32 bytes in length.');if(!(r instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let e=r,t=$r.getPublicKey(e);return{privateKey:wu(e,t),publicKey:t}}function gu(r,e){let t=r.subarray(0,wo);return $r.sign(e instanceof Uint8Array?e:e.subarray(),t)}function yu(r,e,t){return $r.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function wu(r,e){let t=new Uint8Array(St);for(let n=0;n<wo;n++)t[n]=r[n],t[wo+n]=e[n];return t}var Ce={get(r=globalThis){let e=r.crypto;if(e?.subtle==null)throw Object.assign(new Error("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"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}};var js={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function bu(r){let e=r?.algorithm??"AES-GCM",t=r?.keyLength??16,n=r?.nonceLength??12,o=r?.digest??"SHA-256",i=r?.saltLength??16,s=r?.iterations??32767,a=Ce.get();t*=8;async function c(l,h){let w=a.getRandomValues(new Uint8Array(i)),B=a.getRandomValues(new Uint8Array(n)),m={name:e,iv:B};typeof h=="string"&&(h=z(h));let d;if(h.length===0){d=await a.subtle.importKey("jwk",js,{name:"AES-GCM"},!0,["encrypt"]);try{let R={name:"PBKDF2",salt:w,iterations:s,hash:{name:o}},y=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);d=await a.subtle.deriveKey(R,y,{name:e,length:t},!0,["encrypt"])}catch{d=await a.subtle.importKey("jwk",js,{name:"AES-GCM"},!0,["encrypt"])}}else{let R={name:"PBKDF2",salt:w,iterations:s,hash:{name:o}},y=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);d=await a.subtle.deriveKey(R,y,{name:e,length:t},!0,["encrypt"])}let E=await a.subtle.encrypt(m,d,l);return Ne([w,m.iv,new Uint8Array(E)])}async function f(l,h){let w=l.subarray(0,i),B=l.subarray(i,i+n),m=l.subarray(i+n),d={name:e,iv:B};typeof h=="string"&&(h=z(h));let E;if(h.length===0)try{let y={name:"PBKDF2",salt:w,iterations:s,hash:{name:o}},k=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);E=await a.subtle.deriveKey(y,k,{name:e,length:t},!0,["decrypt"])}catch{E=await a.subtle.importKey("jwk",js,{name:"AES-GCM"},!0,["decrypt"])}else{let y={name:"PBKDF2",salt:w,iterations:s,hash:{name:o}},k=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);E=await a.subtle.deriveKey(y,k,{name:e,length:t},!0,["decrypt"])}let R=await a.subtle.decrypt(d,E,m);return new Uint8Array(R)}return{encrypt:c,decrypt:f}}async function Kr(r,e){let n=await bu().encrypt(r,e);return ln.encode(n)}var Ys=new Float32Array([-0]),Zt=new Uint8Array(Ys.buffer);function xu(r,e,t){Ys[0]=r,e[t]=Zt[0],e[t+1]=Zt[1],e[t+2]=Zt[2],e[t+3]=Zt[3]}function Eu(r,e){return Zt[0]=r[e],Zt[1]=r[e+1],Zt[2]=r[e+2],Zt[3]=r[e+3],Ys[0]}var Zs=new Float64Array([-0]),Ie=new Uint8Array(Zs.buffer);function vu(r,e,t){Zs[0]=r,e[t]=Ie[0],e[t+1]=Ie[1],e[t+2]=Ie[2],e[t+3]=Ie[3],e[t+4]=Ie[4],e[t+5]=Ie[5],e[t+6]=Ie[6],e[t+7]=Ie[7]}function Bu(r,e){return Ie[0]=r[e],Ie[1]=r[e+1],Ie[2]=r[e+2],Ie[3]=r[e+3],Ie[4]=r[e+4],Ie[5]=r[e+5],Ie[6]=r[e+6],Ie[7]=r[e+7],Zs[0]}var Cp=BigInt(Number.MAX_SAFE_INTEGER),_p=BigInt(Number.MIN_SAFE_INTEGER),He=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return pr;if(e<Cp&&e>_p)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,o=e-(n<<32n);return t&&(n=~n|0n,o=~o|0n,++o>Au&&(o=0n,++n>Au&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return pr;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):pr}},pr=new He(0,0);pr.toBigInt=function(){return 0n};pr.zzEncode=pr.zzDecode=function(){return this};pr.length=function(){return 1};var Au=4294967296n;function Su(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Iu(r,e,t){if(t-e<1)return"";let o,i=[],s=0,a;for(;e<t;)a=r[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function Ws(r,e,t){let n=t,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128);return t-n}function nt(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function bo(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var Js=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,nt(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw nt(this,4);return bo(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw nt(this,4);return bo(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw nt(this,4);let e=Eu(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw nt(this,4);let e=Bu(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw nt(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Iu(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw nt(this,e);this.pos+=e}else do if(this.pos>=this.len)throw nt(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new He(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw nt(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw nt(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw nt(this,8);let e=bo(this.buf,this.pos+=4),t=bo(this.buf,this.pos+=4);return new He(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=ms(this.buf,this.pos);return this.pos+=De(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Xs(r){return new Js(r instanceof Uint8Array?r:r.subarray())}function qr(r,e,t){let n=Xs(r);return e.decode(n,void 0,t)}function Qs(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return Qe(s);o+s>e&&(n=Qe(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var mr=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function ea(){}var ra=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Up=Qs();function Lp(r){return globalThis.Buffer!=null?Qe(r):Up(r)}var vn=class{len;head;tail;states;constructor(){this.len=0,this.head=new mr(ea,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new mr(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new na((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(xo,10,He.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=He.fromBigInt(e);return this._push(xo,t.length(),t)}uint64Number(e){return this._push(ps,De(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=He.fromBigInt(e).zzEncode();return this._push(xo,t.length(),t)}sint64Number(e){let t=He.fromNumber(e).zzEncode();return this._push(xo,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(ta,1,e?1:0)}fixed32(e){return this._push(En,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=He.fromBigInt(e);return this._push(En,4,t.lo)._push(En,4,t.hi)}fixed64Number(e){let t=He.fromNumber(e);return this._push(En,4,t.lo)._push(En,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(xu,4,e)}double(e){return this._push(vu,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(ta,1,0):this.uint32(t)._push(Dp,t,e)}string(e){let t=Su(e);return t!==0?this.uint32(t)._push(Ws,t,e):this._push(ta,1,0)}fork(){return this.states=new ra(this),this.head=this.tail=new mr(ea,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 mr(ea,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=Lp(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function ta(r,e,t){e[t]=r&255}function Op(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var na=class extends mr{next;constructor(e,t){super(Op,e,t),this.next=void 0}};function xo(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function En(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function Dp(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(vn.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(Vp,e,r),this},vn.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(Pp,e,r),this});function Vp(r,e,t){e.set(r,t)}function Pp(r,e,t){r.length<40?Ws(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(z(r),t)}function oa(){return new vn}function zr(r,e){let t=oa();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var Gr;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Gr||(Gr={}));function Eo(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function Bn(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return Eo("enum",Gr.VARINT,t,n)}function jr(r,e){return Eo("message",Gr.LENGTH_DELIMITED,r,e)}var ue;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(ue||(ue={}));var ia;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(ia||(ia={}));(function(r){r.codec=()=>Bn(ia)})(ue||(ue={}));var dt;(function(r){let e;r.codec=()=>(e==null&&(e=jr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ue.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let o={},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let s=t.uint32();switch(s>>>3){case 1:o.Type=ue.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(s&7);break}}return o})),e),r.encode=t=>zr(t,r.codec()),r.decode=t=>qr(t,r.codec())})(dt||(dt={}));var It;(function(r){let e;r.codec=()=>(e==null&&(e=jr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ue.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let o={},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let s=t.uint32();switch(s>>>3){case 1:o.Type=ue.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(s&7);break}}return o})),e),r.encode=t=>zr(t,r.codec()),r.decode=t=>qr(t,r.codec())})(It||(It={}));var An=class{_key;constructor(e){this._key=Yr(e,Hr)}verify(e,t){return yu(this._key,t,e)}marshal(){return this._key}get bytes(){return dt.encode({Type:ue.Ed25519,Data:this.marshal()}).subarray()}equals(e){return se(this.bytes,e.bytes)}hash(){let e=ve.digest(this.bytes);return Ye(e)?e.then(({bytes:t})=>t):e.bytes}},gr=class{_key;_publicKey;constructor(e,t){this._key=Yr(e,St),this._publicKey=Yr(t,Hr)}sign(e){return gu(this._key,e)}get public(){return new An(this._publicKey)}marshal(){return this._key}get bytes(){return It.encode({Type:ue.Ed25519,Data:this.marshal()}).subarray()}equals(e){return se(this.bytes,e.bytes)}async hash(){let e=ve.digest(this.bytes),t;return Ye(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=$e.digest(this.public.bytes);return ce.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return Kr(this.bytes,e);throw new V(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Fp(r){if(r.length>St){r=Yr(r,St+Hr);let n=r.subarray(0,St),o=r.subarray(St,r.length);return new gr(n,o)}r=Yr(r,St);let e=r.subarray(0,St),t=r.subarray(Hr);return new gr(e,t)}function Mp(r){return r=Yr(r,Hr),new An(r)}async function $p(){let{privateKey:r,publicKey:e}=pu();return new gr(r,e)}async function ku(r){let{privateKey:e,publicKey:t}=mu(r);return new gr(e,t)}function Yr(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new V(`Key must be a Uint8Array of length ${e}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}var ga={};ge(ga,{MAX_RSA_KEY_SIZE:()=>Dn,RsaPrivateKey:()=>Qr,RsaPublicKey:()=>On,fromJwk:()=>pm,generateKeyPair:()=>mm,unmarshalRsaPrivateKey:()=>pa,unmarshalRsaPublicKey:()=>dm});function yr(r){if(isNaN(r)||r<=0)throw new V("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Pr(r)}var Qt={};ge(Qt,{exportToPem:()=>cm,importFromPem:()=>um,jwkToPkcs1:()=>om,jwkToPkix:()=>sm,pkcs1ToJwk:()=>nm,pkixToJwk:()=>im});var Bo=class extends Dr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,co(e);let n=Ht(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return Or(this),this.iHash.update(e),this}digestInto(e){Or(this),Lr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Sn=(r,e,t)=>new Bo(r,e).update(t).digest();Sn.create=(r,e)=>new Bo(r,e);function Hp(r,e,t,n){co(r);let o=Qc({dkLen:32,asyncTick:10},n),{c:i,dkLen:s,asyncTick:a}=o;if(Ur(i),Ur(s),Ur(a),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=Ht(e),f=Ht(t),u=new Uint8Array(s),l=Sn.create(r,c),h=l._cloneInto().update(f);return{c:i,dkLen:s,asyncTick:a,DK:u,PRF:l,PRFSalt:h}}function Kp(r,e,t,n,o){return r.destroy(),e.destroy(),n&&n.destroy(),o.fill(0),t}async function aa(r,e,t,n){let{c:o,dkLen:i,asyncTick:s,DK:a,PRF:c,PRFSalt:f}=Hp(r,e,t,n),u,l=new Uint8Array(4),h=Vr(l),w=new Uint8Array(c.outputLen);for(let B=1,m=0;m<i;B++,m+=c.outputLen){let d=a.subarray(m,m+c.outputLen);h.setInt32(0,B,!1),(u=f._cloneInto(u)).update(l).digestInto(w),d.set(w.subarray(0,d.length)),await Jc(o-1,s,()=>{c._cloneInto(u).update(w).digestInto(w);for(let E=0;E<d.length;E++)d[E]^=w[E]})}return Kp(c,f,a,u,w)}var Z=ir(Tu());function wr(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function Wt(r,e,t=-1){let n=t,o=r,i=0,s=Math.pow(2,e);for(let a=1;a<8;a++){if(r<s){let c;if(n<0)c=new ArrayBuffer(a),i=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),i=n}let f=new Uint8Array(c);for(let u=a-1;u>=0;u--){let l=Math.pow(2,u*e);f[i-u-1]=Math.floor(o/l),o-=f[i-u-1]*l}return c}s*=Math.pow(2,e)}return new ArrayBuffer(0)}function Io(...r){let e=0,t=0;for(let i of r)e+=i.length;let n=new ArrayBuffer(e),o=new Uint8Array(n);for(let i of r)o.set(i,t),t+=i.length;return o}function ua(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)t[a]=0;t[0]=r[0]&128;let n=wr(t,8),o=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(o);for(let a=0;a<this.valueHex.byteLength;a++)i[a]=r[a];return i[0]&=127,wr(i,8)-n}function Nu(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let s=t-e,a=Wt(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=Wt(e,8,n),i=new Uint8Array(o);if(i[0]&128){let s=o.slice(0),a=new Uint8Array(s);o=new ArrayBuffer(o.byteLength+1),i=new Uint8Array(o);for(let c=0;c<s.byteLength;c++)i[c+1]=a[c];i[0]=0}return o}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function Cu(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<t.length;o++)if(t[o]!==n[o])return!1;return!0}function Fe(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,o=new Array(n);for(let s=0;s<n;s++)o[s]="0";return o.join("").concat(t)}var w1=Math.log(2);function Ro(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function la(r){let e=0,t=0;for(let o=0;o<r.length;o++){let i=r[o];e+=i.byteLength}let n=new Uint8Array(e);for(let o=0;o<r.length;o++){let i=r[o];n.set(new Uint8Array(i),t),t+=i.byteLength}return n.buffer}function Ct(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var Rn=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return la(this.items)}},In=[new Uint8Array([1])],_u="0123456789";var Jr="",it=new ArrayBuffer(0),fa=new Uint8Array(0),kn="EndOfContent",Lu="OCTET STRING",Ou="BIT STRING";function _t(r){var e;return e=class extends r{constructor(...n){var o;super(...n);let i=n[0]||{};this.isHexOnly=(o=i.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=i.valueHex?Z.BufferSourceConverter.toUint8Array(i.valueHex):fa}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,o,i){let s=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!Ct(this,s,o,i))return-1;let a=o+i;return this.valueHexView=s.subarray(o,a),this.valueHexView.length?(this.blockLength=i,a):(this.warnings.push("Zero buffer length"),o)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",it)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:Z.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var kt=class{constructor({blockLength:e=0,error:t=Jr,warnings:n=[],valueBeforeDecode:o=fa}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=Z.BufferSourceConverter.toUint8Array(o)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:Z.Convert.ToHex(this.valueBeforeDecodeView)}}};kt.NAME="baseBlock";var Re=class extends kt{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};Re.NAME="valueBlock";var ko=class extends _t(kt){constructor({idBlock:e={}}={}){var t,n,o,i;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?Z.BufferSourceConverter.toUint8Array(e.valueHex):fa,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(o=e.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(i=e.isConstructed)!==null&&i!==void 0?i:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",it}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!e){let i=this.tagNumber;i&=31,t|=i,o[0]=t}return o.buffer}if(!this.isHexOnly){let o=Wt(this.tagNumber,7),i=new Uint8Array(o),s=o.byteLength,a=new Uint8Array(s+1);if(a[0]=t|31,!e){for(let c=0;c<s-1;c++)a[c+1]=i[c]|128;a[s]=i[s-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let o=this.valueHexView;for(let i=0;i<o.length-1;i++)n[i+1]=o[i]|128;n[this.valueHexView.byteLength]=o[o.length-1]}return n.buffer}fromBER(e,t,n){let o=Z.BufferSourceConverter.toUint8Array(e);if(!Ct(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;let a=i[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,f=this.valueHexView=new Uint8Array(255),u=255;for(;i[c]&128;){if(f[c-1]=i[c]&127,c++,c>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let h=new Uint8Array(u);for(let w=0;w<f.length;w++)h[w]=f[w];f=this.valueHexView=new Uint8Array(u)}}this.blockLength=c+1,f[c-1]=i[c]&127;let l=new Uint8Array(c);for(let h=0;h<c;h++)l[h]=f[h];f=this.valueHexView=new Uint8Array(c),f.set(l),this.blockLength<=9?this.tagNumber=wr(f,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};ko.NAME="identificationBlock";var To=class extends kt{constructor({lenBlock:e={}}={}){var t,n,o;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(o=e.length)!==null&&o!==void 0?o:0}fromBER(e,t,n){let o=Z.BufferSourceConverter.toUint8Array(e);if(!Ct(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;if(i[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,t+this.blockLength;let s=i[0]&127;if(s>8)return this.error="Too big integer",-1;if(s+1>i.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=o.subarray(a,a+s);return c[s-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=wr(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let o=Wt(this.length,8);if(o.byteLength>127)return this.error="Too big length",it;if(t=new ArrayBuffer(o.byteLength+1),e)return t;let i=new Uint8Array(o);n=new Uint8Array(t),n[0]=o.byteLength|128;for(let s=0;s<o.byteLength;s++)n[s+1]=i[s];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};To.NAME="lengthBlock";var U={},Be=class extends kt{constructor({name:e=Jr,optional:t=!1,primitiveSchema:n,...o}={},i){super(o),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new ko(o),this.lenBlock=new To(o),this.valueBlock=i?new i(o):new Re(o)}fromBER(e,t,n){let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}toBER(e,t){let n=t||new Rn;t||Du(this);let o=this.idBlock.toBER(e);if(n.write(o),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let i=this.valueBlock.toBER(e);this.lenBlock.length=i.byteLength;let s=this.lenBlock.toBER(e);n.write(s),n.write(i)}return t?it:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():Z.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${Z.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return Cu(t,n)}};Be.NAME="BaseBlock";function Du(r){if(r instanceof U.Constructed)for(let e of r.valueBlock.value)Du(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var No=class extends Be{constructor({value:e=Jr,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};No.NAME="BaseStringBlock";var Co=class extends _t(Re){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};Co.NAME="PrimitiveValueBlock";var Vu,_o=class extends Be{constructor(e={}){super(e,Co),this.idBlock.isConstructed=!1}};Vu=_o;U.Primitive=Vu;_o.NAME="PRIMITIVE";function Xp(r,e){if(r instanceof e)return r;let t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function fi(r,e=0,t=r.length){let n=e,o=new Be({},Re),i=new kt;if(!Ct(i,r,e,t))return o.error=i.error,{offset:-1,result:o};if(!r.subarray(e,e+t).length)return o.error="Zero buffer length",{offset:-1,result:o};let a=o.idBlock.fromBER(r,e,t);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),a===-1)return o.error=o.idBlock.error,{offset:-1,result:o};if(e=a,t-=o.idBlock.blockLength,a=o.lenBlock.fromBER(r,e,t),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),a===-1)return o.error=o.lenBlock.error,{offset:-1,result:o};if(e=a,t-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};let c=Be;switch(o.idBlock.tagClass){case 1:if(o.idBlock.tagNumber>=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};c=U.EndOfContent;break;case 1:c=U.Boolean;break;case 2:c=U.Integer;break;case 3:c=U.BitString;break;case 4:c=U.OctetString;break;case 5:c=U.Null;break;case 6:c=U.ObjectIdentifier;break;case 10:c=U.Enumerated;break;case 12:c=U.Utf8String;break;case 13:c=U.RelativeObjectIdentifier;break;case 14:c=U.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=U.Sequence;break;case 17:c=U.Set;break;case 18:c=U.NumericString;break;case 19:c=U.PrintableString;break;case 20:c=U.TeletexString;break;case 21:c=U.VideotexString;break;case 22:c=U.IA5String;break;case 23:c=U.UTCTime;break;case 24:c=U.GeneralizedTime;break;case 25:c=U.GraphicString;break;case 26:c=U.VisibleString;break;case 27:c=U.GeneralString;break;case 28:c=U.UniversalString;break;case 29:c=U.CharacterString;break;case 30:c=U.BmpString;break;case 31:c=U.DATE;break;case 32:c=U.TimeOfDay;break;case 33:c=U.DateTime;break;case 34:c=U.Duration;break;default:{let f=o.idBlock.isConstructed?new U.Constructed:new U.Primitive;f.idBlock=o.idBlock,f.lenBlock=o.lenBlock,f.warnings=o.warnings,o=f}}break;case 2:case 3:case 4:default:c=o.idBlock.isConstructed?U.Constructed:U.Primitive}return o=Xp(o,c),a=o.fromBER(r,e,o.lenBlock.isIndefiniteForm?t:o.lenBlock.length),o.valueBeforeDecodeView=r.subarray(n,n+o.blockLength),{offset:a,result:o}}function Xr(r){if(!r.byteLength){let e=new Be({},Re);return e.error="Input buffer has zero length",{offset:-1,result:e}}return fi(Z.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function Qp(r,e){return r?1:e}var pt=class extends Re{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let o=Z.BufferSourceConverter.toUint8Array(e);if(!Ct(this,o,t,n))return-1;if(this.valueBeforeDecodeView=o.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let i=t;for(;Qp(this.isIndefiniteForm,n)>0;){let s=fi(o,i,n);if(s.offset===-1)return this.error=s.result.error,this.warnings.concat(s.result.warnings),-1;if(i=s.offset,this.blockLength+=s.result.blockLength,n-=s.result.blockLength,this.value.push(s.result),this.isIndefiniteForm&&s.result.constructor.NAME===kn)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===kn?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new Rn;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return t?it:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};pt.NAME="ConstructedValueBlock";var Pu,Jt=class extends Be{constructor(e={}){super(e,pt),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
4
4
  `).map(o=>` ${o}`).join(`
5
5
  `));let t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
6
6
  ${e.join(`
7
- `)}`:`${t} :`}};Ou=jt;C.Constructed=Ou;jt.NAME="CONSTRUCTED";var Co=class extends Ie{fromBER(e,t,n){return t}toBER(e){return it}};Co.override="EndOfContentValueBlock";var Vu,_o=class extends ve{constructor(e={}){super(e,Co),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Vu=_o;C.EndOfContent=Vu;_o.NAME=An;var Du,Yt=class extends ve{constructor(e={}){super(e,Ie),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){let n=new ArrayBuffer(2);if(!e){let o=new Uint8Array(n);o[0]=5,o[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Du=Yt;C.Null=Du;Yt.NAME="NULL";var Uo=class extends Ct(Ie){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=Y.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){let o=Y.BufferSourceConverter.toUint8Array(e);return Nt(this,o,t,n)?(this.valueHexView=o.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,ia.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Uo.NAME="BooleanValueBlock";var Pu,Lo=class extends ve{constructor(e={}){super(e,Uo),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Pu=Lo;C.Boolean=Pu;Lo.NAME="BOOLEAN";var Oo=class extends Ct(pt){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=pt.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let i=0;i<this.value.length;i++){let s=this.value[i].constructor.NAME;if(s===An){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==Cu)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=super.fromBER(e,t,n),this.blockLength=n;return o}toBER(e,t){return this.isConstructed?pt.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Oo.NAME="OctetStringValueBlock";var Fu,kt=class r extends ve{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Oo),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){let i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(i.byteLength){let s=ui(i,0,i.byteLength);s.offset!==-1&&s.offset===n&&(this.valueBlock.value=[s.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?jt.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${Y.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let t of this.valueBlock.value)t instanceof r&&e.push(t.valueBlock.valueHexView);return Y.BufferSourceConverter.concat(e)}};Fu=kt;C.OctetString=Fu;kt.NAME=Cu;var Vo=class extends Ct(pt){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let o=-1;if(this.isConstructed){if(o=pt.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===An){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==_u)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let f=a.valueBlock;if(this.unusedBits>0&&f.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=f.unusedBits}return o}let i=Y.BufferSourceConverter.toUint8Array(e);if(!Nt(this,i,t,n))return-1;let s=i.subarray(t,t+n);if(this.unusedBits=s[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=s.subarray(1);try{if(a.byteLength){let c=ui(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,t+n}toBER(e,t){if(this.isConstructed)return pt.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return it;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};Vo.NAME="BitStringValueBlock";var Mu,jr=class extends ve{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Vo),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return jt.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let o of t)e.push(o.toString(2).padStart(8,"0"));let n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};Mu=jr;C.BitString=Mu;jr.NAME=_u;var $u;function Jp(r,e){let t=new Uint8Array([0]),n=new Uint8Array(r),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f=0,u=c<s?s:c,l=0;for(let d=u;d>=0;d--,l++){switch(!0){case l<a.length:f=i[s-l]+a[c-l]+t[0];break;default:f=i[s-l]+t[0]}switch(t[0]=f/10,!0){case l>=i.length:i=Ao(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return t[0]>0&&(i=Ao(t,i)),i}function Nu(r){if(r>=vn.length)for(let e=vn.length;e<=r;e++){let t=new Uint8Array([0]),n=vn[e-1].slice(0);for(let o=n.length-1;o>=0;o--){let i=new Uint8Array([(n[o]<<1)+t[0]]);t[0]=i[0]/10,n[o]=i[0]%10}t[0]>0&&(n=Ao(t,n)),vn.push(n)}return vn[r]}function Xp(r,e){let t=0,n=new Uint8Array(r),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f,u=0;for(let l=c;l>=0;l--,u++)switch(f=i[s-u]-a[c-u]-t,!0){case f<0:t=1,i[s-u]=f+10;break;default:t=0,i[s-u]=f}if(t>0)for(let l=s-c+1;l>=0;l--,u++)if(f=i[s-u]-t,f<0)t=1,i[s-u]=f+10;else{t=0,i[s-u]=f;break}return i.slice()}var Sn=class extends Ct(Ie){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=ia.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Ru(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,o=0){let i=this.fromBER(e,t,n);if(i===-1)return i;let s=this.valueHexView;return s[0]===0&&s[1]&128?this.valueHexView=s.subarray(1):o!==0&&s.length<o&&(o-s.length>1&&(o=s.length+1),this.valueHexView=s.subarray(o-s.length)),i}toDER(e=!1){let t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){let o=super.fromBER(e,t,n);return o===-1||this.setValueHex(),o}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=new Uint8Array(this.valueHexView.length*8/3),n=0,o,i=this.valueHexView,s="",a=!1;for(let c=i.byteLength-1;c>=0;c--){o=i[c];for(let f=0;f<8;f++){if((o&1)===1)switch(n){case e:t=Xp(Nu(n),t),s="-";break;default:t=Jp(t,Nu(n))}n++,o>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(s+=Tu.charAt(t[c]));return a===!1&&(s+=Tu.charAt(0)),s}};$u=Sn;Sn.NAME="IntegerValueBlock";Object.defineProperty($u.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Hu,le=class r extends ve{constructor(e={}){super(e,Sn),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return So(),BigInt(this.valueBlock.toString())}static fromBigInt(e){So();let t=BigInt(e),n=new Bn,o=t.toString(16).replace(/^-/,""),i=new Uint8Array(Y.Convert.FromHex(o));if(t<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${Y.Convert.ToHex(a)}`)+t,u=Y.BufferSourceConverter.toUint8Array(Y.Convert.FromHex(f.toString(16)));u[0]|=128,n.write(u)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new r({valueHex:n.final()})}convertToDER(){let e=new r({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new r({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};Hu=le;C.Integer=Hu;le.NAME="INTEGER";var Ku,Do=class extends le{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Ku=Do;C.Enumerated=Ku;Do.NAME="ENUMERATED";var In=class extends Ct(Ie){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;let o=Y.BufferSourceConverter.toUint8Array(e);if(!Nt(this,o,t,n))return-1;let i=o.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=pr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){So();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;let n=new Uint8Array(t.length/7);for(let o=0;o<n.length;o++)n[o]=parseInt(t.slice(o*7,o*7+7),2)+(o+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let t=Gt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",it;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),i=t.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n}toString(){let e="";if(this.isHexOnly)e=Y.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};In.NAME="sidBlock";var Po=class extends Ie{constructor({value:e=Yr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new In;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.value.length===0&&(i.isFirstSid=!0),this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e){let t=[];for(let n=0;n<this.value.length;n++){let o=this.value[n].toBER(e);if(o.byteLength===0)return this.error=this.value[n].error,it;t.push(o)}return sa(t)}fromString(e){this.value=[];let t=0,n=0,o="",i=!1;do if(n=e.indexOf(".",t),n===-1?o=e.substring(t):o=e.substring(t,n),t=n+1,i){let s=this.value[0],a=0;switch(s.valueDec){case 0:break;case 1:a=40;break;case 2:a=80;break;default:this.value=[];return}let c=parseInt(o,10);if(isNaN(c))return;s.valueDec=c+a,i=!1}else{let s=new In;if(o>Number.MAX_SAFE_INTEGER){So();let a=BigInt(o);s.valueBigInt=a}else if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return;this.value.length||(s.isFirstSid=!0,i=!0),this.value.push(s)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),t?(o=`{${o}}`,this.value[n].isFirstSid?e=`2.{${o} - 80}`:e+=o):e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};Po.NAME="ObjectIdentifierValueBlock";var qu,ot=class extends ve{constructor(e={}){super(e,Po),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};qu=ot;C.ObjectIdentifier=qu;ot.NAME="OBJECT IDENTIFIER";var Rn=class extends Ct(Rt){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let o=Y.BufferSourceConverter.toUint8Array(e);if(!Nt(this,o,t,n))return-1;let i=o.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=pr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let t=Gt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",it;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),i=t.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n.buffer}toString(){let e="";return this.isHexOnly?e=Y.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};Rn.NAME="relativeSidBlock";var Fo=class extends Ie{constructor({value:e=Yr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new Rn;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e,t){let n=[];for(let o=0;o<this.value.length;o++){let i=this.value[o].toBER(e);if(i.byteLength===0)return this.error=this.value[o].error,it;n.push(i)}return sa(n)}fromString(e){this.value=[];let t=0,n=0,o="";do{n=e.indexOf(".",t),n===-1?o=e.substring(t):o=e.substring(t,n),t=n+1;let i=new Rn;if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(o=`{${o}}`),e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};Fo.NAME="RelativeObjectIdentifierValueBlock";var zu,Mo=class extends ve{constructor(e={}){super(e,Fo),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};zu=Mo;C.RelativeObjectIdentifier=zu;Mo.NAME="RelativeObjectIdentifier";var Gu,we=class extends jt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Gu=we;C.Sequence=Gu;we.NAME="SEQUENCE";var ju,$o=class extends jt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};ju=$o;C.Set=ju;$o.NAME="SET";var Ho=class extends Ct(Ie){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Yr}toJSON(){return{...super.toJSON(),value:this.value}}};Ho.NAME="StringValueBlock";var Ko=class extends Ho{};Ko.NAME="SimpleStringValueBlock";var Ne=class extends ko{constructor({...e}={}){super(e,Ko)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,Y.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);this.valueBlock.value=e}};Ne.NAME="SIMPLE STRING";var qo=class extends Ne{fromBuffer(e){this.valueBlock.valueHexView=Y.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=Y.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=Y.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(Y.Convert.FromUtf8String(e)),this.valueBlock.value=e}};qo.NAME="Utf8StringValueBlock";var Yu,Tt=class extends qo{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Yu=Tt;C.Utf8String=Yu;Tt.NAME="UTF8String";var zo=class extends Ne{fromBuffer(e){this.valueBlock.value=Y.Convert.ToUtf16String(e),this.valueBlock.valueHexView=Y.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(Y.Convert.FromUtf16String(e))}};zo.NAME="BmpStringValueBlock";var Zu,Go=class extends zo{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Zu=Go;C.BmpString=Zu;Go.NAME="BMPString";var jo=class extends Ne{fromBuffer(e){let t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let o=0;o<n.length;o+=4)n[o]=n[o+3],n[o+1]=n[o+2],n[o+2]=0,n[o+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let o=0;o<t;o++){let i=Gt(e.charCodeAt(o),8),s=new Uint8Array(i);if(s.length>4)continue;let a=4-s.length;for(let c=s.length-1;c>=0;c--)n[o*4+c+a]=s[c]}this.valueBlock.value=e}};jo.NAME="UniversalStringValueBlock";var Wu,Yo=class extends jo{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Wu=Yo;C.UniversalString=Wu;Yo.NAME="UniversalString";var Ju,Zo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Ju=Zo;C.NumericString=Ju;Zo.NAME="NumericString";var Xu,Wo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Xu=Wo;C.PrintableString=Xu;Wo.NAME="PrintableString";var Qu,Jo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Qu=Jo;C.TeletexString=Qu;Jo.NAME="TeletexString";var el,Xo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};el=Xo;C.VideotexString=el;Xo.NAME="VideotexString";var tl,Qo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};tl=Qo;C.IA5String=tl;Qo.NAME="IA5String";var rl,ei=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};rl=ei;C.GraphicString=rl;ei.NAME="GraphicString";var nl,kn=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};nl=kn;C.VisibleString=nl;kn.NAME="VisibleString";var ol,ti=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};ol=ti;C.GeneralString=ol;ti.NAME="GeneralString";var il,ri=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};il=ri;C.CharacterString=il;ri.NAME="CharacterString";var sl,Tn=class extends kn{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let o=0;o<e.length;o++)this.valueBlock.valueHexView[o]=e.charCodeAt(o)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,Y.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}let o=parseInt(n[1],10);o>=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){let t=new Array(7);return t[0]=Ve(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Ve(this.month,2),t[2]=Ve(this.day,2),t[3]=Ve(this.hour,2),t[4]=Ve(this.minute,2),t[5]=Ve(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};sl=Tn;C.UTCTime=sl;Tn.NAME="UTCTime";var al,ni=class extends Tn{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",o="",i=0,s,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{let l=new Number(e[e.length-1]);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let l=1,d=n.indexOf("+"),x="";if(d===-1&&(d=n.indexOf("-"),l=-1),d!==-1){if(x=n.substring(d+1),n=n.substring(0,d),x.length!==2&&x.length!==4)throw new Error("Wrong input string for conversion");let y=parseInt(x.substring(0,2),10);if(isNaN(y.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*y,x.length===4){if(y=parseInt(x.substring(2,4),10),isNaN(y.valueOf()))throw new Error("Wrong input string for conversion");c=l*y}}}let f=n.indexOf(".");if(f===-1&&(f=n.indexOf(",")),f!==-1){let l=new Number(`0${n.substring(f)}`);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");i=l.valueOf(),o=n.substring(0,f)}else o=n;switch(!0){case o.length===8:if(s=/(\d{4})(\d{2})(\d{2})/ig,f!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.minute=Math.floor(l),l=60*(l-this.minute),this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=1e3*i;this.millisecond=Math.floor(l)}break;default:throw new Error("Wrong input string for conversion")}let u=s.exec(o);if(u===null)throw new Error("Wrong input string for conversion");for(let l=1;l<u.length;l++)switch(l){case 1:this.year=parseInt(u[l],10);break;case 2:this.month=parseInt(u[l],10);break;case 3:this.day=parseInt(u[l],10);break;case 4:this.hour=parseInt(u[l],10)+a;break;case 5:this.minute=parseInt(u[l],10)+c;break;case 6:this.second=parseInt(u[l],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){let l=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=l.getUTCFullYear(),this.month=l.getUTCMonth(),this.day=l.getUTCDay(),this.hour=l.getUTCHours(),this.minute=l.getUTCMinutes(),this.second=l.getUTCSeconds(),this.millisecond=l.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){let t=[];return t.push(Ve(this.year,4)),t.push(Ve(this.month,2)),t.push(Ve(this.day,2)),t.push(Ve(this.hour,2)),t.push(Ve(this.minute,2)),t.push(Ve(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Ve(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};al=ni;C.GeneralizedTime=al;ni.NAME="GeneralizedTime";var cl,oi=class extends Tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};cl=oi;C.DATE=cl;oi.NAME="DATE";var ul,ii=class extends Tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};ul=ii;C.TimeOfDay=ul;ii.NAME="TimeOfDay";var ll,si=class extends Tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};ll=si;C.DateTime=ll;si.NAME="DateTime";var fl,ai=class extends Tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};fl=ai;C.Duration=fl;ai.NAME="Duration";var hl,ci=class extends Tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};hl=ci;C.TIME=hl;ci.NAME="TIME";function em(r){let{result:e}=Zr(r),t=e.valueBlock.value;return{n:G(mt(t[1].toBigInt()),"base64url"),e:G(mt(t[2].toBigInt()),"base64url"),d:G(mt(t[3].toBigInt()),"base64url"),p:G(mt(t[4].toBigInt()),"base64url"),q:G(mt(t[5].toBigInt()),"base64url"),dp:G(mt(t[6].toBigInt()),"base64url"),dq:G(mt(t[7].toBigInt()),"base64url"),qi:G(mt(t[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function tm(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new D("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new we({value:[new le({value:0}),le.fromBigInt(gt(z(r.n,"base64url"))),le.fromBigInt(gt(z(r.e,"base64url"))),le.fromBigInt(gt(z(r.d,"base64url"))),le.fromBigInt(gt(z(r.p,"base64url"))),le.fromBigInt(gt(z(r.q,"base64url"))),le.fromBigInt(gt(z(r.dp,"base64url"))),le.fromBigInt(gt(z(r.dq,"base64url"))),le.fromBigInt(gt(z(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function rm(r){let{result:e}=Zr(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:G(mt(t[0].toBigInt()),"base64url"),e:G(mt(t[1].toBigInt()),"base64url")}}function nm(r){if(r.n==null||r.e==null)throw new D("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new we({value:[new we({value:[new ot({value:"1.2.840.113549.1.1.1"}),new Yt]}),new jr({valueHex:new we({value:[le.fromBigInt(gt(z(r.n,"base64url"))),le.fromBigInt(gt(z(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function mt(r){let e=r.toString(16);e.length%2>0&&(e=`0${e}`);let t=e.length/2,n=new Uint8Array(t),o=0,i=0;for(;o<t;)n[o]=parseInt(e.slice(i,i+2),16),o+=1,i+=2;return n}function gt(r){let e=[];return r.forEach(function(t){let n=t.toString(16);n.length%2>0&&(n=`0${n}`),e.push(n)}),BigInt("0x"+e.join(""))}var om=16,ca=32,ua=1e4;async function im(r,e){let t=Te.get(),o=new we({value:[new le({value:0}),new we({value:[new ot({value:"1.2.840.113549.1.1.1"}),new Yt]}),new kt({valueHex:r.marshal()})]}).toBER(),i=new Uint8Array(o,0,o.byteLength),s=dr(om),a=await na(dn,e,s,{c:ua,dkLen:ca}),c=dr(16),f=await t.subtle.importKey("raw",a,"AES-CBC",!1,["encrypt"]),u=await t.subtle.encrypt({name:"AES-CBC",iv:c},f,i),l=new we({value:[new kt({valueHex:s}),new le({value:ua}),new le({value:ca}),new we({value:[new ot({value:"1.2.840.113549.2.11"}),new Yt]})]}),d=new we({value:[new ot({value:"1.2.840.113549.1.5.13"}),new we({value:[new we({value:[new ot({value:"1.2.840.113549.1.5.12"}),l]}),new we({value:[new ot({value:"2.16.840.1.101.3.4.1.42"}),new kt({valueHex:c})]})]})]}),y=new we({value:[d,new kt({valueHex:u})]}).toBER(),h=new Uint8Array(y,0,y.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...G(h,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
8
- `)}async function sm(r,e){let t=Te.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let o=z(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:i}=Zr(o),{iv:s,salt:a,iterations:c,keySize:f,cipherText:u}=am(i),l=await na(dn,e,a,{c,dkLen:f}),d=await t.subtle.importKey("raw",l,"AES-CBC",!1,["decrypt"]),x=Nn(await t.subtle.decrypt({name:"AES-CBC",iv:s},d,u)),{result:y}=Zr(x);n=dl(y)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let o=z(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:i}=Zr(o);n=dl(i)}else throw new D("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return la(n)}function am(r){let e=r.valueBlock.value[0];if(e.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.13")throw new D("Only pkcs5PBES2 encrypted private keys are supported","ERR_INVALID_PARAMS");let n=e.valueBlock.value[1].valueBlock.value[0];if(n.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.12")throw new D("Only pkcs5PBKDF2 key derivation functions are supported","ERR_INVALID_PARAMS");let i=n.valueBlock.value[1],s=Nn(i.valueBlock.value[0].getValue()),a=ua,c=ca;if(i.valueBlock.value.length===3)a=Number(i.valueBlock.value[1].toBigInt()),c=Number(i.valueBlock.value[2].toBigInt());else if(i.valueBlock.value.length===2)throw new D("Could not derive key size and iterations from PEM file - please use @libp2p/rsa to re-import your key","ERR_INVALID_PARAMS");let f=e.valueBlock.value[1].valueBlock.value[1],u=f.valueBlock.value[0].toString();if(u!=="OBJECT IDENTIFIER : 1.2.840.113549.3.7"){if(u!=="OBJECT IDENTIFIER : 1.3.14.3.2.7"){if(u!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.2"){if(u!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.22"){if(u!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.42")throw new D("Only AES-CBC encryption schemes are supported","ERR_INVALID_PARAMS")}}}}let l=Nn(f.valueBlock.value[1].getValue());return{cipherText:Nn(r.valueBlock.value[1].getValue()),salt:s,iterations:a,keySize:c,iv:l}}function dl(r){return Nn(r.valueBlock.value[2].getValue())}function Nn(r){return new Uint8Array(r,0,r.byteLength)}async function pl(r){let e=await Te.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),t=await yl(e);return{privateKey:t[0],publicKey:t[1]}}async function fa(r){let t=[await Te.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await cm(r)],n=await yl({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function ml(r,e){let t=await Te.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Te.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function gl(r,e,t){let n=await Te.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Te.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function yl(r){if(r.privateKey==null||r.publicKey==null)throw new D("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([Te.get().subtle.exportKey("jwk",r.privateKey),Te.get().subtle.exportKey("jwk",r.publicKey)])}async function cm(r){return Te.get().subtle.importKey("jwk",{kty:r.kty,n:r.n,e:r.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function li(r){if(r.kty!=="RSA")throw new D("invalid key type","ERR_INVALID_KEY_TYPE");if(r.n==null)throw new D("invalid key modulus","ERR_INVALID_KEY_MODULUS");return z(r.n,"base64url").length*8}var _n=8192,Cn=class{_key;constructor(e){this._key=e}verify(e,t){return gl(this._key,t,e)}marshal(){return Zt.jwkToPkix(this._key)}get bytes(){return dt.encode({Type:ue.RSA,Data:this.marshal()}).subarray()}equals(e){return se(this.bytes,e.bytes)}hash(){let e=Ee.digest(this.bytes);return Ge(e)?e.then(({bytes:t})=>t):e.bytes}},Wr=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return dr(16)}sign(e){return ml(this._key,e)}get public(){if(this._publicKey==null)throw new D("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new Cn(this._publicKey)}marshal(){return Zt.jwkToPkcs1(this._key)}get bytes(){return St.encode({Type:ue.RSA,Data:this.marshal()}).subarray()}equals(e){return se(this.bytes,e.bytes)}hash(){let e=Ee.digest(this.bytes);return Ge(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return G(e,"base58btc")}async export(e,t="pkcs-8"){if(t==="pkcs-8")return Zt.exportToPem(this,e);if(t==="libp2p-key")return Mr(this.bytes,e);throw new D(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function la(r){let e=Zt.pkcs1ToJwk(r);if(li(e)>_n)throw new D("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await fa(e);return new Wr(t.privateKey,t.publicKey)}function lm(r){let e=Zt.pkixToJwk(r);if(li(e)>_n)throw new D("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new Cn(e)}async function fm(r){if(li(r)>_n)throw new D("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await fa(r);return new Wr(e.privateKey,e.publicKey)}async function hm(r){if(r>_n)throw new D("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await pl(r);return new Wr(e.privateKey,e.publicKey)}var ya={};ge(ya,{Secp256k1PrivateKey:()=>Ln,Secp256k1PublicKey:()=>Un,generateKeyPair:()=>Sm,unmarshalSecp256k1PrivateKey:()=>Bm,unmarshalSecp256k1PublicKey:()=>Am});var dm=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]),Wt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Jt=new Uint32Array(64),da=class extends Vr{constructor(){super(64,32,8,!1),this.A=Wt[0]|0,this.B=Wt[1]|0,this.C=Wt[2]|0,this.D=Wt[3]|0,this.E=Wt[4]|0,this.F=Wt[5]|0,this.G=Wt[6]|0,this.H=Wt[7]|0}get(){let{A:e,B:t,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,t,n,o,i,s,a,c]}set(e,t,n,o,i,s,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,t){for(let l=0;l<16;l++,t+=4)Jt[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let d=Jt[l-15],x=Jt[l-2],y=et(d,7)^et(d,18)^d>>>3,h=et(x,17)^et(x,19)^x>>>10;Jt[l]=h+Jt[l-7]+y+Jt[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let d=et(a,6)^et(a,11)^et(a,25),x=u+d+Wc(a,c,f)+dm[l]+Jt[l]|0,h=(et(n,2)^et(n,13)^et(n,22))+Jc(n,o,i)|0;u=f,f=c,c=a,a=s+x|0,s=i,i=o,o=n,n=x+h|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,f,u)}roundClean(){Jt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var wl=ao(()=>new da);function bl(r){r.lowS!==void 0&&tt("lowS",r.lowS),r.prehash!==void 0&&tt("prehash",r.prehash)}function pm(r){let e=gn(r);ht(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:o}=e;if(t){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:mm,hexToBytes:gm}=lo,mr={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){let{Err:e}=mr;if(r.length<2||r[0]!==2)throw new e("Invalid signature integer tag");let t=r[1],n=r.subarray(2,t+2);if(!t||n.length!==t)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:mm(n),l:r.subarray(t+2)}},toSig(r){let{Err:e}=mr,t=typeof r=="string"?gm(r):r;Dr(t);let n=t.length;if(n<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:o,l:i}=mr._parseInt(t.subarray(2)),{d:s,l:a}=mr._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:o,s}},hexFromSig(r){let e=f=>Number.parseInt(f[0],16)&8?"00"+f:f,t=f=>{let u=f.toString(16);return u.length&1?`0${u}`:u},n=e(t(r.s)),o=e(t(r.r)),i=n.length/2,s=o.length/2,a=t(i),c=t(s);return`30${t(s+i+4)}02${c}${o}02${a}${n}`}},Xt=BigInt(0),be=BigInt(1),H1=BigInt(2),xl=BigInt(3),K1=BigInt(4);function ym(r){let e=pm(r),{Fp:t}=e,n=e.toBytes||((y,h,g)=>{let v=h.toAffine();return Bt(Uint8Array.from([4]),t.toBytes(v.x),t.toBytes(v.y))}),o=e.fromBytes||(y=>{let h=y.subarray(1),g=t.fromBytes(h.subarray(0,t.BYTES)),v=t.fromBytes(h.subarray(t.BYTES,2*t.BYTES));return{x:g,y:v}});function i(y){let{a:h,b:g}=e,v=t.sqr(y),E=t.mul(v,y);return t.add(t.add(E,t.mul(y,h)),g)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function s(y){return pn(y,be,e.n)}function a(y){let{allowedPrivateKeyLengths:h,nByteLength:g,wrapPrivateKey:v,n:E}=e;if(h&&typeof y!="bigint"){if(Ht(y)&&(y=Et(y)),typeof y!="string"||!h.includes(y.length))throw new Error("Invalid key");y=y.padStart(g*2,"0")}let B;try{B=typeof y=="bigint"?y:vt(ae("private key",y,g))}catch{throw new Error(`private key must be ${g} bytes, hex or bigint, not ${typeof y}`)}return v&&(B=Q(B,E)),Le("private key",B,be,E),B}function c(y){if(!(y instanceof l))throw new Error("ProjectivePoint expected")}let f=cr((y,h)=>{let{px:g,py:v,pz:E}=y;if(t.eql(E,t.ONE))return{x:g,y:v};let B=y.is0();h==null&&(h=B?t.ONE:t.inv(E));let O=t.mul(g,h),U=t.mul(v,h),k=t.mul(E,h);if(B)return{x:t.ZERO,y:t.ZERO};if(!t.eql(k,t.ONE))throw new Error("invZ was invalid");return{x:O,y:U}}),u=cr(y=>{if(y.is0()){if(e.allowInfinityPoint&&!t.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:h,y:g}=y.toAffine();if(!t.isValid(h)||!t.isValid(g))throw new Error("bad point: x or y not FE");let v=t.sqr(g),E=i(h);if(!t.eql(v,E))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class l{constructor(h,g,v){if(this.px=h,this.py=g,this.pz=v,h==null||!t.isValid(h))throw new Error("x required");if(g==null||!t.isValid(g))throw new Error("y required");if(v==null||!t.isValid(v))throw new Error("z required");Object.freeze(this)}static fromAffine(h){let{x:g,y:v}=h||{};if(!h||!t.isValid(g)||!t.isValid(v))throw new Error("invalid affine point");if(h instanceof l)throw new Error("projective point not allowed");let E=B=>t.eql(B,t.ZERO);return E(g)&&E(v)?l.ZERO:new l(g,v,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let g=t.invertBatch(h.map(v=>v.pz));return h.map((v,E)=>v.toAffine(g[E])).map(l.fromAffine)}static fromHex(h){let g=l.fromAffine(o(ae("pointHex",h)));return g.assertValidity(),g}static fromPrivateKey(h){return l.BASE.multiply(a(h))}_setWindowSize(h){x.setWindowSize(this,h)}assertValidity(){u(this)}hasEvenY(){let{y:h}=this.toAffine();if(t.isOdd)return!t.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){c(h);let{px:g,py:v,pz:E}=this,{px:B,py:O,pz:U}=h,k=t.eql(t.mul(g,U),t.mul(B,E)),L=t.eql(t.mul(v,U),t.mul(O,E));return k&&L}negate(){return new l(this.px,t.neg(this.py),this.pz)}double(){let{a:h,b:g}=e,v=t.mul(g,xl),{px:E,py:B,pz:O}=this,U=t.ZERO,k=t.ZERO,L=t.ZERO,b=t.mul(E,E),T=t.mul(B,B),V=t.mul(O,O),N=t.mul(E,B);return N=t.add(N,N),L=t.mul(E,O),L=t.add(L,L),U=t.mul(h,L),k=t.mul(v,V),k=t.add(U,k),U=t.sub(T,k),k=t.add(T,k),k=t.mul(U,k),U=t.mul(N,U),L=t.mul(v,L),V=t.mul(h,V),N=t.sub(b,V),N=t.mul(h,N),N=t.add(N,L),L=t.add(b,b),b=t.add(L,b),b=t.add(b,V),b=t.mul(b,N),k=t.add(k,b),V=t.mul(B,O),V=t.add(V,V),b=t.mul(V,N),U=t.sub(U,b),L=t.mul(V,T),L=t.add(L,L),L=t.add(L,L),new l(U,k,L)}add(h){c(h);let{px:g,py:v,pz:E}=this,{px:B,py:O,pz:U}=h,k=t.ZERO,L=t.ZERO,b=t.ZERO,T=e.a,V=t.mul(e.b,xl),N=t.mul(g,B),F=t.mul(v,O),H=t.mul(E,U),S=t.add(g,v),m=t.add(B,O);S=t.mul(S,m),m=t.add(N,F),S=t.sub(S,m),m=t.add(g,E);let p=t.add(B,U);return m=t.mul(m,p),p=t.add(N,H),m=t.sub(m,p),p=t.add(v,E),k=t.add(O,U),p=t.mul(p,k),k=t.add(F,H),p=t.sub(p,k),b=t.mul(T,m),k=t.mul(V,H),b=t.add(k,b),k=t.sub(F,b),b=t.add(F,b),L=t.mul(k,b),F=t.add(N,N),F=t.add(F,N),H=t.mul(T,H),m=t.mul(V,m),F=t.add(F,H),H=t.sub(N,H),H=t.mul(T,H),m=t.add(m,H),N=t.mul(F,m),L=t.add(L,N),N=t.mul(p,m),k=t.mul(S,k),k=t.sub(k,N),N=t.mul(S,F),b=t.mul(p,b),b=t.add(b,N),new l(k,L,b)}subtract(h){return this.add(h.negate())}is0(){return this.equals(l.ZERO)}wNAF(h){return x.wNAFCached(this,h,l.normalizeZ)}multiplyUnsafe(h){Le("scalar",h,Xt,e.n);let g=l.ZERO;if(h===Xt)return g;if(h===be)return this;let{endo:v}=e;if(!v)return x.unsafeLadder(this,h);let{k1neg:E,k1:B,k2neg:O,k2:U}=v.splitScalar(h),k=g,L=g,b=this;for(;B>Xt||U>Xt;)B&be&&(k=k.add(b)),U&be&&(L=L.add(b)),b=b.double(),B>>=be,U>>=be;return E&&(k=k.negate()),O&&(L=L.negate()),L=new l(t.mul(L.px,v.beta),L.py,L.pz),k.add(L)}multiply(h){let{endo:g,n:v}=e;Le("scalar",h,be,v);let E,B;if(g){let{k1neg:O,k1:U,k2neg:k,k2:L}=g.splitScalar(h),{p:b,f:T}=this.wNAF(U),{p:V,f:N}=this.wNAF(L);b=x.constTimeNegate(O,b),V=x.constTimeNegate(k,V),V=new l(t.mul(V.px,g.beta),V.py,V.pz),E=b.add(V),B=T.add(N)}else{let{p:O,f:U}=this.wNAF(h);E=O,B=U}return l.normalizeZ([E,B])[0]}multiplyAndAddUnsafe(h,g,v){let E=l.BASE,B=(U,k)=>k===Xt||k===be||!U.equals(E)?U.multiplyUnsafe(k):U.multiply(k),O=B(this,g).add(B(h,v));return O.is0()?void 0:O}toAffine(h){return f(this,h)}isTorsionFree(){let{h,isTorsionFree:g}=e;if(h===be)return!0;if(g)return g(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:g}=e;return h===be?this:g?g(l,this):this.multiplyUnsafe(e.h)}toRawBytes(h=!0){return tt("isCompressed",h),this.assertValidity(),n(l,this,h)}toHex(h=!0){return tt("isCompressed",h),Et(this.toRawBytes(h))}}l.BASE=new l(e.Gx,e.Gy,t.ONE),l.ZERO=new l(t.ZERO,t.ONE,t.ZERO);let d=e.nBitLength,x=po(l,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:s}}function wm(r){let e=gn(r);return ht(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function El(r){let e=wm(r),{Fp:t,n}=e,o=t.BYTES+1,i=2*t.BYTES+1;function s(S){return Q(S,n)}function a(S){return fo(S,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=ym({...e,toBytes(S,m,p){let A=m.toAffine(),R=t.toBytes(A.x),P=Bt;return tt("isCompressed",p),p?P(Uint8Array.from([m.hasEvenY()?2:3]),R):P(Uint8Array.from([4]),R,t.toBytes(A.y))},fromBytes(S){let m=S.length,p=S[0],A=S.subarray(1);if(m===o&&(p===2||p===3)){let R=vt(A);if(!pn(R,be,t.ORDER))throw new Error("Point is not on curve");let P=u(R),M;try{M=t.sqrt(P)}catch(j){let J=j instanceof Error?": "+j.message:"";throw new Error("Point is not on curve"+J)}let K=(M&be)===be;return(p&1)===1!==K&&(M=t.neg(M)),{x:R,y:M}}else if(m===i&&p===4){let R=t.fromBytes(A.subarray(0,t.BYTES)),P=t.fromBytes(A.subarray(t.BYTES,2*t.BYTES));return{x:R,y:P}}else throw new Error(`Point of length ${m} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),d=S=>Et(qt(S,e.nByteLength));function x(S){let m=n>>be;return S>m}function y(S){return x(S)?s(-S):S}let h=(S,m,p)=>vt(S.slice(m,p));class g{constructor(m,p,A){this.r=m,this.s=p,this.recovery=A,this.assertValidity()}static fromCompact(m){let p=e.nByteLength;return m=ae("compactSignature",m,p*2),new g(h(m,0,p),h(m,p,2*p))}static fromDER(m){let{r:p,s:A}=mr.toSig(ae("DER",m));return new g(p,A)}assertValidity(){Le("r",this.r,be,n),Le("s",this.s,be,n)}addRecoveryBit(m){return new g(this.r,this.s,m)}recoverPublicKey(m){let{r:p,s:A,recovery:R}=this,P=k(ae("msgHash",m));if(R==null||![0,1,2,3].includes(R))throw new Error("recovery id invalid");let M=R===2||R===3?p+e.n:p;if(M>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let K=R&1?"03":"02",W=c.fromHex(K+d(M)),j=a(M),J=s(-P*j),ne=s(A*j),oe=c.BASE.multiplyAndAddUnsafe(W,J,ne);if(!oe)throw new Error("point at infinify");return oe.assertValidity(),oe}hasHighS(){return x(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return sr(this.toDERHex())}toDERHex(){return mr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return sr(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}let v={isValidPrivateKey(S){try{return f(S),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let S=Fs(e.n);return su(e.randomBytes(S),e.n)},precompute(S=8,m=c.BASE){return m._setWindowSize(S),m.multiply(BigInt(3)),m}};function E(S,m=!0){return c.fromPrivateKey(S).toRawBytes(m)}function B(S){let m=Ht(S),p=typeof S=="string",A=(m||p)&&S.length;return m?A===o||A===i:p?A===2*o||A===2*i:S instanceof c}function O(S,m,p=!0){if(B(S))throw new Error("first arg must be private key");if(!B(m))throw new Error("second arg must be public key");return c.fromHex(m).multiply(f(S)).toRawBytes(p)}let U=e.bits2int||function(S){let m=vt(S),p=S.length*8-e.nBitLength;return p>0?m>>BigInt(p):m},k=e.bits2int_modN||function(S){return s(U(S))},L=mn(e.nBitLength);function b(S){return Le(`num < 2^${e.nBitLength}`,S,Xt,L),qt(S,e.nByteLength)}function T(S,m,p=V){if(["recovered","canonical"].some(pe=>pe in p))throw new Error("sign() legacy options not supported");let{hash:A,randomBytes:R}=e,{lowS:P,prehash:M,extraEntropy:K}=p;P==null&&(P=!0),S=ae("msgHash",S),bl(p),M&&(S=ae("prehashed msgHash",A(S)));let W=k(S),j=f(m),J=[b(j),b(W)];if(K!=null&&K!==!1){let pe=K===!0?R(t.BYTES):K;J.push(ae("extraEntropy",pe))}let ne=Bt(...J),oe=W;function _e(pe){let he=U(pe);if(!l(he))return;let We=a(he),me=c.BASE.multiply(he).toAffine(),Je=s(me.x);if(Je===Xt)return;let rr=s(We*s(oe+Je*j));if(rr===Xt)return;let on=(me.x===Je?0:2)|Number(me.y&be),zn=rr;return P&&x(rr)&&(zn=y(rr),on^=1),new g(Je,zn,on)}return{seed:ne,k2sig:_e}}let V={lowS:e.lowS,prehash:!1},N={lowS:e.lowS,prehash:!1};function F(S,m,p=V){let{seed:A,k2sig:R}=T(S,m,p),P=e;return Os(P.hash.outputLen,P.nByteLength,P.hmac)(A,R)}c.BASE._setWindowSize(8);function H(S,m,p,A=N){let R=S;if(m=ae("msgHash",m),p=ae("publicKey",p),"strict"in A)throw new Error("options.strict was renamed to lowS");bl(A);let{lowS:P,prehash:M}=A,K,W;try{if(typeof R=="string"||Ht(R))try{K=g.fromDER(R)}catch(me){if(!(me instanceof mr.Err))throw me;K=g.fromCompact(R)}else if(typeof R=="object"&&typeof R.r=="bigint"&&typeof R.s=="bigint"){let{r:me,s:Je}=R;K=new g(me,Je)}else throw new Error("PARSE");W=c.fromHex(p)}catch(me){if(me.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(P&&K.hasHighS())return!1;M&&(m=e.hash(m));let{r:j,s:J}=K,ne=k(m),oe=a(J),_e=s(ne*oe),pe=s(j*oe),he=c.BASE.multiplyAndAddUnsafe(W,_e,pe)?.toAffine();return he?s(he.x)===j:!1}return{CURVE:e,getPublicKey:E,getSharedSecret:O,sign:F,verify:H,ProjectivePoint:c,Signature:g,utils:v}}function bm(r){return{hash:r,hmac:(e,...t)=>En(r,e,ks(...t)),randomBytes:Or}}function vl(r,e){let t=n=>El({...r,...bm(n)});return Object.freeze({...t(e),create:t})}var Sl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Bl=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),xm=BigInt(1),pa=BigInt(2),Al=(r,e)=>(r+e/pa)/e;function Em(r){let e=Sl,t=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=r*r*r%e,u=f*f*r%e,l=re(u,t,e)*u%e,d=re(l,t,e)*u%e,x=re(d,pa,e)*f%e,y=re(x,o,e)*x%e,h=re(y,i,e)*y%e,g=re(h,a,e)*h%e,v=re(g,c,e)*g%e,E=re(v,a,e)*h%e,B=re(E,t,e)*u%e,O=re(B,s,e)*y%e,U=re(O,n,e)*f%e,k=re(U,pa,e);if(!ma.eql(ma.sqr(k),r))throw new Error("Cannot find square root");return k}var ma=ho(Sl,void 0,void 0,{sqrt:Em}),st=vl({a:BigInt(0),b:BigInt(7),Fp:ma,n:Bl,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=Bl,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-xm*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,s=BigInt("0x100000000000000000000000000000000"),a=Al(i*r,e),c=Al(-n*r,e),f=Q(r-a*t-c*o,e),u=Q(-a*n-c*i,e),l=f>s,d=u>s;if(l&&(f=e-f),d&&(u=e-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:d,k2:u}}}},wl),X1=BigInt(0);var Q1=st.ProjectivePoint;function Il(){return st.utils.randomPrivateKey()}function Rl(r,e){let t=Ee.digest(e instanceof Uint8Array?e:e.subarray());if(Ge(t))return t.then(({digest:n})=>st.sign(n,r).toDERRawBytes()).catch(n=>{throw new D(String(n),"ERR_INVALID_INPUT")});try{return st.sign(t.digest,r).toDERRawBytes()}catch(n){throw new D(String(n),"ERR_INVALID_INPUT")}}function kl(r,e,t){let n=Ee.digest(t instanceof Uint8Array?t:t.subarray());if(Ge(n))return n.then(({digest:o})=>st.verify(e,o,r)).catch(o=>{throw new D(String(o),"ERR_INVALID_INPUT")});try{return st.verify(e,n.digest,r)}catch(o){throw new D(String(o),"ERR_INVALID_INPUT")}}function Tl(r){return st.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Nl(r){try{st.getPublicKey(r,!0)}catch(e){throw new D(String(e),"ERR_INVALID_PRIVATE_KEY")}}function ga(r){try{st.ProjectivePoint.fromHex(r)}catch(e){throw new D(String(e),"ERR_INVALID_PUBLIC_KEY")}}function Cl(r){try{return st.getPublicKey(r,!0)}catch(e){throw new D(String(e),"ERR_INVALID_PRIVATE_KEY")}}var Un=class{_key;constructor(e){ga(e),this._key=e}verify(e,t){return kl(this._key,t,e)}marshal(){return Tl(this._key)}get bytes(){return dt.encode({Type:ue.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return se(this.bytes,e.bytes)}async hash(){let e=Ee.digest(this.bytes),t;return Ge(e)?{bytes:t}=await e:t=e.bytes,t}},Ln=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??Cl(e),Nl(this._key),ga(this._publicKey)}sign(e){return Rl(this._key,e)}get public(){return new Un(this._publicKey)}marshal(){return this._key}get bytes(){return St.encode({Type:ue.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return se(this.bytes,e.bytes)}hash(){let e=Ee.digest(this.bytes);return Ge(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return G(e,"base58btc")}async export(e,t="libp2p-key"){if(t==="libp2p-key")return Mr(this.bytes,e);throw new D(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Bm(r){return new Ln(r)}function Am(r){return new Un(r)}async function Sm(){let r=Il();return new Ln(r)}var fi={rsa:ha,ed25519:ra,secp256k1:ya};function Im(r){let e=Object.keys(fi).join(" / ");return new D(`invalid or unsupported key type ${r}. Must be ${e}`,"ERR_UNSUPPORTED_KEY_TYPE")}function wa(r){let e=dt.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case ue.RSA:return fi.rsa.unmarshalRsaPublicKey(t);case ue.Ed25519:return fi.ed25519.unmarshalEd25519PublicKey(t);case ue.Secp256k1:return fi.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw Im(e.Type??"unknown")}}var ag=nr(hi(),1);var km="/",Tm=new TextEncoder().encode(km),g2=Tm[0];var cg=nr(xa(),1);var Ll="ERR_IPNS_EXPIRED_RECORD",di="ERR_UNRECOGNIZED_VALIDITY";var _t="ERR_SIGNATURE_VERIFICATION";var Ea="ERR_UNDEFINED_PARAMETER",Ol="ERR_INVALID_RECORD_DATA",Vl="ERR_INVALID_VALUE",Dl="ERR_INVALID_EMBEDDED_KEY";var Pl="ERR_RECORD_TOO_LARGE";var at;(function(r){let e;(function(o){o.EOL="EOL"})(e=r.ValidityType||(r.ValidityType={}));let t;(function(o){o[o.EOL=0]="EOL"})(t||(t={})),function(o){o.codec=()=>bn(t)}(e=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=qr((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),r.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)=>{let s={},a=i==null?o.len:o.pos+i;for(;o.pos<a;){let c=o.uint32();switch(c>>>3){case 1:s.value=o.bytes();break;case 2:s.signatureV1=o.bytes();break;case 3:s.validityType=r.ValidityType.codec().decode(o);break;case 4:s.validity=o.bytes();break;case 5:s.sequence=o.uint64();break;case 6:s.ttl=o.uint64();break;case 7:s.pubKey=o.bytes();break;case 8:s.signatureV2=o.bytes();break;case 9:s.data=o.bytes();break;default:o.skipType(c&7);break}}return s})),n),r.encode=o=>Hr(o,r.codec()),r.decode=o=>$r(o,r.codec())})(at||(at={}));var Nm=["string","number","bigint","symbol"],Cm=["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 Ml(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(Nm.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(_m(r))return"Buffer";let t=Um(r);return t||"Object"}function _m(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Um(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(Cm.includes(e))return e}var w=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};w.uint=new w(0,"uint",!0);w.negint=new w(1,"negint",!0);w.bytes=new w(2,"bytes",!0);w.string=new w(3,"string",!0);w.array=new w(4,"array",!1);w.map=new w(5,"map",!1);w.tag=new w(6,"tag",!1);w.float=new w(7,"float",!0);w.false=new w(7,"false",!0);w.true=new w(7,"true",!0);w.null=new w(7,"null",!0);w.undefined=new w(7,"undefined",!0);w.break=new w(7,"break",!0);var _=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Jr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Lm=new TextDecoder,Om=new TextEncoder;function pi(r){return Jr&&globalThis.Buffer.isBuffer(r)}function ql(r){return r instanceof Uint8Array?pi(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var zl=Jr?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):Hl(r,e,t):(r,e,t)=>t-e>64?Lm.decode(r.subarray(e,t)):Hl(r,e,t),Gl=Jr?r=>r.length>64?globalThis.Buffer.from(r):$l(r):r=>r.length>64?Om.encode(r):$l(r);var Xr=Jr?(r,e,t)=>pi(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),jl=Jr?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),ql(globalThis.Buffer.concat(r,e))):(r,e)=>{let t=new Uint8Array(e),n=0;for(let o of r)n+o.length>t.length&&(o=o.subarray(0,t.length-n)),t.set(o,n),n+=o.length;return t},Yl=Jr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Zl(r,e){if(pi(r)&&pi(e))return r.compare(e);for(let t=0;t<r.length;t++)if(r[t]!==e[t])return r[t]<e[t]?-1:1;return 0}function $l(r){let e=[],t=0;for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(r.charCodeAt(++n)&1023),e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128)}return e}function Hl(r,e,t){let n=[];for(;e<t;){let o=r[e],i=null,s=o>239?4:o>223?3:o>191?2:1;if(e+s<=t){let a,c,f,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=r[e+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=r[e+1],c=r[e+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=r[e+1],c=r[e+2],f=r[e+3],(a&192)===128&&(c&192)===128&&(f&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|f&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),e+=s}return Vm(n)}var Kl=4096;function Vm(r){let e=r.length;if(e<=Kl)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Kl));return t}var Dm=256,mi=class{constructor(e=Dm){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=t.length-(this.maxCursor-this.cursor)-1;t.set(e,o)}else{if(t){let o=t.length-(this.maxCursor-this.cursor)-1;o<t.length&&(this.chunks[this.chunks.length-1]=t.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(t=Yl(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=Xr(n,0,this.cursor)}else t=jl(this.chunks,this.cursor);return e&&this.reset(),t}};var $="CBOR decode error:",va="CBOR encode error:",On=[];On[23]=1;On[24]=2;On[25]=3;On[26]=5;On[27]=9;function Ut(r,e,t){if(r.length-e<t)throw new Error(`${$} not enough data for type`)}var xe=[24,256,65536,4294967296,BigInt("18446744073709551616")];function $e(r,e,t){Ut(r,e,1);let n=r[e];if(t.strict===!0&&n<xe[0])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function He(r,e,t){Ut(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<xe[1])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function Ke(r,e,t){Ut(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<xe[2])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function qe(r,e,t){Ut(r,e,8);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3],o=r[e+4]*16777216+(r[e+5]<<16)+(r[e+6]<<8)+r[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(t.strict===!0&&i<xe[3])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(t.allowBigInt===!0)return i;throw new Error(`${$} integers outside of the safe integer range are not supported`)}function Wl(r,e,t,n){return new _(w.uint,$e(r,e+1,n),2)}function Jl(r,e,t,n){return new _(w.uint,He(r,e+1,n),3)}function Xl(r,e,t,n){return new _(w.uint,Ke(r,e+1,n),5)}function Ql(r,e,t,n){return new _(w.uint,qe(r,e+1,n),9)}function Ye(r,e){return Be(r,0,e.value)}function Be(r,e,t){if(t<xe[0]){let n=Number(t);r.push([e|n])}else if(t<xe[1]){let n=Number(t);r.push([e|24,n])}else if(t<xe[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<xe[3]){let n=Number(t);r.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(t);if(n<xe[4]){let o=[e|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,r.push(o)}else throw new Error(`${$} encountered BigInt larger than allowable range`)}}Ye.encodedSize=function(e){return Be.encodedSize(e.value)};Be.encodedSize=function(e){return e<xe[0]?1:e<xe[1]?2:e<xe[2]?3:e<xe[3]?5:9};Ye.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function ef(r,e,t,n){return new _(w.negint,-1-$e(r,e+1,n),2)}function tf(r,e,t,n){return new _(w.negint,-1-He(r,e+1,n),3)}function rf(r,e,t,n){return new _(w.negint,-1-Ke(r,e+1,n),5)}var Ba=BigInt(-1),nf=BigInt(1);function of(r,e,t,n){let o=qe(r,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new _(w.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${$} integers outside of the safe integer range are not supported`);return new _(w.negint,Ba-BigInt(o),9)}function gi(r,e){let t=e.value,n=typeof t=="bigint"?t*Ba-nf:t*-1-1;Be(r,e.type.majorEncoded,n)}gi.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*Ba-nf:t*-1-1;return n<xe[0]?1:n<xe[1]?2:n<xe[2]?3:n<xe[3]?5:9};gi.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function Vn(r,e,t,n){Ut(r,e,t+n);let o=Xr(r,e+t,e+t+n);return new _(w.bytes,o,t+n)}function sf(r,e,t,n){return Vn(r,e,1,t)}function af(r,e,t,n){return Vn(r,e,2,$e(r,e+1,n))}function cf(r,e,t,n){return Vn(r,e,3,He(r,e+1,n))}function uf(r,e,t,n){return Vn(r,e,5,Ke(r,e+1,n))}function lf(r,e,t,n){let o=qe(r,e+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer bytes lengths not supported`);return Vn(r,e,9,o)}function yi(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===w.string?Gl(r.value):r.value),r.encodedBytes}function Qr(r,e){let t=yi(e);Be(r,e.type.majorEncoded,t.length),r.push(t)}Qr.encodedSize=function(e){let t=yi(e);return Be.encodedSize(t.length)+t.length};Qr.compareTokens=function(e,t){return Fm(yi(e),yi(t))};function Fm(r,e){return r.length<e.length?-1:r.length>e.length?1:Zl(r,e)}function Dn(r,e,t,n,o){let i=t+n;Ut(r,e,i);let s=new _(w.string,zl(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Xr(r,e+t,e+i)),s}function ff(r,e,t,n){return Dn(r,e,1,t,n)}function hf(r,e,t,n){return Dn(r,e,2,$e(r,e+1,n),n)}function df(r,e,t,n){return Dn(r,e,3,He(r,e+1,n),n)}function pf(r,e,t,n){return Dn(r,e,5,Ke(r,e+1,n),n)}function mf(r,e,t,n){let o=qe(r,e+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer string lengths not supported`);return Dn(r,e,9,o,n)}var gf=Qr;function en(r,e,t,n){return new _(w.array,n,t)}function yf(r,e,t,n){return en(r,e,1,t)}function wf(r,e,t,n){return en(r,e,2,$e(r,e+1,n))}function bf(r,e,t,n){return en(r,e,3,He(r,e+1,n))}function xf(r,e,t,n){return en(r,e,5,Ke(r,e+1,n))}function Ef(r,e,t,n){let o=qe(r,e+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer array lengths not supported`);return en(r,e,9,o)}function vf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return en(r,e,1,1/0)}function wi(r,e){Be(r,w.array.majorEncoded,e.value)}wi.compareTokens=Ye.compareTokens;wi.encodedSize=function(e){return Be.encodedSize(e.value)};function tn(r,e,t,n){return new _(w.map,n,t)}function Bf(r,e,t,n){return tn(r,e,1,t)}function Af(r,e,t,n){return tn(r,e,2,$e(r,e+1,n))}function Sf(r,e,t,n){return tn(r,e,3,He(r,e+1,n))}function If(r,e,t,n){return tn(r,e,5,Ke(r,e+1,n))}function Rf(r,e,t,n){let o=qe(r,e+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer map lengths not supported`);return tn(r,e,9,o)}function kf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return tn(r,e,1,1/0)}function bi(r,e){Be(r,w.map.majorEncoded,e.value)}bi.compareTokens=Ye.compareTokens;bi.encodedSize=function(e){return Be.encodedSize(e.value)};function Tf(r,e,t,n){return new _(w.tag,t,1)}function Nf(r,e,t,n){return new _(w.tag,$e(r,e+1,n),2)}function Cf(r,e,t,n){return new _(w.tag,He(r,e+1,n),3)}function _f(r,e,t,n){return new _(w.tag,Ke(r,e+1,n),5)}function Uf(r,e,t,n){return new _(w.tag,qe(r,e+1,n),9)}function xi(r,e){Be(r,w.tag.majorEncoded,e.value)}xi.compareTokens=Ye.compareTokens;xi.encodedSize=function(e){return Be.encodedSize(e.value)};var zm=20,Gm=21,jm=22,Ym=23;function Lf(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${$} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new _(w.null,null,1):new _(w.undefined,void 0,1)}function Of(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return new _(w.break,void 0,1)}function Aa(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${$} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${$} Infinity values are not supported`)}return new _(w.float,r,e)}function Vf(r,e,t,n){return Aa(Sa(r,e+1),3,n)}function Df(r,e,t,n){return Aa(Ia(r,e+1),5,n)}function Pf(r,e,t,n){return Aa(Hf(r,e+1),9,n)}function Ei(r,e,t){let n=e.value;if(n===!1)r.push([w.float.majorEncoded|zm]);else if(n===!0)r.push([w.float.majorEncoded|Gm]);else if(n===null)r.push([w.float.majorEncoded|jm]);else if(n===void 0)r.push([w.float.majorEncoded|Ym]);else{let o,i=!1;(!t||t.float64!==!0)&&(Mf(n),o=Sa(ct,1),n===o||Number.isNaN(n)?(ct[0]=249,r.push(ct.slice(0,3)),i=!0):($f(n),o=Ia(ct,1),n===o&&(ct[0]=250,r.push(ct.slice(0,5)),i=!0))),i||(Zm(n),o=Hf(ct,1),ct[0]=251,r.push(ct.slice(0,9)))}}Ei.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!t||t.float64!==!0){Mf(n);let o=Sa(ct,1);if(n===o||Number.isNaN(n))return 3;if($f(n),o=Ia(ct,1),n===o)return 5}return 9};var Ff=new ArrayBuffer(9),Ze=new DataView(Ff,1),ct=new Uint8Array(Ff,0);function Mf(r){if(r===1/0)Ze.setUint16(0,31744,!1);else if(r===-1/0)Ze.setUint16(0,64512,!1);else if(Number.isNaN(r))Ze.setUint16(0,32256,!1);else{Ze.setFloat32(0,r);let e=Ze.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)Ze.setUint16(0,31744,!1);else if(t===0)Ze.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?Ze.setUint16(0,0):o<-14?Ze.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):Ze.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Sa(r,e){if(r.length-e<2)throw new Error(`${$} not enough data for float16`);let t=(r[e]<<8)+r[e+1];if(t===31744)return 1/0;if(t===64512)return-1/0;if(t===32256)return NaN;let n=t>>10&31,o=t&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,t&32768?-i:i}function $f(r){Ze.setFloat32(0,r,!1)}function Ia(r,e){if(r.length-e<4)throw new Error(`${$} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function Zm(r){Ze.setFloat64(0,r,!1)}function Hf(r,e){if(r.length-e<8)throw new Error(`${$} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}Ei.compareTokens=Ye.compareTokens;function Z(r,e,t){throw new Error(`${$} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function vi(r){return()=>{throw new Error(`${$} ${r}`)}}var I=[];for(let r=0;r<=23;r++)I[r]=Z;I[24]=Wl;I[25]=Jl;I[26]=Xl;I[27]=Ql;I[28]=Z;I[29]=Z;I[30]=Z;I[31]=Z;for(let r=32;r<=55;r++)I[r]=Z;I[56]=ef;I[57]=tf;I[58]=rf;I[59]=of;I[60]=Z;I[61]=Z;I[62]=Z;I[63]=Z;for(let r=64;r<=87;r++)I[r]=sf;I[88]=af;I[89]=cf;I[90]=uf;I[91]=lf;I[92]=Z;I[93]=Z;I[94]=Z;I[95]=vi("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)I[r]=ff;I[120]=hf;I[121]=df;I[122]=pf;I[123]=mf;I[124]=Z;I[125]=Z;I[126]=Z;I[127]=vi("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)I[r]=yf;I[152]=wf;I[153]=bf;I[154]=xf;I[155]=Ef;I[156]=Z;I[157]=Z;I[158]=Z;I[159]=vf;for(let r=160;r<=183;r++)I[r]=Bf;I[184]=Af;I[185]=Sf;I[186]=If;I[187]=Rf;I[188]=Z;I[189]=Z;I[190]=Z;I[191]=kf;for(let r=192;r<=215;r++)I[r]=Tf;I[216]=Nf;I[217]=Cf;I[218]=_f;I[219]=Uf;I[220]=Z;I[221]=Z;I[222]=Z;I[223]=Z;for(let r=224;r<=243;r++)I[r]=vi("simple values are not supported");I[244]=Z;I[245]=Z;I[246]=Z;I[247]=Lf;I[248]=vi("simple values are not supported");I[249]=Vf;I[250]=Df;I[251]=Pf;I[252]=Z;I[253]=Z;I[254]=Z;I[255]=Of;var ut=[];for(let r=0;r<24;r++)ut[r]=new _(w.uint,r,1);for(let r=-1;r>=-24;r--)ut[31-r]=new _(w.negint,r,1);ut[64]=new _(w.bytes,new Uint8Array(0),1);ut[96]=new _(w.string,"",1);ut[128]=new _(w.array,0,1);ut[160]=new _(w.map,0,1);ut[244]=new _(w.false,!1,1);ut[245]=new _(w.true,!0,1);ut[246]=new _(w.null,null,1);function Jm(){let r=[];return r[w.uint.major]=Ye,r[w.negint.major]=gi,r[w.bytes.major]=Qr,r[w.string.major]=gf,r[w.array.major]=wi,r[w.map.major]=bi,r[w.tag.major]=xi,r[w.float.major]=Ei,r}var dE=Jm(),pE=new mi,Bi=class r{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${va} object contains circular references`);return new r(t,e)}},Qt={null:new _(w.null,null),undefined:new _(w.undefined,void 0),true:new _(w.true,!0),false:new _(w.false,!1),emptyArray:new _(w.array,0),emptyMap:new _(w.map,0)},er={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new _(w.float,r):r>=0?new _(w.uint,r):new _(w.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new _(w.uint,r):new _(w.negint,r)},Uint8Array(r,e,t,n){return new _(w.bytes,r)},string(r,e,t,n){return new _(w.string,r)},boolean(r,e,t,n){return r?Qt.true:Qt.false},null(r,e,t,n){return Qt.null},undefined(r,e,t,n){return Qt.undefined},ArrayBuffer(r,e,t,n){return new _(w.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new _(w.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[Qt.emptyArray,new _(w.break)]:Qt.emptyArray;n=Bi.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=Ra(s,t,n);return t.addBreakTokens?[new _(w.array,r.length),o,new _(w.break)]:[new _(w.array,r.length),o]},Object(r,e,t,n){let o=e!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return t.addBreakTokens===!0?[Qt.emptyMap,new _(w.break)]:Qt.emptyMap;n=Bi.createCheck(n,r);let a=[],c=0;for(let f of i)a[c++]=[Ra(f,t,n),Ra(o?r.get(f):r[f],t,n)];return Xm(a,t),t.addBreakTokens?[new _(w.map,s),a,new _(w.break)]:[new _(w.map,s),a]}};er.Map=er.Object;er.Buffer=er.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))er[`${r}Array`]=er.DataView;function Ra(r,e={},t){let n=Ml(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||er[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=er[n];if(!i)throw new Error(`${va} unsupported type: ${n}`);return i(r,n,e,t)}function Xm(r,e){e.mapSorter&&r.sort(e.mapSorter)}var Qm={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Ai=class{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],t=ut[e];if(t===void 0){let n=I[e];if(!n)throw new Error(`${$} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;t=n(this.data,this._pos,o,this.options)}return this._pos+=t.encodedLength,t}},Pn=Symbol.for("DONE"),Si=Symbol.for("BREAK");function eg(r,e,t){let n=[];for(let o=0;o<r.value;o++){let i=rn(e,t);if(i===Si){if(r.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed array`)}if(i===Pn)throw new Error(`${$} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function tg(r,e,t){let n=t.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<r.value;s++){let a=rn(e,t);if(a===Si){if(r.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed map`)}if(a===Pn)throw new Error(`${$} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${$} non-string keys not supported (got ${typeof a})`);if(t.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${$} found repeat map key "${a}"`);let c=rn(e,t);if(c===Pn)throw new Error(`${$} found map but not enough entries (got ${s} [no value], expected ${r.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function rn(r,e){if(r.done())return Pn;let t=r.next();if(t.type===w.break)return Si;if(t.type.terminal)return t.value;if(t.type===w.array)return eg(t,r,e);if(t.type===w.map)return tg(t,r,e);if(t.type===w.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=rn(r,e);return e.tags[t.value](n)}throw new Error(`${$} tag not supported (${t.value})`)}throw new Error("unsupported")}function Kf(r,e){if(!(r instanceof Uint8Array))throw new Error(`${$} data to decode must be a Uint8Array`);e=Object.assign({},Qm,e);let t=e.tokenizer||new Ai(r,e),n=rn(t,e);if(n===Pn)throw new Error(`${$} did not find any content to decode`);if(n===Si)throw new Error(`${$} got unexpected break`);return[n,r.subarray(t.pos())]}function ka(r,e){let[t,n]=Kf(r,e);if(n.length>0)throw new Error(`${$} too many terminals, data makes no sense`);return t}var ze=nr(hi(),1);var qf=Ot("ipns:utils"),zf=z("/ipns/"),og=114,Gf=async(r,e)=>{if(e==null||r==null){let n=new Error("one or more of the provided parameters are not defined");throw qf.error(n),(0,ze.default)(n,Ea)}let t;if(e.pubKey!=null){try{t=wa(e.pubKey)}catch(o){throw qf.error(o),o}if(!(await Tc(e.pubKey)).equals(r))throw(0,ze.default)(new Error("Embedded public key did not match PeerID"),Dl)}else r.publicKey!=null&&(t=wa(r.publicKey));if(t!=null)return t;throw(0,ze.default)(new Error("no public key is available"),Ea)};var jf=r=>{let e=z("ipns-signature:");return ke([e,r])},yr=r=>"signatureV1"in r?at.encode({value:z(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:z(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):at.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data});function yt(r){let e=at.decode(r);if(e.sequence!=null&&(e.sequence=BigInt(e.sequence)),e.ttl!=null&&(e.ttl=BigInt(e.ttl)),e.signatureV2==null||e.data==null)throw(0,ze.default)(new Error("missing data or signatureV2"),_t);let t=Yf(e.data),n=ig(t.Value),o=G(t.Validity);if(e.value!=null&&e.signatureV1!=null)return sg(e),{value:n,validityType:at.ValidityType.EOL,validity:o,sequence:t.Sequence,ttl:t.TTL,pubKey:e.pubKey,signatureV1:e.signatureV1,signatureV2:e.signatureV2,data:e.data};if(e.signatureV2!=null)return{value:n,validityType:at.ValidityType.EOL,validity:o,sequence:t.Sequence,ttl:t.TTL,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}var Ta=r=>ke([zf,r.toBytes()]),nn=r=>fn(r.slice(zf.length));var Yf=r=>{let e=ka(r);if(e.ValidityType===0)e.ValidityType=at.ValidityType.EOL;else throw(0,ze.default)(new Error("Unknown validity type"),di);return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e},ig=r=>{if(r!=null){if(rc(r))return`/ipns/${r.toCID().toString(Jn)}`;if(r instanceof Uint8Array){let n=G(r);n.startsWith("/")&&(r=n)}let e=r.toString().trim();if(e.startsWith("/")&&e.length>1)return e;let t=ye.asCID(r);if(t!=null)return t.code===og?`/ipns/${t.toString(Jn)}`:`/ipfs/${t.toV1().toString()}`;try{return r instanceof Uint8Array?`/ipfs/${ye.decode(r).toV1().toString()}`:`/ipfs/${ye.parse(e).toV1().toString()}`}catch{}}throw(0,ze.default)(new Error("Value must be a valid content path starting with /"),Vl)},sg=r=>{if(r.data==null)throw(0,ze.default)(new Error("Record data is missing"),Ol);let e=Yf(r.data);if(!se(e.Value,r.value??new Uint8Array(0)))throw(0,ze.default)(new Error('Field "value" did not match between protobuf and CBOR'),_t);if(!se(e.Validity,r.validity??new Uint8Array(0)))throw(0,ze.default)(new Error('Field "validity" did not match between protobuf and CBOR'),_t);if(e.ValidityType!==r.validityType)throw(0,ze.default)(new Error('Field "validityType" did not match between protobuf and CBOR'),_t);if(e.Sequence!==r.sequence)throw(0,ze.default)(new Error('Field "sequence" did not match between protobuf and CBOR'),_t);if(e.TTL!==r.ttl)throw(0,ze.default)(new Error('Field "ttl" did not match between protobuf and CBOR'),_t)};var HE=Ot("ipns"),KE=Fe.code,qE=60*60*1e9,ug="/ipns/",zE=ug.length;var Fn=nr(hi(),1),Zf=nr(xa(),1);var Ii=Ot("ipns:validator"),lg=1024*10,fg=async(r,e)=>{let t=yt(e),n;try{let o=jf(t.data);n=await r.verify(o,t.signatureV2)}catch{n=!1}if(!n)throw Ii.error("record signature verification failed"),(0,Fn.default)(new Error("record signature verification failed"),_t);if(t.validityType===at.ValidityType.EOL){if(Zf.default.fromString(t.validity).toDate().getTime()<Date.now())throw Ii.error("record has expired"),(0,Fn.default)(new Error("record has expired"),Ll)}else if(t.validityType!=null)throw Ii.error("unrecognized validity type"),(0,Fn.default)(new Error("unrecognized validity type"),di);Ii("ipns record for %s is valid",t.value)};async function Wf(r,e){if(e.byteLength>lg)throw(0,Fn.default)(new Error("record too large"),Pl);let t=nn(r),n=yt(e),o=await Gf(t,n);await fg(o,e)}async function*Mn(r){let e=/\r?\n/,t=new TextDecoder("utf8"),n="";for await(let o of r){typeof o=="string"&&(o=new TextEncoder().encode(o)),n+=t.decode(o,{stream:!0});let i=n.split(e);n=i.pop()??"";for(let s=0;s<i.length;s++)yield JSON.parse(i[s])}n+=t.decode(),n!==""&&(yield JSON.parse(n))}function wt(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var Ca=nr(Xf(),1);var Hn=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},_a=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},Qf=r=>globalThis.DOMException===void 0?new _a(r):new DOMException(r),eh=r=>{let e=r.reason===void 0?Qf("This operation was aborted."):r.reason;return e instanceof Error?e:Qf(e)};function Ua(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=e,s,c=new Promise((f,u)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){let{signal:d}=e;d.aborted&&u(eh(d)),d.addEventListener("abort",()=>{u(eh(d))})}if(t===Number.POSITIVE_INFINITY){r.then(f,u);return}let l=new Hn;s=i.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(d){u(d)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?f():o instanceof Error?u(o):(l.message=o??`Promise timed out after ${t} milliseconds`,u(l))},t),(async()=>{try{f(await r)}catch(d){u(d)}})()}).finally(()=>{c.clear()});return c.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},c}function La(r,e,t){let n=0,o=r.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;t(r[s],e)<=0?(n=++s,o-=i+1):o=i}return n}var Kn=class{#e=[];enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&this.#e[this.size-1].priority>=t.priority){this.#e.push(n);return}let o=La(this.#e,n,(i,s)=>s.priority-i.priority);this.#e.splice(o,0,n)}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return this.#e.length}};var qn=class extends Ca.default{#e;#r;#i=0;#a;#c;#p=0;#n;#u;#t;#m;#o=0;#l;#s;#g;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Kn,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#r=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#a=e.intervalCap,this.#c=e.interval,this.#t=new e.queueClass,this.#m=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#g=e.throwOnTimeout===!0,this.#s=e.autoStart===!1}get#b(){return this.#r||this.#i<this.#a}get#x(){return this.#o<this.#l}#E(){this.#o--,this.#f(),this.emit("next")}#v(){this.#w(),this.#y(),this.#u=void 0}get#B(){let e=Date.now();if(this.#n===void 0){let t=this.#p-e;if(t<0)this.#i=this.#e?this.#o:0;else return this.#u===void 0&&(this.#u=setTimeout(()=>{this.#v()},t)),!0}return!1}#f(){if(this.#t.size===0)return this.#n&&clearInterval(this.#n),this.#n=void 0,this.emit("empty"),this.#o===0&&this.emit("idle"),!1;if(!this.#s){let e=!this.#B;if(this.#b&&this.#x){let t=this.#t.dequeue();return t?(this.emit("active"),t(),e&&this.#y(),!0):!1}}return!1}#y(){this.#r||this.#n!==void 0||(this.#n=setInterval(()=>{this.#w()},this.#c),this.#p=Date.now()+this.#c)}#w(){this.#i===0&&this.#o===0&&this.#n&&(clearInterval(this.#n),this.#n=void 0),this.#i=this.#e?this.#o:0,this.#h()}#h(){for(;this.#f(););}get concurrency(){return this.#l}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#l=e,this.#h()}async#A(e){return new Promise((t,n)=>{e.addEventListener("abort",()=>{n(e.reason)},{once:!0})})}async add(e,t={}){return t={timeout:this.timeout,throwOnTimeout:this.#g,...t},new Promise((n,o)=>{this.#t.enqueue(async()=>{this.#o++,this.#i++;try{t.signal?.throwIfAborted();let i=e({signal:t.signal});t.timeout&&(i=Ua(Promise.resolve(i),{milliseconds:t.timeout})),t.signal&&(i=Promise.race([i,this.#A(t.signal)]));let s=await i;n(s),this.emit("completed",s)}catch(i){if(i instanceof Hn&&!t.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#E()}},t),this.emit("add"),this.#f()})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return this.#s?(this.#s=!1,this.#h(),this):this}pause(){this.#s=!0}clear(){this.#t=new this.#m}async onEmpty(){this.#t.size!==0&&await this.#d("empty")}async onSizeLessThan(e){this.#t.size<e||await this.#d("next",()=>this.#t.size<e)}async onIdle(){this.#o===0&&this.#t.size===0||await this.#d("idle")}async#d(e,t){return new Promise(n=>{let o=()=>{t&&!t()||(this.off(e,o),n())};this.on(e,o)})}get size(){return this.#t.size}sizeBy(e){return this.#t.filter(e).length}get pending(){return this.#o}get isPaused(){return this.#s}};function pg(r){return r[Symbol.asyncIterator]!=null}function mg(r){if(pg(r))return(async()=>{for await(let e of r)return e})();for(let e of r)return e}var ki=mg;function gg(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var th=gg;function yg(r){return r[Symbol.asyncIterator]!=null}function wg(r,e){let t=0;if(yg(r))return async function*(){for await(let c of r)yield e(c,t++)}();let n=th(r),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let s=e(o,t++);if(typeof s.then=="function")return async function*(){yield await s;for await(let c of n)yield e(c,t++)}();let a=e;return function*(){yield s;for(let c of n)yield a(c,t++)}()}var Ti=wg;var Oa=z("/ipns/");function rh(r){return se(r.subarray(0,Oa.byteLength),Oa)}var nh=r=>fn(r.slice(Oa.length)),Ni=class{client;constructor(e){this.client=e}async*findProviders(e,t={}){yield*Ti(this.client.getProviders(e,t),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async put(e,t,n){if(!rh(e))return;let o=nh(e),i=yt(t);await this.client.putIPNS(o,i,n)}async get(e,t){if(!rh(e))throw new D("Not found","ERR_NOT_FOUND");let n=nh(e);try{let o=await this.client.getIPNS(n,t);return yr(o)}catch(o){throw o.code==="ERR_BAD_RESPONSE"?new D("Not found","ERR_NOT_FOUND"):o}}},Ci=class{client;constructor(e){this.client=e}async findPeer(e,t={}){let n=await ki(this.client.getPeers(e,t));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new D("Not found","ERR_NOT_FOUND")}async*getClosestPeers(e,t={}){}};var De=Ot("delegated-routing-v1-http-api-client"),oh={concurrentRequests:4,timeout:3e4},_i=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;constructor(e,t={}){this.started=!1,this.shutDownController=new AbortController,br(1/0,this.shutDownController.signal),this.httpQueue=new qn({concurrency:t.concurrentRequests??oh.concurrentRequests}),this.clientUrl=e instanceof URL?e:new URL(e),this.timeout=t.timeout??oh.timeout,this.contentRouting=new Ni(this),this.peerRouting=new Ci(this)}get[tc](){return this.contentRouting}get[nc](){return this.peerRouting}isStarted(){return this.started}start(){this.started=!0}stop(){this.httpQueue.clear(),this.shutDownController.abort(),this.started=!1}async*getProviders(e,t={}){De("getProviders starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=hn([this.shutDownController.signal,n,t.signal]);br(1/0,n,o);let i=wt(),s=wt();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=`${this.clientUrl}routing/v1/providers/${e.toString()}`,f=await fetch(a,{headers:{Accept:"application/x-ndjson"},signal:o});if(f.status===404)throw new D("No matching records found.","ERR_NOT_FOUND");if(f.status===422)throw new D("Request does not conform to schema or semantic constraints.","ERR_INVALID_REQUEST");if(f.body==null)throw new D("Routing response had no body","ERR_BAD_RESPONSE");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let d of l.Providers){let x=this.#e(d);x!=null&&(yield x)}}else for await(let l of Mn(oo(f.body))){let d=this.#e(l);d!=null&&(yield d)}}catch(a){De.error("getProviders errored:",a)}finally{o.clear(),s.resolve(),De("getProviders finished: %c",e)}}async*getPeers(e,t={}){De("getPeers starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=hn([this.shutDownController.signal,n,t.signal]);br(1/0,n,o);let i=wt(),s=wt();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=`${this.clientUrl}routing/v1/peers/${e.toCID().toString()}`,f=await fetch(a,{headers:{Accept:"application/x-ndjson"},signal:o});if(f.status===404)throw new D("No matching records found.","ERR_NOT_FOUND");if(f.status===422)throw new D("Request does not conform to schema or semantic constraints.","ERR_INVALID_REQUEST");if(f.body==null)throw new D("Routing response had no body","ERR_BAD_RESPONSE");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let d of l.Peers){let x=this.#e(d);x!=null&&(yield x)}}else for await(let l of Mn(oo(f.body))){let d=this.#e(l);d!=null&&(yield d)}}catch(a){De.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),De("getPeers finished: %c",e)}}async getIPNS(e,t={}){De("getIPNS starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=hn([this.shutDownController.signal,n,t.signal]);br(1/0,n,o);let i=wt(),s=wt();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.clientUrl}routing/v1/ipns/${e.toCID().toString()}`;try{await i.promise;let f=await fetch(a,{headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o});if(De("getIPNS GET %s %d",a,f.status),f.status===404)throw new D("No matching records found.","ERR_NOT_FOUND");if(f.status===422)throw new D("Request does not conform to schema or semantic constraints.","ERR_INVALID_REQUEST");if(f.body==null)throw new D("GET ipns response had no body","ERR_BAD_RESPONSE");let u=await f.arrayBuffer(),l=new Uint8Array(u,0,u.byteLength);return t.validate!==!1&&await Wf(Ta(e),l),yt(l)}catch(c){throw De.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),De("getIPNS finished: %c",e)}}async putIPNS(e,t,n={}){De("putIPNS starts: %c",e);let o=AbortSignal.timeout(this.timeout),i=hn([this.shutDownController.signal,o,n.signal]);br(1/0,o,i);let s=wt(),a=wt();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${e.toCID().toString()}`;try{await s.promise;let f=yr(t),l=await fetch(c,{method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i});if(De("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new D("PUT ipns response had status other than 200","ERR_BAD_RESPONSE")}catch(f){throw De.error("putIPNS PUT %s error:",c,f.stack),f}finally{i.clear(),a.resolve(),De("putIPNS finished: %c",e)}}#e(e){let t=[],n=e.Addrs?.map(ir)??[];return e.Protocols!=null&&t.push(...e.Protocols),e.Protocol!=null&&(t.push(e.Protocol),delete e.Protocol),{...e,Schema:"peer",ID:as(e.ID),Addrs:n,Protocols:t}}};function ih(r,e={}){return new _i(new URL(r),e)}var sh=z("/ipns/");function ah(r){return se(r.subarray(0,sh.byteLength),sh)}var Va=class{client;constructor(e){this.client=ih(e)}async provide(e,t){}async*findProviders(e,t){yield*Ti(this.client.getProviders(e,t),n=>({id:n.ID,multiaddrs:n.Addrs,protocols:n.Protocols}))}async put(e,t,n){if(!ah(e))return;let o=nn(e),i=yt(t);await this.client.putIPNS(o,i,n)}async get(e,t){if(!ah(e))throw new D("Not found","ERR_NOT_FOUND");let n=nn(e);try{let o=await this.client.getIPNS(n,t);return yr(o)}catch(o){throw o.code==="ERR_BAD_RESPONSE"?new D("Not found","ERR_NOT_FOUND"):o}}async findPeer(e,t){let n=await ki(this.client.getPeers(e,t));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new D("Not found","ERR_NOT_FOUND")}async*getClosestPeers(e,t){}};function ch(r){return new Va(new URL(r))}var uh="[a-fA-F\\d:]",tr=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${uh})|(?<=${uh})(?=\\s|$))`:"",lt="(?: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}",fe="[a-fA-F\\d]{1,4}",Ui=`
7
+ `)}`:`${t} :`}};Pu=Jt;U.Constructed=Pu;Jt.NAME="CONSTRUCTED";var Uo=class extends Re{fromBER(e,t,n){return t}toBER(e){return it}};Uo.override="EndOfContentValueBlock";var Fu,Lo=class extends Be{constructor(e={}){super(e,Uo),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Fu=Lo;U.EndOfContent=Fu;Lo.NAME=kn;var Mu,Xt=class extends Be{constructor(e={}){super(e,Re),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){let n=new ArrayBuffer(2);if(!e){let o=new Uint8Array(n);o[0]=5,o[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Mu=Xt;U.Null=Mu;Xt.NAME="NULL";var Oo=class extends _t(Re){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=Z.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){let o=Z.BufferSourceConverter.toUint8Array(e);return Ct(this,o,t,n)?(this.valueHexView=o.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,ua.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Oo.NAME="BooleanValueBlock";var $u,Do=class extends Be{constructor(e={}){super(e,Oo),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};$u=Do;U.Boolean=$u;Do.NAME="BOOLEAN";var Vo=class extends _t(pt){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=pt.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let i=0;i<this.value.length;i++){let s=this.value[i].constructor.NAME;if(s===kn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==Lu)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=super.fromBER(e,t,n),this.blockLength=n;return o}toBER(e,t){return this.isConstructed?pt.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Vo.NAME="OctetStringValueBlock";var Hu,Tt=class r extends Be{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Vo),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){let i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(i.byteLength){let s=fi(i,0,i.byteLength);s.offset!==-1&&s.offset===n&&(this.valueBlock.value=[s.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Jt.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${Z.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let t of this.valueBlock.value)t instanceof r&&e.push(t.valueBlock.valueHexView);return Z.BufferSourceConverter.concat(e)}};Hu=Tt;U.OctetString=Hu;Tt.NAME=Lu;var Po=class extends _t(pt){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let o=-1;if(this.isConstructed){if(o=pt.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===kn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Ou)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let f=a.valueBlock;if(this.unusedBits>0&&f.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=f.unusedBits}return o}let i=Z.BufferSourceConverter.toUint8Array(e);if(!Ct(this,i,t,n))return-1;let s=i.subarray(t,t+n);if(this.unusedBits=s[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=s.subarray(1);try{if(a.byteLength){let c=fi(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,t+n}toBER(e,t){if(this.isConstructed)return pt.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return it;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};Po.NAME="BitStringValueBlock";var Ku,Wr=class extends Be{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Po),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Jt.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let o of t)e.push(o.toString(2).padStart(8,"0"));let n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};Ku=Wr;U.BitString=Ku;Wr.NAME=Ou;var qu;function em(r,e){let t=new Uint8Array([0]),n=new Uint8Array(r),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f=0,u=c<s?s:c,l=0;for(let h=u;h>=0;h--,l++){switch(!0){case l<a.length:f=i[s-l]+a[c-l]+t[0];break;default:f=i[s-l]+t[0]}switch(t[0]=f/10,!0){case l>=i.length:i=Io(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return t[0]>0&&(i=Io(t,i)),i}function Uu(r){if(r>=In.length)for(let e=In.length;e<=r;e++){let t=new Uint8Array([0]),n=In[e-1].slice(0);for(let o=n.length-1;o>=0;o--){let i=new Uint8Array([(n[o]<<1)+t[0]]);t[0]=i[0]/10,n[o]=i[0]%10}t[0]>0&&(n=Io(t,n)),In.push(n)}return In[r]}function tm(r,e){let t=0,n=new Uint8Array(r),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f,u=0;for(let l=c;l>=0;l--,u++)switch(f=i[s-u]-a[c-u]-t,!0){case f<0:t=1,i[s-u]=f+10;break;default:t=0,i[s-u]=f}if(t>0)for(let l=s-c+1;l>=0;l--,u++)if(f=i[s-u]-t,f<0)t=1,i[s-u]=f+10;else{t=0,i[s-u]=f;break}return i.slice()}var Tn=class extends _t(Re){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=ua.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Nu(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,o=0){let i=this.fromBER(e,t,n);if(i===-1)return i;let s=this.valueHexView;return s[0]===0&&s[1]&128?this.valueHexView=s.subarray(1):o!==0&&s.length<o&&(o-s.length>1&&(o=s.length+1),this.valueHexView=s.subarray(o-s.length)),i}toDER(e=!1){let t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){let o=super.fromBER(e,t,n);return o===-1||this.setValueHex(),o}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=new Uint8Array(this.valueHexView.length*8/3),n=0,o,i=this.valueHexView,s="",a=!1;for(let c=i.byteLength-1;c>=0;c--){o=i[c];for(let f=0;f<8;f++){if((o&1)===1)switch(n){case e:t=tm(Uu(n),t),s="-";break;default:t=em(t,Uu(n))}n++,o>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(s+=_u.charAt(t[c]));return a===!1&&(s+=_u.charAt(0)),s}};qu=Tn;Tn.NAME="IntegerValueBlock";Object.defineProperty(qu.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var zu,le=class r extends Be{constructor(e={}){super(e,Tn),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Ro(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Ro();let t=BigInt(e),n=new Rn,o=t.toString(16).replace(/^-/,""),i=new Uint8Array(Z.Convert.FromHex(o));if(t<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${Z.Convert.ToHex(a)}`)+t,u=Z.BufferSourceConverter.toUint8Array(Z.Convert.FromHex(f.toString(16)));u[0]|=128,n.write(u)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new r({valueHex:n.final()})}convertToDER(){let e=new r({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new r({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};zu=le;U.Integer=zu;le.NAME="INTEGER";var Gu,Fo=class extends le{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Gu=Fo;U.Enumerated=Gu;Fo.NAME="ENUMERATED";var Nn=class extends _t(Re){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;let o=Z.BufferSourceConverter.toUint8Array(e);if(!Ct(this,o,t,n))return-1;let i=o.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=wr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){Ro();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;let n=new Uint8Array(t.length/7);for(let o=0;o<n.length;o++)n[o]=parseInt(t.slice(o*7,o*7+7),2)+(o+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let t=Wt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",it;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),i=t.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n}toString(){let e="";if(this.isHexOnly)e=Z.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};Nn.NAME="sidBlock";var Mo=class extends Re{constructor({value:e=Jr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new Nn;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.value.length===0&&(i.isFirstSid=!0),this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e){let t=[];for(let n=0;n<this.value.length;n++){let o=this.value[n].toBER(e);if(o.byteLength===0)return this.error=this.value[n].error,it;t.push(o)}return la(t)}fromString(e){this.value=[];let t=0,n=0,o="",i=!1;do if(n=e.indexOf(".",t),n===-1?o=e.substring(t):o=e.substring(t,n),t=n+1,i){let s=this.value[0],a=0;switch(s.valueDec){case 0:break;case 1:a=40;break;case 2:a=80;break;default:this.value=[];return}let c=parseInt(o,10);if(isNaN(c))return;s.valueDec=c+a,i=!1}else{let s=new Nn;if(o>Number.MAX_SAFE_INTEGER){Ro();let a=BigInt(o);s.valueBigInt=a}else if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return;this.value.length||(s.isFirstSid=!0,i=!0),this.value.push(s)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),t?(o=`{${o}}`,this.value[n].isFirstSid?e=`2.{${o} - 80}`:e+=o):e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};Mo.NAME="ObjectIdentifierValueBlock";var ju,ot=class extends Be{constructor(e={}){super(e,Mo),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};ju=ot;U.ObjectIdentifier=ju;ot.NAME="OBJECT IDENTIFIER";var Cn=class extends _t(kt){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let o=Z.BufferSourceConverter.toUint8Array(e);if(!Ct(this,o,t,n))return-1;let i=o.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=wr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let t=Wt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",it;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),i=t.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n.buffer}toString(){let e="";return this.isHexOnly?e=Z.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};Cn.NAME="relativeSidBlock";var $o=class extends Re{constructor({value:e=Jr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new Cn;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e,t){let n=[];for(let o=0;o<this.value.length;o++){let i=this.value[o].toBER(e);if(i.byteLength===0)return this.error=this.value[o].error,it;n.push(i)}return la(n)}fromString(e){this.value=[];let t=0,n=0,o="";do{n=e.indexOf(".",t),n===-1?o=e.substring(t):o=e.substring(t,n),t=n+1;let i=new Cn;if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(o=`{${o}}`),e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};$o.NAME="RelativeObjectIdentifierValueBlock";var Yu,Ho=class extends Be{constructor(e={}){super(e,$o),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Yu=Ho;U.RelativeObjectIdentifier=Yu;Ho.NAME="RelativeObjectIdentifier";var Zu,we=class extends Jt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Zu=we;U.Sequence=Zu;we.NAME="SEQUENCE";var Wu,Ko=class extends Jt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Wu=Ko;U.Set=Wu;Ko.NAME="SET";var qo=class extends _t(Re){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Jr}toJSON(){return{...super.toJSON(),value:this.value}}};qo.NAME="StringValueBlock";var zo=class extends qo{};zo.NAME="SimpleStringValueBlock";var _e=class extends No{constructor({...e}={}){super(e,zo)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,Z.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);this.valueBlock.value=e}};_e.NAME="SIMPLE STRING";var Go=class extends _e{fromBuffer(e){this.valueBlock.valueHexView=Z.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=Z.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=Z.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(Z.Convert.FromUtf8String(e)),this.valueBlock.value=e}};Go.NAME="Utf8StringValueBlock";var Ju,Nt=class extends Go{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Ju=Nt;U.Utf8String=Ju;Nt.NAME="UTF8String";var jo=class extends _e{fromBuffer(e){this.valueBlock.value=Z.Convert.ToUtf16String(e),this.valueBlock.valueHexView=Z.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(Z.Convert.FromUtf16String(e))}};jo.NAME="BmpStringValueBlock";var Xu,Yo=class extends jo{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Xu=Yo;U.BmpString=Xu;Yo.NAME="BMPString";var Zo=class extends _e{fromBuffer(e){let t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let o=0;o<n.length;o+=4)n[o]=n[o+3],n[o+1]=n[o+2],n[o+2]=0,n[o+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let o=0;o<t;o++){let i=Wt(e.charCodeAt(o),8),s=new Uint8Array(i);if(s.length>4)continue;let a=4-s.length;for(let c=s.length-1;c>=0;c--)n[o*4+c+a]=s[c]}this.valueBlock.value=e}};Zo.NAME="UniversalStringValueBlock";var Qu,Wo=class extends Zo{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Qu=Wo;U.UniversalString=Qu;Wo.NAME="UniversalString";var el,Jo=class extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};el=Jo;U.NumericString=el;Jo.NAME="NumericString";var tl,Xo=class extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};tl=Xo;U.PrintableString=tl;Xo.NAME="PrintableString";var rl,Qo=class extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};rl=Qo;U.TeletexString=rl;Qo.NAME="TeletexString";var nl,ei=class extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};nl=ei;U.VideotexString=nl;ei.NAME="VideotexString";var ol,ti=class extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};ol=ti;U.IA5String=ol;ti.NAME="IA5String";var il,ri=class extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};il=ri;U.GraphicString=il;ri.NAME="GraphicString";var sl,_n=class extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};sl=_n;U.VisibleString=sl;_n.NAME="VisibleString";var al,ni=class extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};al=ni;U.GeneralString=al;ni.NAME="GeneralString";var cl,oi=class extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};cl=oi;U.CharacterString=cl;oi.NAME="CharacterString";var ul,Un=class extends _n{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let o=0;o<e.length;o++)this.valueBlock.valueHexView[o]=e.charCodeAt(o)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,Z.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}let o=parseInt(n[1],10);o>=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){let t=new Array(7);return t[0]=Fe(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Fe(this.month,2),t[2]=Fe(this.day,2),t[3]=Fe(this.hour,2),t[4]=Fe(this.minute,2),t[5]=Fe(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};ul=Un;U.UTCTime=ul;Un.NAME="UTCTime";var ll,ii=class extends Un{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",o="",i=0,s,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{let l=new Number(e[e.length-1]);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let l=1,h=n.indexOf("+"),w="";if(h===-1&&(h=n.indexOf("-"),l=-1),h!==-1){if(w=n.substring(h+1),n=n.substring(0,h),w.length!==2&&w.length!==4)throw new Error("Wrong input string for conversion");let B=parseInt(w.substring(0,2),10);if(isNaN(B.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*B,w.length===4){if(B=parseInt(w.substring(2,4),10),isNaN(B.valueOf()))throw new Error("Wrong input string for conversion");c=l*B}}}let f=n.indexOf(".");if(f===-1&&(f=n.indexOf(",")),f!==-1){let l=new Number(`0${n.substring(f)}`);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");i=l.valueOf(),o=n.substring(0,f)}else o=n;switch(!0){case o.length===8:if(s=/(\d{4})(\d{2})(\d{2})/ig,f!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.minute=Math.floor(l),l=60*(l-this.minute),this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=1e3*i;this.millisecond=Math.floor(l)}break;default:throw new Error("Wrong input string for conversion")}let u=s.exec(o);if(u===null)throw new Error("Wrong input string for conversion");for(let l=1;l<u.length;l++)switch(l){case 1:this.year=parseInt(u[l],10);break;case 2:this.month=parseInt(u[l],10);break;case 3:this.day=parseInt(u[l],10);break;case 4:this.hour=parseInt(u[l],10)+a;break;case 5:this.minute=parseInt(u[l],10)+c;break;case 6:this.second=parseInt(u[l],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){let l=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=l.getUTCFullYear(),this.month=l.getUTCMonth(),this.day=l.getUTCDay(),this.hour=l.getUTCHours(),this.minute=l.getUTCMinutes(),this.second=l.getUTCSeconds(),this.millisecond=l.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){let t=[];return t.push(Fe(this.year,4)),t.push(Fe(this.month,2)),t.push(Fe(this.day,2)),t.push(Fe(this.hour,2)),t.push(Fe(this.minute,2)),t.push(Fe(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Fe(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};ll=ii;U.GeneralizedTime=ll;ii.NAME="GeneralizedTime";var fl,si=class extends Nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};fl=si;U.DATE=fl;si.NAME="DATE";var hl,ai=class extends Nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};hl=ai;U.TimeOfDay=hl;ai.NAME="TimeOfDay";var dl,ci=class extends Nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};dl=ci;U.DateTime=dl;ci.NAME="DateTime";var pl,ui=class extends Nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};pl=ui;U.Duration=pl;ui.NAME="Duration";var ml,li=class extends Nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};ml=li;U.TIME=ml;li.NAME="TIME";function nm(r){let{result:e}=Xr(r),t=e.valueBlock.value;return{n:G(mt(t[1].toBigInt()),"base64url"),e:G(mt(t[2].toBigInt()),"base64url"),d:G(mt(t[3].toBigInt()),"base64url"),p:G(mt(t[4].toBigInt()),"base64url"),q:G(mt(t[5].toBigInt()),"base64url"),dp:G(mt(t[6].toBigInt()),"base64url"),dq:G(mt(t[7].toBigInt()),"base64url"),qi:G(mt(t[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function om(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new V("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new we({value:[new le({value:0}),le.fromBigInt(gt(z(r.n,"base64url"))),le.fromBigInt(gt(z(r.e,"base64url"))),le.fromBigInt(gt(z(r.d,"base64url"))),le.fromBigInt(gt(z(r.p,"base64url"))),le.fromBigInt(gt(z(r.q,"base64url"))),le.fromBigInt(gt(z(r.dp,"base64url"))),le.fromBigInt(gt(z(r.dq,"base64url"))),le.fromBigInt(gt(z(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function im(r){let{result:e}=Xr(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:G(mt(t[0].toBigInt()),"base64url"),e:G(mt(t[1].toBigInt()),"base64url")}}function sm(r){if(r.n==null||r.e==null)throw new V("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new we({value:[new we({value:[new ot({value:"1.2.840.113549.1.1.1"}),new Xt]}),new Wr({valueHex:new we({value:[le.fromBigInt(gt(z(r.n,"base64url"))),le.fromBigInt(gt(z(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function mt(r){let e=r.toString(16);e.length%2>0&&(e=`0${e}`);let t=e.length/2,n=new Uint8Array(t),o=0,i=0;for(;o<t;)n[o]=parseInt(e.slice(i,i+2),16),o+=1,i+=2;return n}function gt(r){let e=[];return r.forEach(function(t){let n=t.toString(16);n.length%2>0&&(n=`0${n}`),e.push(n)}),BigInt("0x"+e.join(""))}var am=16,ha=32,da=1e4;async function cm(r,e){let t=Ce.get(),o=new we({value:[new le({value:0}),new we({value:[new ot({value:"1.2.840.113549.1.1.1"}),new Xt]}),new Tt({valueHex:r.marshal()})]}).toBER(),i=new Uint8Array(o,0,o.byteLength),s=yr(am),a=await aa(yn,e,s,{c:da,dkLen:ha}),c=yr(16),f=await t.subtle.importKey("raw",a,"AES-CBC",!1,["encrypt"]),u=await t.subtle.encrypt({name:"AES-CBC",iv:c},f,i),l=new we({value:[new Tt({valueHex:s}),new le({value:da}),new le({value:ha}),new we({value:[new ot({value:"1.2.840.113549.2.11"}),new Xt]})]}),h=new we({value:[new ot({value:"1.2.840.113549.1.5.13"}),new we({value:[new we({value:[new ot({value:"1.2.840.113549.1.5.12"}),l]}),new we({value:[new ot({value:"2.16.840.1.101.3.4.1.42"}),new Tt({valueHex:c})]})]})]}),B=new we({value:[h,new Tt({valueHex:u})]}).toBER(),m=new Uint8Array(B,0,B.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...G(m,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
8
+ `)}async function um(r,e){let t=Ce.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let o=z(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:i}=Xr(o),{iv:s,salt:a,iterations:c,keySize:f,cipherText:u}=lm(i),l=await aa(yn,e,a,{c,dkLen:f}),h=await t.subtle.importKey("raw",l,"AES-CBC",!1,["decrypt"]),w=Ln(await t.subtle.decrypt({name:"AES-CBC",iv:s},h,u)),{result:B}=Xr(w);n=gl(B)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let o=z(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:i}=Xr(o);n=gl(i)}else throw new V("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return pa(n)}function lm(r){let e=r.valueBlock.value[0];if(e.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.13")throw new V("Only pkcs5PBES2 encrypted private keys are supported","ERR_INVALID_PARAMS");let n=e.valueBlock.value[1].valueBlock.value[0];if(n.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.12")throw new V("Only pkcs5PBKDF2 key derivation functions are supported","ERR_INVALID_PARAMS");let i=n.valueBlock.value[1],s=Ln(i.valueBlock.value[0].getValue()),a=da,c=ha;if(i.valueBlock.value.length===3)a=Number(i.valueBlock.value[1].toBigInt()),c=Number(i.valueBlock.value[2].toBigInt());else if(i.valueBlock.value.length===2)throw new V("Could not derive key size and iterations from PEM file - please use @libp2p/rsa to re-import your key","ERR_INVALID_PARAMS");let f=e.valueBlock.value[1].valueBlock.value[1],u=f.valueBlock.value[0].toString();if(u!=="OBJECT IDENTIFIER : 1.2.840.113549.3.7"){if(u!=="OBJECT IDENTIFIER : 1.3.14.3.2.7"){if(u!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.2"){if(u!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.22"){if(u!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.42")throw new V("Only AES-CBC encryption schemes are supported","ERR_INVALID_PARAMS")}}}}let l=Ln(f.valueBlock.value[1].getValue());return{cipherText:Ln(r.valueBlock.value[1].getValue()),salt:s,iterations:a,keySize:c,iv:l}}function gl(r){return Ln(r.valueBlock.value[2].getValue())}function Ln(r){return new Uint8Array(r,0,r.byteLength)}async function yl(r){let e=await Ce.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),t=await xl(e);return{privateKey:t[0],publicKey:t[1]}}async function ma(r){let t=[await Ce.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await fm(r)],n=await xl({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function wl(r,e){let t=await Ce.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Ce.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function bl(r,e,t){let n=await Ce.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Ce.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function xl(r){if(r.privateKey==null||r.publicKey==null)throw new V("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([Ce.get().subtle.exportKey("jwk",r.privateKey),Ce.get().subtle.exportKey("jwk",r.publicKey)])}async function fm(r){return Ce.get().subtle.importKey("jwk",{kty:r.kty,n:r.n,e:r.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function hi(r){if(r.kty!=="RSA")throw new V("invalid key type","ERR_INVALID_KEY_TYPE");if(r.n==null)throw new V("invalid key modulus","ERR_INVALID_KEY_MODULUS");return z(r.n,"base64url").length*8}var Dn=8192,On=class{_key;constructor(e){this._key=e}verify(e,t){return bl(this._key,t,e)}marshal(){return Qt.jwkToPkix(this._key)}get bytes(){return dt.encode({Type:ue.RSA,Data:this.marshal()}).subarray()}equals(e){return se(this.bytes,e.bytes)}hash(){let e=ve.digest(this.bytes);return Ye(e)?e.then(({bytes:t})=>t):e.bytes}},Qr=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return yr(16)}sign(e){return wl(this._key,e)}get public(){if(this._publicKey==null)throw new V("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new On(this._publicKey)}marshal(){return Qt.jwkToPkcs1(this._key)}get bytes(){return It.encode({Type:ue.RSA,Data:this.marshal()}).subarray()}equals(e){return se(this.bytes,e.bytes)}hash(){let e=ve.digest(this.bytes);return Ye(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return G(e,"base58btc")}async export(e,t="pkcs-8"){if(t==="pkcs-8")return Qt.exportToPem(this,e);if(t==="libp2p-key")return Kr(this.bytes,e);throw new V(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function pa(r){let e=Qt.pkcs1ToJwk(r);if(hi(e)>Dn)throw new V("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await ma(e);return new Qr(t.privateKey,t.publicKey)}function dm(r){let e=Qt.pkixToJwk(r);if(hi(e)>Dn)throw new V("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new On(e)}async function pm(r){if(hi(r)>Dn)throw new V("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await ma(r);return new Qr(e.privateKey,e.publicKey)}async function mm(r){if(r>Dn)throw new V("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await yl(r);return new Qr(e.privateKey,e.publicKey)}var Ea={};ge(Ea,{Secp256k1PrivateKey:()=>Pn,Secp256k1PublicKey:()=>Vn,generateKeyPair:()=>km,unmarshalSecp256k1PrivateKey:()=>Im,unmarshalSecp256k1PublicKey:()=>Rm});var gm=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]),er=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),tr=new Uint32Array(64),ya=class extends Fr{constructor(){super(64,32,8,!1),this.A=er[0]|0,this.B=er[1]|0,this.C=er[2]|0,this.D=er[3]|0,this.E=er[4]|0,this.F=er[5]|0,this.G=er[6]|0,this.H=er[7]|0}get(){let{A:e,B:t,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,t,n,o,i,s,a,c]}set(e,t,n,o,i,s,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,t){for(let l=0;l<16;l++,t+=4)tr[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let h=tr[l-15],w=tr[l-2],B=et(h,7)^et(h,18)^h>>>3,m=et(w,17)^et(w,19)^w>>>10;tr[l]=m+tr[l-7]+B+tr[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let h=et(a,6)^et(a,11)^et(a,25),w=u+h+eu(a,c,f)+gm[l]+tr[l]|0,m=(et(n,2)^et(n,13)^et(n,22))+tu(n,o,i)|0;u=f,f=c,c=a,a=s+w|0,s=i,i=o,o=n,n=w+m|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,f,u)}roundClean(){tr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var El=uo(()=>new ya);function vl(r){r.lowS!==void 0&&tt("lowS",r.lowS),r.prehash!==void 0&&tt("prehash",r.prehash)}function ym(r){let e=xn(r);ht(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:o}=e;if(t){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:wm,hexToBytes:bm}=ho,Ut={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(r,e)=>{let{Err:t}=Ut;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,o=ur(n);if(o.length/2&128)throw new t("tlv.encode: long form length too big");let i=n>127?ur(o.length/2|128):"";return`${ur(r)}${i}${o}${e}`},decode(r,e){let{Err:t}=Ut,n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new t("tlv.decode(long): indefinite length not supported");if(c>4)throw new t("tlv.decode(long): byte length is too big");let f=e.subarray(n,n+c);if(f.length!==c)throw new t("tlv.decode: length bytes not complete");if(f[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(n+=c,s<128)throw new t("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(r){let{Err:e}=Ut;if(r<Lt)throw new e("integer: negative integers are not allowed");let t=ur(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected assertion");return t},decode(r){let{Err:e}=Ut;if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return wm(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=Ut,o=typeof r=="string"?bm(r):r;Mr(o);let{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("Invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:f,l:u}=n.decode(2,c);if(u.length)throw new e("Invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(f)}},hexFromSig(r){let{_tlv:e,_int:t}=Ut,n=`${e.encode(2,t.encode(r.r))}${e.encode(2,t.encode(r.s))}`;return e.encode(48,n)}},Lt=BigInt(0),be=BigInt(1),q1=BigInt(2),Bl=BigInt(3),z1=BigInt(4);function xm(r){let e=ym(r),{Fp:t}=e,n=Yt(e.n,e.nBitLength),o=e.toBytes||((m,d,E)=>{let R=d.toAffine();return At(Uint8Array.from([4]),t.toBytes(R.x),t.toBytes(R.y))}),i=e.fromBytes||(m=>{let d=m.subarray(1),E=t.fromBytes(d.subarray(0,t.BYTES)),R=t.fromBytes(d.subarray(t.BYTES,2*t.BYTES));return{x:E,y:R}});function s(m){let{a:d,b:E}=e,R=t.sqr(m),y=t.mul(R,m);return t.add(t.add(y,t.mul(m,d)),E)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(m){return wn(m,be,e.n)}function c(m){let{allowedPrivateKeyLengths:d,nByteLength:E,wrapPrivateKey:R,n:y}=e;if(d&&typeof m!="bigint"){if(zt(m)&&(m=vt(m)),typeof m!="string"||!d.includes(m.length))throw new Error("Invalid key");m=m.padStart(E*2,"0")}let k;try{k=typeof m=="bigint"?m:Bt(ae("private key",m,E))}catch{throw new Error(`private key must be ${E} bytes, hex or bigint, not ${typeof m}`)}return R&&(k=ee(k,y)),Ve("private key",k,be,y),k}function f(m){if(!(m instanceof h))throw new Error("ProjectivePoint expected")}let u=hr((m,d)=>{let{px:E,py:R,pz:y}=m;if(t.eql(y,t.ONE))return{x:E,y:R};let k=m.is0();d==null&&(d=k?t.ONE:t.inv(y));let P=t.mul(E,d),O=t.mul(R,d),C=t.mul(y,d);if(k)return{x:t.ZERO,y:t.ZERO};if(!t.eql(C,t.ONE))throw new Error("invZ was invalid");return{x:P,y:O}}),l=hr(m=>{if(m.is0()){if(e.allowInfinityPoint&&!t.is0(m.py))return;throw new Error("bad point: ZERO")}let{x:d,y:E}=m.toAffine();if(!t.isValid(d)||!t.isValid(E))throw new Error("bad point: x or y not FE");let R=t.sqr(E),y=s(d);if(!t.eql(R,y))throw new Error("bad point: equation left != right");if(!m.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,E,R){if(this.px=d,this.py=E,this.pz=R,d==null||!t.isValid(d))throw new Error("x required");if(E==null||!t.isValid(E))throw new Error("y required");if(R==null||!t.isValid(R))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:E,y:R}=d||{};if(!d||!t.isValid(E)||!t.isValid(R))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let y=k=>t.eql(k,t.ZERO);return y(E)&&y(R)?h.ZERO:new h(E,R,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let E=t.invertBatch(d.map(R=>R.pz));return d.map((R,y)=>R.toAffine(E[y])).map(h.fromAffine)}static fromHex(d){let E=h.fromAffine(i(ae("pointHex",d)));return E.assertValidity(),E}static fromPrivateKey(d){return h.BASE.multiply(c(d))}static msm(d,E){return go(h,n,d,E)}_setWindowSize(d){B.setWindowSize(this,d)}assertValidity(){l(this)}hasEvenY(){let{y:d}=this.toAffine();if(t.isOdd)return!t.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){f(d);let{px:E,py:R,pz:y}=this,{px:k,py:P,pz:O}=d,C=t.eql(t.mul(E,O),t.mul(k,y)),b=t.eql(t.mul(R,O),t.mul(P,y));return C&&b}negate(){return new h(this.px,t.neg(this.py),this.pz)}double(){let{a:d,b:E}=e,R=t.mul(E,Bl),{px:y,py:k,pz:P}=this,O=t.ZERO,C=t.ZERO,b=t.ZERO,v=t.mul(y,y),F=t.mul(k,k),_=t.mul(P,P),N=t.mul(y,k);return N=t.add(N,N),b=t.mul(y,P),b=t.add(b,b),O=t.mul(d,b),C=t.mul(R,_),C=t.add(O,C),O=t.sub(F,C),C=t.add(F,C),C=t.mul(O,C),O=t.mul(N,O),b=t.mul(R,b),_=t.mul(d,_),N=t.sub(v,_),N=t.mul(d,N),N=t.add(N,b),b=t.add(v,v),v=t.add(b,v),v=t.add(v,_),v=t.mul(v,N),C=t.add(C,v),_=t.mul(k,P),_=t.add(_,_),v=t.mul(_,N),O=t.sub(O,v),b=t.mul(_,F),b=t.add(b,b),b=t.add(b,b),new h(O,C,b)}add(d){f(d);let{px:E,py:R,pz:y}=this,{px:k,py:P,pz:O}=d,C=t.ZERO,b=t.ZERO,v=t.ZERO,F=e.a,_=t.mul(e.b,Bl),N=t.mul(E,k),K=t.mul(R,P),S=t.mul(y,O),I=t.add(E,R),g=t.add(k,P);I=t.mul(I,g),g=t.add(N,K),I=t.sub(I,g),g=t.add(E,y);let p=t.add(k,O);return g=t.mul(g,p),p=t.add(N,S),g=t.sub(g,p),p=t.add(R,y),C=t.add(P,O),p=t.mul(p,C),C=t.add(K,S),p=t.sub(p,C),v=t.mul(F,g),C=t.mul(_,S),v=t.add(C,v),C=t.sub(K,v),v=t.add(K,v),b=t.mul(C,v),K=t.add(N,N),K=t.add(K,N),S=t.mul(F,S),g=t.mul(_,g),K=t.add(K,S),S=t.sub(N,S),S=t.mul(F,S),g=t.add(g,S),N=t.mul(K,g),b=t.add(b,N),N=t.mul(p,g),C=t.mul(I,C),C=t.sub(C,N),N=t.mul(I,K),v=t.mul(p,v),v=t.add(v,N),new h(C,b,v)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return B.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){Ve("scalar",d,Lt,e.n);let E=h.ZERO;if(d===Lt)return E;if(d===be)return this;let{endo:R}=e;if(!R)return B.unsafeLadder(this,d);let{k1neg:y,k1:k,k2neg:P,k2:O}=R.splitScalar(d),C=E,b=E,v=this;for(;k>Lt||O>Lt;)k&be&&(C=C.add(v)),O&be&&(b=b.add(v)),v=v.double(),k>>=be,O>>=be;return y&&(C=C.negate()),P&&(b=b.negate()),b=new h(t.mul(b.px,R.beta),b.py,b.pz),C.add(b)}multiply(d){let{endo:E,n:R}=e;Ve("scalar",d,be,R);let y,k;if(E){let{k1neg:P,k1:O,k2neg:C,k2:b}=E.splitScalar(d),{p:v,f:F}=this.wNAF(O),{p:_,f:N}=this.wNAF(b);v=B.constTimeNegate(P,v),_=B.constTimeNegate(C,_),_=new h(t.mul(_.px,E.beta),_.py,_.pz),y=v.add(_),k=F.add(N)}else{let{p:P,f:O}=this.wNAF(d);y=P,k=O}return h.normalizeZ([y,k])[0]}multiplyAndAddUnsafe(d,E,R){let y=h.BASE,k=(O,C)=>C===Lt||C===be||!O.equals(y)?O.multiplyUnsafe(C):O.multiply(C),P=k(this,E).add(k(d,R));return P.is0()?void 0:P}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:E}=e;if(d===be)return!0;if(E)return E(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:E}=e;return d===be?this:E?E(h,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return tt("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return tt("isCompressed",d),vt(this.toRawBytes(d))}}h.BASE=new h(e.Gx,e.Gy,t.ONE),h.ZERO=new h(t.ZERO,t.ONE,t.ZERO);let w=e.nBitLength,B=mo(h,e.endo?Math.ceil(w/2):w);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function Em(r){let e=xn(r);return ht(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Al(r){let e=Em(r),{Fp:t,n}=e,o=t.BYTES+1,i=2*t.BYTES+1;function s(S){return ee(S,n)}function a(S){return po(S,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=xm({...e,toBytes(S,I,g){let p=I.toAffine(),A=t.toBytes(p.x),D=At;return tt("isCompressed",g),g?D(Uint8Array.from([I.hasEvenY()?2:3]),A):D(Uint8Array.from([4]),A,t.toBytes(p.y))},fromBytes(S){let I=S.length,g=S[0],p=S.subarray(1);if(I===o&&(g===2||g===3)){let A=Bt(p);if(!wn(A,be,t.ORDER))throw new Error("Point is not on curve");let D=u(A),M;try{M=t.sqrt(D)}catch(W){let Y=W instanceof Error?": "+W.message:"";throw new Error("Point is not on curve"+Y)}let $=(M&be)===be;return(g&1)===1!==$&&(M=t.neg(M)),{x:A,y:M}}else if(I===i&&g===4){let A=t.fromBytes(p.subarray(0,t.BYTES)),D=t.fromBytes(p.subarray(t.BYTES,2*t.BYTES));return{x:A,y:D}}else throw new Error(`Point of length ${I} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),h=S=>vt(jt(S,e.nByteLength));function w(S){let I=n>>be;return S>I}function B(S){return w(S)?s(-S):S}let m=(S,I,g)=>Bt(S.slice(I,g));class d{constructor(I,g,p){this.r=I,this.s=g,this.recovery=p,this.assertValidity()}static fromCompact(I){let g=e.nByteLength;return I=ae("compactSignature",I,g*2),new d(m(I,0,g),m(I,g,2*g))}static fromDER(I){let{r:g,s:p}=Ut.toSig(ae("DER",I));return new d(g,p)}assertValidity(){Ve("r",this.r,be,n),Ve("s",this.s,be,n)}addRecoveryBit(I){return new d(this.r,this.s,I)}recoverPublicKey(I){let{r:g,s:p,recovery:A}=this,D=O(ae("msgHash",I));if(A==null||![0,1,2,3].includes(A))throw new Error("recovery id invalid");let M=A===2||A===3?g+e.n:g;if(M>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let $=A&1?"03":"02",j=c.fromHex($+h(M)),W=a(M),Y=s(-D*W),Q=s(p*W),re=c.BASE.multiplyAndAddUnsafe(j,Y,Q);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return lr(this.toDERHex())}toDERHex(){return Ut.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return lr(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let E={isValidPrivateKey(S){try{return f(S),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let S=Ks(e.n);return uu(e.randomBytes(S),e.n)},precompute(S=8,I=c.BASE){return I._setWindowSize(S),I.multiply(BigInt(3)),I}};function R(S,I=!0){return c.fromPrivateKey(S).toRawBytes(I)}function y(S){let I=zt(S),g=typeof S=="string",p=(I||g)&&S.length;return I?p===o||p===i:g?p===2*o||p===2*i:S instanceof c}function k(S,I,g=!0){if(y(S))throw new Error("first arg must be private key");if(!y(I))throw new Error("second arg must be public key");return c.fromHex(I).multiply(f(S)).toRawBytes(g)}let P=e.bits2int||function(S){let I=Bt(S),g=S.length*8-e.nBitLength;return g>0?I>>BigInt(g):I},O=e.bits2int_modN||function(S){return s(P(S))},C=bn(e.nBitLength);function b(S){return Ve(`num < 2^${e.nBitLength}`,S,Lt,C),jt(S,e.nByteLength)}function v(S,I,g=F){if(["recovered","canonical"].some(me=>me in g))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:A}=e,{lowS:D,prehash:M,extraEntropy:$}=g;D==null&&(D=!0),S=ae("msgHash",S),vl(g),M&&(S=ae("prehashed msgHash",p(S)));let j=O(S),W=f(I),Y=[b(W),b(j)];if($!=null&&$!==!1){let me=$===!0?A(t.BYTES):$;Y.push(ae("extraEntropy",me))}let Q=At(...Y),re=j;function pe(me){let Ee=P(me);if(!l(Ee))return;let Te=a(Ee),he=c.BASE.multiply(Ee).toAffine(),Oe=s(he.x);if(Oe===Lt)return;let bt=s(Te*s(re+Oe*W));if(bt===Lt)return;let cn=(he.x===Oe?0:2)|Number(he.y&be),un=bt;return D&&w(bt)&&(un=B(bt),cn^=1),new d(Oe,un,cn)}return{seed:Q,k2sig:pe}}let F={lowS:e.lowS,prehash:!1},_={lowS:e.lowS,prehash:!1};function N(S,I,g=F){let{seed:p,k2sig:A}=v(S,I,g),D=e;return Fs(D.hash.outputLen,D.nByteLength,D.hmac)(p,A)}c.BASE._setWindowSize(8);function K(S,I,g,p=_){let A=S;if(I=ae("msgHash",I),g=ae("publicKey",g),"strict"in p)throw new Error("options.strict was renamed to lowS");vl(p);let{lowS:D,prehash:M}=p,$,j;try{if(typeof A=="string"||zt(A))try{$=d.fromDER(A)}catch(he){if(!(he instanceof Ut.Err))throw he;$=d.fromCompact(A)}else if(typeof A=="object"&&typeof A.r=="bigint"&&typeof A.s=="bigint"){let{r:he,s:Oe}=A;$=new d(he,Oe)}else throw new Error("PARSE");j=c.fromHex(g)}catch(he){if(he.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(D&&$.hasHighS())return!1;M&&(I=e.hash(I));let{r:W,s:Y}=$,Q=O(I),re=a(Y),pe=s(Q*re),me=s(W*re),Ee=c.BASE.multiplyAndAddUnsafe(j,pe,me)?.toAffine();return Ee?s(Ee.x)===W:!1}return{CURVE:e,getPublicKey:R,getSharedSecret:k,sign:N,verify:K,ProjectivePoint:c,Signature:d,utils:E}}function vm(r){return{hash:r,hmac:(e,...t)=>Sn(r,e,Cs(...t)),randomBytes:Pr}}function Sl(r,e){let t=n=>Al({...r,...vm(n)});return Object.freeze({...t(e),create:t})}var kl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Il=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Bm=BigInt(1),wa=BigInt(2),Rl=(r,e)=>(r+e/wa)/e;function Am(r){let e=kl,t=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=r*r*r%e,u=f*f*r%e,l=oe(u,t,e)*u%e,h=oe(l,t,e)*u%e,w=oe(h,wa,e)*f%e,B=oe(w,o,e)*w%e,m=oe(B,i,e)*B%e,d=oe(m,a,e)*m%e,E=oe(d,c,e)*d%e,R=oe(E,a,e)*m%e,y=oe(R,t,e)*u%e,k=oe(y,s,e)*B%e,P=oe(k,n,e)*f%e,O=oe(P,wa,e);if(!ba.eql(ba.sqr(O),r))throw new Error("Cannot find square root");return O}var ba=Yt(kl,void 0,void 0,{sqrt:Am}),st=Sl({a:BigInt(0),b:BigInt(7),Fp:ba,n:Il,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=Il,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Bm*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,s=BigInt("0x100000000000000000000000000000000"),a=Rl(i*r,e),c=Rl(-n*r,e),f=ee(r-a*t-c*o,e),u=ee(-a*n-c*i,e),l=f>s,h=u>s;if(l&&(f=e-f),h&&(u=e-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:h,k2:u}}}},El),eE=BigInt(0);var tE=st.ProjectivePoint;function Tl(){return st.utils.randomPrivateKey()}function Nl(r,e){let t=ve.digest(e instanceof Uint8Array?e:e.subarray());if(Ye(t))return t.then(({digest:n})=>st.sign(n,r).toDERRawBytes()).catch(n=>{throw new V(String(n),"ERR_INVALID_INPUT")});try{return st.sign(t.digest,r).toDERRawBytes()}catch(n){throw new V(String(n),"ERR_INVALID_INPUT")}}function Cl(r,e,t){let n=ve.digest(t instanceof Uint8Array?t:t.subarray());if(Ye(n))return n.then(({digest:o})=>st.verify(e,o,r)).catch(o=>{throw new V(String(o),"ERR_INVALID_INPUT")});try{return st.verify(e,n.digest,r)}catch(o){throw new V(String(o),"ERR_INVALID_INPUT")}}function _l(r){return st.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Ul(r){try{st.getPublicKey(r,!0)}catch(e){throw new V(String(e),"ERR_INVALID_PRIVATE_KEY")}}function xa(r){try{st.ProjectivePoint.fromHex(r)}catch(e){throw new V(String(e),"ERR_INVALID_PUBLIC_KEY")}}function Ll(r){try{return st.getPublicKey(r,!0)}catch(e){throw new V(String(e),"ERR_INVALID_PRIVATE_KEY")}}var Vn=class{_key;constructor(e){xa(e),this._key=e}verify(e,t){return Cl(this._key,t,e)}marshal(){return _l(this._key)}get bytes(){return dt.encode({Type:ue.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return se(this.bytes,e.bytes)}async hash(){let e=ve.digest(this.bytes),t;return Ye(e)?{bytes:t}=await e:t=e.bytes,t}},Pn=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??Ll(e),Ul(this._key),xa(this._publicKey)}sign(e){return Nl(this._key,e)}get public(){return new Vn(this._publicKey)}marshal(){return this._key}get bytes(){return It.encode({Type:ue.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return se(this.bytes,e.bytes)}hash(){let e=ve.digest(this.bytes);return Ye(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return G(e,"base58btc")}async export(e,t="libp2p-key"){if(t==="libp2p-key")return Kr(this.bytes,e);throw new V(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Im(r){return new Pn(r)}function Rm(r){return new Vn(r)}async function km(){let r=Tl();return new Pn(r)}var di={rsa:ga,ed25519:sa,secp256k1:Ea};function Tm(r){let e=Object.keys(di).join(" / ");return new V(`invalid or unsupported key type ${r}. Must be ${e}`,"ERR_UNSUPPORTED_KEY_TYPE")}function va(r){let e=dt.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case ue.RSA:return di.rsa.unmarshalRsaPublicKey(t);case ue.Ed25519:return di.ed25519.unmarshalEd25519PublicKey(t);case ue.Secp256k1:return di.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw Tm(e.Type??"unknown")}}var lg=ir(pi(),1);var Cm="/",_m=new TextEncoder().encode(Cm),wE=_m[0];var fg=ir(Aa(),1);var Vl="ERR_IPNS_EXPIRED_RECORD",mi="ERR_UNRECOGNIZED_VALIDITY";var Ot="ERR_SIGNATURE_VERIFICATION";var Sa="ERR_UNDEFINED_PARAMETER",Pl="ERR_INVALID_RECORD_DATA",Fl="ERR_INVALID_VALUE",Ml="ERR_INVALID_EMBEDDED_KEY";var $l="ERR_RECORD_TOO_LARGE";var at;(function(r){let e;(function(o){o.EOL="EOL"})(e=r.ValidityType||(r.ValidityType={}));let t;(function(o){o[o.EOL=0]="EOL"})(t||(t={})),function(o){o.codec=()=>Bn(t)}(e=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=jr((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),r.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)=>{let s={},a=i==null?o.len:o.pos+i;for(;o.pos<a;){let c=o.uint32();switch(c>>>3){case 1:s.value=o.bytes();break;case 2:s.signatureV1=o.bytes();break;case 3:s.validityType=r.ValidityType.codec().decode(o);break;case 4:s.validity=o.bytes();break;case 5:s.sequence=o.uint64();break;case 6:s.ttl=o.uint64();break;case 7:s.pubKey=o.bytes();break;case 8:s.signatureV2=o.bytes();break;case 9:s.data=o.bytes();break;default:o.skipType(c&7);break}}return s})),n),r.encode=o=>zr(o,r.codec()),r.decode=o=>qr(o,r.codec())})(at||(at={}));var Um=["string","number","bigint","symbol"],Lm=["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 Kl(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(Um.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(Om(r))return"Buffer";let t=Dm(r);return t||"Object"}function Om(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Dm(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(Lm.includes(e))return e}var x=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};x.uint=new x(0,"uint",!0);x.negint=new x(1,"negint",!0);x.bytes=new x(2,"bytes",!0);x.string=new x(3,"string",!0);x.array=new x(4,"array",!1);x.map=new x(5,"map",!1);x.tag=new x(6,"tag",!1);x.float=new x(7,"float",!0);x.false=new x(7,"false",!0);x.true=new x(7,"true",!0);x.null=new x(7,"null",!0);x.undefined=new x(7,"undefined",!0);x.break=new x(7,"break",!0);var L=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var en=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Vm=new TextDecoder,Pm=new TextEncoder;function gi(r){return en&&globalThis.Buffer.isBuffer(r)}function jl(r){return r instanceof Uint8Array?gi(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Yl=en?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):zl(r,e,t):(r,e,t)=>t-e>64?Vm.decode(r.subarray(e,t)):zl(r,e,t),Zl=en?r=>r.length>64?globalThis.Buffer.from(r):ql(r):r=>r.length>64?Pm.encode(r):ql(r);var tn=en?(r,e,t)=>gi(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),Wl=en?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),jl(globalThis.Buffer.concat(r,e))):(r,e)=>{let t=new Uint8Array(e),n=0;for(let o of r)n+o.length>t.length&&(o=o.subarray(0,t.length-n)),t.set(o,n),n+=o.length;return t},Jl=en?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Xl(r,e){if(gi(r)&&gi(e))return r.compare(e);for(let t=0;t<r.length;t++)if(r[t]!==e[t])return r[t]<e[t]?-1:1;return 0}function ql(r){let e=[],t=0;for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(r.charCodeAt(++n)&1023),e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128)}return e}function zl(r,e,t){let n=[];for(;e<t;){let o=r[e],i=null,s=o>239?4:o>223?3:o>191?2:1;if(e+s<=t){let a,c,f,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=r[e+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=r[e+1],c=r[e+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=r[e+1],c=r[e+2],f=r[e+3],(a&192)===128&&(c&192)===128&&(f&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|f&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),e+=s}return Fm(n)}var Gl=4096;function Fm(r){let e=r.length;if(e<=Gl)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Gl));return t}var Mm=256,yi=class{constructor(e=Mm){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=t.length-(this.maxCursor-this.cursor)-1;t.set(e,o)}else{if(t){let o=t.length-(this.maxCursor-this.cursor)-1;o<t.length&&(this.chunks[this.chunks.length-1]=t.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(t=Jl(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=tn(n,0,this.cursor)}else t=Wl(this.chunks,this.cursor);return e&&this.reset(),t}};var H="CBOR decode error:",Ia="CBOR encode error:",Fn=[];Fn[23]=1;Fn[24]=2;Fn[25]=3;Fn[26]=5;Fn[27]=9;function Dt(r,e,t){if(r.length-e<t)throw new Error(`${H} not enough data for type`)}var xe=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Ke(r,e,t){Dt(r,e,1);let n=r[e];if(t.strict===!0&&n<xe[0])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function qe(r,e,t){Dt(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<xe[1])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function ze(r,e,t){Dt(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<xe[2])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function Ge(r,e,t){Dt(r,e,8);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3],o=r[e+4]*16777216+(r[e+5]<<16)+(r[e+6]<<8)+r[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(t.strict===!0&&i<xe[3])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(t.allowBigInt===!0)return i;throw new Error(`${H} integers outside of the safe integer range are not supported`)}function Ql(r,e,t,n){return new L(x.uint,Ke(r,e+1,n),2)}function ef(r,e,t,n){return new L(x.uint,qe(r,e+1,n),3)}function tf(r,e,t,n){return new L(x.uint,ze(r,e+1,n),5)}function rf(r,e,t,n){return new L(x.uint,Ge(r,e+1,n),9)}function We(r,e){return Ae(r,0,e.value)}function Ae(r,e,t){if(t<xe[0]){let n=Number(t);r.push([e|n])}else if(t<xe[1]){let n=Number(t);r.push([e|24,n])}else if(t<xe[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<xe[3]){let n=Number(t);r.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(t);if(n<xe[4]){let o=[e|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,r.push(o)}else throw new Error(`${H} encountered BigInt larger than allowable range`)}}We.encodedSize=function(e){return Ae.encodedSize(e.value)};Ae.encodedSize=function(e){return e<xe[0]?1:e<xe[1]?2:e<xe[2]?3:e<xe[3]?5:9};We.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function nf(r,e,t,n){return new L(x.negint,-1-Ke(r,e+1,n),2)}function of(r,e,t,n){return new L(x.negint,-1-qe(r,e+1,n),3)}function sf(r,e,t,n){return new L(x.negint,-1-ze(r,e+1,n),5)}var Ra=BigInt(-1),af=BigInt(1);function cf(r,e,t,n){let o=Ge(r,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new L(x.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${H} integers outside of the safe integer range are not supported`);return new L(x.negint,Ra-BigInt(o),9)}function wi(r,e){let t=e.value,n=typeof t=="bigint"?t*Ra-af:t*-1-1;Ae(r,e.type.majorEncoded,n)}wi.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*Ra-af:t*-1-1;return n<xe[0]?1:n<xe[1]?2:n<xe[2]?3:n<xe[3]?5:9};wi.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function Mn(r,e,t,n){Dt(r,e,t+n);let o=tn(r,e+t,e+t+n);return new L(x.bytes,o,t+n)}function uf(r,e,t,n){return Mn(r,e,1,t)}function lf(r,e,t,n){return Mn(r,e,2,Ke(r,e+1,n))}function ff(r,e,t,n){return Mn(r,e,3,qe(r,e+1,n))}function hf(r,e,t,n){return Mn(r,e,5,ze(r,e+1,n))}function df(r,e,t,n){let o=Ge(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer bytes lengths not supported`);return Mn(r,e,9,o)}function bi(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===x.string?Zl(r.value):r.value),r.encodedBytes}function rn(r,e){let t=bi(e);Ae(r,e.type.majorEncoded,t.length),r.push(t)}rn.encodedSize=function(e){let t=bi(e);return Ae.encodedSize(t.length)+t.length};rn.compareTokens=function(e,t){return Hm(bi(e),bi(t))};function Hm(r,e){return r.length<e.length?-1:r.length>e.length?1:Xl(r,e)}function $n(r,e,t,n,o){let i=t+n;Dt(r,e,i);let s=new L(x.string,Yl(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=tn(r,e+t,e+i)),s}function pf(r,e,t,n){return $n(r,e,1,t,n)}function mf(r,e,t,n){return $n(r,e,2,Ke(r,e+1,n),n)}function gf(r,e,t,n){return $n(r,e,3,qe(r,e+1,n),n)}function yf(r,e,t,n){return $n(r,e,5,ze(r,e+1,n),n)}function wf(r,e,t,n){let o=Ge(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer string lengths not supported`);return $n(r,e,9,o,n)}var bf=rn;function nn(r,e,t,n){return new L(x.array,n,t)}function xf(r,e,t,n){return nn(r,e,1,t)}function Ef(r,e,t,n){return nn(r,e,2,Ke(r,e+1,n))}function vf(r,e,t,n){return nn(r,e,3,qe(r,e+1,n))}function Bf(r,e,t,n){return nn(r,e,5,ze(r,e+1,n))}function Af(r,e,t,n){let o=Ge(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer array lengths not supported`);return nn(r,e,9,o)}function Sf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return nn(r,e,1,1/0)}function xi(r,e){Ae(r,x.array.majorEncoded,e.value)}xi.compareTokens=We.compareTokens;xi.encodedSize=function(e){return Ae.encodedSize(e.value)};function on(r,e,t,n){return new L(x.map,n,t)}function If(r,e,t,n){return on(r,e,1,t)}function Rf(r,e,t,n){return on(r,e,2,Ke(r,e+1,n))}function kf(r,e,t,n){return on(r,e,3,qe(r,e+1,n))}function Tf(r,e,t,n){return on(r,e,5,ze(r,e+1,n))}function Nf(r,e,t,n){let o=Ge(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer map lengths not supported`);return on(r,e,9,o)}function Cf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return on(r,e,1,1/0)}function Ei(r,e){Ae(r,x.map.majorEncoded,e.value)}Ei.compareTokens=We.compareTokens;Ei.encodedSize=function(e){return Ae.encodedSize(e.value)};function _f(r,e,t,n){return new L(x.tag,t,1)}function Uf(r,e,t,n){return new L(x.tag,Ke(r,e+1,n),2)}function Lf(r,e,t,n){return new L(x.tag,qe(r,e+1,n),3)}function Of(r,e,t,n){return new L(x.tag,ze(r,e+1,n),5)}function Df(r,e,t,n){return new L(x.tag,Ge(r,e+1,n),9)}function vi(r,e){Ae(r,x.tag.majorEncoded,e.value)}vi.compareTokens=We.compareTokens;vi.encodedSize=function(e){return Ae.encodedSize(e.value)};var Ym=20,Zm=21,Wm=22,Jm=23;function Vf(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${H} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new L(x.null,null,1):new L(x.undefined,void 0,1)}function Pf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return new L(x.break,void 0,1)}function ka(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${H} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${H} Infinity values are not supported`)}return new L(x.float,r,e)}function Ff(r,e,t,n){return ka(Ta(r,e+1),3,n)}function Mf(r,e,t,n){return ka(Na(r,e+1),5,n)}function $f(r,e,t,n){return ka(zf(r,e+1),9,n)}function Bi(r,e,t){let n=e.value;if(n===!1)r.push([x.float.majorEncoded|Ym]);else if(n===!0)r.push([x.float.majorEncoded|Zm]);else if(n===null)r.push([x.float.majorEncoded|Wm]);else if(n===void 0)r.push([x.float.majorEncoded|Jm]);else{let o,i=!1;(!t||t.float64!==!0)&&(Kf(n),o=Ta(ct,1),n===o||Number.isNaN(n)?(ct[0]=249,r.push(ct.slice(0,3)),i=!0):(qf(n),o=Na(ct,1),n===o&&(ct[0]=250,r.push(ct.slice(0,5)),i=!0))),i||(Xm(n),o=zf(ct,1),ct[0]=251,r.push(ct.slice(0,9)))}}Bi.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!t||t.float64!==!0){Kf(n);let o=Ta(ct,1);if(n===o||Number.isNaN(n))return 3;if(qf(n),o=Na(ct,1),n===o)return 5}return 9};var Hf=new ArrayBuffer(9),Je=new DataView(Hf,1),ct=new Uint8Array(Hf,0);function Kf(r){if(r===1/0)Je.setUint16(0,31744,!1);else if(r===-1/0)Je.setUint16(0,64512,!1);else if(Number.isNaN(r))Je.setUint16(0,32256,!1);else{Je.setFloat32(0,r);let e=Je.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)Je.setUint16(0,31744,!1);else if(t===0)Je.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?Je.setUint16(0,0):o<-14?Je.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):Je.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Ta(r,e){if(r.length-e<2)throw new Error(`${H} not enough data for float16`);let t=(r[e]<<8)+r[e+1];if(t===31744)return 1/0;if(t===64512)return-1/0;if(t===32256)return NaN;let n=t>>10&31,o=t&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,t&32768?-i:i}function qf(r){Je.setFloat32(0,r,!1)}function Na(r,e){if(r.length-e<4)throw new Error(`${H} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function Xm(r){Je.setFloat64(0,r,!1)}function zf(r,e){if(r.length-e<8)throw new Error(`${H} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}Bi.compareTokens=We.compareTokens;function J(r,e,t){throw new Error(`${H} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function Ai(r){return()=>{throw new Error(`${H} ${r}`)}}var T=[];for(let r=0;r<=23;r++)T[r]=J;T[24]=Ql;T[25]=ef;T[26]=tf;T[27]=rf;T[28]=J;T[29]=J;T[30]=J;T[31]=J;for(let r=32;r<=55;r++)T[r]=J;T[56]=nf;T[57]=of;T[58]=sf;T[59]=cf;T[60]=J;T[61]=J;T[62]=J;T[63]=J;for(let r=64;r<=87;r++)T[r]=uf;T[88]=lf;T[89]=ff;T[90]=hf;T[91]=df;T[92]=J;T[93]=J;T[94]=J;T[95]=Ai("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)T[r]=pf;T[120]=mf;T[121]=gf;T[122]=yf;T[123]=wf;T[124]=J;T[125]=J;T[126]=J;T[127]=Ai("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)T[r]=xf;T[152]=Ef;T[153]=vf;T[154]=Bf;T[155]=Af;T[156]=J;T[157]=J;T[158]=J;T[159]=Sf;for(let r=160;r<=183;r++)T[r]=If;T[184]=Rf;T[185]=kf;T[186]=Tf;T[187]=Nf;T[188]=J;T[189]=J;T[190]=J;T[191]=Cf;for(let r=192;r<=215;r++)T[r]=_f;T[216]=Uf;T[217]=Lf;T[218]=Of;T[219]=Df;T[220]=J;T[221]=J;T[222]=J;T[223]=J;for(let r=224;r<=243;r++)T[r]=Ai("simple values are not supported");T[244]=J;T[245]=J;T[246]=J;T[247]=Vf;T[248]=Ai("simple values are not supported");T[249]=Ff;T[250]=Mf;T[251]=$f;T[252]=J;T[253]=J;T[254]=J;T[255]=Pf;var ut=[];for(let r=0;r<24;r++)ut[r]=new L(x.uint,r,1);for(let r=-1;r>=-24;r--)ut[31-r]=new L(x.negint,r,1);ut[64]=new L(x.bytes,new Uint8Array(0),1);ut[96]=new L(x.string,"",1);ut[128]=new L(x.array,0,1);ut[160]=new L(x.map,0,1);ut[244]=new L(x.false,!1,1);ut[245]=new L(x.true,!0,1);ut[246]=new L(x.null,null,1);function eg(){let r=[];return r[x.uint.major]=We,r[x.negint.major]=wi,r[x.bytes.major]=rn,r[x.string.major]=bf,r[x.array.major]=xi,r[x.map.major]=Ei,r[x.tag.major]=vi,r[x.float.major]=Bi,r}var m2=eg(),g2=new yi,Si=class r{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${Ia} object contains circular references`);return new r(t,e)}},rr={null:new L(x.null,null),undefined:new L(x.undefined,void 0),true:new L(x.true,!0),false:new L(x.false,!1),emptyArray:new L(x.array,0),emptyMap:new L(x.map,0)},nr={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new L(x.float,r):r>=0?new L(x.uint,r):new L(x.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new L(x.uint,r):new L(x.negint,r)},Uint8Array(r,e,t,n){return new L(x.bytes,r)},string(r,e,t,n){return new L(x.string,r)},boolean(r,e,t,n){return r?rr.true:rr.false},null(r,e,t,n){return rr.null},undefined(r,e,t,n){return rr.undefined},ArrayBuffer(r,e,t,n){return new L(x.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new L(x.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[rr.emptyArray,new L(x.break)]:rr.emptyArray;n=Si.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=Ca(s,t,n);return t.addBreakTokens?[new L(x.array,r.length),o,new L(x.break)]:[new L(x.array,r.length),o]},Object(r,e,t,n){let o=e!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return t.addBreakTokens===!0?[rr.emptyMap,new L(x.break)]:rr.emptyMap;n=Si.createCheck(n,r);let a=[],c=0;for(let f of i)a[c++]=[Ca(f,t,n),Ca(o?r.get(f):r[f],t,n)];return tg(a,t),t.addBreakTokens?[new L(x.map,s),a,new L(x.break)]:[new L(x.map,s),a]}};nr.Map=nr.Object;nr.Buffer=nr.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))nr[`${r}Array`]=nr.DataView;function Ca(r,e={},t){let n=Kl(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||nr[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=nr[n];if(!i)throw new Error(`${Ia} unsupported type: ${n}`);return i(r,n,e,t)}function tg(r,e){e.mapSorter&&r.sort(e.mapSorter)}var rg={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Ii=class{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],t=ut[e];if(t===void 0){let n=T[e];if(!n)throw new Error(`${H} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;t=n(this.data,this._pos,o,this.options)}return this._pos+=t.encodedLength,t}},Hn=Symbol.for("DONE"),Ri=Symbol.for("BREAK");function ng(r,e,t){let n=[];for(let o=0;o<r.value;o++){let i=sn(e,t);if(i===Ri){if(r.value===1/0)break;throw new Error(`${H} got unexpected break to lengthed array`)}if(i===Hn)throw new Error(`${H} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function og(r,e,t){let n=t.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<r.value;s++){let a=sn(e,t);if(a===Ri){if(r.value===1/0)break;throw new Error(`${H} got unexpected break to lengthed map`)}if(a===Hn)throw new Error(`${H} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${H} non-string keys not supported (got ${typeof a})`);if(t.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${H} found repeat map key "${a}"`);let c=sn(e,t);if(c===Hn)throw new Error(`${H} found map but not enough entries (got ${s} [no value], expected ${r.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function sn(r,e){if(r.done())return Hn;let t=r.next();if(t.type===x.break)return Ri;if(t.type.terminal)return t.value;if(t.type===x.array)return ng(t,r,e);if(t.type===x.map)return og(t,r,e);if(t.type===x.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=sn(r,e);return e.tags[t.value](n)}throw new Error(`${H} tag not supported (${t.value})`)}throw new Error("unsupported")}function Gf(r,e){if(!(r instanceof Uint8Array))throw new Error(`${H} data to decode must be a Uint8Array`);e=Object.assign({},rg,e);let t=e.tokenizer||new Ii(r,e),n=sn(t,e);if(n===Hn)throw new Error(`${H} did not find any content to decode`);if(n===Ri)throw new Error(`${H} got unexpected break`);return[n,r.subarray(t.pos())]}function _a(r,e){let[t,n]=Gf(r,e);if(n.length>0)throw new Error(`${H} too many terminals, data makes no sense`);return t}var je=ir(pi(),1);var jf=Pt("ipns:utils"),Yf=z("/ipns/"),ag=114,Zf=async(r,e)=>{if(e==null||r==null){let n=new Error("one or more of the provided parameters are not defined");throw jf.error(n),(0,je.default)(n,Sa)}let t;if(e.pubKey!=null){try{t=va(e.pubKey)}catch(o){throw jf.error(o),o}if(!(await Uc(e.pubKey)).equals(r))throw(0,je.default)(new Error("Embedded public key did not match PeerID"),Ml)}else r.publicKey!=null&&(t=va(r.publicKey));if(t!=null)return t;throw(0,je.default)(new Error("no public key is available"),Sa)};var Wf=r=>{let e=z("ipns-signature:");return Ne([e,r])},xr=r=>"signatureV1"in r?at.encode({value:z(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:z(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):at.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data});function yt(r){let e=at.decode(r);if(e.sequence!=null&&(e.sequence=BigInt(e.sequence)),e.ttl!=null&&(e.ttl=BigInt(e.ttl)),e.signatureV2==null||e.data==null)throw(0,je.default)(new Error("missing data or signatureV2"),Ot);let t=Jf(e.data),n=cg(t.Value),o=G(t.Validity);if(e.value!=null&&e.signatureV1!=null)return ug(e),{value:n,validityType:at.ValidityType.EOL,validity:o,sequence:t.Sequence,ttl:t.TTL,pubKey:e.pubKey,signatureV1:e.signatureV1,signatureV2:e.signatureV2,data:e.data};if(e.signatureV2!=null)return{value:n,validityType:at.ValidityType.EOL,validity:o,sequence:t.Sequence,ttl:t.TTL,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}var Ua=r=>Ne([Yf,r.toBytes()]),an=r=>mn(r.slice(Yf.length));var Jf=r=>{let e=_a(r);if(e.ValidityType===0)e.ValidityType=at.ValidityType.EOL;else throw(0,je.default)(new Error("Unknown validity type"),mi);return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e},cg=r=>{if(r!=null){if(sc(r))return`/ipns/${r.toCID().toString(eo)}`;if(r instanceof Uint8Array){let n=G(r);n.startsWith("/")&&(r=n)}let e=r.toString().trim();if(e.startsWith("/")&&e.length>1)return e;let t=ye.asCID(r);if(t!=null)return t.code===ag?`/ipns/${t.toString(eo)}`:`/ipfs/${t.toV1().toString()}`;try{return r instanceof Uint8Array?`/ipfs/${ye.decode(r).toV1().toString()}`:`/ipfs/${ye.parse(e).toV1().toString()}`}catch{}}throw(0,je.default)(new Error("Value must be a valid content path starting with /"),Fl)},ug=r=>{if(r.data==null)throw(0,je.default)(new Error("Record data is missing"),Pl);let e=Jf(r.data);if(!se(e.Value,r.value??new Uint8Array(0)))throw(0,je.default)(new Error('Field "value" did not match between protobuf and CBOR'),Ot);if(!se(e.Validity,r.validity??new Uint8Array(0)))throw(0,je.default)(new Error('Field "validity" did not match between protobuf and CBOR'),Ot);if(e.ValidityType!==r.validityType)throw(0,je.default)(new Error('Field "validityType" did not match between protobuf and CBOR'),Ot);if(e.Sequence!==r.sequence)throw(0,je.default)(new Error('Field "sequence" did not match between protobuf and CBOR'),Ot);if(e.TTL!==r.ttl)throw(0,je.default)(new Error('Field "ttl" did not match between protobuf and CBOR'),Ot)};var q2=Pt("ipns"),z2=$e.code,G2=60*60*1e9,hg="/ipns/",j2=hg.length;var Kn=ir(pi(),1),Xf=ir(Aa(),1);var ki=Pt("ipns:validator"),dg=1024*10,pg=async(r,e)=>{let t=yt(e),n;try{let o=Wf(t.data);n=await r.verify(o,t.signatureV2)}catch{n=!1}if(!n)throw ki.error("record signature verification failed"),(0,Kn.default)(new Error("record signature verification failed"),Ot);if(t.validityType===at.ValidityType.EOL){if(Xf.default.fromString(t.validity).toDate().getTime()<Date.now())throw ki.error("record has expired"),(0,Kn.default)(new Error("record has expired"),Vl)}else if(t.validityType!=null)throw ki.error("unrecognized validity type"),(0,Kn.default)(new Error("unrecognized validity type"),mi);ki("ipns record for %s is valid",t.value)};async function Qf(r,e){if(e.byteLength>dg)throw(0,Kn.default)(new Error("record too large"),$l);let t=an(r),n=yt(e),o=await Zf(t,n);await pg(o,e)}async function*qn(r){let e=/\r?\n/,t=new TextDecoder("utf8"),n="";for await(let o of r){typeof o=="string"&&(o=new TextEncoder().encode(o)),n+=t.decode(o,{stream:!0});let i=n.split(e);n=i.pop()??"";for(let s=0;s<i.length;s++)yield JSON.parse(i[s])}n+=t.decode(),n!==""&&(yield JSON.parse(n))}function wt(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var Oa=ir(th(),1);var Gn=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Da=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},rh=r=>globalThis.DOMException===void 0?new Da(r):new DOMException(r),nh=r=>{let e=r.reason===void 0?rh("This operation was aborted."):r.reason;return e instanceof Error?e:rh(e)};function Va(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=e,s,c=new Promise((f,u)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){let{signal:h}=e;h.aborted&&u(nh(h)),h.addEventListener("abort",()=>{u(nh(h))})}if(t===Number.POSITIVE_INFINITY){r.then(f,u);return}let l=new Gn;s=i.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(h){u(h)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?f():o instanceof Error?u(o):(l.message=o??`Promise timed out after ${t} milliseconds`,u(l))},t),(async()=>{try{f(await r)}catch(h){u(h)}})()}).finally(()=>{c.clear()});return c.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},c}function Pa(r,e,t){let n=0,o=r.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;t(r[s],e)<=0?(n=++s,o-=i+1):o=i}return n}var jn=class{#e=[];enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&this.#e[this.size-1].priority>=t.priority){this.#e.push(n);return}let o=Pa(this.#e,n,(i,s)=>s.priority-i.priority);this.#e.splice(o,0,n)}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return this.#e.length}};var Yn=class extends Oa.default{#e;#r;#i=0;#a;#c;#p=0;#n;#u;#t;#m;#o=0;#l;#s;#g;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:jn,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#r=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#a=e.intervalCap,this.#c=e.interval,this.#t=new e.queueClass,this.#m=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#g=e.throwOnTimeout===!0,this.#s=e.autoStart===!1}get#b(){return this.#r||this.#i<this.#a}get#x(){return this.#o<this.#l}#E(){this.#o--,this.#f(),this.emit("next")}#v(){this.#w(),this.#y(),this.#u=void 0}get#B(){let e=Date.now();if(this.#n===void 0){let t=this.#p-e;if(t<0)this.#i=this.#e?this.#o:0;else return this.#u===void 0&&(this.#u=setTimeout(()=>{this.#v()},t)),!0}return!1}#f(){if(this.#t.size===0)return this.#n&&clearInterval(this.#n),this.#n=void 0,this.emit("empty"),this.#o===0&&this.emit("idle"),!1;if(!this.#s){let e=!this.#B;if(this.#b&&this.#x){let t=this.#t.dequeue();return t?(this.emit("active"),t(),e&&this.#y(),!0):!1}}return!1}#y(){this.#r||this.#n!==void 0||(this.#n=setInterval(()=>{this.#w()},this.#c),this.#p=Date.now()+this.#c)}#w(){this.#i===0&&this.#o===0&&this.#n&&(clearInterval(this.#n),this.#n=void 0),this.#i=this.#e?this.#o:0,this.#h()}#h(){for(;this.#f(););}get concurrency(){return this.#l}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#l=e,this.#h()}async#A(e){return new Promise((t,n)=>{e.addEventListener("abort",()=>{n(e.reason)},{once:!0})})}async add(e,t={}){return t={timeout:this.timeout,throwOnTimeout:this.#g,...t},new Promise((n,o)=>{this.#t.enqueue(async()=>{this.#o++,this.#i++;try{t.signal?.throwIfAborted();let i=e({signal:t.signal});t.timeout&&(i=Va(Promise.resolve(i),{milliseconds:t.timeout})),t.signal&&(i=Promise.race([i,this.#A(t.signal)]));let s=await i;n(s),this.emit("completed",s)}catch(i){if(i instanceof Gn&&!t.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#E()}},t),this.emit("add"),this.#f()})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return this.#s?(this.#s=!1,this.#h(),this):this}pause(){this.#s=!0}clear(){this.#t=new this.#m}async onEmpty(){this.#t.size!==0&&await this.#d("empty")}async onSizeLessThan(e){this.#t.size<e||await this.#d("next",()=>this.#t.size<e)}async onIdle(){this.#o===0&&this.#t.size===0||await this.#d("idle")}async#d(e,t){return new Promise(n=>{let o=()=>{t&&!t()||(this.off(e,o),n())};this.on(e,o)})}get size(){return this.#t.size}sizeBy(e){return this.#t.filter(e).length}get pending(){return this.#o}get isPaused(){return this.#s}};function yg(r){return r[Symbol.asyncIterator]!=null}function wg(r){if(yg(r))return(async()=>{for await(let e of r)return e})();for(let e of r)return e}var Ni=wg;function bg(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var oh=bg;function xg(r){return r[Symbol.asyncIterator]!=null}function Eg(r,e){let t=0;if(xg(r))return async function*(){for await(let c of r)yield e(c,t++)}();let n=oh(r),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let s=e(o,t++);if(typeof s.then=="function")return async function*(){yield await s;for await(let c of n)yield e(c,t++)}();let a=e;return function*(){yield s;for(let c of n)yield a(c,t++)}()}var Ci=Eg;var Fa=z("/ipns/");function ih(r){return se(r.subarray(0,Fa.byteLength),Fa)}var sh=r=>mn(r.slice(Fa.length)),_i=class{client;constructor(e){this.client=e}async*findProviders(e,t={}){yield*Ci(this.client.getProviders(e,t),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async put(e,t,n){if(!ih(e))return;let o=sh(e),i=yt(t);await this.client.putIPNS(o,i,n)}async get(e,t){if(!ih(e))throw new V("Not found","ERR_NOT_FOUND");let n=sh(e);try{let o=await this.client.getIPNS(n,t);return xr(o)}catch(o){throw o.code==="ERR_BAD_RESPONSE"?new V("Not found","ERR_NOT_FOUND"):o}}},Ui=class{client;constructor(e){this.client=e}async findPeer(e,t={}){let n=await Ni(this.client.getPeers(e,t));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new V("Not found","ERR_NOT_FOUND")}async*getClosestPeers(e,t={}){}};var Le=Pt("delegated-routing-v1-http-api-client"),ah={concurrentRequests:4,timeout:3e4},Li=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;constructor(e,t={}){this.started=!1,this.shutDownController=new AbortController,vr(1/0,this.shutDownController.signal),this.httpQueue=new Yn({concurrency:t.concurrentRequests??ah.concurrentRequests}),this.clientUrl=e instanceof URL?e:new URL(e),this.timeout=t.timeout??ah.timeout,this.contentRouting=new _i(this),this.peerRouting=new Ui(this)}get[ic](){return this.contentRouting}get[ac](){return this.peerRouting}isStarted(){return this.started}start(){this.started=!0}stop(){this.httpQueue.clear(),this.shutDownController.abort(),this.started=!1}async*getProviders(e,t={}){Le("getProviders starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=gn([this.shutDownController.signal,n,t.signal]);vr(1/0,n,o);let i=wt(),s=wt();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=`${this.clientUrl}routing/v1/providers/${e.toString()}`,f=await fetch(a,{headers:{Accept:"application/x-ndjson"},signal:o});if(f.status===404)throw new V("No matching records found.","ERR_NOT_FOUND");if(f.status===422)throw new V("Request does not conform to schema or semantic constraints.","ERR_INVALID_REQUEST");if(f.body==null)throw new V("Routing response had no body","ERR_BAD_RESPONSE");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let h of l.Providers){let w=this.#e(h);w!=null&&(yield w)}}else for await(let l of qn(ao(f.body))){let h=this.#e(l);h!=null&&(yield h)}}catch(a){Le.error("getProviders errored:",a)}finally{o.clear(),s.resolve(),Le("getProviders finished: %c",e)}}async*getPeers(e,t={}){Le("getPeers starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=gn([this.shutDownController.signal,n,t.signal]);vr(1/0,n,o);let i=wt(),s=wt();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=`${this.clientUrl}routing/v1/peers/${e.toCID().toString()}`,f=await fetch(a,{headers:{Accept:"application/x-ndjson"},signal:o});if(f.status===404)throw new V("No matching records found.","ERR_NOT_FOUND");if(f.status===422)throw new V("Request does not conform to schema or semantic constraints.","ERR_INVALID_REQUEST");if(f.body==null)throw new V("Routing response had no body","ERR_BAD_RESPONSE");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let h of l.Peers){let w=this.#e(h);w!=null&&(yield w)}}else for await(let l of qn(ao(f.body))){let h=this.#e(l);h!=null&&(yield h)}}catch(a){Le.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),Le("getPeers finished: %c",e)}}async getIPNS(e,t={}){Le("getIPNS starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=gn([this.shutDownController.signal,n,t.signal]);vr(1/0,n,o);let i=wt(),s=wt();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.clientUrl}routing/v1/ipns/${e.toCID().toString()}`;try{await i.promise;let f=await fetch(a,{headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o});if(Le("getIPNS GET %s %d",a,f.status),f.status===404)throw new V("No matching records found.","ERR_NOT_FOUND");if(f.status===422)throw new V("Request does not conform to schema or semantic constraints.","ERR_INVALID_REQUEST");if(f.body==null)throw new V("GET ipns response had no body","ERR_BAD_RESPONSE");let u=await f.arrayBuffer(),l=new Uint8Array(u,0,u.byteLength);return t.validate!==!1&&await Qf(Ua(e),l),yt(l)}catch(c){throw Le.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),Le("getIPNS finished: %c",e)}}async putIPNS(e,t,n={}){Le("putIPNS starts: %c",e);let o=AbortSignal.timeout(this.timeout),i=gn([this.shutDownController.signal,o,n.signal]);vr(1/0,o,i);let s=wt(),a=wt();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${e.toCID().toString()}`;try{await s.promise;let f=xr(t),l=await fetch(c,{method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i});if(Le("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new V("PUT ipns response had status other than 200","ERR_BAD_RESPONSE")}catch(f){throw Le.error("putIPNS PUT %s error:",c,f.stack),f}finally{i.clear(),a.resolve(),Le("putIPNS finished: %c",e)}}#e(e){try{let t=[],n=e.Addrs?.map(ar)??[];return e.Protocols!=null&&t.push(...e.Protocols),e.Protocol!=null&&(t.push(e.Protocol),delete e.Protocol),{...e,Schema:"peer",ID:us(e.ID),Addrs:n,Protocols:t}}catch(t){Le.error("could not conform record to peer schema",t)}}};function ch(r,e={}){return new Li(new URL(r),e)}var uh=z("/ipns/");function lh(r){return se(r.subarray(0,uh.byteLength),uh)}var Ma=class{client;constructor(e){this.client=ch(e)}async provide(e,t){}async*findProviders(e,t){yield*Ci(this.client.getProviders(e,t),n=>({id:n.ID,multiaddrs:n.Addrs,protocols:n.Protocols}))}async put(e,t,n){if(!lh(e))return;let o=an(e),i=yt(t);await this.client.putIPNS(o,i,n)}async get(e,t){if(!lh(e))throw new V("Not found","ERR_NOT_FOUND");let n=an(e);try{let o=await this.client.getIPNS(n,t);return xr(o)}catch(o){throw o.code==="ERR_BAD_RESPONSE"?new V("Not found","ERR_NOT_FOUND"):o}}async findPeer(e,t){let n=await Ni(this.client.getPeers(e,t));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new V("Not found","ERR_NOT_FOUND")}async*getClosestPeers(e,t){}};function fh(r){return new Ma(new URL(r))}var hh="[a-fA-F\\d:]",or=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${hh})|(?<=${hh})(?=\\s|$))`:"",lt="(?: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}",fe="[a-fA-F\\d]{1,4}",Oi=`
9
9
  (?:
10
10
  (?:${fe}:){7}(?:${fe}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
11
11
  (?:${fe}:){6}(?:${lt}|:${fe}|:)| // 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
@@ -16,7 +16,7 @@ ${e.join(`
16
16
  (?:${fe}:){1}(?:(?::${fe}){0,4}:${lt}|(?::${fe}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
17
17
  (?::(?:(?::${fe}){0,5}:${lt}|(?::${fe}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
18
18
  )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
19
- `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),bg=new RegExp(`(?:^${lt}$)|(?:^${Ui}$)`),xg=new RegExp(`^${lt}$`),Eg=new RegExp(`^${Ui}$`),Da=r=>r&&r.exact?bg:new RegExp(`(?:${tr(r)}${lt}${tr(r)})|(?:${tr(r)}${Ui}${tr(r)})`,"g");Da.v4=r=>r&&r.exact?xg:new RegExp(`${tr(r)}${lt}${tr(r)}`,"g");Da.v6=r=>r&&r.exact?Eg:new RegExp(`${tr(r)}${Ui}${tr(r)}`,"g");var Pa=Da;function Fa(r){let e=(...t)=>r(...t);return Object.defineProperty(e,"name",{value:`functionTimeout(${r.name||"<anonymous>"})`,configurable:!0}),e}function lh(){return!1}var{toString:vg}=Object.prototype;function Ma(r){return vg.call(r)==="[object RegExp]"}var fh={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function $a(r,e={}){if(!Ma(r))throw new TypeError("Expected a RegExp instance");let t=Object.keys(fh).map(o=>(typeof e[o]=="boolean"?e[o]:r[o])?fh[o]:"").join(""),n=new RegExp(e.source||r.source,t);return n.lastIndex=typeof e.lastIndex=="number"?e.lastIndex:r.lastIndex,n}function Ha(r,e,{timeout:t}={}){try{return Fa(()=>$a(r).test(e),{timeout:t})()}catch(n){if(lh(n))return!1;throw n}}var Bg=15,Ag=45,hh={timeout:400};function Ka(r){return r.length>Ag?!1:Ha(Pa.v6({exact:!0}),r,hh)}function dh(r){return r.length>Bg?!1:Ha(Pa.v4({exact:!0}),r,hh)}var ph={http:"80",https:"443",ws:"80",wss:"443"},Sg=["http","https","ws","wss"];function mh(r,e){e=e??{};let t=e.defaultDnsType??"dns4",{scheme:n,hostname:o,port:i}=Ig(r),a="/"+[Rg(o,t),kg(i,n),Tg(n)].filter(c=>!!c).reduce((c,f)=>c.concat(f),[]).join("/");return ir(a)}function Ig(r){let[e]=r.split(":");Sg.includes(e)||(r="http"+r.substring(e.length));let{protocol:t,hostname:n,port:o}=new URL(r);if(o==null||o===""){let i=Ng(e);i!=null&&(o=i),i==null&&t==="http:"&&(o="80")}return{scheme:e,hostname:n,port:o}}function Rg(r,e){if(!(r==null||r==="")){if(dh(r))return["ip4",r];if(Ka(r))return["ip6",r];if(r[0]==="["){let t=r.substring(1,r.length-1);if(Ka(t))return["ip6",t]}return[e,r]}}function kg(r,e){if(!(r==null||r===""))return e==="udp"?["udp",r]:["tcp",r]}function Tg(r){if(r.match(/^tcp$|^udp$/)==null)return[r]}function Ng(r){if(!(r==null||r===""||ph[r]==null))return ph[r]}var Cg=["https://trustless-gateway.link","https://4everland.io"],_g=2336,Ug=Symbol.for("nodejs.util.inspect.custom"),qa=class{type="url";multihash;privateKey;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Fe.digest(z(this.url))}[Ug](){return`PeerId(${this.url})`}[wr]=!0;toString(){return this.toCID().toString()}toCID(){return ye.createV1(_g,this.multihash)}toBytes(){return this.toCID().bytes}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=G(e)),e.toString()===this.toString())}};function Lg(r){return r=r.toString(),{id:new qa(new URL(r)),multiaddrs:[mh(r)]}}var za=class{gateways;constructor(e={}){this.gateways=(e.gateways??Cg).map(t=>Lg(t))}async*findProviders(e,t){yield*this.gateways.toSorted(()=>Math.random()>.5?1:-1).map(n=>({...n,protocols:["transport-ipfs-gateway-http"]}))}};function gh(r={}){return new za(r)}var Ga=class{libp2p;constructor(e){this.libp2p=e}async provide(e,t){await this.libp2p.contentRouting.provide(e,t)}async*findProviders(e,t){yield*this.libp2p.contentRouting.findProviders(e,t)}async put(e,t,n){await this.libp2p.contentRouting.put(e,t,n)}async get(e,t){return this.libp2p.contentRouting.get(e,t)}async findPeer(e,t){return this.libp2p.peerRouting.findPeer(e,t)}async*getClosestPeers(e,t){yield*this.libp2p.peerRouting.getClosestPeers(e,t)}};function yh(r){return new Ga(r)}return Nh(Og);})();
19
+ `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),vg=new RegExp(`(?:^${lt}$)|(?:^${Oi}$)`),Bg=new RegExp(`^${lt}$`),Ag=new RegExp(`^${Oi}$`),$a=r=>r&&r.exact?vg:new RegExp(`(?:${or(r)}${lt}${or(r)})|(?:${or(r)}${Oi}${or(r)})`,"g");$a.v4=r=>r&&r.exact?Bg:new RegExp(`${or(r)}${lt}${or(r)}`,"g");$a.v6=r=>r&&r.exact?Ag:new RegExp(`${or(r)}${Oi}${or(r)}`,"g");var Ha=$a;function Ka(r){let e=(...t)=>r(...t);return Object.defineProperty(e,"name",{value:`functionTimeout(${r.name||"<anonymous>"})`,configurable:!0}),e}function dh(){return!1}var{toString:Sg}=Object.prototype;function qa(r){return Sg.call(r)==="[object RegExp]"}var ph={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function za(r,e={}){if(!qa(r))throw new TypeError("Expected a RegExp instance");let t=Object.keys(ph).map(o=>(typeof e[o]=="boolean"?e[o]:r[o])?ph[o]:"").join(""),n=new RegExp(e.source||r.source,t);return n.lastIndex=typeof e.lastIndex=="number"?e.lastIndex:r.lastIndex,n}function Ga(r,e,{timeout:t}={}){try{return Ka(()=>za(r).test(e),{timeout:t})()}catch(n){if(dh(n))return!1;throw n}}var Ig=15,Rg=45,mh={timeout:400};function ja(r){return r.length>Rg?!1:Ga(Ha.v6({exact:!0}),r,mh)}function gh(r){return r.length>Ig?!1:Ga(Ha.v4({exact:!0}),r,mh)}var yh={http:"80",https:"443",ws:"80",wss:"443"},kg=["http","https","ws","wss"];function wh(r,e){e=e??{};let t=e.defaultDnsType??"dns4",{scheme:n,hostname:o,port:i}=Tg(r),a="/"+[Ng(o,t),Cg(i,n),_g(n)].filter(c=>!!c).reduce((c,f)=>c.concat(f),[]).join("/");return ar(a)}function Tg(r){let[e]=r.split(":");kg.includes(e)||(r="http"+r.substring(e.length));let{protocol:t,hostname:n,port:o}=new URL(r);if(o==null||o===""){let i=Ug(e);i!=null&&(o=i),i==null&&t==="http:"&&(o="80")}return{scheme:e,hostname:n,port:o}}function Ng(r,e){if(!(r==null||r==="")){if(gh(r))return["ip4",r];if(ja(r))return["ip6",r];if(r[0]==="["){let t=r.substring(1,r.length-1);if(ja(t))return["ip6",t]}return[e,r]}}function Cg(r,e){if(!(r==null||r===""))return e==="udp"?["udp",r]:["tcp",r]}function _g(r){if(r.match(/^tcp$|^udp$/)==null)return[r]}function Ug(r){if(!(r==null||r===""||yh[r]==null))return yh[r]}var Lg=["https://trustless-gateway.link","https://4everland.io"],Og=2336,Dg=Symbol.for("nodejs.util.inspect.custom"),Ya=class{type="url";multihash;privateKey;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=$e.digest(z(this.url))}[Dg](){return`PeerId(${this.url})`}[Er]=!0;toString(){return this.toCID().toString()}toCID(){return ye.createV1(Og,this.multihash)}toBytes(){return this.toCID().bytes}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=G(e)),e.toString()===this.toString())}};function Vg(r){return r=r.toString(),{id:new Ya(new URL(r)),multiaddrs:[wh(r)]}}var Za=class{gateways;constructor(e={}){this.gateways=(e.gateways??Lg).map(t=>Vg(t))}async*findProviders(e,t){yield*this.gateways.toSorted(()=>Math.random()>.5?1:-1).map(n=>({...n,protocols:["transport-ipfs-gateway-http"]}))}};function bh(r={}){return new Za(r)}var Wa=class{libp2p;constructor(e){this.libp2p=e}async provide(e,t){await this.libp2p.contentRouting.provide(e,t)}async*findProviders(e,t){yield*this.libp2p.contentRouting.findProviders(e,t)}async put(e,t,n){await this.libp2p.contentRouting.put(e,t,n)}async get(e,t){return this.libp2p.contentRouting.get(e,t)}async findPeer(e,t){return this.libp2p.peerRouting.findPeer(e,t)}async*getClosestPeers(e,t){yield*this.libp2p.peerRouting.getClosestPeers(e,t)}};function xh(r){return new Wa(r)}return Lh(Pg);})();
20
20
  /*! Bundled license information:
21
21
 
22
22
  pvtsutils/build/index.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helia/routers",
3
- "version": "1.1.1-ac4bdb8",
3
+ "version": "1.1.1-e567717",
4
4
  "description": "Routers for Helia",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/ipfs/helia/tree/main/packages/routers#readme",
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@helia/delegated-routing-v1-http-api-client": "^3.0.0",
57
- "@helia/interface": "4.3.1-ac4bdb8",
57
+ "@helia/interface": "4.3.1-e567717",
58
58
  "@libp2p/interface": "^1.1.4",
59
59
  "@multiformats/uri-to-multiaddr": "^8.0.0",
60
60
  "ipns": "^9.0.0",