UNPKG

@libp2p/interface-mocks

Version:
2 lines 81.4 kB
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PInterfaceMocks = factory()}(typeof self !== 'undefined' ? self : this, function () { "use strict";var Libp2PInterfaceMocks=(()=>{var Ao=Object.create;var Fe=Object.defineProperty;var Io=Object.getOwnPropertyDescriptor;var Po=Object.getOwnPropertyNames;var To=Object.getPrototypeOf,Lo=Object.prototype.hasOwnProperty;var ko=(r,e,t)=>e in r?Fe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var j=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),k=(r,e)=>{for(var t in e)Fe(r,t,{get:e[t],enumerable:!0})},_r=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Po(e))!Lo.call(r,o)&&o!==t&&Fe(r,o,{get:()=>e[o],enumerable:!(n=Io(e,o))||n.enumerable});return r};var be=(r,e,t)=>(t=r!=null?Ao(To(r)):{},_r(e||!r||!r.__esModule?Fe(t,"default",{value:r,enumerable:!0}):t,r)),No=r=>_r(Fe({},"__esModule",{value:!0}),r);var Dt=(r,e,t)=>(ko(r,typeof e!="symbol"?e+"":e,t),t);var wn=j((Uc,bn)=>{bn.exports=ur;var gn=128,Gs=127,qs=~Gs,Hs=Math.pow(2,31);function ur(r,e,t){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw ur.bytes=0,new RangeError("Could not encode varint");e=e||[],t=t||0;for(var n=t;r>=Hs;)e[t++]=r&255|gn,r/=128;for(;r&qs;)e[t++]=r&255|gn,r>>>=7;return e[t]=r|0,ur.bytes=t-n+1,e}});var En=j((Mc,xn)=>{xn.exports=lr;var Ws=128,yn=127;function lr(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a||o>49)throw lr.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&yn)<<o:(i&yn)*Math.pow(2,o),o+=7}while(i>=Ws);return lr.bytes=s-n,t}});var vn=j((Bc,Sn)=>{var Xs=Math.pow(2,7),Js=Math.pow(2,14),Ks=Math.pow(2,21),Qs=Math.pow(2,28),Ys=Math.pow(2,35),Zs=Math.pow(2,42),ei=Math.pow(2,49),ti=Math.pow(2,56),ri=Math.pow(2,63);Sn.exports=function(r){return r<Xs?1:r<Js?2:r<Ks?3:r<Qs?4:r<Ys?5:r<Zs?6:r<ei?7:r<ti?8:r<ri?9:10}});var lt=j((_c,Cn)=>{Cn.exports={encode:wn(),decode:En(),encodingLength:vn()}});var Xn=j((Hl,Wn)=>{var Te=1e3,Le=Te*60,ke=Le*60,fe=ke*24,Di=fe*7,Ri=fe*365.25;Wn.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return Fi(r);if(t==="number"&&isFinite(r))return e.long?Mi(r):Ui(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Fi(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*Ri;case"weeks":case"week":case"w":return t*Di;case"days":case"day":case"d":return t*fe;case"hours":case"hour":case"hrs":case"hr":case"h":return t*ke;case"minutes":case"minute":case"mins":case"min":case"m":return t*Le;case"seconds":case"second":case"secs":case"sec":case"s":return t*Te;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Ui(r){var e=Math.abs(r);return e>=fe?Math.round(r/fe)+"d":e>=ke?Math.round(r/ke)+"h":e>=Le?Math.round(r/Le)+"m":e>=Te?Math.round(r/Te)+"s":r+"ms"}function Mi(r){var e=Math.abs(r);return e>=fe?bt(r,e,fe,"day"):e>=ke?bt(r,e,ke,"hour"):e>=Le?bt(r,e,Le,"minute"):e>=Te?bt(r,e,Te,"second"):r+" ms"}function bt(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var Kn=j((Wl,Jn)=>{function Bi(r){t.debug=t,t.default=t,t.coerce=h,t.disable=s,t.enable=o,t.enabled=i,t.humanize=Xn(),t.destroy=l,Object.keys(r).forEach(c=>{t[c]=r[c]}),t.names=[],t.skips=[],t.formatters={};function e(c){let u=0;for(let f=0;f<c.length;f++)u=(u<<5)-u+c.charCodeAt(f),u|=0;return t.colors[Math.abs(u)%t.colors.length]}t.selectColor=e;function t(c){let u,f=null,m,p;function d(...x){if(!d.enabled)return;let S=d,I=Number(new Date),D=I-(u||I);S.diff=D,S.prev=u,S.curr=I,u=I,x[0]=t.coerce(x[0]),typeof x[0]!="string"&&x.unshift("%O");let P=0;x[0]=x[0].replace(/%([a-zA-Z%])/g,(R,L)=>{if(R==="%%")return"%";P++;let F=t.formatters[L];if(typeof F=="function"){let ge=x[P];R=F.call(S,ge),x.splice(P,1),P--}return R}),t.formatArgs.call(S,x),(S.log||t.log).apply(S,x)}return d.namespace=c,d.useColors=t.useColors(),d.color=t.selectColor(c),d.extend=n,d.destroy=t.destroy,Object.defineProperty(d,"enabled",{enumerable:!0,configurable:!1,get:()=>f!==null?f:(m!==t.namespaces&&(m=t.namespaces,p=t.enabled(c)),p),set:x=>{f=x}}),typeof t.init=="function"&&t.init(d),d}function n(c,u){let f=t(this.namespace+(typeof u>"u"?":":u)+c);return f.log=this.log,f}function o(c){t.save(c),t.namespaces=c,t.names=[],t.skips=[];let u,f=(typeof c=="string"?c:"").split(/[\s,]+/),m=f.length;for(u=0;u<m;u++)f[u]&&(c=f[u].replace(/\*/g,".*?"),c[0]==="-"?t.skips.push(new RegExp("^"+c.slice(1)+"$")):t.names.push(new RegExp("^"+c+"$")))}function s(){let c=[...t.names.map(a),...t.skips.map(a).map(u=>"-"+u)].join(",");return t.enable(""),c}function i(c){if(c[c.length-1]==="*")return!0;let u,f;for(u=0,f=t.skips.length;u<f;u++)if(t.skips[u].test(c))return!1;for(u=0,f=t.names.length;u<f;u++)if(t.names[u].test(c))return!0;return!1}function a(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function h(c){return c instanceof Error?c.stack||c.message:c}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}Jn.exports=Bi});var Qn=j((N,wt)=>{N.formatArgs=zi;N.save=$i;N.load=Vi;N.useColors=_i;N.storage=ji();N.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();N.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function _i(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function zi(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+wt.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}N.log=console.debug||console.log||(()=>{});function $i(r){try{r?N.storage.setItem("debug",r):N.storage.removeItem("debug")}catch{}}function Vi(){let r;try{r=N.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function ji(){try{return localStorage}catch{}}wt.exports=Kn()(N);var{formatters:Gi}=wt.exports;Gi.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var to=j((hf,eo)=>{"use strict";function Zn(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function ta(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return Zn(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),Zn(new o,t)}}eo.exports=ta});var lo=j((xh,uo)=>{"use strict";uo.exports=r=>{if(Object.prototype.toString.call(r)!=="[object Object]")return!1;let e=Object.getPrototypeOf(r);return e===null||e===Object.prototype}});var bo=j((mo,go)=>{"use strict";var It=lo(),{hasOwnProperty:ho}=Object.prototype,{propertyIsEnumerable:ma}=Object,De=(r,e,t)=>Object.defineProperty(r,e,{value:t,writable:!0,enumerable:!0,configurable:!0}),ga=mo,fo={concatArrays:!1,ignoreUndefined:!1},Pt=r=>{let e=[];for(let t in r)ho.call(r,t)&&e.push(t);if(Object.getOwnPropertySymbols){let t=Object.getOwnPropertySymbols(r);for(let n of t)ma.call(r,n)&&e.push(n)}return e};function Re(r){return Array.isArray(r)?ba(r):It(r)?wa(r):r}function ba(r){let e=r.slice(0,0);return Pt(r).forEach(t=>{De(e,t,Re(r[t]))}),e}function wa(r){let e=Object.getPrototypeOf(r)===null?Object.create(null):{};return Pt(r).forEach(t=>{De(e,t,Re(r[t]))}),e}var po=(r,e,t,n)=>(t.forEach(o=>{typeof e[o]>"u"&&n.ignoreUndefined||(o in r&&r[o]!==Object.getPrototypeOf(r)?De(r,o,Nr(r[o],e[o],n)):De(r,o,Re(e[o])))}),r),ya=(r,e,t)=>{let n=r.slice(0,0),o=0;return[r,e].forEach(s=>{let i=[];for(let a=0;a<s.length;a++)ho.call(s,a)&&(i.push(String(a)),s===r?De(n,o++,s[a]):De(n,o++,Re(s[a])));n=po(n,s,Pt(s).filter(a=>!i.includes(a)),t)}),n};function Nr(r,e,t){return t.concatArrays&&Array.isArray(r)&&Array.isArray(e)?ya(r,e,t):!It(e)||!It(r)?Re(e):po(r,e,Pt(e),t)}go.exports=function(...r){let e=Nr(Re(fo),this!==ga&&this||{},fo),t={_:{}};for(let n of r)if(n!==void 0){if(!It(n))throw new TypeError("`"+n+"` is not an Option Object");t=Nr(t,{_:n},e)}return t._}});var Ea={};k(Ea,{connectionPair:()=>Lt,mockConnection:()=>me,mockConnectionEncrypter:()=>jn,mockConnectionGater:()=>Gn,mockConnectionManager:()=>Eo,mockDuplex:()=>vo,mockMetrics:()=>Co,mockMultiaddrConnPair:()=>ao,mockMultiaddrConnection:()=>tt,mockMuxer:()=>At,mockNetwork:()=>kt,mockRegistrar:()=>Tt,mockStream:()=>xo,mockUpgrader:()=>So});var Rt=class extends Error{code;constructor(e="Unexpected Peer"){super(e),this.code=Rt.code}},Ue=Rt;Dt(Ue,"code","ERR_UNEXPECTED_PEER");var Oo=Vr,zr=128,Do=127,Ro=~Do,Fo=Math.pow(2,31);function Vr(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Fo;)e[t++]=r&255|zr,r/=128;for(;r&Ro;)e[t++]=r&255|zr,r>>>=7;return e[t]=r|0,Vr.bytes=t-n+1,e}var Uo=Ft,Mo=128,$r=127;function Ft(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Ft.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&$r)<<o:(i&$r)*Math.pow(2,o),o+=7}while(i>=Mo);return Ft.bytes=s-n,t}var Bo=Math.pow(2,7),_o=Math.pow(2,14),zo=Math.pow(2,21),$o=Math.pow(2,28),Vo=Math.pow(2,35),jo=Math.pow(2,42),Go=Math.pow(2,49),qo=Math.pow(2,56),Ho=Math.pow(2,63),Wo=function(r){return r<Bo?1:r<_o?2:r<zo?3:r<$o?4:r<Vo?5:r<jo?6:r<Go?7:r<qo?8:r<Ho?9:10},Xo={encode:Oo,decode:Uo,encodingLength:Wo},Jo=Xo,Me=Jo;var Be=(r,e=0)=>[Me.decode(r,e),Me.decode.bytes],we=(r,e,t=0)=>(Me.encode(r,e,t),e),ye=r=>Me.encodingLength(r);var Pa=new Uint8Array(0);var jr=(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},H=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 Gr=r=>new TextEncoder().encode(r),qr=r=>new TextDecoder().decode(r);var Y=(r,e)=>{let t=e.byteLength,n=ye(r),o=n+ye(t),s=new Uint8Array(o+t);return we(r,s,0),we(t,s,n),s.set(e,o),new xe(r,t,e,s)},oe=r=>{let e=H(r),[t,n]=Be(e),[o,s]=Be(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new xe(t,o,i,e)},Wr=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&jr(r.bytes,t.bytes)}},xe=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var zt={};k(zt,{base58btc:()=>C,base58flickr:()=>ts});function Ko(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,h=r.charAt(0),l=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function u(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var d=0,x=0,S=0,I=p.length;S!==I&&p[S]===0;)S++,d++;for(var D=(I-S)*c+1>>>0,P=new Uint8Array(D);S!==I;){for(var B=p[S],R=0,L=D-1;(B!==0||R<x)&&L!==-1;L--,R++)B+=256*P[L]>>>0,P[L]=B%a>>>0,B=B/a>>>0;if(B!==0)throw new Error("Non-zero carry");x=R,S++}for(var F=D-x;F!==D&&P[F]===0;)F++;for(var ge=h.repeat(d);F<D;++F)ge+=r.charAt(P[F]);return ge}function f(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var d=0;if(p[d]!==" "){for(var x=0,S=0;p[d]===h;)x++,d++;for(var I=(p.length-d)*l+1>>>0,D=new Uint8Array(I);p[d];){var P=t[p.charCodeAt(d)];if(P===255)return;for(var B=0,R=I-1;(P!==0||B<S)&&R!==-1;R--,B++)P+=a*D[R]>>>0,D[R]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");S=B,d++}if(p[d]!==" "){for(var L=I-S;L!==I&&D[L]===0;)L++;for(var F=new Uint8Array(x+(I-L)),ge=x;L!==I;)F[ge++]=D[L++];return F}}}function m(p){var d=f(p);if(d)return d;throw new Error(`Non-${e} character`)}return{encode:u,decodeUnsafe:f,decode:m}}var Qo=Ko,Yo=Qo,Xr=Yo;var Ut=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 Jr(this,e)}},Bt=class{constructor(e){this.decoders=e}or(e){return Jr(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`)}},Jr=(r,e)=>new Bt({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),_t=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ut(e,t,n),this.decoder=new Mt(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Ee=({name:r,prefix:e,encode:t,decode:n})=>new _t(r,e,t,n),Z=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=Xr(t,e);return Ee({prefix:r,name:e,encode:n,decode:s=>H(o(s))})},Zo=(r,e,t,n)=>{let o={};for(let c=0;c<e.length;++c)o[e[c]]=c;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,h=0,l=0;for(let c=0;c<s;++c){let u=o[r[c]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<t|u,a+=t,a>=8&&(a-=8,i[l++]=255&h>>a)}if(a>=t||255&h<<8-a)throw new SyntaxError("Unexpected end of data");return i},es=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let h=0;h<r.length;++h)for(a=a<<8|r[h],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},E=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>Ee({prefix:e,name:r,encode(o){return es(o,n,t)},decode(o){return Zo(o,n,t,r)}});var C=Z({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ts=Z({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var $t={};k($t,{base32:()=>_,base32hex:()=>ss,base32hexpad:()=>as,base32hexpadupper:()=>cs,base32hexupper:()=>is,base32pad:()=>ns,base32padupper:()=>os,base32upper:()=>rs,base32z:()=>us});var _=E({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),rs=E({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ns=E({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),os=E({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ss=E({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),is=E({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),as=E({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),cs=E({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),us=E({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Kr=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return fs(t,Vt(r),e||C.encoder);default:return hs(t,Vt(r),e||_.encoder)}};var Qr=new WeakMap,Vt=r=>{let e=Qr.get(r);if(e==null){let t=new Map;return Qr.set(r,t),t}return e},g=class{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!==_e)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==ds)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return g.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=Y(e,t);return g.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 g.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&Wr(e.multihash,n.multihash)}toString(e){return Kr(this,e)}toJSON(){return{"/":Kr(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 g)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new g(n,o,s,i||Yr(n,o,s.bytes))}else if(t[ps]===!0){let{version:n,multihash:o,code:s}=t,i=oe(o);return g.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!==_e)throw new Error(`Version 0 CID must use dag-pb (code: ${_e}) block encoding`);return new g(e,t,n,n.bytes)}case 1:{let o=Yr(e,t,n.bytes);return new g(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return g.create(0,_e,e)}static createV1(e,t){return g.create(1,e,t)}static decode(e){let[t,n]=g.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=g.inspectBytes(e),n=t.size-t.multihashSize,o=H(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new xe(t.multihashCode,t.digestSize,s,o);return[t.version===0?g.createV0(i):g.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[u,f]=Be(e.subarray(t));return t+=f,u},o=n(),s=_e;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(),h=n(),l=t+h,c=l-i;return{version:o,codec:s,multihashCode:a,digestSize:h,multihashSize:c,size:l}}static parse(e,t){let[n,o]=ls(e,t),s=g.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Vt(s).set(n,e),s}},ls=(r,e)=>{switch(r[0]){case"Q":{let t=e||C;return[C.prefix,t.decode(`${C.prefix}${r}`)]}case C.prefix:{let t=e||C;return[C.prefix,t.decode(r)]}case _.prefix:{let t=e||_;return[_.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)]}}},fs=(r,e,t)=>{let{prefix:n}=t;if(n!==C.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},hs=(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},_e=112,ds=18,Yr=(r,e,t)=>{let n=ye(r),o=n+ye(e),s=new Uint8Array(o+t.byteLength);return we(r,s,0),we(e,s,n),s.set(t,o),s},ps=Symbol.for("@ipld/js-cid/CID");var jt={};k(jt,{identity:()=>ms});var ms=Ee({prefix:"\0",name:"identity",encode:r=>qr(r),decode:r=>Gr(r)});var Gt={};k(Gt,{base2:()=>gs});var gs=E({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var qt={};k(qt,{base8:()=>bs});var bs=E({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ht={};k(Ht,{base10:()=>ws});var ws=Z({prefix:"9",name:"base10",alphabet:"0123456789"});var Wt={};k(Wt,{base16:()=>ys,base16upper:()=>xs});var ys=E({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),xs=E({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Xt={};k(Xt,{base36:()=>Es,base36upper:()=>Ss});var Es=Z({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ss=Z({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Kt={};k(Kt,{base64:()=>Jt,base64pad:()=>vs,base64url:()=>Cs,base64urlpad:()=>As});var Jt=E({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),vs=E({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Cs=E({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),As=E({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Qt={};k(Qt,{base256emoji:()=>ks});var Zr=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}"),Is=Zr.reduce((r,e,t)=>(r[t]=e,r),[]),Ps=Zr.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Ts(r){return r.reduce((e,t)=>(e+=Is[t],e),"")}function Ls(r){let e=[];for(let t of r){let n=Ps[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var ks=Ee({prefix:"\u{1F680}",name:"base256emoji",encode:Ts,decode:Ls});var er={};k(er,{sha256:()=>nt,sha512:()=>Ns});var Zt=({name:r,code:e,encode:t})=>new Yt(r,e,t),Yt=class{constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Y(this.code,t):t.then(n=>Y(this.code,n))}else throw Error("Unknown type, must be binary type")}};var tn=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),nt=Zt({name:"sha2-256",code:18,encode:tn("SHA-256")}),Ns=Zt({name:"sha2-512",code:19,encode:tn("SHA-512")});var tr={};k(tr,{identity:()=>ot});var rn=0,Os="identity",nn=H,Ds=r=>Y(rn,nn(r)),ot={code:rn,name:Os,encode:nn,digest:Ds};var Ya=new TextEncoder,Za=new TextDecoder;var ee={...jt,...Gt,...qt,...Ht,...Wt,...$t,...Xt,...zt,...Kt,...Qt},oc={...er,...tr};function ie(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 v=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var rr=Symbol.for("@libp2p/peer-id");function nr(r){return r!=null&&!!r[rr]}var Us=Symbol.for("nodejs.util.inspect.custom"),on=Object.values(ee).map(r=>r.decoder).reduce((r,e)=>r.or(e),ee.identity.decoder),sn=114,an=36,cn=37,ze=class{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()})`}get[rr](){return!0}toString(){return this.string==null&&(this.string=C.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return g.createV1(sn,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return ie(this.multihash.bytes,e);if(typeof e=="string")return w(e).equals(this);if(e?.multihash?.bytes!=null)return ie(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[Us](){return`PeerId(${this.toString()})`}},$e=class extends ze{constructor(e){super({...e,type:"RSA"}),this.type="RSA",this.publicKey=e.publicKey}},Ve=class extends ze{constructor(e){super({...e,type:"Ed25519"}),this.type="Ed25519",this.publicKey=e.multihash.digest}},je=class extends ze{constructor(e){super({...e,type:"secp256k1"}),this.type="secp256k1",this.publicKey=e.multihash.digest}};function w(r,e){if(e=e??on,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=oe(C.decode(`z${r}`));return r.startsWith("12D")?new Ve({multihash:t}):r.startsWith("16U")?new je({multihash:t}):new $e({multihash:t})}return st(on.decode(r))}function st(r){try{let e=oe(r);if(e.code===ot.code){if(e.digest.length===an)return new Ve({multihash:e});if(e.digest.length===cn)return new je({multihash:e})}if(e.code===nt.code)return new $e({multihash:e})}catch{return Ms(g.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Ms(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==sn)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===nt.code)return new $e({multihash:r.multihash});if(e.code===ot.code){if(e.digest.length===an)return new Ve({multihash:r.multihash});if(e.digest.length===cn)return new je({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var it=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 h=a==="0",l=2**(8*o)-1;for(;;){let c=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let f=Number.parseInt(u,e);if(!Number.isNaN(f))return f});if(c===void 0)break;if(s*=e,s+=c,s>l||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&h&&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 un=45,Bs=15,Se=new it;function or(r){if(!(r.length>Bs))return Se.new(r).parseWith(()=>Se.readIPv4Addr())}function sr(r){if(!(r.length>un))return Se.new(r).parseWith(()=>Se.readIPv6Addr())}function at(r){if(!(r.length>un))return Se.new(r).parseWith(()=>Se.readIPAddr())}function ln(r){return!!or(r)}function fn(r){return!!sr(r)}function ct(r){return!!at(r)}function ae(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function W(r=0){return globalThis.Buffer?.alloc!=null?ae(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function z(r=0){return globalThis.Buffer?.allocUnsafe!=null?ae(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function dn(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var hn=dn("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ir=dn("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=z(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),_s={utf8:hn,"utf-8":hn,hex:ee.base16,latin1:ir,ascii:ir,binary:ir,...ee},ut=_s;function A(r,e="utf8"){let t=ut[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 pn=ln,zs=fn,ar=function(r){let e=0;if(r=r.toString().trim(),pn(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(zs(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=pn(t[n]),i;s&&(i=ar(t[n]),t[n]=A(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,A(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")},mn=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 Ge={},cr={},Vs=[[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"]];Vs.forEach(r=>{let e=js(...r);cr[e.code]=e,Ge[e.name]=e});function js(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function b(r){if(typeof r=="number"){if(cr[r]!=null)return cr[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ge[r]!=null)return Ge[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var G=be(lt(),1);function T(r,e="utf8"){let t=ut[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?ae(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function U(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=z(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return ae(t)}var Yc=parseInt("0xFFFF",16),Zc=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var ku=b("ip4"),Nu=b("ip6"),Ou=b("ipcidr");function Nn(r,e){switch(b(r).code){case 4:case 41:return ci(e);case 42:return Ln(e);case 6:case 273:case 33:case 132:return Dn(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ln(e);case 421:return hi(e);case 444:return kn(e);case 445:return kn(e);case 466:return fi(e);default:return A(e,"base16")}}function On(r,e){switch(b(r).code){case 4:return Pn(e);case 41:return Pn(e);case 42:return Tn(e);case 6:case 273:case 33:case 132:return hr(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Tn(e);case 421:return ui(e);case 444:return di(e);case 445:return pi(e);case 466:return li(e);default:return T(e,"base16")}}var fr=Object.values(ee).map(r=>r.decoder),ai=function(){let r=fr[0].or(fr[1]);return fr.slice(2).forEach(e=>r=r.or(e)),r}();function Pn(r){if(!ct(r))throw new Error("invalid ip address");return ar(r)}function ci(r){let e=mn(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!ct(e))throw new Error("invalid ip address");return e}function hr(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function Dn(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Tn(r){let e=T(r),t=Uint8Array.from(G.default.encode(e.length));return U([t,e],t.length+e.length)}function Ln(r){let e=G.default.decode(r);if(r=r.slice(G.default.decode.bytes),r.length!==e)throw new Error("inconsistent lengths");return A(r)}function ui(r){let e;r[0]==="Q"||r[0]==="1"?e=oe(C.decode(`z${r}`)).bytes:e=g.parse(r).multihash.bytes;let t=Uint8Array.from(G.default.encode(e.length));return U([t,e],t.length+e.length)}function li(r){let e=ai.decode(r),t=Uint8Array.from(G.default.encode(e.length));return U([t,e],t.length+e.length)}function fi(r){let e=G.default.decode(r),t=r.slice(G.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return"u"+A(t,"base64url")}function hi(r){let e=G.default.decode(r),t=r.slice(G.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return A(t,"base58btc")}function di(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=_.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=hr(n);return U([t,o],t.length+o.length)}function pi(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=_.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=hr(n);return U([t,o],t.length+o.length)}function kn(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=A(e,"base32"),o=Dn(t);return`${n}:${o}`}var ve=be(lt(),1);function mi(r){let e=[],t=r.split("/").slice(1);if(t.length===1&&t[0]==="")return[];for(let n=0;n<t.length;n++){let o=t[n],s=b(o);if(s.size===0){e.push([o]);continue}if(n++,n>=t.length)throw Fn("invalid address: "+r);if(s.path===!0){e.push([o,br(t.slice(n).join("/"))]);break}e.push([o,t[n]])}return e}function gi(r){let e=[];return r.map(t=>{let n=dt(t);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),br(e.join("/"))}function bi(r){return r.map(e=>{Array.isArray(e)||(e=[e]);let t=dt(e);return e.length>1?[t.code,On(t.code,e[1])]:[t.code]})}function dr(r){return r.map(e=>{let t=dt(e);return e[1]!=null?[t.code,Nn(t.code,e[1])]:[t.code]})}function pr(r){return ht(U(r.map(e=>{let t=dt(e),n=Uint8Array.from(ve.default.encode(t.code));return e.length>1&&e[1]!=null&&(n=U([n,e[1]])),n})))}function mr(r,e){return r.size>0?r.size/8:r.size===0?0:ve.default.decode(e)+(ve.default.decode.bytes??0)}function ft(r){let e=[],t=0;for(;t<r.length;){let n=ve.default.decode(r,t),o=ve.default.decode.bytes??0,s=b(n),i=mr(s,r.slice(t+o));if(i===0){e.push([n]),t+=o;continue}let a=r.slice(t+o,t+o+i);if(t+=i+o,t>r.length)throw Fn("Invalid address Uint8Array: "+A(r,"base16"));e.push([n,a])}return e}function gr(r){let e=ft(r),t=dr(e);return gi(t)}function wi(r){r=br(r);let e=mi(r),t=bi(e);return pr(t)}function Rn(r){return wi(r)}function ht(r){let e=yi(r);if(e!=null)throw e;return Uint8Array.from(r)}function yi(r){try{ft(r)}catch(e){return e}}function br(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function Fn(r){return new Error("Error parsing address: "+r)}function dt(r){return b(r[0])}var wr=be(lt(),1);var X=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Ce=function(r,e,t,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!o:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(r,t):o?o.value=t:e.set(r,t),t},qe,He,We,re,Un,Ei=Symbol.for("nodejs.util.inspect.custom"),Si=[b("dns").code,b("dns4").code,b("dns6").code,b("dnsaddr").code],vi=new Map,Mn=Symbol.for("@multiformats/js-multiaddr/multiaddr");function yr(r){return!!r?.[Mn]}var J=class{constructor(e){if(qe.set(this,void 0),He.set(this,void 0),We.set(this,void 0),re.set(this,void 0),this[Un]=!0,e==null&&(e=""),e instanceof Uint8Array)this.bytes=ht(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=Rn(e)}else if(yr(e))this.bytes=ht(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return X(this,qe,"f")==null&&Ce(this,qe,gr(this.bytes),"f"),X(this,qe,"f")}toJSON(){return this.toString()}toOptions(){let e,t,n,o,s="",i=b("tcp"),a=b("udp"),h=b("ip4"),l=b("ip6"),c=b("dns6"),u=b("ip6zone");for(let[m,p]of this.stringTuples())m===u.code&&(s=`%${p??""}`),Si.includes(m)&&(t=i.name,o=443,n=`${p??""}${s}`,e=m===c.code?6:4),(m===i.code||m===a.code)&&(t=b(m).name,o=parseInt(p??"")),(m===h.code||m===l.code)&&(t=b(m).name,n=`${p??""}${s}`,e=m===l.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.protoCodes().map(e=>Object.assign({},b(e)))}protoCodes(){let e=[],t=this.bytes,n=0;for(;n<t.length;){let o=wr.default.decode(t,n),s=wr.default.decode.bytes??0,i=b(o),a=mr(i,t.slice(n+s));n+=a+s,e.push(o)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return X(this,He,"f")==null&&Ce(this,He,ft(this.bytes),"f"),X(this,He,"f")}stringTuples(){return X(this,We,"f")==null&&Ce(this,We,dr(this.tuples()),"f"),X(this,We,"f")}encapsulate(e){return e=new J(e),new J(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 J(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 J(pr(t.slice(0,n)));return this}getPeerId(){try{let t=this.stringTuples().filter(n=>n[0]===Ge.ipfs.code).pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?A(C.decode(`z${n}`),"base58btc"):A(g.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){if(X(this,re,"f")===void 0)try{Ce(this,re,this.stringTuples().filter(e=>b(e[0]).path===!0)[0][1],"f"),X(this,re,"f")==null&&Ce(this,re,null,"f")}catch{Ce(this,re,null,"f")}return X(this,re,"f")}equals(e){return ie(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=vi.get(t.name);if(n==null)throw new v(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new J(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)}[(qe=new WeakMap,He=new WeakMap,We=new WeakMap,re=new WeakMap,Un=Mn,Ei)](){return`Multiaddr(${gr(this.bytes)})`}};function te(r){return new J(r)}var _n=Symbol.for("@achingbrain/uint8arraylist");function Bn(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let o=t+n.byteLength;if(e<o)return{buf:n,index:e-t};t=o}throw new RangeError("index is out of bounds")}function pt(r){return!!r?.[_n]}var y=class{constructor(...e){Object.defineProperty(this,_n,{value:!0}),this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(pt(n))t+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(pt(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=Bn(this.bufs,e);return t.buf[t.index]}set(e,t){let n=Bn(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(pt(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:o}=this._subList(e,t);return U(n,o)}subarray(e,t){let{bufs:n,length:o}=this._subList(e,t);return n.length===1?n[0]:U(n,o)}sublist(e,t){let{bufs:n,length:o}=this._subList(e,t),s=new y;return s.length=o,s.bufs=n,s}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,h=a+i.byteLength;if(o=h,e>=h)continue;let l=e>=a&&e<h,c=t>a&&t<=h;if(l&&c){if(e===a&&t===h){n.push(i);break}let u=e-a;n.push(i.subarray(u,u+(t-e)));break}if(l){if(e===0){n.push(i);continue}n.push(i.subarray(e-a));continue}if(c){if(t===h){n.push(i);break}n.push(i.subarray(0,t-a));break}n.push(i)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!pt(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let u=0;u<s;u++)i[u]=-1;for(let u=0;u<o;u++)i[n[u]]=u;let a=i,h=this.byteLength-n.byteLength,l=n.byteLength-1,c;for(let u=t;u<=h;u+=c){c=0;for(let f=l;f>=0;f--){let m=this.get(u+f);if(n[f]!==m){c=Math.max(1,f-a[m]);break}}if(c===0)return u}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=z(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let o=W(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,t,n),this.write(o,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let o=W(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,t,n),this.write(o,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let o=W(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,t,n),this.write(o,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=z(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let o=W(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,t,n),this.write(o,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let o=W(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,t,n),this.write(o,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let o=W(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,t,n),this.write(o,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let o=W(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,t,n),this.write(o,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let o=W(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,t,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof y)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!ie(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new y;return n.bufs=e,t==null&&(t=e.reduce((o,s)=>o+s.byteLength,0)),n.length=t,n}};function xr(r){let e=async function*(){let t=yield,n=new y;for await(let o of r){if(t==null){n.append(o),t=yield n,n=new y;continue}for(n.append(o);n.length>=t;){let s=n.sublist(0,t);if(n.consume(t),t=yield s,t==null){n.length>0&&(t=yield n,n=new y);break}}}if(t!=null)throw Object.assign(new Error(`stream ended before ${t} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return e.next(),e}var mt=class{constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this