@helia/ipns 7.2.2-a8fdfc2 → 7.2.2-b4877b5

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.HeliaIpns = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var HeliaIpns=(()=>{var kf=Object.create;var Fn=Object.defineProperty;var If=Object.getOwnPropertyDescriptor;var Tf=Object.getOwnPropertyNames;var Cf=Object.getPrototypeOf,Nf=Object.prototype.hasOwnProperty;var tr=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),de=(r,e)=>{for(var t in e)Fn(r,t,{get:e[t],enumerable:!0})},fa=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Tf(e))!Nf.call(r,o)&&o!==t&&Fn(r,o,{get:()=>e[o],enumerable:!(n=If(e,o))||n.enumerable});return r};var ht=(r,e,t)=>(t=r!=null?kf(Cf(r)):{},fa(e||!r||!r.__esModule?Fn(t,"default",{value:r,enumerable:!0}):t,r)),_f=r=>fa(Fn({},"__esModule",{value:!0}),r);var pa=tr((ag,da)=>{var wr=1e3,br=wr*60,xr=br*60,rr=xr*24,Uf=rr*7,Df=rr*365.25;da.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return Lf(r);if(t==="number"&&isFinite(r))return e.long?Of(r):Vf(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Lf(r){if(r=String(r),!(r.length>100)){var 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){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*Df;case"weeks":case"week":case"w":return t*Uf;case"days":case"day":case"d":return t*rr;case"hours":case"hour":case"hrs":case"hr":case"h":return t*xr;case"minutes":case"minute":case"mins":case"min":case"m":return t*br;case"seconds":case"second":case"secs":case"sec":case"s":return t*wr;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Vf(r){var e=Math.abs(r);return e>=rr?Math.round(r/rr)+"d":e>=xr?Math.round(r/xr)+"h":e>=br?Math.round(r/br)+"m":e>=wr?Math.round(r/wr)+"s":r+"ms"}function Of(r){var e=Math.abs(r);return e>=rr?Pn(r,e,rr,"day"):e>=xr?Pn(r,e,xr,"hour"):e>=br?Pn(r,e,br,"minute"):e>=wr?Pn(r,e,wr,"second"):r+" ms"}function Pn(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var ma=tr((cg,ga)=>{function Ff(r){t.debug=t,t.default=t,t.coerce=c,t.disable=i,t.enable=o,t.enabled=s,t.humanize=pa(),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,v,m;function h(...p){if(!h.enabled)return;let b=h,k=Number(new Date),E=k-(l||k);b.diff=E,b.prev=l,b.curr=k,l=k,p[0]=t.coerce(p[0]),typeof p[0]!="string"&&p.unshift("%O");let D=0;p[0]=p[0].replace(/%([a-zA-Z%])/g,(I,N)=>{if(I==="%%")return"%";D++;let y=t.formatters[N];if(typeof y=="function"){let C=p[D];I=y.call(b,C),p.splice(D,1),D--}return I}),t.formatArgs.call(b,p),(b.log||t.log).apply(b,p)}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:(v!==t.namespaces&&(v=t.namespaces,m=t.enabled(u)),m),set:p=>{d=p}}),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,]+/),v=d.length;for(l=0;l<v;l++)d[l]&&(u=d[l].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.slice(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.enable(t.load()),t}ga.exports=Ff});var ya=tr((Ue,Mn)=>{Ue.formatArgs=Mf;Ue.save=Hf;Ue.load=Kf;Ue.useColors=Pf;Ue.storage=$f();Ue.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Ue.colors=["#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 Pf(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Mf(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Mn.exports.humanize(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)}Ue.log=console.debug||console.log||(()=>{});function Hf(r){try{r?Ue.storage.setItem("debug",r):Ue.storage.removeItem("debug")}catch{}}function Kf(){let r;try{r=Ue.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function $f(){try{return localStorage}catch{}}Mn.exports=ma()(Ue);var{formatters:qf}=Mn.exports;qf.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Tc=tr($r=>{"use strict";var x0="[object ArrayBuffer]",xt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===x0}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}},vs="string",E0=/^[0-9a-f]+$/i,v0=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,B0=/^[a-zA-Z0-9-_]+$/,co=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=xt.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}},Ke=class{static toString(e,t=!1){let n=xt.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}},uo=class r{static isHex(e){return typeof e===vs&&E0.test(e)}static isBase64(e){return typeof e===vs&&v0.test(e)}static isBase64Url(e){return typeof e===vs&&B0.test(e)}static ToString(e,t="utf8"){let n=xt.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 Ke.toString(n,!0);case"utf16":case"utf16be":return Ke.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 Ke.fromString(e,!0);case"utf16":case"utf16be":return Ke.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=xt.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 co.fromString(e);case"utf16":case"utf16be":return Ke.fromString(e);case"utf16le":case"usc2":return Ke.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 co.toString(e);case"utf16":case"utf16be":return Ke.toString(e);case"utf16le":case"usc2":return Ke.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=xt.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=xt.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 Ke.toString(e,t)}static FromUtf16String(e,t=!1){return Ke.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,"")||""}};uo.DEFAULT_UTF8_ENCODING="utf8";function A0(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 S0(...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 R0(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}$r.BufferSourceConverter=xt;$r.Convert=uo;$r.assign=A0;$r.combine=S0;$r.isEqual=R0});var Xo=tr((hb,Ou)=>{"use strict";function Vu(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function ip(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 Vu(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),Vu(new o,t)}}Ou.exports=ip});var ei=tr((yb,Os)=>{var mb=function(){typeof Os<"u"&&(Os.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(y){var C=y-y%1;return C==0&&(y<0||y===0&&1/y!=1/0)?-0:C},u=h.prototype,l=(h.fromDate=function(y){return new h(+y)},h.fromInt64BE=D(0,1,2,3,0,4),h.fromInt64LE=D(3,2,1,0,4,0),h.fromString=function(T){var C,V=new h,T=(T+="").replace(/^\s*[+\-]?\d+/,function(M){var M=+M,Z=1970+(M-1970)%400;return V.year=M-Z,Z}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(O,M,Z){return M<0&&(Z*=-1),C=6e4*(60*+M+ +Z),""}).replace(/\.\d+$/,function(O){return V.nano=+(O+c).substr(1,9),""}).split(/\D+/);if(1<T.length?T[1]--:T[1]=0,V.time=C=Date.UTC.apply(Date,T)-(C||0),isNaN(C))throw new TypeError("Invalid Date");return p(V)},h.fromTimeT=function(y){return k(y,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(y){return this.nano+=+y||0,this},u.getNano=function(){var y=p(this);return(y.time%1e3*a+ +y.nano+1e9)%1e9},u.getTimeT=function(){var C=p(this),y=Math.floor(C.time/1e3),C=C.year;return C&&(y+=C*t*r/e),y},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return b(p(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(y){var C=this,V=C.toDate(),T={H:function(){return I(V.getUTCHours())},L:function(){return N(V.getUTCMilliseconds(),3)},M:function(){return I(V.getUTCMinutes())},N:function(){return N(C.getNano(),9)},S:function(){return I(V.getUTCSeconds())},Y:function(){var O=C.getYear();return 999999<O?"+"+O:9999<O?"+"+N(O,6):0<=O?N(O,4):-999999<=O?"-"+N(-O,6):O},a:function(){return v[V.getUTCDay()]},b:function(){return d[V.getUTCMonth()]},d:function(){return I(V.getUTCDate())},e:function(){return function(O){return(9<O?"":" ")+(0|O)}(V.getUTCDate())},m:function(){return I(V.getUTCMonth()+1)}};return function O(M){return M.replace(/%./g,function(Z){var A=Z[1],x=m[A],A=T[A];return x?O(x):A?A():Z})}(y||l)},u.writeInt64BE=E(0,1,2,3,0,4),u.writeInt64LE=E(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),d=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],v=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],m={"%":"%",F:"%Y-%m-%d",n:`
3
- `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return h;function h(y,C,V){var T=this;if(!(T instanceof h))return new h(y,C,V);T.time=+y||0,T.nano=+C||0,T.year=+V||0,p(T)}function p(y){var C,V,T,O=y.year,M=y.time,Z=y.nano,x=((Z<0||a<=Z)&&(Z-=(V=Math.floor(Z/a))*a,M+=V,V=1),O%e);return(M<-i||i<M||x)&&((C=f(M/o))&&(O+=C*e,M-=C*o),(T=b(M)).setUTCFullYear(x+T.getUTCFullYear()),T=(M=+T)+(C=f((O-=x)/e))*o,C&&-i<=T&&T<=i&&(O-=C*e,M=T),V=1),V&&(y.year=O,y.time=M,y.nano=Z),y}function b(y){var C=new Date(0);return C.setTime(y),C}function k(O,T){O=+O||0;var V=f((T=(T|0)*s)/n)+f(O/n),T=T%n+O%n,O=f(T/n);return O&&(V+=O,T-=O*n),new h(1e3*T,0,V*e)}function E(y,C,V,T,O,M){return function(x,A){var B=p(this);x=x||new Array(8),S(x,A|=0);var w=Math.floor(B.time/1e3),B=B.year*(t*r/e),P=f(B/s)+f(w/s),B=B%s+w%s,w=Math.floor(B/s);return w&&(P+=w,B-=w*s),Z(x,A+O,P),Z(x,A+M,B),x};function Z(x,A,P){x[A+y]=P>>24&255,x[A+C]=P>>16&255,x[A+V]=P>>8&255,x[A+T]=255&P}}function D(y,C,V,T,O,M){return function(x,A){S(x,A|=0);var P=Z(x,A+O);return k(Z(x,A+M),P)};function Z(x,A){return 16777216*x[A+y]+(x[A+C]<<16|x[A+V]<<8|x[A+T])}}function S(y,C){if(y=y&&y.length,y==null)throw new TypeError("Invalid Buffer");if(y<C+8)throw new RangeError("Out of range")}function I(y){return(9<y?"":"0")+(0|y)}function N(y,C){return(c+(0|y)).substr(-C)}}()});var ff=tr((l1,lf)=>{lf.exports=function(r){if(!r)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,t=Object.create(null),n=Object.create(null);function o(i,s){t[i]=s,e++,e>=r&&(e=0,n=t,t=Object.create(null))}return{has:function(i){return t[i]!==void 0||n[i]!==void 0},remove:function(i){t[i]!==void 0&&(t[i]=void 0),n[i]!==void 0&&(n[i]=void 0)},get:function(i){var s=t[i];if(s!==void 0)return s;if((s=n[i])!==void 0)return o(i,s),s},set:function(i,s){t[i]!==void 0?t[i]=s:o(i,s)},clear:function(){t=Object.create(null),n=Object.create(null)}}}});var ng={};de(ng,{ipns:()=>rg,ipnsSelector:()=>gi,ipnsValidator:()=>yi});var Ei=Symbol.for("@libp2p/peer-id");function ha(r){return r!=null&&!!r[Ei]}var $=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var De=ht(ya(),1);var Ri={};de(Ri,{base32:()=>Ut,base32hex:()=>Xf,base32hexpad:()=>eh,base32hexpadupper:()=>th,base32hexupper:()=>Qf,base32pad:()=>Wf,base32padupper:()=>Jf,base32upper:()=>Aa,base32z:()=>rh});var ug=new Uint8Array(0);function wa(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 dt(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 ba(r){return new TextEncoder().encode(r)}function xa(r){return new TextDecoder().decode(r)}function zf(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(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var h=0,p=0,b=0,k=m.length;b!==k&&m[b]===0;)b++,h++;for(var E=(k-b)*u+1>>>0,D=new Uint8Array(E);b!==k;){for(var S=m[b],I=0,N=E-1;(S!==0||I<p)&&N!==-1;N--,I++)S+=256*D[N]>>>0,D[N]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");p=I,b++}for(var y=E-p;y!==E&&D[y]===0;)y++;for(var C=c.repeat(h);y<E;++y)C+=r.charAt(D[y]);return C}function d(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var h=0;if(m[h]!==" "){for(var p=0,b=0;m[h]===c;)p++,h++;for(var k=(m.length-h)*f+1>>>0,E=new Uint8Array(k);m[h];){var D=t[m.charCodeAt(h)];if(D===255)return;for(var S=0,I=k-1;(D!==0||S<b)&&I!==-1;I--,S++)D+=a*E[I]>>>0,E[I]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");b=S,h++}if(m[h]!==" "){for(var N=k-b;N!==k&&E[N]===0;)N++;for(var y=new Uint8Array(p+(k-N)),C=p;N!==k;)y[C++]=E[N++];return y}}}function v(m){var h=d(m);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:d,decode:v}}var Gf=zf,jf=Gf,va=jf;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")}},Bi=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 Ba(this,e)}},Ai=class{decoders;constructor(e){this.decoders=e}or(e){return Ba(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 Ba(r,e){return new Ai({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Si=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 Bi(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Er({name:r,prefix:e,encode:t,decode:n}){return new Si(r,e,t,n)}function _t({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=va(t,r);return Er({prefix:e,name:r,encode:n,decode:i=>dt(o(i))})}function Yf(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 Zf(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 se({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Er({prefix:e,name:r,encode(o){return Zf(o,n,t)},decode(o){return Yf(o,n,t,r)}})}var Ut=se({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Aa=se({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Wf=se({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Jf=se({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Xf=se({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Qf=se({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),eh=se({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),th=se({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),rh=se({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ki={};de(ki,{base58btc:()=>we,base58flickr:()=>nh});var we=_t({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),nh=_t({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ii={};de(Ii,{base64:()=>rn,base64pad:()=>oh,base64url:()=>ih,base64urlpad:()=>sh});var rn=se({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),oh=se({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ih=se({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),sh=se({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});De.default.formatters.b=r=>r==null?"undefined":we.baseEncode(r);De.default.formatters.t=r=>r==null?"undefined":Ut.baseEncode(r);De.default.formatters.m=r=>r==null?"undefined":rn.baseEncode(r);De.default.formatters.p=r=>r==null?"undefined":r.toString();De.default.formatters.c=r=>r==null?"undefined":r.toString();De.default.formatters.k=r=>r==null?"undefined":r.toString();De.default.formatters.a=r=>r==null?"undefined":r.toString();function ah(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 Dt(r){let e=ah(`${r}:trace`);return De.default.enabled(`${r}:trace`)&&De.default.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=(0,De.default)(`${r}:trace`)),Object.assign((0,De.default)(r),{error:(0,De.default)(`${r}:error`),trace:e})}var Ti={};de(Ti,{base10:()=>ch});var ch=_t({prefix:"9",name:"base10",alphabet:"0123456789"});var Ci={};de(Ci,{base16:()=>uh,base16upper:()=>lh});var uh=se({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),lh=se({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ni={};de(Ni,{base2:()=>fh});var fh=se({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var _i={};de(_i,{base256emoji:()=>mh});var Sa=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}"),hh=Sa.reduce((r,e,t)=>(r[t]=e,r),[]),dh=Sa.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function ph(r){return r.reduce((e,t)=>(e+=hh[t],e),"")}function gh(r){let e=[];for(let t of r){let n=dh[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var mh=Er({prefix:"\u{1F680}",name:"base256emoji",encode:ph,decode:gh});var Ui={};de(Ui,{base36:()=>Hn,base36upper:()=>yh});var Hn=_t({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),yh=_t({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Di={};de(Di,{base8:()=>wh});var wh=se({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Li={};de(Li,{identity:()=>bh});var bh=Er({prefix:"\0",name:"identity",encode:r=>xa(r),decode:r=>ba(r)});var Tg=new TextEncoder,Cg=new TextDecoder;var Oi={};de(Oi,{identity:()=>tt});var vh=Ia,Ra=128,Bh=127,Ah=~Bh,Sh=Math.pow(2,31);function Ia(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Sh;)e[t++]=r&255|Ra,r/=128;for(;r&Ah;)e[t++]=r&255|Ra,r>>>=7;return e[t]=r|0,Ia.bytes=t-n+1,e}var Rh=Vi,kh=128,ka=127;function Vi(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw Vi.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&ka)<<o:(s&ka)*Math.pow(2,o),o+=7}while(s>=kh);return Vi.bytes=i-n,t}var Ih=Math.pow(2,7),Th=Math.pow(2,14),Ch=Math.pow(2,21),Nh=Math.pow(2,28),_h=Math.pow(2,35),Uh=Math.pow(2,42),Dh=Math.pow(2,49),Lh=Math.pow(2,56),Vh=Math.pow(2,63),Oh=function(r){return r<Ih?1:r<Th?2:r<Ch?3:r<Nh?4:r<_h?5:r<Uh?6:r<Dh?7:r<Lh?8:r<Vh?9:10},Fh={encode:vh,decode:Rh,encodingLength:Oh},Ph=Fh,nn=Ph;function on(r,e=0){return[nn.decode(r,e),nn.decode.bytes]}function vr(r,e,t=0){return nn.encode(r,e,t),e}function Br(r){return nn.encodingLength(r)}function et(r,e){let t=e.byteLength,n=Br(r),o=n+Br(t),i=new Uint8Array(o+t);return vr(r,i,0),vr(t,i,n),i.set(e,o),new Ar(r,t,e,i)}function nr(r){let e=dt(r),[t,n]=on(e),[o,i]=on(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Ar(t,o,s,e)}function Ta(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&wa(r.bytes,t.bytes)}}var Ar=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var Ca=0,Mh="identity",Na=dt;function Hh(r){return et(Ca,Na(r))}var tt={code:Ca,name:Mh,encode:Na,digest:Hh};var Mi={};de(Mi,{sha256:()=>be,sha512:()=>Kh});function Pi({name:r,code:e,encode:t}){return new Fi(r,e,t)}var Fi=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?et(this.code,t):t.then(n=>et(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Ua(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var be=Pi({name:"sha2-256",code:18,encode:Ua("SHA-256")}),Kh=Pi({name:"sha2-512",code:19,encode:Ua("SHA-512")});function Da(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return qh(t,Hi(r),e??we.encoder);default:return zh(t,Hi(r),e??Ut.encoder)}}var La=new WeakMap;function Hi(r){let e=La.get(r);if(e==null){let t=new Map;return La.set(r,t),t}return e}var Re=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!==sn)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Gh)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=et(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&&Ta(e.multihash,n.multihash)}toString(e){return Da(this,e)}toJSON(){return{"/":Da(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??Va(n,o,i.bytes))}else if(t[jh]===!0){let{version:n,multihash:o,code:i}=t,s=nr(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!==sn)throw new Error(`Version 0 CID must use dag-pb (code: ${sn}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Va(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,sn,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=dt(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 Ar(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]=on(e.subarray(t));return t+=d,l},o=n(),i=sn;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]=$h(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 Hi(i).set(n,e),i}};function $h(r,e){switch(r[0]){case"Q":{let t=e??we;return[we.prefix,t.decode(`${we.prefix}${r}`)]}case we.prefix:{let t=e??we;return[we.prefix,t.decode(r)]}case Ut.prefix:{let t=e??Ut;return[Ut.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 qh(r,e,t){let{prefix:n}=t;if(n!==we.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 zh(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 sn=112,Gh=18;function Va(r,e,t){let n=Br(r),o=n+Br(e),i=new Uint8Array(o+t.byteLength);return vr(r,i,0),vr(e,i,n),i.set(t,o),i}var jh=Symbol.for("@ipld/js-cid/CID");var Sr={...Li,...Ni,...Di,...Ti,...Ci,...Ri,...Ui,...ki,...Ii,..._i},Jg={...Mi,...Oi};function fe(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}var Yh=Symbol.for("nodejs.util.inspect.custom"),Oa=Object.values(Sr).map(r=>r.decoder).reduce((r,e)=>r.or(e),Sr.identity.decoder),Fa=114,Ki=36,$i=37,an=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()})`}[Ei]=!0;toString(){return this.string==null&&(this.string=we.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Re.createV1(Fa,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return fe(this.multihash.bytes,e);if(typeof e=="string")return cn(e).equals(this);if(e?.multihash?.bytes!=null)return fe(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[Yh](){return`PeerId(${this.toString()})`}},Rr=class extends an{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},kr=class extends an{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Ir=class extends an{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function cn(r,e){if(e=e??Oa,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=nr(we.decode(`z${r}`));return r.startsWith("12D")?new kr({multihash:t}):r.startsWith("16U")?new Ir({multihash:t}):new Rr({multihash:t})}return qi(Oa.decode(r))}function qi(r){try{let e=nr(r);if(e.code===tt.code){if(e.digest.length===Ki)return new kr({multihash:e});if(e.digest.length===$i)return new Ir({multihash:e})}if(e.code===be.code)return new Rr({multihash:e})}catch{return Zh(Re.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Zh(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Fa)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===be.code)return new Rr({multihash:r.multihash});if(e.code===tt.code){if(e.digest.length===Ki)return new kr({multihash:r.multihash});if(e.digest.length===$i)return new Ir({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function Pa(r,e){return r.length===Ki?new kr({multihash:et(tt.code,r),privateKey:e}):r.length===$i?new Ir({multihash:et(tt.code,r),privateKey:e}):new Rr({multihash:await be.digest(r),publicKey:r,privateKey:e})}var xs={};de(xs,{Ed25519PrivateKey:()=>fr,Ed25519PublicKey:()=>gn,generateKeyPair:()=>y0,generateKeyPairFromSeed:()=>Ic,unmarshalEd25519PrivateKey:()=>g0,unmarshalEd25519PublicKey:()=>m0});function zi(r=0){return new Uint8Array(r)}function rt(r=0){return new Uint8Array(r)}function ir(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=rt(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function Ha(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Ma=Ha("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Gi=Ha("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=rt(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Wh={utf8:Ma,"utf-8":Ma,hex:Sr.base16,latin1:Gi,ascii:Gi,binary:Gi,...Sr},$n=Wh;function J(r,e="utf8"){let t=$n[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function He(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Tr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function Jh(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Cr(r,...e){if(!Jh(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 qn(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Tr(r.outputLen),Tr(r.blockLen)}function Nr(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 Ka(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 zn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Ur=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Ge=(r,e)=>r<<32-e|r>>>e;var Rm=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var Xh=async()=>{};async function $a(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 Xh(),n+=i)}}function ji(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Lt(r){return typeof r=="string"&&(r=ji(r)),Cr(r),r}function Gn(...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 _r=class{clone(){return this._cloneInto()}},Qh={}.toString;function qa(r,e){if(e!==void 0&&Qh.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function jn(r){let e=n=>r().update(Lt(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Dr(r=32){if(zn&&typeof zn.getRandomValues=="function")return zn.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function ed(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 za=(r,e,t)=>r&e^~r&t,Ga=(r,e,t)=>r&e^r&t^e&t,Lr=class extends _r{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=Ur(this.buffer)}update(e){Nr(this);let{view:t,buffer:n,blockLen:o}=this;e=Lt(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=Ur(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){Nr(this),Ka(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;ed(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Ur(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 Yn=BigInt(4294967295),Yi=BigInt(32);function ja(r,e=!1){return e?{h:Number(r&Yn),l:Number(r>>Yi&Yn)}:{h:Number(r>>Yi&Yn)|0,l:Number(r&Yn)|0}}function td(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}=ja(r[o],e);[t[o],n[o]]=[i,s]}return[t,n]}var rd=(r,e)=>BigInt(r>>>0)<<Yi|BigInt(e>>>0),nd=(r,e,t)=>r>>>t,od=(r,e,t)=>r<<32-t|e>>>t,id=(r,e,t)=>r>>>t|e<<32-t,sd=(r,e,t)=>r<<32-t|e>>>t,ad=(r,e,t)=>r<<64-t|e>>>t-32,cd=(r,e,t)=>r>>>t-32|e<<64-t,ud=(r,e)=>e,ld=(r,e)=>r,fd=(r,e,t)=>r<<t|e>>>32-t,hd=(r,e,t)=>e<<t|r>>>32-t,dd=(r,e,t)=>e<<t-32|r>>>64-t,pd=(r,e,t)=>r<<t-32|e>>>64-t;function gd(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var md=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),yd=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,wd=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),bd=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,xd=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),Ed=(r,e,t,n,o,i)=>e+t+n+o+i+(r/2**32|0)|0;var vd={fromBig:ja,split:td,toBig:rd,shrSH:nd,shrSL:od,rotrSH:id,rotrSL:sd,rotrBH:ad,rotrBL:cd,rotr32H:ud,rotr32L:ld,rotlSH:fd,rotlSL:hd,rotlBH:dd,rotlBL:pd,add:gd,add3L:md,add3H:yd,add4L:wd,add4H:bd,add5H:Ed,add5L:xd},q=vd;var[Bd,Ad]=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))),Vt=new Uint32Array(80),Ot=new Uint32Array(80),Zi=class extends Lr{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:v,Gl:m,Hh:h,Hl:p}=this;return[e,t,n,o,i,s,a,c,f,u,l,d,v,m,h,p]}set(e,t,n,o,i,s,a,c,f,u,l,d,v,m,h,p){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=v|0,this.Gl=m|0,this.Hh=h|0,this.Hl=p|0}process(e,t){for(let E=0;E<16;E++,t+=4)Vt[E]=e.getUint32(t),Ot[E]=e.getUint32(t+=4);for(let E=16;E<80;E++){let D=Vt[E-15]|0,S=Ot[E-15]|0,I=q.rotrSH(D,S,1)^q.rotrSH(D,S,8)^q.shrSH(D,S,7),N=q.rotrSL(D,S,1)^q.rotrSL(D,S,8)^q.shrSL(D,S,7),y=Vt[E-2]|0,C=Ot[E-2]|0,V=q.rotrSH(y,C,19)^q.rotrBH(y,C,61)^q.shrSH(y,C,6),T=q.rotrSL(y,C,19)^q.rotrBL(y,C,61)^q.shrSL(y,C,6),O=q.add4L(N,T,Ot[E-7],Ot[E-16]),M=q.add4H(O,I,V,Vt[E-7],Vt[E-16]);Vt[E]=M|0,Ot[E]=O|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:d,Fh:v,Fl:m,Gh:h,Gl:p,Hh:b,Hl:k}=this;for(let E=0;E<80;E++){let D=q.rotrSH(l,d,14)^q.rotrSH(l,d,18)^q.rotrBH(l,d,41),S=q.rotrSL(l,d,14)^q.rotrSL(l,d,18)^q.rotrBL(l,d,41),I=l&v^~l&h,N=d&m^~d&p,y=q.add5L(k,S,N,Ad[E],Ot[E]),C=q.add5H(y,b,D,I,Bd[E],Vt[E]),V=y|0,T=q.rotrSH(n,o,28)^q.rotrBH(n,o,34)^q.rotrBH(n,o,39),O=q.rotrSL(n,o,28)^q.rotrBL(n,o,34)^q.rotrBL(n,o,39),M=n&i^n&a^i&a,Z=o&s^o&c^s&c;b=h|0,k=p|0,h=v|0,p=m|0,v=l|0,m=d|0,{h:l,l:d}=q.add(f|0,u|0,C|0,V|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let x=q.add3L(V,O,Z);n=q.add3H(x,C,T,M),o=x|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:v,l:m}=q.add(this.Fh|0,this.Fl|0,v|0,m|0),{h,l:p}=q.add(this.Gh|0,this.Gl|0,h|0,p|0),{h:b,l:k}=q.add(this.Hh|0,this.Hl|0,b|0,k|0),this.set(n,o,i,s,a,c,f,u,l,d,v,m,h,p,b,k)}roundClean(){Vt.fill(0),Ot.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 Vr=jn(()=>new Zi);var Wn={};de(Wn,{abytes:()=>Or,bitGet:()=>Nd,bitLen:()=>Cd,bitMask:()=>un,bitSet:()=>_d,bytesToHex:()=>gt,bytesToNumberBE:()=>mt,bytesToNumberLE:()=>Pt,concatBytes:()=>yt,createHmacDrbg:()=>Xi,ensureBytes:()=>ae,equalBytes:()=>Id,hexToBytes:()=>sr,hexToNumber:()=>Ji,isBytes:()=>Ft,numberToBytesBE:()=>Mt,numberToBytesLE:()=>ar,numberToHexUnpadded:()=>Ja,numberToVarBytesBE:()=>kd,utf8ToBytes:()=>Td,validateObject:()=>nt});var Wa=BigInt(0),Zn=BigInt(1),Sd=BigInt(2);function Ft(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Or(r){if(!Ft(r))throw new Error("Uint8Array expected")}var Rd=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function gt(r){Or(r);let e="";for(let t=0;t<r.length;t++)e+=Rd[r[t]];return e}function Ja(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function Ji(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var pt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Ya(r){if(r>=pt._0&&r<=pt._9)return r-pt._0;if(r>=pt._A&&r<=pt._F)return r-(pt._A-10);if(r>=pt._a&&r<=pt._f)return r-(pt._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=Ya(r.charCodeAt(i)),a=Ya(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 mt(r){return Ji(gt(r))}function Pt(r){return Or(r),Ji(gt(Uint8Array.from(r).reverse()))}function Mt(r,e){return sr(r.toString(16).padStart(e*2,"0"))}function ar(r,e){return Mt(r,e).reverse()}function kd(r){return sr(Ja(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(Ft(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 yt(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];Or(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 Id(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 Td(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Cd(r){let e;for(e=0;r>Wa;r>>=Zn,e+=1);return e}function Nd(r,e){return r>>BigInt(e)&Zn}function _d(r,e,t){return r|(t?Zn:Wa)<<BigInt(e)}var un=r=>(Sd<<BigInt(r-1))-Zn,Wi=r=>new Uint8Array(r),Za=r=>Uint8Array.from(r);function Xi(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=Wi(r),o=Wi(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>t(o,n,...l),c=(l=Wi())=>{o=a(Za([0]),l),n=a(),l.length!==0&&(o=a(Za([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 v=n.slice();d.push(v),l+=n.length}return yt(...d)};return(l,d)=>{s(),c(l);let v;for(;!(v=d(f()));)c();return s(),v}}var Ud={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"||Ft(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 nt(r,e,t={}){let n=(o,i,s)=>{let a=Ud[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 he=BigInt(0),te=BigInt(1),cr=BigInt(2),Dd=BigInt(3),Qi=BigInt(4),Xa=BigInt(5),Qa=BigInt(8),Ld=BigInt(9),Vd=BigInt(16);function ee(r,e){let t=r%e;return t>=he?t:e+t}function Od(r,e,t){if(t<=he||e<he)throw new Error("Expected power/modulo > 0");if(t===te)return he;let n=te;for(;e>he;)e&te&&(n=n*r%t),r=r*r%t,e>>=te;return n}function re(r,e,t){let n=r;for(;e-- >he;)n*=n,n%=t;return n}function Jn(r,e){if(r===he||e<=he)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=ee(r,e),n=e,o=he,i=te,s=te,a=he;for(;t!==he;){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 ee(o,e)}function Fd(r){let e=(r-te)/cr,t,n,o;for(t=r-te,n=0;t%cr===he;t/=cr,n++);for(o=cr;o<r&&Od(o,e,r)!==r-te;o++);if(n===1){let s=(r+te)/Qi;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)/cr;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 v=1;for(let h=a.sqr(d);v<f&&!a.eql(h,a.ONE);v++)h=a.sqr(h);let m=a.pow(u,te<<BigInt(f-v-1));u=a.sqr(m),l=a.mul(l,m),d=a.mul(d,u),f=v}return l}}function Pd(r){if(r%Qi===Dd){let e=(r+te)/Qi;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%Qa===Xa){let e=(r-Xa)/Qa;return function(n,o){let i=n.mul(o,cr),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,cr),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%Vd,Fd(r)}var ec=(r,e)=>(ee(r,e)&te)===te,Md=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function es(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Md.reduce((n,o)=>(n[o]="function",n),e);return nt(r,t)}function Hd(r,e,t){if(t<he)throw new Error("Expected power > 0");if(t===he)return r.ONE;if(t===te)return e;let n=r.ONE,o=e;for(;t>he;)t&te&&(n=r.mul(n,o)),o=r.sqr(o),t>>=te;return n}function Kd(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 ts(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Xn(r,e,t=!1,n={}){if(r<=he)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:i}=ts(r,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=Pd(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:un(o),ZERO:he,ONE:te,create:c=>ee(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return he<=c&&c<r},is0:c=>c===he,isOdd:c=>(c&te)===te,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)=>Hd(a,c,f),div:(c,f)=>ee(c*Jn(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Jn(c,r),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>Kd(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>t?ar(c,i):Mt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return t?Pt(c):mt(c)}});return Object.freeze(a)}function tc(r,e){if(!r.isOdd)throw new Error("Field doesn't have isOdd");let t=r.sqrt(e);return r.isOdd(t)?r.neg(t):t}function rc(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 rs(r){let e=rc(r);return e+Math.ceil(e/2)}function nc(r,e,t=!1){let n=r.length,o=rc(e),i=rs(e);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=t?mt(r):Pt(r),a=ee(s,e-te)+te;return t?ar(a,o):Mt(a,o)}var qd=BigInt(0),ns=BigInt(1);function Qn(r,e){let t=(o,i)=>{let s=i.negate();return o?s:i},n=o=>{let i=Math.ceil(e/o)+1,s=2**(o-1);return{windows:i,windowSize:s}};return{constTimeNegate:t,unsafeLadder(o,i){let s=r.ZERO,a=o;for(;i>qd;)i&ns&&(s=s.add(a)),a=a.double(),i>>=ns;return s},precomputeWindow(o,i){let{windows:s,windowSize:a}=n(i),c=[],f=o,u=f;for(let l=0;l<s;l++){u=f,c.push(u);for(let d=1;d<a;d++)u=u.add(f),c.push(u);f=u.double()}return c},wNAF(o,i,s){let{windows:a,windowSize:c}=n(o),f=r.ZERO,u=r.BASE,l=BigInt(2**o-1),d=2**o,v=BigInt(o);for(let m=0;m<a;m++){let h=m*c,p=Number(s&l);s>>=v,p>c&&(p-=d,s+=ns);let b=h,k=h+Math.abs(p)-1,E=m%2!==0,D=p<0;p===0?u=u.add(t(E,i[b])):f=f.add(t(D,i[k]))}return{p:f,f:u}},wNAFCached(o,i,s,a){let c=o._WINDOW_SIZE||1,f=i.get(o);return f||(f=this.precomputeWindow(o,c),c!==1&&i.set(o,a(f))),this.wNAF(c,f,s)}}}function ln(r){return es(r.Fp),nt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ts(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var je=BigInt(0),Le=BigInt(1),eo=BigInt(2),zd=BigInt(8),Gd={zip215:!0};function jd(r){let e=ln(r);return nt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function to(r){let e=jd(r),{Fp:t,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=e,f=eo<<BigInt(a*8)-Le,u=t.create,l=e.uvRatio||((B,w)=>{try{return{isValid:!0,value:t.sqrt(B*t.inv(w))}}catch{return{isValid:!1,value:je}}}),d=e.adjustScalarBytes||(B=>B),v=e.domain||((B,w,L)=>{if(w.length||L)throw new Error("Contexts/pre-hash are not supported");return B}),m=B=>typeof B=="bigint"&&je<B,h=(B,w)=>m(B)&&m(w)&&B<w,p=B=>B===je||h(B,f);function b(B,w){if(h(B,w))return B;throw new Error(`Expected valid scalar < ${w}, got ${typeof B} ${B}`)}function k(B){return B===je?B:b(B,n)}let E=new Map;function D(B){if(!(B instanceof S))throw new Error("ExtendedPoint expected")}class S{constructor(w,L,F,H){if(this.ex=w,this.ey=L,this.ez=F,this.et=H,!p(w))throw new Error("x required");if(!p(L))throw new Error("y required");if(!p(F))throw new Error("z required");if(!p(H))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(w){if(w instanceof S)throw new Error("extended point not allowed");let{x:L,y:F}=w||{};if(!p(L)||!p(F))throw new Error("invalid affine point");return new S(L,F,Le,u(L*F))}static normalizeZ(w){let L=t.invertBatch(w.map(F=>F.ez));return w.map((F,H)=>F.toAffine(L[H])).map(S.fromAffine)}_setWindowSize(w){this._WINDOW_SIZE=w,E.delete(this)}assertValidity(){let{a:w,d:L}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:F,ey:H,ez:z,et:G}=this,Q=u(F*F),Y=u(H*H),W=u(z*z),ce=u(W*W),ie=u(Q*w),me=u(W*u(ie+Y)),ye=u(ce+u(L*u(Q*Y)));if(me!==ye)throw new Error("bad point: equation left != right (1)");let le=u(F*H),Be=u(z*G);if(le!==Be)throw new Error("bad point: equation left != right (2)")}equals(w){D(w);let{ex:L,ey:F,ez:H}=this,{ex:z,ey:G,ez:Q}=w,Y=u(L*Q),W=u(z*H),ce=u(F*Q),ie=u(G*H);return Y===W&&ce===ie}is0(){return this.equals(S.ZERO)}negate(){return new S(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:w}=e,{ex:L,ey:F,ez:H}=this,z=u(L*L),G=u(F*F),Q=u(eo*u(H*H)),Y=u(w*z),W=L+F,ce=u(u(W*W)-z-G),ie=Y+G,me=ie-Q,ye=Y-G,le=u(ce*me),Be=u(ie*ye),ft=u(ce*ye),er=u(me*ie);return new S(le,Be,er,ft)}add(w){D(w);let{a:L,d:F}=e,{ex:H,ey:z,ez:G,et:Q}=this,{ex:Y,ey:W,ez:ce,et:ie}=w;if(L===BigInt(-1)){let oa=u((z-H)*(W+Y)),ia=u((z+H)*(W-Y)),xi=u(ia-oa);if(xi===je)return this.double();let sa=u(G*eo*ie),aa=u(Q*eo*ce),ca=aa+sa,ua=ia+oa,la=aa-sa,Bf=u(ca*xi),Af=u(ua*la),Sf=u(ca*la),Rf=u(xi*ua);return new S(Bf,Af,Rf,Sf)}let me=u(H*Y),ye=u(z*W),le=u(Q*F*ie),Be=u(G*ce),ft=u((H+z)*(Y+W)-me-ye),er=Be-le,tn=Be+le,na=u(ye-L*me),bf=u(ft*er),xf=u(tn*na),Ef=u(ft*na),vf=u(er*tn);return new S(bf,xf,vf,Ef)}subtract(w){return this.add(w.negate())}wNAF(w){return y.wNAFCached(this,E,w,S.normalizeZ)}multiply(w){let{p:L,f:F}=this.wNAF(b(w,n));return S.normalizeZ([L,F])[0]}multiplyUnsafe(w){let L=k(w);return L===je?N:this.equals(N)||L===Le?this:this.equals(I)?this.wNAF(L).p:y.unsafeLadder(this,L)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return y.unsafeLadder(this,n).is0()}toAffine(w){let{ex:L,ey:F,ez:H}=this,z=this.is0();w==null&&(w=z?zd:t.inv(H));let G=u(L*w),Q=u(F*w),Y=u(H*w);if(z)return{x:je,y:Le};if(Y!==Le)throw new Error("invZ was invalid");return{x:G,y:Q}}clearCofactor(){let{h:w}=e;return w===Le?this:this.multiplyUnsafe(w)}static fromHex(w,L=!1){let{d:F,a:H}=e,z=t.BYTES;w=ae("pointHex",w,z);let G=w.slice(),Q=w[z-1];G[z-1]=Q&-129;let Y=Pt(G);Y===je||(L?b(Y,f):b(Y,t.ORDER));let W=u(Y*Y),ce=u(W-Le),ie=u(F*W-H),{isValid:me,value:ye}=l(ce,ie);if(!me)throw new Error("Point.fromHex: invalid y coordinate");let le=(ye&Le)===Le,Be=(Q&128)!==0;if(!L&&ye===je&&Be)throw new Error("Point.fromHex: x=0 and x_0=1");return Be!==le&&(ye=u(-ye)),S.fromAffine({x:ye,y:Y})}static fromPrivateKey(w){return T(w).point}toRawBytes(){let{x:w,y:L}=this.toAffine(),F=ar(L,t.BYTES);return F[F.length-1]|=w&Le?128:0,F}toHex(){return gt(this.toRawBytes())}}S.BASE=new S(e.Gx,e.Gy,Le,u(e.Gx*e.Gy)),S.ZERO=new S(je,Le,Le,je);let{BASE:I,ZERO:N}=S,y=Qn(S,a*8);function C(B){return ee(B,n)}function V(B){return C(Pt(B))}function T(B){let w=a;B=ae("private key",B,w);let L=ae("hashed private key",i(B),2*w),F=d(L.slice(0,w)),H=L.slice(w,2*w),z=V(F),G=I.multiply(z),Q=G.toRawBytes();return{head:F,prefix:H,scalar:z,point:G,pointBytes:Q}}function O(B){return T(B).pointBytes}function M(B=new Uint8Array,...w){let L=yt(...w);return V(i(v(L,ae("context",B),!!o)))}function Z(B,w,L={}){B=ae("message",B),o&&(B=o(B));let{prefix:F,scalar:H,pointBytes:z}=T(w),G=M(L.context,F,B),Q=I.multiply(G).toRawBytes(),Y=M(L.context,Q,z,B),W=C(G+Y*H);k(W);let ce=yt(Q,ar(W,t.BYTES));return ae("result",ce,a*2)}let x=Gd;function A(B,w,L,F=x){let{context:H,zip215:z}=F,G=t.BYTES;B=ae("signature",B,2*G),w=ae("message",w),o&&(w=o(w));let Q=Pt(B.slice(G,2*G)),Y,W,ce;try{Y=S.fromHex(L,z),W=S.fromHex(B.slice(0,G),z),ce=I.multiplyUnsafe(Q)}catch{return!1}if(!z&&Y.isSmallOrder())return!1;let ie=M(H,W.toRawBytes(),Y.toRawBytes(),w);return W.add(Y.multiplyUnsafe(ie)).subtract(ce).clearCofactor().equals(S.ZERO)}return I._setWindowSize(8),{CURVE:e,getPublicKey:O,sign:Z,verify:A,ExtendedPoint:S,utils:{getExtendedPublicKey:T,randomPrivateKey:()=>s(t.BYTES),precompute(B=8,w=S.BASE){return w._setWindowSize(B),w.multiply(BigInt(3)),w}}}}var is=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),oc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Ym=BigInt(0),Yd=BigInt(1),os=BigInt(2),Zd=BigInt(5),ic=BigInt(10),Wd=BigInt(20),Jd=BigInt(40),sc=BigInt(80);function Xd(r){let e=is,n=r*r%e*r%e,o=re(n,os,e)*n%e,i=re(o,Yd,e)*r%e,s=re(i,Zd,e)*i%e,a=re(s,ic,e)*s%e,c=re(a,Wd,e)*a%e,f=re(c,Jd,e)*c%e,u=re(f,sc,e)*f%e,l=re(u,sc,e)*f%e,d=re(l,ic,e)*s%e;return{pow_p_5_8:re(d,os,e)*r%e,b2:n}}function Qd(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function e0(r,e){let t=is,n=ee(e*e*e,t),o=ee(n*n*e,t),i=Xd(r*o).pow_p_5_8,s=ee(r*n*i,t),a=ee(e*s*s,t),c=s,f=ee(s*oc,t),u=a===r,l=a===ee(-r,t),d=a===ee(-r*oc,t);return u&&(s=c),(l||d)&&(s=f),ec(s,t)&&(s=ee(-s,t)),{isValid:u||l,value:s}}var wt=Xn(is,void 0,!0),ss={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:wt,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Vr,randomBytes:Dr,adjustScalarBytes:Qd,uvRatio:e0},Fr=to(ss);function ac(r,e,t){if(e.length>255)throw new Error("Context is too big");return Gn(ji("SigEd25519 no Ed25519 collisions"),new Uint8Array([t?1:0,e.length]),e,r)}var Zm=to({...ss,domain:ac}),Wm=to({...ss,domain:ac,prehash:Vr});var t0=(wt.ORDER+BigInt(3))/BigInt(8),Jm=wt.pow(os,t0),Xm=wt.sqrt(wt.neg(wt.ONE)),Qm=(wt.ORDER-BigInt(5))/BigInt(8),ey=BigInt(486662);var ty=tc(wt,wt.neg(BigInt(486664)));var ry=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),ny=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),oy=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),iy=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var sy=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Pr=32,bt=64,ro=32;function cc(){let r=Fr.utils.randomPrivateKey(),e=Fr.getPublicKey(r);return{privateKey:hc(r,e),publicKey:e}}function uc(r){if(r.length!==ro)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=Fr.getPublicKey(e);return{privateKey:hc(e,t),publicKey:t}}function lc(r,e){let t=r.subarray(0,ro);return Fr.sign(e instanceof Uint8Array?e:e.subarray(),t)}function fc(r,e,t){return Fr.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function hc(r,e){let t=new Uint8Array(bt);for(let n=0;n<ro;n++)t[n]=r[n],t[ro+n]=e[n];return t}var ke={get(r=globalThis){let e=r.crypto;if(e==null||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 as={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function dc(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=ke.get();t*=8;async function c(l,d){let v=a.getRandomValues(new Uint8Array(i)),m=a.getRandomValues(new Uint8Array(n)),h={name:e,iv:m};typeof d=="string"&&(d=J(d));let p;if(d.length===0){p=await a.subtle.importKey("jwk",as,{name:"AES-GCM"},!0,["encrypt"]);try{let k={name:"PBKDF2",salt:v,iterations:s,hash:{name:o}},E=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);p=await a.subtle.deriveKey(k,E,{name:e,length:t},!0,["encrypt"])}catch{p=await a.subtle.importKey("jwk",as,{name:"AES-GCM"},!0,["encrypt"])}}else{let k={name:"PBKDF2",salt:v,iterations:s,hash:{name:o}},E=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);p=await a.subtle.deriveKey(k,E,{name:e,length:t},!0,["encrypt"])}let b=await a.subtle.encrypt(h,p,l);return ir([v,h.iv,new Uint8Array(b)])}async function f(l,d){let v=l.subarray(0,i),m=l.subarray(i,i+n),h=l.subarray(i+n),p={name:e,iv:m};typeof d=="string"&&(d=J(d));let b;if(d.length===0)try{let E={name:"PBKDF2",salt:v,iterations:s,hash:{name:o}},D=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);b=await a.subtle.deriveKey(E,D,{name:e,length:t},!0,["decrypt"])}catch{b=await a.subtle.importKey("jwk",as,{name:"AES-GCM"},!0,["decrypt"])}else{let E={name:"PBKDF2",salt:v,iterations:s,hash:{name:o}},D=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);b=await a.subtle.deriveKey(E,D,{name:e,length:t},!0,["decrypt"])}let k=await a.subtle.decrypt(p,b,h);return new Uint8Array(k)}return{encrypt:c,decrypt:f}}async function Mr(r,e){let n=await dc().encrypt(r,e);return rn.encode(n)}var o0=Math.pow(2,7),i0=Math.pow(2,14),s0=Math.pow(2,21),pc=Math.pow(2,28),gc=Math.pow(2,35),mc=Math.pow(2,42),yc=Math.pow(2,49),Ie=128,Ht=127;function fn(r){if(r<o0)return 1;if(r<i0)return 2;if(r<s0)return 3;if(r<pc)return 4;if(r<gc)return 5;if(r<mc)return 6;if(r<yc)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function wc(r,e,t=0){switch(fn(r)){case 8:e[t++]=r&255|Ie,r/=128;case 7:e[t++]=r&255|Ie,r/=128;case 6:e[t++]=r&255|Ie,r/=128;case 5:e[t++]=r&255|Ie,r/=128;case 4:e[t++]=r&255|Ie,r>>>=7;case 3:e[t++]=r&255|Ie,r>>>=7;case 2:e[t++]=r&255|Ie,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function bc(r,e){let t=r[e],n=0;if(n+=t&Ht,t<Ie||(t=r[e+1],n+=(t&Ht)<<7,t<Ie)||(t=r[e+2],n+=(t&Ht)<<14,t<Ie)||(t=r[e+3],n+=(t&Ht)<<21,t<Ie)||(t=r[e+4],n+=(t&Ht)*pc,t<Ie)||(t=r[e+5],n+=(t&Ht)*gc,t<Ie)||(t=r[e+6],n+=(t&Ht)*mc,t<Ie)||(t=r[e+7],n+=(t&Ht)*yc,t<Ie))return n;throw new RangeError("Could not decode varint")}var cs=new Float32Array([-0]),Kt=new Uint8Array(cs.buffer);function xc(r,e,t){cs[0]=r,e[t]=Kt[0],e[t+1]=Kt[1],e[t+2]=Kt[2],e[t+3]=Kt[3]}function Ec(r,e){return Kt[0]=r[e],Kt[1]=r[e+1],Kt[2]=r[e+2],Kt[3]=r[e+3],cs[0]}var us=new Float64Array([-0]),Ae=new Uint8Array(us.buffer);function vc(r,e,t){us[0]=r,e[t]=Ae[0],e[t+1]=Ae[1],e[t+2]=Ae[2],e[t+3]=Ae[3],e[t+4]=Ae[4],e[t+5]=Ae[5],e[t+6]=Ae[6],e[t+7]=Ae[7]}function Bc(r,e){return Ae[0]=r[e],Ae[1]=r[e+1],Ae[2]=r[e+2],Ae[3]=r[e+3],Ae[4]=r[e+4],Ae[5]=r[e+5],Ae[6]=r[e+6],Ae[7]=r[e+7],us[0]}var a0=BigInt(Number.MAX_SAFE_INTEGER),c0=BigInt(Number.MIN_SAFE_INTEGER),Ve=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 ur;if(e<a0&&e>c0)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>Ac&&(o=0n,++n>Ac&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return ur;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):ur}},ur=new Ve(0,0);ur.toBigInt=function(){return 0n};ur.zzEncode=ur.zzDecode=function(){return this};ur.length=function(){return 1};var Ac=4294967296n;function Sc(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 Rc(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 ls(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 Ye(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function no(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var fs=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,Ye(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 Ye(this,4);return no(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ye(this,4);return no(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Ye(this,4);let e=Ec(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Ye(this,4);let e=Bc(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 Ye(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Rc(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Ye(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Ye(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 Ve(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 Ye(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 Ye(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 Ye(this,8);let e=no(this.buf,this.pos+=4),t=no(this.buf,this.pos+=4);return new Ve(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=bc(this.buf,this.pos);return this.pos+=fn(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 hs(r){return new fs(r instanceof Uint8Array?r:r.subarray())}function $t(r,e,t){let n=hs(r);return e.decode(n,void 0,t)}function ds(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return rt(s);o+s>e&&(n=rt(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var lr=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function ps(){}var ms=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},u0=ds();function l0(r){return globalThis.Buffer!=null?rt(r):u0(r)}var dn=class{len;head;tail;states;constructor(){this.len=0,this.head=new lr(ps,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new lr(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new ys((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(oo,10,Ve.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Ve.fromBigInt(e);return this._push(oo,t.length(),t)}uint64Number(e){return this._push(wc,fn(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=Ve.fromBigInt(e).zzEncode();return this._push(oo,t.length(),t)}sint64Number(e){let t=Ve.fromNumber(e).zzEncode();return this._push(oo,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(gs,1,e?1:0)}fixed32(e){return this._push(hn,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Ve.fromBigInt(e);return this._push(hn,4,t.lo)._push(hn,4,t.hi)}fixed64Number(e){let t=Ve.fromNumber(e);return this._push(hn,4,t.lo)._push(hn,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(xc,4,e)}double(e){return this._push(vc,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(gs,1,0):this.uint32(t)._push(h0,t,e)}string(e){let t=Sc(e);return t!==0?this.uint32(t)._push(ls,t,e):this._push(gs,1,0)}fork(){return this.states=new ms(this),this.head=this.tail=new lr(ps,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 lr(ps,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=l0(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function gs(r,e,t){e[t]=r&255}function f0(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var ys=class extends lr{next;constructor(e,t){super(f0,e,t),this.next=void 0}};function oo(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 hn(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 h0(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(dn.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(d0,e,r),this},dn.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(p0,e,r),this});function d0(r,e,t){e.set(r,t)}function p0(r,e,t){r.length<40?ls(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(J(r),t)}function ws(){return new dn}function qt(r,e){let t=ws();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var Hr;(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"})(Hr||(Hr={}));function io(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function pn(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 io("enum",Hr.VARINT,t,n)}function zt(r,e){return io("message",Hr.LENGTH_DELIMITED,r,e)}var ne;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(ne||(ne={}));var bs;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(bs||(bs={}));(function(r){r.codec=()=>pn(bs)})(ne||(ne={}));var ot;(function(r){let e;r.codec=()=>(e==null&&(e=zt((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ne.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=ne.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(s&7);break}}return o})),e),r.encode=t=>qt(t,r.codec()),r.decode=t=>$t(t,r.codec())})(ot||(ot={}));var it;(function(r){let e;r.codec=()=>(e==null&&(e=zt((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ne.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=ne.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(s&7);break}}return o})),e),r.encode=t=>qt(t,r.codec()),r.decode=t=>$t(t,r.codec())})(it||(it={}));var gn=class{_key;constructor(e){this._key=Kr(e,Pr)}verify(e,t){return fc(this._key,t,e)}marshal(){return this._key}get bytes(){return ot.encode({Type:ne.Ed25519,Data:this.marshal()}).subarray()}equals(e){return fe(this.bytes,e.bytes)}hash(){let e=be.digest(this.bytes);return He(e)?e.then(({bytes:t})=>t):e.bytes}},fr=class{_key;_publicKey;constructor(e,t){this._key=Kr(e,bt),this._publicKey=Kr(t,Pr)}sign(e){return lc(this._key,e)}get public(){return new gn(this._publicKey)}marshal(){return this._key}get bytes(){return it.encode({Type:ne.Ed25519,Data:this.marshal()}).subarray()}equals(e){return fe(this.bytes,e.bytes)}async hash(){let e=be.digest(this.bytes),t;return He(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=tt.digest(this.public.bytes);return we.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return Mr(this.bytes,e);throw new $(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function g0(r){if(r.length>bt){r=Kr(r,bt+Pr);let n=r.subarray(0,bt),o=r.subarray(bt,r.length);return new fr(n,o)}r=Kr(r,bt);let e=r.subarray(0,bt),t=r.subarray(Pr);return new fr(e,t)}function m0(r){return r=Kr(r,Pr),new gn(r)}async function y0(){let{privateKey:r,publicKey:e}=cc();return new fr(r,e)}async function Ic(r){let{privateKey:e,publicKey:t}=uc(r);return new fr(e,t)}function Kr(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new $(`Key must be a Uint8Array of length ${e}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}function oe(r,e="utf8"){let t=$n[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var Cs={};de(Cs,{MAX_RSA_KEY_SIZE:()=>kn,RsaPrivateKey:()=>jr,RsaPublicKey:()=>Rn,fromJwk:()=>q0,generateKeyPair:()=>z0,unmarshalRsaPrivateKey:()=>Is,unmarshalRsaPublicKey:()=>$0});function hr(r){if(isNaN(r)||r<=0)throw new $("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Dr(r)}var Zt={};de(Zt,{exportToPem:()=>F0,importFromPem:()=>P0,jwkToPkcs1:()=>D0,jwkToPkix:()=>V0,pkcs1ToJwk:()=>U0,pkixToJwk:()=>L0});var ao=class extends _r{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,qn(e);let n=Lt(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 Nr(this),this.iHash.update(e),this}digestInto(e){Nr(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()}},mn=(r,e,t)=>new ao(r,e).update(t).digest();mn.create=(r,e)=>new ao(r,e);function w0(r,e,t,n){qn(r);let o=qa({dkLen:32,asyncTick:10},n),{c:i,dkLen:s,asyncTick:a}=o;if(Tr(i),Tr(s),Tr(a),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=Lt(e),f=Lt(t),u=new Uint8Array(s),l=mn.create(r,c),d=l._cloneInto().update(f);return{c:i,dkLen:s,asyncTick:a,DK:u,PRF:l,PRFSalt:d}}function b0(r,e,t,n,o){return r.destroy(),e.destroy(),n&&n.destroy(),o.fill(0),t}async function Es(r,e,t,n){let{c:o,dkLen:i,asyncTick:s,DK:a,PRF:c,PRFSalt:f}=w0(r,e,t,n),u,l=new Uint8Array(4),d=Ur(l),v=new Uint8Array(c.outputLen);for(let m=1,h=0;h<i;m++,h+=c.outputLen){let p=a.subarray(h,h+c.outputLen);d.setInt32(0,m,!1),(u=f._cloneInto(u)).update(l).digestInto(v),p.set(v.subarray(0,p.length)),await $a(o-1,s,()=>{c._cloneInto(u).update(v).digestInto(v);for(let b=0;b<p.length;b++)p[b]^=v[b]})}return b0(c,f,a,u,v)}var j=ht(Tc());function dr(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 lo(...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 Bs(){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=dr(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,dr(i,8)-n}function Cc(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 Nc(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 Ne(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 gw=Math.log(2);function fo(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function As(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 At(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 wn=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return As(this.items)}},yn=[new Uint8Array([1])],_c="0123456789";var zr="",We=new ArrayBuffer(0),Ss=new Uint8Array(0),bn="EndOfContent",Dc="OCTET STRING",Lc="BIT STRING";function St(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?j.BufferSourceConverter.toUint8Array(i.valueHex):Ss}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(!At(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",We)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:j.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var Et=class{constructor({blockLength:e=0,error:t=zr,warnings:n=[],valueBeforeDecode:o=Ss}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=j.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:j.Convert.ToHex(this.valueBeforeDecodeView)}}};Et.NAME="baseBlock";var Se=class extends Et{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'")}};Se.NAME="valueBlock";var ho=class extends St(Et){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?j.BufferSourceConverter.toUint8Array(e.valueHex):Ss,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",We}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=j.BufferSourceConverter.toUint8Array(e);if(!At(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 v=0;v<f.length;v++)d[v]=f[v];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=dr(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}}};ho.NAME="identificationBlock";var po=class extends Et{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=j.BufferSourceConverter.toUint8Array(e);if(!At(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=dr(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",We;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}}};po.NAME="lengthBlock";var _={},xe=class extends Et{constructor({name:e=zr,optional:t=!1,primitiveSchema:n,...o}={},i){super(o),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new ho(o),this.lenBlock=new po(o),this.valueBlock=i?new i(o):new Se(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 wn;t||Vc(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?We: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():j.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${j.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 Nc(t,n)}};xe.NAME="BaseBlock";function Vc(r){if(r instanceof _.Constructed)for(let e of r.valueBlock.value)Vc(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var go=class extends xe{constructor({value:e=zr,...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}'`}};go.NAME="BaseStringBlock";var mo=class extends St(Se){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};mo.NAME="PrimitiveValueBlock";var Oc,yo=class extends xe{constructor(e={}){super(e,mo),this.idBlock.isConstructed=!1}};Oc=yo;_.Primitive=Oc;yo.NAME="PRIMITIVE";function I0(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 Wo(r,e=0,t=r.length){let n=e,o=new xe({},Se),i=new Et;if(!At(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=xe;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=_.EndOfContent;break;case 1:c=_.Boolean;break;case 2:c=_.Integer;break;case 3:c=_.BitString;break;case 4:c=_.OctetString;break;case 5:c=_.Null;break;case 6:c=_.ObjectIdentifier;break;case 10:c=_.Enumerated;break;case 12:c=_.Utf8String;break;case 13:c=_.RelativeObjectIdentifier;break;case 14:c=_.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=_.Sequence;break;case 17:c=_.Set;break;case 18:c=_.NumericString;break;case 19:c=_.PrintableString;break;case 20:c=_.TeletexString;break;case 21:c=_.VideotexString;break;case 22:c=_.IA5String;break;case 23:c=_.UTCTime;break;case 24:c=_.GeneralizedTime;break;case 25:c=_.GraphicString;break;case 26:c=_.VisibleString;break;case 27:c=_.GeneralString;break;case 28:c=_.UniversalString;break;case 29:c=_.CharacterString;break;case 30:c=_.BmpString;break;case 31:c=_.DATE;break;case 32:c=_.TimeOfDay;break;case 33:c=_.DateTime;break;case 34:c=_.Duration;break;default:{let f=o.idBlock.isConstructed?new _.Constructed:new _.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?_.Constructed:_.Primitive}return o=I0(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 Gr(r){if(!r.byteLength){let e=new xe({},Se);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Wo(j.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function T0(r,e){return r?1:e}var st=class extends Se{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let o=j.BufferSourceConverter.toUint8Array(e);if(!At(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(;T0(this.isIndefiniteForm,n)>0;){let s=Wo(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===bn)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===bn?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new wn;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return t?We:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};st.NAME="ConstructedValueBlock";var Fc,jt=class extends xe{constructor(e={}){super(e,st),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 HeliaIpns=(()=>{var Ef=Object.create;var On=Object.defineProperty;var vf=Object.getOwnPropertyDescriptor;var Bf=Object.getOwnPropertyNames;var Af=Object.getPrototypeOf,Sf=Object.prototype.hasOwnProperty;var er=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),de=(r,e)=>{for(var t in e)On(r,t,{get:e[t],enumerable:!0})},sa=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Bf(e))!Sf.call(r,o)&&o!==t&&On(r,o,{get:()=>e[o],enumerable:!(n=vf(e,o))||n.enumerable});return r};var ht=(r,e,t)=>(t=r!=null?Ef(Af(r)):{},sa(e||!r||!r.__esModule?On(t,"default",{value:r,enumerable:!0}):t,r)),Rf=r=>sa(On({},"__esModule",{value:!0}),r);var ua=er((tg,ca)=>{var yr=1e3,wr=yr*60,br=wr*60,tr=br*24,kf=tr*7,If=tr*365.25;ca.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return Tf(r);if(t==="number"&&isFinite(r))return e.long?Nf(r):Cf(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Tf(r){if(r=String(r),!(r.length>100)){var 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){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*If;case"weeks":case"week":case"w":return t*kf;case"days":case"day":case"d":return t*tr;case"hours":case"hour":case"hrs":case"hr":case"h":return t*br;case"minutes":case"minute":case"mins":case"min":case"m":return t*wr;case"seconds":case"second":case"secs":case"sec":case"s":return t*yr;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Cf(r){var e=Math.abs(r);return e>=tr?Math.round(r/tr)+"d":e>=br?Math.round(r/br)+"h":e>=wr?Math.round(r/wr)+"m":e>=yr?Math.round(r/yr)+"s":r+"ms"}function Nf(r){var e=Math.abs(r);return e>=tr?Fn(r,e,tr,"day"):e>=br?Fn(r,e,br,"hour"):e>=wr?Fn(r,e,wr,"minute"):e>=yr?Fn(r,e,yr,"second"):r+" ms"}function Fn(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var fa=er((rg,la)=>{function _f(r){t.debug=t,t.default=t,t.coerce=c,t.disable=i,t.enable=o,t.enabled=s,t.humanize=ua(),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,E,m;function h(...p){if(!h.enabled)return;let b=h,k=Number(new Date),v=k-(l||k);b.diff=v,b.prev=l,b.curr=k,l=k,p[0]=t.coerce(p[0]),typeof p[0]!="string"&&p.unshift("%O");let D=0;p[0]=p[0].replace(/%([a-zA-Z%])/g,(I,N)=>{if(I==="%%")return"%";D++;let y=t.formatters[N];if(typeof y=="function"){let C=p[D];I=y.call(b,C),p.splice(D,1),D--}return I}),t.formatArgs.call(b,p),(b.log||t.log).apply(b,p)}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:(E!==t.namespaces&&(E=t.namespaces,m=t.enabled(u)),m),set:p=>{d=p}}),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,]+/),E=d.length;for(l=0;l<E;l++)d[l]&&(u=d[l].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.slice(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.enable(t.load()),t}la.exports=_f});var ha=er((Ue,Pn)=>{Ue.formatArgs=Df;Ue.save=Lf;Ue.load=Vf;Ue.useColors=Uf;Ue.storage=Of();Ue.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Ue.colors=["#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 Uf(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Df(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Pn.exports.humanize(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)}Ue.log=console.debug||console.log||(()=>{});function Lf(r){try{r?Ue.storage.setItem("debug",r):Ue.storage.removeItem("debug")}catch{}}function Vf(){let r;try{r=Ue.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Of(){try{return localStorage}catch{}}Pn.exports=fa()(Ue);var{formatters:Ff}=Pn.exports;Ff.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Bc=er(Hr=>{"use strict";var p0="[object ArrayBuffer]",bt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===p0}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}},ys="string",g0=/^[0-9a-f]+$/i,m0=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,y0=/^[a-zA-Z0-9-_]+$/,io=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=bt.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}},Ke=class{static toString(e,t=!1){let n=bt.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===ys&&g0.test(e)}static isBase64(e){return typeof e===ys&&m0.test(e)}static isBase64Url(e){return typeof e===ys&&y0.test(e)}static ToString(e,t="utf8"){let n=bt.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 Ke.toString(n,!0);case"utf16":case"utf16be":return Ke.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 Ke.fromString(e,!0);case"utf16":case"utf16be":return Ke.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=bt.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 io.fromString(e);case"utf16":case"utf16be":return Ke.fromString(e);case"utf16le":case"usc2":return Ke.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 io.toString(e);case"utf16":case"utf16be":return Ke.toString(e);case"utf16le":case"usc2":return Ke.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=bt.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=bt.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 Ke.toString(e,t)}static FromUtf16String(e,t=!1){return Ke.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 w0(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 b0(...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 x0(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}Hr.BufferSourceConverter=bt;Hr.Convert=so;Hr.assign=w0;Hr.combine=b0;Hr.isEqual=x0});var Zo=er((Ww,Nu)=>{"use strict";function Cu(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function Q0(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 Cu(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),Cu(new o,t)}}Nu.exports=Q0});var Jo=er((tb,_s)=>{var eb=function(){typeof _s<"u"&&(_s.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(y){var C=y-y%1;return C==0&&(y<0||y===0&&1/y!=1/0)?-0:C},u=h.prototype,l=(h.fromDate=function(y){return new h(+y)},h.fromInt64BE=D(0,1,2,3,0,4),h.fromInt64LE=D(3,2,1,0,4,0),h.fromString=function(T){var C,V=new h,T=(T+="").replace(/^\s*[+\-]?\d+/,function(M){var M=+M,Z=1970+(M-1970)%400;return V.year=M-Z,Z}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(O,M,Z){return M<0&&(Z*=-1),C=6e4*(60*+M+ +Z),""}).replace(/\.\d+$/,function(O){return V.nano=+(O+c).substr(1,9),""}).split(/\D+/);if(1<T.length?T[1]--:T[1]=0,V.time=C=Date.UTC.apply(Date,T)-(C||0),isNaN(C))throw new TypeError("Invalid Date");return p(V)},h.fromTimeT=function(y){return k(y,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(y){return this.nano+=+y||0,this},u.getNano=function(){var y=p(this);return(y.time%1e3*a+ +y.nano+1e9)%1e9},u.getTimeT=function(){var C=p(this),y=Math.floor(C.time/1e3),C=C.year;return C&&(y+=C*t*r/e),y},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return b(p(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(y){var C=this,V=C.toDate(),T={H:function(){return I(V.getUTCHours())},L:function(){return N(V.getUTCMilliseconds(),3)},M:function(){return I(V.getUTCMinutes())},N:function(){return N(C.getNano(),9)},S:function(){return I(V.getUTCSeconds())},Y:function(){var O=C.getYear();return 999999<O?"+"+O:9999<O?"+"+N(O,6):0<=O?N(O,4):-999999<=O?"-"+N(-O,6):O},a:function(){return E[V.getUTCDay()]},b:function(){return d[V.getUTCMonth()]},d:function(){return I(V.getUTCDate())},e:function(){return function(O){return(9<O?"":" ")+(0|O)}(V.getUTCDate())},m:function(){return I(V.getUTCMonth()+1)}};return function O(M){return M.replace(/%./g,function(Z){var A=Z[1],x=m[A],A=T[A];return x?O(x):A?A():Z})}(y||l)},u.writeInt64BE=v(0,1,2,3,0,4),u.writeInt64LE=v(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),d=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],E=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],m={"%":"%",F:"%Y-%m-%d",n:`
3
+ `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return h;function h(y,C,V){var T=this;if(!(T instanceof h))return new h(y,C,V);T.time=+y||0,T.nano=+C||0,T.year=+V||0,p(T)}function p(y){var C,V,T,O=y.year,M=y.time,Z=y.nano,x=((Z<0||a<=Z)&&(Z-=(V=Math.floor(Z/a))*a,M+=V,V=1),O%e);return(M<-i||i<M||x)&&((C=f(M/o))&&(O+=C*e,M-=C*o),(T=b(M)).setUTCFullYear(x+T.getUTCFullYear()),T=(M=+T)+(C=f((O-=x)/e))*o,C&&-i<=T&&T<=i&&(O-=C*e,M=T),V=1),V&&(y.year=O,y.time=M,y.nano=Z),y}function b(y){var C=new Date(0);return C.setTime(y),C}function k(O,T){O=+O||0;var V=f((T=(T|0)*s)/n)+f(O/n),T=T%n+O%n,O=f(T/n);return O&&(V+=O,T-=O*n),new h(1e3*T,0,V*e)}function v(y,C,V,T,O,M){return function(x,A){var B=p(this);x=x||new Array(8),S(x,A|=0);var w=Math.floor(B.time/1e3),B=B.year*(t*r/e),P=f(B/s)+f(w/s),B=B%s+w%s,w=Math.floor(B/s);return w&&(P+=w,B-=w*s),Z(x,A+O,P),Z(x,A+M,B),x};function Z(x,A,P){x[A+y]=P>>24&255,x[A+C]=P>>16&255,x[A+V]=P>>8&255,x[A+T]=255&P}}function D(y,C,V,T,O,M){return function(x,A){S(x,A|=0);var P=Z(x,A+O);return k(Z(x,A+M),P)};function Z(x,A){return 16777216*x[A+y]+(x[A+C]<<16|x[A+V]<<8|x[A+T])}}function S(y,C){if(y=y&&y.length,y==null)throw new TypeError("Invalid Buffer");if(y<C+8)throw new RangeError("Out of range")}function I(y){return(9<y?"":"0")+(0|y)}function N(y,C){return(c+(0|y)).substr(-C)}}()});var of=er((Yx,nf)=>{nf.exports=function(r){if(!r)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,t=Object.create(null),n=Object.create(null);function o(i,s){t[i]=s,e++,e>=r&&(e=0,n=t,t=Object.create(null))}return{has:function(i){return t[i]!==void 0||n[i]!==void 0},remove:function(i){t[i]!==void 0&&(t[i]=void 0),n[i]!==void 0&&(n[i]=void 0)},get:function(i){var s=t[i];if(s!==void 0)return s;if((s=n[i])!==void 0)return o(i,s),s},set:function(i,s){t[i]!==void 0?t[i]=s:o(i,s)},clear:function(){t=Object.create(null),n=Object.create(null)}}}});var Jp={};de(Jp,{ipns:()=>Wp,ipnsSelector:()=>hi,ipnsValidator:()=>pi});var wi=Symbol.for("@libp2p/peer-id");function aa(r){return r!=null&&!!r[wi]}var $=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var De=ht(ha(),1);var Bi={};de(Bi,{base32:()=>_t,base32hex:()=>Gf,base32hexpad:()=>Yf,base32hexpadupper:()=>Zf,base32hexupper:()=>jf,base32pad:()=>qf,base32padupper:()=>zf,base32upper:()=>ba,base32z:()=>Wf});var ng=new Uint8Array(0);function da(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 dt(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 pa(r){return new TextEncoder().encode(r)}function ga(r){return new TextDecoder().decode(r)}function Pf(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(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var h=0,p=0,b=0,k=m.length;b!==k&&m[b]===0;)b++,h++;for(var v=(k-b)*u+1>>>0,D=new Uint8Array(v);b!==k;){for(var S=m[b],I=0,N=v-1;(S!==0||I<p)&&N!==-1;N--,I++)S+=256*D[N]>>>0,D[N]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");p=I,b++}for(var y=v-p;y!==v&&D[y]===0;)y++;for(var C=c.repeat(h);y<v;++y)C+=r.charAt(D[y]);return C}function d(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var h=0;if(m[h]!==" "){for(var p=0,b=0;m[h]===c;)p++,h++;for(var k=(m.length-h)*f+1>>>0,v=new Uint8Array(k);m[h];){var D=t[m.charCodeAt(h)];if(D===255)return;for(var S=0,I=k-1;(D!==0||S<b)&&I!==-1;I--,S++)D+=a*v[I]>>>0,v[I]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");b=S,h++}if(m[h]!==" "){for(var N=k-b;N!==k&&v[N]===0;)N++;for(var y=new Uint8Array(p+(k-N)),C=p;N!==k;)y[C++]=v[N++];return y}}}function E(m){var h=d(m);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:d,decode:E}}var Mf=Pf,Hf=Mf,ya=Hf;var bi=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")}},xi=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 wa(this,e)}},Ei=class{decoders;constructor(e){this.decoders=e}or(e){return wa(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 wa(r,e){return new Ei({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var vi=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 bi(e,t,n),this.decoder=new xi(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 vi(r,e,t,n)}function Nt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=ya(t,r);return xr({prefix:e,name:r,encode:n,decode:i=>dt(o(i))})}function Kf(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 $f(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 se({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return xr({prefix:e,name:r,encode(o){return $f(o,n,t)},decode(o){return Kf(o,n,t,r)}})}var _t=se({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ba=se({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),qf=se({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),zf=se({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Gf=se({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),jf=se({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Yf=se({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zf=se({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Wf=se({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ai={};de(Ai,{base58btc:()=>we,base58flickr:()=>Jf});var we=Nt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Jf=Nt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Si={};de(Si,{base64:()=>en,base64pad:()=>Xf,base64url:()=>Qf,base64urlpad:()=>eh});var en=se({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Xf=se({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Qf=se({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),eh=se({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});De.default.formatters.b=r=>r==null?"undefined":we.baseEncode(r);De.default.formatters.t=r=>r==null?"undefined":_t.baseEncode(r);De.default.formatters.m=r=>r==null?"undefined":en.baseEncode(r);De.default.formatters.p=r=>r==null?"undefined":r.toString();De.default.formatters.c=r=>r==null?"undefined":r.toString();De.default.formatters.k=r=>r==null?"undefined":r.toString();De.default.formatters.a=r=>r==null?"undefined":r.toString();function th(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 Ut(r){let e=th(`${r}:trace`);return De.default.enabled(`${r}:trace`)&&De.default.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=(0,De.default)(`${r}:trace`)),Object.assign((0,De.default)(r),{error:(0,De.default)(`${r}:error`),trace:e})}var Ri={};de(Ri,{base10:()=>rh});var rh=Nt({prefix:"9",name:"base10",alphabet:"0123456789"});var ki={};de(ki,{base16:()=>nh,base16upper:()=>oh});var nh=se({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),oh=se({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ii={};de(Ii,{base2:()=>ih});var ih=se({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ti={};de(Ti,{base256emoji:()=>lh});var xa=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}"),sh=xa.reduce((r,e,t)=>(r[t]=e,r),[]),ah=xa.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function ch(r){return r.reduce((e,t)=>(e+=sh[t],e),"")}function uh(r){let e=[];for(let t of r){let n=ah[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var lh=xr({prefix:"\u{1F680}",name:"base256emoji",encode:ch,decode:uh});var Ci={};de(Ci,{base36:()=>Mn,base36upper:()=>fh});var Mn=Nt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),fh=Nt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ni={};de(Ni,{base8:()=>hh});var hh=se({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var _i={};de(_i,{identity:()=>dh});var dh=xr({prefix:"\0",name:"identity",encode:r=>ga(r),decode:r=>pa(r)});var Bg=new TextEncoder,Ag=new TextDecoder;var Di={};de(Di,{identity:()=>tt});var mh=Ba,Ea=128,yh=127,wh=~yh,bh=Math.pow(2,31);function Ba(r,e,t){e=e||[],t=t||0;for(var n=t;r>=bh;)e[t++]=r&255|Ea,r/=128;for(;r&wh;)e[t++]=r&255|Ea,r>>>=7;return e[t]=r|0,Ba.bytes=t-n+1,e}var xh=Ui,Eh=128,va=127;function Ui(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw Ui.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&va)<<o:(s&va)*Math.pow(2,o),o+=7}while(s>=Eh);return Ui.bytes=i-n,t}var vh=Math.pow(2,7),Bh=Math.pow(2,14),Ah=Math.pow(2,21),Sh=Math.pow(2,28),Rh=Math.pow(2,35),kh=Math.pow(2,42),Ih=Math.pow(2,49),Th=Math.pow(2,56),Ch=Math.pow(2,63),Nh=function(r){return r<vh?1:r<Bh?2:r<Ah?3:r<Sh?4:r<Rh?5:r<kh?6:r<Ih?7:r<Th?8:r<Ch?9:10},_h={encode:mh,decode:xh,encodingLength:Nh},Uh=_h,tn=Uh;function rn(r,e=0){return[tn.decode(r,e),tn.decode.bytes]}function Er(r,e,t=0){return tn.encode(r,e,t),e}function vr(r){return tn.encodingLength(r)}function et(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 rr(r){let e=dt(r),[t,n]=rn(e),[o,i]=rn(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 Aa(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&da(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 Sa=0,Dh="identity",Ra=dt;function Lh(r){return et(Sa,Ra(r))}var tt={code:Sa,name:Dh,encode:Ra,digest:Lh};var Oi={};de(Oi,{sha256:()=>be,sha512:()=>Vh});function Vi({name:r,code:e,encode:t}){return new Li(r,e,t)}var Li=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?et(this.code,t):t.then(n=>et(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Ia(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var be=Vi({name:"sha2-256",code:18,encode:Ia("SHA-256")}),Vh=Vi({name:"sha2-512",code:19,encode:Ia("SHA-512")});function Ta(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Fh(t,Fi(r),e??we.encoder);default:return Ph(t,Fi(r),e??_t.encoder)}}var Ca=new WeakMap;function Fi(r){let e=Ca.get(r);if(e==null){let t=new Map;return Ca.set(r,t),t}return e}var Re=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!==nn)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Mh)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=et(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&&Aa(e.multihash,n.multihash)}toString(e){return Ta(this,e)}toJSON(){return{"/":Ta(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??Na(n,o,i.bytes))}else if(t[Hh]===!0){let{version:n,multihash:o,code:i}=t,s=rr(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!==nn)throw new Error(`Version 0 CID must use dag-pb (code: ${nn}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Na(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,nn,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=dt(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]=rn(e.subarray(t));return t+=d,l},o=n(),i=nn;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]=Oh(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 Fi(i).set(n,e),i}};function Oh(r,e){switch(r[0]){case"Q":{let t=e??we;return[we.prefix,t.decode(`${we.prefix}${r}`)]}case we.prefix:{let t=e??we;return[we.prefix,t.decode(r)]}case _t.prefix:{let t=e??_t;return[_t.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 Fh(r,e,t){let{prefix:n}=t;if(n!==we.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 Ph(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 nn=112,Mh=18;function Na(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 Hh=Symbol.for("@ipld/js-cid/CID");var Ar={..._i,...Ii,...Ni,...Ri,...ki,...Bi,...Ci,...Ai,...Si,...Ti},zg={...Oi,...Di};function fe(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}var Kh=Symbol.for("nodejs.util.inspect.custom"),_a=Object.values(Ar).map(r=>r.decoder).reduce((r,e)=>r.or(e),Ar.identity.decoder),Ua=114,Pi=36,Mi=37,on=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()})`}[wi]=!0;toString(){return this.string==null&&(this.string=we.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Re.createV1(Ua,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return fe(this.multihash.bytes,e);if(typeof e=="string")return sn(e).equals(this);if(e?.multihash?.bytes!=null)return fe(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[Kh](){return`PeerId(${this.toString()})`}},Sr=class extends on{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Rr=class extends on{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},kr=class extends on{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function sn(r,e){if(e=e??_a,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=rr(we.decode(`z${r}`));return r.startsWith("12D")?new Rr({multihash:t}):r.startsWith("16U")?new kr({multihash:t}):new Sr({multihash:t})}return Hi(_a.decode(r))}function Hi(r){try{let e=rr(r);if(e.code===tt.code){if(e.digest.length===Pi)return new Rr({multihash:e});if(e.digest.length===Mi)return new kr({multihash:e})}if(e.code===be.code)return new Sr({multihash:e})}catch{return $h(Re.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function $h(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Ua)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===be.code)return new Sr({multihash:r.multihash});if(e.code===tt.code){if(e.digest.length===Pi)return new Rr({multihash:r.multihash});if(e.digest.length===Mi)return new kr({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function Da(r,e){return r.length===Pi?new Rr({multihash:et(tt.code,r),privateKey:e}):r.length===Mi?new kr({multihash:et(tt.code,r),privateKey:e}):new Sr({multihash:await be.digest(r),publicKey:r,privateKey:e})}var gs={};de(gs,{Ed25519PrivateKey:()=>lr,Ed25519PublicKey:()=>pn,generateKeyPair:()=>f0,generateKeyPairFromSeed:()=>vc,unmarshalEd25519PrivateKey:()=>u0,unmarshalEd25519PublicKey:()=>l0});function Ki(r=0){return new Uint8Array(r)}function rt(r=0){return new Uint8Array(r)}function or(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=rt(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function Va(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var La=Va("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),$i=Va("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=rt(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),qh={utf8:La,"utf-8":La,hex:Ar.base16,latin1:$i,ascii:$i,binary:$i,...Ar},Kn=qh;function J(r,e="utf8"){let t=Kn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function He(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Ir(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function zh(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Tr(r,...e){if(!zh(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 $n(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ir(r.outputLen),Ir(r.blockLen)}function Cr(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 Oa(r,e){Tr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var qn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var _r=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Ge=(r,e)=>r<<32-e|r>>>e;var xm=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var Gh=async()=>{};async function Fa(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 Gh(),n+=i)}}function Pa(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Dt(r){return typeof r=="string"&&(r=Pa(r)),Tr(r),r}function qi(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];Tr(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 Nr=class{clone(){return this._cloneInto()}},jh={}.toString;function Ma(r,e){if(e!==void 0&&jh.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function zn(r){let e=n=>r().update(Dt(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Ur(r=32){if(qn&&typeof qn.getRandomValues=="function")return qn.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function Yh(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 Ha=(r,e,t)=>r&e^~r&t,Ka=(r,e,t)=>r&e^r&t^e&t,Dr=class extends Nr{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=_r(this.buffer)}update(e){Cr(this);let{view:t,buffer:n,blockLen:o}=this;e=Dt(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=_r(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){Cr(this),Oa(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;Yh(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=_r(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 Gn=BigInt(4294967295),zi=BigInt(32);function $a(r,e=!1){return e?{h:Number(r&Gn),l:Number(r>>zi&Gn)}:{h:Number(r>>zi&Gn)|0,l:Number(r&Gn)|0}}function Zh(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}=$a(r[o],e);[t[o],n[o]]=[i,s]}return[t,n]}var Wh=(r,e)=>BigInt(r>>>0)<<zi|BigInt(e>>>0),Jh=(r,e,t)=>r>>>t,Xh=(r,e,t)=>r<<32-t|e>>>t,Qh=(r,e,t)=>r>>>t|e<<32-t,ed=(r,e,t)=>r<<32-t|e>>>t,td=(r,e,t)=>r<<64-t|e>>>t-32,rd=(r,e,t)=>r>>>t-32|e<<64-t,nd=(r,e)=>e,od=(r,e)=>r,id=(r,e,t)=>r<<t|e>>>32-t,sd=(r,e,t)=>e<<t|r>>>32-t,ad=(r,e,t)=>e<<t-32|r>>>64-t,cd=(r,e,t)=>r<<t-32|e>>>64-t;function ud(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var ld=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),fd=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,hd=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),dd=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,pd=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),gd=(r,e,t,n,o,i)=>e+t+n+o+i+(r/2**32|0)|0;var md={fromBig:$a,split:Zh,toBig:Wh,shrSH:Jh,shrSL:Xh,rotrSH:Qh,rotrSL:ed,rotrBH:td,rotrBL:rd,rotr32H:nd,rotr32L:od,rotlSH:id,rotlSL:sd,rotlBH:ad,rotlBL:cd,add:ud,add3L:ld,add3H:fd,add4L:hd,add4H:dd,add5H:gd,add5L:pd},q=md;var[yd,wd]=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))),Lt=new Uint32Array(80),Vt=new Uint32Array(80),Gi=class extends Dr{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:E,Gl:m,Hh:h,Hl:p}=this;return[e,t,n,o,i,s,a,c,f,u,l,d,E,m,h,p]}set(e,t,n,o,i,s,a,c,f,u,l,d,E,m,h,p){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=E|0,this.Gl=m|0,this.Hh=h|0,this.Hl=p|0}process(e,t){for(let v=0;v<16;v++,t+=4)Lt[v]=e.getUint32(t),Vt[v]=e.getUint32(t+=4);for(let v=16;v<80;v++){let D=Lt[v-15]|0,S=Vt[v-15]|0,I=q.rotrSH(D,S,1)^q.rotrSH(D,S,8)^q.shrSH(D,S,7),N=q.rotrSL(D,S,1)^q.rotrSL(D,S,8)^q.shrSL(D,S,7),y=Lt[v-2]|0,C=Vt[v-2]|0,V=q.rotrSH(y,C,19)^q.rotrBH(y,C,61)^q.shrSH(y,C,6),T=q.rotrSL(y,C,19)^q.rotrBL(y,C,61)^q.shrSL(y,C,6),O=q.add4L(N,T,Vt[v-7],Vt[v-16]),M=q.add4H(O,I,V,Lt[v-7],Lt[v-16]);Lt[v]=M|0,Vt[v]=O|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:d,Fh:E,Fl:m,Gh:h,Gl:p,Hh:b,Hl:k}=this;for(let v=0;v<80;v++){let D=q.rotrSH(l,d,14)^q.rotrSH(l,d,18)^q.rotrBH(l,d,41),S=q.rotrSL(l,d,14)^q.rotrSL(l,d,18)^q.rotrBL(l,d,41),I=l&E^~l&h,N=d&m^~d&p,y=q.add5L(k,S,N,wd[v],Vt[v]),C=q.add5H(y,b,D,I,yd[v],Lt[v]),V=y|0,T=q.rotrSH(n,o,28)^q.rotrBH(n,o,34)^q.rotrBH(n,o,39),O=q.rotrSL(n,o,28)^q.rotrBL(n,o,34)^q.rotrBL(n,o,39),M=n&i^n&a^i&a,Z=o&s^o&c^s&c;b=h|0,k=p|0,h=E|0,p=m|0,E=l|0,m=d|0,{h:l,l:d}=q.add(f|0,u|0,C|0,V|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let x=q.add3L(V,O,Z);n=q.add3H(x,C,T,M),o=x|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:E,l:m}=q.add(this.Fh|0,this.Fl|0,E|0,m|0),{h,l:p}=q.add(this.Gh|0,this.Gl|0,h|0,p|0),{h:b,l:k}=q.add(this.Hh|0,this.Hl|0,b|0,k|0),this.set(n,o,i,s,a,c,f,u,l,d,E,m,h,p,b,k)}roundClean(){Lt.fill(0),Vt.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 an=zn(()=>new Gi);var Yn={};de(Yn,{abytes:()=>Lr,bitGet:()=>Sd,bitLen:()=>Ad,bitMask:()=>cn,bitSet:()=>Rd,bytesToHex:()=>gt,bytesToNumberBE:()=>mt,bytesToNumberLE:()=>Ft,concatBytes:()=>yt,createHmacDrbg:()=>Zi,ensureBytes:()=>ae,equalBytes:()=>vd,hexToBytes:()=>ir,hexToNumber:()=>Yi,isBytes:()=>Ot,numberToBytesBE:()=>Pt,numberToBytesLE:()=>sr,numberToHexUnpadded:()=>ja,numberToVarBytesBE:()=>Ed,utf8ToBytes:()=>Bd,validateObject:()=>nt});var Ga=BigInt(0),jn=BigInt(1),bd=BigInt(2);function Ot(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Lr(r){if(!Ot(r))throw new Error("Uint8Array expected")}var xd=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function gt(r){Lr(r);let e="";for(let t=0;t<r.length;t++)e+=xd[r[t]];return e}function ja(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function Yi(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var pt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function qa(r){if(r>=pt._0&&r<=pt._9)return r-pt._0;if(r>=pt._A&&r<=pt._F)return r-(pt._A-10);if(r>=pt._a&&r<=pt._f)return r-(pt._a-10)}function ir(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=qa(r.charCodeAt(i)),a=qa(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 mt(r){return Yi(gt(r))}function Ft(r){return Lr(r),Yi(gt(Uint8Array.from(r).reverse()))}function Pt(r,e){return ir(r.toString(16).padStart(e*2,"0"))}function sr(r,e){return Pt(r,e).reverse()}function Ed(r){return ir(ja(r))}function ae(r,e,t){let n;if(typeof e=="string")try{n=ir(e)}catch(i){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${i}`)}else if(Ot(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 yt(...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}function vd(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 Bd(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Ad(r){let e;for(e=0;r>Ga;r>>=jn,e+=1);return e}function Sd(r,e){return r>>BigInt(e)&jn}function Rd(r,e,t){return r|(t?jn:Ga)<<BigInt(e)}var cn=r=>(bd<<BigInt(r-1))-jn,ji=r=>new Uint8Array(r),za=r=>Uint8Array.from(r);function Zi(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=ji(r),o=ji(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>t(o,n,...l),c=(l=ji())=>{o=a(za([0]),l),n=a(),l.length!==0&&(o=a(za([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 E=n.slice();d.push(E),l+=n.length}return yt(...d)};return(l,d)=>{s(),c(l);let E;for(;!(E=d(f()));)c();return s(),E}}var kd={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"||Ot(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 nt(r,e,t={}){let n=(o,i,s)=>{let a=kd[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 he=BigInt(0),te=BigInt(1),ar=BigInt(2),Id=BigInt(3),Wi=BigInt(4),Ya=BigInt(5),Za=BigInt(8),Td=BigInt(9),Cd=BigInt(16);function ee(r,e){let t=r%e;return t>=he?t:e+t}function Nd(r,e,t){if(t<=he||e<he)throw new Error("Expected power/modulo > 0");if(t===te)return he;let n=te;for(;e>he;)e&te&&(n=n*r%t),r=r*r%t,e>>=te;return n}function re(r,e,t){let n=r;for(;e-- >he;)n*=n,n%=t;return n}function Zn(r,e){if(r===he||e<=he)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=ee(r,e),n=e,o=he,i=te,s=te,a=he;for(;t!==he;){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 ee(o,e)}function _d(r){let e=(r-te)/ar,t,n,o;for(t=r-te,n=0;t%ar===he;t/=ar,n++);for(o=ar;o<r&&Nd(o,e,r)!==r-te;o++);if(n===1){let s=(r+te)/Wi;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)/ar;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 E=1;for(let h=a.sqr(d);E<f&&!a.eql(h,a.ONE);E++)h=a.sqr(h);let m=a.pow(u,te<<BigInt(f-E-1));u=a.sqr(m),l=a.mul(l,m),d=a.mul(d,u),f=E}return l}}function Ud(r){if(r%Wi===Id){let e=(r+te)/Wi;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%Za===Ya){let e=(r-Ya)/Za;return function(n,o){let i=n.mul(o,ar),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,ar),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%Cd,_d(r)}var Wa=(r,e)=>(ee(r,e)&te)===te,Dd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ji(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Dd.reduce((n,o)=>(n[o]="function",n),e);return nt(r,t)}function Ld(r,e,t){if(t<he)throw new Error("Expected power > 0");if(t===he)return r.ONE;if(t===te)return e;let n=r.ONE,o=e;for(;t>he;)t&te&&(n=r.mul(n,o)),o=r.sqr(o),t>>=te;return n}function Vd(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 Xi(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Wn(r,e,t=!1,n={}){if(r<=he)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:i}=Xi(r,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=Ud(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:cn(o),ZERO:he,ONE:te,create:c=>ee(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return he<=c&&c<r},is0:c=>c===he,isOdd:c=>(c&te)===te,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)=>Ld(a,c,f),div:(c,f)=>ee(c*Zn(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Zn(c,r),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>Vd(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>t?sr(c,i):Pt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return t?Ft(c):mt(c)}});return Object.freeze(a)}function Ja(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 Qi(r){let e=Ja(r);return e+Math.ceil(e/2)}function Xa(r,e,t=!1){let n=r.length,o=Ja(e),i=Qi(e);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=t?mt(r):Ft(r),a=ee(s,e-te)+te;return t?sr(a,o):Pt(a,o)}var Fd=BigInt(0),es=BigInt(1);function Jn(r,e){let t=(o,i)=>{let s=i.negate();return o?s:i},n=o=>{let i=Math.ceil(e/o)+1,s=2**(o-1);return{windows:i,windowSize:s}};return{constTimeNegate:t,unsafeLadder(o,i){let s=r.ZERO,a=o;for(;i>Fd;)i&es&&(s=s.add(a)),a=a.double(),i>>=es;return s},precomputeWindow(o,i){let{windows:s,windowSize:a}=n(i),c=[],f=o,u=f;for(let l=0;l<s;l++){u=f,c.push(u);for(let d=1;d<a;d++)u=u.add(f),c.push(u);f=u.double()}return c},wNAF(o,i,s){let{windows:a,windowSize:c}=n(o),f=r.ZERO,u=r.BASE,l=BigInt(2**o-1),d=2**o,E=BigInt(o);for(let m=0;m<a;m++){let h=m*c,p=Number(s&l);s>>=E,p>c&&(p-=d,s+=es);let b=h,k=h+Math.abs(p)-1,v=m%2!==0,D=p<0;p===0?u=u.add(t(v,i[b])):f=f.add(t(D,i[k]))}return{p:f,f:u}},wNAFCached(o,i,s,a){let c=o._WINDOW_SIZE||1,f=i.get(o);return f||(f=this.precomputeWindow(o,c),c!==1&&i.set(o,a(f))),this.wNAF(c,f,s)}}}function un(r){return Ji(r.Fp),nt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Xi(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var je=BigInt(0),Le=BigInt(1),Xn=BigInt(2),Pd=BigInt(8),Md={zip215:!0};function Hd(r){let e=un(r);return nt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Qa(r){let e=Hd(r),{Fp:t,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=e,f=Xn<<BigInt(a*8)-Le,u=t.create,l=e.uvRatio||((B,w)=>{try{return{isValid:!0,value:t.sqrt(B*t.inv(w))}}catch{return{isValid:!1,value:je}}}),d=e.adjustScalarBytes||(B=>B),E=e.domain||((B,w,L)=>{if(w.length||L)throw new Error("Contexts/pre-hash are not supported");return B}),m=B=>typeof B=="bigint"&&je<B,h=(B,w)=>m(B)&&m(w)&&B<w,p=B=>B===je||h(B,f);function b(B,w){if(h(B,w))return B;throw new Error(`Expected valid scalar < ${w}, got ${typeof B} ${B}`)}function k(B){return B===je?B:b(B,n)}let v=new Map;function D(B){if(!(B instanceof S))throw new Error("ExtendedPoint expected")}class S{constructor(w,L,F,H){if(this.ex=w,this.ey=L,this.ez=F,this.et=H,!p(w))throw new Error("x required");if(!p(L))throw new Error("y required");if(!p(F))throw new Error("z required");if(!p(H))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(w){if(w instanceof S)throw new Error("extended point not allowed");let{x:L,y:F}=w||{};if(!p(L)||!p(F))throw new Error("invalid affine point");return new S(L,F,Le,u(L*F))}static normalizeZ(w){let L=t.invertBatch(w.map(F=>F.ez));return w.map((F,H)=>F.toAffine(L[H])).map(S.fromAffine)}_setWindowSize(w){this._WINDOW_SIZE=w,v.delete(this)}assertValidity(){let{a:w,d:L}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:F,ey:H,ez:z,et:G}=this,Q=u(F*F),Y=u(H*H),W=u(z*z),ce=u(W*W),ie=u(Q*w),me=u(W*u(ie+Y)),ye=u(ce+u(L*u(Q*Y)));if(me!==ye)throw new Error("bad point: equation left != right (1)");let le=u(F*H),Be=u(z*G);if(le!==Be)throw new Error("bad point: equation left != right (2)")}equals(w){D(w);let{ex:L,ey:F,ez:H}=this,{ex:z,ey:G,ez:Q}=w,Y=u(L*Q),W=u(z*H),ce=u(F*Q),ie=u(G*H);return Y===W&&ce===ie}is0(){return this.equals(S.ZERO)}negate(){return new S(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:w}=e,{ex:L,ey:F,ez:H}=this,z=u(L*L),G=u(F*F),Q=u(Xn*u(H*H)),Y=u(w*z),W=L+F,ce=u(u(W*W)-z-G),ie=Y+G,me=ie-Q,ye=Y-G,le=u(ce*me),Be=u(ie*ye),ft=u(ce*ye),Qt=u(me*ie);return new S(le,Be,Qt,ft)}add(w){D(w);let{a:L,d:F}=e,{ex:H,ey:z,ez:G,et:Q}=this,{ex:Y,ey:W,ez:ce,et:ie}=w;if(L===BigInt(-1)){let Qs=u((z-H)*(W+Y)),ea=u((z+H)*(W-Y)),yi=u(ea-Qs);if(yi===je)return this.double();let ta=u(G*Xn*ie),ra=u(Q*Xn*ce),na=ra+ta,oa=ea+Qs,ia=ra-ta,yf=u(na*yi),wf=u(oa*ia),bf=u(na*ia),xf=u(yi*oa);return new S(yf,wf,xf,bf)}let me=u(H*Y),ye=u(z*W),le=u(Q*F*ie),Be=u(G*ce),ft=u((H+z)*(Y+W)-me-ye),Qt=Be-le,Qr=Be+le,Xs=u(ye-L*me),df=u(ft*Qt),pf=u(Qr*Xs),gf=u(ft*Xs),mf=u(Qt*Qr);return new S(df,pf,mf,gf)}subtract(w){return this.add(w.negate())}wNAF(w){return y.wNAFCached(this,v,w,S.normalizeZ)}multiply(w){let{p:L,f:F}=this.wNAF(b(w,n));return S.normalizeZ([L,F])[0]}multiplyUnsafe(w){let L=k(w);return L===je?N:this.equals(N)||L===Le?this:this.equals(I)?this.wNAF(L).p:y.unsafeLadder(this,L)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return y.unsafeLadder(this,n).is0()}toAffine(w){let{ex:L,ey:F,ez:H}=this,z=this.is0();w==null&&(w=z?Pd:t.inv(H));let G=u(L*w),Q=u(F*w),Y=u(H*w);if(z)return{x:je,y:Le};if(Y!==Le)throw new Error("invZ was invalid");return{x:G,y:Q}}clearCofactor(){let{h:w}=e;return w===Le?this:this.multiplyUnsafe(w)}static fromHex(w,L=!1){let{d:F,a:H}=e,z=t.BYTES;w=ae("pointHex",w,z);let G=w.slice(),Q=w[z-1];G[z-1]=Q&-129;let Y=Ft(G);Y===je||(L?b(Y,f):b(Y,t.ORDER));let W=u(Y*Y),ce=u(W-Le),ie=u(F*W-H),{isValid:me,value:ye}=l(ce,ie);if(!me)throw new Error("Point.fromHex: invalid y coordinate");let le=(ye&Le)===Le,Be=(Q&128)!==0;if(!L&&ye===je&&Be)throw new Error("Point.fromHex: x=0 and x_0=1");return Be!==le&&(ye=u(-ye)),S.fromAffine({x:ye,y:Y})}static fromPrivateKey(w){return T(w).point}toRawBytes(){let{x:w,y:L}=this.toAffine(),F=sr(L,t.BYTES);return F[F.length-1]|=w&Le?128:0,F}toHex(){return gt(this.toRawBytes())}}S.BASE=new S(e.Gx,e.Gy,Le,u(e.Gx*e.Gy)),S.ZERO=new S(je,Le,Le,je);let{BASE:I,ZERO:N}=S,y=Jn(S,a*8);function C(B){return ee(B,n)}function V(B){return C(Ft(B))}function T(B){let w=a;B=ae("private key",B,w);let L=ae("hashed private key",i(B),2*w),F=d(L.slice(0,w)),H=L.slice(w,2*w),z=V(F),G=I.multiply(z),Q=G.toRawBytes();return{head:F,prefix:H,scalar:z,point:G,pointBytes:Q}}function O(B){return T(B).pointBytes}function M(B=new Uint8Array,...w){let L=yt(...w);return V(i(E(L,ae("context",B),!!o)))}function Z(B,w,L={}){B=ae("message",B),o&&(B=o(B));let{prefix:F,scalar:H,pointBytes:z}=T(w),G=M(L.context,F,B),Q=I.multiply(G).toRawBytes(),Y=M(L.context,Q,z,B),W=C(G+Y*H);k(W);let ce=yt(Q,sr(W,t.BYTES));return ae("result",ce,a*2)}let x=Md;function A(B,w,L,F=x){let{context:H,zip215:z}=F,G=t.BYTES;B=ae("signature",B,2*G),w=ae("message",w),o&&(w=o(w));let Q=Ft(B.slice(G,2*G)),Y,W,ce;try{Y=S.fromHex(L,z),W=S.fromHex(B.slice(0,G),z),ce=I.multiplyUnsafe(Q)}catch{return!1}if(!z&&Y.isSmallOrder())return!1;let ie=M(H,W.toRawBytes(),Y.toRawBytes(),w);return W.add(Y.multiplyUnsafe(ie)).subtract(ce).clearCofactor().equals(S.ZERO)}return I._setWindowSize(8),{CURVE:e,getPublicKey:O,sign:Z,verify:A,ExtendedPoint:S,utils:{getExtendedPublicKey:T,randomPrivateKey:()=>s(t.BYTES),precompute(B=8,w=S.BASE){return w._setWindowSize(B),w.multiply(BigInt(3)),w}}}}var ts=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ec=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),$m=BigInt(0),Kd=BigInt(1),tc=BigInt(2),qm=BigInt(3),$d=BigInt(5),qd=BigInt(8);function zd(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),o=BigInt(80),i=ts,a=r*r%i*r%i,c=re(a,tc,i)*a%i,f=re(c,Kd,i)*r%i,u=re(f,$d,i)*f%i,l=re(u,e,i)*u%i,d=re(l,t,i)*l%i,E=re(d,n,i)*d%i,m=re(E,o,i)*E%i,h=re(m,o,i)*E%i,p=re(h,e,i)*u%i;return{pow_p_5_8:re(p,tc,i)*r%i,b2:a}}function Gd(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function jd(r,e){let t=ts,n=ee(e*e*e,t),o=ee(n*n*e,t),i=zd(r*o).pow_p_5_8,s=ee(r*n*i,t),a=ee(e*s*s,t),c=s,f=ee(s*ec,t),u=a===r,l=a===ee(-r,t),d=a===ee(-r*ec,t);return u&&(s=c),(l||d)&&(s=f),Wa(s,t)&&(s=ee(-s,t)),{isValid:u||l,value:s}}var Yd=Wn(ts,void 0,!0),Zd={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Yd,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:qd,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:an,randomBytes:Ur,adjustScalarBytes:Gd,uvRatio:jd},Vr=Qa(Zd);var Or=32,wt=64,Qn=32;function rc(){let r=Vr.utils.randomPrivateKey(),e=Vr.getPublicKey(r);return{privateKey:sc(r,e),publicKey:e}}function nc(r){if(r.length!==Qn)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=Vr.getPublicKey(e);return{privateKey:sc(e,t),publicKey:t}}function oc(r,e){let t=r.subarray(0,Qn);return Vr.sign(e instanceof Uint8Array?e:e.subarray(),t)}function ic(r,e,t){return Vr.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function sc(r,e){let t=new Uint8Array(wt);for(let n=0;n<Qn;n++)t[n]=r[n],t[Qn+n]=e[n];return t}var ke={get(r=globalThis){let e=r.crypto;if(e==null||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 rs={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function ac(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=ke.get();t*=8;async function c(l,d){let E=a.getRandomValues(new Uint8Array(i)),m=a.getRandomValues(new Uint8Array(n)),h={name:e,iv:m};typeof d=="string"&&(d=J(d));let p;if(d.length===0){p=await a.subtle.importKey("jwk",rs,{name:"AES-GCM"},!0,["encrypt"]);try{let k={name:"PBKDF2",salt:E,iterations:s,hash:{name:o}},v=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);p=await a.subtle.deriveKey(k,v,{name:e,length:t},!0,["encrypt"])}catch{p=await a.subtle.importKey("jwk",rs,{name:"AES-GCM"},!0,["encrypt"])}}else{let k={name:"PBKDF2",salt:E,iterations:s,hash:{name:o}},v=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);p=await a.subtle.deriveKey(k,v,{name:e,length:t},!0,["encrypt"])}let b=await a.subtle.encrypt(h,p,l);return or([E,h.iv,new Uint8Array(b)])}async function f(l,d){let E=l.subarray(0,i),m=l.subarray(i,i+n),h=l.subarray(i+n),p={name:e,iv:m};typeof d=="string"&&(d=J(d));let b;if(d.length===0)try{let v={name:"PBKDF2",salt:E,iterations:s,hash:{name:o}},D=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);b=await a.subtle.deriveKey(v,D,{name:e,length:t},!0,["decrypt"])}catch{b=await a.subtle.importKey("jwk",rs,{name:"AES-GCM"},!0,["decrypt"])}else{let v={name:"PBKDF2",salt:E,iterations:s,hash:{name:o}},D=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);b=await a.subtle.deriveKey(v,D,{name:e,length:t},!0,["decrypt"])}let k=await a.subtle.decrypt(p,b,h);return new Uint8Array(k)}return{encrypt:c,decrypt:f}}async function Fr(r,e){let n=await ac().encrypt(r,e);return en.encode(n)}var Xd=Math.pow(2,7),Qd=Math.pow(2,14),e0=Math.pow(2,21),cc=Math.pow(2,28),uc=Math.pow(2,35),lc=Math.pow(2,42),fc=Math.pow(2,49),Ie=128,Mt=127;function ln(r){if(r<Xd)return 1;if(r<Qd)return 2;if(r<e0)return 3;if(r<cc)return 4;if(r<uc)return 5;if(r<lc)return 6;if(r<fc)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function hc(r,e,t=0){switch(ln(r)){case 8:e[t++]=r&255|Ie,r/=128;case 7:e[t++]=r&255|Ie,r/=128;case 6:e[t++]=r&255|Ie,r/=128;case 5:e[t++]=r&255|Ie,r/=128;case 4:e[t++]=r&255|Ie,r>>>=7;case 3:e[t++]=r&255|Ie,r>>>=7;case 2:e[t++]=r&255|Ie,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function dc(r,e){let t=r[e],n=0;if(n+=t&Mt,t<Ie||(t=r[e+1],n+=(t&Mt)<<7,t<Ie)||(t=r[e+2],n+=(t&Mt)<<14,t<Ie)||(t=r[e+3],n+=(t&Mt)<<21,t<Ie)||(t=r[e+4],n+=(t&Mt)*cc,t<Ie)||(t=r[e+5],n+=(t&Mt)*uc,t<Ie)||(t=r[e+6],n+=(t&Mt)*lc,t<Ie)||(t=r[e+7],n+=(t&Mt)*fc,t<Ie))return n;throw new RangeError("Could not decode varint")}var ns=new Float32Array([-0]),Ht=new Uint8Array(ns.buffer);function pc(r,e,t){ns[0]=r,e[t]=Ht[0],e[t+1]=Ht[1],e[t+2]=Ht[2],e[t+3]=Ht[3]}function gc(r,e){return Ht[0]=r[e],Ht[1]=r[e+1],Ht[2]=r[e+2],Ht[3]=r[e+3],ns[0]}var os=new Float64Array([-0]),Ae=new Uint8Array(os.buffer);function mc(r,e,t){os[0]=r,e[t]=Ae[0],e[t+1]=Ae[1],e[t+2]=Ae[2],e[t+3]=Ae[3],e[t+4]=Ae[4],e[t+5]=Ae[5],e[t+6]=Ae[6],e[t+7]=Ae[7]}function yc(r,e){return Ae[0]=r[e],Ae[1]=r[e+1],Ae[2]=r[e+2],Ae[3]=r[e+3],Ae[4]=r[e+4],Ae[5]=r[e+5],Ae[6]=r[e+6],Ae[7]=r[e+7],os[0]}var t0=BigInt(Number.MAX_SAFE_INTEGER),r0=BigInt(Number.MIN_SAFE_INTEGER),Ve=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 cr;if(e<t0&&e>r0)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>wc&&(o=0n,++n>wc&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return cr;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):cr}},cr=new Ve(0,0);cr.toBigInt=function(){return 0n};cr.zzEncode=cr.zzDecode=function(){return this};cr.length=function(){return 1};var wc=4294967296n;function bc(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 xc(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 is(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 Ye(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function eo(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var ss=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,Ye(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 Ye(this,4);return eo(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ye(this,4);return eo(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Ye(this,4);let e=gc(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Ye(this,4);let e=yc(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 Ye(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return xc(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Ye(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Ye(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 Ve(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 Ye(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 Ye(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 Ye(this,8);let e=eo(this.buf,this.pos+=4),t=eo(this.buf,this.pos+=4);return new Ve(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=dc(this.buf,this.pos);return this.pos+=ln(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 as(r){return new ss(r instanceof Uint8Array?r:r.subarray())}function Kt(r,e,t){let n=as(r);return e.decode(n,void 0,t)}function cs(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return rt(s);o+s>e&&(n=rt(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var ur=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function us(){}var fs=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},n0=cs();function o0(r){return globalThis.Buffer!=null?rt(r):n0(r)}var hn=class{len;head;tail;states;constructor(){this.len=0,this.head=new ur(us,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new ur(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new hs((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(to,10,Ve.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Ve.fromBigInt(e);return this._push(to,t.length(),t)}uint64Number(e){return this._push(hc,ln(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=Ve.fromBigInt(e).zzEncode();return this._push(to,t.length(),t)}sint64Number(e){let t=Ve.fromNumber(e).zzEncode();return this._push(to,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(ls,1,e?1:0)}fixed32(e){return this._push(fn,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Ve.fromBigInt(e);return this._push(fn,4,t.lo)._push(fn,4,t.hi)}fixed64Number(e){let t=Ve.fromNumber(e);return this._push(fn,4,t.lo)._push(fn,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(pc,4,e)}double(e){return this._push(mc,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(ls,1,0):this.uint32(t)._push(s0,t,e)}string(e){let t=bc(e);return t!==0?this.uint32(t)._push(is,t,e):this._push(ls,1,0)}fork(){return this.states=new fs(this),this.head=this.tail=new ur(us,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 ur(us,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=o0(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function ls(r,e,t){e[t]=r&255}function i0(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var hs=class extends ur{next;constructor(e,t){super(i0,e,t),this.next=void 0}};function to(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 fn(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 s0(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(hn.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(a0,e,r),this},hn.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(c0,e,r),this});function a0(r,e,t){e.set(r,t)}function c0(r,e,t){r.length<40?is(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(J(r),t)}function ds(){return new hn}function $t(r,e){let t=ds();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var Pr;(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"})(Pr||(Pr={}));function ro(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function dn(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 ro("enum",Pr.VARINT,t,n)}function qt(r,e){return ro("message",Pr.LENGTH_DELIMITED,r,e)}var ne;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(ne||(ne={}));var ps;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(ps||(ps={}));(function(r){r.codec=()=>dn(ps)})(ne||(ne={}));var ot;(function(r){let e;r.codec=()=>(e==null&&(e=qt((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ne.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=ne.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(s&7);break}}return o})),e),r.encode=t=>$t(t,r.codec()),r.decode=t=>Kt(t,r.codec())})(ot||(ot={}));var it;(function(r){let e;r.codec=()=>(e==null&&(e=qt((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ne.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=ne.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(s&7);break}}return o})),e),r.encode=t=>$t(t,r.codec()),r.decode=t=>Kt(t,r.codec())})(it||(it={}));var pn=class{_key;constructor(e){this._key=Mr(e,Or)}verify(e,t){return ic(this._key,t,e)}marshal(){return this._key}get bytes(){return ot.encode({Type:ne.Ed25519,Data:this.marshal()}).subarray()}equals(e){return fe(this.bytes,e.bytes)}hash(){let e=be.digest(this.bytes);return He(e)?e.then(({bytes:t})=>t):e.bytes}},lr=class{_key;_publicKey;constructor(e,t){this._key=Mr(e,wt),this._publicKey=Mr(t,Or)}sign(e){return oc(this._key,e)}get public(){return new pn(this._publicKey)}marshal(){return this._key}get bytes(){return it.encode({Type:ne.Ed25519,Data:this.marshal()}).subarray()}equals(e){return fe(this.bytes,e.bytes)}async hash(){let e=be.digest(this.bytes),t;return He(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=tt.digest(this.public.bytes);return we.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return Fr(this.bytes,e);throw new $(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function u0(r){if(r.length>wt){r=Mr(r,wt+Or);let n=r.subarray(0,wt),o=r.subarray(wt,r.length);return new lr(n,o)}r=Mr(r,wt);let e=r.subarray(0,wt),t=r.subarray(Or);return new lr(e,t)}function l0(r){return r=Mr(r,Or),new pn(r)}async function f0(){let{privateKey:r,publicKey:e}=rc();return new lr(r,e)}async function vc(r){let{privateKey:e,publicKey:t}=nc(r);return new lr(e,t)}function Mr(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new $(`Key must be a Uint8Array of length ${e}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}function oe(r,e="utf8"){let t=Kn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var Ss={};de(Ss,{MAX_RSA_KEY_SIZE:()=>Rn,RsaPrivateKey:()=>zr,RsaPublicKey:()=>Sn,fromJwk:()=>F0,generateKeyPair:()=>P0,unmarshalRsaPrivateKey:()=>Bs,unmarshalRsaPublicKey:()=>O0});function fr(r){if(isNaN(r)||r<=0)throw new $("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Ur(r)}var Yt={};de(Yt,{exportToPem:()=>_0,importFromPem:()=>U0,jwkToPkcs1:()=>I0,jwkToPkix:()=>C0,pkcs1ToJwk:()=>k0,pkixToJwk:()=>T0});var oo=class extends Nr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,$n(e);let n=Dt(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 Cr(this),this.iHash.update(e),this}digestInto(e){Cr(this),Tr(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()}},gn=(r,e,t)=>new oo(r,e).update(t).digest();gn.create=(r,e)=>new oo(r,e);function h0(r,e,t,n){$n(r);let o=Ma({dkLen:32,asyncTick:10},n),{c:i,dkLen:s,asyncTick:a}=o;if(Ir(i),Ir(s),Ir(a),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=Dt(e),f=Dt(t),u=new Uint8Array(s),l=gn.create(r,c),d=l._cloneInto().update(f);return{c:i,dkLen:s,asyncTick:a,DK:u,PRF:l,PRFSalt:d}}function d0(r,e,t,n,o){return r.destroy(),e.destroy(),n&&n.destroy(),o.fill(0),t}async function ms(r,e,t,n){let{c:o,dkLen:i,asyncTick:s,DK:a,PRF:c,PRFSalt:f}=h0(r,e,t,n),u,l=new Uint8Array(4),d=_r(l),E=new Uint8Array(c.outputLen);for(let m=1,h=0;h<i;m++,h+=c.outputLen){let p=a.subarray(h,h+c.outputLen);d.setInt32(0,m,!1),(u=f._cloneInto(u)).update(l).digestInto(E),p.set(E.subarray(0,p.length)),await Fa(o-1,s,()=>{c._cloneInto(u).update(E).digestInto(E);for(let b=0;b<p.length;b++)p[b]^=E[b]})}return d0(c,f,a,u,E)}var j=ht(Bc());function hr(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 zt(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 ws(){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=hr(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,hr(i,8)-n}function Ac(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=zt(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=zt(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 Sc(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 Ne(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 Qy=Math.log(2);function co(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function bs(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 Bt(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 yn=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return bs(this.items)}},mn=[new Uint8Array([1])],Rc="0123456789";var $r="",We=new ArrayBuffer(0),xs=new Uint8Array(0),wn="EndOfContent",Ic="OCTET STRING",Tc="BIT STRING";function At(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?j.BufferSourceConverter.toUint8Array(i.valueHex):xs}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(!Bt(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",We)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:j.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var xt=class{constructor({blockLength:e=0,error:t=$r,warnings:n=[],valueBeforeDecode:o=xs}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=j.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:j.Convert.ToHex(this.valueBeforeDecodeView)}}};xt.NAME="baseBlock";var Se=class extends xt{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'")}};Se.NAME="valueBlock";var uo=class extends At(xt){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?j.BufferSourceConverter.toUint8Array(e.valueHex):xs,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",We}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=zt(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=j.BufferSourceConverter.toUint8Array(e);if(!Bt(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 E=0;E<f.length;E++)d[E]=f[E];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=hr(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}}};uo.NAME="identificationBlock";var lo=class extends xt{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=j.BufferSourceConverter.toUint8Array(e);if(!Bt(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=hr(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=zt(this.length,8);if(o.byteLength>127)return this.error="Too big length",We;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}}};lo.NAME="lengthBlock";var _={},xe=class extends xt{constructor({name:e=$r,optional:t=!1,primitiveSchema:n,...o}={},i){super(o),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new uo(o),this.lenBlock=new lo(o),this.valueBlock=i?new i(o):new Se(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 yn;t||Cc(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?We: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():j.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${j.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 Sc(t,n)}};xe.NAME="BaseBlock";function Cc(r){if(r instanceof _.Constructed)for(let e of r.valueBlock.value)Cc(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var fo=class extends xe{constructor({value:e=$r,...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}'`}};fo.NAME="BaseStringBlock";var ho=class extends At(Se){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};ho.NAME="PrimitiveValueBlock";var Nc,po=class extends xe{constructor(e={}){super(e,ho),this.idBlock.isConstructed=!1}};Nc=po;_.Primitive=Nc;po.NAME="PRIMITIVE";function v0(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 jo(r,e=0,t=r.length){let n=e,o=new xe({},Se),i=new xt;if(!Bt(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=xe;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=_.EndOfContent;break;case 1:c=_.Boolean;break;case 2:c=_.Integer;break;case 3:c=_.BitString;break;case 4:c=_.OctetString;break;case 5:c=_.Null;break;case 6:c=_.ObjectIdentifier;break;case 10:c=_.Enumerated;break;case 12:c=_.Utf8String;break;case 13:c=_.RelativeObjectIdentifier;break;case 14:c=_.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=_.Sequence;break;case 17:c=_.Set;break;case 18:c=_.NumericString;break;case 19:c=_.PrintableString;break;case 20:c=_.TeletexString;break;case 21:c=_.VideotexString;break;case 22:c=_.IA5String;break;case 23:c=_.UTCTime;break;case 24:c=_.GeneralizedTime;break;case 25:c=_.GraphicString;break;case 26:c=_.VisibleString;break;case 27:c=_.GeneralString;break;case 28:c=_.UniversalString;break;case 29:c=_.CharacterString;break;case 30:c=_.BmpString;break;case 31:c=_.DATE;break;case 32:c=_.TimeOfDay;break;case 33:c=_.DateTime;break;case 34:c=_.Duration;break;default:{let f=o.idBlock.isConstructed?new _.Constructed:new _.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?_.Constructed:_.Primitive}return o=v0(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 qr(r){if(!r.byteLength){let e=new xe({},Se);return e.error="Input buffer has zero length",{offset:-1,result:e}}return jo(j.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function B0(r,e){return r?1:e}var st=class extends Se{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let o=j.BufferSourceConverter.toUint8Array(e);if(!Bt(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(;B0(this.isIndefiniteForm,n)>0;){let s=jo(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===wn)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===wn?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new yn;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return t?We:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};st.NAME="ConstructedValueBlock";var _c,Gt=class extends xe{constructor(e={}){super(e,st),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} :`}};Fc=jt;_.Constructed=Fc;jt.NAME="CONSTRUCTED";var wo=class extends Se{fromBER(e,t,n){return t}toBER(e){return We}};wo.override="EndOfContentValueBlock";var Pc,bo=class extends xe{constructor(e={}){super(e,wo),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Pc=bo;_.EndOfContent=Pc;bo.NAME=bn;var Mc,Yt=class extends xe{constructor(e={}){super(e,Se),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}`}};Mc=Yt;_.Null=Mc;Yt.NAME="NULL";var xo=class extends St(Se){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=j.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=j.BufferSourceConverter.toUint8Array(e);return At(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,Bs.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};xo.NAME="BooleanValueBlock";var Hc,Eo=class extends xe{constructor(e={}){super(e,xo),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}`}};Hc=Eo;_.Boolean=Hc;Eo.NAME="BOOLEAN";var vo=class extends St(st){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=st.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===bn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==Dc)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?st.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 Kc,vt=class r extends xe{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=Wo(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} : ${j.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 j.BufferSourceConverter.concat(e)}};Kc=vt;_.OctetString=Kc;vt.NAME=Dc;var Bo=class extends St(st){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=st.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===bn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Lc)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=j.BufferSourceConverter.toUint8Array(e);if(!At(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=Wo(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 st.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return We;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}}};Bo.NAME="BitStringValueBlock";var $c,qr=class extends xe{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},Bo),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)}`}}};$c=qr;_.BitString=$c;qr.NAME=Lc;var qc;function C0(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=lo(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return t[0]>0&&(i=lo(t,i)),i}function Uc(r){if(r>=yn.length)for(let e=yn.length;e<=r;e++){let t=new Uint8Array([0]),n=yn[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=lo(t,n)),yn.push(n)}return yn[r]}function N0(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 xn=class extends St(Se){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=Bs.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Cc(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=N0(Uc(n),t),s="-";break;default:t=C0(t,Uc(n))}n++,o>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(s+=_c.charAt(t[c]));return a===!1&&(s+=_c.charAt(0)),s}};qc=xn;xn.NAME="IntegerValueBlock";Object.defineProperty(qc.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var zc,ue=class r extends xe{constructor(e={}){super(e,xn),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return fo(),BigInt(this.valueBlock.toString())}static fromBigInt(e){fo();let t=BigInt(e),n=new wn,o=t.toString(16).replace(/^-/,""),i=new Uint8Array(j.Convert.FromHex(o));if(t<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${j.Convert.ToHex(a)}`)+t,u=j.BufferSourceConverter.toUint8Array(j.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()}`}};zc=ue;_.Integer=zc;ue.NAME="INTEGER";var Gc,Ao=class extends ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Gc=Ao;_.Enumerated=Gc;Ao.NAME="ENUMERATED";var En=class extends St(Se){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=j.BufferSourceConverter.toUint8Array(e);if(!At(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=dr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){fo();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",We;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=j.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}}};En.NAME="sidBlock";var So=class extends Se{constructor({value:e=zr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new En;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.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,We;t.push(o)}return As(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 En;if(o>Number.MAX_SAFE_INTEGER){fo();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}};So.NAME="ObjectIdentifierValueBlock";var jc,Ze=class extends xe{constructor(e={}){super(e,So),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};jc=Ze;_.ObjectIdentifier=jc;Ze.NAME="OBJECT IDENTIFIER";var vn=class extends St(Et){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let o=j.BufferSourceConverter.toUint8Array(e);if(!At(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=dr(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",We;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=j.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};vn.NAME="relativeSidBlock";var Ro=class extends Se{constructor({value:e=zr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new vn;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,We;n.push(i)}return As(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 vn;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}};Ro.NAME="RelativeObjectIdentifierValueBlock";var Yc,ko=class extends xe{constructor(e={}){super(e,Ro),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()}}};Yc=ko;_.RelativeObjectIdentifier=Yc;ko.NAME="RelativeObjectIdentifier";var Zc,pe=class extends jt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Zc=pe;_.Sequence=Zc;pe.NAME="SEQUENCE";var Wc,Io=class extends jt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Wc=Io;_.Set=Wc;Io.NAME="SET";var To=class extends St(Se){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=zr}toJSON(){return{...super.toJSON(),value:this.value}}};To.NAME="StringValueBlock";var Co=class extends To{};Co.NAME="SimpleStringValueBlock";var Te=class extends go{constructor({...e}={}){super(e,Co)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,j.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}};Te.NAME="SIMPLE STRING";var No=class extends Te{fromBuffer(e){this.valueBlock.valueHexView=j.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=j.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=j.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(j.Convert.FromUtf8String(e)),this.valueBlock.value=e}};No.NAME="Utf8StringValueBlock";var Jc,Bt=class extends No{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Jc=Bt;_.Utf8String=Jc;Bt.NAME="UTF8String";var _o=class extends Te{fromBuffer(e){this.valueBlock.value=j.Convert.ToUtf16String(e),this.valueBlock.valueHexView=j.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(j.Convert.FromUtf16String(e))}};_o.NAME="BmpStringValueBlock";var Xc,Uo=class extends _o{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Xc=Uo;_.BmpString=Xc;Uo.NAME="BMPString";var Do=class extends Te{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}};Do.NAME="UniversalStringValueBlock";var Qc,Lo=class extends Do{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Qc=Lo;_.UniversalString=Qc;Lo.NAME="UniversalString";var eu,Vo=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};eu=Vo;_.NumericString=eu;Vo.NAME="NumericString";var tu,Oo=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};tu=Oo;_.PrintableString=tu;Oo.NAME="PrintableString";var ru,Fo=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};ru=Fo;_.TeletexString=ru;Fo.NAME="TeletexString";var nu,Po=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};nu=Po;_.VideotexString=nu;Po.NAME="VideotexString";var ou,Mo=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};ou=Mo;_.IA5String=ou;Mo.NAME="IA5String";var iu,Ho=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};iu=Ho;_.GraphicString=iu;Ho.NAME="GraphicString";var su,Bn=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};su=Bn;_.VisibleString=su;Bn.NAME="VisibleString";var au,Ko=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};au=Ko;_.GeneralString=au;Ko.NAME="GeneralString";var cu,$o=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};cu=$o;_.CharacterString=cu;$o.NAME="CharacterString";var uu,An=class extends Bn{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,j.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]=Ne(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Ne(this.month,2),t[2]=Ne(this.day,2),t[3]=Ne(this.hour,2),t[4]=Ne(this.minute,2),t[5]=Ne(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}}};uu=An;_.UTCTime=uu;An.NAME="UTCTime";var lu,qo=class extends An{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("+"),v="";if(d===-1&&(d=n.indexOf("-"),l=-1),d!==-1){if(v=n.substring(d+1),n=n.substring(0,d),v.length!==2&&v.length!==4)throw new Error("Wrong input string for conversion");let m=parseInt(v.substring(0,2),10);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*m,v.length===4){if(m=parseInt(v.substring(2,4),10),isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");c=l*m}}}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(Ne(this.year,4)),t.push(Ne(this.month,2)),t.push(Ne(this.day,2)),t.push(Ne(this.hour,2)),t.push(Ne(this.minute,2)),t.push(Ne(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Ne(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};lu=qo;_.GeneralizedTime=lu;qo.NAME="GeneralizedTime";var fu,zo=class extends Bt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};fu=zo;_.DATE=fu;zo.NAME="DATE";var hu,Go=class extends Bt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};hu=Go;_.TimeOfDay=hu;Go.NAME="TimeOfDay";var du,jo=class extends Bt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};du=jo;_.DateTime=du;jo.NAME="DateTime";var pu,Yo=class extends Bt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};pu=Yo;_.Duration=pu;Yo.NAME="Duration";var gu,Zo=class extends Bt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};gu=Zo;_.TIME=gu;Zo.NAME="TIME";function U0(r){let{result:e}=Gr(r),t=e.valueBlock.value;return{n:oe(at(t[1].toBigInt()),"base64url"),e:oe(at(t[2].toBigInt()),"base64url"),d:oe(at(t[3].toBigInt()),"base64url"),p:oe(at(t[4].toBigInt()),"base64url"),q:oe(at(t[5].toBigInt()),"base64url"),dp:oe(at(t[6].toBigInt()),"base64url"),dq:oe(at(t[7].toBigInt()),"base64url"),qi:oe(at(t[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function D0(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 $("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new pe({value:[new ue({value:0}),ue.fromBigInt(ct(J(r.n,"base64url"))),ue.fromBigInt(ct(J(r.e,"base64url"))),ue.fromBigInt(ct(J(r.d,"base64url"))),ue.fromBigInt(ct(J(r.p,"base64url"))),ue.fromBigInt(ct(J(r.q,"base64url"))),ue.fromBigInt(ct(J(r.dp,"base64url"))),ue.fromBigInt(ct(J(r.dq,"base64url"))),ue.fromBigInt(ct(J(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function L0(r){let{result:e}=Gr(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:oe(at(t[0].toBigInt()),"base64url"),e:oe(at(t[1].toBigInt()),"base64url")}}function V0(r){if(r.n==null||r.e==null)throw new $("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new pe({value:[new pe({value:[new Ze({value:"1.2.840.113549.1.1.1"}),new Yt]}),new qr({valueHex:new pe({value:[ue.fromBigInt(ct(J(r.n,"base64url"))),ue.fromBigInt(ct(J(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function at(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 ct(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 O0=16,Rs=32,ks=1e4;async function F0(r,e){let t=ke.get(),o=new pe({value:[new ue({value:0}),new pe({value:[new Ze({value:"1.2.840.113549.1.1.1"}),new Yt]}),new vt({valueHex:r.marshal()})]}).toBER(),i=new Uint8Array(o,0,o.byteLength),s=hr(O0),a=await Es(Vr,e,s,{c:ks,dkLen:Rs}),c=hr(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 pe({value:[new vt({valueHex:s}),new ue({value:ks}),new ue({value:Rs}),new pe({value:[new Ze({value:"1.2.840.113549.2.11"}),new Yt]})]}),d=new pe({value:[new Ze({value:"1.2.840.113549.1.5.13"}),new pe({value:[new pe({value:[new Ze({value:"1.2.840.113549.1.5.12"}),l]}),new pe({value:[new Ze({value:"2.16.840.1.101.3.4.1.42"}),new vt({valueHex:c})]})]})]}),m=new pe({value:[d,new vt({valueHex:u})]}).toBER(),h=new Uint8Array(m,0,m.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...oe(h,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
8
- `)}async function P0(r,e){let t=ke.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let o=J(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:i}=Gr(o),{iv:s,salt:a,iterations:c,keySize:f,cipherText:u}=M0(i),l=await Es(Vr,e,a,{c,dkLen:f}),d=await t.subtle.importKey("raw",l,"AES-CBC",!1,["decrypt"]),v=Sn(await t.subtle.decrypt({name:"AES-CBC",iv:s},d,u)),{result:m}=Gr(v);n=mu(m)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let o=J(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:i}=Gr(o);n=mu(i)}else throw new $("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return Is(n)}function M0(r){let e=r.valueBlock.value[0];if(e.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.13")throw new $("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 $("Only pkcs5PBKDF2 key derivation functions are supported","ERR_INVALID_PARAMS");let i=n.valueBlock.value[1],s=Sn(i.valueBlock.value[0].getValue()),a=ks,c=Rs;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 $("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 $("Only AES-CBC encryption schemes are supported","ERR_INVALID_PARAMS")}}}}let l=Sn(f.valueBlock.value[1].getValue());return{cipherText:Sn(r.valueBlock.value[1].getValue()),salt:s,iterations:a,keySize:c,iv:l}}function mu(r){return Sn(r.valueBlock.value[2].getValue())}function Sn(r){return new Uint8Array(r,0,r.byteLength)}async function yu(r){let e=await ke.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 xu(e);return{privateKey:t[0],publicKey:t[1]}}async function Ts(r){let t=[await ke.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await H0(r)],n=await xu({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function wu(r,e){let t=await ke.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await ke.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function bu(r,e,t){let n=await ke.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return ke.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function xu(r){if(r.privateKey==null||r.publicKey==null)throw new $("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([ke.get().subtle.exportKey("jwk",r.privateKey),ke.get().subtle.exportKey("jwk",r.publicKey)])}async function H0(r){return ke.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 Jo(r){if(r.kty!=="RSA")throw new $("invalid key type","ERR_INVALID_KEY_TYPE");if(r.n==null)throw new $("invalid key modulus","ERR_INVALID_KEY_MODULUS");return J(r.n,"base64url").length*8}var kn=8192,Rn=class{_key;constructor(e){this._key=e}verify(e,t){return bu(this._key,t,e)}marshal(){return Zt.jwkToPkix(this._key)}get bytes(){return ot.encode({Type:ne.RSA,Data:this.marshal()}).subarray()}equals(e){return fe(this.bytes,e.bytes)}hash(){let e=be.digest(this.bytes);return He(e)?e.then(({bytes:t})=>t):e.bytes}},jr=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return hr(16)}sign(e){return wu(this._key,e)}get public(){if(this._publicKey==null)throw new $("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new Rn(this._publicKey)}marshal(){return Zt.jwkToPkcs1(this._key)}get bytes(){return it.encode({Type:ne.RSA,Data:this.marshal()}).subarray()}equals(e){return fe(this.bytes,e.bytes)}hash(){let e=be.digest(this.bytes);return He(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return oe(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 $(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function Is(r){let e=Zt.pkcs1ToJwk(r);if(Jo(e)>kn)throw new $("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await Ts(e);return new jr(t.privateKey,t.publicKey)}function $0(r){let e=Zt.pkixToJwk(r);if(Jo(e)>kn)throw new $("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new Rn(e)}async function q0(r){if(Jo(r)>kn)throw new $("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await Ts(r);return new jr(e.privateKey,e.publicKey)}async function z0(r){if(r>kn)throw new $("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await yu(r);return new jr(e.privateKey,e.publicKey)}var Ls={};de(Ls,{Secp256k1PrivateKey:()=>Tn,Secp256k1PublicKey:()=>In,generateKeyPair:()=>op,unmarshalSecp256k1PrivateKey:()=>rp,unmarshalSecp256k1PublicKey:()=>np});var G0=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),Ns=class extends Lr{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],v=Jt[l-2],m=Ge(d,7)^Ge(d,18)^d>>>3,h=Ge(v,17)^Ge(v,19)^v>>>10;Jt[l]=h+Jt[l-7]+m+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=Ge(a,6)^Ge(a,11)^Ge(a,25),v=u+d+za(a,c,f)+G0[l]+Jt[l]|0,h=(Ge(n,2)^Ge(n,13)^Ge(n,22))+Ga(n,o,i)|0;u=f,f=c,c=a,a=s+v|0,s=i,i=o,o=n,n=v+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 Eu=jn(()=>new Ns);function j0(r){let e=ln(r);nt(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:Y0,hexToBytes:Z0}=Wn,pr={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){let{Err:e}=pr;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:Y0(n),l:r.subarray(t+2)}},toSig(r){let{Err:e}=pr,t=typeof r=="string"?Z0(r):r;Or(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}=pr._parseInt(t.subarray(2)),{d:s,l:a}=pr._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}`}},Rt=BigInt(0),$e=BigInt(1),Hw=BigInt(2),vu=BigInt(3),Kw=BigInt(4);function W0(r){let e=j0(r),{Fp:t}=e,n=e.toBytes||((m,h,p)=>{let b=h.toAffine();return yt(Uint8Array.from([4]),t.toBytes(b.x),t.toBytes(b.y))}),o=e.fromBytes||(m=>{let h=m.subarray(1),p=t.fromBytes(h.subarray(0,t.BYTES)),b=t.fromBytes(h.subarray(t.BYTES,2*t.BYTES));return{x:p,y:b}});function i(m){let{a:h,b:p}=e,b=t.sqr(m),k=t.mul(b,m);return t.add(t.add(k,t.mul(m,h)),p)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function s(m){return typeof m=="bigint"&&Rt<m&&m<e.n}function a(m){if(!s(m))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(m){let{allowedPrivateKeyLengths:h,nByteLength:p,wrapPrivateKey:b,n:k}=e;if(h&&typeof m!="bigint"){if(Ft(m)&&(m=gt(m)),typeof m!="string"||!h.includes(m.length))throw new Error("Invalid key");m=m.padStart(p*2,"0")}let E;try{E=typeof m=="bigint"?m:mt(ae("private key",m,p))}catch{throw new Error(`private key must be ${p} bytes, hex or bigint, not ${typeof m}`)}return b&&(E=ee(E,k)),a(E),E}let f=new Map;function u(m){if(!(m instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(h,p,b){if(this.px=h,this.py=p,this.pz=b,h==null||!t.isValid(h))throw new Error("x required");if(p==null||!t.isValid(p))throw new Error("y required");if(b==null||!t.isValid(b))throw new Error("z required")}static fromAffine(h){let{x:p,y:b}=h||{};if(!h||!t.isValid(p)||!t.isValid(b))throw new Error("invalid affine point");if(h instanceof l)throw new Error("projective point not allowed");let k=E=>t.eql(E,t.ZERO);return k(p)&&k(b)?l.ZERO:new l(p,b,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let p=t.invertBatch(h.map(b=>b.pz));return h.map((b,k)=>b.toAffine(p[k])).map(l.fromAffine)}static fromHex(h){let p=l.fromAffine(o(ae("pointHex",h)));return p.assertValidity(),p}static fromPrivateKey(h){return l.BASE.multiply(c(h))}_setWindowSize(h){this._WINDOW_SIZE=h,f.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:h,y:p}=this.toAffine();if(!t.isValid(h)||!t.isValid(p))throw new Error("bad point: x or y not FE");let b=t.sqr(p),k=i(h);if(!t.eql(b,k))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:h}=this.toAffine();if(t.isOdd)return!t.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){u(h);let{px:p,py:b,pz:k}=this,{px:E,py:D,pz:S}=h,I=t.eql(t.mul(p,S),t.mul(E,k)),N=t.eql(t.mul(b,S),t.mul(D,k));return I&&N}negate(){return new l(this.px,t.neg(this.py),this.pz)}double(){let{a:h,b:p}=e,b=t.mul(p,vu),{px:k,py:E,pz:D}=this,S=t.ZERO,I=t.ZERO,N=t.ZERO,y=t.mul(k,k),C=t.mul(E,E),V=t.mul(D,D),T=t.mul(k,E);return T=t.add(T,T),N=t.mul(k,D),N=t.add(N,N),S=t.mul(h,N),I=t.mul(b,V),I=t.add(S,I),S=t.sub(C,I),I=t.add(C,I),I=t.mul(S,I),S=t.mul(T,S),N=t.mul(b,N),V=t.mul(h,V),T=t.sub(y,V),T=t.mul(h,T),T=t.add(T,N),N=t.add(y,y),y=t.add(N,y),y=t.add(y,V),y=t.mul(y,T),I=t.add(I,y),V=t.mul(E,D),V=t.add(V,V),y=t.mul(V,T),S=t.sub(S,y),N=t.mul(V,C),N=t.add(N,N),N=t.add(N,N),new l(S,I,N)}add(h){u(h);let{px:p,py:b,pz:k}=this,{px:E,py:D,pz:S}=h,I=t.ZERO,N=t.ZERO,y=t.ZERO,C=e.a,V=t.mul(e.b,vu),T=t.mul(p,E),O=t.mul(b,D),M=t.mul(k,S),Z=t.add(p,b),x=t.add(E,D);Z=t.mul(Z,x),x=t.add(T,O),Z=t.sub(Z,x),x=t.add(p,k);let A=t.add(E,S);return x=t.mul(x,A),A=t.add(T,M),x=t.sub(x,A),A=t.add(b,k),I=t.add(D,S),A=t.mul(A,I),I=t.add(O,M),A=t.sub(A,I),y=t.mul(C,x),I=t.mul(V,M),y=t.add(I,y),I=t.sub(O,y),y=t.add(O,y),N=t.mul(I,y),O=t.add(T,T),O=t.add(O,T),M=t.mul(C,M),x=t.mul(V,x),O=t.add(O,M),M=t.sub(T,M),M=t.mul(C,M),x=t.add(x,M),T=t.mul(O,x),N=t.add(N,T),T=t.mul(A,x),I=t.mul(Z,I),I=t.sub(I,T),T=t.mul(Z,O),y=t.mul(A,y),y=t.add(y,T),new l(I,N,y)}subtract(h){return this.add(h.negate())}is0(){return this.equals(l.ZERO)}wNAF(h){return v.wNAFCached(this,f,h,p=>{let b=t.invertBatch(p.map(k=>k.pz));return p.map((k,E)=>k.toAffine(b[E])).map(l.fromAffine)})}multiplyUnsafe(h){let p=l.ZERO;if(h===Rt)return p;if(a(h),h===$e)return this;let{endo:b}=e;if(!b)return v.unsafeLadder(this,h);let{k1neg:k,k1:E,k2neg:D,k2:S}=b.splitScalar(h),I=p,N=p,y=this;for(;E>Rt||S>Rt;)E&$e&&(I=I.add(y)),S&$e&&(N=N.add(y)),y=y.double(),E>>=$e,S>>=$e;return k&&(I=I.negate()),D&&(N=N.negate()),N=new l(t.mul(N.px,b.beta),N.py,N.pz),I.add(N)}multiply(h){a(h);let p=h,b,k,{endo:E}=e;if(E){let{k1neg:D,k1:S,k2neg:I,k2:N}=E.splitScalar(p),{p:y,f:C}=this.wNAF(S),{p:V,f:T}=this.wNAF(N);y=v.constTimeNegate(D,y),V=v.constTimeNegate(I,V),V=new l(t.mul(V.px,E.beta),V.py,V.pz),b=y.add(V),k=C.add(T)}else{let{p:D,f:S}=this.wNAF(p);b=D,k=S}return l.normalizeZ([b,k])[0]}multiplyAndAddUnsafe(h,p,b){let k=l.BASE,E=(S,I)=>I===Rt||I===$e||!S.equals(k)?S.multiplyUnsafe(I):S.multiply(I),D=E(this,p).add(E(h,b));return D.is0()?void 0:D}toAffine(h){let{px:p,py:b,pz:k}=this,E=this.is0();h==null&&(h=E?t.ONE:t.inv(k));let D=t.mul(p,h),S=t.mul(b,h),I=t.mul(k,h);if(E)return{x:t.ZERO,y:t.ZERO};if(!t.eql(I,t.ONE))throw new Error("invZ was invalid");return{x:D,y:S}}isTorsionFree(){let{h,isTorsionFree:p}=e;if(h===$e)return!0;if(p)return p(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:p}=e;return h===$e?this:p?p(l,this):this.multiplyUnsafe(e.h)}toRawBytes(h=!0){return this.assertValidity(),n(l,this,h)}toHex(h=!0){return gt(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,v=Qn(l,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:s}}function J0(r){let e=ln(r);return nt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Bu(r){let e=J0(r),{Fp:t,n}=e,o=t.BYTES+1,i=2*t.BYTES+1;function s(x){return Rt<x&&x<t.ORDER}function a(x){return ee(x,n)}function c(x){return Jn(x,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:d}=W0({...e,toBytes(x,A,P){let B=A.toAffine(),w=t.toBytes(B.x),L=yt;return P?L(Uint8Array.from([A.hasEvenY()?2:3]),w):L(Uint8Array.from([4]),w,t.toBytes(B.y))},fromBytes(x){let A=x.length,P=x[0],B=x.subarray(1);if(A===o&&(P===2||P===3)){let w=mt(B);if(!s(w))throw new Error("Point is not on curve");let L=l(w),F;try{F=t.sqrt(L)}catch(G){let Q=G instanceof Error?": "+G.message:"";throw new Error("Point is not on curve"+Q)}let H=(F&$e)===$e;return(P&1)===1!==H&&(F=t.neg(F)),{x:w,y:F}}else if(A===i&&P===4){let w=t.fromBytes(B.subarray(0,t.BYTES)),L=t.fromBytes(B.subarray(t.BYTES,2*t.BYTES));return{x:w,y:L}}else throw new Error(`Point of length ${A} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),v=x=>gt(Mt(x,e.nByteLength));function m(x){let A=n>>$e;return x>A}function h(x){return m(x)?a(-x):x}let p=(x,A,P)=>mt(x.slice(A,P));class b{constructor(A,P,B){this.r=A,this.s=P,this.recovery=B,this.assertValidity()}static fromCompact(A){let P=e.nByteLength;return A=ae("compactSignature",A,P*2),new b(p(A,0,P),p(A,P,2*P))}static fromDER(A){let{r:P,s:B}=pr.toSig(ae("DER",A));return new b(P,B)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(A){return new b(this.r,this.s,A)}recoverPublicKey(A){let{r:P,s:B,recovery:w}=this,L=N(ae("msgHash",A));if(w==null||![0,1,2,3].includes(w))throw new Error("recovery id invalid");let F=w===2||w===3?P+e.n:P;if(F>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let H=w&1?"03":"02",z=f.fromHex(H+v(F)),G=c(F),Q=a(-L*G),Y=a(B*G),W=f.BASE.multiplyAndAddUnsafe(z,Q,Y);if(!W)throw new Error("point at infinify");return W.assertValidity(),W}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new b(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return sr(this.toDERHex())}toDERHex(){return pr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return sr(this.toCompactHex())}toCompactHex(){return v(this.r)+v(this.s)}}let k={isValidPrivateKey(x){try{return u(x),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let x=rs(e.n);return nc(e.randomBytes(x),e.n)},precompute(x=8,A=f.BASE){return A._setWindowSize(x),A.multiply(BigInt(3)),A}};function E(x,A=!0){return f.fromPrivateKey(x).toRawBytes(A)}function D(x){let A=Ft(x),P=typeof x=="string",B=(A||P)&&x.length;return A?B===o||B===i:P?B===2*o||B===2*i:x instanceof f}function S(x,A,P=!0){if(D(x))throw new Error("first arg must be private key");if(!D(A))throw new Error("second arg must be public key");return f.fromHex(A).multiply(u(x)).toRawBytes(P)}let I=e.bits2int||function(x){let A=mt(x),P=x.length*8-e.nBitLength;return P>0?A>>BigInt(P):A},N=e.bits2int_modN||function(x){return a(I(x))},y=un(e.nBitLength);function C(x){if(typeof x!="bigint")throw new Error("bigint expected");if(!(Rt<=x&&x<y))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Mt(x,e.nByteLength)}function V(x,A,P=T){if(["recovered","canonical"].some(ie=>ie in P))throw new Error("sign() legacy options not supported");let{hash:B,randomBytes:w}=e,{lowS:L,prehash:F,extraEntropy:H}=P;L==null&&(L=!0),x=ae("msgHash",x),F&&(x=ae("prehashed msgHash",B(x)));let z=N(x),G=u(A),Q=[C(G),C(z)];if(H!=null&&H!==!1){let ie=H===!0?w(t.BYTES):H;Q.push(ae("extraEntropy",ie))}let Y=yt(...Q),W=z;function ce(ie){let me=I(ie);if(!d(me))return;let ye=c(me),le=f.BASE.multiply(me).toAffine(),Be=a(le.x);if(Be===Rt)return;let ft=a(ye*a(W+Be*G));if(ft===Rt)return;let er=(le.x===Be?0:2)|Number(le.y&$e),tn=ft;return L&&m(ft)&&(tn=h(ft),er^=1),new b(Be,tn,er)}return{seed:Y,k2sig:ce}}let T={lowS:e.lowS,prehash:!1},O={lowS:e.lowS,prehash:!1};function M(x,A,P=T){let{seed:B,k2sig:w}=V(x,A,P),L=e;return Xi(L.hash.outputLen,L.nByteLength,L.hmac)(B,w)}f.BASE._setWindowSize(8);function Z(x,A,P,B=O){let w=x;if(A=ae("msgHash",A),P=ae("publicKey",P),"strict"in B)throw new Error("options.strict was renamed to lowS");let{lowS:L,prehash:F}=B,H,z;try{if(typeof w=="string"||Ft(w))try{H=b.fromDER(w)}catch(le){if(!(le instanceof pr.Err))throw le;H=b.fromCompact(w)}else if(typeof w=="object"&&typeof w.r=="bigint"&&typeof w.s=="bigint"){let{r:le,s:Be}=w;H=new b(le,Be)}else throw new Error("PARSE");z=f.fromHex(P)}catch(le){if(le.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(L&&H.hasHighS())return!1;F&&(A=e.hash(A));let{r:G,s:Q}=H,Y=N(A),W=c(Q),ce=a(Y*W),ie=a(G*W),me=f.BASE.multiplyAndAddUnsafe(z,ce,ie)?.toAffine();return me?a(me.x)===G:!1}return{CURVE:e,getPublicKey:E,getSharedSecret:S,sign:M,verify:Z,ProjectivePoint:f,Signature:b,utils:k}}function X0(r){return{hash:r,hmac:(e,...t)=>mn(r,e,Gn(...t)),randomBytes:Dr}}function Au(r,e){let t=n=>Bu({...r,...X0(n)});return Object.freeze({...t(e),create:t})}var ku=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Su=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Q0=BigInt(1),_s=BigInt(2),Ru=(r,e)=>(r+e/_s)/e;function ep(r){let e=ku,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,v=re(d,_s,e)*f%e,m=re(v,o,e)*v%e,h=re(m,i,e)*m%e,p=re(h,a,e)*h%e,b=re(p,c,e)*p%e,k=re(b,a,e)*h%e,E=re(k,t,e)*u%e,D=re(E,s,e)*m%e,S=re(D,n,e)*f%e,I=re(S,_s,e);if(!Us.eql(Us.sqr(I),r))throw new Error("Cannot find square root");return I}var Us=Xn(ku,void 0,void 0,{sqrt:ep}),Je=Au({a:BigInt(0),b:BigInt(7),Fp:Us,n:Su,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=Su,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Q0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,s=BigInt("0x100000000000000000000000000000000"),a=Ru(i*r,e),c=Ru(-n*r,e),f=ee(r-a*t-c*o,e),u=ee(-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}}}},Eu),Jw=BigInt(0);var Xw=Je.ProjectivePoint;function Iu(){return Je.utils.randomPrivateKey()}function Tu(r,e){let t=be.digest(e instanceof Uint8Array?e:e.subarray());if(He(t))return t.then(({digest:n})=>Je.sign(n,r).toDERRawBytes()).catch(n=>{throw new $(String(n),"ERR_INVALID_INPUT")});try{return Je.sign(t.digest,r).toDERRawBytes()}catch(n){throw new $(String(n),"ERR_INVALID_INPUT")}}function Cu(r,e,t){let n=be.digest(t instanceof Uint8Array?t:t.subarray());if(He(n))return n.then(({digest:o})=>Je.verify(e,o,r)).catch(o=>{throw new $(String(o),"ERR_INVALID_INPUT")});try{return Je.verify(e,n.digest,r)}catch(o){throw new $(String(o),"ERR_INVALID_INPUT")}}function Nu(r){return Je.ProjectivePoint.fromHex(r).toRawBytes(!0)}function _u(r){try{Je.getPublicKey(r,!0)}catch(e){throw new $(String(e),"ERR_INVALID_PRIVATE_KEY")}}function Ds(r){try{Je.ProjectivePoint.fromHex(r)}catch(e){throw new $(String(e),"ERR_INVALID_PUBLIC_KEY")}}function Uu(r){try{return Je.getPublicKey(r,!0)}catch(e){throw new $(String(e),"ERR_INVALID_PRIVATE_KEY")}}var In=class{_key;constructor(e){Ds(e),this._key=e}verify(e,t){return Cu(this._key,t,e)}marshal(){return Nu(this._key)}get bytes(){return ot.encode({Type:ne.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return fe(this.bytes,e.bytes)}async hash(){let e=be.digest(this.bytes),t;return He(e)?{bytes:t}=await e:t=e.bytes,t}},Tn=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??Uu(e),_u(this._key),Ds(this._publicKey)}sign(e){return Tu(this._key,e)}get public(){return new In(this._publicKey)}marshal(){return this._key}get bytes(){return it.encode({Type:ne.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return fe(this.bytes,e.bytes)}hash(){let e=be.digest(this.bytes);return He(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return oe(e,"base58btc")}async export(e,t="libp2p-key"){if(t==="libp2p-key")return Mr(this.bytes,e);throw new $(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function rp(r){return new Tn(r)}function np(r){return new In(r)}async function op(){let r=Iu();return new Tn(r)}var gr={rsa:Cs,ed25519:xs,secp256k1:Ls};function Du(r){let e=Object.keys(gr).join(" / ");return new $(`invalid or unsupported key type ${r}. Must be ${e}`,"ERR_UNSUPPORTED_KEY_TYPE")}function Vs(r){let e=ot.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case ne.RSA:return gr.rsa.unmarshalRsaPublicKey(t);case ne.Ed25519:return gr.ed25519.unmarshalEd25519PublicKey(t);case ne.Secp256k1:return gr.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw Du(e.Type??"unknown")}}async function Lu(r){let e=it.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case ne.RSA:return gr.rsa.unmarshalRsaPrivateKey(t);case ne.Ed25519:return gr.ed25519.unmarshalEd25519PrivateKey(t);case ne.Secp256k1:return gr.secp256k1.unmarshalSecp256k1PrivateKey(t);default:throw Du(e.Type??"RSA")}}var Js=ht(Xo(),1);var kt="/",Fu=new TextEncoder().encode(kt),Qo=Fu[0],Yr=class r{_buf;constructor(e,t){if(typeof e=="string")this._buf=J(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(t==null&&(t=!0),t&&this.clean(),this._buf.byteLength===0||this._buf[0]!==Qo)throw new Error("Invalid key")}toString(e="utf8"){return oe(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new r(e.join(kt))}static random(){return new r(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new r(e):typeof e.uint8Array=="function"?new r(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=Fu),this._buf[0]!==Qo){let e=new Uint8Array(this._buf.byteLength+1);e.fill(Qo,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Qo;)this._buf=this._buf.subarray(0,-1)}less(e){let t=this.list(),n=e.list();for(let o=0;o<t.length;o++){if(n.length<o+1)return!1;let i=t[o],s=n[o];if(i<s)return!0;if(i>s)return!1}return t.length<n.length}reverse(){return r.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(kt).slice(1)}type(){return sp(this.baseNamespace())}name(){return ap(this.baseNamespace())}instance(e){return new r(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(kt)||(e+=kt),e+=this.type(),new r(e)}parent(){let e=this.list();return e.length===1?new r(kt):new r(e.slice(0,-1).join(kt))}child(e){return this.toString()===kt?e:e.toString()===kt?this:new r(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return r.withNamespaces([...this.namespaces(),...cp(e.map(t=>t.namespaces()))])}};function sp(r){let e=r.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function ap(r){let e=r.split(":");return e[e.length-1]}function cp(r){return[].concat(...r)}var of=ht(ei(),1);var Pu="ERR_IPNS_EXPIRED_RECORD",Cn="ERR_UNRECOGNIZED_VALIDITY",Mu="ERR_SIGNATURE_CREATION",It="ERR_SIGNATURE_VERIFICATION";var Fs="ERR_UNDEFINED_PARAMETER",Hu="ERR_INVALID_RECORD_DATA",Ku="ERR_INVALID_VALUE",$u="ERR_INVALID_EMBEDDED_KEY",qu="ERR_MISSING_PRIVATE_KEY",zu="ERR_RECORD_TOO_LARGE";var Ee;(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=()=>pn(t)}(e=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=zt((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=>qt(o,r.codec()),r.decode=o=>$t(o,r.codec())})(Ee||(Ee={}));var up=["string","number","bigint","symbol"],lp=["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 Gu(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(up.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(fp(r))return"Buffer";let t=hp(r);return t||"Object"}function fp(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function hp(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(lp.includes(e))return e}var g=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}};g.uint=new g(0,"uint",!0);g.negint=new g(1,"negint",!0);g.bytes=new g(2,"bytes",!0);g.string=new g(3,"string",!0);g.array=new g(4,"array",!1);g.map=new g(5,"map",!1);g.tag=new g(6,"tag",!1);g.float=new g(7,"float",!0);g.false=new g(7,"false",!0);g.true=new g(7,"true",!0);g.null=new g(7,"null",!0);g.undefined=new g(7,"undefined",!0);g.break=new g(7,"break",!0);var U=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 Zr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",dp=new TextDecoder,pp=new TextEncoder;function ti(r){return Zr&&globalThis.Buffer.isBuffer(r)}function Ms(r){return r instanceof Uint8Array?ti(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Wu=Zr?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):Yu(r,e,t):(r,e,t)=>t-e>64?dp.decode(r.subarray(e,t)):Yu(r,e,t),Ju=Zr?r=>r.length>64?globalThis.Buffer.from(r):ju(r):r=>r.length>64?pp.encode(r):ju(r),ut=r=>Uint8Array.from(r),Wr=Zr?(r,e,t)=>ti(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),Xu=Zr?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),Ms(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},Qu=Zr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function el(r,e){if(ti(r)&&ti(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 ju(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 Yu(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 gp(n)}var Zu=4096;function gp(r){let e=r.length;if(e<=Zu)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Zu));return t}var mp=256,Nn=class{constructor(e=mp){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=Qu(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=Wr(n,0,this.cursor)}else t=Xu(this.chunks,this.cursor);return e&&this.reset(),t}};var K="CBOR decode error:",Hs="CBOR encode error:",_n=[];_n[23]=1;_n[24]=2;_n[25]=3;_n[26]=5;_n[27]=9;function Tt(r,e,t){if(r.length-e<t)throw new Error(`${K} not enough data for type`)}var ge=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Oe(r,e,t){Tt(r,e,1);let n=r[e];if(t.strict===!0&&n<ge[0])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function Fe(r,e,t){Tt(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<ge[1])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function Pe(r,e,t){Tt(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<ge[2])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function Me(r,e,t){Tt(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<ge[3])throw new Error(`${K} 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(`${K} integers outside of the safe integer range are not supported`)}function tl(r,e,t,n){return new U(g.uint,Oe(r,e+1,n),2)}function rl(r,e,t,n){return new U(g.uint,Fe(r,e+1,n),3)}function nl(r,e,t,n){return new U(g.uint,Pe(r,e+1,n),5)}function ol(r,e,t,n){return new U(g.uint,Me(r,e+1,n),9)}function qe(r,e){return ve(r,0,e.value)}function ve(r,e,t){if(t<ge[0]){let n=Number(t);r.push([e|n])}else if(t<ge[1]){let n=Number(t);r.push([e|24,n])}else if(t<ge[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<ge[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<ge[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(`${K} encountered BigInt larger than allowable range`)}}qe.encodedSize=function(e){return ve.encodedSize(e.value)};ve.encodedSize=function(e){return e<ge[0]?1:e<ge[1]?2:e<ge[2]?3:e<ge[3]?5:9};qe.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function il(r,e,t,n){return new U(g.negint,-1-Oe(r,e+1,n),2)}function sl(r,e,t,n){return new U(g.negint,-1-Fe(r,e+1,n),3)}function al(r,e,t,n){return new U(g.negint,-1-Pe(r,e+1,n),5)}var Ks=BigInt(-1),cl=BigInt(1);function ul(r,e,t,n){let o=Me(r,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new U(g.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${K} integers outside of the safe integer range are not supported`);return new U(g.negint,Ks-BigInt(o),9)}function ri(r,e){let t=e.value,n=typeof t=="bigint"?t*Ks-cl:t*-1-1;ve(r,e.type.majorEncoded,n)}ri.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*Ks-cl:t*-1-1;return n<ge[0]?1:n<ge[1]?2:n<ge[2]?3:n<ge[3]?5:9};ri.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function Un(r,e,t,n){Tt(r,e,t+n);let o=Wr(r,e+t,e+t+n);return new U(g.bytes,o,t+n)}function ll(r,e,t,n){return Un(r,e,1,t)}function fl(r,e,t,n){return Un(r,e,2,Oe(r,e+1,n))}function hl(r,e,t,n){return Un(r,e,3,Fe(r,e+1,n))}function dl(r,e,t,n){return Un(r,e,5,Pe(r,e+1,n))}function pl(r,e,t,n){let o=Me(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer bytes lengths not supported`);return Un(r,e,9,o)}function ni(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===g.string?Ju(r.value):r.value),r.encodedBytes}function Jr(r,e){let t=ni(e);ve(r,e.type.majorEncoded,t.length),r.push(t)}Jr.encodedSize=function(e){let t=ni(e);return ve.encodedSize(t.length)+t.length};Jr.compareTokens=function(e,t){return wp(ni(e),ni(t))};function wp(r,e){return r.length<e.length?-1:r.length>e.length?1:el(r,e)}function Dn(r,e,t,n,o){let i=t+n;Tt(r,e,i);let s=new U(g.string,Wu(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Wr(r,e+t,e+i)),s}function gl(r,e,t,n){return Dn(r,e,1,t,n)}function ml(r,e,t,n){return Dn(r,e,2,Oe(r,e+1,n),n)}function yl(r,e,t,n){return Dn(r,e,3,Fe(r,e+1,n),n)}function wl(r,e,t,n){return Dn(r,e,5,Pe(r,e+1,n),n)}function bl(r,e,t,n){let o=Me(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer string lengths not supported`);return Dn(r,e,9,o,n)}var xl=Jr;function Xr(r,e,t,n){return new U(g.array,n,t)}function El(r,e,t,n){return Xr(r,e,1,t)}function vl(r,e,t,n){return Xr(r,e,2,Oe(r,e+1,n))}function Bl(r,e,t,n){return Xr(r,e,3,Fe(r,e+1,n))}function Al(r,e,t,n){return Xr(r,e,5,Pe(r,e+1,n))}function Sl(r,e,t,n){let o=Me(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer array lengths not supported`);return Xr(r,e,9,o)}function Rl(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return Xr(r,e,1,1/0)}function oi(r,e){ve(r,g.array.majorEncoded,e.value)}oi.compareTokens=qe.compareTokens;oi.encodedSize=function(e){return ve.encodedSize(e.value)};function Qr(r,e,t,n){return new U(g.map,n,t)}function kl(r,e,t,n){return Qr(r,e,1,t)}function Il(r,e,t,n){return Qr(r,e,2,Oe(r,e+1,n))}function Tl(r,e,t,n){return Qr(r,e,3,Fe(r,e+1,n))}function Cl(r,e,t,n){return Qr(r,e,5,Pe(r,e+1,n))}function Nl(r,e,t,n){let o=Me(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer map lengths not supported`);return Qr(r,e,9,o)}function _l(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return Qr(r,e,1,1/0)}function ii(r,e){ve(r,g.map.majorEncoded,e.value)}ii.compareTokens=qe.compareTokens;ii.encodedSize=function(e){return ve.encodedSize(e.value)};function Ul(r,e,t,n){return new U(g.tag,t,1)}function Dl(r,e,t,n){return new U(g.tag,Oe(r,e+1,n),2)}function Ll(r,e,t,n){return new U(g.tag,Fe(r,e+1,n),3)}function Vl(r,e,t,n){return new U(g.tag,Pe(r,e+1,n),5)}function Ol(r,e,t,n){return new U(g.tag,Me(r,e+1,n),9)}function si(r,e){ve(r,g.tag.majorEncoded,e.value)}si.compareTokens=qe.compareTokens;si.encodedSize=function(e){return ve.encodedSize(e.value)};var Ap=20,Sp=21,Rp=22,kp=23;function Fl(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${K} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new U(g.null,null,1):new U(g.undefined,void 0,1)}function Pl(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return new U(g.break,void 0,1)}function $s(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${K} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${K} Infinity values are not supported`)}return new U(g.float,r,e)}function Ml(r,e,t,n){return $s(qs(r,e+1),3,n)}function Hl(r,e,t,n){return $s(zs(r,e+1),5,n)}function Kl(r,e,t,n){return $s(Gl(r,e+1),9,n)}function ai(r,e,t){let n=e.value;if(n===!1)r.push([g.float.majorEncoded|Ap]);else if(n===!0)r.push([g.float.majorEncoded|Sp]);else if(n===null)r.push([g.float.majorEncoded|Rp]);else if(n===void 0)r.push([g.float.majorEncoded|kp]);else{let o,i=!1;(!t||t.float64!==!0)&&(ql(n),o=qs(Xe,1),n===o||Number.isNaN(n)?(Xe[0]=249,r.push(Xe.slice(0,3)),i=!0):(zl(n),o=zs(Xe,1),n===o&&(Xe[0]=250,r.push(Xe.slice(0,5)),i=!0))),i||(Ip(n),o=Gl(Xe,1),Xe[0]=251,r.push(Xe.slice(0,9)))}}ai.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){ql(n);let o=qs(Xe,1);if(n===o||Number.isNaN(n))return 3;if(zl(n),o=zs(Xe,1),n===o)return 5}return 9};var $l=new ArrayBuffer(9),ze=new DataView($l,1),Xe=new Uint8Array($l,0);function ql(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 qs(r,e){if(r.length-e<2)throw new Error(`${K} 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 zl(r){ze.setFloat32(0,r,!1)}function zs(r,e){if(r.length-e<4)throw new Error(`${K} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function Ip(r){ze.setFloat64(0,r,!1)}function Gl(r,e){if(r.length-e<8)throw new Error(`${K} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}ai.compareTokens=qe.compareTokens;function X(r,e,t){throw new Error(`${K} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function ci(r){return()=>{throw new Error(`${K} ${r}`)}}var R=[];for(let r=0;r<=23;r++)R[r]=X;R[24]=tl;R[25]=rl;R[26]=nl;R[27]=ol;R[28]=X;R[29]=X;R[30]=X;R[31]=X;for(let r=32;r<=55;r++)R[r]=X;R[56]=il;R[57]=sl;R[58]=al;R[59]=ul;R[60]=X;R[61]=X;R[62]=X;R[63]=X;for(let r=64;r<=87;r++)R[r]=ll;R[88]=fl;R[89]=hl;R[90]=dl;R[91]=pl;R[92]=X;R[93]=X;R[94]=X;R[95]=ci("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)R[r]=gl;R[120]=ml;R[121]=yl;R[122]=wl;R[123]=bl;R[124]=X;R[125]=X;R[126]=X;R[127]=ci("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)R[r]=El;R[152]=vl;R[153]=Bl;R[154]=Al;R[155]=Sl;R[156]=X;R[157]=X;R[158]=X;R[159]=Rl;for(let r=160;r<=183;r++)R[r]=kl;R[184]=Il;R[185]=Tl;R[186]=Cl;R[187]=Nl;R[188]=X;R[189]=X;R[190]=X;R[191]=_l;for(let r=192;r<=215;r++)R[r]=Ul;R[216]=Dl;R[217]=Ll;R[218]=Vl;R[219]=Ol;R[220]=X;R[221]=X;R[222]=X;R[223]=X;for(let r=224;r<=243;r++)R[r]=ci("simple values are not supported");R[244]=X;R[245]=X;R[246]=X;R[247]=Fl;R[248]=ci("simple values are not supported");R[249]=Ml;R[250]=Hl;R[251]=Kl;R[252]=X;R[253]=X;R[254]=X;R[255]=Pl;var Qe=[];for(let r=0;r<24;r++)Qe[r]=new U(g.uint,r,1);for(let r=-1;r>=-24;r--)Qe[31-r]=new U(g.negint,r,1);Qe[64]=new U(g.bytes,new Uint8Array(0),1);Qe[96]=new U(g.string,"",1);Qe[128]=new U(g.array,0,1);Qe[160]=new U(g.map,0,1);Qe[244]=new U(g.false,!1,1);Qe[245]=new U(g.true,!0,1);Qe[246]=new U(g.null,null,1);function jl(r){switch(r.type){case g.false:return ut([244]);case g.true:return ut([245]);case g.null:return ut([246]);case g.bytes:return r.value.length?void 0:ut([64]);case g.string:return r.value===""?ut([96]):void 0;case g.array:return r.value===0?ut([128]):void 0;case g.map:return r.value===0?ut([160]):void 0;case g.uint:return r.value<24?ut([Number(r.value)]):void 0;case g.negint:if(r.value>=-24)return ut([31-Number(r.value)])}}var Cp={float64:!1,mapSorter:Up,quickEncodeToken:jl};function Np(){let r=[];return r[g.uint.major]=qe,r[g.negint.major]=ri,r[g.bytes.major]=Jr,r[g.string.major]=xl,r[g.array.major]=oi,r[g.map.major]=ii,r[g.tag.major]=si,r[g.float.major]=ai,r}var Yl=Np(),Gs=new Nn,li=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(`${Hs} object contains circular references`);return new r(t,e)}},Xt={null:new U(g.null,null),undefined:new U(g.undefined,void 0),true:new U(g.true,!0),false:new U(g.false,!1),emptyArray:new U(g.array,0),emptyMap:new U(g.map,0)},Qt={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new U(g.float,r):r>=0?new U(g.uint,r):new U(g.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new U(g.uint,r):new U(g.negint,r)},Uint8Array(r,e,t,n){return new U(g.bytes,r)},string(r,e,t,n){return new U(g.string,r)},boolean(r,e,t,n){return r?Xt.true:Xt.false},null(r,e,t,n){return Xt.null},undefined(r,e,t,n){return Xt.undefined},ArrayBuffer(r,e,t,n){return new U(g.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new U(g.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[Xt.emptyArray,new U(g.break)]:Xt.emptyArray;n=li.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=ui(s,t,n);return t.addBreakTokens?[new U(g.array,r.length),o,new U(g.break)]:[new U(g.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?[Xt.emptyMap,new U(g.break)]:Xt.emptyMap;n=li.createCheck(n,r);let a=[],c=0;for(let f of i)a[c++]=[ui(f,t,n),ui(o?r.get(f):r[f],t,n)];return _p(a,t),t.addBreakTokens?[new U(g.map,s),a,new U(g.break)]:[new U(g.map,s),a]}};Qt.Map=Qt.Object;Qt.Buffer=Qt.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Qt[`${r}Array`]=Qt.DataView;function ui(r,e={},t){let n=Gu(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||Qt[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=Qt[n];if(!i)throw new Error(`${Hs} unsupported type: ${n}`);return i(r,n,e,t)}function _p(r,e){e.mapSorter&&r.sort(e.mapSorter)}function Up(r,e){let t=Array.isArray(r[0])?r[0][0]:r[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(t.type!==n.type)return t.type.compare(n.type);let o=t.type.major,i=Yl[o].compareTokens(t,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Zl(r,e,t,n){if(Array.isArray(e))for(let o of e)Zl(r,o,t,n);else t[e.type.major](r,e,n)}function Dp(r,e,t){let n=ui(r,t);if(!Array.isArray(n)&&t.quickEncodeToken){let o=t.quickEncodeToken(n);if(o)return o;let i=e[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,t),a=new Nn(s);if(i(a,n,t),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Ms(a.chunks[0])}}return Gs.reset(),Zl(Gs,n,e,t),Gs.toBytes(!0)}function js(r,e){return e=Object.assign({},Cp,e),Dp(r,Yl,e)}var Lp={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},fi=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=Qe[e];if(t===void 0){let n=R[e];if(!n)throw new Error(`${K} 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}},Ln=Symbol.for("DONE"),hi=Symbol.for("BREAK");function Vp(r,e,t){let n=[];for(let o=0;o<r.value;o++){let i=en(e,t);if(i===hi){if(r.value===1/0)break;throw new Error(`${K} got unexpected break to lengthed array`)}if(i===Ln)throw new Error(`${K} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function Op(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=en(e,t);if(a===hi){if(r.value===1/0)break;throw new Error(`${K} got unexpected break to lengthed map`)}if(a===Ln)throw new Error(`${K} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${K} non-string keys not supported (got ${typeof a})`);if(t.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${K} found repeat map key "${a}"`);let c=en(e,t);if(c===Ln)throw new Error(`${K} 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 en(r,e){if(r.done())return Ln;let t=r.next();if(t.type===g.break)return hi;if(t.type.terminal)return t.value;if(t.type===g.array)return Vp(t,r,e);if(t.type===g.map)return Op(t,r,e);if(t.type===g.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=en(r,e);return e.tags[t.value](n)}throw new Error(`${K} tag not supported (${t.value})`)}throw new Error("unsupported")}function Wl(r,e){if(!(r instanceof Uint8Array))throw new Error(`${K} data to decode must be a Uint8Array`);e=Object.assign({},Lp,e);let t=e.tokenizer||new fi(r,e),n=en(t,e);if(n===Ln)throw new Error(`${K} did not find any content to decode`);if(n===hi)throw new Error(`${K} got unexpected break`);return[n,r.subarray(t.pos())]}function Ys(r,e){let[t,n]=Wl(r,e);if(n.length>0)throw new Error(`${K} too many terminals, data makes no sense`);return t}var _e=ht(Xo(),1);var Jl=Dt("ipns:utils"),Xl=J("/ipns/"),Pp=114,Ql=async(r,e)=>{if(e==null||r==null){let n=new Error("one or more of the provided parameters are not defined");throw Jl.error(n),(0,_e.default)(n,Fs)}let t;if(e.pubKey!=null){try{t=Vs(e.pubKey)}catch(o){throw Jl.error(o),o}if(!(await Pa(e.pubKey)).equals(r))throw(0,_e.default)(new Error("Embedded public key did not match PeerID"),$u)}else r.publicKey!=null&&(t=Vs(r.publicKey));if(t!=null)return t;throw(0,_e.default)(new Error("no public key is available"),Fs)},ef=(r,e,t)=>{let n=J(e);return ir([r,t,n])},di=r=>{let e=J("ipns-signature:");return ir([e,r])},Zs=r=>"signatureV1"in r?Ee.encode({value:J(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:J(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):Ee.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data});function lt(r){let e=Ee.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,_e.default)(new Error("missing data or signatureV2"),It);let t=nf(e.data),n=Ws(t.Value),o=oe(t.Validity);if(e.value!=null&&e.signatureV1!=null)return Mp(e),{value:n,validityType:Ee.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:Ee.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 pi=r=>ir([Xl,r.toBytes()]),tf=r=>qi(r.slice(Xl.length)),rf=(r,e,t,n,o)=>{let i;if(e===Ee.ValidityType.EOL)i=0;else throw(0,_e.default)(new Error("Unknown validity type"),Cn);return js({Value:r,Validity:t,ValidityType:i,Sequence:n,TTL:o})},nf=r=>{let e=Ys(r);if(e.ValidityType===0)e.ValidityType=Ee.ValidityType.EOL;else throw(0,_e.default)(new Error("Unknown validity type"),Cn);return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e},Ws=r=>{if(r!=null){if(ha(r))return`/ipns/${r.toCID().toString(Hn)}`;if(r instanceof Uint8Array){let n=oe(r);n.startsWith("/")&&(r=n)}let e=r.toString().trim();if(e.startsWith("/")&&e.length>1)return e;let t=Re.asCID(r);if(t!=null)return t.code===Pp?`/ipns/${t.toString(Hn)}`:`/ipfs/${t.toV1().toString()}`;try{return r instanceof Uint8Array?`/ipfs/${Re.decode(r).toV1().toString()}`:`/ipfs/${Re.parse(e).toV1().toString()}`}catch{}}throw(0,_e.default)(new Error("Value must be a valid content path starting with /"),Ku)},Mp=r=>{if(r.data==null)throw(0,_e.default)(new Error("Record data is missing"),Hu);let e=nf(r.data);if(!fe(e.Value,r.value??new Uint8Array(0)))throw(0,_e.default)(new Error('Field "value" did not match between protobuf and CBOR'),It);if(!fe(e.Validity,r.validity??new Uint8Array(0)))throw(0,_e.default)(new Error('Field "validity" did not match between protobuf and CBOR'),It);if(e.ValidityType!==r.validityType)throw(0,_e.default)(new Error('Field "validityType" did not match between protobuf and CBOR'),It);if(e.Sequence!==r.sequence)throw(0,_e.default)(new Error('Field "sequence" did not match between protobuf and CBOR'),It);if(e.TTL!==r.ttl)throw(0,_e.default)(new Error('Field "ttl" did not match between protobuf and CBOR'),It)};var Hp=Dt("ipns"),Kp=tt.code,sf=60*60*1e9,$p="/ipns/",Fx=$p.length,af={v1Compatible:!0,ttlNs:sf};async function cf(r,e,t,n,o=af){let i=new of.default(Date.now()+Number(n)),s=Ee.ValidityType.EOL,a=BigInt(o.ttlNs!=null?o.ttlNs:sf);return qp(r,e,t,s,i.toString(),a,o)}var qp=async(r,e,t,n,o,i,s=af)=>{t=BigInt(t);let a=J(o),c=Ws(e),f=J(c);if(r.privateKey==null)throw(0,Js.default)(new Error("Missing private key"),qu);let u=await Lu(r.privateKey),l=rf(f,n,a,t,i),d=di(l),v=await u.sign(d),m;if(r.publicKey!=null){let h=nr(r.toBytes());(h.code!==Kp||!fe(r.publicKey,h.digest))&&(m=r.publicKey)}if(s.v1Compatible===!0){let h=await zp(u,f,n,a),p={value:c,signatureV1:h,validity:o,validityType:n,sequence:t,ttl:i,signatureV2:v,data:l};return m!=null&&(p.pubKey=m),p}else{let h={value:c,validity:o,validityType:n,sequence:t,ttl:i,signatureV2:v,data:l};return m!=null&&(h.pubKey=m),h}};var zp=async(r,e,t,n)=>{try{let o=ef(e,t,n);return await r.sign(o)}catch(o){throw Hp.error("record signature creation failed",o),(0,Js.default)(new Error("record signature creation failed"),Mu)}};var Xs=ht(ei(),1);function gi(r,e){let t=e.map((n,o)=>({record:lt(n),index:o}));return t.sort((n,o)=>{let i=n.record.sequence,s=o.record.sequence;if(i>s)return-1;if(i<s)return 1;if(n.record.validityType===Ee.ValidityType.EOL&&o.record.validityType===Ee.ValidityType.EOL){let a=Xs.default.fromString(n.record.validity).toDate(),c=Xs.default.fromString(o.record.validity).toDate();if(a.getTime()>c.getTime())return-1;if(a.getTime()<c.getTime())return 1}return 0}),t[0].index}var Vn=ht(Xo(),1),uf=ht(ei(),1);var mi=Dt("ipns:validator"),Gp=1024*10,jp=async(r,e)=>{let t=lt(e),n;try{let o=di(t.data);n=await r.verify(o,t.signatureV2)}catch{n=!1}if(!n)throw mi.error("record signature verification failed"),(0,Vn.default)(new Error("record signature verification failed"),It);if(t.validityType===Ee.ValidityType.EOL){if(uf.default.fromString(t.validity).toDate().getTime()<Date.now())throw mi.error("record has expired"),(0,Vn.default)(new Error("record has expired"),Pu)}else if(t.validityType!=null)throw mi.error("unrecognized validity type"),(0,Vn.default)(new Error("unrecognized validity type"),Cn);mi("ipns record for %s is valid",t.value)};async function yi(r,e){if(e.byteLength>Gp)throw(0,Vn.default)(new Error("record too large"),zu);let t=tf(r),n=lt(e),o=await Ql(t,n);await jp(o,e)}var Ce=class extends Event{constructor(e,t){super(e),this.detail=t}};var Wp=ht(ff(),1);var Ct;(function(r){r[r.A=1]="A",r[r.CNAME=5]="CNAME",r[r.TXT=16]="TXT",r[r.AAAA=28]="AAAA"})(Ct||(Ct={}));var Jp=32;async function hf(r,e,t,n,o={}){if(e===0)throw new Error("recursion limit exceeded");n("query %s for TXT and CNAME records",r);let s=(await t.query(r,{...o,types:[Ct.TXT]})).Answer.sort((f,u)=>f.data.localeCompare(u.data));n("found %d TXT records for %s",s.length,r);for(let f of s)try{let u=f.data;if(u.startsWith('"')&&u.endsWith('"')&&(u=u.substring(1,u.length-1)),!u.startsWith("dnslink="))continue;n("%s TXT %s",f.name,u),u=u.replace("dnslink=","");let[,l,d,...v]=u.split("/");if(l==="ipfs")try{return{value:`/ipfs/${Re.parse(d)}${v.length>0?`/${v.join("/")}`:""}`,answer:f}}catch{}else if(l==="ipns"){try{return{value:`/ipns/${cn(d)}${v.length>0?`/${v.join("/")}`:""}`,answer:f}}catch{}return await wi(d,e-1,t,n,o)}else{if(l==="dnslink")return await wi(d,e-1,t,n,o);n('unknown protocol "%s" in DNSLink record for domain: %s',l,r);continue}}catch(u){n.error("could not parse DNS link record for domain %s, %s",r,f.data,u)}n("no DNSLink records found for %s, falling back to CNAME",r);let c=(await t.query(r,{...o,types:[Ct.CNAME]})).Answer.sort((f,u)=>f.data.localeCompare(u.data));n("found %d CNAME records for %s",c.length,r);for(let f of c)try{return await wi(f.data,e-1,t,n,o)}catch(u){n.error("domain %s cname %s had no DNSLink records",r,f.data,u)}throw new $(`No DNSLink records found for domain: ${r}`,"ERR_DNSLINK_NOT_FOUND")}async function wi(r,e,t,n,o={}){if(e===0)throw new Error("recursion limit exceeded");r.startsWith("_dnslink.")||(r=`_dnslink.${r}`);try{return await hf(r,e,t,n,o)}catch(i){if(i.code!=="ENOTFOUND"&&i.code!=="ERR_DNSLINK_NOT_FOUND"&&i.code!=="ENODATA")throw i;return r.startsWith("_dnslink.")?r=r.replace("_dnslink.",""):r=`_dnslink.${r}`,await hf(r,e,t,n,o)}}async function df(r,e,t,n={}){return wi(r,n.maxRecursiveDepth??Jp,e,t,n)}var Qs=class{routing;constructor(e){this.routing=e}async put(e,t,n={}){try{await this.routing.put(e,t,n)}catch(o){n.onProgress?.(new Ce("ipns:routing:helia:error",o))}}async get(e,t={}){try{return await this.routing.get(e,t)}catch(n){t.onProgress?.(new Ce("ipns:routing:helia:error",n))}throw new Error("Not found")}};function pf(r){return new Qs(r)}var On;(function(r){let e;r.codec=()=>(e==null&&(e=zt((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.key!=null&&t.key.byteLength>0&&(n.uint32(10),n.bytes(t.key)),t.value!=null&&t.value.byteLength>0&&(n.uint32(18),n.bytes(t.value)),t.timeReceived!=null&&t.timeReceived!==""&&(n.uint32(42),n.string(t.timeReceived)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={key:zi(0),value:zi(0),timeReceived:""},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{i.key=t.bytes();break}case 2:{i.value=t.bytes();break}case 5:{i.timeReceived=t.string();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>qt(t,r.codec()),r.decode=(t,n)=>$t(t,r.codec(),n)})(On||(On={}));function gf(r){let e=r.getUTCFullYear(),t=String(r.getUTCMonth()+1).padStart(2,"0"),n=String(r.getUTCDate()).padStart(2,"0"),o=String(r.getUTCHours()).padStart(2,"0"),i=String(r.getUTCMinutes()).padStart(2,"0"),s=String(r.getUTCSeconds()).padStart(2,"0"),a=r.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${e}-${t}-${n}T${o}:${i}:${s}.${c}Z`}function mf(r){let e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),t=String(r).trim().match(e);if(t==null)throw new Error("Invalid format");let n=parseInt(t[1],10),o=parseInt(t[2],10)-1,i=parseInt(t[3],10),s=parseInt(t[4],10),a=parseInt(t[5],10),c=parseInt(t[6],10),f=parseInt(t[7].slice(0,-6),10);return new Date(Date.UTC(n,o,i,s,a,c,f))}var yr=class r{key;value;timeReceived;constructor(e,t,n){if(!(e instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(t instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=e,this.value=t,this.timeReceived=n}serialize(){return On.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:gf(this.timeReceived)}}static deserialize(e){let t=On.decode(e);return new r(t.key,t.value,new Date(t.timeReceived))}static fromDeserialized(e){let t=mf(e.timeReceived);if(e.key==null)throw new Error("key missing from deserialized object");if(e.value==null)throw new Error("value missing from deserialized object");return new r(e.key,e.value,t)}};var yf;(function(r){r[r.SEND_QUERY=0]="SEND_QUERY",r[r.PEER_RESPONSE=1]="PEER_RESPONSE",r[r.FINAL_PEER=2]="FINAL_PEER",r[r.QUERY_ERROR=3]="QUERY_ERROR",r[r.PROVIDER=4]="PROVIDER",r[r.VALUE=5]="VALUE",r[r.ADD_PEER=6]="ADD_PEER",r[r.DIAL_PEER=7]="DIAL_PEER"})(yf||(yf={}));function bi(r){return new Yr("/dht/record/"+oe(r,"base32"),!1)}function wf(r){return{async put(e,t,n={}){try{let o=bi(e);try{let s=await r.get(o),a=yr.deserialize(s);if(fe(a.value,t))return}catch(s){if(s.code!=="ERR_NOT_FOUND")throw s}let i=new yr(e,t,new Date);n.onProgress?.(new Ce("ipns:routing:datastore:put")),await r.put(o,i.serialize(),n)}catch(o){throw n.onProgress?.(new Ce("ipns:routing:datastore:error",o)),o}},async get(e,t={}){try{let n=bi(e);t.onProgress?.(new Ce("ipns:routing:datastore:get"));let o=await r.get(n,t),i=yr.deserialize(o);return{record:i.value,created:i.timeReceived}}catch(n){throw t.onProgress?.(new Ce("ipns:routing:datastore:error",n)),n}},async has(e,t={}){let n=bi(e);return r.has(n,t)},async delete(e,t){let n=bi(e);return r.delete(n,t)}}}var Nt=Dt("helia:ipns"),Qp=60*1e3,ra=60*Qp,eg=24*ra,ea=23*ra,tg=BigInt(ra)*1000000n,ta=class{routers;localStore;timeout;dns;log;constructor(e,t=[]){this.routers=[pf(e.routing),...t],this.localStore=wf(e.datastore),this.dns=e.dns,this.log=e.logger.forComponent("helia:ipns")}async publish(e,t,n={}){try{let o=1n,i=pi(e);if(await this.localStore.has(i,n)){let{record:c}=await this.localStore.get(i,n);o=lt(c).sequence+1n}let s=await cf(e,t,o,n.lifetime??eg,n),a=Zs(s);return await this.localStore.put(i,a,n),n.offline!==!0&&await Promise.all(this.routers.map(async c=>{await c.put(i,a,n)})),s}catch(o){throw n.onProgress?.(new Ce("ipns:publish:error",o)),o}}async resolve(e,t={}){let n=pi(e),o=await this.#t(n,t);return{...await this.#e(o.value,t),record:o}}async resolveDNSLink(e,t={}){let n=await df(e,this.dns,this.log,t);return{...await this.#e(n.value,t),answer:n.answer}}republish(e={}){if(this.timeout!=null)throw new Error("Republish is already running");e.signal?.addEventListener("abort",()=>{clearTimeout(this.timeout)});async function t(){let n=Date.now();e.onProgress?.(new Ce("ipns:republish:start"));let i=Date.now()-n,s=ea-i;s<0&&(s=e.interval??ea),setTimeout(()=>{t().catch(a=>{Nt.error("error republishing",a)})},s)}this.timeout=setTimeout(()=>{t().catch(n=>{Nt.error("error republishing",n)})},e.interval??ea)}async#e(e,t={}){let n=e.split("/");try{let o=n[1];if(o==="ipns"){let{cid:i}=await this.resolve(cn(n[2]),t),s=n.slice(3).join("/");return{cid:i,path:s}}else if(o==="ipfs"){let i=Re.parse(n[2]),s=n.slice(3).join("/");return{cid:i,path:s}}}catch(o){Nt.error("error parsing ipfs path",o)}throw Nt.error("invalid ipfs path %s",e),new Error("Invalid value")}async#t(e,t={}){let n=[];if(await this.localStore.has(e,t))if(Nt("record is present in the cache"),t.nocache!==!0)try{let{record:a,created:c}=await this.localStore.get(e,t);this.log("record retrieved from cache"),await yi(e,a),this.log("record was valid");let f=lt(a),u=Number((f.ttl??tg)/1000000n);if(c.getTime()+u>Date.now())return this.log("record TTL was valid"),f;if(t.offline===!0)return this.log("record TTL has been reached but we are resolving offline-only, returning record"),f;this.log("record TTL has been reached, searching routing for updates"),n.push(a)}catch(a){this.log("cached record was invalid",a),await this.localStore.delete(e,t)}else Nt("ignoring local cache due to nocache=true option");if(t.offline===!0)throw new $("Record was not present in the cache or has expired","ERR_NOT_FOUND");Nt("did not have record locally");let i=0;if(await Promise.all(this.routers.map(async a=>{let c;try{c=await a.get(e,{...t,validate:!1})}catch(f){Nt.error("error finding IPNS record",f);return}try{await yi(e,c),n.push(c)}catch(f){i++,Nt.error("error finding IPNS record",f)}})),n.length===0)throw i>0?new $(`${i>1?`${i} records`:"Record"} found for routing key ${i>1?"were":"was"} invalid`,"ERR_RECORDS_FAILED_VALIDATION"):new $("Could not find record for routing key","ERR_NOT_FOUND");let s=n[gi(e,n)];return await this.localStore.put(e,s,t),lt(s)}};function rg(r,{routers:e=[]}={}){return new ta(r,e)}return _f(ng);})();
7
+ `)}`:`${t} :`}};_c=Gt;_.Constructed=_c;Gt.NAME="CONSTRUCTED";var go=class extends Se{fromBER(e,t,n){return t}toBER(e){return We}};go.override="EndOfContentValueBlock";var Uc,mo=class extends xe{constructor(e={}){super(e,go),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Uc=mo;_.EndOfContent=Uc;mo.NAME=wn;var Dc,jt=class extends xe{constructor(e={}){super(e,Se),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}`}};Dc=jt;_.Null=Dc;jt.NAME="NULL";var yo=class extends At(Se){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=j.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=j.BufferSourceConverter.toUint8Array(e);return Bt(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,ws.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};yo.NAME="BooleanValueBlock";var Lc,wo=class extends xe{constructor(e={}){super(e,yo),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}`}};Lc=wo;_.Boolean=Lc;wo.NAME="BOOLEAN";var bo=class extends At(st){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=st.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===wn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==Ic)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?st.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};bo.NAME="OctetStringValueBlock";var Vc,Et=class r extends xe{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},bo),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=jo(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?Gt.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${j.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 j.BufferSourceConverter.concat(e)}};Vc=Et;_.OctetString=Vc;Et.NAME=Ic;var xo=class extends At(st){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=st.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===wn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Tc)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=j.BufferSourceConverter.toUint8Array(e);if(!Bt(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=jo(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 st.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return We;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}}};xo.NAME="BitStringValueBlock";var Oc,Kr=class extends xe{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},xo),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 Gt.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)}`}}};Oc=Kr;_.BitString=Oc;Kr.NAME=Tc;var Fc;function A0(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 kc(r){if(r>=mn.length)for(let e=mn.length;e<=r;e++){let t=new Uint8Array([0]),n=mn[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)),mn.push(n)}return mn[r]}function S0(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 bn=class extends At(Se){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=ws.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Ac(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=S0(kc(n),t),s="-";break;default:t=A0(t,kc(n))}n++,o>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(s+=Rc.charAt(t[c]));return a===!1&&(s+=Rc.charAt(0)),s}};Fc=bn;bn.NAME="IntegerValueBlock";Object.defineProperty(Fc.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Pc,ue=class r extends xe{constructor(e={}){super(e,bn),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return co(),BigInt(this.valueBlock.toString())}static fromBigInt(e){co();let t=BigInt(e),n=new yn,o=t.toString(16).replace(/^-/,""),i=new Uint8Array(j.Convert.FromHex(o));if(t<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${j.Convert.ToHex(a)}`)+t,u=j.BufferSourceConverter.toUint8Array(j.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()}`}};Pc=ue;_.Integer=Pc;ue.NAME="INTEGER";var Mc,Eo=class extends ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Mc=Eo;_.Enumerated=Mc;Eo.NAME="ENUMERATED";var xn=class extends At(Se){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=j.BufferSourceConverter.toUint8Array(e);if(!Bt(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=hr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){co();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=zt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",We;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=j.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}}};xn.NAME="sidBlock";var vo=class extends Se{constructor({value:e=$r,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new xn;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,We;t.push(o)}return bs(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 xn;if(o>Number.MAX_SAFE_INTEGER){co();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}};vo.NAME="ObjectIdentifierValueBlock";var Hc,Ze=class extends xe{constructor(e={}){super(e,vo),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()}}};Hc=Ze;_.ObjectIdentifier=Hc;Ze.NAME="OBJECT IDENTIFIER";var En=class extends At(xt){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let o=j.BufferSourceConverter.toUint8Array(e);if(!Bt(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=hr(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=zt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",We;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=j.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};En.NAME="relativeSidBlock";var Bo=class extends Se{constructor({value:e=$r,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new En;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e,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,We;n.push(i)}return bs(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 En;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}};Bo.NAME="RelativeObjectIdentifierValueBlock";var Kc,Ao=class extends xe{constructor(e={}){super(e,Bo),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()}}};Kc=Ao;_.RelativeObjectIdentifier=Kc;Ao.NAME="RelativeObjectIdentifier";var $c,pe=class extends Gt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};$c=pe;_.Sequence=$c;pe.NAME="SEQUENCE";var qc,So=class extends Gt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};qc=So;_.Set=qc;So.NAME="SET";var Ro=class extends At(Se){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=$r}toJSON(){return{...super.toJSON(),value:this.value}}};Ro.NAME="StringValueBlock";var ko=class extends Ro{};ko.NAME="SimpleStringValueBlock";var Te=class extends fo{constructor({...e}={}){super(e,ko)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,j.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}};Te.NAME="SIMPLE STRING";var Io=class extends Te{fromBuffer(e){this.valueBlock.valueHexView=j.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=j.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=j.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(j.Convert.FromUtf8String(e)),this.valueBlock.value=e}};Io.NAME="Utf8StringValueBlock";var zc,vt=class extends Io{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};zc=vt;_.Utf8String=zc;vt.NAME="UTF8String";var To=class extends Te{fromBuffer(e){this.valueBlock.value=j.Convert.ToUtf16String(e),this.valueBlock.valueHexView=j.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(j.Convert.FromUtf16String(e))}};To.NAME="BmpStringValueBlock";var Gc,Co=class extends To{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Gc=Co;_.BmpString=Gc;Co.NAME="BMPString";var No=class extends Te{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=zt(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}};No.NAME="UniversalStringValueBlock";var jc,_o=class extends No{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};jc=_o;_.UniversalString=jc;_o.NAME="UniversalString";var Yc,Uo=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Yc=Uo;_.NumericString=Yc;Uo.NAME="NumericString";var Zc,Do=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Zc=Do;_.PrintableString=Zc;Do.NAME="PrintableString";var Wc,Lo=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Wc=Lo;_.TeletexString=Wc;Lo.NAME="TeletexString";var Jc,Vo=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Jc=Vo;_.VideotexString=Jc;Vo.NAME="VideotexString";var Xc,Oo=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Xc=Oo;_.IA5String=Xc;Oo.NAME="IA5String";var Qc,Fo=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Qc=Fo;_.GraphicString=Qc;Fo.NAME="GraphicString";var eu,vn=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};eu=vn;_.VisibleString=eu;vn.NAME="VisibleString";var tu,Po=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};tu=Po;_.GeneralString=tu;Po.NAME="GeneralString";var ru,Mo=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};ru=Mo;_.CharacterString=ru;Mo.NAME="CharacterString";var nu,Bn=class extends vn{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,j.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]=Ne(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Ne(this.month,2),t[2]=Ne(this.day,2),t[3]=Ne(this.hour,2),t[4]=Ne(this.minute,2),t[5]=Ne(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}}};nu=Bn;_.UTCTime=nu;Bn.NAME="UTCTime";var ou,Ho=class extends Bn{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("+"),E="";if(d===-1&&(d=n.indexOf("-"),l=-1),d!==-1){if(E=n.substring(d+1),n=n.substring(0,d),E.length!==2&&E.length!==4)throw new Error("Wrong input string for conversion");let m=parseInt(E.substring(0,2),10);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*m,E.length===4){if(m=parseInt(E.substring(2,4),10),isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");c=l*m}}}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(Ne(this.year,4)),t.push(Ne(this.month,2)),t.push(Ne(this.day,2)),t.push(Ne(this.hour,2)),t.push(Ne(this.minute,2)),t.push(Ne(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Ne(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};ou=Ho;_.GeneralizedTime=ou;Ho.NAME="GeneralizedTime";var iu,Ko=class extends vt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};iu=Ko;_.DATE=iu;Ko.NAME="DATE";var su,$o=class extends vt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};su=$o;_.TimeOfDay=su;$o.NAME="TimeOfDay";var au,qo=class extends vt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};au=qo;_.DateTime=au;qo.NAME="DateTime";var cu,zo=class extends vt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};cu=zo;_.Duration=cu;zo.NAME="Duration";var uu,Go=class extends vt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};uu=Go;_.TIME=uu;Go.NAME="TIME";function k0(r){let{result:e}=qr(r),t=e.valueBlock.value;return{n:oe(at(t[1].toBigInt()),"base64url"),e:oe(at(t[2].toBigInt()),"base64url"),d:oe(at(t[3].toBigInt()),"base64url"),p:oe(at(t[4].toBigInt()),"base64url"),q:oe(at(t[5].toBigInt()),"base64url"),dp:oe(at(t[6].toBigInt()),"base64url"),dq:oe(at(t[7].toBigInt()),"base64url"),qi:oe(at(t[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function I0(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 $("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new pe({value:[new ue({value:0}),ue.fromBigInt(ct(J(r.n,"base64url"))),ue.fromBigInt(ct(J(r.e,"base64url"))),ue.fromBigInt(ct(J(r.d,"base64url"))),ue.fromBigInt(ct(J(r.p,"base64url"))),ue.fromBigInt(ct(J(r.q,"base64url"))),ue.fromBigInt(ct(J(r.dp,"base64url"))),ue.fromBigInt(ct(J(r.dq,"base64url"))),ue.fromBigInt(ct(J(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function T0(r){let{result:e}=qr(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:oe(at(t[0].toBigInt()),"base64url"),e:oe(at(t[1].toBigInt()),"base64url")}}function C0(r){if(r.n==null||r.e==null)throw new $("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new pe({value:[new pe({value:[new Ze({value:"1.2.840.113549.1.1.1"}),new jt]}),new Kr({valueHex:new pe({value:[ue.fromBigInt(ct(J(r.n,"base64url"))),ue.fromBigInt(ct(J(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function at(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 ct(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 N0=16,Es=32,vs=1e4;async function _0(r,e){let t=ke.get(),o=new pe({value:[new ue({value:0}),new pe({value:[new Ze({value:"1.2.840.113549.1.1.1"}),new jt]}),new Et({valueHex:r.marshal()})]}).toBER(),i=new Uint8Array(o,0,o.byteLength),s=fr(N0),a=await ms(an,e,s,{c:vs,dkLen:Es}),c=fr(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 pe({value:[new Et({valueHex:s}),new ue({value:vs}),new ue({value:Es}),new pe({value:[new Ze({value:"1.2.840.113549.2.11"}),new jt]})]}),d=new pe({value:[new Ze({value:"1.2.840.113549.1.5.13"}),new pe({value:[new pe({value:[new Ze({value:"1.2.840.113549.1.5.12"}),l]}),new pe({value:[new Ze({value:"2.16.840.1.101.3.4.1.42"}),new Et({valueHex:c})]})]})]}),m=new pe({value:[d,new Et({valueHex:u})]}).toBER(),h=new Uint8Array(m,0,m.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...oe(h,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
8
+ `)}async function U0(r,e){let t=ke.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let o=J(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:i}=qr(o),{iv:s,salt:a,iterations:c,keySize:f,cipherText:u}=D0(i),l=await ms(an,e,a,{c,dkLen:f}),d=await t.subtle.importKey("raw",l,"AES-CBC",!1,["decrypt"]),E=An(await t.subtle.decrypt({name:"AES-CBC",iv:s},d,u)),{result:m}=qr(E);n=lu(m)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let o=J(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:i}=qr(o);n=lu(i)}else throw new $("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return Bs(n)}function D0(r){let e=r.valueBlock.value[0];if(e.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.13")throw new $("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 $("Only pkcs5PBKDF2 key derivation functions are supported","ERR_INVALID_PARAMS");let i=n.valueBlock.value[1],s=An(i.valueBlock.value[0].getValue()),a=vs,c=Es;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 $("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 $("Only AES-CBC encryption schemes are supported","ERR_INVALID_PARAMS")}}}}let l=An(f.valueBlock.value[1].getValue());return{cipherText:An(r.valueBlock.value[1].getValue()),salt:s,iterations:a,keySize:c,iv:l}}function lu(r){return An(r.valueBlock.value[2].getValue())}function An(r){return new Uint8Array(r,0,r.byteLength)}async function fu(r){let e=await ke.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 pu(e);return{privateKey:t[0],publicKey:t[1]}}async function As(r){let t=[await ke.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await L0(r)],n=await pu({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function hu(r,e){let t=await ke.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await ke.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function du(r,e,t){let n=await ke.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return ke.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function pu(r){if(r.privateKey==null||r.publicKey==null)throw new $("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([ke.get().subtle.exportKey("jwk",r.privateKey),ke.get().subtle.exportKey("jwk",r.publicKey)])}async function L0(r){return ke.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 Yo(r){if(r.kty!=="RSA")throw new $("invalid key type","ERR_INVALID_KEY_TYPE");if(r.n==null)throw new $("invalid key modulus","ERR_INVALID_KEY_MODULUS");return J(r.n,"base64url").length*8}var Rn=8192,Sn=class{_key;constructor(e){this._key=e}verify(e,t){return du(this._key,t,e)}marshal(){return Yt.jwkToPkix(this._key)}get bytes(){return ot.encode({Type:ne.RSA,Data:this.marshal()}).subarray()}equals(e){return fe(this.bytes,e.bytes)}hash(){let e=be.digest(this.bytes);return He(e)?e.then(({bytes:t})=>t):e.bytes}},zr=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return fr(16)}sign(e){return hu(this._key,e)}get public(){if(this._publicKey==null)throw new $("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new Sn(this._publicKey)}marshal(){return Yt.jwkToPkcs1(this._key)}get bytes(){return it.encode({Type:ne.RSA,Data:this.marshal()}).subarray()}equals(e){return fe(this.bytes,e.bytes)}hash(){let e=be.digest(this.bytes);return He(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return oe(e,"base58btc")}async export(e,t="pkcs-8"){if(t==="pkcs-8")return Yt.exportToPem(this,e);if(t==="libp2p-key")return Fr(this.bytes,e);throw new $(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function Bs(r){let e=Yt.pkcs1ToJwk(r);if(Yo(e)>Rn)throw new $("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await As(e);return new zr(t.privateKey,t.publicKey)}function O0(r){let e=Yt.pkixToJwk(r);if(Yo(e)>Rn)throw new $("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new Sn(e)}async function F0(r){if(Yo(r)>Rn)throw new $("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await As(r);return new zr(e.privateKey,e.publicKey)}async function P0(r){if(r>Rn)throw new $("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await fu(r);return new zr(e.privateKey,e.publicKey)}var Cs={};de(Cs,{Secp256k1PrivateKey:()=>In,Secp256k1PublicKey:()=>kn,generateKeyPair:()=>X0,unmarshalSecp256k1PrivateKey:()=>W0,unmarshalSecp256k1PublicKey:()=>J0});var M0=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]),Zt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Wt=new Uint32Array(64),Rs=class extends Dr{constructor(){super(64,32,8,!1),this.A=Zt[0]|0,this.B=Zt[1]|0,this.C=Zt[2]|0,this.D=Zt[3]|0,this.E=Zt[4]|0,this.F=Zt[5]|0,this.G=Zt[6]|0,this.H=Zt[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)Wt[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let d=Wt[l-15],E=Wt[l-2],m=Ge(d,7)^Ge(d,18)^d>>>3,h=Ge(E,17)^Ge(E,19)^E>>>10;Wt[l]=h+Wt[l-7]+m+Wt[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=Ge(a,6)^Ge(a,11)^Ge(a,25),E=u+d+Ha(a,c,f)+M0[l]+Wt[l]|0,h=(Ge(n,2)^Ge(n,13)^Ge(n,22))+Ka(n,o,i)|0;u=f,f=c,c=a,a=s+E|0,s=i,i=o,o=n,n=E+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(){Wt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var gu=zn(()=>new Rs);function H0(r){let e=un(r);nt(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:K0,hexToBytes:$0}=Yn,dr={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){let{Err:e}=dr;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:K0(n),l:r.subarray(t+2)}},toSig(r){let{Err:e}=dr,t=typeof r=="string"?$0(r):r;Lr(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}=dr._parseInt(t.subarray(2)),{d:s,l:a}=dr._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}`}},St=BigInt(0),$e=BigInt(1),Sw=BigInt(2),mu=BigInt(3),Rw=BigInt(4);function q0(r){let e=H0(r),{Fp:t}=e,n=e.toBytes||((m,h,p)=>{let b=h.toAffine();return yt(Uint8Array.from([4]),t.toBytes(b.x),t.toBytes(b.y))}),o=e.fromBytes||(m=>{let h=m.subarray(1),p=t.fromBytes(h.subarray(0,t.BYTES)),b=t.fromBytes(h.subarray(t.BYTES,2*t.BYTES));return{x:p,y:b}});function i(m){let{a:h,b:p}=e,b=t.sqr(m),k=t.mul(b,m);return t.add(t.add(k,t.mul(m,h)),p)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function s(m){return typeof m=="bigint"&&St<m&&m<e.n}function a(m){if(!s(m))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(m){let{allowedPrivateKeyLengths:h,nByteLength:p,wrapPrivateKey:b,n:k}=e;if(h&&typeof m!="bigint"){if(Ot(m)&&(m=gt(m)),typeof m!="string"||!h.includes(m.length))throw new Error("Invalid key");m=m.padStart(p*2,"0")}let v;try{v=typeof m=="bigint"?m:mt(ae("private key",m,p))}catch{throw new Error(`private key must be ${p} bytes, hex or bigint, not ${typeof m}`)}return b&&(v=ee(v,k)),a(v),v}let f=new Map;function u(m){if(!(m instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(h,p,b){if(this.px=h,this.py=p,this.pz=b,h==null||!t.isValid(h))throw new Error("x required");if(p==null||!t.isValid(p))throw new Error("y required");if(b==null||!t.isValid(b))throw new Error("z required")}static fromAffine(h){let{x:p,y:b}=h||{};if(!h||!t.isValid(p)||!t.isValid(b))throw new Error("invalid affine point");if(h instanceof l)throw new Error("projective point not allowed");let k=v=>t.eql(v,t.ZERO);return k(p)&&k(b)?l.ZERO:new l(p,b,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let p=t.invertBatch(h.map(b=>b.pz));return h.map((b,k)=>b.toAffine(p[k])).map(l.fromAffine)}static fromHex(h){let p=l.fromAffine(o(ae("pointHex",h)));return p.assertValidity(),p}static fromPrivateKey(h){return l.BASE.multiply(c(h))}_setWindowSize(h){this._WINDOW_SIZE=h,f.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:h,y:p}=this.toAffine();if(!t.isValid(h)||!t.isValid(p))throw new Error("bad point: x or y not FE");let b=t.sqr(p),k=i(h);if(!t.eql(b,k))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:h}=this.toAffine();if(t.isOdd)return!t.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){u(h);let{px:p,py:b,pz:k}=this,{px:v,py:D,pz:S}=h,I=t.eql(t.mul(p,S),t.mul(v,k)),N=t.eql(t.mul(b,S),t.mul(D,k));return I&&N}negate(){return new l(this.px,t.neg(this.py),this.pz)}double(){let{a:h,b:p}=e,b=t.mul(p,mu),{px:k,py:v,pz:D}=this,S=t.ZERO,I=t.ZERO,N=t.ZERO,y=t.mul(k,k),C=t.mul(v,v),V=t.mul(D,D),T=t.mul(k,v);return T=t.add(T,T),N=t.mul(k,D),N=t.add(N,N),S=t.mul(h,N),I=t.mul(b,V),I=t.add(S,I),S=t.sub(C,I),I=t.add(C,I),I=t.mul(S,I),S=t.mul(T,S),N=t.mul(b,N),V=t.mul(h,V),T=t.sub(y,V),T=t.mul(h,T),T=t.add(T,N),N=t.add(y,y),y=t.add(N,y),y=t.add(y,V),y=t.mul(y,T),I=t.add(I,y),V=t.mul(v,D),V=t.add(V,V),y=t.mul(V,T),S=t.sub(S,y),N=t.mul(V,C),N=t.add(N,N),N=t.add(N,N),new l(S,I,N)}add(h){u(h);let{px:p,py:b,pz:k}=this,{px:v,py:D,pz:S}=h,I=t.ZERO,N=t.ZERO,y=t.ZERO,C=e.a,V=t.mul(e.b,mu),T=t.mul(p,v),O=t.mul(b,D),M=t.mul(k,S),Z=t.add(p,b),x=t.add(v,D);Z=t.mul(Z,x),x=t.add(T,O),Z=t.sub(Z,x),x=t.add(p,k);let A=t.add(v,S);return x=t.mul(x,A),A=t.add(T,M),x=t.sub(x,A),A=t.add(b,k),I=t.add(D,S),A=t.mul(A,I),I=t.add(O,M),A=t.sub(A,I),y=t.mul(C,x),I=t.mul(V,M),y=t.add(I,y),I=t.sub(O,y),y=t.add(O,y),N=t.mul(I,y),O=t.add(T,T),O=t.add(O,T),M=t.mul(C,M),x=t.mul(V,x),O=t.add(O,M),M=t.sub(T,M),M=t.mul(C,M),x=t.add(x,M),T=t.mul(O,x),N=t.add(N,T),T=t.mul(A,x),I=t.mul(Z,I),I=t.sub(I,T),T=t.mul(Z,O),y=t.mul(A,y),y=t.add(y,T),new l(I,N,y)}subtract(h){return this.add(h.negate())}is0(){return this.equals(l.ZERO)}wNAF(h){return E.wNAFCached(this,f,h,p=>{let b=t.invertBatch(p.map(k=>k.pz));return p.map((k,v)=>k.toAffine(b[v])).map(l.fromAffine)})}multiplyUnsafe(h){let p=l.ZERO;if(h===St)return p;if(a(h),h===$e)return this;let{endo:b}=e;if(!b)return E.unsafeLadder(this,h);let{k1neg:k,k1:v,k2neg:D,k2:S}=b.splitScalar(h),I=p,N=p,y=this;for(;v>St||S>St;)v&$e&&(I=I.add(y)),S&$e&&(N=N.add(y)),y=y.double(),v>>=$e,S>>=$e;return k&&(I=I.negate()),D&&(N=N.negate()),N=new l(t.mul(N.px,b.beta),N.py,N.pz),I.add(N)}multiply(h){a(h);let p=h,b,k,{endo:v}=e;if(v){let{k1neg:D,k1:S,k2neg:I,k2:N}=v.splitScalar(p),{p:y,f:C}=this.wNAF(S),{p:V,f:T}=this.wNAF(N);y=E.constTimeNegate(D,y),V=E.constTimeNegate(I,V),V=new l(t.mul(V.px,v.beta),V.py,V.pz),b=y.add(V),k=C.add(T)}else{let{p:D,f:S}=this.wNAF(p);b=D,k=S}return l.normalizeZ([b,k])[0]}multiplyAndAddUnsafe(h,p,b){let k=l.BASE,v=(S,I)=>I===St||I===$e||!S.equals(k)?S.multiplyUnsafe(I):S.multiply(I),D=v(this,p).add(v(h,b));return D.is0()?void 0:D}toAffine(h){let{px:p,py:b,pz:k}=this,v=this.is0();h==null&&(h=v?t.ONE:t.inv(k));let D=t.mul(p,h),S=t.mul(b,h),I=t.mul(k,h);if(v)return{x:t.ZERO,y:t.ZERO};if(!t.eql(I,t.ONE))throw new Error("invZ was invalid");return{x:D,y:S}}isTorsionFree(){let{h,isTorsionFree:p}=e;if(h===$e)return!0;if(p)return p(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:p}=e;return h===$e?this:p?p(l,this):this.multiplyUnsafe(e.h)}toRawBytes(h=!0){return this.assertValidity(),n(l,this,h)}toHex(h=!0){return gt(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,E=Jn(l,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:s}}function z0(r){let e=un(r);return nt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function yu(r){let e=z0(r),{Fp:t,n}=e,o=t.BYTES+1,i=2*t.BYTES+1;function s(x){return St<x&&x<t.ORDER}function a(x){return ee(x,n)}function c(x){return Zn(x,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:d}=q0({...e,toBytes(x,A,P){let B=A.toAffine(),w=t.toBytes(B.x),L=yt;return P?L(Uint8Array.from([A.hasEvenY()?2:3]),w):L(Uint8Array.from([4]),w,t.toBytes(B.y))},fromBytes(x){let A=x.length,P=x[0],B=x.subarray(1);if(A===o&&(P===2||P===3)){let w=mt(B);if(!s(w))throw new Error("Point is not on curve");let L=l(w),F;try{F=t.sqrt(L)}catch(G){let Q=G instanceof Error?": "+G.message:"";throw new Error("Point is not on curve"+Q)}let H=(F&$e)===$e;return(P&1)===1!==H&&(F=t.neg(F)),{x:w,y:F}}else if(A===i&&P===4){let w=t.fromBytes(B.subarray(0,t.BYTES)),L=t.fromBytes(B.subarray(t.BYTES,2*t.BYTES));return{x:w,y:L}}else throw new Error(`Point of length ${A} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),E=x=>gt(Pt(x,e.nByteLength));function m(x){let A=n>>$e;return x>A}function h(x){return m(x)?a(-x):x}let p=(x,A,P)=>mt(x.slice(A,P));class b{constructor(A,P,B){this.r=A,this.s=P,this.recovery=B,this.assertValidity()}static fromCompact(A){let P=e.nByteLength;return A=ae("compactSignature",A,P*2),new b(p(A,0,P),p(A,P,2*P))}static fromDER(A){let{r:P,s:B}=dr.toSig(ae("DER",A));return new b(P,B)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(A){return new b(this.r,this.s,A)}recoverPublicKey(A){let{r:P,s:B,recovery:w}=this,L=N(ae("msgHash",A));if(w==null||![0,1,2,3].includes(w))throw new Error("recovery id invalid");let F=w===2||w===3?P+e.n:P;if(F>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let H=w&1?"03":"02",z=f.fromHex(H+E(F)),G=c(F),Q=a(-L*G),Y=a(B*G),W=f.BASE.multiplyAndAddUnsafe(z,Q,Y);if(!W)throw new Error("point at infinify");return W.assertValidity(),W}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new b(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return ir(this.toDERHex())}toDERHex(){return dr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ir(this.toCompactHex())}toCompactHex(){return E(this.r)+E(this.s)}}let k={isValidPrivateKey(x){try{return u(x),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let x=Qi(e.n);return Xa(e.randomBytes(x),e.n)},precompute(x=8,A=f.BASE){return A._setWindowSize(x),A.multiply(BigInt(3)),A}};function v(x,A=!0){return f.fromPrivateKey(x).toRawBytes(A)}function D(x){let A=Ot(x),P=typeof x=="string",B=(A||P)&&x.length;return A?B===o||B===i:P?B===2*o||B===2*i:x instanceof f}function S(x,A,P=!0){if(D(x))throw new Error("first arg must be private key");if(!D(A))throw new Error("second arg must be public key");return f.fromHex(A).multiply(u(x)).toRawBytes(P)}let I=e.bits2int||function(x){let A=mt(x),P=x.length*8-e.nBitLength;return P>0?A>>BigInt(P):A},N=e.bits2int_modN||function(x){return a(I(x))},y=cn(e.nBitLength);function C(x){if(typeof x!="bigint")throw new Error("bigint expected");if(!(St<=x&&x<y))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Pt(x,e.nByteLength)}function V(x,A,P=T){if(["recovered","canonical"].some(ie=>ie in P))throw new Error("sign() legacy options not supported");let{hash:B,randomBytes:w}=e,{lowS:L,prehash:F,extraEntropy:H}=P;L==null&&(L=!0),x=ae("msgHash",x),F&&(x=ae("prehashed msgHash",B(x)));let z=N(x),G=u(A),Q=[C(G),C(z)];if(H!=null&&H!==!1){let ie=H===!0?w(t.BYTES):H;Q.push(ae("extraEntropy",ie))}let Y=yt(...Q),W=z;function ce(ie){let me=I(ie);if(!d(me))return;let ye=c(me),le=f.BASE.multiply(me).toAffine(),Be=a(le.x);if(Be===St)return;let ft=a(ye*a(W+Be*G));if(ft===St)return;let Qt=(le.x===Be?0:2)|Number(le.y&$e),Qr=ft;return L&&m(ft)&&(Qr=h(ft),Qt^=1),new b(Be,Qr,Qt)}return{seed:Y,k2sig:ce}}let T={lowS:e.lowS,prehash:!1},O={lowS:e.lowS,prehash:!1};function M(x,A,P=T){let{seed:B,k2sig:w}=V(x,A,P),L=e;return Zi(L.hash.outputLen,L.nByteLength,L.hmac)(B,w)}f.BASE._setWindowSize(8);function Z(x,A,P,B=O){let w=x;if(A=ae("msgHash",A),P=ae("publicKey",P),"strict"in B)throw new Error("options.strict was renamed to lowS");let{lowS:L,prehash:F}=B,H,z;try{if(typeof w=="string"||Ot(w))try{H=b.fromDER(w)}catch(le){if(!(le instanceof dr.Err))throw le;H=b.fromCompact(w)}else if(typeof w=="object"&&typeof w.r=="bigint"&&typeof w.s=="bigint"){let{r:le,s:Be}=w;H=new b(le,Be)}else throw new Error("PARSE");z=f.fromHex(P)}catch(le){if(le.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(L&&H.hasHighS())return!1;F&&(A=e.hash(A));let{r:G,s:Q}=H,Y=N(A),W=c(Q),ce=a(Y*W),ie=a(G*W),me=f.BASE.multiplyAndAddUnsafe(z,ce,ie)?.toAffine();return me?a(me.x)===G:!1}return{CURVE:e,getPublicKey:v,getSharedSecret:S,sign:M,verify:Z,ProjectivePoint:f,Signature:b,utils:k}}function G0(r){return{hash:r,hmac:(e,...t)=>gn(r,e,qi(...t)),randomBytes:Ur}}function wu(r,e){let t=n=>yu({...r,...G0(n)});return Object.freeze({...t(e),create:t})}var Eu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),bu=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),j0=BigInt(1),ks=BigInt(2),xu=(r,e)=>(r+e/ks)/e;function Y0(r){let e=Eu,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,E=re(d,ks,e)*f%e,m=re(E,o,e)*E%e,h=re(m,i,e)*m%e,p=re(h,a,e)*h%e,b=re(p,c,e)*p%e,k=re(b,a,e)*h%e,v=re(k,t,e)*u%e,D=re(v,s,e)*m%e,S=re(D,n,e)*f%e,I=re(S,ks,e);if(!Is.eql(Is.sqr(I),r))throw new Error("Cannot find square root");return I}var Is=Wn(Eu,void 0,void 0,{sqrt:Y0}),Je=wu({a:BigInt(0),b:BigInt(7),Fp:Is,n:bu,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=bu,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-j0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,s=BigInt("0x100000000000000000000000000000000"),a=xu(i*r,e),c=xu(-n*r,e),f=ee(r-a*t-c*o,e),u=ee(-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}}}},gu),Lw=BigInt(0);var Vw=Je.ProjectivePoint;function vu(){return Je.utils.randomPrivateKey()}function Bu(r,e){let t=be.digest(e instanceof Uint8Array?e:e.subarray());if(He(t))return t.then(({digest:n})=>Je.sign(n,r).toDERRawBytes()).catch(n=>{throw new $(String(n),"ERR_INVALID_INPUT")});try{return Je.sign(t.digest,r).toDERRawBytes()}catch(n){throw new $(String(n),"ERR_INVALID_INPUT")}}function Au(r,e,t){let n=be.digest(t instanceof Uint8Array?t:t.subarray());if(He(n))return n.then(({digest:o})=>Je.verify(e,o,r)).catch(o=>{throw new $(String(o),"ERR_INVALID_INPUT")});try{return Je.verify(e,n.digest,r)}catch(o){throw new $(String(o),"ERR_INVALID_INPUT")}}function Su(r){return Je.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Ru(r){try{Je.getPublicKey(r,!0)}catch(e){throw new $(String(e),"ERR_INVALID_PRIVATE_KEY")}}function Ts(r){try{Je.ProjectivePoint.fromHex(r)}catch(e){throw new $(String(e),"ERR_INVALID_PUBLIC_KEY")}}function ku(r){try{return Je.getPublicKey(r,!0)}catch(e){throw new $(String(e),"ERR_INVALID_PRIVATE_KEY")}}var kn=class{_key;constructor(e){Ts(e),this._key=e}verify(e,t){return Au(this._key,t,e)}marshal(){return Su(this._key)}get bytes(){return ot.encode({Type:ne.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return fe(this.bytes,e.bytes)}async hash(){let e=be.digest(this.bytes),t;return He(e)?{bytes:t}=await e:t=e.bytes,t}},In=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??ku(e),Ru(this._key),Ts(this._publicKey)}sign(e){return Bu(this._key,e)}get public(){return new kn(this._publicKey)}marshal(){return this._key}get bytes(){return it.encode({Type:ne.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return fe(this.bytes,e.bytes)}hash(){let e=be.digest(this.bytes);return He(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return oe(e,"base58btc")}async export(e,t="libp2p-key"){if(t==="libp2p-key")return Fr(this.bytes,e);throw new $(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function W0(r){return new In(r)}function J0(r){return new kn(r)}async function X0(){let r=vu();return new In(r)}var pr={rsa:Ss,ed25519:gs,secp256k1:Cs};function Iu(r){let e=Object.keys(pr).join(" / ");return new $(`invalid or unsupported key type ${r}. Must be ${e}`,"ERR_UNSUPPORTED_KEY_TYPE")}function Ns(r){let e=ot.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case ne.RSA:return pr.rsa.unmarshalRsaPublicKey(t);case ne.Ed25519:return pr.ed25519.unmarshalEd25519PublicKey(t);case ne.Secp256k1:return pr.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw Iu(e.Type??"unknown")}}async function Tu(r){let e=it.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case ne.RSA:return pr.rsa.unmarshalRsaPrivateKey(t);case ne.Ed25519:return pr.ed25519.unmarshalEd25519PrivateKey(t);case ne.Secp256k1:return pr.secp256k1.unmarshalSecp256k1PrivateKey(t);default:throw Iu(e.Type??"RSA")}}var Gs=ht(Zo(),1);var Rt="/",_u=new TextEncoder().encode(Rt),Wo=_u[0],Gr=class r{_buf;constructor(e,t){if(typeof e=="string")this._buf=J(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(t==null&&(t=!0),t&&this.clean(),this._buf.byteLength===0||this._buf[0]!==Wo)throw new Error("Invalid key")}toString(e="utf8"){return oe(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new r(e.join(Rt))}static random(){return new r(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new r(e):typeof e.uint8Array=="function"?new r(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=_u),this._buf[0]!==Wo){let e=new Uint8Array(this._buf.byteLength+1);e.fill(Wo,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Wo;)this._buf=this._buf.subarray(0,-1)}less(e){let t=this.list(),n=e.list();for(let o=0;o<t.length;o++){if(n.length<o+1)return!1;let i=t[o],s=n[o];if(i<s)return!0;if(i>s)return!1}return t.length<n.length}reverse(){return r.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(Rt).slice(1)}type(){return ep(this.baseNamespace())}name(){return tp(this.baseNamespace())}instance(e){return new r(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(Rt)||(e+=Rt),e+=this.type(),new r(e)}parent(){let e=this.list();return e.length===1?new r(Rt):new r(e.slice(0,-1).join(Rt))}child(e){return this.toString()===Rt?e:e.toString()===Rt?this:new r(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return r.withNamespaces([...this.namespaces(),...rp(e.map(t=>t.namespaces()))])}};function ep(r){let e=r.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function tp(r){let e=r.split(":");return e[e.length-1]}function rp(r){return[].concat(...r)}var Xl=ht(Jo(),1);var Uu="ERR_IPNS_EXPIRED_RECORD",Tn="ERR_UNRECOGNIZED_VALIDITY",Du="ERR_SIGNATURE_CREATION",kt="ERR_SIGNATURE_VERIFICATION";var Us="ERR_UNDEFINED_PARAMETER",Lu="ERR_INVALID_RECORD_DATA",Vu="ERR_INVALID_VALUE",Ou="ERR_INVALID_EMBEDDED_KEY",Fu="ERR_MISSING_PRIVATE_KEY",Pu="ERR_RECORD_TOO_LARGE";var Ee;(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=()=>dn(t)}(e=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=qt((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=>$t(o,r.codec()),r.decode=o=>Kt(o,r.codec())})(Ee||(Ee={}));var np=["string","number","bigint","symbol"],op=["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 Mu(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(np.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(ip(r))return"Buffer";let t=sp(r);return t||"Object"}function ip(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function sp(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(op.includes(e))return e}var g=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}};g.uint=new g(0,"uint",!0);g.negint=new g(1,"negint",!0);g.bytes=new g(2,"bytes",!0);g.string=new g(3,"string",!0);g.array=new g(4,"array",!1);g.map=new g(5,"map",!1);g.tag=new g(6,"tag",!1);g.float=new g(7,"float",!0);g.false=new g(7,"false",!0);g.true=new g(7,"true",!0);g.null=new g(7,"null",!0);g.undefined=new g(7,"undefined",!0);g.break=new g(7,"break",!0);var U=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",ap=new TextDecoder,cp=new TextEncoder;function Xo(r){return jr&&globalThis.Buffer.isBuffer(r)}function Ls(r){return r instanceof Uint8Array?Xo(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var qu=jr?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):Ku(r,e,t):(r,e,t)=>t-e>64?ap.decode(r.subarray(e,t)):Ku(r,e,t),zu=jr?r=>r.length>64?globalThis.Buffer.from(r):Hu(r):r=>r.length>64?cp.encode(r):Hu(r),ut=r=>Uint8Array.from(r),Yr=jr?(r,e,t)=>Xo(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),Gu=jr?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),Ls(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},ju=jr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Yu(r,e){if(Xo(r)&&Xo(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 Hu(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 Ku(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 up(n)}var $u=4096;function up(r){let e=r.length;if(e<=$u)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=$u));return t}var lp=256,Cn=class{constructor(e=lp){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=ju(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=Yr(n,0,this.cursor)}else t=Gu(this.chunks,this.cursor);return e&&this.reset(),t}};var K="CBOR decode error:",Vs="CBOR encode error:",Nn=[];Nn[23]=1;Nn[24]=2;Nn[25]=3;Nn[26]=5;Nn[27]=9;function It(r,e,t){if(r.length-e<t)throw new Error(`${K} not enough data for type`)}var ge=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Oe(r,e,t){It(r,e,1);let n=r[e];if(t.strict===!0&&n<ge[0])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function Fe(r,e,t){It(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<ge[1])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function Pe(r,e,t){It(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<ge[2])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function Me(r,e,t){It(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<ge[3])throw new Error(`${K} 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(`${K} integers outside of the safe integer range are not supported`)}function Zu(r,e,t,n){return new U(g.uint,Oe(r,e+1,n),2)}function Wu(r,e,t,n){return new U(g.uint,Fe(r,e+1,n),3)}function Ju(r,e,t,n){return new U(g.uint,Pe(r,e+1,n),5)}function Xu(r,e,t,n){return new U(g.uint,Me(r,e+1,n),9)}function qe(r,e){return ve(r,0,e.value)}function ve(r,e,t){if(t<ge[0]){let n=Number(t);r.push([e|n])}else if(t<ge[1]){let n=Number(t);r.push([e|24,n])}else if(t<ge[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<ge[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<ge[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(`${K} encountered BigInt larger than allowable range`)}}qe.encodedSize=function(e){return ve.encodedSize(e.value)};ve.encodedSize=function(e){return e<ge[0]?1:e<ge[1]?2:e<ge[2]?3:e<ge[3]?5:9};qe.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function Qu(r,e,t,n){return new U(g.negint,-1-Oe(r,e+1,n),2)}function el(r,e,t,n){return new U(g.negint,-1-Fe(r,e+1,n),3)}function tl(r,e,t,n){return new U(g.negint,-1-Pe(r,e+1,n),5)}var Os=BigInt(-1),rl=BigInt(1);function nl(r,e,t,n){let o=Me(r,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new U(g.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${K} integers outside of the safe integer range are not supported`);return new U(g.negint,Os-BigInt(o),9)}function Qo(r,e){let t=e.value,n=typeof t=="bigint"?t*Os-rl:t*-1-1;ve(r,e.type.majorEncoded,n)}Qo.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*Os-rl:t*-1-1;return n<ge[0]?1:n<ge[1]?2:n<ge[2]?3:n<ge[3]?5:9};Qo.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function _n(r,e,t,n){It(r,e,t+n);let o=Yr(r,e+t,e+t+n);return new U(g.bytes,o,t+n)}function ol(r,e,t,n){return _n(r,e,1,t)}function il(r,e,t,n){return _n(r,e,2,Oe(r,e+1,n))}function sl(r,e,t,n){return _n(r,e,3,Fe(r,e+1,n))}function al(r,e,t,n){return _n(r,e,5,Pe(r,e+1,n))}function cl(r,e,t,n){let o=Me(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer bytes lengths not supported`);return _n(r,e,9,o)}function ei(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===g.string?zu(r.value):r.value),r.encodedBytes}function Zr(r,e){let t=ei(e);ve(r,e.type.majorEncoded,t.length),r.push(t)}Zr.encodedSize=function(e){let t=ei(e);return ve.encodedSize(t.length)+t.length};Zr.compareTokens=function(e,t){return hp(ei(e),ei(t))};function hp(r,e){return r.length<e.length?-1:r.length>e.length?1:Yu(r,e)}function Un(r,e,t,n,o){let i=t+n;It(r,e,i);let s=new U(g.string,qu(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Yr(r,e+t,e+i)),s}function ul(r,e,t,n){return Un(r,e,1,t,n)}function ll(r,e,t,n){return Un(r,e,2,Oe(r,e+1,n),n)}function fl(r,e,t,n){return Un(r,e,3,Fe(r,e+1,n),n)}function hl(r,e,t,n){return Un(r,e,5,Pe(r,e+1,n),n)}function dl(r,e,t,n){let o=Me(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer string lengths not supported`);return Un(r,e,9,o,n)}var pl=Zr;function Wr(r,e,t,n){return new U(g.array,n,t)}function gl(r,e,t,n){return Wr(r,e,1,t)}function ml(r,e,t,n){return Wr(r,e,2,Oe(r,e+1,n))}function yl(r,e,t,n){return Wr(r,e,3,Fe(r,e+1,n))}function wl(r,e,t,n){return Wr(r,e,5,Pe(r,e+1,n))}function bl(r,e,t,n){let o=Me(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer array lengths not supported`);return Wr(r,e,9,o)}function xl(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return Wr(r,e,1,1/0)}function ti(r,e){ve(r,g.array.majorEncoded,e.value)}ti.compareTokens=qe.compareTokens;ti.encodedSize=function(e){return ve.encodedSize(e.value)};function Jr(r,e,t,n){return new U(g.map,n,t)}function El(r,e,t,n){return Jr(r,e,1,t)}function vl(r,e,t,n){return Jr(r,e,2,Oe(r,e+1,n))}function Bl(r,e,t,n){return Jr(r,e,3,Fe(r,e+1,n))}function Al(r,e,t,n){return Jr(r,e,5,Pe(r,e+1,n))}function Sl(r,e,t,n){let o=Me(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer map lengths not supported`);return Jr(r,e,9,o)}function Rl(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return Jr(r,e,1,1/0)}function ri(r,e){ve(r,g.map.majorEncoded,e.value)}ri.compareTokens=qe.compareTokens;ri.encodedSize=function(e){return ve.encodedSize(e.value)};function kl(r,e,t,n){return new U(g.tag,t,1)}function Il(r,e,t,n){return new U(g.tag,Oe(r,e+1,n),2)}function Tl(r,e,t,n){return new U(g.tag,Fe(r,e+1,n),3)}function Cl(r,e,t,n){return new U(g.tag,Pe(r,e+1,n),5)}function Nl(r,e,t,n){return new U(g.tag,Me(r,e+1,n),9)}function ni(r,e){ve(r,g.tag.majorEncoded,e.value)}ni.compareTokens=qe.compareTokens;ni.encodedSize=function(e){return ve.encodedSize(e.value)};var wp=20,bp=21,xp=22,Ep=23;function _l(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${K} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new U(g.null,null,1):new U(g.undefined,void 0,1)}function Ul(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return new U(g.break,void 0,1)}function Fs(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${K} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${K} Infinity values are not supported`)}return new U(g.float,r,e)}function Dl(r,e,t,n){return Fs(Ps(r,e+1),3,n)}function Ll(r,e,t,n){return Fs(Ms(r,e+1),5,n)}function Vl(r,e,t,n){return Fs(Ml(r,e+1),9,n)}function oi(r,e,t){let n=e.value;if(n===!1)r.push([g.float.majorEncoded|wp]);else if(n===!0)r.push([g.float.majorEncoded|bp]);else if(n===null)r.push([g.float.majorEncoded|xp]);else if(n===void 0)r.push([g.float.majorEncoded|Ep]);else{let o,i=!1;(!t||t.float64!==!0)&&(Fl(n),o=Ps(Xe,1),n===o||Number.isNaN(n)?(Xe[0]=249,r.push(Xe.slice(0,3)),i=!0):(Pl(n),o=Ms(Xe,1),n===o&&(Xe[0]=250,r.push(Xe.slice(0,5)),i=!0))),i||(vp(n),o=Ml(Xe,1),Xe[0]=251,r.push(Xe.slice(0,9)))}}oi.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){Fl(n);let o=Ps(Xe,1);if(n===o||Number.isNaN(n))return 3;if(Pl(n),o=Ms(Xe,1),n===o)return 5}return 9};var Ol=new ArrayBuffer(9),ze=new DataView(Ol,1),Xe=new Uint8Array(Ol,0);function Fl(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 Ps(r,e){if(r.length-e<2)throw new Error(`${K} 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 Pl(r){ze.setFloat32(0,r,!1)}function Ms(r,e){if(r.length-e<4)throw new Error(`${K} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function vp(r){ze.setFloat64(0,r,!1)}function Ml(r,e){if(r.length-e<8)throw new Error(`${K} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}oi.compareTokens=qe.compareTokens;function X(r,e,t){throw new Error(`${K} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function ii(r){return()=>{throw new Error(`${K} ${r}`)}}var R=[];for(let r=0;r<=23;r++)R[r]=X;R[24]=Zu;R[25]=Wu;R[26]=Ju;R[27]=Xu;R[28]=X;R[29]=X;R[30]=X;R[31]=X;for(let r=32;r<=55;r++)R[r]=X;R[56]=Qu;R[57]=el;R[58]=tl;R[59]=nl;R[60]=X;R[61]=X;R[62]=X;R[63]=X;for(let r=64;r<=87;r++)R[r]=ol;R[88]=il;R[89]=sl;R[90]=al;R[91]=cl;R[92]=X;R[93]=X;R[94]=X;R[95]=ii("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)R[r]=ul;R[120]=ll;R[121]=fl;R[122]=hl;R[123]=dl;R[124]=X;R[125]=X;R[126]=X;R[127]=ii("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)R[r]=gl;R[152]=ml;R[153]=yl;R[154]=wl;R[155]=bl;R[156]=X;R[157]=X;R[158]=X;R[159]=xl;for(let r=160;r<=183;r++)R[r]=El;R[184]=vl;R[185]=Bl;R[186]=Al;R[187]=Sl;R[188]=X;R[189]=X;R[190]=X;R[191]=Rl;for(let r=192;r<=215;r++)R[r]=kl;R[216]=Il;R[217]=Tl;R[218]=Cl;R[219]=Nl;R[220]=X;R[221]=X;R[222]=X;R[223]=X;for(let r=224;r<=243;r++)R[r]=ii("simple values are not supported");R[244]=X;R[245]=X;R[246]=X;R[247]=_l;R[248]=ii("simple values are not supported");R[249]=Dl;R[250]=Ll;R[251]=Vl;R[252]=X;R[253]=X;R[254]=X;R[255]=Ul;var Qe=[];for(let r=0;r<24;r++)Qe[r]=new U(g.uint,r,1);for(let r=-1;r>=-24;r--)Qe[31-r]=new U(g.negint,r,1);Qe[64]=new U(g.bytes,new Uint8Array(0),1);Qe[96]=new U(g.string,"",1);Qe[128]=new U(g.array,0,1);Qe[160]=new U(g.map,0,1);Qe[244]=new U(g.false,!1,1);Qe[245]=new U(g.true,!0,1);Qe[246]=new U(g.null,null,1);function Hl(r){switch(r.type){case g.false:return ut([244]);case g.true:return ut([245]);case g.null:return ut([246]);case g.bytes:return r.value.length?void 0:ut([64]);case g.string:return r.value===""?ut([96]):void 0;case g.array:return r.value===0?ut([128]):void 0;case g.map:return r.value===0?ut([160]):void 0;case g.uint:return r.value<24?ut([Number(r.value)]):void 0;case g.negint:if(r.value>=-24)return ut([31-Number(r.value)])}}var Ap={float64:!1,mapSorter:kp,quickEncodeToken:Hl};function Sp(){let r=[];return r[g.uint.major]=qe,r[g.negint.major]=Qo,r[g.bytes.major]=Zr,r[g.string.major]=pl,r[g.array.major]=ti,r[g.map.major]=ri,r[g.tag.major]=ni,r[g.float.major]=oi,r}var Kl=Sp(),Hs=new Cn,ai=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(`${Vs} object contains circular references`);return new r(t,e)}},Jt={null:new U(g.null,null),undefined:new U(g.undefined,void 0),true:new U(g.true,!0),false:new U(g.false,!1),emptyArray:new U(g.array,0),emptyMap:new U(g.map,0)},Xt={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new U(g.float,r):r>=0?new U(g.uint,r):new U(g.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new U(g.uint,r):new U(g.negint,r)},Uint8Array(r,e,t,n){return new U(g.bytes,r)},string(r,e,t,n){return new U(g.string,r)},boolean(r,e,t,n){return r?Jt.true:Jt.false},null(r,e,t,n){return Jt.null},undefined(r,e,t,n){return Jt.undefined},ArrayBuffer(r,e,t,n){return new U(g.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new U(g.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[Jt.emptyArray,new U(g.break)]:Jt.emptyArray;n=ai.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=si(s,t,n);return t.addBreakTokens?[new U(g.array,r.length),o,new U(g.break)]:[new U(g.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?[Jt.emptyMap,new U(g.break)]:Jt.emptyMap;n=ai.createCheck(n,r);let a=[],c=0;for(let f of i)a[c++]=[si(f,t,n),si(o?r.get(f):r[f],t,n)];return Rp(a,t),t.addBreakTokens?[new U(g.map,s),a,new U(g.break)]:[new U(g.map,s),a]}};Xt.Map=Xt.Object;Xt.Buffer=Xt.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Xt[`${r}Array`]=Xt.DataView;function si(r,e={},t){let n=Mu(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||Xt[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=Xt[n];if(!i)throw new Error(`${Vs} unsupported type: ${n}`);return i(r,n,e,t)}function Rp(r,e){e.mapSorter&&r.sort(e.mapSorter)}function kp(r,e){let t=Array.isArray(r[0])?r[0][0]:r[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(t.type!==n.type)return t.type.compare(n.type);let o=t.type.major,i=Kl[o].compareTokens(t,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function $l(r,e,t,n){if(Array.isArray(e))for(let o of e)$l(r,o,t,n);else t[e.type.major](r,e,n)}function Ip(r,e,t){let n=si(r,t);if(!Array.isArray(n)&&t.quickEncodeToken){let o=t.quickEncodeToken(n);if(o)return o;let i=e[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,t),a=new Cn(s);if(i(a,n,t),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Ls(a.chunks[0])}}return Hs.reset(),$l(Hs,n,e,t),Hs.toBytes(!0)}function Ks(r,e){return e=Object.assign({},Ap,e),Ip(r,Kl,e)}var Tp={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},ci=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=Qe[e];if(t===void 0){let n=R[e];if(!n)throw new Error(`${K} 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}},Dn=Symbol.for("DONE"),ui=Symbol.for("BREAK");function Cp(r,e,t){let n=[];for(let o=0;o<r.value;o++){let i=Xr(e,t);if(i===ui){if(r.value===1/0)break;throw new Error(`${K} got unexpected break to lengthed array`)}if(i===Dn)throw new Error(`${K} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function Np(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=Xr(e,t);if(a===ui){if(r.value===1/0)break;throw new Error(`${K} got unexpected break to lengthed map`)}if(a===Dn)throw new Error(`${K} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${K} non-string keys not supported (got ${typeof a})`);if(t.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${K} found repeat map key "${a}"`);let c=Xr(e,t);if(c===Dn)throw new Error(`${K} 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 Xr(r,e){if(r.done())return Dn;let t=r.next();if(t.type===g.break)return ui;if(t.type.terminal)return t.value;if(t.type===g.array)return Cp(t,r,e);if(t.type===g.map)return Np(t,r,e);if(t.type===g.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=Xr(r,e);return e.tags[t.value](n)}throw new Error(`${K} tag not supported (${t.value})`)}throw new Error("unsupported")}function ql(r,e){if(!(r instanceof Uint8Array))throw new Error(`${K} data to decode must be a Uint8Array`);e=Object.assign({},Tp,e);let t=e.tokenizer||new ci(r,e),n=Xr(t,e);if(n===Dn)throw new Error(`${K} did not find any content to decode`);if(n===ui)throw new Error(`${K} got unexpected break`);return[n,r.subarray(t.pos())]}function $s(r,e){let[t,n]=ql(r,e);if(n.length>0)throw new Error(`${K} too many terminals, data makes no sense`);return t}var _e=ht(Zo(),1);var zl=Ut("ipns:utils"),Gl=J("/ipns/"),Up=114,jl=async(r,e)=>{if(e==null||r==null){let n=new Error("one or more of the provided parameters are not defined");throw zl.error(n),(0,_e.default)(n,Us)}let t;if(e.pubKey!=null){try{t=Ns(e.pubKey)}catch(o){throw zl.error(o),o}if(!(await Da(e.pubKey)).equals(r))throw(0,_e.default)(new Error("Embedded public key did not match PeerID"),Ou)}else r.publicKey!=null&&(t=Ns(r.publicKey));if(t!=null)return t;throw(0,_e.default)(new Error("no public key is available"),Us)},Yl=(r,e,t)=>{let n=J(e);return or([r,t,n])},li=r=>{let e=J("ipns-signature:");return or([e,r])},qs=r=>"signatureV1"in r?Ee.encode({value:J(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:J(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):Ee.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data});function lt(r){let e=Ee.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,_e.default)(new Error("missing data or signatureV2"),kt);let t=Jl(e.data),n=zs(t.Value),o=oe(t.Validity);if(e.value!=null&&e.signatureV1!=null)return Dp(e),{value:n,validityType:Ee.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:Ee.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 fi=r=>or([Gl,r.toBytes()]),Zl=r=>Hi(r.slice(Gl.length)),Wl=(r,e,t,n,o)=>{let i;if(e===Ee.ValidityType.EOL)i=0;else throw(0,_e.default)(new Error("Unknown validity type"),Tn);return Ks({Value:r,Validity:t,ValidityType:i,Sequence:n,TTL:o})},Jl=r=>{let e=$s(r);if(e.ValidityType===0)e.ValidityType=Ee.ValidityType.EOL;else throw(0,_e.default)(new Error("Unknown validity type"),Tn);return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e},zs=r=>{if(r!=null){if(aa(r))return`/ipns/${r.toCID().toString(Mn)}`;if(r instanceof Uint8Array){let n=oe(r);n.startsWith("/")&&(r=n)}let e=r.toString().trim();if(e.startsWith("/")&&e.length>1)return e;let t=Re.asCID(r);if(t!=null)return t.code===Up?`/ipns/${t.toString(Mn)}`:`/ipfs/${t.toV1().toString()}`;try{return r instanceof Uint8Array?`/ipfs/${Re.decode(r).toV1().toString()}`:`/ipfs/${Re.parse(e).toV1().toString()}`}catch{}}throw(0,_e.default)(new Error("Value must be a valid content path starting with /"),Vu)},Dp=r=>{if(r.data==null)throw(0,_e.default)(new Error("Record data is missing"),Lu);let e=Jl(r.data);if(!fe(e.Value,r.value??new Uint8Array(0)))throw(0,_e.default)(new Error('Field "value" did not match between protobuf and CBOR'),kt);if(!fe(e.Validity,r.validity??new Uint8Array(0)))throw(0,_e.default)(new Error('Field "validity" did not match between protobuf and CBOR'),kt);if(e.ValidityType!==r.validityType)throw(0,_e.default)(new Error('Field "validityType" did not match between protobuf and CBOR'),kt);if(e.Sequence!==r.sequence)throw(0,_e.default)(new Error('Field "sequence" did not match between protobuf and CBOR'),kt);if(e.TTL!==r.ttl)throw(0,_e.default)(new Error('Field "ttl" did not match between protobuf and CBOR'),kt)};var Lp=Ut("ipns"),Vp=tt.code,Ql=60*60*1e9,Op="/ipns/",vx=Op.length,ef={v1Compatible:!0,ttlNs:Ql};async function tf(r,e,t,n,o=ef){let i=new Xl.default(Date.now()+Number(n)),s=Ee.ValidityType.EOL,a=BigInt(o.ttlNs!=null?o.ttlNs:Ql);return Fp(r,e,t,s,i.toString(),a,o)}var Fp=async(r,e,t,n,o,i,s=ef)=>{t=BigInt(t);let a=J(o),c=zs(e),f=J(c);if(r.privateKey==null)throw(0,Gs.default)(new Error("Missing private key"),Fu);let u=await Tu(r.privateKey),l=Wl(f,n,a,t,i),d=li(l),E=await u.sign(d),m;if(r.publicKey!=null){let h=rr(r.toBytes());(h.code!==Vp||!fe(r.publicKey,h.digest))&&(m=r.publicKey)}if(s.v1Compatible===!0){let h=await Pp(u,f,n,a),p={value:c,signatureV1:h,validity:o,validityType:n,sequence:t,ttl:i,signatureV2:E,data:l};return m!=null&&(p.pubKey=m),p}else{let h={value:c,validity:o,validityType:n,sequence:t,ttl:i,signatureV2:E,data:l};return m!=null&&(h.pubKey=m),h}};var Pp=async(r,e,t,n)=>{try{let o=Yl(e,t,n);return await r.sign(o)}catch(o){throw Lp.error("record signature creation failed",o),(0,Gs.default)(new Error("record signature creation failed"),Du)}};var js=ht(Jo(),1);function hi(r,e){let t=e.map((n,o)=>({record:lt(n),index:o}));return t.sort((n,o)=>{let i=n.record.sequence,s=o.record.sequence;if(i>s)return-1;if(i<s)return 1;if(n.record.validityType===Ee.ValidityType.EOL&&o.record.validityType===Ee.ValidityType.EOL){let a=js.default.fromString(n.record.validity).toDate(),c=js.default.fromString(o.record.validity).toDate();if(a.getTime()>c.getTime())return-1;if(a.getTime()<c.getTime())return 1}return 0}),t[0].index}var Ln=ht(Zo(),1),rf=ht(Jo(),1);var di=Ut("ipns:validator"),Mp=1024*10,Hp=async(r,e)=>{let t=lt(e),n;try{let o=li(t.data);n=await r.verify(o,t.signatureV2)}catch{n=!1}if(!n)throw di.error("record signature verification failed"),(0,Ln.default)(new Error("record signature verification failed"),kt);if(t.validityType===Ee.ValidityType.EOL){if(rf.default.fromString(t.validity).toDate().getTime()<Date.now())throw di.error("record has expired"),(0,Ln.default)(new Error("record has expired"),Uu)}else if(t.validityType!=null)throw di.error("unrecognized validity type"),(0,Ln.default)(new Error("unrecognized validity type"),Tn);di("ipns record for %s is valid",t.value)};async function pi(r,e){if(e.byteLength>Mp)throw(0,Ln.default)(new Error("record too large"),Pu);let t=Zl(r),n=lt(e),o=await jl(t,n);await Hp(o,e)}var Ce=class extends Event{constructor(e,t){super(e),this.detail=t}};var qp=ht(of(),1);var Tt;(function(r){r[r.A=1]="A",r[r.CNAME=5]="CNAME",r[r.TXT=16]="TXT",r[r.AAAA=28]="AAAA"})(Tt||(Tt={}));var zp=32;async function sf(r,e,t,n,o={}){if(e===0)throw new Error("recursion limit exceeded");n("query %s for TXT and CNAME records",r);let s=(await t.query(r,{...o,types:[Tt.TXT]})).Answer.sort((f,u)=>f.data.localeCompare(u.data));n("found %d TXT records for %s",s.length,r);for(let f of s)try{let u=f.data;if(u.startsWith('"')&&u.endsWith('"')&&(u=u.substring(1,u.length-1)),!u.startsWith("dnslink="))continue;n("%s TXT %s",f.name,u),u=u.replace("dnslink=","");let[,l,d,...E]=u.split("/");if(l==="ipfs")try{return{value:`/ipfs/${Re.parse(d)}${E.length>0?`/${E.join("/")}`:""}`,answer:f}}catch{}else if(l==="ipns"){try{return{value:`/ipns/${sn(d)}${E.length>0?`/${E.join("/")}`:""}`,answer:f}}catch{}return await gi(d,e-1,t,n,o)}else{if(l==="dnslink")return await gi(d,e-1,t,n,o);n('unknown protocol "%s" in DNSLink record for domain: %s',l,r);continue}}catch(u){n.error("could not parse DNS link record for domain %s, %s",r,f.data,u)}n("no DNSLink records found for %s, falling back to CNAME",r);let c=(await t.query(r,{...o,types:[Tt.CNAME]})).Answer.sort((f,u)=>f.data.localeCompare(u.data));n("found %d CNAME records for %s",c.length,r);for(let f of c)try{return await gi(f.data,e-1,t,n,o)}catch(u){n.error("domain %s cname %s had no DNSLink records",r,f.data,u)}throw new $(`No DNSLink records found for domain: ${r}`,"ERR_DNSLINK_NOT_FOUND")}async function gi(r,e,t,n,o={}){if(e===0)throw new Error("recursion limit exceeded");r.startsWith("_dnslink.")||(r=`_dnslink.${r}`);try{return await sf(r,e,t,n,o)}catch(i){if(i.code!=="ENOTFOUND"&&i.code!=="ERR_DNSLINK_NOT_FOUND"&&i.code!=="ENODATA")throw i;return r.startsWith("_dnslink.")?r=r.replace("_dnslink.",""):r=`_dnslink.${r}`,await sf(r,e,t,n,o)}}async function af(r,e,t,n={}){return gi(r,n.maxRecursiveDepth??zp,e,t,n)}var Ys=class{routing;constructor(e){this.routing=e}async put(e,t,n={}){try{await this.routing.put(e,t,n)}catch(o){n.onProgress?.(new Ce("ipns:routing:helia:error",o))}}async get(e,t={}){try{return await this.routing.get(e,t)}catch(n){t.onProgress?.(new Ce("ipns:routing:helia:error",n))}throw new Error("Not found")}};function cf(r){return new Ys(r)}var Vn;(function(r){let e;r.codec=()=>(e==null&&(e=qt((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.key!=null&&t.key.byteLength>0&&(n.uint32(10),n.bytes(t.key)),t.value!=null&&t.value.byteLength>0&&(n.uint32(18),n.bytes(t.value)),t.timeReceived!=null&&t.timeReceived!==""&&(n.uint32(42),n.string(t.timeReceived)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={key:Ki(0),value:Ki(0),timeReceived:""},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{i.key=t.bytes();break}case 2:{i.value=t.bytes();break}case 5:{i.timeReceived=t.string();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>$t(t,r.codec()),r.decode=(t,n)=>Kt(t,r.codec(),n)})(Vn||(Vn={}));function uf(r){let e=r.getUTCFullYear(),t=String(r.getUTCMonth()+1).padStart(2,"0"),n=String(r.getUTCDate()).padStart(2,"0"),o=String(r.getUTCHours()).padStart(2,"0"),i=String(r.getUTCMinutes()).padStart(2,"0"),s=String(r.getUTCSeconds()).padStart(2,"0"),a=r.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${e}-${t}-${n}T${o}:${i}:${s}.${c}Z`}function lf(r){let e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),t=String(r).trim().match(e);if(t==null)throw new Error("Invalid format");let n=parseInt(t[1],10),o=parseInt(t[2],10)-1,i=parseInt(t[3],10),s=parseInt(t[4],10),a=parseInt(t[5],10),c=parseInt(t[6],10),f=parseInt(t[7].slice(0,-6),10);return new Date(Date.UTC(n,o,i,s,a,c,f))}var mr=class r{key;value;timeReceived;constructor(e,t,n){if(!(e instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(t instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=e,this.value=t,this.timeReceived=n}serialize(){return Vn.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:uf(this.timeReceived)}}static deserialize(e){let t=Vn.decode(e);return new r(t.key,t.value,new Date(t.timeReceived))}static fromDeserialized(e){let t=lf(e.timeReceived);if(e.key==null)throw new Error("key missing from deserialized object");if(e.value==null)throw new Error("value missing from deserialized object");return new r(e.key,e.value,t)}};var ff;(function(r){r[r.SEND_QUERY=0]="SEND_QUERY",r[r.PEER_RESPONSE=1]="PEER_RESPONSE",r[r.FINAL_PEER=2]="FINAL_PEER",r[r.QUERY_ERROR=3]="QUERY_ERROR",r[r.PROVIDER=4]="PROVIDER",r[r.VALUE=5]="VALUE",r[r.ADD_PEER=6]="ADD_PEER",r[r.DIAL_PEER=7]="DIAL_PEER"})(ff||(ff={}));function mi(r){return new Gr("/dht/record/"+oe(r,"base32"),!1)}function hf(r){return{async put(e,t,n={}){try{let o=mi(e);try{let s=await r.get(o),a=mr.deserialize(s);if(fe(a.value,t))return}catch(s){if(s.code!=="ERR_NOT_FOUND")throw s}let i=new mr(e,t,new Date);n.onProgress?.(new Ce("ipns:routing:datastore:put")),await r.put(o,i.serialize(),n)}catch(o){throw n.onProgress?.(new Ce("ipns:routing:datastore:error",o)),o}},async get(e,t={}){try{let n=mi(e);t.onProgress?.(new Ce("ipns:routing:datastore:get"));let o=await r.get(n,t),i=mr.deserialize(o);return{record:i.value,created:i.timeReceived}}catch(n){throw t.onProgress?.(new Ce("ipns:routing:datastore:error",n)),n}},async has(e,t={}){let n=mi(e);return r.has(n,t)},async delete(e,t){let n=mi(e);return r.delete(n,t)}}}var Ct=Ut("helia:ipns"),jp=60*1e3,Js=60*jp,Yp=24*Js,Zs=23*Js,Zp=BigInt(Js)*1000000n,Ws=class{routers;localStore;timeout;dns;log;constructor(e,t=[]){this.routers=[cf(e.routing),...t],this.localStore=hf(e.datastore),this.dns=e.dns,this.log=e.logger.forComponent("helia:ipns")}async publish(e,t,n={}){try{let o=1n,i=fi(e);if(await this.localStore.has(i,n)){let{record:c}=await this.localStore.get(i,n);o=lt(c).sequence+1n}let s=await tf(e,t,o,n.lifetime??Yp,n),a=qs(s);return await this.localStore.put(i,a,n),n.offline!==!0&&await Promise.all(this.routers.map(async c=>{await c.put(i,a,n)})),s}catch(o){throw n.onProgress?.(new Ce("ipns:publish:error",o)),o}}async resolve(e,t={}){let n=fi(e),o=await this.#t(n,t);return{...await this.#e(o.value,t),record:o}}async resolveDNSLink(e,t={}){let n=await af(e,this.dns,this.log,t);return{...await this.#e(n.value,t),answer:n.answer}}republish(e={}){if(this.timeout!=null)throw new Error("Republish is already running");e.signal?.addEventListener("abort",()=>{clearTimeout(this.timeout)});async function t(){let n=Date.now();e.onProgress?.(new Ce("ipns:republish:start"));let i=Date.now()-n,s=Zs-i;s<0&&(s=e.interval??Zs),setTimeout(()=>{t().catch(a=>{Ct.error("error republishing",a)})},s)}this.timeout=setTimeout(()=>{t().catch(n=>{Ct.error("error republishing",n)})},e.interval??Zs)}async#e(e,t={}){let n=e.split("/");try{let o=n[1];if(o==="ipns"){let{cid:i}=await this.resolve(sn(n[2]),t),s=n.slice(3).join("/");return{cid:i,path:s}}else if(o==="ipfs"){let i=Re.parse(n[2]),s=n.slice(3).join("/");return{cid:i,path:s}}}catch(o){Ct.error("error parsing ipfs path",o)}throw Ct.error("invalid ipfs path %s",e),new Error("Invalid value")}async#t(e,t={}){let n=[];if(await this.localStore.has(e,t))if(Ct("record is present in the cache"),t.nocache!==!0)try{let{record:a,created:c}=await this.localStore.get(e,t);this.log("record retrieved from cache"),await pi(e,a),this.log("record was valid");let f=lt(a),u=Number((f.ttl??Zp)/1000000n);if(c.getTime()+u>Date.now())return this.log("record TTL was valid"),f;if(t.offline===!0)return this.log("record TTL has been reached but we are resolving offline-only, returning record"),f;this.log("record TTL has been reached, searching routing for updates"),n.push(a)}catch(a){this.log("cached record was invalid",a),await this.localStore.delete(e,t)}else Ct("ignoring local cache due to nocache=true option");if(t.offline===!0)throw new $("Record was not present in the cache or has expired","ERR_NOT_FOUND");Ct("did not have record locally");let i=0;if(await Promise.all(this.routers.map(async a=>{let c;try{c=await a.get(e,{...t,validate:!1})}catch(f){Ct.error("error finding IPNS record",f);return}try{await pi(e,c),n.push(c)}catch(f){i++,Ct.error("error finding IPNS record",f)}})),n.length===0)throw i>0?new $(`${i>1?`${i} records`:"Record"} found for routing key ${i>1?"were":"was"} invalid`,"ERR_RECORDS_FAILED_VALIDATION"):new $("Could not find record for routing key","ERR_NOT_FOUND");let s=n[hi(e,n)];return await this.localStore.put(e,s,t),lt(s)}};function Wp(r,{routers:e=[]}={}){return new Ws(r,e)}return Rf(Jp);})();
9
9
  /*! Bundled license information:
10
10
 
11
11
  pvtsutils/build/index.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helia/ipns",
3
- "version": "7.2.2-a8fdfc2",
3
+ "version": "7.2.2-b4877b5",
4
4
  "description": "An implementation of IPNS for Helia",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/ipfs/helia/tree/main/packages/ipns#readme",
@@ -164,7 +164,7 @@
164
164
  "release": "aegir release"
165
165
  },
166
166
  "dependencies": {
167
- "@helia/interface": "4.3.0-a8fdfc2",
167
+ "@helia/interface": "4.3.0-b4877b5",
168
168
  "@libp2p/interface": "^1.1.4",
169
169
  "@libp2p/kad-dht": "^12.0.8",
170
170
  "@libp2p/logger": "^4.0.7",
@@ -179,10 +179,10 @@
179
179
  "devDependencies": {
180
180
  "@libp2p/peer-id-factory": "^4.0.7",
181
181
  "@types/dns-packet": "^5.6.5",
182
- "aegir": "^42.2.5",
182
+ "aegir": "^43.0.1",
183
183
  "datastore-core": "^9.2.9",
184
184
  "it-drain": "^3.0.5",
185
- "sinon": "^17.0.1",
185
+ "sinon": "^18.0.0",
186
186
  "sinon-ts": "^2.0.0"
187
187
  },
188
188
  "browser": {