@libp2p/memory 1.1.9 → 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,4 +1,4 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PMemory = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PMemory=(()=>{var jt=Object.defineProperty;var kr=Object.getOwnPropertyDescriptor;var Fr=Object.getOwnPropertyNames;var Lr=Object.prototype.hasOwnProperty;var k=(r,t)=>{for(var e in t)jt(r,e,{get:t[e],enumerable:!0})},zr=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Fr(t))!Lr.call(r,o)&&o!==e&&jt(r,o,{get:()=>t[o],enumerable:!(n=kr(t,o))||n.enumerable});return r};var $r=r=>zr(jt({},"__esModule",{value:!0}),r);var zo={};k(zo,{memory:()=>Lo});var Be=Symbol.for("@libp2p/transport");var Ve;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Ve||(Ve={}));var H=class extends Error{static name="ConnectionFailedError";constructor(t="Connection failed"){super(t),this.name="ConnectionFailedError"}};var wt=class extends Error{static name="ListenError";constructor(t="Listen error"){super(t),this.name="ListenError"}};var gt=class extends EventTarget{#t=new Map;constructor(){super()}listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e={}){return this.dispatchEvent(new CustomEvent(t,e))}};var Re=Symbol.for("@libp2p/service-capabilities"),Oo=Symbol.for("@libp2p/service-dependencies");var bt=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",w=2**(8*o)-1;for(;;){let v=this.readAtomically(()=>{let U=this.readChar();if(U===void 0)return;let N=Number.parseInt(U,t);if(!Number.isNaN(N))return N});if(v===void 0)break;if(s*=t,s+=v,s>w||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[o]=i[0],e[o+1]=i[1],e[o+2]=i[2],e[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=t(s.subarray(0,i));return e.set(s.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Oe=45,Vr=15,X=new bt;function qt(r){if(!(r.length>Vr))return X.new(r).parseWith(()=>X.readIPv4Addr())}function Wt(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Oe))return X.new(r).parseWith(()=>X.readIPv6Addr())}function yt(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>Oe)return;let e=X.new(r).parseWith(()=>X.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}function Et(r){return!!qt(r)}function vt(r){return!!Wt(r)}function It(r){return!!yt(r)}var Xt={};k(Xt,{base58btc:()=>S,base58flickr:()=>Wr});var ms=new Uint8Array(0);function _e(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function V(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function je(r){return new TextEncoder().encode(r)}function qe(r){return new TextDecoder().decode(r)}function Br(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,c=r.charAt(0),w=Math.log(a)/Math.log(256),v=Math.log(256)/Math.log(a);function U(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var y=0,p=0,E=0,T=d.length;E!==T&&d[E]===0;)E++,y++;for(var I=(T-E)*v+1>>>0,M=new Uint8Array(I);E!==T;){for(var F=d[E],_=0,L=I-1;(F!==0||_<p)&&L!==-1;L--,_++)F+=256*M[L]>>>0,M[L]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");p=_,E++}for(var $=I-p;$!==I&&M[$]===0;)$++;for(var xt=c.repeat(y);$<I;++$)xt+=r.charAt(M[$]);return xt}function N(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var y=0;if(d[y]!==" "){for(var p=0,E=0;d[y]===c;)p++,y++;for(var T=(d.length-y)*w+1>>>0,I=new Uint8Array(T);d[y];){var M=e[d.charCodeAt(y)];if(M===255)return;for(var F=0,_=T-1;(M!==0||F<E)&&_!==-1;_--,F++)M+=a*I[_]>>>0,I[_]=M%256>>>0,M=M/256>>>0;if(M!==0)throw new Error("Non-zero carry");E=F,y++}if(d[y]!==" "){for(var L=T-E;L!==T&&I[L]===0;)L++;for(var $=new Uint8Array(p+(T-L)),xt=p;L!==T;)$[xt++]=I[L++];return $}}}function A(d){var y=N(d);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:U,decodeUnsafe:N,decode:A}}var Rr=Br,Or=Rr,Ge=Or;var Gt=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Qt=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,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 Qe(this,t)}},Jt=class{decoders;constructor(t){this.decoders=t}or(t){return Qe(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Qe(r,t){return new Jt({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Ht=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Gt(t,e,n),this.decoder=new Qt(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function K({name:r,prefix:t,encode:e,decode:n}){return new Ht(r,t,e,n)}function j({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Ge(e,r);return K({prefix:t,name:r,encode:n,decode:s=>V(o(s))})}function _r(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,a=0,c=0;for(let w=0;w<o;++w){let v=t[r[w]];if(v===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|v,i+=e,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=e||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function jr(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function qr(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function b({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=qr(n);return K({prefix:t,name:r,encode(s){return jr(s,n,e)},decode(s){return _r(s,o,e,r)}})}var S=j({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Wr=j({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Zt={};k(Zt,{base64:()=>Gr,base64pad:()=>Qr,base64url:()=>Kt,base64urlpad:()=>Jr});var Gr=b({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Qr=b({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Kt=b({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Jr=b({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Hr=r=>r.toString().split("/").slice(1),Z=r=>({match:t=>t.length<1?!1:r(t[0])?t.slice(1):!1,pattern:"fn"}),u=r=>({match:t=>Z(e=>e===r).match(t),pattern:r}),G=()=>({match:r=>Z(t=>typeof t=="string").match(r),pattern:"{string}"}),Y=()=>({match:r=>Z(t=>!isNaN(parseInt(t))).match(r),pattern:"{number}"}),m=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{S.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),ut=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{Kt.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),f=r=>({match:t=>{let e=r.match(t);return e===!1?t:e},pattern:`optional(${r.pattern})`}),C=(...r)=>({match:t=>{let e;for(let n of r){let o=n.match(t);o!==!1&&(e==null||o.length<e.length)&&(e=o)}return e??!1},pattern:`or(${r.map(t=>t.pattern).join(", ")})`}),l=(...r)=>({match:t=>{for(let e of r){let n=e.match(t);if(n===!1)return!1;t=n}return t},pattern:`and(${r.map(t=>t.pattern).join(", ")})`});function g(...r){function t(o){let s=Hr(o);for(let i of r){let a=i.match(s);if(a===!1)return!1;s=a}return s}function e(o){return t(o)!==!1}function n(o){let s=t(o);return s===!1?!1:s.length===0}return{matchers:r,matches:e,exactMatch:n}}var Xr=m(),Ps=g(Xr),St=l(u("dns4"),G()),Ct=l(u("dns6"),G()),Pt=l(u("dnsaddr"),G()),te=l(u("dns"),G()),Ts=g(St,f(m())),Ds=g(Ct,f(m())),Us=g(Pt,f(m())),Ns=g(C(te,Pt,St,Ct),f(m())),Je=l(u("ip4"),Z(Et)),He=l(u("ip6"),Z(vt)),ee=C(Je,He),B=C(ee,te,St,Ct,Pt),Ms=g(C(ee,l(C(te,Pt,St,Ct),f(m())))),ks=g(Je),Fs=g(He),Ls=g(ee),re=l(B,u("tcp"),Y()),lt=l(B,u("udp"),Y()),zs=g(l(re,f(m()))),$s=g(lt),ne=l(lt,u("quic"),f(m())),Tt=l(lt,u("quic-v1"),f(m())),Kr=C(ne,Tt),Vs=g(ne),Bs=g(Tt),Yt=C(B,re,lt,ne,Tt),Xe=C(l(Yt,u("ws"),f(m()))),Rs=g(Xe),Ke=C(l(Yt,u("wss"),f(m())),l(Yt,u("tls"),f(l(u("sni"),G())),u("ws"),f(m()))),Os=g(Ke),Ze=l(lt,u("webrtc-direct"),f(ut()),f(ut()),f(m())),_s=g(Ze),Ye=l(Tt,u("webtransport"),f(ut()),f(ut()),f(m())),js=g(Ye),At=C(Xe,Ke,l(re,f(m())),l(Kr,f(m())),l(B,f(m())),Ze,Ye,m()),qs=g(At),Zr=l(At,u("p2p-circuit"),m()),Ws=g(Zr),Yr=C(l(At,u("p2p-circuit"),u("webrtc"),f(m())),l(At,u("webrtc"),f(m())),l(u("webrtc"),f(m()))),Gs=g(Yr),tn=C(l(B,u("tcp"),Y(),u("http"),f(m())),l(B,u("http"),f(m()))),Qs=g(tn),en=C(l(B,u("tcp"),C(l(u("443"),u("http")),l(Y(),u("https")),l(Y(),u("tls"),u("http"))),f(m())),l(B,u("tls"),u("http"),f(m())),l(B,u("https"),f(m()))),Js=g(en),rn=C(l(u("memory"),G(),f(m()))),tr=g(rn);function tt(r=0){return new Uint8Array(r)}var nn=Math.pow(2,7),on=Math.pow(2,14),sn=Math.pow(2,21),oe=Math.pow(2,28),se=Math.pow(2,35),ie=Math.pow(2,42),ae=Math.pow(2,49),h=128,P=127;function z(r){if(r<nn)return 1;if(r<on)return 2;if(r<sn)return 3;if(r<oe)return 4;if(r<se)return 5;if(r<ie)return 6;if(r<ae)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function an(r,t,e=0){switch(z(r)){case 8:t[e++]=r&255|h,r/=128;case 7:t[e++]=r&255|h,r/=128;case 6:t[e++]=r&255|h,r/=128;case 5:t[e++]=r&255|h,r/=128;case 4:t[e++]=r&255|h,r>>>=7;case 3:t[e++]=r&255|h,r>>>=7;case 2:t[e++]=r&255|h,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function cn(r,t,e=0){switch(z(r)){case 8:t.set(e++,r&255|h),r/=128;case 7:t.set(e++,r&255|h),r/=128;case 6:t.set(e++,r&255|h),r/=128;case 5:t.set(e++,r&255|h),r/=128;case 4:t.set(e++,r&255|h),r>>>=7;case 3:t.set(e++,r&255|h),r>>>=7;case 2:t.set(e++,r&255|h),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function un(r,t){let e=r[t],n=0;if(n+=e&P,e<h||(e=r[t+1],n+=(e&P)<<7,e<h)||(e=r[t+2],n+=(e&P)<<14,e<h)||(e=r[t+3],n+=(e&P)<<21,e<h)||(e=r[t+4],n+=(e&P)*oe,e<h)||(e=r[t+5],n+=(e&P)*se,e<h)||(e=r[t+6],n+=(e&P)*ie,e<h)||(e=r[t+7],n+=(e&P)*ae,e<h))return n;throw new RangeError("Could not decode varint")}function ln(r,t){let e=r.get(t),n=0;if(n+=e&P,e<h||(e=r.get(t+1),n+=(e&P)<<7,e<h)||(e=r.get(t+2),n+=(e&P)<<14,e<h)||(e=r.get(t+3),n+=(e&P)<<21,e<h)||(e=r.get(t+4),n+=(e&P)*oe,e<h)||(e=r.get(t+5),n+=(e&P)*se,e<h)||(e=r.get(t+6),n+=(e&P)*ie,e<h)||(e=r.get(t+7),n+=(e&P)*ae,e<h))return n;throw new RangeError("Could not decode varint")}function et(r,t,e=0){return t==null&&(t=tt(z(r))),t instanceof Uint8Array?an(r,t,e):cn(r,t,e)}function Q(r,t=0){return r instanceof Uint8Array?un(r,t):ln(r,t)}function R(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=tt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var ce={};k(ce,{base10:()=>pn});var pn=j({prefix:"9",name:"base10",alphabet:"0123456789"});var ue={};k(ue,{base16:()=>dn,base16upper:()=>fn});var dn=b({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),fn=b({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var le={};k(le,{base2:()=>hn});var hn=b({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var pe={};k(pe,{base256emoji:()=>bn});var rr=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}"),mn=rr.reduce((r,t,e)=>(r[e]=t,r),[]),xn=rr.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function wn(r){return r.reduce((t,e)=>(t+=mn[e],t),"")}function gn(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=xn[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var bn=K({prefix:"\u{1F680}",name:"base256emoji",encode:wn,decode:gn});var de={};k(de,{base32:()=>O,base32hex:()=>In,base32hexpad:()=>Sn,base32hexpadupper:()=>Cn,base32hexupper:()=>An,base32pad:()=>En,base32padupper:()=>vn,base32upper:()=>yn,base32z:()=>Pn});var O=b({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),yn=b({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),En=b({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vn=b({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),In=b({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),An=b({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Sn=b({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Cn=b({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Pn=b({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var fe={};k(fe,{base36:()=>pt,base36upper:()=>Tn});var pt=j({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Tn=j({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var he={};k(he,{base8:()=>Dn});var Dn=b({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var me={};k(me,{identity:()=>Un});var Un=K({prefix:"\0",name:"identity",encode:r=>qe(r),decode:r=>je(r)});var di=new TextEncoder,fi=new TextDecoder;var we={};k(we,{identity:()=>Yn});var kn=sr,nr=128,Fn=127,Ln=~Fn,zn=Math.pow(2,31);function sr(r,t,e){t=t||[],e=e||0;for(var n=e;r>=zn;)t[e++]=r&255|nr,r/=128;for(;r&Ln;)t[e++]=r&255|nr,r>>>=7;return t[e]=r|0,sr.bytes=e-n+1,t}var $n=xe,Vn=128,or=127;function xe(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw xe.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&or)<<o:(i&or)*Math.pow(2,o),o+=7}while(i>=Vn);return xe.bytes=s-n,e}var Bn=Math.pow(2,7),Rn=Math.pow(2,14),On=Math.pow(2,21),_n=Math.pow(2,28),jn=Math.pow(2,35),qn=Math.pow(2,42),Wn=Math.pow(2,49),Gn=Math.pow(2,56),Qn=Math.pow(2,63),Jn=function(r){return r<Bn?1:r<Rn?2:r<On?3:r<_n?4:r<jn?5:r<qn?6:r<Wn?7:r<Gn?8:r<Qn?9:10},Hn={encode:kn,decode:$n,encodingLength:Jn},Xn=Hn,dt=Xn;function ft(r,t=0){return[dt.decode(r,t),dt.decode.bytes]}function rt(r,t,e=0){return dt.encode(r,t,e),t}function nt(r){return dt.encodingLength(r)}function J(r,t){let e=t.byteLength,n=nt(r),o=n+nt(e),s=new Uint8Array(o+e);return rt(r,s,0),rt(e,s,n),s.set(t,o),new ot(r,e,t,s)}function Ut(r){let t=V(r),[e,n]=ft(t),[o,s]=ft(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ot(e,o,i,t)}function ir(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&_e(r.bytes,e.bytes)}}var ot=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var ar=0,Kn="identity",cr=V;function Zn(r){return J(ar,cr(r))}var Yn={code:ar,name:Kn,encode:cr,digest:Zn};var ye={};k(ye,{sha256:()=>to,sha512:()=>eo});function be({name:r,code:t,encode:e}){return new ge(r,t,e)}var ge=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?J(this.code,e):e.then(n=>J(this.code,n))}else throw Error("Unknown type, must be binary type")}};function lr(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var to=be({name:"sha2-256",code:18,encode:lr("SHA-256")}),eo=be({name:"sha2-512",code:19,encode:lr("SHA-512")});function pr(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return no(e,Ee(r),t??S.encoder);default:return oo(e,Ee(r),t??O.encoder)}}var dr=new WeakMap;function Ee(r){let t=dr.get(r);if(t==null){let e=new Map;return dr.set(r,e),e}return t}var q=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==ht)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==so)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=J(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&ir(t.multihash,n.multihash)}toString(t){return pr(this,t)}toJSON(){return{"/":pr(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??fr(n,o,s.bytes))}else if(e[io]===!0){let{version:n,multihash:o,code:s}=e,i=Ut(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==ht)throw new Error(`Version 0 CID must use dag-pb (code: ${ht}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=fr(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,ht,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=V(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new ot(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[U,N]=ft(t.subarray(e));return e+=N,U},o=n(),s=ht;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),c=n(),w=e+c,v=w-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:v,size:w}}static parse(t,e){let[n,o]=ro(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ee(s).set(n,t),s}};function ro(r,t){switch(r[0]){case"Q":{let e=t??S;return[S.prefix,e.decode(`${S.prefix}${r}`)]}case S.prefix:{let e=t??S;return[S.prefix,e.decode(r)]}case O.prefix:{let e=t??O;return[O.prefix,e.decode(r)]}case pt.prefix:{let e=t??pt;return[pt.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function no(r,t,e){let{prefix:n}=e;if(n!==S.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function oo(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var ht=112,so=18;function fr(r,t,e){let n=nt(r),o=n+nt(t),s=new Uint8Array(o+e.byteLength);return rt(r,s,0),rt(t,s,n),s.set(e,o),s}var io=Symbol.for("@ipld/js-cid/CID");var mt={...me,...le,...he,...ce,...ue,...de,...fe,...Xt,...Zt,...pe},Li={...ye,...we};function mr(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var hr=mr("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ve=mr("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=tt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),ao={utf8:hr,"utf-8":hr,hex:mt.base16,latin1:ve,ascii:ve,binary:ve,...mt},Nt=ao;function D(r,t="utf8"){let e=Nt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Ji=parseInt("0xFFFF",16),Hi=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Mt(r,t="utf8"){let e=Nt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}var gr=Et,fo=vt,Ie=function(r){let t=0;if(r=r.toString().trim(),gr(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(fo(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=gr(e[n]),i;s&&(i=Ie(e[n]),e[n]=D(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,D(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},br=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var it={},Ae={},mo=[[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"],[481,-1,"http-path"],[777,-1,"memory"]];mo.forEach(r=>{let t=xo(...r);Ae[t.code]=t,it[t.name]=t});function xo(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function x(r){if(typeof r=="number"){if(Ae[r]!=null)return Ae[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(it[r]!=null)return it[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Ma=x("ip4"),ka=x("ip6"),Fa=x("ipcidr");function Te(r,t){switch(x(r).code){case 4:case 41:return go(t);case 42:return Pe(t);case 43:return D(t,"base10");case 6:case 273:case 33:case 132:return vr(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Pe(t);case 421:return vo(t);case 444:return Er(t);case 445:return Er(t);case 466:return Eo(t);case 481:return globalThis.encodeURIComponent(Pe(t));default:return D(t,"base16")}}function De(r,t){switch(x(r).code){case 4:return yr(t);case 41:return yr(t);case 42:return Ce(t);case 43:return Mt(t,"base10");case 6:case 273:case 33:case 132:return Ue(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ce(t);case 421:return bo(t);case 444:return Io(t);case 445:return Ao(t);case 466:return yo(t);case 481:return Ce(globalThis.decodeURIComponent(t));default:return Mt(t,"base16")}}var Se=Object.values(mt).map(r=>r.decoder),wo=function(){let r=Se[0].or(Se[1]);return Se.slice(2).forEach(t=>r=r.or(t)),r}();function yr(r){if(!It(r))throw new Error("invalid ip address");return Ie(r)}function go(r){let t=br(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!It(t))throw new Error("invalid ip address");return t}function Ue(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function vr(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Ce(r){let t=Mt(r),e=Uint8Array.from(et(t.length));return R([e,t],e.length+t.length)}function Pe(r){let t=Q(r);if(r=r.slice(z(t)),r.length!==t)throw new Error("inconsistent lengths");return D(r)}function bo(r){let t;r[0]==="Q"||r[0]==="1"?t=Ut(S.decode(`z${r}`)).bytes:t=q.parse(r).multihash.bytes;let e=Uint8Array.from(et(t.length));return R([e,t],e.length+t.length)}function yo(r){let t=wo.decode(r),e=Uint8Array.from(et(t.length));return R([e,t],e.length+t.length)}function Eo(r){let t=Q(r),e=r.slice(z(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+D(e,"base64url")}function vo(r){let t=Q(r),e=r.slice(z(t));if(e.length!==t)throw new Error("inconsistent lengths");return D(e,"base58btc")}function Io(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=O.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=Ue(n);return R([e,o],e.length+o.length)}function Ao(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=O.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=Ue(n);return R([e,o],e.length+o.length)}function Er(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=D(t,"base32"),o=vr(e);return`${n}:${o}`}function Ir(r){r=Ne(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],a=x(i);if(a.size===0){t.push([a.code]),e.push([a.code]);continue}if(s++,s>=o.length)throw new kt("invalid address: "+r);if(a.path===!0){n=Ne(o.slice(s).join("/")),t.push([a.code,De(a.code,n)]),e.push([a.code,n]);break}let c=De(a.code,o[s]);t.push([a.code,c]),e.push([a.code,Te(a.code,c)])}return{string:Ar(e),bytes:Ft(t),tuples:t,stringTuples:e,path:n}}function Me(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=Q(r,o),i=z(s),a=x(s),c=So(a,r.slice(o+i));if(c===0){t.push([s]),e.push([s]),o+=i;continue}let w=r.slice(o+i,o+i+c);if(o+=c+i,o>r.length)throw new kt("Invalid address Uint8Array: "+D(r,"base16"));t.push([s,w]);let v=Te(s,w);if(e.push([s,v]),a.path===!0){n=v;break}}return{bytes:Uint8Array.from(r),string:Ar(e),tuples:t,stringTuples:e,path:n}}function Ar(r){let t=[];return r.map(e=>{let n=x(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Ne(t.join("/"))}function Ft(r){return R(r.map(t=>{let e=x(t[0]),n=Uint8Array.from(et(e.code));return t.length>1&&t[1]!=null&&(n=R([n,t[1]])),n}))}function So(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=Q(t instanceof Uint8Array?t:Uint8Array.from(t));return e+z(e)}}function Ne(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var kt=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};function Sr(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var Co=Symbol.for("nodejs.util.inspect.custom"),Fe=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Po=[x("dns").code,x("dns4").code,x("dns6").code,x("dnsaddr").code],ke=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Lt=class r{bytes;#t;#e;#r;#n;[Fe]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=Me(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Ir(t)}else if(Pr(t))e=Me(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",i=x("tcp"),a=x("udp"),c=x("ip4"),w=x("ip6"),v=x("dns6"),U=x("ip6zone");for(let[A,d]of this.stringTuples())A===U.code&&(s=`%${d??""}`),Po.includes(A)&&(e=i.name==="tcp"?"tcp":"udp",o=443,n=`${d??""}${s}`,t=A===v.code?6:4),(A===i.code||A===a.code)&&(e=x(A).name==="tcp"?"tcp":"udp",o=parseInt(d??"")),(A===c.code||A===w.code)&&(e=x(A).name==="tcp"?"tcp":"udp",n=`${d??""}${s}`,t=A===w.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},x(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>x(t).name)}tuples(){return this.#e.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(Ft(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===it.p2p.code&&t.push([n,o]),n===it["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?D(S.decode(`z${n}`),"base58btc"):D(q.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Sr(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=Cr.get(e.name);if(n==null)throw new ke(`no available resolver for ${e.name}`);return(await n(this,t)).map(s=>W(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[Co](){return`Multiaddr(${this.#t})`}};var Cr=new Map;function Pr(r){return!!r?.[Fe]}function W(r){return new Lt(r)}var Tr=()=>{let r=new Error("Delay aborted");return r.name="AbortError",r},To=new WeakMap;function Do({clearTimeout:r,setTimeout:t}={}){return(e,{value:n,signal:o}={})=>{if(o?.aborted)return Promise.reject(Tr());let s,i,a,c=r??clearTimeout,w=()=>{c(s),a(Tr())},v=()=>{o&&o.removeEventListener("abort",w)},U=new Promise((N,A)=>{i=()=>{v(),N(n)},a=A,s=(t??setTimeout)(i,e)});return o&&o.addEventListener("abort",w,{once:!0}),To.set(U,()=>{c(s),s=null,i()}),U}}var Uo=Do(),zt=Uo;function No(r){let[t,e]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[e](){return this}}}var Dr=No;function Mo(r){return r[Symbol.asyncIterator]!=null}function ko(r,t){let e=0;if(Mo(r))return async function*(){for await(let c of r)yield t(c,e++)}();let n=Dr(r),{value:o,done:s}=n.next();if(s===!0)return function*(){}();let i=t(o,e++);if(typeof i.then=="function")return async function*(){yield await i;for await(let c of n)yield t(c,e++)}();let a=t;return function*(){yield i;for(let c of n)yield a(c,e++)}()}var Le=ko;function $t(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Vt=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||(t-1&t)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},at=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new Vt(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new Vt(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var ze=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function $e(r={}){return Fo(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function Fo(r,t){t=t??{};let e=t.onEnd,n=new at,o,s,i,a=$t(),c=async()=>{try{return n.isEmpty()?i?{done:!0}:await new Promise((p,E)=>{s=T=>{s=null,n.push(T);try{p(r(n))}catch(I){E(I)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=$t()})}},w=p=>s!=null?s(p):(n.push(p),o),v=p=>(n=new at,s!=null?s({error:p}):(n.push({error:p}),o)),U=p=>{if(i)return o;if(t?.objectMode!==!0&&p?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return w({done:!1,value:p})},N=p=>i?o:(i=!0,p!=null?v(p):w({done:!0})),A=()=>(n=new at,N(),{done:!0}),d=p=>(N(p),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:A,throw:d,push:U,end:N,get readableLength(){return n.size},onEmpty:async p=>{let E=p?.signal;if(E?.throwIfAborted(),n.isEmpty())return;let T,I;E!=null&&(T=new Promise((M,F)=>{I=()=>{F(new ze)},E.addEventListener("abort",I)}));try{await Promise.race([a.promise,T])}finally{I!=null&&E!=null&&E?.removeEventListener("abort",I)}}},e==null)return o;let y=o;return o={[Symbol.asyncIterator](){return this},next(){return y.next()},throw(p){return y.throw(p),e!=null&&(e(p),e=void 0),{done:!0}},return(){return y.return(),e!=null&&(e(),e=void 0),{done:!0}},push:U,end(p){return y.end(p),e!=null&&(e(p),e=void 0),o},get readableLength(){return y.readableLength},onEmpty:p=>y.onEmpty(p)},o}var Bt=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function Ur(r,t,e){if(t==null)return r;if(t.aborted)return r.catch(()=>{}),Promise.reject(new Bt(e?.errorMessage,e?.errorCode,e?.errorName));let n,o=new Bt(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((s,i)=>{n=()=>{i(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var ct=new Map,Rt=class{components;init;connections;latency;constructor(t,e){this.components=t,this.init=e,this.connections=new Set,this.latency=e.latency??0}async dial(t,e){let n=$e(),o=$e(),s=this,i={source:async function*(){yield*Le(o,async c=>(s.latency>0&&await zt(s.latency),c))}(),sink:async c=>{for await(let w of c)n.push(w)},close:async()=>{n.end(),this.connections.delete(i),i.timeline.close=Date.now(),o.end(),this.connections.delete(a),a.timeline.close=Date.now()},abort:c=>{n.end(c),this.connections.delete(i),i.timeline.close=Date.now(),o.end(c),this.connections.delete(a),a.timeline.close=Date.now()},timeline:{open:Date.now()},remoteAddr:W(`${this.init.address}/p2p/${this.components.peerId}`),log:this.components.logger.forComponent("libp2p:memory:outgoing:1")},a={source:async function*(){yield*Le(n,async c=>(s.latency>0&&await zt(s.latency),c))}(),sink:async c=>{for await(let w of c)o.push(w)},close:async()=>{o.end(),this.connections.delete(a),a.timeline.close=Date.now(),n.end(),this.connections.delete(i),i.timeline.close=Date.now()},abort:c=>{o.end(c),this.connections.delete(a),a.timeline.close=Date.now(),n.end(c),this.connections.delete(i),i.timeline.close=Date.now()},timeline:{open:Date.now()},remoteAddr:W(`${this.init.address}-outgoing/p2p/${t}`),log:this.components.logger.forComponent("libp2p:memory:outgoing:1")};return this.connections.add(i),this.connections.add(a),await Ur(zt(this.latency),e),this.init.onConnection(a),i}close(){[...this.connections].forEach(t=>{t.abort(new H("Memory Connection closed"))})}};var Nr="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Mr=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Nr[e[r]&63];return t};var Ot=class extends gt{listenAddr;connection;components;init;shutdownController;constructor(t,e){super(),this.components=t,this.init=e,this.shutdownController=new AbortController,this.shutdownController.signal}async listen(t){let[[,e]]=t.stringTuples(),n=`/memory/${e??Mr()}`;if(e!=null&&ct.has(n))throw new wt(`Memory address ${n} already in use`);this.connection=new Rt(this.components,{...this.init,onConnection:this.onConnection.bind(this),address:n}),this.listenAddr=W(n),ct.set(n,this.connection),queueMicrotask(()=>{this.safeDispatchEvent("listening")})}onConnection(t){this.init.upgrader.upgradeInbound(t,{...this.init.upgraderOptions,signal:this.shutdownController.signal}).catch(e=>{t.abort(e)})}getAddrs(){return this.listenAddr==null?[]:[this.listenAddr]}updateAnnounceAddrs(){}async close(){this.connection?.close(),this.listenAddr!=null&&ct.delete(this.listenAddr.toString()),this.shutdownController.abort(),queueMicrotask(()=>{this.safeDispatchEvent("close")})}};var _t=class{components;init;constructor(t,e={}){this.components=t,this.init=e}[Be]=!0;[Symbol.toStringTag]="@libp2p/memory";[Re]=["@libp2p/transport"];async dial(t,e){e.signal.throwIfAborted();let n=ct.get(`${t.getPeerId()==null?t:t.decapsulate("/p2p")}`);if(n==null)throw new H(`No memory listener found at ${t}`);let o=await n.dial(this.components.peerId,e.signal);try{return e.signal.throwIfAborted(),await e.upgrader.upgradeOutbound(o,{...e,...this.init.upgraderOptions})}catch(s){throw o.abort(s),s}}createListener(t){return new Ot(this.components,{...t,...this.init})}listenFilter(t){return t.filter(e=>tr.exactMatch(e))}dialFilter(t){return this.listenFilter(t)}};function Lo(r){return t=>new _t(t,r)}return $r(zo);})();
2
+ "use strict";var Libp2PMemory=(()=>{var jt=Object.defineProperty;var kr=Object.getOwnPropertyDescriptor;var Fr=Object.getOwnPropertyNames;var Lr=Object.prototype.hasOwnProperty;var k=(r,t)=>{for(var e in t)jt(r,e,{get:t[e],enumerable:!0})},zr=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Fr(t))!Lr.call(r,o)&&o!==e&&jt(r,o,{get:()=>t[o],enumerable:!(n=kr(t,o))||n.enumerable});return r};var $r=r=>zr(jt({},"__esModule",{value:!0}),r);var zo={};k(zo,{memory:()=>Lo});var Be=Symbol.for("@libp2p/transport");var Ve;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Ve||(Ve={}));var H=class extends Error{static name="ConnectionFailedError";constructor(t="Connection failed"){super(t),this.name="ConnectionFailedError"}};var wt=class extends Error{static name="ListenError";constructor(t="Listen error"){super(t),this.name="ListenError"}};var gt=class extends EventTarget{#t=new Map;constructor(){super()}listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e={}){return this.dispatchEvent(new CustomEvent(t,e))}};var Re=Symbol.for("@libp2p/service-capabilities"),Oo=Symbol.for("@libp2p/service-dependencies");var bt=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",w=2**(8*o)-1;for(;;){let v=this.readAtomically(()=>{let U=this.readChar();if(U===void 0)return;let N=Number.parseInt(U,t);if(!Number.isNaN(N))return N});if(v===void 0)break;if(s*=t,s+=v,s>w||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[o]=i[0],e[o+1]=i[1],e[o+2]=i[2],e[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=t(s.subarray(0,i));return e.set(s.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Oe=45,Vr=15,X=new bt;function qt(r){if(!(r.length>Vr))return X.new(r).parseWith(()=>X.readIPv4Addr())}function Wt(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Oe))return X.new(r).parseWith(()=>X.readIPv6Addr())}function yt(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>Oe)return;let e=X.new(r).parseWith(()=>X.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}function Et(r){return!!qt(r)}function vt(r){return!!Wt(r)}function It(r){return!!yt(r)}var Xt={};k(Xt,{base58btc:()=>S,base58flickr:()=>Wr});var hs=new Uint8Array(0);function _e(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function V(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function je(r){return new TextEncoder().encode(r)}function qe(r){return new TextDecoder().decode(r)}function Br(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,c=r.charAt(0),w=Math.log(a)/Math.log(256),v=Math.log(256)/Math.log(a);function U(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var y=0,p=0,E=0,T=d.length;E!==T&&d[E]===0;)E++,y++;for(var I=(T-E)*v+1>>>0,M=new Uint8Array(I);E!==T;){for(var F=d[E],_=0,L=I-1;(F!==0||_<p)&&L!==-1;L--,_++)F+=256*M[L]>>>0,M[L]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");p=_,E++}for(var $=I-p;$!==I&&M[$]===0;)$++;for(var xt=c.repeat(y);$<I;++$)xt+=r.charAt(M[$]);return xt}function N(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var y=0;if(d[y]!==" "){for(var p=0,E=0;d[y]===c;)p++,y++;for(var T=(d.length-y)*w+1>>>0,I=new Uint8Array(T);d[y];){var M=e[d.charCodeAt(y)];if(M===255)return;for(var F=0,_=T-1;(M!==0||F<E)&&_!==-1;_--,F++)M+=a*I[_]>>>0,I[_]=M%256>>>0,M=M/256>>>0;if(M!==0)throw new Error("Non-zero carry");E=F,y++}if(d[y]!==" "){for(var L=T-E;L!==T&&I[L]===0;)L++;for(var $=new Uint8Array(p+(T-L)),xt=p;L!==T;)$[xt++]=I[L++];return $}}}function A(d){var y=N(d);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:U,decodeUnsafe:N,decode:A}}var Rr=Br,Or=Rr,Ge=Or;var Gt=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Qt=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,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 Qe(this,t)}},Jt=class{decoders;constructor(t){this.decoders=t}or(t){return Qe(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Qe(r,t){return new Jt({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Ht=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Gt(t,e,n),this.decoder=new Qt(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function K({name:r,prefix:t,encode:e,decode:n}){return new Ht(r,t,e,n)}function j({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Ge(e,r);return K({prefix:t,name:r,encode:n,decode:s=>V(o(s))})}function _r(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,a=0,c=0;for(let w=0;w<o;++w){let v=t[r[w]];if(v===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|v,i+=e,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=e||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function jr(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function qr(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function b({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=qr(n);return K({prefix:t,name:r,encode(s){return jr(s,n,e)},decode(s){return _r(s,o,e,r)}})}var S=j({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Wr=j({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Zt={};k(Zt,{base64:()=>Gr,base64pad:()=>Qr,base64url:()=>Kt,base64urlpad:()=>Jr});var Gr=b({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Qr=b({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Kt=b({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Jr=b({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Hr=r=>r.toString().split("/").slice(1),Z=r=>({match:t=>t.length<1?!1:r(t[0])?t.slice(1):!1,pattern:"fn"}),u=r=>({match:t=>Z(e=>e===r).match(t),pattern:r}),G=()=>({match:r=>Z(t=>typeof t=="string").match(r),pattern:"{string}"}),Y=()=>({match:r=>Z(t=>!isNaN(parseInt(t))).match(r),pattern:"{number}"}),m=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{S.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),ut=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{Kt.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),f=r=>({match:t=>{let e=r.match(t);return e===!1?t:e},pattern:`optional(${r.pattern})`}),C=(...r)=>({match:t=>{let e;for(let n of r){let o=n.match(t);o!==!1&&(e==null||o.length<e.length)&&(e=o)}return e??!1},pattern:`or(${r.map(t=>t.pattern).join(", ")})`}),l=(...r)=>({match:t=>{for(let e of r){let n=e.match(t);if(n===!1)return!1;t=n}return t},pattern:`and(${r.map(t=>t.pattern).join(", ")})`});function g(...r){function t(o){let s=Hr(o);for(let i of r){let a=i.match(s);if(a===!1)return!1;s=a}return s}function e(o){return t(o)!==!1}function n(o){let s=t(o);return s===!1?!1:s.length===0}return{matchers:r,matches:e,exactMatch:n}}var Xr=m(),Cs=g(Xr),St=l(u("dns4"),G()),Ct=l(u("dns6"),G()),Pt=l(u("dnsaddr"),G()),te=l(u("dns"),G()),Ps=g(St,f(m())),Ts=g(Ct,f(m())),Ds=g(Pt,f(m())),Us=g(C(te,Pt,St,Ct),f(m())),Je=l(u("ip4"),Z(Et)),He=l(u("ip6"),Z(vt)),ee=C(Je,He),B=C(ee,te,St,Ct,Pt),Ns=g(C(ee,l(C(te,Pt,St,Ct),f(m())))),Ms=g(Je),ks=g(He),Fs=g(ee),re=l(B,u("tcp"),Y()),lt=l(B,u("udp"),Y()),Ls=g(l(re,f(m()))),zs=g(lt),ne=l(lt,u("quic"),f(m())),Tt=l(lt,u("quic-v1"),f(m())),Kr=C(ne,Tt),$s=g(ne),Vs=g(Tt),Yt=C(B,re,lt,ne,Tt),Xe=C(l(Yt,u("ws"),f(m()))),Bs=g(Xe),Ke=C(l(Yt,u("wss"),f(m())),l(Yt,u("tls"),f(l(u("sni"),G())),u("ws"),f(m()))),Rs=g(Ke),Ze=l(lt,u("webrtc-direct"),f(ut()),f(ut()),f(m())),Os=g(Ze),Ye=l(Tt,u("webtransport"),f(ut()),f(ut()),f(m())),_s=g(Ye),At=C(Xe,Ke,l(re,f(m())),l(Kr,f(m())),l(B,f(m())),Ze,Ye,m()),js=g(At),Zr=l(At,u("p2p-circuit"),m()),qs=g(Zr),Yr=C(l(At,u("p2p-circuit"),u("webrtc"),f(m())),l(At,u("webrtc"),f(m())),l(u("webrtc"),f(m()))),Ws=g(Yr),tn=C(l(B,u("tcp"),Y(),u("http"),f(m())),l(B,u("http"),f(m()))),Gs=g(tn),en=C(l(B,u("tcp"),C(l(u("443"),u("http")),l(Y(),u("https")),l(Y(),u("tls"),u("http"))),f(m())),l(B,u("tls"),u("http"),f(m())),l(B,u("https"),f(m()))),Qs=g(en),rn=C(l(u("memory"),G(),f(m()))),tr=g(rn);function tt(r=0){return new Uint8Array(r)}var nn=Math.pow(2,7),on=Math.pow(2,14),sn=Math.pow(2,21),oe=Math.pow(2,28),se=Math.pow(2,35),ie=Math.pow(2,42),ae=Math.pow(2,49),h=128,P=127;function z(r){if(r<nn)return 1;if(r<on)return 2;if(r<sn)return 3;if(r<oe)return 4;if(r<se)return 5;if(r<ie)return 6;if(r<ae)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function an(r,t,e=0){switch(z(r)){case 8:t[e++]=r&255|h,r/=128;case 7:t[e++]=r&255|h,r/=128;case 6:t[e++]=r&255|h,r/=128;case 5:t[e++]=r&255|h,r/=128;case 4:t[e++]=r&255|h,r>>>=7;case 3:t[e++]=r&255|h,r>>>=7;case 2:t[e++]=r&255|h,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function cn(r,t,e=0){switch(z(r)){case 8:t.set(e++,r&255|h),r/=128;case 7:t.set(e++,r&255|h),r/=128;case 6:t.set(e++,r&255|h),r/=128;case 5:t.set(e++,r&255|h),r/=128;case 4:t.set(e++,r&255|h),r>>>=7;case 3:t.set(e++,r&255|h),r>>>=7;case 2:t.set(e++,r&255|h),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function un(r,t){let e=r[t],n=0;if(n+=e&P,e<h||(e=r[t+1],n+=(e&P)<<7,e<h)||(e=r[t+2],n+=(e&P)<<14,e<h)||(e=r[t+3],n+=(e&P)<<21,e<h)||(e=r[t+4],n+=(e&P)*oe,e<h)||(e=r[t+5],n+=(e&P)*se,e<h)||(e=r[t+6],n+=(e&P)*ie,e<h)||(e=r[t+7],n+=(e&P)*ae,e<h))return n;throw new RangeError("Could not decode varint")}function ln(r,t){let e=r.get(t),n=0;if(n+=e&P,e<h||(e=r.get(t+1),n+=(e&P)<<7,e<h)||(e=r.get(t+2),n+=(e&P)<<14,e<h)||(e=r.get(t+3),n+=(e&P)<<21,e<h)||(e=r.get(t+4),n+=(e&P)*oe,e<h)||(e=r.get(t+5),n+=(e&P)*se,e<h)||(e=r.get(t+6),n+=(e&P)*ie,e<h)||(e=r.get(t+7),n+=(e&P)*ae,e<h))return n;throw new RangeError("Could not decode varint")}function et(r,t,e=0){return t==null&&(t=tt(z(r))),t instanceof Uint8Array?an(r,t,e):cn(r,t,e)}function Q(r,t=0){return r instanceof Uint8Array?un(r,t):ln(r,t)}function R(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=tt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var ce={};k(ce,{base10:()=>pn});var pn=j({prefix:"9",name:"base10",alphabet:"0123456789"});var ue={};k(ue,{base16:()=>dn,base16upper:()=>fn});var dn=b({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),fn=b({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var le={};k(le,{base2:()=>hn});var hn=b({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var pe={};k(pe,{base256emoji:()=>bn});var rr=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}"),mn=rr.reduce((r,t,e)=>(r[e]=t,r),[]),xn=rr.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function wn(r){return r.reduce((t,e)=>(t+=mn[e],t),"")}function gn(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=xn[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var bn=K({prefix:"\u{1F680}",name:"base256emoji",encode:wn,decode:gn});var de={};k(de,{base32:()=>O,base32hex:()=>In,base32hexpad:()=>Sn,base32hexpadupper:()=>Cn,base32hexupper:()=>An,base32pad:()=>En,base32padupper:()=>vn,base32upper:()=>yn,base32z:()=>Pn});var O=b({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),yn=b({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),En=b({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vn=b({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),In=b({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),An=b({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Sn=b({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Cn=b({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Pn=b({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var fe={};k(fe,{base36:()=>pt,base36upper:()=>Tn});var pt=j({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Tn=j({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var he={};k(he,{base8:()=>Dn});var Dn=b({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var me={};k(me,{identity:()=>Un});var Un=K({prefix:"\0",name:"identity",encode:r=>qe(r),decode:r=>je(r)});var pi=new TextEncoder,di=new TextDecoder;var we={};k(we,{identity:()=>Yn});var kn=sr,nr=128,Fn=127,Ln=~Fn,zn=Math.pow(2,31);function sr(r,t,e){t=t||[],e=e||0;for(var n=e;r>=zn;)t[e++]=r&255|nr,r/=128;for(;r&Ln;)t[e++]=r&255|nr,r>>>=7;return t[e]=r|0,sr.bytes=e-n+1,t}var $n=xe,Vn=128,or=127;function xe(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw xe.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&or)<<o:(i&or)*Math.pow(2,o),o+=7}while(i>=Vn);return xe.bytes=s-n,e}var Bn=Math.pow(2,7),Rn=Math.pow(2,14),On=Math.pow(2,21),_n=Math.pow(2,28),jn=Math.pow(2,35),qn=Math.pow(2,42),Wn=Math.pow(2,49),Gn=Math.pow(2,56),Qn=Math.pow(2,63),Jn=function(r){return r<Bn?1:r<Rn?2:r<On?3:r<_n?4:r<jn?5:r<qn?6:r<Wn?7:r<Gn?8:r<Qn?9:10},Hn={encode:kn,decode:$n,encodingLength:Jn},Xn=Hn,dt=Xn;function ft(r,t=0){return[dt.decode(r,t),dt.decode.bytes]}function rt(r,t,e=0){return dt.encode(r,t,e),t}function nt(r){return dt.encodingLength(r)}function J(r,t){let e=t.byteLength,n=nt(r),o=n+nt(e),s=new Uint8Array(o+e);return rt(r,s,0),rt(e,s,n),s.set(t,o),new ot(r,e,t,s)}function Ut(r){let t=V(r),[e,n]=ft(t),[o,s]=ft(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ot(e,o,i,t)}function ir(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&_e(r.bytes,e.bytes)}}var ot=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var ar=0,Kn="identity",cr=V;function Zn(r){return J(ar,cr(r))}var Yn={code:ar,name:Kn,encode:cr,digest:Zn};var ye={};k(ye,{sha256:()=>to,sha512:()=>eo});function be({name:r,code:t,encode:e}){return new ge(r,t,e)}var ge=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?J(this.code,e):e.then(n=>J(this.code,n))}else throw Error("Unknown type, must be binary type")}};function lr(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var to=be({name:"sha2-256",code:18,encode:lr("SHA-256")}),eo=be({name:"sha2-512",code:19,encode:lr("SHA-512")});function pr(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return no(e,Ee(r),t??S.encoder);default:return oo(e,Ee(r),t??O.encoder)}}var dr=new WeakMap;function Ee(r){let t=dr.get(r);if(t==null){let e=new Map;return dr.set(r,e),e}return t}var q=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==ht)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==so)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=J(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&ir(t.multihash,n.multihash)}toString(t){return pr(this,t)}toJSON(){return{"/":pr(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??fr(n,o,s.bytes))}else if(e[io]===!0){let{version:n,multihash:o,code:s}=e,i=Ut(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==ht)throw new Error(`Version 0 CID must use dag-pb (code: ${ht}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=fr(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,ht,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=V(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new ot(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[U,N]=ft(t.subarray(e));return e+=N,U},o=n(),s=ht;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),c=n(),w=e+c,v=w-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:v,size:w}}static parse(t,e){let[n,o]=ro(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ee(s).set(n,t),s}};function ro(r,t){switch(r[0]){case"Q":{let e=t??S;return[S.prefix,e.decode(`${S.prefix}${r}`)]}case S.prefix:{let e=t??S;return[S.prefix,e.decode(r)]}case O.prefix:{let e=t??O;return[O.prefix,e.decode(r)]}case pt.prefix:{let e=t??pt;return[pt.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function no(r,t,e){let{prefix:n}=e;if(n!==S.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function oo(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var ht=112,so=18;function fr(r,t,e){let n=nt(r),o=n+nt(t),s=new Uint8Array(o+e.byteLength);return rt(r,s,0),rt(t,s,n),s.set(e,o),s}var io=Symbol.for("@ipld/js-cid/CID");var mt={...me,...le,...he,...ce,...ue,...de,...fe,...Xt,...Zt,...pe},Fi={...ye,...we};function mr(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var hr=mr("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ve=mr("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=tt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),ao={utf8:hr,"utf-8":hr,hex:mt.base16,latin1:ve,ascii:ve,binary:ve,...mt},Nt=ao;function D(r,t="utf8"){let e=Nt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Qi=parseInt("0xFFFF",16),Ji=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Mt(r,t="utf8"){let e=Nt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}var gr=Et,fo=vt,Ie=function(r){let t=0;if(r=r.toString().trim(),gr(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(fo(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=gr(e[n]),i;s&&(i=Ie(e[n]),e[n]=D(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,D(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},br=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var it={},Ae={},mo=[[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"],[481,-1,"http-path"],[777,-1,"memory"]];mo.forEach(r=>{let t=xo(...r);Ae[t.code]=t,it[t.name]=t});function xo(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function x(r){if(typeof r=="number"){if(Ae[r]!=null)return Ae[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(it[r]!=null)return it[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Na=x("ip4"),Ma=x("ip6"),ka=x("ipcidr");function Te(r,t){switch(x(r).code){case 4:case 41:return go(t);case 42:return Pe(t);case 43:return D(t,"base10");case 6:case 273:case 33:case 132:return vr(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Pe(t);case 421:return vo(t);case 444:return Er(t);case 445:return Er(t);case 466:return Eo(t);case 481:return globalThis.encodeURIComponent(Pe(t));default:return D(t,"base16")}}function De(r,t){switch(x(r).code){case 4:return yr(t);case 41:return yr(t);case 42:return Ce(t);case 43:return Mt(t,"base10");case 6:case 273:case 33:case 132:return Ue(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ce(t);case 421:return bo(t);case 444:return Io(t);case 445:return Ao(t);case 466:return yo(t);case 481:return Ce(globalThis.decodeURIComponent(t));default:return Mt(t,"base16")}}var Se=Object.values(mt).map(r=>r.decoder),wo=function(){let r=Se[0].or(Se[1]);return Se.slice(2).forEach(t=>r=r.or(t)),r}();function yr(r){if(!It(r))throw new Error("invalid ip address");return Ie(r)}function go(r){let t=br(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!It(t))throw new Error("invalid ip address");return t}function Ue(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function vr(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Ce(r){let t=Mt(r),e=Uint8Array.from(et(t.length));return R([e,t],e.length+t.length)}function Pe(r){let t=Q(r);if(r=r.slice(z(t)),r.length!==t)throw new Error("inconsistent lengths");return D(r)}function bo(r){let t;r[0]==="Q"||r[0]==="1"?t=Ut(S.decode(`z${r}`)).bytes:t=q.parse(r).multihash.bytes;let e=Uint8Array.from(et(t.length));return R([e,t],e.length+t.length)}function yo(r){let t=wo.decode(r),e=Uint8Array.from(et(t.length));return R([e,t],e.length+t.length)}function Eo(r){let t=Q(r),e=r.slice(z(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+D(e,"base64url")}function vo(r){let t=Q(r),e=r.slice(z(t));if(e.length!==t)throw new Error("inconsistent lengths");return D(e,"base58btc")}function Io(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=O.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=Ue(n);return R([e,o],e.length+o.length)}function Ao(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=O.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=Ue(n);return R([e,o],e.length+o.length)}function Er(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=D(t,"base32"),o=vr(e);return`${n}:${o}`}function Ir(r){r=Ne(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],a=x(i);if(a.size===0){t.push([a.code]),e.push([a.code]);continue}if(s++,s>=o.length)throw new kt("invalid address: "+r);if(a.path===!0){n=Ne(o.slice(s).join("/")),t.push([a.code,De(a.code,n)]),e.push([a.code,n]);break}let c=De(a.code,o[s]);t.push([a.code,c]),e.push([a.code,Te(a.code,c)])}return{string:Ar(e),bytes:Ft(t),tuples:t,stringTuples:e,path:n}}function Me(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=Q(r,o),i=z(s),a=x(s),c=So(a,r.slice(o+i));if(c===0){t.push([s]),e.push([s]),o+=i;continue}let w=r.slice(o+i,o+i+c);if(o+=c+i,o>r.length)throw new kt("Invalid address Uint8Array: "+D(r,"base16"));t.push([s,w]);let v=Te(s,w);if(e.push([s,v]),a.path===!0){n=v;break}}return{bytes:Uint8Array.from(r),string:Ar(e),tuples:t,stringTuples:e,path:n}}function Ar(r){let t=[];return r.map(e=>{let n=x(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Ne(t.join("/"))}function Ft(r){return R(r.map(t=>{let e=x(t[0]),n=Uint8Array.from(et(e.code));return t.length>1&&t[1]!=null&&(n=R([n,t[1]])),n}))}function So(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=Q(t instanceof Uint8Array?t:Uint8Array.from(t));return e+z(e)}}function Ne(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var kt=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};function Sr(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var Co=Symbol.for("nodejs.util.inspect.custom"),Fe=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Po=[x("dns").code,x("dns4").code,x("dns6").code,x("dnsaddr").code],ke=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Lt=class r{bytes;#t;#e;#r;#n;[Fe]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=Me(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Ir(t)}else if(Pr(t))e=Me(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",i=x("tcp"),a=x("udp"),c=x("ip4"),w=x("ip6"),v=x("dns6"),U=x("ip6zone");for(let[A,d]of this.stringTuples())A===U.code&&(s=`%${d??""}`),Po.includes(A)&&(e=i.name==="tcp"?"tcp":"udp",o=443,n=`${d??""}${s}`,t=A===v.code?6:4),(A===i.code||A===a.code)&&(e=x(A).name==="tcp"?"tcp":"udp",o=parseInt(d??"")),(A===c.code||A===w.code)&&(e=x(A).name==="tcp"?"tcp":"udp",n=`${d??""}${s}`,t=A===w.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},x(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>x(t).name)}tuples(){return this.#e.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(Ft(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===it.p2p.code&&t.push([n,o]),n===it["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?D(S.decode(`z${n}`),"base58btc"):D(q.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Sr(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=Cr.get(e.name);if(n==null)throw new ke(`no available resolver for ${e.name}`);return(await n(this,t)).map(s=>W(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[Co](){return`Multiaddr(${this.#t})`}};var Cr=new Map;function Pr(r){return!!r?.[Fe]}function W(r){return new Lt(r)}var Tr=()=>{let r=new Error("Delay aborted");return r.name="AbortError",r},To=new WeakMap;function Do({clearTimeout:r,setTimeout:t}={}){return(e,{value:n,signal:o}={})=>{if(o?.aborted)return Promise.reject(Tr());let s,i,a,c=r??clearTimeout,w=()=>{c(s),a(Tr())},v=()=>{o&&o.removeEventListener("abort",w)},U=new Promise((N,A)=>{i=()=>{v(),N(n)},a=A,s=(t??setTimeout)(i,e)});return o&&o.addEventListener("abort",w,{once:!0}),To.set(U,()=>{c(s),s=null,i()}),U}}var Uo=Do(),zt=Uo;function No(r){let[t,e]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[e](){return this}}}var Dr=No;function Mo(r){return r[Symbol.asyncIterator]!=null}function ko(r,t){let e=0;if(Mo(r))return async function*(){for await(let c of r)yield t(c,e++)}();let n=Dr(r),{value:o,done:s}=n.next();if(s===!0)return function*(){}();let i=t(o,e++);if(typeof i.then=="function")return async function*(){yield await i;for(let c of n)yield t(c,e++)}();let a=t;return function*(){yield i;for(let c of n)yield a(c,e++)}()}var Le=ko;function $t(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Vt=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||(t-1&t)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},at=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new Vt(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new Vt(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var ze=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function $e(r={}){return Fo(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function Fo(r,t){t=t??{};let e=t.onEnd,n=new at,o,s,i,a=$t(),c=async()=>{try{return n.isEmpty()?i?{done:!0}:await new Promise((p,E)=>{s=T=>{s=null,n.push(T);try{p(r(n))}catch(I){E(I)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=$t()})}},w=p=>s!=null?s(p):(n.push(p),o),v=p=>(n=new at,s!=null?s({error:p}):(n.push({error:p}),o)),U=p=>{if(i)return o;if(t?.objectMode!==!0&&p?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return w({done:!1,value:p})},N=p=>i?o:(i=!0,p!=null?v(p):w({done:!0})),A=()=>(n=new at,N(),{done:!0}),d=p=>(N(p),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:A,throw:d,push:U,end:N,get readableLength(){return n.size},onEmpty:async p=>{let E=p?.signal;if(E?.throwIfAborted(),n.isEmpty())return;let T,I;E!=null&&(T=new Promise((M,F)=>{I=()=>{F(new ze)},E.addEventListener("abort",I)}));try{await Promise.race([a.promise,T])}finally{I!=null&&E!=null&&E?.removeEventListener("abort",I)}}},e==null)return o;let y=o;return o={[Symbol.asyncIterator](){return this},next(){return y.next()},throw(p){return y.throw(p),e!=null&&(e(p),e=void 0),{done:!0}},return(){return y.return(),e!=null&&(e(),e=void 0),{done:!0}},push:U,end(p){return y.end(p),e!=null&&(e(p),e=void 0),o},get readableLength(){return y.readableLength},onEmpty:p=>y.onEmpty(p)},o}var Bt=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function Ur(r,t,e){if(t==null)return r;if(t.aborted)return r.catch(()=>{}),Promise.reject(new Bt(e?.errorMessage,e?.errorCode,e?.errorName));let n,o=new Bt(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((s,i)=>{n=()=>{i(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var ct=new Map,Rt=class{components;init;connections;latency;constructor(t,e){this.components=t,this.init=e,this.connections=new Set,this.latency=e.latency??0}async dial(t,e){let n=$e(),o=$e(),s=this,i={source:async function*(){yield*Le(o,async c=>(s.latency>0&&await zt(s.latency),c))}(),sink:async c=>{for await(let w of c)n.push(w)},close:async()=>{n.end(),this.connections.delete(i),i.timeline.close=Date.now(),o.end(),this.connections.delete(a),a.timeline.close=Date.now()},abort:c=>{n.end(c),this.connections.delete(i),i.timeline.close=Date.now(),o.end(c),this.connections.delete(a),a.timeline.close=Date.now()},timeline:{open:Date.now()},remoteAddr:W(`${this.init.address}/p2p/${this.components.peerId}`),log:this.components.logger.forComponent("libp2p:memory:outgoing:1")},a={source:async function*(){yield*Le(n,async c=>(s.latency>0&&await zt(s.latency),c))}(),sink:async c=>{for await(let w of c)o.push(w)},close:async()=>{o.end(),this.connections.delete(a),a.timeline.close=Date.now(),n.end(),this.connections.delete(i),i.timeline.close=Date.now()},abort:c=>{o.end(c),this.connections.delete(a),a.timeline.close=Date.now(),n.end(c),this.connections.delete(i),i.timeline.close=Date.now()},timeline:{open:Date.now()},remoteAddr:W(`${this.init.address}-outgoing/p2p/${t}`),log:this.components.logger.forComponent("libp2p:memory:outgoing:1")};return this.connections.add(i),this.connections.add(a),await Ur(zt(this.latency),e),this.init.onConnection(a),i}close(){[...this.connections].forEach(t=>{t.abort(new H("Memory Connection closed"))})}};var Nr="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Mr=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Nr[e[r]&63];return t};var Ot=class extends gt{listenAddr;connection;components;init;shutdownController;constructor(t,e){super(),this.components=t,this.init=e,this.shutdownController=new AbortController,this.shutdownController.signal}async listen(t){let[[,e]]=t.stringTuples(),n=`/memory/${e??Mr()}`;if(e!=null&&ct.has(n))throw new wt(`Memory address ${n} already in use`);this.connection=new Rt(this.components,{...this.init,onConnection:this.onConnection.bind(this),address:n}),this.listenAddr=W(n),ct.set(n,this.connection),queueMicrotask(()=>{this.safeDispatchEvent("listening")})}onConnection(t){this.init.upgrader.upgradeInbound(t,{...this.init.upgraderOptions,signal:this.shutdownController.signal}).catch(e=>{t.abort(e)})}getAddrs(){return this.listenAddr==null?[]:[this.listenAddr]}updateAnnounceAddrs(){}async close(){this.connection?.close(),this.listenAddr!=null&&ct.delete(this.listenAddr.toString()),this.shutdownController.abort(),queueMicrotask(()=>{this.safeDispatchEvent("close")})}};var _t=class{components;init;constructor(t,e={}){this.components=t,this.init=e}[Be]=!0;[Symbol.toStringTag]="@libp2p/memory";[Re]=["@libp2p/transport"];async dial(t,e){e.signal.throwIfAborted();let n=ct.get(`${t.getPeerId()==null?t:t.decapsulate("/p2p")}`);if(n==null)throw new H(`No memory listener found at ${t}`);let o=await n.dial(this.components.peerId,e.signal);try{return e.signal.throwIfAborted(),await e.upgrader.upgradeOutbound(o,{...e,...this.init.upgraderOptions})}catch(s){throw o.abort(s),s}}createListener(t){return new Ot(this.components,{...t,...this.init})}listenFilter(t){return t.filter(e=>tr.exactMatch(e))}dialFilter(t){return this.listenFilter(t)}};function Lo(r){return t=>new _t(t,r)}return $r(zo);})();
3
3
  return Libp2PMemory}));
4
4
  //# sourceMappingURL=index.min.js.map