@helia/ipns 4.0.0-3477b27 → 4.0.0-4836d52

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 Pg=Object.create;var ps=Object.defineProperty;var Mg=Object.getOwnPropertyDescriptor;var Fg=Object.getOwnPropertyNames;var $g=Object.getPrototypeOf,Hg=Object.prototype.hasOwnProperty;var Ue=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),M=(r,e)=>{for(var t in e)ps(r,t,{get:e[t],enumerable:!0})},ff=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Fg(e))!Hg.call(r,o)&&o!==t&&ps(r,o,{get:()=>e[o],enumerable:!(n=Mg(e,o))||n.enumerable});return r};var _e=(r,e,t)=>(t=r!=null?Pg($g(r)):{},ff(e||!r||!r.__esModule?ps(t,"default",{value:r,enumerable:!0}):t,r)),Kg=r=>ff(ps({},"__esModule",{value:!0}),r);var pa=Ue((xA,df)=>{var rn=1e3,nn=rn*60,on=nn*60,Ur=on*24,zg=Ur*7,qg=Ur*365.25;df.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return Gg(r);if(t==="number"&&isFinite(r))return e.long?Wg(r):jg(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Gg(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*qg;case"weeks":case"week":case"w":return t*zg;case"days":case"day":case"d":return t*Ur;case"hours":case"hour":case"hrs":case"hr":case"h":return t*on;case"minutes":case"minute":case"mins":case"min":case"m":return t*nn;case"seconds":case"second":case"secs":case"sec":case"s":return t*rn;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function jg(r){var e=Math.abs(r);return e>=Ur?Math.round(r/Ur)+"d":e>=on?Math.round(r/on)+"h":e>=nn?Math.round(r/nn)+"m":e>=rn?Math.round(r/rn)+"s":r+"ms"}function Wg(r){var e=Math.abs(r);return e>=Ur?ms(r,e,Ur,"day"):e>=on?ms(r,e,on,"hour"):e>=nn?ms(r,e,nn,"minute"):e>=rn?ms(r,e,rn,"second"):r+" ms"}function ms(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var mf=Ue((vA,pf)=>{function Yg(r){t.debug=t,t.default=t,t.coerce=c,t.disable=s,t.enable=o,t.enabled=i,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 p=0;p<u.length;p++)l=(l<<5)-l+u.charCodeAt(p),l|=0;return t.colors[Math.abs(l)%t.colors.length]}t.selectColor=e;function t(u){let l,p=null,x,d;function h(...m){if(!h.enabled)return;let g=h,A=Number(new Date),b=A-(l||A);g.diff=b,g.prev=l,g.curr=A,l=A,m[0]=t.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let S=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(I,C)=>{if(I==="%%")return"%";S++;let y=t.formatters[C];if(typeof y=="function"){let k=m[S];I=y.call(g,k),m.splice(S,1),S--}return I}),t.formatArgs.call(g,m),(g.log||t.log).apply(g,m)}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:()=>p!==null?p:(x!==t.namespaces&&(x=t.namespaces,d=t.enabled(u)),d),set:m=>{p=m}}),typeof t.init=="function"&&t.init(h),h}function n(u,l){let p=t(this.namespace+(typeof l>"u"?":":l)+u);return p.log=this.log,p}function o(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let l,p=(typeof u=="string"?u:"").split(/[\s,]+/),x=p.length;for(l=0;l<x;l++)p[l]&&(u=p[l].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.slice(1)+"$")):t.names.push(new RegExp("^"+u+"$")))}function s(){let u=[...t.names.map(a),...t.skips.map(a).map(l=>"-"+l)].join(",");return t.enable(""),u}function i(u){if(u[u.length-1]==="*")return!0;let l,p;for(l=0,p=t.skips.length;l<p;l++)if(t.skips[l].test(u))return!1;for(l=0,p=t.names.length;l<p;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}pf.exports=Yg});var ma=Ue((Ze,gs)=>{Ze.formatArgs=Jg;Ze.save=Xg;Ze.load=Qg;Ze.useColors=Zg;Ze.storage=ey();Ze.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`."))}})();Ze.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 Zg(){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 Jg(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+gs.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)}Ze.log=console.debug||console.log||(()=>{});function Xg(r){try{r?Ze.storage.setItem("debug",r):Ze.storage.removeItem("debug")}catch{}}function Qg(){let r;try{r=Ze.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function ey(){try{return localStorage}catch{}}gs.exports=mf()(Ze);var{formatters:ty}=gs.exports;ty.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var xh=Ue(In=>{"use strict";var kw="[object ArrayBuffer]",$t=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===kw}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 s=0;s<n.length;s++)if(n[s]!==o[s])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 i of t)n+=i.byteLength;let o=new Uint8Array(n),s=0;for(let i of t){let a=this.toUint8Array(i);o.set(a,s),s+=a.length}return e[e.length-1]instanceof Function?this.toView(o,e[e.length-1]):o.buffer}},yc="string",Rw=/^[0-9a-f]+$/i,Nw=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Uw=/^[a-zA-Z0-9-_]+$/,Vs=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=$t.toUint8Array(e),n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return decodeURIComponent(escape(n))}},st=class{static toString(e,t=!1){let n=$t.toArrayBuffer(e),o=new DataView(n),s="";for(let i=0;i<n.byteLength;i+=2){let a=o.getUint16(i,t);s+=String.fromCharCode(a)}return s}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),o=new DataView(n);for(let s=0;s<e.length;s++)o.setUint16(s*2,e.charCodeAt(s),t);return n}},Ps=class r{static isHex(e){return typeof e===yc&&Rw.test(e)}static isBase64(e){return typeof e===yc&&Nw.test(e)}static isBase64Url(e){return typeof e===yc&&Uw.test(e)}static ToString(e,t="utf8"){let n=$t.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 st.toString(n,!0);case"utf16":case"utf16be":return st.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 st.fromString(e,!0);case"utf16":case"utf16be":return st.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=$t.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 Vs.fromString(e);case"utf16":case"utf16be":return st.fromString(e);case"utf16le":case"usc2":return st.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 Vs.toString(e);case"utf16":case"utf16be":return st.toString(e);case"utf16le":case"usc2":return st.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=$t.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=$t.toUint8Array(e),n="",o=t.length;for(let s=0;s<o;s++){let i=t[s];i<16&&(n+="0"),n+=i.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 s=t.slice(o,o+2);n[o/2]=parseInt(s,16)}return n.buffer}static ToUtf16String(e,t=!1){return st.toString(e,t)}static FromUtf16String(e,t=!1){return st.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,"")||""}};Ps.DEFAULT_UTF8_ENCODING="utf8";function _w(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let s in o)t[s]=o[s]}return t}function Dw(...r){let e=r.map(o=>o.byteLength).reduce((o,s)=>o+s),t=new Uint8Array(e),n=0;return r.map(o=>new Uint8Array(o)).forEach(o=>{for(let s of o)t[n++]=s}),t.buffer}function Lw(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}In.BufferSourceConverter=$t;In.Convert=Ps;In.assign=_w;In.combine=Dw;In.isEqual=Lw});var _o=Ue((x3,Td)=>{"use strict";function Cd(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function gx(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 Cd(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),Cd(new o,t)}}Td.exports=gx});var _c=Ue((S3,Uc)=>{var B3=function(){typeof Uc<"u"&&(Uc.exports=h);var r=86400,e=3200,t=146097*e/400,n=r*t,o=1e3*n,s=864e13,i=4294967296,a=1e6,c="000000000",f=Math.trunc||function(y){var k=y-y%1;return k==0&&(y<0||y===0&&1/y!=1/0)?-0:k},u=h.prototype,l=(h.fromDate=function(y){return new h(+y)},h.fromInt64BE=S(0,1,2,3,0,4),h.fromInt64LE=S(3,2,1,0,4,0),h.fromString=function(U){var k,O=new h,U=(U+="").replace(/^\s*[+\-]?\d+/,function(H){var H=+H,X=1970+(H-1970)%400;return O.year=H-X,X}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(V,H,X){return H<0&&(X*=-1),k=6e4*(60*+H+ +X),""}).replace(/\.\d+$/,function(V){return O.nano=+(V+c).substr(1,9),""}).split(/\D+/);if(1<U.length?U[1]--:U[1]=0,O.time=k=Date.UTC.apply(Date,U)-(k||0),isNaN(k))throw new TypeError("Invalid Date");return m(O)},h.fromTimeT=function(y){return A(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=m(this);return(y.time%1e3*a+ +y.nano+1e9)%1e9},u.getTimeT=function(){var k=m(this),y=Math.floor(k.time/1e3),k=k.year;return k&&(y+=k*t*r/e),y},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return g(m(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(y){var k=this,O=k.toDate(),U={H:function(){return I(O.getUTCHours())},L:function(){return C(O.getUTCMilliseconds(),3)},M:function(){return I(O.getUTCMinutes())},N:function(){return C(k.getNano(),9)},S:function(){return I(O.getUTCSeconds())},Y:function(){var V=k.getYear();return 999999<V?"+"+V:9999<V?"+"+C(V,6):0<=V?C(V,4):-999999<=V?"-"+C(-V,6):V},a:function(){return x[O.getUTCDay()]},b:function(){return p[O.getUTCMonth()]},d:function(){return I(O.getUTCDate())},e:function(){return function(V){return(9<V?"":" ")+(0|V)}(O.getUTCDate())},m:function(){return I(O.getUTCMonth()+1)}};return function V(H){return H.replace(/%./g,function(X){var R=X[1],B=d[R],R=U[R];return B?V(B):R?R():X})}(y||l)},u.writeInt64BE=b(0,1,2,3,0,4),u.writeInt64LE=b(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),p=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],x=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],d={"%":"%",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,k,O){var U=this;if(!(U instanceof h))return new h(y,k,O);U.time=+y||0,U.nano=+k||0,U.year=+O||0,m(U)}function m(y){var k,O,U,V=y.year,H=y.time,X=y.nano,B=((X<0||a<=X)&&(X-=(O=Math.floor(X/a))*a,H+=O,O=1),V%e);return(H<-s||s<H||B)&&((k=f(H/o))&&(V+=k*e,H-=k*o),(U=g(H)).setUTCFullYear(B+U.getUTCFullYear()),U=(H=+U)+(k=f((V-=B)/e))*o,k&&-s<=U&&U<=s&&(V-=k*e,H=U),O=1),O&&(y.year=V,y.time=H,y.nano=X),y}function g(y){var k=new Date(0);return k.setTime(y),k}function A(V,U){V=+V||0;var O=f((U=(U|0)*i)/n)+f(V/n),U=U%n+V%n,V=f(U/n);return V&&(O+=V,U-=V*n),new h(1e3*U,0,O*e)}function b(y,k,O,U,V,H){return function(B,R){var T=m(this);B=B||new Array(8),v(B,R|=0);var E=Math.floor(T.time/1e3),T=T.year*(t*r/e),$=f(T/i)+f(E/i),T=T%i+E%i,E=Math.floor(T/i);return E&&($+=E,T-=E*i),X(B,R+V,$),X(B,R+H,T),B};function X(B,R,$){B[R+y]=$>>24&255,B[R+k]=$>>16&255,B[R+O]=$>>8&255,B[R+U]=255&$}}function S(y,k,O,U,V,H){return function(B,R){v(B,R|=0);var $=X(B,R+V);return A(X(B,R+H),$)};function X(B,R){return 16777216*B[R+y]+(B[R+k]<<16|B[R+O]<<8|B[R+U])}}function v(y,k){if(y=y&&y.length,y==null)throw new TypeError("Invalid Buffer");if(y<k+8)throw new RangeError("Out of range")}function I(y){return(9<y?"":"0")+(0|y)}function C(y,k){return(c+(0|y)).substr(-k)}}()});var z0=Ue((VC,K0)=>{K0.exports=Ku;var H0=128,I2=127,C2=~I2,T2=Math.pow(2,31);function Ku(r,e,t){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw Ku.bytes=0,new RangeError("Could not encode varint");e=e||[],t=t||0;for(var n=t;r>=T2;)e[t++]=r&255|H0,r/=128;for(;r&C2;)e[t++]=r&255|H0,r>>>=7;return e[t]=r|0,Ku.bytes=t-n+1,e}});var j0=Ue((PC,G0)=>{G0.exports=zu;var k2=128,q0=127;function zu(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a||o>49)throw zu.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&q0)<<o:(i&q0)*Math.pow(2,o),o+=7}while(i>=k2);return zu.bytes=s-n,t}});var Y0=Ue((MC,W0)=>{var R2=Math.pow(2,7),N2=Math.pow(2,14),U2=Math.pow(2,21),_2=Math.pow(2,28),D2=Math.pow(2,35),L2=Math.pow(2,42),O2=Math.pow(2,49),V2=Math.pow(2,56),P2=Math.pow(2,63);W0.exports=function(r){return r<R2?1:r<N2?2:r<U2?3:r<_2?4:r<D2?5:r<L2?6:r<O2?7:r<V2?8:r<P2?9:10}});var Ji=Ue((FC,Z0)=>{Z0.exports={encode:z0(),decode:j0(),encodingLength:Y0()}});var $l=Ue((_k,tg)=>{"use strict";var z8=typeof navigator<"u"&&navigator.product==="ReactNative";function q8(){return z8?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}var cs=self.URL,eg=q8(),Fl=class{constructor(e="",t=eg){this.super=new cs(e,t),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(e){this.super.hash=e}set host(e){this.super.host=e}set hostname(e){this.super.hostname=e}set href(e){this.super.href=e}set password(e){this.super.password=e}set pathname(e){this.super.pathname=e}set port(e){this.super.port=e}set protocol(e){this.super.protocol=e}set search(e){this.super.search=e}set username(e){this.super.username=e}static createObjectURL(e){return cs.createObjectURL(e)}static revokeObjectURL(e){cs.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function G8(r){if(typeof r=="string")return new cs(r).toString();if(!(r instanceof cs)){let e=r.username&&r.password?`${r.username}:${r.password}@`:"",t=r.auth?r.auth+"@":"",n=r.port?":"+r.port:"",o=r.protocol?r.protocol+"//":"",s=r.host||"",i=r.hostname||"",a=r.search||(r.query?"?"+r.query:""),c=r.hash||"",f=r.pathname||"",u=r.path||f+a;return`${o}${e||t}${s||i+n}${u}${c}`}}tg.exports={URLWithLegacySupport:Fl,URLSearchParams:self.URLSearchParams,defaultBase:eg,format:G8}});var og=Ue((Dk,ng)=>{"use strict";var{URLWithLegacySupport:rg,format:j8}=$l();ng.exports=(r,e={},t={},n)=>{let o=e.protocol?e.protocol.replace(":",""):"http";o=(t[o]||n||o)+":";let s;try{s=new rg(r)}catch{s={}}let i=Object.assign({},e,{protocol:o||s.protocol,host:e.host||s.host});return new rg(r,j8(i)).toString()}});var ig=Ue((Lk,sg)=>{"use strict";var{URLWithLegacySupport:W8,format:Y8,URLSearchParams:Z8,defaultBase:J8}=$l(),X8=og();sg.exports={URL:W8,URLSearchParams:Z8,format:Y8,relative:X8,defaultBase:J8}});var hg=Ue((zk,fg)=>{"use strict";fg.exports=lg;var nA=pa(),Rr=lg.prototype,oA=new Date%1e9;function sA(){return(Math.random()*1e9>>>0)+oA++}function lg(r){r=r||{},this.id=r.id||sA(),this.max=r.max||1/0,this.items=r.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(r.lastModified||new Date);for(var e,t,n=this.items.length;n--;)e=this.items[n],t=new Date(e.expires)-new Date,this._lookup[e.key]=e,t>0?this.expire(e.key,t):t<=0&&this.delete(e.key)}Rr.has=function(r){return r in this._lookup};Rr.get=function(r){if(!this.has(r))return null;var e=this._lookup[r];return e.refresh&&this.expire(r,e.refresh),this.items.splice(this.items.indexOf(e),1),this.items.push(e),e.value};Rr.meta=function(r){if(!this.has(r))return null;var e=this._lookup[r];return"meta"in e?e.meta:null};Rr.set=function(r,e,t){var n=this._lookup[r],o=this._lookup[r]={key:r,value:e};return this.lastModified=new Date,n?(clearTimeout(n.timeout),this.items.splice(this.items.indexOf(n),1,o)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(o),this.size++),t&&("ttl"in t&&this.expire(r,t.ttl),"meta"in t&&(o.meta=t.meta),t.refresh&&(o.refresh=t.ttl)),this};Rr.delete=function(r){var e=this._lookup[r];return e?(this.lastModified=new Date,this.items.splice(this.items.indexOf(e),1),clearTimeout(e.timeout),delete this._lookup[r],this.size--,this):!1};Rr.expire=function(r,e){var t=e||0,n=this._lookup[r];if(!n)return this;if(typeof t=="string"&&(t=nA(e)),typeof t!="number")throw new TypeError("Expiration time must be a string or number.");return clearTimeout(n.timeout),n.timeout=setTimeout(this.delete.bind(this,n.key),t),n.expires=Number(new Date)+t,this};Rr.clear=function(){for(var r=this.items.length;r--;)this.delete(this.items[r].key);return this};Rr.toJSON=function(){for(var r=new Array(this.items.length),e,t=r.length;t--;)e=this.items[t],r[t]={key:e.key,meta:e.meta,value:e.value,expires:e.expires,refresh:e.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:r}}});var gg=Ue((Gk,jl)=>{"use strict";var aA=Object.prototype.hasOwnProperty,Ke="~";function us(){}Object.create&&(us.prototype=Object.create(null),new us().__proto__||(Ke=!1));function cA(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function mg(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new cA(t,n||r,o),i=Ke?Ke+e:e;return r._events[i]?r._events[i].fn?r._events[i]=[r._events[i],s]:r._events[i].push(s):(r._events[i]=s,r._eventsCount++),r}function ua(r,e){--r._eventsCount===0?r._events=new us:delete r._events[e]}function Ve(){this._events=new us,this._eventsCount=0}Ve.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)aA.call(t,n)&&e.push(Ke?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Ve.prototype.listeners=function(e){var t=Ke?Ke+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,s=n.length,i=new Array(s);o<s;o++)i[o]=n[o].fn;return i};Ve.prototype.listenerCount=function(e){var t=Ke?Ke+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Ve.prototype.emit=function(e,t,n,o,s,i){var a=Ke?Ke+e:e;if(!this._events[a])return!1;var c=this._events[a],f=arguments.length,u,l;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,o),!0;case 5:return c.fn.call(c.context,t,n,o,s),!0;case 6:return c.fn.call(c.context,t,n,o,s,i),!0}for(l=1,u=new Array(f-1);l<f;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var p=c.length,x;for(l=0;l<p;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),f){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;case 4:c[l].fn.call(c[l].context,t,n,o);break;default:if(!u)for(x=1,u=new Array(f-1);x<f;x++)u[x-1]=arguments[x];c[l].fn.apply(c[l].context,u)}}return!0};Ve.prototype.on=function(e,t,n){return mg(this,e,t,n,!1)};Ve.prototype.once=function(e,t,n){return mg(this,e,t,n,!0)};Ve.prototype.removeListener=function(e,t,n,o){var s=Ke?Ke+e:e;if(!this._events[s])return this;if(!t)return ua(this,s),this;var i=this._events[s];if(i.fn)i.fn===t&&(!o||i.once)&&(!n||i.context===n)&&ua(this,s);else{for(var a=0,c=[],f=i.length;a<f;a++)(i[a].fn!==t||o&&!i[a].once||n&&i[a].context!==n)&&c.push(i[a]);c.length?this._events[s]=c.length===1?c[0]:c:ua(this,s)}return this};Ve.prototype.removeAllListeners=function(e){var t;return e?(t=Ke?Ke+e:e,this._events[t]&&ua(this,t)):(this._events=new us,this._eventsCount=0),this};Ve.prototype.off=Ve.prototype.removeListener;Ve.prototype.addListener=Ve.prototype.on;Ve.prefixed=Ke;Ve.EventEmitter=Ve;typeof jl<"u"&&(jl.exports=Ve)});var xg=Ue((rR,wg)=>{wg.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(s,i){t[s]=i,e++,e>=r&&(e=0,n=t,t=Object.create(null))}return{has:function(s){return t[s]!==void 0||n[s]!==void 0},remove:function(s){t[s]!==void 0&&(t[s]=void 0),n[s]!==void 0&&(n[s]=void 0)},get:function(s){var i=t[s];if(i!==void 0)return i;if((i=n[s])!==void 0)return o(s,i),i},set:function(s,i){t[s]!==void 0?t[s]=i:o(s,i)},clear:function(){t=Object.create(null),n=Object.create(null)}}}});var gA={};M(gA,{ipns:()=>mA,ipnsSelector:()=>Fi,ipnsValidator:()=>Zc});var da=Symbol.for("@libp2p/peer-id");function hf(r){return r!=null&&!!r[da]}var q=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var Je=_e(ma(),1);var xa={};M(xa,{base32:()=>sr,base32hex:()=>uy,base32hexpad:()=>fy,base32hexpadupper:()=>hy,base32hexupper:()=>ly,base32pad:()=>ay,base32padupper:()=>cy,base32upper:()=>Ef,base32z:()=>dy});var EA=new Uint8Array(0);function gf(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 yf(r){return new TextEncoder().encode(r)}function bf(r){return new TextDecoder().decode(r)}function ry(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 s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=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(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var h=0,m=0,g=0,A=d.length;g!==A&&d[g]===0;)g++,h++;for(var b=(A-g)*u+1>>>0,S=new Uint8Array(b);g!==A;){for(var v=d[g],I=0,C=b-1;(v!==0||I<m)&&C!==-1;C--,I++)v+=256*S[C]>>>0,S[C]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");m=I,g++}for(var y=b-m;y!==b&&S[y]===0;)y++;for(var k=c.repeat(h);y<b;++y)k+=r.charAt(S[y]);return k}function p(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var h=0;if(d[h]!==" "){for(var m=0,g=0;d[h]===c;)m++,h++;for(var A=(d.length-h)*f+1>>>0,b=new Uint8Array(A);d[h];){var S=t[d.charCodeAt(h)];if(S===255)return;for(var v=0,I=A-1;(S!==0||v<g)&&I!==-1;I--,v++)S+=a*b[I]>>>0,b[I]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");g=v,h++}if(d[h]!==" "){for(var C=A-g;C!==A&&b[C]===0;)C++;for(var y=new Uint8Array(m+(A-C)),k=m;C!==A;)y[k++]=b[C++];return y}}}function x(d){var h=p(d);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:x}}var ny=ry,oy=ny,xf=oy;var ga=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")}},ya=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 vf(this,e)}},ba=class{decoders;constructor(e){this.decoders=e}or(e){return vf(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 vf(r,e){return new ba({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var wa=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 ga(e,t,n),this.decoder=new ya(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function sn({name:r,prefix:e,encode:t,decode:n}){return new wa(r,e,t,n)}function or({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=xf(t,r);return sn({prefix:e,name:r,encode:n,decode:s=>Dt(o(s))})}function sy(r,e,t,n){let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,c=0,f=0;for(let u=0;u<s;++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,i[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function iy(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s}function he({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return sn({prefix:e,name:r,encode(o){return iy(o,n,t)},decode(o){return sy(o,n,t,r)}})}var sr=he({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ef=he({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ay=he({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),cy=he({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),uy=he({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ly=he({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),fy=he({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),hy=he({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),dy=he({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var va={};M(va,{base58btc:()=>Se,base58flickr:()=>py});var Se=or({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),py=or({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ea={};M(Ea,{base64:()=>io,base64pad:()=>my,base64url:()=>gy,base64urlpad:()=>yy});var io=he({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),my=he({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),gy=he({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),yy=he({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});Je.default.formatters.b=r=>r==null?"undefined":Se.baseEncode(r);Je.default.formatters.t=r=>r==null?"undefined":sr.baseEncode(r);Je.default.formatters.m=r=>r==null?"undefined":io.baseEncode(r);Je.default.formatters.p=r=>r==null?"undefined":r.toString();Je.default.formatters.c=r=>r==null?"undefined":r.toString();Je.default.formatters.k=r=>r==null?"undefined":r.toString();Je.default.formatters.a=r=>r==null?"undefined":r.toString();function by(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 ir(r){let e=by(`${r}:trace`);return Je.default.enabled(`${r}:trace`)&&Je.default.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=(0,Je.default)(`${r}:trace`)),Object.assign((0,Je.default)(r),{error:(0,Je.default)(`${r}:error`),trace:e})}var Aa={};M(Aa,{base10:()=>wy});var wy=or({prefix:"9",name:"base10",alphabet:"0123456789"});var Ba={};M(Ba,{base16:()=>xy,base16upper:()=>vy});var xy=he({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),vy=he({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Sa={};M(Sa,{base2:()=>Ey});var Ey=he({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ia={};M(Ia,{base256emoji:()=>Cy});var Af=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}"),Ay=Af.reduce((r,e,t)=>(r[t]=e,r),[]),By=Af.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Sy(r){return r.reduce((e,t)=>(e+=Ay[t],e),"")}function Iy(r){let e=[];for(let t of r){let n=By[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var Cy=sn({prefix:"\u{1F680}",name:"base256emoji",encode:Sy,decode:Iy});var Ca={};M(Ca,{base36:()=>ys,base36upper:()=>Ty});var ys=or({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ty=or({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ta={};M(Ta,{base8:()=>ky});var ky=he({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ka={};M(ka,{identity:()=>Ry});var Ry=sn({prefix:"\0",name:"identity",encode:r=>bf(r),decode:r=>yf(r)});var HA=new TextEncoder,KA=new TextDecoder;var Na={};M(Na,{identity:()=>vt});var _y=If,Bf=128,Dy=127,Ly=~Dy,Oy=Math.pow(2,31);function If(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Oy;)e[t++]=r&255|Bf,r/=128;for(;r&Ly;)e[t++]=r&255|Bf,r>>>=7;return e[t]=r|0,If.bytes=t-n+1,e}var Vy=Ra,Py=128,Sf=127;function Ra(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Ra.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Sf)<<o:(i&Sf)*Math.pow(2,o),o+=7}while(i>=Py);return Ra.bytes=s-n,t}var My=Math.pow(2,7),Fy=Math.pow(2,14),$y=Math.pow(2,21),Hy=Math.pow(2,28),Ky=Math.pow(2,35),zy=Math.pow(2,42),qy=Math.pow(2,49),Gy=Math.pow(2,56),jy=Math.pow(2,63),Wy=function(r){return r<My?1:r<Fy?2:r<$y?3:r<Hy?4:r<Ky?5:r<zy?6:r<qy?7:r<Gy?8:r<jy?9:10},Yy={encode:_y,decode:Vy,encodingLength:Wy},Zy=Yy,ao=Zy;function co(r,e=0){return[ao.decode(r,e),ao.decode.bytes]}function an(r,e,t=0){return ao.encode(r,e,t),e}function cn(r){return ao.encodingLength(r)}function xt(r,e){let t=e.byteLength,n=cn(r),o=n+cn(t),s=new Uint8Array(o+t);return an(r,s,0),an(t,s,n),s.set(e,o),new un(r,t,e,s)}function _r(r){let e=Dt(r),[t,n]=co(e),[o,s]=co(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new un(t,o,i,e)}function Cf(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&gf(r.bytes,t.bytes)}}var un=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var Tf=0,Jy="identity",kf=Dt;function Xy(r){return xt(Tf,kf(r))}var vt={code:Tf,name:Jy,encode:kf,digest:Xy};var Da={};M(Da,{sha256:()=>Ie,sha512:()=>Qy});function _a({name:r,code:e,encode:t}){return new Ua(r,e,t)}var Ua=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?xt(this.code,t):t.then(n=>xt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Nf(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Ie=_a({name:"sha2-256",code:18,encode:Nf("SHA-256")}),Qy=_a({name:"sha2-512",code:19,encode:Nf("SHA-512")});function Uf(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return tb(t,La(r),e??Se.encoder);default:return rb(t,La(r),e??sr.encoder)}}var _f=new WeakMap;function La(r){let e=_f.get(r);if(e==null){let t=new Map;return _f.set(r,t),t}return e}var Xe=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!==uo)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==nb)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=xt(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&&Cf(e.multihash,n.multihash)}toString(e){return Uf(this,e)}toJSON(){return{"/":Uf(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:s,bytes:i}=t;return new r(n,o,s,i??Df(n,o,s.bytes))}else if(t[ob]===!0){let{version:n,multihash:o,code:s}=t,i=_r(o);return r.create(n,s,i)}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!==uo)throw new Error(`Version 0 CID must use dag-pb (code: ${uo}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Df(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,uo,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 s=o.subarray(t.multihashSize-t.digestSize),i=new un(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,p]=co(e.subarray(t));return t+=p,l},o=n(),s=uo;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),c=n(),f=t+c,u=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=eb(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return La(s).set(n,e),s}};function eb(r,e){switch(r[0]){case"Q":{let t=e??Se;return[Se.prefix,t.decode(`${Se.prefix}${r}`)]}case Se.prefix:{let t=e??Se;return[Se.prefix,t.decode(r)]}case sr.prefix:{let t=e??sr;return[sr.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 tb(r,e,t){let{prefix:n}=t;if(n!==Se.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o}function rb(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o}var uo=112,nb=18;function Df(r,e,t){let n=cn(r),o=n+cn(e),s=new Uint8Array(o+t.byteLength);return an(r,s,0),an(e,s,n),s.set(t,o),s}var ob=Symbol.for("@ipld/js-cid/CID");var ln={...ka,...Sa,...Ta,...Aa,...Ba,...xa,...Ca,...va,...Ea,...Ia},lB={...Da,...Na};function Ce(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 sb=Symbol.for("nodejs.util.inspect.custom"),Lf=Object.values(ln).map(r=>r.decoder).reduce((r,e)=>r.or(e),ln.identity.decoder),Of=114,Oa=36,Va=37,lo=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()})`}[da]=!0;toString(){return this.string==null&&(this.string=Se.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Xe.createV1(Of,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return Ce(this.multihash.bytes,e);if(typeof e=="string")return Pa(e).equals(this);if(e?.multihash?.bytes!=null)return Ce(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[sb](){return`PeerId(${this.toString()})`}},fn=class extends lo{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},hn=class extends lo{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},dn=class extends lo{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function Pa(r,e){if(e=e??Lf,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=_r(Se.decode(`z${r}`));return r.startsWith("12D")?new hn({multihash:t}):r.startsWith("16U")?new dn({multihash:t}):new fn({multihash:t})}return Ma(Lf.decode(r))}function Ma(r){try{let e=_r(r);if(e.code===vt.code){if(e.digest.length===Oa)return new hn({multihash:e});if(e.digest.length===Va)return new dn({multihash:e})}if(e.code===Ie.code)return new fn({multihash:e})}catch{return ib(Xe.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function ib(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Of)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===Ie.code)return new fn({multihash:r.multihash});if(e.code===vt.code){if(e.digest.length===Oa)return new hn({multihash:r.multihash});if(e.digest.length===Va)return new dn({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function Vf(r,e){return r.length===Oa?new hn({multihash:xt(vt.code,r),privateKey:e}):r.length===Va?new dn({multihash:xt(vt.code,r),privateKey:e}):new fn({multihash:await Ie.digest(r),publicKey:r,privateKey:e})}var mc={};M(mc,{Ed25519PrivateKey:()=>Hr,Ed25519PublicKey:()=>bo,generateKeyPair:()=>Iw,generateKeyPairFromSeed:()=>wh,unmarshalEd25519PrivateKey:()=>Bw,unmarshalEd25519PublicKey:()=>Sw});function Lr(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function lt(r=0){return globalThis.Buffer?.allocUnsafe!=null?Lr(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Or(r,e){if(globalThis.Buffer!=null)return Lr(globalThis.Buffer.concat(r,e));e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=lt(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return Lr(t)}function Mf(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Pf=Mf("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Fa=Mf("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=lt(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),ab={utf8:Pf,"utf-8":Pf,hex:ln.base16,latin1:Fa,ascii:Fa,binary:Fa,...ln},ws=ab;function ee(r,e="utf8"){let t=ws[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Lr(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function ot(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function pn(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function cb(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function $a(r,...e){if(!cb(r))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(r.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${r.length}`)}function xs(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");pn(r.outputLen),pn(r.blockLen)}function mn(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 Ff(r,e){$a(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var vs=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function $f(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var yn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),ft=(r,e)=>r<<32-e|r>>>e,ub=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!ub)throw new Error("Non little-endian hardware is not supported");var lb=async()=>{};async function Hf(r,e,t){let n=Date.now();for(let o=0;o<r;o++){t(o);let s=Date.now()-n;s>=0&&s<e||(await lb(),n+=s)}}function Ha(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function ar(r){if(typeof r=="string"&&(r=Ha(r)),!$f(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function Es(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];if(!$f(o))throw new Error("Uint8Array expected");e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let s=r[n];t.set(s,o),o+=s.length}return t}var gn=class{clone(){return this._cloneInto()}},fb={}.toString;function Kf(r,e){if(e!==void 0&&fb.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function As(r){let e=n=>r().update(ar(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function bn(r=32){if(vs&&typeof vs.getRandomValues=="function")return vs.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function hb(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(t>>o&s),a=Number(t&s),c=n?4:0,f=n?0:4;r.setUint32(e+c,i,n),r.setUint32(e+f,a,n)}var wn=class extends gn{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=yn(this.buffer)}update(e){mn(this);let{view:t,buffer:n,blockLen:o}=this;e=ar(e);let s=e.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=yn(e);for(;o<=s-i;i+=o)this.process(c,i);continue}n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){mn(this),Ff(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)t[l]=0;hb(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=yn(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],s)}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:s,destroyed:i,pos:a}=this;return e.length=o,e.pos=a,e.finished=s,e.destroyed=i,o%t&&e.buffer.set(n),e}};var Bs=BigInt(4294967295),Ka=BigInt(32);function zf(r,e=!1){return e?{h:Number(r&Bs),l:Number(r>>Ka&Bs)}:{h:Number(r>>Ka&Bs)|0,l:Number(r&Bs)|0}}function db(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:i}=zf(r[o],e);[t[o],n[o]]=[s,i]}return[t,n]}var pb=(r,e)=>BigInt(r>>>0)<<Ka|BigInt(e>>>0),mb=(r,e,t)=>r>>>t,gb=(r,e,t)=>r<<32-t|e>>>t,yb=(r,e,t)=>r>>>t|e<<32-t,bb=(r,e,t)=>r<<32-t|e>>>t,wb=(r,e,t)=>r<<64-t|e>>>t-32,xb=(r,e,t)=>r>>>t-32|e<<64-t,vb=(r,e)=>e,Eb=(r,e)=>r,Ab=(r,e,t)=>r<<t|e>>>32-t,Bb=(r,e,t)=>e<<t|r>>>32-t,Sb=(r,e,t)=>e<<t-32|r>>>64-t,Ib=(r,e,t)=>r<<t-32|e>>>64-t;function Cb(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var Tb=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),kb=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,Rb=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),Nb=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,Ub=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),_b=(r,e,t,n,o,s)=>e+t+n+o+s+(r/2**32|0)|0;var Db={fromBig:zf,split:db,toBig:pb,shrSH:mb,shrSL:gb,rotrSH:yb,rotrSL:bb,rotrBH:wb,rotrBL:xb,rotr32H:vb,rotr32L:Eb,rotlSH:Ab,rotlSL:Bb,rotlBH:Sb,rotlBL:Ib,add:Cb,add3L:Tb,add3H:kb,add4L:Rb,add4H:Nb,add5H:_b,add5L:Ub},j=Db;var[Lb,Ob]=j.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))),cr=new Uint32Array(80),ur=new Uint32Array(80),za=class extends wn{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:s,Cl:i,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:p,Gh:x,Gl:d,Hh:h,Hl:m}=this;return[e,t,n,o,s,i,a,c,f,u,l,p,x,d,h,m]}set(e,t,n,o,s,i,a,c,f,u,l,p,x,d,h,m){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=p|0,this.Gh=x|0,this.Gl=d|0,this.Hh=h|0,this.Hl=m|0}process(e,t){for(let b=0;b<16;b++,t+=4)cr[b]=e.getUint32(t),ur[b]=e.getUint32(t+=4);for(let b=16;b<80;b++){let S=cr[b-15]|0,v=ur[b-15]|0,I=j.rotrSH(S,v,1)^j.rotrSH(S,v,8)^j.shrSH(S,v,7),C=j.rotrSL(S,v,1)^j.rotrSL(S,v,8)^j.shrSL(S,v,7),y=cr[b-2]|0,k=ur[b-2]|0,O=j.rotrSH(y,k,19)^j.rotrBH(y,k,61)^j.shrSH(y,k,6),U=j.rotrSL(y,k,19)^j.rotrBL(y,k,61)^j.shrSL(y,k,6),V=j.add4L(C,U,ur[b-7],ur[b-16]),H=j.add4H(V,I,O,cr[b-7],cr[b-16]);cr[b]=H|0,ur[b]=V|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:p,Fh:x,Fl:d,Gh:h,Gl:m,Hh:g,Hl:A}=this;for(let b=0;b<80;b++){let S=j.rotrSH(l,p,14)^j.rotrSH(l,p,18)^j.rotrBH(l,p,41),v=j.rotrSL(l,p,14)^j.rotrSL(l,p,18)^j.rotrBL(l,p,41),I=l&x^~l&h,C=p&d^~p&m,y=j.add5L(A,v,C,Ob[b],ur[b]),k=j.add5H(y,g,S,I,Lb[b],cr[b]),O=y|0,U=j.rotrSH(n,o,28)^j.rotrBH(n,o,34)^j.rotrBH(n,o,39),V=j.rotrSL(n,o,28)^j.rotrBL(n,o,34)^j.rotrBL(n,o,39),H=n&s^n&a^s&a,X=o&i^o&c^i&c;g=h|0,A=m|0,h=x|0,m=d|0,x=l|0,d=p|0,{h:l,l:p}=j.add(f|0,u|0,k|0,O|0),f=a|0,u=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let B=j.add3L(O,V,X);n=j.add3H(B,k,U,H),o=B|0}({h:n,l:o}=j.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=j.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=j.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=j.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:p}=j.add(this.Eh|0,this.El|0,l|0,p|0),{h:x,l:d}=j.add(this.Fh|0,this.Fl|0,x|0,d|0),{h,l:m}=j.add(this.Gh|0,this.Gl|0,h|0,m|0),{h:g,l:A}=j.add(this.Hh|0,this.Hl|0,g|0,A|0),this.set(n,o,s,i,a,c,f,u,l,p,x,d,h,m,g,A)}roundClean(){cr.fill(0),ur.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 xn=As(()=>new za);var Is={};M(Is,{bitGet:()=>Kb,bitLen:()=>Hb,bitMask:()=>fo,bitSet:()=>zb,bytesToHex:()=>Ot,bytesToNumberBE:()=>Vt,bytesToNumberLE:()=>lr,concatBytes:()=>Pt,createHmacDrbg:()=>ja,ensureBytes:()=>de,equalBytes:()=>Fb,hexToBytes:()=>Vr,hexToNumber:()=>Ga,isBytes:()=>ht,numberToBytesBE:()=>fr,numberToBytesLE:()=>Pr,numberToHexUnpadded:()=>Wf,numberToVarBytesBE:()=>Mb,utf8ToBytes:()=>$b,validateObject:()=>Et});var jf=BigInt(0),Ss=BigInt(1),Vb=BigInt(2);function ht(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var Pb=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Ot(r){if(!ht(r))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=Pb[r[t]];return e}function Wf(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function Ga(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var Lt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function qf(r){if(r>=Lt._0&&r<=Lt._9)return r-Lt._0;if(r>=Lt._A&&r<=Lt._F)return r-(Lt._A-10);if(r>=Lt._a&&r<=Lt._f)return r-(Lt._a-10)}function Vr(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,s=0;o<t;o++,s+=2){let i=qf(r.charCodeAt(s)),a=qf(r.charCodeAt(s+1));if(i===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function Vt(r){return Ga(Ot(r))}function lr(r){if(!ht(r))throw new Error("Uint8Array expected");return Ga(Ot(Uint8Array.from(r).reverse()))}function fr(r,e){return Vr(r.toString(16).padStart(e*2,"0"))}function Pr(r,e){return fr(r,e).reverse()}function Mb(r){return Vr(Wf(r))}function de(r,e,t){let n;if(typeof e=="string")try{n=Vr(e)}catch(s){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${s}`)}else if(ht(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof t=="number"&&o!==t)throw new Error(`${r} expected ${t} bytes, got ${o}`);return n}function Pt(...r){let e=0;for(let o=0;o<r.length;o++){let s=r[o];if(!ht(s))throw new Error("Uint8Array expected");e+=s.length}let t=new Uint8Array(e),n=0;for(let o=0;o<r.length;o++){let s=r[o];t.set(s,n),n+=s.length}return t}function Fb(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 $b(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Hb(r){let e;for(e=0;r>jf;r>>=Ss,e+=1);return e}function Kb(r,e){return r>>BigInt(e)&Ss}var zb=(r,e,t)=>r|(t?Ss:jf)<<BigInt(e),fo=r=>(Vb<<BigInt(r-1))-Ss,qa=r=>new Uint8Array(r),Gf=r=>Uint8Array.from(r);function ja(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=qa(r),o=qa(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},a=(...l)=>t(o,n,...l),c=(l=qa())=>{o=a(Gf([0]),l),n=a(),l.length!==0&&(o=a(Gf([1]),l),n=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l<e;){n=a();let x=n.slice();p.push(x),l+=n.length}return Pt(...p)};return(l,p)=>{i(),c(l);let x;for(;!(x=p(f()));)c();return i(),x}}var qb={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||ht(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Et(r,e,t={}){let n=(o,s,i)=>{let a=qb[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=r[o];if(!(i&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${s}`)};for(let[o,s]of Object.entries(e))n(o,s,!1);for(let[o,s]of Object.entries(t))n(o,s,!0);return r}var xe=BigInt(0),ie=BigInt(1),Mr=BigInt(2),Gb=BigInt(3),Wa=BigInt(4),Yf=BigInt(5),Zf=BigInt(8),jb=BigInt(9),Wb=BigInt(16);function oe(r,e){let t=r%e;return t>=xe?t:e+t}function Yb(r,e,t){if(t<=xe||e<xe)throw new Error("Expected power/modulo > 0");if(t===ie)return xe;let n=ie;for(;e>xe;)e&ie&&(n=n*r%t),r=r*r%t,e>>=ie;return n}function ae(r,e,t){let n=r;for(;e-- >xe;)n*=n,n%=t;return n}function Cs(r,e){if(r===xe||e<=xe)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=oe(r,e),n=e,o=xe,s=ie,i=ie,a=xe;for(;t!==xe;){let f=n/t,u=n%t,l=o-i*f,p=s-a*f;n=t,t=u,o=i,s=a,i=l,a=p}if(n!==ie)throw new Error("invert: does not exist");return oe(o,e)}function Zb(r){let e=(r-ie)/Mr,t,n,o;for(t=r-ie,n=0;t%Mr===xe;t/=Mr,n++);for(o=Mr;o<r&&Yb(o,e,r)!==r-ie;o++);if(n===1){let i=(r+ie)/Wa;return function(c,f){let u=c.pow(f,i);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let s=(t+ie)/Mr;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,s),p=a.pow(c,t);for(;!a.eql(p,a.ONE);){if(a.eql(p,a.ZERO))return a.ZERO;let x=1;for(let h=a.sqr(p);x<f&&!a.eql(h,a.ONE);x++)h=a.sqr(h);let d=a.pow(u,ie<<BigInt(f-x-1));u=a.sqr(d),l=a.mul(l,d),p=a.mul(p,u),f=x}return l}}function Jb(r){if(r%Wa===Gb){let e=(r+ie)/Wa;return function(n,o){let s=n.pow(o,e);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%Zf===Yf){let e=(r-Yf)/Zf;return function(n,o){let s=n.mul(o,Mr),i=n.pow(s,e),a=n.mul(o,i),c=n.mul(n.mul(a,Mr),i),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%Wb,Zb(r)}var Jf=(r,e)=>(oe(r,e)&ie)===ie,Xb=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ya(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Xb.reduce((n,o)=>(n[o]="function",n),e);return Et(r,t)}function Qb(r,e,t){if(t<xe)throw new Error("Expected power > 0");if(t===xe)return r.ONE;if(t===ie)return e;let n=r.ONE,o=e;for(;t>xe;)t&ie&&(n=r.mul(n,o)),o=r.sqr(o),t>>=ie;return n}function ew(r,e){let t=new Array(e.length),n=e.reduce((s,i,a)=>r.is0(i)?s:(t[a]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return e.reduceRight((s,i,a)=>r.is0(i)?s:(t[a]=r.mul(s,t[a]),r.mul(s,i)),o),t}function Za(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Ts(r,e,t=!1,n={}){if(r<=xe)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:s}=Za(r,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=Jb(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:s,MASK:fo(o),ZERO:xe,ONE:ie,create:c=>oe(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return xe<=c&&c<r},is0:c=>c===xe,isOdd:c=>(c&ie)===ie,neg:c=>oe(-c,r),eql:(c,f)=>c===f,sqr:c=>oe(c*c,r),add:(c,f)=>oe(c+f,r),sub:(c,f)=>oe(c-f,r),mul:(c,f)=>oe(c*f,r),pow:(c,f)=>Qb(a,c,f),div:(c,f)=>oe(c*Cs(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Cs(c,r),sqrt:n.sqrt||(c=>i(a,c)),invertBatch:c=>ew(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>t?Pr(c,s):fr(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return t?lr(c):Vt(c)}});return Object.freeze(a)}function Xf(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 Qf(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 Ja(r){let e=Qf(r);return e+Math.ceil(e/2)}function eh(r,e,t=!1){let n=r.length,o=Qf(e),s=Ja(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let i=t?Vt(r):lr(r),a=oe(i,e-ie)+ie;return t?Pr(a,o):fr(a,o)}var rw=BigInt(0),Xa=BigInt(1);function ks(r,e){let t=(o,s)=>{let i=s.negate();return o?i:s},n=o=>{let s=Math.ceil(e/o)+1,i=2**(o-1);return{windows:s,windowSize:i}};return{constTimeNegate:t,unsafeLadder(o,s){let i=r.ZERO,a=o;for(;s>rw;)s&Xa&&(i=i.add(a)),a=a.double(),s>>=Xa;return i},precomputeWindow(o,s){let{windows:i,windowSize:a}=n(s),c=[],f=o,u=f;for(let l=0;l<i;l++){u=f,c.push(u);for(let p=1;p<a;p++)u=u.add(f),c.push(u);f=u.double()}return c},wNAF(o,s,i){let{windows:a,windowSize:c}=n(o),f=r.ZERO,u=r.BASE,l=BigInt(2**o-1),p=2**o,x=BigInt(o);for(let d=0;d<a;d++){let h=d*c,m=Number(i&l);i>>=x,m>c&&(m-=p,i+=Xa);let g=h,A=h+Math.abs(m)-1,b=d%2!==0,S=m<0;m===0?u=u.add(t(b,s[g])):f=f.add(t(S,s[A]))}return{p:f,f:u}},wNAFCached(o,s,i,a){let c=o._WINDOW_SIZE||1,f=s.get(o);return f||(f=this.precomputeWindow(o,c),c!==1&&s.set(o,a(f))),this.wNAF(c,f,i)}}}function ho(r){return Ya(r.Fp),Et(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Za(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var dt=BigInt(0),Qe=BigInt(1),Rs=BigInt(2),nw=BigInt(8),ow={zip215:!0};function sw(r){let e=ho(r);return Et(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Ns(r){let e=sw(r),{Fp:t,n,prehash:o,hash:s,randomBytes:i,nByteLength:a,h:c}=e,f=Rs<<BigInt(a*8)-Qe,u=t.create,l=e.uvRatio||((T,E)=>{try{return{isValid:!0,value:t.sqrt(T*t.inv(E))}}catch{return{isValid:!1,value:dt}}}),p=e.adjustScalarBytes||(T=>T),x=e.domain||((T,E,L)=>{if(E.length||L)throw new Error("Contexts/pre-hash are not supported");return T}),d=T=>typeof T=="bigint"&&dt<T,h=(T,E)=>d(T)&&d(E)&&T<E,m=T=>T===dt||h(T,f);function g(T,E){if(h(T,E))return T;throw new Error(`Expected valid scalar < ${E}, got ${typeof T} ${T}`)}function A(T){return T===dt?T:g(T,n)}let b=new Map;function S(T){if(!(T instanceof v))throw new Error("ExtendedPoint expected")}class v{constructor(E,L,F,z){if(this.ex=E,this.ey=L,this.ez=F,this.et=z,!m(E))throw new Error("x required");if(!m(L))throw new Error("y required");if(!m(F))throw new Error("z required");if(!m(z))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(E){if(E instanceof v)throw new Error("extended point not allowed");let{x:L,y:F}=E||{};if(!m(L)||!m(F))throw new Error("invalid affine point");return new v(L,F,Qe,u(L*F))}static normalizeZ(E){let L=t.invertBatch(E.map(F=>F.ez));return E.map((F,z)=>F.toAffine(L[z])).map(v.fromAffine)}_setWindowSize(E){this._WINDOW_SIZE=E,b.delete(this)}assertValidity(){let{a:E,d:L}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:F,ey:z,ez:W,et:Y}=this,ne=u(F*F),J=u(z*z),Q=u(W*W),ye=u(Q*Q),fe=u(ne*E),Ae=u(Q*u(fe+J)),Be=u(ye+u(L*u(ne*J)));if(Ae!==Be)throw new Error("bad point: equation left != right (1)");let we=u(F*z),Ne=u(W*Y);if(we!==Ne)throw new Error("bad point: equation left != right (2)")}equals(E){S(E);let{ex:L,ey:F,ez:z}=this,{ex:W,ey:Y,ez:ne}=E,J=u(L*ne),Q=u(W*z),ye=u(F*ne),fe=u(Y*z);return J===Q&&ye===fe}is0(){return this.equals(v.ZERO)}negate(){return new v(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:E}=e,{ex:L,ey:F,ez:z}=this,W=u(L*L),Y=u(F*F),ne=u(Rs*u(z*z)),J=u(E*W),Q=L+F,ye=u(u(Q*Q)-W-Y),fe=J+Y,Ae=fe-ne,Be=J-Y,we=u(ye*Ae),Ne=u(fe*Be),_t=u(ye*Be),Nr=u(Ae*fe);return new v(we,Ne,Nr,_t)}add(E){S(E);let{a:L,d:F}=e,{ex:z,ey:W,ez:Y,et:ne}=this,{ex:J,ey:Q,ez:ye,et:fe}=E;if(L===BigInt(-1)){let nf=u((W-z)*(Q+J)),of=u((W+z)*(Q-J)),ha=u(of-nf);if(ha===dt)return this.double();let sf=u(Y*Rs*fe),af=u(ne*Rs*ye),cf=af+sf,uf=of+nf,lf=af-sf,Dg=u(cf*ha),Lg=u(uf*lf),Og=u(cf*lf),Vg=u(ha*uf);return new v(Dg,Lg,Vg,Og)}let Ae=u(z*J),Be=u(W*Q),we=u(ne*F*fe),Ne=u(Y*ye),_t=u((z+W)*(J+Q)-Ae-Be),Nr=Ne-we,so=Ne+we,rf=u(Be-L*Ae),Rg=u(_t*Nr),Ng=u(so*rf),Ug=u(_t*rf),_g=u(Nr*so);return new v(Rg,Ng,_g,Ug)}subtract(E){return this.add(E.negate())}wNAF(E){return y.wNAFCached(this,b,E,v.normalizeZ)}multiply(E){let{p:L,f:F}=this.wNAF(g(E,n));return v.normalizeZ([L,F])[0]}multiplyUnsafe(E){let L=A(E);return L===dt?C:this.equals(C)||L===Qe?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(E){let{ex:L,ey:F,ez:z}=this,W=this.is0();E==null&&(E=W?nw:t.inv(z));let Y=u(L*E),ne=u(F*E),J=u(z*E);if(W)return{x:dt,y:Qe};if(J!==Qe)throw new Error("invZ was invalid");return{x:Y,y:ne}}clearCofactor(){let{h:E}=e;return E===Qe?this:this.multiplyUnsafe(E)}static fromHex(E,L=!1){let{d:F,a:z}=e,W=t.BYTES;E=de("pointHex",E,W);let Y=E.slice(),ne=E[W-1];Y[W-1]=ne&-129;let J=lr(Y);J===dt||(L?g(J,f):g(J,t.ORDER));let Q=u(J*J),ye=u(Q-Qe),fe=u(F*Q-z),{isValid:Ae,value:Be}=l(ye,fe);if(!Ae)throw new Error("Point.fromHex: invalid y coordinate");let we=(Be&Qe)===Qe,Ne=(ne&128)!==0;if(!L&&Be===dt&&Ne)throw new Error("Point.fromHex: x=0 and x_0=1");return Ne!==we&&(Be=u(-Be)),v.fromAffine({x:Be,y:J})}static fromPrivateKey(E){return U(E).point}toRawBytes(){let{x:E,y:L}=this.toAffine(),F=Pr(L,t.BYTES);return F[F.length-1]|=E&Qe?128:0,F}toHex(){return Ot(this.toRawBytes())}}v.BASE=new v(e.Gx,e.Gy,Qe,u(e.Gx*e.Gy)),v.ZERO=new v(dt,Qe,Qe,dt);let{BASE:I,ZERO:C}=v,y=ks(v,a*8);function k(T){return oe(T,n)}function O(T){return k(lr(T))}function U(T){let E=a;T=de("private key",T,E);let L=de("hashed private key",s(T),2*E),F=p(L.slice(0,E)),z=L.slice(E,2*E),W=O(F),Y=I.multiply(W),ne=Y.toRawBytes();return{head:F,prefix:z,scalar:W,point:Y,pointBytes:ne}}function V(T){return U(T).pointBytes}function H(T=new Uint8Array,...E){let L=Pt(...E);return O(s(x(L,de("context",T),!!o)))}function X(T,E,L={}){T=de("message",T),o&&(T=o(T));let{prefix:F,scalar:z,pointBytes:W}=U(E),Y=H(L.context,F,T),ne=I.multiply(Y).toRawBytes(),J=H(L.context,ne,W,T),Q=k(Y+J*z);A(Q);let ye=Pt(ne,Pr(Q,t.BYTES));return de("result",ye,a*2)}let B=ow;function R(T,E,L,F=B){let{context:z,zip215:W}=F,Y=t.BYTES;T=de("signature",T,2*Y),E=de("message",E),o&&(E=o(E));let ne=lr(T.slice(Y,2*Y)),J,Q,ye;try{J=v.fromHex(L,W),Q=v.fromHex(T.slice(0,Y),W),ye=I.multiplyUnsafe(ne)}catch{return!1}if(!W&&J.isSmallOrder())return!1;let fe=H(z,Q.toRawBytes(),J.toRawBytes(),E);return Q.add(J.multiplyUnsafe(fe)).subtract(ye).clearCofactor().equals(v.ZERO)}return I._setWindowSize(8),{CURVE:e,getPublicKey:V,sign:X,verify:R,ExtendedPoint:v,utils:{getExtendedPublicKey:U,randomPrivateKey:()=>i(t.BYTES),precompute(T=8,E=v.BASE){return E._setWindowSize(T),E.multiply(BigInt(3)),E}}}}var ec=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),th=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),i6=BigInt(0),iw=BigInt(1),Qa=BigInt(2),aw=BigInt(5),rh=BigInt(10),cw=BigInt(20),uw=BigInt(40),nh=BigInt(80);function lw(r){let e=ec,n=r*r%e*r%e,o=ae(n,Qa,e)*n%e,s=ae(o,iw,e)*r%e,i=ae(s,aw,e)*s%e,a=ae(i,rh,e)*i%e,c=ae(a,cw,e)*a%e,f=ae(c,uw,e)*c%e,u=ae(f,nh,e)*f%e,l=ae(u,nh,e)*f%e,p=ae(l,rh,e)*i%e;return{pow_p_5_8:ae(p,Qa,e)*r%e,b2:n}}function fw(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function hw(r,e){let t=ec,n=oe(e*e*e,t),o=oe(n*n*e,t),s=lw(r*o).pow_p_5_8,i=oe(r*n*s,t),a=oe(e*i*i,t),c=i,f=oe(i*th,t),u=a===r,l=a===oe(-r,t),p=a===oe(-r*th,t);return u&&(i=c),(l||p)&&(i=f),Jf(i,t)&&(i=oe(-i,t)),{isValid:u||l,value:i}}var Mt=Ts(ec,void 0,!0),tc={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Mt,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:xn,randomBytes:bn,adjustScalarBytes:fw,uvRatio:hw},vn=Ns(tc);function oh(r,e,t){if(e.length>255)throw new Error("Context is too big");return Es(Ha("SigEd25519 no Ed25519 collisions"),new Uint8Array([t?1:0,e.length]),e,r)}var a6=Ns({...tc,domain:oh}),c6=Ns({...tc,domain:oh,prehash:xn});var dw=(Mt.ORDER+BigInt(3))/BigInt(8),u6=Mt.pow(Qa,dw),l6=Mt.sqrt(Mt.neg(Mt.ONE)),f6=(Mt.ORDER-BigInt(5))/BigInt(8),h6=BigInt(486662);var d6=Xf(Mt,Mt.neg(BigInt(486664)));var p6=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),m6=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),g6=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),y6=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var b6=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var En=32,Ft=64,Us=32;function sh(){let r=vn.utils.randomPrivateKey(),e=vn.getPublicKey(r);return{privateKey:uh(r,e),publicKey:e}}function ih(r){if(r.length!==Us)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=vn.getPublicKey(e);return{privateKey:uh(e,t),publicKey:t}}function ah(r,e){let t=r.subarray(0,Us);return vn.sign(e instanceof Uint8Array?e:e.subarray(),t)}function ch(r,e,t){return vn.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function uh(r,e){let t=new Uint8Array(Ft);for(let n=0;n<Us;n++)t[n]=r[n],t[Us+n]=e[n];return t}var Pe={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 rc={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function lh(r){let e=r?.algorithm??"AES-GCM",t=r?.keyLength??16,n=r?.nonceLength??12,o=r?.digest??"SHA-256",s=r?.saltLength??16,i=r?.iterations??32767,a=Pe.get();t*=8;async function c(l,p){let x=a.getRandomValues(new Uint8Array(s)),d=a.getRandomValues(new Uint8Array(n)),h={name:e,iv:d};typeof p=="string"&&(p=ee(p));let m;if(p.length===0){m=await a.subtle.importKey("jwk",rc,{name:"AES-GCM"},!0,["encrypt"]);try{let A={name:"PBKDF2",salt:x,iterations:i,hash:{name:o}},b=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);m=await a.subtle.deriveKey(A,b,{name:e,length:t},!0,["encrypt"])}catch{m=await a.subtle.importKey("jwk",rc,{name:"AES-GCM"},!0,["encrypt"])}}else{let A={name:"PBKDF2",salt:x,iterations:i,hash:{name:o}},b=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);m=await a.subtle.deriveKey(A,b,{name:e,length:t},!0,["encrypt"])}let g=await a.subtle.encrypt(h,m,l);return Or([x,h.iv,new Uint8Array(g)])}async function f(l,p){let x=l.subarray(0,s),d=l.subarray(s,s+n),h=l.subarray(s+n),m={name:e,iv:d};typeof p=="string"&&(p=ee(p));let g;if(p.length===0)try{let b={name:"PBKDF2",salt:x,iterations:i,hash:{name:o}},S=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(b,S,{name:e,length:t},!0,["decrypt"])}catch{g=await a.subtle.importKey("jwk",rc,{name:"AES-GCM"},!0,["decrypt"])}else{let b={name:"PBKDF2",salt:x,iterations:i,hash:{name:o}},S=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(b,S,{name:e,length:t},!0,["decrypt"])}let A=await a.subtle.decrypt(m,g,h);return new Uint8Array(A)}return{encrypt:c,decrypt:f}}async function An(r,e){let n=await lh().encrypt(r,e);return io.encode(n)}var nc=new Float32Array([-0]),hr=new Uint8Array(nc.buffer);function fh(r,e,t){nc[0]=r,e[t]=hr[0],e[t+1]=hr[1],e[t+2]=hr[2],e[t+3]=hr[3]}function hh(r,e){return hr[0]=r[e],hr[1]=r[e+1],hr[2]=r[e+2],hr[3]=r[e+3],nc[0]}var oc=new Float64Array([-0]),De=new Uint8Array(oc.buffer);function dh(r,e,t){oc[0]=r,e[t]=De[0],e[t+1]=De[1],e[t+2]=De[2],e[t+3]=De[3],e[t+4]=De[4],e[t+5]=De[5],e[t+6]=De[6],e[t+7]=De[7]}function ph(r,e){return De[0]=r[e],De[1]=r[e+1],De[2]=r[e+2],De[3]=r[e+3],De[4]=r[e+4],De[5]=r[e+5],De[6]=r[e+6],De[7]=r[e+7],oc[0]}var gw=BigInt(Number.MAX_SAFE_INTEGER),yw=BigInt(Number.MIN_SAFE_INTEGER),ze=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 Fr;if(e<gw&&e>yw)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>mh&&(o=0n,++n>mh&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return Fr;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):Fr}},Fr=new ze(0,0);Fr.toBigInt=function(){return 0n};Fr.zzEncode=Fr.zzDecode=function(){return this};Fr.length=function(){return 1};var mh=4294967296n;function gh(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 yh(r,e,t){if(t-e<1)return"";let o,s=[],i=0,a;for(;e<t;)a=r[e++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(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,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function sc(r,e,t){let n=t,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,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 pt(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function _s(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var ic=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,pt(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 pt(this,4);return _s(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw pt(this,4);return _s(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw pt(this,4);let e=hh(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw pt(this,4);let e=ph(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 pt(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return yh(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw pt(this,e);this.pos+=e}else do if(this.pos>=this.len)throw pt(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 ze(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 pt(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 pt(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 pt(this,8);let e=_s(this.buf,this.pos+=4),t=_s(this.buf,this.pos+=4);return new ze(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){return this.readLongVarint().toNumber(!0)}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 ac(r){return new ic(r instanceof Uint8Array?r:r.subarray())}function dr(r,e){let t=ac(r);return e.decode(t)}function cc(r){let e=r??8192,t=e>>>1,n,o=e;return function(i){if(i<1||i>t)return lt(i);o+i>e&&(n=lt(e),o=0);let a=n.subarray(o,o+=i);return o&7&&(o=(o|7)+1),a}}var $r=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function uc(){}var fc=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},bw=cc();function ww(r){return globalThis.Buffer!=null?lt(r):bw(r)}var go=class{len;head;tail;states;constructor(){this.len=0,this.head=new $r(uc,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new $r(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new hc((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(po,10,ze.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=ze.fromBigInt(e);return this._push(po,t.length(),t)}uint64Number(e){let t=ze.fromNumber(e);return this._push(po,t.length(),t)}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=ze.fromBigInt(e).zzEncode();return this._push(po,t.length(),t)}sint64Number(e){let t=ze.fromNumber(e).zzEncode();return this._push(po,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(lc,1,e?1:0)}fixed32(e){return this._push(mo,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=ze.fromBigInt(e);return this._push(mo,4,t.lo)._push(mo,4,t.hi)}fixed64Number(e){let t=ze.fromNumber(e);return this._push(mo,4,t.lo)._push(mo,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(fh,4,e)}double(e){return this._push(dh,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(lc,1,0):this.uint32(t)._push(vw,t,e)}string(e){let t=gh(e);return t!==0?this.uint32(t)._push(sc,t,e):this._push(lc,1,0)}fork(){return this.states=new fc(this),this.head=this.tail=new $r(uc,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 $r(uc,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=ww(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function lc(r,e,t){e[t]=r&255}function xw(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var hc=class extends $r{next;constructor(e,t){super(xw,e,t),this.next=void 0}};function po(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 mo(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 vw(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(go.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(Ew,e,r),this},go.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(Aw,e,r),this});function Ew(r,e,t){e.set(r,t)}function Aw(r,e,t){r.length<40?sc(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(ee(r),t)}function dc(){return new go}function pr(r,e){let t=dc();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var Bn;(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"})(Bn||(Bn={}));function Ds(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function yo(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(s,i){let a=e(s);i.int32(a)},n=function(s){let i=s.int32();return e(i)};return Ds("enum",Bn.VARINT,t,n)}function mr(r,e){return Ds("message",Bn.LENGTH_DELIMITED,r,e)}var ce;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(ce||(ce={}));var pc;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(pc||(pc={}));(function(r){r.codec=()=>yo(pc)})(ce||(ce={}));var At;(function(r){let e;r.codec=()=>(e==null&&(e=mr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ce.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let o={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let i=t.uint32();switch(i>>>3){case 1:o.Type=ce.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(i&7);break}}return o})),e),r.encode=t=>pr(t,r.codec()),r.decode=t=>dr(t,r.codec())})(At||(At={}));var Bt;(function(r){let e;r.codec=()=>(e==null&&(e=mr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ce.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let o={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let i=t.uint32();switch(i>>>3){case 1:o.Type=ce.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(i&7);break}}return o})),e),r.encode=t=>pr(t,r.codec()),r.decode=t=>dr(t,r.codec())})(Bt||(Bt={}));var bo=class{_key;constructor(e){this._key=Sn(e,En)}verify(e,t){return ch(this._key,t,e)}marshal(){return this._key}get bytes(){return At.encode({Type:ce.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Ce(this.bytes,e.bytes)}hash(){let e=Ie.digest(this.bytes);return ot(e)?e.then(({bytes:t})=>t):e.bytes}},Hr=class{_key;_publicKey;constructor(e,t){this._key=Sn(e,Ft),this._publicKey=Sn(t,En)}sign(e){return ah(this._key,e)}get public(){return new bo(this._publicKey)}marshal(){return this._key}get bytes(){return Bt.encode({Type:ce.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Ce(this.bytes,e.bytes)}async hash(){let e=Ie.digest(this.bytes),t;return ot(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=vt.digest(this.public.bytes);return Se.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return An(this.bytes,e);throw new q(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Bw(r){if(r.length>Ft){r=Sn(r,Ft+En);let n=r.subarray(0,Ft),o=r.subarray(Ft,r.length);return new Hr(n,o)}r=Sn(r,Ft);let e=r.subarray(0,Ft),t=r.subarray(En);return new Hr(e,t)}function Sw(r){return r=Sn(r,En),new bo(r)}async function Iw(){let{privateKey:r,publicKey:e}=sh();return new Hr(r,e)}async function wh(r){let{privateKey:e,publicKey:t}=ih(r);return new Hr(e,t)}function Sn(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new q(`Key must be a Uint8Array of length ${e}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}function ue(r,e="utf8"){let t=ws[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var Sc={};M(Sc,{MAX_RSA_KEY_SIZE:()=>Ro,RsaPrivateKey:()=>Rn,RsaPublicKey:()=>ko,fromJwk:()=>Qw,generateKeyPair:()=>ex,unmarshalRsaPrivateKey:()=>Ac,unmarshalRsaPublicKey:()=>Xw});function Kr(r){if(isNaN(r)||r<=0)throw new q("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return bn(r)}var wr={};M(wr,{exportToPem:()=>jw,importFromPem:()=>Ww,jwkToPkcs1:()=>Kw,jwkToPkix:()=>qw,pkcs1ToJwk:()=>Hw,pkixToJwk:()=>zw});var Os=class extends gn{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,xs(e);let n=ar(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,s=new Uint8Array(o);s.set(n.length>o?e.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=e.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(e){return mn(this),this.iHash.update(e),this}digestInto(e){mn(this),$a(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:s,blockLen:i,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,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()}},wo=(r,e,t)=>new Os(r,e).update(t).digest();wo.create=(r,e)=>new Os(r,e);function Cw(r,e,t,n){xs(r);let o=Kf({dkLen:32,asyncTick:10},n),{c:s,dkLen:i,asyncTick:a}=o;if(pn(s),pn(i),pn(a),s<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=ar(e),f=ar(t),u=new Uint8Array(i),l=wo.create(r,c),p=l._cloneInto().update(f);return{c:s,dkLen:i,asyncTick:a,DK:u,PRF:l,PRFSalt:p}}function Tw(r,e,t,n,o){return r.destroy(),e.destroy(),n&&n.destroy(),o.fill(0),t}async function gc(r,e,t,n){let{c:o,dkLen:s,asyncTick:i,DK:a,PRF:c,PRFSalt:f}=Cw(r,e,t,n),u,l=new Uint8Array(4),p=yn(l),x=new Uint8Array(c.outputLen);for(let d=1,h=0;h<s;d++,h+=c.outputLen){let m=a.subarray(h,h+c.outputLen);p.setInt32(0,d,!1),(u=f._cloneInto(u)).update(l).digestInto(x),m.set(x.subarray(0,m.length)),await Hf(o-1,i,()=>{c._cloneInto(u).update(x).digestInto(x);for(let g=0;g<m.length;g++)m[g]^=x[g]})}return Tw(c,f,a,u,x)}var Z=_e(xh());function zr(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 gr(r,e,t=-1){let n=t,o=r,s=0,i=Math.pow(2,e);for(let a=1;a<8;a++){if(r<i){let c;if(n<0)c=new ArrayBuffer(a),s=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),s=n}let f=new Uint8Array(c);for(let u=a-1;u>=0;u--){let l=Math.pow(2,u*e);f[s-u-1]=Math.floor(o/l),o-=f[s-u-1]*l}return c}i*=Math.pow(2,e)}return new ArrayBuffer(0)}function Ms(...r){let e=0,t=0;for(let s of r)e+=s.length;let n=new ArrayBuffer(e),o=new Uint8Array(n);for(let s of r)o.set(s,t),t+=s.length;return o}function bc(){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=zr(t,8),o=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(o);for(let a=0;a<this.valueHex.byteLength;a++)s[a]=r[a];return s[0]&=127,zr(s,8)-n}function vh(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let i=t-e,a=gr(i,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=gr(e,8,n),s=new Uint8Array(o);if(s[0]&128){let i=o.slice(0),a=new Uint8Array(i);o=new ArrayBuffer(o.byteLength+1),s=new Uint8Array(o);for(let c=0;c<i.byteLength;c++)s[c+1]=a[c];s[0]=0}return o}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function Eh(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 qe(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,o=new Array(n);for(let i=0;i<n;i++)o[i]="0";return o.join("").concat(t)}var AS=Math.log(2);function Fs(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function wc(r){let e=0,t=0;for(let o=0;o<r.length;o++){let s=r[o];e+=s.byteLength}let n=new Uint8Array(e);for(let o=0;o<r.length;o++){let s=r[o];n.set(new Uint8Array(s),t),t+=s.byteLength}return n.buffer}function qt(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 vo=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return wc(this.items)}},xo=[new Uint8Array([1])],Ah="0123456789";var Tn="",gt=new ArrayBuffer(0),xc=new Uint8Array(0),Eo="EndOfContent",Sh="OCTET STRING",Ih="BIT STRING";function Gt(r){var e;return e=class extends r{constructor(...n){var o;super(...n);let s=n[0]||{};this.isHexOnly=(o=s.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=s.valueHex?Z.BufferSourceConverter.toUint8Array(s.valueHex):xc}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,o,s){let i=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!qt(this,i,o,s))return-1;let a=o+s;return this.valueHexView=i.subarray(o,a),this.valueHexView.length?(this.blockLength=s,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",gt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:Z.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var Ht=class{constructor({blockLength:e=0,error:t=Tn,warnings:n=[],valueBeforeDecode:o=xc}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=Z.BufferSourceConverter.toUint8Array(o)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:Z.Convert.ToHex(this.valueBeforeDecodeView)}}};Ht.NAME="baseBlock";var Le=class extends Ht{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'")}};Le.NAME="valueBlock";var $s=class extends Gt(Ht){constructor({idBlock:e={}}={}){var t,n,o,s;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?Z.BufferSourceConverter.toUint8Array(e.valueHex):xc,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(o=e.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!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",gt}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,t|=s,o[0]=t}return o.buffer}if(!this.isHexOnly){let o=gr(this.tagNumber,7),s=new Uint8Array(o),i=o.byteLength,a=new Uint8Array(i+1);if(a[0]=t|31,!e){for(let c=0;c<i-1;c++)a[c+1]=s[c]|128;a[i]=s[i-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let o=this.valueHexView;for(let s=0;s<o.length-1;s++)n[s+1]=o[s]|128;n[this.valueHexView.byteLength]=o[o.length-1]}return n.buffer}fromBER(e,t,n){let o=Z.BufferSourceConverter.toUint8Array(e);if(!qt(this,o,t,n))return-1;let s=o.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[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=(s[0]&32)===32,this.isHexOnly=!1;let a=s[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,f=this.valueHexView=new Uint8Array(255),u=255;for(;s[c]&128;){if(f[c-1]=s[c]&127,c++,c>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let p=new Uint8Array(u);for(let x=0;x<f.length;x++)p[x]=f[x];f=this.valueHexView=new Uint8Array(u)}}this.blockLength=c+1,f[c-1]=s[c]&127;let l=new Uint8Array(c);for(let p=0;p<c;p++)l[p]=f[p];f=this.valueHexView=new Uint8Array(c),f.set(l),this.blockLength<=9?this.tagNumber=zr(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}}};$s.NAME="identificationBlock";var Hs=class extends Ht{constructor({lenBlock:e={}}={}){var t,n,o;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(o=e.length)!==null&&o!==void 0?o:0}fromBER(e,t,n){let o=Z.BufferSourceConverter.toUint8Array(e);if(!qt(this,o,t,n))return-1;let s=o.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,t+this.blockLength;let i=s[0]&127;if(i>8)return this.error="Too big integer",-1;if(i+1>s.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=o.subarray(a,a+i);return c[i-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=zr(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=i+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=gr(this.length,8);if(o.byteLength>127)return this.error="Too big length",gt;if(t=new ArrayBuffer(o.byteLength+1),e)return t;let s=new Uint8Array(o);n=new Uint8Array(t),n[0]=o.byteLength|128;for(let i=0;i<o.byteLength;i++)n[i+1]=s[i];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}}};Hs.NAME="lengthBlock";var _={},Te=class extends Ht{constructor({name:e=Tn,optional:t=!1,primitiveSchema:n,...o}={},s){super(o),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new $s(o),this.lenBlock=new Hs(o),this.valueBlock=s?new s(o):new Le(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 vo;t||Ch(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 s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;let i=this.lenBlock.toBER(e);n.write(i),n.write(s)}return t?gt:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():Z.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${Z.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return Eh(t,n)}};Te.NAME="BaseBlock";function Ch(r){if(r instanceof _.Constructed)for(let e of r.valueBlock.value)Ch(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var Ks=class extends Te{constructor({value:e=Tn,...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}'`}};Ks.NAME="BaseStringBlock";var zs=class extends Gt(Le){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};zs.NAME="PrimitiveValueBlock";var Th,qs=class extends Te{constructor(e={}){super(e,zs),this.idBlock.isConstructed=!1}};Th=qs;_.Primitive=Th;qs.NAME="PRIMITIVE";function Vw(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 Bi(r,e=0,t=r.length){let n=e,o=new Te({},Le),s=new Ht;if(!qt(s,r,e,t))return o.error=s.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=Te;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=Vw(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 kn(r){if(!r.byteLength){let e=new Te({},Le);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Bi(Z.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function Pw(r,e){return r?1:e}var St=class extends Le{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let o=Z.BufferSourceConverter.toUint8Array(e);if(!qt(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 s=t;for(;Pw(this.isIndefiniteForm,n)>0;){let i=Bi(o,s,n);if(i.offset===-1)return this.error=i.result.error,this.warnings.concat(i.result.warnings),-1;if(s=i.offset,this.blockLength+=i.result.blockLength,n-=i.result.blockLength,this.value.push(i.result),this.isIndefiniteForm&&i.result.constructor.NAME===Eo)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Eo?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){let n=t||new vo;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return t?gt: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 kh,yr=class extends Te{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 Fg=Object.create;var ms=Object.defineProperty;var $g=Object.getOwnPropertyDescriptor;var Hg=Object.getOwnPropertyNames;var Kg=Object.getPrototypeOf,zg=Object.prototype.hasOwnProperty;var Le=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),M=(r,e)=>{for(var t in e)ms(r,t,{get:e[t],enumerable:!0})},hf=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Hg(e))!zg.call(r,o)&&o!==t&&ms(r,o,{get:()=>e[o],enumerable:!(n=$g(e,o))||n.enumerable});return r};var Se=(r,e,t)=>(t=r!=null?Fg(Kg(r)):{},hf(e||!r||!r.__esModule?ms(t,"default",{value:r,enumerable:!0}):t,r)),qg=r=>hf(ms({},"__esModule",{value:!0}),r);var ma=Le((vA,pf)=>{var rn=1e3,nn=rn*60,on=nn*60,Ur=on*24,Gg=Ur*7,jg=Ur*365.25;pf.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return Wg(r);if(t==="number"&&isFinite(r))return e.long?Zg(r):Yg(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Wg(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*jg;case"weeks":case"week":case"w":return t*Gg;case"days":case"day":case"d":return t*Ur;case"hours":case"hour":case"hrs":case"hr":case"h":return t*on;case"minutes":case"minute":case"mins":case"min":case"m":return t*nn;case"seconds":case"second":case"secs":case"sec":case"s":return t*rn;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Yg(r){var e=Math.abs(r);return e>=Ur?Math.round(r/Ur)+"d":e>=on?Math.round(r/on)+"h":e>=nn?Math.round(r/nn)+"m":e>=rn?Math.round(r/rn)+"s":r+"ms"}function Zg(r){var e=Math.abs(r);return e>=Ur?gs(r,e,Ur,"day"):e>=on?gs(r,e,on,"hour"):e>=nn?gs(r,e,nn,"minute"):e>=rn?gs(r,e,rn,"second"):r+" ms"}function gs(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var gf=Le((EA,mf)=>{function Jg(r){t.debug=t,t.default=t,t.coerce=c,t.disable=s,t.enable=o,t.enabled=i,t.humanize=ma(),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 p=0;p<u.length;p++)l=(l<<5)-l+u.charCodeAt(p),l|=0;return t.colors[Math.abs(l)%t.colors.length]}t.selectColor=e;function t(u){let l,p=null,x,d;function h(...m){if(!h.enabled)return;let g=h,A=Number(new Date),b=A-(l||A);g.diff=b,g.prev=l,g.curr=A,l=A,m[0]=t.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let S=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(I,C)=>{if(I==="%%")return"%";S++;let y=t.formatters[C];if(typeof y=="function"){let k=m[S];I=y.call(g,k),m.splice(S,1),S--}return I}),t.formatArgs.call(g,m),(g.log||t.log).apply(g,m)}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:()=>p!==null?p:(x!==t.namespaces&&(x=t.namespaces,d=t.enabled(u)),d),set:m=>{p=m}}),typeof t.init=="function"&&t.init(h),h}function n(u,l){let p=t(this.namespace+(typeof l>"u"?":":l)+u);return p.log=this.log,p}function o(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let l,p=(typeof u=="string"?u:"").split(/[\s,]+/),x=p.length;for(l=0;l<x;l++)p[l]&&(u=p[l].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.slice(1)+"$")):t.names.push(new RegExp("^"+u+"$")))}function s(){let u=[...t.names.map(a),...t.skips.map(a).map(l=>"-"+l)].join(",");return t.enable(""),u}function i(u){if(u[u.length-1]==="*")return!0;let l,p;for(l=0,p=t.skips.length;l<p;l++)if(t.skips[l].test(u))return!1;for(l=0,p=t.names.length;l<p;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}mf.exports=Jg});var ga=Le((Ze,ys)=>{Ze.formatArgs=Qg;Ze.save=ey;Ze.load=ty;Ze.useColors=Xg;Ze.storage=ry();Ze.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`."))}})();Ze.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 Xg(){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 Qg(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+ys.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)}Ze.log=console.debug||console.log||(()=>{});function ey(r){try{r?Ze.storage.setItem("debug",r):Ze.storage.removeItem("debug")}catch{}}function ty(){let r;try{r=Ze.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function ry(){try{return localStorage}catch{}}ys.exports=gf()(Ze);var{formatters:ny}=ys.exports;ny.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var vh=Le(In=>{"use strict";var Nw="[object ArrayBuffer]",$t=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Nw}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 s=0;s<n.length;s++)if(n[s]!==o[s])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 i of t)n+=i.byteLength;let o=new Uint8Array(n),s=0;for(let i of t){let a=this.toUint8Array(i);o.set(a,s),s+=a.length}return e[e.length-1]instanceof Function?this.toView(o,e[e.length-1]):o.buffer}},bc="string",Uw=/^[0-9a-f]+$/i,_w=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Dw=/^[a-zA-Z0-9-_]+$/,Ps=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=$t.toUint8Array(e),n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return decodeURIComponent(escape(n))}},st=class{static toString(e,t=!1){let n=$t.toArrayBuffer(e),o=new DataView(n),s="";for(let i=0;i<n.byteLength;i+=2){let a=o.getUint16(i,t);s+=String.fromCharCode(a)}return s}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),o=new DataView(n);for(let s=0;s<e.length;s++)o.setUint16(s*2,e.charCodeAt(s),t);return n}},Ms=class r{static isHex(e){return typeof e===bc&&Uw.test(e)}static isBase64(e){return typeof e===bc&&_w.test(e)}static isBase64Url(e){return typeof e===bc&&Dw.test(e)}static ToString(e,t="utf8"){let n=$t.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 st.toString(n,!0);case"utf16":case"utf16be":return st.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 st.fromString(e,!0);case"utf16":case"utf16be":return st.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=$t.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 Ps.fromString(e);case"utf16":case"utf16be":return st.fromString(e);case"utf16le":case"usc2":return st.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 Ps.toString(e);case"utf16":case"utf16be":return st.toString(e);case"utf16le":case"usc2":return st.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=$t.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=$t.toUint8Array(e),n="",o=t.length;for(let s=0;s<o;s++){let i=t[s];i<16&&(n+="0"),n+=i.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 s=t.slice(o,o+2);n[o/2]=parseInt(s,16)}return n.buffer}static ToUtf16String(e,t=!1){return st.toString(e,t)}static FromUtf16String(e,t=!1){return st.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,"")||""}};Ms.DEFAULT_UTF8_ENCODING="utf8";function Lw(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let s in o)t[s]=o[s]}return t}function Ow(...r){let e=r.map(o=>o.byteLength).reduce((o,s)=>o+s),t=new Uint8Array(e),n=0;return r.map(o=>new Uint8Array(o)).forEach(o=>{for(let s of o)t[n++]=s}),t.buffer}function Vw(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}In.BufferSourceConverter=$t;In.Convert=Ms;In.assign=Lw;In.combine=Ow;In.isEqual=Vw});var Do=Le((v3,kd)=>{"use strict";function Td(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function bx(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 Td(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),Td(new o,t)}}kd.exports=bx});var Ti=Le((I3,_c)=>{var S3=function(){typeof _c<"u"&&(_c.exports=h);var r=86400,e=3200,t=146097*e/400,n=r*t,o=1e3*n,s=864e13,i=4294967296,a=1e6,c="000000000",f=Math.trunc||function(y){var k=y-y%1;return k==0&&(y<0||y===0&&1/y!=1/0)?-0:k},u=h.prototype,l=(h.fromDate=function(y){return new h(+y)},h.fromInt64BE=S(0,1,2,3,0,4),h.fromInt64LE=S(3,2,1,0,4,0),h.fromString=function(U){var k,O=new h,U=(U+="").replace(/^\s*[+\-]?\d+/,function(H){var H=+H,X=1970+(H-1970)%400;return O.year=H-X,X}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(V,H,X){return H<0&&(X*=-1),k=6e4*(60*+H+ +X),""}).replace(/\.\d+$/,function(V){return O.nano=+(V+c).substr(1,9),""}).split(/\D+/);if(1<U.length?U[1]--:U[1]=0,O.time=k=Date.UTC.apply(Date,U)-(k||0),isNaN(k))throw new TypeError("Invalid Date");return m(O)},h.fromTimeT=function(y){return A(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=m(this);return(y.time%1e3*a+ +y.nano+1e9)%1e9},u.getTimeT=function(){var k=m(this),y=Math.floor(k.time/1e3),k=k.year;return k&&(y+=k*t*r/e),y},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return g(m(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(y){var k=this,O=k.toDate(),U={H:function(){return I(O.getUTCHours())},L:function(){return C(O.getUTCMilliseconds(),3)},M:function(){return I(O.getUTCMinutes())},N:function(){return C(k.getNano(),9)},S:function(){return I(O.getUTCSeconds())},Y:function(){var V=k.getYear();return 999999<V?"+"+V:9999<V?"+"+C(V,6):0<=V?C(V,4):-999999<=V?"-"+C(-V,6):V},a:function(){return x[O.getUTCDay()]},b:function(){return p[O.getUTCMonth()]},d:function(){return I(O.getUTCDate())},e:function(){return function(V){return(9<V?"":" ")+(0|V)}(O.getUTCDate())},m:function(){return I(O.getUTCMonth()+1)}};return function V(H){return H.replace(/%./g,function(X){var R=X[1],B=d[R],R=U[R];return B?V(B):R?R():X})}(y||l)},u.writeInt64BE=b(0,1,2,3,0,4),u.writeInt64LE=b(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),p=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],x=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],d={"%":"%",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,k,O){var U=this;if(!(U instanceof h))return new h(y,k,O);U.time=+y||0,U.nano=+k||0,U.year=+O||0,m(U)}function m(y){var k,O,U,V=y.year,H=y.time,X=y.nano,B=((X<0||a<=X)&&(X-=(O=Math.floor(X/a))*a,H+=O,O=1),V%e);return(H<-s||s<H||B)&&((k=f(H/o))&&(V+=k*e,H-=k*o),(U=g(H)).setUTCFullYear(B+U.getUTCFullYear()),U=(H=+U)+(k=f((V-=B)/e))*o,k&&-s<=U&&U<=s&&(V-=k*e,H=U),O=1),O&&(y.year=V,y.time=H,y.nano=X),y}function g(y){var k=new Date(0);return k.setTime(y),k}function A(V,U){V=+V||0;var O=f((U=(U|0)*i)/n)+f(V/n),U=U%n+V%n,V=f(U/n);return V&&(O+=V,U-=V*n),new h(1e3*U,0,O*e)}function b(y,k,O,U,V,H){return function(B,R){var T=m(this);B=B||new Array(8),v(B,R|=0);var E=Math.floor(T.time/1e3),T=T.year*(t*r/e),$=f(T/i)+f(E/i),T=T%i+E%i,E=Math.floor(T/i);return E&&($+=E,T-=E*i),X(B,R+V,$),X(B,R+H,T),B};function X(B,R,$){B[R+y]=$>>24&255,B[R+k]=$>>16&255,B[R+O]=$>>8&255,B[R+U]=255&$}}function S(y,k,O,U,V,H){return function(B,R){v(B,R|=0);var $=X(B,R+V);return A(X(B,R+H),$)};function X(B,R){return 16777216*B[R+y]+(B[R+k]<<16|B[R+O]<<8|B[R+U])}}function v(y,k){if(y=y&&y.length,y==null)throw new TypeError("Invalid Buffer");if(y<k+8)throw new RangeError("Out of range")}function I(y){return(9<y?"":"0")+(0|y)}function C(y,k){return(c+(0|y)).substr(-k)}}()});var q0=Le((MC,z0)=>{z0.exports=Ku;var K0=128,C2=127,T2=~C2,k2=Math.pow(2,31);function Ku(r,e,t){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw Ku.bytes=0,new RangeError("Could not encode varint");e=e||[],t=t||0;for(var n=t;r>=k2;)e[t++]=r&255|K0,r/=128;for(;r&T2;)e[t++]=r&255|K0,r>>>=7;return e[t]=r|0,Ku.bytes=t-n+1,e}});var W0=Le((FC,j0)=>{j0.exports=zu;var R2=128,G0=127;function zu(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a||o>49)throw zu.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&G0)<<o:(i&G0)*Math.pow(2,o),o+=7}while(i>=R2);return zu.bytes=s-n,t}});var Z0=Le(($C,Y0)=>{var N2=Math.pow(2,7),U2=Math.pow(2,14),_2=Math.pow(2,21),D2=Math.pow(2,28),L2=Math.pow(2,35),O2=Math.pow(2,42),V2=Math.pow(2,49),P2=Math.pow(2,56),M2=Math.pow(2,63);Y0.exports=function(r){return r<N2?1:r<U2?2:r<_2?3:r<D2?4:r<L2?5:r<O2?6:r<V2?7:r<P2?8:r<M2?9:10}});var Qi=Le((HC,J0)=>{J0.exports={encode:q0(),decode:W0(),encodingLength:Z0()}});var $l=Le((Lk,rg)=>{"use strict";var q8=typeof navigator<"u"&&navigator.product==="ReactNative";function G8(){return q8?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}var us=self.URL,tg=G8(),Fl=class{constructor(e="",t=tg){this.super=new us(e,t),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(e){this.super.hash=e}set host(e){this.super.host=e}set hostname(e){this.super.hostname=e}set href(e){this.super.href=e}set password(e){this.super.password=e}set pathname(e){this.super.pathname=e}set port(e){this.super.port=e}set protocol(e){this.super.protocol=e}set search(e){this.super.search=e}set username(e){this.super.username=e}static createObjectURL(e){return us.createObjectURL(e)}static revokeObjectURL(e){us.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function j8(r){if(typeof r=="string")return new us(r).toString();if(!(r instanceof us)){let e=r.username&&r.password?`${r.username}:${r.password}@`:"",t=r.auth?r.auth+"@":"",n=r.port?":"+r.port:"",o=r.protocol?r.protocol+"//":"",s=r.host||"",i=r.hostname||"",a=r.search||(r.query?"?"+r.query:""),c=r.hash||"",f=r.pathname||"",u=r.path||f+a;return`${o}${e||t}${s||i+n}${u}${c}`}}rg.exports={URLWithLegacySupport:Fl,URLSearchParams:self.URLSearchParams,defaultBase:tg,format:j8}});var sg=Le((Ok,og)=>{"use strict";var{URLWithLegacySupport:ng,format:W8}=$l();og.exports=(r,e={},t={},n)=>{let o=e.protocol?e.protocol.replace(":",""):"http";o=(t[o]||n||o)+":";let s;try{s=new ng(r)}catch{s={}}let i=Object.assign({},e,{protocol:o||s.protocol,host:e.host||s.host});return new ng(r,W8(i)).toString()}});var ag=Le((Vk,ig)=>{"use strict";var{URLWithLegacySupport:Y8,format:Z8,URLSearchParams:J8,defaultBase:X8}=$l(),Q8=sg();ig.exports={URL:Y8,URLSearchParams:J8,format:Z8,relative:Q8,defaultBase:X8}});var dg=Le((Gk,hg)=>{"use strict";hg.exports=fg;var oA=ma(),Rr=fg.prototype,sA=new Date%1e9;function iA(){return(Math.random()*1e9>>>0)+sA++}function fg(r){r=r||{},this.id=r.id||iA(),this.max=r.max||1/0,this.items=r.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(r.lastModified||new Date);for(var e,t,n=this.items.length;n--;)e=this.items[n],t=new Date(e.expires)-new Date,this._lookup[e.key]=e,t>0?this.expire(e.key,t):t<=0&&this.delete(e.key)}Rr.has=function(r){return r in this._lookup};Rr.get=function(r){if(!this.has(r))return null;var e=this._lookup[r];return e.refresh&&this.expire(r,e.refresh),this.items.splice(this.items.indexOf(e),1),this.items.push(e),e.value};Rr.meta=function(r){if(!this.has(r))return null;var e=this._lookup[r];return"meta"in e?e.meta:null};Rr.set=function(r,e,t){var n=this._lookup[r],o=this._lookup[r]={key:r,value:e};return this.lastModified=new Date,n?(clearTimeout(n.timeout),this.items.splice(this.items.indexOf(n),1,o)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(o),this.size++),t&&("ttl"in t&&this.expire(r,t.ttl),"meta"in t&&(o.meta=t.meta),t.refresh&&(o.refresh=t.ttl)),this};Rr.delete=function(r){var e=this._lookup[r];return e?(this.lastModified=new Date,this.items.splice(this.items.indexOf(e),1),clearTimeout(e.timeout),delete this._lookup[r],this.size--,this):!1};Rr.expire=function(r,e){var t=e||0,n=this._lookup[r];if(!n)return this;if(typeof t=="string"&&(t=oA(e)),typeof t!="number")throw new TypeError("Expiration time must be a string or number.");return clearTimeout(n.timeout),n.timeout=setTimeout(this.delete.bind(this,n.key),t),n.expires=Number(new Date)+t,this};Rr.clear=function(){for(var r=this.items.length;r--;)this.delete(this.items[r].key);return this};Rr.toJSON=function(){for(var r=new Array(this.items.length),e,t=r.length;t--;)e=this.items[t],r[t]={key:e.key,meta:e.meta,value:e.value,expires:e.expires,refresh:e.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:r}}});var yg=Le((Wk,jl)=>{"use strict";var cA=Object.prototype.hasOwnProperty,ze="~";function ls(){}Object.create&&(ls.prototype=Object.create(null),new ls().__proto__||(ze=!1));function uA(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function gg(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new uA(t,n||r,o),i=ze?ze+e:e;return r._events[i]?r._events[i].fn?r._events[i]=[r._events[i],s]:r._events[i].push(s):(r._events[i]=s,r._eventsCount++),r}function fa(r,e){--r._eventsCount===0?r._events=new ls:delete r._events[e]}function Me(){this._events=new ls,this._eventsCount=0}Me.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)cA.call(t,n)&&e.push(ze?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Me.prototype.listeners=function(e){var t=ze?ze+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,s=n.length,i=new Array(s);o<s;o++)i[o]=n[o].fn;return i};Me.prototype.listenerCount=function(e){var t=ze?ze+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Me.prototype.emit=function(e,t,n,o,s,i){var a=ze?ze+e:e;if(!this._events[a])return!1;var c=this._events[a],f=arguments.length,u,l;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,o),!0;case 5:return c.fn.call(c.context,t,n,o,s),!0;case 6:return c.fn.call(c.context,t,n,o,s,i),!0}for(l=1,u=new Array(f-1);l<f;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var p=c.length,x;for(l=0;l<p;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),f){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;case 4:c[l].fn.call(c[l].context,t,n,o);break;default:if(!u)for(x=1,u=new Array(f-1);x<f;x++)u[x-1]=arguments[x];c[l].fn.apply(c[l].context,u)}}return!0};Me.prototype.on=function(e,t,n){return gg(this,e,t,n,!1)};Me.prototype.once=function(e,t,n){return gg(this,e,t,n,!0)};Me.prototype.removeListener=function(e,t,n,o){var s=ze?ze+e:e;if(!this._events[s])return this;if(!t)return fa(this,s),this;var i=this._events[s];if(i.fn)i.fn===t&&(!o||i.once)&&(!n||i.context===n)&&fa(this,s);else{for(var a=0,c=[],f=i.length;a<f;a++)(i[a].fn!==t||o&&!i[a].once||n&&i[a].context!==n)&&c.push(i[a]);c.length?this._events[s]=c.length===1?c[0]:c:fa(this,s)}return this};Me.prototype.removeAllListeners=function(e){var t;return e?(t=ze?ze+e:e,this._events[t]&&fa(this,t)):(this._events=new ls,this._eventsCount=0),this};Me.prototype.off=Me.prototype.removeListener;Me.prototype.addListener=Me.prototype.on;Me.prefixed=ze;Me.EventEmitter=Me;typeof jl<"u"&&(jl.exports=Me)});var vg=Le((oR,xg)=>{xg.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(s,i){t[s]=i,e++,e>=r&&(e=0,n=t,t=Object.create(null))}return{has:function(s){return t[s]!==void 0||n[s]!==void 0},remove:function(s){t[s]!==void 0&&(t[s]=void 0),n[s]!==void 0&&(n[s]=void 0)},get:function(s){var i=t[s];if(i!==void 0)return i;if((i=n[s])!==void 0)return o(s,i),i},set:function(s,i){t[s]!==void 0?t[s]=i:o(s,i)},clear:function(){t=Object.create(null),n=Object.create(null)}}}});var yA={};M(yA,{ipns:()=>gA,ipnsSelector:()=>Hi,ipnsValidator:()=>Zc});var pa=Symbol.for("@libp2p/peer-id");function df(r){return r!=null&&!!r[pa]}var K=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var Je=Se(ga(),1);var va={};M(va,{base32:()=>sr,base32hex:()=>fy,base32hexpad:()=>dy,base32hexpadupper:()=>py,base32hexupper:()=>hy,base32pad:()=>uy,base32padupper:()=>ly,base32upper:()=>Af,base32z:()=>my});var AA=new Uint8Array(0);function yf(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 bf(r){return new TextEncoder().encode(r)}function wf(r){return new TextDecoder().decode(r)}function oy(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 s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=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(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var h=0,m=0,g=0,A=d.length;g!==A&&d[g]===0;)g++,h++;for(var b=(A-g)*u+1>>>0,S=new Uint8Array(b);g!==A;){for(var v=d[g],I=0,C=b-1;(v!==0||I<m)&&C!==-1;C--,I++)v+=256*S[C]>>>0,S[C]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");m=I,g++}for(var y=b-m;y!==b&&S[y]===0;)y++;for(var k=c.repeat(h);y<b;++y)k+=r.charAt(S[y]);return k}function p(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var h=0;if(d[h]!==" "){for(var m=0,g=0;d[h]===c;)m++,h++;for(var A=(d.length-h)*f+1>>>0,b=new Uint8Array(A);d[h];){var S=t[d.charCodeAt(h)];if(S===255)return;for(var v=0,I=A-1;(S!==0||v<g)&&I!==-1;I--,v++)S+=a*b[I]>>>0,b[I]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");g=v,h++}if(d[h]!==" "){for(var C=A-g;C!==A&&b[C]===0;)C++;for(var y=new Uint8Array(m+(A-C)),k=m;C!==A;)y[k++]=b[C++];return y}}}function x(d){var h=p(d);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:x}}var sy=oy,iy=sy,vf=iy;var ya=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")}},ba=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 Ef(this,e)}},wa=class{decoders;constructor(e){this.decoders=e}or(e){return Ef(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 Ef(r,e){return new wa({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var xa=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 ya(e,t,n),this.decoder=new ba(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function sn({name:r,prefix:e,encode:t,decode:n}){return new xa(r,e,t,n)}function or({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=vf(t,r);return sn({prefix:e,name:r,encode:n,decode:s=>Dt(o(s))})}function ay(r,e,t,n){let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,c=0,f=0;for(let u=0;u<s;++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,i[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function cy(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s}function he({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return sn({prefix:e,name:r,encode(o){return cy(o,n,t)},decode(o){return ay(o,n,t,r)}})}var sr=he({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Af=he({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),uy=he({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ly=he({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),fy=he({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),hy=he({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),dy=he({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),py=he({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),my=he({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ea={};M(Ea,{base58btc:()=>Ie,base58flickr:()=>gy});var Ie=or({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),gy=or({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Aa={};M(Aa,{base64:()=>ao,base64pad:()=>yy,base64url:()=>by,base64urlpad:()=>wy});var ao=he({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),yy=he({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),by=he({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wy=he({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});Je.default.formatters.b=r=>r==null?"undefined":Ie.baseEncode(r);Je.default.formatters.t=r=>r==null?"undefined":sr.baseEncode(r);Je.default.formatters.m=r=>r==null?"undefined":ao.baseEncode(r);Je.default.formatters.p=r=>r==null?"undefined":r.toString();Je.default.formatters.c=r=>r==null?"undefined":r.toString();Je.default.formatters.k=r=>r==null?"undefined":r.toString();Je.default.formatters.a=r=>r==null?"undefined":r.toString();function xy(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 ir(r){let e=xy(`${r}:trace`);return Je.default.enabled(`${r}:trace`)&&Je.default.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=(0,Je.default)(`${r}:trace`)),Object.assign((0,Je.default)(r),{error:(0,Je.default)(`${r}:error`),trace:e})}var Ba={};M(Ba,{base10:()=>vy});var vy=or({prefix:"9",name:"base10",alphabet:"0123456789"});var Sa={};M(Sa,{base16:()=>Ey,base16upper:()=>Ay});var Ey=he({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ay=he({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ia={};M(Ia,{base2:()=>By});var By=he({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ca={};M(Ca,{base256emoji:()=>ky});var Bf=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}"),Sy=Bf.reduce((r,e,t)=>(r[t]=e,r),[]),Iy=Bf.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Cy(r){return r.reduce((e,t)=>(e+=Sy[t],e),"")}function Ty(r){let e=[];for(let t of r){let n=Iy[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var ky=sn({prefix:"\u{1F680}",name:"base256emoji",encode:Cy,decode:Ty});var Ta={};M(Ta,{base36:()=>bs,base36upper:()=>Ry});var bs=or({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ry=or({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ka={};M(ka,{base8:()=>Ny});var Ny=he({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ra={};M(Ra,{identity:()=>Uy});var Uy=sn({prefix:"\0",name:"identity",encode:r=>wf(r),decode:r=>bf(r)});var KA=new TextEncoder,zA=new TextDecoder;var Ua={};M(Ua,{identity:()=>vt});var Ly=Cf,Sf=128,Oy=127,Vy=~Oy,Py=Math.pow(2,31);function Cf(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Py;)e[t++]=r&255|Sf,r/=128;for(;r&Vy;)e[t++]=r&255|Sf,r>>>=7;return e[t]=r|0,Cf.bytes=t-n+1,e}var My=Na,Fy=128,If=127;function Na(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Na.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&If)<<o:(i&If)*Math.pow(2,o),o+=7}while(i>=Fy);return Na.bytes=s-n,t}var $y=Math.pow(2,7),Hy=Math.pow(2,14),Ky=Math.pow(2,21),zy=Math.pow(2,28),qy=Math.pow(2,35),Gy=Math.pow(2,42),jy=Math.pow(2,49),Wy=Math.pow(2,56),Yy=Math.pow(2,63),Zy=function(r){return r<$y?1:r<Hy?2:r<Ky?3:r<zy?4:r<qy?5:r<Gy?6:r<jy?7:r<Wy?8:r<Yy?9:10},Jy={encode:Ly,decode:My,encodingLength:Zy},Xy=Jy,co=Xy;function uo(r,e=0){return[co.decode(r,e),co.decode.bytes]}function an(r,e,t=0){return co.encode(r,e,t),e}function cn(r){return co.encodingLength(r)}function xt(r,e){let t=e.byteLength,n=cn(r),o=n+cn(t),s=new Uint8Array(o+t);return an(r,s,0),an(t,s,n),s.set(e,o),new un(r,t,e,s)}function _r(r){let e=Dt(r),[t,n]=uo(e),[o,s]=uo(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new un(t,o,i,e)}function Tf(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&yf(r.bytes,t.bytes)}}var un=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var kf=0,Qy="identity",Rf=Dt;function eb(r){return xt(kf,Rf(r))}var vt={code:kf,name:Qy,encode:Rf,digest:eb};var La={};M(La,{sha256:()=>Ce,sha512:()=>tb});function Da({name:r,code:e,encode:t}){return new _a(r,e,t)}var _a=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?xt(this.code,t):t.then(n=>xt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Uf(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Ce=Da({name:"sha2-256",code:18,encode:Uf("SHA-256")}),tb=Da({name:"sha2-512",code:19,encode:Uf("SHA-512")});function _f(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return nb(t,Oa(r),e??Ie.encoder);default:return ob(t,Oa(r),e??sr.encoder)}}var Df=new WeakMap;function Oa(r){let e=Df.get(r);if(e==null){let t=new Map;return Df.set(r,t),t}return e}var Xe=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!==lo)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==sb)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=xt(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&&Tf(e.multihash,n.multihash)}toString(e){return _f(this,e)}toJSON(){return{"/":_f(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:s,bytes:i}=t;return new r(n,o,s,i??Lf(n,o,s.bytes))}else if(t[ib]===!0){let{version:n,multihash:o,code:s}=t,i=_r(o);return r.create(n,s,i)}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!==lo)throw new Error(`Version 0 CID must use dag-pb (code: ${lo}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Lf(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,lo,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 s=o.subarray(t.multihashSize-t.digestSize),i=new un(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,p]=uo(e.subarray(t));return t+=p,l},o=n(),s=lo;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),c=n(),f=t+c,u=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=rb(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Oa(s).set(n,e),s}};function rb(r,e){switch(r[0]){case"Q":{let t=e??Ie;return[Ie.prefix,t.decode(`${Ie.prefix}${r}`)]}case Ie.prefix:{let t=e??Ie;return[Ie.prefix,t.decode(r)]}case sr.prefix:{let t=e??sr;return[sr.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 nb(r,e,t){let{prefix:n}=t;if(n!==Ie.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o}function ob(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o}var lo=112,sb=18;function Lf(r,e,t){let n=cn(r),o=n+cn(e),s=new Uint8Array(o+t.byteLength);return an(r,s,0),an(e,s,n),s.set(t,o),s}var ib=Symbol.for("@ipld/js-cid/CID");var ln={...Ra,...Ia,...ka,...Ba,...Sa,...va,...Ta,...Ea,...Aa,...Ca},fB={...La,...Ua};function Te(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 ab=Symbol.for("nodejs.util.inspect.custom"),Of=Object.values(ln).map(r=>r.decoder).reduce((r,e)=>r.or(e),ln.identity.decoder),Vf=114,Va=36,Pa=37,fo=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()})`}[pa]=!0;toString(){return this.string==null&&(this.string=Ie.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Xe.createV1(Vf,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return Te(this.multihash.bytes,e);if(typeof e=="string")return Ma(e).equals(this);if(e?.multihash?.bytes!=null)return Te(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[ab](){return`PeerId(${this.toString()})`}},fn=class extends fo{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},hn=class extends fo{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},dn=class extends fo{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function Ma(r,e){if(e=e??Of,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=_r(Ie.decode(`z${r}`));return r.startsWith("12D")?new hn({multihash:t}):r.startsWith("16U")?new dn({multihash:t}):new fn({multihash:t})}return Fa(Of.decode(r))}function Fa(r){try{let e=_r(r);if(e.code===vt.code){if(e.digest.length===Va)return new hn({multihash:e});if(e.digest.length===Pa)return new dn({multihash:e})}if(e.code===Ce.code)return new fn({multihash:e})}catch{return cb(Xe.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function cb(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Vf)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===Ce.code)return new fn({multihash:r.multihash});if(e.code===vt.code){if(e.digest.length===Va)return new hn({multihash:r.multihash});if(e.digest.length===Pa)return new dn({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function Pf(r,e){return r.length===Va?new hn({multihash:xt(vt.code,r),privateKey:e}):r.length===Pa?new dn({multihash:xt(vt.code,r),privateKey:e}):new fn({multihash:await Ce.digest(r),publicKey:r,privateKey:e})}var gc={};M(gc,{Ed25519PrivateKey:()=>Hr,Ed25519PublicKey:()=>wo,generateKeyPair:()=>Tw,generateKeyPairFromSeed:()=>xh,unmarshalEd25519PrivateKey:()=>Iw,unmarshalEd25519PublicKey:()=>Cw});function Lr(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function lt(r=0){return globalThis.Buffer?.allocUnsafe!=null?Lr(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Or(r,e){if(globalThis.Buffer!=null)return Lr(globalThis.Buffer.concat(r,e));e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=lt(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return Lr(t)}function Ff(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Mf=Ff("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),$a=Ff("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=lt(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),ub={utf8:Mf,"utf-8":Mf,hex:ln.base16,latin1:$a,ascii:$a,binary:$a,...ln},xs=ub;function ee(r,e="utf8"){let t=xs[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Lr(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function ot(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function pn(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function lb(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Ha(r,...e){if(!lb(r))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(r.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${r.length}`)}function vs(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");pn(r.outputLen),pn(r.blockLen)}function mn(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 $f(r,e){Ha(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var Es=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Hf(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var yn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),ft=(r,e)=>r<<32-e|r>>>e,fb=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!fb)throw new Error("Non little-endian hardware is not supported");var hb=async()=>{};async function Kf(r,e,t){let n=Date.now();for(let o=0;o<r;o++){t(o);let s=Date.now()-n;s>=0&&s<e||(await hb(),n+=s)}}function Ka(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function ar(r){if(typeof r=="string"&&(r=Ka(r)),!Hf(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function As(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];if(!Hf(o))throw new Error("Uint8Array expected");e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let s=r[n];t.set(s,o),o+=s.length}return t}var gn=class{clone(){return this._cloneInto()}},db={}.toString;function zf(r,e){if(e!==void 0&&db.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function Bs(r){let e=n=>r().update(ar(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function bn(r=32){if(Es&&typeof Es.getRandomValues=="function")return Es.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function pb(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(t>>o&s),a=Number(t&s),c=n?4:0,f=n?0:4;r.setUint32(e+c,i,n),r.setUint32(e+f,a,n)}var wn=class extends gn{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=yn(this.buffer)}update(e){mn(this);let{view:t,buffer:n,blockLen:o}=this;e=ar(e);let s=e.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=yn(e);for(;o<=s-i;i+=o)this.process(c,i);continue}n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){mn(this),$f(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)t[l]=0;pb(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=yn(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],s)}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:s,destroyed:i,pos:a}=this;return e.length=o,e.pos=a,e.finished=s,e.destroyed=i,o%t&&e.buffer.set(n),e}};var Ss=BigInt(4294967295),za=BigInt(32);function qf(r,e=!1){return e?{h:Number(r&Ss),l:Number(r>>za&Ss)}:{h:Number(r>>za&Ss)|0,l:Number(r&Ss)|0}}function mb(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:i}=qf(r[o],e);[t[o],n[o]]=[s,i]}return[t,n]}var gb=(r,e)=>BigInt(r>>>0)<<za|BigInt(e>>>0),yb=(r,e,t)=>r>>>t,bb=(r,e,t)=>r<<32-t|e>>>t,wb=(r,e,t)=>r>>>t|e<<32-t,xb=(r,e,t)=>r<<32-t|e>>>t,vb=(r,e,t)=>r<<64-t|e>>>t-32,Eb=(r,e,t)=>r>>>t-32|e<<64-t,Ab=(r,e)=>e,Bb=(r,e)=>r,Sb=(r,e,t)=>r<<t|e>>>32-t,Ib=(r,e,t)=>e<<t|r>>>32-t,Cb=(r,e,t)=>e<<t-32|r>>>64-t,Tb=(r,e,t)=>r<<t-32|e>>>64-t;function kb(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var Rb=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),Nb=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,Ub=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),_b=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,Db=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),Lb=(r,e,t,n,o,s)=>e+t+n+o+s+(r/2**32|0)|0;var Ob={fromBig:qf,split:mb,toBig:gb,shrSH:yb,shrSL:bb,rotrSH:wb,rotrSL:xb,rotrBH:vb,rotrBL:Eb,rotr32H:Ab,rotr32L:Bb,rotlSH:Sb,rotlSL:Ib,rotlBH:Cb,rotlBL:Tb,add:kb,add3L:Rb,add3H:Nb,add4L:Ub,add4H:_b,add5H:Lb,add5L:Db},j=Ob;var[Vb,Pb]=j.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))),cr=new Uint32Array(80),ur=new Uint32Array(80),qa=class extends wn{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:s,Cl:i,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:p,Gh:x,Gl:d,Hh:h,Hl:m}=this;return[e,t,n,o,s,i,a,c,f,u,l,p,x,d,h,m]}set(e,t,n,o,s,i,a,c,f,u,l,p,x,d,h,m){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=p|0,this.Gh=x|0,this.Gl=d|0,this.Hh=h|0,this.Hl=m|0}process(e,t){for(let b=0;b<16;b++,t+=4)cr[b]=e.getUint32(t),ur[b]=e.getUint32(t+=4);for(let b=16;b<80;b++){let S=cr[b-15]|0,v=ur[b-15]|0,I=j.rotrSH(S,v,1)^j.rotrSH(S,v,8)^j.shrSH(S,v,7),C=j.rotrSL(S,v,1)^j.rotrSL(S,v,8)^j.shrSL(S,v,7),y=cr[b-2]|0,k=ur[b-2]|0,O=j.rotrSH(y,k,19)^j.rotrBH(y,k,61)^j.shrSH(y,k,6),U=j.rotrSL(y,k,19)^j.rotrBL(y,k,61)^j.shrSL(y,k,6),V=j.add4L(C,U,ur[b-7],ur[b-16]),H=j.add4H(V,I,O,cr[b-7],cr[b-16]);cr[b]=H|0,ur[b]=V|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:p,Fh:x,Fl:d,Gh:h,Gl:m,Hh:g,Hl:A}=this;for(let b=0;b<80;b++){let S=j.rotrSH(l,p,14)^j.rotrSH(l,p,18)^j.rotrBH(l,p,41),v=j.rotrSL(l,p,14)^j.rotrSL(l,p,18)^j.rotrBL(l,p,41),I=l&x^~l&h,C=p&d^~p&m,y=j.add5L(A,v,C,Pb[b],ur[b]),k=j.add5H(y,g,S,I,Vb[b],cr[b]),O=y|0,U=j.rotrSH(n,o,28)^j.rotrBH(n,o,34)^j.rotrBH(n,o,39),V=j.rotrSL(n,o,28)^j.rotrBL(n,o,34)^j.rotrBL(n,o,39),H=n&s^n&a^s&a,X=o&i^o&c^i&c;g=h|0,A=m|0,h=x|0,m=d|0,x=l|0,d=p|0,{h:l,l:p}=j.add(f|0,u|0,k|0,O|0),f=a|0,u=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let B=j.add3L(O,V,X);n=j.add3H(B,k,U,H),o=B|0}({h:n,l:o}=j.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=j.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=j.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=j.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:p}=j.add(this.Eh|0,this.El|0,l|0,p|0),{h:x,l:d}=j.add(this.Fh|0,this.Fl|0,x|0,d|0),{h,l:m}=j.add(this.Gh|0,this.Gl|0,h|0,m|0),{h:g,l:A}=j.add(this.Hh|0,this.Hl|0,g|0,A|0),this.set(n,o,s,i,a,c,f,u,l,p,x,d,h,m,g,A)}roundClean(){cr.fill(0),ur.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 xn=Bs(()=>new qa);var Cs={};M(Cs,{bitGet:()=>qb,bitLen:()=>zb,bitMask:()=>ho,bitSet:()=>Gb,bytesToHex:()=>Ot,bytesToNumberBE:()=>Vt,bytesToNumberLE:()=>lr,concatBytes:()=>Pt,createHmacDrbg:()=>Wa,ensureBytes:()=>de,equalBytes:()=>Hb,hexToBytes:()=>Vr,hexToNumber:()=>ja,isBytes:()=>ht,numberToBytesBE:()=>fr,numberToBytesLE:()=>Pr,numberToHexUnpadded:()=>Yf,numberToVarBytesBE:()=>$b,utf8ToBytes:()=>Kb,validateObject:()=>Et});var Wf=BigInt(0),Is=BigInt(1),Mb=BigInt(2);function ht(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var Fb=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Ot(r){if(!ht(r))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=Fb[r[t]];return e}function Yf(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function ja(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var Lt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Gf(r){if(r>=Lt._0&&r<=Lt._9)return r-Lt._0;if(r>=Lt._A&&r<=Lt._F)return r-(Lt._A-10);if(r>=Lt._a&&r<=Lt._f)return r-(Lt._a-10)}function Vr(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,s=0;o<t;o++,s+=2){let i=Gf(r.charCodeAt(s)),a=Gf(r.charCodeAt(s+1));if(i===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function Vt(r){return ja(Ot(r))}function lr(r){if(!ht(r))throw new Error("Uint8Array expected");return ja(Ot(Uint8Array.from(r).reverse()))}function fr(r,e){return Vr(r.toString(16).padStart(e*2,"0"))}function Pr(r,e){return fr(r,e).reverse()}function $b(r){return Vr(Yf(r))}function de(r,e,t){let n;if(typeof e=="string")try{n=Vr(e)}catch(s){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${s}`)}else if(ht(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof t=="number"&&o!==t)throw new Error(`${r} expected ${t} bytes, got ${o}`);return n}function Pt(...r){let e=0;for(let o=0;o<r.length;o++){let s=r[o];if(!ht(s))throw new Error("Uint8Array expected");e+=s.length}let t=new Uint8Array(e),n=0;for(let o=0;o<r.length;o++){let s=r[o];t.set(s,n),n+=s.length}return t}function Hb(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 Kb(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function zb(r){let e;for(e=0;r>Wf;r>>=Is,e+=1);return e}function qb(r,e){return r>>BigInt(e)&Is}var Gb=(r,e,t)=>r|(t?Is:Wf)<<BigInt(e),ho=r=>(Mb<<BigInt(r-1))-Is,Ga=r=>new Uint8Array(r),jf=r=>Uint8Array.from(r);function Wa(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=Ga(r),o=Ga(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},a=(...l)=>t(o,n,...l),c=(l=Ga())=>{o=a(jf([0]),l),n=a(),l.length!==0&&(o=a(jf([1]),l),n=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l<e;){n=a();let x=n.slice();p.push(x),l+=n.length}return Pt(...p)};return(l,p)=>{i(),c(l);let x;for(;!(x=p(f()));)c();return i(),x}}var jb={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||ht(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Et(r,e,t={}){let n=(o,s,i)=>{let a=jb[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=r[o];if(!(i&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${s}`)};for(let[o,s]of Object.entries(e))n(o,s,!1);for(let[o,s]of Object.entries(t))n(o,s,!0);return r}var xe=BigInt(0),ie=BigInt(1),Mr=BigInt(2),Wb=BigInt(3),Ya=BigInt(4),Zf=BigInt(5),Jf=BigInt(8),Yb=BigInt(9),Zb=BigInt(16);function oe(r,e){let t=r%e;return t>=xe?t:e+t}function Jb(r,e,t){if(t<=xe||e<xe)throw new Error("Expected power/modulo > 0");if(t===ie)return xe;let n=ie;for(;e>xe;)e&ie&&(n=n*r%t),r=r*r%t,e>>=ie;return n}function ae(r,e,t){let n=r;for(;e-- >xe;)n*=n,n%=t;return n}function Ts(r,e){if(r===xe||e<=xe)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=oe(r,e),n=e,o=xe,s=ie,i=ie,a=xe;for(;t!==xe;){let f=n/t,u=n%t,l=o-i*f,p=s-a*f;n=t,t=u,o=i,s=a,i=l,a=p}if(n!==ie)throw new Error("invert: does not exist");return oe(o,e)}function Xb(r){let e=(r-ie)/Mr,t,n,o;for(t=r-ie,n=0;t%Mr===xe;t/=Mr,n++);for(o=Mr;o<r&&Jb(o,e,r)!==r-ie;o++);if(n===1){let i=(r+ie)/Ya;return function(c,f){let u=c.pow(f,i);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let s=(t+ie)/Mr;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,s),p=a.pow(c,t);for(;!a.eql(p,a.ONE);){if(a.eql(p,a.ZERO))return a.ZERO;let x=1;for(let h=a.sqr(p);x<f&&!a.eql(h,a.ONE);x++)h=a.sqr(h);let d=a.pow(u,ie<<BigInt(f-x-1));u=a.sqr(d),l=a.mul(l,d),p=a.mul(p,u),f=x}return l}}function Qb(r){if(r%Ya===Wb){let e=(r+ie)/Ya;return function(n,o){let s=n.pow(o,e);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%Jf===Zf){let e=(r-Zf)/Jf;return function(n,o){let s=n.mul(o,Mr),i=n.pow(s,e),a=n.mul(o,i),c=n.mul(n.mul(a,Mr),i),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%Zb,Xb(r)}var Xf=(r,e)=>(oe(r,e)&ie)===ie,ew=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Za(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=ew.reduce((n,o)=>(n[o]="function",n),e);return Et(r,t)}function tw(r,e,t){if(t<xe)throw new Error("Expected power > 0");if(t===xe)return r.ONE;if(t===ie)return e;let n=r.ONE,o=e;for(;t>xe;)t&ie&&(n=r.mul(n,o)),o=r.sqr(o),t>>=ie;return n}function rw(r,e){let t=new Array(e.length),n=e.reduce((s,i,a)=>r.is0(i)?s:(t[a]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return e.reduceRight((s,i,a)=>r.is0(i)?s:(t[a]=r.mul(s,t[a]),r.mul(s,i)),o),t}function Ja(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function ks(r,e,t=!1,n={}){if(r<=xe)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:s}=Ja(r,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=Qb(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:s,MASK:ho(o),ZERO:xe,ONE:ie,create:c=>oe(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return xe<=c&&c<r},is0:c=>c===xe,isOdd:c=>(c&ie)===ie,neg:c=>oe(-c,r),eql:(c,f)=>c===f,sqr:c=>oe(c*c,r),add:(c,f)=>oe(c+f,r),sub:(c,f)=>oe(c-f,r),mul:(c,f)=>oe(c*f,r),pow:(c,f)=>tw(a,c,f),div:(c,f)=>oe(c*Ts(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Ts(c,r),sqrt:n.sqrt||(c=>i(a,c)),invertBatch:c=>rw(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>t?Pr(c,s):fr(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return t?lr(c):Vt(c)}});return Object.freeze(a)}function Qf(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 eh(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 Xa(r){let e=eh(r);return e+Math.ceil(e/2)}function th(r,e,t=!1){let n=r.length,o=eh(e),s=Xa(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let i=t?Vt(r):lr(r),a=oe(i,e-ie)+ie;return t?Pr(a,o):fr(a,o)}var ow=BigInt(0),Qa=BigInt(1);function Rs(r,e){let t=(o,s)=>{let i=s.negate();return o?i:s},n=o=>{let s=Math.ceil(e/o)+1,i=2**(o-1);return{windows:s,windowSize:i}};return{constTimeNegate:t,unsafeLadder(o,s){let i=r.ZERO,a=o;for(;s>ow;)s&Qa&&(i=i.add(a)),a=a.double(),s>>=Qa;return i},precomputeWindow(o,s){let{windows:i,windowSize:a}=n(s),c=[],f=o,u=f;for(let l=0;l<i;l++){u=f,c.push(u);for(let p=1;p<a;p++)u=u.add(f),c.push(u);f=u.double()}return c},wNAF(o,s,i){let{windows:a,windowSize:c}=n(o),f=r.ZERO,u=r.BASE,l=BigInt(2**o-1),p=2**o,x=BigInt(o);for(let d=0;d<a;d++){let h=d*c,m=Number(i&l);i>>=x,m>c&&(m-=p,i+=Qa);let g=h,A=h+Math.abs(m)-1,b=d%2!==0,S=m<0;m===0?u=u.add(t(b,s[g])):f=f.add(t(S,s[A]))}return{p:f,f:u}},wNAFCached(o,s,i,a){let c=o._WINDOW_SIZE||1,f=s.get(o);return f||(f=this.precomputeWindow(o,c),c!==1&&s.set(o,a(f))),this.wNAF(c,f,i)}}}function po(r){return Za(r.Fp),Et(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ja(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var dt=BigInt(0),Qe=BigInt(1),Ns=BigInt(2),sw=BigInt(8),iw={zip215:!0};function aw(r){let e=po(r);return Et(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Us(r){let e=aw(r),{Fp:t,n,prehash:o,hash:s,randomBytes:i,nByteLength:a,h:c}=e,f=Ns<<BigInt(a*8)-Qe,u=t.create,l=e.uvRatio||((T,E)=>{try{return{isValid:!0,value:t.sqrt(T*t.inv(E))}}catch{return{isValid:!1,value:dt}}}),p=e.adjustScalarBytes||(T=>T),x=e.domain||((T,E,L)=>{if(E.length||L)throw new Error("Contexts/pre-hash are not supported");return T}),d=T=>typeof T=="bigint"&&dt<T,h=(T,E)=>d(T)&&d(E)&&T<E,m=T=>T===dt||h(T,f);function g(T,E){if(h(T,E))return T;throw new Error(`Expected valid scalar < ${E}, got ${typeof T} ${T}`)}function A(T){return T===dt?T:g(T,n)}let b=new Map;function S(T){if(!(T instanceof v))throw new Error("ExtendedPoint expected")}class v{constructor(E,L,F,q){if(this.ex=E,this.ey=L,this.ez=F,this.et=q,!m(E))throw new Error("x required");if(!m(L))throw new Error("y required");if(!m(F))throw new Error("z required");if(!m(q))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(E){if(E instanceof v)throw new Error("extended point not allowed");let{x:L,y:F}=E||{};if(!m(L)||!m(F))throw new Error("invalid affine point");return new v(L,F,Qe,u(L*F))}static normalizeZ(E){let L=t.invertBatch(E.map(F=>F.ez));return E.map((F,q)=>F.toAffine(L[q])).map(v.fromAffine)}_setWindowSize(E){this._WINDOW_SIZE=E,b.delete(this)}assertValidity(){let{a:E,d:L}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:F,ey:q,ez:W,et:Y}=this,ne=u(F*F),J=u(q*q),Q=u(W*W),ye=u(Q*Q),fe=u(ne*E),Ae=u(Q*u(fe+J)),Be=u(ye+u(L*u(ne*J)));if(Ae!==Be)throw new Error("bad point: equation left != right (1)");let we=u(F*q),De=u(W*Y);if(we!==De)throw new Error("bad point: equation left != right (2)")}equals(E){S(E);let{ex:L,ey:F,ez:q}=this,{ex:W,ey:Y,ez:ne}=E,J=u(L*ne),Q=u(W*q),ye=u(F*ne),fe=u(Y*q);return J===Q&&ye===fe}is0(){return this.equals(v.ZERO)}negate(){return new v(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:E}=e,{ex:L,ey:F,ez:q}=this,W=u(L*L),Y=u(F*F),ne=u(Ns*u(q*q)),J=u(E*W),Q=L+F,ye=u(u(Q*Q)-W-Y),fe=J+Y,Ae=fe-ne,Be=J-Y,we=u(ye*Ae),De=u(fe*Be),_t=u(ye*Be),Nr=u(Ae*fe);return new v(we,De,Nr,_t)}add(E){S(E);let{a:L,d:F}=e,{ex:q,ey:W,ez:Y,et:ne}=this,{ex:J,ey:Q,ez:ye,et:fe}=E;if(L===BigInt(-1)){let of=u((W-q)*(Q+J)),sf=u((W+q)*(Q-J)),da=u(sf-of);if(da===dt)return this.double();let af=u(Y*Ns*fe),cf=u(ne*Ns*ye),uf=cf+af,lf=sf+of,ff=cf-af,Og=u(uf*da),Vg=u(lf*ff),Pg=u(uf*ff),Mg=u(da*lf);return new v(Og,Vg,Mg,Pg)}let Ae=u(q*J),Be=u(W*Q),we=u(ne*F*fe),De=u(Y*ye),_t=u((q+W)*(J+Q)-Ae-Be),Nr=De-we,io=De+we,nf=u(Be-L*Ae),Ug=u(_t*Nr),_g=u(io*nf),Dg=u(_t*nf),Lg=u(Nr*io);return new v(Ug,_g,Lg,Dg)}subtract(E){return this.add(E.negate())}wNAF(E){return y.wNAFCached(this,b,E,v.normalizeZ)}multiply(E){let{p:L,f:F}=this.wNAF(g(E,n));return v.normalizeZ([L,F])[0]}multiplyUnsafe(E){let L=A(E);return L===dt?C:this.equals(C)||L===Qe?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(E){let{ex:L,ey:F,ez:q}=this,W=this.is0();E==null&&(E=W?sw:t.inv(q));let Y=u(L*E),ne=u(F*E),J=u(q*E);if(W)return{x:dt,y:Qe};if(J!==Qe)throw new Error("invZ was invalid");return{x:Y,y:ne}}clearCofactor(){let{h:E}=e;return E===Qe?this:this.multiplyUnsafe(E)}static fromHex(E,L=!1){let{d:F,a:q}=e,W=t.BYTES;E=de("pointHex",E,W);let Y=E.slice(),ne=E[W-1];Y[W-1]=ne&-129;let J=lr(Y);J===dt||(L?g(J,f):g(J,t.ORDER));let Q=u(J*J),ye=u(Q-Qe),fe=u(F*Q-q),{isValid:Ae,value:Be}=l(ye,fe);if(!Ae)throw new Error("Point.fromHex: invalid y coordinate");let we=(Be&Qe)===Qe,De=(ne&128)!==0;if(!L&&Be===dt&&De)throw new Error("Point.fromHex: x=0 and x_0=1");return De!==we&&(Be=u(-Be)),v.fromAffine({x:Be,y:J})}static fromPrivateKey(E){return U(E).point}toRawBytes(){let{x:E,y:L}=this.toAffine(),F=Pr(L,t.BYTES);return F[F.length-1]|=E&Qe?128:0,F}toHex(){return Ot(this.toRawBytes())}}v.BASE=new v(e.Gx,e.Gy,Qe,u(e.Gx*e.Gy)),v.ZERO=new v(dt,Qe,Qe,dt);let{BASE:I,ZERO:C}=v,y=Rs(v,a*8);function k(T){return oe(T,n)}function O(T){return k(lr(T))}function U(T){let E=a;T=de("private key",T,E);let L=de("hashed private key",s(T),2*E),F=p(L.slice(0,E)),q=L.slice(E,2*E),W=O(F),Y=I.multiply(W),ne=Y.toRawBytes();return{head:F,prefix:q,scalar:W,point:Y,pointBytes:ne}}function V(T){return U(T).pointBytes}function H(T=new Uint8Array,...E){let L=Pt(...E);return O(s(x(L,de("context",T),!!o)))}function X(T,E,L={}){T=de("message",T),o&&(T=o(T));let{prefix:F,scalar:q,pointBytes:W}=U(E),Y=H(L.context,F,T),ne=I.multiply(Y).toRawBytes(),J=H(L.context,ne,W,T),Q=k(Y+J*q);A(Q);let ye=Pt(ne,Pr(Q,t.BYTES));return de("result",ye,a*2)}let B=iw;function R(T,E,L,F=B){let{context:q,zip215:W}=F,Y=t.BYTES;T=de("signature",T,2*Y),E=de("message",E),o&&(E=o(E));let ne=lr(T.slice(Y,2*Y)),J,Q,ye;try{J=v.fromHex(L,W),Q=v.fromHex(T.slice(0,Y),W),ye=I.multiplyUnsafe(ne)}catch{return!1}if(!W&&J.isSmallOrder())return!1;let fe=H(q,Q.toRawBytes(),J.toRawBytes(),E);return Q.add(J.multiplyUnsafe(fe)).subtract(ye).clearCofactor().equals(v.ZERO)}return I._setWindowSize(8),{CURVE:e,getPublicKey:V,sign:X,verify:R,ExtendedPoint:v,utils:{getExtendedPublicKey:U,randomPrivateKey:()=>i(t.BYTES),precompute(T=8,E=v.BASE){return E._setWindowSize(T),E.multiply(BigInt(3)),E}}}}var tc=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),rh=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),a6=BigInt(0),cw=BigInt(1),ec=BigInt(2),uw=BigInt(5),nh=BigInt(10),lw=BigInt(20),fw=BigInt(40),oh=BigInt(80);function hw(r){let e=tc,n=r*r%e*r%e,o=ae(n,ec,e)*n%e,s=ae(o,cw,e)*r%e,i=ae(s,uw,e)*s%e,a=ae(i,nh,e)*i%e,c=ae(a,lw,e)*a%e,f=ae(c,fw,e)*c%e,u=ae(f,oh,e)*f%e,l=ae(u,oh,e)*f%e,p=ae(l,nh,e)*i%e;return{pow_p_5_8:ae(p,ec,e)*r%e,b2:n}}function dw(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function pw(r,e){let t=tc,n=oe(e*e*e,t),o=oe(n*n*e,t),s=hw(r*o).pow_p_5_8,i=oe(r*n*s,t),a=oe(e*i*i,t),c=i,f=oe(i*rh,t),u=a===r,l=a===oe(-r,t),p=a===oe(-r*rh,t);return u&&(i=c),(l||p)&&(i=f),Xf(i,t)&&(i=oe(-i,t)),{isValid:u||l,value:i}}var Mt=ks(tc,void 0,!0),rc={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Mt,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:xn,randomBytes:bn,adjustScalarBytes:dw,uvRatio:pw},vn=Us(rc);function sh(r,e,t){if(e.length>255)throw new Error("Context is too big");return As(Ka("SigEd25519 no Ed25519 collisions"),new Uint8Array([t?1:0,e.length]),e,r)}var c6=Us({...rc,domain:sh}),u6=Us({...rc,domain:sh,prehash:xn});var mw=(Mt.ORDER+BigInt(3))/BigInt(8),l6=Mt.pow(ec,mw),f6=Mt.sqrt(Mt.neg(Mt.ONE)),h6=(Mt.ORDER-BigInt(5))/BigInt(8),d6=BigInt(486662);var p6=Qf(Mt,Mt.neg(BigInt(486664)));var m6=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),g6=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),y6=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),b6=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var w6=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var En=32,Ft=64,_s=32;function ih(){let r=vn.utils.randomPrivateKey(),e=vn.getPublicKey(r);return{privateKey:lh(r,e),publicKey:e}}function ah(r){if(r.length!==_s)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=vn.getPublicKey(e);return{privateKey:lh(e,t),publicKey:t}}function ch(r,e){let t=r.subarray(0,_s);return vn.sign(e instanceof Uint8Array?e:e.subarray(),t)}function uh(r,e,t){return vn.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function lh(r,e){let t=new Uint8Array(Ft);for(let n=0;n<_s;n++)t[n]=r[n],t[_s+n]=e[n];return t}var Fe={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 nc={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function fh(r){let e=r?.algorithm??"AES-GCM",t=r?.keyLength??16,n=r?.nonceLength??12,o=r?.digest??"SHA-256",s=r?.saltLength??16,i=r?.iterations??32767,a=Fe.get();t*=8;async function c(l,p){let x=a.getRandomValues(new Uint8Array(s)),d=a.getRandomValues(new Uint8Array(n)),h={name:e,iv:d};typeof p=="string"&&(p=ee(p));let m;if(p.length===0){m=await a.subtle.importKey("jwk",nc,{name:"AES-GCM"},!0,["encrypt"]);try{let A={name:"PBKDF2",salt:x,iterations:i,hash:{name:o}},b=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);m=await a.subtle.deriveKey(A,b,{name:e,length:t},!0,["encrypt"])}catch{m=await a.subtle.importKey("jwk",nc,{name:"AES-GCM"},!0,["encrypt"])}}else{let A={name:"PBKDF2",salt:x,iterations:i,hash:{name:o}},b=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);m=await a.subtle.deriveKey(A,b,{name:e,length:t},!0,["encrypt"])}let g=await a.subtle.encrypt(h,m,l);return Or([x,h.iv,new Uint8Array(g)])}async function f(l,p){let x=l.subarray(0,s),d=l.subarray(s,s+n),h=l.subarray(s+n),m={name:e,iv:d};typeof p=="string"&&(p=ee(p));let g;if(p.length===0)try{let b={name:"PBKDF2",salt:x,iterations:i,hash:{name:o}},S=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(b,S,{name:e,length:t},!0,["decrypt"])}catch{g=await a.subtle.importKey("jwk",nc,{name:"AES-GCM"},!0,["decrypt"])}else{let b={name:"PBKDF2",salt:x,iterations:i,hash:{name:o}},S=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(b,S,{name:e,length:t},!0,["decrypt"])}let A=await a.subtle.decrypt(m,g,h);return new Uint8Array(A)}return{encrypt:c,decrypt:f}}async function An(r,e){let n=await fh().encrypt(r,e);return ao.encode(n)}var oc=new Float32Array([-0]),hr=new Uint8Array(oc.buffer);function hh(r,e,t){oc[0]=r,e[t]=hr[0],e[t+1]=hr[1],e[t+2]=hr[2],e[t+3]=hr[3]}function dh(r,e){return hr[0]=r[e],hr[1]=r[e+1],hr[2]=r[e+2],hr[3]=r[e+3],oc[0]}var sc=new Float64Array([-0]),Oe=new Uint8Array(sc.buffer);function ph(r,e,t){sc[0]=r,e[t]=Oe[0],e[t+1]=Oe[1],e[t+2]=Oe[2],e[t+3]=Oe[3],e[t+4]=Oe[4],e[t+5]=Oe[5],e[t+6]=Oe[6],e[t+7]=Oe[7]}function mh(r,e){return Oe[0]=r[e],Oe[1]=r[e+1],Oe[2]=r[e+2],Oe[3]=r[e+3],Oe[4]=r[e+4],Oe[5]=r[e+5],Oe[6]=r[e+6],Oe[7]=r[e+7],sc[0]}var bw=BigInt(Number.MAX_SAFE_INTEGER),ww=BigInt(Number.MIN_SAFE_INTEGER),qe=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 Fr;if(e<bw&&e>ww)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>gh&&(o=0n,++n>gh&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return Fr;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):Fr}},Fr=new qe(0,0);Fr.toBigInt=function(){return 0n};Fr.zzEncode=Fr.zzDecode=function(){return this};Fr.length=function(){return 1};var gh=4294967296n;function yh(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 bh(r,e,t){if(t-e<1)return"";let o,s=[],i=0,a;for(;e<t;)a=r[e++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(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,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function ic(r,e,t){let n=t,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,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 pt(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Ds(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var ac=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,pt(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 pt(this,4);return Ds(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw pt(this,4);return Ds(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw pt(this,4);let e=dh(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw pt(this,4);let e=mh(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 pt(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return bh(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw pt(this,e);this.pos+=e}else do if(this.pos>=this.len)throw pt(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 qe(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 pt(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 pt(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 pt(this,8);let e=Ds(this.buf,this.pos+=4),t=Ds(this.buf,this.pos+=4);return new qe(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){return this.readLongVarint().toNumber(!0)}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 cc(r){return new ac(r instanceof Uint8Array?r:r.subarray())}function dr(r,e){let t=cc(r);return e.decode(t)}function uc(r){let e=r??8192,t=e>>>1,n,o=e;return function(i){if(i<1||i>t)return lt(i);o+i>e&&(n=lt(e),o=0);let a=n.subarray(o,o+=i);return o&7&&(o=(o|7)+1),a}}var $r=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function lc(){}var hc=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},xw=uc();function vw(r){return globalThis.Buffer!=null?lt(r):xw(r)}var yo=class{len;head;tail;states;constructor(){this.len=0,this.head=new $r(lc,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new $r(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new dc((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(mo,10,qe.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=qe.fromBigInt(e);return this._push(mo,t.length(),t)}uint64Number(e){let t=qe.fromNumber(e);return this._push(mo,t.length(),t)}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=qe.fromBigInt(e).zzEncode();return this._push(mo,t.length(),t)}sint64Number(e){let t=qe.fromNumber(e).zzEncode();return this._push(mo,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(fc,1,e?1:0)}fixed32(e){return this._push(go,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=qe.fromBigInt(e);return this._push(go,4,t.lo)._push(go,4,t.hi)}fixed64Number(e){let t=qe.fromNumber(e);return this._push(go,4,t.lo)._push(go,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(hh,4,e)}double(e){return this._push(ph,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(fc,1,0):this.uint32(t)._push(Aw,t,e)}string(e){let t=yh(e);return t!==0?this.uint32(t)._push(ic,t,e):this._push(fc,1,0)}fork(){return this.states=new hc(this),this.head=this.tail=new $r(lc,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 $r(lc,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=vw(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function fc(r,e,t){e[t]=r&255}function Ew(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var dc=class extends $r{next;constructor(e,t){super(Ew,e,t),this.next=void 0}};function mo(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 go(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 Aw(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(yo.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(Bw,e,r),this},yo.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(Sw,e,r),this});function Bw(r,e,t){e.set(r,t)}function Sw(r,e,t){r.length<40?ic(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(ee(r),t)}function pc(){return new yo}function pr(r,e){let t=pc();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var Bn;(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"})(Bn||(Bn={}));function Ls(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function bo(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(s,i){let a=e(s);i.int32(a)},n=function(s){let i=s.int32();return e(i)};return Ls("enum",Bn.VARINT,t,n)}function mr(r,e){return Ls("message",Bn.LENGTH_DELIMITED,r,e)}var ce;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(ce||(ce={}));var mc;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(mc||(mc={}));(function(r){r.codec=()=>bo(mc)})(ce||(ce={}));var At;(function(r){let e;r.codec=()=>(e==null&&(e=mr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ce.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let o={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let i=t.uint32();switch(i>>>3){case 1:o.Type=ce.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(i&7);break}}return o})),e),r.encode=t=>pr(t,r.codec()),r.decode=t=>dr(t,r.codec())})(At||(At={}));var Bt;(function(r){let e;r.codec=()=>(e==null&&(e=mr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ce.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let o={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let i=t.uint32();switch(i>>>3){case 1:o.Type=ce.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(i&7);break}}return o})),e),r.encode=t=>pr(t,r.codec()),r.decode=t=>dr(t,r.codec())})(Bt||(Bt={}));var wo=class{_key;constructor(e){this._key=Sn(e,En)}verify(e,t){return uh(this._key,t,e)}marshal(){return this._key}get bytes(){return At.encode({Type:ce.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Te(this.bytes,e.bytes)}hash(){let e=Ce.digest(this.bytes);return ot(e)?e.then(({bytes:t})=>t):e.bytes}},Hr=class{_key;_publicKey;constructor(e,t){this._key=Sn(e,Ft),this._publicKey=Sn(t,En)}sign(e){return ch(this._key,e)}get public(){return new wo(this._publicKey)}marshal(){return this._key}get bytes(){return Bt.encode({Type:ce.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Te(this.bytes,e.bytes)}async hash(){let e=Ce.digest(this.bytes),t;return ot(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=vt.digest(this.public.bytes);return Ie.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return An(this.bytes,e);throw new K(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Iw(r){if(r.length>Ft){r=Sn(r,Ft+En);let n=r.subarray(0,Ft),o=r.subarray(Ft,r.length);return new Hr(n,o)}r=Sn(r,Ft);let e=r.subarray(0,Ft),t=r.subarray(En);return new Hr(e,t)}function Cw(r){return r=Sn(r,En),new wo(r)}async function Tw(){let{privateKey:r,publicKey:e}=ih();return new Hr(r,e)}async function xh(r){let{privateKey:e,publicKey:t}=ah(r);return new Hr(e,t)}function Sn(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new K(`Key must be a Uint8Array of length ${e}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}function ue(r,e="utf8"){let t=xs[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var Ic={};M(Ic,{MAX_RSA_KEY_SIZE:()=>No,RsaPrivateKey:()=>Rn,RsaPublicKey:()=>Ro,fromJwk:()=>tx,generateKeyPair:()=>rx,unmarshalRsaPrivateKey:()=>Bc,unmarshalRsaPublicKey:()=>ex});function Kr(r){if(isNaN(r)||r<=0)throw new K("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return bn(r)}var wr={};M(wr,{exportToPem:()=>Yw,importFromPem:()=>Zw,jwkToPkcs1:()=>qw,jwkToPkix:()=>jw,pkcs1ToJwk:()=>zw,pkixToJwk:()=>Gw});var Vs=class extends gn{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,vs(e);let n=ar(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,s=new Uint8Array(o);s.set(n.length>o?e.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=e.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(e){return mn(this),this.iHash.update(e),this}digestInto(e){mn(this),Ha(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:s,blockLen:i,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,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()}},xo=(r,e,t)=>new Vs(r,e).update(t).digest();xo.create=(r,e)=>new Vs(r,e);function kw(r,e,t,n){vs(r);let o=zf({dkLen:32,asyncTick:10},n),{c:s,dkLen:i,asyncTick:a}=o;if(pn(s),pn(i),pn(a),s<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=ar(e),f=ar(t),u=new Uint8Array(i),l=xo.create(r,c),p=l._cloneInto().update(f);return{c:s,dkLen:i,asyncTick:a,DK:u,PRF:l,PRFSalt:p}}function Rw(r,e,t,n,o){return r.destroy(),e.destroy(),n&&n.destroy(),o.fill(0),t}async function yc(r,e,t,n){let{c:o,dkLen:s,asyncTick:i,DK:a,PRF:c,PRFSalt:f}=kw(r,e,t,n),u,l=new Uint8Array(4),p=yn(l),x=new Uint8Array(c.outputLen);for(let d=1,h=0;h<s;d++,h+=c.outputLen){let m=a.subarray(h,h+c.outputLen);p.setInt32(0,d,!1),(u=f._cloneInto(u)).update(l).digestInto(x),m.set(x.subarray(0,m.length)),await Kf(o-1,i,()=>{c._cloneInto(u).update(x).digestInto(x);for(let g=0;g<m.length;g++)m[g]^=x[g]})}return Rw(c,f,a,u,x)}var Z=Se(vh());function zr(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 gr(r,e,t=-1){let n=t,o=r,s=0,i=Math.pow(2,e);for(let a=1;a<8;a++){if(r<i){let c;if(n<0)c=new ArrayBuffer(a),s=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),s=n}let f=new Uint8Array(c);for(let u=a-1;u>=0;u--){let l=Math.pow(2,u*e);f[s-u-1]=Math.floor(o/l),o-=f[s-u-1]*l}return c}i*=Math.pow(2,e)}return new ArrayBuffer(0)}function Fs(...r){let e=0,t=0;for(let s of r)e+=s.length;let n=new ArrayBuffer(e),o=new Uint8Array(n);for(let s of r)o.set(s,t),t+=s.length;return o}function wc(){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=zr(t,8),o=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(o);for(let a=0;a<this.valueHex.byteLength;a++)s[a]=r[a];return s[0]&=127,zr(s,8)-n}function Eh(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let i=t-e,a=gr(i,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=gr(e,8,n),s=new Uint8Array(o);if(s[0]&128){let i=o.slice(0),a=new Uint8Array(i);o=new ArrayBuffer(o.byteLength+1),s=new Uint8Array(o);for(let c=0;c<i.byteLength;c++)s[c+1]=a[c];s[0]=0}return o}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function Ah(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 Ge(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,o=new Array(n);for(let i=0;i<n;i++)o[i]="0";return o.join("").concat(t)}var BS=Math.log(2);function $s(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function xc(r){let e=0,t=0;for(let o=0;o<r.length;o++){let s=r[o];e+=s.byteLength}let n=new Uint8Array(e);for(let o=0;o<r.length;o++){let s=r[o];n.set(new Uint8Array(s),t),t+=s.byteLength}return n.buffer}function qt(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 Eo=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return xc(this.items)}},vo=[new Uint8Array([1])],Bh="0123456789";var Tn="",gt=new ArrayBuffer(0),vc=new Uint8Array(0),Ao="EndOfContent",Ih="OCTET STRING",Ch="BIT STRING";function Gt(r){var e;return e=class extends r{constructor(...n){var o;super(...n);let s=n[0]||{};this.isHexOnly=(o=s.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=s.valueHex?Z.BufferSourceConverter.toUint8Array(s.valueHex):vc}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,o,s){let i=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!qt(this,i,o,s))return-1;let a=o+s;return this.valueHexView=i.subarray(o,a),this.valueHexView.length?(this.blockLength=s,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",gt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:Z.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var Ht=class{constructor({blockLength:e=0,error:t=Tn,warnings:n=[],valueBeforeDecode:o=vc}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=Z.BufferSourceConverter.toUint8Array(o)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:Z.Convert.ToHex(this.valueBeforeDecodeView)}}};Ht.NAME="baseBlock";var Ve=class extends Ht{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'")}};Ve.NAME="valueBlock";var Hs=class extends Gt(Ht){constructor({idBlock:e={}}={}){var t,n,o,s;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?Z.BufferSourceConverter.toUint8Array(e.valueHex):vc,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(o=e.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!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",gt}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,t|=s,o[0]=t}return o.buffer}if(!this.isHexOnly){let o=gr(this.tagNumber,7),s=new Uint8Array(o),i=o.byteLength,a=new Uint8Array(i+1);if(a[0]=t|31,!e){for(let c=0;c<i-1;c++)a[c+1]=s[c]|128;a[i]=s[i-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let o=this.valueHexView;for(let s=0;s<o.length-1;s++)n[s+1]=o[s]|128;n[this.valueHexView.byteLength]=o[o.length-1]}return n.buffer}fromBER(e,t,n){let o=Z.BufferSourceConverter.toUint8Array(e);if(!qt(this,o,t,n))return-1;let s=o.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[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=(s[0]&32)===32,this.isHexOnly=!1;let a=s[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,f=this.valueHexView=new Uint8Array(255),u=255;for(;s[c]&128;){if(f[c-1]=s[c]&127,c++,c>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let p=new Uint8Array(u);for(let x=0;x<f.length;x++)p[x]=f[x];f=this.valueHexView=new Uint8Array(u)}}this.blockLength=c+1,f[c-1]=s[c]&127;let l=new Uint8Array(c);for(let p=0;p<c;p++)l[p]=f[p];f=this.valueHexView=new Uint8Array(c),f.set(l),this.blockLength<=9?this.tagNumber=zr(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}}};Hs.NAME="identificationBlock";var Ks=class extends Ht{constructor({lenBlock:e={}}={}){var t,n,o;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(o=e.length)!==null&&o!==void 0?o:0}fromBER(e,t,n){let o=Z.BufferSourceConverter.toUint8Array(e);if(!qt(this,o,t,n))return-1;let s=o.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,t+this.blockLength;let i=s[0]&127;if(i>8)return this.error="Too big integer",-1;if(i+1>s.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=o.subarray(a,a+i);return c[i-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=zr(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=i+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=gr(this.length,8);if(o.byteLength>127)return this.error="Too big length",gt;if(t=new ArrayBuffer(o.byteLength+1),e)return t;let s=new Uint8Array(o);n=new Uint8Array(t),n[0]=o.byteLength|128;for(let i=0;i<o.byteLength;i++)n[i+1]=s[i];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}}};Ks.NAME="lengthBlock";var _={},ke=class extends Ht{constructor({name:e=Tn,optional:t=!1,primitiveSchema:n,...o}={},s){super(o),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Hs(o),this.lenBlock=new Ks(o),this.valueBlock=s?new s(o):new Ve(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 Eo;t||Th(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 s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;let i=this.lenBlock.toBER(e);n.write(i),n.write(s)}return t?gt:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():Z.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${Z.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return Ah(t,n)}};ke.NAME="BaseBlock";function Th(r){if(r instanceof _.Constructed)for(let e of r.valueBlock.value)Th(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var zs=class extends ke{constructor({value:e=Tn,...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}'`}};zs.NAME="BaseStringBlock";var qs=class extends Gt(Ve){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};qs.NAME="PrimitiveValueBlock";var kh,Gs=class extends ke{constructor(e={}){super(e,qs),this.idBlock.isConstructed=!1}};kh=Gs;_.Primitive=kh;Gs.NAME="PRIMITIVE";function Mw(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 Si(r,e=0,t=r.length){let n=e,o=new ke({},Ve),s=new Ht;if(!qt(s,r,e,t))return o.error=s.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=ke;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=Mw(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 kn(r){if(!r.byteLength){let e=new ke({},Ve);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Si(Z.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function Fw(r,e){return r?1:e}var St=class extends Ve{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let o=Z.BufferSourceConverter.toUint8Array(e);if(!qt(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 s=t;for(;Fw(this.isIndefiniteForm,n)>0;){let i=Si(o,s,n);if(i.offset===-1)return this.error=i.result.error,this.warnings.concat(i.result.warnings),-1;if(s=i.offset,this.blockLength+=i.result.blockLength,n-=i.result.blockLength,this.value.push(i.result),this.isIndefiniteForm&&i.result.constructor.NAME===Ao)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Ao?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){let n=t||new Eo;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return t?gt: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 Rh,yr=class extends ke{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} :`}};kh=yr;_.Constructed=kh;yr.NAME="CONSTRUCTED";var Gs=class extends Le{fromBER(e,t,n){return t}toBER(e){return gt}};Gs.override="EndOfContentValueBlock";var Rh,js=class extends Te{constructor(e={}){super(e,Gs),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Rh=js;_.EndOfContent=Rh;js.NAME=Eo;var Nh,br=class extends Te{constructor(e={}){super(e,Le),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}`}};Nh=br;_.Null=Nh;br.NAME="NULL";var Ws=class extends Gt(Le){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=Z.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){let o=Z.BufferSourceConverter.toUint8Array(e);return qt(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,bc.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Ws.NAME="BooleanValueBlock";var Uh,Ys=class extends Te{constructor(e={}){super(e,Ws),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}`}};Uh=Ys;_.Boolean=Uh;Ys.NAME="BOOLEAN";var Zs=class extends Gt(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 s=0;s<this.value.length;s++){let i=this.value[s].constructor.NAME;if(i===Eo){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(i!==Sh)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}}};Zs.NAME="OctetStringValueBlock";var _h,Kt=class r extends Te{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,s;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Zs),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 s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(s.byteLength){let i=Bi(s,0,s.byteLength);i.offset!==-1&&i.offset===n&&(this.valueBlock.value=[i.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?yr.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${Z.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let t of this.valueBlock.value)t instanceof r&&e.push(t.valueBlock.valueHexView);return Z.BufferSourceConverter.concat(e)}};_h=Kt;_.OctetString=_h;Kt.NAME=Sh;var Js=class extends Gt(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===Eo){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Ih)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 s=Z.BufferSourceConverter.toUint8Array(e);if(!qt(this,s,t,n))return-1;let i=s.subarray(t,t+n);if(this.unusedBits=i[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=i.subarray(1);try{if(a.byteLength){let c=Bi(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=i.subarray(1),this.blockLength=i.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 gt;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}}};Js.NAME="BitStringValueBlock";var Dh,Cn=class extends Te{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,s;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Js),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 yr.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)}`}}};Dh=Cn;_.BitString=Dh;Cn.NAME=Ih;var Lh;function Mw(r,e){let t=new Uint8Array([0]),n=new Uint8Array(r),o=new Uint8Array(e),s=n.slice(0),i=s.length-1,a=o.slice(0),c=a.length-1,f=0,u=c<i?i:c,l=0;for(let p=u;p>=0;p--,l++){switch(!0){case l<a.length:f=s[i-l]+a[c-l]+t[0];break;default:f=s[i-l]+t[0]}switch(t[0]=f/10,!0){case l>=s.length:s=Ms(new Uint8Array([f%10]),s);break;default:s[i-l]=f%10}}return t[0]>0&&(s=Ms(t,s)),s}function Bh(r){if(r>=xo.length)for(let e=xo.length;e<=r;e++){let t=new Uint8Array([0]),n=xo[e-1].slice(0);for(let o=n.length-1;o>=0;o--){let s=new Uint8Array([(n[o]<<1)+t[0]]);t[0]=s[0]/10,n[o]=s[0]%10}t[0]>0&&(n=Ms(t,n)),xo.push(n)}return xo[r]}function Fw(r,e){let t=0,n=new Uint8Array(r),o=new Uint8Array(e),s=n.slice(0),i=s.length-1,a=o.slice(0),c=a.length-1,f,u=0;for(let l=c;l>=0;l--,u++)switch(f=s[i-u]-a[c-u]-t,!0){case f<0:t=1,s[i-u]=f+10;break;default:t=0,s[i-u]=f}if(t>0)for(let l=i-c+1;l>=0;l--,u++)if(f=s[i-u]-t,f<0)t=1,s[i-u]=f+10;else{t=0,s[i-u]=f;break}return s.slice()}var Ao=class extends Gt(Le){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=bc.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(vh(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,o=0){let s=this.fromBER(e,t,n);if(s===-1)return s;let i=this.valueHexView;return i[0]===0&&i[1]&128?this.valueHexView=i.subarray(1):o!==0&&i.length<o&&(o-i.length>1&&(o=i.length+1),this.valueHexView=i.subarray(o-i.length)),s}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,s=this.valueHexView,i="",a=!1;for(let c=s.byteLength-1;c>=0;c--){o=s[c];for(let f=0;f<8;f++){if((o&1)===1)switch(n){case e:t=Fw(Bh(n),t),i="-";break;default:t=Mw(t,Bh(n))}n++,o>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(i+=Ah.charAt(t[c]));return a===!1&&(i+=Ah.charAt(0)),i}};Lh=Ao;Ao.NAME="IntegerValueBlock";Object.defineProperty(Lh.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Oh,be=class r extends Te{constructor(e={}){super(e,Ao),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Fs(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Fs();let t=BigInt(e),n=new vo,o=t.toString(16).replace(/^-/,""),s=new Uint8Array(Z.Convert.FromHex(o));if(t<0){let a=new Uint8Array(s.length+(s[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${Z.Convert.ToHex(a)}`)+t,u=Z.BufferSourceConverter.toUint8Array(Z.Convert.FromHex(f.toString(16)));u[0]|=128,n.write(u)}else s[0]&128&&n.write(new Uint8Array([0])),n.write(s);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()}`}};Oh=be;_.Integer=Oh;be.NAME="INTEGER";var Vh,Xs=class extends be{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Vh=Xs;_.Enumerated=Vh;Xs.NAME="ENUMERATED";var Bo=class extends Gt(Le){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;let o=Z.BufferSourceConverter.toUint8Array(e);if(!qt(this,o,t,n))return-1;let s=o.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=s[a]&127,this.blockLength++,!!(s[a]&128));a++);let i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)i[a]=this.valueHexView[a];return this.valueHexView=i,s[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=zr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){Fs();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,s=new Uint8Array(this.blockLength);for(let i=0;i<this.blockLength-1;i++)s[i]=o[i]|128;return s[this.blockLength-1]=o[this.blockLength-1],s.buffer}let t=gr(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",gt;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),s=t.byteLength-1;for(let i=0;i<s;i++)n[i]=o[i]|128;n[s]=o[s]}return n}toString(){let e="";if(this.isHexOnly)e=Z.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};Bo.NAME="sidBlock";var Qs=class extends Le{constructor({value:e=Tn,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let s=new Bo;if(o=s.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=s.error,o;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}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,gt;t.push(o)}return wc(t)}fromString(e){this.value=[];let t=0,n=0,o="",s=!1;do if(n=e.indexOf(".",t),n===-1?o=e.substring(t):o=e.substring(t,n),t=n+1,s){let i=this.value[0],a=0;switch(i.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;i.valueDec=c+a,s=!1}else{let i=new Bo;if(o>Number.MAX_SAFE_INTEGER){Fs();let a=BigInt(o);i.valueBigInt=a}else if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return;this.value.length||(i.isFirstSid=!0,s=!0),this.value.push(i)}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}};Qs.NAME="ObjectIdentifierValueBlock";var Ph,mt=class extends Te{constructor(e={}){super(e,Qs),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()}}};Ph=mt;_.ObjectIdentifier=Ph;mt.NAME="OBJECT IDENTIFIER";var So=class extends Gt(Ht){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let o=Z.BufferSourceConverter.toUint8Array(e);if(!qt(this,o,t,n))return-1;let s=o.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=s[a]&127,this.blockLength++,!!(s[a]&128));a++);let i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)i[a]=this.valueHexView[a];return this.valueHexView=i,s[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=zr(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,s=new Uint8Array(this.blockLength);for(let i=0;i<this.blockLength-1;i++)s[i]=o[i]|128;return s[this.blockLength-1]=o[this.blockLength-1],s.buffer}let t=gr(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",gt;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),s=t.byteLength-1;for(let i=0;i<s;i++)n[i]=o[i]|128;n[s]=o[s]}return n.buffer}toString(){let e="";return this.isHexOnly?e=Z.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};So.NAME="relativeSidBlock";var ei=class extends Le{constructor({value:e=Tn,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let s=new So;if(o=s.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=s.error,o;this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return o}toBER(e,t){let n=[];for(let o=0;o<this.value.length;o++){let s=this.value[o].toBER(e);if(s.byteLength===0)return this.error=this.value[o].error,gt;n.push(s)}return wc(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 s=new So;if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return!0;this.value.push(s)}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}};ei.NAME="RelativeObjectIdentifierValueBlock";var Mh,ti=class extends Te{constructor(e={}){super(e,ei),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()}}};Mh=ti;_.RelativeObjectIdentifier=Mh;ti.NAME="RelativeObjectIdentifier";var Fh,ve=class extends yr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Fh=ve;_.Sequence=Fh;ve.NAME="SEQUENCE";var $h,ri=class extends yr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};$h=ri;_.Set=$h;ri.NAME="SET";var ni=class extends Gt(Le){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Tn}toJSON(){return{...super.toJSON(),value:this.value}}};ni.NAME="StringValueBlock";var oi=class extends ni{};oi.NAME="SimpleStringValueBlock";var Me=class extends Ks{constructor({...e}={}){super(e,oi)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,Z.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);this.valueBlock.value=e}};Me.NAME="SIMPLE STRING";var si=class extends Me{fromBuffer(e){this.valueBlock.valueHexView=Z.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=Z.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=Z.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(Z.Convert.FromUtf8String(e)),this.valueBlock.value=e}};si.NAME="Utf8StringValueBlock";var Hh,zt=class extends si{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Hh=zt;_.Utf8String=Hh;zt.NAME="UTF8String";var ii=class extends Me{fromBuffer(e){this.valueBlock.value=Z.Convert.ToUtf16String(e),this.valueBlock.valueHexView=Z.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(Z.Convert.FromUtf16String(e))}};ii.NAME="BmpStringValueBlock";var Kh,ai=class extends ii{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Kh=ai;_.BmpString=Kh;ai.NAME="BMPString";var ci=class extends Me{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 s=gr(e.charCodeAt(o),8),i=new Uint8Array(s);if(i.length>4)continue;let a=4-i.length;for(let c=i.length-1;c>=0;c--)n[o*4+c+a]=i[c]}this.valueBlock.value=e}};ci.NAME="UniversalStringValueBlock";var zh,ui=class extends ci{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};zh=ui;_.UniversalString=zh;ui.NAME="UniversalString";var qh,li=class extends Me{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};qh=li;_.NumericString=qh;li.NAME="NumericString";var Gh,fi=class extends Me{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Gh=fi;_.PrintableString=Gh;fi.NAME="PrintableString";var jh,hi=class extends Me{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};jh=hi;_.TeletexString=jh;hi.NAME="TeletexString";var Wh,di=class extends Me{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Wh=di;_.VideotexString=Wh;di.NAME="VideotexString";var Yh,pi=class extends Me{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Yh=pi;_.IA5String=Yh;pi.NAME="IA5String";var Zh,mi=class extends Me{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Zh=mi;_.GraphicString=Zh;mi.NAME="GraphicString";var Jh,Io=class extends Me{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Jh=Io;_.VisibleString=Jh;Io.NAME="VisibleString";var Xh,gi=class extends Me{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};Xh=gi;_.GeneralString=Xh;gi.NAME="GeneralString";var Qh,yi=class extends Me{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Qh=yi;_.CharacterString=Qh;yi.NAME="CharacterString";var ed,Co=class extends Io{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let o=0;o<e.length;o++)this.valueBlock.valueHexView[o]=e.charCodeAt(o)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,Z.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}let o=parseInt(n[1],10);o>=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){let t=new Array(7);return t[0]=qe(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=qe(this.month,2),t[2]=qe(this.day,2),t[3]=qe(this.hour,2),t[4]=qe(this.minute,2),t[5]=qe(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}}};ed=Co;_.UTCTime=ed;Co.NAME="UTCTime";var td,bi=class extends Co{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="",s=0,i,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,p=n.indexOf("+"),x="";if(p===-1&&(p=n.indexOf("-"),l=-1),p!==-1){if(x=n.substring(p+1),n=n.substring(0,p),x.length!==2&&x.length!==4)throw new Error("Wrong input string for conversion");let d=parseInt(x.substring(0,2),10);if(isNaN(d.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*d,x.length===4){if(d=parseInt(x.substring(2,4),10),isNaN(d.valueOf()))throw new Error("Wrong input string for conversion");c=l*d}}}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");s=l.valueOf(),o=n.substring(0,f)}else o=n;switch(!0){case o.length===8:if(i=/(\d{4})(\d{2})(\d{2})/ig,f!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*s;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(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*s;this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===14:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=1e3*s;this.millisecond=Math.floor(l)}break;default:throw new Error("Wrong input string for conversion")}let u=i.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(qe(this.year,4)),t.push(qe(this.month,2)),t.push(qe(this.day,2)),t.push(qe(this.hour,2)),t.push(qe(this.minute,2)),t.push(qe(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(qe(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};td=bi;_.GeneralizedTime=td;bi.NAME="GeneralizedTime";var rd,wi=class extends zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};rd=wi;_.DATE=rd;wi.NAME="DATE";var nd,xi=class extends zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};nd=xi;_.TimeOfDay=nd;xi.NAME="TimeOfDay";var od,vi=class extends zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};od=vi;_.DateTime=od;vi.NAME="DateTime";var sd,Ei=class extends zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};sd=Ei;_.Duration=sd;Ei.NAME="Duration";var id,Ai=class extends zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};id=Ai;_.TIME=id;Ai.NAME="TIME";function Hw(r){let{result:e}=kn(r),t=e.valueBlock.value;return{n:ue(It(t[1].toBigInt()),"base64url"),e:ue(It(t[2].toBigInt()),"base64url"),d:ue(It(t[3].toBigInt()),"base64url"),p:ue(It(t[4].toBigInt()),"base64url"),q:ue(It(t[5].toBigInt()),"base64url"),dp:ue(It(t[6].toBigInt()),"base64url"),dq:ue(It(t[7].toBigInt()),"base64url"),qi:ue(It(t[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function Kw(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 q("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new ve({value:[new be({value:0}),be.fromBigInt(Ct(ee(r.n,"base64url"))),be.fromBigInt(Ct(ee(r.e,"base64url"))),be.fromBigInt(Ct(ee(r.d,"base64url"))),be.fromBigInt(Ct(ee(r.p,"base64url"))),be.fromBigInt(Ct(ee(r.q,"base64url"))),be.fromBigInt(Ct(ee(r.dp,"base64url"))),be.fromBigInt(Ct(ee(r.dq,"base64url"))),be.fromBigInt(Ct(ee(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function zw(r){let{result:e}=kn(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:ue(It(t[0].toBigInt()),"base64url"),e:ue(It(t[1].toBigInt()),"base64url")}}function qw(r){if(r.n==null||r.e==null)throw new q("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new ve({value:[new ve({value:[new mt({value:"1.2.840.113549.1.1.1"}),new br]}),new Cn({valueHex:new ve({value:[be.fromBigInt(Ct(ee(r.n,"base64url"))),be.fromBigInt(Ct(ee(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function It(r){let e=r.toString(16);e.length%2>0&&(e=`0${e}`);let t=e.length/2,n=new Uint8Array(t),o=0,s=0;for(;o<t;)n[o]=parseInt(e.slice(s,s+2),16),o+=1,s+=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 Gw=16,vc=32,Ec=1e4;async function jw(r,e){let t=Pe.get(),o=new ve({value:[new be({value:0}),new ve({value:[new mt({value:"1.2.840.113549.1.1.1"}),new br]}),new Kt({valueHex:r.marshal()})]}).toBER(),s=new Uint8Array(o,0,o.byteLength),i=Kr(Gw),a=await gc(xn,e,i,{c:Ec,dkLen:vc}),c=Kr(16),f=await t.subtle.importKey("raw",a,"AES-CBC",!1,["encrypt"]),u=await t.subtle.encrypt({name:"AES-CBC",iv:c},f,s),l=new ve({value:[new Kt({valueHex:i}),new be({value:Ec}),new be({value:vc}),new ve({value:[new mt({value:"1.2.840.113549.2.11"}),new br]})]}),p=new ve({value:[new mt({value:"1.2.840.113549.1.5.13"}),new ve({value:[new ve({value:[new mt({value:"1.2.840.113549.1.5.12"}),l]}),new ve({value:[new mt({value:"2.16.840.1.101.3.4.1.42"}),new Kt({valueHex:c})]})]})]}),d=new ve({value:[p,new Kt({valueHex:u})]}).toBER(),h=new Uint8Array(d,0,d.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...ue(h,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
8
- `)}async function Ww(r,e){let t=Pe.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let o=ee(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:s}=kn(o),{iv:i,salt:a,iterations:c,keySize:f,cipherText:u}=Yw(s),l=await gc(xn,e,a,{c,dkLen:f}),p=await t.subtle.importKey("raw",l,"AES-CBC",!1,["decrypt"]),x=To(await t.subtle.decrypt({name:"AES-CBC",iv:i},p,u)),{result:d}=kn(x);n=ad(d)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let o=ee(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:s}=kn(o);n=ad(s)}else throw new q("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return Ac(n)}function Yw(r){let e=r.valueBlock.value[0];if(e.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.13")throw new q("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 q("Only pkcs5PBKDF2 key derivation functions are supported","ERR_INVALID_PARAMS");let s=n.valueBlock.value[1],i=To(s.valueBlock.value[0].getValue()),a=Ec,c=vc;if(s.valueBlock.value.length===3)a=Number(s.valueBlock.value[1].toBigInt()),c=Number(s.valueBlock.value[2].toBigInt());else if(s.valueBlock.value.length===2)throw new q("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 q("Only AES-CBC encryption schemes are supported","ERR_INVALID_PARAMS")}}}}let l=To(f.valueBlock.value[1].getValue());return{cipherText:To(r.valueBlock.value[1].getValue()),salt:i,iterations:a,keySize:c,iv:l}}function ad(r){return To(r.valueBlock.value[2].getValue())}function To(r){return new Uint8Array(r,0,r.byteLength)}async function cd(r){let e=await Pe.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 fd(e);return{privateKey:t[0],publicKey:t[1]}}async function Bc(r){let t=[await Pe.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await Zw(r)],n=await fd({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function ud(r,e){let t=await Pe.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Pe.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function ld(r,e,t){let n=await Pe.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Pe.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function fd(r){if(r.privateKey==null||r.publicKey==null)throw new q("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([Pe.get().subtle.exportKey("jwk",r.privateKey),Pe.get().subtle.exportKey("jwk",r.publicKey)])}async function Zw(r){return Pe.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 Si(r){if(r.kty!=="RSA")throw new q("invalid key type","ERR_INVALID_KEY_TYPE");if(r.n==null)throw new q("invalid key modulus","ERR_INVALID_KEY_MODULUS");return ee(r.n,"base64url").length*8}var Ro=8192,ko=class{_key;constructor(e){this._key=e}verify(e,t){return ld(this._key,t,e)}marshal(){return wr.jwkToPkix(this._key)}get bytes(){return At.encode({Type:ce.RSA,Data:this.marshal()}).subarray()}equals(e){return Ce(this.bytes,e.bytes)}hash(){let e=Ie.digest(this.bytes);return ot(e)?e.then(({bytes:t})=>t):e.bytes}},Rn=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return Kr(16)}sign(e){return ud(this._key,e)}get public(){if(this._publicKey==null)throw new q("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new ko(this._publicKey)}marshal(){return wr.jwkToPkcs1(this._key)}get bytes(){return Bt.encode({Type:ce.RSA,Data:this.marshal()}).subarray()}equals(e){return Ce(this.bytes,e.bytes)}hash(){let e=Ie.digest(this.bytes);return ot(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return ue(e,"base58btc")}async export(e,t="pkcs-8"){if(t==="pkcs-8")return wr.exportToPem(this,e);if(t==="libp2p-key")return An(this.bytes,e);throw new q(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function Ac(r){let e=wr.pkcs1ToJwk(r);if(Si(e)>Ro)throw new q("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await Bc(e);return new Rn(t.privateKey,t.publicKey)}function Xw(r){let e=wr.pkixToJwk(r);if(Si(e)>Ro)throw new q("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new ko(e)}async function Qw(r){if(Si(r)>Ro)throw new q("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await Bc(r);return new Rn(e.privateKey,e.publicKey)}async function ex(r){if(r>Ro)throw new q("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await cd(r);return new Rn(e.privateKey,e.publicKey)}var Rc={};M(Rc,{Secp256k1PrivateKey:()=>Uo,Secp256k1PublicKey:()=>No,generateKeyPair:()=>mx,unmarshalSecp256k1PrivateKey:()=>dx,unmarshalSecp256k1PublicKey:()=>px});var tx=(r,e,t)=>r&e^~r&t,rx=(r,e,t)=>r&e^r&t^e&t,nx=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]),xr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),vr=new Uint32Array(64),Ic=class extends wn{constructor(){super(64,32,8,!1),this.A=xr[0]|0,this.B=xr[1]|0,this.C=xr[2]|0,this.D=xr[3]|0,this.E=xr[4]|0,this.F=xr[5]|0,this.G=xr[6]|0,this.H=xr[7]|0}get(){let{A:e,B:t,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[e,t,n,o,s,i,a,c]}set(e,t,n,o,s,i,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(e,t){for(let l=0;l<16;l++,t+=4)vr[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let p=vr[l-15],x=vr[l-2],d=ft(p,7)^ft(p,18)^p>>>3,h=ft(x,17)^ft(x,19)^x>>>10;vr[l]=h+vr[l-7]+d+vr[l-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let p=ft(a,6)^ft(a,11)^ft(a,25),x=u+p+tx(a,c,f)+nx[l]+vr[l]|0,h=(ft(n,2)^ft(n,13)^ft(n,22))+rx(n,o,s)|0;u=f,f=c,c=a,a=i+x|0,i=s,s=o,o=n,n=x+h|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+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,s,i,a,c,f,u)}roundClean(){vr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var hd=As(()=>new Ic);function ox(r){let e=ho(r);Et(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:sx,hexToBytes:ix}=Is,qr={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){let{Err:e}=qr;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:sx(n),l:r.subarray(t+2)}},toSig(r){let{Err:e}=qr,t=typeof r=="string"?ix(r):r;if(!ht(t))throw new Error("ui8a expected");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:s}=qr._parseInt(t.subarray(2)),{d:i,l:a}=qr._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:o,s:i}},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)),s=n.length/2,i=o.length/2,a=t(s),c=t(i);return`30${t(i+s+4)}02${c}${o}02${a}${n}`}},jt=BigInt(0),it=BigInt(1),YS=BigInt(2),dd=BigInt(3),ZS=BigInt(4);function ax(r){let e=ox(r),{Fp:t}=e,n=e.toBytes||((d,h,m)=>{let g=h.toAffine();return Pt(Uint8Array.from([4]),t.toBytes(g.x),t.toBytes(g.y))}),o=e.fromBytes||(d=>{let h=d.subarray(1),m=t.fromBytes(h.subarray(0,t.BYTES)),g=t.fromBytes(h.subarray(t.BYTES,2*t.BYTES));return{x:m,y:g}});function s(d){let{a:h,b:m}=e,g=t.sqr(d),A=t.mul(g,d);return t.add(t.add(A,t.mul(d,h)),m)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function i(d){return typeof d=="bigint"&&jt<d&&d<e.n}function a(d){if(!i(d))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(d){let{allowedPrivateKeyLengths:h,nByteLength:m,wrapPrivateKey:g,n:A}=e;if(h&&typeof d!="bigint"){if(ht(d)&&(d=Ot(d)),typeof d!="string"||!h.includes(d.length))throw new Error("Invalid key");d=d.padStart(m*2,"0")}let b;try{b=typeof d=="bigint"?d:Vt(de("private key",d,m))}catch{throw new Error(`private key must be ${m} bytes, hex or bigint, not ${typeof d}`)}return g&&(b=oe(b,A)),a(b),b}let f=new Map;function u(d){if(!(d instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(h,m,g){if(this.px=h,this.py=m,this.pz=g,h==null||!t.isValid(h))throw new Error("x required");if(m==null||!t.isValid(m))throw new Error("y required");if(g==null||!t.isValid(g))throw new Error("z required")}static fromAffine(h){let{x:m,y:g}=h||{};if(!h||!t.isValid(m)||!t.isValid(g))throw new Error("invalid affine point");if(h instanceof l)throw new Error("projective point not allowed");let A=b=>t.eql(b,t.ZERO);return A(m)&&A(g)?l.ZERO:new l(m,g,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let m=t.invertBatch(h.map(g=>g.pz));return h.map((g,A)=>g.toAffine(m[A])).map(l.fromAffine)}static fromHex(h){let m=l.fromAffine(o(de("pointHex",h)));return m.assertValidity(),m}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:m}=this.toAffine();if(!t.isValid(h)||!t.isValid(m))throw new Error("bad point: x or y not FE");let g=t.sqr(m),A=s(h);if(!t.eql(g,A))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:m,py:g,pz:A}=this,{px:b,py:S,pz:v}=h,I=t.eql(t.mul(m,v),t.mul(b,A)),C=t.eql(t.mul(g,v),t.mul(S,A));return I&&C}negate(){return new l(this.px,t.neg(this.py),this.pz)}double(){let{a:h,b:m}=e,g=t.mul(m,dd),{px:A,py:b,pz:S}=this,v=t.ZERO,I=t.ZERO,C=t.ZERO,y=t.mul(A,A),k=t.mul(b,b),O=t.mul(S,S),U=t.mul(A,b);return U=t.add(U,U),C=t.mul(A,S),C=t.add(C,C),v=t.mul(h,C),I=t.mul(g,O),I=t.add(v,I),v=t.sub(k,I),I=t.add(k,I),I=t.mul(v,I),v=t.mul(U,v),C=t.mul(g,C),O=t.mul(h,O),U=t.sub(y,O),U=t.mul(h,U),U=t.add(U,C),C=t.add(y,y),y=t.add(C,y),y=t.add(y,O),y=t.mul(y,U),I=t.add(I,y),O=t.mul(b,S),O=t.add(O,O),y=t.mul(O,U),v=t.sub(v,y),C=t.mul(O,k),C=t.add(C,C),C=t.add(C,C),new l(v,I,C)}add(h){u(h);let{px:m,py:g,pz:A}=this,{px:b,py:S,pz:v}=h,I=t.ZERO,C=t.ZERO,y=t.ZERO,k=e.a,O=t.mul(e.b,dd),U=t.mul(m,b),V=t.mul(g,S),H=t.mul(A,v),X=t.add(m,g),B=t.add(b,S);X=t.mul(X,B),B=t.add(U,V),X=t.sub(X,B),B=t.add(m,A);let R=t.add(b,v);return B=t.mul(B,R),R=t.add(U,H),B=t.sub(B,R),R=t.add(g,A),I=t.add(S,v),R=t.mul(R,I),I=t.add(V,H),R=t.sub(R,I),y=t.mul(k,B),I=t.mul(O,H),y=t.add(I,y),I=t.sub(V,y),y=t.add(V,y),C=t.mul(I,y),V=t.add(U,U),V=t.add(V,U),H=t.mul(k,H),B=t.mul(O,B),V=t.add(V,H),H=t.sub(U,H),H=t.mul(k,H),B=t.add(B,H),U=t.mul(V,B),C=t.add(C,U),U=t.mul(R,B),I=t.mul(X,I),I=t.sub(I,U),U=t.mul(X,V),y=t.mul(R,y),y=t.add(y,U),new l(I,C,y)}subtract(h){return this.add(h.negate())}is0(){return this.equals(l.ZERO)}wNAF(h){return x.wNAFCached(this,f,h,m=>{let g=t.invertBatch(m.map(A=>A.pz));return m.map((A,b)=>A.toAffine(g[b])).map(l.fromAffine)})}multiplyUnsafe(h){let m=l.ZERO;if(h===jt)return m;if(a(h),h===it)return this;let{endo:g}=e;if(!g)return x.unsafeLadder(this,h);let{k1neg:A,k1:b,k2neg:S,k2:v}=g.splitScalar(h),I=m,C=m,y=this;for(;b>jt||v>jt;)b&it&&(I=I.add(y)),v&it&&(C=C.add(y)),y=y.double(),b>>=it,v>>=it;return A&&(I=I.negate()),S&&(C=C.negate()),C=new l(t.mul(C.px,g.beta),C.py,C.pz),I.add(C)}multiply(h){a(h);let m=h,g,A,{endo:b}=e;if(b){let{k1neg:S,k1:v,k2neg:I,k2:C}=b.splitScalar(m),{p:y,f:k}=this.wNAF(v),{p:O,f:U}=this.wNAF(C);y=x.constTimeNegate(S,y),O=x.constTimeNegate(I,O),O=new l(t.mul(O.px,b.beta),O.py,O.pz),g=y.add(O),A=k.add(U)}else{let{p:S,f:v}=this.wNAF(m);g=S,A=v}return l.normalizeZ([g,A])[0]}multiplyAndAddUnsafe(h,m,g){let A=l.BASE,b=(v,I)=>I===jt||I===it||!v.equals(A)?v.multiplyUnsafe(I):v.multiply(I),S=b(this,m).add(b(h,g));return S.is0()?void 0:S}toAffine(h){let{px:m,py:g,pz:A}=this,b=this.is0();h==null&&(h=b?t.ONE:t.inv(A));let S=t.mul(m,h),v=t.mul(g,h),I=t.mul(A,h);if(b)return{x:t.ZERO,y:t.ZERO};if(!t.eql(I,t.ONE))throw new Error("invZ was invalid");return{x:S,y:v}}isTorsionFree(){let{h,isTorsionFree:m}=e;if(h===it)return!0;if(m)return m(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:m}=e;return h===it?this:m?m(l,this):this.multiplyUnsafe(e.h)}toRawBytes(h=!0){return this.assertValidity(),n(l,this,h)}toHex(h=!0){return Ot(this.toRawBytes(h))}}l.BASE=new l(e.Gx,e.Gy,t.ONE),l.ZERO=new l(t.ZERO,t.ONE,t.ZERO);let p=e.nBitLength,x=ks(l,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:i}}function cx(r){let e=ho(r);return Et(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function pd(r){let e=cx(r),{Fp:t,n}=e,o=t.BYTES+1,s=2*t.BYTES+1;function i(B){return jt<B&&B<t.ORDER}function a(B){return oe(B,n)}function c(B){return Cs(B,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:p}=ax({...e,toBytes(B,R,$){let T=R.toAffine(),E=t.toBytes(T.x),L=Pt;return $?L(Uint8Array.from([R.hasEvenY()?2:3]),E):L(Uint8Array.from([4]),E,t.toBytes(T.y))},fromBytes(B){let R=B.length,$=B[0],T=B.subarray(1);if(R===o&&($===2||$===3)){let E=Vt(T);if(!i(E))throw new Error("Point is not on curve");let L=l(E),F=t.sqrt(L),z=(F&it)===it;return($&1)===1!==z&&(F=t.neg(F)),{x:E,y:F}}else if(R===s&&$===4){let E=t.fromBytes(T.subarray(0,t.BYTES)),L=t.fromBytes(T.subarray(t.BYTES,2*t.BYTES));return{x:E,y:L}}else throw new Error(`Point of length ${R} was invalid. Expected ${o} compressed bytes or ${s} uncompressed bytes`)}}),x=B=>Ot(fr(B,e.nByteLength));function d(B){let R=n>>it;return B>R}function h(B){return d(B)?a(-B):B}let m=(B,R,$)=>Vt(B.slice(R,$));class g{constructor(R,$,T){this.r=R,this.s=$,this.recovery=T,this.assertValidity()}static fromCompact(R){let $=e.nByteLength;return R=de("compactSignature",R,$*2),new g(m(R,0,$),m(R,$,2*$))}static fromDER(R){let{r:$,s:T}=qr.toSig(de("DER",R));return new g($,T)}assertValidity(){if(!p(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!p(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(R){return new g(this.r,this.s,R)}recoverPublicKey(R){let{r:$,s:T,recovery:E}=this,L=C(de("msgHash",R));if(E==null||![0,1,2,3].includes(E))throw new Error("recovery id invalid");let F=E===2||E===3?$+e.n:$;if(F>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let z=E&1?"03":"02",W=f.fromHex(z+x(F)),Y=c(F),ne=a(-L*Y),J=a(T*Y),Q=f.BASE.multiplyAndAddUnsafe(W,ne,J);if(!Q)throw new Error("point at infinify");return Q.assertValidity(),Q}hasHighS(){return d(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Vr(this.toDERHex())}toDERHex(){return qr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Vr(this.toCompactHex())}toCompactHex(){return x(this.r)+x(this.s)}}let A={isValidPrivateKey(B){try{return u(B),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let B=Ja(e.n);return eh(e.randomBytes(B),e.n)},precompute(B=8,R=f.BASE){return R._setWindowSize(B),R.multiply(BigInt(3)),R}};function b(B,R=!0){return f.fromPrivateKey(B).toRawBytes(R)}function S(B){let R=ht(B),$=typeof B=="string",T=(R||$)&&B.length;return R?T===o||T===s:$?T===2*o||T===2*s:B instanceof f}function v(B,R,$=!0){if(S(B))throw new Error("first arg must be private key");if(!S(R))throw new Error("second arg must be public key");return f.fromHex(R).multiply(u(B)).toRawBytes($)}let I=e.bits2int||function(B){let R=Vt(B),$=B.length*8-e.nBitLength;return $>0?R>>BigInt($):R},C=e.bits2int_modN||function(B){return a(I(B))},y=fo(e.nBitLength);function k(B){if(typeof B!="bigint")throw new Error("bigint expected");if(!(jt<=B&&B<y))throw new Error(`bigint expected < 2^${e.nBitLength}`);return fr(B,e.nByteLength)}function O(B,R,$=U){if(["recovered","canonical"].some(fe=>fe in $))throw new Error("sign() legacy options not supported");let{hash:T,randomBytes:E}=e,{lowS:L,prehash:F,extraEntropy:z}=$;L==null&&(L=!0),B=de("msgHash",B),F&&(B=de("prehashed msgHash",T(B)));let W=C(B),Y=u(R),ne=[k(Y),k(W)];if(z!=null){let fe=z===!0?E(t.BYTES):z;ne.push(de("extraEntropy",fe))}let J=Pt(...ne),Q=W;function ye(fe){let Ae=I(fe);if(!p(Ae))return;let Be=c(Ae),we=f.BASE.multiply(Ae).toAffine(),Ne=a(we.x);if(Ne===jt)return;let _t=a(Be*a(Q+Ne*Y));if(_t===jt)return;let Nr=(we.x===Ne?0:2)|Number(we.y&it),so=_t;return L&&d(_t)&&(so=h(_t),Nr^=1),new g(Ne,so,Nr)}return{seed:J,k2sig:ye}}let U={lowS:e.lowS,prehash:!1},V={lowS:e.lowS,prehash:!1};function H(B,R,$=U){let{seed:T,k2sig:E}=O(B,R,$),L=e;return ja(L.hash.outputLen,L.nByteLength,L.hmac)(T,E)}f.BASE._setWindowSize(8);function X(B,R,$,T=V){let E=B;if(R=de("msgHash",R),$=de("publicKey",$),"strict"in T)throw new Error("options.strict was renamed to lowS");let{lowS:L,prehash:F}=T,z,W;try{if(typeof E=="string"||ht(E))try{z=g.fromDER(E)}catch(we){if(!(we instanceof qr.Err))throw we;z=g.fromCompact(E)}else if(typeof E=="object"&&typeof E.r=="bigint"&&typeof E.s=="bigint"){let{r:we,s:Ne}=E;z=new g(we,Ne)}else throw new Error("PARSE");W=f.fromHex($)}catch(we){if(we.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(L&&z.hasHighS())return!1;F&&(R=e.hash(R));let{r:Y,s:ne}=z,J=C(R),Q=c(ne),ye=a(J*Q),fe=a(Y*Q),Ae=f.BASE.multiplyAndAddUnsafe(W,ye,fe)?.toAffine();return Ae?a(Ae.x)===Y:!1}return{CURVE:e,getPublicKey:b,getSharedSecret:v,sign:H,verify:X,ProjectivePoint:f,Signature:g,utils:A}}function ux(r){return{hash:r,hmac:(e,...t)=>wo(r,e,Es(...t)),randomBytes:bn}}function md(r,e){let t=n=>pd({...r,...ux(n)});return Object.freeze({...t(e),create:t})}var bd=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),gd=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),lx=BigInt(1),Cc=BigInt(2),yd=(r,e)=>(r+e/Cc)/e;function fx(r){let e=bd,t=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),f=r*r*r%e,u=f*f*r%e,l=ae(u,t,e)*u%e,p=ae(l,t,e)*u%e,x=ae(p,Cc,e)*f%e,d=ae(x,o,e)*x%e,h=ae(d,s,e)*d%e,m=ae(h,a,e)*h%e,g=ae(m,c,e)*m%e,A=ae(g,a,e)*h%e,b=ae(A,t,e)*u%e,S=ae(b,i,e)*d%e,v=ae(S,n,e)*f%e,I=ae(v,Cc,e);if(!Tc.eql(Tc.sqr(I),r))throw new Error("Cannot find square root");return I}var Tc=Ts(bd,void 0,void 0,{sqrt:fx}),yt=md({a:BigInt(0),b:BigInt(7),Fp:Tc,n:gd,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=gd,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-lx*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=t,i=BigInt("0x100000000000000000000000000000000"),a=yd(s*r,e),c=yd(-n*r,e),f=oe(r-a*t-c*o,e),u=oe(-a*n-c*s,e),l=f>i,p=u>i;if(l&&(f=e-f),p&&(u=e-u),f>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:p,k2:u}}}},hd),s3=BigInt(0);var i3=yt.ProjectivePoint;function wd(){return yt.utils.randomPrivateKey()}function xd(r,e){let t=Ie.digest(e instanceof Uint8Array?e:e.subarray());if(ot(t))return t.then(({digest:n})=>yt.sign(n,r).toDERRawBytes()).catch(n=>{throw new q(String(n),"ERR_INVALID_INPUT")});try{return yt.sign(t.digest,r).toDERRawBytes()}catch(n){throw new q(String(n),"ERR_INVALID_INPUT")}}function vd(r,e,t){let n=Ie.digest(t instanceof Uint8Array?t:t.subarray());if(ot(n))return n.then(({digest:o})=>yt.verify(e,o,r)).catch(o=>{throw new q(String(o),"ERR_INVALID_INPUT")});try{return yt.verify(e,n.digest,r)}catch(o){throw new q(String(o),"ERR_INVALID_INPUT")}}function Ed(r){return yt.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Ad(r){try{yt.getPublicKey(r,!0)}catch(e){throw new q(String(e),"ERR_INVALID_PRIVATE_KEY")}}function kc(r){try{yt.ProjectivePoint.fromHex(r)}catch(e){throw new q(String(e),"ERR_INVALID_PUBLIC_KEY")}}function Bd(r){try{return yt.getPublicKey(r,!0)}catch(e){throw new q(String(e),"ERR_INVALID_PRIVATE_KEY")}}var No=class{_key;constructor(e){kc(e),this._key=e}verify(e,t){return vd(this._key,t,e)}marshal(){return Ed(this._key)}get bytes(){return At.encode({Type:ce.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Ce(this.bytes,e.bytes)}async hash(){let e=Ie.digest(this.bytes),t;return ot(e)?{bytes:t}=await e:t=e.bytes,t}},Uo=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??Bd(e),Ad(this._key),kc(this._publicKey)}sign(e){return xd(this._key,e)}get public(){return new No(this._publicKey)}marshal(){return this._key}get bytes(){return Bt.encode({Type:ce.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Ce(this.bytes,e.bytes)}hash(){let e=Ie.digest(this.bytes);return ot(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return ue(e,"base58btc")}async export(e,t="libp2p-key"){if(t==="libp2p-key")return An(this.bytes,e);throw new q(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function dx(r){return new Uo(r)}function px(r){return new No(r)}async function mx(){let r=wd();return new Uo(r)}var Gr={rsa:Sc,ed25519:mc,secp256k1:Rc};function Sd(r){let e=Object.keys(Gr).join(" / ");return new q(`invalid or unsupported key type ${r}. Must be ${e}`,"ERR_UNSUPPORTED_KEY_TYPE")}function Nc(r){let e=At.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case ce.RSA:return Gr.rsa.unmarshalRsaPublicKey(t);case ce.Ed25519:return Gr.ed25519.unmarshalEd25519PublicKey(t);case ce.Secp256k1:return Gr.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw Sd(e.Type??"unknown")}}async function Id(r){let e=Bt.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case ce.RSA:return Gr.rsa.unmarshalRsaPrivateKey(t);case ce.Ed25519:return Gr.ed25519.unmarshalEd25519PrivateKey(t);case ce.Secp256k1:return Gr.secp256k1.unmarshalSecp256k1PrivateKey(t);default:throw Sd(e.Type??"RSA")}}var Yc=_e(_o(),1);var Wt="/",kd=new TextEncoder().encode(Wt),Ii=kd[0],Nn=class r{_buf;constructor(e,t){if(typeof e=="string")this._buf=ee(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]!==Ii)throw new Error("Invalid key")}toString(e="utf8"){return ue(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new r(e.join(Wt))}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=kd),this._buf[0]!==Ii){let e=new Uint8Array(this._buf.byteLength+1);e.fill(Ii,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Ii;)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 s=t[o],i=n[o];if(s<i)return!0;if(s>i)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(Wt).slice(1)}type(){return yx(this.baseNamespace())}name(){return bx(this.baseNamespace())}instance(e){return new r(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(Wt)||(e+=Wt),e+=this.type(),new r(e)}parent(){let e=this.list();return e.length===1?new r(Wt):new r(e.slice(0,-1).join(Wt))}child(e){return this.toString()===Wt?e:e.toString()===Wt?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(),...wx(e.map(t=>t.namespaces()))])}};function yx(r){let e=r.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function bx(r){let e=r.split(":");return e[e.length-1]}function wx(r){return[].concat(...r)}var Zp=_e(_c(),1);var Rd="ERR_IPNS_EXPIRED_RECORD",Do="ERR_UNRECOGNIZED_VALIDITY",Nd="ERR_SIGNATURE_CREATION",Yt="ERR_SIGNATURE_VERIFICATION",Ud="ERR_UNRECOGNIZED_FORMAT";var Dc="ERR_UNDEFINED_PARAMETER",_d="ERR_INVALID_RECORD_DATA",Dd="ERR_INVALID_VALUE",Ld="ERR_INVALID_EMBEDDED_KEY",Od="ERR_MISSING_PRIVATE_KEY",Vd="ERR_RECORD_TOO_LARGE";var Ge;(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=()=>yo(t)}(e=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=mr((o,s,i={})=>{i.lengthDelimited!==!1&&s.fork(),o.value!=null&&(s.uint32(10),s.bytes(o.value)),o.signatureV1!=null&&(s.uint32(18),s.bytes(o.signatureV1)),o.validityType!=null&&(s.uint32(24),r.ValidityType.codec().encode(o.validityType,s)),o.validity!=null&&(s.uint32(34),s.bytes(o.validity)),o.sequence!=null&&(s.uint32(40),s.uint64(o.sequence)),o.ttl!=null&&(s.uint32(48),s.uint64(o.ttl)),o.pubKey!=null&&(s.uint32(58),s.bytes(o.pubKey)),o.signatureV2!=null&&(s.uint32(66),s.bytes(o.signatureV2)),o.data!=null&&(s.uint32(74),s.bytes(o.data)),i.lengthDelimited!==!1&&s.ldelim()},(o,s)=>{let i={},a=s==null?o.len:o.pos+s;for(;o.pos<a;){let c=o.uint32();switch(c>>>3){case 1:i.value=o.bytes();break;case 2:i.signatureV1=o.bytes();break;case 3:i.validityType=r.ValidityType.codec().decode(o);break;case 4:i.validity=o.bytes();break;case 5:i.sequence=o.uint64();break;case 6:i.ttl=o.uint64();break;case 7:i.pubKey=o.bytes();break;case 8:i.signatureV2=o.bytes();break;case 9:i.data=o.bytes();break;default:o.skipType(c&7);break}}return i})),n),r.encode=o=>pr(o,r.codec()),r.decode=o=>dr(o,r.codec())})(Ge||(Ge={}));var xx=["string","number","bigint","symbol"],vx=["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 Pd(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(xx.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(Ex(r))return"Buffer";let t=Ax(r);return t||"Object"}function Ex(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Ax(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(vx.includes(e))return e}var w=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};w.uint=new w(0,"uint",!0);w.negint=new w(1,"negint",!0);w.bytes=new w(2,"bytes",!0);w.string=new w(3,"string",!0);w.array=new w(4,"array",!1);w.map=new w(5,"map",!1);w.tag=new w(6,"tag",!1);w.float=new w(7,"float",!0);w.false=new w(7,"false",!0);w.true=new w(7,"true",!0);w.null=new w(7,"null",!0);w.undefined=new w(7,"undefined",!0);w.break=new w(7,"break",!0);var D=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 Un=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Bx=new TextDecoder,Sx=new TextEncoder;function Ci(r){return Un&&globalThis.Buffer.isBuffer(r)}function Oc(r){return r instanceof Uint8Array?Ci(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Hd=Un?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):Fd(r,e,t):(r,e,t)=>t-e>64?Bx.decode(r.subarray(e,t)):Fd(r,e,t),Kd=Un?r=>r.length>64?globalThis.Buffer.from(r):Md(r):r=>r.length>64?Sx.encode(r):Md(r),Tt=r=>Uint8Array.from(r),_n=Un?(r,e,t)=>Ci(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),zd=Un?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),Oc(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},qd=Un?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Gd(r,e){if(Ci(r)&&Ci(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 Md(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 Fd(r,e,t){let n=[];for(;e<t;){let o=r[e],s=null,i=o>239?4:o>223?3:o>191?2:1;if(e+i<=t){let a,c,f,u;switch(i){case 1:o<128&&(s=o);break;case 2:a=r[e+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(s=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)&&(s=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&&(s=u))}}s===null?(s=65533,i=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),e+=i}return Ix(n)}var $d=4096;function Ix(r){let e=r.length;if(e<=$d)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=$d));return t}var Cx=256,Lo=class{constructor(e=Cx){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=qd(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=_n(n,0,this.cursor)}else t=zd(this.chunks,this.cursor);return e&&this.reset(),t}};var K="CBOR decode error:",Vc="CBOR encode error:",Oo=[];Oo[23]=1;Oo[24]=2;Oo[25]=3;Oo[26]=5;Oo[27]=9;function Zt(r,e,t){if(r.length-e<t)throw new Error(`${K} not enough data for type`)}var Ee=[24,256,65536,4294967296,BigInt("18446744073709551616")];function et(r,e,t){Zt(r,e,1);let n=r[e];if(t.strict===!0&&n<Ee[0])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function tt(r,e,t){Zt(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<Ee[1])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function rt(r,e,t){Zt(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<Ee[2])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function nt(r,e,t){Zt(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],s=(BigInt(n)<<BigInt(32))+BigInt(o);if(t.strict===!0&&s<Ee[3])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);if(s<=Number.MAX_SAFE_INTEGER)return Number(s);if(t.allowBigInt===!0)return s;throw new Error(`${K} integers outside of the safe integer range are not supported`)}function jd(r,e,t,n){return new D(w.uint,et(r,e+1,n),2)}function Wd(r,e,t,n){return new D(w.uint,tt(r,e+1,n),3)}function Yd(r,e,t,n){return new D(w.uint,rt(r,e+1,n),5)}function Zd(r,e,t,n){return new D(w.uint,nt(r,e+1,n),9)}function at(r,e){return ke(r,0,e.value)}function ke(r,e,t){if(t<Ee[0]){let n=Number(t);r.push([e|n])}else if(t<Ee[1]){let n=Number(t);r.push([e|24,n])}else if(t<Ee[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<Ee[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<Ee[4]){let o=[e|27,0,0,0,0,0,0,0],s=Number(n&BigInt(4294967295)),i=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=s&255,s=s>>8,o[7]=s&255,s=s>>8,o[6]=s&255,s=s>>8,o[5]=s&255,o[4]=i&255,i=i>>8,o[3]=i&255,i=i>>8,o[2]=i&255,i=i>>8,o[1]=i&255,r.push(o)}else throw new Error(`${K} encountered BigInt larger than allowable range`)}}at.encodedSize=function(e){return ke.encodedSize(e.value)};ke.encodedSize=function(e){return e<Ee[0]?1:e<Ee[1]?2:e<Ee[2]?3:e<Ee[3]?5:9};at.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function Jd(r,e,t,n){return new D(w.negint,-1-et(r,e+1,n),2)}function Xd(r,e,t,n){return new D(w.negint,-1-tt(r,e+1,n),3)}function Qd(r,e,t,n){return new D(w.negint,-1-rt(r,e+1,n),5)}var Pc=BigInt(-1),ep=BigInt(1);function tp(r,e,t,n){let o=nt(r,e+1,n);if(typeof o!="bigint"){let s=-1-o;if(s>=Number.MIN_SAFE_INTEGER)return new D(w.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${K} integers outside of the safe integer range are not supported`);return new D(w.negint,Pc-BigInt(o),9)}function Ti(r,e){let t=e.value,n=typeof t=="bigint"?t*Pc-ep:t*-1-1;ke(r,e.type.majorEncoded,n)}Ti.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*Pc-ep:t*-1-1;return n<Ee[0]?1:n<Ee[1]?2:n<Ee[2]?3:n<Ee[3]?5:9};Ti.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function Vo(r,e,t,n){Zt(r,e,t+n);let o=_n(r,e+t,e+t+n);return new D(w.bytes,o,t+n)}function rp(r,e,t,n){return Vo(r,e,1,t)}function np(r,e,t,n){return Vo(r,e,2,et(r,e+1,n))}function op(r,e,t,n){return Vo(r,e,3,tt(r,e+1,n))}function sp(r,e,t,n){return Vo(r,e,5,rt(r,e+1,n))}function ip(r,e,t,n){let o=nt(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer bytes lengths not supported`);return Vo(r,e,9,o)}function ki(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===w.string?Kd(r.value):r.value),r.encodedBytes}function Dn(r,e){let t=ki(e);ke(r,e.type.majorEncoded,t.length),r.push(t)}Dn.encodedSize=function(e){let t=ki(e);return ke.encodedSize(t.length)+t.length};Dn.compareTokens=function(e,t){return kx(ki(e),ki(t))};function kx(r,e){return r.length<e.length?-1:r.length>e.length?1:Gd(r,e)}function Po(r,e,t,n,o){let s=t+n;Zt(r,e,s);let i=new D(w.string,Hd(r,e+t,e+s),s);return o.retainStringBytes===!0&&(i.byteValue=_n(r,e+t,e+s)),i}function ap(r,e,t,n){return Po(r,e,1,t,n)}function cp(r,e,t,n){return Po(r,e,2,et(r,e+1,n),n)}function up(r,e,t,n){return Po(r,e,3,tt(r,e+1,n),n)}function lp(r,e,t,n){return Po(r,e,5,rt(r,e+1,n),n)}function fp(r,e,t,n){let o=nt(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer string lengths not supported`);return Po(r,e,9,o,n)}var hp=Dn;function Ln(r,e,t,n){return new D(w.array,n,t)}function dp(r,e,t,n){return Ln(r,e,1,t)}function pp(r,e,t,n){return Ln(r,e,2,et(r,e+1,n))}function mp(r,e,t,n){return Ln(r,e,3,tt(r,e+1,n))}function gp(r,e,t,n){return Ln(r,e,5,rt(r,e+1,n))}function yp(r,e,t,n){let o=nt(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer array lengths not supported`);return Ln(r,e,9,o)}function bp(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return Ln(r,e,1,1/0)}function Ri(r,e){ke(r,w.array.majorEncoded,e.value)}Ri.compareTokens=at.compareTokens;Ri.encodedSize=function(e){return ke.encodedSize(e.value)};function On(r,e,t,n){return new D(w.map,n,t)}function wp(r,e,t,n){return On(r,e,1,t)}function xp(r,e,t,n){return On(r,e,2,et(r,e+1,n))}function vp(r,e,t,n){return On(r,e,3,tt(r,e+1,n))}function Ep(r,e,t,n){return On(r,e,5,rt(r,e+1,n))}function Ap(r,e,t,n){let o=nt(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer map lengths not supported`);return On(r,e,9,o)}function Bp(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return On(r,e,1,1/0)}function Ni(r,e){ke(r,w.map.majorEncoded,e.value)}Ni.compareTokens=at.compareTokens;Ni.encodedSize=function(e){return ke.encodedSize(e.value)};function Sp(r,e,t,n){return new D(w.tag,t,1)}function Ip(r,e,t,n){return new D(w.tag,et(r,e+1,n),2)}function Cp(r,e,t,n){return new D(w.tag,tt(r,e+1,n),3)}function Tp(r,e,t,n){return new D(w.tag,rt(r,e+1,n),5)}function kp(r,e,t,n){return new D(w.tag,nt(r,e+1,n),9)}function Ui(r,e){ke(r,w.tag.majorEncoded,e.value)}Ui.compareTokens=at.compareTokens;Ui.encodedSize=function(e){return ke.encodedSize(e.value)};var Lx=20,Ox=21,Vx=22,Px=23;function Rp(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${K} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new D(w.null,null,1):new D(w.undefined,void 0,1)}function Np(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return new D(w.break,void 0,1)}function Mc(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 D(w.float,r,e)}function Up(r,e,t,n){return Mc(Fc(r,e+1),3,n)}function _p(r,e,t,n){return Mc($c(r,e+1),5,n)}function Dp(r,e,t,n){return Mc(Pp(r,e+1),9,n)}function _i(r,e,t){let n=e.value;if(n===!1)r.push([w.float.majorEncoded|Lx]);else if(n===!0)r.push([w.float.majorEncoded|Ox]);else if(n===null)r.push([w.float.majorEncoded|Vx]);else if(n===void 0)r.push([w.float.majorEncoded|Px]);else{let o,s=!1;(!t||t.float64!==!0)&&(Op(n),o=Fc(bt,1),n===o||Number.isNaN(n)?(bt[0]=249,r.push(bt.slice(0,3)),s=!0):(Vp(n),o=$c(bt,1),n===o&&(bt[0]=250,r.push(bt.slice(0,5)),s=!0))),s||(Mx(n),o=Pp(bt,1),bt[0]=251,r.push(bt.slice(0,9)))}}_i.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){Op(n);let o=Fc(bt,1);if(n===o||Number.isNaN(n))return 3;if(Vp(n),o=$c(bt,1),n===o)return 5}return 9};var Lp=new ArrayBuffer(9),ct=new DataView(Lp,1),bt=new Uint8Array(Lp,0);function Op(r){if(r===1/0)ct.setUint16(0,31744,!1);else if(r===-1/0)ct.setUint16(0,64512,!1);else if(Number.isNaN(r))ct.setUint16(0,32256,!1);else{ct.setFloat32(0,r);let e=ct.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)ct.setUint16(0,31744,!1);else if(t===0)ct.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?ct.setUint16(0,0):o<-14?ct.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):ct.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Fc(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,s;return n===0?s=o*2**-24:n!==31?s=(o+1024)*2**(n-25):s=o===0?1/0:NaN,t&32768?-s:s}function Vp(r){ct.setFloat32(0,r,!1)}function $c(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 Mx(r){ct.setFloat64(0,r,!1)}function Pp(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)}_i.compareTokens=at.compareTokens;function te(r,e,t){throw new Error(`${K} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function Di(r){return()=>{throw new Error(`${K} ${r}`)}}var N=[];for(let r=0;r<=23;r++)N[r]=te;N[24]=jd;N[25]=Wd;N[26]=Yd;N[27]=Zd;N[28]=te;N[29]=te;N[30]=te;N[31]=te;for(let r=32;r<=55;r++)N[r]=te;N[56]=Jd;N[57]=Xd;N[58]=Qd;N[59]=tp;N[60]=te;N[61]=te;N[62]=te;N[63]=te;for(let r=64;r<=87;r++)N[r]=rp;N[88]=np;N[89]=op;N[90]=sp;N[91]=ip;N[92]=te;N[93]=te;N[94]=te;N[95]=Di("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)N[r]=ap;N[120]=cp;N[121]=up;N[122]=lp;N[123]=fp;N[124]=te;N[125]=te;N[126]=te;N[127]=Di("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)N[r]=dp;N[152]=pp;N[153]=mp;N[154]=gp;N[155]=yp;N[156]=te;N[157]=te;N[158]=te;N[159]=bp;for(let r=160;r<=183;r++)N[r]=wp;N[184]=xp;N[185]=vp;N[186]=Ep;N[187]=Ap;N[188]=te;N[189]=te;N[190]=te;N[191]=Bp;for(let r=192;r<=215;r++)N[r]=Sp;N[216]=Ip;N[217]=Cp;N[218]=Tp;N[219]=kp;N[220]=te;N[221]=te;N[222]=te;N[223]=te;for(let r=224;r<=243;r++)N[r]=Di("simple values are not supported");N[244]=te;N[245]=te;N[246]=te;N[247]=Rp;N[248]=Di("simple values are not supported");N[249]=Up;N[250]=_p;N[251]=Dp;N[252]=te;N[253]=te;N[254]=te;N[255]=Np;var wt=[];for(let r=0;r<24;r++)wt[r]=new D(w.uint,r,1);for(let r=-1;r>=-24;r--)wt[31-r]=new D(w.negint,r,1);wt[64]=new D(w.bytes,new Uint8Array(0),1);wt[96]=new D(w.string,"",1);wt[128]=new D(w.array,0,1);wt[160]=new D(w.map,0,1);wt[244]=new D(w.false,!1,1);wt[245]=new D(w.true,!0,1);wt[246]=new D(w.null,null,1);function Mp(r){switch(r.type){case w.false:return Tt([244]);case w.true:return Tt([245]);case w.null:return Tt([246]);case w.bytes:return r.value.length?void 0:Tt([64]);case w.string:return r.value===""?Tt([96]):void 0;case w.array:return r.value===0?Tt([128]):void 0;case w.map:return r.value===0?Tt([160]):void 0;case w.uint:return r.value<24?Tt([Number(r.value)]):void 0;case w.negint:if(r.value>=-24)return Tt([31-Number(r.value)])}}var $x={float64:!1,mapSorter:zx,quickEncodeToken:Mp};function Hx(){let r=[];return r[w.uint.major]=at,r[w.negint.major]=Ti,r[w.bytes.major]=Dn,r[w.string.major]=hp,r[w.array.major]=Ri,r[w.map.major]=Ni,r[w.tag.major]=Ui,r[w.float.major]=_i,r}var Fp=Hx(),Hc=new Lo,Oi=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(`${Vc} object contains circular references`);return new r(t,e)}},Er={null:new D(w.null,null),undefined:new D(w.undefined,void 0),true:new D(w.true,!0),false:new D(w.false,!1),emptyArray:new D(w.array,0),emptyMap:new D(w.map,0)},Ar={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new D(w.float,r):r>=0?new D(w.uint,r):new D(w.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new D(w.uint,r):new D(w.negint,r)},Uint8Array(r,e,t,n){return new D(w.bytes,r)},string(r,e,t,n){return new D(w.string,r)},boolean(r,e,t,n){return r?Er.true:Er.false},null(r,e,t,n){return Er.null},undefined(r,e,t,n){return Er.undefined},ArrayBuffer(r,e,t,n){return new D(w.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new D(w.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[Er.emptyArray,new D(w.break)]:Er.emptyArray;n=Oi.createCheck(n,r);let o=[],s=0;for(let i of r)o[s++]=Li(i,t,n);return t.addBreakTokens?[new D(w.array,r.length),o,new D(w.break)]:[new D(w.array,r.length),o]},Object(r,e,t,n){let o=e!=="Object",s=o?r.keys():Object.keys(r),i=o?r.size:s.length;if(!i)return t.addBreakTokens===!0?[Er.emptyMap,new D(w.break)]:Er.emptyMap;n=Oi.createCheck(n,r);let a=[],c=0;for(let f of s)a[c++]=[Li(f,t,n),Li(o?r.get(f):r[f],t,n)];return Kx(a,t),t.addBreakTokens?[new D(w.map,i),a,new D(w.break)]:[new D(w.map,i),a]}};Ar.Map=Ar.Object;Ar.Buffer=Ar.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Ar[`${r}Array`]=Ar.DataView;function Li(r,e={},t){let n=Pd(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||Ar[n];if(typeof o=="function"){let i=o(r,n,e,t);if(i!=null)return i}let s=Ar[n];if(!s)throw new Error(`${Vc} unsupported type: ${n}`);return s(r,n,e,t)}function Kx(r,e){e.mapSorter&&r.sort(e.mapSorter)}function zx(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,s=Fp[o].compareTokens(t,n);return s===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),s}function $p(r,e,t,n){if(Array.isArray(e))for(let o of e)$p(r,o,t,n);else t[e.type.major](r,e,n)}function qx(r,e,t){let n=Li(r,t);if(!Array.isArray(n)&&t.quickEncodeToken){let o=t.quickEncodeToken(n);if(o)return o;let s=e[n.type.major];if(s.encodedSize){let i=s.encodedSize(n,t),a=new Lo(i);if(s(a,n,t),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Oc(a.chunks[0])}}return Hc.reset(),$p(Hc,n,e,t),Hc.toBytes(!0)}function Kc(r,e){return e=Object.assign({},$x,e),qx(r,Fp,e)}var Gx={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},zc=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=wt[e];if(t===void 0){let n=N[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}},Mo=Symbol.for("DONE"),Vi=Symbol.for("BREAK");function jx(r,e,t){let n=[];for(let o=0;o<r.value;o++){let s=Fo(e,t);if(s===Vi){if(r.value===1/0)break;throw new Error(`${K} got unexpected break to lengthed array`)}if(s===Mo)throw new Error(`${K} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=s}return n}function Wx(r,e,t){let n=t.useMaps===!0,o=n?void 0:{},s=n?new Map:void 0;for(let i=0;i<r.value;i++){let a=Fo(e,t);if(a===Vi){if(r.value===1/0)break;throw new Error(`${K} got unexpected break to lengthed map`)}if(a===Mo)throw new Error(`${K} found map but not enough entries (got ${i} [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&&s.has(a)||!n&&a in o))throw new Error(`${K} found repeat map key "${a}"`);let c=Fo(e,t);if(c===Mo)throw new Error(`${K} found map but not enough entries (got ${i} [no value], expected ${r.value})`);n?s.set(a,c):o[a]=c}return n?s:o}function Fo(r,e){if(r.done())return Mo;let t=r.next();if(t.type===w.break)return Vi;if(t.type.terminal)return t.value;if(t.type===w.array)return jx(t,r,e);if(t.type===w.map)return Wx(t,r,e);if(t.type===w.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=Fo(r,e);return e.tags[t.value](n)}throw new Error(`${K} tag not supported (${t.value})`)}throw new Error("unsupported")}function Hp(r,e){if(!(r instanceof Uint8Array))throw new Error(`${K} data to decode must be a Uint8Array`);e=Object.assign({},Gx,e);let t=e.tokenizer||new zc(r,e),n=Fo(t,e);if(n===Mo)throw new Error(`${K} did not find any content to decode`);if(n===Vi)throw new Error(`${K} got unexpected break`);return[n,r.subarray(t.pos())]}function qc(r,e){let[t,n]=Hp(r,e);if(n.length>0)throw new Error(`${K} too many terminals, data makes no sense`);return t}var Fe=_e(_o(),1);var Kp=_e(_c(),1);var Gc=ir("ipns:utils"),zp=ee("/ipns/"),Zx=114;function Jx(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,s=parseInt(t[3],10),i=parseInt(t[4],10),a=parseInt(t[5],10),c=parseInt(t[6],10),f=parseInt(t[7].padEnd(6,"0").slice(0,3),10);return new Date(Date.UTC(n,o,s,i,a,c,f))}var qp=async(r,e)=>{if(e==null||r==null){let n=new Error("one or more of the provided parameters are not defined");throw Gc.error(n),(0,Fe.default)(n,Dc)}let t;if(e.pubKey!=null){try{t=Nc(e.pubKey)}catch(o){throw Gc.error(o),o}if(!(await Vf(e.pubKey)).equals(r))throw(0,Fe.default)(new Error("Embedded public key did not match PeerID"),Ld)}else r.publicKey!=null&&(t=Nc(r.publicKey));if(t!=null)return t;throw(0,Fe.default)(new Error("no public key is available"),Dc)},Gp=(r,e,t)=>{let n=ee(e);return Or([r,t,n])},Pi=r=>{let e=ee("ipns-signature:");return Or([e,r])},jc=r=>"signatureV1"in r?Ge.encode({value:ee(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:ee(r.validity.toString()),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):Ge.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data});function Jt(r){let e=Ge.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,Fe.default)(new Error("missing data or signatureV2"),Yt);let t=Yp(e.data),n=Wc(t.Value),o;try{o=Kp.default.fromDate(Jx(ue(t.Validity)))}catch{throw Gc.error("unrecognized validity format (not an rfc3339 format)"),(0,Fe.default)(new Error("unrecognized validity format (not an rfc3339 format)"),Ud)}if(e.value!=null&&e.signatureV1!=null)return Xx(e),{value:n,validityType:Ge.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:Ge.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 Mi=r=>Or([zp,r.toBytes()]),jp=r=>Ma(r.slice(zp.length)),Wp=(r,e,t,n,o)=>{let s;if(t===Ge.ValidityType.EOL)s=0;else throw(0,Fe.default)(new Error("Unknown validity type"),Do);return Kc({Value:r,Validity:e,ValidityType:s,Sequence:n,TTL:o})},Yp=r=>{let e=qc(r);if(e.ValidityType===0)e.ValidityType=Ge.ValidityType.EOL;else throw(0,Fe.default)(new Error("Unknown validity type"),Do);return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e},Wc=r=>{if(r!=null){if(hf(r))return`/ipns/${r.toCID().toString(ys)}`;if(r instanceof Uint8Array){let n=ue(r);n.startsWith("/")&&(r=n)}let e=r.toString().trim();if(e.startsWith("/")&&e.length>1)return e;let t=Xe.asCID(r);if(t!=null)return t.code===Zx?`/ipns/${t.toString(ys)}`:`/ipfs/${t.toV1().toString()}`;try{return r instanceof Uint8Array?`/ipfs/${Xe.decode(r).toV1().toString()}`:`/ipfs/${Xe.parse(e).toV1().toString()}`}catch{}}throw(0,Fe.default)(new Error("Value must be a valid content path starting with /"),Dd)},Xx=r=>{if(r.data==null)throw(0,Fe.default)(new Error("Record data is missing"),_d);let e=Yp(r.data);if(!Ce(e.Value,r.value??new Uint8Array(0)))throw(0,Fe.default)(new Error('Field "value" did not match between protobuf and CBOR'),Yt);if(!Ce(e.Validity,r.validity??new Uint8Array(0)))throw(0,Fe.default)(new Error('Field "validity" did not match between protobuf and CBOR'),Yt);if(e.ValidityType!==r.validityType)throw(0,Fe.default)(new Error('Field "validityType" did not match between protobuf and CBOR'),Yt);if(e.Sequence!==r.sequence)throw(0,Fe.default)(new Error('Field "sequence" did not match between protobuf and CBOR'),Yt);if(e.TTL!==r.ttl)throw(0,Fe.default)(new Error('Field "ttl" did not match between protobuf and CBOR'),Yt)};var Qx=ir("ipns"),e1=vt.code,t1="/ipns/",G4=t1.length,Jp={v1Compatible:!0};async function Xp(r,e,t,n,o=Jp){let s=new Zp.default(Date.now()+Number(n)),i=Ge.ValidityType.EOL,[a,c]=n.toString().split("."),f=BigInt(a)*BigInt(1e5)+BigInt(c??"0");return r1(r,e,t,i,s,f,o)}var r1=async(r,e,t,n,o,s,i=Jp)=>{t=BigInt(t);let a=ee(o.toString()),c=Wc(e),f=ee(c);if(r.privateKey==null)throw(0,Yc.default)(new Error("Missing private key"),Od);let u=await Id(r.privateKey),l=Wp(f,a,n,t,s),p=Pi(l),x=await u.sign(p),d;if(r.publicKey!=null){let h=_r(r.toBytes());(h.code!==e1||!Ce(r.publicKey,h.digest))&&(d=r.publicKey)}if(i.v1Compatible===!0){let h=await n1(u,f,n,a),m={value:c,signatureV1:h,validity:o,validityType:n,sequence:t,ttl:s,signatureV2:x,data:l};return d!=null&&(m.pubKey=d),m}else{let h={value:c,validity:o,validityType:n,sequence:t,ttl:s,signatureV2:x,data:l};return d!=null&&(h.pubKey=d),h}};var n1=async(r,e,t,n)=>{try{let o=Gp(e,t,n);return await r.sign(o)}catch(o){throw Qx.error("record signature creation failed",o),(0,Yc.default)(new Error("record signature creation failed"),Nd)}};function Fi(r,e){let t=e.map((n,o)=>({record:Jt(n),index:o}));return t.sort((n,o)=>{let s=n.record.sequence,i=o.record.sequence;if(s>i)return-1;if(s<i)return 1;let a=n.record.validity.toDate(),c=o.record.validity.toDate();return a.getTime()>c.getTime()?-1:a.getTime()<c.getTime()?1:0}),t[0].index}var $o=_e(_o(),1);var $i=ir("ipns:validator"),o1=1024*10,s1=async(r,e)=>{let t=Jt(e),n;try{let o=Pi(t.data);n=await r.verify(o,t.signatureV2)}catch{n=!1}if(!n)throw $i.error("record signature verification failed"),(0,$o.default)(new Error("record signature verification failed"),Yt);if(t.validityType===Ge.ValidityType.EOL){if(t.validity.toDate().getTime()<Date.now())throw $i.error("record has expired"),(0,$o.default)(new Error("record has expired"),Rd)}else if(t.validityType!=null)throw $i.error("unrecognized validity type"),(0,$o.default)(new Error("unrecognized validity type"),Do);$i("ipns record for %b is valid",t.value)};async function Zc(r,e){if(e.byteLength>o1)throw(0,$o.default)(new Error("record too large"),Vd);let t=jp(r),n=Jt(e),o=await qp(t,n);await s1(o,e)}var je=class extends Event{constructor(e,t){super(e),this.detail=t}};var tu={};M(tu,{base58btc:()=>$e,base58flickr:()=>f1});function i1(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 s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=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(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var h=0,m=0,g=0,A=d.length;g!==A&&d[g]===0;)g++,h++;for(var b=(A-g)*u+1>>>0,S=new Uint8Array(b);g!==A;){for(var v=d[g],I=0,C=b-1;(v!==0||I<m)&&C!==-1;C--,I++)v+=256*S[C]>>>0,S[C]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");m=I,g++}for(var y=b-m;y!==b&&S[y]===0;)y++;for(var k=c.repeat(h);y<b;++y)k+=r.charAt(S[y]);return k}function p(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var h=0;if(d[h]!==" "){for(var m=0,g=0;d[h]===c;)m++,h++;for(var A=(d.length-h)*f+1>>>0,b=new Uint8Array(A);d[h];){var S=t[d.charCodeAt(h)];if(S===255)return;for(var v=0,I=A-1;(S!==0||v<g)&&I!==-1;I--,v++)S+=a*b[I]>>>0,b[I]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");g=v,h++}if(d[h]!==" "){for(var C=A-g;C!==A&&b[C]===0;)C++;for(var y=new Uint8Array(m+(A-C)),k=m;C!==A;)y[k++]=b[C++];return y}}}function x(d){var h=p(d);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:x}}var a1=i1,c1=a1,Qp=c1;var sI=new Uint8Array(0);var e0=(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},Xt=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var t0=r=>new TextEncoder().encode(r),r0=r=>new TextDecoder().decode(r);var Jc=class{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")}},Xc=class{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 o0(this,e)}},Qc=class{constructor(e){this.decoders=e}or(e){return o0(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},o0=(r,e)=>new Qc({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),eu=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Jc(e,t,n),this.decoder=new Xc(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Vn=({name:r,prefix:e,encode:t,decode:n})=>new eu(r,e,t,n),Br=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=Qp(t,e);return Vn({prefix:r,name:e,encode:n,decode:s=>Xt(o(s))})},u1=(r,e,t,n)=>{let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,c=0,f=0;for(let u=0;u<s;++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,i[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i},l1=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s},pe=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>Vn({prefix:e,name:r,encode(o){return l1(o,n,t)},decode(o){return u1(o,n,t,r)}});var $e=Br({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),f1=Br({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ru={};M(ru,{base32:()=>kt,base32hex:()=>m1,base32hexpad:()=>y1,base32hexpadupper:()=>b1,base32hexupper:()=>g1,base32pad:()=>d1,base32padupper:()=>p1,base32upper:()=>h1,base32z:()=>w1});var kt=pe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),h1=pe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),d1=pe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),p1=pe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),m1=pe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),g1=pe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),y1=pe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),b1=pe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),w1=pe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var x1=a0,s0=128,v1=127,E1=~v1,A1=Math.pow(2,31);function a0(r,e,t){e=e||[],t=t||0;for(var n=t;r>=A1;)e[t++]=r&255|s0,r/=128;for(;r&E1;)e[t++]=r&255|s0,r>>>=7;return e[t]=r|0,a0.bytes=t-n+1,e}var B1=nu,S1=128,i0=127;function nu(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw nu.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&i0)<<o:(i&i0)*Math.pow(2,o),o+=7}while(i>=S1);return nu.bytes=s-n,t}var I1=Math.pow(2,7),C1=Math.pow(2,14),T1=Math.pow(2,21),k1=Math.pow(2,28),R1=Math.pow(2,35),N1=Math.pow(2,42),U1=Math.pow(2,49),_1=Math.pow(2,56),D1=Math.pow(2,63),L1=function(r){return r<I1?1:r<C1?2:r<T1?3:r<k1?4:r<R1?5:r<N1?6:r<U1?7:r<_1?8:r<D1?9:10},O1={encode:x1,decode:B1,encodingLength:L1},V1=O1,Ho=V1;var Ko=(r,e=0)=>[Ho.decode(r,e),Ho.decode.bytes],Pn=(r,e,t=0)=>(Ho.encode(r,e,t),e),Mn=r=>Ho.encodingLength(r);var Wr=(r,e)=>{let t=e.byteLength,n=Mn(r),o=n+Mn(t),s=new Uint8Array(o+t);return Pn(r,s,0),Pn(t,s,n),s.set(e,o),new Fn(r,t,e,s)},zo=r=>{let e=Xt(r),[t,n]=Ko(e),[o,s]=Ko(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Fn(t,o,i,e)},c0=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&e0(r.bytes,t.bytes)}},Fn=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var Ki=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let p=Number.parseInt(l,e);if(!Number.isNaN(p))return p});if(u===void 0)break;if(s*=e,s+=u,s>f||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return t[o]=i[0],t[o+1]=i[1],t[o+2]=i[2],t[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];t[o]=s>>8,t[o+1]=s&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=e(s.subarray(0,i));return t.set(s.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var u0=45,P1=15,$n=new Ki;function ou(r){if(!(r.length>P1))return $n.new(r).parseWith(()=>$n.readIPv4Addr())}function su(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>u0))return $n.new(r).parseWith(()=>$n.readIPv6Addr())}function zi(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>u0))return $n.new(r).parseWith(()=>$n.readIPAddr())}function qi(r){return!!ou(r)}function Gi(r){return!!su(r)}function Sr(r){return!!zi(r)}var lu={};M(lu,{base10:()=>z1});function M1(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 s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=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(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var h=0,m=0,g=0,A=d.length;g!==A&&d[g]===0;)g++,h++;for(var b=(A-g)*u+1>>>0,S=new Uint8Array(b);g!==A;){for(var v=d[g],I=0,C=b-1;(v!==0||I<m)&&C!==-1;C--,I++)v+=256*S[C]>>>0,S[C]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");m=I,g++}for(var y=b-m;y!==b&&S[y]===0;)y++;for(var k=c.repeat(h);y<b;++y)k+=r.charAt(S[y]);return k}function p(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var h=0;if(d[h]!==" "){for(var m=0,g=0;d[h]===c;)m++,h++;for(var A=(d.length-h)*f+1>>>0,b=new Uint8Array(A);d[h];){var S=t[d.charCodeAt(h)];if(S===255)return;for(var v=0,I=A-1;(S!==0||v<g)&&I!==-1;I--,v++)S+=a*b[I]>>>0,b[I]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");g=v,h++}if(d[h]!==" "){for(var C=A-g;C!==A&&b[C]===0;)C++;for(var y=new Uint8Array(m+(A-C)),k=m;C!==A;)y[k++]=b[C++];return y}}}function x(d){var h=p(d);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:x}}var F1=M1,$1=F1,l0=$1;var xI=new Uint8Array(0);var f0=(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},Qt=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")};var h0=r=>new TextEncoder().encode(r),d0=r=>new TextDecoder().decode(r);var iu=class{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")}},au=class{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 m0(this,e)}},cu=class{constructor(e){this.decoders=e}or(e){return m0(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},m0=(r,e)=>new cu({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),uu=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new iu(e,t,n),this.decoder=new au(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Hn=({name:r,prefix:e,encode:t,decode:n})=>new uu(r,e,t,n),Ir=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=l0(t,e);return Hn({prefix:r,name:e,encode:n,decode:s=>Qt(o(s))})},H1=(r,e,t,n)=>{let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,c=0,f=0;for(let u=0;u<s;++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,i[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i},K1=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s},me=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>Hn({prefix:e,name:r,encode(o){return K1(o,n,t)},decode(o){return H1(o,n,t,r)}});var z1=Ir({prefix:"9",name:"base10",alphabet:"0123456789"});var fu={};M(fu,{base16:()=>q1,base16upper:()=>G1});var q1=me({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),G1=me({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var hu={};M(hu,{base2:()=>j1});var j1=me({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var du={};M(du,{base256emoji:()=>X1});var g0=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}"),W1=g0.reduce((r,e,t)=>(r[t]=e,r),[]),Y1=g0.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Z1(r){return r.reduce((e,t)=>(e+=W1[t],e),"")}function J1(r){let e=[];for(let t of r){let n=Y1[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var X1=Hn({prefix:"\u{1F680}",name:"base256emoji",encode:Z1,decode:J1});var pu={};M(pu,{base32:()=>Kn,base32hex:()=>rv,base32hexpad:()=>ov,base32hexpadupper:()=>sv,base32hexupper:()=>nv,base32pad:()=>ev,base32padupper:()=>tv,base32upper:()=>Q1,base32z:()=>iv});var Kn=me({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Q1=me({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ev=me({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),tv=me({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),rv=me({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),nv=me({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ov=me({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),sv=me({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),iv=me({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var mu={};M(mu,{base36:()=>av,base36upper:()=>cv});var av=Ir({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),cv=Ir({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var gu={};M(gu,{base58btc:()=>Rt,base58flickr:()=>uv});var Rt=Ir({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),uv=Ir({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var yu={};M(yu,{base64:()=>lv,base64pad:()=>fv,base64url:()=>hv,base64urlpad:()=>dv});var lv=me({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),fv=me({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),hv=me({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),dv=me({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var bu={};M(bu,{base8:()=>pv});var pv=me({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var wu={};M(wu,{identity:()=>mv});var mv=Hn({prefix:"\0",name:"identity",encode:r=>d0(r),decode:r=>h0(r)});var LI=new TextEncoder,OI=new TextDecoder;var vu={};M(vu,{identity:()=>Pv});var bv=w0,y0=128,wv=127,xv=~wv,vv=Math.pow(2,31);function w0(r,e,t){e=e||[],t=t||0;for(var n=t;r>=vv;)e[t++]=r&255|y0,r/=128;for(;r&xv;)e[t++]=r&255|y0,r>>>=7;return e[t]=r|0,w0.bytes=t-n+1,e}var Ev=xu,Av=128,b0=127;function xu(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw xu.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&b0)<<o:(i&b0)*Math.pow(2,o),o+=7}while(i>=Av);return xu.bytes=s-n,t}var Bv=Math.pow(2,7),Sv=Math.pow(2,14),Iv=Math.pow(2,21),Cv=Math.pow(2,28),Tv=Math.pow(2,35),kv=Math.pow(2,42),Rv=Math.pow(2,49),Nv=Math.pow(2,56),Uv=Math.pow(2,63),_v=function(r){return r<Bv?1:r<Sv?2:r<Iv?3:r<Cv?4:r<Tv?5:r<kv?6:r<Rv?7:r<Nv?8:r<Uv?9:10},Dv={encode:bv,decode:Ev,encodingLength:_v},Lv=Dv,qo=Lv;var Go=(r,e=0)=>[qo.decode(r,e),qo.decode.bytes],zn=(r,e,t=0)=>(qo.encode(r,e,t),e),qn=r=>qo.encodingLength(r);var Zr=(r,e)=>{let t=e.byteLength,n=qn(r),o=n+qn(t),s=new Uint8Array(o+t);return zn(r,s,0),zn(t,s,n),s.set(e,o),new Gn(r,t,e,s)},x0=r=>{let e=Qt(r),[t,n]=Go(e),[o,s]=Go(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Gn(t,o,i,e)},v0=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&f0(r.bytes,t.bytes)}},Gn=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var E0=0,Ov="identity",A0=Qt,Vv=r=>Zr(E0,A0(r)),Pv={code:E0,name:Ov,encode:A0,digest:Vv};var Bu={};M(Bu,{sha256:()=>Mv,sha512:()=>Fv});var Au=({name:r,code:e,encode:t})=>new Eu(r,e,t),Eu=class{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?Zr(this.code,t):t.then(n=>Zr(this.code,n))}else throw Error("Unknown type, must be binary type")}};var S0=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Mv=Au({name:"sha2-256",code:18,encode:S0("SHA-256")}),Fv=Au({name:"sha2-512",code:19,encode:S0("SHA-512")});var I0=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Hv(t,Su(r),e||Rt.encoder);default:return Kv(t,Su(r),e||Kn.encoder)}};var C0=new WeakMap,Su=r=>{let e=C0.get(r);if(e==null){let t=new Map;return C0.set(r,t),t}return e},Wi=class r{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!==Wo)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==zv)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=Zr(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&&e.code===n.code&&e.version===n.version&&v0(e.multihash,n.multihash)}toString(e){return I0(this,e)}toJSON(){return{"/":I0(this)}}link(){return this}get[Symbol.toStringTag](){return"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:s,bytes:i}=t;return new r(n,o,s,i||T0(n,o,s.bytes))}else if(t[qv]===!0){let{version:n,multihash:o,code:s}=t,i=x0(o);return r.create(n,s,i)}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!==Wo)throw new Error(`Version 0 CID must use dag-pb (code: ${Wo}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=T0(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Wo,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=Qt(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new Gn(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,p]=Go(e.subarray(t));return t+=p,l},o=n(),s=Wo;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),c=n(),f=t+c,u=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=$v(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Su(s).set(n,e),s}},$v=(r,e)=>{switch(r[0]){case"Q":{let t=e||Rt;return[Rt.prefix,t.decode(`${Rt.prefix}${r}`)]}case Rt.prefix:{let t=e||Rt;return[Rt.prefix,t.decode(r)]}case Kn.prefix:{let t=e||Kn;return[Kn.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)]}}},Hv=(r,e,t)=>{let{prefix:n}=t;if(n!==Rt.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},Kv=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},Wo=112,zv=18,T0=(r,e,t)=>{let n=qn(r),o=n+qn(e),s=new Uint8Array(o+t.byteLength);return zn(r,s,0),zn(e,s,n),s.set(t,o),s},qv=Symbol.for("@ipld/js-cid/CID");var Iu={...wu,...hu,...bu,...lu,...fu,...pu,...mu,...gu,...yu,...du},XI={...Bu,...vu};function jn(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Yi(r=0){return globalThis.Buffer?.allocUnsafe!=null?jn(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function R0(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var k0=R0("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Cu=R0("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=Yi(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Gv={utf8:k0,"utf-8":k0,hex:Iu.base16,latin1:Cu,ascii:Cu,binary:Cu,...Iu},Zi=Gv;function He(r,e="utf8"){let t=Zi[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var N0=qi,jv=Gi,Tu=function(r){let e=0;if(r=r.toString().trim(),N0(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(jv(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=N0(t[n]),i;s&&(i=Tu(t[n]),t[n]=He(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,He(i.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let s=[n,1];for(n=9-t.length;n>0;n--)s.push("0");t.splice.apply(t,s)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){let s=parseInt(t[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},U0=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let s=0;s<t;s++)o.push(r[e+s]);return o.join(".")}if(t===16){let o=[];for(let s=0;s<t;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Yo={},ku={},Yv=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc"],[281,0,"webrtc-w3c"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];Yv.forEach(r=>{let e=Zv(...r);ku[e.code]=e,Yo[e.name]=e});function Zv(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function le(r){if(typeof r=="number"){if(ku[r]!=null)return ku[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Yo[r]!=null)return Yo[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var _0=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Xv(t,Ru(r),e||$e.encoder);default:return Qv(t,Ru(r),e||kt.encoder)}};var D0=new WeakMap,Ru=r=>{let e=D0.get(r);if(e==null){let t=new Map;return D0.set(r,t),t}return e},ut=class r{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!==Zo)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==e2)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=Wr(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&&e.code===n.code&&e.version===n.version&&c0(e.multihash,n.multihash)}toString(e){return _0(this,e)}toJSON(){return{"/":_0(this)}}link(){return this}get[Symbol.toStringTag](){return"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:s,bytes:i}=t;return new r(n,o,s,i||L0(n,o,s.bytes))}else if(t[t2]===!0){let{version:n,multihash:o,code:s}=t,i=zo(o);return r.create(n,s,i)}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!==Zo)throw new Error(`Version 0 CID must use dag-pb (code: ${Zo}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=L0(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Zo,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=Xt(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new Fn(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,p]=Ko(e.subarray(t));return t+=p,l},o=n(),s=Zo;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),c=n(),f=t+c,u=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=Jv(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ru(s).set(n,e),s}},Jv=(r,e)=>{switch(r[0]){case"Q":{let t=e||$e;return[$e.prefix,t.decode(`${$e.prefix}${r}`)]}case $e.prefix:{let t=e||$e;return[$e.prefix,t.decode(r)]}case kt.prefix:{let t=e||kt;return[kt.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)]}}},Xv=(r,e,t)=>{let{prefix:n}=t;if(n!==$e.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},Qv=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},Zo=112,e2=18,L0=(r,e,t)=>{let n=Mn(r),o=n+Mn(e),s=new Uint8Array(o+t.byteLength);return Pn(r,s,0),Pn(e,s,n),s.set(t,o),s},t2=Symbol.for("@ipld/js-cid/CID");var Nu={};M(Nu,{identity:()=>r2});var r2=Vn({prefix:"\0",name:"identity",encode:r=>r0(r),decode:r=>t0(r)});var Uu={};M(Uu,{base2:()=>n2});var n2=pe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var _u={};M(_u,{base8:()=>o2});var o2=pe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Du={};M(Du,{base10:()=>s2});var s2=Br({prefix:"9",name:"base10",alphabet:"0123456789"});var Lu={};M(Lu,{base16:()=>i2,base16upper:()=>a2});var i2=pe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),a2=pe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ou={};M(Ou,{base36:()=>c2,base36upper:()=>u2});var c2=Br({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),u2=Br({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Vu={};M(Vu,{base64:()=>l2,base64pad:()=>f2,base64url:()=>h2,base64urlpad:()=>d2});var l2=pe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),f2=pe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),h2=pe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),d2=pe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Pu={};M(Pu,{base256emoji:()=>b2});var O0=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}"),p2=O0.reduce((r,e,t)=>(r[t]=e,r),[]),m2=O0.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function g2(r){return r.reduce((e,t)=>(e+=p2[t],e),"")}function y2(r){let e=[];for(let t of r){let n=m2[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var b2=Vn({prefix:"\u{1F680}",name:"base256emoji",encode:g2,decode:y2});var $u={};M($u,{sha256:()=>w2,sha512:()=>x2});var Fu=({name:r,code:e,encode:t})=>new Mu(r,e,t),Mu=class{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?Wr(this.code,t):t.then(n=>Wr(this.code,n))}else throw Error("Unknown type, must be binary type")}};var P0=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),w2=Fu({name:"sha2-256",code:18,encode:P0("SHA-256")}),x2=Fu({name:"sha2-512",code:19,encode:P0("SHA-512")});var Hu={};M(Hu,{identity:()=>A2});var M0=0,v2="identity",F0=Xt,E2=r=>Wr(M0,F0(r)),A2={code:M0,name:v2,encode:F0,digest:E2};var kC=new TextEncoder,RC=new TextDecoder;var $0={...Nu,...Uu,..._u,...Du,...Lu,...ru,...Ou,...tu,...Vu,...Pu},LC={...$u,...Hu};var Nt=_e(Ji(),1);function qu(r,e="utf8"){let t=Zi[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?jn(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function er(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=Yi(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return jn(t)}function tm(r,e){switch(le(r).code){case 4:case 41:return F2(e);case 42:return Q0(e);case 6:case 273:case 33:case 132:return nm(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Q0(e);case 421:return z2(e);case 444:return em(e);case 445:return em(e);case 466:return K2(e);default:return He(e,"base16")}}function rm(r,e){switch(le(r).code){case 4:return J0(e);case 41:return J0(e);case 42:return X0(e);case 6:case 273:case 33:case 132:return ju(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return X0(e);case 421:return $2(e);case 444:return q2(e);case 445:return G2(e);case 466:return H2(e);default:return qu(e,"base16")}}var Gu=Object.values($0).map(r=>r.decoder),M2=function(){let r=Gu[0].or(Gu[1]);return Gu.slice(2).forEach(e=>r=r.or(e)),r}();function J0(r){if(!Sr(r))throw new Error("invalid ip address");return Tu(r)}function F2(r){let e=U0(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Sr(e))throw new Error("invalid ip address");return e}function ju(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function nm(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function X0(r){let e=qu(r),t=Uint8Array.from(Nt.default.encode(e.length));return er([t,e],t.length+e.length)}function Q0(r){let e=Nt.default.decode(r);if(r=r.slice(Nt.default.decode.bytes),r.length!==e)throw new Error("inconsistent lengths");return He(r)}function $2(r){let e;r[0]==="Q"||r[0]==="1"?e=zo($e.decode(`z${r}`)).bytes:e=ut.parse(r).multihash.bytes;let t=Uint8Array.from(Nt.default.encode(e.length));return er([t,e],t.length+e.length)}function H2(r){let e=M2.decode(r),t=Uint8Array.from(Nt.default.encode(e.length));return er([t,e],t.length+e.length)}function K2(r){let e=Nt.default.decode(r),t=r.slice(Nt.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return"u"+He(t,"base64url")}function z2(r){let e=Nt.default.decode(r),t=r.slice(Nt.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return He(t,"base58btc")}function q2(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=kt.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ju(n);return er([t,o],t.length+o.length)}function G2(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=kt.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ju(n);return er([t,o],t.length+o.length)}function em(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=He(e,"base32"),o=nm(t);return`${n}:${o}`}var Wn=_e(Ji(),1);function j2(r){let e=[],t=r.split("/").slice(1);if(t.length===1&&t[0]==="")return[];for(let n=0;n<t.length;n++){let o=t[n],s=le(o);if(s.size===0){e.push([o]);continue}if(n++,n>=t.length)throw sm("invalid address: "+r);if(s.path===!0){e.push([o,Xu(t.slice(n).join("/"))]);break}e.push([o,t[n]])}return e}function W2(r){let e=[];return r.map(t=>{let n=ea(t);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),Xu(e.join("/"))}function Y2(r){return r.map(e=>{Array.isArray(e)||(e=[e]);let t=ea(e);return e.length>1?[t.code,rm(t.code,e[1])]:[t.code]})}function Wu(r){return r.map(e=>{let t=ea(e);return e[1]!=null?[t.code,tm(t.code,e[1])]:[t.code]})}function Yu(r){return Qi(er(r.map(e=>{let t=ea(e),n=Uint8Array.from(Wn.default.encode(t.code));return e.length>1&&e[1]!=null&&(n=er([n,e[1]])),n})))}function Zu(r,e){return r.size>0?r.size/8:r.size===0?0:Wn.default.decode(e)+(Wn.default.decode.bytes??0)}function Xi(r){let e=[],t=0;for(;t<r.length;){let n=Wn.default.decode(r,t),o=Wn.default.decode.bytes??0,s=le(n),i=Zu(s,r.slice(t+o));if(i===0){e.push([n]),t+=o;continue}let a=r.slice(t+o,t+o+i);if(t+=i+o,t>r.length)throw sm("Invalid address Uint8Array: "+He(r,"base16"));e.push([n,a])}return e}function Ju(r){let e=Xi(r),t=Wu(e);return W2(t)}function Z2(r){r=Xu(r);let e=j2(r),t=Y2(e);return Yu(t)}function om(r){return Z2(r)}function Qi(r){let e=J2(r);if(e!=null)throw e;return Uint8Array.from(r)}function J2(r){try{Xi(r)}catch(e){return e}}function Xu(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function sm(r){return new Error("Error parsing address: "+r)}function ea(r){return le(r[0])}var el=_e(Ji(),1);var um=_e(_o(),1);function im(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 Yn=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Qu=function(r,e,t,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!o:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(r,t):o?o.value=t:e.set(r,t),t},Jo,Xo,Qo,am,Q2=Symbol.for("nodejs.util.inspect.custom"),eE=[le("dns").code,le("dns4").code,le("dns6").code,le("dnsaddr").code],tE=new Map,lm=Symbol.for("@multiformats/js-multiaddr/multiaddr");function rE(r){return!!r?.[lm]}var cm=class r{constructor(e){if(Jo.set(this,void 0),Xo.set(this,void 0),Qo.set(this,void 0),this[am]=!0,e==null&&(e=""),e instanceof Uint8Array)this.bytes=Qi(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=om(e)}else if(rE(e))this.bytes=Qi(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return Yn(this,Jo,"f")==null&&Qu(this,Jo,Ju(this.bytes),"f"),Yn(this,Jo,"f")}toJSON(){return this.toString()}toOptions(){let e,t,n,o,s="",i=le("tcp"),a=le("udp"),c=le("ip4"),f=le("ip6"),u=le("dns6"),l=le("ip6zone");for(let[x,d]of this.stringTuples())x===l.code&&(s=`%${d??""}`),eE.includes(x)&&(t=i.name,o=443,n=`${d??""}${s}`,e=x===u.code?6:4),(x===i.code||x===a.code)&&(t=le(x).name,o=parseInt(d??"")),(x===c.code||x===f.code)&&(t=le(x).name,n=`${d??""}${s}`,e=x===f.code?6:4);if(e==null||t==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:o}}protos(){return this.protoCodes().map(e=>Object.assign({},le(e)))}protoCodes(){let e=[],t=this.bytes,n=0;for(;n<t.length;){let o=el.default.decode(t,n),s=el.default.decode.bytes??0,i=le(o),a=Zu(i,t.slice(n+s));n+=a+s,e.push(o)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return Yn(this,Xo,"f")==null&&Qu(this,Xo,Xi(this.bytes),"f"),Yn(this,Xo,"f")}stringTuples(){return Yn(this,Qo,"f")==null&&Qu(this,Qo,Wu(this.tuples()),"f"),Yn(this,Qo,"f")}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(Yu(t.slice(0,n)));return this}getPeerId(){try{let t=this.stringTuples().filter(n=>n[0]===Yo.ipfs.code).pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?He($e.decode(`z${n}`),"base58btc"):He(ut.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let e=null;try{e=this.stringTuples().filter(t=>le(t[0]).path===!0)[0][1],e==null&&(e=null)}catch{e=null}return e}equals(e){return im(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=tE.get(t.name);if(n==null)throw(0,um.default)(new Error(`no available resolver for ${t.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new r(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[(Jo=new WeakMap,Xo=new WeakMap,Qo=new WeakMap,am=lm,Q2)](){return`Multiaddr(${Ju(this.bytes)})`}};var sl={};M(sl,{base58btc:()=>We,base58flickr:()=>cE});var dT=new Uint8Array(0);function fm(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 tr(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 hm(r){return new TextEncoder().encode(r)}function dm(r){return new TextDecoder().decode(r)}function nE(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 s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=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(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var h=0,m=0,g=0,A=d.length;g!==A&&d[g]===0;)g++,h++;for(var b=(A-g)*u+1>>>0,S=new Uint8Array(b);g!==A;){for(var v=d[g],I=0,C=b-1;(v!==0||I<m)&&C!==-1;C--,I++)v+=256*S[C]>>>0,S[C]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");m=I,g++}for(var y=b-m;y!==b&&S[y]===0;)y++;for(var k=c.repeat(h);y<b;++y)k+=r.charAt(S[y]);return k}function p(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var h=0;if(d[h]!==" "){for(var m=0,g=0;d[h]===c;)m++,h++;for(var A=(d.length-h)*f+1>>>0,b=new Uint8Array(A);d[h];){var S=t[d.charCodeAt(h)];if(S===255)return;for(var v=0,I=A-1;(S!==0||v<g)&&I!==-1;I--,v++)S+=a*b[I]>>>0,b[I]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");g=v,h++}if(d[h]!==" "){for(var C=A-g;C!==A&&b[C]===0;)C++;for(var y=new Uint8Array(m+(A-C)),k=m;C!==A;)y[k++]=b[C++];return y}}}function x(d){var h=p(d);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:x}}var oE=nE,sE=oE,mm=sE;var tl=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")}},rl=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 gm(this,e)}},nl=class{decoders;constructor(e){this.decoders=e}or(e){return gm(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 gm(r,e){return new nl({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var ol=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 tl(e,t,n),this.decoder=new rl(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Zn({name:r,prefix:e,encode:t,decode:n}){return new ol(r,e,t,n)}function Cr({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=mm(t,r);return Zn({prefix:e,name:r,encode:n,decode:s=>tr(o(s))})}function iE(r,e,t,n){let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,c=0,f=0;for(let u=0;u<s;++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,i[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function aE(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s}function ge({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Zn({prefix:e,name:r,encode(o){return aE(o,n,t)},decode(o){return iE(o,n,t,r)}})}var We=Cr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),cE=Cr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var il={};M(il,{base32:()=>rr,base32hex:()=>hE,base32hexpad:()=>pE,base32hexpadupper:()=>mE,base32hexupper:()=>dE,base32pad:()=>lE,base32padupper:()=>fE,base32upper:()=>uE,base32z:()=>gE});var rr=ge({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),uE=ge({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),lE=ge({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),fE=ge({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),hE=ge({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),dE=ge({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),pE=ge({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),mE=ge({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),gE=ge({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var yE=wm,ym=128,bE=127,wE=~bE,xE=Math.pow(2,31);function wm(r,e,t){e=e||[],t=t||0;for(var n=t;r>=xE;)e[t++]=r&255|ym,r/=128;for(;r&wE;)e[t++]=r&255|ym,r>>>=7;return e[t]=r|0,wm.bytes=t-n+1,e}var vE=al,EE=128,bm=127;function al(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw al.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&bm)<<o:(i&bm)*Math.pow(2,o),o+=7}while(i>=EE);return al.bytes=s-n,t}var AE=Math.pow(2,7),BE=Math.pow(2,14),SE=Math.pow(2,21),IE=Math.pow(2,28),CE=Math.pow(2,35),TE=Math.pow(2,42),kE=Math.pow(2,49),RE=Math.pow(2,56),NE=Math.pow(2,63),UE=function(r){return r<AE?1:r<BE?2:r<SE?3:r<IE?4:r<CE?5:r<TE?6:r<kE?7:r<RE?8:r<NE?9:10},_E={encode:yE,decode:vE,encodingLength:UE},DE=_E,es=DE;function ts(r,e=0){return[es.decode(r,e),es.decode.bytes]}function Jn(r,e,t=0){return es.encode(r,e,t),e}function Xn(r){return es.encodingLength(r)}function Jr(r,e){let t=e.byteLength,n=Xn(r),o=n+Xn(t),s=new Uint8Array(o+t);return Jn(r,s,0),Jn(t,s,n),s.set(e,o),new Qn(r,t,e,s)}function ra(r){let e=tr(r),[t,n]=ts(e),[o,s]=ts(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Qn(t,o,i,e)}function xm(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&fm(r.bytes,t.bytes)}}var Qn=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};function vm(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return OE(t,cl(r),e??We.encoder);default:return VE(t,cl(r),e??rr.encoder)}}var Em=new WeakMap;function cl(r){let e=Em.get(r);if(e==null){let t=new Map;return Em.set(r,t),t}return e}var Tr=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!==rs)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==PE)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=Jr(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&&xm(e.multihash,n.multihash)}toString(e){return vm(this,e)}toJSON(){return{"/":vm(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:s,bytes:i}=t;return new r(n,o,s,i??Am(n,o,s.bytes))}else if(t[ME]===!0){let{version:n,multihash:o,code:s}=t,i=ra(o);return r.create(n,s,i)}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!==rs)throw new Error(`Version 0 CID must use dag-pb (code: ${rs}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Am(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,rs,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=tr(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new Qn(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,p]=ts(e.subarray(t));return t+=p,l},o=n(),s=rs;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),c=n(),f=t+c,u=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=LE(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return cl(s).set(n,e),s}};function LE(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 rr.prefix:{let t=e??rr;return[rr.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 OE(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 s=t.encode(r).slice(1);return e.set(n,s),s}else return o}function VE(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o}var rs=112,PE=18;function Am(r,e,t){let n=Xn(r),o=n+Xn(e),s=new Uint8Array(o+t.byteLength);return Jn(r,s,0),Jn(e,s,n),s.set(t,o),s}var ME=Symbol.for("@ipld/js-cid/CID");function Bm(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 ul={};M(ul,{base10:()=>FE});var FE=Cr({prefix:"9",name:"base10",alphabet:"0123456789"});var ll={};M(ll,{base16:()=>$E,base16upper:()=>HE});var $E=ge({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),HE=ge({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var fl={};M(fl,{base2:()=>KE});var KE=ge({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var hl={};M(hl,{base256emoji:()=>WE});var Sm=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}"),zE=Sm.reduce((r,e,t)=>(r[t]=e,r),[]),qE=Sm.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function GE(r){return r.reduce((e,t)=>(e+=zE[t],e),"")}function jE(r){let e=[];for(let t of r){let n=qE[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var WE=Zn({prefix:"\u{1F680}",name:"base256emoji",encode:GE,decode:jE});var dl={};M(dl,{base36:()=>YE,base36upper:()=>ZE});var YE=Cr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ZE=Cr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var pl={};M(pl,{base64:()=>JE,base64pad:()=>XE,base64url:()=>QE,base64urlpad:()=>e8});var JE=ge({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),XE=ge({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),QE=ge({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),e8=ge({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ml={};M(ml,{base8:()=>t8});var t8=ge({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var gl={};M(gl,{identity:()=>r8});var r8=Zn({prefix:"\0",name:"identity",encode:r=>dm(r),decode:r=>hm(r)});var PT=new TextEncoder,MT=new TextDecoder;var yl={};M(yl,{identity:()=>a8});var Im=0,s8="identity",Cm=tr;function i8(r){return Jr(Im,Cm(r))}var a8={code:Im,name:s8,encode:Cm,digest:i8};var xl={};M(xl,{sha256:()=>c8,sha512:()=>u8});function wl({name:r,code:e,encode:t}){return new bl(r,e,t)}var bl=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?Jr(this.code,t):t.then(n=>Jr(this.code,n))}else throw Error("Unknown type, must be binary type")}};function km(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var c8=wl({name:"sha2-256",code:18,encode:km("SHA-256")}),u8=wl({name:"sha2-512",code:19,encode:km("SHA-512")});var ns={...gl,...fl,...ml,...ul,...ll,...il,...dl,...sl,...pl,...hl},XT={...xl,...yl};function Xr(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function na(r=0){return globalThis.Buffer?.allocUnsafe!=null?Xr(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Nm(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Rm=Nm("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),vl=Nm("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=na(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),l8={utf8:Rm,"utf-8":Rm,hex:ns.base16,latin1:vl,ascii:vl,binary:vl,...ns},oa=l8;function Ye(r,e="utf8"){let t=oa[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var f8=Math.pow(2,7),h8=Math.pow(2,14),d8=Math.pow(2,21),El=Math.pow(2,28),Al=Math.pow(2,35),Bl=Math.pow(2,42),Sl=Math.pow(2,49),re=128,Oe=127;function Ut(r){if(r<f8)return 1;if(r<h8)return 2;if(r<d8)return 3;if(r<El)return 4;if(r<Al)return 5;if(r<Bl)return 6;if(r<Sl)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function p8(r,e,t=0){switch(Ut(r)){case 8:e[t++]=r&255|re,r/=128;case 7:e[t++]=r&255|re,r/=128;case 6:e[t++]=r&255|re,r/=128;case 5:e[t++]=r&255|re,r/=128;case 4:e[t++]=r&255|re,r>>>=7;case 3:e[t++]=r&255|re,r>>>=7;case 2:e[t++]=r&255|re,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function m8(r,e,t=0){switch(Ut(r)){case 8:e.set(t++,r&255|re),r/=128;case 7:e.set(t++,r&255|re),r/=128;case 6:e.set(t++,r&255|re),r/=128;case 5:e.set(t++,r&255|re),r/=128;case 4:e.set(t++,r&255|re),r>>>=7;case 3:e.set(t++,r&255|re),r>>>=7;case 2:e.set(t++,r&255|re),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function g8(r,e){let t=r[e],n=0;if(n+=t&Oe,t<re||(t=r[e+1],n+=(t&Oe)<<7,t<re)||(t=r[e+2],n+=(t&Oe)<<14,t<re)||(t=r[e+3],n+=(t&Oe)<<21,t<re)||(t=r[e+4],n+=(t&Oe)*El,t<re)||(t=r[e+5],n+=(t&Oe)*Al,t<re)||(t=r[e+6],n+=(t&Oe)*Bl,t<re)||(t=r[e+7],n+=(t&Oe)*Sl,t<re))return n;throw new RangeError("Could not decode varint")}function y8(r,e){let t=r.get(e),n=0;if(n+=t&Oe,t<re||(t=r.get(e+1),n+=(t&Oe)<<7,t<re)||(t=r.get(e+2),n+=(t&Oe)<<14,t<re)||(t=r.get(e+3),n+=(t&Oe)<<21,t<re)||(t=r.get(e+4),n+=(t&Oe)*El,t<re)||(t=r.get(e+5),n+=(t&Oe)*Al,t<re)||(t=r.get(e+6),n+=(t&Oe)*Bl,t<re)||(t=r.get(e+7),n+=(t&Oe)*Sl,t<re))return n;throw new RangeError("Could not decode varint")}function to(r,e,t=0){return e==null&&(e=lt(Ut(r))),e instanceof Uint8Array?p8(r,e,t):m8(r,e,t)}function Qr(r,e=0){return r instanceof Uint8Array?g8(r,e):y8(r,e)}function nr(r,e){if(globalThis.Buffer!=null)return Xr(globalThis.Buffer.concat(r,e));e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=na(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return Xr(t)}var b5=parseInt("0xFFFF",16),w5=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Il(r,e="utf8"){let t=oa[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Xr(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var Lm=qi,E8=Gi,Cl=function(r){let e=0;if(r=r.toString().trim(),Lm(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(E8(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=Lm(t[n]),i;s&&(i=Cl(t[n]),t[n]=Ye(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,Ye(i.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let s=[n,1];for(n=9-t.length;n>0;n--)s.push("0");t.splice.apply(t,s)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){let s=parseInt(t[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},Om=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let s=0;s<t;s++)o.push(r[e+s]);return o.join(".")}if(t===16){let o=[];for(let s=0;s<t;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var ro={},Tl={},B8=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];B8.forEach(r=>{let e=S8(...r);Tl[e.code]=e,ro[e.name]=e});function S8(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function se(r){if(typeof r=="number"){if(Tl[r]!=null)return Tl[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(ro[r]!=null)return ro[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var nk=se("ip4"),ok=se("ip6"),sk=se("ipcidr");function Rl(r,e){switch(se(r).code){case 4:case 41:return C8(e);case 42:return Mm(e);case 6:case 273:case 33:case 132:return $m(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Mm(e);case 421:return N8(e);case 444:return Fm(e);case 445:return Fm(e);case 466:return R8(e);default:return Ye(e,"base16")}}function Nl(r,e){switch(se(r).code){case 4:return Vm(e);case 41:return Vm(e);case 42:return Pm(e);case 6:case 273:case 33:case 132:return Ul(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Pm(e);case 421:return T8(e);case 444:return U8(e);case 445:return _8(e);case 466:return k8(e);default:return Il(e,"base16")}}var kl=Object.values(ns).map(r=>r.decoder),I8=function(){let r=kl[0].or(kl[1]);return kl.slice(2).forEach(e=>r=r.or(e)),r}();function Vm(r){if(!Sr(r))throw new Error("invalid ip address");return Cl(r)}function C8(r){let e=Om(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Sr(e))throw new Error("invalid ip address");return e}function Ul(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function $m(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Pm(r){let e=Il(r),t=Uint8Array.from(to(e.length));return nr([t,e],t.length+e.length)}function Mm(r){let e=Qr(r);if(r=r.slice(Ut(e)),r.length!==e)throw new Error("inconsistent lengths");return Ye(r)}function T8(r){let e;r[0]==="Q"||r[0]==="1"?e=ra(We.decode(`z${r}`)).bytes:e=Tr.parse(r).multihash.bytes;let t=Uint8Array.from(to(e.length));return nr([t,e],t.length+e.length)}function k8(r){let e=I8.decode(r),t=Uint8Array.from(to(e.length));return nr([t,e],t.length+e.length)}function R8(r){let e=Qr(r),t=r.slice(Ut(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+Ye(t,"base64url")}function N8(r){let e=Qr(r),t=r.slice(Ut(e));if(t.length!==e)throw new Error("inconsistent lengths");return Ye(t,"base58btc")}function U8(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=rr.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ul(n);return nr([t,o],t.length+o.length)}function _8(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=rr.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ul(n);return nr([t,o],t.length+o.length)}function Fm(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=Ye(e,"base32"),o=$m(t);return`${n}:${o}`}function Hm(r){r=_l(r);let e=[],t=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],a=se(i);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(s++,s>=o.length)throw zm("invalid address: "+r);if(a.path===!0){n=_l(o.slice(s).join("/")),e.push([a.code,Nl(a.code,n)]),t.push([a.code,n]);break}let c=Nl(a.code,o[s]);e.push([a.code,c]),t.push([a.code,Rl(a.code,c)])}return{string:Km(t),bytes:Ll(e),tuples:e,stringTuples:t,path:n}}function Dl(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let s=Qr(r,o),i=Ut(s),a=se(s),c=D8(a,r.slice(o+i));if(c===0){e.push([s]),t.push([s]),o+=i;continue}let f=r.slice(o+i,o+i+c);if(o+=c+i,o>r.length)throw zm("Invalid address Uint8Array: "+Ye(r,"base16"));e.push([s,f]);let u=Rl(s,f);if(t.push([s,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Km(t),tuples:e,stringTuples:t,path:n}}function Km(r){let e=[];return r.map(t=>{let n=se(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),_l(e.join("/"))}function Ll(r){return nr(r.map(e=>{let t=se(e[0]),n=Uint8Array.from(to(t.code));return e.length>1&&e[1]!=null&&(n=nr([n,e[1]])),n}))}function D8(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Qr(e instanceof Uint8Array?e:Uint8Array.from(e));return t+Ut(t)}}function _l(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function zm(r){return new Error("Error parsing address: "+r)}var L8=Symbol.for("nodejs.util.inspect.custom"),Ol=Symbol.for("@multiformats/js-multiaddr/multiaddr"),O8=[se("dns").code,se("dns4").code,se("dns6").code,se("dnsaddr").code],sa=class r{bytes;#e;#t;#s;#a;[Ol]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=Dl(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=Hm(e)}else if(Gm(e))t=Dl(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#t=t.tuples,this.#s=t.stringTuples,this.#a=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,o,s="",i=se("tcp"),a=se("udp"),c=se("ip4"),f=se("ip6"),u=se("dns6"),l=se("ip6zone");for(let[x,d]of this.stringTuples())x===l.code&&(s=`%${d??""}`),O8.includes(x)&&(t=i.name,o=443,n=`${d??""}${s}`,e=x===u.code?6:4),(x===i.code||x===a.code)&&(t=se(x).name,o=parseInt(d??"")),(x===c.code||x===f.code)&&(t=se(x).name,n=`${d??""}${s}`,e=x===f.code?6:4);if(e==null||t==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:o}}protos(){return this.#t.map(([e])=>Object.assign({},se(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>se(e).name)}tuples(){return this.#t}stringTuples(){return this.#s}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(Ll(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===ro.p2p.code&&e.push([n,o]),n===ro["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?Ye(We.decode(`z${n}`),"base58btc"):Ye(Tr.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(e){return Bm(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=qm.get(t.name);if(n==null)throw new q(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new r(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[L8](){return`Multiaddr(${this.#e})`}};var qm=new Map;function Gm(r){return!!r?.[Ol]}function ia(r){return new sa(r)}var V8=P("dns4"),P8=P("dns6"),M8=P("dnsaddr"),en=Re(P("dns"),M8,V8,P8),aa=Re(P("ip4"),P("ip6")),no=Re(G(aa,P("tcp")),G(en,P("tcp"))),Ml=G(aa,P("udp")),F8=G(Ml,P("utp")),$8=G(Ml,P("quic")),ss=Re(G(no,P("ws")),G(en,P("ws"))),is=Re(G(no,P("wss")),G(en,P("wss")),G(no,P("tls"),P("ws")),G(en,P("tls"),P("ws"))),Vl=Re(G(no,P("http")),G(aa,P("http")),G(en,P("http"))),Pl=Re(G(no,P("https")),G(aa,P("https")),G(en,P("https"))),jm=G(Ml,P("webrtc"),P("certhash")),Ym=Re(G(jm,P("p2p")),jm),Zm=Re(G(ss,P("p2p-webrtc-star"),P("p2p")),G(is,P("p2p-webrtc-star"),P("p2p")),G(ss,P("p2p-webrtc-star")),G(is,P("p2p-webrtc-star"))),Nk=Re(G(ss,P("p2p-websocket-star"),P("p2p")),G(is,P("p2p-websocket-star"),P("p2p")),G(ss,P("p2p-websocket-star")),G(is,P("p2p-websocket-star"))),Jm=Re(G(Vl,P("p2p-webrtc-direct"),P("p2p")),G(Pl,P("p2p-webrtc-direct"),P("p2p")),G(Vl,P("p2p-webrtc-direct")),G(Pl,P("p2p-webrtc-direct"))),as=Re(ss,is,Vl,Pl,Zm,Jm,no,F8,$8,en,Ym),Uk=Re(G(as,P("p2p-stardust"),P("p2p")),G(as,P("p2p-stardust"))),kr=Re(G(as,P("p2p")),Zm,Jm,Ym,P("p2p")),Wm=Re(G(kr,P("p2p-circuit"),kr),G(kr,P("p2p-circuit")),G(P("p2p-circuit"),kr),G(as,P("p2p-circuit")),G(P("p2p-circuit"),as),P("p2p-circuit")),Xm=()=>Re(G(Wm,Xm),Wm),os=Xm(),H8=Re(G(os,kr,os),G(kr,os),G(os,kr),os,kr);function Qm(r){function e(t){let n;try{n=ia(t)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return e}function G(...r){function e(t){if(t.length<r.length)return null;let n=t;return r.some(o=>(n=typeof o=="function"?o().partialMatch(t):o.partialMatch(t),Array.isArray(n)&&(t=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Qm(e),partialMatch:e}}function Re(...r){function e(n){let o=null;return r.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Qm(e),partialMatch:e}}function P(r){let e=r;function t(o){let s;try{s=ia(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===e}function n(o){return o.length===0?null:o[0]===e?o.slice(1):null}return{toString:function(){return e},matches:t,partialMatch:n}}var Q8=_e(ig(),1);function ag(r){try{return eA(r)?!!ut.parse(r):r instanceof Uint8Array?!!ut.decode(r):!!ut.asCID(r)}catch{return!1}}function eA(r){return typeof r=="string"}var cg=32,Hl=async(r,e,t,n={})=>{if(e===0)throw new Error("recursion limit exceeded");let o;try{o=await t(r,n)}catch(c){if(c.code!=="ENOTFOUND"&&c.code!=="ERR_DNSLINK_NOT_FOUND"&&c.code!=="ENODATA")throw c;r.startsWith("_dnslink.")?r=r.replace("_dnslink.",""):r=`_dnslink.${r}`,o=await t(r,n)}let s=o.replace("dnslink=",""),i=s.split("/")[2];return ag(i)?s:Hl(i,e-1,t,n)},rA=/^dnslink=.+$/,ug=async(r,e)=>{let o=(await r.resolveTxt(e)).flat().filter(s=>rA.test(s))[0];if(o==null)throw new q(`No dnslink records found for domain: ${e}`,"ERR_DNSLINK_NOT_FOUND");return o};var zl=_e(ma(),1),ql=_e(hg(),1);function ca(r,e,t){return`${r}?name=${e}&type=${t}`}async function dg(r,e){return await(await fetch(r,{headers:new Headers({accept:"application/dns-json"}),signal:e})).json()}function tn(r,e){return`${e}_${r}`}var Kl=Object.assign((0,zl.default)("dns-over-http-resolver"),{error:(0,zl.default)("dns-over-http-resolver:error")}),Gl=class{_cache;_TXTcache;_servers;_request;_abortControllers;constructor(e={}){this._cache=new ql.default({max:e?.maxCache??100}),this._TXTcache=new ql.default({max:e?.maxCache??100}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"],this._request=e.request??dg,this._abortControllers=[]}cancel(){this._abortControllers.forEach(e=>{e.abort()})}getServers(){return this._servers}_getShuffledServers(){let e=[...this._servers];for(let t=e.length-1;t>0;t--){let n=Math.floor(Math.random()*t),o=e[t];e[t]=e[n],e[n]=o}return e}setServers(e){this._servers=e}async resolve(e,t="A"){switch(t){case"A":return this.resolve4(e);case"AAAA":return this.resolve6(e);case"TXT":return this.resolveTxt(e);default:throw new Error(`${t} is not supported`)}}async resolve4(e){let t="A",n=this._cache.get(tn(e,t));if(n!=null)return n;let o=!1;for(let s of this._getShuffledServers()){let i=new AbortController;this._abortControllers.push(i);try{let a=await this._request(ca(s,e,t),i.signal),c=a.Answer.map(u=>u.data),f=Math.min(...a.Answer.map(u=>u.TTL));return this._cache.set(tn(e,t),c,{ttl:f}),c}catch{i.signal.aborted&&(o=!0),Kl.error(`${s} could not resolve ${e} record ${t}`)}finally{this._abortControllers=this._abortControllers.filter(a=>a!==i)}}throw o?Object.assign(new Error("queryA ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record ${t}`)}async resolve6(e){let t="AAAA",n=this._cache.get(tn(e,t));if(n!=null)return n;let o=!1;for(let s of this._getShuffledServers()){let i=new AbortController;this._abortControllers.push(i);try{let a=await this._request(ca(s,e,t),i.signal),c=a.Answer.map(u=>u.data),f=Math.min(...a.Answer.map(u=>u.TTL));return this._cache.set(tn(e,t),c,{ttl:f}),c}catch{i.signal.aborted&&(o=!0),Kl.error(`${s} could not resolve ${e} record ${t}`)}finally{this._abortControllers=this._abortControllers.filter(a=>a!==i)}}throw o?Object.assign(new Error("queryAaaa ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record ${t}`)}async resolveTxt(e){let t="TXT",n=this._TXTcache.get(tn(e,t));if(n!=null)return n;let o=!1;for(let s of this._getShuffledServers()){let i=new AbortController;this._abortControllers.push(i);try{let a=await this._request(ca(s,e,t),i.signal),c=a.Answer.map(u=>[u.data.replace(/['"]+/g,"")]),f=Math.min(...a.Answer.map(u=>u.TTL));return this._TXTcache.set(tn(e,t),c,{ttl:f}),c}catch{i.signal.aborted&&(o=!0),Kl.error(`${s} could not resolve ${e} record ${t}`)}finally{this._abortControllers=this._abortControllers.filter(a=>a!==i)}}throw o?Object.assign(new Error("queryTxt ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record ${t}`)}clearCache(){this._cache.clear(),this._TXTcache.clear()}},pg=Gl;var Wl=_e(gg(),1);var ls=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Yl=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},yg=r=>globalThis.DOMException===void 0?new Yl(r):new DOMException(r),bg=r=>{let e=r.reason===void 0?yg("This operation was aborted."):r.reason;return e instanceof Error?e:yg(e)};function Zl(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:s={setTimeout,clearTimeout}}=e,i,c=new Promise((f,u)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){let{signal:p}=e;p.aborted&&u(bg(p)),p.addEventListener("abort",()=>{u(bg(p))})}if(t===Number.POSITIVE_INFINITY){r.then(f,u);return}let l=new ls;i=s.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(p){u(p)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?f():o instanceof Error?u(o):(l.message=o??`Promise timed out after ${t} milliseconds`,u(l))},t),(async()=>{try{f(await r)}catch(p){u(p)}})()}).finally(()=>{c.clear()});return c.clear=()=>{s.clearTimeout.call(void 0,i),i=void 0},c}function Jl(r,e,t){let n=0,o=r.length;for(;o>0;){let s=Math.trunc(o/2),i=n+s;t(r[i],e)<=0?(n=++i,o-=s+1):o=s}return n}var fs=class{#e=[];enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&this.#e[this.size-1].priority>=t.priority){this.#e.push(n);return}let o=Jl(this.#e,n,(s,i)=>i.priority-s.priority);this.#e.splice(o,0,n)}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return this.#e.length}};var hs=class extends Wl.default{#e;#t;#s=0;#a;#c;#p=0;#n;#u;#r;#m;#o=0;#l;#i;#g;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:fs,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#t=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#a=e.intervalCap,this.#c=e.interval,this.#r=new e.queueClass,this.#m=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#g=e.throwOnTimeout===!0,this.#i=e.autoStart===!1}get#w(){return this.#t||this.#s<this.#a}get#x(){return this.#o<this.#l}#v(){this.#o--,this.#f(),this.emit("next")}#E(){this.#b(),this.#y(),this.#u=void 0}get#A(){let e=Date.now();if(this.#n===void 0){let t=this.#p-e;if(t<0)this.#s=this.#e?this.#o:0;else return this.#u===void 0&&(this.#u=setTimeout(()=>{this.#E()},t)),!0}return!1}#f(){if(this.#r.size===0)return this.#n&&clearInterval(this.#n),this.#n=void 0,this.emit("empty"),this.#o===0&&this.emit("idle"),!1;if(!this.#i){let e=!this.#A;if(this.#w&&this.#x){let t=this.#r.dequeue();return t?(this.emit("active"),t(),e&&this.#y(),!0):!1}}return!1}#y(){this.#t||this.#n!==void 0||(this.#n=setInterval(()=>{this.#b()},this.#c),this.#p=Date.now()+this.#c)}#b(){this.#s===0&&this.#o===0&&this.#n&&(clearInterval(this.#n),this.#n=void 0),this.#s=this.#e?this.#o:0,this.#h()}#h(){for(;this.#f(););}get concurrency(){return this.#l}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#l=e,this.#h()}async#B(e){return new Promise((t,n)=>{e.addEventListener("abort",()=>{n(e.reason)},{once:!0})})}async add(e,t={}){return t={timeout:this.timeout,throwOnTimeout:this.#g,...t},new Promise((n,o)=>{this.#r.enqueue(async()=>{this.#o++,this.#s++;try{t.signal?.throwIfAborted();let s=e({signal:t.signal});t.timeout&&(s=Zl(Promise.resolve(s),{milliseconds:t.timeout})),t.signal&&(s=Promise.race([s,this.#B(t.signal)]));let i=await s;n(i),this.emit("completed",i)}catch(s){if(s instanceof ls&&!t.throwOnTimeout){n();return}o(s),this.emit("error",s)}finally{this.#v()}},t),this.emit("add"),this.#f()})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return this.#i?(this.#i=!1,this.#h(),this):this}pause(){this.#i=!0}clear(){this.#r=new this.#m}async onEmpty(){this.#r.size!==0&&await this.#d("empty")}async onSizeLessThan(e){this.#r.size<e||await this.#d("next",()=>this.#r.size<e)}async onIdle(){this.#o===0&&this.#r.size===0||await this.#d("idle")}async#d(e,t){return new Promise(n=>{let o=()=>{t&&!t()||(this.off(e,o),n())};this.on(e,o)})}get size(){return this.#r.size}sizeBy(e){return this.#r.filter(e).length}get pending(){return this.#o}get isPaused(){return this.#i}};var vg=_e(xg(),1),la=class{lru;constructor(e){this.lru=(0,vg.default)(e)}get(e){let t=this.lru.get(e);if(t!=null){if(t.expire!=null&&t.expire<Date.now()){this.lru.remove(e);return}return t.value}}set(e,t,n){this.lru.set(e,{value:t,expire:Date.now()+n})}has(e){return this.get(e)!=null}remove(e){this.lru.remove(e)}clear(){this.lru.clear()}};var Xl=new la(1e3),uA=60*1e3,lA=new hs({concurrency:4}),fA=async function(e,t={}){let n=new pg({maxCache:0});if(t.nocache!==!0&&Xl.has(e)){let s=Xl.get(e);if(s!=null)return t?.onProgress?.(new je("dnslink:cache",{detail:s})),s}t.onProgress?.(new je("dnslink:query",{detail:e}));let o=await lA.add(async()=>{let s=await ug(n,e);return t.onProgress?.(new je("dnslink:answer",{detail:s})),Xl.set(e,s,uA),s},{signal:t?.signal});if(o==null)throw new Error("No DNS response received");return o},Eg=fA;function Ag(){return async(r,e={})=>Hl(r,cg,Eg,e)}var ds;(function(r){let e;r.codec=()=>(e==null&&(e=mr((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)=>{let o={key:new Uint8Array(0),value:new Uint8Array(0),timeReceived:""},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let i=t.uint32();switch(i>>>3){case 1:o.key=t.bytes();break;case 2:o.value=t.bytes();break;case 5:o.timeReceived=t.string();break;default:t.skipType(i&7);break}}return o})),e),r.encode=t=>pr(t,r.codec()),r.decode=t=>dr(t,r.codec())})(ds||(ds={}));function Bg(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"),s=String(r.getUTCMinutes()).padStart(2,"0"),i=String(r.getUTCSeconds()).padStart(2,"0"),a=r.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${e}-${t}-${n}T${o}:${s}:${i}.${c}Z`}function Sg(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,s=parseInt(t[3],10),i=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,s,i,a,c,f))}var oo=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 ds.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:Bg(this.timeReceived)}}static deserialize(e){let t=ds.decode(e);return new r(t.key,t.value,new Date(t.timeReceived))}static fromDeserialized(e){let t=Sg(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 Ig;(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"})(Ig||(Ig={}));var Cg;(function(r){r[r.PUT_VALUE=0]="PUT_VALUE",r[r.GET_VALUE=1]="GET_VALUE",r[r.ADD_PROVIDER=2]="ADD_PROVIDER",r[r.GET_PROVIDERS=3]="GET_PROVIDERS",r[r.FIND_NODE=4]="FIND_NODE",r[r.PING=5]="PING"})(Cg||(Cg={}));function Ql(r){return new Nn("/dht/record/"+ue(r,"base32"),!1)}function Tg(r){return{async put(e,t,n={}){try{let o=Ql(e),s=new oo(e,t,new Date);n.onProgress?.(new je("ipns:routing:datastore:put")),await r.put(o,s.serialize(),n)}catch(o){throw n.onProgress?.(new je("ipns:routing:datastore:error",o)),o}},async get(e,t={}){try{let n=Ql(e);t.onProgress?.(new je("ipns:routing:datastore:get"));let o=await r.get(n,t);return oo.deserialize(o).value}catch(n){throw t.onProgress?.(new je("ipns:routing:datastore:error",n)),n}},async has(e,t={}){let n=Ql(e);return r.has(n,t)}}}var fa=ir("helia:ipns"),dA=60*1e3,kg=60*dA,pA=24*kg,ef=23*kg,tf=class{routers;localStore;timeout;defaultResolvers;constructor(e,t=[],n=[]){this.routers=t,this.localStore=Tg(e.datastore),this.defaultResolvers=n.length>0?n:[Ag()]}async publish(e,t,n={}){try{let o=1n,s=Mi(e);if(await this.localStore.has(s,n)){let c=await this.localStore.get(s,n);o=Jt(c).sequence+1n}let i=await Xp(e,t,o,n.lifetime??pA,n),a=jc(i);return await this.localStore.put(s,a,n),n.offline!==!0&&await Promise.all(this.routers.map(async c=>{await c.put(s,a,n)})),i}catch(o){throw n.onProgress?.(new je("ipns:publish:error",o)),o}}async resolve(e,t={}){let n=Mi(e),o=await this.#t(n,t);return this.#e(o.value,t)}async resolveDns(e,t={}){let n=t.resolvers??this.defaultResolvers,o=await Promise.any(n.map(async s=>s(e,t)));return this.#e(o,t)}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 je("ipns:republish:start"));let s=Date.now()-n,i=ef-s;i<0&&(i=e.interval??ef),setTimeout(()=>{t().catch(a=>{fa.error("error republishing",a)})},i)}this.timeout=setTimeout(()=>{t().catch(n=>{fa.error("error republishing",n)})},e.interval??ef)}async#e(e,t={}){let n=e.split("/");if(n.length===3){let o=n[1];if(o==="ipns")return this.resolve(Pa(n[2]),t);if(o==="ipfs")return Xe.parse(n[2])}throw fa.error("invalid ipfs path %s",e),new Error("Invalid value")}async#t(e,t={}){let n=[this.localStore,...this.routers];t.offline===!0&&(n=[this.localStore]);let o=[];if(await Promise.all(n.map(async i=>{try{let a=await i.get(e,t);await Zc(e,a),o.push(a)}catch(a){fa.error("error finding IPNS record",a)}})),o.length===0)throw new q("Could not find record for routing key","ERR_NOT_FOUND");let s=o[Fi(e,o)];return await this.localStore.put(e,s,t),Jt(s)}};function mA(r,{routers:e=[],resolvers:t=[]}){return new tf(r,e,t)}return Kg(gA);})();
7
+ `)}`:`${t} :`}};Rh=yr;_.Constructed=Rh;yr.NAME="CONSTRUCTED";var js=class extends Ve{fromBER(e,t,n){return t}toBER(e){return gt}};js.override="EndOfContentValueBlock";var Nh,Ws=class extends ke{constructor(e={}){super(e,js),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Nh=Ws;_.EndOfContent=Nh;Ws.NAME=Ao;var Uh,br=class extends ke{constructor(e={}){super(e,Ve),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}`}};Uh=br;_.Null=Uh;br.NAME="NULL";var Ys=class extends Gt(Ve){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=Z.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){let o=Z.BufferSourceConverter.toUint8Array(e);return qt(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,wc.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Ys.NAME="BooleanValueBlock";var _h,Zs=class extends ke{constructor(e={}){super(e,Ys),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}`}};_h=Zs;_.Boolean=_h;Zs.NAME="BOOLEAN";var Js=class extends Gt(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 s=0;s<this.value.length;s++){let i=this.value[s].constructor.NAME;if(i===Ao){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(i!==Ih)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}}};Js.NAME="OctetStringValueBlock";var Dh,Kt=class r extends ke{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,s;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Js),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 s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(s.byteLength){let i=Si(s,0,s.byteLength);i.offset!==-1&&i.offset===n&&(this.valueBlock.value=[i.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?yr.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${Z.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let t of this.valueBlock.value)t instanceof r&&e.push(t.valueBlock.valueHexView);return Z.BufferSourceConverter.concat(e)}};Dh=Kt;_.OctetString=Dh;Kt.NAME=Ih;var Xs=class extends Gt(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===Ao){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Ch)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 s=Z.BufferSourceConverter.toUint8Array(e);if(!qt(this,s,t,n))return-1;let i=s.subarray(t,t+n);if(this.unusedBits=i[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=i.subarray(1);try{if(a.byteLength){let c=Si(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=i.subarray(1),this.blockLength=i.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 gt;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}}};Xs.NAME="BitStringValueBlock";var Lh,Cn=class extends ke{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,s;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Xs),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 yr.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)}`}}};Lh=Cn;_.BitString=Lh;Cn.NAME=Ch;var Oh;function $w(r,e){let t=new Uint8Array([0]),n=new Uint8Array(r),o=new Uint8Array(e),s=n.slice(0),i=s.length-1,a=o.slice(0),c=a.length-1,f=0,u=c<i?i:c,l=0;for(let p=u;p>=0;p--,l++){switch(!0){case l<a.length:f=s[i-l]+a[c-l]+t[0];break;default:f=s[i-l]+t[0]}switch(t[0]=f/10,!0){case l>=s.length:s=Fs(new Uint8Array([f%10]),s);break;default:s[i-l]=f%10}}return t[0]>0&&(s=Fs(t,s)),s}function Sh(r){if(r>=vo.length)for(let e=vo.length;e<=r;e++){let t=new Uint8Array([0]),n=vo[e-1].slice(0);for(let o=n.length-1;o>=0;o--){let s=new Uint8Array([(n[o]<<1)+t[0]]);t[0]=s[0]/10,n[o]=s[0]%10}t[0]>0&&(n=Fs(t,n)),vo.push(n)}return vo[r]}function Hw(r,e){let t=0,n=new Uint8Array(r),o=new Uint8Array(e),s=n.slice(0),i=s.length-1,a=o.slice(0),c=a.length-1,f,u=0;for(let l=c;l>=0;l--,u++)switch(f=s[i-u]-a[c-u]-t,!0){case f<0:t=1,s[i-u]=f+10;break;default:t=0,s[i-u]=f}if(t>0)for(let l=i-c+1;l>=0;l--,u++)if(f=s[i-u]-t,f<0)t=1,s[i-u]=f+10;else{t=0,s[i-u]=f;break}return s.slice()}var Bo=class extends Gt(Ve){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=wc.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Eh(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,o=0){let s=this.fromBER(e,t,n);if(s===-1)return s;let i=this.valueHexView;return i[0]===0&&i[1]&128?this.valueHexView=i.subarray(1):o!==0&&i.length<o&&(o-i.length>1&&(o=i.length+1),this.valueHexView=i.subarray(o-i.length)),s}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,s=this.valueHexView,i="",a=!1;for(let c=s.byteLength-1;c>=0;c--){o=s[c];for(let f=0;f<8;f++){if((o&1)===1)switch(n){case e:t=Hw(Sh(n),t),i="-";break;default:t=$w(t,Sh(n))}n++,o>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(i+=Bh.charAt(t[c]));return a===!1&&(i+=Bh.charAt(0)),i}};Oh=Bo;Bo.NAME="IntegerValueBlock";Object.defineProperty(Oh.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Vh,be=class r extends ke{constructor(e={}){super(e,Bo),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return $s(),BigInt(this.valueBlock.toString())}static fromBigInt(e){$s();let t=BigInt(e),n=new Eo,o=t.toString(16).replace(/^-/,""),s=new Uint8Array(Z.Convert.FromHex(o));if(t<0){let a=new Uint8Array(s.length+(s[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${Z.Convert.ToHex(a)}`)+t,u=Z.BufferSourceConverter.toUint8Array(Z.Convert.FromHex(f.toString(16)));u[0]|=128,n.write(u)}else s[0]&128&&n.write(new Uint8Array([0])),n.write(s);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()}`}};Vh=be;_.Integer=Vh;be.NAME="INTEGER";var Ph,Qs=class extends be{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Ph=Qs;_.Enumerated=Ph;Qs.NAME="ENUMERATED";var So=class extends Gt(Ve){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;let o=Z.BufferSourceConverter.toUint8Array(e);if(!qt(this,o,t,n))return-1;let s=o.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=s[a]&127,this.blockLength++,!!(s[a]&128));a++);let i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)i[a]=this.valueHexView[a];return this.valueHexView=i,s[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=zr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){$s();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,s=new Uint8Array(this.blockLength);for(let i=0;i<this.blockLength-1;i++)s[i]=o[i]|128;return s[this.blockLength-1]=o[this.blockLength-1],s.buffer}let t=gr(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",gt;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),s=t.byteLength-1;for(let i=0;i<s;i++)n[i]=o[i]|128;n[s]=o[s]}return n}toString(){let e="";if(this.isHexOnly)e=Z.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};So.NAME="sidBlock";var ei=class extends Ve{constructor({value:e=Tn,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let s=new So;if(o=s.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=s.error,o;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}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,gt;t.push(o)}return xc(t)}fromString(e){this.value=[];let t=0,n=0,o="",s=!1;do if(n=e.indexOf(".",t),n===-1?o=e.substring(t):o=e.substring(t,n),t=n+1,s){let i=this.value[0],a=0;switch(i.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;i.valueDec=c+a,s=!1}else{let i=new So;if(o>Number.MAX_SAFE_INTEGER){$s();let a=BigInt(o);i.valueBigInt=a}else if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return;this.value.length||(i.isFirstSid=!0,s=!0),this.value.push(i)}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}};ei.NAME="ObjectIdentifierValueBlock";var Mh,mt=class extends ke{constructor(e={}){super(e,ei),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()}}};Mh=mt;_.ObjectIdentifier=Mh;mt.NAME="OBJECT IDENTIFIER";var Io=class extends Gt(Ht){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let o=Z.BufferSourceConverter.toUint8Array(e);if(!qt(this,o,t,n))return-1;let s=o.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=s[a]&127,this.blockLength++,!!(s[a]&128));a++);let i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)i[a]=this.valueHexView[a];return this.valueHexView=i,s[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=zr(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,s=new Uint8Array(this.blockLength);for(let i=0;i<this.blockLength-1;i++)s[i]=o[i]|128;return s[this.blockLength-1]=o[this.blockLength-1],s.buffer}let t=gr(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",gt;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),s=t.byteLength-1;for(let i=0;i<s;i++)n[i]=o[i]|128;n[s]=o[s]}return n.buffer}toString(){let e="";return this.isHexOnly?e=Z.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};Io.NAME="relativeSidBlock";var ti=class extends Ve{constructor({value:e=Tn,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let s=new Io;if(o=s.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=s.error,o;this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return o}toBER(e,t){let n=[];for(let o=0;o<this.value.length;o++){let s=this.value[o].toBER(e);if(s.byteLength===0)return this.error=this.value[o].error,gt;n.push(s)}return xc(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 s=new Io;if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return!0;this.value.push(s)}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}};ti.NAME="RelativeObjectIdentifierValueBlock";var Fh,ri=class extends ke{constructor(e={}){super(e,ti),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()}}};Fh=ri;_.RelativeObjectIdentifier=Fh;ri.NAME="RelativeObjectIdentifier";var $h,ve=class extends yr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};$h=ve;_.Sequence=$h;ve.NAME="SEQUENCE";var Hh,ni=class extends yr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Hh=ni;_.Set=Hh;ni.NAME="SET";var oi=class extends Gt(Ve){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Tn}toJSON(){return{...super.toJSON(),value:this.value}}};oi.NAME="StringValueBlock";var si=class extends oi{};si.NAME="SimpleStringValueBlock";var $e=class extends zs{constructor({...e}={}){super(e,si)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,Z.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);this.valueBlock.value=e}};$e.NAME="SIMPLE STRING";var ii=class extends $e{fromBuffer(e){this.valueBlock.valueHexView=Z.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=Z.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=Z.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(Z.Convert.FromUtf8String(e)),this.valueBlock.value=e}};ii.NAME="Utf8StringValueBlock";var Kh,zt=class extends ii{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Kh=zt;_.Utf8String=Kh;zt.NAME="UTF8String";var ai=class extends $e{fromBuffer(e){this.valueBlock.value=Z.Convert.ToUtf16String(e),this.valueBlock.valueHexView=Z.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(Z.Convert.FromUtf16String(e))}};ai.NAME="BmpStringValueBlock";var zh,ci=class extends ai{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};zh=ci;_.BmpString=zh;ci.NAME="BMPString";var ui=class extends $e{fromBuffer(e){let t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let o=0;o<n.length;o+=4)n[o]=n[o+3],n[o+1]=n[o+2],n[o+2]=0,n[o+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let o=0;o<t;o++){let s=gr(e.charCodeAt(o),8),i=new Uint8Array(s);if(i.length>4)continue;let a=4-i.length;for(let c=i.length-1;c>=0;c--)n[o*4+c+a]=i[c]}this.valueBlock.value=e}};ui.NAME="UniversalStringValueBlock";var qh,li=class extends ui{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};qh=li;_.UniversalString=qh;li.NAME="UniversalString";var Gh,fi=class extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Gh=fi;_.NumericString=Gh;fi.NAME="NumericString";var jh,hi=class extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};jh=hi;_.PrintableString=jh;hi.NAME="PrintableString";var Wh,di=class extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Wh=di;_.TeletexString=Wh;di.NAME="TeletexString";var Yh,pi=class extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Yh=pi;_.VideotexString=Yh;pi.NAME="VideotexString";var Zh,mi=class extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Zh=mi;_.IA5String=Zh;mi.NAME="IA5String";var Jh,gi=class extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Jh=gi;_.GraphicString=Jh;gi.NAME="GraphicString";var Xh,Co=class extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Xh=Co;_.VisibleString=Xh;Co.NAME="VisibleString";var Qh,yi=class extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};Qh=yi;_.GeneralString=Qh;yi.NAME="GeneralString";var ed,bi=class extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};ed=bi;_.CharacterString=ed;bi.NAME="CharacterString";var td,To=class extends Co{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let o=0;o<e.length;o++)this.valueBlock.valueHexView[o]=e.charCodeAt(o)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,Z.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}let o=parseInt(n[1],10);o>=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){let t=new Array(7);return t[0]=Ge(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Ge(this.month,2),t[2]=Ge(this.day,2),t[3]=Ge(this.hour,2),t[4]=Ge(this.minute,2),t[5]=Ge(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}}};td=To;_.UTCTime=td;To.NAME="UTCTime";var rd,wi=class extends To{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="",s=0,i,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,p=n.indexOf("+"),x="";if(p===-1&&(p=n.indexOf("-"),l=-1),p!==-1){if(x=n.substring(p+1),n=n.substring(0,p),x.length!==2&&x.length!==4)throw new Error("Wrong input string for conversion");let d=parseInt(x.substring(0,2),10);if(isNaN(d.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*d,x.length===4){if(d=parseInt(x.substring(2,4),10),isNaN(d.valueOf()))throw new Error("Wrong input string for conversion");c=l*d}}}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");s=l.valueOf(),o=n.substring(0,f)}else o=n;switch(!0){case o.length===8:if(i=/(\d{4})(\d{2})(\d{2})/ig,f!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*s;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(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*s;this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===14:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=1e3*s;this.millisecond=Math.floor(l)}break;default:throw new Error("Wrong input string for conversion")}let u=i.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(Ge(this.year,4)),t.push(Ge(this.month,2)),t.push(Ge(this.day,2)),t.push(Ge(this.hour,2)),t.push(Ge(this.minute,2)),t.push(Ge(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Ge(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};rd=wi;_.GeneralizedTime=rd;wi.NAME="GeneralizedTime";var nd,xi=class extends zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};nd=xi;_.DATE=nd;xi.NAME="DATE";var od,vi=class extends zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};od=vi;_.TimeOfDay=od;vi.NAME="TimeOfDay";var sd,Ei=class extends zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};sd=Ei;_.DateTime=sd;Ei.NAME="DateTime";var id,Ai=class extends zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};id=Ai;_.Duration=id;Ai.NAME="Duration";var ad,Bi=class extends zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};ad=Bi;_.TIME=ad;Bi.NAME="TIME";function zw(r){let{result:e}=kn(r),t=e.valueBlock.value;return{n:ue(It(t[1].toBigInt()),"base64url"),e:ue(It(t[2].toBigInt()),"base64url"),d:ue(It(t[3].toBigInt()),"base64url"),p:ue(It(t[4].toBigInt()),"base64url"),q:ue(It(t[5].toBigInt()),"base64url"),dp:ue(It(t[6].toBigInt()),"base64url"),dq:ue(It(t[7].toBigInt()),"base64url"),qi:ue(It(t[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function qw(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 K("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new ve({value:[new be({value:0}),be.fromBigInt(Ct(ee(r.n,"base64url"))),be.fromBigInt(Ct(ee(r.e,"base64url"))),be.fromBigInt(Ct(ee(r.d,"base64url"))),be.fromBigInt(Ct(ee(r.p,"base64url"))),be.fromBigInt(Ct(ee(r.q,"base64url"))),be.fromBigInt(Ct(ee(r.dp,"base64url"))),be.fromBigInt(Ct(ee(r.dq,"base64url"))),be.fromBigInt(Ct(ee(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function Gw(r){let{result:e}=kn(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:ue(It(t[0].toBigInt()),"base64url"),e:ue(It(t[1].toBigInt()),"base64url")}}function jw(r){if(r.n==null||r.e==null)throw new K("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new ve({value:[new ve({value:[new mt({value:"1.2.840.113549.1.1.1"}),new br]}),new Cn({valueHex:new ve({value:[be.fromBigInt(Ct(ee(r.n,"base64url"))),be.fromBigInt(Ct(ee(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function It(r){let e=r.toString(16);e.length%2>0&&(e=`0${e}`);let t=e.length/2,n=new Uint8Array(t),o=0,s=0;for(;o<t;)n[o]=parseInt(e.slice(s,s+2),16),o+=1,s+=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 Ww=16,Ec=32,Ac=1e4;async function Yw(r,e){let t=Fe.get(),o=new ve({value:[new be({value:0}),new ve({value:[new mt({value:"1.2.840.113549.1.1.1"}),new br]}),new Kt({valueHex:r.marshal()})]}).toBER(),s=new Uint8Array(o,0,o.byteLength),i=Kr(Ww),a=await yc(xn,e,i,{c:Ac,dkLen:Ec}),c=Kr(16),f=await t.subtle.importKey("raw",a,"AES-CBC",!1,["encrypt"]),u=await t.subtle.encrypt({name:"AES-CBC",iv:c},f,s),l=new ve({value:[new Kt({valueHex:i}),new be({value:Ac}),new be({value:Ec}),new ve({value:[new mt({value:"1.2.840.113549.2.11"}),new br]})]}),p=new ve({value:[new mt({value:"1.2.840.113549.1.5.13"}),new ve({value:[new ve({value:[new mt({value:"1.2.840.113549.1.5.12"}),l]}),new ve({value:[new mt({value:"2.16.840.1.101.3.4.1.42"}),new Kt({valueHex:c})]})]})]}),d=new ve({value:[p,new Kt({valueHex:u})]}).toBER(),h=new Uint8Array(d,0,d.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...ue(h,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
8
+ `)}async function Zw(r,e){let t=Fe.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let o=ee(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:s}=kn(o),{iv:i,salt:a,iterations:c,keySize:f,cipherText:u}=Jw(s),l=await yc(xn,e,a,{c,dkLen:f}),p=await t.subtle.importKey("raw",l,"AES-CBC",!1,["decrypt"]),x=ko(await t.subtle.decrypt({name:"AES-CBC",iv:i},p,u)),{result:d}=kn(x);n=cd(d)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let o=ee(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:s}=kn(o);n=cd(s)}else throw new K("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return Bc(n)}function Jw(r){let e=r.valueBlock.value[0];if(e.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.13")throw new K("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 K("Only pkcs5PBKDF2 key derivation functions are supported","ERR_INVALID_PARAMS");let s=n.valueBlock.value[1],i=ko(s.valueBlock.value[0].getValue()),a=Ac,c=Ec;if(s.valueBlock.value.length===3)a=Number(s.valueBlock.value[1].toBigInt()),c=Number(s.valueBlock.value[2].toBigInt());else if(s.valueBlock.value.length===2)throw new K("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 K("Only AES-CBC encryption schemes are supported","ERR_INVALID_PARAMS")}}}}let l=ko(f.valueBlock.value[1].getValue());return{cipherText:ko(r.valueBlock.value[1].getValue()),salt:i,iterations:a,keySize:c,iv:l}}function cd(r){return ko(r.valueBlock.value[2].getValue())}function ko(r){return new Uint8Array(r,0,r.byteLength)}async function ud(r){let e=await Fe.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 hd(e);return{privateKey:t[0],publicKey:t[1]}}async function Sc(r){let t=[await Fe.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await Xw(r)],n=await hd({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function ld(r,e){let t=await Fe.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Fe.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function fd(r,e,t){let n=await Fe.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Fe.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function hd(r){if(r.privateKey==null||r.publicKey==null)throw new K("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([Fe.get().subtle.exportKey("jwk",r.privateKey),Fe.get().subtle.exportKey("jwk",r.publicKey)])}async function Xw(r){return Fe.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 Ii(r){if(r.kty!=="RSA")throw new K("invalid key type","ERR_INVALID_KEY_TYPE");if(r.n==null)throw new K("invalid key modulus","ERR_INVALID_KEY_MODULUS");return ee(r.n,"base64url").length*8}var No=8192,Ro=class{_key;constructor(e){this._key=e}verify(e,t){return fd(this._key,t,e)}marshal(){return wr.jwkToPkix(this._key)}get bytes(){return At.encode({Type:ce.RSA,Data:this.marshal()}).subarray()}equals(e){return Te(this.bytes,e.bytes)}hash(){let e=Ce.digest(this.bytes);return ot(e)?e.then(({bytes:t})=>t):e.bytes}},Rn=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return Kr(16)}sign(e){return ld(this._key,e)}get public(){if(this._publicKey==null)throw new K("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new Ro(this._publicKey)}marshal(){return wr.jwkToPkcs1(this._key)}get bytes(){return Bt.encode({Type:ce.RSA,Data:this.marshal()}).subarray()}equals(e){return Te(this.bytes,e.bytes)}hash(){let e=Ce.digest(this.bytes);return ot(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return ue(e,"base58btc")}async export(e,t="pkcs-8"){if(t==="pkcs-8")return wr.exportToPem(this,e);if(t==="libp2p-key")return An(this.bytes,e);throw new K(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function Bc(r){let e=wr.pkcs1ToJwk(r);if(Ii(e)>No)throw new K("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await Sc(e);return new Rn(t.privateKey,t.publicKey)}function ex(r){let e=wr.pkixToJwk(r);if(Ii(e)>No)throw new K("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new Ro(e)}async function tx(r){if(Ii(r)>No)throw new K("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await Sc(r);return new Rn(e.privateKey,e.publicKey)}async function rx(r){if(r>No)throw new K("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await ud(r);return new Rn(e.privateKey,e.publicKey)}var Nc={};M(Nc,{Secp256k1PrivateKey:()=>_o,Secp256k1PublicKey:()=>Uo,generateKeyPair:()=>yx,unmarshalSecp256k1PrivateKey:()=>mx,unmarshalSecp256k1PublicKey:()=>gx});var nx=(r,e,t)=>r&e^~r&t,ox=(r,e,t)=>r&e^r&t^e&t,sx=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]),xr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),vr=new Uint32Array(64),Cc=class extends wn{constructor(){super(64,32,8,!1),this.A=xr[0]|0,this.B=xr[1]|0,this.C=xr[2]|0,this.D=xr[3]|0,this.E=xr[4]|0,this.F=xr[5]|0,this.G=xr[6]|0,this.H=xr[7]|0}get(){let{A:e,B:t,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[e,t,n,o,s,i,a,c]}set(e,t,n,o,s,i,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(e,t){for(let l=0;l<16;l++,t+=4)vr[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let p=vr[l-15],x=vr[l-2],d=ft(p,7)^ft(p,18)^p>>>3,h=ft(x,17)^ft(x,19)^x>>>10;vr[l]=h+vr[l-7]+d+vr[l-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let p=ft(a,6)^ft(a,11)^ft(a,25),x=u+p+nx(a,c,f)+sx[l]+vr[l]|0,h=(ft(n,2)^ft(n,13)^ft(n,22))+ox(n,o,s)|0;u=f,f=c,c=a,a=i+x|0,i=s,s=o,o=n,n=x+h|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+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,s,i,a,c,f,u)}roundClean(){vr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var dd=Bs(()=>new Cc);function ix(r){let e=po(r);Et(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:ax,hexToBytes:cx}=Cs,qr={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){let{Err:e}=qr;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:ax(n),l:r.subarray(t+2)}},toSig(r){let{Err:e}=qr,t=typeof r=="string"?cx(r):r;if(!ht(t))throw new Error("ui8a expected");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:s}=qr._parseInt(t.subarray(2)),{d:i,l:a}=qr._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:o,s:i}},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)),s=n.length/2,i=o.length/2,a=t(s),c=t(i);return`30${t(i+s+4)}02${c}${o}02${a}${n}`}},jt=BigInt(0),it=BigInt(1),ZS=BigInt(2),pd=BigInt(3),JS=BigInt(4);function ux(r){let e=ix(r),{Fp:t}=e,n=e.toBytes||((d,h,m)=>{let g=h.toAffine();return Pt(Uint8Array.from([4]),t.toBytes(g.x),t.toBytes(g.y))}),o=e.fromBytes||(d=>{let h=d.subarray(1),m=t.fromBytes(h.subarray(0,t.BYTES)),g=t.fromBytes(h.subarray(t.BYTES,2*t.BYTES));return{x:m,y:g}});function s(d){let{a:h,b:m}=e,g=t.sqr(d),A=t.mul(g,d);return t.add(t.add(A,t.mul(d,h)),m)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function i(d){return typeof d=="bigint"&&jt<d&&d<e.n}function a(d){if(!i(d))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(d){let{allowedPrivateKeyLengths:h,nByteLength:m,wrapPrivateKey:g,n:A}=e;if(h&&typeof d!="bigint"){if(ht(d)&&(d=Ot(d)),typeof d!="string"||!h.includes(d.length))throw new Error("Invalid key");d=d.padStart(m*2,"0")}let b;try{b=typeof d=="bigint"?d:Vt(de("private key",d,m))}catch{throw new Error(`private key must be ${m} bytes, hex or bigint, not ${typeof d}`)}return g&&(b=oe(b,A)),a(b),b}let f=new Map;function u(d){if(!(d instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(h,m,g){if(this.px=h,this.py=m,this.pz=g,h==null||!t.isValid(h))throw new Error("x required");if(m==null||!t.isValid(m))throw new Error("y required");if(g==null||!t.isValid(g))throw new Error("z required")}static fromAffine(h){let{x:m,y:g}=h||{};if(!h||!t.isValid(m)||!t.isValid(g))throw new Error("invalid affine point");if(h instanceof l)throw new Error("projective point not allowed");let A=b=>t.eql(b,t.ZERO);return A(m)&&A(g)?l.ZERO:new l(m,g,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let m=t.invertBatch(h.map(g=>g.pz));return h.map((g,A)=>g.toAffine(m[A])).map(l.fromAffine)}static fromHex(h){let m=l.fromAffine(o(de("pointHex",h)));return m.assertValidity(),m}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:m}=this.toAffine();if(!t.isValid(h)||!t.isValid(m))throw new Error("bad point: x or y not FE");let g=t.sqr(m),A=s(h);if(!t.eql(g,A))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:m,py:g,pz:A}=this,{px:b,py:S,pz:v}=h,I=t.eql(t.mul(m,v),t.mul(b,A)),C=t.eql(t.mul(g,v),t.mul(S,A));return I&&C}negate(){return new l(this.px,t.neg(this.py),this.pz)}double(){let{a:h,b:m}=e,g=t.mul(m,pd),{px:A,py:b,pz:S}=this,v=t.ZERO,I=t.ZERO,C=t.ZERO,y=t.mul(A,A),k=t.mul(b,b),O=t.mul(S,S),U=t.mul(A,b);return U=t.add(U,U),C=t.mul(A,S),C=t.add(C,C),v=t.mul(h,C),I=t.mul(g,O),I=t.add(v,I),v=t.sub(k,I),I=t.add(k,I),I=t.mul(v,I),v=t.mul(U,v),C=t.mul(g,C),O=t.mul(h,O),U=t.sub(y,O),U=t.mul(h,U),U=t.add(U,C),C=t.add(y,y),y=t.add(C,y),y=t.add(y,O),y=t.mul(y,U),I=t.add(I,y),O=t.mul(b,S),O=t.add(O,O),y=t.mul(O,U),v=t.sub(v,y),C=t.mul(O,k),C=t.add(C,C),C=t.add(C,C),new l(v,I,C)}add(h){u(h);let{px:m,py:g,pz:A}=this,{px:b,py:S,pz:v}=h,I=t.ZERO,C=t.ZERO,y=t.ZERO,k=e.a,O=t.mul(e.b,pd),U=t.mul(m,b),V=t.mul(g,S),H=t.mul(A,v),X=t.add(m,g),B=t.add(b,S);X=t.mul(X,B),B=t.add(U,V),X=t.sub(X,B),B=t.add(m,A);let R=t.add(b,v);return B=t.mul(B,R),R=t.add(U,H),B=t.sub(B,R),R=t.add(g,A),I=t.add(S,v),R=t.mul(R,I),I=t.add(V,H),R=t.sub(R,I),y=t.mul(k,B),I=t.mul(O,H),y=t.add(I,y),I=t.sub(V,y),y=t.add(V,y),C=t.mul(I,y),V=t.add(U,U),V=t.add(V,U),H=t.mul(k,H),B=t.mul(O,B),V=t.add(V,H),H=t.sub(U,H),H=t.mul(k,H),B=t.add(B,H),U=t.mul(V,B),C=t.add(C,U),U=t.mul(R,B),I=t.mul(X,I),I=t.sub(I,U),U=t.mul(X,V),y=t.mul(R,y),y=t.add(y,U),new l(I,C,y)}subtract(h){return this.add(h.negate())}is0(){return this.equals(l.ZERO)}wNAF(h){return x.wNAFCached(this,f,h,m=>{let g=t.invertBatch(m.map(A=>A.pz));return m.map((A,b)=>A.toAffine(g[b])).map(l.fromAffine)})}multiplyUnsafe(h){let m=l.ZERO;if(h===jt)return m;if(a(h),h===it)return this;let{endo:g}=e;if(!g)return x.unsafeLadder(this,h);let{k1neg:A,k1:b,k2neg:S,k2:v}=g.splitScalar(h),I=m,C=m,y=this;for(;b>jt||v>jt;)b&it&&(I=I.add(y)),v&it&&(C=C.add(y)),y=y.double(),b>>=it,v>>=it;return A&&(I=I.negate()),S&&(C=C.negate()),C=new l(t.mul(C.px,g.beta),C.py,C.pz),I.add(C)}multiply(h){a(h);let m=h,g,A,{endo:b}=e;if(b){let{k1neg:S,k1:v,k2neg:I,k2:C}=b.splitScalar(m),{p:y,f:k}=this.wNAF(v),{p:O,f:U}=this.wNAF(C);y=x.constTimeNegate(S,y),O=x.constTimeNegate(I,O),O=new l(t.mul(O.px,b.beta),O.py,O.pz),g=y.add(O),A=k.add(U)}else{let{p:S,f:v}=this.wNAF(m);g=S,A=v}return l.normalizeZ([g,A])[0]}multiplyAndAddUnsafe(h,m,g){let A=l.BASE,b=(v,I)=>I===jt||I===it||!v.equals(A)?v.multiplyUnsafe(I):v.multiply(I),S=b(this,m).add(b(h,g));return S.is0()?void 0:S}toAffine(h){let{px:m,py:g,pz:A}=this,b=this.is0();h==null&&(h=b?t.ONE:t.inv(A));let S=t.mul(m,h),v=t.mul(g,h),I=t.mul(A,h);if(b)return{x:t.ZERO,y:t.ZERO};if(!t.eql(I,t.ONE))throw new Error("invZ was invalid");return{x:S,y:v}}isTorsionFree(){let{h,isTorsionFree:m}=e;if(h===it)return!0;if(m)return m(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:m}=e;return h===it?this:m?m(l,this):this.multiplyUnsafe(e.h)}toRawBytes(h=!0){return this.assertValidity(),n(l,this,h)}toHex(h=!0){return Ot(this.toRawBytes(h))}}l.BASE=new l(e.Gx,e.Gy,t.ONE),l.ZERO=new l(t.ZERO,t.ONE,t.ZERO);let p=e.nBitLength,x=Rs(l,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:i}}function lx(r){let e=po(r);return Et(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function md(r){let e=lx(r),{Fp:t,n}=e,o=t.BYTES+1,s=2*t.BYTES+1;function i(B){return jt<B&&B<t.ORDER}function a(B){return oe(B,n)}function c(B){return Ts(B,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:p}=ux({...e,toBytes(B,R,$){let T=R.toAffine(),E=t.toBytes(T.x),L=Pt;return $?L(Uint8Array.from([R.hasEvenY()?2:3]),E):L(Uint8Array.from([4]),E,t.toBytes(T.y))},fromBytes(B){let R=B.length,$=B[0],T=B.subarray(1);if(R===o&&($===2||$===3)){let E=Vt(T);if(!i(E))throw new Error("Point is not on curve");let L=l(E),F=t.sqrt(L),q=(F&it)===it;return($&1)===1!==q&&(F=t.neg(F)),{x:E,y:F}}else if(R===s&&$===4){let E=t.fromBytes(T.subarray(0,t.BYTES)),L=t.fromBytes(T.subarray(t.BYTES,2*t.BYTES));return{x:E,y:L}}else throw new Error(`Point of length ${R} was invalid. Expected ${o} compressed bytes or ${s} uncompressed bytes`)}}),x=B=>Ot(fr(B,e.nByteLength));function d(B){let R=n>>it;return B>R}function h(B){return d(B)?a(-B):B}let m=(B,R,$)=>Vt(B.slice(R,$));class g{constructor(R,$,T){this.r=R,this.s=$,this.recovery=T,this.assertValidity()}static fromCompact(R){let $=e.nByteLength;return R=de("compactSignature",R,$*2),new g(m(R,0,$),m(R,$,2*$))}static fromDER(R){let{r:$,s:T}=qr.toSig(de("DER",R));return new g($,T)}assertValidity(){if(!p(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!p(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(R){return new g(this.r,this.s,R)}recoverPublicKey(R){let{r:$,s:T,recovery:E}=this,L=C(de("msgHash",R));if(E==null||![0,1,2,3].includes(E))throw new Error("recovery id invalid");let F=E===2||E===3?$+e.n:$;if(F>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let q=E&1?"03":"02",W=f.fromHex(q+x(F)),Y=c(F),ne=a(-L*Y),J=a(T*Y),Q=f.BASE.multiplyAndAddUnsafe(W,ne,J);if(!Q)throw new Error("point at infinify");return Q.assertValidity(),Q}hasHighS(){return d(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Vr(this.toDERHex())}toDERHex(){return qr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Vr(this.toCompactHex())}toCompactHex(){return x(this.r)+x(this.s)}}let A={isValidPrivateKey(B){try{return u(B),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let B=Xa(e.n);return th(e.randomBytes(B),e.n)},precompute(B=8,R=f.BASE){return R._setWindowSize(B),R.multiply(BigInt(3)),R}};function b(B,R=!0){return f.fromPrivateKey(B).toRawBytes(R)}function S(B){let R=ht(B),$=typeof B=="string",T=(R||$)&&B.length;return R?T===o||T===s:$?T===2*o||T===2*s:B instanceof f}function v(B,R,$=!0){if(S(B))throw new Error("first arg must be private key");if(!S(R))throw new Error("second arg must be public key");return f.fromHex(R).multiply(u(B)).toRawBytes($)}let I=e.bits2int||function(B){let R=Vt(B),$=B.length*8-e.nBitLength;return $>0?R>>BigInt($):R},C=e.bits2int_modN||function(B){return a(I(B))},y=ho(e.nBitLength);function k(B){if(typeof B!="bigint")throw new Error("bigint expected");if(!(jt<=B&&B<y))throw new Error(`bigint expected < 2^${e.nBitLength}`);return fr(B,e.nByteLength)}function O(B,R,$=U){if(["recovered","canonical"].some(fe=>fe in $))throw new Error("sign() legacy options not supported");let{hash:T,randomBytes:E}=e,{lowS:L,prehash:F,extraEntropy:q}=$;L==null&&(L=!0),B=de("msgHash",B),F&&(B=de("prehashed msgHash",T(B)));let W=C(B),Y=u(R),ne=[k(Y),k(W)];if(q!=null){let fe=q===!0?E(t.BYTES):q;ne.push(de("extraEntropy",fe))}let J=Pt(...ne),Q=W;function ye(fe){let Ae=I(fe);if(!p(Ae))return;let Be=c(Ae),we=f.BASE.multiply(Ae).toAffine(),De=a(we.x);if(De===jt)return;let _t=a(Be*a(Q+De*Y));if(_t===jt)return;let Nr=(we.x===De?0:2)|Number(we.y&it),io=_t;return L&&d(_t)&&(io=h(_t),Nr^=1),new g(De,io,Nr)}return{seed:J,k2sig:ye}}let U={lowS:e.lowS,prehash:!1},V={lowS:e.lowS,prehash:!1};function H(B,R,$=U){let{seed:T,k2sig:E}=O(B,R,$),L=e;return Wa(L.hash.outputLen,L.nByteLength,L.hmac)(T,E)}f.BASE._setWindowSize(8);function X(B,R,$,T=V){let E=B;if(R=de("msgHash",R),$=de("publicKey",$),"strict"in T)throw new Error("options.strict was renamed to lowS");let{lowS:L,prehash:F}=T,q,W;try{if(typeof E=="string"||ht(E))try{q=g.fromDER(E)}catch(we){if(!(we instanceof qr.Err))throw we;q=g.fromCompact(E)}else if(typeof E=="object"&&typeof E.r=="bigint"&&typeof E.s=="bigint"){let{r:we,s:De}=E;q=new g(we,De)}else throw new Error("PARSE");W=f.fromHex($)}catch(we){if(we.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(L&&q.hasHighS())return!1;F&&(R=e.hash(R));let{r:Y,s:ne}=q,J=C(R),Q=c(ne),ye=a(J*Q),fe=a(Y*Q),Ae=f.BASE.multiplyAndAddUnsafe(W,ye,fe)?.toAffine();return Ae?a(Ae.x)===Y:!1}return{CURVE:e,getPublicKey:b,getSharedSecret:v,sign:H,verify:X,ProjectivePoint:f,Signature:g,utils:A}}function fx(r){return{hash:r,hmac:(e,...t)=>xo(r,e,As(...t)),randomBytes:bn}}function gd(r,e){let t=n=>md({...r,...fx(n)});return Object.freeze({...t(e),create:t})}var wd=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),yd=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),hx=BigInt(1),Tc=BigInt(2),bd=(r,e)=>(r+e/Tc)/e;function dx(r){let e=wd,t=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),f=r*r*r%e,u=f*f*r%e,l=ae(u,t,e)*u%e,p=ae(l,t,e)*u%e,x=ae(p,Tc,e)*f%e,d=ae(x,o,e)*x%e,h=ae(d,s,e)*d%e,m=ae(h,a,e)*h%e,g=ae(m,c,e)*m%e,A=ae(g,a,e)*h%e,b=ae(A,t,e)*u%e,S=ae(b,i,e)*d%e,v=ae(S,n,e)*f%e,I=ae(v,Tc,e);if(!kc.eql(kc.sqr(I),r))throw new Error("Cannot find square root");return I}var kc=ks(wd,void 0,void 0,{sqrt:dx}),yt=gd({a:BigInt(0),b:BigInt(7),Fp:kc,n:yd,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=yd,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-hx*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=t,i=BigInt("0x100000000000000000000000000000000"),a=bd(s*r,e),c=bd(-n*r,e),f=oe(r-a*t-c*o,e),u=oe(-a*n-c*s,e),l=f>i,p=u>i;if(l&&(f=e-f),p&&(u=e-u),f>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:p,k2:u}}}},dd),i3=BigInt(0);var a3=yt.ProjectivePoint;function xd(){return yt.utils.randomPrivateKey()}function vd(r,e){let t=Ce.digest(e instanceof Uint8Array?e:e.subarray());if(ot(t))return t.then(({digest:n})=>yt.sign(n,r).toDERRawBytes()).catch(n=>{throw new K(String(n),"ERR_INVALID_INPUT")});try{return yt.sign(t.digest,r).toDERRawBytes()}catch(n){throw new K(String(n),"ERR_INVALID_INPUT")}}function Ed(r,e,t){let n=Ce.digest(t instanceof Uint8Array?t:t.subarray());if(ot(n))return n.then(({digest:o})=>yt.verify(e,o,r)).catch(o=>{throw new K(String(o),"ERR_INVALID_INPUT")});try{return yt.verify(e,n.digest,r)}catch(o){throw new K(String(o),"ERR_INVALID_INPUT")}}function Ad(r){return yt.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Bd(r){try{yt.getPublicKey(r,!0)}catch(e){throw new K(String(e),"ERR_INVALID_PRIVATE_KEY")}}function Rc(r){try{yt.ProjectivePoint.fromHex(r)}catch(e){throw new K(String(e),"ERR_INVALID_PUBLIC_KEY")}}function Sd(r){try{return yt.getPublicKey(r,!0)}catch(e){throw new K(String(e),"ERR_INVALID_PRIVATE_KEY")}}var Uo=class{_key;constructor(e){Rc(e),this._key=e}verify(e,t){return Ed(this._key,t,e)}marshal(){return Ad(this._key)}get bytes(){return At.encode({Type:ce.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Te(this.bytes,e.bytes)}async hash(){let e=Ce.digest(this.bytes),t;return ot(e)?{bytes:t}=await e:t=e.bytes,t}},_o=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??Sd(e),Bd(this._key),Rc(this._publicKey)}sign(e){return vd(this._key,e)}get public(){return new Uo(this._publicKey)}marshal(){return this._key}get bytes(){return Bt.encode({Type:ce.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Te(this.bytes,e.bytes)}hash(){let e=Ce.digest(this.bytes);return ot(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return ue(e,"base58btc")}async export(e,t="libp2p-key"){if(t==="libp2p-key")return An(this.bytes,e);throw new K(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function mx(r){return new _o(r)}function gx(r){return new Uo(r)}async function yx(){let r=xd();return new _o(r)}var Gr={rsa:Ic,ed25519:gc,secp256k1:Nc};function Id(r){let e=Object.keys(Gr).join(" / ");return new K(`invalid or unsupported key type ${r}. Must be ${e}`,"ERR_UNSUPPORTED_KEY_TYPE")}function Uc(r){let e=At.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case ce.RSA:return Gr.rsa.unmarshalRsaPublicKey(t);case ce.Ed25519:return Gr.ed25519.unmarshalEd25519PublicKey(t);case ce.Secp256k1:return Gr.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw Id(e.Type??"unknown")}}async function Cd(r){let e=Bt.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case ce.RSA:return Gr.rsa.unmarshalRsaPrivateKey(t);case ce.Ed25519:return Gr.ed25519.unmarshalEd25519PrivateKey(t);case ce.Secp256k1:return Gr.secp256k1.unmarshalSecp256k1PrivateKey(t);default:throw Id(e.Type??"RSA")}}var Wc=Se(Do(),1);var Wt="/",Rd=new TextEncoder().encode(Wt),Ci=Rd[0],Nn=class r{_buf;constructor(e,t){if(typeof e=="string")this._buf=ee(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]!==Ci)throw new Error("Invalid key")}toString(e="utf8"){return ue(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new r(e.join(Wt))}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=Rd),this._buf[0]!==Ci){let e=new Uint8Array(this._buf.byteLength+1);e.fill(Ci,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Ci;)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 s=t[o],i=n[o];if(s<i)return!0;if(s>i)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(Wt).slice(1)}type(){return wx(this.baseNamespace())}name(){return xx(this.baseNamespace())}instance(e){return new r(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(Wt)||(e+=Wt),e+=this.type(),new r(e)}parent(){let e=this.list();return e.length===1?new r(Wt):new r(e.slice(0,-1).join(Wt))}child(e){return this.toString()===Wt?e:e.toString()===Wt?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(),...vx(e.map(t=>t.namespaces()))])}};function wx(r){let e=r.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function xx(r){let e=r.split(":");return e[e.length-1]}function vx(r){return[].concat(...r)}var Zp=Se(Ti(),1);var Nd="ERR_IPNS_EXPIRED_RECORD",Lo="ERR_UNRECOGNIZED_VALIDITY",Ud="ERR_SIGNATURE_CREATION",Yt="ERR_SIGNATURE_VERIFICATION";var Dc="ERR_UNDEFINED_PARAMETER",_d="ERR_INVALID_RECORD_DATA",Dd="ERR_INVALID_VALUE",Ld="ERR_INVALID_EMBEDDED_KEY",Od="ERR_MISSING_PRIVATE_KEY",Vd="ERR_RECORD_TOO_LARGE";var Re;(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=()=>bo(t)}(e=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=mr((o,s,i={})=>{i.lengthDelimited!==!1&&s.fork(),o.value!=null&&(s.uint32(10),s.bytes(o.value)),o.signatureV1!=null&&(s.uint32(18),s.bytes(o.signatureV1)),o.validityType!=null&&(s.uint32(24),r.ValidityType.codec().encode(o.validityType,s)),o.validity!=null&&(s.uint32(34),s.bytes(o.validity)),o.sequence!=null&&(s.uint32(40),s.uint64(o.sequence)),o.ttl!=null&&(s.uint32(48),s.uint64(o.ttl)),o.pubKey!=null&&(s.uint32(58),s.bytes(o.pubKey)),o.signatureV2!=null&&(s.uint32(66),s.bytes(o.signatureV2)),o.data!=null&&(s.uint32(74),s.bytes(o.data)),i.lengthDelimited!==!1&&s.ldelim()},(o,s)=>{let i={},a=s==null?o.len:o.pos+s;for(;o.pos<a;){let c=o.uint32();switch(c>>>3){case 1:i.value=o.bytes();break;case 2:i.signatureV1=o.bytes();break;case 3:i.validityType=r.ValidityType.codec().decode(o);break;case 4:i.validity=o.bytes();break;case 5:i.sequence=o.uint64();break;case 6:i.ttl=o.uint64();break;case 7:i.pubKey=o.bytes();break;case 8:i.signatureV2=o.bytes();break;case 9:i.data=o.bytes();break;default:o.skipType(c&7);break}}return i})),n),r.encode=o=>pr(o,r.codec()),r.decode=o=>dr(o,r.codec())})(Re||(Re={}));var Ex=["string","number","bigint","symbol"],Ax=["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 Pd(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(Ex.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(Bx(r))return"Buffer";let t=Sx(r);return t||"Object"}function Bx(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Sx(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(Ax.includes(e))return e}var w=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};w.uint=new w(0,"uint",!0);w.negint=new w(1,"negint",!0);w.bytes=new w(2,"bytes",!0);w.string=new w(3,"string",!0);w.array=new w(4,"array",!1);w.map=new w(5,"map",!1);w.tag=new w(6,"tag",!1);w.float=new w(7,"float",!0);w.false=new w(7,"false",!0);w.true=new w(7,"true",!0);w.null=new w(7,"null",!0);w.undefined=new w(7,"undefined",!0);w.break=new w(7,"break",!0);var D=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 Un=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Ix=new TextDecoder,Cx=new TextEncoder;function ki(r){return Un&&globalThis.Buffer.isBuffer(r)}function Oc(r){return r instanceof Uint8Array?ki(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Hd=Un?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):Fd(r,e,t):(r,e,t)=>t-e>64?Ix.decode(r.subarray(e,t)):Fd(r,e,t),Kd=Un?r=>r.length>64?globalThis.Buffer.from(r):Md(r):r=>r.length>64?Cx.encode(r):Md(r),Tt=r=>Uint8Array.from(r),_n=Un?(r,e,t)=>ki(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),zd=Un?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),Oc(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},qd=Un?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Gd(r,e){if(ki(r)&&ki(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 Md(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 Fd(r,e,t){let n=[];for(;e<t;){let o=r[e],s=null,i=o>239?4:o>223?3:o>191?2:1;if(e+i<=t){let a,c,f,u;switch(i){case 1:o<128&&(s=o);break;case 2:a=r[e+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(s=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)&&(s=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&&(s=u))}}s===null?(s=65533,i=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),e+=i}return Tx(n)}var $d=4096;function Tx(r){let e=r.length;if(e<=$d)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=$d));return t}var kx=256,Oo=class{constructor(e=kx){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=qd(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=_n(n,0,this.cursor)}else t=zd(this.chunks,this.cursor);return e&&this.reset(),t}};var z="CBOR decode error:",Vc="CBOR encode error:",Vo=[];Vo[23]=1;Vo[24]=2;Vo[25]=3;Vo[26]=5;Vo[27]=9;function Zt(r,e,t){if(r.length-e<t)throw new Error(`${z} not enough data for type`)}var Ee=[24,256,65536,4294967296,BigInt("18446744073709551616")];function et(r,e,t){Zt(r,e,1);let n=r[e];if(t.strict===!0&&n<Ee[0])throw new Error(`${z} integer encoded in more bytes than necessary (strict decode)`);return n}function tt(r,e,t){Zt(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<Ee[1])throw new Error(`${z} integer encoded in more bytes than necessary (strict decode)`);return n}function rt(r,e,t){Zt(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<Ee[2])throw new Error(`${z} integer encoded in more bytes than necessary (strict decode)`);return n}function nt(r,e,t){Zt(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],s=(BigInt(n)<<BigInt(32))+BigInt(o);if(t.strict===!0&&s<Ee[3])throw new Error(`${z} integer encoded in more bytes than necessary (strict decode)`);if(s<=Number.MAX_SAFE_INTEGER)return Number(s);if(t.allowBigInt===!0)return s;throw new Error(`${z} integers outside of the safe integer range are not supported`)}function jd(r,e,t,n){return new D(w.uint,et(r,e+1,n),2)}function Wd(r,e,t,n){return new D(w.uint,tt(r,e+1,n),3)}function Yd(r,e,t,n){return new D(w.uint,rt(r,e+1,n),5)}function Zd(r,e,t,n){return new D(w.uint,nt(r,e+1,n),9)}function at(r,e){return Ne(r,0,e.value)}function Ne(r,e,t){if(t<Ee[0]){let n=Number(t);r.push([e|n])}else if(t<Ee[1]){let n=Number(t);r.push([e|24,n])}else if(t<Ee[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<Ee[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<Ee[4]){let o=[e|27,0,0,0,0,0,0,0],s=Number(n&BigInt(4294967295)),i=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=s&255,s=s>>8,o[7]=s&255,s=s>>8,o[6]=s&255,s=s>>8,o[5]=s&255,o[4]=i&255,i=i>>8,o[3]=i&255,i=i>>8,o[2]=i&255,i=i>>8,o[1]=i&255,r.push(o)}else throw new Error(`${z} encountered BigInt larger than allowable range`)}}at.encodedSize=function(e){return Ne.encodedSize(e.value)};Ne.encodedSize=function(e){return e<Ee[0]?1:e<Ee[1]?2:e<Ee[2]?3:e<Ee[3]?5:9};at.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function Jd(r,e,t,n){return new D(w.negint,-1-et(r,e+1,n),2)}function Xd(r,e,t,n){return new D(w.negint,-1-tt(r,e+1,n),3)}function Qd(r,e,t,n){return new D(w.negint,-1-rt(r,e+1,n),5)}var Pc=BigInt(-1),ep=BigInt(1);function tp(r,e,t,n){let o=nt(r,e+1,n);if(typeof o!="bigint"){let s=-1-o;if(s>=Number.MIN_SAFE_INTEGER)return new D(w.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${z} integers outside of the safe integer range are not supported`);return new D(w.negint,Pc-BigInt(o),9)}function Ri(r,e){let t=e.value,n=typeof t=="bigint"?t*Pc-ep:t*-1-1;Ne(r,e.type.majorEncoded,n)}Ri.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*Pc-ep:t*-1-1;return n<Ee[0]?1:n<Ee[1]?2:n<Ee[2]?3:n<Ee[3]?5:9};Ri.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function Po(r,e,t,n){Zt(r,e,t+n);let o=_n(r,e+t,e+t+n);return new D(w.bytes,o,t+n)}function rp(r,e,t,n){return Po(r,e,1,t)}function np(r,e,t,n){return Po(r,e,2,et(r,e+1,n))}function op(r,e,t,n){return Po(r,e,3,tt(r,e+1,n))}function sp(r,e,t,n){return Po(r,e,5,rt(r,e+1,n))}function ip(r,e,t,n){let o=nt(r,e+1,n);if(typeof o=="bigint")throw new Error(`${z} 64-bit integer bytes lengths not supported`);return Po(r,e,9,o)}function Ni(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===w.string?Kd(r.value):r.value),r.encodedBytes}function Dn(r,e){let t=Ni(e);Ne(r,e.type.majorEncoded,t.length),r.push(t)}Dn.encodedSize=function(e){let t=Ni(e);return Ne.encodedSize(t.length)+t.length};Dn.compareTokens=function(e,t){return Nx(Ni(e),Ni(t))};function Nx(r,e){return r.length<e.length?-1:r.length>e.length?1:Gd(r,e)}function Mo(r,e,t,n,o){let s=t+n;Zt(r,e,s);let i=new D(w.string,Hd(r,e+t,e+s),s);return o.retainStringBytes===!0&&(i.byteValue=_n(r,e+t,e+s)),i}function ap(r,e,t,n){return Mo(r,e,1,t,n)}function cp(r,e,t,n){return Mo(r,e,2,et(r,e+1,n),n)}function up(r,e,t,n){return Mo(r,e,3,tt(r,e+1,n),n)}function lp(r,e,t,n){return Mo(r,e,5,rt(r,e+1,n),n)}function fp(r,e,t,n){let o=nt(r,e+1,n);if(typeof o=="bigint")throw new Error(`${z} 64-bit integer string lengths not supported`);return Mo(r,e,9,o,n)}var hp=Dn;function Ln(r,e,t,n){return new D(w.array,n,t)}function dp(r,e,t,n){return Ln(r,e,1,t)}function pp(r,e,t,n){return Ln(r,e,2,et(r,e+1,n))}function mp(r,e,t,n){return Ln(r,e,3,tt(r,e+1,n))}function gp(r,e,t,n){return Ln(r,e,5,rt(r,e+1,n))}function yp(r,e,t,n){let o=nt(r,e+1,n);if(typeof o=="bigint")throw new Error(`${z} 64-bit integer array lengths not supported`);return Ln(r,e,9,o)}function bp(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${z} indefinite length items not allowed`);return Ln(r,e,1,1/0)}function Ui(r,e){Ne(r,w.array.majorEncoded,e.value)}Ui.compareTokens=at.compareTokens;Ui.encodedSize=function(e){return Ne.encodedSize(e.value)};function On(r,e,t,n){return new D(w.map,n,t)}function wp(r,e,t,n){return On(r,e,1,t)}function xp(r,e,t,n){return On(r,e,2,et(r,e+1,n))}function vp(r,e,t,n){return On(r,e,3,tt(r,e+1,n))}function Ep(r,e,t,n){return On(r,e,5,rt(r,e+1,n))}function Ap(r,e,t,n){let o=nt(r,e+1,n);if(typeof o=="bigint")throw new Error(`${z} 64-bit integer map lengths not supported`);return On(r,e,9,o)}function Bp(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${z} indefinite length items not allowed`);return On(r,e,1,1/0)}function _i(r,e){Ne(r,w.map.majorEncoded,e.value)}_i.compareTokens=at.compareTokens;_i.encodedSize=function(e){return Ne.encodedSize(e.value)};function Sp(r,e,t,n){return new D(w.tag,t,1)}function Ip(r,e,t,n){return new D(w.tag,et(r,e+1,n),2)}function Cp(r,e,t,n){return new D(w.tag,tt(r,e+1,n),3)}function Tp(r,e,t,n){return new D(w.tag,rt(r,e+1,n),5)}function kp(r,e,t,n){return new D(w.tag,nt(r,e+1,n),9)}function Di(r,e){Ne(r,w.tag.majorEncoded,e.value)}Di.compareTokens=at.compareTokens;Di.encodedSize=function(e){return Ne.encodedSize(e.value)};var Vx=20,Px=21,Mx=22,Fx=23;function Rp(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${z} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new D(w.null,null,1):new D(w.undefined,void 0,1)}function Np(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${z} indefinite length items not allowed`);return new D(w.break,void 0,1)}function Mc(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${z} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${z} Infinity values are not supported`)}return new D(w.float,r,e)}function Up(r,e,t,n){return Mc(Fc(r,e+1),3,n)}function _p(r,e,t,n){return Mc($c(r,e+1),5,n)}function Dp(r,e,t,n){return Mc(Pp(r,e+1),9,n)}function Li(r,e,t){let n=e.value;if(n===!1)r.push([w.float.majorEncoded|Vx]);else if(n===!0)r.push([w.float.majorEncoded|Px]);else if(n===null)r.push([w.float.majorEncoded|Mx]);else if(n===void 0)r.push([w.float.majorEncoded|Fx]);else{let o,s=!1;(!t||t.float64!==!0)&&(Op(n),o=Fc(bt,1),n===o||Number.isNaN(n)?(bt[0]=249,r.push(bt.slice(0,3)),s=!0):(Vp(n),o=$c(bt,1),n===o&&(bt[0]=250,r.push(bt.slice(0,5)),s=!0))),s||($x(n),o=Pp(bt,1),bt[0]=251,r.push(bt.slice(0,9)))}}Li.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){Op(n);let o=Fc(bt,1);if(n===o||Number.isNaN(n))return 3;if(Vp(n),o=$c(bt,1),n===o)return 5}return 9};var Lp=new ArrayBuffer(9),ct=new DataView(Lp,1),bt=new Uint8Array(Lp,0);function Op(r){if(r===1/0)ct.setUint16(0,31744,!1);else if(r===-1/0)ct.setUint16(0,64512,!1);else if(Number.isNaN(r))ct.setUint16(0,32256,!1);else{ct.setFloat32(0,r);let e=ct.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)ct.setUint16(0,31744,!1);else if(t===0)ct.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?ct.setUint16(0,0):o<-14?ct.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):ct.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Fc(r,e){if(r.length-e<2)throw new Error(`${z} 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,s;return n===0?s=o*2**-24:n!==31?s=(o+1024)*2**(n-25):s=o===0?1/0:NaN,t&32768?-s:s}function Vp(r){ct.setFloat32(0,r,!1)}function $c(r,e){if(r.length-e<4)throw new Error(`${z} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function $x(r){ct.setFloat64(0,r,!1)}function Pp(r,e){if(r.length-e<8)throw new Error(`${z} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}Li.compareTokens=at.compareTokens;function te(r,e,t){throw new Error(`${z} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function Oi(r){return()=>{throw new Error(`${z} ${r}`)}}var N=[];for(let r=0;r<=23;r++)N[r]=te;N[24]=jd;N[25]=Wd;N[26]=Yd;N[27]=Zd;N[28]=te;N[29]=te;N[30]=te;N[31]=te;for(let r=32;r<=55;r++)N[r]=te;N[56]=Jd;N[57]=Xd;N[58]=Qd;N[59]=tp;N[60]=te;N[61]=te;N[62]=te;N[63]=te;for(let r=64;r<=87;r++)N[r]=rp;N[88]=np;N[89]=op;N[90]=sp;N[91]=ip;N[92]=te;N[93]=te;N[94]=te;N[95]=Oi("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)N[r]=ap;N[120]=cp;N[121]=up;N[122]=lp;N[123]=fp;N[124]=te;N[125]=te;N[126]=te;N[127]=Oi("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)N[r]=dp;N[152]=pp;N[153]=mp;N[154]=gp;N[155]=yp;N[156]=te;N[157]=te;N[158]=te;N[159]=bp;for(let r=160;r<=183;r++)N[r]=wp;N[184]=xp;N[185]=vp;N[186]=Ep;N[187]=Ap;N[188]=te;N[189]=te;N[190]=te;N[191]=Bp;for(let r=192;r<=215;r++)N[r]=Sp;N[216]=Ip;N[217]=Cp;N[218]=Tp;N[219]=kp;N[220]=te;N[221]=te;N[222]=te;N[223]=te;for(let r=224;r<=243;r++)N[r]=Oi("simple values are not supported");N[244]=te;N[245]=te;N[246]=te;N[247]=Rp;N[248]=Oi("simple values are not supported");N[249]=Up;N[250]=_p;N[251]=Dp;N[252]=te;N[253]=te;N[254]=te;N[255]=Np;var wt=[];for(let r=0;r<24;r++)wt[r]=new D(w.uint,r,1);for(let r=-1;r>=-24;r--)wt[31-r]=new D(w.negint,r,1);wt[64]=new D(w.bytes,new Uint8Array(0),1);wt[96]=new D(w.string,"",1);wt[128]=new D(w.array,0,1);wt[160]=new D(w.map,0,1);wt[244]=new D(w.false,!1,1);wt[245]=new D(w.true,!0,1);wt[246]=new D(w.null,null,1);function Mp(r){switch(r.type){case w.false:return Tt([244]);case w.true:return Tt([245]);case w.null:return Tt([246]);case w.bytes:return r.value.length?void 0:Tt([64]);case w.string:return r.value===""?Tt([96]):void 0;case w.array:return r.value===0?Tt([128]):void 0;case w.map:return r.value===0?Tt([160]):void 0;case w.uint:return r.value<24?Tt([Number(r.value)]):void 0;case w.negint:if(r.value>=-24)return Tt([31-Number(r.value)])}}var Kx={float64:!1,mapSorter:Gx,quickEncodeToken:Mp};function zx(){let r=[];return r[w.uint.major]=at,r[w.negint.major]=Ri,r[w.bytes.major]=Dn,r[w.string.major]=hp,r[w.array.major]=Ui,r[w.map.major]=_i,r[w.tag.major]=Di,r[w.float.major]=Li,r}var Fp=zx(),Hc=new Oo,Pi=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(`${Vc} object contains circular references`);return new r(t,e)}},Er={null:new D(w.null,null),undefined:new D(w.undefined,void 0),true:new D(w.true,!0),false:new D(w.false,!1),emptyArray:new D(w.array,0),emptyMap:new D(w.map,0)},Ar={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new D(w.float,r):r>=0?new D(w.uint,r):new D(w.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new D(w.uint,r):new D(w.negint,r)},Uint8Array(r,e,t,n){return new D(w.bytes,r)},string(r,e,t,n){return new D(w.string,r)},boolean(r,e,t,n){return r?Er.true:Er.false},null(r,e,t,n){return Er.null},undefined(r,e,t,n){return Er.undefined},ArrayBuffer(r,e,t,n){return new D(w.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new D(w.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[Er.emptyArray,new D(w.break)]:Er.emptyArray;n=Pi.createCheck(n,r);let o=[],s=0;for(let i of r)o[s++]=Vi(i,t,n);return t.addBreakTokens?[new D(w.array,r.length),o,new D(w.break)]:[new D(w.array,r.length),o]},Object(r,e,t,n){let o=e!=="Object",s=o?r.keys():Object.keys(r),i=o?r.size:s.length;if(!i)return t.addBreakTokens===!0?[Er.emptyMap,new D(w.break)]:Er.emptyMap;n=Pi.createCheck(n,r);let a=[],c=0;for(let f of s)a[c++]=[Vi(f,t,n),Vi(o?r.get(f):r[f],t,n)];return qx(a,t),t.addBreakTokens?[new D(w.map,i),a,new D(w.break)]:[new D(w.map,i),a]}};Ar.Map=Ar.Object;Ar.Buffer=Ar.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Ar[`${r}Array`]=Ar.DataView;function Vi(r,e={},t){let n=Pd(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||Ar[n];if(typeof o=="function"){let i=o(r,n,e,t);if(i!=null)return i}let s=Ar[n];if(!s)throw new Error(`${Vc} unsupported type: ${n}`);return s(r,n,e,t)}function qx(r,e){e.mapSorter&&r.sort(e.mapSorter)}function Gx(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,s=Fp[o].compareTokens(t,n);return s===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),s}function $p(r,e,t,n){if(Array.isArray(e))for(let o of e)$p(r,o,t,n);else t[e.type.major](r,e,n)}function jx(r,e,t){let n=Vi(r,t);if(!Array.isArray(n)&&t.quickEncodeToken){let o=t.quickEncodeToken(n);if(o)return o;let s=e[n.type.major];if(s.encodedSize){let i=s.encodedSize(n,t),a=new Oo(i);if(s(a,n,t),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Oc(a.chunks[0])}}return Hc.reset(),$p(Hc,n,e,t),Hc.toBytes(!0)}function Kc(r,e){return e=Object.assign({},Kx,e),jx(r,Fp,e)}var Wx={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},zc=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=wt[e];if(t===void 0){let n=N[e];if(!n)throw new Error(`${z} 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}},Fo=Symbol.for("DONE"),Mi=Symbol.for("BREAK");function Yx(r,e,t){let n=[];for(let o=0;o<r.value;o++){let s=$o(e,t);if(s===Mi){if(r.value===1/0)break;throw new Error(`${z} got unexpected break to lengthed array`)}if(s===Fo)throw new Error(`${z} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=s}return n}function Zx(r,e,t){let n=t.useMaps===!0,o=n?void 0:{},s=n?new Map:void 0;for(let i=0;i<r.value;i++){let a=$o(e,t);if(a===Mi){if(r.value===1/0)break;throw new Error(`${z} got unexpected break to lengthed map`)}if(a===Fo)throw new Error(`${z} found map but not enough entries (got ${i} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${z} non-string keys not supported (got ${typeof a})`);if(t.rejectDuplicateMapKeys===!0&&(n&&s.has(a)||!n&&a in o))throw new Error(`${z} found repeat map key "${a}"`);let c=$o(e,t);if(c===Fo)throw new Error(`${z} found map but not enough entries (got ${i} [no value], expected ${r.value})`);n?s.set(a,c):o[a]=c}return n?s:o}function $o(r,e){if(r.done())return Fo;let t=r.next();if(t.type===w.break)return Mi;if(t.type.terminal)return t.value;if(t.type===w.array)return Yx(t,r,e);if(t.type===w.map)return Zx(t,r,e);if(t.type===w.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=$o(r,e);return e.tags[t.value](n)}throw new Error(`${z} tag not supported (${t.value})`)}throw new Error("unsupported")}function Hp(r,e){if(!(r instanceof Uint8Array))throw new Error(`${z} data to decode must be a Uint8Array`);e=Object.assign({},Wx,e);let t=e.tokenizer||new zc(r,e),n=$o(t,e);if(n===Fo)throw new Error(`${z} did not find any content to decode`);if(n===Mi)throw new Error(`${z} got unexpected break`);return[n,r.subarray(t.pos())]}function qc(r,e){let[t,n]=Hp(r,e);if(n.length>0)throw new Error(`${z} too many terminals, data makes no sense`);return t}var je=Se(Do(),1);var Kp=ir("ipns:utils"),zp=ee("/ipns/"),Xx=114,qp=async(r,e)=>{if(e==null||r==null){let n=new Error("one or more of the provided parameters are not defined");throw Kp.error(n),(0,je.default)(n,Dc)}let t;if(e.pubKey!=null){try{t=Uc(e.pubKey)}catch(o){throw Kp.error(o),o}if(!(await Pf(e.pubKey)).equals(r))throw(0,je.default)(new Error("Embedded public key did not match PeerID"),Ld)}else r.publicKey!=null&&(t=Uc(r.publicKey));if(t!=null)return t;throw(0,je.default)(new Error("no public key is available"),Dc)},Gp=(r,e,t)=>{let n=ee(e);return Or([r,t,n])},Fi=r=>{let e=ee("ipns-signature:");return Or([e,r])},Gc=r=>"signatureV1"in r?Re.encode({value:ee(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:ee(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):Re.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data});function Jt(r){let e=Re.decode(r);if(e.sequence!=null&&(e.sequence=BigInt(e.sequence)),e.ttl!=null&&(e.ttl=BigInt(e.ttl)),e.signatureV2==null||e.data==null)throw(0,je.default)(new Error("missing data or signatureV2"),Yt);let t=Yp(e.data),n=jc(t.Value),o=ue(t.Validity);if(e.value!=null&&e.signatureV1!=null)return Qx(e),{value:n,validityType:Re.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:Re.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 $i=r=>Or([zp,r.toBytes()]),jp=r=>Fa(r.slice(zp.length)),Wp=(r,e,t,n,o)=>{let s;if(e===Re.ValidityType.EOL)s=0;else throw(0,je.default)(new Error("Unknown validity type"),Lo);return Kc({Value:r,Validity:t,ValidityType:s,Sequence:n,TTL:o})},Yp=r=>{let e=qc(r);if(e.ValidityType===0)e.ValidityType=Re.ValidityType.EOL;else throw(0,je.default)(new Error("Unknown validity type"),Lo);return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e},jc=r=>{if(r!=null){if(df(r))return`/ipns/${r.toCID().toString(bs)}`;if(r instanceof Uint8Array){let n=ue(r);n.startsWith("/")&&(r=n)}let e=r.toString().trim();if(e.startsWith("/")&&e.length>1)return e;let t=Xe.asCID(r);if(t!=null)return t.code===Xx?`/ipns/${t.toString(bs)}`:`/ipfs/${t.toV1().toString()}`;try{return r instanceof Uint8Array?`/ipfs/${Xe.decode(r).toV1().toString()}`:`/ipfs/${Xe.parse(e).toV1().toString()}`}catch{}}throw(0,je.default)(new Error("Value must be a valid content path starting with /"),Dd)},Qx=r=>{if(r.data==null)throw(0,je.default)(new Error("Record data is missing"),_d);let e=Yp(r.data);if(!Te(e.Value,r.value??new Uint8Array(0)))throw(0,je.default)(new Error('Field "value" did not match between protobuf and CBOR'),Yt);if(!Te(e.Validity,r.validity??new Uint8Array(0)))throw(0,je.default)(new Error('Field "validity" did not match between protobuf and CBOR'),Yt);if(e.ValidityType!==r.validityType)throw(0,je.default)(new Error('Field "validityType" did not match between protobuf and CBOR'),Yt);if(e.Sequence!==r.sequence)throw(0,je.default)(new Error('Field "sequence" did not match between protobuf and CBOR'),Yt);if(e.TTL!==r.ttl)throw(0,je.default)(new Error('Field "ttl" did not match between protobuf and CBOR'),Yt)};var e1=ir("ipns"),t1=vt.code,r1="/ipns/",j4=r1.length,Jp={v1Compatible:!0};async function Xp(r,e,t,n,o=Jp){let s=new Zp.default(Date.now()+Number(n)),i=Re.ValidityType.EOL,[a,c]=n.toString().split("."),f=BigInt(a)*BigInt(1e5)+BigInt(c??"0");return n1(r,e,t,i,s.toString(),f,o)}var n1=async(r,e,t,n,o,s,i=Jp)=>{t=BigInt(t);let a=ee(o),c=jc(e),f=ee(c);if(r.privateKey==null)throw(0,Wc.default)(new Error("Missing private key"),Od);let u=await Cd(r.privateKey),l=Wp(f,n,a,t,s),p=Fi(l),x=await u.sign(p),d;if(r.publicKey!=null){let h=_r(r.toBytes());(h.code!==t1||!Te(r.publicKey,h.digest))&&(d=r.publicKey)}if(i.v1Compatible===!0){let h=await o1(u,f,n,a),m={value:c,signatureV1:h,validity:o,validityType:n,sequence:t,ttl:s,signatureV2:x,data:l};return d!=null&&(m.pubKey=d),m}else{let h={value:c,validity:o,validityType:n,sequence:t,ttl:s,signatureV2:x,data:l};return d!=null&&(h.pubKey=d),h}};var o1=async(r,e,t,n)=>{try{let o=Gp(e,t,n);return await r.sign(o)}catch(o){throw e1.error("record signature creation failed",o),(0,Wc.default)(new Error("record signature creation failed"),Ud)}};var Yc=Se(Ti(),1);function Hi(r,e){let t=e.map((n,o)=>({record:Jt(n),index:o}));return t.sort((n,o)=>{let s=n.record.sequence,i=o.record.sequence;if(s>i)return-1;if(s<i)return 1;if(n.record.validityType===Re.ValidityType.EOL&&o.record.validityType===Re.ValidityType.EOL){let a=Yc.default.fromString(n.record.validity).toDate(),c=Yc.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 Ho=Se(Do(),1),Qp=Se(Ti(),1);var Ki=ir("ipns:validator"),s1=1024*10,i1=async(r,e)=>{let t=Jt(e),n;try{let o=Fi(t.data);n=await r.verify(o,t.signatureV2)}catch{n=!1}if(!n)throw Ki.error("record signature verification failed"),(0,Ho.default)(new Error("record signature verification failed"),Yt);if(t.validityType===Re.ValidityType.EOL){if(Qp.default.fromString(t.validity).toDate().getTime()<Date.now())throw Ki.error("record has expired"),(0,Ho.default)(new Error("record has expired"),Nd)}else if(t.validityType!=null)throw Ki.error("unrecognized validity type"),(0,Ho.default)(new Error("unrecognized validity type"),Lo);Ki("ipns record for %s is valid",t.value)};async function Zc(r,e){if(e.byteLength>s1)throw(0,Ho.default)(new Error("record too large"),Vd);let t=jp(r),n=Jt(e),o=await qp(t,n);await i1(o,e)}var Ue=class extends Event{constructor(e,t){super(e),this.detail=t}};var tu={};M(tu,{base58btc:()=>He,base58flickr:()=>h1});function a1(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 s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=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(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var h=0,m=0,g=0,A=d.length;g!==A&&d[g]===0;)g++,h++;for(var b=(A-g)*u+1>>>0,S=new Uint8Array(b);g!==A;){for(var v=d[g],I=0,C=b-1;(v!==0||I<m)&&C!==-1;C--,I++)v+=256*S[C]>>>0,S[C]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");m=I,g++}for(var y=b-m;y!==b&&S[y]===0;)y++;for(var k=c.repeat(h);y<b;++y)k+=r.charAt(S[y]);return k}function p(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var h=0;if(d[h]!==" "){for(var m=0,g=0;d[h]===c;)m++,h++;for(var A=(d.length-h)*f+1>>>0,b=new Uint8Array(A);d[h];){var S=t[d.charCodeAt(h)];if(S===255)return;for(var v=0,I=A-1;(S!==0||v<g)&&I!==-1;I--,v++)S+=a*b[I]>>>0,b[I]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");g=v,h++}if(d[h]!==" "){for(var C=A-g;C!==A&&b[C]===0;)C++;for(var y=new Uint8Array(m+(A-C)),k=m;C!==A;)y[k++]=b[C++];return y}}}function x(d){var h=p(d);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:x}}var c1=a1,u1=c1,e0=u1;var aI=new Uint8Array(0);var t0=(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},Xt=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var r0=r=>new TextEncoder().encode(r),n0=r=>new TextDecoder().decode(r);var Jc=class{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")}},Xc=class{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 s0(this,e)}},Qc=class{constructor(e){this.decoders=e}or(e){return s0(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},s0=(r,e)=>new Qc({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),eu=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Jc(e,t,n),this.decoder=new Xc(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Vn=({name:r,prefix:e,encode:t,decode:n})=>new eu(r,e,t,n),Br=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=e0(t,e);return Vn({prefix:r,name:e,encode:n,decode:s=>Xt(o(s))})},l1=(r,e,t,n)=>{let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,c=0,f=0;for(let u=0;u<s;++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,i[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i},f1=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s},pe=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>Vn({prefix:e,name:r,encode(o){return f1(o,n,t)},decode(o){return l1(o,n,t,r)}});var He=Br({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),h1=Br({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ru={};M(ru,{base32:()=>kt,base32hex:()=>g1,base32hexpad:()=>b1,base32hexpadupper:()=>w1,base32hexupper:()=>y1,base32pad:()=>p1,base32padupper:()=>m1,base32upper:()=>d1,base32z:()=>x1});var kt=pe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),d1=pe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),p1=pe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),m1=pe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),g1=pe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),y1=pe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),b1=pe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),w1=pe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),x1=pe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var v1=c0,i0=128,E1=127,A1=~E1,B1=Math.pow(2,31);function c0(r,e,t){e=e||[],t=t||0;for(var n=t;r>=B1;)e[t++]=r&255|i0,r/=128;for(;r&A1;)e[t++]=r&255|i0,r>>>=7;return e[t]=r|0,c0.bytes=t-n+1,e}var S1=nu,I1=128,a0=127;function nu(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw nu.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&a0)<<o:(i&a0)*Math.pow(2,o),o+=7}while(i>=I1);return nu.bytes=s-n,t}var C1=Math.pow(2,7),T1=Math.pow(2,14),k1=Math.pow(2,21),R1=Math.pow(2,28),N1=Math.pow(2,35),U1=Math.pow(2,42),_1=Math.pow(2,49),D1=Math.pow(2,56),L1=Math.pow(2,63),O1=function(r){return r<C1?1:r<T1?2:r<k1?3:r<R1?4:r<N1?5:r<U1?6:r<_1?7:r<D1?8:r<L1?9:10},V1={encode:v1,decode:S1,encodingLength:O1},P1=V1,Ko=P1;var zo=(r,e=0)=>[Ko.decode(r,e),Ko.decode.bytes],Pn=(r,e,t=0)=>(Ko.encode(r,e,t),e),Mn=r=>Ko.encodingLength(r);var Wr=(r,e)=>{let t=e.byteLength,n=Mn(r),o=n+Mn(t),s=new Uint8Array(o+t);return Pn(r,s,0),Pn(t,s,n),s.set(e,o),new Fn(r,t,e,s)},qo=r=>{let e=Xt(r),[t,n]=zo(e),[o,s]=zo(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Fn(t,o,i,e)},u0=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&t0(r.bytes,t.bytes)}},Fn=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var qi=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let p=Number.parseInt(l,e);if(!Number.isNaN(p))return p});if(u===void 0)break;if(s*=e,s+=u,s>f||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return t[o]=i[0],t[o+1]=i[1],t[o+2]=i[2],t[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];t[o]=s>>8,t[o+1]=s&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=e(s.subarray(0,i));return t.set(s.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var l0=45,M1=15,$n=new qi;function ou(r){if(!(r.length>M1))return $n.new(r).parseWith(()=>$n.readIPv4Addr())}function su(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>l0))return $n.new(r).parseWith(()=>$n.readIPv6Addr())}function Gi(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>l0))return $n.new(r).parseWith(()=>$n.readIPAddr())}function ji(r){return!!ou(r)}function Wi(r){return!!su(r)}function Sr(r){return!!Gi(r)}var lu={};M(lu,{base10:()=>q1});function F1(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 s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=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(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var h=0,m=0,g=0,A=d.length;g!==A&&d[g]===0;)g++,h++;for(var b=(A-g)*u+1>>>0,S=new Uint8Array(b);g!==A;){for(var v=d[g],I=0,C=b-1;(v!==0||I<m)&&C!==-1;C--,I++)v+=256*S[C]>>>0,S[C]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");m=I,g++}for(var y=b-m;y!==b&&S[y]===0;)y++;for(var k=c.repeat(h);y<b;++y)k+=r.charAt(S[y]);return k}function p(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var h=0;if(d[h]!==" "){for(var m=0,g=0;d[h]===c;)m++,h++;for(var A=(d.length-h)*f+1>>>0,b=new Uint8Array(A);d[h];){var S=t[d.charCodeAt(h)];if(S===255)return;for(var v=0,I=A-1;(S!==0||v<g)&&I!==-1;I--,v++)S+=a*b[I]>>>0,b[I]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");g=v,h++}if(d[h]!==" "){for(var C=A-g;C!==A&&b[C]===0;)C++;for(var y=new Uint8Array(m+(A-C)),k=m;C!==A;)y[k++]=b[C++];return y}}}function x(d){var h=p(d);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:x}}var $1=F1,H1=$1,f0=H1;var EI=new Uint8Array(0);var h0=(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},Qt=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")};var d0=r=>new TextEncoder().encode(r),p0=r=>new TextDecoder().decode(r);var iu=class{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")}},au=class{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 g0(this,e)}},cu=class{constructor(e){this.decoders=e}or(e){return g0(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},g0=(r,e)=>new cu({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),uu=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new iu(e,t,n),this.decoder=new au(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Hn=({name:r,prefix:e,encode:t,decode:n})=>new uu(r,e,t,n),Ir=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=f0(t,e);return Hn({prefix:r,name:e,encode:n,decode:s=>Qt(o(s))})},K1=(r,e,t,n)=>{let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,c=0,f=0;for(let u=0;u<s;++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,i[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i},z1=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s},me=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>Hn({prefix:e,name:r,encode(o){return z1(o,n,t)},decode(o){return K1(o,n,t,r)}});var q1=Ir({prefix:"9",name:"base10",alphabet:"0123456789"});var fu={};M(fu,{base16:()=>G1,base16upper:()=>j1});var G1=me({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),j1=me({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var hu={};M(hu,{base2:()=>W1});var W1=me({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var du={};M(du,{base256emoji:()=>Q1});var y0=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}"),Y1=y0.reduce((r,e,t)=>(r[t]=e,r),[]),Z1=y0.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function J1(r){return r.reduce((e,t)=>(e+=Y1[t],e),"")}function X1(r){let e=[];for(let t of r){let n=Z1[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var Q1=Hn({prefix:"\u{1F680}",name:"base256emoji",encode:J1,decode:X1});var pu={};M(pu,{base32:()=>Kn,base32hex:()=>nv,base32hexpad:()=>sv,base32hexpadupper:()=>iv,base32hexupper:()=>ov,base32pad:()=>tv,base32padupper:()=>rv,base32upper:()=>ev,base32z:()=>av});var Kn=me({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ev=me({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),tv=me({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),rv=me({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),nv=me({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ov=me({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),sv=me({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),iv=me({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),av=me({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var mu={};M(mu,{base36:()=>cv,base36upper:()=>uv});var cv=Ir({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),uv=Ir({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var gu={};M(gu,{base58btc:()=>Rt,base58flickr:()=>lv});var Rt=Ir({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),lv=Ir({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var yu={};M(yu,{base64:()=>fv,base64pad:()=>hv,base64url:()=>dv,base64urlpad:()=>pv});var fv=me({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),hv=me({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),dv=me({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),pv=me({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var bu={};M(bu,{base8:()=>mv});var mv=me({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var wu={};M(wu,{identity:()=>gv});var gv=Hn({prefix:"\0",name:"identity",encode:r=>p0(r),decode:r=>d0(r)});var VI=new TextEncoder,PI=new TextDecoder;var vu={};M(vu,{identity:()=>Mv});var wv=x0,b0=128,xv=127,vv=~xv,Ev=Math.pow(2,31);function x0(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Ev;)e[t++]=r&255|b0,r/=128;for(;r&vv;)e[t++]=r&255|b0,r>>>=7;return e[t]=r|0,x0.bytes=t-n+1,e}var Av=xu,Bv=128,w0=127;function xu(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw xu.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&w0)<<o:(i&w0)*Math.pow(2,o),o+=7}while(i>=Bv);return xu.bytes=s-n,t}var Sv=Math.pow(2,7),Iv=Math.pow(2,14),Cv=Math.pow(2,21),Tv=Math.pow(2,28),kv=Math.pow(2,35),Rv=Math.pow(2,42),Nv=Math.pow(2,49),Uv=Math.pow(2,56),_v=Math.pow(2,63),Dv=function(r){return r<Sv?1:r<Iv?2:r<Cv?3:r<Tv?4:r<kv?5:r<Rv?6:r<Nv?7:r<Uv?8:r<_v?9:10},Lv={encode:wv,decode:Av,encodingLength:Dv},Ov=Lv,Go=Ov;var jo=(r,e=0)=>[Go.decode(r,e),Go.decode.bytes],zn=(r,e,t=0)=>(Go.encode(r,e,t),e),qn=r=>Go.encodingLength(r);var Zr=(r,e)=>{let t=e.byteLength,n=qn(r),o=n+qn(t),s=new Uint8Array(o+t);return zn(r,s,0),zn(t,s,n),s.set(e,o),new Gn(r,t,e,s)},v0=r=>{let e=Qt(r),[t,n]=jo(e),[o,s]=jo(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Gn(t,o,i,e)},E0=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&h0(r.bytes,t.bytes)}},Gn=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var A0=0,Vv="identity",B0=Qt,Pv=r=>Zr(A0,B0(r)),Mv={code:A0,name:Vv,encode:B0,digest:Pv};var Bu={};M(Bu,{sha256:()=>Fv,sha512:()=>$v});var Au=({name:r,code:e,encode:t})=>new Eu(r,e,t),Eu=class{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?Zr(this.code,t):t.then(n=>Zr(this.code,n))}else throw Error("Unknown type, must be binary type")}};var I0=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Fv=Au({name:"sha2-256",code:18,encode:I0("SHA-256")}),$v=Au({name:"sha2-512",code:19,encode:I0("SHA-512")});var C0=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Kv(t,Su(r),e||Rt.encoder);default:return zv(t,Su(r),e||Kn.encoder)}};var T0=new WeakMap,Su=r=>{let e=T0.get(r);if(e==null){let t=new Map;return T0.set(r,t),t}return e},Zi=class r{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!==Yo)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==qv)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=Zr(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&&e.code===n.code&&e.version===n.version&&E0(e.multihash,n.multihash)}toString(e){return C0(this,e)}toJSON(){return{"/":C0(this)}}link(){return this}get[Symbol.toStringTag](){return"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:s,bytes:i}=t;return new r(n,o,s,i||k0(n,o,s.bytes))}else if(t[Gv]===!0){let{version:n,multihash:o,code:s}=t,i=v0(o);return r.create(n,s,i)}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!==Yo)throw new Error(`Version 0 CID must use dag-pb (code: ${Yo}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=k0(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Yo,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=Qt(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new Gn(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,p]=jo(e.subarray(t));return t+=p,l},o=n(),s=Yo;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),c=n(),f=t+c,u=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=Hv(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Su(s).set(n,e),s}},Hv=(r,e)=>{switch(r[0]){case"Q":{let t=e||Rt;return[Rt.prefix,t.decode(`${Rt.prefix}${r}`)]}case Rt.prefix:{let t=e||Rt;return[Rt.prefix,t.decode(r)]}case Kn.prefix:{let t=e||Kn;return[Kn.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)]}}},Kv=(r,e,t)=>{let{prefix:n}=t;if(n!==Rt.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},zv=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},Yo=112,qv=18,k0=(r,e,t)=>{let n=qn(r),o=n+qn(e),s=new Uint8Array(o+t.byteLength);return zn(r,s,0),zn(e,s,n),s.set(t,o),s},Gv=Symbol.for("@ipld/js-cid/CID");var Iu={...wu,...hu,...bu,...lu,...fu,...pu,...mu,...gu,...yu,...du},eC={...Bu,...vu};function jn(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Ji(r=0){return globalThis.Buffer?.allocUnsafe!=null?jn(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function N0(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var R0=N0("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Cu=N0("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=Ji(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),jv={utf8:R0,"utf-8":R0,hex:Iu.base16,latin1:Cu,ascii:Cu,binary:Cu,...Iu},Xi=jv;function Ke(r,e="utf8"){let t=Xi[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var U0=ji,Wv=Wi,Tu=function(r){let e=0;if(r=r.toString().trim(),U0(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(Wv(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=U0(t[n]),i;s&&(i=Tu(t[n]),t[n]=Ke(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,Ke(i.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let s=[n,1];for(n=9-t.length;n>0;n--)s.push("0");t.splice.apply(t,s)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){let s=parseInt(t[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},_0=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let s=0;s<t;s++)o.push(r[e+s]);return o.join(".")}if(t===16){let o=[];for(let s=0;s<t;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Zo={},ku={},Zv=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc"],[281,0,"webrtc-w3c"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];Zv.forEach(r=>{let e=Jv(...r);ku[e.code]=e,Zo[e.name]=e});function Jv(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function le(r){if(typeof r=="number"){if(ku[r]!=null)return ku[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Zo[r]!=null)return Zo[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var D0=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Qv(t,Ru(r),e||He.encoder);default:return e2(t,Ru(r),e||kt.encoder)}};var L0=new WeakMap,Ru=r=>{let e=L0.get(r);if(e==null){let t=new Map;return L0.set(r,t),t}return e},ut=class r{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!==Jo)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==t2)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=Wr(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&&e.code===n.code&&e.version===n.version&&u0(e.multihash,n.multihash)}toString(e){return D0(this,e)}toJSON(){return{"/":D0(this)}}link(){return this}get[Symbol.toStringTag](){return"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:s,bytes:i}=t;return new r(n,o,s,i||O0(n,o,s.bytes))}else if(t[r2]===!0){let{version:n,multihash:o,code:s}=t,i=qo(o);return r.create(n,s,i)}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!==Jo)throw new Error(`Version 0 CID must use dag-pb (code: ${Jo}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=O0(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Jo,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=Xt(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new Fn(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,p]=zo(e.subarray(t));return t+=p,l},o=n(),s=Jo;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),c=n(),f=t+c,u=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=Xv(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ru(s).set(n,e),s}},Xv=(r,e)=>{switch(r[0]){case"Q":{let t=e||He;return[He.prefix,t.decode(`${He.prefix}${r}`)]}case He.prefix:{let t=e||He;return[He.prefix,t.decode(r)]}case kt.prefix:{let t=e||kt;return[kt.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)]}}},Qv=(r,e,t)=>{let{prefix:n}=t;if(n!==He.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},e2=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},Jo=112,t2=18,O0=(r,e,t)=>{let n=Mn(r),o=n+Mn(e),s=new Uint8Array(o+t.byteLength);return Pn(r,s,0),Pn(e,s,n),s.set(t,o),s},r2=Symbol.for("@ipld/js-cid/CID");var Nu={};M(Nu,{identity:()=>n2});var n2=Vn({prefix:"\0",name:"identity",encode:r=>n0(r),decode:r=>r0(r)});var Uu={};M(Uu,{base2:()=>o2});var o2=pe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var _u={};M(_u,{base8:()=>s2});var s2=pe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Du={};M(Du,{base10:()=>i2});var i2=Br({prefix:"9",name:"base10",alphabet:"0123456789"});var Lu={};M(Lu,{base16:()=>a2,base16upper:()=>c2});var a2=pe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),c2=pe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ou={};M(Ou,{base36:()=>u2,base36upper:()=>l2});var u2=Br({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),l2=Br({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Vu={};M(Vu,{base64:()=>f2,base64pad:()=>h2,base64url:()=>d2,base64urlpad:()=>p2});var f2=pe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),h2=pe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),d2=pe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),p2=pe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Pu={};M(Pu,{base256emoji:()=>w2});var V0=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}"),m2=V0.reduce((r,e,t)=>(r[t]=e,r),[]),g2=V0.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function y2(r){return r.reduce((e,t)=>(e+=m2[t],e),"")}function b2(r){let e=[];for(let t of r){let n=g2[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var w2=Vn({prefix:"\u{1F680}",name:"base256emoji",encode:y2,decode:b2});var $u={};M($u,{sha256:()=>x2,sha512:()=>v2});var Fu=({name:r,code:e,encode:t})=>new Mu(r,e,t),Mu=class{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?Wr(this.code,t):t.then(n=>Wr(this.code,n))}else throw Error("Unknown type, must be binary type")}};var M0=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),x2=Fu({name:"sha2-256",code:18,encode:M0("SHA-256")}),v2=Fu({name:"sha2-512",code:19,encode:M0("SHA-512")});var Hu={};M(Hu,{identity:()=>B2});var F0=0,E2="identity",$0=Xt,A2=r=>Wr(F0,$0(r)),B2={code:F0,name:E2,encode:$0,digest:A2};var NC=new TextEncoder,UC=new TextDecoder;var H0={...Nu,...Uu,..._u,...Du,...Lu,...ru,...Ou,...tu,...Vu,...Pu},VC={...$u,...Hu};var Nt=Se(Qi(),1);function qu(r,e="utf8"){let t=Xi[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?jn(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function er(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=Ji(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return jn(t)}function rm(r,e){switch(le(r).code){case 4:case 41:return $2(e);case 42:return em(e);case 6:case 273:case 33:case 132:return om(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return em(e);case 421:return q2(e);case 444:return tm(e);case 445:return tm(e);case 466:return z2(e);default:return Ke(e,"base16")}}function nm(r,e){switch(le(r).code){case 4:return X0(e);case 41:return X0(e);case 42:return Q0(e);case 6:case 273:case 33:case 132:return ju(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Q0(e);case 421:return H2(e);case 444:return G2(e);case 445:return j2(e);case 466:return K2(e);default:return qu(e,"base16")}}var Gu=Object.values(H0).map(r=>r.decoder),F2=function(){let r=Gu[0].or(Gu[1]);return Gu.slice(2).forEach(e=>r=r.or(e)),r}();function X0(r){if(!Sr(r))throw new Error("invalid ip address");return Tu(r)}function $2(r){let e=_0(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Sr(e))throw new Error("invalid ip address");return e}function ju(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function om(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Q0(r){let e=qu(r),t=Uint8Array.from(Nt.default.encode(e.length));return er([t,e],t.length+e.length)}function em(r){let e=Nt.default.decode(r);if(r=r.slice(Nt.default.decode.bytes),r.length!==e)throw new Error("inconsistent lengths");return Ke(r)}function H2(r){let e;r[0]==="Q"||r[0]==="1"?e=qo(He.decode(`z${r}`)).bytes:e=ut.parse(r).multihash.bytes;let t=Uint8Array.from(Nt.default.encode(e.length));return er([t,e],t.length+e.length)}function K2(r){let e=F2.decode(r),t=Uint8Array.from(Nt.default.encode(e.length));return er([t,e],t.length+e.length)}function z2(r){let e=Nt.default.decode(r),t=r.slice(Nt.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return"u"+Ke(t,"base64url")}function q2(r){let e=Nt.default.decode(r),t=r.slice(Nt.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return Ke(t,"base58btc")}function G2(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=kt.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ju(n);return er([t,o],t.length+o.length)}function j2(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=kt.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ju(n);return er([t,o],t.length+o.length)}function tm(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=Ke(e,"base32"),o=om(t);return`${n}:${o}`}var Wn=Se(Qi(),1);function W2(r){let e=[],t=r.split("/").slice(1);if(t.length===1&&t[0]==="")return[];for(let n=0;n<t.length;n++){let o=t[n],s=le(o);if(s.size===0){e.push([o]);continue}if(n++,n>=t.length)throw im("invalid address: "+r);if(s.path===!0){e.push([o,Xu(t.slice(n).join("/"))]);break}e.push([o,t[n]])}return e}function Y2(r){let e=[];return r.map(t=>{let n=ra(t);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),Xu(e.join("/"))}function Z2(r){return r.map(e=>{Array.isArray(e)||(e=[e]);let t=ra(e);return e.length>1?[t.code,nm(t.code,e[1])]:[t.code]})}function Wu(r){return r.map(e=>{let t=ra(e);return e[1]!=null?[t.code,rm(t.code,e[1])]:[t.code]})}function Yu(r){return ta(er(r.map(e=>{let t=ra(e),n=Uint8Array.from(Wn.default.encode(t.code));return e.length>1&&e[1]!=null&&(n=er([n,e[1]])),n})))}function Zu(r,e){return r.size>0?r.size/8:r.size===0?0:Wn.default.decode(e)+(Wn.default.decode.bytes??0)}function ea(r){let e=[],t=0;for(;t<r.length;){let n=Wn.default.decode(r,t),o=Wn.default.decode.bytes??0,s=le(n),i=Zu(s,r.slice(t+o));if(i===0){e.push([n]),t+=o;continue}let a=r.slice(t+o,t+o+i);if(t+=i+o,t>r.length)throw im("Invalid address Uint8Array: "+Ke(r,"base16"));e.push([n,a])}return e}function Ju(r){let e=ea(r),t=Wu(e);return Y2(t)}function J2(r){r=Xu(r);let e=W2(r),t=Z2(e);return Yu(t)}function sm(r){return J2(r)}function ta(r){let e=X2(r);if(e!=null)throw e;return Uint8Array.from(r)}function X2(r){try{ea(r)}catch(e){return e}}function Xu(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function im(r){return new Error("Error parsing address: "+r)}function ra(r){return le(r[0])}var el=Se(Qi(),1);var lm=Se(Do(),1);function am(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 Yn=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Qu=function(r,e,t,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!o:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(r,t):o?o.value=t:e.set(r,t),t},Xo,Qo,es,cm,eE=Symbol.for("nodejs.util.inspect.custom"),tE=[le("dns").code,le("dns4").code,le("dns6").code,le("dnsaddr").code],rE=new Map,fm=Symbol.for("@multiformats/js-multiaddr/multiaddr");function nE(r){return!!r?.[fm]}var um=class r{constructor(e){if(Xo.set(this,void 0),Qo.set(this,void 0),es.set(this,void 0),this[cm]=!0,e==null&&(e=""),e instanceof Uint8Array)this.bytes=ta(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=sm(e)}else if(nE(e))this.bytes=ta(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return Yn(this,Xo,"f")==null&&Qu(this,Xo,Ju(this.bytes),"f"),Yn(this,Xo,"f")}toJSON(){return this.toString()}toOptions(){let e,t,n,o,s="",i=le("tcp"),a=le("udp"),c=le("ip4"),f=le("ip6"),u=le("dns6"),l=le("ip6zone");for(let[x,d]of this.stringTuples())x===l.code&&(s=`%${d??""}`),tE.includes(x)&&(t=i.name,o=443,n=`${d??""}${s}`,e=x===u.code?6:4),(x===i.code||x===a.code)&&(t=le(x).name,o=parseInt(d??"")),(x===c.code||x===f.code)&&(t=le(x).name,n=`${d??""}${s}`,e=x===f.code?6:4);if(e==null||t==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:o}}protos(){return this.protoCodes().map(e=>Object.assign({},le(e)))}protoCodes(){let e=[],t=this.bytes,n=0;for(;n<t.length;){let o=el.default.decode(t,n),s=el.default.decode.bytes??0,i=le(o),a=Zu(i,t.slice(n+s));n+=a+s,e.push(o)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return Yn(this,Qo,"f")==null&&Qu(this,Qo,ea(this.bytes),"f"),Yn(this,Qo,"f")}stringTuples(){return Yn(this,es,"f")==null&&Qu(this,es,Wu(this.tuples()),"f"),Yn(this,es,"f")}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(Yu(t.slice(0,n)));return this}getPeerId(){try{let t=this.stringTuples().filter(n=>n[0]===Zo.ipfs.code).pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?Ke(He.decode(`z${n}`),"base58btc"):Ke(ut.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let e=null;try{e=this.stringTuples().filter(t=>le(t[0]).path===!0)[0][1],e==null&&(e=null)}catch{e=null}return e}equals(e){return am(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=rE.get(t.name);if(n==null)throw(0,lm.default)(new Error(`no available resolver for ${t.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new r(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[(Xo=new WeakMap,Qo=new WeakMap,es=new WeakMap,cm=fm,eE)](){return`Multiaddr(${Ju(this.bytes)})`}};var sl={};M(sl,{base58btc:()=>We,base58flickr:()=>uE});var mT=new Uint8Array(0);function hm(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 tr(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 dm(r){return new TextEncoder().encode(r)}function pm(r){return new TextDecoder().decode(r)}function oE(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 s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=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(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var h=0,m=0,g=0,A=d.length;g!==A&&d[g]===0;)g++,h++;for(var b=(A-g)*u+1>>>0,S=new Uint8Array(b);g!==A;){for(var v=d[g],I=0,C=b-1;(v!==0||I<m)&&C!==-1;C--,I++)v+=256*S[C]>>>0,S[C]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");m=I,g++}for(var y=b-m;y!==b&&S[y]===0;)y++;for(var k=c.repeat(h);y<b;++y)k+=r.charAt(S[y]);return k}function p(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var h=0;if(d[h]!==" "){for(var m=0,g=0;d[h]===c;)m++,h++;for(var A=(d.length-h)*f+1>>>0,b=new Uint8Array(A);d[h];){var S=t[d.charCodeAt(h)];if(S===255)return;for(var v=0,I=A-1;(S!==0||v<g)&&I!==-1;I--,v++)S+=a*b[I]>>>0,b[I]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");g=v,h++}if(d[h]!==" "){for(var C=A-g;C!==A&&b[C]===0;)C++;for(var y=new Uint8Array(m+(A-C)),k=m;C!==A;)y[k++]=b[C++];return y}}}function x(d){var h=p(d);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:x}}var sE=oE,iE=sE,gm=iE;var tl=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")}},rl=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 ym(this,e)}},nl=class{decoders;constructor(e){this.decoders=e}or(e){return ym(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 ym(r,e){return new nl({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var ol=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 tl(e,t,n),this.decoder=new rl(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Zn({name:r,prefix:e,encode:t,decode:n}){return new ol(r,e,t,n)}function Cr({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=gm(t,r);return Zn({prefix:e,name:r,encode:n,decode:s=>tr(o(s))})}function aE(r,e,t,n){let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,c=0,f=0;for(let u=0;u<s;++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,i[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function cE(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s}function ge({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Zn({prefix:e,name:r,encode(o){return cE(o,n,t)},decode(o){return aE(o,n,t,r)}})}var We=Cr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),uE=Cr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var il={};M(il,{base32:()=>rr,base32hex:()=>dE,base32hexpad:()=>mE,base32hexpadupper:()=>gE,base32hexupper:()=>pE,base32pad:()=>fE,base32padupper:()=>hE,base32upper:()=>lE,base32z:()=>yE});var rr=ge({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),lE=ge({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),fE=ge({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),hE=ge({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),dE=ge({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),pE=ge({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),mE=ge({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),gE=ge({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),yE=ge({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var bE=xm,bm=128,wE=127,xE=~wE,vE=Math.pow(2,31);function xm(r,e,t){e=e||[],t=t||0;for(var n=t;r>=vE;)e[t++]=r&255|bm,r/=128;for(;r&xE;)e[t++]=r&255|bm,r>>>=7;return e[t]=r|0,xm.bytes=t-n+1,e}var EE=al,AE=128,wm=127;function al(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw al.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&wm)<<o:(i&wm)*Math.pow(2,o),o+=7}while(i>=AE);return al.bytes=s-n,t}var BE=Math.pow(2,7),SE=Math.pow(2,14),IE=Math.pow(2,21),CE=Math.pow(2,28),TE=Math.pow(2,35),kE=Math.pow(2,42),RE=Math.pow(2,49),NE=Math.pow(2,56),UE=Math.pow(2,63),_E=function(r){return r<BE?1:r<SE?2:r<IE?3:r<CE?4:r<TE?5:r<kE?6:r<RE?7:r<NE?8:r<UE?9:10},DE={encode:bE,decode:EE,encodingLength:_E},LE=DE,ts=LE;function rs(r,e=0){return[ts.decode(r,e),ts.decode.bytes]}function Jn(r,e,t=0){return ts.encode(r,e,t),e}function Xn(r){return ts.encodingLength(r)}function Jr(r,e){let t=e.byteLength,n=Xn(r),o=n+Xn(t),s=new Uint8Array(o+t);return Jn(r,s,0),Jn(t,s,n),s.set(e,o),new Qn(r,t,e,s)}function oa(r){let e=tr(r),[t,n]=rs(e),[o,s]=rs(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Qn(t,o,i,e)}function vm(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&hm(r.bytes,t.bytes)}}var Qn=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};function Em(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return VE(t,cl(r),e??We.encoder);default:return PE(t,cl(r),e??rr.encoder)}}var Am=new WeakMap;function cl(r){let e=Am.get(r);if(e==null){let t=new Map;return Am.set(r,t),t}return e}var Tr=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!==ns)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==ME)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=Jr(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&&vm(e.multihash,n.multihash)}toString(e){return Em(this,e)}toJSON(){return{"/":Em(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:s,bytes:i}=t;return new r(n,o,s,i??Bm(n,o,s.bytes))}else if(t[FE]===!0){let{version:n,multihash:o,code:s}=t,i=oa(o);return r.create(n,s,i)}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!==ns)throw new Error(`Version 0 CID must use dag-pb (code: ${ns}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Bm(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,ns,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=tr(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new Qn(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,p]=rs(e.subarray(t));return t+=p,l},o=n(),s=ns;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),c=n(),f=t+c,u=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=OE(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return cl(s).set(n,e),s}};function OE(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 rr.prefix:{let t=e??rr;return[rr.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 VE(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 s=t.encode(r).slice(1);return e.set(n,s),s}else return o}function PE(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o}var ns=112,ME=18;function Bm(r,e,t){let n=Xn(r),o=n+Xn(e),s=new Uint8Array(o+t.byteLength);return Jn(r,s,0),Jn(e,s,n),s.set(t,o),s}var FE=Symbol.for("@ipld/js-cid/CID");function Sm(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 ul={};M(ul,{base10:()=>$E});var $E=Cr({prefix:"9",name:"base10",alphabet:"0123456789"});var ll={};M(ll,{base16:()=>HE,base16upper:()=>KE});var HE=ge({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),KE=ge({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var fl={};M(fl,{base2:()=>zE});var zE=ge({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var hl={};M(hl,{base256emoji:()=>YE});var Im=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}"),qE=Im.reduce((r,e,t)=>(r[t]=e,r),[]),GE=Im.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function jE(r){return r.reduce((e,t)=>(e+=qE[t],e),"")}function WE(r){let e=[];for(let t of r){let n=GE[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var YE=Zn({prefix:"\u{1F680}",name:"base256emoji",encode:jE,decode:WE});var dl={};M(dl,{base36:()=>ZE,base36upper:()=>JE});var ZE=Cr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),JE=Cr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var pl={};M(pl,{base64:()=>XE,base64pad:()=>QE,base64url:()=>e8,base64urlpad:()=>t8});var XE=ge({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),QE=ge({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),e8=ge({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),t8=ge({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ml={};M(ml,{base8:()=>r8});var r8=ge({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var gl={};M(gl,{identity:()=>n8});var n8=Zn({prefix:"\0",name:"identity",encode:r=>pm(r),decode:r=>dm(r)});var FT=new TextEncoder,$T=new TextDecoder;var yl={};M(yl,{identity:()=>c8});var Cm=0,i8="identity",Tm=tr;function a8(r){return Jr(Cm,Tm(r))}var c8={code:Cm,name:i8,encode:Tm,digest:a8};var xl={};M(xl,{sha256:()=>u8,sha512:()=>l8});function wl({name:r,code:e,encode:t}){return new bl(r,e,t)}var bl=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?Jr(this.code,t):t.then(n=>Jr(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Rm(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var u8=wl({name:"sha2-256",code:18,encode:Rm("SHA-256")}),l8=wl({name:"sha2-512",code:19,encode:Rm("SHA-512")});var os={...gl,...fl,...ml,...ul,...ll,...il,...dl,...sl,...pl,...hl},e5={...xl,...yl};function Xr(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function sa(r=0){return globalThis.Buffer?.allocUnsafe!=null?Xr(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Um(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Nm=Um("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),vl=Um("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=sa(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),f8={utf8:Nm,"utf-8":Nm,hex:os.base16,latin1:vl,ascii:vl,binary:vl,...os},ia=f8;function Ye(r,e="utf8"){let t=ia[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var h8=Math.pow(2,7),d8=Math.pow(2,14),p8=Math.pow(2,21),El=Math.pow(2,28),Al=Math.pow(2,35),Bl=Math.pow(2,42),Sl=Math.pow(2,49),re=128,Pe=127;function Ut(r){if(r<h8)return 1;if(r<d8)return 2;if(r<p8)return 3;if(r<El)return 4;if(r<Al)return 5;if(r<Bl)return 6;if(r<Sl)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function m8(r,e,t=0){switch(Ut(r)){case 8:e[t++]=r&255|re,r/=128;case 7:e[t++]=r&255|re,r/=128;case 6:e[t++]=r&255|re,r/=128;case 5:e[t++]=r&255|re,r/=128;case 4:e[t++]=r&255|re,r>>>=7;case 3:e[t++]=r&255|re,r>>>=7;case 2:e[t++]=r&255|re,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function g8(r,e,t=0){switch(Ut(r)){case 8:e.set(t++,r&255|re),r/=128;case 7:e.set(t++,r&255|re),r/=128;case 6:e.set(t++,r&255|re),r/=128;case 5:e.set(t++,r&255|re),r/=128;case 4:e.set(t++,r&255|re),r>>>=7;case 3:e.set(t++,r&255|re),r>>>=7;case 2:e.set(t++,r&255|re),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function y8(r,e){let t=r[e],n=0;if(n+=t&Pe,t<re||(t=r[e+1],n+=(t&Pe)<<7,t<re)||(t=r[e+2],n+=(t&Pe)<<14,t<re)||(t=r[e+3],n+=(t&Pe)<<21,t<re)||(t=r[e+4],n+=(t&Pe)*El,t<re)||(t=r[e+5],n+=(t&Pe)*Al,t<re)||(t=r[e+6],n+=(t&Pe)*Bl,t<re)||(t=r[e+7],n+=(t&Pe)*Sl,t<re))return n;throw new RangeError("Could not decode varint")}function b8(r,e){let t=r.get(e),n=0;if(n+=t&Pe,t<re||(t=r.get(e+1),n+=(t&Pe)<<7,t<re)||(t=r.get(e+2),n+=(t&Pe)<<14,t<re)||(t=r.get(e+3),n+=(t&Pe)<<21,t<re)||(t=r.get(e+4),n+=(t&Pe)*El,t<re)||(t=r.get(e+5),n+=(t&Pe)*Al,t<re)||(t=r.get(e+6),n+=(t&Pe)*Bl,t<re)||(t=r.get(e+7),n+=(t&Pe)*Sl,t<re))return n;throw new RangeError("Could not decode varint")}function to(r,e,t=0){return e==null&&(e=lt(Ut(r))),e instanceof Uint8Array?m8(r,e,t):g8(r,e,t)}function Qr(r,e=0){return r instanceof Uint8Array?y8(r,e):b8(r,e)}function nr(r,e){if(globalThis.Buffer!=null)return Xr(globalThis.Buffer.concat(r,e));e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=sa(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return Xr(t)}var x5=parseInt("0xFFFF",16),v5=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Il(r,e="utf8"){let t=ia[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Xr(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var Om=ji,A8=Wi,Cl=function(r){let e=0;if(r=r.toString().trim(),Om(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(A8(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=Om(t[n]),i;s&&(i=Cl(t[n]),t[n]=Ye(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,Ye(i.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let s=[n,1];for(n=9-t.length;n>0;n--)s.push("0");t.splice.apply(t,s)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){let s=parseInt(t[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},Vm=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let s=0;s<t;s++)o.push(r[e+s]);return o.join(".")}if(t===16){let o=[];for(let s=0;s<t;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var ro={},Tl={},S8=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];S8.forEach(r=>{let e=I8(...r);Tl[e.code]=e,ro[e.name]=e});function I8(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function se(r){if(typeof r=="number"){if(Tl[r]!=null)return Tl[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(ro[r]!=null)return ro[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var sk=se("ip4"),ik=se("ip6"),ak=se("ipcidr");function Rl(r,e){switch(se(r).code){case 4:case 41:return T8(e);case 42:return Fm(e);case 6:case 273:case 33:case 132:return Hm(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Fm(e);case 421:return U8(e);case 444:return $m(e);case 445:return $m(e);case 466:return N8(e);default:return Ye(e,"base16")}}function Nl(r,e){switch(se(r).code){case 4:return Pm(e);case 41:return Pm(e);case 42:return Mm(e);case 6:case 273:case 33:case 132:return Ul(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Mm(e);case 421:return k8(e);case 444:return _8(e);case 445:return D8(e);case 466:return R8(e);default:return Il(e,"base16")}}var kl=Object.values(os).map(r=>r.decoder),C8=function(){let r=kl[0].or(kl[1]);return kl.slice(2).forEach(e=>r=r.or(e)),r}();function Pm(r){if(!Sr(r))throw new Error("invalid ip address");return Cl(r)}function T8(r){let e=Vm(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Sr(e))throw new Error("invalid ip address");return e}function Ul(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function Hm(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Mm(r){let e=Il(r),t=Uint8Array.from(to(e.length));return nr([t,e],t.length+e.length)}function Fm(r){let e=Qr(r);if(r=r.slice(Ut(e)),r.length!==e)throw new Error("inconsistent lengths");return Ye(r)}function k8(r){let e;r[0]==="Q"||r[0]==="1"?e=oa(We.decode(`z${r}`)).bytes:e=Tr.parse(r).multihash.bytes;let t=Uint8Array.from(to(e.length));return nr([t,e],t.length+e.length)}function R8(r){let e=C8.decode(r),t=Uint8Array.from(to(e.length));return nr([t,e],t.length+e.length)}function N8(r){let e=Qr(r),t=r.slice(Ut(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+Ye(t,"base64url")}function U8(r){let e=Qr(r),t=r.slice(Ut(e));if(t.length!==e)throw new Error("inconsistent lengths");return Ye(t,"base58btc")}function _8(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=rr.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ul(n);return nr([t,o],t.length+o.length)}function D8(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=rr.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ul(n);return nr([t,o],t.length+o.length)}function $m(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=Ye(e,"base32"),o=Hm(t);return`${n}:${o}`}function Km(r){r=_l(r);let e=[],t=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],a=se(i);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(s++,s>=o.length)throw qm("invalid address: "+r);if(a.path===!0){n=_l(o.slice(s).join("/")),e.push([a.code,Nl(a.code,n)]),t.push([a.code,n]);break}let c=Nl(a.code,o[s]);e.push([a.code,c]),t.push([a.code,Rl(a.code,c)])}return{string:zm(t),bytes:Ll(e),tuples:e,stringTuples:t,path:n}}function Dl(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let s=Qr(r,o),i=Ut(s),a=se(s),c=L8(a,r.slice(o+i));if(c===0){e.push([s]),t.push([s]),o+=i;continue}let f=r.slice(o+i,o+i+c);if(o+=c+i,o>r.length)throw qm("Invalid address Uint8Array: "+Ye(r,"base16"));e.push([s,f]);let u=Rl(s,f);if(t.push([s,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:zm(t),tuples:e,stringTuples:t,path:n}}function zm(r){let e=[];return r.map(t=>{let n=se(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),_l(e.join("/"))}function Ll(r){return nr(r.map(e=>{let t=se(e[0]),n=Uint8Array.from(to(t.code));return e.length>1&&e[1]!=null&&(n=nr([n,e[1]])),n}))}function L8(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Qr(e instanceof Uint8Array?e:Uint8Array.from(e));return t+Ut(t)}}function _l(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function qm(r){return new Error("Error parsing address: "+r)}var O8=Symbol.for("nodejs.util.inspect.custom"),Ol=Symbol.for("@multiformats/js-multiaddr/multiaddr"),V8=[se("dns").code,se("dns4").code,se("dns6").code,se("dnsaddr").code],aa=class r{bytes;#e;#t;#s;#a;[Ol]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=Dl(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=Km(e)}else if(jm(e))t=Dl(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#t=t.tuples,this.#s=t.stringTuples,this.#a=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,o,s="",i=se("tcp"),a=se("udp"),c=se("ip4"),f=se("ip6"),u=se("dns6"),l=se("ip6zone");for(let[x,d]of this.stringTuples())x===l.code&&(s=`%${d??""}`),V8.includes(x)&&(t=i.name,o=443,n=`${d??""}${s}`,e=x===u.code?6:4),(x===i.code||x===a.code)&&(t=se(x).name,o=parseInt(d??"")),(x===c.code||x===f.code)&&(t=se(x).name,n=`${d??""}${s}`,e=x===f.code?6:4);if(e==null||t==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:o}}protos(){return this.#t.map(([e])=>Object.assign({},se(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>se(e).name)}tuples(){return this.#t}stringTuples(){return this.#s}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(Ll(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===ro.p2p.code&&e.push([n,o]),n===ro["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?Ye(We.decode(`z${n}`),"base58btc"):Ye(Tr.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(e){return Sm(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=Gm.get(t.name);if(n==null)throw new K(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new r(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[O8](){return`Multiaddr(${this.#e})`}};var Gm=new Map;function jm(r){return!!r?.[Ol]}function ca(r){return new aa(r)}var P8=P("dns4"),M8=P("dns6"),F8=P("dnsaddr"),en=_e(P("dns"),F8,P8,M8),ua=_e(P("ip4"),P("ip6")),no=_e(G(ua,P("tcp")),G(en,P("tcp"))),Ml=G(ua,P("udp")),$8=G(Ml,P("utp")),H8=G(Ml,P("quic")),is=_e(G(no,P("ws")),G(en,P("ws"))),as=_e(G(no,P("wss")),G(en,P("wss")),G(no,P("tls"),P("ws")),G(en,P("tls"),P("ws"))),Vl=_e(G(no,P("http")),G(ua,P("http")),G(en,P("http"))),Pl=_e(G(no,P("https")),G(ua,P("https")),G(en,P("https"))),Wm=G(Ml,P("webrtc"),P("certhash")),Zm=_e(G(Wm,P("p2p")),Wm),Jm=_e(G(is,P("p2p-webrtc-star"),P("p2p")),G(as,P("p2p-webrtc-star"),P("p2p")),G(is,P("p2p-webrtc-star")),G(as,P("p2p-webrtc-star"))),_k=_e(G(is,P("p2p-websocket-star"),P("p2p")),G(as,P("p2p-websocket-star"),P("p2p")),G(is,P("p2p-websocket-star")),G(as,P("p2p-websocket-star"))),Xm=_e(G(Vl,P("p2p-webrtc-direct"),P("p2p")),G(Pl,P("p2p-webrtc-direct"),P("p2p")),G(Vl,P("p2p-webrtc-direct")),G(Pl,P("p2p-webrtc-direct"))),cs=_e(is,as,Vl,Pl,Jm,Xm,no,$8,H8,en,Zm),Dk=_e(G(cs,P("p2p-stardust"),P("p2p")),G(cs,P("p2p-stardust"))),kr=_e(G(cs,P("p2p")),Jm,Xm,Zm,P("p2p")),Ym=_e(G(kr,P("p2p-circuit"),kr),G(kr,P("p2p-circuit")),G(P("p2p-circuit"),kr),G(cs,P("p2p-circuit")),G(P("p2p-circuit"),cs),P("p2p-circuit")),Qm=()=>_e(G(Ym,Qm),Ym),ss=Qm(),K8=_e(G(ss,kr,ss),G(kr,ss),G(ss,kr),ss,kr);function eg(r){function e(t){let n;try{n=ca(t)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return e}function G(...r){function e(t){if(t.length<r.length)return null;let n=t;return r.some(o=>(n=typeof o=="function"?o().partialMatch(t):o.partialMatch(t),Array.isArray(n)&&(t=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:eg(e),partialMatch:e}}function _e(...r){function e(n){let o=null;return r.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:eg(e),partialMatch:e}}function P(r){let e=r;function t(o){let s;try{s=ca(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===e}function n(o){return o.length===0?null:o[0]===e?o.slice(1):null}return{toString:function(){return e},matches:t,partialMatch:n}}var eA=Se(ag(),1);function cg(r){try{return tA(r)?!!ut.parse(r):r instanceof Uint8Array?!!ut.decode(r):!!ut.asCID(r)}catch{return!1}}function tA(r){return typeof r=="string"}var ug=32,Hl=async(r,e,t,n={})=>{if(e===0)throw new Error("recursion limit exceeded");let o;try{o=await t(r,n)}catch(c){if(c.code!=="ENOTFOUND"&&c.code!=="ERR_DNSLINK_NOT_FOUND"&&c.code!=="ENODATA")throw c;r.startsWith("_dnslink.")?r=r.replace("_dnslink.",""):r=`_dnslink.${r}`,o=await t(r,n)}let s=o.replace("dnslink=",""),i=s.split("/")[2];return cg(i)?s:Hl(i,e-1,t,n)},nA=/^dnslink=.+$/,lg=async(r,e)=>{let o=(await r.resolveTxt(e)).flat().filter(s=>nA.test(s))[0];if(o==null)throw new K(`No dnslink records found for domain: ${e}`,"ERR_DNSLINK_NOT_FOUND");return o};var zl=Se(ga(),1),ql=Se(dg(),1);function la(r,e,t){return`${r}?name=${e}&type=${t}`}async function pg(r,e){return await(await fetch(r,{headers:new Headers({accept:"application/dns-json"}),signal:e})).json()}function tn(r,e){return`${e}_${r}`}var Kl=Object.assign((0,zl.default)("dns-over-http-resolver"),{error:(0,zl.default)("dns-over-http-resolver:error")}),Gl=class{_cache;_TXTcache;_servers;_request;_abortControllers;constructor(e={}){this._cache=new ql.default({max:e?.maxCache??100}),this._TXTcache=new ql.default({max:e?.maxCache??100}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"],this._request=e.request??pg,this._abortControllers=[]}cancel(){this._abortControllers.forEach(e=>{e.abort()})}getServers(){return this._servers}_getShuffledServers(){let e=[...this._servers];for(let t=e.length-1;t>0;t--){let n=Math.floor(Math.random()*t),o=e[t];e[t]=e[n],e[n]=o}return e}setServers(e){this._servers=e}async resolve(e,t="A"){switch(t){case"A":return this.resolve4(e);case"AAAA":return this.resolve6(e);case"TXT":return this.resolveTxt(e);default:throw new Error(`${t} is not supported`)}}async resolve4(e){let t="A",n=this._cache.get(tn(e,t));if(n!=null)return n;let o=!1;for(let s of this._getShuffledServers()){let i=new AbortController;this._abortControllers.push(i);try{let a=await this._request(la(s,e,t),i.signal),c=a.Answer.map(u=>u.data),f=Math.min(...a.Answer.map(u=>u.TTL));return this._cache.set(tn(e,t),c,{ttl:f}),c}catch{i.signal.aborted&&(o=!0),Kl.error(`${s} could not resolve ${e} record ${t}`)}finally{this._abortControllers=this._abortControllers.filter(a=>a!==i)}}throw o?Object.assign(new Error("queryA ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record ${t}`)}async resolve6(e){let t="AAAA",n=this._cache.get(tn(e,t));if(n!=null)return n;let o=!1;for(let s of this._getShuffledServers()){let i=new AbortController;this._abortControllers.push(i);try{let a=await this._request(la(s,e,t),i.signal),c=a.Answer.map(u=>u.data),f=Math.min(...a.Answer.map(u=>u.TTL));return this._cache.set(tn(e,t),c,{ttl:f}),c}catch{i.signal.aborted&&(o=!0),Kl.error(`${s} could not resolve ${e} record ${t}`)}finally{this._abortControllers=this._abortControllers.filter(a=>a!==i)}}throw o?Object.assign(new Error("queryAaaa ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record ${t}`)}async resolveTxt(e){let t="TXT",n=this._TXTcache.get(tn(e,t));if(n!=null)return n;let o=!1;for(let s of this._getShuffledServers()){let i=new AbortController;this._abortControllers.push(i);try{let a=await this._request(la(s,e,t),i.signal),c=a.Answer.map(u=>[u.data.replace(/['"]+/g,"")]),f=Math.min(...a.Answer.map(u=>u.TTL));return this._TXTcache.set(tn(e,t),c,{ttl:f}),c}catch{i.signal.aborted&&(o=!0),Kl.error(`${s} could not resolve ${e} record ${t}`)}finally{this._abortControllers=this._abortControllers.filter(a=>a!==i)}}throw o?Object.assign(new Error("queryTxt ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record ${t}`)}clearCache(){this._cache.clear(),this._TXTcache.clear()}},mg=Gl;var Wl=Se(yg(),1);var fs=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Yl=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},bg=r=>globalThis.DOMException===void 0?new Yl(r):new DOMException(r),wg=r=>{let e=r.reason===void 0?bg("This operation was aborted."):r.reason;return e instanceof Error?e:bg(e)};function Zl(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:s={setTimeout,clearTimeout}}=e,i,c=new Promise((f,u)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){let{signal:p}=e;p.aborted&&u(wg(p)),p.addEventListener("abort",()=>{u(wg(p))})}if(t===Number.POSITIVE_INFINITY){r.then(f,u);return}let l=new fs;i=s.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(p){u(p)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?f():o instanceof Error?u(o):(l.message=o??`Promise timed out after ${t} milliseconds`,u(l))},t),(async()=>{try{f(await r)}catch(p){u(p)}})()}).finally(()=>{c.clear()});return c.clear=()=>{s.clearTimeout.call(void 0,i),i=void 0},c}function Jl(r,e,t){let n=0,o=r.length;for(;o>0;){let s=Math.trunc(o/2),i=n+s;t(r[i],e)<=0?(n=++i,o-=s+1):o=s}return n}var hs=class{#e=[];enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&this.#e[this.size-1].priority>=t.priority){this.#e.push(n);return}let o=Jl(this.#e,n,(s,i)=>i.priority-s.priority);this.#e.splice(o,0,n)}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return this.#e.length}};var ds=class extends Wl.default{#e;#t;#s=0;#a;#c;#p=0;#n;#u;#r;#m;#o=0;#l;#i;#g;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:hs,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#t=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#a=e.intervalCap,this.#c=e.interval,this.#r=new e.queueClass,this.#m=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#g=e.throwOnTimeout===!0,this.#i=e.autoStart===!1}get#w(){return this.#t||this.#s<this.#a}get#x(){return this.#o<this.#l}#v(){this.#o--,this.#f(),this.emit("next")}#E(){this.#b(),this.#y(),this.#u=void 0}get#A(){let e=Date.now();if(this.#n===void 0){let t=this.#p-e;if(t<0)this.#s=this.#e?this.#o:0;else return this.#u===void 0&&(this.#u=setTimeout(()=>{this.#E()},t)),!0}return!1}#f(){if(this.#r.size===0)return this.#n&&clearInterval(this.#n),this.#n=void 0,this.emit("empty"),this.#o===0&&this.emit("idle"),!1;if(!this.#i){let e=!this.#A;if(this.#w&&this.#x){let t=this.#r.dequeue();return t?(this.emit("active"),t(),e&&this.#y(),!0):!1}}return!1}#y(){this.#t||this.#n!==void 0||(this.#n=setInterval(()=>{this.#b()},this.#c),this.#p=Date.now()+this.#c)}#b(){this.#s===0&&this.#o===0&&this.#n&&(clearInterval(this.#n),this.#n=void 0),this.#s=this.#e?this.#o:0,this.#h()}#h(){for(;this.#f(););}get concurrency(){return this.#l}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#l=e,this.#h()}async#B(e){return new Promise((t,n)=>{e.addEventListener("abort",()=>{n(e.reason)},{once:!0})})}async add(e,t={}){return t={timeout:this.timeout,throwOnTimeout:this.#g,...t},new Promise((n,o)=>{this.#r.enqueue(async()=>{this.#o++,this.#s++;try{t.signal?.throwIfAborted();let s=e({signal:t.signal});t.timeout&&(s=Zl(Promise.resolve(s),{milliseconds:t.timeout})),t.signal&&(s=Promise.race([s,this.#B(t.signal)]));let i=await s;n(i),this.emit("completed",i)}catch(s){if(s instanceof fs&&!t.throwOnTimeout){n();return}o(s),this.emit("error",s)}finally{this.#v()}},t),this.emit("add"),this.#f()})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return this.#i?(this.#i=!1,this.#h(),this):this}pause(){this.#i=!0}clear(){this.#r=new this.#m}async onEmpty(){this.#r.size!==0&&await this.#d("empty")}async onSizeLessThan(e){this.#r.size<e||await this.#d("next",()=>this.#r.size<e)}async onIdle(){this.#o===0&&this.#r.size===0||await this.#d("idle")}async#d(e,t){return new Promise(n=>{let o=()=>{t&&!t()||(this.off(e,o),n())};this.on(e,o)})}get size(){return this.#r.size}sizeBy(e){return this.#r.filter(e).length}get pending(){return this.#o}get isPaused(){return this.#i}};var Eg=Se(vg(),1),ha=class{lru;constructor(e){this.lru=(0,Eg.default)(e)}get(e){let t=this.lru.get(e);if(t!=null){if(t.expire!=null&&t.expire<Date.now()){this.lru.remove(e);return}return t.value}}set(e,t,n){this.lru.set(e,{value:t,expire:Date.now()+n})}has(e){return this.get(e)!=null}remove(e){this.lru.remove(e)}clear(){this.lru.clear()}};var Xl=new ha(1e3),lA=60*1e3,fA=new ds({concurrency:4}),hA=async function(e,t={}){let n=new mg({maxCache:0});if(t.nocache!==!0&&Xl.has(e)){let s=Xl.get(e);if(s!=null)return t?.onProgress?.(new Ue("dnslink:cache",{detail:s})),s}t.onProgress?.(new Ue("dnslink:query",{detail:e}));let o=await fA.add(async()=>{let s=await lg(n,e);return t.onProgress?.(new Ue("dnslink:answer",{detail:s})),Xl.set(e,s,lA),s},{signal:t?.signal});if(o==null)throw new Error("No DNS response received");return o},Ag=hA;function Bg(){return async(r,e={})=>Hl(r,ug,Ag,e)}var Ql=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 Ue("ipns:routing:helia:error",o))}}async get(e,t={}){try{return await this.routing.get(e,t)}catch(n){t.onProgress?.(new Ue("ipns:routing:helia:error",n))}throw new Error("Not found")}};function Sg(r){return new Ql(r)}var ps;(function(r){let e;r.codec=()=>(e==null&&(e=mr((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)=>{let o={key:new Uint8Array(0),value:new Uint8Array(0),timeReceived:""},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let i=t.uint32();switch(i>>>3){case 1:o.key=t.bytes();break;case 2:o.value=t.bytes();break;case 5:o.timeReceived=t.string();break;default:t.skipType(i&7);break}}return o})),e),r.encode=t=>pr(t,r.codec()),r.decode=t=>dr(t,r.codec())})(ps||(ps={}));function Ig(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"),s=String(r.getUTCMinutes()).padStart(2,"0"),i=String(r.getUTCSeconds()).padStart(2,"0"),a=r.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${e}-${t}-${n}T${o}:${s}:${i}.${c}Z`}function Cg(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,s=parseInt(t[3],10),i=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,s,i,a,c,f))}var oo=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 ps.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:Ig(this.timeReceived)}}static deserialize(e){let t=ps.decode(e);return new r(t.key,t.value,new Date(t.timeReceived))}static fromDeserialized(e){let t=Cg(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 Tg;(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"})(Tg||(Tg={}));var kg;(function(r){r[r.PUT_VALUE=0]="PUT_VALUE",r[r.GET_VALUE=1]="GET_VALUE",r[r.ADD_PROVIDER=2]="ADD_PROVIDER",r[r.GET_PROVIDERS=3]="GET_PROVIDERS",r[r.FIND_NODE=4]="FIND_NODE",r[r.PING=5]="PING"})(kg||(kg={}));function ef(r){return new Nn("/dht/record/"+ue(r,"base32"),!1)}function Rg(r){return{async put(e,t,n={}){try{let o=ef(e),s=new oo(e,t,new Date);n.onProgress?.(new Ue("ipns:routing:datastore:put")),await r.put(o,s.serialize(),n)}catch(o){throw n.onProgress?.(new Ue("ipns:routing:datastore:error",o)),o}},async get(e,t={}){try{let n=ef(e);t.onProgress?.(new Ue("ipns:routing:datastore:get"));let o=await r.get(n,t);return oo.deserialize(o).value}catch(n){throw t.onProgress?.(new Ue("ipns:routing:datastore:error",n)),n}},async has(e,t={}){let n=ef(e);return r.has(n,t)}}}var so=ir("helia:ipns"),pA=60*1e3,Ng=60*pA,mA=24*Ng,tf=23*Ng,rf=class{routers;localStore;timeout;defaultResolvers;constructor(e,t=[],n=[]){this.routers=[Sg(e.routing),...t],this.localStore=Rg(e.datastore),this.defaultResolvers=n.length>0?n:[Bg()]}async publish(e,t,n={}){try{let o=1n,s=$i(e);if(await this.localStore.has(s,n)){let c=await this.localStore.get(s,n);o=Jt(c).sequence+1n}let i=await Xp(e,t,o,n.lifetime??mA,n),a=Gc(i);return await this.localStore.put(s,a,n),n.offline!==!0&&await Promise.all(this.routers.map(async c=>{await c.put(s,a,n)})),i}catch(o){throw n.onProgress?.(new Ue("ipns:publish:error",o)),o}}async resolve(e,t={}){let n=$i(e),o=await this.#t(n,t);return this.#e(o.value,t)}async resolveDns(e,t={}){let n=t.resolvers??this.defaultResolvers,o=await Promise.any(n.map(async s=>s(e,t)));return this.#e(o,t)}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 Ue("ipns:republish:start"));let s=Date.now()-n,i=tf-s;i<0&&(i=e.interval??tf),setTimeout(()=>{t().catch(a=>{so.error("error republishing",a)})},i)}this.timeout=setTimeout(()=>{t().catch(n=>{so.error("error republishing",n)})},e.interval??tf)}async#e(e,t={}){let n=e.split("/");if(n.length===3){let o=n[1];if(o==="ipns")return this.resolve(Ma(n[2]),t);if(o==="ipfs")return Xe.parse(n[2])}throw so.error("invalid ipfs path %s",e),new Error("Invalid value")}async#t(e,t={}){let n=[this.localStore,...this.routers];t.offline===!0&&(n=[this.localStore]);let o=[],s=0;if(await Promise.all(n.map(async a=>{let c;try{c=await a.get(e,{...t,validate:!1})}catch(f){a===this.localStore&&f.code==="ERR_NOT_FOUND"?so("did not have record locally"):so.error("error finding IPNS record",f);return}try{await Zc(e,c),o.push(c)}catch(f){s++,so.error("error finding IPNS record",f)}})),o.length===0)throw s>0?new K(`${s>1?`${s} records`:"Record"} found for routing key ${s>1?"were":"was"} invalid`,"ERR_RECORDS_FAILED_VALIDATION"):new K("Could not find record for routing key","ERR_NOT_FOUND");let i=o[Hi(e,o)];return await this.localStore.put(e,i,t),Jt(i)}};function gA(r,{routers:e=[],resolvers:t=[]}={}){return new rf(r,e,t)}return qg(yA);})();
9
9
  /*! Bundled license information:
10
10
 
11
11
  pvtsutils/build/index.js: