@libp2p/bootstrap 10.0.8-178fe2671 → 10.0.8-4e0135c7d
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.Libp2PBootstrap = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PBootstrap=(()=>{var Dt=Object.defineProperty;var Ir=Object.getOwnPropertyDescriptor;var Tr=Object.getOwnPropertyNames;var Pr=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var r in t)Dt(e,r,{get:t[r],enumerable:!0})},Cr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Tr(t))!Pr.call(e,o)&&o!==r&&Dt(e,o,{get:()=>t[o],enumerable:!(n=Ir(t,o))||n.enumerable});return e};var Dr=e=>Cr(Dt({},"__esModule",{value:!0}),e);var To={};v(To,{bootstrap:()=>Io});var Co=Symbol.for("@libp2p/connection");var Uo=Symbol.for("@libp2p/content-routing");var ve=Symbol.for("@libp2p/peer-discovery");var Ee=Symbol.for("@libp2p/peer-id");var Mo=Symbol.for("@libp2p/peer-routing");var Ae;(function(e){e.Accept="accept",e.Ignore="ignore",e.Reject="reject"})(Ae||(Ae={}));var _o=Symbol.for("@libp2p/transport");var Ie;(function(e){e[e.FATAL_ALL=0]="FATAL_ALL",e[e.NO_FATAL=1]="NO_FATAL"})(Ie||(Ie={}));var at=class extends Error{code;props;constructor(t,r,n){super(t),this.code=r,this.name=n?.name??"CodeError",this.props=n??{}}};var gt=class extends EventTarget{#t=new Map;listenerCount(t){let r=this.#t.get(t);return r==null?0:r.length}addEventListener(t,r,n){super.addEventListener(t,r,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:r,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,r,n){super.removeEventListener(t.toString(),r??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==r),this.#t.set(t,o))}dispatchEvent(t){let r=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),r}safeDispatchEvent(t,r){return this.dispatchEvent(new Ur(t,r))}},Ut=class extends Event{detail;constructor(t,r){super(t,r),this.detail=r?.detail}},Ur=globalThis.CustomEvent??Ut;var Mt={};v(Mt,{base58btc:()=>w,base58flickr:()=>kr});function Nr(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");r[a]=o}var p=e.length,f=e.charAt(0),b=Math.log(p)/Math.log(256),g=Math.log(256)/Math.log(p);function I(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return"";for(var y=0,j=0,T=0,D=u.length;T!==D&&u[T]===0;)T++,y++;for(var U=(D-T)*g+1>>>0,A=new Uint8Array(U);T!==D;){for(var N=u[T],O=0,P=U-1;(N!==0||O<j)&&P!==-1;P--,O++)N+=256*A[P]>>>0,A[P]=N%p>>>0,N=N/p>>>0;if(N!==0)throw new Error("Non-zero carry");j=O,T++}for(var R=U-j;R!==U&&A[R]===0;)R++;for(var mt=f.repeat(y);R<U;++R)mt+=e.charAt(A[R]);return mt}function B(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var y=0;if(u[y]!==" "){for(var j=0,T=0;u[y]===f;)j++,y++;for(var D=(u.length-y)*b+1>>>0,U=new Uint8Array(D);u[y];){var A=r[u.charCodeAt(y)];if(A===255)return;for(var N=0,O=D-1;(A!==0||N<T)&&O!==-1;O--,N++)A+=p*U[O]>>>0,U[O]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");T=N,y++}if(u[y]!==" "){for(var P=D-T;P!==D&&U[P]===0;)P++;for(var R=new Uint8Array(j+(D-P)),mt=j;P!==D;)R[mt++]=U[P++];return R}}}function E(u){var y=B(u);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:I,decodeUnsafe:B,decode:E}}var Lr=Nr,Rr=Lr,Te=Rr;var xs=new Uint8Array(0);var Pe=(e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0},F=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};var Ce=e=>new TextEncoder().encode(e),De=e=>new TextDecoder().decode(e);var Nt=class{constructor(t,r,n){this.name=t,this.prefix=r,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,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.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 Ne(this,t)}},Rt=class{constructor(t){this.decoders=t}or(t){return Ne(this,t)}decode(t){let r=t[0],n=this.decoders[r];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`)}},Ne=(e,t)=>new Rt({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}}),Ft=class{constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Nt(t,r,n),this.decoder=new Lt(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},X=({name:e,prefix:t,encode:r,decode:n})=>new Ft(e,t,r,n),_=({prefix:e,name:t,alphabet:r})=>{let{encode:n,decode:o}=Te(r,t);return X({prefix:e,name:t,encode:n,decode:s=>F(o(s))})},Fr=(e,t,r,n)=>{let o={};for(let g=0;g<t.length;++g)o[t[g]]=g;let s=e.length;for(;e[s-1]==="=";)--s;let a=new Uint8Array(s*r/8|0),p=0,f=0,b=0;for(let g=0;g<s;++g){let I=o[e[g]];if(I===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<r|I,p+=r,p>=8&&(p-=8,a[b++]=255&f>>p)}if(p>=r||255&f<<8-p)throw new SyntaxError("Unexpected end of data");return a},Mr=(e,t,r)=>{let n=t[t.length-1]==="=",o=(1<<r)-1,s="",a=0,p=0;for(let f=0;f<e.length;++f)for(p=p<<8|e[f],a+=8;a>r;)a-=r,s+=t[o&p>>a];if(a&&(s+=t[o&p<<r-a]),n)for(;s.length*r&7;)s+="=";return s},h=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>X({prefix:t,name:e,encode(o){return Mr(o,n,r)},decode(o){return Fr(o,n,r,e)}});var w=_({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),kr=_({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var kt={};v(kt,{base10:()=>Br});var Br=_({prefix:"9",name:"base10",alphabet:"0123456789"});var Bt={};v(Bt,{base16:()=>Or,base16upper:()=>_r});var Or=h({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),_r=h({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ot={};v(Ot,{base2:()=>zr});var zr=h({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var _t={};v(_t,{base256emoji:()=>Gr});var Le=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}"),Vr=Le.reduce((e,t,r)=>(e[r]=t,e),[]),$r=Le.reduce((e,t,r)=>(e[t.codePointAt(0)]=r,e),[]);function jr(e){return e.reduce((t,r)=>(t+=Vr[r],t),"")}function qr(e){let t=[];for(let r of e){let n=$r[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);t.push(n)}return new Uint8Array(t)}var Gr=X({prefix:"\u{1F680}",name:"base256emoji",encode:jr,decode:qr});var zt={};v(zt,{base32:()=>M,base32hex:()=>Jr,base32hexpad:()=>Qr,base32hexpadupper:()=>Yr,base32hexupper:()=>Xr,base32pad:()=>Kr,base32padupper:()=>Hr,base32upper:()=>Wr,base32z:()=>Zr});var M=h({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Wr=h({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Kr=h({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Hr=h({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Jr=h({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Xr=h({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Qr=h({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Yr=h({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Zr=h({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Vt={};v(Vt,{base36:()=>tn,base36upper:()=>en});var tn=_({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),en=_({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var $t={};v($t,{base64:()=>rn,base64pad:()=>nn,base64url:()=>on,base64urlpad:()=>sn});var rn=h({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),nn=h({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),on=h({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),sn=h({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var jt={};v(jt,{base8:()=>an});var an=h({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var qt={};v(qt,{identity:()=>cn});var cn=X({prefix:"\0",name:"identity",encode:e=>De(e),decode:e=>Ce(e)});var Rs=new TextEncoder,Fs=new TextDecoder;var Wt={};v(Wt,{identity:()=>xt});var ln=Me,Re=128,dn=127,fn=~dn,hn=Math.pow(2,31);function Me(e,t,r){t=t||[],r=r||0;for(var n=r;e>=hn;)t[r++]=e&255|Re,e/=128;for(;e&fn;)t[r++]=e&255|Re,e>>>=7;return t[r]=e|0,Me.bytes=r-n+1,t}var mn=Gt,gn=128,Fe=127;function Gt(e,n){var r=0,n=n||0,o=0,s=n,a,p=e.length;do{if(s>=p)throw Gt.bytes=0,new RangeError("Could not decode varint");a=e[s++],r+=o<28?(a&Fe)<<o:(a&Fe)*Math.pow(2,o),o+=7}while(a>=gn);return Gt.bytes=s-n,r}var wn=Math.pow(2,7),xn=Math.pow(2,14),bn=Math.pow(2,21),yn=Math.pow(2,28),Sn=Math.pow(2,35),vn=Math.pow(2,42),En=Math.pow(2,49),An=Math.pow(2,56),In=Math.pow(2,63),Tn=function(e){return e<wn?1:e<xn?2:e<bn?3:e<yn?4:e<Sn?5:e<vn?6:e<En?7:e<An?8:e<In?9:10},Pn={encode:ln,decode:mn,encodingLength:Tn},Cn=Pn,ct=Cn;var pt=(e,t=0)=>[ct.decode(e,t),ct.decode.bytes],Q=(e,t,r=0)=>(ct.encode(e,t,r),t),Y=e=>ct.encodingLength(e);var z=(e,t)=>{let r=t.byteLength,n=Y(e),o=n+Y(r),s=new Uint8Array(o+r);return Q(e,s,0),Q(r,s,n),s.set(t,o),new Z(e,r,t,s)},q=e=>{let t=F(e),[r,n]=pt(t),[o,s]=pt(t.subarray(n)),a=t.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new Z(r,o,a,t)},ke=(e,t)=>{if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Pe(e.bytes,r.bytes)}},Z=class{constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};var Be=0,Dn="identity",Oe=F,Un=e=>z(Be,Oe(e)),xt={code:Be,name:Dn,encode:Oe,digest:Un};var Jt={};v(Jt,{sha256:()=>bt,sha512:()=>Nn});var Ht=({name:e,code:t,encode:r})=>new Kt(e,t,r),Kt=class{constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?z(this.code,r):r.then(n=>z(this.code,n))}else throw Error("Unknown type, must be binary type")}};var ze=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),bt=Ht({name:"sha2-256",code:18,encode:ze("SHA-256")}),Nn=Ht({name:"sha2-512",code:19,encode:ze("SHA-512")});var Ve=(e,t)=>{let{bytes:r,version:n}=e;switch(n){case 0:return Rn(r,Xt(e),t||w.encoder);default:return Fn(r,Xt(e),t||M.encoder)}};var $e=new WeakMap,Xt=e=>{let t=$e.get(e);if(t==null){let r=new Map;return $e.set(e,r),r}return t},C=class e{constructor(t,r,n,o){this.code=r,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:r}=this;if(t!==ut)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Mn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=z(t,r);return e.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 e.equals(this,t)}static equals(t,r){let n=r;return n&&t.code===n.code&&t.version===n.version&&ke(t.multihash,n.multihash)}toString(t){return Ve(this,t)}toJSON(){return{"/":Ve(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 r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:a}=r;return new e(n,o,s,a||je(n,o,s.bytes))}else if(r[kn]===!0){let{version:n,multihash:o,code:s}=r,a=q(o);return e.create(n,s,a)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==ut)throw new Error(`Version 0 CID must use dag-pb (code: ${ut}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=je(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,ut,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=F(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),a=new Z(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(a):e.createV1(r.codec,a),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[I,B]=pt(t.subarray(r));return r+=B,I},o=n(),s=ut;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,p=n(),f=n(),b=r+f,g=b-a;return{version:o,codec:s,multihashCode:p,digestSize:f,multihashSize:g,size:b}}static parse(t,r){let[n,o]=Ln(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Xt(s).set(n,t),s}},Ln=(e,t)=>{switch(e[0]){case"Q":{let r=t||w;return[w.prefix,r.decode(`${w.prefix}${e}`)]}case w.prefix:{let r=t||w;return[w.prefix,r.decode(e)]}case M.prefix:{let r=t||M;return[M.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}},Rn=(e,t,r)=>{let{prefix:n}=r;if(n!==w.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o},Fn=(e,t,r)=>{let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o},ut=112,Mn=18,je=(e,t,r)=>{let n=Y(e),o=n+Y(t),s=new Uint8Array(o+r.byteLength);return Q(e,s,0),Q(t,s,n),s.set(r,o),s},kn=Symbol.for("@ipld/js-cid/CID");var V={...qt,...Ot,...jt,...kt,...Bt,...zt,...Vt,...Mt,...$t,..._t},Xs={...Jt,...Wt};function Qt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}var Bn=Symbol.for("nodejs.util.inspect.custom"),qe=Object.values(V).map(e=>e.decoder).reduce((e,t)=>e.or(t),V.identity.decoder),Ge=114,We=36,Ke=37,lt=class{type;multihash;privateKey;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Ee]=!0;toString(){return this.string==null&&(this.string=w.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return C.createV1(Ge,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t instanceof Uint8Array)return Qt(this.multihash.bytes,t);if(typeof t=="string")return Yt(t).equals(this);if(t?.multihash?.bytes!=null)return Qt(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Bn](){return`PeerId(${this.toString()})`}},dt=class extends lt{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},ft=class extends lt{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.multihash.digest}},ht=class extends lt{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.multihash.digest}};function Yt(e,t){if(t=t??qe,e.charAt(0)==="1"||e.charAt(0)==="Q"){let r=q(w.decode(`z${e}`));return e.startsWith("12D")?new ft({multihash:r}):e.startsWith("16U")?new ht({multihash:r}):new dt({multihash:r})}return On(qe.decode(e))}function On(e){try{let t=q(e);if(t.code===xt.code){if(t.digest.length===We)return new ft({multihash:t});if(t.digest.length===Ke)return new ht({multihash:t})}if(t.code===bt.code)return new dt({multihash:t})}catch{return _n(C.decode(e))}throw new Error("Supplied PeerID CID is invalid")}function _n(e){if(e==null||e.multihash==null||e.version==null||e.version===1&&e.code!==Ge)throw new Error("Supplied PeerID CID is invalid");let t=e.multihash;if(t.code===bt.code)return new dt({multihash:e.multihash});if(t.code===xt.code){if(t.digest.length===We)return new ft({multihash:e.multihash});if(t.digest.length===Ke)return new ht({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}function He(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function tt(e){return globalThis.Buffer!=null?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function et(e=0){return globalThis.Buffer?.allocUnsafe!=null?tt(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function Xe(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Je=Xe("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Zt=Xe("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=et(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),zn={utf8:Je,"utf-8":Je,hex:V.base16,latin1:Zt,ascii:Zt,binary:Zt,...V},yt=zn;function S(e,t="utf8"){let r=yt[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8"):r.encoder.encode(e).substring(1)}var Vn=Math.pow(2,7),$n=Math.pow(2,14),jn=Math.pow(2,21),te=Math.pow(2,28),ee=Math.pow(2,35),re=Math.pow(2,42),ne=Math.pow(2,49),l=128,x=127;function L(e){if(e<Vn)return 1;if(e<$n)return 2;if(e<jn)return 3;if(e<te)return 4;if(e<ee)return 5;if(e<re)return 6;if(e<ne)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function qn(e,t,r=0){switch(L(e)){case 8:t[r++]=e&255|l,e/=128;case 7:t[r++]=e&255|l,e/=128;case 6:t[r++]=e&255|l,e/=128;case 5:t[r++]=e&255|l,e/=128;case 4:t[r++]=e&255|l,e>>>=7;case 3:t[r++]=e&255|l,e>>>=7;case 2:t[r++]=e&255|l,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Gn(e,t,r=0){switch(L(e)){case 8:t.set(r++,e&255|l),e/=128;case 7:t.set(r++,e&255|l),e/=128;case 6:t.set(r++,e&255|l),e/=128;case 5:t.set(r++,e&255|l),e/=128;case 4:t.set(r++,e&255|l),e>>>=7;case 3:t.set(r++,e&255|l),e>>>=7;case 2:t.set(r++,e&255|l),e>>>=7;case 1:{t.set(r++,e&255),e>>>=7;break}default:throw new Error("unreachable")}return t}function Wn(e,t){let r=e[t],n=0;if(n+=r&x,r<l||(r=e[t+1],n+=(r&x)<<7,r<l)||(r=e[t+2],n+=(r&x)<<14,r<l)||(r=e[t+3],n+=(r&x)<<21,r<l)||(r=e[t+4],n+=(r&x)*te,r<l)||(r=e[t+5],n+=(r&x)*ee,r<l)||(r=e[t+6],n+=(r&x)*re,r<l)||(r=e[t+7],n+=(r&x)*ne,r<l))return n;throw new RangeError("Could not decode varint")}function Kn(e,t){let r=e.get(t),n=0;if(n+=r&x,r<l||(r=e.get(t+1),n+=(r&x)<<7,r<l)||(r=e.get(t+2),n+=(r&x)<<14,r<l)||(r=e.get(t+3),n+=(r&x)<<21,r<l)||(r=e.get(t+4),n+=(r&x)*te,r<l)||(r=e.get(t+5),n+=(r&x)*ee,r<l)||(r=e.get(t+6),n+=(r&x)*re,r<l)||(r=e.get(t+7),n+=(r&x)*ne,r<l))return n;throw new RangeError("Could not decode varint")}function rt(e,t,r=0){return t==null&&(t=et(L(e))),t instanceof Uint8Array?qn(e,t,r):Gn(e,t,r)}function W(e,t=0){return e instanceof Uint8Array?Wn(e,t):Kn(e,t)}function k(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=et(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return tt(r)}var St=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let s=0,a=0,p=this.peekChar();if(p===void 0)return;let f=p==="0",b=2**(8*o)-1;for(;;){let g=this.readAtomically(()=>{let I=this.readChar();if(I===void 0)return;let B=Number.parseInt(I,t);if(!Number.isNaN(B))return B});if(g===void 0)break;if(s*=t,s+=g,s>b||(a+=1,r!==void 0&&a>r))return}if(a!==0)return!n&&f&&a>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let a=this.readSeparator(":",n,()=>this.readIPv4Addr());if(a!==void 0)return r[o]=a[0],r[o+1]=a[1],r[o+2]=a[2],r[o+3]=a[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];r[o]=s>>8,r[o+1]=s&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),a=16-(n+2),[p]=t(s.subarray(0,a));return r.set(s.subarray(0,p),16-p),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Ye=45,Hn=15,nt=new St;function oe(e){if(!(e.length>Hn))return nt.new(e).parseWith(()=>nt.readIPv4Addr())}function se(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Ye))return nt.new(e).parseWith(()=>nt.readIPv6Addr())}function vt(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Ye))return nt.new(e).parseWith(()=>nt.readIPAddr())}var Ui=parseInt("0xFFFF",16),Ni=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function ie(e,t="utf8"){let r=yt[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?tt(globalThis.Buffer.from(e,"utf-8")):r.decoder.decode(`${r.prefix}${e}`)}function er(e){return!!oe(e)}function rr(e){return!!se(e)}function Et(e){return!!vt(e)}var nr=er,Zn=rr,ae=function(e){let t=0;if(e=e.toString().trim(),nr(e)){let r=new Uint8Array(t+4);return e.split(/\./g).forEach(n=>{r[t++]=parseInt(n,10)&255}),r}if(Zn(e)){let r=e.split(":",8),n;for(n=0;n<r.length;n++){let s=nr(r[n]),a;s&&(a=ae(r[n]),r[n]=S(a.slice(0,2),"base16")),a!=null&&++n<8&&r.splice(n,0,S(a.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let s=[n,1];for(n=9-r.length;n>0;n--)s.push("0");r.splice.apply(r,s)}let o=new Uint8Array(t+16);for(n=0;n<r.length;n++){let s=parseInt(r[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},or=function(e,t=0,r){t=~~t,r=r??e.length-t;let n=new DataView(e.buffer);if(r===4){let o=[];for(let s=0;s<r;s++)o.push(e[t+s]);return o.join(".")}if(r===16){let o=[];for(let s=0;s<r;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var ot={},ce={},eo=[[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"]];eo.forEach(e=>{let t=ro(...e);ce[t.code]=t,ot[t.name]=t});function ro(e,t,r,n,o){return{code:e,size:t,name:r,resolvable:!!n,path:!!o}}function d(e){if(typeof e=="number"){if(ce[e]!=null)return ce[e];throw new Error(`no protocol with code: ${e}`)}else if(typeof e=="string"){if(ot[e]!=null)return ot[e];throw new Error(`no protocol with name: ${e}`)}throw new Error(`invalid protocol id type: ${typeof e}`)}var wa=d("ip4"),xa=d("ip6"),ba=d("ipcidr");function ue(e,t){switch(d(e).code){case 4:case 41:return oo(t);case 42:return ar(t);case 6:case 273:case 33:case 132:return pr(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ar(t);case 421:return co(t);case 444:return cr(t);case 445:return cr(t);case 466:return ao(t);default:return S(t,"base16")}}function le(e,t){switch(d(e).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 de(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ir(t);case 421:return so(t);case 444:return po(t);case 445:return uo(t);case 466:return io(t);default:return ie(t,"base16")}}var pe=Object.values(V).map(e=>e.decoder),no=function(){let e=pe[0].or(pe[1]);return pe.slice(2).forEach(t=>e=e.or(t)),e}();function sr(e){if(!Et(e))throw new Error("invalid ip address");return ae(e)}function oo(e){let t=or(e,0,e.length);if(t==null)throw new Error("ipBuff is required");if(!Et(t))throw new Error("invalid ip address");return t}function de(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function pr(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function ir(e){let t=ie(e),r=Uint8Array.from(rt(t.length));return k([r,t],r.length+t.length)}function ar(e){let t=W(e);if(e=e.slice(L(t)),e.length!==t)throw new Error("inconsistent lengths");return S(e)}function so(e){let t;e[0]==="Q"||e[0]==="1"?t=q(w.decode(`z${e}`)).bytes:t=C.parse(e).multihash.bytes;let r=Uint8Array.from(rt(t.length));return k([r,t],r.length+t.length)}function io(e){let t=no.decode(e),r=Uint8Array.from(rt(t.length));return k([r,t],r.length+t.length)}function ao(e){let t=W(e),r=e.slice(L(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+S(r,"base64url")}function co(e){let t=W(e),r=e.slice(L(t));if(r.length!==t)throw new Error("inconsistent lengths");return S(r,"base58btc")}function po(e){let t=e.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 r=M.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=de(n);return k([r,o],r.length+o.length)}function uo(e){let t=e.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 r=M.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=de(n);return k([r,o],r.length+o.length)}function cr(e){let t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=S(t,"base32"),o=pr(r);return`${n}:${o}`}function ur(e){e=fe(e);let t=[],r=[],n=null,o=e.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 a=o[s],p=d(a);if(p.size===0){t.push([p.code]),r.push([p.code]);continue}if(s++,s>=o.length)throw dr("invalid address: "+e);if(p.path===!0){n=fe(o.slice(s).join("/")),t.push([p.code,le(p.code,n)]),r.push([p.code,n]);break}let f=le(p.code,o[s]);t.push([p.code,f]),r.push([p.code,ue(p.code,f)])}return{string:lr(r),bytes:me(t),tuples:t,stringTuples:r,path:n}}function he(e){let t=[],r=[],n=null,o=0;for(;o<e.length;){let s=W(e,o),a=L(s),p=d(s),f=lo(p,e.slice(o+a));if(f===0){t.push([s]),r.push([s]),o+=a;continue}let b=e.slice(o+a,o+a+f);if(o+=f+a,o>e.length)throw dr("Invalid address Uint8Array: "+S(e,"base16"));t.push([s,b]);let g=ue(s,b);if(r.push([s,g]),p.path===!0){n=g;break}}return{bytes:Uint8Array.from(e),string:lr(r),tuples:t,stringTuples:r,path:n}}function lr(e){let t=[];return e.map(r=>{let n=d(r[0]);return t.push(n.name),r.length>1&&r[1]!=null&&t.push(r[1]),null}),fe(t.join("/"))}function me(e){return k(e.map(t=>{let r=d(t[0]),n=Uint8Array.from(rt(r.code));return t.length>1&&t[1]!=null&&(n=k([n,t[1]])),n}))}function lo(e,t){if(e.size>0)return e.size/8;if(e.size===0)return 0;{let r=W(t instanceof Uint8Array?t:Uint8Array.from(t));return r+L(r)}}function fe(e){return"/"+e.trim().split("/").filter(t=>t).join("/")}function dr(e){return new Error("Error parsing address: "+e)}var fo=Symbol.for("nodejs.util.inspect.custom"),ge=Symbol.for("@multiformats/js-multiaddr/multiaddr"),ho=[d("dns").code,d("dns4").code,d("dns6").code,d("dnsaddr").code],At=class e{bytes;#t;#e;#r;#n;[ge]=!0;constructor(t){t==null&&(t="");let r;if(t instanceof Uint8Array)r=he(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);r=ur(t)}else if(hr(t))r=he(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.bytes,this.#t=r.string,this.#e=r.tuples,this.#r=r.stringTuples,this.#n=r.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,r,n,o,s="",a=d("tcp"),p=d("udp"),f=d("ip4"),b=d("ip6"),g=d("dns6"),I=d("ip6zone");for(let[E,u]of this.stringTuples())E===I.code&&(s=`%${u??""}`),ho.includes(E)&&(r=a.name,o=443,n=`${u??""}${s}`,t=E===g.code?6:4),(E===a.code||E===p.code)&&(r=d(E).name,o=parseInt(u??"")),(E===f.code||E===b.code)&&(r=d(E).name,n=`${u??""}${s}`,t=E===b.code?6:4);if(t==null||r==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:r,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},d(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>d(t).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(t){return t=new e(t),new e(this.toString()+t.toString())}decapsulate(t){let r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new e(n.slice(0,o))}decapsulateCode(t){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===t)return new e(me(r.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===ot.p2p.code&&t.push([n,o]),n===ot["p2p-circuit"].code&&(t=[])});let r=t.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?S(w.decode(`z${n}`),"base58btc"):S(C.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return He(this.bytes,t.bytes)}async resolve(t){let r=this.protos().find(s=>s.resolvable);if(r==null)return[this];let n=fr.get(r.name);if(n==null)throw new at(`no available resolver for ${r.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(s=>new e(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 r=(t??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[fo](){return`Multiaddr(${this.#t})`}};var fr=new Map;function hr(e){return!!e?.[ge]}function st(e){return new At(e)}var mo=i("dns4"),go=i("dns6"),wo=i("dnsaddr"),H=m(i("dns"),wo,mo,go),Pt=m(i("ip4"),i("ip6")),it=m(c(Pt,i("tcp")),c(H,i("tcp"))),Ct=c(Pt,i("udp")),xo=c(Ct,i("utp")),bo=c(Ct,i("quic")),yo=c(Ct,i("quic-v1")),we=m(c(it,i("ws")),c(H,i("ws"))),It=m(c(we,i("p2p")),we),xe=m(c(it,i("wss")),c(H,i("wss")),c(it,i("tls"),i("ws")),c(H,i("tls"),i("ws"))),Tt=m(c(xe,i("p2p")),xe),be=m(c(it,i("http")),c(Pt,i("http")),c(H,i("http"))),ye=m(c(it,i("https")),c(Pt,i("https")),c(H,i("https"))),mr=c(Ct,i("webrtc-direct"),i("certhash")),xr=m(c(mr,i("p2p")),mr),gr=c(yo,i("webtransport"),i("certhash"),i("certhash")),br=m(c(gr,i("p2p")),gr),yr=m(c(It,i("p2p-webrtc-star"),i("p2p")),c(Tt,i("p2p-webrtc-star"),i("p2p")),c(It,i("p2p-webrtc-star")),c(Tt,i("p2p-webrtc-star"))),Ga=m(c(It,i("p2p-websocket-star"),i("p2p")),c(Tt,i("p2p-websocket-star"),i("p2p")),c(It,i("p2p-websocket-star")),c(Tt,i("p2p-websocket-star"))),Sr=m(c(be,i("p2p-webrtc-direct"),i("p2p")),c(ye,i("p2p-webrtc-direct"),i("p2p")),c(be,i("p2p-webrtc-direct")),c(ye,i("p2p-webrtc-direct"))),J=m(we,xe,be,ye,yr,Sr,it,xo,bo,H,xr,br),Wa=m(c(J,i("p2p-stardust"),i("p2p")),c(J,i("p2p-stardust"))),$=m(c(J,i("p2p")),yr,Sr,xr,br,i("p2p")),wr=m(c($,i("p2p-circuit"),$),c($,i("p2p-circuit")),c(i("p2p-circuit"),$),c(J,i("p2p-circuit")),c(i("p2p-circuit"),J),i("p2p-circuit")),vr=()=>m(c(wr,vr),wr),K=vr(),Er=m(c(K,$,K),c($,K),c(K,$),K,$);var Ka=m(c(K,i("webrtc"),i("p2p")),c(K,i("webrtc")),c(J,i("webrtc"),i("p2p")),c(J,i("webrtc")),i("webrtc"));function Ar(e){function t(r){let n;try{n=st(r)}catch{return!1}let o=e(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function c(...e){function t(r){if(r.length<e.length)return null;let n=r;return e.some(o=>(n=typeof o=="function"?o().partialMatch(r):o.partialMatch(r),Array.isArray(n)&&(r=n),n===null)),n}return{toString:function(){return"{ "+e.join(" ")+" }"},input:e,matches:Ar(t),partialMatch:t}}function m(...e){function t(n){let o=null;return e.some(s=>{let a=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return a!=null?(o=a,!0):!1}),o}return{toString:function(){return"{ "+e.join(" ")+" }"},input:e,matches:Ar(t),partialMatch:t}}function i(e){let t=e;function r(o){let s;try{s=st(o)}catch{return!1}let a=s.protoNames();return a.length===1&&a[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:r,partialMatch:n}}var So="bootstrap",vo=50,Eo=12e4,Ao=1e3,Se=class extends gt{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(t,r={list:[]}){if(r.list==null||r.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super(),this.components=t,this.log=t.logger.forComponent("libp2p:bootstrap"),this.timeout=r.timeout??Ao,this.list=[];for(let n of r.list){if(!Er.matches(n)){this.log.error("Invalid multiaddr");continue}let o=st(n),s=o.getPeerId();if(s==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let a={id:Yt(s),multiaddrs:[o]};this.list.push(a)}this._init=r}[ve]=this;[Symbol.toStringTag]="@libp2p/bootstrap";isStarted(){return!!this.timer}start(){this.isStarted()||(this.log("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(t=>{this.log.error(t)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(let t of this.list){if(await this.components.peerStore.merge(t.id,{tags:{[this._init.tagName??So]:{value:this._init.tagValue??vo,ttl:this._init.tagTTL??Eo}}}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function Io(e){return t=>new Se(t,e)}return Dr(To);})();
|
|
2
|
+
"use strict";var Libp2PBootstrap=(()=>{var at=Object.defineProperty;var No=Object.getOwnPropertyDescriptor;var Lo=Object.getOwnPropertyNames;var Mo=Object.prototype.hasOwnProperty;var m=(r,e)=>{for(var t in e)at(r,t,{get:e[t],enumerable:!0})},zo=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Lo(e))!Mo.call(r,o)&&o!==t&&at(r,o,{get:()=>e[o],enumerable:!(n=No(e,o))||n.enumerable});return r};var Ro=r=>zo(at({},"__esModule",{value:!0}),r);var _c={};m(_c,{bootstrap:()=>qc});var Gc=Symbol.for("@libp2p/connection");var Xc=Symbol.for("@libp2p/content-routing");var jr=Symbol.for("@libp2p/peer-discovery");var qr=Symbol.for("@libp2p/peer-id");var Zc=Symbol.for("@libp2p/peer-routing");var _r;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(_r||(_r={}));var np=Symbol.for("@libp2p/transport");var Jr;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Jr||(Jr={}));var Te=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var _e=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 Fo(e,t))}},ct=class extends Event{detail;constructor(e,t){super(e,t),this.detail=t?.detail}},Fo=globalThis.CustomEvent??ct;var ut={};m(ut,{base58btc:()=>O,base58flickr:()=>jo});var Rp=new Uint8Array(0);function Gr(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function $(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Wr(r){return new TextEncoder().encode(r)}function Xr(r){return new TextDecoder().decode(r)}function Bo(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var a=r.length,d=r.charAt(0),A=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function C(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";for(var u=0,D=0,b=0,w=c.length;b!==w&&c[b]===0;)b++,u++;for(var g=(w-b)*h+1>>>0,l=new Uint8Array(g);b!==w;){for(var y=c[b],I=0,x=g-1;(y!==0||I<D)&&x!==-1;x--,I++)y+=256*l[x]>>>0,l[x]=y%a>>>0,y=y/a>>>0;if(y!==0)throw new Error("Non-zero carry");D=I,b++}for(var S=g-D;S!==g&&l[S]===0;)S++;for(var R=d.repeat(u);S<g;++S)R+=r.charAt(l[S]);return R}function L(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;var u=0;if(c[u]!==" "){for(var D=0,b=0;c[u]===d;)D++,u++;for(var w=(c.length-u)*A+1>>>0,g=new Uint8Array(w);c[u];){var l=t[c.charCodeAt(u)];if(l===255)return;for(var y=0,I=w-1;(l!==0||y<b)&&I!==-1;I--,y++)l+=a*g[I]>>>0,g[I]=l%256>>>0,l=l/256>>>0;if(l!==0)throw new Error("Non-zero carry");b=y,u++}if(c[u]!==" "){for(var x=w-b;x!==w&&g[x]===0;)x++;for(var S=new Uint8Array(D+(w-x)),R=D;x!==w;)S[R++]=g[x++];return S}}}function M(c){var u=L(c);if(u)return u;throw new Error(`Non-${e} character`)}return{encode:C,decodeUnsafe:L,decode:M}}var Oo=Bo,ko=Oo,Qr=ko;var pt=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},dt=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Hr(this,e)}},ft=class{decoders;constructor(e){this.decoders=e}or(e){return Hr(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Hr(r,e){return new ft({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var ht=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new pt(e,t,n),this.decoder=new dt(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function se({name:r,prefix:e,encode:t,decode:n}){return new ht(r,e,t,n)}function G({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=Qr(t,r);return se({prefix:e,name:r,encode:n,decode:s=>$(o(s))})}function Vo(r,e,t,n){let o={};for(let h=0;h<e.length;++h)o[e[h]]=h;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,d=0,A=0;for(let h=0;h<s;++h){let C=o[r[h]];if(C===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<t|C,a+=t,a>=8&&(a-=8,i[A++]=255&d>>a)}if(a>=t||255&d<<8-a)throw new SyntaxError("Unexpected end of data");return i}function $o(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let d=0;d<r.length;++d)for(a=a<<8|r[d],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s}function T({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return se({prefix:e,name:r,encode(o){return $o(o,n,t)},decode(o){return Vo(o,n,t,r)}})}var O=G({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),jo=G({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var lt={};m(lt,{base10:()=>qo});var qo=G({prefix:"9",name:"base10",alphabet:"0123456789"});var mt={};m(mt,{base16:()=>_o,base16upper:()=>Jo});var _o=T({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Jo=T({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var bt={};m(bt,{base2:()=>Go});var Go=T({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var xt={};m(xt,{base256emoji:()=>Ho});var Yr=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}"),Wo=Yr.reduce((r,e,t)=>(r[t]=e,r),[]),Xo=Yr.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Ko(r){return r.reduce((e,t)=>(e+=Wo[t],e),"")}function Qo(r){let e=[];for(let t of r){let n=Xo[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var Ho=se({prefix:"\u{1F680}",name:"base256emoji",encode:Ko,decode:Qo});var wt={};m(wt,{base32:()=>ie,base32hex:()=>ts,base32hexpad:()=>ns,base32hexpadupper:()=>os,base32hexupper:()=>rs,base32pad:()=>Zo,base32padupper:()=>es,base32upper:()=>Yo,base32z:()=>ss});var ie=T({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Yo=T({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Zo=T({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),es=T({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ts=T({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),rs=T({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ns=T({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),os=T({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ss=T({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var gt={};m(gt,{base36:()=>is,base36upper:()=>as});var is=G({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),as=G({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var yt={};m(yt,{base64:()=>cs,base64pad:()=>ps,base64url:()=>ds,base64urlpad:()=>fs});var cs=T({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ps=T({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ds=T({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),fs=T({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var vt={};m(vt,{base8:()=>hs});var hs=T({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var St={};m(St,{identity:()=>us});var us=se({prefix:"\0",name:"identity",encode:r=>Xr(r),decode:r=>Wr(r)});var Hp=new TextEncoder,Yp=new TextDecoder;var Et={};m(Et,{identity:()=>Ge});var bs=tn,Zr=128,xs=127,ws=~xs,gs=Math.pow(2,31);function tn(r,e,t){e=e||[],t=t||0;for(var n=t;r>=gs;)e[t++]=r&255|Zr,r/=128;for(;r&ws;)e[t++]=r&255|Zr,r>>>=7;return e[t]=r|0,tn.bytes=t-n+1,e}var ys=At,vs=128,en=127;function At(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw At.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&en)<<o:(i&en)*Math.pow(2,o),o+=7}while(i>=vs);return At.bytes=s-n,t}var Ss=Math.pow(2,7),As=Math.pow(2,14),Es=Math.pow(2,21),Is=Math.pow(2,28),Cs=Math.pow(2,35),Ds=Math.pow(2,42),Ts=Math.pow(2,49),Us=Math.pow(2,56),Ps=Math.pow(2,63),Ns=function(r){return r<Ss?1:r<As?2:r<Es?3:r<Is?4:r<Cs?5:r<Ds?6:r<Ts?7:r<Us?8:r<Ps?9:10},Ls={encode:bs,decode:ys,encodingLength:Ns},Ms=Ls,Ue=Ms;function Pe(r,e=0){return[Ue.decode(r,e),Ue.decode.bytes]}function ae(r,e,t=0){return Ue.encode(r,e,t),e}function ce(r){return Ue.encodingLength(r)}function W(r,e){let t=e.byteLength,n=ce(r),o=n+ce(t),s=new Uint8Array(o+t);return ae(r,s,0),ae(t,s,n),s.set(e,o),new pe(r,t,e,s)}function Ne(r){let e=$(r),[t,n]=Pe(e),[o,s]=Pe(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new pe(t,o,i,e)}function rn(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Gr(r.bytes,t.bytes)}}var pe=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var nn=0,zs="identity",on=$;function Rs(r){return W(nn,on(r))}var Ge={code:nn,name:zs,encode:on,digest:Rs};var Dt={};m(Dt,{sha256:()=>We,sha512:()=>Fs});function Ct({name:r,code:e,encode:t}){return new It(r,e,t)}var It=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?W(this.code,t):t.then(n=>W(this.code,n))}else throw Error("Unknown type, must be binary type")}};function an(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var We=Ct({name:"sha2-256",code:18,encode:an("SHA-256")}),Fs=Ct({name:"sha2-512",code:19,encode:an("SHA-512")});function cn(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Os(t,Tt(r),e??O.encoder);default:return ks(t,Tt(r),e??ie.encoder)}}var pn=new WeakMap;function Tt(r){let e=pn.get(r);if(e==null){let t=new Map;return pn.set(r,t),t}return e}var Y=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Le)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Vs)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=W(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&rn(e.multihash,n.multihash)}toString(e){return cn(this,e)}toJSON(){return{"/":cn(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new r(n,o,s,i??dn(n,o,s.bytes))}else if(t[$s]===!0){let{version:n,multihash:o,code:s}=t,i=Ne(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!==Le)throw new Error(`Version 0 CID must use dag-pb (code: ${Le}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=dn(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Le,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=$(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 pe(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[C,L]=Pe(e.subarray(t));return t+=L,C},o=n(),s=Le;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),d=n(),A=t+d,h=A-i;return{version:o,codec:s,multihashCode:a,digestSize:d,multihashSize:h,size:A}}static parse(e,t){let[n,o]=Bs(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 Tt(s).set(n,e),s}};function Bs(r,e){switch(r[0]){case"Q":{let t=e??O;return[O.prefix,t.decode(`${O.prefix}${r}`)]}case O.prefix:{let t=e??O;return[O.prefix,t.decode(r)]}case ie.prefix:{let t=e??ie;return[ie.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Os(r,e,t){let{prefix:n}=t;if(n!==O.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o}function ks(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o}var Le=112,Vs=18;function dn(r,e,t){let n=ce(r),o=n+ce(e),s=new Uint8Array(o+t.byteLength);return ae(r,s,0),ae(e,s,n),s.set(t,o),s}var $s=Symbol.for("@ipld/js-cid/CID");var Ut={...St,...bt,...vt,...lt,...mt,...wt,...gt,...ut,...yt,...xt},gd={...Dt,...Et};function Pt(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 js=Symbol.for("nodejs.util.inspect.custom"),fn=Object.values(Ut).map(r=>r.decoder).reduce((r,e)=>r.or(e),Ut.identity.decoder),hn=114,un=36,ln=37,Me=class{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[qr]=!0;toString(){return this.string==null&&(this.string=O.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Y.createV1(hn,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return Pt(this.multihash.bytes,e);if(typeof e=="string")return Nt(e).equals(this);if(e?.multihash?.bytes!=null)return Pt(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[js](){return`PeerId(${this.toString()})`}},ze=class extends Me{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Re=class extends Me{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Fe=class extends Me{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function Nt(r,e){if(e=e??fn,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=Ne(O.decode(`z${r}`));return r.startsWith("12D")?new Re({multihash:t}):r.startsWith("16U")?new Fe({multihash:t}):new ze({multihash:t})}return qs(fn.decode(r))}function qs(r){try{let e=Ne(r);if(e.code===Ge.code){if(e.digest.length===un)return new Re({multihash:e});if(e.digest.length===ln)return new Fe({multihash:e})}if(e.code===We.code)return new ze({multihash:e})}catch{return _s(Y.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function _s(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==hn)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===We.code)return new ze({multihash:r.multihash});if(e.code===Ge.code){if(e.digest.length===un)return new Re({multihash:r.multihash});if(e.digest.length===ln)return new Fe({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var Ft={};m(Ft,{base58btc:()=>F,base58flickr:()=>Qs});function Js(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var a=r.length,d=r.charAt(0),A=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function C(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";for(var u=0,D=0,b=0,w=c.length;b!==w&&c[b]===0;)b++,u++;for(var g=(w-b)*h+1>>>0,l=new Uint8Array(g);b!==w;){for(var y=c[b],I=0,x=g-1;(y!==0||I<D)&&x!==-1;x--,I++)y+=256*l[x]>>>0,l[x]=y%a>>>0,y=y/a>>>0;if(y!==0)throw new Error("Non-zero carry");D=I,b++}for(var S=g-D;S!==g&&l[S]===0;)S++;for(var R=d.repeat(u);S<g;++S)R+=r.charAt(l[S]);return R}function L(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;var u=0;if(c[u]!==" "){for(var D=0,b=0;c[u]===d;)D++,u++;for(var w=(c.length-u)*A+1>>>0,g=new Uint8Array(w);c[u];){var l=t[c.charCodeAt(u)];if(l===255)return;for(var y=0,I=w-1;(l!==0||y<b)&&I!==-1;I--,y++)l+=a*g[I]>>>0,g[I]=l%256>>>0,l=l/256>>>0;if(l!==0)throw new Error("Non-zero carry");b=y,u++}if(c[u]!==" "){for(var x=w-b;x!==w&&g[x]===0;)x++;for(var S=new Uint8Array(D+(w-x)),R=D;x!==w;)S[R++]=g[x++];return S}}}function M(c){var u=L(c);if(u)return u;throw new Error(`Non-${e} character`)}return{encode:C,decodeUnsafe:L,decode:M}}var Gs=Js,Ws=Gs,mn=Ws;var Ld=new Uint8Array(0);var bn=(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},j=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 xn=r=>new TextEncoder().encode(r),wn=r=>new TextDecoder().decode(r);var Lt=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")}},Mt=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 yn(this,e)}},zt=class{constructor(e){this.decoders=e}or(e){return yn(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`)}},yn=(r,e)=>new zt({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),Rt=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Lt(e,t,n),this.decoder=new Mt(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},fe=({name:r,prefix:e,encode:t,decode:n})=>new Rt(r,e,t,n),X=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=mn(t,e);return fe({prefix:r,name:e,encode:n,decode:s=>j(o(s))})},Xs=(r,e,t,n)=>{let o={};for(let h=0;h<e.length;++h)o[e[h]]=h;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,d=0,A=0;for(let h=0;h<s;++h){let C=o[r[h]];if(C===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<t|C,a+=t,a>=8&&(a-=8,i[A++]=255&d>>a)}if(a>=t||255&d<<8-a)throw new SyntaxError("Unexpected end of data");return i},Ks=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let d=0;d<r.length;++d)for(a=a<<8|r[d],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s},U=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>fe({prefix:e,name:r,encode(o){return Ks(o,n,t)},decode(o){return Xs(o,n,t,r)}});var F=X({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Qs=X({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Bt={};m(Bt,{base32:()=>q,base32hex:()=>ei,base32hexpad:()=>ri,base32hexpadupper:()=>ni,base32hexupper:()=>ti,base32pad:()=>Ys,base32padupper:()=>Zs,base32upper:()=>Hs,base32z:()=>oi});var q=U({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Hs=U({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ys=U({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Zs=U({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ei=U({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ti=U({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ri=U({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ni=U({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),oi=U({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var si=An,vn=128,ii=127,ai=~ii,ci=Math.pow(2,31);function An(r,e,t){e=e||[],t=t||0;for(var n=t;r>=ci;)e[t++]=r&255|vn,r/=128;for(;r&ai;)e[t++]=r&255|vn,r>>>=7;return e[t]=r|0,An.bytes=t-n+1,e}var pi=Ot,di=128,Sn=127;function Ot(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Ot.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Sn)<<o:(i&Sn)*Math.pow(2,o),o+=7}while(i>=di);return Ot.bytes=s-n,t}var fi=Math.pow(2,7),hi=Math.pow(2,14),ui=Math.pow(2,21),li=Math.pow(2,28),mi=Math.pow(2,35),bi=Math.pow(2,42),xi=Math.pow(2,49),wi=Math.pow(2,56),gi=Math.pow(2,63),yi=function(r){return r<fi?1:r<hi?2:r<ui?3:r<li?4:r<mi?5:r<bi?6:r<xi?7:r<wi?8:r<gi?9:10},vi={encode:si,decode:pi,encodingLength:yi},Si=vi,Be=Si;var Oe=(r,e=0)=>[Be.decode(r,e),Be.decode.bytes],he=(r,e,t=0)=>(Be.encode(r,e,t),e),ue=r=>Be.encodingLength(r);var Z=(r,e)=>{let t=e.byteLength,n=ue(r),o=n+ue(t),s=new Uint8Array(o+t);return he(r,s,0),he(t,s,n),s.set(e,o),new le(r,t,e,s)},Ke=r=>{let e=j(r),[t,n]=Oe(e),[o,s]=Oe(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new le(t,o,i,e)},En=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&bn(r.bytes,t.bytes)}},le=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var In=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Ei(t,kt(r),e||F.encoder);default:return Ii(t,kt(r),e||q.encoder)}};var Cn=new WeakMap,kt=r=>{let e=Cn.get(r);if(e==null){let t=new Map;return Cn.set(r,t),t}return e},K=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!==ke)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Ci)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=Z(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&&En(e.multihash,n.multihash)}toString(e){return In(this,e)}toJSON(){return{"/":In(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||Dn(n,o,s.bytes))}else if(t[Di]===!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!==ke)throw new Error(`Version 0 CID must use dag-pb (code: ${ke}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Dn(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,ke,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=j(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 le(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[C,L]=Oe(e.subarray(t));return t+=L,C},o=n(),s=ke;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),d=n(),A=t+d,h=A-i;return{version:o,codec:s,multihashCode:a,digestSize:d,multihashSize:h,size:A}}static parse(e,t){let[n,o]=Ai(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 kt(s).set(n,e),s}},Ai=(r,e)=>{switch(r[0]){case"Q":{let t=e||F;return[F.prefix,t.decode(`${F.prefix}${r}`)]}case F.prefix:{let t=e||F;return[F.prefix,t.decode(r)]}case q.prefix:{let t=e||q;return[q.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)]}}},Ei=(r,e,t)=>{let{prefix:n}=t;if(n!==F.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},Ii=(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},ke=112,Ci=18,Dn=(r,e,t)=>{let n=ue(r),o=n+ue(e),s=new Uint8Array(o+t.byteLength);return he(r,s,0),he(e,s,n),s.set(t,o),s},Di=Symbol.for("@ipld/js-cid/CID");function Tn(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 _t={};m(_t,{base10:()=>Mi});function Ti(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var a=r.length,d=r.charAt(0),A=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function C(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";for(var u=0,D=0,b=0,w=c.length;b!==w&&c[b]===0;)b++,u++;for(var g=(w-b)*h+1>>>0,l=new Uint8Array(g);b!==w;){for(var y=c[b],I=0,x=g-1;(y!==0||I<D)&&x!==-1;x--,I++)y+=256*l[x]>>>0,l[x]=y%a>>>0,y=y/a>>>0;if(y!==0)throw new Error("Non-zero carry");D=I,b++}for(var S=g-D;S!==g&&l[S]===0;)S++;for(var R=d.repeat(u);S<g;++S)R+=r.charAt(l[S]);return R}function L(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;var u=0;if(c[u]!==" "){for(var D=0,b=0;c[u]===d;)D++,u++;for(var w=(c.length-u)*A+1>>>0,g=new Uint8Array(w);c[u];){var l=t[c.charCodeAt(u)];if(l===255)return;for(var y=0,I=w-1;(l!==0||y<b)&&I!==-1;I--,y++)l+=a*g[I]>>>0,g[I]=l%256>>>0,l=l/256>>>0;if(l!==0)throw new Error("Non-zero carry");b=y,u++}if(c[u]!==" "){for(var x=w-b;x!==w&&g[x]===0;)x++;for(var S=new Uint8Array(D+(w-x)),R=D;x!==w;)S[R++]=g[x++];return S}}}function M(c){var u=L(c);if(u)return u;throw new Error(`Non-${e} character`)}return{encode:C,decodeUnsafe:L,decode:M}}var Ui=Ti,Pi=Ui,Un=Pi;var Xd=new Uint8Array(0);var Pn=(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},_=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 Nn=r=>new TextEncoder().encode(r),Ln=r=>new TextDecoder().decode(r);var Vt=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")}},$t=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 zn(this,e)}},jt=class{constructor(e){this.decoders=e}or(e){return zn(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`)}},zn=(r,e)=>new jt({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),qt=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Vt(e,t,n),this.decoder=new $t(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},be=({name:r,prefix:e,encode:t,decode:n})=>new qt(r,e,t,n),Q=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=Un(t,e);return be({prefix:r,name:e,encode:n,decode:s=>_(o(s))})},Ni=(r,e,t,n)=>{let o={};for(let h=0;h<e.length;++h)o[e[h]]=h;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,d=0,A=0;for(let h=0;h<s;++h){let C=o[r[h]];if(C===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<t|C,a+=t,a>=8&&(a-=8,i[A++]=255&d>>a)}if(a>=t||255&d<<8-a)throw new SyntaxError("Unexpected end of data");return i},Li=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let d=0;d<r.length;++d)for(a=a<<8|r[d],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s},P=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>be({prefix:e,name:r,encode(o){return Li(o,n,t)},decode(o){return Ni(o,n,t,r)}});var Mi=Q({prefix:"9",name:"base10",alphabet:"0123456789"});var Jt={};m(Jt,{base16:()=>zi,base16upper:()=>Ri});var zi=P({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ri=P({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Gt={};m(Gt,{base2:()=>Fi});var Fi=P({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Wt={};m(Wt,{base256emoji:()=>$i});var Rn=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}"),Bi=Rn.reduce((r,e,t)=>(r[t]=e,r),[]),Oi=Rn.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function ki(r){return r.reduce((e,t)=>(e+=Bi[t],e),"")}function Vi(r){let e=[];for(let t of r){let n=Oi[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var $i=be({prefix:"\u{1F680}",name:"base256emoji",encode:ki,decode:Vi});var Xt={};m(Xt,{base32:()=>xe,base32hex:()=>Ji,base32hexpad:()=>Wi,base32hexpadupper:()=>Xi,base32hexupper:()=>Gi,base32pad:()=>qi,base32padupper:()=>_i,base32upper:()=>ji,base32z:()=>Ki});var xe=P({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ji=P({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),qi=P({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),_i=P({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ji=P({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Gi=P({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Wi=P({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Xi=P({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ki=P({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Kt={};m(Kt,{base36:()=>Qi,base36upper:()=>Hi});var Qi=Q({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Hi=Q({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Qt={};m(Qt,{base58btc:()=>k,base58flickr:()=>Yi});var k=Q({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Yi=Q({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ht={};m(Ht,{base64:()=>Zi,base64pad:()=>ea,base64url:()=>ta,base64urlpad:()=>ra});var Zi=P({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ea=P({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ta=P({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ra=P({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Yt={};m(Yt,{base8:()=>na});var na=P({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Zt={};m(Zt,{identity:()=>oa});var oa=be({prefix:"\0",name:"identity",encode:r=>Ln(r),decode:r=>Nn(r)});var df=new TextEncoder,ff=new TextDecoder;var tr={};m(tr,{identity:()=>Da});var aa=On,Fn=128,ca=127,pa=~ca,da=Math.pow(2,31);function On(r,e,t){e=e||[],t=t||0;for(var n=t;r>=da;)e[t++]=r&255|Fn,r/=128;for(;r&pa;)e[t++]=r&255|Fn,r>>>=7;return e[t]=r|0,On.bytes=t-n+1,e}var fa=er,ha=128,Bn=127;function er(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw er.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Bn)<<o:(i&Bn)*Math.pow(2,o),o+=7}while(i>=ha);return er.bytes=s-n,t}var ua=Math.pow(2,7),la=Math.pow(2,14),ma=Math.pow(2,21),ba=Math.pow(2,28),xa=Math.pow(2,35),wa=Math.pow(2,42),ga=Math.pow(2,49),ya=Math.pow(2,56),va=Math.pow(2,63),Sa=function(r){return r<ua?1:r<la?2:r<ma?3:r<ba?4:r<xa?5:r<wa?6:r<ga?7:r<ya?8:r<va?9:10},Aa={encode:aa,decode:fa,encodingLength:Sa},Ea=Aa,Ve=Ea;var $e=(r,e=0)=>[Ve.decode(r,e),Ve.decode.bytes],we=(r,e,t=0)=>(Ve.encode(r,e,t),e),ge=r=>Ve.encodingLength(r);var ee=(r,e)=>{let t=e.byteLength,n=ge(r),o=n+ge(t),s=new Uint8Array(o+t);return we(r,s,0),we(t,s,n),s.set(e,o),new ye(r,t,e,s)},kn=r=>{let e=_(r),[t,n]=$e(e),[o,s]=$e(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ye(t,o,i,e)},Vn=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Pn(r.bytes,t.bytes)}},ye=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var $n=0,Ia="identity",jn=_,Ca=r=>ee($n,jn(r)),Da={code:$n,name:Ia,encode:jn,digest:Ca};var or={};m(or,{sha256:()=>Ta,sha512:()=>Ua});var nr=({name:r,code:e,encode:t})=>new rr(r,e,t),rr=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 _n=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Ta=nr({name:"sha2-256",code:18,encode:_n("SHA-256")}),Ua=nr({name:"sha2-512",code:19,encode:_n("SHA-512")});var Jn=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Na(t,sr(r),e||k.encoder);default:return La(t,sr(r),e||xe.encoder)}};var Gn=new WeakMap,sr=r=>{let e=Gn.get(r);if(e==null){let t=new Map;return Gn.set(r,t),t}return e},He=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!==qe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Ma)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&&Vn(e.multihash,n.multihash)}toString(e){return Jn(this,e)}toJSON(){return{"/":Jn(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||Wn(n,o,s.bytes))}else if(t[za]===!0){let{version:n,multihash:o,code:s}=t,i=kn(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!==qe)throw new Error(`Version 0 CID must use dag-pb (code: ${qe}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Wn(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,qe,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=_(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 ye(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[C,L]=$e(e.subarray(t));return t+=L,C},o=n(),s=qe;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),d=n(),A=t+d,h=A-i;return{version:o,codec:s,multihashCode:a,digestSize:d,multihashSize:h,size:A}}static parse(e,t){let[n,o]=Pa(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 sr(s).set(n,e),s}},Pa=(r,e)=>{switch(r[0]){case"Q":{let t=e||k;return[k.prefix,t.decode(`${k.prefix}${r}`)]}case k.prefix:{let t=e||k;return[k.prefix,t.decode(r)]}case xe.prefix:{let t=e||xe;return[xe.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)]}}},Na=(r,e,t)=>{let{prefix:n}=t;if(n!==k.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},La=(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},qe=112,Ma=18,Wn=(r,e,t)=>{let n=ge(r),o=n+ge(e),s=new Uint8Array(o+t.byteLength);return we(r,s,0),we(e,s,n),s.set(t,o),s},za=Symbol.for("@ipld/js-cid/CID");var ir={...Zt,...Gt,...Yt,..._t,...Jt,...Xt,...Kt,...Qt,...Ht,...Wt},Df={...or,...tr};function ve(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Se(r=0){return globalThis.Buffer?.allocUnsafe!=null?ve(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Kn(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Xn=Kn("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ar=Kn("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=Se(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Ra={utf8:Xn,"utf-8":Xn,hex:ir.base16,latin1:ar,ascii:ar,binary:ar,...ir},Ye=Ra;function B(r,e="utf8"){let t=Ye[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 Fa=Math.pow(2,7),Ba=Math.pow(2,14),Oa=Math.pow(2,21),cr=Math.pow(2,28),pr=Math.pow(2,35),dr=Math.pow(2,42),fr=Math.pow(2,49),v=128,z=127;function V(r){if(r<Fa)return 1;if(r<Ba)return 2;if(r<Oa)return 3;if(r<cr)return 4;if(r<pr)return 5;if(r<dr)return 6;if(r<fr)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ka(r,e,t=0){switch(V(r)){case 8:e[t++]=r&255|v,r/=128;case 7:e[t++]=r&255|v,r/=128;case 6:e[t++]=r&255|v,r/=128;case 5:e[t++]=r&255|v,r/=128;case 4:e[t++]=r&255|v,r>>>=7;case 3:e[t++]=r&255|v,r>>>=7;case 2:e[t++]=r&255|v,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Va(r,e,t=0){switch(V(r)){case 8:e.set(t++,r&255|v),r/=128;case 7:e.set(t++,r&255|v),r/=128;case 6:e.set(t++,r&255|v),r/=128;case 5:e.set(t++,r&255|v),r/=128;case 4:e.set(t++,r&255|v),r>>>=7;case 3:e.set(t++,r&255|v),r>>>=7;case 2:e.set(t++,r&255|v),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function $a(r,e){let t=r[e],n=0;if(n+=t&z,t<v||(t=r[e+1],n+=(t&z)<<7,t<v)||(t=r[e+2],n+=(t&z)<<14,t<v)||(t=r[e+3],n+=(t&z)<<21,t<v)||(t=r[e+4],n+=(t&z)*cr,t<v)||(t=r[e+5],n+=(t&z)*pr,t<v)||(t=r[e+6],n+=(t&z)*dr,t<v)||(t=r[e+7],n+=(t&z)*fr,t<v))return n;throw new RangeError("Could not decode varint")}function ja(r,e){let t=r.get(e),n=0;if(n+=t&z,t<v||(t=r.get(e+1),n+=(t&z)<<7,t<v)||(t=r.get(e+2),n+=(t&z)<<14,t<v)||(t=r.get(e+3),n+=(t&z)<<21,t<v)||(t=r.get(e+4),n+=(t&z)*cr,t<v)||(t=r.get(e+5),n+=(t&z)*pr,t<v)||(t=r.get(e+6),n+=(t&z)*dr,t<v)||(t=r.get(e+7),n+=(t&z)*fr,t<v))return n;throw new RangeError("Could not decode varint")}function Ae(r,e,t=0){return e==null&&(e=Se(V(r))),e instanceof Uint8Array?ka(r,e,t):Va(r,e,t)}function te(r,e=0){return r instanceof Uint8Array?$a(r,e):ja(r,e)}function J(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=Se(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return ve(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,a=this.peekChar();if(a===void 0)return;let d=a==="0",A=2**(8*o)-1;for(;;){let h=this.readAtomically(()=>{let C=this.readChar();if(C===void 0)return;let L=Number.parseInt(C,e);if(!Number.isNaN(L))return L});if(h===void 0)break;if(s*=e,s+=h,s>A||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&d&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return t[o]=i[0],t[o+1]=i[1],t[o+2]=i[2],t[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];t[o]=s>>8,t[o+1]=s&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=e(s.subarray(0,i));return t.set(s.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Hn=45,qa=15,Ee=new Ze;function hr(r){if(!(r.length>qa))return Ee.new(r).parseWith(()=>Ee.readIPv4Addr())}function ur(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Hn))return Ee.new(r).parseWith(()=>Ee.readIPv6Addr())}function et(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Hn))return Ee.new(r).parseWith(()=>Ee.readIPAddr())}var Qf=parseInt("0xFFFF",16),Hf=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var lr={};m(lr,{base10:()=>Xa});var Xa=X({prefix:"9",name:"base10",alphabet:"0123456789"});var mr={};m(mr,{base16:()=>Ka,base16upper:()=>Qa});var Ka=U({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Qa=U({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var br={};m(br,{base2:()=>Ha});var Ha=U({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var xr={};m(xr,{base256emoji:()=>rc});var eo=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}"),Ya=eo.reduce((r,e,t)=>(r[t]=e,r),[]),Za=eo.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function ec(r){return r.reduce((e,t)=>(e+=Ya[t],e),"")}function tc(r){let e=[];for(let t of r){let n=Za[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var rc=fe({prefix:"\u{1F680}",name:"base256emoji",encode:ec,decode:tc});var wr={};m(wr,{base36:()=>nc,base36upper:()=>oc});var nc=X({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),oc=X({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var gr={};m(gr,{base64:()=>sc,base64pad:()=>ic,base64url:()=>ac,base64urlpad:()=>cc});var sc=U({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ic=U({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ac=U({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),cc=U({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var yr={};m(yr,{base8:()=>pc});var pc=U({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var vr={};m(vr,{identity:()=>dc});var dc=fe({prefix:"\0",name:"identity",encode:r=>wn(r),decode:r=>xn(r)});var Th=new TextEncoder,Uh=new TextDecoder;var Sr={};m(Sr,{identity:()=>mc});var to=0,uc="identity",ro=j,lc=r=>Z(to,ro(r)),mc={code:to,name:uc,encode:ro,digest:lc};var Ir={};m(Ir,{sha256:()=>bc,sha512:()=>xc});var Er=({name:r,code:e,encode:t})=>new Ar(r,e,t),Ar=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?Z(this.code,t):t.then(n=>Z(this.code,n))}else throw Error("Unknown type, must be binary type")}};var oo=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),bc=Er({name:"sha2-256",code:18,encode:oo("SHA-256")}),xc=Er({name:"sha2-512",code:19,encode:oo("SHA-512")});var so={...vr,...br,...yr,...lr,...mr,...Bt,...wr,...Ft,...gr,...xr},Bh={...Ir,...Sr};function Cr(r,e="utf8"){let t=Ye[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?ve(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function io(r){return!!hr(r)}function ao(r){return!!ur(r)}function tt(r){return!!et(r)}var co=io,wc=ao,Dr=function(r){let e=0;if(r=r.toString().trim(),co(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(wc(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=co(t[n]),i;s&&(i=Dr(t[n]),t[n]=B(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,B(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")},po=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 Ie={},Tr={},yc=[[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"]];yc.forEach(r=>{let e=vc(...r);Tr[e.code]=e,Ie[e.name]=e});function vc(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function E(r){if(typeof r=="number"){if(Tr[r]!=null)return Tr[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ie[r]!=null)return Ie[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var nu=E("ip4"),ou=E("ip6"),su=E("ipcidr");function Pr(r,e){switch(E(r).code){case 4:case 41:return Ac(e);case 42:return uo(e);case 6:case 273:case 33:case 132:return mo(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return uo(e);case 421:return Dc(e);case 444:return lo(e);case 445:return lo(e);case 466:return Cc(e);default:return B(e,"base16")}}function Nr(r,e){switch(E(r).code){case 4:return fo(e);case 41:return fo(e);case 42:return ho(e);case 6:case 273:case 33:case 132:return Lr(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ho(e);case 421:return Ec(e);case 444:return Tc(e);case 445:return Uc(e);case 466:return Ic(e);default:return Cr(e,"base16")}}var Ur=Object.values(so).map(r=>r.decoder),Sc=function(){let r=Ur[0].or(Ur[1]);return Ur.slice(2).forEach(e=>r=r.or(e)),r}();function fo(r){if(!tt(r))throw new Error("invalid ip address");return Dr(r)}function Ac(r){let e=po(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!tt(e))throw new Error("invalid ip address");return e}function Lr(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function mo(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function ho(r){let e=Cr(r),t=Uint8Array.from(Ae(e.length));return J([t,e],t.length+e.length)}function uo(r){let e=te(r);if(r=r.slice(V(e)),r.length!==e)throw new Error("inconsistent lengths");return B(r)}function Ec(r){let e;r[0]==="Q"||r[0]==="1"?e=Ke(F.decode(`z${r}`)).bytes:e=K.parse(r).multihash.bytes;let t=Uint8Array.from(Ae(e.length));return J([t,e],t.length+e.length)}function Ic(r){let e=Sc.decode(r),t=Uint8Array.from(Ae(e.length));return J([t,e],t.length+e.length)}function Cc(r){let e=te(r),t=r.slice(V(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+B(t,"base64url")}function Dc(r){let e=te(r),t=r.slice(V(e));if(t.length!==e)throw new Error("inconsistent lengths");return B(t,"base58btc")}function Tc(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=q.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=Lr(n);return J([t,o],t.length+o.length)}function Uc(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=q.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=Lr(n);return J([t,o],t.length+o.length)}function lo(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=B(e,"base32"),o=mo(t);return`${n}:${o}`}function bo(r){r=Mr(r);let e=[],t=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],a=E(i);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(s++,s>=o.length)throw wo("invalid address: "+r);if(a.path===!0){n=Mr(o.slice(s).join("/")),e.push([a.code,Nr(a.code,n)]),t.push([a.code,n]);break}let d=Nr(a.code,o[s]);e.push([a.code,d]),t.push([a.code,Pr(a.code,d)])}return{string:xo(t),bytes:Rr(e),tuples:e,stringTuples:t,path:n}}function zr(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let s=te(r,o),i=V(s),a=E(s),d=Pc(a,r.slice(o+i));if(d===0){e.push([s]),t.push([s]),o+=i;continue}let A=r.slice(o+i,o+i+d);if(o+=d+i,o>r.length)throw wo("Invalid address Uint8Array: "+B(r,"base16"));e.push([s,A]);let h=Pr(s,A);if(t.push([s,h]),a.path===!0){n=h;break}}return{bytes:Uint8Array.from(r),string:xo(t),tuples:e,stringTuples:t,path:n}}function xo(r){let e=[];return r.map(t=>{let n=E(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),Mr(e.join("/"))}function Rr(r){return J(r.map(e=>{let t=E(e[0]),n=Uint8Array.from(Ae(t.code));return e.length>1&&e[1]!=null&&(n=J([n,e[1]])),n}))}function Pc(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=te(e instanceof Uint8Array?e:Uint8Array.from(e));return t+V(t)}}function Mr(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function wo(r){return new Error("Error parsing address: "+r)}var Nc=Symbol.for("nodejs.util.inspect.custom"),Fr=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Lc=[E("dns").code,E("dns4").code,E("dns6").code,E("dnsaddr").code],rt=class r{bytes;#e;#t;#r;#n;[Fr]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=zr(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=bo(e)}else if(yo(e))t=zr(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=E("tcp"),a=E("udp"),d=E("ip4"),A=E("ip6"),h=E("dns6"),C=E("ip6zone");for(let[M,c]of this.stringTuples())M===C.code&&(s=`%${c??""}`),Lc.includes(M)&&(t=i.name,o=443,n=`${c??""}${s}`,e=M===h.code?6:4),(M===i.code||M===a.code)&&(t=E(M).name,o=parseInt(c??"")),(M===d.code||M===A.code)&&(t=E(M).name,n=`${c??""}${s}`,e=M===A.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({},E(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>E(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(Rr(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===Ie.p2p.code&&e.push([n,o]),n===Ie["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?B(F.decode(`z${n}`),"base58btc"):B(K.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return Tn(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=go.get(t.name);if(n==null)throw new Te(`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)}[Nc](){return`Multiaddr(${this.#e})`}};var go=new Map;function yo(r){return!!r?.[Fr]}function Ce(r){return new rt(r)}var Mc=p("dns4"),zc=p("dns6"),Rc=p("dnsaddr"),ne=N(p("dns"),Rc,Mc,zc),st=N(p("ip4"),p("ip6")),De=N(f(st,p("tcp")),f(ne,p("tcp"))),it=f(st,p("udp")),Fc=f(it,p("utp")),Bc=f(it,p("quic")),Oc=f(it,p("quic-v1")),Br=N(f(De,p("ws")),f(ne,p("ws"))),nt=N(f(Br,p("p2p")),Br),Or=N(f(De,p("wss")),f(ne,p("wss")),f(De,p("tls"),p("ws")),f(ne,p("tls"),p("ws"))),ot=N(f(Or,p("p2p")),Or),kr=N(f(De,p("http")),f(st,p("http")),f(ne,p("http"))),Vr=N(f(De,p("https")),f(st,p("https")),f(ne,p("https"))),vo=f(it,p("webrtc-direct"),p("certhash")),Eo=N(f(vo,p("p2p")),vo),So=f(Oc,p("webtransport"),p("certhash"),p("certhash")),Io=N(f(So,p("p2p")),So),Co=N(f(nt,p("p2p-webrtc-star"),p("p2p")),f(ot,p("p2p-webrtc-star"),p("p2p")),f(nt,p("p2p-webrtc-star")),f(ot,p("p2p-webrtc-star"))),Nu=N(f(nt,p("p2p-websocket-star"),p("p2p")),f(ot,p("p2p-websocket-star"),p("p2p")),f(nt,p("p2p-websocket-star")),f(ot,p("p2p-websocket-star"))),Do=N(f(kr,p("p2p-webrtc-direct"),p("p2p")),f(Vr,p("p2p-webrtc-direct"),p("p2p")),f(kr,p("p2p-webrtc-direct")),f(Vr,p("p2p-webrtc-direct"))),oe=N(Br,Or,kr,Vr,Co,Do,De,Fc,Bc,ne,Eo,Io),Lu=N(f(oe,p("p2p-stardust"),p("p2p")),f(oe,p("p2p-stardust"))),H=N(f(oe,p("p2p")),Co,Do,Eo,Io,p("p2p")),Ao=N(f(H,p("p2p-circuit"),H),f(H,p("p2p-circuit")),f(p("p2p-circuit"),H),f(oe,p("p2p-circuit")),f(p("p2p-circuit"),oe),p("p2p-circuit")),To=()=>N(f(Ao,To),Ao),re=To(),Uo=N(f(re,H,re),f(H,re),f(re,H),re,H);var Mu=N(f(re,p("webrtc"),p("p2p")),f(re,p("webrtc")),f(oe,p("webrtc"),p("p2p")),f(oe,p("webrtc")),p("webrtc"));function Po(r){function e(t){let n;try{n=Ce(t)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return e}function f(...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:Po(e),partialMatch:e}}function N(...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:Po(e),partialMatch:e}}function p(r){let e=r;function t(o){let s;try{s=Ce(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 kc="bootstrap",Vc=50,$c=12e4,jc=1e3,$r=class extends _e{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(e,t={list:[]}){if(t.list==null||t.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super(),this.components=e,this.log=e.logger.forComponent("libp2p:bootstrap"),this.timeout=t.timeout??jc,this.list=[];for(let n of t.list){if(!Uo.matches(n)){this.log.error("Invalid multiaddr");continue}let o=Ce(n),s=o.getPeerId();if(s==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let i={id:Nt(s),multiaddrs:[o]};this.list.push(i)}this._init=t}[jr]=this;[Symbol.toStringTag]="@libp2p/bootstrap";isStarted(){return!!this.timer}start(){this.isStarted()||(this.log("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(e=>{this.log.error(e)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(let e of this.list){if(await this.components.peerStore.merge(e.id,{tags:{[this._init.tagName??kc]:{value:this._init.tagValue??Vc,ttl:this._init.tagTTL??$c}}}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:e})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function qc(r){return e=>new $r(e,r)}return Ro(_c);})();
|
|
3
3
|
return Libp2PBootstrap}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/bootstrap",
|
|
3
|
-
"version": "10.0.8-
|
|
3
|
+
"version": "10.0.8-4e0135c7d",
|
|
4
4
|
"description": "Peer discovery via a list of bootstrap peers",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap#readme",
|
|
@@ -53,14 +53,14 @@
|
|
|
53
53
|
"test:electron-main": "aegir test -t electron-main"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@libp2p/interface": "1.0.2-
|
|
57
|
-
"@libp2p/peer-id": "4.0.2-
|
|
56
|
+
"@libp2p/interface": "1.0.2-4e0135c7d",
|
|
57
|
+
"@libp2p/peer-id": "4.0.2-4e0135c7d",
|
|
58
58
|
"@multiformats/mafmt": "^12.1.6",
|
|
59
59
|
"@multiformats/multiaddr": "^12.1.10"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@libp2p/interface-compliance-tests": "5.0.8-
|
|
63
|
-
"@libp2p/logger": "4.0.2-
|
|
62
|
+
"@libp2p/interface-compliance-tests": "5.0.8-4e0135c7d",
|
|
63
|
+
"@libp2p/logger": "4.0.2-4e0135c7d",
|
|
64
64
|
"aegir": "^41.0.2",
|
|
65
65
|
"sinon-ts": "^2.0.0"
|
|
66
66
|
}
|