@libp2p/daemon-server 4.0.0 → 4.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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
4
4
  [![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
5
5
  [![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-daemon.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-daemon)
6
- [![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-daemon/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-daemon/actions/workflows/js-test-and-release.yml)
6
+ [![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-daemon/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/libp2p/js-libp2p-daemon/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
7
7
 
8
8
  > API server for libp2p-daemon instances
9
9
 
@@ -13,7 +13,7 @@
13
13
  - [Specs](#specs)
14
14
  - [Usage](#usage)
15
15
  - [License](#license)
16
- - [Contribute](#contribute)
16
+ - [Contribution](#contribution)
17
17
 
18
18
  ## Install
19
19
 
@@ -49,6 +49,6 @@ Licensed under either of
49
49
  - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
50
50
  - MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
51
51
 
52
- ## Contribute
52
+ ## Contribution
53
53
 
54
54
  Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
@@ -0,0 +1,7 @@
1
+ (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PDaemonServer = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
+ "use strict";var Libp2PDaemonServer=(()=>{var Ru=Object.create;var Sr=Object.defineProperty;var ku=Object.getOwnPropertyDescriptor;var Lu=Object.getOwnPropertyNames;var Ou=Object.getPrototypeOf,Nu=Object.prototype.hasOwnProperty;var Ot=(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 B=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),dt=(r,t)=>{for(var e in t)Sr(r,e,{get:t[e],enumerable:!0})},lo=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Lu(t))!Nu.call(r,i)&&i!==e&&Sr(r,i,{get:()=>t[i],enumerable:!(n=ku(t,i))||n.enumerable});return r};var N=(r,t,e)=>(e=r!=null?Ru(Ou(r)):{},lo(t||!r||!r.__esModule?Sr(e,"default",{value:r,enumerable:!0}):e,r)),Mu=r=>lo(Sr({},"__esModule",{value:!0}),r);var No=B((qp,Oo)=>{Oo.exports=Jn;var Lo=128,Wl=127,Zl=~Wl,Kl=Math.pow(2,31);function Jn(r,t,e){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw Jn.bytes=0,new RangeError("Could not encode varint");t=t||[],e=e||0;for(var n=e;r>=Kl;)t[e++]=r&255|Lo,r/=128;for(;r&Zl;)t[e++]=r&255|Lo,r>>>=7;return t[e]=r|0,Jn.bytes=e-n+1,t}});var Uo=B((Wp,Po)=>{Po.exports=Qn;var Xl=128,Mo=127;function Qn(r,n){var e=0,n=n||0,i=0,o=n,a,l=r.length;do{if(o>=l||i>49)throw Qn.bytes=0,new RangeError("Could not decode varint");a=r[o++],e+=i<28?(a&Mo)<<i:(a&Mo)*Math.pow(2,i),i+=7}while(a>=Xl);return Qn.bytes=o-n,e}});var Go=B((Zp,Fo)=>{var jl=Math.pow(2,7),Yl=Math.pow(2,14),Jl=Math.pow(2,21),Ql=Math.pow(2,28),tf=Math.pow(2,35),ef=Math.pow(2,42),rf=Math.pow(2,49),nf=Math.pow(2,56),of=Math.pow(2,63);Fo.exports=function(r){return r<jl?1:r<Yl?2:r<Jl?3:r<Ql?4:r<tf?5:r<ef?6:r<rf?7:r<nf?8:r<of?9:10}});var Dr=B((Kp,$o)=>{$o.exports={encode:No(),decode:Uo(),encodingLength:Go()}});var kr=B((dd,Jo)=>{"use strict";function Yo(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function Ef(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 Yo(r,e)}catch{e.message=r.message,e.stack=r.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(r)),Yo(new i,e)}}Jo.exports=Ef});var us=B((Id,as)=>{var Me=1e3,Pe=Me*60,Ue=Pe*60,ge=Ue*24,Rf=ge*7,kf=ge*365.25;as.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return Lf(r);if(e==="number"&&isFinite(r))return t.long?Nf(r):Of(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Lf(r){if(r=String(r),!(r.length>100)){var 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*kf;case"weeks":case"week":case"w":return e*Rf;case"days":case"day":case"d":return e*ge;case"hours":case"hour":case"hrs":case"hr":case"h":return e*Ue;case"minutes":case"minute":case"mins":case"min":case"m":return e*Pe;case"seconds":case"second":case"secs":case"sec":case"s":return e*Me;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function Of(r){var t=Math.abs(r);return t>=ge?Math.round(r/ge)+"d":t>=Ue?Math.round(r/Ue)+"h":t>=Pe?Math.round(r/Pe)+"m":t>=Me?Math.round(r/Me)+"s":r+"ms"}function Nf(r){var t=Math.abs(r);return t>=ge?Or(r,t,ge,"day"):t>=Ue?Or(r,t,Ue,"hour"):t>=Pe?Or(r,t,Pe,"minute"):t>=Me?Or(r,t,Me,"second"):r+" ms"}function Or(r,t,e,n){var i=t>=e*1.5;return Math.round(r/e)+" "+n+(i?"s":"")}});var fi=B((Cd,ls)=>{function Mf(r){e.debug=e,e.default=e,e.coerce=f,e.disable=o,e.enable=i,e.enabled=a,e.humanize=us(),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,S,b;function T(..._){if(!T.enabled)return;let I=T,D=Number(new Date),G=D-(g||D);I.diff=G,I.prev=g,I.curr=D,g=D,_[0]=e.coerce(_[0]),typeof _[0]!="string"&&_.unshift("%O");let q=0;_[0]=_[0].replace(/%([a-zA-Z%])/g,(ct,ot)=>{if(ct==="%%")return"%";q++;let at=e.formatters[ot];if(typeof at=="function"){let It=_[q];ct=at.call(I,It),_.splice(q,1),q--}return ct}),e.formatArgs.call(I,_),(I.log||e.log).apply(I,_)}return T.namespace=h,T.useColors=e.useColors(),T.color=e.selectColor(h),T.extend=n,T.destroy=e.destroy,Object.defineProperty(T,"enabled",{enumerable:!0,configurable:!1,get:()=>w!==null?w:(S!==e.namespaces&&(S=e.namespaces,b=e.enabled(h)),b),set:_=>{w=_}}),typeof e.init=="function"&&e.init(T),T}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,]+/),S=w.length;for(g=0;g<S;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 o(){let h=[...e.names.map(l),...e.skips.map(l).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 l(h){return h.toString().substring(2,h.toString().length-2).replace(/\.\*\?$/,"*")}function f(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}ls.exports=Mf});var fs=B((mt,Nr)=>{mt.formatArgs=Uf;mt.save=Ff;mt.load=Gf;mt.useColors=Pf;mt.storage=$f();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 Pf(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Uf(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Nr.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 Ff(r){try{r?mt.storage.setItem("debug",r):mt.storage.removeItem("debug")}catch{}}function Gf(){let r;try{r=mt.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function $f(){try{return localStorage}catch{}}Nr.exports=fi()(mt);var{formatters:zf}=Nr.exports;zf.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var ps=B((Dd,hs)=>{"use strict";hs.exports=(r,t=process.argv)=>{let e=r.startsWith("-")?"":r.length===1?"-":"--",n=t.indexOf(e+r),i=t.indexOf("--");return n!==-1&&(i===-1||n<i)}});var gs=B((_d,ms)=>{"use strict";var Vf=Ot("os"),ds=Ot("tty"),St=ps(),{env:X}=process,re;St("no-color")||St("no-colors")||St("color=false")||St("color=never")?re=0:(St("color")||St("colors")||St("color=true")||St("color=always"))&&(re=1);"FORCE_COLOR"in X&&(X.FORCE_COLOR==="true"?re=1:X.FORCE_COLOR==="false"?re=0:re=X.FORCE_COLOR.length===0?1:Math.min(parseInt(X.FORCE_COLOR,10),3));function hi(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function pi(r,t){if(re===0)return 0;if(St("color=16m")||St("color=full")||St("color=truecolor"))return 3;if(St("color=256"))return 2;if(r&&!t&&re===void 0)return 0;let e=re||0;if(X.TERM==="dumb")return e;if(process.platform==="win32"){let n=Vf.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in X)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in X)||X.CI_NAME==="codeship"?1:e;if("TEAMCITY_VERSION"in X)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(X.TEAMCITY_VERSION)?1:0;if(X.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in X){let n=parseInt((X.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(X.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(X.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(X.TERM)||"COLORTERM"in X?1:e}function Hf(r){let t=pi(r,r&&r.isTTY);return hi(t)}ms.exports={supportsColor:Hf,stdout:hi(pi(!0,ds.isatty(1))),stderr:hi(pi(!0,ds.isatty(2)))}});var bs=B((J,Pr)=>{var qf=Ot("tty"),Mr=Ot("util");J.init=Jf;J.log=Xf;J.formatArgs=Zf;J.save=jf;J.load=Yf;J.useColors=Wf;J.destroy=Mr.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");J.colors=[6,2,3,4,5,1];try{let r=gs();r&&(r.stderr||r).level>=2&&(J.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{}J.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,o)=>o.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 J.inspectOpts?Boolean(J.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),o=` ${i};1m${t} \x1B[0m`;r[0]=o+r[0].split(`
3
+ `).join(`
4
+ `+o),r.push(i+"m+"+Pr.exports.humanize(this.diff)+"\x1B[0m")}else r[0]=Kf()+t+" "+r[0]}function Kf(){return J.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Xf(...r){return process.stderr.write(Mr.format(...r)+`
5
+ `)}function jf(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function Yf(){return process.env.DEBUG}function Jf(r){r.inspectOpts={};let t=Object.keys(J.inspectOpts);for(let e=0;e<t.length;e++)r.inspectOpts[t[e]]=J.inspectOpts[t[e]]}Pr.exports=fi()(J);var{formatters:ys}=Pr.exports;ys.o=function(r){return this.inspectOpts.colors=this.useColors,Mr.inspect(r,this.inspectOpts).split(`
6
+ `).map(t=>t.trim()).join(" ")};ys.O=function(r){return this.inspectOpts.colors=this.useColors,Mr.inspect(r,this.inspectOpts)}});var ws=B((Bd,di)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?di.exports=fs():di.exports=bs()});var Ur=B((Nd,Es)=>{Es.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 Ss=B((Md,vs)=>{vs.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 mi=B((Pd,Ts)=>{var Qf=Ss();Ts.exports=r=>async t=>{t=Qf(t);let e=I=>{typeof I.return=="function"&&I.return()},n=null,i=null,o=I=>{n=I,i&&i(I),e(t)},a=null,l=!1,f=()=>{l=!0,a&&a()},d=null,h=!1,g=()=>{h=!0,d&&d()},w=null,S=()=>{w&&w()},b=()=>new Promise((I,D)=>{a=w=I,i=D,r.once("drain",S)}),T=()=>(e(t),new Promise((I,D)=>{if(l||h||n)return I();d=a=I,i=D})),_=()=>{r.removeListener("error",o),r.removeListener("close",f),r.removeListener("finish",g),r.removeListener("drain",S)};r.once("error",o),r.once("close",f),r.once("finish",g);try{for await(let I of t){if(!r.writable||r.destroyed||n)break;r.write(I)===!1&&await b()}}catch(I){n||r.destroy(),n=I}try{if(r.writable&&r.end(),await T(),n)throw n}finally{_()}}});var gi=B((Ud,xs)=>{var th=mi(),eh=Ur();xs.exports=r=>({sink:th(r),source:eh(r)})});var Is=B((Fd,As)=>{var rh=gi();As.exports=r=>async function*(t){let e=rh(r),n;if(e.sink(t).catch(i=>{n=i}),yield*e.source,n)throw n}});var Cs=B((Gd,Fe)=>{Fe.exports=Ur();Fe.exports.source=Ur();Fe.exports.sink=mi();Fe.exports.transform=Is();Fe.exports.duplex=gi()});var bi=B(($r,Bs)=>{(function(){var r,t=0xdeadbeefcafe,e=(t&16777215)==15715070;function n(s,c,u){s!=null&&(typeof s=="number"?this.fromNumber(s,c,u):c==null&&typeof s!="string"?this.fromString(s,256):this.fromString(s,c))}function i(){return new n(null)}function o(s,c,u,p,m,y){for(;--y>=0;){var E=c*this[s++]+u[p]+m;m=Math.floor(E/67108864),u[p++]=E&67108863}return m}function a(s,c,u,p,m,y){for(var E=c&32767,v=c>>15;--y>=0;){var L=this[s]&32767,K=this[s++]>>15,bt=v*L+K*E;L=E*L+((bt&32767)<<15)+u[p]+(m&1073741823),m=(L>>>30)+(bt>>>15)+v*K+(m>>>30),u[p++]=L&1073741823}return m}function l(s,c,u,p,m,y){for(var E=c&16383,v=c>>14;--y>=0;){var L=this[s]&16383,K=this[s++]>>14,bt=v*L+K*E;L=E*L+((bt&16383)<<14)+u[p]+m,m=(L>>28)+(bt>>14)+v*K,u[p++]=L&268435455}return m}var f=typeof navigator<"u";f&&e&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=a,r=30):f&&e&&navigator.appName!="Netscape"?(n.prototype.am=o,r=26):(n.prototype.am=l,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,S;for(w="0".charCodeAt(0),S=0;S<=9;++S)g[w++]=S;for(w="a".charCodeAt(0),S=10;S<36;++S)g[w++]=S;for(w="A".charCodeAt(0),S=10;S<36;++S)g[w++]=S;function b(s){return h.charAt(s)}function T(s,c){var u=g[s.charCodeAt(c)];return u??-1}function _(s){for(var c=this.t-1;c>=0;--c)s[c]=this[c];s.t=this.t,s.s=this.s}function I(s){this.t=1,this.s=s<0?-1:0,s>0?this[0]=s:s<-1?this[0]=s+this.DV:this.t=0}function D(s){var c=i();return c.fromInt(s),c}function G(s,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(s,c);return}this.t=0,this.s=0;for(var p=s.length,m=!1,y=0;--p>=0;){var E=u==8?s[p]&255:T(s,p);if(E<0){s.charAt(p)=="-"&&(m=!0);continue}m=!1,y==0?this[this.t++]=E:y+u>this.DB?(this[this.t-1]|=(E&(1<<this.DB-y)-1)<<y,this[this.t++]=E>>this.DB-y):this[this.t-1]|=E<<y,y+=u,y>=this.DB&&(y-=this.DB)}u==8&&s[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 s=this.s&this.DM;this.t>0&&this[this.t-1]==s;)--this.t}function ft(s){if(this.s<0)return"-"+this.negate().toString(s);var c;if(s==16)c=4;else if(s==8)c=3;else if(s==2)c=1;else if(s==32)c=5;else if(s==4)c=2;else return this.toRadix(s);var u=(1<<c)-1,p,m=!1,y="",E=this.t,v=this.DB-E*this.DB%c;if(E-- >0)for(v<this.DB&&(p=this[E]>>v)>0&&(m=!0,y=b(p));E>=0;)v<c?(p=(this[E]&(1<<v)-1)<<c-v,p|=this[--E]>>(v+=this.DB-c)):(p=this[E]>>(v-=c)&u,v<=0&&(v+=this.DB,--E)),p>0&&(m=!0),m&&(y+=b(p));return m?y:"0"}function ct(){var s=i();return n.ZERO.subTo(this,s),s}function ot(){return this.s<0?this.negate():this}function at(s){var c=this.s-s.s;if(c!=0)return c;var u=this.t;if(c=u-s.t,c!=0)return this.s<0?-c:c;for(;--u>=0;)if((c=this[u]-s[u])!=0)return c;return 0}function It(s){var c=1,u;return(u=s>>>16)!=0&&(s=u,c+=16),(u=s>>8)!=0&&(s=u,c+=8),(u=s>>4)!=0&&(s=u,c+=4),(u=s>>2)!=0&&(s=u,c+=2),(u=s>>1)!=0&&(s=u,c+=1),c}function Yc(){return this.t<=0?0:this.DB*(this.t-1)+It(this[this.t-1]^this.s&this.DM)}function Jc(s,c){var u;for(u=this.t-1;u>=0;--u)c[u+s]=this[u];for(u=s-1;u>=0;--u)c[u]=0;c.t=this.t+s,c.s=this.s}function Qc(s,c){for(var u=s;u<this.t;++u)c[u-s]=this[u];c.t=Math.max(this.t-s,0),c.s=this.s}function ta(s,c){var u=s%this.DB,p=this.DB-u,m=(1<<p)-1,y=Math.floor(s/this.DB),E=this.s<<u&this.DM,v;for(v=this.t-1;v>=0;--v)c[v+y+1]=this[v]>>p|E,E=(this[v]&m)<<u;for(v=y-1;v>=0;--v)c[v]=0;c[y]=E,c.t=this.t+y+1,c.s=this.s,c.clamp()}function ea(s,c){c.s=this.s;var u=Math.floor(s/this.DB);if(u>=this.t){c.t=0;return}var p=s%this.DB,m=this.DB-p,y=(1<<p)-1;c[0]=this[u]>>p;for(var E=u+1;E<this.t;++E)c[E-u-1]|=(this[E]&y)<<m,c[E-u]=this[E]>>p;p>0&&(c[this.t-u-1]|=(this.s&y)<<m),c.t=this.t-u,c.clamp()}function ra(s,c){for(var u=0,p=0,m=Math.min(s.t,this.t);u<m;)p+=this[u]-s[u],c[u++]=p&this.DM,p>>=this.DB;if(s.t<this.t){for(p-=s.s;u<this.t;)p+=this[u],c[u++]=p&this.DM,p>>=this.DB;p+=this.s}else{for(p+=this.s;u<s.t;)p-=s[u],c[u++]=p&this.DM,p>>=this.DB;p-=s.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 na(s,c){var u=this.abs(),p=s.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!=s.s&&n.ZERO.subTo(c,c)}function ia(s){for(var c=this.abs(),u=s.t=2*c.t;--u>=0;)s[u]=0;for(u=0;u<c.t-1;++u){var p=c.am(u,c[u],s,2*u,0,1);(s[u+c.t]+=c.am(u+1,2*c[u],s,2*u+1,p,c.t-u-1))>=c.DV&&(s[u+c.t]-=c.DV,s[u+c.t+1]=1)}s.t>0&&(s[s.t-1]+=c.am(u,c[u],s,2*u,0,1)),s.s=0,s.clamp()}function oa(s,c,u){var p=s.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(),E=this.s,v=s.s,L=this.DB-It(p[p.t-1]);L>0?(p.lShiftTo(L,y),m.lShiftTo(L,u)):(p.copyTo(y),m.copyTo(u));var K=y.t,bt=y[K-1];if(bt!=0){var pt=bt*(1<<this.F1)+(K>1?y[K-2]>>this.F2:0),Ft=this.FV/pt,Er=(1<<this.F1)/pt,Dt=1<<this.F2,_t=u.t,vr=_t-K,jt=c??i();for(y.dlShiftTo(vr,jt),u.compareTo(jt)>=0&&(u[u.t++]=1,u.subTo(jt,u)),n.ONE.dlShiftTo(K,jt),jt.subTo(y,y);y.t<K;)y[y.t++]=0;for(;--vr>=0;){var In=u[--_t]==bt?this.DM:Math.floor(u[_t]*Ft+(u[_t-1]+Dt)*Er);if((u[_t]+=y.am(0,In,u,vr,0,K))<In)for(y.dlShiftTo(vr,jt),u.subTo(jt,u);u[_t]<--In;)u.subTo(jt,u)}c!=null&&(u.drShiftTo(K,c),E!=v&&n.ZERO.subTo(c,c)),u.t=K,u.clamp(),L>0&&u.rShiftTo(L,u),E<0&&n.ZERO.subTo(u,u)}}}function sa(s){var c=i();return this.abs().divRemTo(s,null,c),this.s<0&&c.compareTo(n.ZERO)>0&&s.subTo(c,c),c}function ae(s){this.m=s}function ca(s){return s.s<0||s.compareTo(this.m)>=0?s.mod(this.m):s}function aa(s){return s}function ua(s){s.divRemTo(this.m,null,s)}function la(s,c,u){s.multiplyTo(c,u),this.reduce(u)}function fa(s,c){s.squareTo(c),this.reduce(c)}ae.prototype.convert=ca,ae.prototype.revert=aa,ae.prototype.reduce=ua,ae.prototype.mulTo=la,ae.prototype.sqrTo=fa;function ha(){if(this.t<1)return 0;var s=this[0];if(!(s&1))return 0;var c=s&3;return c=c*(2-(s&15)*c)&15,c=c*(2-(s&255)*c)&255,c=c*(2-((s&65535)*c&65535))&65535,c=c*(2-s*c%this.DV)%this.DV,c>0?this.DV-c:-c}function ue(s){this.m=s,this.mp=s.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<s.DB-15)-1,this.mt2=2*s.t}function pa(s){var c=i();return s.abs().dlShiftTo(this.m.t,c),c.divRemTo(this.m,null,c),s.s<0&&c.compareTo(n.ZERO)>0&&this.m.subTo(c,c),c}function da(s){var c=i();return s.copyTo(c),this.reduce(c),c}function ma(s){for(;s.t<=this.mt2;)s[s.t++]=0;for(var c=0;c<this.m.t;++c){var u=s[c]&32767,p=u*this.mpl+((u*this.mph+(s[c]>>15)*this.mpl&this.um)<<15)&s.DM;for(u=c+this.m.t,s[u]+=this.m.am(0,p,s,c,0,this.m.t);s[u]>=s.DV;)s[u]-=s.DV,s[++u]++}s.clamp(),s.drShiftTo(this.m.t,s),s.compareTo(this.m)>=0&&s.subTo(this.m,s)}function ga(s,c){s.squareTo(c),this.reduce(c)}function ya(s,c,u){s.multiplyTo(c,u),this.reduce(u)}ue.prototype.convert=pa,ue.prototype.revert=da,ue.prototype.reduce=ma,ue.prototype.mulTo=ya,ue.prototype.sqrTo=ga;function ba(){return(this.t>0?this[0]&1:this.s)==0}function wa(s,c){if(s>4294967295||s<1)return n.ONE;var u=i(),p=i(),m=c.convert(this),y=It(s)-1;for(m.copyTo(u);--y>=0;)if(c.sqrTo(u,p),(s&1<<y)>0)c.mulTo(p,m,u);else{var E=u;u=p,p=E}return c.revert(u)}function Ea(s,c){var u;return s<256||c.isEven()?u=new ae(c):u=new ue(c),this.exp(s,u)}n.prototype.copyTo=_,n.prototype.fromInt=I,n.prototype.fromString=G,n.prototype.clamp=q,n.prototype.dlShiftTo=Jc,n.prototype.drShiftTo=Qc,n.prototype.lShiftTo=ta,n.prototype.rShiftTo=ea,n.prototype.subTo=ra,n.prototype.multiplyTo=na,n.prototype.squareTo=ia,n.prototype.divRemTo=oa,n.prototype.invDigit=ha,n.prototype.isEven=ba,n.prototype.exp=wa,n.prototype.toString=ft,n.prototype.negate=ct,n.prototype.abs=ot,n.prototype.compareTo=at,n.prototype.bitLength=Yc,n.prototype.mod=sa,n.prototype.modPowInt=Ea,n.ZERO=D(0),n.ONE=D(1);function va(){var s=i();return this.copyTo(s),s}function Sa(){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 Ta(){return this.t==0?this.s:this[0]<<24>>24}function xa(){return this.t==0?this.s:this[0]<<16>>16}function Aa(s){return Math.floor(Math.LN2*this.DB/Math.log(s))}function Ia(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function Ca(s){if(s==null&&(s=10),this.signum()==0||s<2||s>36)return"0";var c=this.chunkSize(s),u=Math.pow(s,c),p=D(u),m=i(),y=i(),E="";for(this.divRemTo(p,m,y);m.signum()>0;)E=(u+y.intValue()).toString(s).substr(1)+E,m.divRemTo(p,m,y);return y.intValue().toString(s)+E}function Da(s,c){this.fromInt(0),c==null&&(c=10);for(var u=this.chunkSize(c),p=Math.pow(c,u),m=!1,y=0,E=0,v=0;v<s.length;++v){var L=T(s,v);if(L<0){s.charAt(v)=="-"&&this.signum()==0&&(m=!0);continue}E=c*E+L,++y>=u&&(this.dMultiply(p),this.dAddOffset(E,0),y=0,E=0)}y>0&&(this.dMultiply(Math.pow(c,y)),this.dAddOffset(E,0)),m&&n.ZERO.subTo(this,this)}function _a(s,c,u){if(typeof c=="number")if(s<2)this.fromInt(1);else for(this.fromNumber(s,u),this.testBit(s-1)||this.bitwiseTo(n.ONE.shiftLeft(s-1),Sn,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(c);)this.dAddOffset(2,0),this.bitLength()>s&&this.subTo(n.ONE.shiftLeft(s-1),this);else{var p=new Array,m=s&7;p.length=(s>>3)+1,c.nextBytes(p),m>0?p[0]&=(1<<m)-1:p[0]=0,this.fromString(p,256)}}function Ba(){var s=this.t,c=new Array;c[0]=this.s;var u=this.DB-s*this.DB%8,p,m=0;if(s-- >0)for(u<this.DB&&(p=this[s]>>u)!=(this.s&this.DM)>>u&&(c[m++]=p|this.s<<this.DB-u);s>=0;)u<8?(p=(this[s]&(1<<u)-1)<<8-u,p|=this[--s]>>(u+=this.DB-8)):(p=this[s]>>(u-=8)&255,u<=0&&(u+=this.DB,--s)),p&128&&(p|=-256),m==0&&(this.s&128)!=(p&128)&&++m,(m>0||p!=this.s)&&(c[m++]=p);return c}function Ra(s){return this.compareTo(s)==0}function ka(s){return this.compareTo(s)<0?this:s}function La(s){return this.compareTo(s)>0?this:s}function Oa(s,c,u){var p,m,y=Math.min(s.t,this.t);for(p=0;p<y;++p)u[p]=c(this[p],s[p]);if(s.t<this.t){for(m=s.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<s.t;++p)u[p]=c(m,s[p]);u.t=s.t}u.s=c(this.s,s.s),u.clamp()}function Na(s,c){return s&c}function Ma(s){var c=i();return this.bitwiseTo(s,Na,c),c}function Sn(s,c){return s|c}function Pa(s){var c=i();return this.bitwiseTo(s,Sn,c),c}function io(s,c){return s^c}function Ua(s){var c=i();return this.bitwiseTo(s,io,c),c}function oo(s,c){return s&~c}function Fa(s){var c=i();return this.bitwiseTo(s,oo,c),c}function Ga(){for(var s=i(),c=0;c<this.t;++c)s[c]=this.DM&~this[c];return s.t=this.t,s.s=~this.s,s}function $a(s){var c=i();return s<0?this.rShiftTo(-s,c):this.lShiftTo(s,c),c}function za(s){var c=i();return s<0?this.lShiftTo(-s,c):this.rShiftTo(s,c),c}function Va(s){if(s==0)return-1;var c=0;return s&65535||(s>>=16,c+=16),s&255||(s>>=8,c+=8),s&15||(s>>=4,c+=4),s&3||(s>>=2,c+=2),s&1||++c,c}function Ha(){for(var s=0;s<this.t;++s)if(this[s]!=0)return s*this.DB+Va(this[s]);return this.s<0?this.t*this.DB:-1}function qa(s){for(var c=0;s!=0;)s&=s-1,++c;return c}function Wa(){for(var s=0,c=this.s&this.DM,u=0;u<this.t;++u)s+=qa(this[u]^c);return s}function Za(s){var c=Math.floor(s/this.DB);return c>=this.t?this.s!=0:(this[c]&1<<s%this.DB)!=0}function Ka(s,c){var u=n.ONE.shiftLeft(s);return this.bitwiseTo(u,c,u),u}function Xa(s){return this.changeBit(s,Sn)}function ja(s){return this.changeBit(s,oo)}function Ya(s){return this.changeBit(s,io)}function Ja(s,c){for(var u=0,p=0,m=Math.min(s.t,this.t);u<m;)p+=this[u]+s[u],c[u++]=p&this.DM,p>>=this.DB;if(s.t<this.t){for(p+=s.s;u<this.t;)p+=this[u],c[u++]=p&this.DM,p>>=this.DB;p+=this.s}else{for(p+=this.s;u<s.t;)p+=s[u],c[u++]=p&this.DM,p>>=this.DB;p+=s.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 Qa(s){var c=i();return this.addTo(s,c),c}function tu(s){var c=i();return this.subTo(s,c),c}function eu(s){var c=i();return this.multiplyTo(s,c),c}function ru(){var s=i();return this.squareTo(s),s}function nu(s){var c=i();return this.divRemTo(s,c,null),c}function iu(s){var c=i();return this.divRemTo(s,null,c),c}function ou(s){var c=i(),u=i();return this.divRemTo(s,c,u),new Array(c,u)}function su(s){this[this.t]=this.am(0,s-1,this,0,0,this.t),++this.t,this.clamp()}function cu(s,c){if(s!=0){for(;this.t<=c;)this[this.t++]=0;for(this[c]+=s;this[c]>=this.DV;)this[c]-=this.DV,++c>=this.t&&(this[this.t++]=0),++this[c]}}function je(){}function so(s){return s}function au(s,c,u){s.multiplyTo(c,u)}function uu(s,c){s.squareTo(c)}je.prototype.convert=so,je.prototype.revert=so,je.prototype.mulTo=au,je.prototype.sqrTo=uu;function lu(s){return this.exp(s,new je)}function fu(s,c,u){var p=Math.min(this.t+s.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,s[p],u,p,0,this.t);for(m=Math.min(s.t,c);p<m;++p)this.am(0,s[p],u,p,0,c-p);u.clamp()}function hu(s,c,u){--c;var p=u.t=this.t+s.t-c;for(u.s=0;--p>=0;)u[p]=0;for(p=Math.max(c-this.t,0);p<s.t;++p)u[this.t+p-c]=this.am(c-p,s[p],u,0,0,this.t+p-c);u.clamp(),u.drShiftTo(1,u)}function le(s){this.r2=i(),this.q3=i(),n.ONE.dlShiftTo(2*s.t,this.r2),this.mu=this.r2.divide(s),this.m=s}function pu(s){if(s.s<0||s.t>2*this.m.t)return s.mod(this.m);if(s.compareTo(this.m)<0)return s;var c=i();return s.copyTo(c),this.reduce(c),c}function du(s){return s}function mu(s){for(s.drShiftTo(this.m.t-1,this.r2),s.t>this.m.t+1&&(s.t=this.m.t+1,s.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);s.compareTo(this.r2)<0;)s.dAddOffset(1,this.m.t+1);for(s.subTo(this.r2,s);s.compareTo(this.m)>=0;)s.subTo(this.m,s)}function gu(s,c){s.squareTo(c),this.reduce(c)}function yu(s,c,u){s.multiplyTo(c,u),this.reduce(u)}le.prototype.convert=pu,le.prototype.revert=du,le.prototype.reduce=mu,le.prototype.mulTo=yu,le.prototype.sqrTo=gu;function bu(s,c){var u=s.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 ae(c):c.isEven()?y=new le(c):y=new ue(c);var E=new Array,v=3,L=p-1,K=(1<<p)-1;if(E[1]=y.convert(this),p>1){var bt=i();for(y.sqrTo(E[1],bt);v<=K;)E[v]=i(),y.mulTo(bt,E[v-2],E[v]),v+=2}var pt=s.t-1,Ft,Er=!0,Dt=i(),_t;for(u=It(s[pt])-1;pt>=0;){for(u>=L?Ft=s[pt]>>u-L&K:(Ft=(s[pt]&(1<<u+1)-1)<<L-u,pt>0&&(Ft|=s[pt-1]>>this.DB+u-L)),v=p;!(Ft&1);)Ft>>=1,--v;if((u-=v)<0&&(u+=this.DB,--pt),Er)E[Ft].copyTo(m),Er=!1;else{for(;v>1;)y.sqrTo(m,Dt),y.sqrTo(Dt,m),v-=2;v>0?y.sqrTo(m,Dt):(_t=m,m=Dt,Dt=_t),y.mulTo(Dt,E[Ft],m)}for(;pt>=0&&!(s[pt]&1<<u);)y.sqrTo(m,Dt),_t=m,m=Dt,Dt=_t,--u<0&&(u=this.DB-1,--pt)}return y.revert(m)}function wu(s){var c=this.s<0?this.negate():this.clone(),u=s.s<0?s.negate():s.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 Eu(s){if(s<=0)return 0;var c=this.DV%s,u=this.s<0?s-1:0;if(this.t>0)if(c==0)u=this[0]%s;else for(var p=this.t-1;p>=0;--p)u=(c*u+this[p])%s;return u}function vu(s){var c=s.isEven();if(this.isEven()&&c||s.signum()==0)return n.ZERO;for(var u=s.clone(),p=this.clone(),m=D(1),y=D(0),E=D(0),v=D(1);u.signum()!=0;){for(;u.isEven();)u.rShiftTo(1,u),c?((!m.isEven()||!y.isEven())&&(m.addTo(this,m),y.subTo(s,y)),m.rShiftTo(1,m)):y.isEven()||y.subTo(s,y),y.rShiftTo(1,y);for(;p.isEven();)p.rShiftTo(1,p),c?((!E.isEven()||!v.isEven())&&(E.addTo(this,E),v.subTo(s,v)),E.rShiftTo(1,E)):v.isEven()||v.subTo(s,v),v.rShiftTo(1,v);u.compareTo(p)>=0?(u.subTo(p,u),c&&m.subTo(E,m),y.subTo(v,y)):(p.subTo(u,p),c&&E.subTo(m,E),v.subTo(y,v))}if(p.compareTo(n.ONE)!=0)return n.ZERO;if(v.compareTo(s)>=0)return v.subtract(s);if(v.signum()<0)v.addTo(s,v);else return v;return v.signum()<0?v.add(s):v}var st=[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],Su=(1<<26)/st[st.length-1];function Tu(s){var c,u=this.abs();if(u.t==1&&u[0]<=st[st.length-1]){for(c=0;c<st.length;++c)if(u[0]==st[c])return!0;return!1}if(u.isEven())return!1;for(c=1;c<st.length;){for(var p=st[c],m=c+1;m<st.length&&p<Su;)p*=st[m++];for(p=u.modInt(p);c<m;)if(p%st[c++]==0)return!1}return u.millerRabin(s)}function xu(s){var c=this.subtract(n.ONE),u=c.getLowestSetBit();if(u<=0)return!1;var p=c.shiftRight(u);s=s+1>>1,s>st.length&&(s=st.length);for(var m=i(),y=0;y<s;++y){m.fromInt(st[Math.floor(Math.random()*st.length)]);var E=m.modPow(p,this);if(E.compareTo(n.ONE)!=0&&E.compareTo(c)!=0){for(var v=1;v++<u&&E.compareTo(c)!=0;)if(E=E.modPowInt(2,this),E.compareTo(n.ONE)==0)return!1;if(E.compareTo(c)!=0)return!1}}return!0}n.prototype.chunkSize=Aa,n.prototype.toRadix=Ca,n.prototype.fromRadix=Da,n.prototype.fromNumber=_a,n.prototype.bitwiseTo=Oa,n.prototype.changeBit=Ka,n.prototype.addTo=Ja,n.prototype.dMultiply=su,n.prototype.dAddOffset=cu,n.prototype.multiplyLowerTo=fu,n.prototype.multiplyUpperTo=hu,n.prototype.modInt=Eu,n.prototype.millerRabin=xu,n.prototype.clone=va,n.prototype.intValue=Sa,n.prototype.byteValue=Ta,n.prototype.shortValue=xa,n.prototype.signum=Ia,n.prototype.toByteArray=Ba,n.prototype.equals=Ra,n.prototype.min=ka,n.prototype.max=La,n.prototype.and=Ma,n.prototype.or=Pa,n.prototype.xor=Ua,n.prototype.andNot=Fa,n.prototype.not=Ga,n.prototype.shiftLeft=$a,n.prototype.shiftRight=za,n.prototype.getLowestSetBit=Ha,n.prototype.bitCount=Wa,n.prototype.testBit=Za,n.prototype.setBit=Xa,n.prototype.clearBit=ja,n.prototype.flipBit=Ya,n.prototype.add=Qa,n.prototype.subtract=tu,n.prototype.multiply=eu,n.prototype.divide=nu,n.prototype.remainder=iu,n.prototype.divideAndRemainder=ou,n.prototype.modPow=bu,n.prototype.modInverse=vu,n.prototype.pow=lu,n.prototype.gcd=wu,n.prototype.isProbablePrime=Tu,n.prototype.square=ru,n.prototype.Barrett=le;var wr,ht,Z;function Au(s){ht[Z++]^=s&255,ht[Z++]^=s>>8&255,ht[Z++]^=s>>16&255,ht[Z++]^=s>>24&255,Z>=An&&(Z-=An)}function co(){Au(new Date().getTime())}if(ht==null){ht=new Array,Z=0;var Ct;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var ao=new Uint8Array(32);for(window.crypto.getRandomValues(ao),Ct=0;Ct<32;++Ct)ht[Z++]=ao[Ct]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var uo=window.crypto.random(32);for(Ct=0;Ct<uo.length;++Ct)ht[Z++]=uo.charCodeAt(Ct)&255}}for(;Z<An;)Ct=Math.floor(65536*Math.random()),ht[Z++]=Ct>>>8,ht[Z++]=Ct&255;Z=0,co()}function Iu(){if(wr==null){for(co(),wr=Bu(),wr.init(ht),Z=0;Z<ht.length;++Z)ht[Z]=0;Z=0}return wr.next()}function Cu(s){var c;for(c=0;c<s.length;++c)s[c]=Iu()}function Tn(){}Tn.prototype.nextBytes=Cu;function xn(){this.i=0,this.j=0,this.S=new Array}function Du(s){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]+s[c%s.length]&255,p=this.S[c],this.S[c]=this.S[u],this.S[u]=p;this.i=0,this.j=0}function _u(){var s;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,s=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=s,this.S[s+this.S[this.i]&255]}xn.prototype.init=Du,xn.prototype.next=_u;function Bu(){return new xn}var An=256;typeof $r<"u"?$r=Bs.exports={default:n,BigInteger:n,SecureRandom:Tn}:this.jsbn={BigInteger:n,SecureRandom:Tn}}).call($r)});var ur=B(zr=>{(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(o(a),arguments)}function e(a,l){return t.apply(null,[a].concat(l||[]))}function n(a,l){var f=1,d=a.length,h,g="",w,S,b,T,_,I,D,G;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=l[f],S=0;S<b.keys.length;S++){if(h==null)throw new Error(t('[sprintf] Cannot access property "%s" of undefined value "%s"',b.keys[S],b.keys[S-1]));h=h[b.keys[S]]}else b.param_no?h=l[b.param_no]:h=l[f++];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)?(G=D?"+":"-",h=h.toString().replace(r.sign,"")):G="",_=b.pad_char?b.pad_char==="0"?"0":b.pad_char.charAt(1):" ",I=b.width-(G+h).length,T=b.width&&I>0?_.repeat(I):"",g+=b.align?G+h+T:_==="0"?G+T+h:T+G+h)}return g}var i=Object.create(null);function o(a){if(i[a])return i[a];for(var l=a,f,d=[],h=0;l;){if((f=r.text.exec(l))!==null)d.push(f[0]);else if((f=r.modulo.exec(l))!==null)d.push("%");else if((f=r.placeholder.exec(l))!==null){if(f[2]){h|=1;var g=[],w=f[2],S=[];if((S=r.key.exec(w))!==null)for(g.push(S[1]);(w=w.substring(S[0].length))!=="";)if((S=r.key_access.exec(w))!==null)g.push(S[1]);else if((S=r.index_access.exec(w))!==null)g.push(S[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");f[2]=g}else h|=2;if(h===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");d.push({placeholder:f[0],param_no:f[1],keys:f[2],sign:f[3],pad_char:f[4],align:f[5],width:f[6],precision:f[7],type:f[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");l=l.substring(f[0].length)}return i[a]=d}typeof zr<"u"&&(zr.sprintf=t,zr.vsprintf=e),typeof window<"u"&&(window.sprintf=t,window.vsprintf=e,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:e}}))})()});var nc=B((m0,rc)=>{"use strict";rc.exports=kh;function kh(r,t){for(var e=new Array(arguments.length-1),n=0,i=2,o=!0;i<arguments.length;)e[n++]=arguments[i++];return new Promise(function(l,f){e[n]=function(h){if(o)if(o=!1,h)f(h);else{for(var g=new Array(arguments.length-1),w=0;w<g.length;)g[w++]=arguments[w];l.apply(null,g)}};try{r.apply(t||null,e)}catch(d){o&&(o=!1,f(d))}})}});var cc=B(sc=>{"use strict";var rn=sc;rn.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 Ze=new Array(64),oc=new Array(123);for(kt=0;kt<64;)oc[Ze[kt]=kt<26?kt+65:kt<52?kt+71:kt<62?kt-4:kt-59|43]=kt++;var kt;rn.encode=function(t,e,n){for(var i=null,o=[],a=0,l=0,f;e<n;){var d=t[e++];switch(l){case 0:o[a++]=Ze[d>>2],f=(d&3)<<4,l=1;break;case 1:o[a++]=Ze[f|d>>4],f=(d&15)<<2,l=2;break;case 2:o[a++]=Ze[f|d>>6],o[a++]=Ze[d&63],l=0;break}a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,o)),a=0)}return l&&(o[a++]=Ze[f],o[a++]=61,l===1&&(o[a++]=61)),i?(a&&i.push(String.fromCharCode.apply(String,o.slice(0,a))),i.join("")):String.fromCharCode.apply(String,o.slice(0,a))};var ic="invalid encoding";rn.decode=function(t,e,n){for(var i=n,o=0,a,l=0;l<t.length;){var f=t.charCodeAt(l++);if(f===61&&o>1)break;if((f=oc[f])===void 0)throw Error(ic);switch(o){case 0:a=f,o=1;break;case 1:e[n++]=a<<2|(f&48)>>4,a=f,o=2;break;case 2:e[n++]=(a&15)<<4|(f&60)>>2,a=f,o=3;break;case 3:e[n++]=(a&3)<<6|f,o=0;break}}if(o===1)throw Error(ic);return n-i};rn.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}});var uc=B((y0,ac)=>{"use strict";ac.exports=nn;function nn(){this._listeners={}}nn.prototype.on=function(t,e,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:n||this}),this};nn.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};nn.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 gc=B((b0,mc)=>{"use strict";mc.exports=lc(lc);function lc(r){return typeof Float32Array<"u"?function(){var t=new Float32Array([-0]),e=new Uint8Array(t.buffer),n=e[3]===128;function i(f,d,h){t[0]=f,d[h]=e[0],d[h+1]=e[1],d[h+2]=e[2],d[h+3]=e[3]}function o(f,d,h){t[0]=f,d[h]=e[3],d[h+1]=e[2],d[h+2]=e[1],d[h+3]=e[0]}r.writeFloatLE=n?i:o,r.writeFloatBE=n?o:i;function a(f,d){return e[0]=f[d],e[1]=f[d+1],e[2]=f[d+2],e[3]=f[d+3],t[0]}function l(f,d){return e[3]=f[d],e[2]=f[d+1],e[1]=f[d+2],e[0]=f[d+3],t[0]}r.readFloatLE=n?a:l,r.readFloatBE=n?l:a}():function(){function t(n,i,o,a){var l=i<0?1:0;if(l&&(i=-i),i===0)n(1/i>0?0:2147483648,o,a);else if(isNaN(i))n(2143289344,o,a);else if(i>34028234663852886e22)n((l<<31|2139095040)>>>0,o,a);else if(i<11754943508222875e-54)n((l<<31|Math.round(i/1401298464324817e-60))>>>0,o,a);else{var f=Math.floor(Math.log(i)/Math.LN2),d=Math.round(i*Math.pow(2,-f)*8388608)&8388607;n((l<<31|f+127<<23|d)>>>0,o,a)}}r.writeFloatLE=t.bind(null,fc),r.writeFloatBE=t.bind(null,hc);function e(n,i,o){var a=n(i,o),l=(a>>31)*2+1,f=a>>>23&255,d=a&8388607;return f===255?d?NaN:l*(1/0):f===0?l*1401298464324817e-60*d:l*Math.pow(2,f-150)*(d+8388608)}r.readFloatLE=e.bind(null,pc),r.readFloatBE=e.bind(null,dc)}(),typeof Float64Array<"u"?function(){var t=new Float64Array([-0]),e=new Uint8Array(t.buffer),n=e[7]===128;function i(f,d,h){t[0]=f,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 o(f,d,h){t[0]=f,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:o,r.writeDoubleBE=n?o:i;function a(f,d){return e[0]=f[d],e[1]=f[d+1],e[2]=f[d+2],e[3]=f[d+3],e[4]=f[d+4],e[5]=f[d+5],e[6]=f[d+6],e[7]=f[d+7],t[0]}function l(f,d){return e[7]=f[d],e[6]=f[d+1],e[5]=f[d+2],e[4]=f[d+3],e[3]=f[d+4],e[2]=f[d+5],e[1]=f[d+6],e[0]=f[d+7],t[0]}r.readDoubleLE=n?a:l,r.readDoubleBE=n?l:a}():function(){function t(n,i,o,a,l,f){var d=a<0?1:0;if(d&&(a=-a),a===0)n(0,l,f+i),n(1/a>0?0:2147483648,l,f+o);else if(isNaN(a))n(0,l,f+i),n(2146959360,l,f+o);else if(a>17976931348623157e292)n(0,l,f+i),n((d<<31|2146435072)>>>0,l,f+o);else{var h;if(a<22250738585072014e-324)h=a/5e-324,n(h>>>0,l,f+i),n((d<<31|h/4294967296)>>>0,l,f+o);else{var g=Math.floor(Math.log(a)/Math.LN2);g===1024&&(g=1023),h=a*Math.pow(2,-g),n(h*4503599627370496>>>0,l,f+i),n((d<<31|g+1023<<20|h*1048576&1048575)>>>0,l,f+o)}}}r.writeDoubleLE=t.bind(null,fc,0,4),r.writeDoubleBE=t.bind(null,hc,4,0);function e(n,i,o,a,l){var f=n(a,l+i),d=n(a,l+o),h=(d>>31)*2+1,g=d>>>20&2047,w=4294967296*(d&1048575)+f;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,pc,0,4),r.readDoubleBE=e.bind(null,dc,4,0)}(),r}function fc(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 hc(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 pc(r,t){return(r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24)>>>0}function dc(r,t){return(r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3])>>>0}});var yc=B((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 wc=B(bc=>{"use strict";var $i=bc;$i.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};$i.read=function(t,e,n){var i=n-e;if(i<1)return"";for(var o=null,a=[],l=0,f;e<n;)f=t[e++],f<128?a[l++]=f:f>191&&f<224?a[l++]=(f&31)<<6|t[e++]&63:f>239&&f<365?(f=((f&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,a[l++]=55296+(f>>10),a[l++]=56320+(f&1023)):a[l++]=(f&15)<<12|(t[e++]&63)<<6|t[e++]&63,l>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,a)),l=0);return o?(l&&o.push(String.fromCharCode.apply(String,a.slice(0,l))),o.join("")):String.fromCharCode.apply(String,a.slice(0,l))};$i.write=function(t,e,n){for(var i=n,o,a,l=0;l<t.length;++l)o=t.charCodeAt(l),o<128?e[n++]=o:o<2048?(e[n++]=o>>6|192,e[n++]=o&63|128):(o&64512)===55296&&((a=t.charCodeAt(l+1))&64512)===56320?(o=65536+((o&1023)<<10)+(a&1023),++l,e[n++]=o>>18|240,e[n++]=o>>12&63|128,e[n++]=o>>6&63|128,e[n++]=o&63|128):(e[n++]=o>>12|224,e[n++]=o>>6&63|128,e[n++]=o&63|128);return n-i}});var vc=B((E0,Ec)=>{"use strict";Ec.exports=Lh;function Lh(r,t,e){var n=e||8192,i=n>>>1,o=null,a=n;return function(f){if(f<1||f>i)return r(f);a+f>n&&(o=r(n),a=0);var d=t.call(o,a,a+=f);return a&7&&(a=(a|7)+1),d}}});var Tc=B((v0,Sc)=>{"use strict";Sc.exports=j;var hr=xe();function j(r,t){this.lo=r>>>0,this.hi=t>>>0}var Te=j.zero=new j(0,0);Te.toNumber=function(){return 0};Te.zzEncode=Te.zzDecode=function(){return this};Te.length=function(){return 1};var Oh=j.zeroHash="\0\0\0\0\0\0\0\0";j.fromNumber=function(t){if(t===0)return Te;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(hr.isString(t))if(hr.Long)t=hr.Long.fromString(t);else return j.fromNumber(parseInt(t,10));return t.low||t.high?new j(t.low>>>0,t.high>>>0):Te};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 hr.Long?new hr.Long(this.lo|0,this.hi|0,Boolean(t)):{low:this.lo|0,high:this.hi|0,unsigned:Boolean(t)}};var ie=String.prototype.charCodeAt;j.fromHash=function(t){return t===Oh?Te:new j((ie.call(t,0)|ie.call(t,1)<<8|ie.call(t,2)<<16|ie.call(t,3)<<24)>>>0,(ie.call(t,4)|ie.call(t,5)<<8|ie.call(t,6)<<16|ie.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 xe=B(zi=>{"use strict";var x=zi;x.asPromise=nc();x.base64=cc();x.EventEmitter=uc();x.float=gc();x.inquire=yc();x.utf8=wc();x.pool=vc();x.LongBits=Tc();x.isNode=Boolean(typeof globalThis<"u"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);x.global=x.isNode&&globalThis||typeof window<"u"&&window||typeof self<"u"&&self||zi;x.emptyArray=Object.freeze?Object.freeze([]):[];x.emptyObject=Object.freeze?Object.freeze({}):{};x.isInteger=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};x.isString=function(t){return typeof t=="string"||t instanceof String};x.isObject=function(t){return t&&typeof t=="object"};x.isset=x.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};x.Buffer=function(){try{var r=x.inquire("buffer").Buffer;return r.prototype.utf8Write?r:null}catch{return null}}();x._Buffer_from=null;x._Buffer_allocUnsafe=null;x.newBuffer=function(t){return typeof t=="number"?x.Buffer?x._Buffer_allocUnsafe(t):new x.Array(t):x.Buffer?x._Buffer_from(t):typeof Uint8Array>"u"?t:new Uint8Array(t)};x.Array=typeof Uint8Array<"u"?Uint8Array:Array;x.Long=x.global.dcodeIO&&x.global.dcodeIO.Long||x.global.Long||x.inquire("long");x.key2Re=/^true|false|0|1$/;x.key32Re=/^-?(?:0|[1-9][0-9]*)$/;x.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;x.longToHash=function(t){return t?x.LongBits.from(t).toHash():x.LongBits.zeroHash};x.longFromHash=function(t,e){var n=x.LongBits.fromHash(t);return x.Long?x.Long.fromBits(n.lo,n.hi,e):n.toNumber(Boolean(e))};function xc(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}x.merge=xc;x.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)};function Ac(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&&xc(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}x.newError=Ac;x.ProtocolError=Ac("ProtocolError");x.oneOfGetter=function(t){for(var e={},n=0;n<t.length;++n)e[t[n]]=1;return function(){for(var i=Object.keys(this),o=i.length-1;o>-1;--o)if(e[i[o]]===1&&this[i[o]]!==void 0&&this[i[o]]!==null)return i[o]}};x.oneOfSetter=function(t){return function(e){for(var n=0;n<t.length;++n)t[n]!==e&&delete this[t[n]]}};x.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};x._configure=function(){var r=x.Buffer;if(!r){x._Buffer_from=x._Buffer_allocUnsafe=null;return}x._Buffer_from=r.from!==Uint8Array.from&&r.from||function(e,n){return new r(e,n)},x._Buffer_allocUnsafe=r.allocUnsafe||function(e){return new r(e)}}});var qi=B((T0,Bc)=>{"use strict";Bc.exports=$;var Pt=xe(),Hi,Dc=Pt.LongBits,Nh=Pt.utf8;function Lt(r,t){return RangeError("index out of range: "+r.pos+" + "+(t||1)+" > "+r.len)}function $(r){this.buf=r,this.pos=0,this.len=r.length}var Ic=typeof Uint8Array<"u"?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new $(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new $(t);throw Error("illegal buffer")},_c=function(){return Pt.Buffer?function(e){return($.create=function(i){return Pt.Buffer.isBuffer(i)?new Hi(i):Ic(i)})(e)}:Ic};$.create=_c();$.prototype._slice=Pt.Array.prototype.subarray||Pt.Array.prototype.slice;$.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,Lt(this,10);return t}}();$.prototype.int32=function(){return this.uint32()|0};$.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(t&1)|0};function Vi(){var r=new Dc(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 Lt(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 Lt(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")}$.prototype.bool=function(){return this.uint32()!==0};function on(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}$.prototype.fixed32=function(){if(this.pos+4>this.len)throw Lt(this,4);return on(this.buf,this.pos+=4)};$.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Lt(this,4);return on(this.buf,this.pos+=4)|0};function Cc(){if(this.pos+8>this.len)throw Lt(this,8);return new Dc(on(this.buf,this.pos+=4),on(this.buf,this.pos+=4))}$.prototype.float=function(){if(this.pos+4>this.len)throw Lt(this,4);var t=Pt.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};$.prototype.double=function(){if(this.pos+8>this.len)throw Lt(this,4);var t=Pt.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};$.prototype.bytes=function(){var t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Lt(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)};$.prototype.string=function(){var t=this.bytes();return Nh.read(t,0,t.length)};$.prototype.skip=function(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Lt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Lt(this);while(this.buf[this.pos++]&128);return this};$.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};$._configure=function(r){Hi=r,$.create=_c(),Hi._configure();var t=Pt.Long?"toLong":"toNumber";Pt.merge($.prototype,{int64:function(){return Vi.call(this)[t](!1)},uint64:function(){return Vi.call(this)[t](!0)},sint64:function(){return Vi.call(this).zzDecode()[t](!1)},fixed64:function(){return Cc.call(this)[t](!0)},sfixed64:function(){return Cc.call(this)[t](!1)}})}});var Oc=B((x0,Lc)=>{"use strict";Lc.exports=Ae;var kc=qi();(Ae.prototype=Object.create(kc.prototype)).constructor=Ae;var Rc=xe();function Ae(r){kc.call(this,r)}Ae._configure=function(){Rc.Buffer&&(Ae.prototype._slice=Rc.Buffer.prototype.slice)};Ae.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))};Ae._configure()});var Ji=B((A0,Uc)=>{"use strict";Uc.exports=R;var Tt=xe(),Wi,sn=Tt.LongBits,Nc=Tt.base64,Mc=Tt.utf8;function pr(r,t,e){this.fn=r,this.len=t,this.next=void 0,this.val=e}function Ki(){}function Mh(r){this.head=r.head,this.tail=r.tail,this.len=r.len,this.next=r.states}function R(){this.len=0,this.head=new pr(Ki,0,0),this.tail=this.head,this.states=null}var Pc=function(){return Tt.Buffer?function(){return(R.create=function(){return new Wi})()}:function(){return new R}};R.create=Pc();R.alloc=function(t){return new Tt.Array(t)};Tt.Array!==Array&&(R.alloc=Tt.pool(R.alloc,Tt.Array.prototype.subarray));R.prototype._push=function(t,e,n){return this.tail=this.tail.next=new pr(t,e,n),this.len+=e,this};function Xi(r,t,e){t[e]=r&255}function Ph(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}function ji(r,t){this.len=r,this.next=void 0,this.val=t}ji.prototype=Object.create(pr.prototype);ji.prototype.fn=Ph;R.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new ji((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};R.prototype.int32=function(t){return t<0?this._push(Yi,10,sn.fromNumber(t)):this.uint32(t)};R.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)};function Yi(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}R.prototype.uint64=function(t){var e=sn.from(t);return this._push(Yi,e.length(),e)};R.prototype.int64=R.prototype.uint64;R.prototype.sint64=function(t){var e=sn.from(t).zzEncode();return this._push(Yi,e.length(),e)};R.prototype.bool=function(t){return this._push(Xi,1,t?1:0)};function Zi(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}R.prototype.fixed32=function(t){return this._push(Zi,4,t>>>0)};R.prototype.sfixed32=R.prototype.fixed32;R.prototype.fixed64=function(t){var e=sn.from(t);return this._push(Zi,4,e.lo)._push(Zi,4,e.hi)};R.prototype.sfixed64=R.prototype.fixed64;R.prototype.float=function(t){return this._push(Tt.float.writeFloatLE,4,t)};R.prototype.double=function(t){return this._push(Tt.float.writeDoubleLE,8,t)};var Uh=Tt.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]};R.prototype.bytes=function(t){var e=t.length>>>0;if(!e)return this._push(Xi,1,0);if(Tt.isString(t)){var n=R.alloc(e=Nc.length(t));Nc.decode(t,n,0),t=n}return this.uint32(e)._push(Uh,e,t)};R.prototype.string=function(t){var e=Mc.length(t);return e?this.uint32(e)._push(Mc.write,e,t):this._push(Xi,1,0)};R.prototype.fork=function(){return this.states=new Mh(this),this.head=this.tail=new pr(Ki,0,0),this.len=0,this};R.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(Ki,0,0),this.len=0),this};R.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};R.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};R._configure=function(r){Wi=r,R.create=Pc(),Wi._configure()}});var $c=B((I0,Gc)=>{"use strict";Gc.exports=Ut;var Fc=Ji();(Ut.prototype=Object.create(Fc.prototype)).constructor=Ut;var oe=xe();function Ut(){Fc.call(this)}Ut._configure=function(){Ut.alloc=oe._Buffer_allocUnsafe,Ut.writeBytesBuffer=oe.Buffer&&oe.Buffer.prototype instanceof Uint8Array&&oe.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++]}};Ut.prototype.bytes=function(t){oe.isString(t)&&(t=oe._Buffer_from(t,"base64"));var e=t.length>>>0;return this.uint32(e),e&&this._push(Ut.writeBytesBuffer,e,t),this};function Fh(r,t,e){r.length<40?oe.utf8.write(r,t,e):t.utf8Write?t.utf8Write(r,e):t.write(r,e)}Ut.prototype.string=function(t){var e=oe.Buffer.byteLength(t);return this.uint32(e),e&&this._push(Fh,e,t),this};Ut._configure()});var Kh={};dt(Kh,{Server:()=>vn,createServer:()=>Zh});var Ws=N(Ot("net"),1);var Yt=Ot("node:net");function Tr(r){return Boolean((0,Yt.isIP)(r))}var Rn={};dt(Rn,{identity:()=>zu});function Pu(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 o=r.charAt(i),a=o.charCodeAt(0);if(e[a]!==255)throw new TypeError(o+" is ambiguous");e[a]=i}var l=r.length,f=r.charAt(0),d=Math.log(l)/Math.log(256),h=Math.log(256)/Math.log(l);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 T=0,_=0,I=0,D=b.length;I!==D&&b[I]===0;)I++,T++;for(var G=(D-I)*h+1>>>0,q=new Uint8Array(G);I!==D;){for(var ft=b[I],ct=0,ot=G-1;(ft!==0||ct<_)&&ot!==-1;ot--,ct++)ft+=256*q[ot]>>>0,q[ot]=ft%l>>>0,ft=ft/l>>>0;if(ft!==0)throw new Error("Non-zero carry");_=ct,I++}for(var at=G-_;at!==G&&q[at]===0;)at++;for(var It=f.repeat(T);at<G;++at)It+=r.charAt(q[at]);return It}function w(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var T=0;if(b[T]!==" "){for(var _=0,I=0;b[T]===f;)_++,T++;for(var D=(b.length-T)*d+1>>>0,G=new Uint8Array(D);b[T];){var q=e[b.charCodeAt(T)];if(q===255)return;for(var ft=0,ct=D-1;(q!==0||ft<I)&&ct!==-1;ct--,ft++)q+=l*G[ct]>>>0,G[ct]=q%256>>>0,q=q/256>>>0;if(q!==0)throw new Error("Non-zero carry");I=ft,T++}if(b[T]!==" "){for(var ot=D-I;ot!==D&&G[ot]===0;)ot++;for(var at=new Uint8Array(_+(D-ot)),It=_;ot!==D;)at[It++]=G[ot++];return at}}}function S(b){var T=w(b);if(T)return T;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:w,decode:S}}var Uu=Pu,Fu=Uu,fo=Fu;var Jh=new Uint8Array(0);var ho=(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 po=r=>new TextEncoder().encode(r),mo=r=>new TextDecoder().decode(r);var Cn=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")}},Dn=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 yo(this,t)}},_n=class{constructor(t){this.decoders=t}or(t){return yo(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`)}},yo=(r,t)=>new _n({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Bn=class{constructor(t,e,n,i){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=i,this.encoder=new Cn(t,e,n),this.decoder=new Dn(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},_e=({name:r,prefix:t,encode:e,decode:n})=>new Bn(r,t,e,n),Jt=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:i}=fo(e,t);return _e({prefix:r,name:t,encode:n,decode:o=>wt(i(o))})},Gu=(r,t,e,n)=>{let i={};for(let h=0;h<t.length;++h)i[t[h]]=h;let o=r.length;for(;r[o-1]==="=";)--o;let a=new Uint8Array(o*e/8|0),l=0,f=0,d=0;for(let h=0;h<o;++h){let g=i[r[h]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<e|g,l+=e,l>=8&&(l-=8,a[d++]=255&f>>l)}if(l>=e||255&f<<8-l)throw new SyntaxError("Unexpected end of data");return a},$u=(r,t,e)=>{let n=t[t.length-1]==="=",i=(1<<e)-1,o="",a=0,l=0;for(let f=0;f<r.length;++f)for(l=l<<8|r[f],a+=8;a>e;)a-=e,o+=t[i&l>>a];if(a&&(o+=t[i&l<<e-a]),n)for(;o.length*e&7;)o+="=";return o},U=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>_e({prefix:t,name:r,encode(i){return $u(i,n,e)},decode(i){return Gu(i,n,e,r)}});var zu=_e({prefix:"\0",name:"identity",encode:r=>mo(r),decode:r=>po(r)});var kn={};dt(kn,{base2:()=>Vu});var Vu=U({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ln={};dt(Ln,{base8:()=>Hu});var Hu=U({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var On={};dt(On,{base10:()=>qu});var qu=Jt({prefix:"9",name:"base10",alphabet:"0123456789"});var Nn={};dt(Nn,{base16:()=>Wu,base16upper:()=>Zu});var Wu=U({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Zu=U({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Mn={};dt(Mn,{base32:()=>Bt,base32hex:()=>Yu,base32hexpad:()=>Qu,base32hexpadupper:()=>tl,base32hexupper:()=>Ju,base32pad:()=>Xu,base32padupper:()=>ju,base32upper:()=>Ku,base32z:()=>el});var Bt=U({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ku=U({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Xu=U({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ju=U({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Yu=U({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ju=U({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Qu=U({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),tl=U({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),el=U({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Pn={};dt(Pn,{base36:()=>rl,base36upper:()=>nl});var rl=Jt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),nl=Jt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Un={};dt(Un,{base58btc:()=>W,base58flickr:()=>il});var W=Jt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),il=Jt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Gn={};dt(Gn,{base64:()=>Fn,base64pad:()=>ol,base64url:()=>sl,base64urlpad:()=>cl});var Fn=U({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ol=U({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),sl=U({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),cl=U({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var $n={};dt($n,{base256emoji:()=>hl});var bo=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}"),al=bo.reduce((r,t,e)=>(r[e]=t,r),[]),ul=bo.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function ll(r){return r.reduce((t,e)=>(t+=al[e],t),"")}function fl(r){let t=[];for(let e of r){let n=ul[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var hl=_e({prefix:"\u{1F680}",name:"base256emoji",encode:ll,decode:fl});var Wn={};dt(Wn,{sha256:()=>Ar,sha512:()=>Rl});var qn=N(Ot("crypto"),1);var pl=vo,wo=128,dl=127,ml=~dl,gl=Math.pow(2,31);function vo(r,t,e){t=t||[],e=e||0;for(var n=e;r>=gl;)t[e++]=r&255|wo,r/=128;for(;r&ml;)t[e++]=r&255|wo,r>>>=7;return t[e]=r|0,vo.bytes=e-n+1,t}var yl=zn,bl=128,Eo=127;function zn(r,n){var e=0,n=n||0,i=0,o=n,a,l=r.length;do{if(o>=l)throw zn.bytes=0,new RangeError("Could not decode varint");a=r[o++],e+=i<28?(a&Eo)<<i:(a&Eo)*Math.pow(2,i),i+=7}while(a>=bl);return zn.bytes=o-n,e}var wl=Math.pow(2,7),El=Math.pow(2,14),vl=Math.pow(2,21),Sl=Math.pow(2,28),Tl=Math.pow(2,35),xl=Math.pow(2,42),Al=Math.pow(2,49),Il=Math.pow(2,56),Cl=Math.pow(2,63),Dl=function(r){return r<wl?1:r<El?2:r<vl?3:r<Sl?4:r<Tl?5:r<xl?6:r<Al?7:r<Il?8:r<Cl?9:10},_l={encode:pl,decode:yl,encodingLength:Dl},Bl=_l,Ye=Bl;var Je=(r,t=0)=>[Ye.decode(r,t),Ye.decode.bytes],Be=(r,t,e=0)=>(Ye.encode(r,t,e),t),Re=r=>Ye.encodingLength(r);var Qt=(r,t)=>{let e=t.byteLength,n=Re(r),i=n+Re(e),o=new Uint8Array(i+e);return Be(r,o,0),Be(e,o,n),o.set(t,i),new ke(r,e,t,o)},fe=r=>{let t=wt(r),[e,n]=Je(t),[i,o]=Je(t.subarray(n)),a=t.subarray(n+o);if(a.byteLength!==i)throw new Error("Incorrect length");return new ke(e,i,a,t)},So=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&ho(r.bytes,e.bytes)}},ke=class{constructor(t,e,n,i){this.code=t,this.size=e,this.digest=n,this.bytes=i}};var Hn=({name:r,code:t,encode:e})=>new Vn(r,t,e),Vn=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 Ar=Hn({name:"sha2-256",code:18,encode:r=>wt(qn.default.createHash("sha256").update(r).digest())}),Rl=Hn({name:"sha2-512",code:19,encode:r=>wt(qn.default.createHash("sha512").update(r).digest())});var Zn={};dt(Zn,{identity:()=>Ir});var xo=0,kl="identity",Ao=wt,Ll=r=>Qt(xo,Ao(r)),Ir={code:xo,name:kl,encode:Ao,digest:Ll};var Ep=new TextEncoder,vp=new TextDecoder;var Io=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return Pl(e,Kn(r),t||W.encoder);default:return Ul(e,Kn(r),t||Bt.encoder)}};var Co=new WeakMap,Kn=r=>{let t=Co.get(r);if(t==null){let e=new Map;return Co.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!==Qe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Fl)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&&So(t.multihash,n.multihash)}toString(t){return Io(this,t)}toJSON(){return{"/":Io(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:o,bytes:a}=e;return new k(n,i,o,a||Do(n,i,o.bytes))}else if(e[Gl]===!0){let{version:n,multihash:i,code:o}=e,a=fe(i);return k.create(n,o,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!==Qe)throw new Error(`Version 0 CID must use dag-pb (code: ${Qe}) block encoding`);return new k(t,e,n,n.bytes)}case 1:{let i=Do(t,e,n.bytes);return new k(t,e,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return k.create(0,Qe,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 o=i.subarray(e.multihashSize-e.digestSize),a=new ke(e.multihashCode,e.digestSize,o,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]=Je(t.subarray(e));return e+=w,g},i=n(),o=Qe;if(i===18?(i=0,e=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let a=e,l=n(),f=n(),d=e+f,h=d-a;return{version:i,codec:o,multihashCode:l,digestSize:f,multihashSize:h,size:d}}static parse(t,e){let[n,i]=Ml(t,e),o=k.decode(i);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Kn(o).set(n,t),o}},Ml=(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 Bt.prefix:{let e=t||Bt;return[Bt.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)]}}},Pl=(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 o=e.encode(r).slice(1);return t.set(n,o),o}else return i},Ul=(r,t,e)=>{let{prefix:n}=e,i=t.get(n);if(i==null){let o=e.encode(r);return t.set(n,o),o}else return i},Qe=112,Fl=18,Do=(r,t,e)=>{let n=Re(r),i=n+Re(t),o=new Uint8Array(i+e.byteLength);return Be(r,o,0),Be(t,o,n),o.set(e,i),o},Gl=Symbol.for("@ipld/js-cid/CID");var te={...Rn,...kn,...Ln,...On,...Nn,...Mn,...Pn,...Un,...Gn,...$n},Rp={...Wn,...Zn};function pe(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Gt(r=0){return globalThis.Buffer?.alloc!=null?pe(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function $t(r=0){return globalThis.Buffer?.allocUnsafe!=null?pe(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Bo(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var _o=Bo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Xn=Bo("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=$t(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),$l={utf8:_o,"utf-8":_o,hex:te.base16,latin1:Xn,ascii:Xn,binary:Xn,...te},Cr=$l;function ut(r,t="utf8"){let e=Cr[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 Ro=Yt.isIPv4,zl=Yt.isIPv6,jn=function(r){let t=0;if(r=r.toString().trim(),Ro(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(zl(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let o=Ro(e[n]),a;o&&(a=jn(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 o=[n,1];for(n=9-e.length;n>0;n--)o.push("0");e.splice.apply(e,o)}let i=new Uint8Array(t+16);for(n=0;n<e.length;n++){let o=parseInt(e[n],16);i[t++]=o>>8&255,i[t++]=o&255}return i}throw new Error("invalid ip address")},ko=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 o=0;o<e;o++)i.push(r[t+o]);return i.join(".")}if(e===16){let i=[];for(let o=0;o<e;o+=2)i.push(n.getUint16(t+o).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var tr={},Yn={},Hl=[[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"],[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"],[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"]];Hl.forEach(r=>{let t=ql(...r);Yn[t.code]=t,tr[t.name]=t});function ql(r,t,e,n,i){return{code:r,size:t,name:e,resolvable:Boolean(n),path:Boolean(i)}}function O(r){if(typeof r=="number"){if(Yn[r]!=null)return Yn[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 Nt=N(Dr(),1);function er(r,t="utf8"){let e=Cr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?pe(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function Et(r,t){t==null&&(t=r.reduce((i,o)=>i+o.length,0));let e=$t(t),n=0;for(let i of r)e.set(i,n),n+=i.length;return pe(e)}function Wo(r,t){switch(O(r).code){case 4:case 41:return cf(t);case 42:return Ho(t);case 6:case 273:case 33:case 132:return Ko(t).toString();case 53:case 54:case 55:case 56:case 400:case 777:return Ho(t);case 421:return ff(t);case 444:return qo(t);case 445:return qo(t);case 466:return lf(t);default:return ut(t,"base16")}}function Zo(r,t){switch(O(r).code){case 4:return zo(t);case 41:return zo(t);case 42:return Vo(t);case 6:case 273:case 33:case 132:return ei(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 777:return Vo(t);case 421:return af(t);case 444:return hf(t);case 445:return pf(t);case 466:return uf(t);default:return er(t,"base16")}}var ti=Object.values(te).map(r=>r.decoder),sf=function(){let r=ti[0].or(ti[1]);return ti.slice(2).forEach(t=>r=r.or(t)),r}();function zo(r){if(!Tr(r))throw new Error("invalid ip address");return jn(r)}function cf(r){let t=ko(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Tr(t))throw new Error("invalid ip address");return t}function ei(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Ko(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Vo(r){let t=er(r),e=Uint8Array.from(Nt.default.encode(t.length));return Et([e,t],e.length+t.length)}function Ho(r){let t=Nt.default.decode(r);if(r=r.slice(Nt.default.decode.bytes),r.length!==t)throw new Error("inconsistent lengths");return ut(r)}function af(r){let t;r[0]==="Q"||r[0]==="1"?t=fe(W.decode(`z${r}`)).bytes:t=k.parse(r).multihash.bytes;let e=Uint8Array.from(Nt.default.encode(t.length));return Et([e,t],e.length+t.length)}function uf(r){let t=sf.decode(r),e=Uint8Array.from(Nt.default.encode(t.length));return Et([e,t],e.length+t.length)}function lf(r){let t=Nt.default.decode(r),e=r.slice(Nt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return"u"+ut(e,"base64url")}function ff(r){let t=Nt.default.decode(r),e=r.slice(Nt.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return ut(e,"base58btc")}function hf(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=Bt.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=ei(n);return Et([e,i],e.length+i.length)}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!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Bt.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=ei(n);return Et([e,i],e.length+i.length)}function qo(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=ut(t,"base32"),i=Ko(e);return`${n}:${i}`}var Le=N(Dr(),1);function df(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],o=O(i);if(o.size===0){t.push([i]);continue}if(n++,n>=e.length)throw jo("invalid address: "+r);if(o.path===!0){t.push([i,si(e.slice(n).join("/"))]);break}t.push([i,e[n]])}return t}function mf(r){let t=[];return r.map(e=>{let n=Rr(e);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),si(t.join("/"))}function gf(r){return r.map(t=>{Array.isArray(t)||(t=[t]);let e=Rr(t);return t.length>1?[e.code,Zo(e.code,t[1])]:[e.code]})}function ri(r){return r.map(t=>{let e=Rr(t);return t[1]!=null?[e.code,Wo(e.code,t[1])]:[e.code]})}function ni(r){return Br(Et(r.map(t=>{let e=Rr(t),n=Uint8Array.from(Le.default.encode(e.code));return t.length>1&&t[1]!=null&&(n=Et([n,t[1]])),n})))}function ii(r,t){return r.size>0?r.size/8:r.size===0?0:Le.default.decode(t)+(Le.default.decode.bytes??0)}function _r(r){let t=[],e=0;for(;e<r.length;){let n=Le.default.decode(r,e),i=Le.default.decode.bytes??0,o=O(n),a=ii(o,r.slice(e+i));if(a===0){t.push([n]),e+=i;continue}let l=r.slice(e+i,e+i+a);if(e+=a+i,e>r.length)throw jo("Invalid address Uint8Array: "+ut(r,"base16"));t.push([n,l])}return t}function oi(r){let t=_r(r),e=ri(t);return mf(e)}function yf(r){r=si(r);let t=df(r),e=gf(t);return ni(e)}function Xo(r){return yf(r)}function Br(r){let t=bf(r);if(t!=null)throw t;return Uint8Array.from(r)}function bf(r){try{_r(r)}catch(t){return t}}function si(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function jo(r){return new Error("Error parsing address: "+r)}function Rr(r){return O(r[0])}var ai=N(Dr(),1);var ts=N(kr(),1);function de(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 Oe=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)},ci=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},rr,nr,ir,Qo,vf=Symbol.for("nodejs.util.inspect.custom"),Sf=[O("dns").code,O("dns4").code,O("dns6").code,O("dnsaddr").code],Tf=new Map,es=Symbol.for("@multiformats/js-multiaddr/multiaddr");function xf(r){return Boolean(r?.[es])}var zt=class{constructor(t){if(rr.set(this,void 0),nr.set(this,void 0),ir.set(this,void 0),this[Qo]=!0,t==null&&(t=""),t instanceof Uint8Array)this.bytes=Br(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=Xo(t)}else if(xf(t))this.bytes=Br(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return Oe(this,rr,"f")==null&&ci(this,rr,oi(this.bytes),"f"),Oe(this,rr,"f")}toJSON(){return this.toString()}toOptions(){let t,e,n,i,o="",a=O("tcp"),l=O("udp"),f=O("ip4"),d=O("ip6"),h=O("dns6"),g=O("ip6zone");for(let[S,b]of this.stringTuples())S===g.code&&(o=`%${b??""}`),Sf.includes(S)&&(e=a.name,i=443,n=`${b??""}${o}`,t=S===h.code?6:4),(S===a.code||S===l.code)&&(e=O(S).name,i=parseInt(b??"")),(S===f.code||S===d.code)&&(e=O(S).name,n=`${b??""}${o}`,t=S===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({},O(t)))}protoCodes(){let t=[],e=this.bytes,n=0;for(;n<e.length;){let i=ai.default.decode(e,n),o=ai.default.decode.bytes??0,a=O(i),l=ii(a,e.slice(n+o));n+=l+o,t.push(i)}return t}protoNames(){return this.protos().map(t=>t.name)}tuples(){return Oe(this,nr,"f")==null&&ci(this,nr,_r(this.bytes),"f"),Oe(this,nr,"f")}stringTuples(){return Oe(this,ir,"f")==null&&ci(this,ir,ri(this.tuples()),"f"),Oe(this,ir,"f")}encapsulate(t){return t=new zt(t),new zt(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 zt(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 zt(ni(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"?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=>O(e[0]).path===!0)[0][1],t==null&&(t=null)}catch{t=null}return t}equals(t){return de(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(o=>o.resolvable);if(e==null)return[this];let n=Tf.get(e.name);if(n==null)throw(0,ts.default)(new Error(`no available resolver for ${e.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(o=>new zt(o))}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,nr=new WeakMap,ir=new WeakMap,Qo=es,vf)](){return`Multiaddr(${oi(this.bytes)})`}};function vt(r){return new zt(r)}var Af=A("dns4"),If=A("dns6"),Cf=A("dnsaddr"),Ne=tt(A("dns"),Cf,Af,If),Lr=tt(A("ip4"),A("ip6")),me=tt(C(Lr,A("tcp")),C(Ne,A("tcp"))),ns=C(Lr,A("udp")),Df=C(ns,A("utp")),_f=C(ns,A("quic")),sr=tt(C(me,A("ws")),C(Ne,A("ws"))),cr=tt(C(me,A("wss")),C(Ne,A("wss"))),ui=tt(C(me,A("http")),C(Lr,A("http")),C(Ne,A("http"))),li=tt(C(me,A("https")),C(Lr,A("https")),C(Ne,A("https"))),is=tt(C(sr,A("p2p-webrtc-star"),A("p2p")),C(cr,A("p2p-webrtc-star"),A("p2p")),C(sr,A("p2p-webrtc-star")),C(cr,A("p2p-webrtc-star"))),Td=tt(C(sr,A("p2p-websocket-star"),A("p2p")),C(cr,A("p2p-websocket-star"),A("p2p")),C(sr,A("p2p-websocket-star")),C(cr,A("p2p-websocket-star"))),os=tt(C(ui,A("p2p-webrtc-direct"),A("p2p")),C(li,A("p2p-webrtc-direct"),A("p2p")),C(ui,A("p2p-webrtc-direct")),C(li,A("p2p-webrtc-direct"))),ar=tt(sr,cr,ui,li,is,os,me,Df,_f,Ne),xd=tt(C(ar,A("p2p-stardust"),A("p2p")),C(ar,A("p2p-stardust"))),ee=tt(C(ar,A("p2p")),is,os,A("p2p")),rs=tt(C(ee,A("p2p-circuit"),ee),C(ee,A("p2p-circuit")),C(A("p2p-circuit"),ee),C(ar,A("p2p-circuit")),C(A("p2p-circuit"),ar),A("p2p-circuit")),ss=()=>tt(C(rs,ss),rs),or=ss(),Ad=tt(C(or,ee,or),C(ee,or),C(or,ee),or,ee);function cs(r){function t(e){let n;try{n=vt(e)}catch{return!1}let i=r(n.protoNames());return i===null?!1:i===!0||i===!1?i:i.length===0}return t}function C(...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:cs(t),partialMatch:t}}function tt(...r){function t(n){let i=null;return r.some(o=>{let a=typeof o=="function"?o().partialMatch(n):o.partialMatch(n);return a!=null?(i=a,!0):!1}),i}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:cs(t),partialMatch:t}}function A(r){let t=r;function e(i){let o;try{o=vt(i)}catch{return!1}let a=o.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 Mt=N(ws(),1);Mt.default.formatters.b=r=>r==null?"undefined":W.baseEncode(r);Mt.default.formatters.t=r=>r==null?"undefined":Bt.baseEncode(r);Mt.default.formatters.m=r=>r==null?"undefined":Fn.baseEncode(r);Mt.default.formatters.p=r=>r==null?"undefined":r.toString();Mt.default.formatters.c=r=>r==null?"undefined":r.toString();Mt.default.formatters.k=r=>r==null?"undefined":r.toString();function et(r){return Object.assign((0,Mt.default)(r),{error:(0,Mt.default)(`${r}:error`),trace:(0,Mt.default)(`${r}:trace`)})}var zs=N(Cs(),1);var Wr=N(kr(),1);function Fr(r){return this.subnetMask<r.subnetMask?!1:this.mask(r.subnetMask)===r.mask()}function Gr(r){return function(){return this.addressMinusSuffix!==this.correctForm()?!1:this.subnetMask===r&&!this.parsedSubnet?!0:this.parsedSubnet===String(this.subnetMask)}}var Ge=/^(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,yi=/\/\d{1,2}$/;var rt=class extends Error{constructor(t,e){super(t),this.name="AddressError",e!==null&&(this.parseMessage=e)}};var $e=N(bi(),1),ye=N(ur(),1),M=class{constructor(t){this.groups=4,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=Gr(32),this.isInSubnet=Fr,this.address=t;let e=yi.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(yi,"")}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(Ge))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 o=e.slice(i,i+2);n.push(parseInt(o,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,ye.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,ye.sprintf)("%02x%02x",parseInt(this.parsedAddress[e],10),parseInt(this.parsedAddress[e+1],10));t.push((0,ye.sprintf)("%x",parseInt(n,16)))}return t.join(":")}bigInteger(){return new $e.BigInteger(this.parsedAddress.map(t=>(0,ye.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new $e.BigInteger(this.mask()+"0".repeat(32-this.subnetMask),2)}startAddress(){return M.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new $e.BigInteger("1");return M.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new $e.BigInteger(this.mask()+"1".repeat(32-this.subnetMask),2)}endAddress(){return M.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new $e.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,ye.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(Ge,(0,ye.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 ks={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},wi={"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"},Ei=/([^0-9a-f:/%])/gi,vi=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,Si=/\/\d{1,3}(?=%|$)/,Ti=/%.*$/,Ls=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),Os=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);var Ms=N(ur(),1);function nh(r){return r.replace(/^(0+)/,'<span class="zero">$1</span>')}function Vr(r,t=0){return r.split(":").map((n,i)=>/group-v4/.test(n)?n:(0,Ms.sprintf)('<span class="hover-group group-%d">%s</span>',i+t,nh(n)))}var we=N(ur(),1);function Ai(r){return(0,we.sprintf)("(%s)",r.join("|"))}function xi(r){return r.length<4?(0,we.sprintf)("0{0,%d}%s",4-r.length,r):r}var Ii="[^A-Fa-f0-9:]";function Hr(r){let t=[];r.forEach((n,i)=>{parseInt(n,16)===0&&t.push(i)});let e=t.map(n=>r.map((i,o)=>{if(o===n){let a=o===0||o===8-1?":":"";return Ai([xi(i),a])}return xi(i)}).join(":"));return e.push(r.map(xi).join(":")),Ai(e)}function Ci(r,t,e){let n=t?"":":",i=e?"":":",o=[];!t&&!e&&o.push("::"),t&&e&&o.push(""),(e&&!t||!e&&t)&&o.push(":"),o.push((0,we.sprintf)("%s(:0{1,4}){1,%d}",n,r-1)),o.push((0,we.sprintf)("(0{1,4}:){1,%d}%s",r-1,i)),o.push((0,we.sprintf)("(0{1,4}:){%d}0{1,4}",r-1));for(let a=1;a<r-1;a++)for(let l=1;l<r-a;l++)o.push((0,we.sprintf)("(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}",l,r-l-a-1));return Ai(o)}var nt=N(bi(),1),it=N(ur(),1);function qr(r){if(!r)throw new Error("Assertion failed.")}function ih(r){let t=/(\d+)(\d{3})/;for(;t.test(r);)r=r.replace(t,"$1,$2");return r}function oh(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 sh(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 Us(r){return(0,it.sprintf)("%04x",parseInt(r,16))}function Fs(r){return r&255}var F=class{constructor(t,e){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=Fr,this.isCorrect=Gr(128),e===void 0?this.groups=8:this.groups=e,this.address=t;let n=Si.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(Si,"")}else if(/\//.test(t))throw new rt("Invalid subnet mask.");let i=Ti.exec(t);i&&(this.zone=i[0],t=t.replace(Ti,"")),this.addressMinusSuffix=t,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new F(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 F(n.join(":"))}static fromURL(t){let e,n=null,i;if(t.indexOf("[")!==-1&&t.indexOf("]:")!==-1){if(i=Os.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=Ls.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 F(e),port:n}}static fromAddress4(t){let e=new M(t),n=128-(32-e.subnetMask);return new F(`::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 o=n;o>0;o--){let a=o*4;i.splice(a,0,":")}return e=i.join(""),new F(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":ih(new nt.BigInteger("2",10).pow(i).toString(10))}_startAddress(){return new nt.BigInteger(this.mask()+"0".repeat(128-this.subnetMask),2)}startAddress(){return F.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new nt.BigInteger("1");return F.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new nt.BigInteger(this.mask()+"1".repeat(128-this.subnetMask),2)}endAddress(){return F.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new nt.BigInteger("1");return F.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=ks[this.getBits(12,16).intValue()];return this.getType()==="Global unicast"&&t!=="Link local"&&(t="Global"),t||"Unknown"}getType(){for(let t of Object.keys(wi))if(this.isInSubnet(new F(t)))return wi[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 l=parseInt(this.parsedAddress[t],16);l===0&&n++,l!==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 o=i.map(l=>l[1]-l[0]+1);if(i.length>0){let l=o.indexOf(Math.max(...o));e=sh(this.parsedAddress,i[l])}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(Ge);if(i){this.parsedAddress4=i[0],this.address4=new M(this.parsedAddress4);for(let o=0;o<this.address4.groups;o++)if(/^0[0-9]+/.test(this.address4.parsedAddress[o]))throw new rt("IPv4 addresses can't have leading zeroes.",t.replace(Ge,this.address4.parsedAddress.map(oh).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(Ei);if(e)throw new rt((0,it.sprintf)("Bad character%s detected in address: %s",e.length>1?"s":"",e.join("")),t.replace(Ei,'<span class="parse-error">$1</span>'));let n=t.match(vi);if(n)throw new rt((0,it.sprintf)("Address failed regex: %s",n.join("")),t.replace(vi,'<span class="parse-error">$1</span>'));let i=[],o=t.split("::");if(o.length===2){let a=o[0].split(":"),l=o[1].split(":");a.length===1&&a[0]===""&&(a=[]),l.length===1&&l[0]===""&&(l=[]);let f=this.groups-(a.length+l.length);if(!f)throw new rt("Error parsing groups");this.elidedGroups=f,this.elisionBegin=a.length,this.elisionEnd=a.length+this.elidedGroups,i=i.concat(a);for(let d=0;d<f;d++)i.push("0");i=i.concat(l)}else if(o.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(Us).join(":")}decimal(){return this.parsedAddress.map(t=>(0,it.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new nt.BigInteger(this.parsedAddress.map(Us).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 F(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)),o=this.getBits(64,80),a=this.getBitsBase2(64,80),l=o.testBit(15),f=o.testBit(14),d=o.testBit(8),h=o.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:l,microsoft:{reserved:f,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 F(t)}toByteArray(){let t=this.bigInteger().toByteArray();return t.length===17&&t[0]===0?t.slice(1):t}toUnsignedByteArray(){return this.toByteArray().map(Fs)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(Fs))}static fromUnsignedByteArray(t){let e=new nt.BigInteger("256",10),n=new nt.BigInteger("0",10),i=new nt.BigInteger("1",10);for(let o=t.length-1;o>=0;o--)n=n.add(i.multiply(new nt.BigInteger(t[o].toString(10),10))),i=i.multiply(e);return F.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 F("2001::/32"))}is6to4(){return this.isInSubnet(new F("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 Vr(this.address).join(":");qr(typeof this.elidedGroups=="number"),qr(typeof this.elisionBegin=="number");let t=[],[e,n]=this.address.split("::");e.length?t.push(...Vr(e)):t.push("");let i=["hover-group"];for(let o=this.elisionBegin;o<this.elisionBegin+this.elidedGroups;o++)i.push((0,it.sprintf)("group-%d",o));return t.push((0,it.sprintf)('<span class="%s"></span>',i.join(" "))),n.length?t.push(...Vr(n,this.elisionEnd)):t.push(""),this.is4()&&(qr(this.address4 instanceof M),t.pop(),t.push(this.address4.groupForV6())),t.join(":")}regularExpressionString(t=!1){let e=[],n=new F(this.correctForm());if(n.elidedGroups===0)e.push(Hr(n.parsedAddress));else if(n.elidedGroups===8)e.push(Ci(8));else{let i=n.address.split("::");i[0].length&&e.push(Hr(i[0].split(":"))),qr(typeof n.elidedGroups=="number"),e.push(Ci(n.elidedGroups,i[0].length!==0,i[1].length!==0)),i[1].length&&e.push(Hr(i[1].split(":"))),e=[e.join(":")]}return t||(e=["(?=^|",Ii,"|[^\\w\\:])(",...e,")(?=[^\\w\\:]|",Ii,"|$)"]),e.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};var ch=et("libp2p:ip-port-to-multiaddr"),Di={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function Gs(r,t){if(typeof r!="string")throw(0,Wr.default)(new Error(`invalid ip provided: ${r}`),Di.ERR_INVALID_IP_PARAMETER);if(typeof t=="string"&&(t=parseInt(t)),isNaN(t))throw(0,Wr.default)(new Error(`invalid port provided: ${t}`),Di.ERR_INVALID_PORT_PARAMETER);try{return new M(r),vt(`/ip4/${r}/tcp/${t}`)}catch{}try{let e=new F(r);return e.is4()?vt(`/ip4/${e.to4().correctForm()}/tcp/${t}`):vt(`/ip6/${r}/tcp/${t}`)}catch{let n=`invalid ip:port for creating a multiaddr: ${r}:${t}`;throw ch.error(n),(0,Wr.default)(new Error(n),Di.ERR_INVALID_IP)}}var _i=N(Ot("os"),1),$s=N(Ot("path"),1),ah={ip4:"IPv4",ip6:"IPv6"};function Ve(r){let t=r.getPath();return t!=null?_i.default.platform()==="win32"?{path:$s.default.join("\\\\.\\pipe\\",t)}:{path:t}:r.toOptions()}function Bi(r,t,e){let n=i=>vt(`/${r}/${i}/tcp/${e}`);return(uh(t)?fh(ah[r]):[t]).map(n)}function uh(r){return["0.0.0.0","::"].includes(r)}var lh=_i.default.networkInterfaces();function fh(r){let t=[];for(let[,e]of Object.entries(lh))if(e!=null)for(let n of e)n.family===r&&t.push(n.address);return t}var Ht=class extends Error{constructor(t="The operation was aborted"){super(t),this.code=Ht.code,this.type=Ht.type}static get code(){return"ABORT_ERR"}static get type(){return"aborted"}},qt=class extends Error{constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var Rt=et("libp2p:tcp:socket"),Zr=(r,t)=>{let e=t.metrics,n=t.metricPrefix??"",i=t.socketInactivityTimeout??3e5,o=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 qt("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");a=Gs(r.remoteAddress,r.remotePort)}let l=Ve(a),f=l.path??`${l.host??""}:${l.port??""}`,{sink:d,source:h}=zs.default.duplex(r);r.setTimeout(i,()=>{Rt("%s socket read timeout",f),e?.increment({[`${n}timeout`]:!0});let w;r.readable&&(w=new qt("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),r.destroy(w)}),r.once("close",()=>{Rt("%s socket close",f),e?.increment({[`${n}close`]:!0}),g.timeline.close==null&&(g.timeline.close=Date.now())}),r.once("end",()=>{Rt("%s socket end",f),e?.increment({[`${n}end`]:!0})});let g={async sink(w){try{await d(w)}catch(S){S.type!=="aborted"&&Rt(S)}r.end()},source:h,remoteAddr:a,timeline:{open:Date.now()},async close(){if(r.destroyed){Rt("%s socket was already destroyed when trying to close",f);return}Rt("%s closing socket",f),await new Promise((w,S)=>{let b=Date.now(),T=setTimeout(()=>{r.destroyed?(Rt("%s is already destroyed",f),w()):(Rt("%s socket close timeout after %dms, destroying it manually",f,Date.now()-b),r.destroy(new qt("Socket close timeout","ERR_SOCKET_CLOSE_TIMEOUT")))},o).unref();r.once("close",()=>{Rt("%s socket closed",f),clearTimeout(T),w()}),r.once("error",_=>{Rt("%s socket error",f,_),g.timeline.close==null&&(g.timeline.close=Date.now()),r.destroyed&&clearTimeout(T),S(_)}),r.setTimeout(o),r.end(),r.writableLength>0?r.once("drain",()=>{Rt("%s socket drained",f),r.destroy()}):r.destroy()})}};return g};var Vs=N(Ot("net"),1);var Ee=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)},Wt,Kr=class extends EventTarget{constructor(){super(...arguments),Wt.set(this,new Map)}listenerCount(t){let e=Ee(this,Wt,"f").get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let i=Ee(this,Wt,"f").get(t);i==null&&(i=[],Ee(this,Wt,"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=Ee(this,Wt,"f").get(t);i!=null&&(i=i.filter(({callback:o})=>o!==e),Ee(this,Wt,"f").set(t,i))}dispatchEvent(t){let e=super.dispatchEvent(t),n=Ee(this,Wt,"f").get(t.type);return n==null||(n=n.filter(({once:i})=>!i),Ee(this,Wt,"f").set(t.type,n)),e}safeDispatchEvent(t,e){return this.dispatchEvent(new He(t,e))}};Wt=new WeakMap;var Ri=class extends Event{constructor(t,e){super(t,e),this.detail=e?.detail}},He=globalThis.CustomEvent??Ri;var gt=et("libp2p:tcp:listener");async function ki(r){try{await r.close()}catch(t){gt.error("an error occurred closing the connection",t)}}var dh=1,mh=0,Xr=class extends Kr{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=Vs.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]:dh})}this.dispatchEvent(new He("listening"))}).on("error",e=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new He("error",{detail:e}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:mh}),this.dispatchEvent(new He("close"))})}onSocket(t){t.on("error",n=>{gt("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let e;try{e=Zr(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 He("connection",{detail:n}))}).catch(async n=>{gt.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await ki(e)}).catch(n=>{gt.error("closing inbound connection failed",n)})}catch(n){gt.error("inbound connection failed",n),ki(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(Bi("ip4",e.address,e.port)):e.family==="IPv6"&&(t=t.concat(Bi("ip6",e.address,e.port)))}catch(o){gt.error("could not turn %s:%s into multiaddr",e.address,e.port,o)}return t.map(o=>i!=null?o.encapsulate(`/p2p/${i}`):o)}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:Ve(n)},await this.netListen()}async close(){await Promise.all(Array.from(this.connections.values()).map(async t=>{await ki(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 qs=Symbol.for("@libp2p/transport");var Hs;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Hs||(Hs={}));var Zt=et("libp2p:tcp"),Oi=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[qs](){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",l=>{Zt("socket error",l)});let i=Zr(n,{remoteAddr:t,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents}),o=()=>{i.close().catch(l=>{Zt.error("Error closing maConn after abort",l)})};e.signal?.addEventListener("abort",o,{once:!0}),Zt("new outbound connection %s",i.remoteAddr);let a=await e.upgrader.upgradeOutbound(i);if(Zt("outbound connection %s upgraded",i.remoteAddr),e.signal?.removeEventListener("abort",o),e.signal?.aborted===!0)throw a.close().catch(l=>{Zt.error("Error closing conn after abort",l)}),new Ht;return a}async _connect(t,e){if(e.signal?.aborted===!0)throw new Ht;return await new Promise((n,i)=>{let o=Date.now(),a=Ve(t),l=a.path??`${a.host??""}:${a.port}`;Zt("dialing %j",a);let f=Ws.default.connect(a),d=b=>{b.message=`connection error ${l}: ${b.message}`,this.metrics?.dialerEvents.increment({error:!0}),S(b)},h=()=>{Zt("connection timeout %s",l),this.metrics?.dialerEvents.increment({timeout:!0});let b=new qt(`connection timeout after ${Date.now()-o}ms`,"ERR_CONNECT_TIMEOUT");f.emit("error",b)},g=()=>{Zt("connection opened %j",a),this.metrics?.dialerEvents.increment({connect:!0}),S()},w=()=>{Zt("connection aborted %j",a),this.metrics?.dialerEvents.increment({abort:!0}),f.destroy(),S(new Ht)},S=b=>{if(f.removeListener("error",d),f.removeListener("timeout",h),f.removeListener("connect",g),e.signal!=null&&e.signal.removeEventListener("abort",w),b!=null){i(b);return}n(f)};f.on("error",d),f.on("timeout",h),f.on("connect",g),e.signal!=null&&e.signal.addEventListener("abort",w)})}createListener(t){return new Xr({...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:me.matches(e.decapsulateCode(421)))}};function Zs(r={}){return(t={})=>new Oi(t,r)}var Xs=Symbol.for("@achingbrain/uint8arraylist");function Ks(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 jr(r){return Boolean(r?.[Xs])}var lt=class{constructor(...t){Object.defineProperty(this,Xs,{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(jr(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(jr(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=Ks(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Ks(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(jr(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),o=new lt;return o.length=i,o.bufs=n,o}_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 o=0;o<this.bufs.length;o++){let a=this.bufs[o],l=i,f=l+a.byteLength;if(i=f,t>=f)continue;let d=t>=l&&t<f,h=e>l&&e<=f;if(d&&h){if(t===l&&e===f){n.push(a);break}let g=t-l;n.push(a.subarray(g,g+(e-t)));break}if(d){if(t===0){n.push(a);continue}n.push(a.subarray(t-l));continue}if(h){if(e===f){n.push(a);break}n.push(a.subarray(0,e-l));break}n.push(a)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!jr(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 o=256,a=new Int32Array(o);for(let g=0;g<o;g++)a[g]=-1;for(let g=0;g<i;g++)a[n[g]]=g;let l=a,f=this.byteLength-n.byteLength,d=n.byteLength-1,h;for(let g=e;g<=f;g+=h){h=0;for(let w=d;w>=0;w--){let S=this.get(g+w);if(n[w]!==S){h=Math.max(1,w-l[S]);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=$t(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=Gt(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=Gt(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=Gt(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=$t(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=Gt(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=Gt(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=Gt(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=Gt(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=Gt(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(!de(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,o)=>i+o.byteLength,0)),n.length=e,n}};function Yr(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 js=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=Yr(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>js&&(i=0,++n>js&&(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=Yr(t),i=new yt,o=0;if(t.length-e>4){for(;o<4;++o)if(i.lo=(i.lo|(n.get(e)&127)<<o*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;o=0}else for(;o<4;++o){if(e>=t.length)throw RangeError(`index out of range: ${e} > ${t.length}`);if(i.lo=(i.lo|(n.get(e)&127)<<o*7)>>>0,n.get(e++)<128)return i}if(t.length-e>4){for(;o<5;++o)if(i.hi=(i.hi|(n.get(e)&127)<<o*7+3)>>>0,n.get(e++)<128)return i}else if(e<t.byteLength)for(;o<5;++o){if(e>=t.length)throw RangeError(`index out of range: ${e} > ${t.length}`);if(i.hi=(i.hi|(n.get(e)&127)<<o*7+3)>>>0,n.get(e++)<128)return i}throw RangeError("invalid varint encoding")}};var bh=Math.pow(2,7),wh=Math.pow(2,14),Eh=Math.pow(2,21),vh=Math.pow(2,28),Sh=Math.pow(2,35),Th=Math.pow(2,42),xh=Math.pow(2,49),Ah=Math.pow(2,56),Ih=Math.pow(2,63),ve={encodingLength(r){return r<bh?1:r<wh?2:r<Eh?3:r<vh?4:r<Sh?5:r<Th?6:r<xh?7:r<Ah?8:r<Ih?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=$t(ve.encodingLength(r))),yt.fromNumber(r).toBytes(t,e),t},decode(r,t=0){return yt.fromBytes(r,t).toNumber(!0)}};function Ys(r){return globalThis?.Buffer?.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}var Jr=r=>{let t=ve.encodingLength(r),e=Ys(t);return ve.encode(r,e),Jr.bytes=t,e};Jr.bytes=0;function qe(r){r=r??{};let t=r.lengthEncoder??Jr;return async function*(n){for await(let i of n){let o=t(i.byteLength);o instanceof Uint8Array?yield o:yield*o,i instanceof Uint8Array?yield i:yield*i}}}qe.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??Jr;return new lt(e(r.byteLength),r)};var lr=N(kr(),1),Ch=8,Dh=1024*1024*4,Se;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Se||(Se={}));var Ni=r=>{let t=ve.decode(r);return Ni.bytes=ve.encodingLength(t),t};Ni.bytes=0;function fr(r){return async function*(e){let n=new lt,i=Se.LENGTH,o=-1,a=r?.lengthDecoder??Ni,l=r?.maxLengthLength??Ch,f=r?.maxDataLength??Dh;for await(let d of e)for(n.append(d);n.byteLength>0;){if(i===Se.LENGTH)try{if(o=a(n),o<0)throw(0,lr.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>f)throw(0,lr.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let h=a.bytes;n.consume(h),r?.onLength!=null&&r.onLength(o),i=Se.DATA}catch(h){if(h instanceof RangeError){if(n.byteLength>l)throw(0,lr.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw h}if(i===Se.DATA){if(n.byteLength<o)break;let h=n.sublist(0,o);n.consume(o),r?.onData!=null&&r.onData(h),yield h,i=Se.LENGTH}}if(n.byteLength>0)throw(0,lr.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}}fr.fromReader=(r,t)=>{let e=1,n=async function*(){for(;;)try{let{done:o,value:a}=await r.next(e);if(o===!0)return;a!=null&&(yield a)}catch(o){if(o.code==="ERR_UNDER_READ")return{done:!0,value:null};throw o}finally{e=1}}();return fr({...t??{},onLength:o=>{e=o}})(n)};var Qr=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}},We=class{constructor(t={}){this.hwm=t.splitLimit??16,this.head=new Qr(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 Qr(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 ne(r={}){return _h(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 _h(r,t){t=t??{};let e=t.onEnd,n=new We,i,o,a,l=async()=>n.isEmpty()?a?{done:!0}:await new Promise((T,_)=>{o=I=>{o=null,n.push(I);try{T(r(n))}catch(D){_(D)}return i}}):r(n),f=T=>o!=null?o(T):(n.push(T),i),d=T=>(n=new We,o!=null?o({error:T}):(n.push({error:T}),i)),h=T=>{if(a)return i;if(t?.objectMode!==!0&&T?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return f({done:!1,value:T})},g=T=>a?i:(a=!0,T!=null?d(T):f({done:!0})),w=()=>(n=new We,g(),{done:!0}),S=T=>(g(T),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:l,return:w,throw:S,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(T){return b.throw(T),e!=null&&(e(T),e=void 0),{done:!0}},return(){return b.return(),e!=null&&(e(),e=void 0),{done:!0}},push:h,end(T){return b.end(T),e!=null&&(e(T),e=void 0),i},get readableLength(){return b.readableLength}},i}async function*Mi(...r){let t=ne({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async e=>{for await(let n of e)t.push(n)})),t.end()}catch(e){t.end(e)}}),yield*t}var Bh=(...r)=>{let t;for(;r.length>0;)t=r.shift()(t);return t},Qs=r=>r!=null&&(typeof r[Symbol.asyncIterator]=="function"||typeof r[Symbol.iterator]=="function"||typeof r.next=="function"),Pi=r=>r!=null&&typeof r.sink=="function"&&Qs(r.source),Rh=r=>t=>{let e=r.sink(t);if(e.then!=null){let n=ne({objectMode:!0});return e.then(()=>{n.end()},o=>{n.end(o)}),Mi(n,async function*(){yield*r.source,n.end()}())}return r.source};function tn(r,...t){if(Pi(r)){let n=r;r=()=>n.source}else if(Qs(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&Pi(e[e.length-1])&&(e[e.length-1]=e[e.length-1].sink),e.length>2)for(let n=1;n<e.length-1;n++)Pi(e[n])&&(e[n]=Rh(e[n]));return Bh(...e)}function tc(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 o=n.sublist(0,e);if(n.consume(e),e=yield o,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}function Ui(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}function ec(r){let t=ne(),e=tc(r.source),n=Ui(),i,o=r.sink(async function*(){yield*t,yield*await n.promise}());return o.catch(l=>{i=l}),{reader:e,writer:t,stream:{sink:async l=>i!=null?await Promise.reject(i):(n.resolve(l),await o),source:e},rest:()=>t.end(),write:t.push,read:async()=>{let l=await e.next();if(l.value!=null)return l.value}}}var Fi=et("libp2p:daemon-protocol:stream-handler"),en=class{constructor(t){let{stream:e,maxLength:n}=t;this.stream=e,this.shake=ec(this.stream),this.decoder=fr.fromReader(this.shake.reader,{maxDataLength:n??4096})}async read(){let t=await this.decoder.next();if(t.value!=null)return t.value.subarray();Fi("read received no value, closing stream"),await this.close()}write(t){Fi("write message"),this.shake.write(qe.single(t).subarray())}rest(){return this.shake.rest(),this.shake.stream}async close(){Fi("closing the stream"),await this.rest().sink([])}};var Gi={upgradeInbound:async r=>r,upgradeOutbound:async r=>r};var Qi=N(qi(),1),zc=N(Oc(),1),to=N(Ji(),1),Vc=N($c(),1),Hc=N(xe(),1);function Gh(){Hc.default._configure(),Qi.default._configure(zc.default),to.default._configure(Vc.default)}Gh();var qc=["uint64","int64","sint64","fixed64","sfixed64"];function $h(r){for(let t of qc){if(r[t]==null)continue;let e=r[t];r[t]=function(){return BigInt(e.call(this).toString())}}return r}function eo(r){return $h(new Qi.default(r))}function zh(r){for(let t of qc){if(r[t]==null)continue;let e=r[t];r[t]=function(n){return e.call(this,n.toString())}}return r}function ro(){return zh(to.default.create())}function z(r,t){let e=eo(r instanceof Uint8Array?r:r.subarray());return t.decode(e)}function V(r,t){let e=ro();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Ke;(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"})(Ke||(Ke={}));function cn(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Kt(r){function t(i){if(r[i.toString()]==null)throw new Error("Invalid enum value");return r[i]}let e=function(o,a){let l=t(o);a.int32(l)},n=function(o){let a=o.int32();return t(a)};return cn("enum",Ke.VARINT,e,n)}function H(r,t){return cn("message",Ke.LENGTH_DELIMITED,r,t)}var xt;(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=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=H((i,o,a={})=>{a.lengthDelimited!==!1&&o.fork(),i.type!=null&&(o.uint32(8),r.Type.codec().encode(i.type,o)),i.connect!=null&&(o.uint32(18),un.codec().encode(i.connect,o,{writeDefaults:!1})),i.streamOpen!=null&&(o.uint32(26),ln.codec().encode(i.streamOpen,o,{writeDefaults:!1})),i.streamHandler!=null&&(o.uint32(34),fn.codec().encode(i.streamHandler,o,{writeDefaults:!1})),i.dht!=null&&(o.uint32(42),At.codec().encode(i.dht,o,{writeDefaults:!1})),i.connManager!=null&&(o.uint32(50),pn.codec().encode(i.connManager,o,{writeDefaults:!1})),i.disconnect!=null&&(o.uint32(58),dn.codec().encode(i.disconnect,o,{writeDefaults:!1})),i.pubsub!=null&&(o.uint32(66),ce.codec().encode(i.pubsub,o,{writeDefaults:!1})),i.peerStore!=null&&(o.uint32(74),Ce.codec().encode(i.peerStore,o,{writeDefaults:!1})),a.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let a={},l=o==null?i.len:i.pos+o;for(;i.pos<l;){let f=i.uint32();switch(f>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.connect=un.codec().decode(i,i.uint32());break;case 3:a.streamOpen=ln.codec().decode(i,i.uint32());break;case 4:a.streamHandler=fn.codec().decode(i,i.uint32());break;case 5:a.dht=At.codec().decode(i,i.uint32());break;case 6:a.connManager=pn.codec().decode(i,i.uint32());break;case 7:a.disconnect=dn.codec().decode(i,i.uint32());break;case 8:a.pubsub=ce.codec().decode(i,i.uint32());break;case 9:a.peerStore=Ce.codec().decode(i,i.uint32());break;default:i.skipType(f&7);break}}return a})),n),r.encode=i=>V(i,r.codec()),r.decode=i=>z(i,r.codec())})(xt||(xt={}));var Ie;(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=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=H((i,o,a={})=>{if(a.lengthDelimited!==!1&&o.fork(),i.type!=null&&(o.uint32(8),r.Type.codec().encode(i.type,o)),i.error!=null&&(o.uint32(18),hn.codec().encode(i.error,o,{writeDefaults:!1})),i.streamInfo!=null&&(o.uint32(26),Xe.codec().encode(i.streamInfo,o,{writeDefaults:!1})),i.identify!=null&&(o.uint32(34),an.codec().encode(i.identify,o,{writeDefaults:!1})),i.dht!=null&&(o.uint32(42),Q.codec().encode(i.dht,o,{writeDefaults:!1})),i.peers!=null)for(let l of i.peers)o.uint32(50),se.codec().encode(l,o,{writeDefaults:!0});i.pubsub!=null&&(o.uint32(58),mn.codec().encode(i.pubsub,o,{writeDefaults:!1})),i.peerStore!=null&&(o.uint32(66),gn.codec().encode(i.peerStore,o,{writeDefaults:!1})),a.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let a={peers:[]},l=o==null?i.len:i.pos+o;for(;i.pos<l;){let f=i.uint32();switch(f>>>3){case 1:a.type=r.Type.codec().decode(i);break;case 2:a.error=hn.codec().decode(i,i.uint32());break;case 3:a.streamInfo=Xe.codec().decode(i,i.uint32());break;case 4:a.identify=an.codec().decode(i,i.uint32());break;case 5:a.dht=Q.codec().decode(i,i.uint32());break;case 6:a.peers.push(se.codec().decode(i,i.uint32()));break;case 7:a.pubsub=mn.codec().decode(i,i.uint32());break;case 8:a.peerStore=gn.codec().decode(i,i.uint32());break;default:i.skipType(f&7);break}}return a})),n),r.encode=i=>V(i,r.codec()),r.decode=i=>z(i,r.codec())})(Ie||(Ie={}));var an;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||e.id!=null&&e.id.byteLength>0)&&(n.uint32(10),n.bytes(e.id)),e.addrs!=null)for(let o of e.addrs)n.uint32(18),n.bytes(o);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={id:new Uint8Array(0),addrs:[]},o=n==null?e.len:e.pos+n;for(;e.pos<o;){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=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(an||(an={}));var un;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||e.peer!=null&&e.peer.byteLength>0)&&(n.uint32(10),n.bytes(e.peer)),e.addrs!=null)for(let o of e.addrs)n.uint32(18),n.bytes(o);e.timeout!=null&&(n.uint32(24),n.int64(e.timeout)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={peer:new Uint8Array(0),addrs:[]},o=n==null?e.len:e.pos+n;for(;e.pos<o;){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=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(un||(un={}));var ln;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||e.peer!=null&&e.peer.byteLength>0)&&(n.uint32(10),n.bytes(e.peer)),e.proto!=null)for(let o of e.proto)n.uint32(18),n.string(o);e.timeout!=null&&(n.uint32(24),n.int64(e.timeout)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={peer:new Uint8Array(0),proto:[]},o=n==null?e.len:e.pos+n;for(;e.pos<o;){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=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(ln||(ln={}));var fn;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||e.addr!=null&&e.addr.byteLength>0)&&(n.uint32(10),n.bytes(e.addr)),e.proto!=null)for(let o of e.proto)n.uint32(18),n.string(o);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={addr:new Uint8Array(0),proto:[]},o=n==null?e.len:e.pos+n;for(;e.pos<o;){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=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(fn||(fn={}));var hn;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||e.msg!=="")&&(n.uint32(10),n.string(e.msg)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={msg:""},o=n==null?e.len:e.pos+n;for(;e.pos<o;){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=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(hn||(hn={}));var Xe;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||e.peer!=null&&e.peer.byteLength>0)&&(n.uint32(10),n.bytes(e.peer)),(i.writeDefaults===!0||e.addr!=null&&e.addr.byteLength>0)&&(n.uint32(18),n.bytes(e.addr)),(i.writeDefaults===!0||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:""},o=n==null?e.len:e.pos+n;for(;e.pos<o;){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=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(Xe||(Xe={}));var At;(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=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=H((i,o,a={})=>{a.lengthDelimited!==!1&&o.fork(),i.type!=null&&(o.uint32(8),r.Type.codec().encode(i.type,o)),i.peer!=null&&(o.uint32(18),o.bytes(i.peer)),i.cid!=null&&(o.uint32(26),o.bytes(i.cid)),i.key!=null&&(o.uint32(34),o.bytes(i.key)),i.value!=null&&(o.uint32(42),o.bytes(i.value)),i.count!=null&&(o.uint32(48),o.int32(i.count)),i.timeout!=null&&(o.uint32(56),o.int64(i.timeout)),a.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let a={},l=o==null?i.len:i.pos+o;for(;i.pos<l;){let f=i.uint32();switch(f>>>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(f&7);break}}return a})),n),r.encode=i=>V(i,r.codec()),r.decode=i=>z(i,r.codec())})(At||(At={}));var Q;(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=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=H((i,o,a={})=>{a.lengthDelimited!==!1&&o.fork(),i.type!=null&&(o.uint32(8),r.Type.codec().encode(i.type,o)),i.peer!=null&&(o.uint32(18),se.codec().encode(i.peer,o,{writeDefaults:!1})),i.value!=null&&(o.uint32(26),o.bytes(i.value)),a.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let a={},l=o==null?i.len:i.pos+o;for(;i.pos<l;){let f=i.uint32();switch(f>>>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(f&7);break}}return a})),n),r.encode=i=>V(i,r.codec()),r.decode=i=>z(i,r.codec())})(Q||(Q={}));var se;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||e.id!=null&&e.id.byteLength>0)&&(n.uint32(10),n.bytes(e.id)),e.addrs!=null)for(let o of e.addrs)n.uint32(18),n.bytes(o);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={id:new Uint8Array(0),addrs:[]},o=n==null?e.len:e.pos+n;for(;e.pos<o;){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=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(se||(se={}));var pn;(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=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=H((i,o,a={})=>{a.lengthDelimited!==!1&&o.fork(),i.type!=null&&(o.uint32(8),r.Type.codec().encode(i.type,o)),i.peer!=null&&(o.uint32(18),o.bytes(i.peer)),i.tag!=null&&(o.uint32(26),o.string(i.tag)),i.weight!=null&&(o.uint32(32),o.int64(i.weight)),a.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let a={},l=o==null?i.len:i.pos+o;for(;i.pos<l;){let f=i.uint32();switch(f>>>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(f&7);break}}return a})),n),r.encode=i=>V(i,r.codec()),r.decode=i=>z(i,r.codec())})(pn||(pn={}));var dn;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||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)},o=n==null?e.len:e.pos+n;for(;e.pos<o;){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=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(dn||(dn={}));var ce;(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=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=H((i,o,a={})=>{a.lengthDelimited!==!1&&o.fork(),i.type!=null&&(o.uint32(8),r.Type.codec().encode(i.type,o)),i.topic!=null&&(o.uint32(18),o.string(i.topic)),i.data!=null&&(o.uint32(26),o.bytes(i.data)),a.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let a={},l=o==null?i.len:i.pos+o;for(;i.pos<l;){let f=i.uint32();switch(f>>>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(f&7);break}}return a})),n),r.encode=i=>V(i,r.codec()),r.decode=i=>z(i,r.codec())})(ce||(ce={}));var dr;(function(r){let t;r.codec=()=>(t==null&&(t=H((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 o of e.topicIDs)n.uint32(34),n.string(o);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:[]},o=n==null?e.len:e.pos+n;for(;e.pos<o;){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=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(dr||(dr={}));var mn;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.topics!=null)for(let o of e.topics)n.uint32(10),n.string(o);if(e.peerIDs!=null)for(let o of e.peerIDs)n.uint32(18),n.bytes(o);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={topics:[],peerIDs:[]},o=n==null?e.len:e.pos+n;for(;e.pos<o;){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=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(mn||(mn={}));var Ce;(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=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=H((i,o,a={})=>{if(a.lengthDelimited!==!1&&o.fork(),i.type!=null&&(o.uint32(8),r.Type.codec().encode(i.type,o)),i.id!=null&&(o.uint32(18),o.bytes(i.id)),i.protos!=null)for(let l of i.protos)o.uint32(26),o.string(l);a.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let a={protos:[]},l=o==null?i.len:i.pos+o;for(;i.pos<l;){let f=i.uint32();switch(f>>>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(f&7);break}}return a})),n),r.encode=i=>V(i,r.codec()),r.decode=i=>z(i,r.codec())})(Ce||(Ce={}));var gn;(function(r){let t;r.codec=()=>(t==null&&(t=H((e,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),e.peer!=null&&(n.uint32(10),se.codec().encode(e.peer,n,{writeDefaults:!1})),e.protos!=null)for(let o of e.protos)n.uint32(18),n.string(o);i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={protos:[]},o=n==null?e.len:e.pos+n;for(;e.pos<o;){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=>V(e,r.codec()),r.decode=e=>z(e,r.codec())})(gn||(gn={}));function Y(r){return Ie.encode({type:Ie.Type.OK,peers:[],...r}).subarray()}function P(r){return Ie.encode({type:Ie.Type.ERROR,error:{msg:r.message},peers:[]}).subarray()}async function yn(r){for await(let t of r);}var bn=et("libp2p:daemon-server:dht"),wn=class{constructor(t){let{dht:e}=t;this.dht=e}async*provide(t){try{await yn(this.dht.provide(t)),yield Y()}catch(e){bn.error(e),yield P(e)}}async*getClosestPeers(t){yield Y({dht:{type:Q.Type.BEGIN}});for await(let e of this.dht.getClosestPeers(t))e.name==="PEER_RESPONSE"&&(yield*e.closer.map(n=>Q.encode({type:Q.Type.VALUE,value:n.id.toBytes()})));yield Q.encode({type:Q.Type.END})}async*getPublicKey(t){yield P(new Error("FIX ME: not implemented"))}async*getValue(t){try{for await(let e of this.dht.get(t))e.name==="VALUE"&&(yield Y({dht:{type:Q.Type.VALUE,value:e.value}}))}catch(e){bn.error(e),yield P(e)}}async*putValue(t,e){try{await yn(this.dht.put(t,e)),yield Y()}catch(n){bn.error(n),yield P(n)}}async*findPeer(t){try{for await(let e of this.dht.findPeer(t))e.name==="FINAL_PEER"&&(yield Y({dht:{type:Q.Type.VALUE,peer:{id:e.peer.id.toBytes(),addrs:e.peer.multiaddrs.map(n=>n.bytes)}}}));throw new Error("Peer not found")}catch(e){bn.error(e),yield P(e)}}async*findProviders(t,e){yield Y({dht:{type:Q.Type.BEGIN}});try{let n=e,i=0;for await(let o of this.dht.findProviders(t))if(o.name==="PEER_RESPONSE"){for(let a of o.providers)i++,yield Q.encode({type:Q.Type.VALUE,peer:{id:a.id.toBytes(),addrs:(a.multiaddrs??[]).map(l=>l.bytes)}});if(n===i)break}}catch(n){yield P(n)}yield Q.encode({type:Q.Type.END})}};var Wc=Symbol.for("@libp2p/peer-id");var Vh=Symbol.for("nodejs.util.inspect.custom"),Zc=Object.values(te).map(r=>r.decoder).reduce((r,t)=>r.or(t),te.identity.decoder),Kc=114,Xc=36,jc=37,mr=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[Wc](){return!0}toString(){return this.string==null&&(this.string=W.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return k.createV1(Kc,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t instanceof Uint8Array)return de(this.multihash.bytes,t);if(typeof t=="string")return Hh(t).equals(this);if(t?.multihash?.bytes!=null)return de(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Vh](){return`PeerId(${this.toString()})`}},gr=class extends mr{constructor(t){super({...t,type:"RSA"}),this.type="RSA",this.publicKey=t.publicKey}},yr=class extends mr{constructor(t){super({...t,type:"Ed25519"}),this.type="Ed25519",this.publicKey=t.multihash.digest}},br=class extends mr{constructor(t){super({...t,type:"secp256k1"}),this.type="secp256k1",this.publicKey=t.multihash.digest}};function Hh(r,t){if(t=t??Zc,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=fe(W.decode(`z${r}`));return r.startsWith("12D")?new yr({multihash:e}):r.startsWith("16U")?new br({multihash:e}):new gr({multihash:e})}return De(Zc.decode(r))}function De(r){try{let t=fe(r);if(t.code===Ir.code){if(t.digest.length===Xc)return new yr({multihash:t});if(t.digest.length===jc)return new br({multihash:t})}if(t.code===Ar.code)return new gr({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!==Kc)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===Ar.code)return new gr({multihash:r.multihash});if(t.code===Ir.code){if(t.digest.length===Xc)return new yr({multihash:r.multihash});if(t.digest.length===jc)return new br({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var no=et("libp2p:daemon-server:pubsub"),En=class{constructor(t){let{pubsub:e}=t;this.pubsub=e}async*getTopics(){try{yield Y({pubsub:{topics:this.pubsub.getTopics(),peerIDs:[]}})}catch(t){no.error(t),yield P(t)}}async*subscribe(t){try{let e=ne();this.pubsub.subscribe(t),await this.pubsub.addEventListener("message",n=>{let i=n.detail;i.topic===t&&(i.type==="signed"?e.push(dr.encode({from:i.from.toBytes(),data:i.data,seqno:i.sequenceNumber==null?void 0:er(i.sequenceNumber.toString(16).padStart(16,"0"),"base16"),topicIDs:[i.topic],signature:i.signature,key:i.key}).subarray()):e.push(dr.encode({data:i.data,topicIDs:[i.topic]}).subarray()))}),yield Y(),yield*e}catch(e){no.error(e),yield P(e)}}async*publish(t,e){try{await this.pubsub.publish(t,e),yield Y()}catch(n){no.error(n),yield P(n)}}};var Wh=1<<22,Xt=et("libp2p:daemon-server"),vn=class{constructor(t){let{multiaddr:e,libp2pNode:n}=t;this.multiaddr=e,this.libp2p=n,this.tcp=Zs()(),this.listener=this.tcp.createListener({handler:this.handleConnection.bind(this),upgrader:Gi}),this._onExit=this._onExit.bind(this),n.dht!=null&&(this.dhtOperations=new wn({dht:n.dht})),n.pubsub!=null&&(this.pubsubOperations=new En({pubsub:n.pubsub}))}async connect(t){if(t.connect==null||t.connect.addrs==null)throw new Error("Invalid request");let e=t.connect.peer,n=t.connect.addrs.map(o=>vt(o)),i=De(e);return await this.libp2p.peerStore.addressBook.set(i,n),await this.libp2p.dial(i)}async openStream(t){if(t.streamOpen==null||t.streamOpen.proto==null)throw new Error("Invalid request");let{peer:e,proto:n}=t.streamOpen,i=De(e),o=await this.libp2p.dial(i),a=await o.newStream(n);return{streamInfo:{peer:i.toBytes(),addr:o.remoteAddr.bytes,proto:a.stat.protocol??""},connection:a}}async registerStreamHandler(t){if(t.streamHandler==null||t.streamHandler.proto==null)throw new Error("Invalid request");let e=t.streamHandler.proto,n=vt(t.streamHandler.addr),i;await this.libp2p.handle(e,({connection:o,stream:a})=>{Promise.resolve().then(async()=>{i=await this.tcp.dial(n,{upgrader:Gi});let l=Xe.encode({peer:o.remotePeer.toBytes(),addr:o.remoteAddr.bytes,proto:a.stat.protocol??""}),f=qe.single(l);await tn(async function*(){yield f,yield*a.source}(),async function*(d){for await(let h of d)yield*h},i,a.sink)}).catch(async l=>{Xt.error(l),i!=null&&await i.close(l)}).finally(()=>{i?.close().catch(l=>{Xt.error(l)})})})}_listen(){process.on("SIGTERM",this._onExit),process.on("SIGINT",this._onExit),process.on("SIGHUP",this._onExit)}_onExit(){this.stop({exit:!0}).catch(t=>{Xt.error(t)})}async start(){this._listen(),await this.libp2p.start(),await this.listener.listen(this.multiaddr)}getMultiaddr(){let t=this.listener.getAddrs();if(t.length>0)return t[0];throw new Error("Not started")}async stop(t={exit:!1}){await this.libp2p.stop(),await this.listener.close(),t.exit&&Xt("server closed, exiting"),process.removeListener("SIGTERM",this._onExit),process.removeListener("SIGINT",this._onExit),process.removeListener("SIGHUP",this._onExit)}async*handlePeerStoreRequest(t){try{switch(t.type){case Ce.Type.GET_PROTOCOLS:if(t.id==null)throw new Error("Invalid request");let e=De(t.id),i=(await this.libp2p.peerStore.get(e)).protocols;yield Y({peerStore:{protos:i}});return;case Ce.Type.GET_PEER_INFO:throw new Error("ERR_NOT_IMPLEMENTED");default:throw new Error("ERR_INVALID_REQUEST_TYPE")}}catch(e){Xt.error(e),yield P(e)}}async*handlePubsubRequest(t){try{if(this.libp2p.pubsub==null||this.pubsubOperations==null)throw new Error("PubSub not configured");switch(t.type){case ce.Type.GET_TOPICS:yield*this.pubsubOperations.getTopics();return;case ce.Type.SUBSCRIBE:if(t.topic==null)throw new Error("Invalid request");yield*this.pubsubOperations.subscribe(t.topic);return;case ce.Type.PUBLISH:if(t.topic==null||t.data==null)throw new Error("Invalid request");yield*this.pubsubOperations.publish(t.topic,t.data);return;default:throw new Error("ERR_INVALID_REQUEST_TYPE")}}catch(e){Xt.error(e),yield P(e)}}async*handleDHTRequest(t){try{if(this.libp2p.dht==null||this.dhtOperations==null)throw new Error("DHT not configured");switch(t.type){case At.Type.FIND_PEER:if(t.peer==null)throw new Error("Invalid request");yield*this.dhtOperations.findPeer(De(t.peer));return;case At.Type.FIND_PROVIDERS:if(t.cid==null)throw new Error("Invalid request");yield*this.dhtOperations.findProviders(k.decode(t.cid),t.count??20);return;case At.Type.PROVIDE:if(t.cid==null)throw new Error("Invalid request");yield*this.dhtOperations.provide(k.decode(t.cid));return;case At.Type.GET_CLOSEST_PEERS:if(t.key==null)throw new Error("Invalid request");yield*this.dhtOperations.getClosestPeers(t.key);return;case At.Type.GET_PUBLIC_KEY:if(t.peer==null)throw new Error("Invalid request");yield*this.dhtOperations.getPublicKey(De(t.peer));return;case At.Type.GET_VALUE:if(t.key==null)throw new Error("Invalid request");yield*this.dhtOperations.getValue(t.key);return;case At.Type.PUT_VALUE:if(t.key==null||t.value==null)throw new Error("Invalid request");yield*this.dhtOperations.putValue(t.key,t.value);return;default:throw new Error("ERR_INVALID_REQUEST_TYPE")}}catch(e){Xt.error(e),yield P(e)}}handleConnection(t){let e=this,n=new en({stream:t,maxLength:Wh});tn(n.decoder,i=>async function*(){let o;for await(let a of i)try{switch(o=xt.decode(a),o.type){case xt.Type.CONNECT:{try{await e.connect(o)}catch(l){yield P(l);break}yield Y();break}case xt.Type.IDENTIFY:{yield Y({identify:{id:e.libp2p.peerId.toBytes(),addrs:e.libp2p.getMultiaddrs().map(l=>l.decapsulateCode(O("p2p").code)).map(l=>l.bytes)}});break}case xt.Type.LIST_PEERS:{let l=[],f=new Set;for(let d of e.libp2p.getConnections()){let h=d.remotePeer.toString();f.has(h)||(f.add(h),l.push({id:d.remotePeer.toBytes(),addrs:[d.remoteAddr.bytes]}))}yield Y({peers:l});break}case xt.Type.STREAM_OPEN:{let l;try{l=await e.openStream(o)}catch(d){yield P(d);break}yield Y({streamInfo:l.streamInfo});let f=n.rest();await tn(f,l.connection,async function*(d){for await(let h of d)yield*h},f);return}case xt.Type.STREAM_HANDLER:{try{await e.registerStreamHandler(o)}catch(l){yield P(l);break}yield Y();break}case xt.Type.PEERSTORE:{if(o.peerStore==null){yield P(new Error("ERR_INVALID_REQUEST"));break}yield*e.handlePeerStoreRequest(o.peerStore);break}case xt.Type.PUBSUB:{if(o.pubsub==null){yield P(new Error("ERR_INVALID_REQUEST"));break}yield*e.handlePubsubRequest(o.pubsub);break}case xt.Type.DHT:{if(o.dht==null){yield P(new Error("ERR_INVALID_REQUEST"));break}yield*e.handleDHTRequest(o.dht);break}default:yield P(new Error("ERR_INVALID_REQUEST_TYPE"));break}}catch(l){Xt.error(l),yield P(l);continue}}(),async function(i){for await(let o of i)n.write(o)}).catch(i=>{Xt(i)})}},Zh=(r,t)=>new vn({multiaddr:r,libp2pNode:t});return Mu(Kh);})();
7
+ return Libp2PDaemonServer}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/daemon-server",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "API server for libp2p-daemon instances",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p-daemon/tree/master/packages/libp2p-daemon-server#readme",
@@ -22,7 +22,7 @@
22
22
  "types": "./dist/src/index.d.ts",
23
23
  "files": [
24
24
  "src",
25
- "dist/src",
25
+ "dist",
26
26
  "!dist/test",
27
27
  "!**/*.tsbuildinfo"
28
28
  ],
@@ -147,7 +147,7 @@
147
147
  "@libp2p/interfaces": "^3.0.2",
148
148
  "@libp2p/logger": "^2.0.0",
149
149
  "@libp2p/peer-id": "^2.0.0",
150
- "@libp2p/tcp": "^5.0.0",
150
+ "@libp2p/tcp": "^6.0.8",
151
151
  "@multiformats/multiaddr": "^11.0.0",
152
152
  "it-drain": "^2.0.0",
153
153
  "it-length-prefixed": "^8.0.2",
@@ -157,8 +157,8 @@
157
157
  "uint8arrays": "^4.0.2"
158
158
  },
159
159
  "devDependencies": {
160
- "aegir": "^37.2.0",
161
- "sinon": "^14.0.0",
160
+ "aegir": "^37.9.1",
161
+ "sinon": "^15.0.1",
162
162
  "sinon-ts": "^1.0.0"
163
163
  }
164
164
  }