@libp2p/daemon-client 5.0.1 → 5.0.2

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,7 +1,7 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PDaemonClient = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PDaemonClient=(()=>{var Bf=Object.create;var Wr=Object.defineProperty;var Df=Object.getOwnPropertyDescriptor;var Pf=Object.getOwnPropertyNames;var Of=Object.getPrototypeOf,Lf=Object.prototype.hasOwnProperty;var Qt=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+r+'" is not supported')});var k=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),vt=(r,t)=>{for(var e in t)Wr(r,e,{get:t[e],enumerable:!0})},Ti=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Pf(t))!Lf.call(r,o)&&o!==e&&Wr(r,o,{get:()=>t[o],enumerable:!(n=Df(t,o))||n.enumerable});return r};var O=(r,t,e)=>(e=r!=null?Bf(Of(r)):{},Ti(t||!r||!r.__esModule?Wr(e,"default",{value:r,enumerable:!0}):e,r)),Nf=r=>Ti(Wr({},"__esModule",{value:!0}),r);var qi=k((tg,ji)=>{ji.exports=Co;var Hi=128,jp=127,qp=~jp,Wp=Math.pow(2,31);function Co(r,t,e){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw Co.bytes=0,new RangeError("Could not encode varint");t=t||[],e=e||0;for(var n=e;r>=Wp;)t[e++]=r&255|Hi,r/=128;for(;r&qp;)t[e++]=r&255|Hi,r>>>=7;return t[e]=r|0,Co.bytes=e-n+1,t}});var Yi=k((eg,Ki)=>{Ki.exports=Bo;var Kp=128,Wi=127;function Bo(r,n){var e=0,n=n||0,o=0,s=n,c,f=r.length;do{if(s>=f||o>49)throw Bo.bytes=0,new RangeError("Could not decode varint");c=r[s++],e+=o<28?(c&Wi)<<o:(c&Wi)*Math.pow(2,o),o+=7}while(c>=Kp);return Bo.bytes=s-n,e}});var Xi=k((rg,Zi)=>{var Yp=Math.pow(2,7),Zp=Math.pow(2,14),Xp=Math.pow(2,21),Jp=Math.pow(2,28),Qp=Math.pow(2,35),th=Math.pow(2,42),eh=Math.pow(2,49),rh=Math.pow(2,56),nh=Math.pow(2,63);Zi.exports=function(r){return r<Yp?1:r<Zp?2:r<Xp?3:r<Jp?4:r<Qp?5:r<th?6:r<eh?7:r<rh?8:r<nh?9:10}});var St=k((ng,Ji)=>{Ji.exports={encode:qi(),decode:Yi(),encodingLength:Xi()}});var xe=k((Sg,uc)=>{"use strict";function ac(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function wh(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return ac(r,e)}catch{e.message=r.message,e.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),ac(new o,e)}}uc.exports=wh});var vc=k((Ng,Ec)=>{var Ve=1e3,Ge=Ve*60,He=Ge*60,_e=He*24,Ch=_e*7,Bh=_e*365.25;Ec.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return Dh(r);if(e==="number"&&isFinite(r))return t.long?Oh(r):Ph(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Dh(r){if(r=String(r),!(r.length>100)){var t=/^(-?(?:\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(t){var e=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return e*Bh;case"weeks":case"week":case"w":return e*Ch;case"days":case"day":case"d":return e*_e;case"hours":case"hour":case"hrs":case"hr":case"h":return e*He;case"minutes":case"minute":case"mins":case"min":case"m":return e*Ge;case"seconds":case"second":case"secs":case"sec":case"s":return e*Ve;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function Ph(r){var t=Math.abs(r);return t>=_e?Math.round(r/_e)+"d":t>=He?Math.round(r/He)+"h":t>=Ge?Math.round(r/Ge)+"m":t>=Ve?Math.round(r/Ve)+"s":r+"ms"}function Oh(r){var t=Math.abs(r);return t>=_e?rn(r,t,_e,"day"):t>=He?rn(r,t,He,"hour"):t>=Ge?rn(r,t,Ge,"minute"):t>=Ve?rn(r,t,Ve,"second"):r+" ms"}function rn(r,t,e,n){var o=t>=e*1.5;return Math.round(r/e)+" "+n+(o?"s":"")}});var Ho=k((kg,Tc)=>{function Lh(r){e.debug=e,e.default=e,e.coerce=l,e.disable=s,e.enable=o,e.enabled=c,e.humanize=vc(),e.destroy=d,Object.keys(r).forEach(p=>{e[p]=r[p]}),e.names=[],e.skips=[],e.formatters={};function t(p){let y=0;for(let E=0;E<p.length;E++)y=(y<<5)-y+p.charCodeAt(E),y|=0;return e.colors[Math.abs(y)%e.colors.length]}e.selectColor=t;function e(p){let y,E=null,b,g;function x(...N){if(!x.enabled)return;let C=x,L=Number(new Date),K=L-(y||L);C.diff=K,C.prev=y,C.curr=L,y=L,N[0]=e.coerce(N[0]),typeof N[0]!="string"&&N.unshift("%O");let et=0;N[0]=N[0].replace(/%([a-zA-Z%])/g,(dt,pt)=>{if(dt==="%%")return"%";et++;let mt=e.formatters[pt];if(typeof mt=="function"){let Lt=N[et];dt=mt.call(C,Lt),N.splice(et,1),et--}return dt}),e.formatArgs.call(C,N),(C.log||e.log).apply(C,N)}return x.namespace=p,x.useColors=e.useColors(),x.color=e.selectColor(p),x.extend=n,x.destroy=e.destroy,Object.defineProperty(x,"enabled",{enumerable:!0,configurable:!1,get:()=>E!==null?E:(b!==e.namespaces&&(b=e.namespaces,g=e.enabled(p)),g),set:N=>{E=N}}),typeof e.init=="function"&&e.init(x),x}function n(p,y){let E=e(this.namespace+(typeof y>"u"?":":y)+p);return E.log=this.log,E}function o(p){e.save(p),e.namespaces=p,e.names=[],e.skips=[];let y,E=(typeof p=="string"?p:"").split(/[\s,]+/),b=E.length;for(y=0;y<b;y++)E[y]&&(p=E[y].replace(/\*/g,".*?"),p[0]==="-"?e.skips.push(new RegExp("^"+p.slice(1)+"$")):e.names.push(new RegExp("^"+p+"$")))}function s(){let p=[...e.names.map(f),...e.skips.map(f).map(y=>"-"+y)].join(",");return e.enable(""),p}function c(p){if(p[p.length-1]==="*")return!0;let y,E;for(y=0,E=e.skips.length;y<E;y++)if(e.skips[y].test(p))return!1;for(y=0,E=e.names.length;y<E;y++)if(e.names[y].test(p))return!0;return!1}function f(p){return p.toString().substring(2,p.toString().length-2).replace(/\.\*\?$/,"*")}function l(p){return p instanceof Error?p.stack||p.message:p}function d(){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 e.enable(e.load()),e}Tc.exports=Lh});var Sc=k((At,nn)=>{At.formatArgs=kh;At.save=Mh;At.load=Uh;At.useColors=Nh;At.storage=Fh();At.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`."))}})();At.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 Nh(){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 kh(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+nn.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(e++,o==="%c"&&(n=e))}),r.splice(n,0,t)}At.log=console.debug||console.log||(()=>{});function Mh(r){try{r?At.storage.setItem("debug",r):At.storage.removeItem("debug")}catch{}}function Uh(){let r;try{r=At.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Fh(){try{return localStorage}catch{}}nn.exports=Ho()(At);var{formatters:$h}=nn.exports;$h.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Ac=k((Mg,xc)=>{"use strict";xc.exports=(r,t)=>{t=t||process.argv;let e=r.startsWith("-")?"":r.length===1?"-":"--",n=t.indexOf(e+r),o=t.indexOf("--");return n!==-1&&(o===-1?!0:n<o)}});var Ic=k((Ug,_c)=>{"use strict";var zh=Qt("os"),Ut=Ac(),at=process.env,je;Ut("no-color")||Ut("no-colors")||Ut("color=false")?je=!1:(Ut("color")||Ut("colors")||Ut("color=true")||Ut("color=always"))&&(je=!0);"FORCE_COLOR"in at&&(je=at.FORCE_COLOR.length===0||parseInt(at.FORCE_COLOR,10)!==0);function Vh(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Gh(r){if(je===!1)return 0;if(Ut("color=16m")||Ut("color=full")||Ut("color=truecolor"))return 3;if(Ut("color=256"))return 2;if(r&&!r.isTTY&&je!==!0)return 0;let t=je?1:0;if(process.platform==="win32"){let e=zh.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in at)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in at)||at.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in at)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(at.TEAMCITY_VERSION)?1:0;if(at.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in at){let e=parseInt((at.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(at.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(at.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(at.TERM)||"COLORTERM"in at?1:(at.TERM==="dumb",t)}function jo(r){let t=Gh(r);return Vh(t)}_c.exports={supportsColor:jo,stdout:jo(process.stdout),stderr:jo(process.stderr)}});var Cc=k((it,sn)=>{var Hh=Qt("tty"),on=Qt("util");it.init=Xh;it.log=Kh;it.formatArgs=qh;it.save=Yh;it.load=Zh;it.useColors=jh;it.destroy=on.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");it.colors=[6,2,3,4,5,1];try{let r=Ic();r&&(r.stderr||r).level>=2&&(it.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}it.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,t)=>{let e=t.substring(6).toLowerCase().replace(/_([a-z])/g,(o,s)=>s.toUpperCase()),n=process.env[t];return/^(yes|on|true|enabled)$/i.test(n)?n=!0:/^(no|off|false|disabled)$/i.test(n)?n=!1:n==="null"?n=null:n=Number(n),r[e]=n,r},{});function jh(){return"colors"in it.inspectOpts?!!it.inspectOpts.colors:Hh.isatty(process.stderr.fd)}function qh(r){let{namespace:t,useColors:e}=this;if(e){let n=this.color,o="\x1B[3"+(n<8?n:"8;5;"+n),s=` ${o};1m${t} \x1B[0m`;r[0]=s+r[0].split(`
2
+ "use strict";var Libp2PDaemonClient=(()=>{var _u=Object.create;var gr=Object.defineProperty;var Ru=Object.getOwnPropertyDescriptor;var Cu=Object.getOwnPropertyNames;var Du=Object.getPrototypeOf,Bu=Object.prototype.hasOwnProperty;var $t=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+r+'" is not supported')});var L=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),dt=(r,t)=>{for(var e in t)gr(r,e,{get:t[e],enumerable:!0})},ss=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Cu(t))!Bu.call(r,i)&&i!==e&&gr(r,i,{get:()=>t[i],enumerable:!(n=Ru(t,i))||n.enumerable});return r};var F=(r,t,e)=>(e=r!=null?_u(Du(r)):{},ss(t||!r||!r.__esModule?gr(e,"default",{value:r,enumerable:!0}):e,r)),Lu=r=>ss(gr({},"__esModule",{value:!0}),r);var Cs=L((qp,Rs)=>{Rs.exports=Yn;var _s=128,Vl=127,zl=~Vl,Hl=Math.pow(2,31);function Yn(r,t,e){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw Yn.bytes=0,new RangeError("Could not encode varint");t=t||[],e=e||0;for(var n=e;r>=Hl;)t[e++]=r&255|_s,r/=128;for(;r&zl;)t[e++]=r&255|_s,r>>>=7;return t[e]=r|0,Yn.bytes=e-n+1,t}});var Ls=L((Wp,Bs)=>{Bs.exports=Kn;var Yl=128,Ds=127;function Kn(r,n){var e=0,n=n||0,i=0,s=n,a,f=r.length;do{if(s>=f||i>49)throw Kn.bytes=0,new RangeError("Could not decode varint");a=r[s++],e+=i<28?(a&Ds)<<i:(a&Ds)*Math.pow(2,i),i+=7}while(a>=Yl);return Kn.bytes=s-n,e}});var ks=L((Zp,Ns)=>{var Kl=Math.pow(2,7),ql=Math.pow(2,14),Wl=Math.pow(2,21),Zl=Math.pow(2,28),Xl=Math.pow(2,35),jl=Math.pow(2,42),Jl=Math.pow(2,49),Ql=Math.pow(2,56),tf=Math.pow(2,63);Ns.exports=function(r){return r<Kl?1:r<ql?2:r<Wl?3:r<Zl?4:r<Xl?5:r<jl?6:r<Jl?7:r<Ql?8:r<tf?9:10}});var Tr=L((Xp,Ps)=>{Ps.exports={encode:Cs(),decode:Ls(),encodingLength:ks()}});var ei=L((em,Ws)=>{"use strict";function qs(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function vf(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return qs(r,e)}catch{e.message=r.message,e.stack=r.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(r)),qs(new i,e)}}Ws.exports=vf});var ao=L((Em,co)=>{var Le=1e3,Ne=Le*60,ke=Ne*60,de=ke*24,Lf=de*7,Nf=de*365.25;co.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return kf(r);if(e==="number"&&isFinite(r))return t.long?Of(r):Pf(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function kf(r){if(r=String(r),!(r.length>100)){var t=/^(-?(?:\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(t){var e=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return e*Nf;case"weeks":case"week":case"w":return e*Lf;case"days":case"day":case"d":return e*de;case"hours":case"hour":case"hrs":case"hr":case"h":return e*ke;case"minutes":case"minute":case"mins":case"min":case"m":return e*Ne;case"seconds":case"second":case"secs":case"sec":case"s":return e*Le;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function Pf(r){var t=Math.abs(r);return t>=de?Math.round(r/de)+"d":t>=ke?Math.round(r/ke)+"h":t>=Ne?Math.round(r/Ne)+"m":t>=Le?Math.round(r/Le)+"s":r+"ms"}function Of(r){var t=Math.abs(r);return t>=de?Cr(r,t,de,"day"):t>=ke?Cr(r,t,ke,"hour"):t>=Ne?Cr(r,t,Ne,"minute"):t>=Le?Cr(r,t,Le,"second"):r+" ms"}function Cr(r,t,e,n){var i=t>=e*1.5;return Math.round(r/e)+" "+n+(i?"s":"")}});var ci=L((vm,uo)=>{function Mf(r){e.debug=e,e.default=e,e.coerce=l,e.disable=s,e.enable=i,e.enabled=a,e.humanize=ao(),e.destroy=d,Object.keys(r).forEach(h=>{e[h]=r[h]}),e.names=[],e.skips=[],e.formatters={};function t(h){let g=0;for(let w=0;w<h.length;w++)g=(g<<5)-g+h.charCodeAt(w),g|=0;return e.colors[Math.abs(g)%e.colors.length]}e.selectColor=t;function e(h){let g,w=null,x,b;function A(...B){if(!A.enabled)return;let R=A,D=Number(new Date),V=D-(g||D);R.diff=V,R.prev=g,R.curr=D,g=D,B[0]=e.coerce(B[0]),typeof B[0]!="string"&&B.unshift("%O");let q=0;B[0]=B[0].replace(/%([a-zA-Z%])/g,(ct,st)=>{if(ct==="%%")return"%";q++;let at=e.formatters[st];if(typeof at=="function"){let At=B[q];ct=at.call(R,At),B.splice(q,1),q--}return ct}),e.formatArgs.call(R,B),(R.log||e.log).apply(R,B)}return A.namespace=h,A.useColors=e.useColors(),A.color=e.selectColor(h),A.extend=n,A.destroy=e.destroy,Object.defineProperty(A,"enabled",{enumerable:!0,configurable:!1,get:()=>w!==null?w:(x!==e.namespaces&&(x=e.namespaces,b=e.enabled(h)),b),set:B=>{w=B}}),typeof e.init=="function"&&e.init(A),A}function n(h,g){let w=e(this.namespace+(typeof g>"u"?":":g)+h);return w.log=this.log,w}function i(h){e.save(h),e.namespaces=h,e.names=[],e.skips=[];let g,w=(typeof h=="string"?h:"").split(/[\s,]+/),x=w.length;for(g=0;g<x;g++)w[g]&&(h=w[g].replace(/\*/g,".*?"),h[0]==="-"?e.skips.push(new RegExp("^"+h.slice(1)+"$")):e.names.push(new RegExp("^"+h+"$")))}function s(){let h=[...e.names.map(f),...e.skips.map(f).map(g=>"-"+g)].join(",");return e.enable(""),h}function a(h){if(h[h.length-1]==="*")return!0;let g,w;for(g=0,w=e.skips.length;g<w;g++)if(e.skips[g].test(h))return!1;for(g=0,w=e.names.length;g<w;g++)if(e.names[g].test(h))return!0;return!1}function f(h){return h.toString().substring(2,h.toString().length-2).replace(/\.\*\?$/,"*")}function l(h){return h instanceof Error?h.stack||h.message:h}function d(){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 e.enable(e.load()),e}uo.exports=Mf});var lo=L((mt,Dr)=>{mt.formatArgs=Uf;mt.save=Gf;mt.load=$f;mt.useColors=Ff;mt.storage=Vf();mt.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`."))}})();mt.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 Ff(){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 Uf(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Dr.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,n=0;r[0].replace(/%[a-zA-Z%]/g,i=>{i!=="%%"&&(e++,i==="%c"&&(n=e))}),r.splice(n,0,t)}mt.log=console.debug||console.log||(()=>{});function Gf(r){try{r?mt.storage.setItem("debug",r):mt.storage.removeItem("debug")}catch{}}function $f(){let r;try{r=mt.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Vf(){try{return localStorage}catch{}}Dr.exports=ci()(mt);var{formatters:zf}=Dr.exports;zf.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var ho=L((Tm,fo)=>{"use strict";fo.exports=(r,t)=>{t=t||process.argv;let e=r.startsWith("-")?"":r.length===1?"-":"--",n=t.indexOf(e+r),i=t.indexOf("--");return n!==-1&&(i===-1?!0:n<i)}});var mo=L((Sm,po)=>{"use strict";var Hf=$t("os"),Bt=ho(),et=process.env,Pe;Bt("no-color")||Bt("no-colors")||Bt("color=false")?Pe=!1:(Bt("color")||Bt("colors")||Bt("color=true")||Bt("color=always"))&&(Pe=!0);"FORCE_COLOR"in et&&(Pe=et.FORCE_COLOR.length===0||parseInt(et.FORCE_COLOR,10)!==0);function Yf(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Kf(r){if(Pe===!1)return 0;if(Bt("color=16m")||Bt("color=full")||Bt("color=truecolor"))return 3;if(Bt("color=256"))return 2;if(r&&!r.isTTY&&Pe!==!0)return 0;let t=Pe?1:0;if(process.platform==="win32"){let e=Hf.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in et)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in et)||et.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in et)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(et.TEAMCITY_VERSION)?1:0;if(et.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in et){let e=parseInt((et.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(et.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(et.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(et.TERM)||"COLORTERM"in et?1:(et.TERM==="dumb",t)}function ai(r){let t=Kf(r);return Yf(t)}po.exports={supportsColor:ai,stdout:ai(process.stdout),stderr:ai(process.stderr)}});var yo=L((Q,Lr)=>{var qf=$t("tty"),Br=$t("util");Q.init=th;Q.log=jf;Q.formatArgs=Zf;Q.save=Jf;Q.load=Qf;Q.useColors=Wf;Q.destroy=Br.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Q.colors=[6,2,3,4,5,1];try{let r=mo();r&&(r.stderr||r).level>=2&&(Q.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}Q.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,t)=>{let e=t.substring(6).toLowerCase().replace(/_([a-z])/g,(i,s)=>s.toUpperCase()),n=process.env[t];return/^(yes|on|true|enabled)$/i.test(n)?n=!0:/^(no|off|false|disabled)$/i.test(n)?n=!1:n==="null"?n=null:n=Number(n),r[e]=n,r},{});function Wf(){return"colors"in Q.inspectOpts?!!Q.inspectOpts.colors:qf.isatty(process.stderr.fd)}function Zf(r){let{namespace:t,useColors:e}=this;if(e){let n=this.color,i="\x1B[3"+(n<8?n:"8;5;"+n),s=` ${i};1m${t} \x1B[0m`;r[0]=s+r[0].split(`
3
3
  `).join(`
4
- `+s),r.push(o+"m+"+sn.exports.humanize(this.diff)+"\x1B[0m")}else r[0]=Wh()+t+" "+r[0]}function Wh(){return it.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Kh(...r){return process.stderr.write(on.format(...r)+`
5
- `)}function Yh(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function Zh(){return process.env.DEBUG}function Xh(r){r.inspectOpts={};let t=Object.keys(it.inspectOpts);for(let e=0;e<t.length;e++)r.inspectOpts[t[e]]=it.inspectOpts[t[e]]}sn.exports=Ho()(it);var{formatters:Rc}=sn.exports;Rc.o=function(r){return this.inspectOpts.colors=this.useColors,on.inspect(r,this.inspectOpts).split(`
6
- `).map(t=>t.trim()).join(" ")};Rc.O=function(r){return this.inspectOpts.colors=this.useColors,on.inspect(r,this.inspectOpts)}});var Bc=k((Fg,qo)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?qo.exports=Sc():qo.exports=Cc()});var cn=k((Hg,Dc)=>{Dc.exports=r=>{if(r[Symbol.asyncIterator])return r;if(r.getReader)return async function*(){let t=r.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}}();throw new Error("unknown stream")}});var Oc=k((jg,Pc)=>{Pc.exports=function(t){if(t){if(typeof t[Symbol.iterator]=="function")return t[Symbol.iterator]();if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t.next=="function")return t}throw new Error("argument is not an iterator or iterable")}});var Wo=k((qg,Lc)=>{var Jh=Oc();Lc.exports=r=>async t=>{t=Jh(t);let e=C=>{typeof C.return=="function"&&C.return()},n=null,o=null,s=C=>{n=C,o&&o(C),e(t)},c=null,f=!1,l=()=>{f=!0,c&&c()},d=null,p=!1,y=()=>{p=!0,d&&d()},E=null,b=()=>{E&&E()},g=()=>new Promise((C,L)=>{c=E=C,o=L,r.once("drain",b)}),x=()=>(e(t),new Promise((C,L)=>{if(f||p||n)return C();d=c=C,o=L})),N=()=>{r.removeListener("error",s),r.removeListener("close",l),r.removeListener("finish",y),r.removeListener("drain",b)};r.once("error",s),r.once("close",l),r.once("finish",y);try{for await(let C of t){if(!r.writable||r.destroyed||n)break;r.write(C)===!1&&await g()}}catch(C){n||r.destroy(),n=C}try{if(r.writable&&r.end(),await x(),n)throw n}finally{N()}}});var Ko=k((Wg,Nc)=>{var Qh=Wo(),td=cn();Nc.exports=r=>({sink:Qh(r),source:td(r)})});var Mc=k((Kg,kc)=>{var ed=Ko();kc.exports=r=>async function*(t){let e=ed(r),n;if(e.sink(t).catch(o=>{n=o}),yield*e.source,n)throw n}});var Uc=k((Yg,qe)=>{qe.exports=cn();qe.exports.source=cn();qe.exports.sink=Wo();qe.exports.transform=Mc();qe.exports.duplex=Ko()});var cs=k((dn,ea)=>{(function(){var r,t=0xdeadbeefcafe,e=(t&16777215)==15715070;function n(i,a,u){i!=null&&(typeof i=="number"?this.fromNumber(i,a,u):a==null&&typeof i!="string"?this.fromString(i,256):this.fromString(i,a))}function o(){return new n(null)}function s(i,a,u,h,m,w){for(;--w>=0;){var T=a*this[i++]+u[h]+m;m=Math.floor(T/67108864),u[h++]=T&67108863}return m}function c(i,a,u,h,m,w){for(var T=a&32767,S=a>>15;--w>=0;){var F=this[i]&32767,nt=this[i++]>>15,Rt=S*F+nt*T;F=T*F+((Rt&32767)<<15)+u[h]+(m&1073741823),m=(F>>>30)+(Rt>>>15)+S*nt+(m>>>30),u[h++]=F&1073741823}return m}function f(i,a,u,h,m,w){for(var T=a&16383,S=a>>14;--w>=0;){var F=this[i]&16383,nt=this[i++]>>14,Rt=S*F+nt*T;F=T*F+((Rt&16383)<<14)+u[h]+m,m=(F>>28)+(Rt>>14)+S*nt,u[h++]=F&268435455}return m}var l=typeof navigator<"u";l&&e&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=c,r=30):l&&e&&navigator.appName!="Netscape"?(n.prototype.am=s,r=26):(n.prototype.am=f,r=28),n.prototype.DB=r,n.prototype.DM=(1<<r)-1,n.prototype.DV=1<<r;var d=52;n.prototype.FV=Math.pow(2,d),n.prototype.F1=d-r,n.prototype.F2=2*r-d;var p="0123456789abcdefghijklmnopqrstuvwxyz",y=new Array,E,b;for(E="0".charCodeAt(0),b=0;b<=9;++b)y[E++]=b;for(E="a".charCodeAt(0),b=10;b<36;++b)y[E++]=b;for(E="A".charCodeAt(0),b=10;b<36;++b)y[E++]=b;function g(i){return p.charAt(i)}function x(i,a){var u=y[i.charCodeAt(a)];return u??-1}function N(i){for(var a=this.t-1;a>=0;--a)i[a]=this[a];i.t=this.t,i.s=this.s}function C(i){this.t=1,this.s=i<0?-1:0,i>0?this[0]=i:i<-1?this[0]=i+this.DV:this.t=0}function L(i){var a=o();return a.fromInt(i),a}function K(i,a){var u;if(a==16)u=4;else if(a==8)u=3;else if(a==256)u=8;else if(a==2)u=1;else if(a==32)u=5;else if(a==4)u=2;else{this.fromRadix(i,a);return}this.t=0,this.s=0;for(var h=i.length,m=!1,w=0;--h>=0;){var T=u==8?i[h]&255:x(i,h);if(T<0){i.charAt(h)=="-"&&(m=!0);continue}m=!1,w==0?this[this.t++]=T:w+u>this.DB?(this[this.t-1]|=(T&(1<<this.DB-w)-1)<<w,this[this.t++]=T>>this.DB-w):this[this.t-1]|=T<<w,w+=u,w>=this.DB&&(w-=this.DB)}u==8&&i[0]&128&&(this.s=-1,w>0&&(this[this.t-1]|=(1<<this.DB-w)-1<<w)),this.clamp(),m&&n.ZERO.subTo(this,this)}function et(){for(var i=this.s&this.DM;this.t>0&&this[this.t-1]==i;)--this.t}function wt(i){if(this.s<0)return"-"+this.negate().toString(i);var a;if(i==16)a=4;else if(i==8)a=3;else if(i==2)a=1;else if(i==32)a=5;else if(i==4)a=2;else return this.toRadix(i);var u=(1<<a)-1,h,m=!1,w="",T=this.t,S=this.DB-T*this.DB%a;if(T-- >0)for(S<this.DB&&(h=this[T]>>S)>0&&(m=!0,w=g(h));T>=0;)S<a?(h=(this[T]&(1<<S)-1)<<a-S,h|=this[--T]>>(S+=this.DB-a)):(h=this[T]>>(S-=a)&u,S<=0&&(S+=this.DB,--T)),h>0&&(m=!0),m&&(w+=g(h));return m?w:"0"}function dt(){var i=o();return n.ZERO.subTo(this,i),i}function pt(){return this.s<0?this.negate():this}function mt(i){var a=this.s-i.s;if(a!=0)return a;var u=this.t;if(a=u-i.t,a!=0)return this.s<0?-a:a;for(;--u>=0;)if((a=this[u]-i[u])!=0)return a;return 0}function Lt(i){var a=1,u;return(u=i>>>16)!=0&&(i=u,a+=16),(u=i>>8)!=0&&(i=u,a+=8),(u=i>>4)!=0&&(i=u,a+=4),(u=i>>2)!=0&&(i=u,a+=2),(u=i>>1)!=0&&(i=u,a+=1),a}function Yu(){return this.t<=0?0:this.DB*(this.t-1)+Lt(this[this.t-1]^this.s&this.DM)}function Zu(i,a){var u;for(u=this.t-1;u>=0;--u)a[u+i]=this[u];for(u=i-1;u>=0;--u)a[u]=0;a.t=this.t+i,a.s=this.s}function Xu(i,a){for(var u=i;u<this.t;++u)a[u-i]=this[u];a.t=Math.max(this.t-i,0),a.s=this.s}function Ju(i,a){var u=i%this.DB,h=this.DB-u,m=(1<<h)-1,w=Math.floor(i/this.DB),T=this.s<<u&this.DM,S;for(S=this.t-1;S>=0;--S)a[S+w+1]=this[S]>>h|T,T=(this[S]&m)<<u;for(S=w-1;S>=0;--S)a[S]=0;a[w]=T,a.t=this.t+w+1,a.s=this.s,a.clamp()}function Qu(i,a){a.s=this.s;var u=Math.floor(i/this.DB);if(u>=this.t){a.t=0;return}var h=i%this.DB,m=this.DB-h,w=(1<<h)-1;a[0]=this[u]>>h;for(var T=u+1;T<this.t;++T)a[T-u-1]|=(this[T]&w)<<m,a[T-u]=this[T]>>h;h>0&&(a[this.t-u-1]|=(this.s&w)<<m),a.t=this.t-u,a.clamp()}function tl(i,a){for(var u=0,h=0,m=Math.min(i.t,this.t);u<m;)h+=this[u]-i[u],a[u++]=h&this.DM,h>>=this.DB;if(i.t<this.t){for(h-=i.s;u<this.t;)h+=this[u],a[u++]=h&this.DM,h>>=this.DB;h+=this.s}else{for(h+=this.s;u<i.t;)h-=i[u],a[u++]=h&this.DM,h>>=this.DB;h-=i.s}a.s=h<0?-1:0,h<-1?a[u++]=this.DV+h:h>0&&(a[u++]=h),a.t=u,a.clamp()}function el(i,a){var u=this.abs(),h=i.abs(),m=u.t;for(a.t=m+h.t;--m>=0;)a[m]=0;for(m=0;m<h.t;++m)a[m+u.t]=u.am(0,h[m],a,m,0,u.t);a.s=0,a.clamp(),this.s!=i.s&&n.ZERO.subTo(a,a)}function rl(i){for(var a=this.abs(),u=i.t=2*a.t;--u>=0;)i[u]=0;for(u=0;u<a.t-1;++u){var h=a.am(u,a[u],i,2*u,0,1);(i[u+a.t]+=a.am(u+1,2*a[u],i,2*u+1,h,a.t-u-1))>=a.DV&&(i[u+a.t]-=a.DV,i[u+a.t+1]=1)}i.t>0&&(i[i.t-1]+=a.am(u,a[u],i,2*u,0,1)),i.s=0,i.clamp()}function nl(i,a,u){var h=i.abs();if(!(h.t<=0)){var m=this.abs();if(m.t<h.t){a?.fromInt(0),u!=null&&this.copyTo(u);return}u==null&&(u=o());var w=o(),T=this.s,S=i.s,F=this.DB-Lt(h[h.t-1]);F>0?(h.lShiftTo(F,w),m.lShiftTo(F,u)):(h.copyTo(w),m.copyTo(u));var nt=w.t,Rt=w[nt-1];if(Rt!=0){var Et=Rt*(1<<this.F1)+(nt>1?w[nt-2]>>this.F2:0),Jt=this.FV/Et,jr=(1<<this.F1)/Et,kt=1<<this.F2,Mt=u.t,qr=Mt-nt,pe=a??o();for(w.dlShiftTo(qr,pe),u.compareTo(pe)>=0&&(u[u.t++]=1,u.subTo(pe,u)),n.ONE.dlShiftTo(nt,pe),pe.subTo(w,w);w.t<nt;)w[w.t++]=0;for(;--qr>=0;){var ro=u[--Mt]==Rt?this.DM:Math.floor(u[Mt]*Jt+(u[Mt-1]+kt)*jr);if((u[Mt]+=w.am(0,ro,u,qr,0,nt))<ro)for(w.dlShiftTo(qr,pe),u.subTo(pe,u);u[Mt]<--ro;)u.subTo(pe,u)}a!=null&&(u.drShiftTo(nt,a),T!=S&&n.ZERO.subTo(a,a)),u.t=nt,u.clamp(),F>0&&u.rShiftTo(F,u),T<0&&n.ZERO.subTo(u,u)}}}function ol(i){var a=o();return this.abs().divRemTo(i,null,a),this.s<0&&a.compareTo(n.ZERO)>0&&i.subTo(a,a),a}function Ee(i){this.m=i}function sl(i){return i.s<0||i.compareTo(this.m)>=0?i.mod(this.m):i}function il(i){return i}function cl(i){i.divRemTo(this.m,null,i)}function al(i,a,u){i.multiplyTo(a,u),this.reduce(u)}function ul(i,a){i.squareTo(a),this.reduce(a)}Ee.prototype.convert=sl,Ee.prototype.revert=il,Ee.prototype.reduce=cl,Ee.prototype.mulTo=al,Ee.prototype.sqrTo=ul;function ll(){if(this.t<1)return 0;var i=this[0];if(!(i&1))return 0;var a=i&3;return a=a*(2-(i&15)*a)&15,a=a*(2-(i&255)*a)&255,a=a*(2-((i&65535)*a&65535))&65535,a=a*(2-i*a%this.DV)%this.DV,a>0?this.DV-a:-a}function ve(i){this.m=i,this.mp=i.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<i.DB-15)-1,this.mt2=2*i.t}function fl(i){var a=o();return i.abs().dlShiftTo(this.m.t,a),a.divRemTo(this.m,null,a),i.s<0&&a.compareTo(n.ZERO)>0&&this.m.subTo(a,a),a}function pl(i){var a=o();return i.copyTo(a),this.reduce(a),a}function hl(i){for(;i.t<=this.mt2;)i[i.t++]=0;for(var a=0;a<this.m.t;++a){var u=i[a]&32767,h=u*this.mpl+((u*this.mph+(i[a]>>15)*this.mpl&this.um)<<15)&i.DM;for(u=a+this.m.t,i[u]+=this.m.am(0,h,i,a,0,this.m.t);i[u]>=i.DV;)i[u]-=i.DV,i[++u]++}i.clamp(),i.drShiftTo(this.m.t,i),i.compareTo(this.m)>=0&&i.subTo(this.m,i)}function dl(i,a){i.squareTo(a),this.reduce(a)}function ml(i,a,u){i.multiplyTo(a,u),this.reduce(u)}ve.prototype.convert=fl,ve.prototype.revert=pl,ve.prototype.reduce=hl,ve.prototype.mulTo=ml,ve.prototype.sqrTo=dl;function gl(){return(this.t>0?this[0]&1:this.s)==0}function yl(i,a){if(i>4294967295||i<1)return n.ONE;var u=o(),h=o(),m=a.convert(this),w=Lt(i)-1;for(m.copyTo(u);--w>=0;)if(a.sqrTo(u,h),(i&1<<w)>0)a.mulTo(h,m,u);else{var T=u;u=h,h=T}return a.revert(u)}function wl(i,a){var u;return i<256||a.isEven()?u=new Ee(a):u=new ve(a),this.exp(i,u)}n.prototype.copyTo=N,n.prototype.fromInt=C,n.prototype.fromString=K,n.prototype.clamp=et,n.prototype.dlShiftTo=Zu,n.prototype.drShiftTo=Xu,n.prototype.lShiftTo=Ju,n.prototype.rShiftTo=Qu,n.prototype.subTo=tl,n.prototype.multiplyTo=el,n.prototype.squareTo=rl,n.prototype.divRemTo=nl,n.prototype.invDigit=ll,n.prototype.isEven=gl,n.prototype.exp=yl,n.prototype.toString=wt,n.prototype.negate=dt,n.prototype.abs=pt,n.prototype.compareTo=mt,n.prototype.bitLength=Yu,n.prototype.mod=ol,n.prototype.modPowInt=wl,n.ZERO=L(0),n.ONE=L(1);function bl(){var i=o();return this.copyTo(i),i}function El(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}function vl(){return this.t==0?this.s:this[0]<<24>>24}function Tl(){return this.t==0?this.s:this[0]<<16>>16}function Sl(i){return Math.floor(Math.LN2*this.DB/Math.log(i))}function xl(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function Al(i){if(i==null&&(i=10),this.signum()==0||i<2||i>36)return"0";var a=this.chunkSize(i),u=Math.pow(i,a),h=L(u),m=o(),w=o(),T="";for(this.divRemTo(h,m,w);m.signum()>0;)T=(u+w.intValue()).toString(i).substr(1)+T,m.divRemTo(h,m,w);return w.intValue().toString(i)+T}function _l(i,a){this.fromInt(0),a==null&&(a=10);for(var u=this.chunkSize(a),h=Math.pow(a,u),m=!1,w=0,T=0,S=0;S<i.length;++S){var F=x(i,S);if(F<0){i.charAt(S)=="-"&&this.signum()==0&&(m=!0);continue}T=a*T+F,++w>=u&&(this.dMultiply(h),this.dAddOffset(T,0),w=0,T=0)}w>0&&(this.dMultiply(Math.pow(a,w)),this.dAddOffset(T,0)),m&&n.ZERO.subTo(this,this)}function Il(i,a,u){if(typeof a=="number")if(i<2)this.fromInt(1);else for(this.fromNumber(i,u),this.testBit(i-1)||this.bitwiseTo(n.ONE.shiftLeft(i-1),Jn,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(a);)this.dAddOffset(2,0),this.bitLength()>i&&this.subTo(n.ONE.shiftLeft(i-1),this);else{var h=new Array,m=i&7;h.length=(i>>3)+1,a.nextBytes(h),m>0?h[0]&=(1<<m)-1:h[0]=0,this.fromString(h,256)}}function Rl(){var i=this.t,a=new Array;a[0]=this.s;var u=this.DB-i*this.DB%8,h,m=0;if(i-- >0)for(u<this.DB&&(h=this[i]>>u)!=(this.s&this.DM)>>u&&(a[m++]=h|this.s<<this.DB-u);i>=0;)u<8?(h=(this[i]&(1<<u)-1)<<8-u,h|=this[--i]>>(u+=this.DB-8)):(h=this[i]>>(u-=8)&255,u<=0&&(u+=this.DB,--i)),h&128&&(h|=-256),m==0&&(this.s&128)!=(h&128)&&++m,(m>0||h!=this.s)&&(a[m++]=h);return a}function Cl(i){return this.compareTo(i)==0}function Bl(i){return this.compareTo(i)<0?this:i}function Dl(i){return this.compareTo(i)>0?this:i}function Pl(i,a,u){var h,m,w=Math.min(i.t,this.t);for(h=0;h<w;++h)u[h]=a(this[h],i[h]);if(i.t<this.t){for(m=i.s&this.DM,h=w;h<this.t;++h)u[h]=a(this[h],m);u.t=this.t}else{for(m=this.s&this.DM,h=w;h<i.t;++h)u[h]=a(m,i[h]);u.t=i.t}u.s=a(this.s,i.s),u.clamp()}function Ol(i,a){return i&a}function Ll(i){var a=o();return this.bitwiseTo(i,Ol,a),a}function Jn(i,a){return i|a}function Nl(i){var a=o();return this.bitwiseTo(i,Jn,a),a}function gi(i,a){return i^a}function kl(i){var a=o();return this.bitwiseTo(i,gi,a),a}function yi(i,a){return i&~a}function Ml(i){var a=o();return this.bitwiseTo(i,yi,a),a}function Ul(){for(var i=o(),a=0;a<this.t;++a)i[a]=this.DM&~this[a];return i.t=this.t,i.s=~this.s,i}function Fl(i){var a=o();return i<0?this.rShiftTo(-i,a):this.lShiftTo(i,a),a}function $l(i){var a=o();return i<0?this.lShiftTo(-i,a):this.rShiftTo(i,a),a}function zl(i){if(i==0)return-1;var a=0;return i&65535||(i>>=16,a+=16),i&255||(i>>=8,a+=8),i&15||(i>>=4,a+=4),i&3||(i>>=2,a+=2),i&1||++a,a}function Vl(){for(var i=0;i<this.t;++i)if(this[i]!=0)return i*this.DB+zl(this[i]);return this.s<0?this.t*this.DB:-1}function Gl(i){for(var a=0;i!=0;)i&=i-1,++a;return a}function Hl(){for(var i=0,a=this.s&this.DM,u=0;u<this.t;++u)i+=Gl(this[u]^a);return i}function jl(i){var a=Math.floor(i/this.DB);return a>=this.t?this.s!=0:(this[a]&1<<i%this.DB)!=0}function ql(i,a){var u=n.ONE.shiftLeft(i);return this.bitwiseTo(u,a,u),u}function Wl(i){return this.changeBit(i,Jn)}function Kl(i){return this.changeBit(i,yi)}function Yl(i){return this.changeBit(i,gi)}function Zl(i,a){for(var u=0,h=0,m=Math.min(i.t,this.t);u<m;)h+=this[u]+i[u],a[u++]=h&this.DM,h>>=this.DB;if(i.t<this.t){for(h+=i.s;u<this.t;)h+=this[u],a[u++]=h&this.DM,h>>=this.DB;h+=this.s}else{for(h+=this.s;u<i.t;)h+=i[u],a[u++]=h&this.DM,h>>=this.DB;h+=i.s}a.s=h<0?-1:0,h>0?a[u++]=h:h<-1&&(a[u++]=this.DV+h),a.t=u,a.clamp()}function Xl(i){var a=o();return this.addTo(i,a),a}function Jl(i){var a=o();return this.subTo(i,a),a}function Ql(i){var a=o();return this.multiplyTo(i,a),a}function tf(){var i=o();return this.squareTo(i),i}function ef(i){var a=o();return this.divRemTo(i,a,null),a}function rf(i){var a=o();return this.divRemTo(i,null,a),a}function nf(i){var a=o(),u=o();return this.divRemTo(i,a,u),new Array(a,u)}function of(i){this[this.t]=this.am(0,i-1,this,0,0,this.t),++this.t,this.clamp()}function sf(i,a){if(i!=0){for(;this.t<=a;)this[this.t++]=0;for(this[a]+=i;this[a]>=this.DV;)this[a]-=this.DV,++a>=this.t&&(this[this.t++]=0),++this[a]}}function lr(){}function wi(i){return i}function cf(i,a,u){i.multiplyTo(a,u)}function af(i,a){i.squareTo(a)}lr.prototype.convert=wi,lr.prototype.revert=wi,lr.prototype.mulTo=cf,lr.prototype.sqrTo=af;function uf(i){return this.exp(i,new lr)}function lf(i,a,u){var h=Math.min(this.t+i.t,a);for(u.s=0,u.t=h;h>0;)u[--h]=0;var m;for(m=u.t-this.t;h<m;++h)u[h+this.t]=this.am(0,i[h],u,h,0,this.t);for(m=Math.min(i.t,a);h<m;++h)this.am(0,i[h],u,h,0,a-h);u.clamp()}function ff(i,a,u){--a;var h=u.t=this.t+i.t-a;for(u.s=0;--h>=0;)u[h]=0;for(h=Math.max(a-this.t,0);h<i.t;++h)u[this.t+h-a]=this.am(a-h,i[h],u,0,0,this.t+h-a);u.clamp(),u.drShiftTo(1,u)}function Te(i){this.r2=o(),this.q3=o(),n.ONE.dlShiftTo(2*i.t,this.r2),this.mu=this.r2.divide(i),this.m=i}function pf(i){if(i.s<0||i.t>2*this.m.t)return i.mod(this.m);if(i.compareTo(this.m)<0)return i;var a=o();return i.copyTo(a),this.reduce(a),a}function hf(i){return i}function df(i){for(i.drShiftTo(this.m.t-1,this.r2),i.t>this.m.t+1&&(i.t=this.m.t+1,i.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);i.compareTo(this.r2)<0;)i.dAddOffset(1,this.m.t+1);for(i.subTo(this.r2,i);i.compareTo(this.m)>=0;)i.subTo(this.m,i)}function mf(i,a){i.squareTo(a),this.reduce(a)}function gf(i,a,u){i.multiplyTo(a,u),this.reduce(u)}Te.prototype.convert=pf,Te.prototype.revert=hf,Te.prototype.reduce=df,Te.prototype.mulTo=gf,Te.prototype.sqrTo=mf;function yf(i,a){var u=i.bitLength(),h,m=L(1),w;if(u<=0)return m;u<18?h=1:u<48?h=3:u<144?h=4:u<768?h=5:h=6,u<8?w=new Ee(a):a.isEven()?w=new Te(a):w=new ve(a);var T=new Array,S=3,F=h-1,nt=(1<<h)-1;if(T[1]=w.convert(this),h>1){var Rt=o();for(w.sqrTo(T[1],Rt);S<=nt;)T[S]=o(),w.mulTo(Rt,T[S-2],T[S]),S+=2}var Et=i.t-1,Jt,jr=!0,kt=o(),Mt;for(u=Lt(i[Et])-1;Et>=0;){for(u>=F?Jt=i[Et]>>u-F&nt:(Jt=(i[Et]&(1<<u+1)-1)<<F-u,Et>0&&(Jt|=i[Et-1]>>this.DB+u-F)),S=h;!(Jt&1);)Jt>>=1,--S;if((u-=S)<0&&(u+=this.DB,--Et),jr)T[Jt].copyTo(m),jr=!1;else{for(;S>1;)w.sqrTo(m,kt),w.sqrTo(kt,m),S-=2;S>0?w.sqrTo(m,kt):(Mt=m,m=kt,kt=Mt),w.mulTo(kt,T[Jt],m)}for(;Et>=0&&!(i[Et]&1<<u);)w.sqrTo(m,kt),Mt=m,m=kt,kt=Mt,--u<0&&(u=this.DB-1,--Et)}return w.revert(m)}function wf(i){var a=this.s<0?this.negate():this.clone(),u=i.s<0?i.negate():i.clone();if(a.compareTo(u)<0){var h=a;a=u,u=h}var m=a.getLowestSetBit(),w=u.getLowestSetBit();if(w<0)return a;for(m<w&&(w=m),w>0&&(a.rShiftTo(w,a),u.rShiftTo(w,u));a.signum()>0;)(m=a.getLowestSetBit())>0&&a.rShiftTo(m,a),(m=u.getLowestSetBit())>0&&u.rShiftTo(m,u),a.compareTo(u)>=0?(a.subTo(u,a),a.rShiftTo(1,a)):(u.subTo(a,u),u.rShiftTo(1,u));return w>0&&u.lShiftTo(w,u),u}function bf(i){if(i<=0)return 0;var a=this.DV%i,u=this.s<0?i-1:0;if(this.t>0)if(a==0)u=this[0]%i;else for(var h=this.t-1;h>=0;--h)u=(a*u+this[h])%i;return u}function Ef(i){var a=i.isEven();if(this.isEven()&&a||i.signum()==0)return n.ZERO;for(var u=i.clone(),h=this.clone(),m=L(1),w=L(0),T=L(0),S=L(1);u.signum()!=0;){for(;u.isEven();)u.rShiftTo(1,u),a?((!m.isEven()||!w.isEven())&&(m.addTo(this,m),w.subTo(i,w)),m.rShiftTo(1,m)):w.isEven()||w.subTo(i,w),w.rShiftTo(1,w);for(;h.isEven();)h.rShiftTo(1,h),a?((!T.isEven()||!S.isEven())&&(T.addTo(this,T),S.subTo(i,S)),T.rShiftTo(1,T)):S.isEven()||S.subTo(i,S),S.rShiftTo(1,S);u.compareTo(h)>=0?(u.subTo(h,u),a&&m.subTo(T,m),w.subTo(S,w)):(h.subTo(u,h),a&&T.subTo(m,T),S.subTo(w,S))}if(h.compareTo(n.ONE)!=0)return n.ZERO;if(S.compareTo(i)>=0)return S.subtract(i);if(S.signum()<0)S.addTo(i,S);else return S;return S.signum()<0?S.add(i):S}var ht=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],vf=(1<<26)/ht[ht.length-1];function Tf(i){var a,u=this.abs();if(u.t==1&&u[0]<=ht[ht.length-1]){for(a=0;a<ht.length;++a)if(u[0]==ht[a])return!0;return!1}if(u.isEven())return!1;for(a=1;a<ht.length;){for(var h=ht[a],m=a+1;m<ht.length&&h<vf;)h*=ht[m++];for(h=u.modInt(h);a<m;)if(h%ht[a++]==0)return!1}return u.millerRabin(i)}function Sf(i){var a=this.subtract(n.ONE),u=a.getLowestSetBit();if(u<=0)return!1;var h=a.shiftRight(u);i=i+1>>1,i>ht.length&&(i=ht.length);for(var m=o(),w=0;w<i;++w){m.fromInt(ht[Math.floor(Math.random()*ht.length)]);var T=m.modPow(h,this);if(T.compareTo(n.ONE)!=0&&T.compareTo(a)!=0){for(var S=1;S++<u&&T.compareTo(a)!=0;)if(T=T.modPowInt(2,this),T.compareTo(n.ONE)==0)return!1;if(T.compareTo(a)!=0)return!1}}return!0}n.prototype.chunkSize=Sl,n.prototype.toRadix=Al,n.prototype.fromRadix=_l,n.prototype.fromNumber=Il,n.prototype.bitwiseTo=Pl,n.prototype.changeBit=ql,n.prototype.addTo=Zl,n.prototype.dMultiply=of,n.prototype.dAddOffset=sf,n.prototype.multiplyLowerTo=lf,n.prototype.multiplyUpperTo=ff,n.prototype.modInt=bf,n.prototype.millerRabin=Sf,n.prototype.clone=bl,n.prototype.intValue=El,n.prototype.byteValue=vl,n.prototype.shortValue=Tl,n.prototype.signum=xl,n.prototype.toByteArray=Rl,n.prototype.equals=Cl,n.prototype.min=Bl,n.prototype.max=Dl,n.prototype.and=Ll,n.prototype.or=Nl,n.prototype.xor=kl,n.prototype.andNot=Ml,n.prototype.not=Ul,n.prototype.shiftLeft=Fl,n.prototype.shiftRight=$l,n.prototype.getLowestSetBit=Vl,n.prototype.bitCount=Hl,n.prototype.testBit=jl,n.prototype.setBit=Wl,n.prototype.clearBit=Kl,n.prototype.flipBit=Yl,n.prototype.add=Xl,n.prototype.subtract=Jl,n.prototype.multiply=Ql,n.prototype.divide=ef,n.prototype.remainder=rf,n.prototype.divideAndRemainder=nf,n.prototype.modPow=yf,n.prototype.modInverse=Ef,n.prototype.pow=uf,n.prototype.gcd=wf,n.prototype.isProbablePrime=Tf,n.prototype.square=tf,n.prototype.Barrett=Te;var Hr,bt,rt;function xf(i){bt[rt++]^=i&255,bt[rt++]^=i>>8&255,bt[rt++]^=i>>16&255,bt[rt++]^=i>>24&255,rt>=eo&&(rt-=eo)}function bi(){xf(new Date().getTime())}if(bt==null){bt=new Array,rt=0;var Nt;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var Ei=new Uint8Array(32);for(window.crypto.getRandomValues(Ei),Nt=0;Nt<32;++Nt)bt[rt++]=Ei[Nt]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var vi=window.crypto.random(32);for(Nt=0;Nt<vi.length;++Nt)bt[rt++]=vi.charCodeAt(Nt)&255}}for(;rt<eo;)Nt=Math.floor(65536*Math.random()),bt[rt++]=Nt>>>8,bt[rt++]=Nt&255;rt=0,bi()}function Af(){if(Hr==null){for(bi(),Hr=Cf(),Hr.init(bt),rt=0;rt<bt.length;++rt)bt[rt]=0;rt=0}return Hr.next()}function _f(i){var a;for(a=0;a<i.length;++a)i[a]=Af()}function Qn(){}Qn.prototype.nextBytes=_f;function to(){this.i=0,this.j=0,this.S=new Array}function If(i){var a,u,h;for(a=0;a<256;++a)this.S[a]=a;for(u=0,a=0;a<256;++a)u=u+this.S[a]+i[a%i.length]&255,h=this.S[a],this.S[a]=this.S[u],this.S[u]=h;this.i=0,this.j=0}function Rf(){var i;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,i=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=i,this.S[i+this.S[this.i]&255]}to.prototype.init=If,to.prototype.next=Rf;function Cf(){return new to}var eo=256;typeof dn<"u"?dn=ea.exports={default:n,BigInteger:n,SecureRandom:Qn}:this.jsbn={BigInteger:n,SecureRandom:Qn}}).call(dn)});var _r=k(mn=>{(function(){"use strict";var r={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function t(c){return n(s(c),arguments)}function e(c,f){return t.apply(null,[c].concat(f||[]))}function n(c,f){var l=1,d=c.length,p,y="",E,b,g,x,N,C,L,K;for(E=0;E<d;E++)if(typeof c[E]=="string")y+=c[E];else if(typeof c[E]=="object"){if(g=c[E],g.keys)for(p=f[l],b=0;b<g.keys.length;b++){if(p==null)throw new Error(t('[sprintf] Cannot access property "%s" of undefined value "%s"',g.keys[b],g.keys[b-1]));p=p[g.keys[b]]}else g.param_no?p=f[g.param_no]:p=f[l++];if(r.not_type.test(g.type)&&r.not_primitive.test(g.type)&&p instanceof Function&&(p=p()),r.numeric_arg.test(g.type)&&typeof p!="number"&&isNaN(p))throw new TypeError(t("[sprintf] expecting number but found %T",p));switch(r.number.test(g.type)&&(L=p>=0),g.type){case"b":p=parseInt(p,10).toString(2);break;case"c":p=String.fromCharCode(parseInt(p,10));break;case"d":case"i":p=parseInt(p,10);break;case"j":p=JSON.stringify(p,null,g.width?parseInt(g.width):0);break;case"e":p=g.precision?parseFloat(p).toExponential(g.precision):parseFloat(p).toExponential();break;case"f":p=g.precision?parseFloat(p).toFixed(g.precision):parseFloat(p);break;case"g":p=g.precision?String(Number(p.toPrecision(g.precision))):parseFloat(p);break;case"o":p=(parseInt(p,10)>>>0).toString(8);break;case"s":p=String(p),p=g.precision?p.substring(0,g.precision):p;break;case"t":p=String(!!p),p=g.precision?p.substring(0,g.precision):p;break;case"T":p=Object.prototype.toString.call(p).slice(8,-1).toLowerCase(),p=g.precision?p.substring(0,g.precision):p;break;case"u":p=parseInt(p,10)>>>0;break;case"v":p=p.valueOf(),p=g.precision?p.substring(0,g.precision):p;break;case"x":p=(parseInt(p,10)>>>0).toString(16);break;case"X":p=(parseInt(p,10)>>>0).toString(16).toUpperCase();break}r.json.test(g.type)?y+=p:(r.number.test(g.type)&&(!L||g.sign)?(K=L?"+":"-",p=p.toString().replace(r.sign,"")):K="",N=g.pad_char?g.pad_char==="0"?"0":g.pad_char.charAt(1):" ",C=g.width-(K+p).length,x=g.width&&C>0?N.repeat(C):"",y+=g.align?K+p+x:N==="0"?K+x+p:x+K+p)}return y}var o=Object.create(null);function s(c){if(o[c])return o[c];for(var f=c,l,d=[],p=0;f;){if((l=r.text.exec(f))!==null)d.push(l[0]);else if((l=r.modulo.exec(f))!==null)d.push("%");else if((l=r.placeholder.exec(f))!==null){if(l[2]){p|=1;var y=[],E=l[2],b=[];if((b=r.key.exec(E))!==null)for(y.push(b[1]);(E=E.substring(b[0].length))!=="";)if((b=r.key_access.exec(E))!==null)y.push(b[1]);else if((b=r.index_access.exec(E))!==null)y.push(b[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");l[2]=y}else p|=2;if(p===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");d.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");f=f.substring(l[0].length)}return o[c]=d}typeof mn<"u"&&(mn.sprintf=t,mn.vsprintf=e),typeof window<"u"&&(window.sprintf=t,window.vsprintf=e,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:e}}))})()});var Na=k((Bw,La)=>{"use strict";La.exports=cm;function cm(r,t){for(var e=new Array(arguments.length-1),n=0,o=2,s=!0;o<arguments.length;)e[n++]=arguments[o++];return new Promise(function(f,l){e[n]=function(p){if(s)if(s=!1,p)l(p);else{for(var y=new Array(arguments.length-1),E=0;E<y.length;)y[E++]=arguments[E];f.apply(null,y)}};try{r.apply(t||null,e)}catch(d){s&&(s=!1,l(d))}})}});var Fa=k(Ua=>{"use strict";var _n=Ua;_n.length=function(t){var e=t.length;if(!e)return 0;for(var n=0;--e%4>1&&t.charAt(e)==="=";)++n;return Math.ceil(t.length*3)/4-n};var rr=new Array(64),Ma=new Array(123);for($t=0;$t<64;)Ma[rr[$t]=$t<26?$t+65:$t<52?$t+71:$t<62?$t-4:$t-59|43]=$t++;var $t;_n.encode=function(t,e,n){for(var o=null,s=[],c=0,f=0,l;e<n;){var d=t[e++];switch(f){case 0:s[c++]=rr[d>>2],l=(d&3)<<4,f=1;break;case 1:s[c++]=rr[l|d>>4],l=(d&15)<<2,f=2;break;case 2:s[c++]=rr[l|d>>6],s[c++]=rr[d&63],f=0;break}c>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,s)),c=0)}return f&&(s[c++]=rr[l],s[c++]=61,f===1&&(s[c++]=61)),o?(c&&o.push(String.fromCharCode.apply(String,s.slice(0,c))),o.join("")):String.fromCharCode.apply(String,s.slice(0,c))};var ka="invalid encoding";_n.decode=function(t,e,n){for(var o=n,s=0,c,f=0;f<t.length;){var l=t.charCodeAt(f++);if(l===61&&s>1)break;if((l=Ma[l])===void 0)throw Error(ka);switch(s){case 0:c=l,s=1;break;case 1:e[n++]=c<<2|(l&48)>>4,c=l,s=2;break;case 2:e[n++]=(c&15)<<4|(l&60)>>2,c=l,s=3;break;case 3:e[n++]=(c&3)<<6|l,s=0;break}}if(s===1)throw Error(ka);return n-o};_n.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}});var za=k((Pw,$a)=>{"use strict";$a.exports=In;function In(){this._listeners={}}In.prototype.on=function(t,e,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:n||this}),this};In.prototype.off=function(t,e){if(t===void 0)this._listeners={};else if(e===void 0)this._listeners[t]=[];else for(var n=this._listeners[t],o=0;o<n.length;)n[o].fn===e?n.splice(o,1):++o;return this};In.prototype.emit=function(t){var e=this._listeners[t];if(e){for(var n=[],o=1;o<arguments.length;)n.push(arguments[o++]);for(o=0;o<e.length;)e[o].fn.apply(e[o++].ctx,n)}return this}});var Ka=k((Ow,Wa)=>{"use strict";Wa.exports=Va(Va);function Va(r){return typeof Float32Array<"u"?function(){var t=new Float32Array([-0]),e=new Uint8Array(t.buffer),n=e[3]===128;function o(l,d,p){t[0]=l,d[p]=e[0],d[p+1]=e[1],d[p+2]=e[2],d[p+3]=e[3]}function s(l,d,p){t[0]=l,d[p]=e[3],d[p+1]=e[2],d[p+2]=e[1],d[p+3]=e[0]}r.writeFloatLE=n?o:s,r.writeFloatBE=n?s:o;function c(l,d){return e[0]=l[d],e[1]=l[d+1],e[2]=l[d+2],e[3]=l[d+3],t[0]}function f(l,d){return e[3]=l[d],e[2]=l[d+1],e[1]=l[d+2],e[0]=l[d+3],t[0]}r.readFloatLE=n?c:f,r.readFloatBE=n?f:c}():function(){function t(n,o,s,c){var f=o<0?1:0;if(f&&(o=-o),o===0)n(1/o>0?0:2147483648,s,c);else if(isNaN(o))n(2143289344,s,c);else if(o>34028234663852886e22)n((f<<31|2139095040)>>>0,s,c);else if(o<11754943508222875e-54)n((f<<31|Math.round(o/1401298464324817e-60))>>>0,s,c);else{var l=Math.floor(Math.log(o)/Math.LN2),d=Math.round(o*Math.pow(2,-l)*8388608)&8388607;n((f<<31|l+127<<23|d)>>>0,s,c)}}r.writeFloatLE=t.bind(null,Ga),r.writeFloatBE=t.bind(null,Ha);function e(n,o,s){var c=n(o,s),f=(c>>31)*2+1,l=c>>>23&255,d=c&8388607;return l===255?d?NaN:f*(1/0):l===0?f*1401298464324817e-60*d:f*Math.pow(2,l-150)*(d+8388608)}r.readFloatLE=e.bind(null,ja),r.readFloatBE=e.bind(null,qa)}(),typeof Float64Array<"u"?function(){var t=new Float64Array([-0]),e=new Uint8Array(t.buffer),n=e[7]===128;function o(l,d,p){t[0]=l,d[p]=e[0],d[p+1]=e[1],d[p+2]=e[2],d[p+3]=e[3],d[p+4]=e[4],d[p+5]=e[5],d[p+6]=e[6],d[p+7]=e[7]}function s(l,d,p){t[0]=l,d[p]=e[7],d[p+1]=e[6],d[p+2]=e[5],d[p+3]=e[4],d[p+4]=e[3],d[p+5]=e[2],d[p+6]=e[1],d[p+7]=e[0]}r.writeDoubleLE=n?o:s,r.writeDoubleBE=n?s:o;function c(l,d){return e[0]=l[d],e[1]=l[d+1],e[2]=l[d+2],e[3]=l[d+3],e[4]=l[d+4],e[5]=l[d+5],e[6]=l[d+6],e[7]=l[d+7],t[0]}function f(l,d){return e[7]=l[d],e[6]=l[d+1],e[5]=l[d+2],e[4]=l[d+3],e[3]=l[d+4],e[2]=l[d+5],e[1]=l[d+6],e[0]=l[d+7],t[0]}r.readDoubleLE=n?c:f,r.readDoubleBE=n?f:c}():function(){function t(n,o,s,c,f,l){var d=c<0?1:0;if(d&&(c=-c),c===0)n(0,f,l+o),n(1/c>0?0:2147483648,f,l+s);else if(isNaN(c))n(0,f,l+o),n(2146959360,f,l+s);else if(c>17976931348623157e292)n(0,f,l+o),n((d<<31|2146435072)>>>0,f,l+s);else{var p;if(c<22250738585072014e-324)p=c/5e-324,n(p>>>0,f,l+o),n((d<<31|p/4294967296)>>>0,f,l+s);else{var y=Math.floor(Math.log(c)/Math.LN2);y===1024&&(y=1023),p=c*Math.pow(2,-y),n(p*4503599627370496>>>0,f,l+o),n((d<<31|y+1023<<20|p*1048576&1048575)>>>0,f,l+s)}}}r.writeDoubleLE=t.bind(null,Ga,0,4),r.writeDoubleBE=t.bind(null,Ha,4,0);function e(n,o,s,c,f){var l=n(c,f+o),d=n(c,f+s),p=(d>>31)*2+1,y=d>>>20&2047,E=4294967296*(d&1048575)+l;return y===2047?E?NaN:p*(1/0):y===0?p*5e-324*E:p*Math.pow(2,y-1075)*(E+4503599627370496)}r.readDoubleLE=e.bind(null,ja,0,4),r.readDoubleBE=e.bind(null,qa,4,0)}(),r}function Ga(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function Ha(r,t,e){t[e]=r>>>24,t[e+1]=r>>>16&255,t[e+2]=r>>>8&255,t[e+3]=r&255}function ja(r,t){return(r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24)>>>0}function qa(r,t){return(r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3])>>>0}});var Ya=k((exports,module)=>{"use strict";module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(r){}return null}});var Xa=k(Za=>{"use strict";var Ns=Za;Ns.length=function(t){for(var e=0,n=0,o=0;o<t.length;++o)n=t.charCodeAt(o),n<128?e+=1:n<2048?e+=2:(n&64512)===55296&&(t.charCodeAt(o+1)&64512)===56320?(++o,e+=4):e+=3;return e};Ns.read=function(t,e,n){var o=n-e;if(o<1)return"";for(var s=null,c=[],f=0,l;e<n;)l=t[e++],l<128?c[f++]=l:l>191&&l<224?c[f++]=(l&31)<<6|t[e++]&63:l>239&&l<365?(l=((l&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,c[f++]=55296+(l>>10),c[f++]=56320+(l&1023)):c[f++]=(l&15)<<12|(t[e++]&63)<<6|t[e++]&63,f>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,c)),f=0);return s?(f&&s.push(String.fromCharCode.apply(String,c.slice(0,f))),s.join("")):String.fromCharCode.apply(String,c.slice(0,f))};Ns.write=function(t,e,n){for(var o=n,s,c,f=0;f<t.length;++f)s=t.charCodeAt(f),s<128?e[n++]=s:s<2048?(e[n++]=s>>6|192,e[n++]=s&63|128):(s&64512)===55296&&((c=t.charCodeAt(f+1))&64512)===56320?(s=65536+((s&1023)<<10)+(c&1023),++f,e[n++]=s>>18|240,e[n++]=s>>12&63|128,e[n++]=s>>6&63|128,e[n++]=s&63|128):(e[n++]=s>>12|224,e[n++]=s>>6&63|128,e[n++]=s&63|128);return n-o}});var Qa=k((Nw,Ja)=>{"use strict";Ja.exports=am;function am(r,t,e){var n=e||8192,o=n>>>1,s=null,c=n;return function(l){if(l<1||l>o)return r(l);c+l>n&&(s=r(n),c=0);var d=t.call(s,c,c+=l);return c&7&&(c=(c|7)+1),d}}});var eu=k((kw,tu)=>{"use strict";tu.exports=ot;var Dr=Pe();function ot(r,t){this.lo=r>>>0,this.hi=t>>>0}var De=ot.zero=new ot(0,0);De.toNumber=function(){return 0};De.zzEncode=De.zzDecode=function(){return this};De.length=function(){return 1};var um=ot.zeroHash="\0\0\0\0\0\0\0\0";ot.fromNumber=function(t){if(t===0)return De;var e=t<0;e&&(t=-t);var n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new ot(n,o)};ot.from=function(t){if(typeof t=="number")return ot.fromNumber(t);if(Dr.isString(t))if(Dr.Long)t=Dr.Long.fromString(t);else return ot.fromNumber(parseInt(t,10));return t.low||t.high?new ot(t.low>>>0,t.high>>>0):De};ot.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var e=~this.lo+1>>>0,n=~this.hi>>>0;return e||(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296};ot.prototype.toLong=function(t){return Dr.Long?new Dr.Long(this.lo|0,this.hi|0,!!t):{low:this.lo|0,high:this.hi|0,unsigned:!!t}};var ye=String.prototype.charCodeAt;ot.fromHash=function(t){return t===um?De:new ot((ye.call(t,0)|ye.call(t,1)<<8|ye.call(t,2)<<16|ye.call(t,3)<<24)>>>0,(ye.call(t,4)|ye.call(t,5)<<8|ye.call(t,6)<<16|ye.call(t,7)<<24)>>>0)};ot.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};ot.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this};ot.prototype.zzDecode=function(){var t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this};ot.prototype.length=function(){var t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}});var Pe=k(ks=>{"use strict";var _=ks;_.asPromise=Na();_.base64=Fa();_.EventEmitter=za();_.float=Ka();_.inquire=Ya();_.utf8=Xa();_.pool=Qa();_.LongBits=eu();_.isNode=!!(typeof globalThis<"u"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);_.global=_.isNode&&globalThis||typeof window<"u"&&window||typeof self<"u"&&self||ks;_.emptyArray=Object.freeze?Object.freeze([]):[];_.emptyObject=Object.freeze?Object.freeze({}):{};_.isInteger=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};_.isString=function(t){return typeof t=="string"||t instanceof String};_.isObject=function(t){return t&&typeof t=="object"};_.isset=_.isSet=function(t,e){var n=t[e];return n!=null&&t.hasOwnProperty(e)?typeof n!="object"||(Array.isArray(n)?n.length:Object.keys(n).length)>0:!1};_.Buffer=function(){try{var r=_.inquire("buffer").Buffer;return r.prototype.utf8Write?r:null}catch{return null}}();_._Buffer_from=null;_._Buffer_allocUnsafe=null;_.newBuffer=function(t){return typeof t=="number"?_.Buffer?_._Buffer_allocUnsafe(t):new _.Array(t):_.Buffer?_._Buffer_from(t):typeof Uint8Array>"u"?t:new Uint8Array(t)};_.Array=typeof Uint8Array<"u"?Uint8Array:Array;_.Long=_.global.dcodeIO&&_.global.dcodeIO.Long||_.global.Long||_.inquire("long");_.key2Re=/^true|false|0|1$/;_.key32Re=/^-?(?:0|[1-9][0-9]*)$/;_.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;_.longToHash=function(t){return t?_.LongBits.from(t).toHash():_.LongBits.zeroHash};_.longFromHash=function(t,e){var n=_.LongBits.fromHash(t);return _.Long?_.Long.fromBits(n.lo,n.hi,e):n.toNumber(!!e)};function ru(r,t,e){for(var n=Object.keys(t),o=0;o<n.length;++o)(r[n[o]]===void 0||!e)&&(r[n[o]]=t[n[o]]);return r}_.merge=ru;_.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)};function nu(r){function t(e,n){if(!(this instanceof t))return new t(e,n);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:new Error().stack||""}),n&&ru(this,n)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return r},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}_.newError=nu;_.ProtocolError=nu("ProtocolError");_.oneOfGetter=function(t){for(var e={},n=0;n<t.length;++n)e[t[n]]=1;return function(){for(var o=Object.keys(this),s=o.length-1;s>-1;--s)if(e[o[s]]===1&&this[o[s]]!==void 0&&this[o[s]]!==null)return o[s]}};_.oneOfSetter=function(t){return function(e){for(var n=0;n<t.length;++n)t[n]!==e&&delete this[t[n]]}};_.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};_._configure=function(){var r=_.Buffer;if(!r){_._Buffer_from=_._Buffer_allocUnsafe=null;return}_._Buffer_from=r.from!==Uint8Array.from&&r.from||function(e,n){return new r(e,n)},_._Buffer_allocUnsafe=r.allocUnsafe||function(e){return new r(e)}}});var Fs=k((Uw,au)=>{"use strict";au.exports=Y;var Kt=Pe(),Us,iu=Kt.LongBits,lm=Kt.utf8;function zt(r,t){return RangeError("index out of range: "+r.pos+" + "+(t||1)+" > "+r.len)}function Y(r){this.buf=r,this.pos=0,this.len=r.length}var ou=typeof Uint8Array<"u"?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new Y(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new Y(t);throw Error("illegal buffer")},cu=function(){return Kt.Buffer?function(e){return(Y.create=function(o){return Kt.Buffer.isBuffer(o)?new Us(o):ou(o)})(e)}:ou};Y.create=cu();Y.prototype._slice=Kt.Array.prototype.subarray||Kt.Array.prototype.slice;Y.prototype.uint32=function(){var t=4294967295;return function(){if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,zt(this,10);return t}}();Y.prototype.int32=function(){return this.uint32()|0};Y.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(t&1)|0};function Ms(){var r=new iu(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(r.lo=(r.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return r;if(r.lo=(r.lo|(this.buf[this.pos]&127)<<28)>>>0,r.hi=(r.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return r;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw zt(this);if(r.lo=(r.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return r}return r.lo=(r.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,r}if(this.len-this.pos>4){for(;t<5;++t)if(r.hi=(r.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return r}else for(;t<5;++t){if(this.pos>=this.len)throw zt(this);if(r.hi=(r.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return r}throw Error("invalid varint encoding")}Y.prototype.bool=function(){return this.uint32()!==0};function Rn(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}Y.prototype.fixed32=function(){if(this.pos+4>this.len)throw zt(this,4);return Rn(this.buf,this.pos+=4)};Y.prototype.sfixed32=function(){if(this.pos+4>this.len)throw zt(this,4);return Rn(this.buf,this.pos+=4)|0};function su(){if(this.pos+8>this.len)throw zt(this,8);return new iu(Rn(this.buf,this.pos+=4),Rn(this.buf,this.pos+=4))}Y.prototype.float=function(){if(this.pos+4>this.len)throw zt(this,4);var t=Kt.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};Y.prototype.double=function(){if(this.pos+8>this.len)throw zt(this,4);var t=Kt.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};Y.prototype.bytes=function(){var t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw zt(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(e,n):e===n?new this.buf.constructor(0):this._slice.call(this.buf,e,n)};Y.prototype.string=function(){var t=this.bytes();return lm.read(t,0,t.length)};Y.prototype.skip=function(t){if(typeof t=="number"){if(this.pos+t>this.len)throw zt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw zt(this);while(this.buf[this.pos++]&128);return this};Y.prototype.skipType=function(r){switch(r){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(r=this.uint32()&7)!==4;)this.skipType(r);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+r+" at offset "+this.pos)}return this};Y._configure=function(r){Us=r,Y.create=cu(),Us._configure();var t=Kt.Long?"toLong":"toNumber";Kt.merge(Y.prototype,{int64:function(){return Ms.call(this)[t](!1)},uint64:function(){return Ms.call(this)[t](!0)},sint64:function(){return Ms.call(this).zzDecode()[t](!1)},fixed64:function(){return su.call(this)[t](!0)},sfixed64:function(){return su.call(this)[t](!1)}})}});var pu=k((Fw,fu)=>{"use strict";fu.exports=Oe;var lu=Fs();(Oe.prototype=Object.create(lu.prototype)).constructor=Oe;var uu=Pe();function Oe(r){lu.call(this,r)}Oe._configure=function(){uu.Buffer&&(Oe.prototype._slice=uu.Buffer.prototype.slice)};Oe.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))};Oe._configure()});var qs=k(($w,gu)=>{"use strict";gu.exports=M;var Pt=Pe(),$s,Cn=Pt.LongBits,hu=Pt.base64,du=Pt.utf8;function Pr(r,t,e){this.fn=r,this.len=t,this.next=void 0,this.val=e}function Vs(){}function fm(r){this.head=r.head,this.tail=r.tail,this.len=r.len,this.next=r.states}function M(){this.len=0,this.head=new Pr(Vs,0,0),this.tail=this.head,this.states=null}var mu=function(){return Pt.Buffer?function(){return(M.create=function(){return new $s})()}:function(){return new M}};M.create=mu();M.alloc=function(t){return new Pt.Array(t)};Pt.Array!==Array&&(M.alloc=Pt.pool(M.alloc,Pt.Array.prototype.subarray));M.prototype._push=function(t,e,n){return this.tail=this.tail.next=new Pr(t,e,n),this.len+=e,this};function Gs(r,t,e){t[e]=r&255}function pm(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}function Hs(r,t){this.len=r,this.next=void 0,this.val=t}Hs.prototype=Object.create(Pr.prototype);Hs.prototype.fn=pm;M.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new Hs((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};M.prototype.int32=function(t){return t<0?this._push(js,10,Cn.fromNumber(t)):this.uint32(t)};M.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)};function js(r,t,e){for(;r.hi;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}M.prototype.uint64=function(t){var e=Cn.from(t);return this._push(js,e.length(),e)};M.prototype.int64=M.prototype.uint64;M.prototype.sint64=function(t){var e=Cn.from(t).zzEncode();return this._push(js,e.length(),e)};M.prototype.bool=function(t){return this._push(Gs,1,t?1:0)};function zs(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}M.prototype.fixed32=function(t){return this._push(zs,4,t>>>0)};M.prototype.sfixed32=M.prototype.fixed32;M.prototype.fixed64=function(t){var e=Cn.from(t);return this._push(zs,4,e.lo)._push(zs,4,e.hi)};M.prototype.sfixed64=M.prototype.fixed64;M.prototype.float=function(t){return this._push(Pt.float.writeFloatLE,4,t)};M.prototype.double=function(t){return this._push(Pt.float.writeDoubleLE,8,t)};var hm=Pt.Array.prototype.set?function(t,e,n){e.set(t,n)}:function(t,e,n){for(var o=0;o<t.length;++o)e[n+o]=t[o]};M.prototype.bytes=function(t){var e=t.length>>>0;if(!e)return this._push(Gs,1,0);if(Pt.isString(t)){var n=M.alloc(e=hu.length(t));hu.decode(t,n,0),t=n}return this.uint32(e)._push(hm,e,t)};M.prototype.string=function(t){var e=du.length(t);return e?this.uint32(e)._push(du.write,e,t):this._push(Gs,1,0)};M.prototype.fork=function(){return this.states=new fm(this),this.head=this.tail=new Pr(Vs,0,0),this.len=0,this};M.prototype.reset=function(){return this.states?(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 Pr(Vs,0,0),this.len=0),this};M.prototype.ldelim=function(){var t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=t.next,this.tail=e,this.len+=n),this};M.prototype.finish=function(){for(var t=this.head.next,e=this.constructor.alloc(this.len),n=0;t;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e};M._configure=function(r){$s=r,M.create=mu(),$s._configure()}});var bu=k((zw,wu)=>{"use strict";wu.exports=Yt;var yu=qs();(Yt.prototype=Object.create(yu.prototype)).constructor=Yt;var we=Pe();function Yt(){yu.call(this)}Yt._configure=function(){Yt.alloc=we._Buffer_allocUnsafe,Yt.writeBytesBuffer=we.Buffer&&we.Buffer.prototype instanceof Uint8Array&&we.Buffer.prototype.set.name==="set"?function(t,e,n){e.set(t,n)}:function(t,e,n){if(t.copy)t.copy(e,n,0,t.length);else for(var o=0;o<t.length;)e[n++]=t[o++]}};Yt.prototype.bytes=function(t){we.isString(t)&&(t=we._Buffer_from(t,"base64"));var e=t.length>>>0;return this.uint32(e),e&&this._push(Yt.writeBytesBuffer,e,t),this};function dm(r,t,e){r.length<40?we.utf8.write(r,t,e):t.utf8Write?t.utf8Write(r,e):t.write(r,e)}Yt.prototype.string=function(t){var e=we.Buffer.byteLength(t);return this.uint32(e),e&&this._push(dm,e,t),this};Yt._configure()});var r0={};vt(r0,{createClient:()=>e0});var te=class extends Error{constructor(t="The operation was aborted"){super(t),this.code=te.code,this.type=te.type}static get code(){return"ABORT_ERR"}static get type(){return"aborted"}},v=class extends Error{constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var Pa=O(Qt("net"),1);var Z=Qt("node:net");function ct(r){return!!(0,Z.isIP)(r)}var co={};vt(co,{identity:()=>zf});function kf(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),c=s.charCodeAt(0);if(e[c]!==255)throw new TypeError(s+" is ambiguous");e[c]=o}var f=r.length,l=r.charAt(0),d=Math.log(f)/Math.log(256),p=Math.log(256)/Math.log(f);function y(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var x=0,N=0,C=0,L=g.length;C!==L&&g[C]===0;)C++,x++;for(var K=(L-C)*p+1>>>0,et=new Uint8Array(K);C!==L;){for(var wt=g[C],dt=0,pt=K-1;(wt!==0||dt<N)&&pt!==-1;pt--,dt++)wt+=256*et[pt]>>>0,et[pt]=wt%f>>>0,wt=wt/f>>>0;if(wt!==0)throw new Error("Non-zero carry");N=dt,C++}for(var mt=K-N;mt!==K&&et[mt]===0;)mt++;for(var Lt=l.repeat(x);mt<K;++mt)Lt+=r.charAt(et[mt]);return Lt}function E(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var x=0;if(g[x]!==" "){for(var N=0,C=0;g[x]===l;)N++,x++;for(var L=(g.length-x)*d+1>>>0,K=new Uint8Array(L);g[x];){var et=e[g.charCodeAt(x)];if(et===255)return;for(var wt=0,dt=L-1;(et!==0||wt<C)&&dt!==-1;dt--,wt++)et+=f*K[dt]>>>0,K[dt]=et%256>>>0,et=et/256>>>0;if(et!==0)throw new Error("Non-zero carry");C=wt,x++}if(g[x]!==" "){for(var pt=L-C;pt!==L&&K[pt]===0;)pt++;for(var mt=new Uint8Array(N+(L-pt)),Lt=N;pt!==L;)mt[Lt++]=K[pt++];return mt}}}function b(g){var x=E(g);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:y,decodeUnsafe:E,decode:b}}var Mf=kf,Uf=Mf,Si=Uf;var c0=new Uint8Array(0);var xi=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0},Ct=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 Ai=r=>new TextEncoder().encode(r),_i=r=>new TextDecoder().decode(r);var no=class{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},oo=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Ri(this,t)}},so=class{constructor(t){this.decoders=t}or(t){return Ri(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Ri=(r,t)=>new so({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),io=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new no(t,e,n),this.decoder=new oo(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},ke=({name:r,prefix:t,encode:e,decode:n})=>new io(r,t,e,n),he=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=Si(e,t);return ke({prefix:r,name:t,encode:n,decode:s=>Ct(o(s))})},Ff=(r,t,e,n)=>{let o={};for(let p=0;p<t.length;++p)o[t[p]]=p;let s=r.length;for(;r[s-1]==="=";)--s;let c=new Uint8Array(s*e/8|0),f=0,l=0,d=0;for(let p=0;p<s;++p){let y=o[r[p]];if(y===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|y,f+=e,f>=8&&(f-=8,c[d++]=255&l>>f)}if(f>=e||255&l<<8-f)throw new SyntaxError("Unexpected end of data");return c},$f=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,s="",c=0,f=0;for(let l=0;l<r.length;++l)for(f=f<<8|r[l],c+=8;c>e;)c-=e,s+=t[o&f>>c];if(c&&(s+=t[o&f<<e-c]),n)for(;s.length*e&7;)s+="=";return s},j=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>ke({prefix:t,name:r,encode(o){return $f(o,n,e)},decode(o){return Ff(o,n,e,r)}});var zf=ke({prefix:"\0",name:"identity",encode:r=>_i(r),decode:r=>Ai(r)});var ao={};vt(ao,{base2:()=>Vf});var Vf=j({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var uo={};vt(uo,{base8:()=>Gf});var Gf=j({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var lo={};vt(lo,{base10:()=>Hf});var Hf=he({prefix:"9",name:"base10",alphabet:"0123456789"});var fo={};vt(fo,{base16:()=>jf,base16upper:()=>qf});var jf=j({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),qf=j({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var po={};vt(po,{base32:()=>X,base32hex:()=>Zf,base32hexpad:()=>Jf,base32hexpadupper:()=>Qf,base32hexupper:()=>Xf,base32pad:()=>Kf,base32padupper:()=>Yf,base32upper:()=>Wf,base32z:()=>tp});var X=j({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Wf=j({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Kf=j({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Yf=j({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Zf=j({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Xf=j({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Jf=j({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Qf=j({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),tp=j({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ho={};vt(ho,{base36:()=>ep,base36upper:()=>rp});var ep=he({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),rp=he({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var mo={};vt(mo,{base58btc:()=>U,base58flickr:()=>np});var U=he({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),np=he({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var yo={};vt(yo,{base64:()=>go,base64pad:()=>op,base64url:()=>sp,base64urlpad:()=>ip});var go=j({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),op=j({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),sp=j({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ip=j({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var wo={};vt(wo,{base256emoji:()=>fp});var Ci=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}"),cp=Ci.reduce((r,t,e)=>(r[e]=t,r),[]),ap=Ci.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function up(r){return r.reduce((t,e)=>(t+=cp[e],t),"")}function lp(r){let t=[];for(let e of r){let n=ap[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var fp=ke({prefix:"\u{1F680}",name:"base256emoji",encode:up,decode:lp});var So={};vt(So,{sha256:()=>Yr,sha512:()=>Bp});var To=O(Qt("crypto"),1);var pp=Pi,Bi=128,hp=127,dp=~hp,mp=Math.pow(2,31);function Pi(r,t,e){t=t||[],e=e||0;for(var n=e;r>=mp;)t[e++]=r&255|Bi,r/=128;for(;r&dp;)t[e++]=r&255|Bi,r>>>=7;return t[e]=r|0,Pi.bytes=e-n+1,t}var gp=bo,yp=128,Di=127;function bo(r,n){var e=0,n=n||0,o=0,s=n,c,f=r.length;do{if(s>=f)throw bo.bytes=0,new RangeError("Could not decode varint");c=r[s++],e+=o<28?(c&Di)<<o:(c&Di)*Math.pow(2,o),o+=7}while(c>=yp);return bo.bytes=s-n,e}var wp=Math.pow(2,7),bp=Math.pow(2,14),Ep=Math.pow(2,21),vp=Math.pow(2,28),Tp=Math.pow(2,35),Sp=Math.pow(2,42),xp=Math.pow(2,49),Ap=Math.pow(2,56),_p=Math.pow(2,63),Ip=function(r){return r<wp?1:r<bp?2:r<Ep?3:r<vp?4:r<Tp?5:r<Sp?6:r<xp?7:r<Ap?8:r<_p?9:10},Rp={encode:pp,decode:gp,encodingLength:Ip},Cp=Rp,fr=Cp;var pr=(r,t=0)=>[fr.decode(r,t),fr.decode.bytes],Me=(r,t,e=0)=>(fr.encode(r,t,e),t),Ue=r=>fr.encodingLength(r);var de=(r,t)=>{let e=t.byteLength,n=Ue(r),o=n+Ue(e),s=new Uint8Array(o+e);return Me(r,s,0),Me(e,s,n),s.set(t,o),new Fe(r,e,t,s)},Tt=r=>{let t=Ct(r),[e,n]=pr(t),[o,s]=pr(t.subarray(n)),c=t.subarray(n+s);if(c.byteLength!==o)throw new Error("Incorrect length");return new Fe(e,o,c,t)},Oi=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&xi(r.bytes,e.bytes)}},Fe=class{constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var vo=({name:r,code:t,encode:e})=>new Eo(r,t,e),Eo=class{constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?de(this.code,e):e.then(n=>de(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Yr=vo({name:"sha2-256",code:18,encode:r=>Ct(To.default.createHash("sha256").update(r).digest())}),Bp=vo({name:"sha2-512",code:19,encode:r=>Ct(To.default.createHash("sha512").update(r).digest())});var xo={};vt(xo,{identity:()=>Zr});var Ni=0,Dp="identity",ki=Ct,Pp=r=>de(Ni,ki(r)),Zr={code:Ni,name:Dp,encode:ki,digest:Pp};var C0=new TextEncoder,B0=new TextDecoder;var Mi=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return kp(e,Ao(r),t||U.encoder);default:return Mp(e,Ao(r),t||X.encoder)}};var Ui=new WeakMap,Ao=r=>{let t=Ui.get(r);if(t==null){let e=new Map;return Ui.set(r,e),e}return t},B=class{constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==hr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Up)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return B.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=de(t,e);return B.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return B.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&Oi(t.multihash,n.multihash)}toString(t){return Mi(this,t)}toJSON(){return{"/":Mi(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof B)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:c}=e;return new B(n,o,s,c||Fi(n,o,s.bytes))}else if(e[Fp]===!0){let{version:n,multihash:o,code:s}=e,c=Tt(o);return B.create(n,s,c)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==hr)throw new Error(`Version 0 CID must use dag-pb (code: ${hr}) block encoding`);return new B(t,e,n,n.bytes)}case 1:{let o=Fi(t,e,n.bytes);return new B(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return B.create(0,hr,t)}static createV1(t,e){return B.create(1,t,e)}static decode(t){let[e,n]=B.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=B.inspectBytes(t),n=e.size-e.multihashSize,o=Ct(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),c=new Fe(e.multihashCode,e.digestSize,s,o);return[e.version===0?B.createV0(c):B.createV1(e.codec,c),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[y,E]=pr(t.subarray(e));return e+=E,y},o=n(),s=hr;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let c=e,f=n(),l=n(),d=e+l,p=d-c;return{version:o,codec:s,multihashCode:f,digestSize:l,multihashSize:p,size:d}}static parse(t,e){let[n,o]=Np(t,e),s=B.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ao(s).set(n,t),s}},Np=(r,t)=>{switch(r[0]){case"Q":{let e=t||U;return[U.prefix,e.decode(`${U.prefix}${r}`)]}case U.prefix:{let e=t||U;return[U.prefix,e.decode(r)]}case X.prefix:{let e=t||X;return[X.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},kp=(r,t,e)=>{let{prefix:n}=e;if(n!==U.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o},Mp=(r,t,e)=>{let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o},hr=112,Up=18,Fi=(r,t,e)=>{let n=Ue(r),o=n+Ue(t),s=new Uint8Array(o+e.byteLength);return Me(r,s,0),Me(t,s,n),s.set(e,o),s},Fp=Symbol.for("@ipld/js-cid/CID");var gt={...co,...ao,...uo,...lo,...fo,...po,...ho,...mo,...yo,...wo},$0={...So,...xo};function Se(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function ee(r=0){return globalThis.Buffer?.alloc!=null?Se(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function re(r=0){return globalThis.Buffer?.allocUnsafe!=null?Se(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function zi(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var $i=zi("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),_o=zi("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=re(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),$p={utf8:$i,"utf-8":$i,hex:gt.base16,latin1:_o,ascii:_o,binary:_o,...gt},Xr=$p;function I(r,t="utf8"){let e=Xr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}var Vi=Z.isIPv4,zp=Z.isIPv6,Io=function(r){let t=0;if(r=r.toString().trim(),Vi(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(zp(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=Vi(e[n]),c;s&&(c=Io(e[n]),e[n]=I(c.slice(0,2),"base16")),c!=null&&++n<8&&e.splice(n,0,I(c.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},Gi=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var dr={},Ro={},Gp=[[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"]];Gp.forEach(r=>{let t=Hp(...r);Ro[t.code]=t,dr[t.name]=t});function Hp(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function z(r){if(typeof r=="number"){if(Ro[r]!=null)return Ro[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(dr[r]!=null)return dr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Ht=O(St(),1);function Bt(r,t="utf8"){let e=Xr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Se(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function D(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=re(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return Se(e)}function nc(r,t){switch(z(r).code){case 4:case 41:return sh(t);case 42:return ec(t);case 6:case 273:case 33:case 132:return sc(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ec(t);case 421:return uh(t);case 444:return rc(t);case 445:return rc(t);case 466:return ah(t);default:return I(t,"base16")}}function oc(r,t){switch(z(r).code){case 4:return Qi(t);case 41:return Qi(t);case 42:return tc(t);case 6:case 273:case 33:case 132:return Po(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return tc(t);case 421:return ih(t);case 444:return lh(t);case 445:return fh(t);case 466:return ch(t);default:return Bt(t,"base16")}}var Do=Object.values(gt).map(r=>r.decoder),oh=function(){let r=Do[0].or(Do[1]);return Do.slice(2).forEach(t=>r=r.or(t)),r}();function Qi(r){if(!ct(r))throw new Error("invalid ip address");return Io(r)}function sh(r){let t=Gi(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!ct(t))throw new Error("invalid ip address");return t}function Po(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function sc(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function tc(r){let t=Bt(r),e=Uint8Array.from(Ht.default.encode(t.length));return D([e,t],e.length+t.length)}function ec(r){let t=Ht.default.decode(r);if(r=r.slice(Ht.default.decode.bytes),r.length!==t)throw new Error("inconsistent lengths");return I(r)}function ih(r){let t;r[0]==="Q"||r[0]==="1"?t=Tt(U.decode(`z${r}`)).bytes:t=B.parse(r).multihash.bytes;let e=Uint8Array.from(Ht.default.encode(t.length));return D([e,t],e.length+t.length)}function ch(r){let t=oh.decode(r),e=Uint8Array.from(Ht.default.encode(t.length));return D([e,t],e.length+t.length)}function ah(r){let t=Ht.default.decode(r),e=r.slice(Ht.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return"u"+I(e,"base64url")}function uh(r){let t=Ht.default.decode(r),e=r.slice(Ht.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return I(e,"base58btc")}function lh(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=X.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Po(n);return D([e,o],e.length+o.length)}function fh(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=X.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Po(n);return D([e,o],e.length+o.length)}function rc(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=I(t,"base32"),o=sc(e);return`${n}:${o}`}var $e=O(St(),1);function ph(r){let t=[],e=r.split("/").slice(1);if(e.length===1&&e[0]==="")return[];for(let n=0;n<e.length;n++){let o=e[n],s=z(o);if(s.size===0){t.push([o]);continue}if(n++,n>=e.length)throw cc("invalid address: "+r);if(s.path===!0){t.push([o,Mo(e.slice(n).join("/"))]);break}t.push([o,e[n]])}return t}function hh(r){let t=[];return r.map(e=>{let n=tn(e);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Mo(t.join("/"))}function dh(r){return r.map(t=>{Array.isArray(t)||(t=[t]);let e=tn(t);return t.length>1?[e.code,oc(e.code,t[1])]:[e.code]})}function Oo(r){return r.map(t=>{let e=tn(t);return t[1]!=null?[e.code,nc(e.code,t[1])]:[e.code]})}function Lo(r){return Qr(D(r.map(t=>{let e=tn(t),n=Uint8Array.from($e.default.encode(e.code));return t.length>1&&t[1]!=null&&(n=D([n,t[1]])),n})))}function No(r,t){return r.size>0?r.size/8:r.size===0?0:$e.default.decode(t)+($e.default.decode.bytes??0)}function Jr(r){let t=[],e=0;for(;e<r.length;){let n=$e.default.decode(r,e),o=$e.default.decode.bytes??0,s=z(n),c=No(s,r.slice(e+o));if(c===0){t.push([n]),e+=o;continue}let f=r.slice(e+o,e+o+c);if(e+=c+o,e>r.length)throw cc("Invalid address Uint8Array: "+I(r,"base16"));t.push([n,f])}return t}function ko(r){let t=Jr(r),e=Oo(t);return hh(e)}function mh(r){r=Mo(r);let t=ph(r),e=dh(t);return Lo(e)}function ic(r){return mh(r)}function Qr(r){let t=gh(r);if(t!=null)throw t;return Uint8Array.from(r)}function gh(r){try{Jr(r)}catch(t){return t}}function Mo(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function cc(r){return new Error("Error parsing address: "+r)}function tn(r){return z(r[0])}var Fo=O(St(),1);var fc=O(xe(),1);function xt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var ze=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Uo=function(r,t,e,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 t=="function"?r!==t||!o:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(r,e):o?o.value=e:t.set(r,e),e},mr,gr,yr,lc,bh=Symbol.for("nodejs.util.inspect.custom"),Eh=[z("dns").code,z("dns4").code,z("dns6").code,z("dnsaddr").code],vh=new Map,pc=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Th(r){return!!r?.[pc]}var ne=class{constructor(t){if(mr.set(this,void 0),gr.set(this,void 0),yr.set(this,void 0),this[lc]=!0,t==null&&(t=""),t instanceof Uint8Array)this.bytes=Qr(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=ic(t)}else if(Th(t))this.bytes=Qr(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return ze(this,mr,"f")==null&&Uo(this,mr,ko(this.bytes),"f"),ze(this,mr,"f")}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",c=z("tcp"),f=z("udp"),l=z("ip4"),d=z("ip6"),p=z("dns6"),y=z("ip6zone");for(let[b,g]of this.stringTuples())b===y.code&&(s=`%${g??""}`),Eh.includes(b)&&(e=c.name,o=443,n=`${g??""}${s}`,t=b===p.code?6:4),(b===c.code||b===f.code)&&(e=z(b).name,o=parseInt(g??"")),(b===l.code||b===d.code)&&(e=z(b).name,n=`${g??""}${s}`,t=b===d.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.protoCodes().map(t=>Object.assign({},z(t)))}protoCodes(){let t=[],e=this.bytes,n=0;for(;n<e.length;){let o=Fo.default.decode(e,n),s=Fo.default.decode.bytes??0,c=z(o),f=No(c,e.slice(n+s));n+=f+s,t.push(o)}return t}protoNames(){return this.protos().map(t=>t.name)}tuples(){return ze(this,gr,"f")==null&&Uo(this,gr,Jr(this.bytes),"f"),ze(this,gr,"f")}stringTuples(){return ze(this,yr,"f")==null&&Uo(this,yr,Oo(this.tuples()),"f"),ze(this,yr,"f")}encapsulate(t){return t=new ne(t),new ne(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new ne(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new ne(Lo(e.slice(0,n)));return this}getPeerId(){try{let e=this.stringTuples().filter(n=>n[0]===dr.ipfs.code).pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?I(U.decode(`z${n}`),"base58btc"):I(B.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let t=null;try{t=this.stringTuples().filter(e=>z(e[0]).path===!0)[0][1],t==null&&(t=null)}catch{t=null}return t}equals(t){return xt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=vh.get(e.name);if(n==null)throw(0,fc.default)(new Error(`no available resolver for ${e.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(s=>new ne(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[(mr=new WeakMap,gr=new WeakMap,yr=new WeakMap,lc=pc,bh)](){return`Multiaddr(${ko(this.bytes)})`}};function $o(r){return new ne(r)}var Sh=A("dns4"),xh=A("dns6"),Ah=A("dnsaddr"),Ae=st(A("dns"),Ah,Sh,xh),en=st(A("ip4"),A("ip6")),ge=st(R(en,A("tcp")),R(Ae,A("tcp"))),Go=R(en,A("udp")),_h=R(Go,A("utp")),Ih=R(Go,A("quic")),br=st(R(ge,A("ws")),R(Ae,A("ws"))),Er=st(R(ge,A("wss")),R(Ae,A("wss")),R(ge,A("tls"),A("ws")),R(Ae,A("tls"),A("ws"))),zo=st(R(ge,A("http")),R(en,A("http")),R(Ae,A("http"))),Vo=st(R(ge,A("https")),R(en,A("https")),R(Ae,A("https"))),hc=R(Go,A("webrtc"),A("certhash")),mc=st(R(hc,A("p2p")),hc),gc=st(R(br,A("p2p-webrtc-star"),A("p2p")),R(Er,A("p2p-webrtc-star"),A("p2p")),R(br,A("p2p-webrtc-star")),R(Er,A("p2p-webrtc-star"))),Pg=st(R(br,A("p2p-websocket-star"),A("p2p")),R(Er,A("p2p-websocket-star"),A("p2p")),R(br,A("p2p-websocket-star")),R(Er,A("p2p-websocket-star"))),yc=st(R(zo,A("p2p-webrtc-direct"),A("p2p")),R(Vo,A("p2p-webrtc-direct"),A("p2p")),R(zo,A("p2p-webrtc-direct")),R(Vo,A("p2p-webrtc-direct"))),vr=st(br,Er,zo,Vo,gc,yc,ge,_h,Ih,Ae,mc),Og=st(R(vr,A("p2p-stardust"),A("p2p")),R(vr,A("p2p-stardust"))),me=st(R(vr,A("p2p")),gc,yc,mc,A("p2p")),dc=st(R(me,A("p2p-circuit"),me),R(me,A("p2p-circuit")),R(A("p2p-circuit"),me),R(vr,A("p2p-circuit")),R(A("p2p-circuit"),vr),A("p2p-circuit")),wc=()=>st(R(dc,wc),dc),wr=wc(),Lg=st(R(wr,me,wr),R(me,wr),R(wr,me),wr,me);function bc(r){function t(e){let n;try{n=$o(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function R(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(o=>(n=typeof o=="function"?o().partialMatch(e):o.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:bc(t),partialMatch:t}}function st(...r){function t(n){let o=null;return r.some(s=>{let c=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return c!=null?(o=c,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:bc(t),partialMatch:t}}function A(r){let t=r;function e(o){let s;try{s=$o(o)}catch{return!1}let c=s.protoNames();return c.length===1&&c[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var jt=O(Bc(),1);jt.default.formatters.b=r=>r==null?"undefined":U.baseEncode(r);jt.default.formatters.t=r=>r==null?"undefined":X.baseEncode(r);jt.default.formatters.m=r=>r==null?"undefined":go.baseEncode(r);jt.default.formatters.p=r=>r==null?"undefined":r.toString();jt.default.formatters.c=r=>r==null?"undefined":r.toString();jt.default.formatters.k=r=>r==null?"undefined":r.toString();function Dt(r){return Object.assign((0,jt.default)(r),{error:(0,jt.default)(`${r}:error`),trace:(0,jt.default)(`${r}:trace`)})}var Ra=O(Uc(),1);var Fc=Z.isIPv4,rd=Z.isIPv6,Yo=function(r){let t=0;if(r=r.toString().trim(),Fc(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(rd(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=Fc(e[n]),c;s&&(c=Yo(e[n]),e[n]=I(c.slice(0,2),"base16")),c!=null&&++n<8&&e.splice(n,0,I(c.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},$c=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Tr={},Zo={},od=[[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"]];od.forEach(r=>{let t=sd(...r);Zo[t.code]=t,Tr[t.name]=t});function sd(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function V(r){if(typeof r=="number"){if(Zo[r]!=null)return Zo[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Tr[r]!=null)return Tr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var qt=O(St(),1);function jc(r,t){switch(V(r).code){case 4:case 41:return cd(t);case 42:return Gc(t);case 6:case 273:case 33:case 132:return Wc(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Gc(t);case 421:return fd(t);case 444:return Hc(t);case 445:return Hc(t);case 466:return ld(t);default:return I(t,"base16")}}function qc(r,t){switch(V(r).code){case 4:return zc(t);case 41:return zc(t);case 42:return Vc(t);case 6:case 273:case 33:case 132:return Jo(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Vc(t);case 421:return ad(t);case 444:return pd(t);case 445:return hd(t);case 466:return ud(t);default:return Bt(t,"base16")}}var Xo=Object.values(gt).map(r=>r.decoder),id=function(){let r=Xo[0].or(Xo[1]);return Xo.slice(2).forEach(t=>r=r.or(t)),r}();function zc(r){if(!ct(r))throw new Error("invalid ip address");return Yo(r)}function cd(r){let t=$c(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!ct(t))throw new Error("invalid ip address");return t}function Jo(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Wc(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Vc(r){let t=Bt(r),e=Uint8Array.from(qt.default.encode(t.length));return D([e,t],e.length+t.length)}function Gc(r){let t=qt.default.decode(r);if(r=r.slice(qt.default.decode.bytes),r.length!==t)throw new Error("inconsistent lengths");return I(r)}function ad(r){let t;r[0]==="Q"||r[0]==="1"?t=Tt(U.decode(`z${r}`)).bytes:t=B.parse(r).multihash.bytes;let e=Uint8Array.from(qt.default.encode(t.length));return D([e,t],e.length+t.length)}function ud(r){let t=id.decode(r),e=Uint8Array.from(qt.default.encode(t.length));return D([e,t],e.length+t.length)}function ld(r){let t=qt.default.decode(r),e=r.slice(qt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return"u"+I(e,"base64url")}function fd(r){let t=qt.default.decode(r),e=r.slice(qt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return I(e,"base58btc")}function pd(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=X.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Jo(n);return D([e,o],e.length+o.length)}function hd(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=X.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Jo(n);return D([e,o],e.length+o.length)}function Hc(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=I(t,"base32"),o=Wc(e);return`${n}:${o}`}var We=O(St(),1);function dd(r){let t=[],e=r.split("/").slice(1);if(e.length===1&&e[0]==="")return[];for(let n=0;n<e.length;n++){let o=e[n],s=V(o);if(s.size===0){t.push([o]);continue}if(n++,n>=e.length)throw Yc("invalid address: "+r);if(s.path===!0){t.push([o,ns(e.slice(n).join("/"))]);break}t.push([o,e[n]])}return t}function md(r){let t=[];return r.map(e=>{let n=ln(e);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),ns(t.join("/"))}function gd(r){return r.map(t=>{Array.isArray(t)||(t=[t]);let e=ln(t);return t.length>1?[e.code,qc(e.code,t[1])]:[e.code]})}function Qo(r){return r.map(t=>{let e=ln(t);return t[1]!=null?[e.code,jc(e.code,t[1])]:[e.code]})}function ts(r){return un(D(r.map(t=>{let e=ln(t),n=Uint8Array.from(We.default.encode(e.code));return t.length>1&&t[1]!=null&&(n=D([n,t[1]])),n})))}function es(r,t){return r.size>0?r.size/8:r.size===0?0:We.default.decode(t)+(We.default.decode.bytes??0)}function an(r){let t=[],e=0;for(;e<r.length;){let n=We.default.decode(r,e),o=We.default.decode.bytes??0,s=V(n),c=es(s,r.slice(e+o));if(c===0){t.push([n]),e+=o;continue}let f=r.slice(e+o,e+o+c);if(e+=c+o,e>r.length)throw Yc("Invalid address Uint8Array: "+I(r,"base16"));t.push([n,f])}return t}function rs(r){let t=an(r),e=Qo(t);return md(e)}function yd(r){r=ns(r);let t=dd(r),e=gd(t);return ts(e)}function Kc(r){return yd(r)}function un(r){let t=wd(r);if(t!=null)throw t;return Uint8Array.from(r)}function wd(r){try{an(r)}catch(t){return t}}function ns(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Yc(r){return new Error("Error parsing address: "+r)}function ln(r){return V(r[0])}var ss=O(St(),1);var Xc=O(xe(),1);var Ke=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},os=function(r,t,e,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 t=="function"?r!==t||!o:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(r,e):o?o.value=e:t.set(r,e),e},Sr,xr,Ar,Zc,Ed=Symbol.for("nodejs.util.inspect.custom"),vd=[V("dns").code,V("dns4").code,V("dns6").code,V("dnsaddr").code],Td=new Map,Jc=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Sd(r){return!!r?.[Jc]}var oe=class{constructor(t){if(Sr.set(this,void 0),xr.set(this,void 0),Ar.set(this,void 0),this[Zc]=!0,t==null&&(t=""),t instanceof Uint8Array)this.bytes=un(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=Kc(t)}else if(Sd(t))this.bytes=un(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return Ke(this,Sr,"f")==null&&os(this,Sr,rs(this.bytes),"f"),Ke(this,Sr,"f")}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",c=V("tcp"),f=V("udp"),l=V("ip4"),d=V("ip6"),p=V("dns6"),y=V("ip6zone");for(let[b,g]of this.stringTuples())b===y.code&&(s=`%${g??""}`),vd.includes(b)&&(e=c.name,o=443,n=`${g??""}${s}`,t=b===p.code?6:4),(b===c.code||b===f.code)&&(e=V(b).name,o=parseInt(g??"")),(b===l.code||b===d.code)&&(e=V(b).name,n=`${g??""}${s}`,t=b===d.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.protoCodes().map(t=>Object.assign({},V(t)))}protoCodes(){let t=[],e=this.bytes,n=0;for(;n<e.length;){let o=ss.default.decode(e,n),s=ss.default.decode.bytes??0,c=V(o),f=es(c,e.slice(n+s));n+=f+s,t.push(o)}return t}protoNames(){return this.protos().map(t=>t.name)}tuples(){return Ke(this,xr,"f")==null&&os(this,xr,an(this.bytes),"f"),Ke(this,xr,"f")}stringTuples(){return Ke(this,Ar,"f")==null&&os(this,Ar,Qo(this.tuples()),"f"),Ke(this,Ar,"f")}encapsulate(t){return t=new oe(t),new oe(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new oe(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new oe(ts(e.slice(0,n)));return this}getPeerId(){try{let e=this.stringTuples().filter(n=>n[0]===Tr.ipfs.code).pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?I(U.decode(`z${n}`),"base58btc"):I(B.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let t=null;try{t=this.stringTuples().filter(e=>V(e[0]).path===!0)[0][1],t==null&&(t=null)}catch{t=null}return t}equals(t){return xt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=Td.get(e.name);if(n==null)throw(0,Xc.default)(new Error(`no available resolver for ${e.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(s=>new oe(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[(Sr=new WeakMap,xr=new WeakMap,Ar=new WeakMap,Zc=Jc,Ed)](){return`Multiaddr(${rs(this.bytes)})`}};function fn(r){return new oe(r)}var bn=O(xe(),1);function pn(r){return this.subnetMask<r.subnetMask?!1:this.mask(r.subnetMask)===r.mask()}function hn(r){return function(){return this.addressMinusSuffix!==this.correctForm()?!1:this.subnetMask===r&&!this.parsedSubnet?!0:this.parsedSubnet===String(this.subnetMask)}}var Ye=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g,is=/\/\d{1,2}$/;var ut=class extends Error{constructor(t,e){super(t),this.name="AddressError",e!==null&&(this.parseMessage=e)}};var Ze=O(cs(),1),Ie=O(_r(),1),$=class{constructor(t){this.groups=4,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=hn(32),this.isInSubnet=pn,this.address=t;let e=is.exec(t);if(e){if(this.parsedSubnet=e[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,this.subnetMask<0||this.subnetMask>32)throw new ut("Invalid subnet mask.");t=t.replace(is,"")}this.addressMinusSuffix=t,this.parsedAddress=this.parse(t)}static isValid(t){try{return new $(t),!0}catch{return!1}}parse(t){let e=t.split(".");if(!t.match(Ye))throw new ut("Invalid IPv4 address.");return e}correctForm(){return this.parsedAddress.map(t=>parseInt(t,10)).join(".")}static fromHex(t){let e=t.replace(/:/g,"").padStart(8,"0"),n=[],o;for(o=0;o<8;o+=2){let s=e.slice(o,o+2);n.push(parseInt(s,16))}return new $(n.join("."))}static fromInteger(t){return $.fromHex(t.toString(16))}static fromArpa(t){let n=t.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join(".");return new $(n)}toHex(){return this.parsedAddress.map(t=>(0,Ie.sprintf)("%02x",parseInt(t,10))).join(":")}toArray(){return this.parsedAddress.map(t=>parseInt(t,10))}toGroup6(){let t=[],e;for(e=0;e<4;e+=2){let n=(0,Ie.sprintf)("%02x%02x",parseInt(this.parsedAddress[e],10),parseInt(this.parsedAddress[e+1],10));t.push((0,Ie.sprintf)("%x",parseInt(n,16)))}return t.join(":")}bigInteger(){return new Ze.BigInteger(this.parsedAddress.map(t=>(0,Ie.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new Ze.BigInteger(this.mask()+"0".repeat(32-this.subnetMask),2)}startAddress(){return $.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new Ze.BigInteger("1");return $.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new Ze.BigInteger(this.mask()+"1".repeat(32-this.subnetMask),2)}endAddress(){return $.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new Ze.BigInteger("1");return $.fromBigInteger(this._endAddress().subtract(t))}static fromBigInteger(t){return $.fromInteger(parseInt(t.toString(),10))}mask(t){return t===void 0&&(t=this.subnetMask),this.getBitsBase2(0,t)}getBitsBase2(t,e){return this.binaryZeroPad().slice(t,e)}reverseForm(t){t||(t={});let e=this.correctForm().split(".").reverse().join(".");return t.omitSuffix?e:(0,Ie.sprintf)("%s.in-addr.arpa.",e)}isMulticast(){return this.isInSubnet(new $("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(32,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(Ye,(0,Ie.sprintf)('<span class="hover-group group-v4 group-6">%s</span>.<span class="hover-group group-v4 group-7">%s</span>',t.slice(0,2).join("."),t.slice(2,4).join(".")))}};var na={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},as={"ff01::1/128":"Multicast (All nodes on this interface)","ff01::2/128":"Multicast (All routers on this interface)","ff02::1/128":"Multicast (All nodes on this link)","ff02::2/128":"Multicast (All routers on this link)","ff05::2/128":"Multicast (All routers in this site)","ff02::5/128":"Multicast (OSPFv3 AllSPF routers)","ff02::6/128":"Multicast (OSPFv3 AllDR routers)","ff02::9/128":"Multicast (RIP routers)","ff02::a/128":"Multicast (EIGRP routers)","ff02::d/128":"Multicast (PIM routers)","ff02::16/128":"Multicast (MLDv2 reports)","ff01::fb/128":"Multicast (mDNSv6)","ff02::fb/128":"Multicast (mDNSv6)","ff05::fb/128":"Multicast (mDNSv6)","ff02::1:2/128":"Multicast (All DHCP servers and relay agents on this link)","ff05::1:2/128":"Multicast (All DHCP servers and relay agents in this site)","ff02::1:3/128":"Multicast (All DHCP servers on this link)","ff05::1:3/128":"Multicast (All DHCP servers in this site)","::/128":"Unspecified","::1/128":"Loopback","ff00::/8":"Multicast","fe80::/10":"Link-local unicast"},us=/([^0-9a-f:/%])/gi,ls=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,fs=/\/\d{1,3}(?=%|$)/,ps=/%.*$/,oa=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),sa=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);var ca=O(_r(),1);function xd(r){return r.replace(/^(0+)/,'<span class="zero">$1</span>')}function gn(r,t=0){return r.split(":").map((n,o)=>/group-v4/.test(n)?n:(0,ca.sprintf)('<span class="hover-group group-%d">%s</span>',o+t,xd(n)))}var Ce=O(_r(),1);function ds(r){return(0,Ce.sprintf)("(%s)",r.join("|"))}function hs(r){return r.length<4?(0,Ce.sprintf)("0{0,%d}%s",4-r.length,r):r}var ms="[^A-Fa-f0-9:]";function yn(r){let t=[];r.forEach((n,o)=>{parseInt(n,16)===0&&t.push(o)});let e=t.map(n=>r.map((o,s)=>{if(s===n){let c=s===0||s===8-1?":":"";return ds([hs(o),c])}return hs(o)}).join(":"));return e.push(r.map(hs).join(":")),ds(e)}function gs(r,t,e){let n=t?"":":",o=e?"":":",s=[];!t&&!e&&s.push("::"),t&&e&&s.push(""),(e&&!t||!e&&t)&&s.push(":"),s.push((0,Ce.sprintf)("%s(:0{1,4}){1,%d}",n,r-1)),s.push((0,Ce.sprintf)("(0{1,4}:){1,%d}%s",r-1,o)),s.push((0,Ce.sprintf)("(0{1,4}:){%d}0{1,4}",r-1));for(let c=1;c<r-1;c++)for(let f=1;f<r-c;f++)s.push((0,Ce.sprintf)("(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}",f,r-f-c-1));return ds(s)}var lt=O(cs(),1),ft=O(_r(),1);function wn(r){if(!r)throw new Error("Assertion failed.")}function Ad(r){let t=/(\d+)(\d{3})/;for(;t.test(r);)r=r.replace(t,"$1,$2");return r}function _d(r){return r=r.replace(/^(0{1,})([1-9]+)$/,'<span class="parse-error">$1</span>$2'),r=r.replace(/^(0{1,})(0)$/,'<span class="parse-error">$1</span>$2'),r}function Id(r,t){let e=[],n=[],o;for(o=0;o<r.length;o++)o<t[0]?e.push(r[o]):o>t[1]&&n.push(r[o]);return e.concat(["compact"]).concat(n)}function ua(r){return(0,ft.sprintf)("%04x",parseInt(r,16))}function la(r){return r&255}var q=class{constructor(t,e){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=pn,this.isCorrect=hn(128),e===void 0?this.groups=8:this.groups=e,this.address=t;let n=fs.exec(t);if(n){if(this.parsedSubnet=n[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,Number.isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>128)throw new ut("Invalid subnet mask.");t=t.replace(fs,"")}else if(/\//.test(t))throw new ut("Invalid subnet mask.");let o=ps.exec(t);o&&(this.zone=o[0],t=t.replace(ps,"")),this.addressMinusSuffix=t,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new q(t),!0}catch{return!1}}static fromBigInteger(t){let e=t.toString(16).padStart(32,"0"),n=[],o;for(o=0;o<8;o++)n.push(e.slice(o*4,(o+1)*4));return new q(n.join(":"))}static fromURL(t){let e,n=null,o;if(t.indexOf("[")!==-1&&t.indexOf("]:")!==-1){if(o=sa.exec(t),o===null)return{error:"failed to parse address with port",address:null,port:null};e=o[1],n=o[2]}else if(t.indexOf("/")!==-1){if(t=t.replace(/^[a-z0-9]+:\/\//,""),o=oa.exec(t),o===null)return{error:"failed to parse address from URL",address:null,port:null};e=o[1]}else e=t;return n?(n=parseInt(n,10),(n<0||n>65536)&&(n=null)):n=null,{address:new q(e),port:n}}static fromAddress4(t){let e=new $(t),n=128-(32-e.subnetMask);return new q(`::ffff:${e.correctForm()}/${n}`)}static fromArpa(t){let e=t.replace(/(\.ip6\.arpa)?\.$/,""),n=7;if(e.length!==63)throw new ut("Invalid 'ip6.arpa' form.");let o=e.split(".").reverse();for(let s=n;s>0;s--){let c=s*4;o.splice(c,0,":")}return e=o.join(""),new q(e)}microsoftTranscription(){return(0,ft.sprintf)("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))}mask(t=this.subnetMask){return this.getBitsBase2(0,t)}possibleSubnets(t=128){let e=128-this.subnetMask,n=Math.abs(t-128),o=e-n;return o<0?"0":Ad(new lt.BigInteger("2",10).pow(o).toString(10))}_startAddress(){return new lt.BigInteger(this.mask()+"0".repeat(128-this.subnetMask),2)}startAddress(){return q.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new lt.BigInteger("1");return q.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new lt.BigInteger(this.mask()+"1".repeat(128-this.subnetMask),2)}endAddress(){return q.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new lt.BigInteger("1");return q.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=na[this.getBits(12,16).intValue()];return this.getType()==="Global unicast"&&t!=="Link local"&&(t="Global"),t||"Unknown"}getType(){for(let t of Object.keys(as))if(this.isInSubnet(new q(t)))return as[t];return"Global unicast"}getBits(t,e){return new lt.BigInteger(this.getBitsBase2(t,e),2)}getBitsBase2(t,e){return this.binaryZeroPad().slice(t,e)}getBitsBase16(t,e){let n=e-t;if(n%4!==0)throw new Error("Length of bits to retrieve must be divisible by four");return this.getBits(t,e).toString(16).padStart(n/4,"0")}getBitsPastSubnet(){return this.getBitsBase2(this.subnetMask,128)}reverseForm(t){t||(t={});let e=Math.floor(this.subnetMask/4),n=this.canonicalForm().replace(/:/g,"").split("").slice(0,e).reverse().join(".");return e>0?t.omitSuffix?n:(0,ft.sprintf)("%s.ip6.arpa.",n):t.omitSuffix?"":"ip6.arpa."}correctForm(){let t,e=[],n=0,o=[];for(t=0;t<this.parsedAddress.length;t++){let f=parseInt(this.parsedAddress[t],16);f===0&&n++,f!==0&&n>0&&(n>1&&o.push([t-n,t-1]),n=0)}n>1&&o.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let s=o.map(f=>f[1]-f[0]+1);if(o.length>0){let f=s.indexOf(Math.max(...s));e=Id(this.parsedAddress,o[f])}else e=this.parsedAddress;for(t=0;t<e.length;t++)e[t]!=="compact"&&(e[t]=parseInt(e[t],16).toString(16));let c=e.join(":");return c=c.replace(/^compact$/,"::"),c=c.replace(/^compact|compact$/,":"),c=c.replace(/compact/,""),c}binaryZeroPad(){return this.bigInteger().toString(2).padStart(128,"0")}parse4in6(t){let e=t.split(":"),o=e.slice(-1)[0].match(Ye);if(o){this.parsedAddress4=o[0],this.address4=new $(this.parsedAddress4);for(let s=0;s<this.address4.groups;s++)if(/^0[0-9]+/.test(this.address4.parsedAddress[s]))throw new ut("IPv4 addresses can't have leading zeroes.",t.replace(Ye,this.address4.parsedAddress.map(_d).join(".")));this.v4=!0,e[e.length-1]=this.address4.toGroup6(),t=e.join(":")}return t}parse(t){t=this.parse4in6(t);let e=t.match(us);if(e)throw new ut((0,ft.sprintf)("Bad character%s detected in address: %s",e.length>1?"s":"",e.join("")),t.replace(us,'<span class="parse-error">$1</span>'));let n=t.match(ls);if(n)throw new ut((0,ft.sprintf)("Address failed regex: %s",n.join("")),t.replace(ls,'<span class="parse-error">$1</span>'));let o=[],s=t.split("::");if(s.length===2){let c=s[0].split(":"),f=s[1].split(":");c.length===1&&c[0]===""&&(c=[]),f.length===1&&f[0]===""&&(f=[]);let l=this.groups-(c.length+f.length);if(!l)throw new ut("Error parsing groups");this.elidedGroups=l,this.elisionBegin=c.length,this.elisionEnd=c.length+this.elidedGroups,o=o.concat(c);for(let d=0;d<l;d++)o.push("0");o=o.concat(f)}else if(s.length===1)o=t.split(":"),this.elidedGroups=0;else throw new ut("Too many :: groups found");if(o=o.map(c=>(0,ft.sprintf)("%x",parseInt(c,16))),o.length!==this.groups)throw new ut("Incorrect number of groups found");return o}canonicalForm(){return this.parsedAddress.map(ua).join(":")}decimal(){return this.parsedAddress.map(t=>(0,ft.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new lt.BigInteger(this.parsedAddress.map(ua).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return $.fromHex(new lt.BigInteger(t.slice(96,128).join(""),2).toString(16))}to4in6(){let t=this.to4(),n=new q(this.parsedAddress.slice(0,6).join(":"),6).correctForm(),o="";return/:$/.test(n)||(o=":"),n+o+t.address}inspectTeredo(){let t=this.getBitsBase16(0,32),e=this.getBits(80,96).xor(new lt.BigInteger("ffff",16)).toString(),n=$.fromHex(this.getBitsBase16(32,64)),o=$.fromHex(this.getBits(96,128).xor(new lt.BigInteger("ffffffff",16)).toString(16)),s=this.getBits(64,80),c=this.getBitsBase2(64,80),f=s.testBit(15),l=s.testBit(14),d=s.testBit(8),p=s.testBit(9),y=new lt.BigInteger(c.slice(2,6)+c.slice(8,16),2).toString(10);return{prefix:(0,ft.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:o.address,flags:c,coneNat:f,microsoft:{reserved:l,universalLocal:p,groupIndividual:d,nonce:y},udpPort:e}}inspect6to4(){let t=this.getBitsBase16(0,16),e=$.fromHex(this.getBitsBase16(16,48));return{prefix:(0,ft.sprintf)("%s",t.slice(0,4)),gateway:e.address}}to6to4(){if(!this.is4())return null;let t=["2002",this.getBitsBase16(96,112),this.getBitsBase16(112,128),"","/16"].join(":");return new q(t)}toByteArray(){let t=this.bigInteger().toByteArray();return t.length===17&&t[0]===0?t.slice(1):t}toUnsignedByteArray(){return this.toByteArray().map(la)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(la))}static fromUnsignedByteArray(t){let e=new lt.BigInteger("256",10),n=new lt.BigInteger("0",10),o=new lt.BigInteger("1",10);for(let s=t.length-1;s>=0;s--)n=n.add(o.multiply(new lt.BigInteger(t[s].toString(10),10))),o=o.multiply(e);return q.fromBigInteger(n)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){return this.getBitsBase2(0,64)==="1111111010000000000000000000000000000000000000000000000000000000"}isMulticast(){return this.getType()==="Multicast"}is4(){return this.v4}isTeredo(){return this.isInSubnet(new q("2001::/32"))}is6to4(){return this.isInSubnet(new q("2002::/16"))}isLoopback(){return this.getType()==="Loopback"}href(t){return t===void 0?t="":t=(0,ft.sprintf)(":%s",t),(0,ft.sprintf)("http://[%s]%s/",this.correctForm(),t)}link(t){t||(t={}),t.className===void 0&&(t.className=""),t.prefix===void 0&&(t.prefix="/#address="),t.v4===void 0&&(t.v4=!1);let e=this.correctForm;return t.v4&&(e=this.to4in6),t.className?(0,ft.sprintf)('<a href="%1$s%2$s" class="%3$s">%2$s</a>',t.prefix,e.call(this),t.className):(0,ft.sprintf)('<a href="%1$s%2$s">%2$s</a>',t.prefix,e.call(this))}group(){if(this.elidedGroups===0)return gn(this.address).join(":");wn(typeof this.elidedGroups=="number"),wn(typeof this.elisionBegin=="number");let t=[],[e,n]=this.address.split("::");e.length?t.push(...gn(e)):t.push("");let o=["hover-group"];for(let s=this.elisionBegin;s<this.elisionBegin+this.elidedGroups;s++)o.push((0,ft.sprintf)("group-%d",s));return t.push((0,ft.sprintf)('<span class="%s"></span>',o.join(" "))),n.length?t.push(...gn(n,this.elisionEnd)):t.push(""),this.is4()&&(wn(this.address4 instanceof $),t.pop(),t.push(this.address4.groupForV6())),t.join(":")}regularExpressionString(t=!1){let e=[],n=new q(this.correctForm());if(n.elidedGroups===0)e.push(yn(n.parsedAddress));else if(n.elidedGroups===8)e.push(gs(8));else{let o=n.address.split("::");o[0].length&&e.push(yn(o[0].split(":"))),wn(typeof n.elidedGroups=="number"),e.push(gs(n.elidedGroups,o[0].length!==0,o[1].length!==0)),o[1].length&&e.push(yn(o[1].split(":"))),e=[e.join(":")]}return t||(e=["(?=^|",ms,"|[^\\w\\:])(",...e,")(?=[^\\w\\:]|",ms,"|$)"]),e.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};var Rd=Dt("libp2p:ip-port-to-multiaddr"),ys={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function fa(r,t){if(typeof r!="string")throw(0,bn.default)(new Error(`invalid ip provided: ${r}`),ys.ERR_INVALID_IP_PARAMETER);if(typeof t=="string"&&(t=parseInt(t)),isNaN(t))throw(0,bn.default)(new Error(`invalid port provided: ${t}`),ys.ERR_INVALID_PORT_PARAMETER);try{return new $(r),fn(`/ip4/${r}/tcp/${t}`)}catch{}try{let e=new q(r);return e.is4()?fn(`/ip4/${e.to4().correctForm()}/tcp/${t}`):fn(`/ip6/${r}/tcp/${t}`)}catch{let n=`invalid ip:port for creating a multiaddr: ${r}:${t}`;throw Rd.error(n),(0,bn.default)(new Error(n),ys.ERR_INVALID_IP)}}var pa=Z.isIPv4,Cd=Z.isIPv6,ws=function(r){let t=0;if(r=r.toString().trim(),pa(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Cd(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=pa(e[n]),c;s&&(c=ws(e[n]),e[n]=I(c.slice(0,2),"base16")),c!=null&&++n<8&&e.splice(n,0,I(c.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},ha=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Ir={},bs={},Dd=[[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"]];Dd.forEach(r=>{let t=Pd(...r);bs[t.code]=t,Ir[t.name]=t});function Pd(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function G(r){if(typeof r=="number"){if(bs[r]!=null)return bs[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ir[r]!=null)return Ir[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Wt=O(St(),1);function wa(r,t){switch(G(r).code){case 4:case 41:return Ld(t);case 42:return ga(t);case 6:case 273:case 33:case 132:return Ea(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ga(t);case 421:return Ud(t);case 444:return ya(t);case 445:return ya(t);case 466:return Md(t);default:return I(t,"base16")}}function ba(r,t){switch(G(r).code){case 4:return da(t);case 41:return da(t);case 42:return ma(t);case 6:case 273:case 33:case 132:return vs(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ma(t);case 421:return Nd(t);case 444:return Fd(t);case 445:return $d(t);case 466:return kd(t);default:return Bt(t,"base16")}}var Es=Object.values(gt).map(r=>r.decoder),Od=function(){let r=Es[0].or(Es[1]);return Es.slice(2).forEach(t=>r=r.or(t)),r}();function da(r){if(!ct(r))throw new Error("invalid ip address");return ws(r)}function Ld(r){let t=ha(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!ct(t))throw new Error("invalid ip address");return t}function vs(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Ea(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function ma(r){let t=Bt(r),e=Uint8Array.from(Wt.default.encode(t.length));return D([e,t],e.length+t.length)}function ga(r){let t=Wt.default.decode(r);if(r=r.slice(Wt.default.decode.bytes),r.length!==t)throw new Error("inconsistent lengths");return I(r)}function Nd(r){let t;r[0]==="Q"||r[0]==="1"?t=Tt(U.decode(`z${r}`)).bytes:t=B.parse(r).multihash.bytes;let e=Uint8Array.from(Wt.default.encode(t.length));return D([e,t],e.length+t.length)}function kd(r){let t=Od.decode(r),e=Uint8Array.from(Wt.default.encode(t.length));return D([e,t],e.length+t.length)}function Md(r){let t=Wt.default.decode(r),e=r.slice(Wt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return"u"+I(e,"base64url")}function Ud(r){let t=Wt.default.decode(r),e=r.slice(Wt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return I(e,"base58btc")}function Fd(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=X.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=vs(n);return D([e,o],e.length+o.length)}function $d(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=X.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=vs(n);return D([e,o],e.length+o.length)}function ya(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=I(t,"base32"),o=Ea(e);return`${n}:${o}`}var Je=O(St(),1);function zd(r){let t=[],e=r.split("/").slice(1);if(e.length===1&&e[0]==="")return[];for(let n=0;n<e.length;n++){let o=e[n],s=G(o);if(s.size===0){t.push([o]);continue}if(n++,n>=e.length)throw Ta("invalid address: "+r);if(s.path===!0){t.push([o,_s(e.slice(n).join("/"))]);break}t.push([o,e[n]])}return t}function Vd(r){let t=[];return r.map(e=>{let n=Tn(e);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),_s(t.join("/"))}function Gd(r){return r.map(t=>{Array.isArray(t)||(t=[t]);let e=Tn(t);return t.length>1?[e.code,ba(e.code,t[1])]:[e.code]})}function Ts(r){return r.map(t=>{let e=Tn(t);return t[1]!=null?[e.code,wa(e.code,t[1])]:[e.code]})}function Ss(r){return vn(D(r.map(t=>{let e=Tn(t),n=Uint8Array.from(Je.default.encode(e.code));return t.length>1&&t[1]!=null&&(n=D([n,t[1]])),n})))}function xs(r,t){return r.size>0?r.size/8:r.size===0?0:Je.default.decode(t)+(Je.default.decode.bytes??0)}function En(r){let t=[],e=0;for(;e<r.length;){let n=Je.default.decode(r,e),o=Je.default.decode.bytes??0,s=G(n),c=xs(s,r.slice(e+o));if(c===0){t.push([n]),e+=o;continue}let f=r.slice(e+o,e+o+c);if(e+=c+o,e>r.length)throw Ta("Invalid address Uint8Array: "+I(r,"base16"));t.push([n,f])}return t}function As(r){let t=En(r),e=Ts(t);return Vd(e)}function Hd(r){r=_s(r);let t=zd(r),e=Gd(t);return Ss(e)}function va(r){return Hd(r)}function vn(r){let t=jd(r);if(t!=null)throw t;return Uint8Array.from(r)}function jd(r){try{En(r)}catch(t){return t}}function _s(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Ta(r){return new Error("Error parsing address: "+r)}function Tn(r){return G(r[0])}var Rs=O(St(),1);var xa=O(xe(),1);var Qe=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Is=function(r,t,e,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 t=="function"?r!==t||!o:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(r,e):o?o.value=e:t.set(r,e),e},Rr,Cr,Br,Sa,Wd=Symbol.for("nodejs.util.inspect.custom"),Kd=[G("dns").code,G("dns4").code,G("dns6").code,G("dnsaddr").code],Yd=new Map,Aa=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Zd(r){return!!r?.[Aa]}var ie=class{constructor(t){if(Rr.set(this,void 0),Cr.set(this,void 0),Br.set(this,void 0),this[Sa]=!0,t==null&&(t=""),t instanceof Uint8Array)this.bytes=vn(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=va(t)}else if(Zd(t))this.bytes=vn(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return Qe(this,Rr,"f")==null&&Is(this,Rr,As(this.bytes),"f"),Qe(this,Rr,"f")}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",c=G("tcp"),f=G("udp"),l=G("ip4"),d=G("ip6"),p=G("dns6"),y=G("ip6zone");for(let[b,g]of this.stringTuples())b===y.code&&(s=`%${g??""}`),Kd.includes(b)&&(e=c.name,o=443,n=`${g??""}${s}`,t=b===p.code?6:4),(b===c.code||b===f.code)&&(e=G(b).name,o=parseInt(g??"")),(b===l.code||b===d.code)&&(e=G(b).name,n=`${g??""}${s}`,t=b===d.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.protoCodes().map(t=>Object.assign({},G(t)))}protoCodes(){let t=[],e=this.bytes,n=0;for(;n<e.length;){let o=Rs.default.decode(e,n),s=Rs.default.decode.bytes??0,c=G(o),f=xs(c,e.slice(n+s));n+=f+s,t.push(o)}return t}protoNames(){return this.protos().map(t=>t.name)}tuples(){return Qe(this,Cr,"f")==null&&Is(this,Cr,En(this.bytes),"f"),Qe(this,Cr,"f")}stringTuples(){return Qe(this,Br,"f")==null&&Is(this,Br,Ts(this.tuples()),"f"),Qe(this,Br,"f")}encapsulate(t){return t=new ie(t),new ie(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new ie(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new ie(Ss(e.slice(0,n)));return this}getPeerId(){try{let e=this.stringTuples().filter(n=>n[0]===Ir.ipfs.code).pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?I(U.decode(`z${n}`),"base58btc"):I(B.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let t=null;try{t=this.stringTuples().filter(e=>G(e[0]).path===!0)[0][1],t==null&&(t=null)}catch{t=null}return t}equals(t){return xt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=Yd.get(e.name);if(n==null)throw(0,xa.default)(new Error(`no available resolver for ${e.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(s=>new ie(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[(Rr=new WeakMap,Cr=new WeakMap,Br=new WeakMap,Sa=Aa,Wd)](){return`Multiaddr(${As(this.bytes)})`}};function _a(r){return new ie(r)}var Cs=O(Qt("os"),1),Ia=O(Qt("path"),1),Xd={ip4:"IPv4",ip6:"IPv6"};function tr(r){let t=r.getPath();return t!=null?Cs.default.platform()==="win32"?{path:Ia.default.join("\\\\.\\pipe\\",t)}:{path:t}:r.toOptions()}function Bs(r,t,e){let n=o=>_a(`/${r}/${o}/tcp/${e}`);return(Jd(t)?tm(Xd[r]):[t]).map(n)}function Jd(r){return["0.0.0.0","::"].includes(r)}var Qd=Cs.default.networkInterfaces();function tm(r){let t=[];for(let[,e]of Object.entries(Qd))if(e!=null)for(let n of e)n.family===r&&t.push(n.address);return t}var Ft=Dt("libp2p:tcp:socket"),Sn=(r,t)=>{let e=t.metrics,n=t.metricPrefix??"",o=t.socketInactivityTimeout??3e5,s=t.socketCloseTimeout??2e3;t.listeningAddr?.getPath()!=null&&(t.remoteAddr=t.listeningAddr),t.remoteAddr?.getPath()!=null&&(t.localAddr=t.remoteAddr);let c;if(t.remoteAddr!=null)c=t.remoteAddr;else{if(r.remoteAddress==null||r.remotePort==null)throw new v("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");c=fa(r.remoteAddress,r.remotePort)}let f=tr(c),l=f.path??`${f.host??""}:${f.port??""}`,{sink:d,source:p}=Ra.default.duplex(r);r.setTimeout(o,()=>{Ft("%s socket read timeout",l),e?.increment({[`${n}timeout`]:!0});let E;r.readable&&(E=new v("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),r.destroy(E)}),r.once("close",()=>{Ft("%s socket close",l),e?.increment({[`${n}close`]:!0}),y.timeline.close==null&&(y.timeline.close=Date.now())}),r.once("end",()=>{Ft("%s socket end",l),e?.increment({[`${n}end`]:!0})});let y={async sink(E){try{await d(E)}catch(b){b.type!=="aborted"&&Ft(b)}r.end()},source:p,remoteAddr:c,timeline:{open:Date.now()},async close(){if(r.destroyed){Ft("%s socket was already destroyed when trying to close",l);return}Ft("%s closing socket",l),await new Promise((E,b)=>{let g=Date.now(),x=setTimeout(()=>{r.destroyed?(Ft("%s is already destroyed",l),E()):(Ft("%s socket close timeout after %dms, destroying it manually",l,Date.now()-g),r.destroy(new v("Socket close timeout","ERR_SOCKET_CLOSE_TIMEOUT")))},s).unref();r.once("close",()=>{Ft("%s socket closed",l),clearTimeout(x),E()}),r.once("error",N=>{Ft("%s socket error",l,N),y.timeline.close==null&&(y.timeline.close=Date.now()),r.destroyed&&clearTimeout(x),b(N)}),r.setTimeout(s),r.end(),r.writableLength>0?r.once("drain",()=>{Ft("%s socket drained",l),r.destroy()}):r.destroy()})}};return y};var Ca=O(Qt("net"),1);var Be=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},ce,xn=class extends EventTarget{constructor(){super(...arguments),ce.set(this,new Map)}listenerCount(t){let e=Be(this,ce,"f").get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=Be(this,ce,"f").get(t);o==null&&(o=[],Be(this,ce,"f").set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=Be(this,ce,"f").get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),Be(this,ce,"f").set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=Be(this,ce,"f").get(t.type);return n==null||(n=n.filter(({once:o})=>!o),Be(this,ce,"f").set(t.type,n)),e}safeDispatchEvent(t,e){return this.dispatchEvent(new er(t,e))}};ce=new WeakMap;var Ds=class extends Event{constructor(t,e){super(t,e),this.detail=e?.detail}},er=globalThis.CustomEvent??Ds;var _t=Dt("libp2p:tcp:listener");async function Ps(r){try{await r.close()}catch(t){_t.error("an error occurred closing the connection",t)}}var nm=1,om=0,An=class extends xn{constructor(t){if(super(),this.context=t,this.connections=new Set,this.status={started:!1},t.keepAlive=t.keepAlive??!0,this.addr="unknown",this.server=Ca.default.createServer(t,this.onSocket.bind(this)),t.maxConnections!==void 0&&(this.server.maxConnections=t.maxConnections),t.closeServerOnMaxConnections!=null&&t.closeServerOnMaxConnections.closeAbove<t.closeServerOnMaxConnections.listenBelow)throw Error("closeAbove must be >= listenBelow");this.server.on("listening",()=>{if(t.metrics!=null){let e=this.server.address();e==null?this.addr="unknown":typeof e=="string"?this.addr=e:this.addr=`${e.address}:${e.port}`,t.metrics?.registerMetricGroup("libp2p_tcp_inbound_connections_total",{label:"address",help:"Current active connections in TCP listener",calculate:()=>({[this.addr]:this.connections.size})}),this.metrics={status:t.metrics.registerMetricGroup("libp2p_tcp_listener_status_info",{label:"address",help:"Current status of the TCP listener socket"}),errors:t.metrics.registerMetricGroup("libp2p_tcp_listener_errors_total",{label:"address",help:"Total count of TCP listener errors by type"}),events:t.metrics.registerMetricGroup("libp2p_tcp_listener_events_total",{label:"address",help:"Total count of TCP listener events by type"})},this.metrics?.status.update({[this.addr]:nm})}this.dispatchEvent(new er("listening"))}).on("error",e=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new er("error",{detail:e}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:om}),this.dispatchEvent(new er("close"))})}onSocket(t){t.on("error",n=>{_t("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let e;try{e=Sn(t,{listeningAddr:this.status.started?this.status.listeningAddr:void 0,socketInactivityTimeout:this.context.socketInactivityTimeout,socketCloseTimeout:this.context.socketCloseTimeout,metrics:this.metrics?.events,metricPrefix:`${this.addr} `})}catch(n){_t.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}_t("new inbound connection %s",e.remoteAddr);try{this.context.upgrader.upgradeInbound(e).then(n=>{_t("inbound connection upgraded %s",e.remoteAddr),this.connections.add(e),t.once("close",()=>{this.connections.delete(e),this.context.closeServerOnMaxConnections!=null&&this.connections.size<this.context.closeServerOnMaxConnections.listenBelow&&this.netListen().catch(o=>{_t.error("error attempting to listen server once connection count under limit",o),this.context.closeServerOnMaxConnections?.onListenError?.(o)})}),this.context.handler!=null&&this.context.handler(n),this.context.closeServerOnMaxConnections!=null&&this.connections.size>=this.context.closeServerOnMaxConnections.closeAbove&&this.netClose(),this.dispatchEvent(new er("connection",{detail:n}))}).catch(async n=>{_t.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await Ps(e)}).catch(n=>{_t.error("closing inbound connection failed",n)})}catch(n){_t.error("inbound connection failed",n),Ps(e).catch(o=>{_t.error("closing inbound connection failed",o),this.metrics?.errors.increment({[`${this.addr} inbound_closing_failed`]:!0})})}}getAddrs(){if(!this.status.started)return[];let t=[],e=this.server.address(),{listeningAddr:n,peerId:o}=this.status;if(e==null)return[];if(typeof e=="string")t=[n];else try{n.toString().startsWith("/ip4")?t=t.concat(Bs("ip4",e.address,e.port)):e.family==="IPv6"&&(t=t.concat(Bs("ip6",e.address,e.port)))}catch(s){_t.error("could not turn %s:%s into multiaddr",e.address,e.port,s)}return t.map(s=>o!=null?s.encapsulate(`/p2p/${o}`):s)}async listen(t){if(this.status.started)throw Error("server is already listening");let e=t.getPeerId(),n=e==null?t.decapsulateCode(421):t;this.status={started:!0,listeningAddr:n,peerId:e,netConfig:tr(n)},await this.netListen()}async close(){await Promise.all(Array.from(this.connections.values()).map(async t=>{await Ps(t)})),this.netClose()}async netListen(){if(!this.status.started||this.server.listening)return;let t=this.status.netConfig;await new Promise((e,n)=>{this.server.once("error",n),this.server.listen(t,e)}),_t("Listening on %s",this.server.address())}netClose(){!this.status.started||!this.server.listening||(_t("Closing server on %s",this.server.address()),this.server.close())}};var Da=Symbol.for("@libp2p/transport");var Ba;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Ba||(Ba={}));var ae=Dt("libp2p:tcp"),Ls=class{constructor(t,e={}){this.opts=e,this.components=t,t.metrics!=null&&(this.metrics={dialerEvents:t.metrics.registerCounterGroup("libp2p_tcp_dialer_events_total",{label:"event",help:"Total count of TCP dialer events by type"})})}get[Da](){return!0}get[Symbol.toStringTag](){return"@libp2p/tcp"}async dial(t,e){e.keepAlive=e.keepAlive??!0;let n=await this._connect(t,e);n.on("error",f=>{ae("socket error",f)});let o=Sn(n,{remoteAddr:t,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents}),s=()=>{o.close().catch(f=>{ae.error("Error closing maConn after abort",f)})};e.signal?.addEventListener("abort",s,{once:!0}),ae("new outbound connection %s",o.remoteAddr);let c=await e.upgrader.upgradeOutbound(o);if(ae("outbound connection %s upgraded",o.remoteAddr),e.signal?.removeEventListener("abort",s),e.signal?.aborted===!0)throw c.close().catch(f=>{ae.error("Error closing conn after abort",f)}),new te;return c}async _connect(t,e){if(e.signal?.aborted===!0)throw new te;return await new Promise((n,o)=>{let s=Date.now(),c=tr(t),f=c.path??`${c.host??""}:${c.port}`;ae("dialing %j",c);let l=Pa.default.connect(c),d=g=>{g.message=`connection error ${f}: ${g.message}`,this.metrics?.dialerEvents.increment({error:!0}),b(g)},p=()=>{ae("connection timeout %s",f),this.metrics?.dialerEvents.increment({timeout:!0});let g=new v(`connection timeout after ${Date.now()-s}ms`,"ERR_CONNECT_TIMEOUT");l.emit("error",g)},y=()=>{ae("connection opened %j",c),this.metrics?.dialerEvents.increment({connect:!0}),b()},E=()=>{ae("connection aborted %j",c),this.metrics?.dialerEvents.increment({abort:!0}),l.destroy(),b(new te)},b=g=>{if(l.removeListener("error",d),l.removeListener("timeout",p),l.removeListener("connect",y),e.signal!=null&&e.signal.removeEventListener("abort",E),g!=null){o(g);return}n(l)};l.on("error",d),l.on("timeout",p),l.on("connect",y),e.signal!=null&&e.signal.addEventListener("abort",E)})}createListener(t){return new An({...t,maxConnections:this.opts.maxConnections,closeServerOnMaxConnections:this.opts.closeServerOnMaxConnections,socketInactivityTimeout:this.opts.inboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.components.metrics})}filter(t){return t=Array.isArray(t)?t:[t],t.filter(e=>e.protoCodes().includes(290)?!1:e.protoCodes().includes(400)?!0:ge.matches(e.decapsulateCode(421)))}};function Oa(r={}){return(t={})=>new Ls(t,r)}var Ws=O(Fs(),1),Eu=O(pu(),1),vu=O(Pe(),1),Ks=O(qs(),1),Tu=O(bu(),1);function mm(){vu.default._configure(),Ws.default._configure(Eu.default),Ks.default._configure(Tu.default)}mm();var Su=["uint64","int64","sint64","fixed64","sfixed64"];function gm(r){for(let t of Su){if(r[t]==null)continue;let e=r[t];r[t]=function(){return BigInt(e.call(this).toString())}}return r}function Ys(r){return gm(new Ws.default(r))}function ym(r){for(let t of Su){if(r[t]==null)continue;let e=r[t];r[t]=function(n){return e.call(this,n.toString())}}return r}function Zs(){return ym(Ks.default.create())}function J(r,t){let e=Ys(r instanceof Uint8Array?r:r.subarray());return t.decode(e)}function Q(r,t){let e=Zs();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var nr;(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"})(nr||(nr={}));function Bn(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function ue(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,c){let f=t(s);c.int32(f)},n=function(s){let c=s.int32();return t(c)};return Bn("enum",nr.VARINT,e,n)}function tt(r,t){return Bn("message",nr.LENGTH_DELIMITED,r,t)}var W;(function(r){let t;(function(o){o.IDENTIFY="IDENTIFY",o.CONNECT="CONNECT",o.STREAM_OPEN="STREAM_OPEN",o.STREAM_HANDLER="STREAM_HANDLER",o.DHT="DHT",o.LIST_PEERS="LIST_PEERS",o.CONNMANAGER="CONNMANAGER",o.DISCONNECT="DISCONNECT",o.PUBSUB="PUBSUB",o.PEERSTORE="PEERSTORE"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.IDENTIFY=0]="IDENTIFY",o[o.CONNECT=1]="CONNECT",o[o.STREAM_OPEN=2]="STREAM_OPEN",o[o.STREAM_HANDLER=3]="STREAM_HANDLER",o[o.DHT=4]="DHT",o[o.LIST_PEERS=5]="LIST_PEERS",o[o.CONNMANAGER=6]="CONNMANAGER",o[o.DISCONNECT=7]="DISCONNECT",o[o.PUBSUB=8]="PUBSUB",o[o.PEERSTORE=9]="PEERSTORE"})(e||(e={})),function(o){o.codec=()=>ue(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=tt((o,s,c={})=>{c.lengthDelimited!==!1&&s.fork(),o.type!=null&&(s.uint32(8),r.Type.codec().encode(o.type,s)),o.connect!=null&&(s.uint32(18),Pn.codec().encode(o.connect,s)),o.streamOpen!=null&&(s.uint32(26),On.codec().encode(o.streamOpen,s)),o.streamHandler!=null&&(s.uint32(34),Ln.codec().encode(o.streamHandler,s)),o.dht!=null&&(s.uint32(42),Ot.codec().encode(o.dht,s)),o.connManager!=null&&(s.uint32(50),kn.codec().encode(o.connManager,s)),o.disconnect!=null&&(s.uint32(58),Mn.codec().encode(o.disconnect,s)),o.pubsub!=null&&(s.uint32(66),le.codec().encode(o.pubsub,s)),o.peerStore!=null&&(s.uint32(74),$n.codec().encode(o.peerStore,s)),c.lengthDelimited!==!1&&s.ldelim()},(o,s)=>{let c={},f=s==null?o.len:o.pos+s;for(;o.pos<f;){let l=o.uint32();switch(l>>>3){case 1:c.type=r.Type.codec().decode(o);break;case 2:c.connect=Pn.codec().decode(o,o.uint32());break;case 3:c.streamOpen=On.codec().decode(o,o.uint32());break;case 4:c.streamHandler=Ln.codec().decode(o,o.uint32());break;case 5:c.dht=Ot.codec().decode(o,o.uint32());break;case 6:c.connManager=kn.codec().decode(o,o.uint32());break;case 7:c.disconnect=Mn.codec().decode(o,o.uint32());break;case 8:c.pubsub=le.codec().decode(o,o.uint32());break;case 9:c.peerStore=$n.codec().decode(o,o.uint32());break;default:o.skipType(l&7);break}}return c})),n),r.encode=o=>Q(o,r.codec()),r.decode=o=>J(o,r.codec())})(W||(W={}));var P;(function(r){let t;(function(o){o.OK="OK",o.ERROR="ERROR"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.OK=0]="OK",o[o.ERROR=1]="ERROR"})(e||(e={})),function(o){o.codec=()=>ue(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=tt((o,s,c={})=>{if(c.lengthDelimited!==!1&&s.fork(),o.type!=null&&(s.uint32(8),r.Type.codec().encode(o.type,s)),o.error!=null&&(s.uint32(18),Nn.codec().encode(o.error,s)),o.streamInfo!=null&&(s.uint32(26),or.codec().encode(o.streamInfo,s)),o.identify!=null&&(s.uint32(34),Dn.codec().encode(o.identify,s)),o.dht!=null&&(s.uint32(42),Vt.codec().encode(o.dht,s)),o.peers!=null)for(let f of o.peers)s.uint32(50),be.codec().encode(f,s);o.pubsub!=null&&(s.uint32(58),Fn.codec().encode(o.pubsub,s)),o.peerStore!=null&&(s.uint32(66),zn.codec().encode(o.peerStore,s)),c.lengthDelimited!==!1&&s.ldelim()},(o,s)=>{let c={peers:[]},f=s==null?o.len:o.pos+s;for(;o.pos<f;){let l=o.uint32();switch(l>>>3){case 1:c.type=r.Type.codec().decode(o);break;case 2:c.error=Nn.codec().decode(o,o.uint32());break;case 3:c.streamInfo=or.codec().decode(o,o.uint32());break;case 4:c.identify=Dn.codec().decode(o,o.uint32());break;case 5:c.dht=Vt.codec().decode(o,o.uint32());break;case 6:c.peers.push(be.codec().decode(o,o.uint32()));break;case 7:c.pubsub=Fn.codec().decode(o,o.uint32());break;case 8:c.peerStore=zn.codec().decode(o,o.uint32());break;default:o.skipType(l&7);break}}return c})),n),r.encode=o=>Q(o,r.codec()),r.decode=o=>J(o,r.codec())})(P||(P={}));var Dn;(function(r){let t;r.codec=()=>(t==null&&(t=tt((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.id!=null&&e.id.byteLength>0&&(n.uint32(10),n.bytes(e.id)),e.addrs!=null)for(let s of e.addrs)n.uint32(18),n.bytes(s);o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={id:new Uint8Array(0),addrs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:o.id=e.bytes();break;case 2:o.addrs.push(e.bytes());break;default:e.skipType(c&7);break}}return o})),t),r.encode=e=>Q(e,r.codec()),r.decode=e=>J(e,r.codec())})(Dn||(Dn={}));var Pn;(function(r){let t;r.codec=()=>(t==null&&(t=tt((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.addrs!=null)for(let s of e.addrs)n.uint32(18),n.bytes(s);e.timeout!=null&&(n.uint32(24),n.int64(e.timeout)),o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={peer:new Uint8Array(0),addrs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:o.peer=e.bytes();break;case 2:o.addrs.push(e.bytes());break;case 3:o.timeout=e.int64();break;default:e.skipType(c&7);break}}return o})),t),r.encode=e=>Q(e,r.codec()),r.decode=e=>J(e,r.codec())})(Pn||(Pn={}));var On;(function(r){let t;r.codec=()=>(t==null&&(t=tt((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.proto!=null)for(let s of e.proto)n.uint32(18),n.string(s);e.timeout!=null&&(n.uint32(24),n.int64(e.timeout)),o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={peer:new Uint8Array(0),proto:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:o.peer=e.bytes();break;case 2:o.proto.push(e.string());break;case 3:o.timeout=e.int64();break;default:e.skipType(c&7);break}}return o})),t),r.encode=e=>Q(e,r.codec()),r.decode=e=>J(e,r.codec())})(On||(On={}));var Ln;(function(r){let t;r.codec=()=>(t==null&&(t=tt((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.addr!=null&&e.addr.byteLength>0&&(n.uint32(10),n.bytes(e.addr)),e.proto!=null)for(let s of e.proto)n.uint32(18),n.string(s);o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={addr:new Uint8Array(0),proto:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:o.addr=e.bytes();break;case 2:o.proto.push(e.string());break;default:e.skipType(c&7);break}}return o})),t),r.encode=e=>Q(e,r.codec()),r.decode=e=>J(e,r.codec())})(Ln||(Ln={}));var Nn;(function(r){let t;r.codec=()=>(t==null&&(t=tt((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.msg!=null&&e.msg!==""&&(n.uint32(10),n.string(e.msg)),o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={msg:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:o.msg=e.string();break;default:e.skipType(c&7);break}}return o})),t),r.encode=e=>Q(e,r.codec()),r.decode=e=>J(e,r.codec())})(Nn||(Nn={}));var or;(function(r){let t;r.codec=()=>(t==null&&(t=tt((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.addr!=null&&e.addr.byteLength>0&&(n.uint32(18),n.bytes(e.addr)),e.proto!=null&&e.proto!==""&&(n.uint32(26),n.string(e.proto)),o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={peer:new Uint8Array(0),addr:new Uint8Array(0),proto:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:o.peer=e.bytes();break;case 2:o.addr=e.bytes();break;case 3:o.proto=e.string();break;default:e.skipType(c&7);break}}return o})),t),r.encode=e=>Q(e,r.codec()),r.decode=e=>J(e,r.codec())})(or||(or={}));var Ot;(function(r){let t;(function(o){o.FIND_PEER="FIND_PEER",o.FIND_PEERS_CONNECTED_TO_PEER="FIND_PEERS_CONNECTED_TO_PEER",o.FIND_PROVIDERS="FIND_PROVIDERS",o.GET_CLOSEST_PEERS="GET_CLOSEST_PEERS",o.GET_PUBLIC_KEY="GET_PUBLIC_KEY",o.GET_VALUE="GET_VALUE",o.SEARCH_VALUE="SEARCH_VALUE",o.PUT_VALUE="PUT_VALUE",o.PROVIDE="PROVIDE"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.FIND_PEER=0]="FIND_PEER",o[o.FIND_PEERS_CONNECTED_TO_PEER=1]="FIND_PEERS_CONNECTED_TO_PEER",o[o.FIND_PROVIDERS=2]="FIND_PROVIDERS",o[o.GET_CLOSEST_PEERS=3]="GET_CLOSEST_PEERS",o[o.GET_PUBLIC_KEY=4]="GET_PUBLIC_KEY",o[o.GET_VALUE=5]="GET_VALUE",o[o.SEARCH_VALUE=6]="SEARCH_VALUE",o[o.PUT_VALUE=7]="PUT_VALUE",o[o.PROVIDE=8]="PROVIDE"})(e||(e={})),function(o){o.codec=()=>ue(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=tt((o,s,c={})=>{c.lengthDelimited!==!1&&s.fork(),o.type!=null&&(s.uint32(8),r.Type.codec().encode(o.type,s)),o.peer!=null&&(s.uint32(18),s.bytes(o.peer)),o.cid!=null&&(s.uint32(26),s.bytes(o.cid)),o.key!=null&&(s.uint32(34),s.bytes(o.key)),o.value!=null&&(s.uint32(42),s.bytes(o.value)),o.count!=null&&(s.uint32(48),s.int32(o.count)),o.timeout!=null&&(s.uint32(56),s.int64(o.timeout)),c.lengthDelimited!==!1&&s.ldelim()},(o,s)=>{let c={},f=s==null?o.len:o.pos+s;for(;o.pos<f;){let l=o.uint32();switch(l>>>3){case 1:c.type=r.Type.codec().decode(o);break;case 2:c.peer=o.bytes();break;case 3:c.cid=o.bytes();break;case 4:c.key=o.bytes();break;case 5:c.value=o.bytes();break;case 6:c.count=o.int32();break;case 7:c.timeout=o.int64();break;default:o.skipType(l&7);break}}return c})),n),r.encode=o=>Q(o,r.codec()),r.decode=o=>J(o,r.codec())})(Ot||(Ot={}));var Vt;(function(r){let t;(function(o){o.BEGIN="BEGIN",o.VALUE="VALUE",o.END="END"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.BEGIN=0]="BEGIN",o[o.VALUE=1]="VALUE",o[o.END=2]="END"})(e||(e={})),function(o){o.codec=()=>ue(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=tt((o,s,c={})=>{c.lengthDelimited!==!1&&s.fork(),o.type!=null&&(s.uint32(8),r.Type.codec().encode(o.type,s)),o.peer!=null&&(s.uint32(18),be.codec().encode(o.peer,s)),o.value!=null&&(s.uint32(26),s.bytes(o.value)),c.lengthDelimited!==!1&&s.ldelim()},(o,s)=>{let c={},f=s==null?o.len:o.pos+s;for(;o.pos<f;){let l=o.uint32();switch(l>>>3){case 1:c.type=r.Type.codec().decode(o);break;case 2:c.peer=be.codec().decode(o,o.uint32());break;case 3:c.value=o.bytes();break;default:o.skipType(l&7);break}}return c})),n),r.encode=o=>Q(o,r.codec()),r.decode=o=>J(o,r.codec())})(Vt||(Vt={}));var be;(function(r){let t;r.codec=()=>(t==null&&(t=tt((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.id!=null&&e.id.byteLength>0&&(n.uint32(10),n.bytes(e.id)),e.addrs!=null)for(let s of e.addrs)n.uint32(18),n.bytes(s);o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={id:new Uint8Array(0),addrs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:o.id=e.bytes();break;case 2:o.addrs.push(e.bytes());break;default:e.skipType(c&7);break}}return o})),t),r.encode=e=>Q(e,r.codec()),r.decode=e=>J(e,r.codec())})(be||(be={}));var kn;(function(r){let t;(function(o){o.TAG_PEER="TAG_PEER",o.UNTAG_PEER="UNTAG_PEER",o.TRIM="TRIM"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.TAG_PEER=0]="TAG_PEER",o[o.UNTAG_PEER=1]="UNTAG_PEER",o[o.TRIM=2]="TRIM"})(e||(e={})),function(o){o.codec=()=>ue(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=tt((o,s,c={})=>{c.lengthDelimited!==!1&&s.fork(),o.type!=null&&(s.uint32(8),r.Type.codec().encode(o.type,s)),o.peer!=null&&(s.uint32(18),s.bytes(o.peer)),o.tag!=null&&(s.uint32(26),s.string(o.tag)),o.weight!=null&&(s.uint32(32),s.int64(o.weight)),c.lengthDelimited!==!1&&s.ldelim()},(o,s)=>{let c={},f=s==null?o.len:o.pos+s;for(;o.pos<f;){let l=o.uint32();switch(l>>>3){case 1:c.type=r.Type.codec().decode(o);break;case 2:c.peer=o.bytes();break;case 3:c.tag=o.string();break;case 4:c.weight=o.int64();break;default:o.skipType(l&7);break}}return c})),n),r.encode=o=>Q(o,r.codec()),r.decode=o=>J(o,r.codec())})(kn||(kn={}));var Mn;(function(r){let t;r.codec=()=>(t==null&&(t=tt((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={peer:new Uint8Array(0)},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:o.peer=e.bytes();break;default:e.skipType(c&7);break}}return o})),t),r.encode=e=>Q(e,r.codec()),r.decode=e=>J(e,r.codec())})(Mn||(Mn={}));var le;(function(r){let t;(function(o){o.GET_TOPICS="GET_TOPICS",o.LIST_PEERS="LIST_PEERS",o.PUBLISH="PUBLISH",o.SUBSCRIBE="SUBSCRIBE"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.GET_TOPICS=0]="GET_TOPICS",o[o.LIST_PEERS=1]="LIST_PEERS",o[o.PUBLISH=2]="PUBLISH",o[o.SUBSCRIBE=3]="SUBSCRIBE"})(e||(e={})),function(o){o.codec=()=>ue(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=tt((o,s,c={})=>{c.lengthDelimited!==!1&&s.fork(),o.type!=null&&(s.uint32(8),r.Type.codec().encode(o.type,s)),o.topic!=null&&(s.uint32(18),s.string(o.topic)),o.data!=null&&(s.uint32(26),s.bytes(o.data)),c.lengthDelimited!==!1&&s.ldelim()},(o,s)=>{let c={},f=s==null?o.len:o.pos+s;for(;o.pos<f;){let l=o.uint32();switch(l>>>3){case 1:c.type=r.Type.codec().decode(o);break;case 2:c.topic=o.string();break;case 3:c.data=o.bytes();break;default:o.skipType(l&7);break}}return c})),n),r.encode=o=>Q(o,r.codec()),r.decode=o=>J(o,r.codec())})(le||(le={}));var Un;(function(r){let t;r.codec=()=>(t==null&&(t=tt((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.from!=null&&(n.uint32(10),n.bytes(e.from)),e.data!=null&&(n.uint32(18),n.bytes(e.data)),e.seqno!=null&&(n.uint32(26),n.bytes(e.seqno)),e.topicIDs!=null)for(let s of e.topicIDs)n.uint32(34),n.string(s);e.signature!=null&&(n.uint32(42),n.bytes(e.signature)),e.key!=null&&(n.uint32(50),n.bytes(e.key)),o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={topicIDs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:o.from=e.bytes();break;case 2:o.data=e.bytes();break;case 3:o.seqno=e.bytes();break;case 4:o.topicIDs.push(e.string());break;case 5:o.signature=e.bytes();break;case 6:o.key=e.bytes();break;default:e.skipType(c&7);break}}return o})),t),r.encode=e=>Q(e,r.codec()),r.decode=e=>J(e,r.codec())})(Un||(Un={}));var Fn;(function(r){let t;r.codec=()=>(t==null&&(t=tt((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.topics!=null)for(let s of e.topics)n.uint32(10),n.string(s);if(e.peerIDs!=null)for(let s of e.peerIDs)n.uint32(18),n.bytes(s);o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={topics:[],peerIDs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:o.topics.push(e.string());break;case 2:o.peerIDs.push(e.bytes());break;default:e.skipType(c&7);break}}return o})),t),r.encode=e=>Q(e,r.codec()),r.decode=e=>J(e,r.codec())})(Fn||(Fn={}));var $n;(function(r){let t;(function(o){o.UNSPECIFIED="UNSPECIFIED",o.GET_PROTOCOLS="GET_PROTOCOLS",o.GET_PEER_INFO="GET_PEER_INFO"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.UNSPECIFIED=0]="UNSPECIFIED",o[o.GET_PROTOCOLS=1]="GET_PROTOCOLS",o[o.GET_PEER_INFO=2]="GET_PEER_INFO"})(e||(e={})),function(o){o.codec=()=>ue(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=tt((o,s,c={})=>{if(c.lengthDelimited!==!1&&s.fork(),o.type!=null&&(s.uint32(8),r.Type.codec().encode(o.type,s)),o.id!=null&&(s.uint32(18),s.bytes(o.id)),o.protos!=null)for(let f of o.protos)s.uint32(26),s.string(f);c.lengthDelimited!==!1&&s.ldelim()},(o,s)=>{let c={protos:[]},f=s==null?o.len:o.pos+s;for(;o.pos<f;){let l=o.uint32();switch(l>>>3){case 1:c.type=r.Type.codec().decode(o);break;case 2:c.id=o.bytes();break;case 3:c.protos.push(o.string());break;default:o.skipType(l&7);break}}return c})),n),r.encode=o=>Q(o,r.codec()),r.decode=o=>J(o,r.codec())})($n||($n={}));var zn;(function(r){let t;r.codec=()=>(t==null&&(t=tt((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.peer!=null&&(n.uint32(10),be.codec().encode(e.peer,n)),e.protos!=null)for(let s of e.protos)n.uint32(18),n.string(s);o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={protos:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:o.peer=be.codec().decode(e,e.uint32());break;case 2:o.protos.push(e.string());break;default:e.skipType(c&7);break}}return o})),t),r.encode=e=>Q(e,r.codec()),r.decode=e=>J(e,r.codec())})(zn||(zn={}));var Au=Symbol.for("@achingbrain/uint8arraylist");function xu(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function Vn(r){return!!r?.[Au]}var yt=class{constructor(...t){Object.defineProperty(this,Au,{value:!0}),this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(Vn(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(Vn(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=xu(this.bufs,t);return e.buf[e.index]}set(t,e){let n=xu(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(Vn(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return D(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:D(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new yt;return s.length=o,s.bufs=n,s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let c=this.bufs[s],f=o,l=f+c.byteLength;if(o=l,t>=l)continue;let d=t>=f&&t<l,p=e>f&&e<=l;if(d&&p){if(t===f&&e===l){n.push(c);break}let y=t-f;n.push(c.subarray(y,y+(e-t)));break}if(d){if(t===0){n.push(c);continue}n.push(c.subarray(t-f));continue}if(p){if(e===l){n.push(c);break}n.push(c.subarray(0,e-f));break}n.push(c)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Vn(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,c=new Int32Array(s);for(let y=0;y<s;y++)c[y]=-1;for(let y=0;y<o;y++)c[n[y]]=y;let f=c,l=this.byteLength-n.byteLength,d=n.byteLength-1,p;for(let y=e;y<=l;y+=p){p=0;for(let E=d;E>=0;E--){let b=this.get(y+E);if(n[E]!==b){p=Math.max(1,E-f[b]);break}}if(p===0)return y}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=re(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=ee(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=ee(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=ee(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=re(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=ee(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=ee(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=ee(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=ee(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=ee(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof yt)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!xt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new yt;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};function Gn(r){return r instanceof Uint8Array?{get(t){return r[t]},set(t,e){r[t]=e}}:{get(t){return r.get(t)},set(t,e){r.set(t,e)}}}var _u=4294967296,It=class{constructor(t=0,e=0){this.hi=t,this.lo=e}toBigInt(t){if(t===!0)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toNumber(t){return Number(this.toBigInt(t))}zzDecode(){let t=-(this.lo&1),e=((this.lo>>>1|this.hi<<31)^t)>>>0,n=(this.hi>>>1^t)>>>0;return new It(n,e)}zzEncode(){let t=this.hi>>31,e=((this.hi<<1|this.lo>>>31)^t)>>>0,n=(this.lo<<1^t)>>>0;return new It(e,n)}toBytes(t,e=0){let n=Gn(t);for(;this.hi>0;)n.set(e++,this.lo&127|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)n.set(e++,this.lo&127|128),this.lo=this.lo>>>7;n.set(e++,this.lo)}static fromBigInt(t){if(t===0n)return new It;let e=t<0;e&&(t=-t);let n=Number(t>>32n)|0,o=Number(t-(BigInt(n)<<32n))|0;return e&&(n=~n>>>0,o=~o>>>0,++o>_u&&(o=0,++n>_u&&(n=0))),new It(n,o)}static fromNumber(t){if(t===0)return new It;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new It(o,n)}static fromBytes(t,e=0){let n=Gn(t),o=new It,s=0;if(t.length-e>4){for(;s<4;++s)if(o.lo=(o.lo|(n.get(e)&127)<<s*7)>>>0,n.get(e++)<128)return o;if(o.lo=(o.lo|(n.get(e)&127)<<28)>>>0,o.hi=(o.hi|(n.get(e)&127)>>4)>>>0,n.get(e++)<128)return o;s=0}else for(;s<4;++s){if(e>=t.length)throw RangeError(`index out of range: ${e} > ${t.length}`);if(o.lo=(o.lo|(n.get(e)&127)<<s*7)>>>0,n.get(e++)<128)return o}if(t.length-e>4){for(;s<5;++s)if(o.hi=(o.hi|(n.get(e)&127)<<s*7+3)>>>0,n.get(e++)<128)return o}else if(e<t.byteLength)for(;s<5;++s){if(e>=t.length)throw RangeError(`index out of range: ${e} > ${t.length}`);if(o.hi=(o.hi|(n.get(e)&127)<<s*7+3)>>>0,n.get(e++)<128)return o}throw RangeError("invalid varint encoding")}};var wm=Math.pow(2,7),bm=Math.pow(2,14),Em=Math.pow(2,21),vm=Math.pow(2,28),Tm=Math.pow(2,35),Sm=Math.pow(2,42),xm=Math.pow(2,49),Am=Math.pow(2,56),_m=Math.pow(2,63),Le={encodingLength(r){return r<wm?1:r<bm?2:r<Em?3:r<vm?4:r<Tm?5:r<Sm?6:r<xm?7:r<Am?8:r<_m?9:10},encode(r,t,e=0){if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return t==null&&(t=re(Le.encodingLength(r))),It.fromNumber(r).toBytes(t,e),t},decode(r,t=0){return It.fromBytes(r,t).toNumber(!0)}};function Iu(r){return globalThis?.Buffer?.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}var Hn=r=>{let t=Le.encodingLength(r),e=Iu(t);return Le.encode(r,e),Hn.bytes=t,e};Hn.bytes=0;function jn(r){r=r??{};let t=r.lengthEncoder??Hn;return async function*(n){for await(let o of n){let s=t(o.byteLength);s instanceof Uint8Array?yield s:yield*s,o instanceof Uint8Array?yield o:yield*o}}}jn.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??Hn;return new yt(e(r.byteLength),r)};var Or=O(xe(),1),Im=8,Rm=1024*1024*4,Ne;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Ne||(Ne={}));var Xs=r=>{let t=Le.decode(r);return Xs.bytes=Le.encodingLength(t),t};Xs.bytes=0;function Lr(r){return async function*(e){let n=new yt,o=Ne.LENGTH,s=-1,c=r?.lengthDecoder??Xs,f=r?.maxLengthLength??Im,l=r?.maxDataLength??Rm;for await(let d of e)for(n.append(d);n.byteLength>0;){if(o===Ne.LENGTH)try{if(s=c(n),s<0)throw(0,Or.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(s>l)throw(0,Or.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let p=c.bytes;n.consume(p),r?.onLength!=null&&r.onLength(s),o=Ne.DATA}catch(p){if(p instanceof RangeError){if(n.byteLength>f)throw(0,Or.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw p}if(o===Ne.DATA){if(n.byteLength<s)break;let p=n.sublist(0,s);n.consume(s),r?.onData!=null&&r.onData(p),yield p,o=Ne.LENGTH}}if(n.byteLength>0)throw(0,Or.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}}Lr.fromReader=(r,t)=>{let e=1,n=async function*(){for(;;)try{let{done:s,value:c}=await r.next(e);if(s===!0)return;c!=null&&(yield c)}catch(s){if(s.code==="ERR_UNDER_READ")return{done:!0,value:null};throw s}finally{e=1}}();return Lr({...t??{},onLength:s=>{e=s}})(n)};function Ru(r){let t=async function*(){let e=yield,n=new yt;for await(let o of r){if(e==null){n.append(o),e=yield n,n=new yt;continue}for(n.append(o);n.length>=e;){let s=n.sublist(0,e);if(n.consume(e),e=yield s,e==null){n.length>0&&(e=yield n,n=new yt);break}}}if(e!=null)throw Object.assign(new Error(`stream ended before ${e} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return t.next(),t}var qn=class{constructor(t){if(!(t>0)||t-1&t)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},sr=class{constructor(t={}){this.hwm=t.splitLimit??16,this.head=new qn(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new qn(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};function Cu(r={}){return Bm(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function Bm(r,t){t=t??{};let e=t.onEnd,n=new sr,o,s,c,f=async()=>n.isEmpty()?c?{done:!0}:await new Promise((x,N)=>{s=C=>{s=null,n.push(C);try{x(r(n))}catch(L){N(L)}return o}}):r(n),l=x=>s!=null?s(x):(n.push(x),o),d=x=>(n=new sr,s!=null?s({error:x}):(n.push({error:x}),o)),p=x=>{if(c)return o;if(t?.objectMode!==!0&&x?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:x})},y=x=>c?o:(c=!0,x!=null?d(x):l({done:!0})),E=()=>(n=new sr,y(),{done:!0}),b=x=>(y(x),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:f,return:E,throw:b,push:p,end:y,get readableLength(){return n.size}},e==null)return o;let g=o;return o={[Symbol.asyncIterator](){return this},next(){return g.next()},throw(x){return g.throw(x),e!=null&&(e(x),e=void 0),{done:!0}},return(){return g.return(),e!=null&&(e(),e=void 0),{done:!0}},push:p,end(x){return g.end(x),e!=null&&(e(x),e=void 0),o},get readableLength(){return g.readableLength}},o}function Js(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}function Bu(r){let t=Cu(),e=Ru(r.source),n=Js(),o,s=r.sink(async function*(){yield*t,yield*await n.promise}());return s.catch(f=>{o=f}),{reader:e,writer:t,stream:{sink:async f=>o!=null?await Promise.reject(o):(n.resolve(f),await s),source:e},rest:()=>t.end(),write:t.push,read:async()=>{let f=await e.next();if(f.value!=null)return f.value}}}var Qs=Dt("libp2p:daemon-protocol:stream-handler"),Nr=class{constructor(t){let{stream:e,maxLength:n}=t;this.stream=e,this.shake=Bu(this.stream),this.decoder=Lr.fromReader(this.shake.reader,{maxDataLength:n??4096})}async read(){let t=await this.decoder.next();if(t.value!=null)return t.value.subarray();Qs("read received no value, closing stream"),await this.close()}write(t){Qs("write message"),this.shake.write(jn.single(t).subarray())}rest(){return this.shake.rest(),this.shake.stream}async close(){Qs("closing the stream"),await this.rest().sink([])}};var Du=Z.isIPv4,Dm=Z.isIPv6,ti=function(r){let t=0;if(r=r.toString().trim(),Du(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Dm(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=Du(e[n]),c;s&&(c=ti(e[n]),e[n]=I(c.slice(0,2),"base16")),c!=null&&++n<8&&e.splice(n,0,I(c.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},Pu=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var kr={},ei={},Om=[[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"]];Om.forEach(r=>{let t=Lm(...r);ei[t.code]=t,kr[t.name]=t});function Lm(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function H(r){if(typeof r=="number"){if(ei[r]!=null)return ei[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(kr[r]!=null)return kr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Zt=O(St(),1);function Mu(r,t){switch(H(r).code){case 4:case 41:return km(t);case 42:return Nu(t);case 6:case 273:case 33:case 132:return Fu(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Nu(t);case 421:return $m(t);case 444:return ku(t);case 445:return ku(t);case 466:return Fm(t);default:return I(t,"base16")}}function Uu(r,t){switch(H(r).code){case 4:return Ou(t);case 41:return Ou(t);case 42:return Lu(t);case 6:case 273:case 33:case 132:return ni(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Lu(t);case 421:return Mm(t);case 444:return zm(t);case 445:return Vm(t);case 466:return Um(t);default:return Bt(t,"base16")}}var ri=Object.values(gt).map(r=>r.decoder),Nm=function(){let r=ri[0].or(ri[1]);return ri.slice(2).forEach(t=>r=r.or(t)),r}();function Ou(r){if(!ct(r))throw new Error("invalid ip address");return ti(r)}function km(r){let t=Pu(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!ct(t))throw new Error("invalid ip address");return t}function ni(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Fu(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Lu(r){let t=Bt(r),e=Uint8Array.from(Zt.default.encode(t.length));return D([e,t],e.length+t.length)}function Nu(r){let t=Zt.default.decode(r);if(r=r.slice(Zt.default.decode.bytes),r.length!==t)throw new Error("inconsistent lengths");return I(r)}function Mm(r){let t;r[0]==="Q"||r[0]==="1"?t=Tt(U.decode(`z${r}`)).bytes:t=B.parse(r).multihash.bytes;let e=Uint8Array.from(Zt.default.encode(t.length));return D([e,t],e.length+t.length)}function Um(r){let t=Nm.decode(r),e=Uint8Array.from(Zt.default.encode(t.length));return D([e,t],e.length+t.length)}function Fm(r){let t=Zt.default.decode(r),e=r.slice(Zt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return"u"+I(e,"base64url")}function $m(r){let t=Zt.default.decode(r),e=r.slice(Zt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return I(e,"base58btc")}function zm(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=X.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ni(n);return D([e,o],e.length+o.length)}function Vm(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=X.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ni(n);return D([e,o],e.length+o.length)}function ku(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=I(t,"base32"),o=Fu(e);return`${n}:${o}`}var ir=O(St(),1);function Gm(r){let t=[],e=r.split("/").slice(1);if(e.length===1&&e[0]==="")return[];for(let n=0;n<e.length;n++){let o=e[n],s=H(o);if(s.size===0){t.push([o]);continue}if(n++,n>=e.length)throw zu("invalid address: "+r);if(s.path===!0){t.push([o,ai(e.slice(n).join("/"))]);break}t.push([o,e[n]])}return t}function Hm(r){let t=[];return r.map(e=>{let n=Yn(e);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),ai(t.join("/"))}function jm(r){return r.map(t=>{Array.isArray(t)||(t=[t]);let e=Yn(t);return t.length>1?[e.code,Uu(e.code,t[1])]:[e.code]})}function oi(r){return r.map(t=>{let e=Yn(t);return t[1]!=null?[e.code,Mu(e.code,t[1])]:[e.code]})}function si(r){return Kn(D(r.map(t=>{let e=Yn(t),n=Uint8Array.from(ir.default.encode(e.code));return t.length>1&&t[1]!=null&&(n=D([n,t[1]])),n})))}function ii(r,t){return r.size>0?r.size/8:r.size===0?0:ir.default.decode(t)+(ir.default.decode.bytes??0)}function Wn(r){let t=[],e=0;for(;e<r.length;){let n=ir.default.decode(r,e),o=ir.default.decode.bytes??0,s=H(n),c=ii(s,r.slice(e+o));if(c===0){t.push([n]),e+=o;continue}let f=r.slice(e+o,e+o+c);if(e+=c+o,e>r.length)throw zu("Invalid address Uint8Array: "+I(r,"base16"));t.push([n,f])}return t}function ci(r){let t=Wn(r),e=oi(t);return Hm(e)}function qm(r){r=ai(r);let t=Gm(r),e=jm(t);return si(e)}function $u(r){return qm(r)}function Kn(r){let t=Wm(r);if(t!=null)throw t;return Uint8Array.from(r)}function Wm(r){try{Wn(r)}catch(t){return t}}function ai(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function zu(r){return new Error("Error parsing address: "+r)}function Yn(r){return H(r[0])}var li=O(St(),1);var Gu=O(xe(),1);var cr=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},ui=function(r,t,e,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 t=="function"?r!==t||!o:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(r,e):o?o.value=e:t.set(r,e),e},Mr,Ur,Fr,Vu,Ym=Symbol.for("nodejs.util.inspect.custom"),Zm=[H("dns").code,H("dns4").code,H("dns6").code,H("dnsaddr").code],Xm=new Map,Hu=Symbol.for("@multiformats/js-multiaddr/multiaddr");function fi(r){return!!r?.[Hu]}var fe=class{constructor(t){if(Mr.set(this,void 0),Ur.set(this,void 0),Fr.set(this,void 0),this[Vu]=!0,t==null&&(t=""),t instanceof Uint8Array)this.bytes=Kn(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=$u(t)}else if(fi(t))this.bytes=Kn(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return cr(this,Mr,"f")==null&&ui(this,Mr,ci(this.bytes),"f"),cr(this,Mr,"f")}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",c=H("tcp"),f=H("udp"),l=H("ip4"),d=H("ip6"),p=H("dns6"),y=H("ip6zone");for(let[b,g]of this.stringTuples())b===y.code&&(s=`%${g??""}`),Zm.includes(b)&&(e=c.name,o=443,n=`${g??""}${s}`,t=b===p.code?6:4),(b===c.code||b===f.code)&&(e=H(b).name,o=parseInt(g??"")),(b===l.code||b===d.code)&&(e=H(b).name,n=`${g??""}${s}`,t=b===d.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.protoCodes().map(t=>Object.assign({},H(t)))}protoCodes(){let t=[],e=this.bytes,n=0;for(;n<e.length;){let o=li.default.decode(e,n),s=li.default.decode.bytes??0,c=H(o),f=ii(c,e.slice(n+s));n+=f+s,t.push(o)}return t}protoNames(){return this.protos().map(t=>t.name)}tuples(){return cr(this,Ur,"f")==null&&ui(this,Ur,Wn(this.bytes),"f"),cr(this,Ur,"f")}stringTuples(){return cr(this,Fr,"f")==null&&ui(this,Fr,oi(this.tuples()),"f"),cr(this,Fr,"f")}encapsulate(t){return t=new fe(t),new fe(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new fe(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new fe(si(e.slice(0,n)));return this}getPeerId(){try{let e=this.stringTuples().filter(n=>n[0]===kr.ipfs.code).pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?I(U.decode(`z${n}`),"base58btc"):I(B.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let t=null;try{t=this.stringTuples().filter(e=>H(e[0]).path===!0)[0][1],t==null&&(t=null)}catch{t=null}return t}equals(t){return xt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=Xm.get(e.name);if(n==null)throw(0,Gu.default)(new Error(`no available resolver for ${e.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(s=>new fe(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[(Mr=new WeakMap,Ur=new WeakMap,Fr=new WeakMap,Vu=Hu,Ym)](){return`Multiaddr(${ci(this.bytes)})`}};function ar(r){return new fe(r)}var pi=Symbol.for("@libp2p/peer-id");function ur(r){return r!=null&&!!r[pi]}var Jm=Symbol.for("nodejs.util.inspect.custom"),ju=Object.values(gt).map(r=>r.decoder).reduce((r,t)=>r.or(t),gt.identity.decoder),qu=114,Wu=36,Ku=37,$r=class{constructor(t){this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}get[pi](){return!0}toString(){return this.string==null&&(this.string=U.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return B.createV1(qu,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t instanceof Uint8Array)return xt(this.multihash.bytes,t);if(typeof t=="string")return Qm(t).equals(this);if(t?.multihash?.bytes!=null)return xt(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Jm](){return`PeerId(${this.toString()})`}},zr=class extends $r{constructor(t){super({...t,type:"RSA"}),this.type="RSA",this.publicKey=t.publicKey}},Vr=class extends $r{constructor(t){super({...t,type:"Ed25519"}),this.type="Ed25519",this.publicKey=t.multihash.digest}},Gr=class extends $r{constructor(t){super({...t,type:"secp256k1"}),this.type="secp256k1",this.publicKey=t.multihash.digest}};function Qm(r,t){if(t=t??ju,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=Tt(U.decode(`z${r}`));return r.startsWith("12D")?new Vr({multihash:e}):r.startsWith("16U")?new Gr({multihash:e}):new zr({multihash:e})}return Xt(ju.decode(r))}function Xt(r){try{let t=Tt(r);if(t.code===Zr.code){if(t.digest.length===Wu)return new Vr({multihash:t});if(t.digest.length===Ku)return new Gr({multihash:t})}if(t.code===Yr.code)return new zr({multihash:t})}catch{return t0(B.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function t0(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==qu)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===Yr.code)return new zr({multihash:r.multihash});if(t.code===Zr.code){if(t.digest.length===Wu)return new Vr({multihash:r.multihash});if(t.digest.length===Ku)return new Gr({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var Zn=class{constructor(t){this.client=t}async put(t,e){if(!(t instanceof Uint8Array))throw new v("invalid key received","ERR_INVALID_KEY");if(!(e instanceof Uint8Array))throw new v("value received is not a Uint8Array","ERR_INVALID_VALUE");let n=await this.client.send({type:W.Type.DHT,dht:{type:Ot.Type.PUT_VALUE,key:t,value:e}}),o=await n.read();if(o==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let s=P.decode(o);if(await n.close(),s.type!==P.Type.OK)throw new v(s.error?.msg??"DHT put failed","ERR_DHT_PUT_FAILED")}async get(t){if(!(t instanceof Uint8Array))throw new v("invalid key received","ERR_INVALID_KEY");let e=await this.client.send({type:W.Type.DHT,dht:{type:Ot.Type.GET_VALUE,key:t}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let o=P.decode(n);if(await e.close(),o.type!==P.Type.OK)throw new v(o.error?.msg??"DHT get failed","ERR_DHT_GET_FAILED");if(o.dht==null||o.dht.value==null)throw new v("Invalid DHT get response","ERR_DHT_GET_FAILED");return o.dht.value}async findPeer(t){if(!ur(t))throw new v("invalid peer id received","ERR_INVALID_PEER_ID");let e=await this.client.send({type:W.Type.DHT,dht:{type:Ot.Type.FIND_PEER,peer:t.toBytes()}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let o=P.decode(n);if(await e.close(),o.type!==P.Type.OK)throw new v(o.error?.msg??"DHT find peer failed","ERR_DHT_FIND_PEER_FAILED");if(o.dht==null||o.dht.peer==null||o.dht.peer.addrs==null)throw new v("Invalid response","ERR_DHT_FIND_PEER_FAILED");return{id:Xt(o.dht.peer.id),multiaddrs:o.dht.peer.addrs.map(s=>ar(s)),protocols:[]}}async provide(t){if(t==null||B.asCID(t)==null)throw new v("invalid cid received","ERR_INVALID_CID");let e=await this.client.send({type:W.Type.DHT,dht:{type:Ot.Type.PROVIDE,cid:t.bytes}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let o=P.decode(n);if(await e.close(),o.type!==P.Type.OK)throw new v(o.error?.msg??"DHT provide failed","ERR_DHT_PROVIDE_FAILED")}async*findProviders(t,e=1){if(t==null||B.asCID(t)==null)throw new v("invalid cid received","ERR_INVALID_CID");let n=await this.client.send({type:W.Type.DHT,dht:{type:Ot.Type.FIND_PROVIDERS,cid:t.bytes,count:e}}),o=await n.read();if(o==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let s=P.decode(o);if(s.type!==P.Type.OK)throw await n.close(),new v(s.error?.msg??"DHT find providers failed","ERR_DHT_FIND_PROVIDERS_FAILED");for(;;){if(o=await n.read(),o==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let c=Vt.decode(o);if(c.type===Vt.Type.END){await n.close();return}if(c.type===Vt.Type.VALUE&&c.peer!=null&&c.peer?.addrs!=null)yield{id:Xt(c.peer.id),multiaddrs:c.peer.addrs.map(f=>ar(f)),protocols:[]};else throw await n.close(),new v("unexpected message received","ERR_UNEXPECTED_MESSAGE_RECEIVED")}}async*getClosestPeers(t){if(!(t instanceof Uint8Array))throw new v("invalid key received","ERR_INVALID_KEY");let e=await this.client.send({type:W.Type.DHT,dht:{type:Ot.Type.GET_CLOSEST_PEERS,key:t}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let o=P.decode(n);if(o.type!==P.Type.OK)throw await e.close(),new v(o.error?.msg??"DHT find providers failed","ERR_DHT_FIND_PROVIDERS_FAILED");for(;;){if(n=await e.read(),n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let s=Vt.decode(n);if(s.type===Vt.Type.END){await e.close();return}if(s.type===Vt.Type.VALUE&&s.value!=null)yield{id:Xt(s.value),multiaddrs:[],protocols:[]};else throw await e.close(),new v("unexpected message received","ERR_UNEXPECTED_MESSAGE_RECEIVED")}}async getPublicKey(t){if(!ur(t))throw new v("invalid peer id received","ERR_INVALID_PEER_ID");let e=await this.client.send({type:W.Type.DHT,dht:{type:Ot.Type.GET_PUBLIC_KEY,peer:t.toBytes()}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let o=P.decode(n);if(await e.close(),o.type!==P.Type.OK)throw new v(o.error?.msg??"DHT get public key failed","ERR_DHT_GET_PUBLIC_KEY_FAILED");if(o.dht==null)throw new v("Invalid response","ERR_DHT_GET_PUBLIC_KEY_FAILED");return o.dht.value}};var Xn=class{constructor(t){this.client=t}async getTopics(){let t=await this.client.send({type:W.Type.PUBSUB,pubsub:{type:le.Type.GET_TOPICS}}),e=await t.read();if(e==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let n=P.decode(e);if(await t.close(),n.type!==P.Type.OK)throw new v(n.error?.msg??"Pubsub get topics failed","ERR_PUBSUB_GET_TOPICS_FAILED");if(n.pubsub==null||n.pubsub.topics==null)throw new v("Invalid response","ERR_PUBSUB_GET_TOPICS_FAILED");return n.pubsub.topics}async publish(t,e){if(typeof t!="string")throw new v("invalid topic received","ERR_INVALID_TOPIC");if(!(e instanceof Uint8Array))throw new v("data received is not a Uint8Array","ERR_INVALID_DATA");let n=await this.client.send({type:W.Type.PUBSUB,pubsub:{type:le.Type.PUBLISH,topic:t,data:e}}),o=await n.read();if(o==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let s=P.decode(o);if(await n.close(),s.type!==P.Type.OK)throw new v(s.error?.msg??"Pubsub publish failed","ERR_PUBSUB_PUBLISH_FAILED")}async subscribe(t){if(typeof t!="string")throw new v("invalid topic received","ERR_INVALID_TOPIC");let e=await this.client.send({type:W.Type.PUBSUB,pubsub:{type:le.Type.SUBSCRIBE,topic:t}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let o=P.decode(n);if(o.type!==P.Type.OK)throw new v(o.error?.msg??"Pubsub publish failed","ERR_PUBSUB_PUBLISH_FAILED");let s=!0;return{async*messages(){for(;s;){if(n=await e.read(),n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");yield Un.decode(n)}},async cancel(){s=!1,await e.close()}}}async getSubscribers(t){if(typeof t!="string")throw new v("invalid topic received","ERR_INVALID_TOPIC");let e=await this.client.send({type:W.Type.PUBSUB,pubsub:{type:le.Type.LIST_PEERS,topic:t}}),n=await e.read();if(n==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let o=P.decode(n);if(await e.close(),o.type!==P.Type.OK)throw new v(o.error?.msg??"Pubsub get subscribers failed","ERR_PUBSUB_GET_SUBSCRIBERS_FAILED");if(o.pubsub==null||o.pubsub.topics==null)throw new v("Invalid response","ERR_PUBSUB_GET_SUBSCRIBERS_FAILED");return o.pubsub.peerIDs.map(s=>Xt(s))}};var hi={upgradeInbound:async r=>r,upgradeOutbound:async r=>r};var di=Dt("libp2p:daemon-client"),mi=class{constructor(t){this.multiaddr=t,this.tcp=Oa()(),this.dht=new Zn(this),this.pubsub=new Xn(this)}async connectDaemon(){return await this.tcp.dial(this.multiaddr,{upgrader:hi})}async send(t){let e=await this.connectDaemon(),n=t.pubsub?.type??t.dht?.type??t.peerStore?.type??"";di("send",t.type,n);let o=new Nr({stream:e});return o.write(W.encode(t)),o}async connect(t,e){if(!ur(t))throw new v("invalid peer id received","ERR_INVALID_PEER_ID");if(!Array.isArray(e))throw new v("addrs received are not in an array","ERR_INVALID_ADDRS_TYPE");e.forEach(c=>{if(!fi(c))throw new v("received an address that is not a multiaddr","ERR_NO_MULTIADDR_RECEIVED")});let n=await this.send({type:W.Type.CONNECT,connect:{peer:t.toBytes(),addrs:e.map(c=>c.bytes)}}),o=await n.read();if(o==null)throw new v("unspecified","ERR_CONNECT_FAILED");let s=P.decode(o);if(s.type!==P.Type.OK){let c=s.error??{msg:"unspecified"};throw new v(c.msg??"unspecified","ERR_CONNECT_FAILED")}await n.close()}async identify(){let t=await this.send({type:W.Type.IDENTIFY}),e=await t.read();if(e==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let n=P.decode(e);if(n.type!==P.Type.OK)throw new v(n.error?.msg??"Identify failed","ERR_IDENTIFY_FAILED");if(n.identify==null||n.identify.addrs==null)throw new v("Invalid response","ERR_IDENTIFY_FAILED");let o=Xt(n.identify?.id),s=n.identify.addrs.map(c=>ar(c));return await t.close(),{peerId:o,addrs:s}}async listPeers(){let t=await this.send({type:W.Type.LIST_PEERS}),e=await t.read();if(e==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let n=P.decode(e);if(n.type!==P.Type.OK)throw new v(n.error?.msg??"List peers failed","ERR_LIST_PEERS_FAILED");return await t.close(),n.peers.map(o=>Xt(o.id))}async openStream(t,e){if(!ur(t))throw new v("invalid peer id received","ERR_INVALID_PEER_ID");if(typeof e!="string")throw new v("invalid protocol received","ERR_INVALID_PROTOCOL");let n=await this.send({type:W.Type.STREAM_OPEN,streamOpen:{peer:t.toBytes(),proto:[e]}}),o=await n.read();if(o==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let s=P.decode(o);if(s.type!==P.Type.OK)throw await n.close(),new v(s.error?.msg??"Open stream failed","ERR_OPEN_STREAM_FAILED");return n.rest()}async registerStreamHandler(t,e){if(typeof t!="string")throw new v("invalid protocol received","ERR_INVALID_PROTOCOL");let n=this.tcp.createListener({upgrader:hi,handler:l=>{Promise.resolve().then(async()=>{let d=new Nr({stream:l}),p=await d.read();if(p==null)throw new v("Could not read open stream response","ERR_OPEN_STREAM_FAILED");if(or.decode(p).proto!==t)throw new v("Incorrect protocol","ERR_OPEN_STREAM_FAILED");await e(d.rest())}).finally(()=>{l.close().catch(d=>{di.error(d)}),n.close().catch(d=>{di.error(d)})})}});await n.listen(ar("/ip4/127.0.0.1/tcp/0"));let o=n.getAddrs()[0];if(o==null)throw new v("Could not listen on port","ERR_REGISTER_STREAM_HANDLER_FAILED");let s=await this.send({type:W.Type.STREAM_HANDLER,streamHandler:{addr:o.bytes,proto:[t]}}),c=await s.read();if(c==null)throw new v("Empty response from remote","ERR_EMPTY_RESPONSE");let f=P.decode(c);if(await s.close(),f.type!==P.Type.OK)throw new v(f.error?.msg??"Register stream handler failed","ERR_REGISTER_STREAM_HANDLER_FAILED")}};function e0(r){return new mi(r)}return Nf(r0);})();
4
+ `+s),r.push(i+"m+"+Lr.exports.humanize(this.diff)+"\x1B[0m")}else r[0]=Xf()+t+" "+r[0]}function Xf(){return Q.inspectOpts.hideDate?"":new Date().toISOString()+" "}function jf(...r){return process.stderr.write(Br.format(...r)+`
5
+ `)}function Jf(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function Qf(){return process.env.DEBUG}function th(r){r.inspectOpts={};let t=Object.keys(Q.inspectOpts);for(let e=0;e<t.length;e++)r.inspectOpts[t[e]]=Q.inspectOpts[t[e]]}Lr.exports=ci()(Q);var{formatters:go}=Lr.exports;go.o=function(r){return this.inspectOpts.colors=this.useColors,Br.inspect(r,this.inspectOpts).split(`
6
+ `).map(t=>t.trim()).join(" ")};go.O=function(r){return this.inspectOpts.colors=this.useColors,Br.inspect(r,this.inspectOpts)}});var bo=L((xm,ui)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?ui.exports=lo():ui.exports=yo()});var Nr=L((Cm,wo)=>{wo.exports=r=>{if(r[Symbol.asyncIterator])return r;if(r.getReader)return async function*(){let t=r.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}}();throw new Error("unknown stream")}});var vo=L((Dm,Eo)=>{Eo.exports=function(t){if(t){if(typeof t[Symbol.iterator]=="function")return t[Symbol.iterator]();if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t.next=="function")return t}throw new Error("argument is not an iterator or iterable")}});var li=L((Bm,To)=>{var rh=vo();To.exports=r=>async t=>{t=rh(t);let e=R=>{typeof R.return=="function"&&R.return()},n=null,i=null,s=R=>{n=R,i&&i(R),e(t)},a=null,f=!1,l=()=>{f=!0,a&&a()},d=null,h=!1,g=()=>{h=!0,d&&d()},w=null,x=()=>{w&&w()},b=()=>new Promise((R,D)=>{a=w=R,i=D,r.once("drain",x)}),A=()=>(e(t),new Promise((R,D)=>{if(f||h||n)return R();d=a=R,i=D})),B=()=>{r.removeListener("error",s),r.removeListener("close",l),r.removeListener("finish",g),r.removeListener("drain",x)};r.once("error",s),r.once("close",l),r.once("finish",g);try{for await(let R of t){if(!r.writable||r.destroyed||n)break;r.write(R)===!1&&await b()}}catch(R){n||r.destroy(),n=R}try{if(r.writable&&r.end(),await A(),n)throw n}finally{B()}}});var fi=L((Lm,So)=>{var nh=li(),ih=Nr();So.exports=r=>({sink:nh(r),source:ih(r)})});var Ao=L((Nm,xo)=>{var sh=fi();xo.exports=r=>async function*(t){let e=sh(r),n;if(e.sink(t).catch(i=>{n=i}),yield*e.source,n)throw n}});var Io=L((km,Oe)=>{Oe.exports=Nr();Oe.exports.source=Nr();Oe.exports.sink=li();Oe.exports.transform=Ao();Oe.exports.duplex=fi()});var pi=L((Or,Co)=>{(function(){var r,t=0xdeadbeefcafe,e=(t&16777215)==15715070;function n(o,c,u){o!=null&&(typeof o=="number"?this.fromNumber(o,c,u):c==null&&typeof o!="string"?this.fromString(o,256):this.fromString(o,c))}function i(){return new n(null)}function s(o,c,u,p,m,y){for(;--y>=0;){var v=c*this[o++]+u[p]+m;m=Math.floor(v/67108864),u[p++]=v&67108863}return m}function a(o,c,u,p,m,y){for(var v=c&32767,T=c>>15;--y>=0;){var O=this[o]&32767,j=this[o++]>>15,bt=T*O+j*v;O=v*O+((bt&32767)<<15)+u[p]+(m&1073741823),m=(O>>>30)+(bt>>>15)+T*j+(m>>>30),u[p++]=O&1073741823}return m}function f(o,c,u,p,m,y){for(var v=c&16383,T=c>>14;--y>=0;){var O=this[o]&16383,j=this[o++]>>14,bt=T*O+j*v;O=v*O+((bt&16383)<<14)+u[p]+m,m=(O>>28)+(bt>>14)+T*j,u[p++]=O&268435455}return m}var l=typeof navigator<"u";l&&e&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=a,r=30):l&&e&&navigator.appName!="Netscape"?(n.prototype.am=s,r=26):(n.prototype.am=f,r=28),n.prototype.DB=r,n.prototype.DM=(1<<r)-1,n.prototype.DV=1<<r;var d=52;n.prototype.FV=Math.pow(2,d),n.prototype.F1=d-r,n.prototype.F2=2*r-d;var h="0123456789abcdefghijklmnopqrstuvwxyz",g=new Array,w,x;for(w="0".charCodeAt(0),x=0;x<=9;++x)g[w++]=x;for(w="a".charCodeAt(0),x=10;x<36;++x)g[w++]=x;for(w="A".charCodeAt(0),x=10;x<36;++x)g[w++]=x;function b(o){return h.charAt(o)}function A(o,c){var u=g[o.charCodeAt(c)];return u??-1}function B(o){for(var c=this.t-1;c>=0;--c)o[c]=this[c];o.t=this.t,o.s=this.s}function R(o){this.t=1,this.s=o<0?-1:0,o>0?this[0]=o:o<-1?this[0]=o+this.DV:this.t=0}function D(o){var c=i();return c.fromInt(o),c}function V(o,c){var u;if(c==16)u=4;else if(c==8)u=3;else if(c==256)u=8;else if(c==2)u=1;else if(c==32)u=5;else if(c==4)u=2;else{this.fromRadix(o,c);return}this.t=0,this.s=0;for(var p=o.length,m=!1,y=0;--p>=0;){var v=u==8?o[p]&255:A(o,p);if(v<0){o.charAt(p)=="-"&&(m=!0);continue}m=!1,y==0?this[this.t++]=v:y+u>this.DB?(this[this.t-1]|=(v&(1<<this.DB-y)-1)<<y,this[this.t++]=v>>this.DB-y):this[this.t-1]|=v<<y,y+=u,y>=this.DB&&(y-=this.DB)}u==8&&o[0]&128&&(this.s=-1,y>0&&(this[this.t-1]|=(1<<this.DB-y)-1<<y)),this.clamp(),m&&n.ZERO.subTo(this,this)}function q(){for(var o=this.s&this.DM;this.t>0&&this[this.t-1]==o;)--this.t}function ft(o){if(this.s<0)return"-"+this.negate().toString(o);var c;if(o==16)c=4;else if(o==8)c=3;else if(o==2)c=1;else if(o==32)c=5;else if(o==4)c=2;else return this.toRadix(o);var u=(1<<c)-1,p,m=!1,y="",v=this.t,T=this.DB-v*this.DB%c;if(v-- >0)for(T<this.DB&&(p=this[v]>>T)>0&&(m=!0,y=b(p));v>=0;)T<c?(p=(this[v]&(1<<T)-1)<<c-T,p|=this[--v]>>(T+=this.DB-c)):(p=this[v]>>(T-=c)&u,T<=0&&(T+=this.DB,--v)),p>0&&(m=!0),m&&(y+=b(p));return m?y:"0"}function ct(){var o=i();return n.ZERO.subTo(this,o),o}function st(){return this.s<0?this.negate():this}function at(o){var c=this.s-o.s;if(c!=0)return c;var u=this.t;if(c=u-o.t,c!=0)return this.s<0?-c:c;for(;--u>=0;)if((c=this[u]-o[u])!=0)return c;return 0}function At(o){var c=1,u;return(u=o>>>16)!=0&&(o=u,c+=16),(u=o>>8)!=0&&(o=u,c+=8),(u=o>>4)!=0&&(o=u,c+=4),(u=o>>2)!=0&&(o=u,c+=2),(u=o>>1)!=0&&(o=u,c+=1),c}function qc(){return this.t<=0?0:this.DB*(this.t-1)+At(this[this.t-1]^this.s&this.DM)}function Wc(o,c){var u;for(u=this.t-1;u>=0;--u)c[u+o]=this[u];for(u=o-1;u>=0;--u)c[u]=0;c.t=this.t+o,c.s=this.s}function Zc(o,c){for(var u=o;u<this.t;++u)c[u-o]=this[u];c.t=Math.max(this.t-o,0),c.s=this.s}function Xc(o,c){var u=o%this.DB,p=this.DB-u,m=(1<<p)-1,y=Math.floor(o/this.DB),v=this.s<<u&this.DM,T;for(T=this.t-1;T>=0;--T)c[T+y+1]=this[T]>>p|v,v=(this[T]&m)<<u;for(T=y-1;T>=0;--T)c[T]=0;c[y]=v,c.t=this.t+y+1,c.s=this.s,c.clamp()}function jc(o,c){c.s=this.s;var u=Math.floor(o/this.DB);if(u>=this.t){c.t=0;return}var p=o%this.DB,m=this.DB-p,y=(1<<p)-1;c[0]=this[u]>>p;for(var v=u+1;v<this.t;++v)c[v-u-1]|=(this[v]&y)<<m,c[v-u]=this[v]>>p;p>0&&(c[this.t-u-1]|=(this.s&y)<<m),c.t=this.t-u,c.clamp()}function Jc(o,c){for(var u=0,p=0,m=Math.min(o.t,this.t);u<m;)p+=this[u]-o[u],c[u++]=p&this.DM,p>>=this.DB;if(o.t<this.t){for(p-=o.s;u<this.t;)p+=this[u],c[u++]=p&this.DM,p>>=this.DB;p+=this.s}else{for(p+=this.s;u<o.t;)p-=o[u],c[u++]=p&this.DM,p>>=this.DB;p-=o.s}c.s=p<0?-1:0,p<-1?c[u++]=this.DV+p:p>0&&(c[u++]=p),c.t=u,c.clamp()}function Qc(o,c){var u=this.abs(),p=o.abs(),m=u.t;for(c.t=m+p.t;--m>=0;)c[m]=0;for(m=0;m<p.t;++m)c[m+u.t]=u.am(0,p[m],c,m,0,u.t);c.s=0,c.clamp(),this.s!=o.s&&n.ZERO.subTo(c,c)}function ta(o){for(var c=this.abs(),u=o.t=2*c.t;--u>=0;)o[u]=0;for(u=0;u<c.t-1;++u){var p=c.am(u,c[u],o,2*u,0,1);(o[u+c.t]+=c.am(u+1,2*c[u],o,2*u+1,p,c.t-u-1))>=c.DV&&(o[u+c.t]-=c.DV,o[u+c.t+1]=1)}o.t>0&&(o[o.t-1]+=c.am(u,c[u],o,2*u,0,1)),o.s=0,o.clamp()}function ea(o,c,u){var p=o.abs();if(!(p.t<=0)){var m=this.abs();if(m.t<p.t){c?.fromInt(0),u!=null&&this.copyTo(u);return}u==null&&(u=i());var y=i(),v=this.s,T=o.s,O=this.DB-At(p[p.t-1]);O>0?(p.lShiftTo(O,y),m.lShiftTo(O,u)):(p.copyTo(y),m.copyTo(u));var j=y.t,bt=y[j-1];if(bt!=0){var pt=bt*(1<<this.F1)+(j>1?y[j-2]>>this.F2:0),Gt=this.FV/pt,dr=(1<<this.F1)/pt,_t=1<<this.F2,Rt=u.t,mr=Rt-j,Xt=c??i();for(y.dlShiftTo(mr,Xt),u.compareTo(Xt)>=0&&(u[u.t++]=1,u.subTo(Xt,u)),n.ONE.dlShiftTo(j,Xt),Xt.subTo(y,y);y.t<j;)y[y.t++]=0;for(;--mr>=0;){var wn=u[--Rt]==bt?this.DM:Math.floor(u[Rt]*Gt+(u[Rt-1]+_t)*dr);if((u[Rt]+=y.am(0,wn,u,mr,0,j))<wn)for(y.dlShiftTo(mr,Xt),u.subTo(Xt,u);u[Rt]<--wn;)u.subTo(Xt,u)}c!=null&&(u.drShiftTo(j,c),v!=T&&n.ZERO.subTo(c,c)),u.t=j,u.clamp(),O>0&&u.rShiftTo(O,u),v<0&&n.ZERO.subTo(u,u)}}}function ra(o){var c=i();return this.abs().divRemTo(o,null,c),this.s<0&&c.compareTo(n.ZERO)>0&&o.subTo(c,c),c}function oe(o){this.m=o}function na(o){return o.s<0||o.compareTo(this.m)>=0?o.mod(this.m):o}function ia(o){return o}function sa(o){o.divRemTo(this.m,null,o)}function oa(o,c,u){o.multiplyTo(c,u),this.reduce(u)}function ca(o,c){o.squareTo(c),this.reduce(c)}oe.prototype.convert=na,oe.prototype.revert=ia,oe.prototype.reduce=sa,oe.prototype.mulTo=oa,oe.prototype.sqrTo=ca;function aa(){if(this.t<1)return 0;var o=this[0];if(!(o&1))return 0;var c=o&3;return c=c*(2-(o&15)*c)&15,c=c*(2-(o&255)*c)&255,c=c*(2-((o&65535)*c&65535))&65535,c=c*(2-o*c%this.DV)%this.DV,c>0?this.DV-c:-c}function ce(o){this.m=o,this.mp=o.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<o.DB-15)-1,this.mt2=2*o.t}function ua(o){var c=i();return o.abs().dlShiftTo(this.m.t,c),c.divRemTo(this.m,null,c),o.s<0&&c.compareTo(n.ZERO)>0&&this.m.subTo(c,c),c}function la(o){var c=i();return o.copyTo(c),this.reduce(c),c}function fa(o){for(;o.t<=this.mt2;)o[o.t++]=0;for(var c=0;c<this.m.t;++c){var u=o[c]&32767,p=u*this.mpl+((u*this.mph+(o[c]>>15)*this.mpl&this.um)<<15)&o.DM;for(u=c+this.m.t,o[u]+=this.m.am(0,p,o,c,0,this.m.t);o[u]>=o.DV;)o[u]-=o.DV,o[++u]++}o.clamp(),o.drShiftTo(this.m.t,o),o.compareTo(this.m)>=0&&o.subTo(this.m,o)}function ha(o,c){o.squareTo(c),this.reduce(c)}function pa(o,c,u){o.multiplyTo(c,u),this.reduce(u)}ce.prototype.convert=ua,ce.prototype.revert=la,ce.prototype.reduce=fa,ce.prototype.mulTo=pa,ce.prototype.sqrTo=ha;function da(){return(this.t>0?this[0]&1:this.s)==0}function ma(o,c){if(o>4294967295||o<1)return n.ONE;var u=i(),p=i(),m=c.convert(this),y=At(o)-1;for(m.copyTo(u);--y>=0;)if(c.sqrTo(u,p),(o&1<<y)>0)c.mulTo(p,m,u);else{var v=u;u=p,p=v}return c.revert(u)}function ga(o,c){var u;return o<256||c.isEven()?u=new oe(c):u=new ce(c),this.exp(o,u)}n.prototype.copyTo=B,n.prototype.fromInt=R,n.prototype.fromString=V,n.prototype.clamp=q,n.prototype.dlShiftTo=Wc,n.prototype.drShiftTo=Zc,n.prototype.lShiftTo=Xc,n.prototype.rShiftTo=jc,n.prototype.subTo=Jc,n.prototype.multiplyTo=Qc,n.prototype.squareTo=ta,n.prototype.divRemTo=ea,n.prototype.invDigit=aa,n.prototype.isEven=da,n.prototype.exp=ma,n.prototype.toString=ft,n.prototype.negate=ct,n.prototype.abs=st,n.prototype.compareTo=at,n.prototype.bitLength=qc,n.prototype.mod=ra,n.prototype.modPowInt=ga,n.ZERO=D(0),n.ONE=D(1);function ya(){var o=i();return this.copyTo(o),o}function ba(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}function wa(){return this.t==0?this.s:this[0]<<24>>24}function Ea(){return this.t==0?this.s:this[0]<<16>>16}function va(o){return Math.floor(Math.LN2*this.DB/Math.log(o))}function Ta(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function Sa(o){if(o==null&&(o=10),this.signum()==0||o<2||o>36)return"0";var c=this.chunkSize(o),u=Math.pow(o,c),p=D(u),m=i(),y=i(),v="";for(this.divRemTo(p,m,y);m.signum()>0;)v=(u+y.intValue()).toString(o).substr(1)+v,m.divRemTo(p,m,y);return y.intValue().toString(o)+v}function xa(o,c){this.fromInt(0),c==null&&(c=10);for(var u=this.chunkSize(c),p=Math.pow(c,u),m=!1,y=0,v=0,T=0;T<o.length;++T){var O=A(o,T);if(O<0){o.charAt(T)=="-"&&this.signum()==0&&(m=!0);continue}v=c*v+O,++y>=u&&(this.dMultiply(p),this.dAddOffset(v,0),y=0,v=0)}y>0&&(this.dMultiply(Math.pow(c,y)),this.dAddOffset(v,0)),m&&n.ZERO.subTo(this,this)}function Aa(o,c,u){if(typeof c=="number")if(o<2)this.fromInt(1);else for(this.fromNumber(o,u),this.testBit(o-1)||this.bitwiseTo(n.ONE.shiftLeft(o-1),mn,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(c);)this.dAddOffset(2,0),this.bitLength()>o&&this.subTo(n.ONE.shiftLeft(o-1),this);else{var p=new Array,m=o&7;p.length=(o>>3)+1,c.nextBytes(p),m>0?p[0]&=(1<<m)-1:p[0]=0,this.fromString(p,256)}}function Ia(){var o=this.t,c=new Array;c[0]=this.s;var u=this.DB-o*this.DB%8,p,m=0;if(o-- >0)for(u<this.DB&&(p=this[o]>>u)!=(this.s&this.DM)>>u&&(c[m++]=p|this.s<<this.DB-u);o>=0;)u<8?(p=(this[o]&(1<<u)-1)<<8-u,p|=this[--o]>>(u+=this.DB-8)):(p=this[o]>>(u-=8)&255,u<=0&&(u+=this.DB,--o)),p&128&&(p|=-256),m==0&&(this.s&128)!=(p&128)&&++m,(m>0||p!=this.s)&&(c[m++]=p);return c}function _a(o){return this.compareTo(o)==0}function Ra(o){return this.compareTo(o)<0?this:o}function Ca(o){return this.compareTo(o)>0?this:o}function Da(o,c,u){var p,m,y=Math.min(o.t,this.t);for(p=0;p<y;++p)u[p]=c(this[p],o[p]);if(o.t<this.t){for(m=o.s&this.DM,p=y;p<this.t;++p)u[p]=c(this[p],m);u.t=this.t}else{for(m=this.s&this.DM,p=y;p<o.t;++p)u[p]=c(m,o[p]);u.t=o.t}u.s=c(this.s,o.s),u.clamp()}function Ba(o,c){return o&c}function La(o){var c=i();return this.bitwiseTo(o,Ba,c),c}function mn(o,c){return o|c}function Na(o){var c=i();return this.bitwiseTo(o,mn,c),c}function Qi(o,c){return o^c}function ka(o){var c=i();return this.bitwiseTo(o,Qi,c),c}function ts(o,c){return o&~c}function Pa(o){var c=i();return this.bitwiseTo(o,ts,c),c}function Oa(){for(var o=i(),c=0;c<this.t;++c)o[c]=this.DM&~this[c];return o.t=this.t,o.s=~this.s,o}function Ma(o){var c=i();return o<0?this.rShiftTo(-o,c):this.lShiftTo(o,c),c}function Fa(o){var c=i();return o<0?this.lShiftTo(-o,c):this.rShiftTo(o,c),c}function Ua(o){if(o==0)return-1;var c=0;return o&65535||(o>>=16,c+=16),o&255||(o>>=8,c+=8),o&15||(o>>=4,c+=4),o&3||(o>>=2,c+=2),o&1||++c,c}function Ga(){for(var o=0;o<this.t;++o)if(this[o]!=0)return o*this.DB+Ua(this[o]);return this.s<0?this.t*this.DB:-1}function $a(o){for(var c=0;o!=0;)o&=o-1,++c;return c}function Va(){for(var o=0,c=this.s&this.DM,u=0;u<this.t;++u)o+=$a(this[u]^c);return o}function za(o){var c=Math.floor(o/this.DB);return c>=this.t?this.s!=0:(this[c]&1<<o%this.DB)!=0}function Ha(o,c){var u=n.ONE.shiftLeft(o);return this.bitwiseTo(u,c,u),u}function Ya(o){return this.changeBit(o,mn)}function Ka(o){return this.changeBit(o,ts)}function qa(o){return this.changeBit(o,Qi)}function Wa(o,c){for(var u=0,p=0,m=Math.min(o.t,this.t);u<m;)p+=this[u]+o[u],c[u++]=p&this.DM,p>>=this.DB;if(o.t<this.t){for(p+=o.s;u<this.t;)p+=this[u],c[u++]=p&this.DM,p>>=this.DB;p+=this.s}else{for(p+=this.s;u<o.t;)p+=o[u],c[u++]=p&this.DM,p>>=this.DB;p+=o.s}c.s=p<0?-1:0,p>0?c[u++]=p:p<-1&&(c[u++]=this.DV+p),c.t=u,c.clamp()}function Za(o){var c=i();return this.addTo(o,c),c}function Xa(o){var c=i();return this.subTo(o,c),c}function ja(o){var c=i();return this.multiplyTo(o,c),c}function Ja(){var o=i();return this.squareTo(o),o}function Qa(o){var c=i();return this.divRemTo(o,c,null),c}function tu(o){var c=i();return this.divRemTo(o,null,c),c}function eu(o){var c=i(),u=i();return this.divRemTo(o,c,u),new Array(c,u)}function ru(o){this[this.t]=this.am(0,o-1,this,0,0,this.t),++this.t,this.clamp()}function nu(o,c){if(o!=0){for(;this.t<=c;)this[this.t++]=0;for(this[c]+=o;this[c]>=this.DV;)this[c]-=this.DV,++c>=this.t&&(this[this.t++]=0),++this[c]}}function We(){}function es(o){return o}function iu(o,c,u){o.multiplyTo(c,u)}function su(o,c){o.squareTo(c)}We.prototype.convert=es,We.prototype.revert=es,We.prototype.mulTo=iu,We.prototype.sqrTo=su;function ou(o){return this.exp(o,new We)}function cu(o,c,u){var p=Math.min(this.t+o.t,c);for(u.s=0,u.t=p;p>0;)u[--p]=0;var m;for(m=u.t-this.t;p<m;++p)u[p+this.t]=this.am(0,o[p],u,p,0,this.t);for(m=Math.min(o.t,c);p<m;++p)this.am(0,o[p],u,p,0,c-p);u.clamp()}function au(o,c,u){--c;var p=u.t=this.t+o.t-c;for(u.s=0;--p>=0;)u[p]=0;for(p=Math.max(c-this.t,0);p<o.t;++p)u[this.t+p-c]=this.am(c-p,o[p],u,0,0,this.t+p-c);u.clamp(),u.drShiftTo(1,u)}function ae(o){this.r2=i(),this.q3=i(),n.ONE.dlShiftTo(2*o.t,this.r2),this.mu=this.r2.divide(o),this.m=o}function uu(o){if(o.s<0||o.t>2*this.m.t)return o.mod(this.m);if(o.compareTo(this.m)<0)return o;var c=i();return o.copyTo(c),this.reduce(c),c}function lu(o){return o}function fu(o){for(o.drShiftTo(this.m.t-1,this.r2),o.t>this.m.t+1&&(o.t=this.m.t+1,o.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);o.compareTo(this.r2)<0;)o.dAddOffset(1,this.m.t+1);for(o.subTo(this.r2,o);o.compareTo(this.m)>=0;)o.subTo(this.m,o)}function hu(o,c){o.squareTo(c),this.reduce(c)}function pu(o,c,u){o.multiplyTo(c,u),this.reduce(u)}ae.prototype.convert=uu,ae.prototype.revert=lu,ae.prototype.reduce=fu,ae.prototype.mulTo=pu,ae.prototype.sqrTo=hu;function du(o,c){var u=o.bitLength(),p,m=D(1),y;if(u<=0)return m;u<18?p=1:u<48?p=3:u<144?p=4:u<768?p=5:p=6,u<8?y=new oe(c):c.isEven()?y=new ae(c):y=new ce(c);var v=new Array,T=3,O=p-1,j=(1<<p)-1;if(v[1]=y.convert(this),p>1){var bt=i();for(y.sqrTo(v[1],bt);T<=j;)v[T]=i(),y.mulTo(bt,v[T-2],v[T]),T+=2}var pt=o.t-1,Gt,dr=!0,_t=i(),Rt;for(u=At(o[pt])-1;pt>=0;){for(u>=O?Gt=o[pt]>>u-O&j:(Gt=(o[pt]&(1<<u+1)-1)<<O-u,pt>0&&(Gt|=o[pt-1]>>this.DB+u-O)),T=p;!(Gt&1);)Gt>>=1,--T;if((u-=T)<0&&(u+=this.DB,--pt),dr)v[Gt].copyTo(m),dr=!1;else{for(;T>1;)y.sqrTo(m,_t),y.sqrTo(_t,m),T-=2;T>0?y.sqrTo(m,_t):(Rt=m,m=_t,_t=Rt),y.mulTo(_t,v[Gt],m)}for(;pt>=0&&!(o[pt]&1<<u);)y.sqrTo(m,_t),Rt=m,m=_t,_t=Rt,--u<0&&(u=this.DB-1,--pt)}return y.revert(m)}function mu(o){var c=this.s<0?this.negate():this.clone(),u=o.s<0?o.negate():o.clone();if(c.compareTo(u)<0){var p=c;c=u,u=p}var m=c.getLowestSetBit(),y=u.getLowestSetBit();if(y<0)return c;for(m<y&&(y=m),y>0&&(c.rShiftTo(y,c),u.rShiftTo(y,u));c.signum()>0;)(m=c.getLowestSetBit())>0&&c.rShiftTo(m,c),(m=u.getLowestSetBit())>0&&u.rShiftTo(m,u),c.compareTo(u)>=0?(c.subTo(u,c),c.rShiftTo(1,c)):(u.subTo(c,u),u.rShiftTo(1,u));return y>0&&u.lShiftTo(y,u),u}function gu(o){if(o<=0)return 0;var c=this.DV%o,u=this.s<0?o-1:0;if(this.t>0)if(c==0)u=this[0]%o;else for(var p=this.t-1;p>=0;--p)u=(c*u+this[p])%o;return u}function yu(o){var c=o.isEven();if(this.isEven()&&c||o.signum()==0)return n.ZERO;for(var u=o.clone(),p=this.clone(),m=D(1),y=D(0),v=D(0),T=D(1);u.signum()!=0;){for(;u.isEven();)u.rShiftTo(1,u),c?((!m.isEven()||!y.isEven())&&(m.addTo(this,m),y.subTo(o,y)),m.rShiftTo(1,m)):y.isEven()||y.subTo(o,y),y.rShiftTo(1,y);for(;p.isEven();)p.rShiftTo(1,p),c?((!v.isEven()||!T.isEven())&&(v.addTo(this,v),T.subTo(o,T)),v.rShiftTo(1,v)):T.isEven()||T.subTo(o,T),T.rShiftTo(1,T);u.compareTo(p)>=0?(u.subTo(p,u),c&&m.subTo(v,m),y.subTo(T,y)):(p.subTo(u,p),c&&v.subTo(m,v),T.subTo(y,T))}if(p.compareTo(n.ONE)!=0)return n.ZERO;if(T.compareTo(o)>=0)return T.subtract(o);if(T.signum()<0)T.addTo(o,T);else return T;return T.signum()<0?T.add(o):T}var ot=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],bu=(1<<26)/ot[ot.length-1];function wu(o){var c,u=this.abs();if(u.t==1&&u[0]<=ot[ot.length-1]){for(c=0;c<ot.length;++c)if(u[0]==ot[c])return!0;return!1}if(u.isEven())return!1;for(c=1;c<ot.length;){for(var p=ot[c],m=c+1;m<ot.length&&p<bu;)p*=ot[m++];for(p=u.modInt(p);c<m;)if(p%ot[c++]==0)return!1}return u.millerRabin(o)}function Eu(o){var c=this.subtract(n.ONE),u=c.getLowestSetBit();if(u<=0)return!1;var p=c.shiftRight(u);o=o+1>>1,o>ot.length&&(o=ot.length);for(var m=i(),y=0;y<o;++y){m.fromInt(ot[Math.floor(Math.random()*ot.length)]);var v=m.modPow(p,this);if(v.compareTo(n.ONE)!=0&&v.compareTo(c)!=0){for(var T=1;T++<u&&v.compareTo(c)!=0;)if(v=v.modPowInt(2,this),v.compareTo(n.ONE)==0)return!1;if(v.compareTo(c)!=0)return!1}}return!0}n.prototype.chunkSize=va,n.prototype.toRadix=Sa,n.prototype.fromRadix=xa,n.prototype.fromNumber=Aa,n.prototype.bitwiseTo=Da,n.prototype.changeBit=Ha,n.prototype.addTo=Wa,n.prototype.dMultiply=ru,n.prototype.dAddOffset=nu,n.prototype.multiplyLowerTo=cu,n.prototype.multiplyUpperTo=au,n.prototype.modInt=gu,n.prototype.millerRabin=Eu,n.prototype.clone=ya,n.prototype.intValue=ba,n.prototype.byteValue=wa,n.prototype.shortValue=Ea,n.prototype.signum=Ta,n.prototype.toByteArray=Ia,n.prototype.equals=_a,n.prototype.min=Ra,n.prototype.max=Ca,n.prototype.and=La,n.prototype.or=Na,n.prototype.xor=ka,n.prototype.andNot=Pa,n.prototype.not=Oa,n.prototype.shiftLeft=Ma,n.prototype.shiftRight=Fa,n.prototype.getLowestSetBit=Ga,n.prototype.bitCount=Va,n.prototype.testBit=za,n.prototype.setBit=Ya,n.prototype.clearBit=Ka,n.prototype.flipBit=qa,n.prototype.add=Za,n.prototype.subtract=Xa,n.prototype.multiply=ja,n.prototype.divide=Qa,n.prototype.remainder=tu,n.prototype.divideAndRemainder=eu,n.prototype.modPow=du,n.prototype.modInverse=yu,n.prototype.pow=ou,n.prototype.gcd=mu,n.prototype.isProbablePrime=wu,n.prototype.square=Ja,n.prototype.Barrett=ae;var pr,ht,X;function vu(o){ht[X++]^=o&255,ht[X++]^=o>>8&255,ht[X++]^=o>>16&255,ht[X++]^=o>>24&255,X>=bn&&(X-=bn)}function rs(){vu(new Date().getTime())}if(ht==null){ht=new Array,X=0;var It;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var ns=new Uint8Array(32);for(window.crypto.getRandomValues(ns),It=0;It<32;++It)ht[X++]=ns[It]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var is=window.crypto.random(32);for(It=0;It<is.length;++It)ht[X++]=is.charCodeAt(It)&255}}for(;X<bn;)It=Math.floor(65536*Math.random()),ht[X++]=It>>>8,ht[X++]=It&255;X=0,rs()}function Tu(){if(pr==null){for(rs(),pr=Iu(),pr.init(ht),X=0;X<ht.length;++X)ht[X]=0;X=0}return pr.next()}function Su(o){var c;for(c=0;c<o.length;++c)o[c]=Tu()}function gn(){}gn.prototype.nextBytes=Su;function yn(){this.i=0,this.j=0,this.S=new Array}function xu(o){var c,u,p;for(c=0;c<256;++c)this.S[c]=c;for(u=0,c=0;c<256;++c)u=u+this.S[c]+o[c%o.length]&255,p=this.S[c],this.S[c]=this.S[u],this.S[u]=p;this.i=0,this.j=0}function Au(){var o;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,o=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=o,this.S[o+this.S[this.i]&255]}yn.prototype.init=xu,yn.prototype.next=Au;function Iu(){return new yn}var bn=256;typeof Or<"u"?Or=Co.exports={default:n,BigInteger:n,SecureRandom:gn}:this.jsbn={BigInteger:n,SecureRandom:gn}}).call(Or)});var ir=L(Mr=>{(function(){"use strict";var r={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function t(a){return n(s(a),arguments)}function e(a,f){return t.apply(null,[a].concat(f||[]))}function n(a,f){var l=1,d=a.length,h,g="",w,x,b,A,B,R,D,V;for(w=0;w<d;w++)if(typeof a[w]=="string")g+=a[w];else if(typeof a[w]=="object"){if(b=a[w],b.keys)for(h=f[l],x=0;x<b.keys.length;x++){if(h==null)throw new Error(t('[sprintf] Cannot access property "%s" of undefined value "%s"',b.keys[x],b.keys[x-1]));h=h[b.keys[x]]}else b.param_no?h=f[b.param_no]:h=f[l++];if(r.not_type.test(b.type)&&r.not_primitive.test(b.type)&&h instanceof Function&&(h=h()),r.numeric_arg.test(b.type)&&typeof h!="number"&&isNaN(h))throw new TypeError(t("[sprintf] expecting number but found %T",h));switch(r.number.test(b.type)&&(D=h>=0),b.type){case"b":h=parseInt(h,10).toString(2);break;case"c":h=String.fromCharCode(parseInt(h,10));break;case"d":case"i":h=parseInt(h,10);break;case"j":h=JSON.stringify(h,null,b.width?parseInt(b.width):0);break;case"e":h=b.precision?parseFloat(h).toExponential(b.precision):parseFloat(h).toExponential();break;case"f":h=b.precision?parseFloat(h).toFixed(b.precision):parseFloat(h);break;case"g":h=b.precision?String(Number(h.toPrecision(b.precision))):parseFloat(h);break;case"o":h=(parseInt(h,10)>>>0).toString(8);break;case"s":h=String(h),h=b.precision?h.substring(0,b.precision):h;break;case"t":h=String(!!h),h=b.precision?h.substring(0,b.precision):h;break;case"T":h=Object.prototype.toString.call(h).slice(8,-1).toLowerCase(),h=b.precision?h.substring(0,b.precision):h;break;case"u":h=parseInt(h,10)>>>0;break;case"v":h=h.valueOf(),h=b.precision?h.substring(0,b.precision):h;break;case"x":h=(parseInt(h,10)>>>0).toString(16);break;case"X":h=(parseInt(h,10)>>>0).toString(16).toUpperCase();break}r.json.test(b.type)?g+=h:(r.number.test(b.type)&&(!D||b.sign)?(V=D?"+":"-",h=h.toString().replace(r.sign,"")):V="",B=b.pad_char?b.pad_char==="0"?"0":b.pad_char.charAt(1):" ",R=b.width-(V+h).length,A=b.width&&R>0?B.repeat(R):"",g+=b.align?V+h+A:B==="0"?V+A+h:A+V+h)}return g}var i=Object.create(null);function s(a){if(i[a])return i[a];for(var f=a,l,d=[],h=0;f;){if((l=r.text.exec(f))!==null)d.push(l[0]);else if((l=r.modulo.exec(f))!==null)d.push("%");else if((l=r.placeholder.exec(f))!==null){if(l[2]){h|=1;var g=[],w=l[2],x=[];if((x=r.key.exec(w))!==null)for(g.push(x[1]);(w=w.substring(x[0].length))!=="";)if((x=r.key_access.exec(w))!==null)g.push(x[1]);else if((x=r.index_access.exec(w))!==null)g.push(x[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");l[2]=g}else h|=2;if(h===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");d.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");f=f.substring(l[0].length)}return i[a]=d}typeof Mr<"u"&&(Mr.sprintf=t,Mr.vsprintf=e),typeof window<"u"&&(window.sprintf=t,window.vsprintf=e,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:e}}))})()});var Wo=L((x0,qo)=>{"use strict";qo.exports=vh;function vh(r,t){for(var e=new Array(arguments.length-1),n=0,i=2,s=!0;i<arguments.length;)e[n++]=arguments[i++];return new Promise(function(f,l){e[n]=function(h){if(s)if(s=!1,h)l(h);else{for(var g=new Array(arguments.length-1),w=0;w<g.length;)g[w++]=arguments[w];f.apply(null,g)}};try{r.apply(t||null,e)}catch(d){s&&(s=!1,l(d))}})}});var Jo=L(jo=>{"use strict";var Hr=jo;Hr.length=function(t){var e=t.length;if(!e)return 0;for(var n=0;--e%4>1&&t.charAt(e)==="=";)++n;return Math.ceil(t.length*3)/4-n};var Ve=new Array(64),Xo=new Array(123);for(Nt=0;Nt<64;)Xo[Ve[Nt]=Nt<26?Nt+65:Nt<52?Nt+71:Nt<62?Nt-4:Nt-59|43]=Nt++;var Nt;Hr.encode=function(t,e,n){for(var i=null,s=[],a=0,f=0,l;e<n;){var d=t[e++];switch(f){case 0:s[a++]=Ve[d>>2],l=(d&3)<<4,f=1;break;case 1:s[a++]=Ve[l|d>>4],l=(d&15)<<2,f=2;break;case 2:s[a++]=Ve[l|d>>6],s[a++]=Ve[d&63],f=0;break}a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),a=0)}return f&&(s[a++]=Ve[l],s[a++]=61,f===1&&(s[a++]=61)),i?(a&&i.push(String.fromCharCode.apply(String,s.slice(0,a))),i.join("")):String.fromCharCode.apply(String,s.slice(0,a))};var Zo="invalid encoding";Hr.decode=function(t,e,n){for(var i=n,s=0,a,f=0;f<t.length;){var l=t.charCodeAt(f++);if(l===61&&s>1)break;if((l=Xo[l])===void 0)throw Error(Zo);switch(s){case 0:a=l,s=1;break;case 1:e[n++]=a<<2|(l&48)>>4,a=l,s=2;break;case 2:e[n++]=(a&15)<<4|(l&60)>>2,a=l,s=3;break;case 3:e[n++]=(a&3)<<6|l,s=0;break}}if(s===1)throw Error(Zo);return n-i};Hr.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}});var tc=L((I0,Qo)=>{"use strict";Qo.exports=Yr;function Yr(){this._listeners={}}Yr.prototype.on=function(t,e,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:n||this}),this};Yr.prototype.off=function(t,e){if(t===void 0)this._listeners={};else if(e===void 0)this._listeners[t]=[];else for(var n=this._listeners[t],i=0;i<n.length;)n[i].fn===e?n.splice(i,1):++i;return this};Yr.prototype.emit=function(t){var e=this._listeners[t];if(e){for(var n=[],i=1;i<arguments.length;)n.push(arguments[i++]);for(i=0;i<e.length;)e[i].fn.apply(e[i++].ctx,n)}return this}});var cc=L((_0,oc)=>{"use strict";oc.exports=ec(ec);function ec(r){return typeof Float32Array<"u"?function(){var t=new Float32Array([-0]),e=new Uint8Array(t.buffer),n=e[3]===128;function i(l,d,h){t[0]=l,d[h]=e[0],d[h+1]=e[1],d[h+2]=e[2],d[h+3]=e[3]}function s(l,d,h){t[0]=l,d[h]=e[3],d[h+1]=e[2],d[h+2]=e[1],d[h+3]=e[0]}r.writeFloatLE=n?i:s,r.writeFloatBE=n?s:i;function a(l,d){return e[0]=l[d],e[1]=l[d+1],e[2]=l[d+2],e[3]=l[d+3],t[0]}function f(l,d){return e[3]=l[d],e[2]=l[d+1],e[1]=l[d+2],e[0]=l[d+3],t[0]}r.readFloatLE=n?a:f,r.readFloatBE=n?f:a}():function(){function t(n,i,s,a){var f=i<0?1:0;if(f&&(i=-i),i===0)n(1/i>0?0:2147483648,s,a);else if(isNaN(i))n(2143289344,s,a);else if(i>34028234663852886e22)n((f<<31|2139095040)>>>0,s,a);else if(i<11754943508222875e-54)n((f<<31|Math.round(i/1401298464324817e-60))>>>0,s,a);else{var l=Math.floor(Math.log(i)/Math.LN2),d=Math.round(i*Math.pow(2,-l)*8388608)&8388607;n((f<<31|l+127<<23|d)>>>0,s,a)}}r.writeFloatLE=t.bind(null,rc),r.writeFloatBE=t.bind(null,nc);function e(n,i,s){var a=n(i,s),f=(a>>31)*2+1,l=a>>>23&255,d=a&8388607;return l===255?d?NaN:f*(1/0):l===0?f*1401298464324817e-60*d:f*Math.pow(2,l-150)*(d+8388608)}r.readFloatLE=e.bind(null,ic),r.readFloatBE=e.bind(null,sc)}(),typeof Float64Array<"u"?function(){var t=new Float64Array([-0]),e=new Uint8Array(t.buffer),n=e[7]===128;function i(l,d,h){t[0]=l,d[h]=e[0],d[h+1]=e[1],d[h+2]=e[2],d[h+3]=e[3],d[h+4]=e[4],d[h+5]=e[5],d[h+6]=e[6],d[h+7]=e[7]}function s(l,d,h){t[0]=l,d[h]=e[7],d[h+1]=e[6],d[h+2]=e[5],d[h+3]=e[4],d[h+4]=e[3],d[h+5]=e[2],d[h+6]=e[1],d[h+7]=e[0]}r.writeDoubleLE=n?i:s,r.writeDoubleBE=n?s:i;function a(l,d){return e[0]=l[d],e[1]=l[d+1],e[2]=l[d+2],e[3]=l[d+3],e[4]=l[d+4],e[5]=l[d+5],e[6]=l[d+6],e[7]=l[d+7],t[0]}function f(l,d){return e[7]=l[d],e[6]=l[d+1],e[5]=l[d+2],e[4]=l[d+3],e[3]=l[d+4],e[2]=l[d+5],e[1]=l[d+6],e[0]=l[d+7],t[0]}r.readDoubleLE=n?a:f,r.readDoubleBE=n?f:a}():function(){function t(n,i,s,a,f,l){var d=a<0?1:0;if(d&&(a=-a),a===0)n(0,f,l+i),n(1/a>0?0:2147483648,f,l+s);else if(isNaN(a))n(0,f,l+i),n(2146959360,f,l+s);else if(a>17976931348623157e292)n(0,f,l+i),n((d<<31|2146435072)>>>0,f,l+s);else{var h;if(a<22250738585072014e-324)h=a/5e-324,n(h>>>0,f,l+i),n((d<<31|h/4294967296)>>>0,f,l+s);else{var g=Math.floor(Math.log(a)/Math.LN2);g===1024&&(g=1023),h=a*Math.pow(2,-g),n(h*4503599627370496>>>0,f,l+i),n((d<<31|g+1023<<20|h*1048576&1048575)>>>0,f,l+s)}}}r.writeDoubleLE=t.bind(null,rc,0,4),r.writeDoubleBE=t.bind(null,nc,4,0);function e(n,i,s,a,f){var l=n(a,f+i),d=n(a,f+s),h=(d>>31)*2+1,g=d>>>20&2047,w=4294967296*(d&1048575)+l;return g===2047?w?NaN:h*(1/0):g===0?h*5e-324*w:h*Math.pow(2,g-1075)*(w+4503599627370496)}r.readDoubleLE=e.bind(null,ic,0,4),r.readDoubleBE=e.bind(null,sc,4,0)}(),r}function rc(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function nc(r,t,e){t[e]=r>>>24,t[e+1]=r>>>16&255,t[e+2]=r>>>8&255,t[e+3]=r&255}function ic(r,t){return(r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24)>>>0}function sc(r,t){return(r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3])>>>0}});var ac=L((exports,module)=>{"use strict";module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(r){}return null}});var lc=L(uc=>{"use strict";var Di=uc;Di.length=function(t){for(var e=0,n=0,i=0;i<t.length;++i)n=t.charCodeAt(i),n<128?e+=1:n<2048?e+=2:(n&64512)===55296&&(t.charCodeAt(i+1)&64512)===56320?(++i,e+=4):e+=3;return e};Di.read=function(t,e,n){var i=n-e;if(i<1)return"";for(var s=null,a=[],f=0,l;e<n;)l=t[e++],l<128?a[f++]=l:l>191&&l<224?a[f++]=(l&31)<<6|t[e++]&63:l>239&&l<365?(l=((l&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,a[f++]=55296+(l>>10),a[f++]=56320+(l&1023)):a[f++]=(l&15)<<12|(t[e++]&63)<<6|t[e++]&63,f>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,a)),f=0);return s?(f&&s.push(String.fromCharCode.apply(String,a.slice(0,f))),s.join("")):String.fromCharCode.apply(String,a.slice(0,f))};Di.write=function(t,e,n){for(var i=n,s,a,f=0;f<t.length;++f)s=t.charCodeAt(f),s<128?e[n++]=s:s<2048?(e[n++]=s>>6|192,e[n++]=s&63|128):(s&64512)===55296&&((a=t.charCodeAt(f+1))&64512)===56320?(s=65536+((s&1023)<<10)+(a&1023),++f,e[n++]=s>>18|240,e[n++]=s>>12&63|128,e[n++]=s>>6&63|128,e[n++]=s&63|128):(e[n++]=s>>12|224,e[n++]=s>>6&63|128,e[n++]=s&63|128);return n-i}});var hc=L((C0,fc)=>{"use strict";fc.exports=Th;function Th(r,t,e){var n=e||8192,i=n>>>1,s=null,a=n;return function(l){if(l<1||l>i)return r(l);a+l>n&&(s=r(n),a=0);var d=t.call(s,a,a+=l);return a&7&&(a=(a|7)+1),d}}});var dc=L((D0,pc)=>{"use strict";pc.exports=J;var sr=Ee();function J(r,t){this.lo=r>>>0,this.hi=t>>>0}var we=J.zero=new J(0,0);we.toNumber=function(){return 0};we.zzEncode=we.zzDecode=function(){return this};we.length=function(){return 1};var Sh=J.zeroHash="\0\0\0\0\0\0\0\0";J.fromNumber=function(t){if(t===0)return we;var e=t<0;e&&(t=-t);var n=t>>>0,i=(t-n)/4294967296>>>0;return e&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new J(n,i)};J.from=function(t){if(typeof t=="number")return J.fromNumber(t);if(sr.isString(t))if(sr.Long)t=sr.Long.fromString(t);else return J.fromNumber(parseInt(t,10));return t.low||t.high?new J(t.low>>>0,t.high>>>0):we};J.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var e=~this.lo+1>>>0,n=~this.hi>>>0;return e||(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296};J.prototype.toLong=function(t){return sr.Long?new sr.Long(this.lo|0,this.hi|0,!!t):{low:this.lo|0,high:this.hi|0,unsigned:!!t}};var ne=String.prototype.charCodeAt;J.fromHash=function(t){return t===Sh?we:new J((ne.call(t,0)|ne.call(t,1)<<8|ne.call(t,2)<<16|ne.call(t,3)<<24)>>>0,(ne.call(t,4)|ne.call(t,5)<<8|ne.call(t,6)<<16|ne.call(t,7)<<24)>>>0)};J.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};J.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this};J.prototype.zzDecode=function(){var t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this};J.prototype.length=function(){var t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}});var Ee=L(Bi=>{"use strict";var I=Bi;I.asPromise=Wo();I.base64=Jo();I.EventEmitter=tc();I.float=cc();I.inquire=ac();I.utf8=lc();I.pool=hc();I.LongBits=dc();I.isNode=!!(typeof globalThis<"u"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);I.global=I.isNode&&globalThis||typeof window<"u"&&window||typeof self<"u"&&self||Bi;I.emptyArray=Object.freeze?Object.freeze([]):[];I.emptyObject=Object.freeze?Object.freeze({}):{};I.isInteger=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};I.isString=function(t){return typeof t=="string"||t instanceof String};I.isObject=function(t){return t&&typeof t=="object"};I.isset=I.isSet=function(t,e){var n=t[e];return n!=null&&t.hasOwnProperty(e)?typeof n!="object"||(Array.isArray(n)?n.length:Object.keys(n).length)>0:!1};I.Buffer=function(){try{var r=I.inquire("buffer").Buffer;return r.prototype.utf8Write?r:null}catch{return null}}();I._Buffer_from=null;I._Buffer_allocUnsafe=null;I.newBuffer=function(t){return typeof t=="number"?I.Buffer?I._Buffer_allocUnsafe(t):new I.Array(t):I.Buffer?I._Buffer_from(t):typeof Uint8Array>"u"?t:new Uint8Array(t)};I.Array=typeof Uint8Array<"u"?Uint8Array:Array;I.Long=I.global.dcodeIO&&I.global.dcodeIO.Long||I.global.Long||I.inquire("long");I.key2Re=/^true|false|0|1$/;I.key32Re=/^-?(?:0|[1-9][0-9]*)$/;I.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;I.longToHash=function(t){return t?I.LongBits.from(t).toHash():I.LongBits.zeroHash};I.longFromHash=function(t,e){var n=I.LongBits.fromHash(t);return I.Long?I.Long.fromBits(n.lo,n.hi,e):n.toNumber(!!e)};function mc(r,t,e){for(var n=Object.keys(t),i=0;i<n.length;++i)(r[n[i]]===void 0||!e)&&(r[n[i]]=t[n[i]]);return r}I.merge=mc;I.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)};function gc(r){function t(e,n){if(!(this instanceof t))return new t(e,n);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:new Error().stack||""}),n&&mc(this,n)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return r},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}I.newError=gc;I.ProtocolError=gc("ProtocolError");I.oneOfGetter=function(t){for(var e={},n=0;n<t.length;++n)e[t[n]]=1;return function(){for(var i=Object.keys(this),s=i.length-1;s>-1;--s)if(e[i[s]]===1&&this[i[s]]!==void 0&&this[i[s]]!==null)return i[s]}};I.oneOfSetter=function(t){return function(e){for(var n=0;n<t.length;++n)t[n]!==e&&delete this[t[n]]}};I.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};I._configure=function(){var r=I.Buffer;if(!r){I._Buffer_from=I._Buffer_allocUnsafe=null;return}I._Buffer_from=r.from!==Uint8Array.from&&r.from||function(e,n){return new r(e,n)},I._Buffer_allocUnsafe=r.allocUnsafe||function(e){return new r(e)}}});var ki=L((L0,vc)=>{"use strict";vc.exports=z;var Mt=Ee(),Ni,wc=Mt.LongBits,xh=Mt.utf8;function kt(r,t){return RangeError("index out of range: "+r.pos+" + "+(t||1)+" > "+r.len)}function z(r){this.buf=r,this.pos=0,this.len=r.length}var yc=typeof Uint8Array<"u"?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new z(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new z(t);throw Error("illegal buffer")},Ec=function(){return Mt.Buffer?function(e){return(z.create=function(i){return Mt.Buffer.isBuffer(i)?new Ni(i):yc(i)})(e)}:yc};z.create=Ec();z.prototype._slice=Mt.Array.prototype.subarray||Mt.Array.prototype.slice;z.prototype.uint32=function(){var t=4294967295;return function(){if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,kt(this,10);return t}}();z.prototype.int32=function(){return this.uint32()|0};z.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(t&1)|0};function Li(){var r=new wc(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(r.lo=(r.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return r;if(r.lo=(r.lo|(this.buf[this.pos]&127)<<28)>>>0,r.hi=(r.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return r;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw kt(this);if(r.lo=(r.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return r}return r.lo=(r.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,r}if(this.len-this.pos>4){for(;t<5;++t)if(r.hi=(r.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return r}else for(;t<5;++t){if(this.pos>=this.len)throw kt(this);if(r.hi=(r.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return r}throw Error("invalid varint encoding")}z.prototype.bool=function(){return this.uint32()!==0};function Kr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}z.prototype.fixed32=function(){if(this.pos+4>this.len)throw kt(this,4);return Kr(this.buf,this.pos+=4)};z.prototype.sfixed32=function(){if(this.pos+4>this.len)throw kt(this,4);return Kr(this.buf,this.pos+=4)|0};function bc(){if(this.pos+8>this.len)throw kt(this,8);return new wc(Kr(this.buf,this.pos+=4),Kr(this.buf,this.pos+=4))}z.prototype.float=function(){if(this.pos+4>this.len)throw kt(this,4);var t=Mt.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};z.prototype.double=function(){if(this.pos+8>this.len)throw kt(this,4);var t=Mt.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};z.prototype.bytes=function(){var t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw kt(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(e,n):e===n?new this.buf.constructor(0):this._slice.call(this.buf,e,n)};z.prototype.string=function(){var t=this.bytes();return xh.read(t,0,t.length)};z.prototype.skip=function(t){if(typeof t=="number"){if(this.pos+t>this.len)throw kt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw kt(this);while(this.buf[this.pos++]&128);return this};z.prototype.skipType=function(r){switch(r){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(r=this.uint32()&7)!==4;)this.skipType(r);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+r+" at offset "+this.pos)}return this};z._configure=function(r){Ni=r,z.create=Ec(),Ni._configure();var t=Mt.Long?"toLong":"toNumber";Mt.merge(z.prototype,{int64:function(){return Li.call(this)[t](!1)},uint64:function(){return Li.call(this)[t](!0)},sint64:function(){return Li.call(this).zzDecode()[t](!1)},fixed64:function(){return bc.call(this)[t](!0)},sfixed64:function(){return bc.call(this)[t](!1)}})}});var Ac=L((N0,xc)=>{"use strict";xc.exports=ve;var Sc=ki();(ve.prototype=Object.create(Sc.prototype)).constructor=ve;var Tc=Ee();function ve(r){Sc.call(this,r)}ve._configure=function(){Tc.Buffer&&(ve.prototype._slice=Tc.Buffer.prototype.slice)};ve.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))};ve._configure()});var $i=L((k0,Cc)=>{"use strict";Cc.exports=N;var St=Ee(),Pi,qr=St.LongBits,Ic=St.base64,_c=St.utf8;function or(r,t,e){this.fn=r,this.len=t,this.next=void 0,this.val=e}function Mi(){}function Ah(r){this.head=r.head,this.tail=r.tail,this.len=r.len,this.next=r.states}function N(){this.len=0,this.head=new or(Mi,0,0),this.tail=this.head,this.states=null}var Rc=function(){return St.Buffer?function(){return(N.create=function(){return new Pi})()}:function(){return new N}};N.create=Rc();N.alloc=function(t){return new St.Array(t)};St.Array!==Array&&(N.alloc=St.pool(N.alloc,St.Array.prototype.subarray));N.prototype._push=function(t,e,n){return this.tail=this.tail.next=new or(t,e,n),this.len+=e,this};function Fi(r,t,e){t[e]=r&255}function Ih(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}function Ui(r,t){this.len=r,this.next=void 0,this.val=t}Ui.prototype=Object.create(or.prototype);Ui.prototype.fn=Ih;N.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new Ui((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};N.prototype.int32=function(t){return t<0?this._push(Gi,10,qr.fromNumber(t)):this.uint32(t)};N.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)};function Gi(r,t,e){for(;r.hi;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}N.prototype.uint64=function(t){var e=qr.from(t);return this._push(Gi,e.length(),e)};N.prototype.int64=N.prototype.uint64;N.prototype.sint64=function(t){var e=qr.from(t).zzEncode();return this._push(Gi,e.length(),e)};N.prototype.bool=function(t){return this._push(Fi,1,t?1:0)};function Oi(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}N.prototype.fixed32=function(t){return this._push(Oi,4,t>>>0)};N.prototype.sfixed32=N.prototype.fixed32;N.prototype.fixed64=function(t){var e=qr.from(t);return this._push(Oi,4,e.lo)._push(Oi,4,e.hi)};N.prototype.sfixed64=N.prototype.fixed64;N.prototype.float=function(t){return this._push(St.float.writeFloatLE,4,t)};N.prototype.double=function(t){return this._push(St.float.writeDoubleLE,8,t)};var _h=St.Array.prototype.set?function(t,e,n){e.set(t,n)}:function(t,e,n){for(var i=0;i<t.length;++i)e[n+i]=t[i]};N.prototype.bytes=function(t){var e=t.length>>>0;if(!e)return this._push(Fi,1,0);if(St.isString(t)){var n=N.alloc(e=Ic.length(t));Ic.decode(t,n,0),t=n}return this.uint32(e)._push(_h,e,t)};N.prototype.string=function(t){var e=_c.length(t);return e?this.uint32(e)._push(_c.write,e,t):this._push(Fi,1,0)};N.prototype.fork=function(){return this.states=new Ah(this),this.head=this.tail=new or(Mi,0,0),this.len=0,this};N.prototype.reset=function(){return this.states?(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 or(Mi,0,0),this.len=0),this};N.prototype.ldelim=function(){var t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=t.next,this.tail=e,this.len+=n),this};N.prototype.finish=function(){for(var t=this.head.next,e=this.constructor.alloc(this.len),n=0;t;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e};N._configure=function(r){Pi=r,N.create=Rc(),Pi._configure()}});var Lc=L((P0,Bc)=>{"use strict";Bc.exports=Ft;var Dc=$i();(Ft.prototype=Object.create(Dc.prototype)).constructor=Ft;var ie=Ee();function Ft(){Dc.call(this)}Ft._configure=function(){Ft.alloc=ie._Buffer_allocUnsafe,Ft.writeBytesBuffer=ie.Buffer&&ie.Buffer.prototype instanceof Uint8Array&&ie.Buffer.prototype.set.name==="set"?function(t,e,n){e.set(t,n)}:function(t,e,n){if(t.copy)t.copy(e,n,0,t.length);else for(var i=0;i<t.length;)e[n++]=t[i++]}};Ft.prototype.bytes=function(t){ie.isString(t)&&(t=ie._Buffer_from(t,"base64"));var e=t.length>>>0;return this.uint32(e),e&&this._push(Ft.writeBytesBuffer,e,t),this};function Rh(r,t,e){r.length<40?ie.utf8.write(r,t,e):t.utf8Write?t.utf8Write(r,e):t.write(r,e)}Ft.prototype.string=function(t){var e=ie.Buffer.byteLength(t);return this.uint32(e),e&&this._push(Rh,e,t),this};Ft._configure()});var Zh={};dt(Zh,{createClient:()=>Wh});var Vt=class extends Error{constructor(t="The operation was aborted"){super(t),this.code=Vt.code,this.type=Vt.type}static get code(){return"ABORT_ERR"}static get type(){return"aborted"}},E=class extends Error{constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var Yo=F($t("net"),1);var jt=$t("node:net");function yr(r){return!!(0,jt.isIP)(r)}var xn={};dt(xn,{identity:()=>Fu});function Nu(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var i=0;i<r.length;i++){var s=r.charAt(i),a=s.charCodeAt(0);if(e[a]!==255)throw new TypeError(s+" is ambiguous");e[a]=i}var f=r.length,l=r.charAt(0),d=Math.log(f)/Math.log(256),h=Math.log(256)/Math.log(f);function g(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var A=0,B=0,R=0,D=b.length;R!==D&&b[R]===0;)R++,A++;for(var V=(D-R)*h+1>>>0,q=new Uint8Array(V);R!==D;){for(var ft=b[R],ct=0,st=V-1;(ft!==0||ct<B)&&st!==-1;st--,ct++)ft+=256*q[st]>>>0,q[st]=ft%f>>>0,ft=ft/f>>>0;if(ft!==0)throw new Error("Non-zero carry");B=ct,R++}for(var at=V-B;at!==V&&q[at]===0;)at++;for(var At=l.repeat(A);at<V;++at)At+=r.charAt(q[at]);return At}function w(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var A=0;if(b[A]!==" "){for(var B=0,R=0;b[A]===l;)B++,A++;for(var D=(b.length-A)*d+1>>>0,V=new Uint8Array(D);b[A];){var q=e[b.charCodeAt(A)];if(q===255)return;for(var ft=0,ct=D-1;(q!==0||ft<R)&&ct!==-1;ct--,ft++)q+=f*V[ct]>>>0,V[ct]=q%256>>>0,q=q/256>>>0;if(q!==0)throw new Error("Non-zero carry");R=ft,A++}if(b[A]!==" "){for(var st=D-R;st!==D&&V[st]===0;)st++;for(var at=new Uint8Array(B+(D-st)),At=B;st!==D;)at[At++]=V[st++];return at}}}function x(b){var A=w(b);if(A)return A;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:w,decode:x}}var ku=Nu,Pu=ku,os=Pu;var tp=new Uint8Array(0);var cs=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0},wt=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 as=r=>new TextEncoder().encode(r),us=r=>new TextDecoder().decode(r);var En=class{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},vn=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return fs(this,t)}},Tn=class{constructor(t){this.decoders=t}or(t){return fs(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},fs=(r,t)=>new Tn({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Sn=class{constructor(t,e,n,i){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=i,this.encoder=new En(t,e,n),this.decoder=new vn(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},xe=({name:r,prefix:t,encode:e,decode:n})=>new Sn(r,t,e,n),Jt=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:i}=os(e,t);return xe({prefix:r,name:t,encode:n,decode:s=>wt(i(s))})},Ou=(r,t,e,n)=>{let i={};for(let h=0;h<t.length;++h)i[t[h]]=h;let s=r.length;for(;r[s-1]==="=";)--s;let a=new Uint8Array(s*e/8|0),f=0,l=0,d=0;for(let h=0;h<s;++h){let g=i[r[h]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|g,f+=e,f>=8&&(f-=8,a[d++]=255&l>>f)}if(f>=e||255&l<<8-f)throw new SyntaxError("Unexpected end of data");return a},Mu=(r,t,e)=>{let n=t[t.length-1]==="=",i=(1<<e)-1,s="",a=0,f=0;for(let l=0;l<r.length;++l)for(f=f<<8|r[l],a+=8;a>e;)a-=e,s+=t[i&f>>a];if(a&&(s+=t[i&f<<e-a]),n)for(;s.length*e&7;)s+="=";return s},U=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>xe({prefix:t,name:r,encode(i){return Mu(i,n,e)},decode(i){return Ou(i,n,e,r)}});var Fu=xe({prefix:"\0",name:"identity",encode:r=>us(r),decode:r=>as(r)});var An={};dt(An,{base2:()=>Uu});var Uu=U({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var In={};dt(In,{base8:()=>Gu});var Gu=U({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var _n={};dt(_n,{base10:()=>$u});var $u=Jt({prefix:"9",name:"base10",alphabet:"0123456789"});var Rn={};dt(Rn,{base16:()=>Vu,base16upper:()=>zu});var Vu=U({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),zu=U({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Cn={};dt(Cn,{base32:()=>Ct,base32hex:()=>qu,base32hexpad:()=>Zu,base32hexpadupper:()=>Xu,base32hexupper:()=>Wu,base32pad:()=>Yu,base32padupper:()=>Ku,base32upper:()=>Hu,base32z:()=>ju});var Ct=U({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Hu=U({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Yu=U({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ku=U({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),qu=U({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Wu=U({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Zu=U({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Xu=U({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ju=U({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Dn={};dt(Dn,{base36:()=>Ju,base36upper:()=>Qu});var Ju=Jt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Qu=Jt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Bn={};dt(Bn,{base58btc:()=>W,base58flickr:()=>tl});var W=Jt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),tl=Jt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Nn={};dt(Nn,{base64:()=>Ln,base64pad:()=>el,base64url:()=>rl,base64urlpad:()=>nl});var Ln=U({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),el=U({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),rl=U({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),nl=U({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var kn={};dt(kn,{base256emoji:()=>al});var hs=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}"),il=hs.reduce((r,t,e)=>(r[e]=t,r),[]),sl=hs.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function ol(r){return r.reduce((t,e)=>(t+=il[e],t),"")}function cl(r){let t=[];for(let e of r){let n=sl[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var al=xe({prefix:"\u{1F680}",name:"base256emoji",encode:ol,decode:cl});var Un={};dt(Un,{sha256:()=>wr,sha512:()=>_l});var Fn=F($t("crypto"),1);var ul=ms,ps=128,ll=127,fl=~ll,hl=Math.pow(2,31);function ms(r,t,e){t=t||[],e=e||0;for(var n=e;r>=hl;)t[e++]=r&255|ps,r/=128;for(;r&fl;)t[e++]=r&255|ps,r>>>=7;return t[e]=r|0,ms.bytes=e-n+1,t}var pl=Pn,dl=128,ds=127;function Pn(r,n){var e=0,n=n||0,i=0,s=n,a,f=r.length;do{if(s>=f)throw Pn.bytes=0,new RangeError("Could not decode varint");a=r[s++],e+=i<28?(a&ds)<<i:(a&ds)*Math.pow(2,i),i+=7}while(a>=dl);return Pn.bytes=s-n,e}var ml=Math.pow(2,7),gl=Math.pow(2,14),yl=Math.pow(2,21),bl=Math.pow(2,28),wl=Math.pow(2,35),El=Math.pow(2,42),vl=Math.pow(2,49),Tl=Math.pow(2,56),Sl=Math.pow(2,63),xl=function(r){return r<ml?1:r<gl?2:r<yl?3:r<bl?4:r<wl?5:r<El?6:r<vl?7:r<Tl?8:r<Sl?9:10},Al={encode:ul,decode:pl,encodingLength:xl},Il=Al,Ze=Il;var Xe=(r,t=0)=>[Ze.decode(r,t),Ze.decode.bytes],Ae=(r,t,e=0)=>(Ze.encode(r,t,e),t),Ie=r=>Ze.encodingLength(r);var Qt=(r,t)=>{let e=t.byteLength,n=Ie(r),i=n+Ie(e),s=new Uint8Array(i+e);return Ae(r,s,0),Ae(e,s,n),s.set(t,i),new _e(r,e,t,s)},ue=r=>{let t=wt(r),[e,n]=Xe(t),[i,s]=Xe(t.subarray(n)),a=t.subarray(n+s);if(a.byteLength!==i)throw new Error("Incorrect length");return new _e(e,i,a,t)},gs=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&cs(r.bytes,e.bytes)}},_e=class{constructor(t,e,n,i){this.code=t,this.size=e,this.digest=n,this.bytes=i}};var Mn=({name:r,code:t,encode:e})=>new On(r,t,e),On=class{constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Qt(this.code,e):e.then(n=>Qt(this.code,n))}else throw Error("Unknown type, must be binary type")}};var wr=Mn({name:"sha2-256",code:18,encode:r=>wt(Fn.default.createHash("sha256").update(r).digest())}),_l=Mn({name:"sha2-512",code:19,encode:r=>wt(Fn.default.createHash("sha512").update(r).digest())});var Gn={};dt(Gn,{identity:()=>Er});var bs=0,Rl="identity",ws=wt,Cl=r=>Qt(bs,ws(r)),Er={code:bs,name:Rl,encode:ws,digest:Cl};var Tp=new TextEncoder,Sp=new TextDecoder;var Es=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return Nl(e,$n(r),t||W.encoder);default:return kl(e,$n(r),t||Ct.encoder)}};var vs=new WeakMap,$n=r=>{let t=vs.get(r);if(t==null){let e=new Map;return vs.set(r,e),e}return t},k=class{constructor(t,e,n,i){this.code=e,this.version=t,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==je)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Pl)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return k.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Qt(t,e);return k.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return k.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&gs(t.multihash,n.multihash)}toString(t){return Es(this,t)}toJSON(){return{"/":Es(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof k)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:i,multihash:s,bytes:a}=e;return new k(n,i,s,a||Ts(n,i,s.bytes))}else if(e[Ol]===!0){let{version:n,multihash:i,code:s}=e,a=ue(i);return k.create(n,s,a)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==je)throw new Error(`Version 0 CID must use dag-pb (code: ${je}) block encoding`);return new k(t,e,n,n.bytes)}case 1:{let i=Ts(t,e,n.bytes);return new k(t,e,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return k.create(0,je,t)}static createV1(t,e){return k.create(1,t,e)}static decode(t){let[e,n]=k.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=k.inspectBytes(t),n=e.size-e.multihashSize,i=wt(t.subarray(n,n+e.multihashSize));if(i.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=i.subarray(e.multihashSize-e.digestSize),a=new _e(e.multihashCode,e.digestSize,s,i);return[e.version===0?k.createV0(a):k.createV1(e.codec,a),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[g,w]=Xe(t.subarray(e));return e+=w,g},i=n(),s=je;if(i===18?(i=0,e=0):s=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let a=e,f=n(),l=n(),d=e+l,h=d-a;return{version:i,codec:s,multihashCode:f,digestSize:l,multihashSize:h,size:d}}static parse(t,e){let[n,i]=Ll(t,e),s=k.decode(i);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return $n(s).set(n,t),s}},Ll=(r,t)=>{switch(r[0]){case"Q":{let e=t||W;return[W.prefix,e.decode(`${W.prefix}${r}`)]}case W.prefix:{let e=t||W;return[W.prefix,e.decode(r)]}case Ct.prefix:{let e=t||Ct;return[Ct.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},Nl=(r,t,e)=>{let{prefix:n}=e;if(n!==W.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let i=t.get(n);if(i==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return i},kl=(r,t,e)=>{let{prefix:n}=e,i=t.get(n);if(i==null){let s=e.encode(r);return t.set(n,s),s}else return i},je=112,Pl=18,Ts=(r,t,e)=>{let n=Ie(r),i=n+Ie(t),s=new Uint8Array(i+e.byteLength);return Ae(r,s,0),Ae(t,s,n),s.set(e,i),s},Ol=Symbol.for("@ipld/js-cid/CID");var te={...xn,...An,...In,..._n,...Rn,...Cn,...Dn,...Bn,...Nn,...kn},Np={...Un,...Gn};function fe(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function zt(r=0){return globalThis.Buffer?.alloc!=null?fe(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function Dt(r=0){return globalThis.Buffer?.allocUnsafe!=null?fe(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function xs(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Ss=xs("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Vn=xs("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=Dt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Ml={utf8:Ss,"utf-8":Ss,hex:te.base16,latin1:Vn,ascii:Vn,binary:Vn,...te},vr=Ml;function ut(r,t="utf8"){let e=vr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}var As=jt.isIPv4,Fl=jt.isIPv6,zn=function(r){let t=0;if(r=r.toString().trim(),As(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Fl(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=As(e[n]),a;s&&(a=zn(e[n]),e[n]=ut(a.slice(0,2),"base16")),a!=null&&++n<8&&e.splice(n,0,ut(a.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let i=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);i[t++]=s>>8&255,i[t++]=s&255}return i}throw new Error("invalid ip address")},Is=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let i=[];for(let s=0;s<e;s++)i.push(r[t+s]);return i.join(".")}if(e===16){let i=[];for(let s=0;s<e;s+=2)i.push(n.getUint16(t+s).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Je={},Hn={},Gl=[[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"]];Gl.forEach(r=>{let t=$l(...r);Hn[t.code]=t,Je[t.name]=t});function $l(r,t,e,n,i){return{code:r,size:t,name:e,resolvable:!!n,path:!!i}}function P(r){if(typeof r=="number"){if(Hn[r]!=null)return Hn[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Je[r]!=null)return Je[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Ot=F(Tr(),1);function qn(r,t="utf8"){let e=vr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?fe(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function Et(r,t){t==null&&(t=r.reduce((i,s)=>i+s.length,0));let e=Dt(t),n=0;for(let i of r)e.set(i,n),n+=i.length;return fe(e)}var Sr=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,i){return this.readAtomically(()=>{let s=0,a=0,f=this.peekChar();if(f===void 0)return;let l=f==="0",d=2**(8*i)-1;for(;;){let h=this.readAtomically(()=>{let g=this.readChar();if(g===void 0)return;let w=Number.parseInt(g,t);if(!Number.isNaN(w))return w});if(h===void 0)break;if(s*=t,s+=h,s>d||(a+=1,e!==void 0&&a>e))return}if(a!==0)return!n&&l&&a>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let i=n*2;if(n<e.length-3){let a=this.readSeparator(":",n,()=>this.readIPv4Addr());if(a!==void 0)return e[i]=a[0],e[i+1]=a[1],e[i+2]=a[2],e[i+3]=a[3],[i+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[i,!1];e[i]=s>>8,e[i+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,i]=t(e);if(n===16)return e;if(i||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),a=16-(n+2),[f]=t(s.subarray(0,a));return e.set(s.subarray(0,f),16-f),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var sd=new Sr;var pd=parseInt("0xFFFF",16),dd=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var qd=P("ip4"),Wd=P("ip6"),Zd=P("ipcidr");function Vs(r,t){switch(P(r).code){case 4:case 41:return af(t);case 42:return Gs(t);case 6:case 273:case 33:case 132:return Hs(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Gs(t);case 421:return hf(t);case 444:return $s(t);case 445:return $s(t);case 466:return ff(t);default:return ut(t,"base16")}}function zs(r,t){switch(P(r).code){case 4:return Fs(t);case 41:return Fs(t);case 42:return Us(t);case 6:case 273:case 33:case 132:return Zn(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Us(t);case 421:return uf(t);case 444:return pf(t);case 445:return df(t);case 466:return lf(t);default:return qn(t,"base16")}}var Wn=Object.values(te).map(r=>r.decoder),cf=function(){let r=Wn[0].or(Wn[1]);return Wn.slice(2).forEach(t=>r=r.or(t)),r}();function Fs(r){if(!yr(r))throw new Error("invalid ip address");return zn(r)}function af(r){let t=Is(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!yr(t))throw new Error("invalid ip address");return t}function Zn(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Hs(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Us(r){let t=qn(r),e=Uint8Array.from(Ot.default.encode(t.length));return Et([e,t],e.length+t.length)}function Gs(r){let t=Ot.default.decode(r);if(r=r.slice(Ot.default.decode.bytes),r.length!==t)throw new Error("inconsistent lengths");return ut(r)}function uf(r){let t;r[0]==="Q"||r[0]==="1"?t=ue(W.decode(`z${r}`)).bytes:t=k.parse(r).multihash.bytes;let e=Uint8Array.from(Ot.default.encode(t.length));return Et([e,t],e.length+t.length)}function lf(r){let t=cf.decode(r),e=Uint8Array.from(Ot.default.encode(t.length));return Et([e,t],e.length+t.length)}function ff(r){let t=Ot.default.decode(r),e=r.slice(Ot.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return"u"+ut(e,"base64url")}function hf(r){let t=Ot.default.decode(r),e=r.slice(Ot.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return ut(e,"base58btc")}function pf(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Ct.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=Zn(n);return Et([e,i],e.length+i.length)}function df(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Ct.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=Zn(n);return Et([e,i],e.length+i.length)}function $s(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=ut(t,"base32"),i=Hs(e);return`${n}:${i}`}var Re=F(Tr(),1);function mf(r){let t=[],e=r.split("/").slice(1);if(e.length===1&&e[0]==="")return[];for(let n=0;n<e.length;n++){let i=e[n],s=P(i);if(s.size===0){t.push([i]);continue}if(n++,n>=e.length)throw Ks("invalid address: "+r);if(s.path===!0){t.push([i,ti(e.slice(n).join("/"))]);break}t.push([i,e[n]])}return t}function gf(r){let t=[];return r.map(e=>{let n=Ir(e);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),ti(t.join("/"))}function yf(r){return r.map(t=>{Array.isArray(t)||(t=[t]);let e=Ir(t);return t.length>1?[e.code,zs(e.code,t[1])]:[e.code]})}function Xn(r){return r.map(t=>{let e=Ir(t);return t[1]!=null?[e.code,Vs(e.code,t[1])]:[e.code]})}function jn(r){return Ar(Et(r.map(t=>{let e=Ir(t),n=Uint8Array.from(Re.default.encode(e.code));return t.length>1&&t[1]!=null&&(n=Et([n,t[1]])),n})))}function Jn(r,t){return r.size>0?r.size/8:r.size===0?0:Re.default.decode(t)+(Re.default.decode.bytes??0)}function xr(r){let t=[],e=0;for(;e<r.length;){let n=Re.default.decode(r,e),i=Re.default.decode.bytes??0,s=P(n),a=Jn(s,r.slice(e+i));if(a===0){t.push([n]),e+=i;continue}let f=r.slice(e+i,e+i+a);if(e+=a+i,e>r.length)throw Ks("Invalid address Uint8Array: "+ut(r,"base16"));t.push([n,f])}return t}function Qn(r){let t=xr(r),e=Xn(t);return gf(e)}function bf(r){r=ti(r);let t=mf(r),e=yf(t);return jn(e)}function Ys(r){return bf(r)}function Ar(r){let t=wf(r);if(t!=null)throw t;return Uint8Array.from(r)}function wf(r){try{xr(r)}catch(t){return t}}function ti(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Ks(r){return new Error("Error parsing address: "+r)}function Ir(r){return P(r[0])}var ni=F(Tr(),1);var Xs=F(ei(),1);function he(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var Ce=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},ri=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},Qe,tr,er,Zs,Tf=Symbol.for("nodejs.util.inspect.custom"),Sf=[P("dns").code,P("dns4").code,P("dns6").code,P("dnsaddr").code],xf=new Map,js=Symbol.for("@multiformats/js-multiaddr/multiaddr");function ii(r){return!!r?.[js]}var Ht=class{constructor(t){if(Qe.set(this,void 0),tr.set(this,void 0),er.set(this,void 0),this[Zs]=!0,t==null&&(t=""),t instanceof Uint8Array)this.bytes=Ar(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=Ys(t)}else if(ii(t))this.bytes=Ar(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return Ce(this,Qe,"f")==null&&ri(this,Qe,Qn(this.bytes),"f"),Ce(this,Qe,"f")}toJSON(){return this.toString()}toOptions(){let t,e,n,i,s="",a=P("tcp"),f=P("udp"),l=P("ip4"),d=P("ip6"),h=P("dns6"),g=P("ip6zone");for(let[x,b]of this.stringTuples())x===g.code&&(s=`%${b??""}`),Sf.includes(x)&&(e=a.name,i=443,n=`${b??""}${s}`,t=x===h.code?6:4),(x===a.code||x===f.code)&&(e=P(x).name,i=parseInt(b??"")),(x===l.code||x===d.code)&&(e=P(x).name,n=`${b??""}${s}`,t=x===d.code?6:4);if(t==null||e==null||n==null||i==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:i}}protos(){return this.protoCodes().map(t=>Object.assign({},P(t)))}protoCodes(){let t=[],e=this.bytes,n=0;for(;n<e.length;){let i=ni.default.decode(e,n),s=ni.default.decode.bytes??0,a=P(i),f=Jn(a,e.slice(n+s));n+=f+s,t.push(i)}return t}protoNames(){return this.protos().map(t=>t.name)}tuples(){return Ce(this,tr,"f")==null&&ri(this,tr,xr(this.bytes),"f"),Ce(this,tr,"f")}stringTuples(){return Ce(this,er,"f")==null&&ri(this,er,Xn(this.tuples()),"f"),Ce(this,er,"f")}encapsulate(t){return t=new Ht(t),new Ht(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),i=n.lastIndexOf(e);if(i<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new Ht(n.slice(0,i))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new Ht(jn(e.slice(0,n)));return this}getPeerId(){try{let e=this.stringTuples().filter(n=>n[0]===Je.ipfs.code).pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?ut(W.decode(`z${n}`),"base58btc"):ut(k.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let t=null;try{t=this.stringTuples().filter(e=>P(e[0]).path===!0)[0][1],t==null&&(t=null)}catch{t=null}return t}equals(t){return he(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=xf.get(e.name);if(n==null)throw(0,Xs.default)(new Error(`no available resolver for ${e.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(s=>new Ht(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[(Qe=new WeakMap,tr=new WeakMap,er=new WeakMap,Zs=js,Tf)](){return`Multiaddr(${Qn(this.bytes)})`}};function tt(r){return new Ht(r)}var Af=S("dns4"),If=S("dns6"),_f=S("dnsaddr"),pe=Z(S("dns"),_f,Af,If),_r=Z(S("ip4"),S("ip6")),re=Z(_(_r,S("tcp")),_(pe,S("tcp"))),Rr=_(_r,S("udp")),Rf=_(Rr,S("utp")),Cf=_(Rr,S("quic")),Df=_(Rr,S("quic-v1")),rr=Z(_(re,S("ws")),_(pe,S("ws"))),nr=Z(_(re,S("wss")),_(pe,S("wss")),_(re,S("tls"),S("ws")),_(pe,S("tls"),S("ws"))),si=Z(_(re,S("http")),_(_r,S("http")),_(pe,S("http"))),oi=Z(_(re,S("https")),_(_r,S("https")),_(pe,S("https"))),Js=_(Rr,S("webrtc-direct"),S("certhash")),eo=Z(_(Js,S("p2p")),Js),Qs=_(Df,S("webtransport"),S("certhash"),S("certhash")),ro=Z(_(Qs,S("p2p")),Qs),no=Z(_(rr,S("p2p-webrtc-star"),S("p2p")),_(nr,S("p2p-webrtc-star"),S("p2p")),_(rr,S("p2p-webrtc-star")),_(nr,S("p2p-webrtc-star"))),gm=Z(_(rr,S("p2p-websocket-star"),S("p2p")),_(nr,S("p2p-websocket-star"),S("p2p")),_(rr,S("p2p-websocket-star")),_(nr,S("p2p-websocket-star"))),io=Z(_(si,S("p2p-webrtc-direct"),S("p2p")),_(oi,S("p2p-webrtc-direct"),S("p2p")),_(si,S("p2p-webrtc-direct")),_(oi,S("p2p-webrtc-direct"))),Be=Z(rr,nr,si,oi,no,io,re,Rf,Cf,pe,eo,ro),ym=Z(_(Be,S("p2p-stardust"),S("p2p")),_(Be,S("p2p-stardust"))),ee=Z(_(Be,S("p2p")),no,io,eo,ro,S("p2p")),to=Z(_(ee,S("p2p-circuit"),ee),_(ee,S("p2p-circuit")),_(S("p2p-circuit"),ee),_(Be,S("p2p-circuit")),_(S("p2p-circuit"),Be),S("p2p-circuit")),so=()=>Z(_(to,so),to),De=so(),bm=Z(_(De,ee,De),_(ee,De),_(De,ee),De,ee);var wm=Z(_(De,S("webrtc")),_(Be,S("webrtc")),S("webrtc"));function oo(r){function t(e){let n;try{n=tt(e)}catch{return!1}let i=r(n.protoNames());return i===null?!1:i===!0||i===!1?i:i.length===0}return t}function _(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(i=>(n=typeof i=="function"?i().partialMatch(e):i.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:oo(t),partialMatch:t}}function Z(...r){function t(n){let i=null;return r.some(s=>{let a=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return a!=null?(i=a,!0):!1}),i}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:oo(t),partialMatch:t}}function S(r){let t=r;function e(i){let s;try{s=tt(i)}catch{return!1}let a=s.protoNames();return a.length===1&&a[0]===t}function n(i){return i.length===0?null:i[0]===t?i.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var vt=F(bo(),1);vt.default.formatters.b=r=>r==null?"undefined":W.baseEncode(r);vt.default.formatters.t=r=>r==null?"undefined":Ct.baseEncode(r);vt.default.formatters.m=r=>r==null?"undefined":Ln.baseEncode(r);vt.default.formatters.p=r=>r==null?"undefined":r.toString();vt.default.formatters.c=r=>r==null?"undefined":r.toString();vt.default.formatters.k=r=>r==null?"undefined":r.toString();function eh(r){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=r,t.destroy=()=>!0,t.extend=()=>t,t}function Tt(r){let t=eh(`${r}:trace`);return vt.default.enabled(`${r}:trace`)&&vt.default.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=(0,vt.default)(`${r}:trace`)),Object.assign((0,vt.default)(r),{error:(0,vt.default)(`${r}:error`),trace:t})}var $o=F(Io(),1);function kr(r){return this.subnetMask<r.subnetMask?!1:this.mask(r.subnetMask)===r.mask()}function Pr(r){return function(){return this.addressMinusSuffix!==this.correctForm()?!1:this.subnetMask===r&&!this.parsedSubnet?!0:this.parsedSubnet===String(this.subnetMask)}}var Me=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g,hi=/\/\d{1,2}$/;var rt=class extends Error{constructor(t,e){super(t),this.name="AddressError",e!==null&&(this.parseMessage=e)}};var Fe=F(pi(),1),me=F(ir(),1),M=class{constructor(t){this.groups=4,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=Pr(32),this.isInSubnet=kr,this.address=t;let e=hi.exec(t);if(e){if(this.parsedSubnet=e[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,this.subnetMask<0||this.subnetMask>32)throw new rt("Invalid subnet mask.");t=t.replace(hi,"")}this.addressMinusSuffix=t,this.parsedAddress=this.parse(t)}static isValid(t){try{return new M(t),!0}catch{return!1}}parse(t){let e=t.split(".");if(!t.match(Me))throw new rt("Invalid IPv4 address.");return e}correctForm(){return this.parsedAddress.map(t=>parseInt(t,10)).join(".")}static fromHex(t){let e=t.replace(/:/g,"").padStart(8,"0"),n=[],i;for(i=0;i<8;i+=2){let s=e.slice(i,i+2);n.push(parseInt(s,16))}return new M(n.join("."))}static fromInteger(t){return M.fromHex(t.toString(16))}static fromArpa(t){let n=t.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join(".");return new M(n)}toHex(){return this.parsedAddress.map(t=>(0,me.sprintf)("%02x",parseInt(t,10))).join(":")}toArray(){return this.parsedAddress.map(t=>parseInt(t,10))}toGroup6(){let t=[],e;for(e=0;e<4;e+=2){let n=(0,me.sprintf)("%02x%02x",parseInt(this.parsedAddress[e],10),parseInt(this.parsedAddress[e+1],10));t.push((0,me.sprintf)("%x",parseInt(n,16)))}return t.join(":")}bigInteger(){return new Fe.BigInteger(this.parsedAddress.map(t=>(0,me.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new Fe.BigInteger(this.mask()+"0".repeat(32-this.subnetMask),2)}startAddress(){return M.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new Fe.BigInteger("1");return M.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new Fe.BigInteger(this.mask()+"1".repeat(32-this.subnetMask),2)}endAddress(){return M.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new Fe.BigInteger("1");return M.fromBigInteger(this._endAddress().subtract(t))}static fromBigInteger(t){return M.fromInteger(parseInt(t.toString(),10))}mask(t){return t===void 0&&(t=this.subnetMask),this.getBitsBase2(0,t)}getBitsBase2(t,e){return this.binaryZeroPad().slice(t,e)}reverseForm(t){t||(t={});let e=this.correctForm().split(".").reverse().join(".");return t.omitSuffix?e:(0,me.sprintf)("%s.in-addr.arpa.",e)}isMulticast(){return this.isInSubnet(new M("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(32,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(Me,(0,me.sprintf)('<span class="hover-group group-v4 group-6">%s</span>.<span class="hover-group group-v4 group-7">%s</span>',t.slice(0,2).join("."),t.slice(2,4).join(".")))}};var Bo={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},di={"ff01::1/128":"Multicast (All nodes on this interface)","ff01::2/128":"Multicast (All routers on this interface)","ff02::1/128":"Multicast (All nodes on this link)","ff02::2/128":"Multicast (All routers on this link)","ff05::2/128":"Multicast (All routers in this site)","ff02::5/128":"Multicast (OSPFv3 AllSPF routers)","ff02::6/128":"Multicast (OSPFv3 AllDR routers)","ff02::9/128":"Multicast (RIP routers)","ff02::a/128":"Multicast (EIGRP routers)","ff02::d/128":"Multicast (PIM routers)","ff02::16/128":"Multicast (MLDv2 reports)","ff01::fb/128":"Multicast (mDNSv6)","ff02::fb/128":"Multicast (mDNSv6)","ff05::fb/128":"Multicast (mDNSv6)","ff02::1:2/128":"Multicast (All DHCP servers and relay agents on this link)","ff05::1:2/128":"Multicast (All DHCP servers and relay agents in this site)","ff02::1:3/128":"Multicast (All DHCP servers on this link)","ff05::1:3/128":"Multicast (All DHCP servers in this site)","::/128":"Unspecified","::1/128":"Loopback","ff00::/8":"Multicast","fe80::/10":"Link-local unicast"},mi=/([^0-9a-f:/%])/gi,gi=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,yi=/\/\d{1,3}(?=%|$)/,bi=/%.*$/,Lo=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),No=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);var Po=F(ir(),1);function oh(r){return r.replace(/^(0+)/,'<span class="zero">$1</span>')}function Fr(r,t=0){return r.split(":").map((n,i)=>/group-v4/.test(n)?n:(0,Po.sprintf)('<span class="hover-group group-%d">%s</span>',i+t,oh(n)))}var ye=F(ir(),1);function Ei(r){return(0,ye.sprintf)("(%s)",r.join("|"))}function wi(r){return r.length<4?(0,ye.sprintf)("0{0,%d}%s",4-r.length,r):r}var vi="[^A-Fa-f0-9:]";function Ur(r){let t=[];r.forEach((n,i)=>{parseInt(n,16)===0&&t.push(i)});let e=t.map(n=>r.map((i,s)=>{if(s===n){let a=s===0||s===8-1?":":"";return Ei([wi(i),a])}return wi(i)}).join(":"));return e.push(r.map(wi).join(":")),Ei(e)}function Ti(r,t,e){let n=t?"":":",i=e?"":":",s=[];!t&&!e&&s.push("::"),t&&e&&s.push(""),(e&&!t||!e&&t)&&s.push(":"),s.push((0,ye.sprintf)("%s(:0{1,4}){1,%d}",n,r-1)),s.push((0,ye.sprintf)("(0{1,4}:){1,%d}%s",r-1,i)),s.push((0,ye.sprintf)("(0{1,4}:){%d}0{1,4}",r-1));for(let a=1;a<r-1;a++)for(let f=1;f<r-a;f++)s.push((0,ye.sprintf)("(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}",f,r-f-a-1));return Ei(s)}var nt=F(pi(),1),it=F(ir(),1);function Gr(r){if(!r)throw new Error("Assertion failed.")}function ch(r){let t=/(\d+)(\d{3})/;for(;t.test(r);)r=r.replace(t,"$1,$2");return r}function ah(r){return r=r.replace(/^(0{1,})([1-9]+)$/,'<span class="parse-error">$1</span>$2'),r=r.replace(/^(0{1,})(0)$/,'<span class="parse-error">$1</span>$2'),r}function uh(r,t){let e=[],n=[],i;for(i=0;i<r.length;i++)i<t[0]?e.push(r[i]):i>t[1]&&n.push(r[i]);return e.concat(["compact"]).concat(n)}function Mo(r){return(0,it.sprintf)("%04x",parseInt(r,16))}function Fo(r){return r&255}var G=class{constructor(t,e){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=kr,this.isCorrect=Pr(128),e===void 0?this.groups=8:this.groups=e,this.address=t;let n=yi.exec(t);if(n){if(this.parsedSubnet=n[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,Number.isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>128)throw new rt("Invalid subnet mask.");t=t.replace(yi,"")}else if(/\//.test(t))throw new rt("Invalid subnet mask.");let i=bi.exec(t);i&&(this.zone=i[0],t=t.replace(bi,"")),this.addressMinusSuffix=t,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new G(t),!0}catch{return!1}}static fromBigInteger(t){let e=t.toString(16).padStart(32,"0"),n=[],i;for(i=0;i<8;i++)n.push(e.slice(i*4,(i+1)*4));return new G(n.join(":"))}static fromURL(t){let e,n=null,i;if(t.indexOf("[")!==-1&&t.indexOf("]:")!==-1){if(i=No.exec(t),i===null)return{error:"failed to parse address with port",address:null,port:null};e=i[1],n=i[2]}else if(t.indexOf("/")!==-1){if(t=t.replace(/^[a-z0-9]+:\/\//,""),i=Lo.exec(t),i===null)return{error:"failed to parse address from URL",address:null,port:null};e=i[1]}else e=t;return n?(n=parseInt(n,10),(n<0||n>65536)&&(n=null)):n=null,{address:new G(e),port:n}}static fromAddress4(t){let e=new M(t),n=128-(32-e.subnetMask);return new G(`::ffff:${e.correctForm()}/${n}`)}static fromArpa(t){let e=t.replace(/(\.ip6\.arpa)?\.$/,""),n=7;if(e.length!==63)throw new rt("Invalid 'ip6.arpa' form.");let i=e.split(".").reverse();for(let s=n;s>0;s--){let a=s*4;i.splice(a,0,":")}return e=i.join(""),new G(e)}microsoftTranscription(){return(0,it.sprintf)("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))}mask(t=this.subnetMask){return this.getBitsBase2(0,t)}possibleSubnets(t=128){let e=128-this.subnetMask,n=Math.abs(t-128),i=e-n;return i<0?"0":ch(new nt.BigInteger("2",10).pow(i).toString(10))}_startAddress(){return new nt.BigInteger(this.mask()+"0".repeat(128-this.subnetMask),2)}startAddress(){return G.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new nt.BigInteger("1");return G.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new nt.BigInteger(this.mask()+"1".repeat(128-this.subnetMask),2)}endAddress(){return G.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new nt.BigInteger("1");return G.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=Bo[this.getBits(12,16).intValue()];return this.getType()==="Global unicast"&&t!=="Link local"&&(t="Global"),t||"Unknown"}getType(){for(let t of Object.keys(di))if(this.isInSubnet(new G(t)))return di[t];return"Global unicast"}getBits(t,e){return new nt.BigInteger(this.getBitsBase2(t,e),2)}getBitsBase2(t,e){return this.binaryZeroPad().slice(t,e)}getBitsBase16(t,e){let n=e-t;if(n%4!==0)throw new Error("Length of bits to retrieve must be divisible by four");return this.getBits(t,e).toString(16).padStart(n/4,"0")}getBitsPastSubnet(){return this.getBitsBase2(this.subnetMask,128)}reverseForm(t){t||(t={});let e=Math.floor(this.subnetMask/4),n=this.canonicalForm().replace(/:/g,"").split("").slice(0,e).reverse().join(".");return e>0?t.omitSuffix?n:(0,it.sprintf)("%s.ip6.arpa.",n):t.omitSuffix?"":"ip6.arpa."}correctForm(){let t,e=[],n=0,i=[];for(t=0;t<this.parsedAddress.length;t++){let f=parseInt(this.parsedAddress[t],16);f===0&&n++,f!==0&&n>0&&(n>1&&i.push([t-n,t-1]),n=0)}n>1&&i.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let s=i.map(f=>f[1]-f[0]+1);if(i.length>0){let f=s.indexOf(Math.max(...s));e=uh(this.parsedAddress,i[f])}else e=this.parsedAddress;for(t=0;t<e.length;t++)e[t]!=="compact"&&(e[t]=parseInt(e[t],16).toString(16));let a=e.join(":");return a=a.replace(/^compact$/,"::"),a=a.replace(/^compact|compact$/,":"),a=a.replace(/compact/,""),a}binaryZeroPad(){return this.bigInteger().toString(2).padStart(128,"0")}parse4in6(t){let e=t.split(":"),i=e.slice(-1)[0].match(Me);if(i){this.parsedAddress4=i[0],this.address4=new M(this.parsedAddress4);for(let s=0;s<this.address4.groups;s++)if(/^0[0-9]+/.test(this.address4.parsedAddress[s]))throw new rt("IPv4 addresses can't have leading zeroes.",t.replace(Me,this.address4.parsedAddress.map(ah).join(".")));this.v4=!0,e[e.length-1]=this.address4.toGroup6(),t=e.join(":")}return t}parse(t){t=this.parse4in6(t);let e=t.match(mi);if(e)throw new rt((0,it.sprintf)("Bad character%s detected in address: %s",e.length>1?"s":"",e.join("")),t.replace(mi,'<span class="parse-error">$1</span>'));let n=t.match(gi);if(n)throw new rt((0,it.sprintf)("Address failed regex: %s",n.join("")),t.replace(gi,'<span class="parse-error">$1</span>'));let i=[],s=t.split("::");if(s.length===2){let a=s[0].split(":"),f=s[1].split(":");a.length===1&&a[0]===""&&(a=[]),f.length===1&&f[0]===""&&(f=[]);let l=this.groups-(a.length+f.length);if(!l)throw new rt("Error parsing groups");this.elidedGroups=l,this.elisionBegin=a.length,this.elisionEnd=a.length+this.elidedGroups,i=i.concat(a);for(let d=0;d<l;d++)i.push("0");i=i.concat(f)}else if(s.length===1)i=t.split(":"),this.elidedGroups=0;else throw new rt("Too many :: groups found");if(i=i.map(a=>(0,it.sprintf)("%x",parseInt(a,16))),i.length!==this.groups)throw new rt("Incorrect number of groups found");return i}canonicalForm(){return this.parsedAddress.map(Mo).join(":")}decimal(){return this.parsedAddress.map(t=>(0,it.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new nt.BigInteger(this.parsedAddress.map(Mo).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return M.fromHex(new nt.BigInteger(t.slice(96,128).join(""),2).toString(16))}to4in6(){let t=this.to4(),n=new G(this.parsedAddress.slice(0,6).join(":"),6).correctForm(),i="";return/:$/.test(n)||(i=":"),n+i+t.address}inspectTeredo(){let t=this.getBitsBase16(0,32),e=this.getBits(80,96).xor(new nt.BigInteger("ffff",16)).toString(),n=M.fromHex(this.getBitsBase16(32,64)),i=M.fromHex(this.getBits(96,128).xor(new nt.BigInteger("ffffffff",16)).toString(16)),s=this.getBits(64,80),a=this.getBitsBase2(64,80),f=s.testBit(15),l=s.testBit(14),d=s.testBit(8),h=s.testBit(9),g=new nt.BigInteger(a.slice(2,6)+a.slice(8,16),2).toString(10);return{prefix:(0,it.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:i.address,flags:a,coneNat:f,microsoft:{reserved:l,universalLocal:h,groupIndividual:d,nonce:g},udpPort:e}}inspect6to4(){let t=this.getBitsBase16(0,16),e=M.fromHex(this.getBitsBase16(16,48));return{prefix:(0,it.sprintf)("%s",t.slice(0,4)),gateway:e.address}}to6to4(){if(!this.is4())return null;let t=["2002",this.getBitsBase16(96,112),this.getBitsBase16(112,128),"","/16"].join(":");return new G(t)}toByteArray(){let t=this.bigInteger().toByteArray();return t.length===17&&t[0]===0?t.slice(1):t}toUnsignedByteArray(){return this.toByteArray().map(Fo)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(Fo))}static fromUnsignedByteArray(t){let e=new nt.BigInteger("256",10),n=new nt.BigInteger("0",10),i=new nt.BigInteger("1",10);for(let s=t.length-1;s>=0;s--)n=n.add(i.multiply(new nt.BigInteger(t[s].toString(10),10))),i=i.multiply(e);return G.fromBigInteger(n)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){return this.getBitsBase2(0,64)==="1111111010000000000000000000000000000000000000000000000000000000"}isMulticast(){return this.getType()==="Multicast"}is4(){return this.v4}isTeredo(){return this.isInSubnet(new G("2001::/32"))}is6to4(){return this.isInSubnet(new G("2002::/16"))}isLoopback(){return this.getType()==="Loopback"}href(t){return t===void 0?t="":t=(0,it.sprintf)(":%s",t),(0,it.sprintf)("http://[%s]%s/",this.correctForm(),t)}link(t){t||(t={}),t.className===void 0&&(t.className=""),t.prefix===void 0&&(t.prefix="/#address="),t.v4===void 0&&(t.v4=!1);let e=this.correctForm;return t.v4&&(e=this.to4in6),t.className?(0,it.sprintf)('<a href="%1$s%2$s" class="%3$s">%2$s</a>',t.prefix,e.call(this),t.className):(0,it.sprintf)('<a href="%1$s%2$s">%2$s</a>',t.prefix,e.call(this))}group(){if(this.elidedGroups===0)return Fr(this.address).join(":");Gr(typeof this.elidedGroups=="number"),Gr(typeof this.elisionBegin=="number");let t=[],[e,n]=this.address.split("::");e.length?t.push(...Fr(e)):t.push("");let i=["hover-group"];for(let s=this.elisionBegin;s<this.elisionBegin+this.elidedGroups;s++)i.push((0,it.sprintf)("group-%d",s));return t.push((0,it.sprintf)('<span class="%s"></span>',i.join(" "))),n.length?t.push(...Fr(n,this.elisionEnd)):t.push(""),this.is4()&&(Gr(this.address4 instanceof M),t.pop(),t.push(this.address4.groupForV6())),t.join(":")}regularExpressionString(t=!1){let e=[],n=new G(this.correctForm());if(n.elidedGroups===0)e.push(Ur(n.parsedAddress));else if(n.elidedGroups===8)e.push(Ti(8));else{let i=n.address.split("::");i[0].length&&e.push(Ur(i[0].split(":"))),Gr(typeof n.elidedGroups=="number"),e.push(Ti(n.elidedGroups,i[0].length!==0,i[1].length!==0)),i[1].length&&e.push(Ur(i[1].split(":"))),e=[e.join(":")]}return t||(e=["(?=^|",vi,"|[^\\w\\:])(",...e,")(?=[^\\w\\:]|",vi,"|$)"]),e.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};var lh=Tt("libp2p:ip-port-to-multiaddr"),Si={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function Uo(r,t){if(typeof r!="string")throw new E(`invalid ip provided: ${r}`,Si.ERR_INVALID_IP_PARAMETER);if(typeof t=="string"&&(t=parseInt(t)),isNaN(t))throw new E(`invalid port provided: ${t}`,Si.ERR_INVALID_PORT_PARAMETER);try{return new M(r),tt(`/ip4/${r}/tcp/${t}`)}catch{}try{let e=new G(r);return e.is4()?tt(`/ip4/${e.to4().correctForm()}/tcp/${t}`):tt(`/ip6/${r}/tcp/${t}`)}catch{let n=`invalid ip:port for creating a multiaddr: ${r}:${t}`;throw lh.error(n),new E(n,Si.ERR_INVALID_IP)}}var xi=F($t("os"),1),Go=F($t("path"),1),fh={ip4:"IPv4",ip6:"IPv6"};function Ge(r){let t=r.getPath();return t!=null?xi.default.platform()==="win32"?{path:Go.default.join("\\\\.\\pipe\\",t)}:{path:t}:r.toOptions()}function Ai(r,t,e){let n=i=>tt(`/${r}/${i}/tcp/${e}`);return(hh(t)?dh(fh[r]):[t]).map(n)}function hh(r){return["0.0.0.0","::"].includes(r)}var ph=xi.default.networkInterfaces();function dh(r){let t=[];for(let[,e]of Object.entries(ph))if(e!=null)for(let n of e)n.family===r&&t.push(n.address);return t}var Lt=Tt("libp2p:tcp:socket"),$r=(r,t)=>{let e=t.metrics,n=t.metricPrefix??"",i=t.socketInactivityTimeout??3e5,s=t.socketCloseTimeout??2e3;t.listeningAddr?.getPath()!=null&&(t.remoteAddr=t.listeningAddr),t.remoteAddr?.getPath()!=null&&(t.localAddr=t.remoteAddr);let a;if(t.remoteAddr!=null)a=t.remoteAddr;else{if(r.remoteAddress==null||r.remotePort==null)throw new E("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");a=Uo(r.remoteAddress,r.remotePort)}let f=Ge(a),l=f.path??`${f.host??""}:${f.port??""}`,{sink:d,source:h}=$o.default.duplex(r);r.setTimeout(i,()=>{Lt("%s socket read timeout",l),e?.increment({[`${n}timeout`]:!0});let w;r.readable&&(w=new E("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),r.destroy(w)}),r.once("close",()=>{Lt("%s socket close",l),e?.increment({[`${n}close`]:!0}),g.timeline.close==null&&(g.timeline.close=Date.now())}),r.once("end",()=>{Lt("%s socket end",l),e?.increment({[`${n}end`]:!0})});let g={async sink(w){try{await d(w)}catch(x){x.type!=="aborted"&&Lt(x)}r.end()},source:h,remoteAddr:a,timeline:{open:Date.now()},async close(){if(r.destroyed){Lt("%s socket was already destroyed when trying to close",l);return}Lt("%s closing socket",l),await new Promise((w,x)=>{let b=Date.now(),A=setTimeout(()=>{r.destroyed?(Lt("%s is already destroyed",l),w()):(Lt("%s socket close timeout after %dms, destroying it manually",l,Date.now()-b),r.destroy(new E("Socket close timeout","ERR_SOCKET_CLOSE_TIMEOUT")))},s).unref();r.once("close",()=>{Lt("%s socket closed",l),clearTimeout(A),w()}),r.once("error",B=>{Lt("%s socket error",l,B),g.timeline.close==null&&(g.timeline.close=Date.now()),r.destroyed&&clearTimeout(A),x(B)}),r.setTimeout(s),r.end(),r.writableLength>0?r.once("drain",()=>{Lt("%s socket drained",l),r.destroy()}):r.destroy()})}};return g};var Vo=F($t("net"),1);var be=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Kt,Vr=class extends EventTarget{constructor(){super(...arguments),Kt.set(this,new Map)}listenerCount(t){let e=be(this,Kt,"f").get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let i=be(this,Kt,"f").get(t);i==null&&(i=[],be(this,Kt,"f").set(t,i)),i.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let i=be(this,Kt,"f").get(t);i!=null&&(i=i.filter(({callback:s})=>s!==e),be(this,Kt,"f").set(t,i))}dispatchEvent(t){let e=super.dispatchEvent(t),n=be(this,Kt,"f").get(t.type);return n==null||(n=n.filter(({once:i})=>!i),be(this,Kt,"f").set(t.type,n)),e}safeDispatchEvent(t,e){return this.dispatchEvent(new $e(t,e))}};Kt=new WeakMap;var Ii=class extends Event{constructor(t,e){super(t,e),this.detail=e?.detail}},$e=globalThis.CustomEvent??Ii;var gt=Tt("libp2p:tcp:listener");async function _i(r){try{await r.close()}catch(t){gt.error("an error occurred closing the connection",t)}}var yh=1,bh=0,zr=class extends Vr{constructor(t){if(super(),this.context=t,this.connections=new Set,this.status={started:!1},t.keepAlive=t.keepAlive??!0,this.addr="unknown",this.server=Vo.default.createServer(t,this.onSocket.bind(this)),t.maxConnections!==void 0&&(this.server.maxConnections=t.maxConnections),t.closeServerOnMaxConnections!=null&&t.closeServerOnMaxConnections.closeAbove<t.closeServerOnMaxConnections.listenBelow)throw Error("closeAbove must be >= listenBelow");this.server.on("listening",()=>{if(t.metrics!=null){let e=this.server.address();e==null?this.addr="unknown":typeof e=="string"?this.addr=e:this.addr=`${e.address}:${e.port}`,t.metrics?.registerMetricGroup("libp2p_tcp_inbound_connections_total",{label:"address",help:"Current active connections in TCP listener",calculate:()=>({[this.addr]:this.connections.size})}),this.metrics={status:t.metrics.registerMetricGroup("libp2p_tcp_listener_status_info",{label:"address",help:"Current status of the TCP listener socket"}),errors:t.metrics.registerMetricGroup("libp2p_tcp_listener_errors_total",{label:"address",help:"Total count of TCP listener errors by type"}),events:t.metrics.registerMetricGroup("libp2p_tcp_listener_events_total",{label:"address",help:"Total count of TCP listener events by type"})},this.metrics?.status.update({[this.addr]:yh})}this.dispatchEvent(new $e("listening"))}).on("error",e=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new $e("error",{detail:e}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:bh}),this.dispatchEvent(new $e("close"))})}onSocket(t){t.on("error",n=>{gt("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let e;try{e=$r(t,{listeningAddr:this.status.started?this.status.listeningAddr:void 0,socketInactivityTimeout:this.context.socketInactivityTimeout,socketCloseTimeout:this.context.socketCloseTimeout,metrics:this.metrics?.events,metricPrefix:`${this.addr} `})}catch(n){gt.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}gt("new inbound connection %s",e.remoteAddr);try{this.context.upgrader.upgradeInbound(e).then(n=>{gt("inbound connection upgraded %s",e.remoteAddr),this.connections.add(e),t.once("close",()=>{this.connections.delete(e),this.context.closeServerOnMaxConnections!=null&&this.connections.size<this.context.closeServerOnMaxConnections.listenBelow&&this.netListen().catch(i=>{gt.error("error attempting to listen server once connection count under limit",i),this.context.closeServerOnMaxConnections?.onListenError?.(i)})}),this.context.handler!=null&&this.context.handler(n),this.context.closeServerOnMaxConnections!=null&&this.connections.size>=this.context.closeServerOnMaxConnections.closeAbove&&this.netClose(),this.dispatchEvent(new $e("connection",{detail:n}))}).catch(async n=>{gt.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await _i(e)}).catch(n=>{gt.error("closing inbound connection failed",n)})}catch(n){gt.error("inbound connection failed",n),_i(e).catch(i=>{gt.error("closing inbound connection failed",i),this.metrics?.errors.increment({[`${this.addr} inbound_closing_failed`]:!0})})}}getAddrs(){if(!this.status.started)return[];let t=[],e=this.server.address(),{listeningAddr:n,peerId:i}=this.status;if(e==null)return[];if(typeof e=="string")t=[n];else try{n.toString().startsWith("/ip4")?t=t.concat(Ai("ip4",e.address,e.port)):e.family==="IPv6"&&(t=t.concat(Ai("ip6",e.address,e.port)))}catch(s){gt.error("could not turn %s:%s into multiaddr",e.address,e.port,s)}return t.map(s=>i!=null?s.encapsulate(`/p2p/${i}`):s)}async listen(t){if(this.status.started)throw Error("server is already listening");let e=t.getPeerId(),n=e==null?t.decapsulateCode(421):t;this.status={started:!0,listeningAddr:n,peerId:e,netConfig:Ge(n)},await this.netListen()}async close(){await Promise.all(Array.from(this.connections.values()).map(async t=>{await _i(t)})),this.netClose()}async netListen(){if(!this.status.started||this.server.listening)return;let t=this.status.netConfig;await new Promise((e,n)=>{this.server.once("error",n),this.server.listen(t,e)}),gt("Listening on %s",this.server.address())}netClose(){!this.status.started||!this.server.listening||(gt("Closing server on %s",this.server.address()),this.server.close())}};var Ho=Symbol.for("@libp2p/transport");var zo;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(zo||(zo={}));var qt=Tt("libp2p:tcp"),Ci=class{constructor(t,e={}){this.opts=e,this.components=t,t.metrics!=null&&(this.metrics={dialerEvents:t.metrics.registerCounterGroup("libp2p_tcp_dialer_events_total",{label:"event",help:"Total count of TCP dialer events by type"})})}get[Ho](){return!0}get[Symbol.toStringTag](){return"@libp2p/tcp"}async dial(t,e){e.keepAlive=e.keepAlive??!0;let n=await this._connect(t,e);n.on("error",f=>{qt("socket error",f)});let i=$r(n,{remoteAddr:t,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents}),s=()=>{i.close().catch(f=>{qt.error("Error closing maConn after abort",f)})};e.signal?.addEventListener("abort",s,{once:!0}),qt("new outbound connection %s",i.remoteAddr);let a=await e.upgrader.upgradeOutbound(i);if(qt("outbound connection %s upgraded",i.remoteAddr),e.signal?.removeEventListener("abort",s),e.signal?.aborted===!0)throw a.close().catch(f=>{qt.error("Error closing conn after abort",f)}),new Vt;return a}async _connect(t,e){if(e.signal?.aborted===!0)throw new Vt;return await new Promise((n,i)=>{let s=Date.now(),a=Ge(t),f=a.path??`${a.host??""}:${a.port}`;qt("dialing %j",a);let l=Yo.default.connect(a),d=b=>{b.message=`connection error ${f}: ${b.message}`,this.metrics?.dialerEvents.increment({error:!0}),x(b)},h=()=>{qt("connection timeout %s",f),this.metrics?.dialerEvents.increment({timeout:!0});let b=new E(`connection timeout after ${Date.now()-s}ms`,"ERR_CONNECT_TIMEOUT");l.emit("error",b)},g=()=>{qt("connection opened %j",a),this.metrics?.dialerEvents.increment({connect:!0}),x()},w=()=>{qt("connection aborted %j",a),this.metrics?.dialerEvents.increment({abort:!0}),l.destroy(),x(new Vt)},x=b=>{if(l.removeListener("error",d),l.removeListener("timeout",h),l.removeListener("connect",g),e.signal!=null&&e.signal.removeEventListener("abort",w),b!=null){i(b);return}n(l)};l.on("error",d),l.on("timeout",h),l.on("connect",g),e.signal!=null&&e.signal.addEventListener("abort",w)})}createListener(t){return new zr({...t,maxConnections:this.opts.maxConnections,closeServerOnMaxConnections:this.opts.closeServerOnMaxConnections,socketInactivityTimeout:this.opts.inboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.components.metrics})}filter(t){return t=Array.isArray(t)?t:[t],t.filter(e=>e.protoCodes().includes(290)?!1:e.protoCodes().includes(400)?!0:re.matches(e.decapsulateCode(421)))}};function Ko(r={}){return(t={})=>new Ci(t,r)}var Vi=F(ki(),1),Nc=F(Ac(),1),kc=F(Ee(),1),zi=F($i(),1),Pc=F(Lc(),1);function Ch(){kc.default._configure(),Vi.default._configure(Nc.default),zi.default._configure(Pc.default)}Ch();var Oc=["uint64","int64","sint64","fixed64","sfixed64"];function Dh(r){for(let t of Oc){if(r[t]==null)continue;let e=r[t];r[t]=function(){return BigInt(e.call(this).toString())}}return r}function Hi(r){return Dh(new Vi.default(r))}function Bh(r){for(let t of Oc){if(r[t]==null)continue;let e=r[t];r[t]=function(n){return e.call(this,n.toString())}}return r}function Yi(){return Bh(zi.default.create())}function H(r,t){let e=Hi(r instanceof Uint8Array?r:r.subarray());return t.decode(e)}function Y(r,t){let e=Yi();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var ze;(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"})(ze||(ze={}));function Wr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Wt(r){function t(i){if(r[i.toString()]==null)throw new Error("Invalid enum value");return r[i]}let e=function(s,a){let f=t(s);a.int32(f)},n=function(s){let a=s.int32();return t(a)};return Wr("enum",ze.VARINT,e,n)}function K(r,t){return Wr("message",ze.LENGTH_DELIMITED,r,t)}var $;(function(r){let t;(function(i){i.IDENTIFY="IDENTIFY",i.CONNECT="CONNECT",i.STREAM_OPEN="STREAM_OPEN",i.STREAM_HANDLER="STREAM_HANDLER",i.DHT="DHT",i.LIST_PEERS="LIST_PEERS",i.CONNMANAGER="CONNMANAGER",i.DISCONNECT="DISCONNECT",i.PUBSUB="PUBSUB",i.PEERSTORE="PEERSTORE"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.IDENTIFY=0]="IDENTIFY",i[i.CONNECT=1]="CONNECT",i[i.STREAM_OPEN=2]="STREAM_OPEN",i[i.STREAM_HANDLER=3]="STREAM_HANDLER",i[i.DHT=4]="DHT",i[i.LIST_PEERS=5]="LIST_PEERS",i[i.CONNMANAGER=6]="CONNMANAGER",i[i.DISCONNECT=7]="DISCONNECT",i[i.PUBSUB=8]="PUBSUB",i[i.PEERSTORE=9]="PEERSTORE"})(e||(e={})),function(i){i.codec=()=>Wt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=K((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.connect!=null&&(s.uint32(18),Xr.codec().encode(i.connect,s)),i.streamOpen!=null&&(s.uint32(26),jr.codec().encode(i.streamOpen,s)),i.streamHandler!=null&&(s.uint32(34),Jr.codec().encode(i.streamHandler,s)),i.dht!=null&&(s.uint32(42),xt.codec().encode(i.dht,s)),i.connManager!=null&&(s.uint32(50),tn.codec().encode(i.connManager,s)),i.disconnect!=null&&(s.uint32(58),en.codec().encode(i.disconnect,s)),i.pubsub!=null&&(s.uint32(66),Zt.codec().encode(i.pubsub,s)),i.peerStore!=null&&(s.uint32(74),sn.codec().encode(i.peerStore,s)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},f=s==null?i.len:i.pos+s;for(;i.pos<f;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.connect=Xr.codec().decode(i,i.uint32());break;case 3:a.streamOpen=jr.codec().decode(i,i.uint32());break;case 4:a.streamHandler=Jr.codec().decode(i,i.uint32());break;case 5:a.dht=xt.codec().decode(i,i.uint32());break;case 6:a.connManager=tn.codec().decode(i,i.uint32());break;case 7:a.disconnect=en.codec().decode(i,i.uint32());break;case 8:a.pubsub=Zt.codec().decode(i,i.uint32());break;case 9:a.peerStore=sn.codec().decode(i,i.uint32());break;default:i.skipType(l&7);break}}return a})),n),r.encode=i=>Y(i,r.codec()),r.decode=i=>H(i,r.codec())})($||($={}));var C;(function(r){let t;(function(i){i.OK="OK",i.ERROR="ERROR"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.OK=0]="OK",i[i.ERROR=1]="ERROR"})(e||(e={})),function(i){i.codec=()=>Wt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=K((i,s,a={})=>{if(a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.error!=null&&(s.uint32(18),Qr.codec().encode(i.error,s)),i.streamInfo!=null&&(s.uint32(26),He.codec().encode(i.streamInfo,s)),i.identify!=null&&(s.uint32(34),Zr.codec().encode(i.identify,s)),i.dht!=null&&(s.uint32(42),Pt.codec().encode(i.dht,s)),i.peers!=null)for(let f of i.peers)s.uint32(50),se.codec().encode(f,s);i.pubsub!=null&&(s.uint32(58),nn.codec().encode(i.pubsub,s)),i.peerStore!=null&&(s.uint32(66),on.codec().encode(i.peerStore,s)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={peers:[]},f=s==null?i.len:i.pos+s;for(;i.pos<f;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.error=Qr.codec().decode(i,i.uint32());break;case 3:a.streamInfo=He.codec().decode(i,i.uint32());break;case 4:a.identify=Zr.codec().decode(i,i.uint32());break;case 5:a.dht=Pt.codec().decode(i,i.uint32());break;case 6:a.peers.push(se.codec().decode(i,i.uint32()));break;case 7:a.pubsub=nn.codec().decode(i,i.uint32());break;case 8:a.peerStore=on.codec().decode(i,i.uint32());break;default:i.skipType(l&7);break}}return a})),n),r.encode=i=>Y(i,r.codec()),r.decode=i=>H(i,r.codec())})(C||(C={}));var Zr;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.id!=null&&e.id.byteLength>0&&(n.uint32(10),n.bytes(e.id)),e.addrs!=null)for(let s of e.addrs)n.uint32(18),n.bytes(s);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={id:new Uint8Array(0),addrs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.id=e.bytes();break;case 2:i.addrs.push(e.bytes());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>Y(e,r.codec()),r.decode=e=>H(e,r.codec())})(Zr||(Zr={}));var Xr;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.addrs!=null)for(let s of e.addrs)n.uint32(18),n.bytes(s);e.timeout!=null&&(n.uint32(24),n.int64(e.timeout)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={peer:new Uint8Array(0),addrs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.peer=e.bytes();break;case 2:i.addrs.push(e.bytes());break;case 3:i.timeout=e.int64();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>Y(e,r.codec()),r.decode=e=>H(e,r.codec())})(Xr||(Xr={}));var jr;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.proto!=null)for(let s of e.proto)n.uint32(18),n.string(s);e.timeout!=null&&(n.uint32(24),n.int64(e.timeout)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={peer:new Uint8Array(0),proto:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.peer=e.bytes();break;case 2:i.proto.push(e.string());break;case 3:i.timeout=e.int64();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>Y(e,r.codec()),r.decode=e=>H(e,r.codec())})(jr||(jr={}));var Jr;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.addr!=null&&e.addr.byteLength>0&&(n.uint32(10),n.bytes(e.addr)),e.proto!=null)for(let s of e.proto)n.uint32(18),n.string(s);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={addr:new Uint8Array(0),proto:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.addr=e.bytes();break;case 2:i.proto.push(e.string());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>Y(e,r.codec()),r.decode=e=>H(e,r.codec())})(Jr||(Jr={}));var Qr;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),e.msg!=null&&e.msg!==""&&(n.uint32(10),n.string(e.msg)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={msg:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.msg=e.string();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>Y(e,r.codec()),r.decode=e=>H(e,r.codec())})(Qr||(Qr={}));var He;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.addr!=null&&e.addr.byteLength>0&&(n.uint32(18),n.bytes(e.addr)),e.proto!=null&&e.proto!==""&&(n.uint32(26),n.string(e.proto)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={peer:new Uint8Array(0),addr:new Uint8Array(0),proto:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.peer=e.bytes();break;case 2:i.addr=e.bytes();break;case 3:i.proto=e.string();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>Y(e,r.codec()),r.decode=e=>H(e,r.codec())})(He||(He={}));var xt;(function(r){let t;(function(i){i.FIND_PEER="FIND_PEER",i.FIND_PEERS_CONNECTED_TO_PEER="FIND_PEERS_CONNECTED_TO_PEER",i.FIND_PROVIDERS="FIND_PROVIDERS",i.GET_CLOSEST_PEERS="GET_CLOSEST_PEERS",i.GET_PUBLIC_KEY="GET_PUBLIC_KEY",i.GET_VALUE="GET_VALUE",i.SEARCH_VALUE="SEARCH_VALUE",i.PUT_VALUE="PUT_VALUE",i.PROVIDE="PROVIDE"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.FIND_PEER=0]="FIND_PEER",i[i.FIND_PEERS_CONNECTED_TO_PEER=1]="FIND_PEERS_CONNECTED_TO_PEER",i[i.FIND_PROVIDERS=2]="FIND_PROVIDERS",i[i.GET_CLOSEST_PEERS=3]="GET_CLOSEST_PEERS",i[i.GET_PUBLIC_KEY=4]="GET_PUBLIC_KEY",i[i.GET_VALUE=5]="GET_VALUE",i[i.SEARCH_VALUE=6]="SEARCH_VALUE",i[i.PUT_VALUE=7]="PUT_VALUE",i[i.PROVIDE=8]="PROVIDE"})(e||(e={})),function(i){i.codec=()=>Wt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=K((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.peer!=null&&(s.uint32(18),s.bytes(i.peer)),i.cid!=null&&(s.uint32(26),s.bytes(i.cid)),i.key!=null&&(s.uint32(34),s.bytes(i.key)),i.value!=null&&(s.uint32(42),s.bytes(i.value)),i.count!=null&&(s.uint32(48),s.int32(i.count)),i.timeout!=null&&(s.uint32(56),s.int64(i.timeout)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},f=s==null?i.len:i.pos+s;for(;i.pos<f;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.peer=i.bytes();break;case 3:a.cid=i.bytes();break;case 4:a.key=i.bytes();break;case 5:a.value=i.bytes();break;case 6:a.count=i.int32();break;case 7:a.timeout=i.int64();break;default:i.skipType(l&7);break}}return a})),n),r.encode=i=>Y(i,r.codec()),r.decode=i=>H(i,r.codec())})(xt||(xt={}));var Pt;(function(r){let t;(function(i){i.BEGIN="BEGIN",i.VALUE="VALUE",i.END="END"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.BEGIN=0]="BEGIN",i[i.VALUE=1]="VALUE",i[i.END=2]="END"})(e||(e={})),function(i){i.codec=()=>Wt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=K((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.peer!=null&&(s.uint32(18),se.codec().encode(i.peer,s)),i.value!=null&&(s.uint32(26),s.bytes(i.value)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},f=s==null?i.len:i.pos+s;for(;i.pos<f;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.peer=se.codec().decode(i,i.uint32());break;case 3:a.value=i.bytes();break;default:i.skipType(l&7);break}}return a})),n),r.encode=i=>Y(i,r.codec()),r.decode=i=>H(i,r.codec())})(Pt||(Pt={}));var se;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.id!=null&&e.id.byteLength>0&&(n.uint32(10),n.bytes(e.id)),e.addrs!=null)for(let s of e.addrs)n.uint32(18),n.bytes(s);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={id:new Uint8Array(0),addrs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.id=e.bytes();break;case 2:i.addrs.push(e.bytes());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>Y(e,r.codec()),r.decode=e=>H(e,r.codec())})(se||(se={}));var tn;(function(r){let t;(function(i){i.TAG_PEER="TAG_PEER",i.UNTAG_PEER="UNTAG_PEER",i.TRIM="TRIM"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.TAG_PEER=0]="TAG_PEER",i[i.UNTAG_PEER=1]="UNTAG_PEER",i[i.TRIM=2]="TRIM"})(e||(e={})),function(i){i.codec=()=>Wt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=K((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.peer!=null&&(s.uint32(18),s.bytes(i.peer)),i.tag!=null&&(s.uint32(26),s.string(i.tag)),i.weight!=null&&(s.uint32(32),s.int64(i.weight)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},f=s==null?i.len:i.pos+s;for(;i.pos<f;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.peer=i.bytes();break;case 3:a.tag=i.string();break;case 4:a.weight=i.int64();break;default:i.skipType(l&7);break}}return a})),n),r.encode=i=>Y(i,r.codec()),r.decode=i=>H(i,r.codec())})(tn||(tn={}));var en;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={peer:new Uint8Array(0)},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.peer=e.bytes();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>Y(e,r.codec()),r.decode=e=>H(e,r.codec())})(en||(en={}));var Zt;(function(r){let t;(function(i){i.GET_TOPICS="GET_TOPICS",i.LIST_PEERS="LIST_PEERS",i.PUBLISH="PUBLISH",i.SUBSCRIBE="SUBSCRIBE"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.GET_TOPICS=0]="GET_TOPICS",i[i.LIST_PEERS=1]="LIST_PEERS",i[i.PUBLISH=2]="PUBLISH",i[i.SUBSCRIBE=3]="SUBSCRIBE"})(e||(e={})),function(i){i.codec=()=>Wt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=K((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.topic!=null&&(s.uint32(18),s.string(i.topic)),i.data!=null&&(s.uint32(26),s.bytes(i.data)),a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={},f=s==null?i.len:i.pos+s;for(;i.pos<f;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.topic=i.string();break;case 3:a.data=i.bytes();break;default:i.skipType(l&7);break}}return a})),n),r.encode=i=>Y(i,r.codec()),r.decode=i=>H(i,r.codec())})(Zt||(Zt={}));var rn;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.from!=null&&(n.uint32(10),n.bytes(e.from)),e.data!=null&&(n.uint32(18),n.bytes(e.data)),e.seqno!=null&&(n.uint32(26),n.bytes(e.seqno)),e.topicIDs!=null)for(let s of e.topicIDs)n.uint32(34),n.string(s);e.signature!=null&&(n.uint32(42),n.bytes(e.signature)),e.key!=null&&(n.uint32(50),n.bytes(e.key)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={topicIDs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.from=e.bytes();break;case 2:i.data=e.bytes();break;case 3:i.seqno=e.bytes();break;case 4:i.topicIDs.push(e.string());break;case 5:i.signature=e.bytes();break;case 6:i.key=e.bytes();break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>Y(e,r.codec()),r.decode=e=>H(e,r.codec())})(rn||(rn={}));var nn;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.topics!=null)for(let s of e.topics)n.uint32(10),n.string(s);if(e.peerIDs!=null)for(let s of e.peerIDs)n.uint32(18),n.bytes(s);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={topics:[],peerIDs:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.topics.push(e.string());break;case 2:i.peerIDs.push(e.bytes());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>Y(e,r.codec()),r.decode=e=>H(e,r.codec())})(nn||(nn={}));var sn;(function(r){let t;(function(i){i.UNSPECIFIED="UNSPECIFIED",i.GET_PROTOCOLS="GET_PROTOCOLS",i.GET_PEER_INFO="GET_PEER_INFO"})(t=r.Type||(r.Type={}));let e;(function(i){i[i.UNSPECIFIED=0]="UNSPECIFIED",i[i.GET_PROTOCOLS=1]="GET_PROTOCOLS",i[i.GET_PEER_INFO=2]="GET_PEER_INFO"})(e||(e={})),function(i){i.codec=()=>Wt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=K((i,s,a={})=>{if(a.lengthDelimited!==!1&&s.fork(),i.type!=null&&(s.uint32(8),r.Type.codec().encode(i.type,s)),i.id!=null&&(s.uint32(18),s.bytes(i.id)),i.protos!=null)for(let f of i.protos)s.uint32(26),s.string(f);a.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let a={protos:[]},f=s==null?i.len:i.pos+s;for(;i.pos<f;){let l=i.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.id=i.bytes();break;case 3:a.protos.push(i.string());break;default:i.skipType(l&7);break}}return a})),n),r.encode=i=>Y(i,r.codec()),r.decode=i=>H(i,r.codec())})(sn||(sn={}));var on;(function(r){let t;r.codec=()=>(t==null&&(t=K((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&(n.uint32(10),se.codec().encode(e.peer,n)),e.protos!=null)for(let s of e.protos)n.uint32(18),n.string(s);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={protos:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:i.peer=se.codec().decode(e,e.uint32());break;case 2:i.protos.push(e.string());break;default:e.skipType(a&7);break}}return i})),t),r.encode=e=>Y(e,r.codec()),r.decode=e=>H(e,r.codec())})(on||(on={}));var Fc=Symbol.for("@achingbrain/uint8arraylist");function Mc(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let i=e+n.byteLength;if(t<i)return{buf:n,index:t-e};e=i}throw new RangeError("index is out of bounds")}function cn(r){return!!r?.[Fc]}var lt=class{constructor(...t){Object.defineProperty(this,Fc,{value:!0}),this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(cn(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(cn(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Mc(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Mc(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(cn(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:i}=this._subList(t,e);return Et(n,i)}subarray(t,e){let{bufs:n,length:i}=this._subList(t,e);return n.length===1?n[0]:Et(n,i)}sublist(t,e){let{bufs:n,length:i}=this._subList(t,e),s=new lt;return s.length=i,s.bufs=n,s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],i=0;for(let s=0;s<this.bufs.length;s++){let a=this.bufs[s],f=i,l=f+a.byteLength;if(i=l,t>=l)continue;let d=t>=f&&t<l,h=e>f&&e<=l;if(d&&h){if(t===f&&e===l){n.push(a);break}let g=t-f;n.push(a.subarray(g,g+(e-t)));break}if(d){if(t===0){n.push(a);continue}n.push(a.subarray(t-f));continue}if(h){if(e===l){n.push(a);break}n.push(a.subarray(0,e-f));break}n.push(a)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!cn(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let i=n.byteLength;if(i===0)throw new TypeError("search must be at least 1 byte long");let s=256,a=new Int32Array(s);for(let g=0;g<s;g++)a[g]=-1;for(let g=0;g<i;g++)a[n[g]]=g;let f=a,l=this.byteLength-n.byteLength,d=n.byteLength-1,h;for(let g=e;g<=l;g+=h){h=0;for(let w=d;w>=0;w--){let x=this.get(g+w);if(n[w]!==x){h=Math.max(1,w-f[x]);break}}if(h===0)return g}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=Dt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let i=zt(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,e,n),this.write(i,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let i=zt(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,e,n),this.write(i,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let i=zt(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,e,n),this.write(i,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=Dt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let i=zt(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,e,n),this.write(i,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let i=zt(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,e,n),this.write(i,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let i=zt(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,e,n),this.write(i,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let i=zt(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,e,n),this.write(i,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let i=zt(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,e,n),this.write(i,t)}equals(t){if(t==null||!(t instanceof lt)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!he(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new lt;return n.bufs=t,e==null&&(e=t.reduce((i,s)=>i+s.byteLength,0)),n.length=e,n}};function an(r){return r instanceof Uint8Array?{get(t){return r[t]},set(t,e){r[t]=e}}:{get(t){return r.get(t)},set(t,e){r.set(t,e)}}}var Uc=4294967296,yt=class{constructor(t=0,e=0){this.hi=t,this.lo=e}toBigInt(t){if(t===!0)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toNumber(t){return Number(this.toBigInt(t))}zzDecode(){let t=-(this.lo&1),e=((this.lo>>>1|this.hi<<31)^t)>>>0,n=(this.hi>>>1^t)>>>0;return new yt(n,e)}zzEncode(){let t=this.hi>>31,e=((this.hi<<1|this.lo>>>31)^t)>>>0,n=(this.lo<<1^t)>>>0;return new yt(e,n)}toBytes(t,e=0){let n=an(t);for(;this.hi>0;)n.set(e++,this.lo&127|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)n.set(e++,this.lo&127|128),this.lo=this.lo>>>7;n.set(e++,this.lo)}static fromBigInt(t){if(t===0n)return new yt;let e=t<0;e&&(t=-t);let n=Number(t>>32n)|0,i=Number(t-(BigInt(n)<<32n))|0;return e&&(n=~n>>>0,i=~i>>>0,++i>Uc&&(i=0,++n>Uc&&(n=0))),new yt(n,i)}static fromNumber(t){if(t===0)return new yt;let e=t<0;e&&(t=-t);let n=t>>>0,i=(t-n)/4294967296>>>0;return e&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new yt(i,n)}static fromBytes(t,e=0){let n=an(t),i=new yt,s=0;if(t.length-e>4){for(;s<4;++s)if(i.lo=(i.lo|(n.get(e)&127)<<s*7)>>>0,n.get(e++)<128)return i;if(i.lo=(i.lo|(n.get(e)&127)<<28)>>>0,i.hi=(i.hi|(n.get(e)&127)>>4)>>>0,n.get(e++)<128)return i;s=0}else for(;s<4;++s){if(e>=t.length)throw RangeError(`index out of range: ${e} > ${t.length}`);if(i.lo=(i.lo|(n.get(e)&127)<<s*7)>>>0,n.get(e++)<128)return i}if(t.length-e>4){for(;s<5;++s)if(i.hi=(i.hi|(n.get(e)&127)<<s*7+3)>>>0,n.get(e++)<128)return i}else if(e<t.byteLength)for(;s<5;++s){if(e>=t.length)throw RangeError(`index out of range: ${e} > ${t.length}`);if(i.hi=(i.hi|(n.get(e)&127)<<s*7+3)>>>0,n.get(e++)<128)return i}throw RangeError("invalid varint encoding")}};var Lh=Math.pow(2,7),Nh=Math.pow(2,14),kh=Math.pow(2,21),Ph=Math.pow(2,28),Oh=Math.pow(2,35),Mh=Math.pow(2,42),Fh=Math.pow(2,49),Uh=Math.pow(2,56),Gh=Math.pow(2,63),Te={encodingLength(r){return r<Lh?1:r<Nh?2:r<kh?3:r<Ph?4:r<Oh?5:r<Mh?6:r<Fh?7:r<Uh?8:r<Gh?9:10},encode(r,t,e=0){if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return t==null&&(t=Dt(Te.encodingLength(r))),yt.fromNumber(r).toBytes(t,e),t},decode(r,t=0){return yt.fromBytes(r,t).toNumber(!0)}};function un(r){return r[Symbol.asyncIterator]!=null}var ln=r=>{let t=Te.encodingLength(r),e=Dt(t);return Te.encode(r,e),ln.bytes=t,e};ln.bytes=0;function fn(r,t){t=t??{};let e=t.lengthEncoder??ln;function*n(i){let s=e(i.byteLength);s instanceof Uint8Array?yield s:yield*s,i instanceof Uint8Array?yield i:yield*i}return un(r)?async function*(){for await(let i of r)yield*n(i)}():function*(){for(let i of r)yield*n(i)}()}fn.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??ln;return new lt(e(r.byteLength),r)};var Ye=F(ei(),1);var $h=8,Vh=1024*1024*4,Se;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Se||(Se={}));var Ki=r=>{let t=Te.decode(r);return Ki.bytes=Te.encodingLength(t),t};Ki.bytes=0;function cr(r,t){let e=new lt,n=Se.LENGTH,i=-1,s=t?.lengthDecoder??Ki,a=t?.maxLengthLength??$h,f=t?.maxDataLength??Vh;function*l(){for(;e.byteLength>0;){if(n===Se.LENGTH)try{if(i=s(e),i<0)throw(0,Ye.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(i>f)throw(0,Ye.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let d=s.bytes;e.consume(d),t?.onLength!=null&&t.onLength(i),n=Se.DATA}catch(d){if(d instanceof RangeError){if(e.byteLength>a)throw(0,Ye.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw d}if(n===Se.DATA){if(e.byteLength<i)break;let d=e.sublist(0,i);e.consume(i),t?.onData!=null&&t.onData(d),yield d,n=Se.LENGTH}}}return un(r)?async function*(){for await(let d of r)e.append(d),yield*l();if(e.byteLength>0)throw(0,Ye.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let d of r)e.append(d),yield*l();if(e.byteLength>0)throw(0,Ye.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}cr.fromReader=(r,t)=>{let e=1,n=async function*(){for(;;)try{let{done:s,value:a}=await r.next(e);if(s===!0)return;a!=null&&(yield a)}catch(s){if(s.code==="ERR_UNDER_READ")return{done:!0,value:null};throw s}finally{e=1}}();return cr(n,{...t??{},onLength:s=>{e=s}})};function Gc(r){let t=async function*(){let e=yield,n=new lt;for await(let i of r){if(e==null){n.append(i),e=yield n,n=new lt;continue}for(n.append(i);n.length>=e;){let s=n.sublist(0,e);if(n.consume(e),e=yield s,e==null){n.length>0&&(e=yield n,n=new lt);break}}}if(e!=null)throw Object.assign(new Error(`stream ended before ${e} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return t.next(),t}var hn=class{constructor(t){if(!(t>0)||t-1&t)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},Ke=class{constructor(t={}){this.hwm=t.splitLimit??16,this.head=new hn(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new hn(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};function $c(r={}){return Hh(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function Hh(r,t){t=t??{};let e=t.onEnd,n=new Ke,i,s,a,f=async()=>n.isEmpty()?a?{done:!0}:await new Promise((A,B)=>{s=R=>{s=null,n.push(R);try{A(r(n))}catch(D){B(D)}return i}}):r(n),l=A=>s!=null?s(A):(n.push(A),i),d=A=>(n=new Ke,s!=null?s({error:A}):(n.push({error:A}),i)),h=A=>{if(a)return i;if(t?.objectMode!==!0&&A?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:A})},g=A=>a?i:(a=!0,A!=null?d(A):l({done:!0})),w=()=>(n=new Ke,g(),{done:!0}),x=A=>(g(A),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:f,return:w,throw:x,push:h,end:g,get readableLength(){return n.size}},e==null)return i;let b=i;return i={[Symbol.asyncIterator](){return this},next(){return b.next()},throw(A){return b.throw(A),e!=null&&(e(A),e=void 0),{done:!0}},return(){return b.return(),e!=null&&(e(),e=void 0),{done:!0}},push:h,end(A){return b.end(A),e!=null&&(e(A),e=void 0),i},get readableLength(){return b.readableLength}},i}function qi(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}function Vc(r){let t=$c(),e=Gc(r.source),n=qi(),i,s=r.sink(async function*(){yield*t,yield*await n.promise}());return s.catch(f=>{i=f}),{reader:e,writer:t,stream:{sink:async f=>i!=null?await Promise.reject(i):(n.resolve(f),await s),source:e},rest:()=>t.end(),write:t.push,read:async()=>{let f=await e.next();if(f.value!=null)return f.value}}}var Wi=Tt("libp2p:daemon-protocol:stream-handler"),ar=class{constructor(t){let{stream:e,maxLength:n}=t;this.stream=e,this.shake=Vc(this.stream),this.decoder=cr.fromReader(this.shake.reader,{maxDataLength:n??4096})}async read(){let t=await this.decoder.next();if(t.value!=null)return t.value.subarray();Wi("read received no value, closing stream"),await this.close()}write(t){Wi("write message"),this.shake.write(fn.single(t).subarray())}rest(){return this.shake.rest(),this.shake.stream}async close(){Wi("closing the stream"),await this.rest().sink([])}};var Zi=Symbol.for("@libp2p/peer-id");function qe(r){return r!=null&&!!r[Zi]}var Yh=Symbol.for("nodejs.util.inspect.custom"),zc=Object.values(te).map(r=>r.decoder).reduce((r,t)=>r.or(t),te.identity.decoder),Hc=114,Yc=36,Kc=37,ur=class{constructor(t){this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}get[Zi](){return!0}toString(){return this.string==null&&(this.string=W.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return k.createV1(Hc,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t instanceof Uint8Array)return he(this.multihash.bytes,t);if(typeof t=="string")return Kh(t).equals(this);if(t?.multihash?.bytes!=null)return he(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Yh](){return`PeerId(${this.toString()})`}},lr=class extends ur{constructor(t){super({...t,type:"RSA"}),this.type="RSA",this.publicKey=t.publicKey}},fr=class extends ur{constructor(t){super({...t,type:"Ed25519"}),this.type="Ed25519",this.publicKey=t.multihash.digest}},hr=class extends ur{constructor(t){super({...t,type:"secp256k1"}),this.type="secp256k1",this.publicKey=t.multihash.digest}};function Kh(r,t){if(t=t??zc,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=ue(W.decode(`z${r}`));return r.startsWith("12D")?new fr({multihash:e}):r.startsWith("16U")?new hr({multihash:e}):new lr({multihash:e})}return Ut(zc.decode(r))}function Ut(r){try{let t=ue(r);if(t.code===Er.code){if(t.digest.length===Yc)return new fr({multihash:t});if(t.digest.length===Kc)return new hr({multihash:t})}if(t.code===wr.code)return new lr({multihash:t})}catch{return qh(k.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function qh(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Hc)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===wr.code)return new lr({multihash:r.multihash});if(t.code===Er.code){if(t.digest.length===Yc)return new fr({multihash:r.multihash});if(t.digest.length===Kc)return new hr({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var pn=class{constructor(t){this.client=t}async put(t,e){if(!(t instanceof Uint8Array))throw new E("invalid key received","ERR_INVALID_KEY");if(!(e instanceof Uint8Array))throw new E("value received is not a Uint8Array","ERR_INVALID_VALUE");let n=await this.client.send({type:$.Type.DHT,dht:{type:xt.Type.PUT_VALUE,key:t,value:e}}),i=await n.read();if(i==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let s=C.decode(i);if(await n.close(),s.type!==C.Type.OK)throw new E(s.error?.msg??"DHT put failed","ERR_DHT_PUT_FAILED")}async get(t){if(!(t instanceof Uint8Array))throw new E("invalid key received","ERR_INVALID_KEY");let e=await this.client.send({type:$.Type.DHT,dht:{type:xt.Type.GET_VALUE,key:t}}),n=await e.read();if(n==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let i=C.decode(n);if(await e.close(),i.type!==C.Type.OK)throw new E(i.error?.msg??"DHT get failed","ERR_DHT_GET_FAILED");if(i.dht==null||i.dht.value==null)throw new E("Invalid DHT get response","ERR_DHT_GET_FAILED");return i.dht.value}async findPeer(t){if(!qe(t))throw new E("invalid peer id received","ERR_INVALID_PEER_ID");let e=await this.client.send({type:$.Type.DHT,dht:{type:xt.Type.FIND_PEER,peer:t.toBytes()}}),n=await e.read();if(n==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let i=C.decode(n);if(await e.close(),i.type!==C.Type.OK)throw new E(i.error?.msg??"DHT find peer failed","ERR_DHT_FIND_PEER_FAILED");if(i.dht==null||i.dht.peer==null||i.dht.peer.addrs==null)throw new E("Invalid response","ERR_DHT_FIND_PEER_FAILED");return{id:Ut(i.dht.peer.id),multiaddrs:i.dht.peer.addrs.map(s=>tt(s)),protocols:[]}}async provide(t){if(t==null||k.asCID(t)==null)throw new E("invalid cid received","ERR_INVALID_CID");let e=await this.client.send({type:$.Type.DHT,dht:{type:xt.Type.PROVIDE,cid:t.bytes}}),n=await e.read();if(n==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let i=C.decode(n);if(await e.close(),i.type!==C.Type.OK)throw new E(i.error?.msg??"DHT provide failed","ERR_DHT_PROVIDE_FAILED")}async*findProviders(t,e=1){if(t==null||k.asCID(t)==null)throw new E("invalid cid received","ERR_INVALID_CID");let n=await this.client.send({type:$.Type.DHT,dht:{type:xt.Type.FIND_PROVIDERS,cid:t.bytes,count:e}}),i=await n.read();if(i==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let s=C.decode(i);if(s.type!==C.Type.OK)throw await n.close(),new E(s.error?.msg??"DHT find providers failed","ERR_DHT_FIND_PROVIDERS_FAILED");for(;;){if(i=await n.read(),i==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let a=Pt.decode(i);if(a.type===Pt.Type.END){await n.close();return}if(a.type===Pt.Type.VALUE&&a.peer!=null&&a.peer?.addrs!=null)yield{id:Ut(a.peer.id),multiaddrs:a.peer.addrs.map(f=>tt(f)),protocols:[]};else throw await n.close(),new E("unexpected message received","ERR_UNEXPECTED_MESSAGE_RECEIVED")}}async*getClosestPeers(t){if(!(t instanceof Uint8Array))throw new E("invalid key received","ERR_INVALID_KEY");let e=await this.client.send({type:$.Type.DHT,dht:{type:xt.Type.GET_CLOSEST_PEERS,key:t}}),n=await e.read();if(n==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let i=C.decode(n);if(i.type!==C.Type.OK)throw await e.close(),new E(i.error?.msg??"DHT find providers failed","ERR_DHT_FIND_PROVIDERS_FAILED");for(;;){if(n=await e.read(),n==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let s=Pt.decode(n);if(s.type===Pt.Type.END){await e.close();return}if(s.type===Pt.Type.VALUE&&s.value!=null)yield{id:Ut(s.value),multiaddrs:[],protocols:[]};else throw await e.close(),new E("unexpected message received","ERR_UNEXPECTED_MESSAGE_RECEIVED")}}async getPublicKey(t){if(!qe(t))throw new E("invalid peer id received","ERR_INVALID_PEER_ID");let e=await this.client.send({type:$.Type.DHT,dht:{type:xt.Type.GET_PUBLIC_KEY,peer:t.toBytes()}}),n=await e.read();if(n==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let i=C.decode(n);if(await e.close(),i.type!==C.Type.OK)throw new E(i.error?.msg??"DHT get public key failed","ERR_DHT_GET_PUBLIC_KEY_FAILED");if(i.dht==null)throw new E("Invalid response","ERR_DHT_GET_PUBLIC_KEY_FAILED");return i.dht.value}};var dn=class{constructor(t){this.client=t}async getTopics(){let t=await this.client.send({type:$.Type.PUBSUB,pubsub:{type:Zt.Type.GET_TOPICS}}),e=await t.read();if(e==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let n=C.decode(e);if(await t.close(),n.type!==C.Type.OK)throw new E(n.error?.msg??"Pubsub get topics failed","ERR_PUBSUB_GET_TOPICS_FAILED");if(n.pubsub==null||n.pubsub.topics==null)throw new E("Invalid response","ERR_PUBSUB_GET_TOPICS_FAILED");return n.pubsub.topics}async publish(t,e){if(typeof t!="string")throw new E("invalid topic received","ERR_INVALID_TOPIC");if(!(e instanceof Uint8Array))throw new E("data received is not a Uint8Array","ERR_INVALID_DATA");let n=await this.client.send({type:$.Type.PUBSUB,pubsub:{type:Zt.Type.PUBLISH,topic:t,data:e}}),i=await n.read();if(i==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let s=C.decode(i);if(await n.close(),s.type!==C.Type.OK)throw new E(s.error?.msg??"Pubsub publish failed","ERR_PUBSUB_PUBLISH_FAILED")}async subscribe(t){if(typeof t!="string")throw new E("invalid topic received","ERR_INVALID_TOPIC");let e=await this.client.send({type:$.Type.PUBSUB,pubsub:{type:Zt.Type.SUBSCRIBE,topic:t}}),n=await e.read();if(n==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let i=C.decode(n);if(i.type!==C.Type.OK)throw new E(i.error?.msg??"Pubsub publish failed","ERR_PUBSUB_PUBLISH_FAILED");let s=!0;return{async*messages(){for(;s;){if(n=await e.read(),n==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");yield rn.decode(n)}},async cancel(){s=!1,await e.close()}}}async getSubscribers(t){if(typeof t!="string")throw new E("invalid topic received","ERR_INVALID_TOPIC");let e=await this.client.send({type:$.Type.PUBSUB,pubsub:{type:Zt.Type.LIST_PEERS,topic:t}}),n=await e.read();if(n==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let i=C.decode(n);if(await e.close(),i.type!==C.Type.OK)throw new E(i.error?.msg??"Pubsub get subscribers failed","ERR_PUBSUB_GET_SUBSCRIBERS_FAILED");if(i.pubsub==null||i.pubsub.topics==null)throw new E("Invalid response","ERR_PUBSUB_GET_SUBSCRIBERS_FAILED");return i.pubsub.peerIDs.map(s=>Ut(s))}};var Xi={upgradeInbound:async r=>r,upgradeOutbound:async r=>r};var ji=Tt("libp2p:daemon-client"),Ji=class{constructor(t){this.multiaddr=t,this.tcp=Ko()(),this.dht=new pn(this),this.pubsub=new dn(this)}async connectDaemon(){return await this.tcp.dial(this.multiaddr,{upgrader:Xi})}async send(t){let e=await this.connectDaemon(),n=t.pubsub?.type??t.dht?.type??t.peerStore?.type??"";ji("send",t.type,n);let i=new ar({stream:e});return i.write($.encode(t)),i}async connect(t,e){if(!qe(t))throw new E("invalid peer id received","ERR_INVALID_PEER_ID");if(!Array.isArray(e))throw new E("addrs received are not in an array","ERR_INVALID_ADDRS_TYPE");e.forEach(a=>{if(!ii(a))throw new E("received an address that is not a multiaddr","ERR_NO_MULTIADDR_RECEIVED")});let n=await this.send({type:$.Type.CONNECT,connect:{peer:t.toBytes(),addrs:e.map(a=>a.bytes)}}),i=await n.read();if(i==null)throw new E("unspecified","ERR_CONNECT_FAILED");let s=C.decode(i);if(s.type!==C.Type.OK){let a=s.error??{msg:"unspecified"};throw new E(a.msg??"unspecified","ERR_CONNECT_FAILED")}await n.close()}async identify(){let t=await this.send({type:$.Type.IDENTIFY}),e=await t.read();if(e==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let n=C.decode(e);if(n.type!==C.Type.OK)throw new E(n.error?.msg??"Identify failed","ERR_IDENTIFY_FAILED");if(n.identify==null||n.identify.addrs==null)throw new E("Invalid response","ERR_IDENTIFY_FAILED");let i=Ut(n.identify?.id),s=n.identify.addrs.map(a=>tt(a));return await t.close(),{peerId:i,addrs:s}}async listPeers(){let t=await this.send({type:$.Type.LIST_PEERS}),e=await t.read();if(e==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let n=C.decode(e);if(n.type!==C.Type.OK)throw new E(n.error?.msg??"List peers failed","ERR_LIST_PEERS_FAILED");return await t.close(),n.peers.map(i=>Ut(i.id))}async openStream(t,e){if(!qe(t))throw new E("invalid peer id received","ERR_INVALID_PEER_ID");if(typeof e!="string")throw new E("invalid protocol received","ERR_INVALID_PROTOCOL");let n=await this.send({type:$.Type.STREAM_OPEN,streamOpen:{peer:t.toBytes(),proto:[e]}}),i=await n.read();if(i==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let s=C.decode(i);if(s.type!==C.Type.OK)throw await n.close(),new E(s.error?.msg??"Open stream failed","ERR_OPEN_STREAM_FAILED");return n.rest()}async registerStreamHandler(t,e){if(typeof t!="string")throw new E("invalid protocol received","ERR_INVALID_PROTOCOL");let n=this.tcp.createListener({upgrader:Xi,handler:l=>{Promise.resolve().then(async()=>{let d=new ar({stream:l}),h=await d.read();if(h==null)throw new E("Could not read open stream response","ERR_OPEN_STREAM_FAILED");if(He.decode(h).proto!==t)throw new E("Incorrect protocol","ERR_OPEN_STREAM_FAILED");await e(d.rest())}).finally(()=>{l.close().catch(d=>{ji.error(d)}),n.close().catch(d=>{ji.error(d)})})}});await n.listen(tt("/ip4/127.0.0.1/tcp/0"));let i=n.getAddrs()[0];if(i==null)throw new E("Could not listen on port","ERR_REGISTER_STREAM_HANDLER_FAILED");let s=await this.send({type:$.Type.STREAM_HANDLER,streamHandler:{addr:i.bytes,proto:[t]}}),a=await s.read();if(a==null)throw new E("Empty response from remote","ERR_EMPTY_RESPONSE");let f=C.decode(a);if(await s.close(),f.type!==C.Type.OK)throw new E(f.error?.msg??"Register stream handler failed","ERR_REGISTER_STREAM_HANDLER_FAILED")}};function Wh(r){return new Ji(r)}return Lu(Zh);})();
7
7
  return Libp2PDaemonClient}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/daemon-client",
3
- "version": "5.0.1",
3
+ "version": "5.0.2",
4
4
  "description": "libp2p-daemon client implementation",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p-daemon/tree/master/packages/libp2p-daemon-client#readme",
@@ -155,8 +155,8 @@
155
155
  "@libp2p/interface-peer-store": "^1.0.0",
156
156
  "@libp2p/interface-pubsub": "^3.0.0",
157
157
  "aegir": "^38.1.6",
158
- "it-all": "^2.0.0",
159
- "it-pipe": "^2.0.3",
158
+ "it-all": "^3.0.1",
159
+ "it-pipe": "^3.0.0",
160
160
  "sinon": "^15.0.1",
161
161
  "sinon-ts": "^1.0.0",
162
162
  "uint8arrays": "^4.0.2"