@libp2p/tcp
Advanced tools
Comparing version 8.0.5 to 8.0.6-0ee4f784
@@ -6,3 +6,3 @@ (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PTcp = factory()}(typeof self !== 'undefined' ? self : this, function () { | ||
`)}function $n(t){t?process.env.DEBUG=t:delete process.env.DEBUG}function Bn(){return process.env.DEBUG}function zn(t){t.inspectOpts={};let e=Object.keys(S.inspectOpts);for(let r=0;r<e.length;r++)t.inspectOpts[e[r]]=S.inspectOpts[e[r]]}De.exports=Qe()(S);var{formatters:cr}=De.exports;cr.o=function(t){return this.inspectOpts.colors=this.useColors,Le.inspect(t,this.inspectOpts).split(` | ||
`).map(e=>e.trim()).join(" ")};cr.O=function(t){return this.inspectOpts.colors=this.useColors,Le.inspect(t,this.inspectOpts)}});var lr=M((ni,Ye)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Ye.exports=rr():Ye.exports=ar()});var Je=M((Da,en)=>{en.exports=t=>{if(t[Symbol.asyncIterator])return t;if(t.getReader)return async function*(){let e=t.getReader();try{for(;;){let{done:r,value:n}=await e.read();if(r)return;yield n}}finally{e.releaseLock()}}();throw new Error("unknown stream")}});var rn=M((_a,tn)=>{tn.exports=function(e){if(e){if(typeof e[Symbol.iterator]=="function")return e[Symbol.iterator]();if(typeof e[Symbol.asyncIterator]=="function")return e[Symbol.asyncIterator]();if(typeof e.next=="function")return e}throw new Error("argument is not an iterator or iterable")}});var qt=M((Ua,nn)=>{var Ns=rn();nn.exports=t=>async e=>{e=Ns(e);let r=m=>{typeof m.return=="function"&&m.return()},n=null,o=null,s=m=>{n=m,o&&o(m),r(e)},i=null,a=!1,p=()=>{a=!0,i&&i()},y=null,l=!1,u=()=>{l=!0,y&&y()},f=null,g=()=>{f&&f()},h=()=>new Promise((m,A)=>{i=f=m,o=A,t.once("drain",g)}),w=()=>(r(e),new Promise((m,A)=>{if(a||l||n)return m();y=i=m,o=A})),C=()=>{t.removeListener("error",s),t.removeListener("close",p),t.removeListener("finish",u),t.removeListener("drain",g)};t.once("error",s),t.once("close",p),t.once("finish",u);try{for await(let m of e){if(!t.writable||t.destroyed||n)break;t.write(m)===!1&&await h()}}catch(m){n||t.destroy(),n=m}try{if(t.writable&&t.end(),await w(),n)throw n}finally{C()}}});var jt=M(($a,on)=>{var Ls=qt(),Ds=Je();on.exports=t=>({sink:Ls(t),source:Ds(t)})});var cn=M((Ba,sn)=>{var _s=jt();sn.exports=t=>async function*(e){let r=_s(t),n;if(r.sink(e).catch(o=>{n=o}),yield*r.source,n)throw n}});var an=M((za,Se)=>{Se.exports=Je();Se.exports.source=Je();Se.exports.sink=qt();Se.exports.transform=cn();Se.exports.duplex=jt()});var Hs={};k(Hs,{tcp:()=>Xs});var pn=ne(X("net"),1);var de=class t extends Error{code;type;constructor(e="The operation was aborted"){super(e),this.code=t.code,this.type=t.type}static code="ABORT_ERR";static type="aborted"},N=class extends Error{code;props;constructor(e,r,n){super(e),this.code=r,this.name=n?.name??"CodeError",this.props=n??{}}};var Yt=Symbol.for("@libp2p/transport");var Kt;(function(t){t[t.FATAL_ALL=0]="FATAL_ALL",t[t.NO_FATAL=1]="NO_FATAL"})(Kt||(Kt={}));var D=ne(lr(),1);var nt={};k(nt,{base32:()=>G,base32hex:()=>Qn,base32hexpad:()=>Yn,base32hexpadupper:()=>Zn,base32hexupper:()=>Kn,base32pad:()=>Xn,base32padupper:()=>Hn,base32upper:()=>Jn,base32z:()=>eo});function Vn(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=t.length,p=t.charAt(0),y=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function u(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var w=0,C=0,m=0,A=h.length;m!==A&&h[m]===0;)m++,w++;for(var U=(A-m)*l+1>>>0,I=new Uint8Array(U);m!==A;){for(var q=h[m],$=0,R=U-1;(q!==0||$<C)&&R!==-1;R--,$++)q+=256*I[R]>>>0,I[R]=q%a>>>0,q=q/a>>>0;if(q!==0)throw new Error("Non-zero carry");C=$,m++}for(var B=U-C;B!==U&&I[B]===0;)B++;for(var ue=p.repeat(w);B<U;++B)ue+=t.charAt(I[B]);return ue}function f(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var w=0;if(h[w]!==" "){for(var C=0,m=0;h[w]===p;)C++,w++;for(var A=(h.length-w)*y+1>>>0,U=new Uint8Array(A);h[w];){var I=r[h.charCodeAt(w)];if(I===255)return;for(var q=0,$=A-1;(I!==0||q<m)&&$!==-1;$--,q++)I+=a*U[$]>>>0,U[$]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");m=q,w++}if(h[w]!==" "){for(var R=A-m;R!==A&&U[R]===0;)R++;for(var B=new Uint8Array(C+(A-R)),ue=C;R!==A;)B[ue++]=U[R++];return B}}}function g(h){var w=f(h);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:u,decodeUnsafe:f,decode:g}}var qn=Vn,jn=qn,ur=jn;var si=new Uint8Array(0);var dr=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},z=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var pr=t=>new TextEncoder().encode(t),fr=t=>new TextDecoder().decode(t);var Ze=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},et=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return mr(this,e)}},tt=class{constructor(e){this.decoders=e}or(e){return mr(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},mr=(t,e)=>new tt({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),rt=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ze(e,r,n),this.decoder=new et(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},ge=({name:t,prefix:e,encode:r,decode:n})=>new rt(t,e,r,n),Y=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=ur(r,e);return ge({prefix:t,name:e,encode:n,decode:s=>z(o(s))})},Gn=(t,e,r,n)=>{let o={};for(let l=0;l<e.length;++l)o[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),a=0,p=0,y=0;for(let l=0;l<s;++l){let u=o[t[l]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);p=p<<r|u,a+=r,a>=8&&(a-=8,i[y++]=255&p>>a)}if(a>=r||255&p<<8-a)throw new SyntaxError("Unexpected end of data");return i},Wn=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let p=0;p<t.length;++p)for(a=a<<8|t[p],i+=8;i>r;)i-=r,s+=e[o&a>>i];if(i&&(s+=e[o&a<<r-i]),n)for(;s.length*r&7;)s+="=";return s},v=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>ge({prefix:e,name:t,encode(o){return Wn(o,n,r)},decode(o){return Gn(o,n,r,t)}});var G=v({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Jn=v({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Xn=v({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Hn=v({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Qn=v({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Kn=v({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Yn=v({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zn=v({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),eo=v({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ot={};k(ot,{base58btc:()=>P,base58flickr:()=>to});var P=Y({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),to=Y({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var it={};k(it,{base64:()=>st,base64pad:()=>ro,base64url:()=>no,base64urlpad:()=>oo});var st=v({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ro=v({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),no=v({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),oo=v({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});D.default.formatters.b=t=>t==null?"undefined":P.baseEncode(t);D.default.formatters.t=t=>t==null?"undefined":G.baseEncode(t);D.default.formatters.m=t=>t==null?"undefined":st.baseEncode(t);D.default.formatters.p=t=>t==null?"undefined":t.toString();D.default.formatters.c=t=>t==null?"undefined":t.toString();D.default.formatters.k=t=>t==null?"undefined":t.toString();D.default.formatters.a=t=>t==null?"undefined":t.toString();function so(t){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=t,e.destroy=()=>!0,e.extend=()=>e,e}function Z(t){let e=so(`${t}:trace`);return D.default.enabled(`${t}:trace`)&&D.default.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(e=(0,D.default)(`${t}:trace`)),Object.assign((0,D.default)(t),{error:(0,D.default)(`${t}:error`),trace:e})}var io=br,gr=128,co=127,ao=~co,lo=Math.pow(2,31);function br(t,e,r){e=e||[],r=r||0;for(var n=r;t>=lo;)e[r++]=t&255|gr,t/=128;for(;t&ao;)e[r++]=t&255|gr,t>>>=7;return e[r]=t|0,br.bytes=r-n+1,e}var uo=ct,po=128,wr=127;function ct(t,n){var r=0,n=n||0,o=0,s=n,i,a=t.length;do{if(s>=a)throw ct.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&wr)<<o:(i&wr)*Math.pow(2,o),o+=7}while(i>=po);return ct.bytes=s-n,r}var fo=Math.pow(2,7),ho=Math.pow(2,14),mo=Math.pow(2,21),go=Math.pow(2,28),wo=Math.pow(2,35),bo=Math.pow(2,42),xo=Math.pow(2,49),yo=Math.pow(2,56),Co=Math.pow(2,63),vo=function(t){return t<fo?1:t<ho?2:t<mo?3:t<go?4:t<wo?5:t<bo?6:t<xo?7:t<yo?8:t<Co?9:10},Eo={encode:io,decode:uo,encodingLength:vo},Ao=Eo,Pe=Ao;var Fe=(t,e=0)=>[Pe.decode(t,e),Pe.decode.bytes],we=(t,e,r=0)=>(Pe.encode(t,e,r),e),be=t=>Pe.encodingLength(t);var se=(t,e)=>{let r=e.byteLength,n=be(t),o=n+be(r),s=new Uint8Array(o+r);return we(t,s,0),we(r,s,n),s.set(e,o),new xe(t,r,e,s)},Ue=t=>{let e=z(t),[r,n]=Fe(e),[o,s]=Fe(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new xe(r,o,i,e)},xr=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&dr(t.bytes,r.bytes)}},xe=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var yr=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return So(r,at(t),e||P.encoder);default:return To(r,at(t),e||G.encoder)}};var Cr=new WeakMap,at=t=>{let e=Cr.get(t);if(e==null){let r=new Map;return Cr.set(t,r),r}return e},ee=class t{constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==Oe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Po)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=se(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&xr(e.multihash,n.multihash)}toString(e){return yr(this,e)}toJSON(){return{"/":yr(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new t(n,o,s,i||vr(n,o,s.bytes))}else if(r[Fo]===!0){let{version:n,multihash:o,code:s}=r,i=Ue(o);return t.create(n,s,i)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==Oe)throw new Error(`Version 0 CID must use dag-pb (code: ${Oe}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=vr(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Oe,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=z(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new xe(r.multihashCode,r.digestSize,s,o);return[r.version===0?t.createV0(i):t.createV1(r.codec,i),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[u,f]=Fe(e.subarray(r));return r+=f,u},o=n(),s=Oe;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,a=n(),p=n(),y=r+p,l=y-i;return{version:o,codec:s,multihashCode:a,digestSize:p,multihashSize:l,size:y}}static parse(e,r){let[n,o]=Io(e,r),s=t.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return at(s).set(n,e),s}},Io=(t,e)=>{switch(t[0]){case"Q":{let r=e||P;return[P.prefix,r.decode(`${P.prefix}${t}`)]}case P.prefix:{let r=e||P;return[P.prefix,r.decode(t)]}case G.prefix:{let r=e||G;return[G.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},So=(t,e,r)=>{let{prefix:n}=r;if(n!==P.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o},To=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o},Oe=112,Po=18,vr=(t,e,r)=>{let n=be(t),o=n+be(e),s=new Uint8Array(o+r.byteLength);return we(t,s,0),we(e,s,n),s.set(r,o),s},Fo=Symbol.for("@ipld/js-cid/CID");function Er(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var lt={};k(lt,{identity:()=>Oo});var Oo=ge({prefix:"\0",name:"identity",encode:t=>fr(t),decode:t=>pr(t)});var ut={};k(ut,{base2:()=>Ro});var Ro=v({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var dt={};k(dt,{base8:()=>Mo});var Mo=v({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var pt={};k(pt,{base10:()=>ko});var ko=Y({prefix:"9",name:"base10",alphabet:"0123456789"});var ft={};k(ft,{base16:()=>No,base16upper:()=>Lo});var No=v({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Lo=v({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ht={};k(ht,{base36:()=>Do,base36upper:()=>_o});var Do=Y({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),_o=Y({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var mt={};k(mt,{base256emoji:()=>Vo});var Ar=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}"),Uo=Ar.reduce((t,e,r)=>(t[r]=e,t),[]),$o=Ar.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Bo(t){return t.reduce((e,r)=>(e+=Uo[r],e),"")}function zo(t){let e=[];for(let r of t){let n=$o[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var Vo=ge({prefix:"\u{1F680}",name:"base256emoji",encode:Bo,decode:zo});var xt={};k(xt,{sha256:()=>qo,sha512:()=>jo});var bt=ne(X("crypto"),1);var wt=({name:t,code:e,encode:r})=>new gt(t,e,r),gt=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?se(this.code,r):r.then(n=>se(this.code,n))}else throw Error("Unknown type, must be binary type")}};var qo=wt({name:"sha2-256",code:18,encode:t=>z(bt.default.createHash("sha256").update(t).digest())}),jo=wt({name:"sha2-512",code:19,encode:t=>z(bt.default.createHash("sha512").update(t).digest())});var yt={};k(yt,{identity:()=>Jo});var Sr=0,Go="identity",Tr=z,Wo=t=>se(Sr,Tr(t)),Jo={code:Sr,name:Go,encode:Tr,digest:Wo};var _i=new TextEncoder,Ui=new TextDecoder;var Re={...lt,...ut,...dt,...pt,...ft,...nt,...ht,...ot,...it,...mt},qi={...xt,...yt};function Ce(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function ve(t=0){return globalThis.Buffer?.allocUnsafe!=null?Ce(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Fr(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var Pr=Fr("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Ct=Fr("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=ve(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Qo={utf8:Pr,"utf-8":Pr,hex:Re.base16,latin1:Ct,ascii:Ct,binary:Ct,...Re},$e=Qo;function O(t,e="utf8"){let r=$e[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var Ko=Math.pow(2,7),Yo=Math.pow(2,14),Zo=Math.pow(2,21),vt=Math.pow(2,28),Et=Math.pow(2,35),At=Math.pow(2,42),It=Math.pow(2,49),b=128,F=127;function W(t){if(t<Ko)return 1;if(t<Yo)return 2;if(t<Zo)return 3;if(t<vt)return 4;if(t<Et)return 5;if(t<At)return 6;if(t<It)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function es(t,e,r=0){switch(W(t)){case 8:e[r++]=t&255|b,t/=128;case 7:e[r++]=t&255|b,t/=128;case 6:e[r++]=t&255|b,t/=128;case 5:e[r++]=t&255|b,t/=128;case 4:e[r++]=t&255|b,t>>>=7;case 3:e[r++]=t&255|b,t>>>=7;case 2:e[r++]=t&255|b,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function ts(t,e,r=0){switch(W(t)){case 8:e.set(r++,t&255|b),t/=128;case 7:e.set(r++,t&255|b),t/=128;case 6:e.set(r++,t&255|b),t/=128;case 5:e.set(r++,t&255|b),t/=128;case 4:e.set(r++,t&255|b),t>>>=7;case 3:e.set(r++,t&255|b),t>>>=7;case 2:e.set(r++,t&255|b),t>>>=7;case 1:{e.set(r++,t&255),t>>>=7;break}default:throw new Error("unreachable")}return e}function rs(t,e){let r=t[e],n=0;if(n+=r&F,r<b||(r=t[e+1],n+=(r&F)<<7,r<b)||(r=t[e+2],n+=(r&F)<<14,r<b)||(r=t[e+3],n+=(r&F)<<21,r<b)||(r=t[e+4],n+=(r&F)*vt,r<b)||(r=t[e+5],n+=(r&F)*Et,r<b)||(r=t[e+6],n+=(r&F)*At,r<b)||(r=t[e+7],n+=(r&F)*It,r<b))return n;throw new RangeError("Could not decode varint")}function ns(t,e){let r=t.get(e),n=0;if(n+=r&F,r<b||(r=t.get(e+1),n+=(r&F)<<7,r<b)||(r=t.get(e+2),n+=(r&F)<<14,r<b)||(r=t.get(e+3),n+=(r&F)<<21,r<b)||(r=t.get(e+4),n+=(r&F)*vt,r<b)||(r=t.get(e+5),n+=(r&F)*Et,r<b)||(r=t.get(e+6),n+=(r&F)*At,r<b)||(r=t.get(e+7),n+=(r&F)*It,r<b))return n;throw new RangeError("Could not decode varint")}function Ee(t,e,r=0){return e==null&&(e=ve(W(t))),e instanceof Uint8Array?es(t,e,r):ts(t,e,r)}function ie(t,e=0){return t instanceof Uint8Array?rs(t,e):ns(t,e)}function H(t,e){e==null&&(e=t.reduce((o,s)=>o+s.length,0));let r=ve(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return Ce(r)}var Be=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let r=this.index,n=e();return n===void 0&&(this.index=r),n}parseWith(e){let r=e();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let r=this.readChar();if(r===e)return r})}readSeparator(e,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,r,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let p=a==="0",y=2**(8*o)-1;for(;;){let l=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let f=Number.parseInt(u,e);if(!Number.isNaN(f))return f});if(l===void 0)break;if(s*=e,s+=l,s>y||(i+=1,r!==void 0&&i>r))return}if(i!==0)return!n&&p&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let r=0;r<e.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[r]=n}return e})}readIPv6Addr(){let e=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return r[o]=i[0],r[o+1]=i[1],r[o+2]=i[2],r[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];r[o]=s>>8,r[o+1]=s&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=e(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=e(s.subarray(0,i));return r.set(s.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var sc=new Be;var fc=parseInt("0xFFFF",16),hc=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function St(t,e="utf8"){let r=$e[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Ce(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var V=X("node:net");function ze(t){return!!(0,V.isIP)(t)}var kr=V.isIPv4,ls=V.isIPv6,Tt=function(t){let e=0;if(t=t.toString().trim(),kr(t)){let r=new Uint8Array(e+4);return t.split(/\./g).forEach(n=>{r[e++]=parseInt(n,10)&255}),r}if(ls(t)){let r=t.split(":",8),n;for(n=0;n<r.length;n++){let s=kr(r[n]),i;s&&(i=Tt(r[n]),r[n]=O(i.slice(0,2),"base16")),i!=null&&++n<8&&r.splice(n,0,O(i.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let s=[n,1];for(n=9-r.length;n>0;n--)s.push("0");r.splice.apply(r,s)}let o=new Uint8Array(e+16);for(n=0;n<r.length;n++){let s=parseInt(r[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},Nr=function(t,e=0,r){e=~~e,r=r??t.length-e;let n=new DataView(t.buffer);if(r===4){let o=[];for(let s=0;s<r;s++)o.push(t[e+s]);return o.join(".")}if(r===16){let o=[];for(let s=0;s<r;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Ae={},Pt={},ds=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];ds.forEach(t=>{let e=ps(...t);Pt[e.code]=e,Ae[e.name]=e});function ps(t,e,r,n,o){return{code:t,size:e,name:r,resolvable:!!n,path:!!o}}function x(t){if(typeof t=="number"){if(Pt[t]!=null)return Pt[t];throw new Error(`no protocol with code: ${t}`)}else if(typeof t=="string"){if(Ae[t]!=null)return Ae[t];throw new Error(`no protocol with name: ${t}`)}throw new Error(`invalid protocol id type: ${typeof t}`)}var ta=x("ip4"),ra=x("ip6"),na=x("ipcidr");function Ot(t,e){switch(x(t).code){case 4:case 41:return hs(e);case 42:return _r(e);case 6:case 273:case 33:case 132:return $r(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return _r(e);case 421:return bs(e);case 444:return Ur(e);case 445:return Ur(e);case 466:return ws(e);default:return O(e,"base16")}}function Rt(t,e){switch(x(t).code){case 4:return Lr(e);case 41:return Lr(e);case 42:return Dr(e);case 6:case 273:case 33:case 132:return Mt(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Dr(e);case 421:return ms(e);case 444:return xs(e);case 445:return ys(e);case 466:return gs(e);default:return St(e,"base16")}}var Ft=Object.values(Re).map(t=>t.decoder),fs=function(){let t=Ft[0].or(Ft[1]);return Ft.slice(2).forEach(e=>t=t.or(e)),t}();function Lr(t){if(!ze(t))throw new Error("invalid ip address");return Tt(t)}function hs(t){let e=Nr(t,0,t.length);if(e==null)throw new Error("ipBuff is required");if(!ze(e))throw new Error("invalid ip address");return e}function Mt(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function $r(t){return new DataView(t.buffer).getUint16(t.byteOffset)}function Dr(t){let e=St(t),r=Uint8Array.from(Ee(e.length));return H([r,e],r.length+e.length)}function _r(t){let e=ie(t);if(t=t.slice(W(e)),t.length!==e)throw new Error("inconsistent lengths");return O(t)}function ms(t){let e;t[0]==="Q"||t[0]==="1"?e=Ue(P.decode(`z${t}`)).bytes:e=ee.parse(t).multihash.bytes;let r=Uint8Array.from(Ee(e.length));return H([r,e],r.length+e.length)}function gs(t){let e=fs.decode(t),r=Uint8Array.from(Ee(e.length));return H([r,e],r.length+e.length)}function ws(t){let e=ie(t),r=t.slice(W(e));if(r.length!==e)throw new Error("inconsistent lengths");return"u"+O(r,"base64url")}function bs(t){let e=ie(t),r=t.slice(W(e));if(r.length!==e)throw new Error("inconsistent lengths");return O(r,"base58btc")}function xs(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let r=G.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Mt(n);return H([r,o],r.length+o.length)}function ys(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let r=G.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Mt(n);return H([r,o],r.length+o.length)}function Ur(t){let e=t.slice(0,t.length-2),r=t.slice(t.length-2),n=O(e,"base32"),o=$r(r);return`${n}:${o}`}function Br(t){t=kt(t);let e=[],r=[],n=null,o=t.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],a=x(i);if(a.size===0){e.push([a.code]),r.push([a.code]);continue}if(s++,s>=o.length)throw Vr("invalid address: "+t);if(a.path===!0){n=kt(o.slice(s).join("/")),e.push([a.code,Rt(a.code,n)]),r.push([a.code,n]);break}let p=Rt(a.code,o[s]);e.push([a.code,p]),r.push([a.code,Ot(a.code,p)])}return{string:zr(r),bytes:Lt(e),tuples:e,stringTuples:r,path:n}}function Nt(t){let e=[],r=[],n=null,o=0;for(;o<t.length;){let s=ie(t,o),i=W(s),a=x(s),p=Cs(a,t.slice(o+i));if(p===0){e.push([s]),r.push([s]),o+=i;continue}let y=t.slice(o+i,o+i+p);if(o+=p+i,o>t.length)throw Vr("Invalid address Uint8Array: "+O(t,"base16"));e.push([s,y]);let l=Ot(s,y);if(r.push([s,l]),a.path===!0){n=l;break}}return{bytes:Uint8Array.from(t),string:zr(r),tuples:e,stringTuples:r,path:n}}function zr(t){let e=[];return t.map(r=>{let n=x(r[0]);return e.push(n.name),r.length>1&&r[1]!=null&&e.push(r[1]),null}),kt(e.join("/"))}function Lt(t){return H(t.map(e=>{let r=x(e[0]),n=Uint8Array.from(Ee(r.code));return e.length>1&&e[1]!=null&&(n=H([n,e[1]])),n}))}function Cs(t,e){if(t.size>0)return t.size/8;if(t.size===0)return 0;{let r=ie(e instanceof Uint8Array?e:Uint8Array.from(e));return r+W(r)}}function kt(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}function Vr(t){return new Error("Error parsing address: "+t)}var vs=Symbol.for("nodejs.util.inspect.custom"),Es=[x("dns").code,x("dns4").code,x("dns6").code,x("dnsaddr").code],As=new Map,qr=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Is(t){return!!t?.[qr]}var Dt=class t{bytes;#e;#t;#r;#n;[qr]=!0;constructor(e){e==null&&(e="");let r;if(e instanceof Uint8Array)r=Nt(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);r=Br(e)}else if(Is(e))r=Nt(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.bytes,this.#e=r.string,this.#t=r.tuples,this.#r=r.stringTuples,this.#n=r.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,r,n,o,s="",i=x("tcp"),a=x("udp"),p=x("ip4"),y=x("ip6"),l=x("dns6"),u=x("ip6zone");for(let[g,h]of this.stringTuples())g===u.code&&(s=`%${h??""}`),Es.includes(g)&&(r=i.name,o=443,n=`${h??""}${s}`,e=g===l.code?6:4),(g===i.code||g===a.code)&&(r=x(g).name,o=parseInt(h??"")),(g===p.code||g===y.code)&&(r=x(g).name,n=`${h??""}${s}`,e=g===y.code?6:4);if(e==null||r==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:r,port:o}}protos(){return this.#t.map(([e])=>Object.assign({},x(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>x(e).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(e){return e=new t(e),new t(this.toString()+e.toString())}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new t(n.slice(0,o))}decapsulateCode(e){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===e)return new t(Lt(r.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===Ae.p2p.code&&e.push([n,o]),n===Ae["p2p-circuit"].code&&(e=[])});let r=e.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?O(P.decode(`z${n}`),"base58btc"):O(ee.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return Er(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(s=>s.resolvable);if(r==null)return[this];let n=As.get(r.name);if(n==null)throw new N(`no available resolver for ${r.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new t(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let r=(e??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[vs](){return`Multiaddr(${this.#e})`}};function Q(t){return new Dt(t)}var Ss=c("dns4"),Ts=c("dns6"),Ps=c("dnsaddr"),ae=E(c("dns"),Ps,Ss,Ts),je=E(c("ip4"),c("ip6")),re=E(d(je,c("tcp")),d(ae,c("tcp"))),Ge=d(je,c("udp")),Fs=d(Ge,c("utp")),Os=d(Ge,c("quic")),Rs=d(Ge,c("quic-v1")),_t=E(d(re,c("ws")),d(ae,c("ws"))),Ve=E(d(_t,c("p2p")),_t),Ut=E(d(re,c("wss")),d(ae,c("wss")),d(re,c("tls"),c("ws")),d(ae,c("tls"),c("ws"))),qe=E(d(Ut,c("p2p")),Ut),$t=E(d(re,c("http")),d(je,c("http")),d(ae,c("http"))),Bt=E(d(re,c("https")),d(je,c("https")),d(ae,c("https"))),jr=d(Ge,c("webrtc-direct"),c("certhash")),Jr=E(d(jr,c("p2p")),jr),Gr=d(Rs,c("webtransport"),c("certhash"),c("certhash")),Xr=E(d(Gr,c("p2p")),Gr),Hr=E(d(Ve,c("p2p-webrtc-star"),c("p2p")),d(qe,c("p2p-webrtc-star"),c("p2p")),d(Ve,c("p2p-webrtc-star")),d(qe,c("p2p-webrtc-star"))),Ia=E(d(Ve,c("p2p-websocket-star"),c("p2p")),d(qe,c("p2p-websocket-star"),c("p2p")),d(Ve,c("p2p-websocket-star")),d(qe,c("p2p-websocket-star"))),Qr=E(d($t,c("p2p-webrtc-direct"),c("p2p")),d(Bt,c("p2p-webrtc-direct"),c("p2p")),d($t,c("p2p-webrtc-direct")),d(Bt,c("p2p-webrtc-direct"))),le=E(_t,Ut,$t,Bt,Hr,Qr,re,Fs,Os,ae,Jr,Xr),Sa=E(d(le,c("p2p-stardust"),c("p2p")),d(le,c("p2p-stardust"))),te=E(d(le,c("p2p")),Hr,Qr,Jr,Xr,c("p2p")),Wr=E(d(te,c("p2p-circuit"),te),d(te,c("p2p-circuit")),d(c("p2p-circuit"),te),d(le,c("p2p-circuit")),d(c("p2p-circuit"),le),c("p2p-circuit")),Kr=()=>E(d(Wr,Kr),Wr),ce=Kr(),Ta=E(d(ce,te,ce),d(te,ce),d(ce,te),ce,te);var Pa=E(d(ce,c("webrtc"),c("p2p")),d(ce,c("webrtc")),d(le,c("webrtc"),c("p2p")),d(le,c("webrtc")),c("webrtc"));function Yr(t){function e(r){let n;try{n=Q(r)}catch{return!1}let o=t(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return e}function d(...t){function e(r){if(r.length<t.length)return null;let n=r;return t.some(o=>(n=typeof o=="function"?o().partialMatch(r):o.partialMatch(r),Array.isArray(n)&&(r=n),n===null)),n}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:Yr(e),partialMatch:e}}function E(...t){function e(n){let o=null;return t.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:Yr(e),partialMatch:e}}function c(t){let e=t;function r(o){let s;try{s=Q(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===e}function n(o){return o.length===0?null:o[0]===e?o.slice(1):null}return{toString:function(){return e},matches:r,partialMatch:n}}var dn=ne(X("net"),1);var We=class extends EventTarget{#e=new Map;listenerCount(e){let r=this.#e.get(e);return r==null?0:r.length}addEventListener(e,r,n){super.addEventListener(e,r,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:r,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,r,n){super.removeEventListener(e.toString(),r??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:s})=>s!==r),this.#e.set(e,o))}dispatchEvent(e){let r=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),r}safeDispatchEvent(e,r){return this.dispatchEvent(new Ie(e,r))}},zt=class extends Event{detail;constructor(e,r){super(e,r),this.detail=r?.detail}},Ie=globalThis.CustomEvent??zt;var ks=Z("libp2p:ip-port-to-multiaddr"),Vt={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function Zr(t,e){if(typeof t!="string")throw new N(`invalid ip provided: ${t}`,Vt.ERR_INVALID_IP_PARAMETER);if(typeof e=="string"&&(e=parseInt(e)),isNaN(e))throw new N(`invalid port provided: ${e}`,Vt.ERR_INVALID_PORT_PARAMETER);if((0,V.isIPv4)(t))return Q(`/ip4/${t}/tcp/${e}`);if((0,V.isIPv6)(t))return Q(`/ip6/${t}/tcp/${e}`);let r=`invalid ip:port for creating a multiaddr: ${t}:${e}`;throw ks.error(r),new N(r,Vt.ERR_INVALID_IP)}var un=ne(an(),1);var Gt=ne(X("os"),1),ln=ne(X("path"),1);var Us={ip4:"IPv4",ip6:"IPv6"};function Te(t,e={}){let r=t.getPath();return r!=null?Gt.default.platform()==="win32"?{path:ln.default.join("\\\\.\\pipe\\",r)}:{path:r}:{...t.toOptions(),...e}}function Wt(t,e,r){let n=o=>Q(`/${t}/${o}/tcp/${r}`);return($s(e)?zs(Us[t]):[e]).map(n)}function $s(t){return["0.0.0.0","::"].includes(t)}var Bs=Gt.default.networkInterfaces();function zs(t){let e=[];for(let[,r]of Object.entries(Bs))if(r!=null)for(let n of r)n.family===t&&e.push(n.address);return e}var J=Z("libp2p:tcp:socket"),Xe=(t,e)=>{let r=e.metrics,n=e.metricPrefix??"",o=e.socketInactivityTimeout??3e5,s=e.socketCloseTimeout??500;e.listeningAddr?.getPath()!=null&&(e.remoteAddr=e.listeningAddr),e.remoteAddr?.getPath()!=null&&(e.localAddr=e.remoteAddr);let i;if(e.remoteAddr!=null)i=e.remoteAddr;else{if(t.remoteAddress==null||t.remotePort==null)throw new N("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");i=Zr(t.remoteAddress,t.remotePort)}let a=Te(i),p=a.path??`${a.host??""}:${a.port??""}`,{sink:y,source:l}=un.default.duplex(t);t.setTimeout(o,()=>{J("%s socket read timeout",p),r?.increment({[`${n}timeout`]:!0});let f;t.readable&&(f=new N("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),t.destroy(f)}),t.once("close",()=>{J("%s socket close",p),r?.increment({[`${n}close`]:!0}),u.timeline.close==null&&(u.timeline.close=Date.now())}),t.once("end",()=>{J("%s socket end",p),r?.increment({[`${n}end`]:!0})});let u={async sink(f){try{await y(f)}catch(g){g.type!=="aborted"&&J(g)}t.end()},source:l,remoteAddr:i,timeline:{open:Date.now()},async close(f={}){if(t.destroyed){J("%s socket was already destroyed when trying to close",p);return}f.signal=f.signal??AbortSignal.timeout(s);try{J("%s closing socket",p),await new Promise((g,h)=>{t.once("close",()=>{J("%s socket closed",p),g()}),t.once("error",w=>{J("%s socket error",p,w),u.timeline.close==null&&(u.timeline.close=Date.now()),h(w)}),t.setTimeout(s),t.end(),t.writableLength>0?t.once("drain",()=>{J("%s socket drained",p),t.destroy()}):t.destroy()})}catch(g){this.abort(g)}},abort:f=>{J("%s socket abort due to error",p,f),t.destroy(f)}};return u};var _=Z("libp2p:tcp:listener");async function Jt(t){try{await t.close()}catch(e){_.error("an error occurred closing the connection",e)}}var js=1,Gs=0,He=class extends We{context;server;connections=new Set;status={started:!1};metrics;addr;constructor(e){if(super(),this.context=e,e.keepAlive=e.keepAlive??!0,this.addr="unknown",this.server=dn.default.createServer(e,this.onSocket.bind(this)),e.maxConnections!==void 0&&(this.server.maxConnections=e.maxConnections),e.closeServerOnMaxConnections!=null&&e.closeServerOnMaxConnections.closeAbove<e.closeServerOnMaxConnections.listenBelow)throw Error("closeAbove must be >= listenBelow");this.server.on("listening",()=>{if(e.metrics!=null){let r=this.server.address();r==null?this.addr="unknown":typeof r=="string"?this.addr=r:this.addr=`${r.address}:${r.port}`,e.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:e.metrics.registerMetricGroup("libp2p_tcp_listener_status_info",{label:"address",help:"Current status of the TCP listener socket"}),errors:e.metrics.registerMetricGroup("libp2p_tcp_listener_errors_total",{label:"address",help:"Total count of TCP listener errors by type"}),events:e.metrics.registerMetricGroup("libp2p_tcp_listener_events_total",{label:"address",help:"Total count of TCP listener events by type"})},this.metrics?.status.update({[this.addr]:js})}this.dispatchEvent(new Ie("listening"))}).on("error",r=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new Ie("error",{detail:r}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:Gs}),this.dispatchEvent(new Ie("close"))})}onSocket(e){e.on("error",n=>{_("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let r;try{r=Xe(e,{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){_.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}_("new inbound connection %s",r.remoteAddr);try{this.context.upgrader.upgradeInbound(r).then(n=>{_("inbound connection upgraded %s",r.remoteAddr),this.connections.add(r),e.once("close",()=>{this.connections.delete(r),this.context.closeServerOnMaxConnections!=null&&this.connections.size<this.context.closeServerOnMaxConnections.listenBelow&&this.netListen().catch(o=>{_.error("error attempting to listen server once connection count under limit",o),this.context.closeServerOnMaxConnections?.onListenError?.(o)})}),this.context.handler!=null&&this.context.handler(n),this.context.closeServerOnMaxConnections!=null&&this.connections.size>=this.context.closeServerOnMaxConnections.closeAbove&&this.netClose(),this.dispatchEvent(new Ie("connection",{detail:n}))}).catch(async n=>{_.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await Jt(r)}).catch(n=>{_.error("closing inbound connection failed",n)})}catch(n){_.error("inbound connection failed",n),Jt(r).catch(o=>{_.error("closing inbound connection failed",o),this.metrics?.errors.increment({[`${this.addr} inbound_closing_failed`]:!0})})}}getAddrs(){if(!this.status.started)return[];let e=[],r=this.server.address(),{listeningAddr:n,peerId:o}=this.status;if(r==null)return[];if(typeof r=="string")e=[n];else try{n.toString().startsWith("/ip4")?e=e.concat(Wt("ip4",r.address,r.port)):r.family==="IPv6"&&(e=e.concat(Wt("ip6",r.address,r.port)))}catch(s){_.error("could not turn %s:%s into multiaddr",r.address,r.port,s)}return e.map(s=>o!=null?s.encapsulate(`/p2p/${o}`):s)}async listen(e){if(this.status.started)throw Error("server is already listening");let r=e.getPeerId(),n=r==null?e.decapsulateCode(421):e,{backlog:o}=this.context;this.status={started:!0,listeningAddr:n,peerId:r,netConfig:Te(n,{backlog:o})},await this.netListen()}async close(){await Promise.all(Array.from(this.connections.values()).map(async e=>{await Jt(e)})),this.netClose()}async netListen(){if(!this.status.started||this.server.listening)return;let e=this.status.netConfig;await new Promise((r,n)=>{this.server.once("error",n),this.server.listen(e,r)}),_("Listening on %s",this.server.address())}netClose(){!this.status.started||!this.server.listening||(_("Closing server on %s",this.server.address()),this.server.close())}};var K=Z("libp2p:tcp"),Ht=class{opts;metrics;components;constructor(e,r={}){this.opts=r,this.components=e,e.metrics!=null&&(this.metrics={dialerEvents:e.metrics.registerCounterGroup("libp2p_tcp_dialer_events_total",{label:"event",help:"Total count of TCP dialer events by type"})})}[Yt]=!0;[Symbol.toStringTag]="@libp2p/tcp";async dial(e,r){r.keepAlive=r.keepAlive??!0;let n=await this._connect(e,r);n.on("error",a=>{K("socket error",a)});let o=Xe(n,{remoteAddr:e,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents}),s=()=>{o.close().catch(a=>{K.error("Error closing maConn after abort",a)})};r.signal?.addEventListener("abort",s,{once:!0}),K("new outbound connection %s",o.remoteAddr);let i=await r.upgrader.upgradeOutbound(o);if(K("outbound connection %s upgraded",o.remoteAddr),r.signal?.removeEventListener("abort",s),r.signal?.aborted===!0)throw i.close().catch(a=>{K.error("Error closing conn after abort",a)}),new de;return i}async _connect(e,r){if(r.signal?.aborted===!0)throw new de;return new Promise((n,o)=>{let s=Date.now(),i=Te(e),a=i.path??`${i.host??""}:${i.port}`;K("dialing %j",i);let p=pn.default.connect(i),y=h=>{h.message=`connection error ${a}: ${h.message}`,this.metrics?.dialerEvents.increment({error:!0}),g(h)},l=()=>{K("connection timeout %s",a),this.metrics?.dialerEvents.increment({timeout:!0});let h=new N(`connection timeout after ${Date.now()-s}ms`,"ERR_CONNECT_TIMEOUT");p.emit("error",h)},u=()=>{K("connection opened %j",i),this.metrics?.dialerEvents.increment({connect:!0}),g()},f=()=>{K("connection aborted %j",i),this.metrics?.dialerEvents.increment({abort:!0}),p.destroy(),g(new de)},g=h=>{if(p.removeListener("error",y),p.removeListener("timeout",l),p.removeListener("connect",u),r.signal!=null&&r.signal.removeEventListener("abort",f),h!=null){o(h);return}n(p)};p.on("error",y),p.on("timeout",l),p.on("connect",u),r.signal!=null&&r.signal.addEventListener("abort",f)})}createListener(e){return new He({...e,maxConnections:this.opts.maxConnections,backlog:this.opts.backlog,closeServerOnMaxConnections:this.opts.closeServerOnMaxConnections,socketInactivityTimeout:this.opts.inboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.components.metrics})}filter(e){return e=Array.isArray(e)?e:[e],e.filter(r=>r.protoCodes().includes(290)?!1:r.protoCodes().includes(400)?!0:re.matches(r.decapsulateCode(421)))}};function Xs(t={}){return(e={})=>new Ht(e,t)}return bn(Hs);})(); | ||
`).map(e=>e.trim()).join(" ")};cr.O=function(t){return this.inspectOpts.colors=this.useColors,Le.inspect(t,this.inspectOpts)}});var lr=M((ni,Ye)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Ye.exports=rr():Ye.exports=ar()});var Je=M((Da,en)=>{en.exports=t=>{if(t[Symbol.asyncIterator])return t;if(t.getReader)return async function*(){let e=t.getReader();try{for(;;){let{done:r,value:n}=await e.read();if(r)return;yield n}}finally{e.releaseLock()}}();throw new Error("unknown stream")}});var rn=M((_a,tn)=>{tn.exports=function(e){if(e){if(typeof e[Symbol.iterator]=="function")return e[Symbol.iterator]();if(typeof e[Symbol.asyncIterator]=="function")return e[Symbol.asyncIterator]();if(typeof e.next=="function")return e}throw new Error("argument is not an iterator or iterable")}});var qt=M((Ua,nn)=>{var Ns=rn();nn.exports=t=>async e=>{e=Ns(e);let r=m=>{typeof m.return=="function"&&m.return()},n=null,o=null,s=m=>{n=m,o&&o(m),r(e)},i=null,a=!1,p=()=>{a=!0,i&&i()},y=null,l=!1,u=()=>{l=!0,y&&y()},f=null,g=()=>{f&&f()},h=()=>new Promise((m,A)=>{i=f=m,o=A,t.once("drain",g)}),w=()=>(r(e),new Promise((m,A)=>{if(a||l||n)return m();y=i=m,o=A})),C=()=>{t.removeListener("error",s),t.removeListener("close",p),t.removeListener("finish",u),t.removeListener("drain",g)};t.once("error",s),t.once("close",p),t.once("finish",u);try{for await(let m of e){if(!t.writable||t.destroyed||n)break;t.write(m)===!1&&await h()}}catch(m){n||t.destroy(),n=m}try{if(t.writable&&t.end(),await w(),n)throw n}finally{C()}}});var jt=M(($a,on)=>{var Ls=qt(),Ds=Je();on.exports=t=>({sink:Ls(t),source:Ds(t)})});var cn=M((Ba,sn)=>{var _s=jt();sn.exports=t=>async function*(e){let r=_s(t),n;if(r.sink(e).catch(o=>{n=o}),yield*r.source,n)throw n}});var an=M((za,Se)=>{Se.exports=Je();Se.exports.source=Je();Se.exports.sink=qt();Se.exports.transform=cn();Se.exports.duplex=jt()});var Hs={};k(Hs,{tcp:()=>Xs});var pn=ne(X("net"),1);var de=class t extends Error{code;type;constructor(e="The operation was aborted"){super(e),this.code=t.code,this.type=t.type}static code="ABORT_ERR";static type="aborted"},N=class extends Error{code;props;constructor(e,r,n){super(e),this.code=r,this.name=n?.name??"CodeError",this.props=n??{}}};var Yt=Symbol.for("@libp2p/transport");var Kt;(function(t){t[t.FATAL_ALL=0]="FATAL_ALL",t[t.NO_FATAL=1]="NO_FATAL"})(Kt||(Kt={}));var D=ne(lr(),1);var nt={};k(nt,{base32:()=>G,base32hex:()=>Qn,base32hexpad:()=>Yn,base32hexpadupper:()=>Zn,base32hexupper:()=>Kn,base32pad:()=>Xn,base32padupper:()=>Hn,base32upper:()=>Jn,base32z:()=>eo});function Vn(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=t.length,p=t.charAt(0),y=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function u(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var w=0,C=0,m=0,A=h.length;m!==A&&h[m]===0;)m++,w++;for(var U=(A-m)*l+1>>>0,I=new Uint8Array(U);m!==A;){for(var q=h[m],$=0,R=U-1;(q!==0||$<C)&&R!==-1;R--,$++)q+=256*I[R]>>>0,I[R]=q%a>>>0,q=q/a>>>0;if(q!==0)throw new Error("Non-zero carry");C=$,m++}for(var B=U-C;B!==U&&I[B]===0;)B++;for(var ue=p.repeat(w);B<U;++B)ue+=t.charAt(I[B]);return ue}function f(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var w=0;if(h[w]!==" "){for(var C=0,m=0;h[w]===p;)C++,w++;for(var A=(h.length-w)*y+1>>>0,U=new Uint8Array(A);h[w];){var I=r[h.charCodeAt(w)];if(I===255)return;for(var q=0,$=A-1;(I!==0||q<m)&&$!==-1;$--,q++)I+=a*U[$]>>>0,U[$]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");m=q,w++}if(h[w]!==" "){for(var R=A-m;R!==A&&U[R]===0;)R++;for(var B=new Uint8Array(C+(A-R)),ue=C;R!==A;)B[ue++]=U[R++];return B}}}function g(h){var w=f(h);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:u,decodeUnsafe:f,decode:g}}var qn=Vn,jn=qn,ur=jn;var si=new Uint8Array(0);var dr=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},z=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var pr=t=>new TextEncoder().encode(t),fr=t=>new TextDecoder().decode(t);var Ze=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},et=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return mr(this,e)}},tt=class{constructor(e){this.decoders=e}or(e){return mr(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},mr=(t,e)=>new tt({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),rt=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ze(e,r,n),this.decoder=new et(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},ge=({name:t,prefix:e,encode:r,decode:n})=>new rt(t,e,r,n),Y=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=ur(r,e);return ge({prefix:t,name:e,encode:n,decode:s=>z(o(s))})},Gn=(t,e,r,n)=>{let o={};for(let l=0;l<e.length;++l)o[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),a=0,p=0,y=0;for(let l=0;l<s;++l){let u=o[t[l]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);p=p<<r|u,a+=r,a>=8&&(a-=8,i[y++]=255&p>>a)}if(a>=r||255&p<<8-a)throw new SyntaxError("Unexpected end of data");return i},Wn=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let p=0;p<t.length;++p)for(a=a<<8|t[p],i+=8;i>r;)i-=r,s+=e[o&a>>i];if(i&&(s+=e[o&a<<r-i]),n)for(;s.length*r&7;)s+="=";return s},v=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>ge({prefix:e,name:t,encode(o){return Wn(o,n,r)},decode(o){return Gn(o,n,r,t)}});var G=v({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Jn=v({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Xn=v({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Hn=v({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Qn=v({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Kn=v({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Yn=v({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zn=v({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),eo=v({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ot={};k(ot,{base58btc:()=>P,base58flickr:()=>to});var P=Y({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),to=Y({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var it={};k(it,{base64:()=>st,base64pad:()=>ro,base64url:()=>no,base64urlpad:()=>oo});var st=v({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ro=v({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),no=v({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),oo=v({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});D.default.formatters.b=t=>t==null?"undefined":P.baseEncode(t);D.default.formatters.t=t=>t==null?"undefined":G.baseEncode(t);D.default.formatters.m=t=>t==null?"undefined":st.baseEncode(t);D.default.formatters.p=t=>t==null?"undefined":t.toString();D.default.formatters.c=t=>t==null?"undefined":t.toString();D.default.formatters.k=t=>t==null?"undefined":t.toString();D.default.formatters.a=t=>t==null?"undefined":t.toString();function so(t){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=t,e.destroy=()=>!0,e.extend=()=>e,e}function Z(t){let e=so(`${t}:trace`);return D.default.enabled(`${t}:trace`)&&D.default.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(e=(0,D.default)(`${t}:trace`)),Object.assign((0,D.default)(t),{error:(0,D.default)(`${t}:error`),trace:e})}var io=br,gr=128,co=127,ao=~co,lo=Math.pow(2,31);function br(t,e,r){e=e||[],r=r||0;for(var n=r;t>=lo;)e[r++]=t&255|gr,t/=128;for(;t&ao;)e[r++]=t&255|gr,t>>>=7;return e[r]=t|0,br.bytes=r-n+1,e}var uo=ct,po=128,wr=127;function ct(t,n){var r=0,n=n||0,o=0,s=n,i,a=t.length;do{if(s>=a)throw ct.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&wr)<<o:(i&wr)*Math.pow(2,o),o+=7}while(i>=po);return ct.bytes=s-n,r}var fo=Math.pow(2,7),ho=Math.pow(2,14),mo=Math.pow(2,21),go=Math.pow(2,28),wo=Math.pow(2,35),bo=Math.pow(2,42),xo=Math.pow(2,49),yo=Math.pow(2,56),Co=Math.pow(2,63),vo=function(t){return t<fo?1:t<ho?2:t<mo?3:t<go?4:t<wo?5:t<bo?6:t<xo?7:t<yo?8:t<Co?9:10},Eo={encode:io,decode:uo,encodingLength:vo},Ao=Eo,Pe=Ao;var Fe=(t,e=0)=>[Pe.decode(t,e),Pe.decode.bytes],we=(t,e,r=0)=>(Pe.encode(t,e,r),e),be=t=>Pe.encodingLength(t);var se=(t,e)=>{let r=e.byteLength,n=be(t),o=n+be(r),s=new Uint8Array(o+r);return we(t,s,0),we(r,s,n),s.set(e,o),new xe(t,r,e,s)},Ue=t=>{let e=z(t),[r,n]=Fe(e),[o,s]=Fe(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new xe(r,o,i,e)},xr=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&dr(t.bytes,r.bytes)}},xe=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var yr=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return So(r,at(t),e||P.encoder);default:return To(r,at(t),e||G.encoder)}};var Cr=new WeakMap,at=t=>{let e=Cr.get(t);if(e==null){let r=new Map;return Cr.set(t,r),r}return e},ee=class t{constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==Oe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Po)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=se(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&xr(e.multihash,n.multihash)}toString(e){return yr(this,e)}toJSON(){return{"/":yr(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new t(n,o,s,i||vr(n,o,s.bytes))}else if(r[Fo]===!0){let{version:n,multihash:o,code:s}=r,i=Ue(o);return t.create(n,s,i)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==Oe)throw new Error(`Version 0 CID must use dag-pb (code: ${Oe}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=vr(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Oe,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=z(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new xe(r.multihashCode,r.digestSize,s,o);return[r.version===0?t.createV0(i):t.createV1(r.codec,i),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[u,f]=Fe(e.subarray(r));return r+=f,u},o=n(),s=Oe;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,a=n(),p=n(),y=r+p,l=y-i;return{version:o,codec:s,multihashCode:a,digestSize:p,multihashSize:l,size:y}}static parse(e,r){let[n,o]=Io(e,r),s=t.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return at(s).set(n,e),s}},Io=(t,e)=>{switch(t[0]){case"Q":{let r=e||P;return[P.prefix,r.decode(`${P.prefix}${t}`)]}case P.prefix:{let r=e||P;return[P.prefix,r.decode(t)]}case G.prefix:{let r=e||G;return[G.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},So=(t,e,r)=>{let{prefix:n}=r;if(n!==P.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o},To=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o},Oe=112,Po=18,vr=(t,e,r)=>{let n=be(t),o=n+be(e),s=new Uint8Array(o+r.byteLength);return we(t,s,0),we(e,s,n),s.set(r,o),s},Fo=Symbol.for("@ipld/js-cid/CID");function Er(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var lt={};k(lt,{base10:()=>Oo});var Oo=Y({prefix:"9",name:"base10",alphabet:"0123456789"});var ut={};k(ut,{base16:()=>Ro,base16upper:()=>Mo});var Ro=v({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Mo=v({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var dt={};k(dt,{base2:()=>ko});var ko=v({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var pt={};k(pt,{base256emoji:()=>Uo});var Ar=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}"),No=Ar.reduce((t,e,r)=>(t[r]=e,t),[]),Lo=Ar.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Do(t){return t.reduce((e,r)=>(e+=No[r],e),"")}function _o(t){let e=[];for(let r of t){let n=Lo[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var Uo=ge({prefix:"\u{1F680}",name:"base256emoji",encode:Do,decode:_o});var ft={};k(ft,{base36:()=>$o,base36upper:()=>Bo});var $o=Y({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Bo=Y({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ht={};k(ht,{base8:()=>zo});var zo=v({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var mt={};k(mt,{identity:()=>Vo});var Vo=ge({prefix:"\0",name:"identity",encode:t=>fr(t),decode:t=>pr(t)});var ki=new TextEncoder,Ni=new TextDecoder;var gt={};k(gt,{identity:()=>Jo});var Ir=0,Go="identity",Sr=z,Wo=t=>se(Ir,Sr(t)),Jo={code:Ir,name:Go,encode:Sr,digest:Wo};var yt={};k(yt,{sha256:()=>Xo,sha512:()=>Ho});var xt=ne(X("crypto"),1);var bt=({name:t,code:e,encode:r})=>new wt(t,e,r),wt=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?se(this.code,r):r.then(n=>se(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Xo=bt({name:"sha2-256",code:18,encode:t=>z(xt.default.createHash("sha256").update(t).digest())}),Ho=bt({name:"sha2-512",code:19,encode:t=>z(xt.default.createHash("sha512").update(t).digest())});var Re={...mt,...dt,...ht,...lt,...ut,...nt,...ft,...ot,...it,...pt},qi={...yt,...gt};function Ce(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function ve(t=0){return globalThis.Buffer?.allocUnsafe!=null?Ce(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Fr(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var Pr=Fr("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Ct=Fr("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=ve(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Qo={utf8:Pr,"utf-8":Pr,hex:Re.base16,latin1:Ct,ascii:Ct,binary:Ct,...Re},$e=Qo;function O(t,e="utf8"){let r=$e[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var Ko=Math.pow(2,7),Yo=Math.pow(2,14),Zo=Math.pow(2,21),vt=Math.pow(2,28),Et=Math.pow(2,35),At=Math.pow(2,42),It=Math.pow(2,49),b=128,F=127;function W(t){if(t<Ko)return 1;if(t<Yo)return 2;if(t<Zo)return 3;if(t<vt)return 4;if(t<Et)return 5;if(t<At)return 6;if(t<It)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function es(t,e,r=0){switch(W(t)){case 8:e[r++]=t&255|b,t/=128;case 7:e[r++]=t&255|b,t/=128;case 6:e[r++]=t&255|b,t/=128;case 5:e[r++]=t&255|b,t/=128;case 4:e[r++]=t&255|b,t>>>=7;case 3:e[r++]=t&255|b,t>>>=7;case 2:e[r++]=t&255|b,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function ts(t,e,r=0){switch(W(t)){case 8:e.set(r++,t&255|b),t/=128;case 7:e.set(r++,t&255|b),t/=128;case 6:e.set(r++,t&255|b),t/=128;case 5:e.set(r++,t&255|b),t/=128;case 4:e.set(r++,t&255|b),t>>>=7;case 3:e.set(r++,t&255|b),t>>>=7;case 2:e.set(r++,t&255|b),t>>>=7;case 1:{e.set(r++,t&255),t>>>=7;break}default:throw new Error("unreachable")}return e}function rs(t,e){let r=t[e],n=0;if(n+=r&F,r<b||(r=t[e+1],n+=(r&F)<<7,r<b)||(r=t[e+2],n+=(r&F)<<14,r<b)||(r=t[e+3],n+=(r&F)<<21,r<b)||(r=t[e+4],n+=(r&F)*vt,r<b)||(r=t[e+5],n+=(r&F)*Et,r<b)||(r=t[e+6],n+=(r&F)*At,r<b)||(r=t[e+7],n+=(r&F)*It,r<b))return n;throw new RangeError("Could not decode varint")}function ns(t,e){let r=t.get(e),n=0;if(n+=r&F,r<b||(r=t.get(e+1),n+=(r&F)<<7,r<b)||(r=t.get(e+2),n+=(r&F)<<14,r<b)||(r=t.get(e+3),n+=(r&F)<<21,r<b)||(r=t.get(e+4),n+=(r&F)*vt,r<b)||(r=t.get(e+5),n+=(r&F)*Et,r<b)||(r=t.get(e+6),n+=(r&F)*At,r<b)||(r=t.get(e+7),n+=(r&F)*It,r<b))return n;throw new RangeError("Could not decode varint")}function Ee(t,e,r=0){return e==null&&(e=ve(W(t))),e instanceof Uint8Array?es(t,e,r):ts(t,e,r)}function ie(t,e=0){return t instanceof Uint8Array?rs(t,e):ns(t,e)}function H(t,e){e==null&&(e=t.reduce((o,s)=>o+s.length,0));let r=ve(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return Ce(r)}var Be=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let r=this.index,n=e();return n===void 0&&(this.index=r),n}parseWith(e){let r=e();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let r=this.readChar();if(r===e)return r})}readSeparator(e,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,r,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let p=a==="0",y=2**(8*o)-1;for(;;){let l=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let f=Number.parseInt(u,e);if(!Number.isNaN(f))return f});if(l===void 0)break;if(s*=e,s+=l,s>y||(i+=1,r!==void 0&&i>r))return}if(i!==0)return!n&&p&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let r=0;r<e.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[r]=n}return e})}readIPv6Addr(){let e=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return r[o]=i[0],r[o+1]=i[1],r[o+2]=i[2],r[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];r[o]=s>>8,r[o+1]=s&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=e(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=e(s.subarray(0,i));return r.set(s.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var sc=new Be;var fc=parseInt("0xFFFF",16),hc=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function St(t,e="utf8"){let r=$e[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Ce(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var V=X("node:net");function ze(t){return!!(0,V.isIP)(t)}var kr=V.isIPv4,ls=V.isIPv6,Tt=function(t){let e=0;if(t=t.toString().trim(),kr(t)){let r=new Uint8Array(e+4);return t.split(/\./g).forEach(n=>{r[e++]=parseInt(n,10)&255}),r}if(ls(t)){let r=t.split(":",8),n;for(n=0;n<r.length;n++){let s=kr(r[n]),i;s&&(i=Tt(r[n]),r[n]=O(i.slice(0,2),"base16")),i!=null&&++n<8&&r.splice(n,0,O(i.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let s=[n,1];for(n=9-r.length;n>0;n--)s.push("0");r.splice.apply(r,s)}let o=new Uint8Array(e+16);for(n=0;n<r.length;n++){let s=parseInt(r[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},Nr=function(t,e=0,r){e=~~e,r=r??t.length-e;let n=new DataView(t.buffer);if(r===4){let o=[];for(let s=0;s<r;s++)o.push(t[e+s]);return o.join(".")}if(r===16){let o=[];for(let s=0;s<r;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Ae={},Pt={},ds=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];ds.forEach(t=>{let e=ps(...t);Pt[e.code]=e,Ae[e.name]=e});function ps(t,e,r,n,o){return{code:t,size:e,name:r,resolvable:!!n,path:!!o}}function x(t){if(typeof t=="number"){if(Pt[t]!=null)return Pt[t];throw new Error(`no protocol with code: ${t}`)}else if(typeof t=="string"){if(Ae[t]!=null)return Ae[t];throw new Error(`no protocol with name: ${t}`)}throw new Error(`invalid protocol id type: ${typeof t}`)}var ta=x("ip4"),ra=x("ip6"),na=x("ipcidr");function Ot(t,e){switch(x(t).code){case 4:case 41:return hs(e);case 42:return _r(e);case 6:case 273:case 33:case 132:return $r(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return _r(e);case 421:return bs(e);case 444:return Ur(e);case 445:return Ur(e);case 466:return ws(e);default:return O(e,"base16")}}function Rt(t,e){switch(x(t).code){case 4:return Lr(e);case 41:return Lr(e);case 42:return Dr(e);case 6:case 273:case 33:case 132:return Mt(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Dr(e);case 421:return ms(e);case 444:return xs(e);case 445:return ys(e);case 466:return gs(e);default:return St(e,"base16")}}var Ft=Object.values(Re).map(t=>t.decoder),fs=function(){let t=Ft[0].or(Ft[1]);return Ft.slice(2).forEach(e=>t=t.or(e)),t}();function Lr(t){if(!ze(t))throw new Error("invalid ip address");return Tt(t)}function hs(t){let e=Nr(t,0,t.length);if(e==null)throw new Error("ipBuff is required");if(!ze(e))throw new Error("invalid ip address");return e}function Mt(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function $r(t){return new DataView(t.buffer).getUint16(t.byteOffset)}function Dr(t){let e=St(t),r=Uint8Array.from(Ee(e.length));return H([r,e],r.length+e.length)}function _r(t){let e=ie(t);if(t=t.slice(W(e)),t.length!==e)throw new Error("inconsistent lengths");return O(t)}function ms(t){let e;t[0]==="Q"||t[0]==="1"?e=Ue(P.decode(`z${t}`)).bytes:e=ee.parse(t).multihash.bytes;let r=Uint8Array.from(Ee(e.length));return H([r,e],r.length+e.length)}function gs(t){let e=fs.decode(t),r=Uint8Array.from(Ee(e.length));return H([r,e],r.length+e.length)}function ws(t){let e=ie(t),r=t.slice(W(e));if(r.length!==e)throw new Error("inconsistent lengths");return"u"+O(r,"base64url")}function bs(t){let e=ie(t),r=t.slice(W(e));if(r.length!==e)throw new Error("inconsistent lengths");return O(r,"base58btc")}function xs(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let r=G.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Mt(n);return H([r,o],r.length+o.length)}function ys(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let r=G.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Mt(n);return H([r,o],r.length+o.length)}function Ur(t){let e=t.slice(0,t.length-2),r=t.slice(t.length-2),n=O(e,"base32"),o=$r(r);return`${n}:${o}`}function Br(t){t=kt(t);let e=[],r=[],n=null,o=t.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],a=x(i);if(a.size===0){e.push([a.code]),r.push([a.code]);continue}if(s++,s>=o.length)throw Vr("invalid address: "+t);if(a.path===!0){n=kt(o.slice(s).join("/")),e.push([a.code,Rt(a.code,n)]),r.push([a.code,n]);break}let p=Rt(a.code,o[s]);e.push([a.code,p]),r.push([a.code,Ot(a.code,p)])}return{string:zr(r),bytes:Lt(e),tuples:e,stringTuples:r,path:n}}function Nt(t){let e=[],r=[],n=null,o=0;for(;o<t.length;){let s=ie(t,o),i=W(s),a=x(s),p=Cs(a,t.slice(o+i));if(p===0){e.push([s]),r.push([s]),o+=i;continue}let y=t.slice(o+i,o+i+p);if(o+=p+i,o>t.length)throw Vr("Invalid address Uint8Array: "+O(t,"base16"));e.push([s,y]);let l=Ot(s,y);if(r.push([s,l]),a.path===!0){n=l;break}}return{bytes:Uint8Array.from(t),string:zr(r),tuples:e,stringTuples:r,path:n}}function zr(t){let e=[];return t.map(r=>{let n=x(r[0]);return e.push(n.name),r.length>1&&r[1]!=null&&e.push(r[1]),null}),kt(e.join("/"))}function Lt(t){return H(t.map(e=>{let r=x(e[0]),n=Uint8Array.from(Ee(r.code));return e.length>1&&e[1]!=null&&(n=H([n,e[1]])),n}))}function Cs(t,e){if(t.size>0)return t.size/8;if(t.size===0)return 0;{let r=ie(e instanceof Uint8Array?e:Uint8Array.from(e));return r+W(r)}}function kt(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}function Vr(t){return new Error("Error parsing address: "+t)}var vs=Symbol.for("nodejs.util.inspect.custom"),Es=[x("dns").code,x("dns4").code,x("dns6").code,x("dnsaddr").code],As=new Map,qr=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Is(t){return!!t?.[qr]}var Dt=class t{bytes;#e;#t;#r;#n;[qr]=!0;constructor(e){e==null&&(e="");let r;if(e instanceof Uint8Array)r=Nt(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);r=Br(e)}else if(Is(e))r=Nt(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.bytes,this.#e=r.string,this.#t=r.tuples,this.#r=r.stringTuples,this.#n=r.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,r,n,o,s="",i=x("tcp"),a=x("udp"),p=x("ip4"),y=x("ip6"),l=x("dns6"),u=x("ip6zone");for(let[g,h]of this.stringTuples())g===u.code&&(s=`%${h??""}`),Es.includes(g)&&(r=i.name,o=443,n=`${h??""}${s}`,e=g===l.code?6:4),(g===i.code||g===a.code)&&(r=x(g).name,o=parseInt(h??"")),(g===p.code||g===y.code)&&(r=x(g).name,n=`${h??""}${s}`,e=g===y.code?6:4);if(e==null||r==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:r,port:o}}protos(){return this.#t.map(([e])=>Object.assign({},x(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>x(e).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(e){return e=new t(e),new t(this.toString()+e.toString())}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new t(n.slice(0,o))}decapsulateCode(e){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===e)return new t(Lt(r.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===Ae.p2p.code&&e.push([n,o]),n===Ae["p2p-circuit"].code&&(e=[])});let r=e.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?O(P.decode(`z${n}`),"base58btc"):O(ee.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return Er(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(s=>s.resolvable);if(r==null)return[this];let n=As.get(r.name);if(n==null)throw new N(`no available resolver for ${r.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new t(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let r=(e??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[vs](){return`Multiaddr(${this.#e})`}};function Q(t){return new Dt(t)}var Ss=c("dns4"),Ts=c("dns6"),Ps=c("dnsaddr"),ae=E(c("dns"),Ps,Ss,Ts),je=E(c("ip4"),c("ip6")),re=E(d(je,c("tcp")),d(ae,c("tcp"))),Ge=d(je,c("udp")),Fs=d(Ge,c("utp")),Os=d(Ge,c("quic")),Rs=d(Ge,c("quic-v1")),_t=E(d(re,c("ws")),d(ae,c("ws"))),Ve=E(d(_t,c("p2p")),_t),Ut=E(d(re,c("wss")),d(ae,c("wss")),d(re,c("tls"),c("ws")),d(ae,c("tls"),c("ws"))),qe=E(d(Ut,c("p2p")),Ut),$t=E(d(re,c("http")),d(je,c("http")),d(ae,c("http"))),Bt=E(d(re,c("https")),d(je,c("https")),d(ae,c("https"))),jr=d(Ge,c("webrtc-direct"),c("certhash")),Jr=E(d(jr,c("p2p")),jr),Gr=d(Rs,c("webtransport"),c("certhash"),c("certhash")),Xr=E(d(Gr,c("p2p")),Gr),Hr=E(d(Ve,c("p2p-webrtc-star"),c("p2p")),d(qe,c("p2p-webrtc-star"),c("p2p")),d(Ve,c("p2p-webrtc-star")),d(qe,c("p2p-webrtc-star"))),Ia=E(d(Ve,c("p2p-websocket-star"),c("p2p")),d(qe,c("p2p-websocket-star"),c("p2p")),d(Ve,c("p2p-websocket-star")),d(qe,c("p2p-websocket-star"))),Qr=E(d($t,c("p2p-webrtc-direct"),c("p2p")),d(Bt,c("p2p-webrtc-direct"),c("p2p")),d($t,c("p2p-webrtc-direct")),d(Bt,c("p2p-webrtc-direct"))),le=E(_t,Ut,$t,Bt,Hr,Qr,re,Fs,Os,ae,Jr,Xr),Sa=E(d(le,c("p2p-stardust"),c("p2p")),d(le,c("p2p-stardust"))),te=E(d(le,c("p2p")),Hr,Qr,Jr,Xr,c("p2p")),Wr=E(d(te,c("p2p-circuit"),te),d(te,c("p2p-circuit")),d(c("p2p-circuit"),te),d(le,c("p2p-circuit")),d(c("p2p-circuit"),le),c("p2p-circuit")),Kr=()=>E(d(Wr,Kr),Wr),ce=Kr(),Ta=E(d(ce,te,ce),d(te,ce),d(ce,te),ce,te);var Pa=E(d(ce,c("webrtc"),c("p2p")),d(ce,c("webrtc")),d(le,c("webrtc"),c("p2p")),d(le,c("webrtc")),c("webrtc"));function Yr(t){function e(r){let n;try{n=Q(r)}catch{return!1}let o=t(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return e}function d(...t){function e(r){if(r.length<t.length)return null;let n=r;return t.some(o=>(n=typeof o=="function"?o().partialMatch(r):o.partialMatch(r),Array.isArray(n)&&(r=n),n===null)),n}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:Yr(e),partialMatch:e}}function E(...t){function e(n){let o=null;return t.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:Yr(e),partialMatch:e}}function c(t){let e=t;function r(o){let s;try{s=Q(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===e}function n(o){return o.length===0?null:o[0]===e?o.slice(1):null}return{toString:function(){return e},matches:r,partialMatch:n}}var dn=ne(X("net"),1);var We=class extends EventTarget{#e=new Map;listenerCount(e){let r=this.#e.get(e);return r==null?0:r.length}addEventListener(e,r,n){super.addEventListener(e,r,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:r,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,r,n){super.removeEventListener(e.toString(),r??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:s})=>s!==r),this.#e.set(e,o))}dispatchEvent(e){let r=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),r}safeDispatchEvent(e,r){return this.dispatchEvent(new Ie(e,r))}},zt=class extends Event{detail;constructor(e,r){super(e,r),this.detail=r?.detail}},Ie=globalThis.CustomEvent??zt;var ks=Z("libp2p:ip-port-to-multiaddr"),Vt={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function Zr(t,e){if(typeof t!="string")throw new N(`invalid ip provided: ${t}`,Vt.ERR_INVALID_IP_PARAMETER);if(typeof e=="string"&&(e=parseInt(e)),isNaN(e))throw new N(`invalid port provided: ${e}`,Vt.ERR_INVALID_PORT_PARAMETER);if((0,V.isIPv4)(t))return Q(`/ip4/${t}/tcp/${e}`);if((0,V.isIPv6)(t))return Q(`/ip6/${t}/tcp/${e}`);let r=`invalid ip:port for creating a multiaddr: ${t}:${e}`;throw ks.error(r),new N(r,Vt.ERR_INVALID_IP)}var un=ne(an(),1);var Gt=ne(X("os"),1),ln=ne(X("path"),1);var Us={ip4:"IPv4",ip6:"IPv6"};function Te(t,e={}){let r=t.getPath();return r!=null?Gt.default.platform()==="win32"?{path:ln.default.join("\\\\.\\pipe\\",r)}:{path:r}:{...t.toOptions(),...e}}function Wt(t,e,r){let n=o=>Q(`/${t}/${o}/tcp/${r}`);return($s(e)?zs(Us[t]):[e]).map(n)}function $s(t){return["0.0.0.0","::"].includes(t)}var Bs=Gt.default.networkInterfaces();function zs(t){let e=[];for(let[,r]of Object.entries(Bs))if(r!=null)for(let n of r)n.family===t&&e.push(n.address);return e}var J=Z("libp2p:tcp:socket"),Xe=(t,e)=>{let r=e.metrics,n=e.metricPrefix??"",o=e.socketInactivityTimeout??3e5,s=e.socketCloseTimeout??500;e.listeningAddr?.getPath()!=null&&(e.remoteAddr=e.listeningAddr),e.remoteAddr?.getPath()!=null&&(e.localAddr=e.remoteAddr);let i;if(e.remoteAddr!=null)i=e.remoteAddr;else{if(t.remoteAddress==null||t.remotePort==null)throw new N("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");i=Zr(t.remoteAddress,t.remotePort)}let a=Te(i),p=a.path??`${a.host??""}:${a.port??""}`,{sink:y,source:l}=un.default.duplex(t);t.setTimeout(o,()=>{J("%s socket read timeout",p),r?.increment({[`${n}timeout`]:!0});let f;t.readable&&(f=new N("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),t.destroy(f)}),t.once("close",()=>{J("%s socket close",p),r?.increment({[`${n}close`]:!0}),u.timeline.close==null&&(u.timeline.close=Date.now())}),t.once("end",()=>{J("%s socket end",p),r?.increment({[`${n}end`]:!0})});let u={async sink(f){try{await y(f)}catch(g){g.type!=="aborted"&&J(g)}t.end()},source:l,remoteAddr:i,timeline:{open:Date.now()},async close(f={}){if(t.destroyed){J("%s socket was already destroyed when trying to close",p);return}f.signal=f.signal??AbortSignal.timeout(s);try{J("%s closing socket",p),await new Promise((g,h)=>{t.once("close",()=>{J("%s socket closed",p),g()}),t.once("error",w=>{J("%s socket error",p,w),u.timeline.close==null&&(u.timeline.close=Date.now()),h(w)}),t.setTimeout(s),t.end(),t.writableLength>0?t.once("drain",()=>{J("%s socket drained",p),t.destroy()}):t.destroy()})}catch(g){this.abort(g)}},abort:f=>{J("%s socket abort due to error",p,f),t.destroy(f)}};return u};var _=Z("libp2p:tcp:listener");async function Jt(t){try{await t.close()}catch(e){_.error("an error occurred closing the connection",e)}}var js=1,Gs=0,He=class extends We{context;server;connections=new Set;status={started:!1};metrics;addr;constructor(e){if(super(),this.context=e,e.keepAlive=e.keepAlive??!0,this.addr="unknown",this.server=dn.default.createServer(e,this.onSocket.bind(this)),e.maxConnections!==void 0&&(this.server.maxConnections=e.maxConnections),e.closeServerOnMaxConnections!=null&&e.closeServerOnMaxConnections.closeAbove<e.closeServerOnMaxConnections.listenBelow)throw Error("closeAbove must be >= listenBelow");this.server.on("listening",()=>{if(e.metrics!=null){let r=this.server.address();r==null?this.addr="unknown":typeof r=="string"?this.addr=r:this.addr=`${r.address}:${r.port}`,e.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:e.metrics.registerMetricGroup("libp2p_tcp_listener_status_info",{label:"address",help:"Current status of the TCP listener socket"}),errors:e.metrics.registerMetricGroup("libp2p_tcp_listener_errors_total",{label:"address",help:"Total count of TCP listener errors by type"}),events:e.metrics.registerMetricGroup("libp2p_tcp_listener_events_total",{label:"address",help:"Total count of TCP listener events by type"})},this.metrics?.status.update({[this.addr]:js})}this.dispatchEvent(new Ie("listening"))}).on("error",r=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new Ie("error",{detail:r}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:Gs}),this.dispatchEvent(new Ie("close"))})}onSocket(e){e.on("error",n=>{_("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let r;try{r=Xe(e,{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){_.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}_("new inbound connection %s",r.remoteAddr);try{this.context.upgrader.upgradeInbound(r).then(n=>{_("inbound connection upgraded %s",r.remoteAddr),this.connections.add(r),e.once("close",()=>{this.connections.delete(r),this.context.closeServerOnMaxConnections!=null&&this.connections.size<this.context.closeServerOnMaxConnections.listenBelow&&this.netListen().catch(o=>{_.error("error attempting to listen server once connection count under limit",o),this.context.closeServerOnMaxConnections?.onListenError?.(o)})}),this.context.handler!=null&&this.context.handler(n),this.context.closeServerOnMaxConnections!=null&&this.connections.size>=this.context.closeServerOnMaxConnections.closeAbove&&this.netClose(),this.dispatchEvent(new Ie("connection",{detail:n}))}).catch(async n=>{_.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await Jt(r)}).catch(n=>{_.error("closing inbound connection failed",n)})}catch(n){_.error("inbound connection failed",n),Jt(r).catch(o=>{_.error("closing inbound connection failed",o),this.metrics?.errors.increment({[`${this.addr} inbound_closing_failed`]:!0})})}}getAddrs(){if(!this.status.started)return[];let e=[],r=this.server.address(),{listeningAddr:n,peerId:o}=this.status;if(r==null)return[];if(typeof r=="string")e=[n];else try{n.toString().startsWith("/ip4")?e=e.concat(Wt("ip4",r.address,r.port)):r.family==="IPv6"&&(e=e.concat(Wt("ip6",r.address,r.port)))}catch(s){_.error("could not turn %s:%s into multiaddr",r.address,r.port,s)}return e.map(s=>o!=null?s.encapsulate(`/p2p/${o}`):s)}async listen(e){if(this.status.started)throw Error("server is already listening");let r=e.getPeerId(),n=r==null?e.decapsulateCode(421):e,{backlog:o}=this.context;this.status={started:!0,listeningAddr:n,peerId:r,netConfig:Te(n,{backlog:o})},await this.netListen()}async close(){await Promise.all(Array.from(this.connections.values()).map(async e=>{await Jt(e)})),this.netClose()}async netListen(){if(!this.status.started||this.server.listening)return;let e=this.status.netConfig;await new Promise((r,n)=>{this.server.once("error",n),this.server.listen(e,r)}),_("Listening on %s",this.server.address())}netClose(){!this.status.started||!this.server.listening||(_("Closing server on %s",this.server.address()),this.server.close())}};var K=Z("libp2p:tcp"),Ht=class{opts;metrics;components;constructor(e,r={}){this.opts=r,this.components=e,e.metrics!=null&&(this.metrics={dialerEvents:e.metrics.registerCounterGroup("libp2p_tcp_dialer_events_total",{label:"event",help:"Total count of TCP dialer events by type"})})}[Yt]=!0;[Symbol.toStringTag]="@libp2p/tcp";async dial(e,r){r.keepAlive=r.keepAlive??!0;let n=await this._connect(e,r);n.on("error",a=>{K("socket error",a)});let o=Xe(n,{remoteAddr:e,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents}),s=()=>{o.close().catch(a=>{K.error("Error closing maConn after abort",a)})};r.signal?.addEventListener("abort",s,{once:!0}),K("new outbound connection %s",o.remoteAddr);let i=await r.upgrader.upgradeOutbound(o);if(K("outbound connection %s upgraded",o.remoteAddr),r.signal?.removeEventListener("abort",s),r.signal?.aborted===!0)throw i.close().catch(a=>{K.error("Error closing conn after abort",a)}),new de;return i}async _connect(e,r){if(r.signal?.aborted===!0)throw new de;return new Promise((n,o)=>{let s=Date.now(),i=Te(e),a=i.path??`${i.host??""}:${i.port}`;K("dialing %j",i);let p=pn.default.connect(i),y=h=>{h.message=`connection error ${a}: ${h.message}`,this.metrics?.dialerEvents.increment({error:!0}),g(h)},l=()=>{K("connection timeout %s",a),this.metrics?.dialerEvents.increment({timeout:!0});let h=new N(`connection timeout after ${Date.now()-s}ms`,"ERR_CONNECT_TIMEOUT");p.emit("error",h)},u=()=>{K("connection opened %j",i),this.metrics?.dialerEvents.increment({connect:!0}),g()},f=()=>{K("connection aborted %j",i),this.metrics?.dialerEvents.increment({abort:!0}),p.destroy(),g(new de)},g=h=>{if(p.removeListener("error",y),p.removeListener("timeout",l),p.removeListener("connect",u),r.signal!=null&&r.signal.removeEventListener("abort",f),h!=null){o(h);return}n(p)};p.on("error",y),p.on("timeout",l),p.on("connect",u),r.signal!=null&&r.signal.addEventListener("abort",f)})}createListener(e){return new He({...e,maxConnections:this.opts.maxConnections,backlog:this.opts.backlog,closeServerOnMaxConnections:this.opts.closeServerOnMaxConnections,socketInactivityTimeout:this.opts.inboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.components.metrics})}filter(e){return e=Array.isArray(e)?e:[e],e.filter(r=>r.protoCodes().includes(290)?!1:r.protoCodes().includes(400)?!0:re.matches(r.decapsulateCode(421)))}};function Xs(t={}){return(e={})=>new Ht(e,t)}return bn(Hs);})(); | ||
return Libp2PTcp})); |
{ | ||
"name": "@libp2p/tcp", | ||
"version": "8.0.5", | ||
"version": "8.0.6-0ee4f784", | ||
"description": "A TCP transport for libp2p", | ||
@@ -53,5 +53,5 @@ "license": "Apache-2.0 OR MIT", | ||
"dependencies": { | ||
"@libp2p/interface": "^0.1.2", | ||
"@libp2p/logger": "^3.0.2", | ||
"@libp2p/utils": "^4.0.2", | ||
"@libp2p/interface": "0.1.2-0ee4f784", | ||
"@libp2p/logger": "3.0.2-0ee4f784", | ||
"@libp2p/utils": "4.0.3-0ee4f784", | ||
"@multiformats/mafmt": "^12.1.2", | ||
@@ -63,3 +63,3 @@ "@multiformats/multiaddr": "^12.1.5", | ||
"devDependencies": { | ||
"@libp2p/interface-compliance-tests": "^4.0.5", | ||
"@libp2p/interface-compliance-tests": "4.0.5-0ee4f784", | ||
"aegir": "^40.0.8", | ||
@@ -66,0 +66,0 @@ "it-all": "^3.0.1", |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
144138
29
1631
2
+ Added@libp2p/interface@0.1.2-0ee4f784(transitive)
+ Added@libp2p/logger@3.0.2-0ee4f784(transitive)
+ Added@libp2p/utils@4.0.3-0ee4f784(transitive)
- Removed@libp2p/interface@0.1.6(transitive)
- Removed@libp2p/logger@3.1.0(transitive)
- Removed@libp2p/utils@4.0.7(transitive)
- Removedrace-signal@1.1.3(transitive)
Updated@libp2p/utils@4.0.3-0ee4f784