@libp2p/tcp 9.0.8-178fe2671 → 9.0.8-5d1f68e92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/package.json +5 -5
package/dist/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PTcp = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PTcp=(()=>{var Or=Object.create;var bt=Object.defineProperty;var Vr=Object.getOwnPropertyDescriptor;var Fr=Object.getOwnPropertyNames;var $r=Object.getPrototypeOf,zr=Object.prototype.hasOwnProperty;var Y=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var Z=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),R=(r,t)=>{for(var e in t)bt(r,e,{get:t[e],enumerable:!0})},Ne=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Fr(t))!zr.call(r,o)&&o!==e&&bt(r,o,{get:()=>t[o],enumerable:!(n=Vr(t,o))||n.enumerable});return r};var tt=(r,t,e)=>(e=r!=null?Or($r(r)):{},Ne(t||!r||!r.__esModule?bt(e,"default",{value:r,enumerable:!0}):e,r)),Br=r=>Ne(bt({},"__esModule",{value:!0}),r);var Dt=Z((da,Sr)=>{Sr.exports=r=>{if(r[Symbol.asyncIterator])return r;if(r.getReader)return async function*(){let t=r.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}}();throw new Error("unknown stream")}});var Tr=Z((ua,Cr)=>{Cr.exports=function(t){if(t){if(typeof t[Symbol.iterator]=="function")return t[Symbol.iterator]();if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t.next=="function")return t}throw new Error("argument is not an iterator or iterable")}});var Ae=Z((fa,Pr)=>{var Uo=Tr();Pr.exports=r=>async t=>{t=Uo(t);let e=w=>{typeof w.return=="function"&&w.return()},n=null,o=null,s=w=>{n=w,o&&o(w),e(t)},i=null,a=!1,u=()=>{a=!0,i&&i()},f=null,m=!1,v=()=>{m=!0,f&&f()},x=null,d=()=>{x&&x()},p=()=>new Promise((w,C)=>{i=x=w,o=C,r.once("drain",d)}),E=()=>(e(t),new Promise((w,C)=>{if(a||m||n)return w();f=i=w,o=C})),N=()=>{r.removeListener("error",s),r.removeListener("close",u),r.removeListener("finish",v),r.removeListener("drain",d)};r.once("error",s),r.once("close",u),r.once("finish",v);try{for await(let w of t){if(!r.writable||r.destroyed||n)break;r.write(w)===!1&&await p()}}catch(w){n||r.destroy(),n=w}try{if(r.writable&&r.end(),await E(),n)throw n}finally{N()}}});var Ie=Z((ha,Rr)=>{var _o=Ae(),ko=Dt();Rr.exports=r=>({sink:_o(r),source:ko(r)})});var Dr=Z((ma,Nr)=>{var Lo=Ie();Nr.exports=r=>async function*(t){let e=Lo(r),n;if(e.sink(t).catch(o=>{n=o}),yield*e.source,n)throw n}});var Mr=Z((ga,ut)=>{ut.exports=Dt();ut.exports.source=Dt();ut.exports.sink=Ae();ut.exports.transform=Dr();ut.exports.duplex=Ie()});var Wo={};R(Wo,{tcp:()=>Go});var Lr=tt(Y("net"),1);var Ho=Symbol.for("@libp2p/connection");var Qo=Symbol.for("@libp2p/content-routing");var Zo=Symbol.for("@libp2p/peer-discovery");var es=Symbol.for("@libp2p/peer-id");var ns=Symbol.for("@libp2p/peer-routing");var De;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(De||(De={}));var Ue=Symbol.for("@libp2p/transport");var Me;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Me||(Me={}));var et=class r extends Error{code;type;constructor(t="The operation was aborted"){super(t),this.code=r.code,this.type=r.type}static code="ABORT_ERR";static type="aborted"},I=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var yt=class extends EventTarget{#t=new Map;listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e){return this.dispatchEvent(new rt(t,e))}},_t=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},rt=globalThis.CustomEvent??_t;var Ft={};R(Ft,{base58btc:()=>T,base58flickr:()=>Hr});function qr(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,u=r.charAt(0),f=Math.log(a)/Math.log(256),m=Math.log(256)/Math.log(a);function v(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var E=0,N=0,w=0,C=p.length;w!==C&&p[w]===0;)w++,E++;for(var k=(C-w)*m+1>>>0,D=new Uint8Array(k);w!==C;){for(var L=p[w],B=0,_=k-1;(L!==0||B<N)&&_!==-1;_--,B++)L+=256*D[_]>>>0,D[_]=L%a>>>0,L=L/a>>>0;if(L!==0)throw new Error("Non-zero carry");N=B,w++}for(var V=k-N;V!==k&&D[V]===0;)V++;for(var xt=u.repeat(E);V<k;++V)xt+=r.charAt(D[V]);return xt}function x(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var E=0;if(p[E]!==" "){for(var N=0,w=0;p[E]===u;)N++,E++;for(var C=(p.length-E)*f+1>>>0,k=new Uint8Array(C);p[E];){var D=e[p.charCodeAt(E)];if(D===255)return;for(var L=0,B=C-1;(D!==0||L<w)&&B!==-1;B--,L++)D+=a*k[B]>>>0,k[B]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");w=L,E++}if(p[E]!==" "){for(var _=C-w;_!==C&&k[_]===0;)_++;for(var V=new Uint8Array(N+(C-_)),xt=N;_!==C;)V[xt++]=k[_++];return V}}}function d(p){var E=x(p);if(E)return E;throw new Error(`Non-${t} character`)}return{encode:v,decodeUnsafe:x,decode:d}}var jr=qr,Gr=jr,_e=Gr;var Ls=new Uint8Array(0);var ke=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0},M=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var Le=r=>new TextEncoder().encode(r),Oe=r=>new TextDecoder().decode(r);var kt=class{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Lt=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Fe(this,t)}},Ot=class{constructor(t){this.decoders=t}or(t){return Fe(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Fe=(r,t)=>new Ot({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Vt=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new kt(t,e,n),this.decoder=new Lt(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},nt=({name:r,prefix:t,encode:e,decode:n})=>new Vt(r,t,e,n),q=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=_e(e,t);return nt({prefix:r,name:t,encode:n,decode:s=>M(o(s))})},Wr=(r,t,e,n)=>{let o={};for(let m=0;m<t.length;++m)o[t[m]]=m;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),a=0,u=0,f=0;for(let m=0;m<s;++m){let v=o[r[m]];if(v===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<e|v,a+=e,a>=8&&(a-=8,i[f++]=255&u>>a)}if(a>=e||255&u<<8-a)throw new SyntaxError("Unexpected end of data");return i},Xr=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let u=0;u<r.length;++u)for(a=a<<8|r[u],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i&&(s+=t[o&a<<e-i]),n)for(;s.length*e&7;)s+="=";return s},b=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>nt({prefix:t,name:r,encode(o){return Xr(o,n,e)},decode(o){return Wr(o,n,e,r)}});var T=q({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Hr=q({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var $t={};R($t,{base32:()=>F,base32hex:()=>Yr,base32hexpad:()=>tn,base32hexpadupper:()=>en,base32hexupper:()=>Zr,base32pad:()=>Qr,base32padupper:()=>Kr,base32upper:()=>Jr,base32z:()=>rn});var F=b({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Jr=b({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Qr=b({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Kr=b({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Yr=b({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Zr=b({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),tn=b({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),en=b({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),rn=b({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var nn=Be,$e=128,on=127,sn=~on,cn=Math.pow(2,31);function Be(r,t,e){t=t||[],e=e||0;for(var n=e;r>=cn;)t[e++]=r&255|$e,r/=128;for(;r&sn;)t[e++]=r&255|$e,r>>>=7;return t[e]=r|0,Be.bytes=e-n+1,t}var an=zt,ln=128,ze=127;function zt(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw zt.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&ze)<<o:(i&ze)*Math.pow(2,o),o+=7}while(i>=ln);return zt.bytes=s-n,e}var pn=Math.pow(2,7),dn=Math.pow(2,14),un=Math.pow(2,21),fn=Math.pow(2,28),hn=Math.pow(2,35),mn=Math.pow(2,42),gn=Math.pow(2,49),wn=Math.pow(2,56),xn=Math.pow(2,63),bn=function(r){return r<pn?1:r<dn?2:r<un?3:r<fn?4:r<hn?5:r<mn?6:r<gn?7:r<wn?8:r<xn?9:10},yn={encode:nn,decode:an,encodingLength:bn},vn=yn,ht=vn;var mt=(r,t=0)=>[ht.decode(r,t),ht.decode.bytes],ot=(r,t,e=0)=>(ht.encode(r,t,e),t),st=r=>ht.encodingLength(r);var X=(r,t)=>{let e=t.byteLength,n=st(r),o=n+st(e),s=new Uint8Array(o+e);return ot(r,s,0),ot(e,s,n),s.set(t,o),new it(r,e,t,s)},Et=r=>{let t=M(r),[e,n]=mt(t),[o,s]=mt(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new it(e,o,i,t)},qe=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&ke(r.bytes,e.bytes)}},it=class{constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var je=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return An(e,Bt(r),t||T.encoder);default:return In(e,Bt(r),t||F.encoder)}};var Ge=new WeakMap,Bt=r=>{let t=Ge.get(r);if(t==null){let e=new Map;return Ge.set(r,e),e}return t},j=class r{constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==gt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Sn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=X(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&qe(t.multihash,n.multihash)}toString(t){return je(this,t)}toJSON(){return{"/":je(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i||We(n,o,s.bytes))}else if(e[Cn]===!0){let{version:n,multihash:o,code:s}=e,i=Et(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==gt)throw new Error(`Version 0 CID must use dag-pb (code: ${gt}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=We(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,gt,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=M(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new it(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[v,x]=mt(t.subarray(e));return e+=x,v},o=n(),s=gt;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),u=n(),f=e+u,m=f-i;return{version:o,codec:s,multihashCode:a,digestSize:u,multihashSize:m,size:f}}static parse(t,e){let[n,o]=En(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Bt(s).set(n,t),s}},En=(r,t)=>{switch(r[0]){case"Q":{let e=t||T;return[T.prefix,e.decode(`${T.prefix}${r}`)]}case T.prefix:{let e=t||T;return[T.prefix,e.decode(r)]}case F.prefix:{let e=t||F;return[F.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},An=(r,t,e)=>{let{prefix:n}=e;if(n!==T.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o},In=(r,t,e)=>{let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o},gt=112,Sn=18,We=(r,t,e)=>{let n=st(r),o=n+st(t),s=new Uint8Array(o+e.byteLength);return ot(r,s,0),ot(t,s,n),s.set(e,o),s},Cn=Symbol.for("@ipld/js-cid/CID");function Xe(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var qt={};R(qt,{base10:()=>Tn});var Tn=q({prefix:"9",name:"base10",alphabet:"0123456789"});var jt={};R(jt,{base16:()=>Pn,base16upper:()=>Rn});var Pn=b({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Rn=b({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Gt={};R(Gt,{base2:()=>Nn});var Nn=b({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Wt={};R(Wt,{base256emoji:()=>kn});var He=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}"),Dn=He.reduce((r,t,e)=>(r[e]=t,r),[]),Mn=He.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Un(r){return r.reduce((t,e)=>(t+=Dn[e],t),"")}function _n(r){let t=[];for(let e of r){let n=Mn[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var kn=nt({prefix:"\u{1F680}",name:"base256emoji",encode:Un,decode:_n});var Xt={};R(Xt,{base36:()=>Ln,base36upper:()=>On});var Ln=q({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),On=q({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ht={};R(Ht,{base64:()=>Vn,base64pad:()=>Fn,base64url:()=>$n,base64urlpad:()=>zn});var Vn=b({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Fn=b({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),$n=b({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),zn=b({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Jt={};R(Jt,{base8:()=>Bn});var Bn=b({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Qt={};R(Qt,{identity:()=>qn});var qn=nt({prefix:"\0",name:"identity",encode:r=>Oe(r),decode:r=>Le(r)});var ii=new TextEncoder,ci=new TextDecoder;var Kt={};R(Kt,{identity:()=>Hn});var Je=0,Wn="identity",Qe=M,Xn=r=>X(Je,Qe(r)),Hn={code:Je,name:Wn,encode:Qe,digest:Xn};var ee={};R(ee,{sha256:()=>Jn,sha512:()=>Qn});var te=tt(Y("crypto"),1);var Zt=({name:r,code:t,encode:e})=>new Yt(r,t,e),Yt=class{constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?X(this.code,e):e.then(n=>X(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Jn=Zt({name:"sha2-256",code:18,encode:r=>M(te.default.createHash("sha256").update(r).digest())}),Qn=Zt({name:"sha2-512",code:19,encode:r=>M(te.default.createHash("sha512").update(r).digest())});var wt={...Qt,...Gt,...Jt,...qt,...jt,...$t,...Xt,...Ft,...Ht,...Wt},gi={...ee,...Kt};function at(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function lt(r=0){return globalThis.Buffer?.allocUnsafe!=null?at(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Ze(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Ye=Ze("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),re=Ze("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=lt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Kn={utf8:Ye,"utf-8":Ye,hex:wt.base16,latin1:re,ascii:re,binary:re,...wt},At=Kn;function P(r,t="utf8"){let e=At[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}var Yn=Math.pow(2,7),Zn=Math.pow(2,14),to=Math.pow(2,21),ne=Math.pow(2,28),oe=Math.pow(2,35),se=Math.pow(2,42),ie=Math.pow(2,49),h=128,S=127;function O(r){if(r<Yn)return 1;if(r<Zn)return 2;if(r<to)return 3;if(r<ne)return 4;if(r<oe)return 5;if(r<se)return 6;if(r<ie)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function eo(r,t,e=0){switch(O(r)){case 8:t[e++]=r&255|h,r/=128;case 7:t[e++]=r&255|h,r/=128;case 6:t[e++]=r&255|h,r/=128;case 5:t[e++]=r&255|h,r/=128;case 4:t[e++]=r&255|h,r>>>=7;case 3:t[e++]=r&255|h,r>>>=7;case 2:t[e++]=r&255|h,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function ro(r,t,e=0){switch(O(r)){case 8:t.set(e++,r&255|h),r/=128;case 7:t.set(e++,r&255|h),r/=128;case 6:t.set(e++,r&255|h),r/=128;case 5:t.set(e++,r&255|h),r/=128;case 4:t.set(e++,r&255|h),r>>>=7;case 3:t.set(e++,r&255|h),r>>>=7;case 2:t.set(e++,r&255|h),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function no(r,t){let e=r[t],n=0;if(n+=e&S,e<h||(e=r[t+1],n+=(e&S)<<7,e<h)||(e=r[t+2],n+=(e&S)<<14,e<h)||(e=r[t+3],n+=(e&S)<<21,e<h)||(e=r[t+4],n+=(e&S)*ne,e<h)||(e=r[t+5],n+=(e&S)*oe,e<h)||(e=r[t+6],n+=(e&S)*se,e<h)||(e=r[t+7],n+=(e&S)*ie,e<h))return n;throw new RangeError("Could not decode varint")}function oo(r,t){let e=r.get(t),n=0;if(n+=e&S,e<h||(e=r.get(t+1),n+=(e&S)<<7,e<h)||(e=r.get(t+2),n+=(e&S)<<14,e<h)||(e=r.get(t+3),n+=(e&S)<<21,e<h)||(e=r.get(t+4),n+=(e&S)*ne,e<h)||(e=r.get(t+5),n+=(e&S)*oe,e<h)||(e=r.get(t+6),n+=(e&S)*se,e<h)||(e=r.get(t+7),n+=(e&S)*ie,e<h))return n;throw new RangeError("Could not decode varint")}function pt(r,t,e=0){return t==null&&(t=lt(O(r))),t instanceof Uint8Array?eo(r,t,e):ro(r,t,e)}function H(r,t=0){return r instanceof Uint8Array?no(r,t):oo(r,t)}function $(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=lt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return at(e)}var It=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let u=a==="0",f=2**(8*o)-1;for(;;){let m=this.readAtomically(()=>{let v=this.readChar();if(v===void 0)return;let x=Number.parseInt(v,t);if(!Number.isNaN(x))return x});if(m===void 0)break;if(s*=t,s+=m,s>f||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&u&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[o]=i[0],e[o+1]=i[1],e[o+2]=i[2],e[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];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=t(s.subarray(0,i));return e.set(s.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Mi=new It;var $i=parseInt("0xFFFF",16),zi=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function ce(r,t="utf8"){let e=At[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?at(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}var U=Y("node:net");function St(r){return!!(0,U.isIP)(r)}var nr=U.isIPv4,po=U.isIPv6,ae=function(r){let t=0;if(r=r.toString().trim(),nr(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(po(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=nr(e[n]),i;s&&(i=ae(e[n]),e[n]=P(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,P(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},or=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var dt={},le={},fo=[[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"]];fo.forEach(r=>{let t=ho(...r);le[t.code]=t,dt[t.name]=t});function ho(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function g(r){if(typeof r=="number"){if(le[r]!=null)return le[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(dt[r]!=null)return dt[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Pc=g("ip4"),Rc=g("ip6"),Nc=g("ipcidr");function de(r,t){switch(g(r).code){case 4:case 41:return go(t);case 42:return cr(t);case 6:case 273:case 33:case 132:return lr(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return cr(t);case 421:return yo(t);case 444:return ar(t);case 445:return ar(t);case 466:return bo(t);default:return P(t,"base16")}}function ue(r,t){switch(g(r).code){case 4:return sr(t);case 41:return sr(t);case 42:return ir(t);case 6:case 273:case 33:case 132:return fe(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ir(t);case 421:return wo(t);case 444:return vo(t);case 445:return Eo(t);case 466:return xo(t);default:return ce(t,"base16")}}var pe=Object.values(wt).map(r=>r.decoder),mo=function(){let r=pe[0].or(pe[1]);return pe.slice(2).forEach(t=>r=r.or(t)),r}();function sr(r){if(!St(r))throw new Error("invalid ip address");return ae(r)}function go(r){let t=or(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!St(t))throw new Error("invalid ip address");return t}function fe(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function lr(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function ir(r){let t=ce(r),e=Uint8Array.from(pt(t.length));return $([e,t],e.length+t.length)}function cr(r){let t=H(r);if(r=r.slice(O(t)),r.length!==t)throw new Error("inconsistent lengths");return P(r)}function wo(r){let t;r[0]==="Q"||r[0]==="1"?t=Et(T.decode(`z${r}`)).bytes:t=j.parse(r).multihash.bytes;let e=Uint8Array.from(pt(t.length));return $([e,t],e.length+t.length)}function xo(r){let t=mo.decode(r),e=Uint8Array.from(pt(t.length));return $([e,t],e.length+t.length)}function bo(r){let t=H(r),e=r.slice(O(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+P(e,"base64url")}function yo(r){let t=H(r),e=r.slice(O(t));if(e.length!==t)throw new Error("inconsistent lengths");return P(e,"base58btc")}function vo(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=F.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=fe(n);return $([e,o],e.length+o.length)}function Eo(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=F.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=fe(n);return $([e,o],e.length+o.length)}function ar(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=P(t,"base32"),o=lr(e);return`${n}:${o}`}function pr(r){r=he(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],a=g(i);if(a.size===0){t.push([a.code]),e.push([a.code]);continue}if(s++,s>=o.length)throw ur("invalid address: "+r);if(a.path===!0){n=he(o.slice(s).join("/")),t.push([a.code,ue(a.code,n)]),e.push([a.code,n]);break}let u=ue(a.code,o[s]);t.push([a.code,u]),e.push([a.code,de(a.code,u)])}return{string:dr(e),bytes:ge(t),tuples:t,stringTuples:e,path:n}}function me(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=H(r,o),i=O(s),a=g(s),u=Ao(a,r.slice(o+i));if(u===0){t.push([s]),e.push([s]),o+=i;continue}let f=r.slice(o+i,o+i+u);if(o+=u+i,o>r.length)throw ur("Invalid address Uint8Array: "+P(r,"base16"));t.push([s,f]);let m=de(s,f);if(e.push([s,m]),a.path===!0){n=m;break}}return{bytes:Uint8Array.from(r),string:dr(e),tuples:t,stringTuples:e,path:n}}function dr(r){let t=[];return r.map(e=>{let n=g(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),he(t.join("/"))}function ge(r){return $(r.map(t=>{let e=g(t[0]),n=Uint8Array.from(pt(e.code));return t.length>1&&t[1]!=null&&(n=$([n,t[1]])),n}))}function Ao(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=H(t instanceof Uint8Array?t:Uint8Array.from(t));return e+O(e)}}function he(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function ur(r){return new Error("Error parsing address: "+r)}var Io=Symbol.for("nodejs.util.inspect.custom"),we=Symbol.for("@multiformats/js-multiaddr/multiaddr"),So=[g("dns").code,g("dns4").code,g("dns6").code,g("dnsaddr").code],Ct=class r{bytes;#t;#e;#r;#n;[we]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=me(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=pr(t)}else if(hr(t))e=me(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",i=g("tcp"),a=g("udp"),u=g("ip4"),f=g("ip6"),m=g("dns6"),v=g("ip6zone");for(let[d,p]of this.stringTuples())d===v.code&&(s=`%${p??""}`),So.includes(d)&&(e=i.name,o=443,n=`${p??""}${s}`,t=d===m.code?6:4),(d===i.code||d===a.code)&&(e=g(d).name,o=parseInt(p??"")),(d===u.code||d===f.code)&&(e=g(d).name,n=`${p??""}${s}`,t=d===f.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},g(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>g(t).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(ge(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===dt.p2p.code&&t.push([n,o]),n===dt["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?P(T.decode(`z${n}`),"base58btc"):P(j.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Xe(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=fr.get(e.name);if(n==null)throw new I(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(s=>new r(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[Io](){return`Multiaddr(${this.#t})`}};var fr=new Map;function hr(r){return!!r?.[we]}function z(r){return new Ct(r)}var Co=c("dns4"),To=c("dns6"),Po=c("dnsaddr"),Q=y(c("dns"),Po,Co,To),Rt=y(c("ip4"),c("ip6")),W=y(l(Rt,c("tcp")),l(Q,c("tcp"))),Nt=l(Rt,c("udp")),Ro=l(Nt,c("utp")),No=l(Nt,c("quic")),Do=l(Nt,c("quic-v1")),xe=y(l(W,c("ws")),l(Q,c("ws"))),Tt=y(l(xe,c("p2p")),xe),be=y(l(W,c("wss")),l(Q,c("wss")),l(W,c("tls"),c("ws")),l(Q,c("tls"),c("ws"))),Pt=y(l(be,c("p2p")),be),ye=y(l(W,c("http")),l(Rt,c("http")),l(Q,c("http"))),ve=y(l(W,c("https")),l(Rt,c("https")),l(Q,c("https"))),mr=l(Nt,c("webrtc-direct"),c("certhash")),xr=y(l(mr,c("p2p")),mr),gr=l(Do,c("webtransport"),c("certhash"),c("certhash")),br=y(l(gr,c("p2p")),gr),yr=y(l(Tt,c("p2p-webrtc-star"),c("p2p")),l(Pt,c("p2p-webrtc-star"),c("p2p")),l(Tt,c("p2p-webrtc-star")),l(Pt,c("p2p-webrtc-star"))),ra=y(l(Tt,c("p2p-websocket-star"),c("p2p")),l(Pt,c("p2p-websocket-star"),c("p2p")),l(Tt,c("p2p-websocket-star")),l(Pt,c("p2p-websocket-star"))),vr=y(l(ye,c("p2p-webrtc-direct"),c("p2p")),l(ve,c("p2p-webrtc-direct"),c("p2p")),l(ye,c("p2p-webrtc-direct")),l(ve,c("p2p-webrtc-direct"))),K=y(xe,be,ye,ve,yr,vr,W,Ro,No,Q,xr,br),na=y(l(K,c("p2p-stardust"),c("p2p")),l(K,c("p2p-stardust"))),G=y(l(K,c("p2p")),yr,vr,xr,br,c("p2p")),wr=y(l(G,c("p2p-circuit"),G),l(G,c("p2p-circuit")),l(c("p2p-circuit"),G),l(K,c("p2p-circuit")),l(c("p2p-circuit"),K),c("p2p-circuit")),Er=()=>y(l(wr,Er),wr),J=Er(),oa=y(l(J,G,J),l(G,J),l(J,G),J,G);var sa=y(l(J,c("webrtc"),c("p2p")),l(J,c("webrtc")),l(K,c("webrtc"),c("p2p")),l(K,c("webrtc")),c("webrtc"));function Ar(r){function t(e){let n;try{n=z(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function l(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(o=>(n=typeof o=="function"?o().partialMatch(e):o.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Ar(t),partialMatch:t}}function y(...r){function t(n){let o=null;return r.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Ar(t),partialMatch:t}}function c(r){let t=r;function e(o){let s;try{s=z(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var kr=tt(Y("net"),1);var Ee={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function Ir(r,t){if(typeof r!="string")throw new I(`invalid ip provided: ${r}`,Ee.ERR_INVALID_IP_PARAMETER);if(typeof t=="string"&&(t=parseInt(t)),isNaN(t))throw new I(`invalid port provided: ${t}`,Ee.ERR_INVALID_PORT_PARAMETER);if((0,U.isIPv4)(r))return z(`/ip4/${r}/tcp/${t}`);if((0,U.isIPv6)(r))return z(`/ip6/${r}/tcp/${t}`);throw new I(`invalid ip:port for creating a multiaddr: ${r}:${t}`,Ee.ERR_INVALID_IP)}var _r=tt(Mr(),1);var Se=tt(Y("os"),1),Ur=tt(Y("path"),1);var Oo={ip4:"IPv4",ip6:"IPv6"};function ft(r,t={}){let e=r.getPath();return e!=null?Se.default.platform()==="win32"?{path:Ur.default.join("\\\\.\\pipe\\",e)}:{path:e}:{...t,...r.toOptions()}}function Ce(r,t,e){let n=o=>z(`/${r}/${o}/tcp/${e}`);return(Vo(t)?$o(Oo[r]):[t]).map(n)}function Vo(r){return["0.0.0.0","::"].includes(r)}var Fo=Se.default.networkInterfaces();function $o(r){let t=[];for(let[,e]of Object.entries(Fo))if(e!=null)for(let n of e)n.family===r&&t.push(n.address);return t}var Mt=(r,t)=>{let e=t.logger.forComponent("libp2p:tcp:socket"),n=t.metrics,o=t.metricPrefix??"",s=t.socketInactivityTimeout??3e5,i=t.socketCloseTimeout??500;t.listeningAddr?.getPath()!=null&&(t.remoteAddr=t.listeningAddr),t.remoteAddr?.getPath()!=null&&(t.localAddr=t.remoteAddr);let a;if(t.remoteAddr!=null)a=t.remoteAddr;else{if(r.remoteAddress==null||r.remotePort==null)throw new I("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");a=Ir(r.remoteAddress,r.remotePort)}let u=ft(a),f=u.path??`${u.host??""}:${u.port??""}`,{sink:m,source:v}=_r.default.duplex(r);r.setTimeout(s,()=>{e("%s socket read timeout",f),n?.increment({[`${o}timeout`]:!0});let d;r.readable&&(d=new I("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),r.destroy(d)}),r.once("close",()=>{e("%s socket close",f),n?.increment({[`${o}close`]:!0}),x.timeline.close==null&&(x.timeline.close=Date.now())}),r.once("end",()=>{e("%s socket end",f),n?.increment({[`${o}end`]:!0})});let x={async sink(d){try{await m(async function*(){for await(let p of d)p instanceof Uint8Array?yield p:yield p.subarray()}())}catch(p){p.type!=="aborted"&&e.error("%s error in sink",f,p)}r.end()},source:v,remoteAddr:a,timeline:{open:Date.now()},async close(d={}){if(r.destroyed){e("%s socket was already destroyed when trying to close",f);return}if(d.signal==null){let p=AbortSignal.timeout(i);d={...d,signal:p}}try{e("%s closing socket",f),await new Promise((p,E)=>{r.once("close",()=>{e("%s socket closed",f),p()}),r.once("error",N=>{e("%s socket error",f,N),x.timeline.close==null&&(x.timeline.close=Date.now()),E(N)}),r.setTimeout(i),r.end(),r.writableLength>0?r.once("drain",()=>{e("%s socket drained",f),r.destroy()}):r.destroy()})}catch(p){this.abort(p)}},abort:d=>{e("%s socket abort due to error",f,d),r.destroy(d)},log:e};return x};async function Te(r,t){try{await r.close()}catch(e){t.log.error("an error occurred closing the connection",e)}}var A;(function(r){r[r.INACTIVE=0]="INACTIVE",r[r.ACTIVE=1]="ACTIVE",r[r.PAUSED=2]="PAUSED"})(A||(A={}));var Ut=class extends yt{context;server;connections=new Set;status={code:A.INACTIVE};metrics;addr;log;constructor(t){if(super(),this.context=t,t.keepAlive=t.keepAlive??!0,t.noDelay=t.noDelay??!0,this.log=t.logger.forComponent("libp2p:tcp:listener"),this.addr="unknown",this.server=kr.default.createServer(t,this.onSocket.bind(this)),t.maxConnections!==void 0&&(this.server.maxConnections=t.maxConnections),t.closeServerOnMaxConnections!=null&&t.closeServerOnMaxConnections.closeAbove<t.closeServerOnMaxConnections.listenBelow)throw new I("closeAbove must be >= listenBelow","ERROR_CONNECTION_LIMITS");this.server.on("listening",()=>{if(t.metrics!=null){let e=this.server.address();e==null?this.addr="unknown":typeof e=="string"?this.addr=e:this.addr=`${e.address}:${e.port}`,t.metrics?.registerMetricGroup("libp2p_tcp_inbound_connections_total",{label:"address",help:"Current active connections in TCP listener",calculate:()=>({[this.addr]:this.connections.size})}),this.metrics={status:t.metrics.registerMetricGroup("libp2p_tcp_listener_status_info",{label:"address",help:"Current status of the TCP listener socket"}),errors:t.metrics.registerMetricGroup("libp2p_tcp_listener_errors_total",{label:"address",help:"Total count of TCP listener errors by type"}),events:t.metrics.registerMetricGroup("libp2p_tcp_listener_events_total",{label:"address",help:"Total count of TCP listener events by type"})},this.metrics?.status.update({[this.addr]:A.ACTIVE})}this.dispatchEvent(new rt("listening"))}).on("error",e=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new rt("error",{detail:e}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:this.status.code}),this.status.code!==A.PAUSED&&this.dispatchEvent(new rt("close"))})}onSocket(t){if(this.status.code!==A.ACTIVE)throw new I("Server is is not listening yet","ERR_SERVER_NOT_RUNNING");t.on("error",n=>{this.log("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let e;try{e=Mt(t,{listeningAddr:this.status.listeningAddr,socketInactivityTimeout:this.context.socketInactivityTimeout,socketCloseTimeout:this.context.socketCloseTimeout,metrics:this.metrics?.events,metricPrefix:`${this.addr} `,logger:this.context.logger})}catch(n){this.log.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}this.log("new inbound connection %s",e.remoteAddr);try{this.context.upgrader.upgradeInbound(e).then(n=>{this.log("inbound connection upgraded %s",e.remoteAddr),this.connections.add(e),t.once("close",()=>{this.connections.delete(e),this.context.closeServerOnMaxConnections!=null&&this.connections.size<this.context.closeServerOnMaxConnections.listenBelow&&this.resume().catch(o=>{this.log.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.pause(!1).catch(o=>{this.log.error("error attempting to close server once connection count over limit",o)}),this.dispatchEvent(new rt("connection",{detail:n}))}).catch(async n=>{this.log.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await Te(e,{log:this.log})}).catch(n=>{this.log.error("closing inbound connection failed",n)})}catch(n){this.log.error("inbound connection failed",n),Te(e,{log:this.log}).catch(o=>{this.log.error("closing inbound connection failed",o),this.metrics?.errors.increment({[`${this.addr} inbound_closing_failed`]:!0})})}}getAddrs(){if(this.status.code===A.INACTIVE)return[];let t=[],e=this.server.address(),{listeningAddr:n,peerId:o}=this.status;if(e==null)return[];if(typeof e=="string")t=[n];else try{n.toString().startsWith("/ip4")?t=t.concat(Ce("ip4",e.address,e.port)):e.family==="IPv6"&&(t=t.concat(Ce("ip6",e.address,e.port)))}catch(s){this.log.error("could not turn %s:%s into multiaddr",e.address,e.port,s)}return t.map(s=>o!=null?s.encapsulate(`/p2p/${o}`):s)}async listen(t){if(this.status.code===A.ACTIVE||this.status.code===A.PAUSED)throw new I("server is already listening","ERR_SERVER_ALREADY_LISTENING");let e=t.getPeerId(),n=e==null?t.decapsulateCode(421):t,{backlog:o}=this.context;try{this.status={code:A.ACTIVE,listeningAddr:n,peerId:e,netConfig:ft(n,{backlog:o})},await this.resume()}catch(s){throw this.status={code:A.INACTIVE},s}}async close(){await Promise.all([Promise.all(Array.from(this.connections.values()).map(async t=>Te(t,{log:this.log}))),this.pause(!0).catch(t=>{this.log.error("error attempting to close server once connection count over limit",t)})])}async resume(){if(this.server.listening||this.status.code===A.INACTIVE)return;let t=this.status.netConfig;await new Promise((e,n)=>{this.server.once("error",n),this.server.listen(t,e)}),this.status={...this.status,code:A.ACTIVE},this.log("Listening on %s",this.server.address())}async pause(t){if(!this.server.listening&&this.status.code===A.PAUSED&&t){this.status={code:A.INACTIVE};return}!this.server.listening||this.status.code!==A.ACTIVE||(this.log("Closing server on %s",this.server.address()),this.status=t?{code:A.INACTIVE}:{...this.status,code:A.PAUSED},await new Promise((e,n)=>{this.server.close(o=>{o!=null?n(o):e()})}))}};var Re=class{opts;metrics;components;log;constructor(t,e={}){this.log=t.logger.forComponent("libp2p:tcp"),this.opts=e,this.components=t,t.metrics!=null&&(this.metrics={dialerEvents:t.metrics.registerCounterGroup("libp2p_tcp_dialer_events_total",{label:"event",help:"Total count of TCP dialer events by type"})})}[Ue]=!0;[Symbol.toStringTag]="@libp2p/tcp";async dial(t,e){e.keepAlive=e.keepAlive??!0,e.noDelay=e.noDelay??!0;let n=await this._connect(t,e);n.on("error",a=>{this.log("socket error",a)});let o=Mt(n,{remoteAddr:t,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents,logger:this.components.logger}),s=()=>{o.close().catch(a=>{this.log.error("Error closing maConn after abort",a)})};e.signal?.addEventListener("abort",s,{once:!0}),this.log("new outbound connection %s",o.remoteAddr);let i=await e.upgrader.upgradeOutbound(o);if(this.log("outbound connection %s upgraded",o.remoteAddr),e.signal?.removeEventListener("abort",s),e.signal?.aborted===!0)throw i.close().catch(a=>{this.log.error("Error closing conn after abort",a)}),new et;return i}async _connect(t,e){if(e.signal?.aborted===!0)throw new et;return new Promise((n,o)=>{let s=Date.now(),i=ft(t,{...this.opts.dialOpts??{},...e});this.log("dialing %a",t);let a=Lr.default.connect(i),u=d=>{let p=i.path??`${i.host??""}:${i.port}`;d.message=`connection error ${p}: ${d.message}`,this.metrics?.dialerEvents.increment({error:!0}),x(d)},f=()=>{this.log("connection timeout %a",t),this.metrics?.dialerEvents.increment({timeout:!0});let d=new I(`connection timeout after ${Date.now()-s}ms`,"ERR_CONNECT_TIMEOUT");a.emit("error",d)},m=()=>{this.log("connection opened %a",t),this.metrics?.dialerEvents.increment({connect:!0}),x()},v=()=>{this.log("connection aborted %a",t),this.metrics?.dialerEvents.increment({abort:!0}),a.destroy(),x(new et)},x=d=>{if(a.removeListener("error",u),a.removeListener("timeout",f),a.removeListener("connect",m),e.signal!=null&&e.signal.removeEventListener("abort",v),d!=null){o(d);return}n(a)};a.on("error",u),a.on("timeout",f),a.on("connect",m),e.signal!=null&&e.signal.addEventListener("abort",v)})}createListener(t){return new Ut({...this.opts.listenOpts??{},...t,maxConnections:this.opts.maxConnections,backlog:this.opts.backlog,closeServerOnMaxConnections:this.opts.closeServerOnMaxConnections,socketInactivityTimeout:this.opts.inboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.components.metrics,logger:this.components.logger})}filter(t){return t=Array.isArray(t)?t:[t],t.filter(e=>e.protoCodes().includes(290)?!1:e.protoCodes().includes(400)?!0:W.matches(e.decapsulateCode(421)))}};function Go(r={}){return t=>new Re(t,r)}return Br(Wo);})();
|
|
2
|
+
"use strict";var Libp2PTcp=(()=>{var Fn=Object.create;var Re=Object.defineProperty;var $n=Object.getOwnPropertyDescriptor;var Bn=Object.getOwnPropertyNames;var qn=Object.getPrototypeOf,jn=Object.prototype.hasOwnProperty;var Y=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var ie=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),A=(r,e)=>{for(var t in e)Re(r,t,{get:e[t],enumerable:!0})},fr=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Bn(e))!jn.call(r,o)&&o!==t&&Re(r,o,{get:()=>e[o],enumerable:!(n=$n(e,o))||n.enumerable});return r};var Z=(r,e,t)=>(t=r!=null?Fn(qn(r)):{},fr(e||!r||!r.__esModule?Re(t,"default",{value:r,enumerable:!0}):t,r)),Gn=r=>fr(Re({},"__esModule",{value:!0}),r);var We=ie((rl,Pn)=>{Pn.exports=r=>{if(r[Symbol.asyncIterator])return r;if(r.getReader)return async function*(){let e=r.getReader();try{for(;;){let{done:t,value:n}=await e.read();if(t)return;yield n}}finally{e.releaseLock()}}();throw new Error("unknown stream")}});var Nn=ie((nl,Dn)=>{Dn.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 ir=ie((ol,Un)=>{var Bi=Nn();Un.exports=r=>async e=>{e=Bi(e);let t=m=>{typeof m.return=="function"&&m.return()},n=null,o=null,s=m=>{n=m,o&&o(m),t(e)},i=null,c=!1,l=()=>{c=!0,i&&i()},f=null,u=!1,y=()=>{u=!0,f&&f()},x=null,h=()=>{x&&x()},a=()=>new Promise((m,v)=>{i=x=m,o=v,r.once("drain",h)}),g=()=>(t(e),new Promise((m,v)=>{if(c||u||n)return m();f=i=m,o=v})),N=()=>{r.removeListener("error",s),r.removeListener("close",l),r.removeListener("finish",y),r.removeListener("drain",h)};r.once("error",s),r.once("close",l),r.once("finish",y);try{for await(let m of e){if(!r.writable||r.destroyed||n)break;r.write(m)===!1&&await a()}}catch(m){n||r.destroy(),n=m}try{if(r.writable&&r.end(),await g(),n)throw n}finally{N()}}});var cr=ie((sl,Rn)=>{var qi=ir(),ji=We();Rn.exports=r=>({sink:qi(r),source:ji(r)})});var On=ie((il,Mn)=>{var Gi=cr();Mn.exports=r=>async function*(e){let t=Gi(r),n;if(t.sink(e).catch(o=>{n=o}),yield*t.source,n)throw n}});var kn=ie((cl,Ae)=>{Ae.exports=We();Ae.exports.source=We();Ae.exports.sink=ir();Ae.exports.transform=On();Ae.exports.duplex=cr()});var tc={};A(tc,{tcp:()=>ec});var zn=Z(Y("net"),1);var nc=Symbol.for("@libp2p/connection");var sc=Symbol.for("@libp2p/content-routing");var ac=Symbol.for("@libp2p/peer-discovery");var pc=Symbol.for("@libp2p/peer-id");var uc=Symbol.for("@libp2p/peer-routing");var hr;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(hr||(hr={}));var gr=Symbol.for("@libp2p/transport");var mr;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(mr||(mr={}));var ce=class r extends Error{code;type;constructor(e="The operation was aborted"){super(e),this.code=r.code,this.type=r.type}static code="ABORT_ERR";static type="aborted"},O=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var Me=class extends EventTarget{#e=new Map;listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:s})=>s!==t),this.#e.set(e,o))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t){return this.dispatchEvent(new ae(e,t))}},He=class extends Event{detail;constructor(e,t){super(e,t),this.detail=t?.detail}},ae=globalThis.CustomEvent??He;var et={};A(et,{base58btc:()=>L,base58flickr:()=>Kn});function Wn(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var c=r.length,l=r.charAt(0),f=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function y(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";for(var g=0,N=0,m=0,v=a.length;m!==v&&a[m]===0;)m++,g++;for(var T=(v-m)*u+1>>>0,E=new Uint8Array(T);m!==v;){for(var P=a[m],M=0,S=T-1;(P!==0||M<N)&&S!==-1;S--,M++)P+=256*E[S]>>>0,E[S]=P%c>>>0,P=P/c>>>0;if(P!==0)throw new Error("Non-zero carry");N=M,m++}for(var U=T-N;U!==T&&E[U]===0;)U++;for(var q=l.repeat(g);U<T;++U)q+=r.charAt(E[U]);return q}function x(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var g=0;if(a[g]!==" "){for(var N=0,m=0;a[g]===l;)N++,g++;for(var v=(a.length-g)*f+1>>>0,T=new Uint8Array(v);a[g];){var E=t[a.charCodeAt(g)];if(E===255)return;for(var P=0,M=v-1;(E!==0||P<m)&&M!==-1;M--,P++)E+=c*T[M]>>>0,T[M]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");m=P,g++}if(a[g]!==" "){for(var S=v-m;S!==v&&T[S]===0;)S++;for(var U=new Uint8Array(N+(v-S)),q=N;S!==v;)U[q++]=T[S++];return U}}}function h(a){var g=x(a);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:x,decode:h}}var Jn=Wn,Xn=Jn,br=Xn;var Gc=new Uint8Array(0);var xr=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0},V=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var wr=r=>new TextEncoder().encode(r),yr=r=>new TextDecoder().decode(r);var Qe=class{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Ke=class{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Er(this,e)}},Ye=class{constructor(e){this.decoders=e}or(e){return Er(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Er=(r,e)=>new Ye({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),Ze=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Qe(e,t,n),this.decoder=new Ke(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},de=({name:r,prefix:e,encode:t,decode:n})=>new Ze(r,e,t,n),J=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=br(t,e);return de({prefix:r,name:e,encode:n,decode:s=>V(o(s))})},Hn=(r,e,t,n)=>{let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),c=0,l=0,f=0;for(let u=0;u<s;++u){let y=o[r[u]];if(y===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<t|y,c+=t,c>=8&&(c-=8,i[f++]=255&l>>c)}if(c>=t||255&l<<8-c)throw new SyntaxError("Unexpected end of data");return i},Qn=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,c=0;for(let l=0;l<r.length;++l)for(c=c<<8|r[l],i+=8;i>t;)i-=t,s+=e[o&c>>i];if(i&&(s+=e[o&c<<t-i]),n)for(;s.length*t&7;)s+="=";return s},I=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>de({prefix:e,name:r,encode(o){return Qn(o,n,t)},decode(o){return Hn(o,n,t,r)}});var L=J({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Kn=J({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var tt={};A(tt,{base32:()=>j,base32hex:()=>to,base32hexpad:()=>no,base32hexpadupper:()=>oo,base32hexupper:()=>ro,base32pad:()=>Zn,base32padupper:()=>eo,base32upper:()=>Yn,base32z:()=>so});var j=I({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Yn=I({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Zn=I({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),eo=I({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),to=I({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ro=I({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),no=I({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),oo=I({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),so=I({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var io=Ir,Ar=128,co=127,ao=~co,po=Math.pow(2,31);function Ir(r,e,t){e=e||[],t=t||0;for(var n=t;r>=po;)e[t++]=r&255|Ar,r/=128;for(;r&ao;)e[t++]=r&255|Ar,r>>>=7;return e[t]=r|0,Ir.bytes=t-n+1,e}var lo=rt,uo=128,Sr=127;function rt(r,n){var t=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw rt.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Sr)<<o:(i&Sr)*Math.pow(2,o),o+=7}while(i>=uo);return rt.bytes=s-n,t}var fo=Math.pow(2,7),ho=Math.pow(2,14),mo=Math.pow(2,21),go=Math.pow(2,28),bo=Math.pow(2,35),xo=Math.pow(2,42),wo=Math.pow(2,49),yo=Math.pow(2,56),vo=Math.pow(2,63),Eo=function(r){return r<fo?1:r<ho?2:r<mo?3:r<go?4:r<bo?5:r<xo?6:r<wo?7:r<yo?8:r<vo?9:10},Ao={encode:io,decode:lo,encodingLength:Eo},So=Ao,Ie=So;var Ce=(r,e=0)=>[Ie.decode(r,e),Ie.decode.bytes],pe=(r,e,t=0)=>(Ie.encode(r,e,t),e),le=r=>Ie.encodingLength(r);var ee=(r,e)=>{let t=e.byteLength,n=le(r),o=n+le(t),s=new Uint8Array(o+t);return pe(r,s,0),pe(t,s,n),s.set(e,o),new ue(r,t,e,s)},ke=r=>{let e=V(r),[t,n]=Ce(e),[o,s]=Ce(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ue(t,o,i,e)},Cr=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&xr(r.bytes,t.bytes)}},ue=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var Tr=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Co(t,nt(r),e||L.encoder);default:return To(t,nt(r),e||j.encoder)}};var Pr=new WeakMap,nt=r=>{let e=Pr.get(r);if(e==null){let t=new Map;return Pr.set(r,t),t}return e},X=class r{constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Te)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Po)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=ee(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&Cr(e.multihash,n.multihash)}toString(e){return Tr(this,e)}toJSON(){return{"/":Tr(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new r(n,o,s,i||Dr(n,o,s.bytes))}else if(t[Do]===!0){let{version:n,multihash:o,code:s}=t,i=ke(o);return r.create(n,s,i)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Te)throw new Error(`Version 0 CID must use dag-pb (code: ${Te}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Dr(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Te,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=V(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new ue(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[y,x]=Ce(e.subarray(t));return t+=x,y},o=n(),s=Te;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,c=n(),l=n(),f=t+l,u=f-i;return{version:o,codec:s,multihashCode:c,digestSize:l,multihashSize:u,size:f}}static parse(e,t){let[n,o]=Io(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return nt(s).set(n,e),s}},Io=(r,e)=>{switch(r[0]){case"Q":{let t=e||L;return[L.prefix,t.decode(`${L.prefix}${r}`)]}case L.prefix:{let t=e||L;return[L.prefix,t.decode(r)]}case j.prefix:{let t=e||j;return[j.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},Co=(r,e,t)=>{let{prefix:n}=t;if(n!==L.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},To=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},Te=112,Po=18,Dr=(r,e,t)=>{let n=le(r),o=n+le(e),s=new Uint8Array(o+t.byteLength);return pe(r,s,0),pe(e,s,n),s.set(t,o),s},Do=Symbol.for("@ipld/js-cid/CID");function Nr(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var at={};A(at,{base10:()=>ko});function No(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var c=r.length,l=r.charAt(0),f=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function y(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";for(var g=0,N=0,m=0,v=a.length;m!==v&&a[m]===0;)m++,g++;for(var T=(v-m)*u+1>>>0,E=new Uint8Array(T);m!==v;){for(var P=a[m],M=0,S=T-1;(P!==0||M<N)&&S!==-1;S--,M++)P+=256*E[S]>>>0,E[S]=P%c>>>0,P=P/c>>>0;if(P!==0)throw new Error("Non-zero carry");N=M,m++}for(var U=T-N;U!==T&&E[U]===0;)U++;for(var q=l.repeat(g);U<T;++U)q+=r.charAt(E[U]);return q}function x(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var g=0;if(a[g]!==" "){for(var N=0,m=0;a[g]===l;)N++,g++;for(var v=(a.length-g)*f+1>>>0,T=new Uint8Array(v);a[g];){var E=t[a.charCodeAt(g)];if(E===255)return;for(var P=0,M=v-1;(E!==0||P<m)&&M!==-1;M--,P++)E+=c*T[M]>>>0,T[M]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");m=P,g++}if(a[g]!==" "){for(var S=v-m;S!==v&&T[S]===0;)S++;for(var U=new Uint8Array(N+(v-S)),q=N;S!==v;)U[q++]=T[S++];return U}}}function h(a){var g=x(a);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:x,decode:h}}var Uo=No,Ro=Uo,Ur=Ro;var ca=new Uint8Array(0);var Rr=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0},z=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var Mr=r=>new TextEncoder().encode(r),Or=r=>new TextDecoder().decode(r);var ot=class{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},st=class{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Lr(this,e)}},it=class{constructor(e){this.decoders=e}or(e){return Lr(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Lr=(r,e)=>new it({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),ct=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new ot(e,t,n),this.decoder=new st(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},he=({name:r,prefix:e,encode:t,decode:n})=>new ct(r,e,t,n),H=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=Ur(t,e);return he({prefix:r,name:e,encode:n,decode:s=>z(o(s))})},Mo=(r,e,t,n)=>{let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),c=0,l=0,f=0;for(let u=0;u<s;++u){let y=o[r[u]];if(y===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<t|y,c+=t,c>=8&&(c-=8,i[f++]=255&l>>c)}if(c>=t||255&l<<8-c)throw new SyntaxError("Unexpected end of data");return i},Oo=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,c=0;for(let l=0;l<r.length;++l)for(c=c<<8|r[l],i+=8;i>t;)i-=t,s+=e[o&c>>i];if(i&&(s+=e[o&c<<t-i]),n)for(;s.length*t&7;)s+="=";return s},C=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>he({prefix:e,name:r,encode(o){return Oo(o,n,t)},decode(o){return Mo(o,n,t,r)}});var ko=H({prefix:"9",name:"base10",alphabet:"0123456789"});var dt={};A(dt,{base16:()=>Lo,base16upper:()=>_o});var Lo=C({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),_o=C({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var pt={};A(pt,{base2:()=>Vo});var Vo=C({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var lt={};A(lt,{base256emoji:()=>qo});var _r=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}"),zo=_r.reduce((r,e,t)=>(r[t]=e,r),[]),Fo=_r.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function $o(r){return r.reduce((e,t)=>(e+=zo[t],e),"")}function Bo(r){let e=[];for(let t of r){let n=Fo[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var qo=he({prefix:"\u{1F680}",name:"base256emoji",encode:$o,decode:Bo});var ut={};A(ut,{base32:()=>me,base32hex:()=>Jo,base32hexpad:()=>Ho,base32hexpadupper:()=>Qo,base32hexupper:()=>Xo,base32pad:()=>Go,base32padupper:()=>Wo,base32upper:()=>jo,base32z:()=>Ko});var me=C({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),jo=C({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Go=C({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Wo=C({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Jo=C({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Xo=C({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ho=C({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Qo=C({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ko=C({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ft={};A(ft,{base36:()=>Yo,base36upper:()=>Zo});var Yo=H({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Zo=H({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ht={};A(ht,{base58btc:()=>$,base58flickr:()=>es});var $=H({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),es=H({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var mt={};A(mt,{base64:()=>ts,base64pad:()=>rs,base64url:()=>ns,base64urlpad:()=>os});var ts=C({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),rs=C({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ns=C({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),os=C({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var gt={};A(gt,{base8:()=>ss});var ss=C({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var bt={};A(bt,{identity:()=>is});var is=he({prefix:"\0",name:"identity",encode:r=>Or(r),decode:r=>Mr(r)});var Ea=new TextEncoder,Aa=new TextDecoder;var wt={};A(wt,{identity:()=>Ds});var ds=Fr,Vr=128,ps=127,ls=~ps,us=Math.pow(2,31);function Fr(r,e,t){e=e||[],t=t||0;for(var n=t;r>=us;)e[t++]=r&255|Vr,r/=128;for(;r&ls;)e[t++]=r&255|Vr,r>>>=7;return e[t]=r|0,Fr.bytes=t-n+1,e}var fs=xt,hs=128,zr=127;function xt(r,n){var t=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw xt.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&zr)<<o:(i&zr)*Math.pow(2,o),o+=7}while(i>=hs);return xt.bytes=s-n,t}var ms=Math.pow(2,7),gs=Math.pow(2,14),bs=Math.pow(2,21),xs=Math.pow(2,28),ws=Math.pow(2,35),ys=Math.pow(2,42),vs=Math.pow(2,49),Es=Math.pow(2,56),As=Math.pow(2,63),Ss=function(r){return r<ms?1:r<gs?2:r<bs?3:r<xs?4:r<ws?5:r<ys?6:r<vs?7:r<Es?8:r<As?9:10},Is={encode:ds,decode:fs,encodingLength:Ss},Cs=Is,Pe=Cs;var De=(r,e=0)=>[Pe.decode(r,e),Pe.decode.bytes],ge=(r,e,t=0)=>(Pe.encode(r,e,t),e),be=r=>Pe.encodingLength(r);var te=(r,e)=>{let t=e.byteLength,n=be(r),o=n+be(t),s=new Uint8Array(o+t);return ge(r,s,0),ge(t,s,n),s.set(e,o),new xe(r,t,e,s)},$r=r=>{let e=z(r),[t,n]=De(e),[o,s]=De(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new xe(t,o,i,e)},Br=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Rr(r.bytes,t.bytes)}},xe=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var qr=0,Ts="identity",jr=z,Ps=r=>te(qr,jr(r)),Ds={code:qr,name:Ts,encode:jr,digest:Ps};var At={};A(At,{sha256:()=>Ns,sha512:()=>Us});var Et=Z(Y("crypto"),1);var vt=({name:r,code:e,encode:t})=>new yt(r,e,t),yt=class{constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?te(this.code,t):t.then(n=>te(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Ns=vt({name:"sha2-256",code:18,encode:r=>z(Et.default.createHash("sha256").update(r).digest())}),Us=vt({name:"sha2-512",code:19,encode:r=>z(Et.default.createHash("sha512").update(r).digest())});var Wr=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Ms(t,St(r),e||$.encoder);default:return Os(t,St(r),e||me.encoder)}};var Jr=new WeakMap,St=r=>{let e=Jr.get(r);if(e==null){let t=new Map;return Jr.set(r,t),t}return e},_e=class r{constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Ue)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==ks)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=te(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&Br(e.multihash,n.multihash)}toString(e){return Wr(this,e)}toJSON(){return{"/":Wr(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new r(n,o,s,i||Xr(n,o,s.bytes))}else if(t[Ls]===!0){let{version:n,multihash:o,code:s}=t,i=$r(o);return r.create(n,s,i)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Ue)throw new Error(`Version 0 CID must use dag-pb (code: ${Ue}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Xr(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Ue,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=z(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new xe(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[y,x]=De(e.subarray(t));return t+=x,y},o=n(),s=Ue;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,c=n(),l=n(),f=t+l,u=f-i;return{version:o,codec:s,multihashCode:c,digestSize:l,multihashSize:u,size:f}}static parse(e,t){let[n,o]=Rs(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return St(s).set(n,e),s}},Rs=(r,e)=>{switch(r[0]){case"Q":{let t=e||$;return[$.prefix,t.decode(`${$.prefix}${r}`)]}case $.prefix:{let t=e||$;return[$.prefix,t.decode(r)]}case me.prefix:{let t=e||me;return[me.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},Ms=(r,e,t)=>{let{prefix:n}=t;if(n!==$.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},Os=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},Ue=112,ks=18,Xr=(r,e,t)=>{let n=be(r),o=n+be(e),s=new Uint8Array(o+t.byteLength);return ge(r,s,0),ge(e,s,n),s.set(t,o),s},Ls=Symbol.for("@ipld/js-cid/CID");var It={...bt,...pt,...gt,...at,...dt,...ut,...ft,...ht,...mt,...lt},Fa={...At,...wt};function we(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function ye(r=0){return globalThis.Buffer?.allocUnsafe!=null?we(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Qr(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Hr=Qr("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ct=Qr("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=ye(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),_s={utf8:Hr,"utf-8":Hr,hex:It.base16,latin1:Ct,ascii:Ct,binary:Ct,...It},Ve=_s;function _(r,e="utf8"){let t=Ve[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var Vs=Math.pow(2,7),zs=Math.pow(2,14),Fs=Math.pow(2,21),Tt=Math.pow(2,28),Pt=Math.pow(2,35),Dt=Math.pow(2,42),Nt=Math.pow(2,49),b=128,k=127;function B(r){if(r<Vs)return 1;if(r<zs)return 2;if(r<Fs)return 3;if(r<Tt)return 4;if(r<Pt)return 5;if(r<Dt)return 6;if(r<Nt)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function $s(r,e,t=0){switch(B(r)){case 8:e[t++]=r&255|b,r/=128;case 7:e[t++]=r&255|b,r/=128;case 6:e[t++]=r&255|b,r/=128;case 5:e[t++]=r&255|b,r/=128;case 4:e[t++]=r&255|b,r>>>=7;case 3:e[t++]=r&255|b,r>>>=7;case 2:e[t++]=r&255|b,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Bs(r,e,t=0){switch(B(r)){case 8:e.set(t++,r&255|b),r/=128;case 7:e.set(t++,r&255|b),r/=128;case 6:e.set(t++,r&255|b),r/=128;case 5:e.set(t++,r&255|b),r/=128;case 4:e.set(t++,r&255|b),r>>>=7;case 3:e.set(t++,r&255|b),r>>>=7;case 2:e.set(t++,r&255|b),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function qs(r,e){let t=r[e],n=0;if(n+=t&k,t<b||(t=r[e+1],n+=(t&k)<<7,t<b)||(t=r[e+2],n+=(t&k)<<14,t<b)||(t=r[e+3],n+=(t&k)<<21,t<b)||(t=r[e+4],n+=(t&k)*Tt,t<b)||(t=r[e+5],n+=(t&k)*Pt,t<b)||(t=r[e+6],n+=(t&k)*Dt,t<b)||(t=r[e+7],n+=(t&k)*Nt,t<b))return n;throw new RangeError("Could not decode varint")}function js(r,e){let t=r.get(e),n=0;if(n+=t&k,t<b||(t=r.get(e+1),n+=(t&k)<<7,t<b)||(t=r.get(e+2),n+=(t&k)<<14,t<b)||(t=r.get(e+3),n+=(t&k)<<21,t<b)||(t=r.get(e+4),n+=(t&k)*Tt,t<b)||(t=r.get(e+5),n+=(t&k)*Pt,t<b)||(t=r.get(e+6),n+=(t&k)*Dt,t<b)||(t=r.get(e+7),n+=(t&k)*Nt,t<b))return n;throw new RangeError("Could not decode varint")}function ve(r,e,t=0){return e==null&&(e=ye(B(r))),e instanceof Uint8Array?$s(r,e,t):Bs(r,e,t)}function re(r,e=0){return r instanceof Uint8Array?qs(r,e):js(r,e)}function G(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=ye(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return we(t)}var ze=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let s=0,i=0,c=this.peekChar();if(c===void 0)return;let l=c==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let y=this.readChar();if(y===void 0)return;let x=Number.parseInt(y,e);if(!Number.isNaN(x))return x});if(u===void 0)break;if(s*=e,s+=u,s>f||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&l&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return t[o]=i[0],t[o+1]=i[1],t[o+2]=i[2],t[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];t[o]=s>>8,t[o+1]=s&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[c]=e(s.subarray(0,i));return t.set(s.subarray(0,c),16-c),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var rd=new ze;var pd=parseInt("0xFFFF",16),ld=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var Ut={};A(Ut,{base10:()=>Qs});var Qs=J({prefix:"9",name:"base10",alphabet:"0123456789"});var Rt={};A(Rt,{base16:()=>Ks,base16upper:()=>Ys});var Ks=I({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ys=I({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Mt={};A(Mt,{base2:()=>Zs});var Zs=I({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ot={};A(Ot,{base256emoji:()=>oi});var en=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}"),ei=en.reduce((r,e,t)=>(r[t]=e,r),[]),ti=en.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function ri(r){return r.reduce((e,t)=>(e+=ei[t],e),"")}function ni(r){let e=[];for(let t of r){let n=ti[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var oi=de({prefix:"\u{1F680}",name:"base256emoji",encode:ri,decode:ni});var kt={};A(kt,{base36:()=>si,base36upper:()=>ii});var si=J({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ii=J({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Lt={};A(Lt,{base64:()=>ci,base64pad:()=>ai,base64url:()=>di,base64urlpad:()=>pi});var ci=I({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ai=I({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),di=I({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),pi=I({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var _t={};A(_t,{base8:()=>li});var li=I({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Vt={};A(Vt,{identity:()=>ui});var ui=de({prefix:"\0",name:"identity",encode:r=>yr(r),decode:r=>wr(r)});var jd=new TextEncoder,Gd=new TextDecoder;var zt={};A(zt,{identity:()=>bi});var tn=0,mi="identity",rn=V,gi=r=>ee(tn,rn(r)),bi={code:tn,name:mi,encode:rn,digest:gi};var qt={};A(qt,{sha256:()=>xi,sha512:()=>wi});var Bt=Z(Y("crypto"),1);var $t=({name:r,code:e,encode:t})=>new Ft(r,e,t),Ft=class{constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?ee(this.code,t):t.then(n=>ee(this.code,n))}else throw Error("Unknown type, must be binary type")}};var xi=$t({name:"sha2-256",code:18,encode:r=>V(Bt.default.createHash("sha256").update(r).digest())}),wi=$t({name:"sha2-512",code:19,encode:r=>V(Bt.default.createHash("sha512").update(r).digest())});var on={...Vt,...Mt,..._t,...Ut,...Rt,...tt,...kt,...et,...Lt,...Ot},ep={...qt,...zt};function jt(r,e="utf8"){let t=Ve[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?we(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var F=Y("node:net");function Fe(r){return!!(0,F.isIP)(r)}var sn=F.isIPv4,yi=F.isIPv6,Gt=function(r){let e=0;if(r=r.toString().trim(),sn(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(yi(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=sn(t[n]),i;s&&(i=Gt(t[n]),t[n]=_(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,_(i.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let s=[n,1];for(n=9-t.length;n>0;n--)s.push("0");t.splice.apply(t,s)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){let s=parseInt(t[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},cn=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let s=0;s<t;s++)o.push(r[e+s]);return o.join(".")}if(t===16){let o=[];for(let s=0;s<t;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Ee={},Wt={},Ei=[[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"]];Ei.forEach(r=>{let e=Ai(...r);Wt[e.code]=e,Ee[e.name]=e});function Ai(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function w(r){if(typeof r=="number"){if(Wt[r]!=null)return Wt[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ee[r]!=null)return Ee[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var wp=w("ip4"),yp=w("ip6"),vp=w("ipcidr");function Xt(r,e){switch(w(r).code){case 4:case 41:return Ii(e);case 42:return pn(e);case 6:case 273:case 33:case 132:return un(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return pn(e);case 421:return Di(e);case 444:return ln(e);case 445:return ln(e);case 466:return Pi(e);default:return _(e,"base16")}}function Ht(r,e){switch(w(r).code){case 4:return an(e);case 41:return an(e);case 42:return dn(e);case 6:case 273:case 33:case 132:return Qt(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return dn(e);case 421:return Ci(e);case 444:return Ni(e);case 445:return Ui(e);case 466:return Ti(e);default:return jt(e,"base16")}}var Jt=Object.values(on).map(r=>r.decoder),Si=function(){let r=Jt[0].or(Jt[1]);return Jt.slice(2).forEach(e=>r=r.or(e)),r}();function an(r){if(!Fe(r))throw new Error("invalid ip address");return Gt(r)}function Ii(r){let e=cn(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Fe(e))throw new Error("invalid ip address");return e}function Qt(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function un(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function dn(r){let e=jt(r),t=Uint8Array.from(ve(e.length));return G([t,e],t.length+e.length)}function pn(r){let e=re(r);if(r=r.slice(B(e)),r.length!==e)throw new Error("inconsistent lengths");return _(r)}function Ci(r){let e;r[0]==="Q"||r[0]==="1"?e=ke(L.decode(`z${r}`)).bytes:e=X.parse(r).multihash.bytes;let t=Uint8Array.from(ve(e.length));return G([t,e],t.length+e.length)}function Ti(r){let e=Si.decode(r),t=Uint8Array.from(ve(e.length));return G([t,e],t.length+e.length)}function Pi(r){let e=re(r),t=r.slice(B(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+_(t,"base64url")}function Di(r){let e=re(r),t=r.slice(B(e));if(t.length!==e)throw new Error("inconsistent lengths");return _(t,"base58btc")}function Ni(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=j.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=Qt(n);return G([t,o],t.length+o.length)}function Ui(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=j.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=Qt(n);return G([t,o],t.length+o.length)}function ln(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=_(e,"base32"),o=un(t);return`${n}:${o}`}function fn(r){r=Kt(r);let e=[],t=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],c=w(i);if(c.size===0){e.push([c.code]),t.push([c.code]);continue}if(s++,s>=o.length)throw mn("invalid address: "+r);if(c.path===!0){n=Kt(o.slice(s).join("/")),e.push([c.code,Ht(c.code,n)]),t.push([c.code,n]);break}let l=Ht(c.code,o[s]);e.push([c.code,l]),t.push([c.code,Xt(c.code,l)])}return{string:hn(t),bytes:Zt(e),tuples:e,stringTuples:t,path:n}}function Yt(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let s=re(r,o),i=B(s),c=w(s),l=Ri(c,r.slice(o+i));if(l===0){e.push([s]),t.push([s]),o+=i;continue}let f=r.slice(o+i,o+i+l);if(o+=l+i,o>r.length)throw mn("Invalid address Uint8Array: "+_(r,"base16"));e.push([s,f]);let u=Xt(s,f);if(t.push([s,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:hn(t),tuples:e,stringTuples:t,path:n}}function hn(r){let e=[];return r.map(t=>{let n=w(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),Kt(e.join("/"))}function Zt(r){return G(r.map(e=>{let t=w(e[0]),n=Uint8Array.from(ve(t.code));return e.length>1&&e[1]!=null&&(n=G([n,e[1]])),n}))}function Ri(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=re(e instanceof Uint8Array?e:Uint8Array.from(e));return t+B(t)}}function Kt(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function mn(r){return new Error("Error parsing address: "+r)}var Mi=Symbol.for("nodejs.util.inspect.custom"),er=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Oi=[w("dns").code,w("dns4").code,w("dns6").code,w("dnsaddr").code],$e=class r{bytes;#e;#t;#r;#n;[er]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=Yt(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=fn(e)}else if(bn(e))t=Yt(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#t=t.tuples,this.#r=t.stringTuples,this.#n=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,o,s="",i=w("tcp"),c=w("udp"),l=w("ip4"),f=w("ip6"),u=w("dns6"),y=w("ip6zone");for(let[h,a]of this.stringTuples())h===y.code&&(s=`%${a??""}`),Oi.includes(h)&&(t=i.name,o=443,n=`${a??""}${s}`,e=h===u.code?6:4),(h===i.code||h===c.code)&&(t=w(h).name,o=parseInt(a??"")),(h===l.code||h===f.code)&&(t=w(h).name,n=`${a??""}${s}`,e=h===f.code?6:4);if(e==null||t==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:o}}protos(){return this.#t.map(([e])=>Object.assign({},w(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>w(e).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(Zt(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===Ee.p2p.code&&e.push([n,o]),n===Ee["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?_(L.decode(`z${n}`),"base58btc"):_(X.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return Nr(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=gn.get(t.name);if(n==null)throw new O(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new r(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[Mi](){return`Multiaddr(${this.#e})`}};var gn=new Map;function bn(r){return!!r?.[er]}function W(r){return new $e(r)}var ki=d("dns4"),Li=d("dns6"),_i=d("dnsaddr"),oe=D(d("dns"),_i,ki,Li),je=D(d("ip4"),d("ip6")),K=D(p(je,d("tcp")),p(oe,d("tcp"))),Ge=p(je,d("udp")),Vi=p(Ge,d("utp")),zi=p(Ge,d("quic")),Fi=p(Ge,d("quic-v1")),tr=D(p(K,d("ws")),p(oe,d("ws"))),Be=D(p(tr,d("p2p")),tr),rr=D(p(K,d("wss")),p(oe,d("wss")),p(K,d("tls"),d("ws")),p(oe,d("tls"),d("ws"))),qe=D(p(rr,d("p2p")),rr),nr=D(p(K,d("http")),p(je,d("http")),p(oe,d("http"))),or=D(p(K,d("https")),p(je,d("https")),p(oe,d("https"))),xn=p(Ge,d("webrtc-direct"),d("certhash")),vn=D(p(xn,d("p2p")),xn),wn=p(Fi,d("webtransport"),d("certhash"),d("certhash")),En=D(p(wn,d("p2p")),wn),An=D(p(Be,d("p2p-webrtc-star"),d("p2p")),p(qe,d("p2p-webrtc-star"),d("p2p")),p(Be,d("p2p-webrtc-star")),p(qe,d("p2p-webrtc-star"))),Jp=D(p(Be,d("p2p-websocket-star"),d("p2p")),p(qe,d("p2p-websocket-star"),d("p2p")),p(Be,d("p2p-websocket-star")),p(qe,d("p2p-websocket-star"))),Sn=D(p(nr,d("p2p-webrtc-direct"),d("p2p")),p(or,d("p2p-webrtc-direct"),d("p2p")),p(nr,d("p2p-webrtc-direct")),p(or,d("p2p-webrtc-direct"))),se=D(tr,rr,nr,or,An,Sn,K,Vi,zi,oe,vn,En),Xp=D(p(se,d("p2p-stardust"),d("p2p")),p(se,d("p2p-stardust"))),Q=D(p(se,d("p2p")),An,Sn,vn,En,d("p2p")),yn=D(p(Q,d("p2p-circuit"),Q),p(Q,d("p2p-circuit")),p(d("p2p-circuit"),Q),p(se,d("p2p-circuit")),p(d("p2p-circuit"),se),d("p2p-circuit")),In=()=>D(p(yn,In),yn),ne=In(),Hp=D(p(ne,Q,ne),p(Q,ne),p(ne,Q),ne,Q);var Qp=D(p(ne,d("webrtc"),d("p2p")),p(ne,d("webrtc")),p(se,d("webrtc"),d("p2p")),p(se,d("webrtc")),d("webrtc"));function Cn(r){function e(t){let n;try{n=W(t)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return e}function p(...r){function e(t){if(t.length<r.length)return null;let n=t;return r.some(o=>(n=typeof o=="function"?o().partialMatch(t):o.partialMatch(t),Array.isArray(n)&&(t=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Cn(e),partialMatch:e}}function D(...r){function e(n){let o=null;return r.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Cn(e),partialMatch:e}}function d(r){let e=r;function t(o){let s;try{s=W(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===e}function n(o){return o.length===0?null:o[0]===e?o.slice(1):null}return{toString:function(){return e},matches:t,partialMatch:n}}var Vn=Z(Y("net"),1);var sr={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function Tn(r,e){if(typeof r!="string")throw new O(`invalid ip provided: ${r}`,sr.ERR_INVALID_IP_PARAMETER);if(typeof e=="string"&&(e=parseInt(e)),isNaN(e))throw new O(`invalid port provided: ${e}`,sr.ERR_INVALID_PORT_PARAMETER);if((0,F.isIPv4)(r))return W(`/ip4/${r}/tcp/${e}`);if((0,F.isIPv6)(r))return W(`/ip6/${r}/tcp/${e}`);throw new O(`invalid ip:port for creating a multiaddr: ${r}:${e}`,sr.ERR_INVALID_IP)}var _n=Z(kn(),1);var ar=Z(Y("os"),1),Ln=Z(Y("path"),1);var Wi={ip4:"IPv4",ip6:"IPv6"};function Se(r,e={}){let t=r.getPath();return t!=null?ar.default.platform()==="win32"?{path:Ln.default.join("\\\\.\\pipe\\",t)}:{path:t}:{...e,...r.toOptions()}}function dr(r,e,t){let n=o=>W(`/${r}/${o}/tcp/${t}`);return(Ji(e)?Hi(Wi[r]):[e]).map(n)}function Ji(r){return["0.0.0.0","::"].includes(r)}var Xi=ar.default.networkInterfaces();function Hi(r){let e=[];for(let[,t]of Object.entries(Xi))if(t!=null)for(let n of t)n.family===r&&e.push(n.address);return e}var Je=(r,e)=>{let t=e.logger.forComponent("libp2p:tcp:socket"),n=e.metrics,o=e.metricPrefix??"",s=e.socketInactivityTimeout??3e5,i=e.socketCloseTimeout??500;e.listeningAddr?.getPath()!=null&&(e.remoteAddr=e.listeningAddr),e.remoteAddr?.getPath()!=null&&(e.localAddr=e.remoteAddr);let c;if(e.remoteAddr!=null)c=e.remoteAddr;else{if(r.remoteAddress==null||r.remotePort==null)throw new O("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");c=Tn(r.remoteAddress,r.remotePort)}let l=Se(c),f=l.path??`${l.host??""}:${l.port??""}`,{sink:u,source:y}=_n.default.duplex(r);r.setTimeout(s,()=>{t("%s socket read timeout",f),n?.increment({[`${o}timeout`]:!0});let h;r.readable&&(h=new O("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),r.destroy(h)}),r.once("close",()=>{t("%s socket close",f),n?.increment({[`${o}close`]:!0}),x.timeline.close==null&&(x.timeline.close=Date.now())}),r.once("end",()=>{t("%s socket end",f),n?.increment({[`${o}end`]:!0})});let x={async sink(h){try{await u(async function*(){for await(let a of h)a instanceof Uint8Array?yield a:yield a.subarray()}())}catch(a){a.type!=="aborted"&&t.error("%s error in sink",f,a)}r.end()},source:y,remoteAddr:c,timeline:{open:Date.now()},async close(h={}){if(r.destroyed){t("%s socket was already destroyed when trying to close",f);return}if(h.signal==null){let a=AbortSignal.timeout(i);h={...h,signal:a}}try{t("%s closing socket",f),await new Promise((a,g)=>{r.once("close",()=>{t("%s socket closed",f),a()}),r.once("error",N=>{t("%s socket error",f,N),x.timeline.close==null&&(x.timeline.close=Date.now()),g(N)}),r.setTimeout(i),r.end(),r.writableLength>0?r.once("drain",()=>{t("%s socket drained",f),r.destroy()}):r.destroy()})}catch(a){this.abort(a)}},abort:h=>{t("%s socket abort due to error",f,h),r.destroy(h)},log:t};return x};async function pr(r,e){try{await r.close()}catch(t){e.log.error("an error occurred closing the connection",t)}}var R;(function(r){r[r.INACTIVE=0]="INACTIVE",r[r.ACTIVE=1]="ACTIVE",r[r.PAUSED=2]="PAUSED"})(R||(R={}));var Xe=class extends Me{context;server;connections=new Set;status={code:R.INACTIVE};metrics;addr;log;constructor(e){if(super(),this.context=e,e.keepAlive=e.keepAlive??!0,e.noDelay=e.noDelay??!0,this.log=e.logger.forComponent("libp2p:tcp:listener"),this.addr="unknown",this.server=Vn.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 new O("closeAbove must be >= listenBelow","ERROR_CONNECTION_LIMITS");this.server.on("listening",()=>{if(e.metrics!=null){let t=this.server.address();t==null?this.addr="unknown":typeof t=="string"?this.addr=t:this.addr=`${t.address}:${t.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]:R.ACTIVE})}this.dispatchEvent(new ae("listening"))}).on("error",t=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new ae("error",{detail:t}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:this.status.code}),this.status.code!==R.PAUSED&&this.dispatchEvent(new ae("close"))})}onSocket(e){if(this.status.code!==R.ACTIVE)throw new O("Server is is not listening yet","ERR_SERVER_NOT_RUNNING");e.on("error",n=>{this.log("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let t;try{t=Je(e,{listeningAddr:this.status.listeningAddr,socketInactivityTimeout:this.context.socketInactivityTimeout,socketCloseTimeout:this.context.socketCloseTimeout,metrics:this.metrics?.events,metricPrefix:`${this.addr} `,logger:this.context.logger})}catch(n){this.log.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}this.log("new inbound connection %s",t.remoteAddr);try{this.context.upgrader.upgradeInbound(t).then(n=>{this.log("inbound connection upgraded %s",t.remoteAddr),this.connections.add(t),e.once("close",()=>{this.connections.delete(t),this.context.closeServerOnMaxConnections!=null&&this.connections.size<this.context.closeServerOnMaxConnections.listenBelow&&this.resume().catch(o=>{this.log.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.pause(!1).catch(o=>{this.log.error("error attempting to close server once connection count over limit",o)}),this.dispatchEvent(new ae("connection",{detail:n}))}).catch(async n=>{this.log.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await pr(t,{log:this.log})}).catch(n=>{this.log.error("closing inbound connection failed",n)})}catch(n){this.log.error("inbound connection failed",n),pr(t,{log:this.log}).catch(o=>{this.log.error("closing inbound connection failed",o),this.metrics?.errors.increment({[`${this.addr} inbound_closing_failed`]:!0})})}}getAddrs(){if(this.status.code===R.INACTIVE)return[];let e=[],t=this.server.address(),{listeningAddr:n,peerId:o}=this.status;if(t==null)return[];if(typeof t=="string")e=[n];else try{n.toString().startsWith("/ip4")?e=e.concat(dr("ip4",t.address,t.port)):t.family==="IPv6"&&(e=e.concat(dr("ip6",t.address,t.port)))}catch(s){this.log.error("could not turn %s:%s into multiaddr",t.address,t.port,s)}return e.map(s=>o!=null?s.encapsulate(`/p2p/${o}`):s)}async listen(e){if(this.status.code===R.ACTIVE||this.status.code===R.PAUSED)throw new O("server is already listening","ERR_SERVER_ALREADY_LISTENING");let t=e.getPeerId(),n=t==null?e.decapsulateCode(421):e,{backlog:o}=this.context;try{this.status={code:R.ACTIVE,listeningAddr:n,peerId:t,netConfig:Se(n,{backlog:o})},await this.resume()}catch(s){throw this.status={code:R.INACTIVE},s}}async close(){await Promise.all([Promise.all(Array.from(this.connections.values()).map(async e=>pr(e,{log:this.log}))),this.pause(!0).catch(e=>{this.log.error("error attempting to close server once connection count over limit",e)})])}async resume(){if(this.server.listening||this.status.code===R.INACTIVE)return;let e=this.status.netConfig;await new Promise((t,n)=>{this.server.once("error",n),this.server.listen(e,t)}),this.status={...this.status,code:R.ACTIVE},this.log("Listening on %s",this.server.address())}async pause(e){if(!this.server.listening&&this.status.code===R.PAUSED&&e){this.status={code:R.INACTIVE};return}!this.server.listening||this.status.code!==R.ACTIVE||(this.log("Closing server on %s",this.server.address()),this.status=e?{code:R.INACTIVE}:{...this.status,code:R.PAUSED},await new Promise((t,n)=>{this.server.close(o=>{o!=null?n(o):t()})}))}};var ur=class{opts;metrics;components;log;constructor(e,t={}){this.log=e.logger.forComponent("libp2p:tcp"),this.opts=t,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"})})}[gr]=!0;[Symbol.toStringTag]="@libp2p/tcp";async dial(e,t){t.keepAlive=t.keepAlive??!0,t.noDelay=t.noDelay??!0;let n=await this._connect(e,t);n.on("error",c=>{this.log("socket error",c)});let o=Je(n,{remoteAddr:e,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents,logger:this.components.logger}),s=()=>{o.close().catch(c=>{this.log.error("Error closing maConn after abort",c)})};t.signal?.addEventListener("abort",s,{once:!0}),this.log("new outbound connection %s",o.remoteAddr);let i=await t.upgrader.upgradeOutbound(o);if(this.log("outbound connection %s upgraded",o.remoteAddr),t.signal?.removeEventListener("abort",s),t.signal?.aborted===!0)throw i.close().catch(c=>{this.log.error("Error closing conn after abort",c)}),new ce;return i}async _connect(e,t){if(t.signal?.aborted===!0)throw new ce;return new Promise((n,o)=>{let s=Date.now(),i=Se(e,{...this.opts.dialOpts??{},...t});this.log("dialing %a",e);let c=zn.default.connect(i),l=h=>{let a=i.path??`${i.host??""}:${i.port}`;h.message=`connection error ${a}: ${h.message}`,this.metrics?.dialerEvents.increment({error:!0}),x(h)},f=()=>{this.log("connection timeout %a",e),this.metrics?.dialerEvents.increment({timeout:!0});let h=new O(`connection timeout after ${Date.now()-s}ms`,"ERR_CONNECT_TIMEOUT");c.emit("error",h)},u=()=>{this.log("connection opened %a",e),this.metrics?.dialerEvents.increment({connect:!0}),x()},y=()=>{this.log("connection aborted %a",e),this.metrics?.dialerEvents.increment({abort:!0}),c.destroy(),x(new ce)},x=h=>{if(c.removeListener("error",l),c.removeListener("timeout",f),c.removeListener("connect",u),t.signal!=null&&t.signal.removeEventListener("abort",y),h!=null){o(h);return}n(c)};c.on("error",l),c.on("timeout",f),c.on("connect",u),t.signal!=null&&t.signal.addEventListener("abort",y)})}createListener(e){return new Xe({...this.opts.listenOpts??{},...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,logger:this.components.logger})}filter(e){return e=Array.isArray(e)?e:[e],e.filter(t=>t.protoCodes().includes(290)?!1:t.protoCodes().includes(400)?!0:K.matches(t.decapsulateCode(421)))}};function ec(r={}){return e=>new ur(e,r)}return Gn(tc);})();
|
|
3
3
|
return Libp2PTcp}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/tcp",
|
|
3
|
-
"version": "9.0.8-
|
|
3
|
+
"version": "9.0.8-5d1f68e92",
|
|
4
4
|
"description": "A TCP transport for libp2p",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/transport-tcp#readme",
|
|
@@ -55,16 +55,16 @@
|
|
|
55
55
|
"test:electron-main": "aegir test -t electron-main"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@libp2p/interface": "1.0.2-
|
|
59
|
-
"@libp2p/utils": "5.1.0-
|
|
58
|
+
"@libp2p/interface": "1.0.2-5d1f68e92",
|
|
59
|
+
"@libp2p/utils": "5.1.0-5d1f68e92",
|
|
60
60
|
"@multiformats/mafmt": "^12.1.6",
|
|
61
61
|
"@multiformats/multiaddr": "^12.1.10",
|
|
62
62
|
"@types/sinon": "^17.0.0",
|
|
63
63
|
"stream-to-it": "^0.2.2"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@libp2p/interface-compliance-tests": "5.0.8-
|
|
67
|
-
"@libp2p/logger": "4.0.2-
|
|
66
|
+
"@libp2p/interface-compliance-tests": "5.0.8-5d1f68e92",
|
|
67
|
+
"@libp2p/logger": "4.0.2-5d1f68e92",
|
|
68
68
|
"aegir": "^41.0.2",
|
|
69
69
|
"it-all": "^3.0.3",
|
|
70
70
|
"it-pipe": "^3.0.1",
|