@libp2p/websockets 5.0.7 → 5.0.9

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,3 +1,3 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PWebsockets = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PWebsockets=(()=>{var Dn=Object.create;var Pe=Object.defineProperty;var Bn=Object.getOwnPropertyDescriptor;var Rn=Object.getOwnPropertyNames;var kn=Object.getPrototypeOf,zn=Object.prototype.hasOwnProperty;var P=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),O=(t,e)=>{for(var r in e)Pe(t,r,{get:e[r],enumerable:!0})},kt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Rn(e))!zn.call(t,o)&&o!==r&&Pe(t,o,{get:()=>e[o],enumerable:!(n=Bn(e,o))||n.enumerable});return t};var V=(t,e,r)=>(r=t!=null?Dn(kn(t)):{},kt(e||!t||!t.__esModule?Pe(r,"default",{value:t,enumerable:!0}):r,t)),Wn=t=>kt(Pe({},"__esModule",{value:!0}),t);var Wt=P(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});var je=class{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(e){if(this.isStopped)return;let r={value:e,done:!1};if(this.pullQueue.length){let n=this.pullQueue.shift();n&&n.resolve(r)}else this.pushQueue.push(Promise.resolve(r)),this.highWaterMark!==void 0&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(let e of this.pullQueue)e.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(e){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(let r of this.pullQueue)r.reject(e);this.pullQueue.length=0}else{let r=Promise.reject(e);r.catch(()=>{}),this.pushQueue.push(r)}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:e=>{let r=this.pushQueue.shift();return r?(this.lowWaterMark!==void 0&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),r):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((n,o)=>{this.pullQueue.push({resolve:n,reject:o})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}},Fe=class{constructor(e,{highWaterMark:r=100,lowWaterMark:n=1}={}){let o=new je;o.highWaterMark=r,o.lowWaterMark=n,o.removeCallback=e({push:s=>o.push(s),stop:()=>o.stop(),fail:s=>o.fail(s),on:(s,i)=>{o.eventHandlers[s]=i}})||(()=>{}),this[Symbol.asyncIterator]=()=>o[Symbol.asyncIterator](),Object.freeze(this)}};Ue.EventIterator=Fe;Ue.default=Fe});var Vt=P(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});var Qe=Wt();he.EventIterator=Qe.EventIterator;function Vn(t,e,r){return new Qe.EventIterator(({push:n})=>(this.addEventListener(t,n,e),()=>this.removeEventListener(t,n,e)),r)}he.subscribe=Vn;he.default=Qe.EventIterator});var bt=P((ya,br)=>{"use strict";var Ko=typeof navigator<"u"&&navigator.product==="ReactNative";function Zo(){return Ko?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}var xe=self.URL,mr=Zo(),mt=class{constructor(e="",r=mr){this.super=new xe(e,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(e){this.super.hash=e}set host(e){this.super.host=e}set hostname(e){this.super.hostname=e}set href(e){this.super.href=e}set password(e){this.super.password=e}set pathname(e){this.super.pathname=e}set port(e){this.super.port=e}set protocol(e){this.super.protocol=e}set search(e){this.super.search=e}set username(e){this.super.username=e}static createObjectURL(e){return xe.createObjectURL(e)}static revokeObjectURL(e){xe.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function Yo(t){if(typeof t=="string")return new xe(t).toString();if(!(t instanceof xe)){let e=t.username&&t.password?`${t.username}:${t.password}@`:"",r=t.auth?t.auth+"@":"",n=t.port?":"+t.port:"",o=t.protocol?t.protocol+"//":"",s=t.host||"",i=t.hostname||"",u=t.search||(t.query?"?"+t.query:""),d=t.hash||"",h=t.pathname||"",a=t.path||h+u;return`${o}${e||r}${s||i+n}${a}${d}`}}br.exports={URLWithLegacySupport:mt,URLSearchParams:self.URLSearchParams,defaultBase:mr,format:Yo}});var yr=P((xa,gr)=>{"use strict";var{URLWithLegacySupport:wr,format:es}=bt();gr.exports=(t,e={},r={},n)=>{let o=e.protocol?e.protocol.replace(":",""):"http";o=(r[o]||n||o)+":";let s;try{s=new wr(t)}catch{s={}}let i=Object.assign({},e,{protocol:o||s.protocol,host:e.host||s.host});return new wr(t,es(i)).toString()}});var vr=P((va,xr)=>{"use strict";var{URLWithLegacySupport:ts,format:rs,URLSearchParams:ns,defaultBase:os}=bt(),ss=yr();xr.exports={URL:ts,URLSearchParams:ns,format:rs,relative:ss,defaultBase:os}});var $r=P((Ra,Mr)=>{Mr.exports=yt;var Nr=128,ps=127,hs=~ps,ms=Math.pow(2,31);function yt(t,e,r){if(Number.MAX_SAFE_INTEGER&&t>Number.MAX_SAFE_INTEGER)throw yt.bytes=0,new RangeError("Could not encode varint");e=e||[],r=r||0;for(var n=r;t>=ms;)e[r++]=t&255|Nr,t/=128;for(;t&hs;)e[r++]=t&255|Nr,t>>>=7;return e[r]=t|0,yt.bytes=r-n+1,e}});var Rr=P((ka,Br)=>{Br.exports=xt;var bs=128,Dr=127;function xt(t,n){var r=0,n=n||0,o=0,s=n,i,u=t.length;do{if(s>=u||o>49)throw xt.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&Dr)<<o:(i&Dr)*Math.pow(2,o),o+=7}while(i>=bs);return xt.bytes=s-n,r}});var zr=P((za,kr)=>{var ws=Math.pow(2,7),gs=Math.pow(2,14),ys=Math.pow(2,21),xs=Math.pow(2,28),vs=Math.pow(2,35),Cs=Math.pow(2,42),Es=Math.pow(2,49),Ss=Math.pow(2,56),As=Math.pow(2,63);kr.exports=function(t){return t<ws?1:t<gs?2:t<ys?3:t<xs?4:t<vs?5:t<Cs?6:t<Es?7:t<Ss?8:t<As?9:10}});var De=P((Wa,Wr)=>{Wr.exports={encode:$r(),decode:Rr(),encodingLength:zr()}});var Yr=P((oc,Zr)=>{"use strict";function Kr(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}function zs(t,e,r){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof e=="object"&&(r=e,e=""),e&&(r.code=e);try{return Kr(t,r)}catch{r.message=t.message,r.stack=t.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(t)),Kr(new o,r)}}Zr.exports=zs});var an=P((bc,sn)=>{var ce=1e3,ue=ce*60,le=ue*60,X=le*24,Gs=X*7,Js=X*365.25;sn.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return Hs(t);if(r==="number"&&isFinite(t))return e.long?Ks(t):Xs(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function Hs(t){if(t=String(t),!(t.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(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*Js;case"weeks":case"week":case"w":return r*Gs;case"days":case"day":case"d":return r*X;case"hours":case"hour":case"hrs":case"hr":case"h":return r*le;case"minutes":case"minute":case"mins":case"min":case"m":return r*ue;case"seconds":case"second":case"secs":case"sec":case"s":return r*ce;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function Xs(t){var e=Math.abs(t);return e>=X?Math.round(t/X)+"d":e>=le?Math.round(t/le)+"h":e>=ue?Math.round(t/ue)+"m":e>=ce?Math.round(t/ce)+"s":t+"ms"}function Ks(t){var e=Math.abs(t);return e>=X?We(t,e,X,"day"):e>=le?We(t,e,le,"hour"):e>=ue?We(t,e,ue,"minute"):e>=ce?We(t,e,ce,"second"):t+" ms"}function We(t,e,r,n){var o=e>=r*1.5;return Math.round(t/r)+" "+n+(o?"s":"")}});var un=P((wc,cn)=>{function Zs(t){r.debug=r,r.default=r,r.coerce=d,r.disable=s,r.enable=o,r.enabled=i,r.humanize=an(),r.destroy=h,Object.keys(t).forEach(a=>{r[a]=t[a]}),r.names=[],r.skips=[],r.formatters={};function e(a){let c=0;for(let p=0;p<a.length;p++)c=(c<<5)-c+a.charCodeAt(p),c|=0;return r.colors[Math.abs(c)%r.colors.length]}r.selectColor=e;function r(a){let c,p=null,v,m;function b(...x){if(!b.enabled)return;let C=b,T=Number(new Date),L=T-(c||T);C.diff=L,C.prev=c,C.curr=T,c=T,x[0]=r.coerce(x[0]),typeof x[0]!="string"&&x.unshift("%O");let S=0;x[0]=x[0].replace(/%([a-zA-Z%])/g,(N,U)=>{if(N==="%%")return"%";S++;let M=r.formatters[U];if(typeof M=="function"){let Z=x[S];N=M.call(C,Z),x.splice(S,1),S--}return N}),r.formatArgs.call(C,x),(C.log||r.log).apply(C,x)}return b.namespace=a,b.useColors=r.useColors(),b.color=r.selectColor(a),b.extend=n,b.destroy=r.destroy,Object.defineProperty(b,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(v!==r.namespaces&&(v=r.namespaces,m=r.enabled(a)),m),set:x=>{p=x}}),typeof r.init=="function"&&r.init(b),b}function n(a,c){let p=r(this.namespace+(typeof c>"u"?":":c)+a);return p.log=this.log,p}function o(a){r.save(a),r.namespaces=a,r.names=[],r.skips=[];let c,p=(typeof a=="string"?a:"").split(/[\s,]+/),v=p.length;for(c=0;c<v;c++)p[c]&&(a=p[c].replace(/\*/g,".*?"),a[0]==="-"?r.skips.push(new RegExp("^"+a.slice(1)+"$")):r.names.push(new RegExp("^"+a+"$")))}function s(){let a=[...r.names.map(u),...r.skips.map(u).map(c=>"-"+c)].join(",");return r.enable(""),a}function i(a){if(a[a.length-1]==="*")return!0;let c,p;for(c=0,p=r.skips.length;c<p;c++)if(r.skips[c].test(a))return!1;for(c=0,p=r.names.length;c<p;c++)if(r.names[c].test(a))return!0;return!1}function u(a){return a.toString().substring(2,a.toString().length-2).replace(/\.\*\?$/,"*")}function d(a){return a instanceof Error?a.stack||a.message:a}function h(){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 r.enable(r.load()),r}cn.exports=Zs});var ln=P((I,Ve)=>{I.formatArgs=ei;I.save=ti;I.load=ri;I.useColors=Ys;I.storage=ni();I.destroy=(()=>{let t=!1;return()=>{t||(t=!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`."))}})();I.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 Ys(){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 ei(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+Ve.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}I.log=console.debug||console.log||(()=>{});function ti(t){try{t?I.storage.setItem("debug",t):I.storage.removeItem("debug")}catch{}}function ri(){let t;try{t=I.storage.getItem("debug")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function ni(){try{return localStorage}catch{}}Ve.exports=un()(I);var{formatters:oi}=Ve.exports;oi.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var dn=P((Cc,fn)=>{function si(){return!!(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0)}fn.exports=si});var bi={};O(bi,{webSockets:()=>mi});var zt=WebSocket;var lr=V(Vt(),1);var Ke={};O(Ke,{identity:()=>Jn});function _n(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var u=t.length,d=t.charAt(0),h=Math.log(u)/Math.log(256),a=Math.log(256)/Math.log(u);function c(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var b=0,x=0,C=0,T=m.length;C!==T&&m[C]===0;)C++,b++;for(var L=(T-C)*a+1>>>0,S=new Uint8Array(L);C!==T;){for(var $=m[C],N=0,U=L-1;($!==0||N<x)&&U!==-1;U--,N++)$+=256*S[U]>>>0,S[U]=$%u>>>0,$=$/u>>>0;if($!==0)throw new Error("Non-zero carry");x=N,C++}for(var M=L-x;M!==L&&S[M]===0;)M++;for(var Z=d.repeat(b);M<L;++M)Z+=t.charAt(S[M]);return Z}function p(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var b=0;if(m[b]!==" "){for(var x=0,C=0;m[b]===d;)x++,b++;for(var T=(m.length-b)*h+1>>>0,L=new Uint8Array(T);m[b];){var S=r[m.charCodeAt(b)];if(S===255)return;for(var $=0,N=T-1;(S!==0||$<C)&&N!==-1;N--,$++)S+=u*L[N]>>>0,L[N]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");C=$,b++}if(m[b]!==" "){for(var U=T-C;U!==T&&L[U]===0;)U++;for(var M=new Uint8Array(x+(T-U)),Z=x;U!==T;)M[Z++]=L[U++];return M}}}function v(m){var b=p(m);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:c,decodeUnsafe:p,decode:v}}var qn=_n,jn=qn,_t=jn;var Ci=new Uint8Array(0);var qt=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},k=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var jt=t=>new TextEncoder().encode(t),Qt=t=>new TextDecoder().decode(t);var Ge=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Je=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Jt(this,e)}},He=class{constructor(e){this.decoders=e}or(e){return Jt(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Jt=(t,e)=>new He({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),Xe=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ge(e,r,n),this.decoder=new Je(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Y=({name:t,prefix:e,encode:r,decode:n})=>new Xe(t,e,r,n),_=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=_t(r,e);return Y({prefix:t,name:e,encode:n,decode:s=>k(o(s))})},Qn=(t,e,r,n)=>{let o={};for(let a=0;a<e.length;++a)o[e[a]]=a;let s=t.length;for(;t[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),u=0,d=0,h=0;for(let a=0;a<s;++a){let c=o[t[a]];if(c===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|c,u+=r,u>=8&&(u-=8,i[h++]=255&d>>u)}if(u>=r||255&d<<8-u)throw new SyntaxError("Unexpected end of data");return i},Gn=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,u=0;for(let d=0;d<t.length;++d)for(u=u<<8|t[d],i+=8;i>r;)i-=r,s+=e[o&u>>i];if(i&&(s+=e[o&u<<r-i]),n)for(;s.length*r&7;)s+="=";return s},y=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Y({prefix:e,name:t,encode(o){return Gn(o,n,r)},decode(o){return Qn(o,n,r,t)}});var Jn=Y({prefix:"\0",name:"identity",encode:t=>Qt(t),decode:t=>jt(t)});var Ze={};O(Ze,{base2:()=>Hn});var Hn=y({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ye={};O(Ye,{base8:()=>Xn});var Xn=y({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var et={};O(et,{base10:()=>Kn});var Kn=_({prefix:"9",name:"base10",alphabet:"0123456789"});var tt={};O(tt,{base16:()=>Zn,base16upper:()=>Yn});var Zn=y({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Yn=y({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var rt={};O(rt,{base32:()=>D,base32hex:()=>no,base32hexpad:()=>so,base32hexpadupper:()=>io,base32hexupper:()=>oo,base32pad:()=>to,base32padupper:()=>ro,base32upper:()=>eo,base32z:()=>ao});var D=y({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),eo=y({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),to=y({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ro=y({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),no=y({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),oo=y({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),so=y({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),io=y({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ao=y({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var nt={};O(nt,{base36:()=>co,base36upper:()=>uo});var co=_({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),uo=_({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ot={};O(ot,{base58btc:()=>A,base58flickr:()=>lo});var A=_({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),lo=_({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var it={};O(it,{base64:()=>st,base64pad:()=>fo,base64url:()=>po,base64urlpad:()=>ho});var st=y({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),fo=y({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),po=y({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ho=y({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var at={};O(at,{base256emoji:()=>yo});var Ht=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}"),mo=Ht.reduce((t,e,r)=>(t[r]=e,t),[]),bo=Ht.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function wo(t){return t.reduce((e,r)=>(e+=mo[r],e),"")}function go(t){let e=[];for(let r of t){let n=bo[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var yo=Y({prefix:"\u{1F680}",name:"base256emoji",encode:wo,decode:go});var ft={};O(ft,{sha256:()=>Ro,sha512:()=>ko});var xo=Zt,Xt=128,vo=127,Co=~vo,Eo=Math.pow(2,31);function Zt(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Eo;)e[r++]=t&255|Xt,t/=128;for(;t&Co;)e[r++]=t&255|Xt,t>>>=7;return e[r]=t|0,Zt.bytes=r-n+1,e}var So=ct,Ao=128,Kt=127;function ct(t,n){var r=0,n=n||0,o=0,s=n,i,u=t.length;do{if(s>=u)throw ct.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&Kt)<<o:(i&Kt)*Math.pow(2,o),o+=7}while(i>=Ao);return ct.bytes=s-n,r}var To=Math.pow(2,7),Po=Math.pow(2,14),Fo=Math.pow(2,21),Uo=Math.pow(2,28),Oo=Math.pow(2,35),Io=Math.pow(2,42),Lo=Math.pow(2,49),No=Math.pow(2,56),Mo=Math.pow(2,63),$o=function(t){return t<To?1:t<Po?2:t<Fo?3:t<Uo?4:t<Oo?5:t<Io?6:t<Lo?7:t<No?8:t<Mo?9:10},Do={encode:xo,decode:So,encodingLength:$o},Bo=Do,me=Bo;var be=(t,e=0)=>[me.decode(t,e),me.decode.bytes],ee=(t,e,r=0)=>(me.encode(t,e,r),e),te=t=>me.encodingLength(t);var H=(t,e)=>{let r=e.byteLength,n=te(t),o=n+te(r),s=new Uint8Array(o+r);return ee(t,s,0),ee(r,s,n),s.set(e,o),new re(t,r,e,s)},Ie=t=>{let e=k(t),[r,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 re(r,o,i,e)},Yt=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&qt(t.bytes,r.bytes)}},re=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var lt=({name:t,code:e,encode:r})=>new ut(t,e,r),ut=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?H(this.code,r):r.then(n=>H(this.code,n))}else throw Error("Unknown type, must be binary type")}};var tr=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Ro=lt({name:"sha2-256",code:18,encode:tr("SHA-256")}),ko=lt({name:"sha2-512",code:19,encode:tr("SHA-512")});var dt={};O(dt,{identity:()=>Vo});var rr=0,zo="identity",nr=k,Wo=t=>H(rr,nr(t)),Vo={code:rr,name:zo,encode:nr,digest:Wo};var _i=new TextEncoder,qi=new TextDecoder;var or=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return Qo(r,pt(t),e||A.encoder);default:return Go(r,pt(t),e||D.encoder)}};var sr=new WeakMap,pt=t=>{let e=sr.get(t);if(e==null){let r=new Map;return sr.set(t,r),r}return e},w=class{constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==we)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Jo)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return w.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=H(e,r);return w.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 w.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&Yt(e.multihash,n.multihash)}toString(e){return or(this,e)}toJSON(){return{"/":or(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof w)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new w(n,o,s,i||ir(n,o,s.bytes))}else if(r[Ho]===!0){let{version:n,multihash:o,code:s}=r,i=Ie(o);return w.create(n,s,i)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==we)throw new Error(`Version 0 CID must use dag-pb (code: ${we}) block encoding`);return new w(e,r,n,n.bytes)}case 1:{let o=ir(e,r,n.bytes);return new w(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return w.create(0,we,e)}static createV1(e,r){return w.create(1,e,r)}static decode(e){let[r,n]=w.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=w.inspectBytes(e),n=r.size-r.multihashSize,o=k(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new re(r.multihashCode,r.digestSize,s,o);return[r.version===0?w.createV0(i):w.createV1(r.codec,i),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[c,p]=be(e.subarray(r));return r+=p,c},o=n(),s=we;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,u=n(),d=n(),h=r+d,a=h-i;return{version:o,codec:s,multihashCode:u,digestSize:d,multihashSize:a,size:h}}static parse(e,r){let[n,o]=jo(e,r),s=w.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return pt(s).set(n,e),s}},jo=(t,e)=>{switch(t[0]){case"Q":{let r=e||A;return[A.prefix,r.decode(`${A.prefix}${t}`)]}case A.prefix:{let r=e||A;return[A.prefix,r.decode(t)]}case D.prefix:{let r=e||D;return[D.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},Qo=(t,e,r)=>{let{prefix:n}=r;if(n!==A.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o},Go=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o},we=112,Jo=18,ir=(t,e,r)=>{let n=te(t),o=n+te(e),s=new Uint8Array(o+r.byteLength);return ee(t,s,0),ee(e,s,n),s.set(r,o),s},Ho=Symbol.for("@ipld/js-cid/CID");var ge={...Ke,...Ze,...Ye,...et,...tt,...rt,...nt,...ot,...it,...at},ea={...ft,...dt};function oe(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Le(t=0){return globalThis.Buffer?.allocUnsafe!=null?oe(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function cr(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var ar=cr("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),ht=cr("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Le(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Xo={utf8:ar,"utf-8":ar,hex:ge.base16,latin1:ht,ascii:ht,binary:ht,...ge},Ne=Xo;function ye(t,e="utf8"){let r=Ne[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?oe(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function ur(t){return t instanceof ArrayBuffer||t?.constructor?.name==="ArrayBuffer"&&typeof t?.byteLength=="number"}var fr=t=>{t.binaryType="arraybuffer";let e=async()=>await new Promise((s,i)=>{if(n)return s();if(o!=null)return i(o);let u=a=>{t.removeEventListener("open",d),t.removeEventListener("error",h),a()},d=()=>u(s),h=a=>{u(()=>i(a.error??new Error(`connect ECONNREFUSED ${t.url}`)))};t.addEventListener("open",d),t.addEventListener("error",h)}),r=async function*(){let s=new lr.EventIterator(({push:i,stop:u,fail:d})=>{let h=c=>{let p=null;typeof c.data=="string"&&(p=ye(c.data)),ur(c.data)&&(p=new Uint8Array(c.data)),c.data instanceof Uint8Array&&(p=c.data),p!=null&&i(p)},a=c=>d(c.error??new Error("Socket error"));return t.addEventListener("message",h),t.addEventListener("error",a),t.addEventListener("close",u),()=>{t.removeEventListener("message",h),t.removeEventListener("error",a),t.removeEventListener("close",u)}},{highWaterMark:1/0});await e();for await(let i of s)yield ur(i)?new Uint8Array(i):i}(),n=t.readyState===1,o;return t.addEventListener("open",()=>{n=!0,o=null}),t.addEventListener("close",()=>{n=!1,o=null}),t.addEventListener("error",s=>{n||(o=s.error??new Error(`connect ECONNREFUSED ${t.url}`))}),Object.assign(r,{connected:e})};var dr=t=>{if(t.readyState>=2)throw new Error("socket closed");if(t.readyState!==1)return new Promise((e,r)=>{function n(){t.removeEventListener("open",o),t.removeEventListener("error",s)}function o(){n(),e()}function s(i){n(),r(i.error??new Error(`connect ECONNREFUSED ${t.url}`))}t.addEventListener("open",o),t.addEventListener("error",s)})};var pr=(t,e)=>(e=e??{},e.closeOnEnd=e.closeOnEnd!==!1,async n=>{for await(let o of n){try{await dr(t)}catch(s){if(s.message==="socket closed")break;throw s}t.send(o)}if(e.closeOnEnd!=null&&t.readyState<=1)return await new Promise((o,s)=>{t.addEventListener("close",i=>{if(i.wasClean||i.code===1006)o();else{let u=Object.assign(new Error("ws error"),{event:i});s(u)}}),setTimeout(()=>t.close())})});var hr=(t,e)=>{e=e??{};let r=fr(t),n=e.remoteAddress,o=e.remotePort;if(t.url!=null)try{let i=new URL(t.url);n=i.hostname,o=parseInt(i.port,10)}catch{}if(n==null||o==null)throw new Error("Remote connection did not have address and/or port");return{sink:pr(t,e),source:r,connected:async()=>await r.connected(),close:async()=>{(t.readyState===t.CONNECTING||t.readyState===t.OPEN)&&await new Promise(i=>{t.addEventListener("close",()=>{i()}),t.close()})},destroy:()=>{t.terminate!=null?t.terminate():t.close()},remoteAddress:n,remotePort:o,socket:t}};var Cr=V(vr(),1),is={http:"ws",https:"wss"},as="ws",Er=(t,e)=>(0,Cr.relative)(t,e,is,as);function Sr(t,e){let r=typeof window>"u"?"":window.location;e=e??{};let n=Er(t,r.toString()),o=new zt(n,e.websocket);return hr(o,e)}var Me=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let r=this.index,n=e();return n===void 0&&(this.index=r),n}parseWith(e){let r=e();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let r=this.readChar();if(r===e)return r})}readSeparator(e,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,r,n,o){return this.readAtomically(()=>{let s=0,i=0,u=this.peekChar();if(u===void 0)return;let d=u==="0",h=2**(8*o)-1;for(;;){let a=this.readAtomically(()=>{let c=this.readChar();if(c===void 0)return;let p=Number.parseInt(c,e);if(!Number.isNaN(p))return p});if(a===void 0)break;if(s*=e,s+=a,s>h||(i+=1,r!==void 0&&i>r))return}if(i!==0)return!n&&d&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let r=0;r<e.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[r]=n}return e})}readIPv6Addr(){let e=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return r[o]=i[0],r[o+1]=i[1],r[o+2]=i[2],r[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];r[o]=s>>8,r[o+1]=s&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=e(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[u]=e(s.subarray(0,i));return r.set(s.subarray(0,u),16-u),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Ar=45,cs=15,se=new Me;function Tr(t){if(!(t.length>cs))return se.new(t).parseWith(()=>se.readIPv4Addr())}function Pr(t){if(!(t.length>Ar))return se.new(t).parseWith(()=>se.readIPv6Addr())}function Fr(t){if(!(t.length>Ar))return se.new(t).parseWith(()=>se.readIPAddr())}function Ur(t){return!!Tr(t)}function Or(t){return!!Pr(t)}function $e(t){return!!Fr(t)}function F(t,e="utf8"){let r=Ne[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var Ir=Ur,us=Or,wt=function(t){let e=0;if(t=t.toString().trim(),Ir(t)){let r=new Uint8Array(e+4);return t.split(/\./g).forEach(n=>{r[e++]=parseInt(n,10)&255}),r}if(us(t)){let r=t.split(":",8),n;for(n=0;n<r.length;n++){let s=Ir(r[n]),i;s&&(i=wt(r[n]),r[n]=F(i.slice(0,2),"base16")),i!=null&&++n<8&&r.splice(n,0,F(i.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let s=[n,1];for(n=9-r.length;n>0;n--)s.push("0");r.splice.apply(r,s)}let o=new Uint8Array(e+16);for(n=0;n<r.length;n++){let s=parseInt(r[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},Lr=function(t,e=0,r){e=~~e,r=r??t.length-e;let n=new DataView(t.buffer);if(r===4){let o=[];for(let s=0;s<r;s++)o.push(t[e+s]);return o.join(".")}if(r===16){let o=[];for(let s=0;s<r;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var ve={},gt={},fs=[[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"]];fs.forEach(t=>{let e=ds(...t);gt[e.code]=e,ve[e.name]=e});function ds(t,e,r,n,o){return{code:t,size:e,name:r,resolvable:!!n,path:!!o}}function g(t){if(typeof t=="number"){if(gt[t]!=null)return gt[t];throw new Error(`no protocol with code: ${t}`)}else if(typeof t=="string"){if(ve[t]!=null)return ve[t];throw new Error(`no protocol with name: ${t}`)}throw new Error(`invalid protocol id type: ${typeof t}`)}var B=V(De(),1);function z(t,e){e==null&&(e=t.reduce((o,s)=>o+s.length,0));let r=Le(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return oe(r)}function Qr(t,e){switch(g(t).code){case 4:case 41:return Ps(e);case 42:return qr(e);case 6:case 273:case 33:case 132:return Jr(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return qr(e);case 421:return Is(e);case 444:return jr(e);case 445:return jr(e);case 466:return Os(e);default:return F(e,"base16")}}function Gr(t,e){switch(g(t).code){case 4:return Vr(e);case 41:return Vr(e);case 42:return _r(e);case 6:case 273:case 33:case 132:return Ct(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return _r(e);case 421:return Fs(e);case 444:return Ls(e);case 445:return Ns(e);case 466:return Us(e);default:return ye(e,"base16")}}var vt=Object.values(ge).map(t=>t.decoder),Ts=function(){let t=vt[0].or(vt[1]);return vt.slice(2).forEach(e=>t=t.or(e)),t}();function Vr(t){if(!$e(t))throw new Error("invalid ip address");return wt(t)}function Ps(t){let e=Lr(t,0,t.length);if(e==null)throw new Error("ipBuff is required");if(!$e(e))throw new Error("invalid ip address");return e}function Ct(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function Jr(t){return new DataView(t.buffer).getUint16(t.byteOffset)}function _r(t){let e=ye(t),r=Uint8Array.from(B.default.encode(e.length));return z([r,e],r.length+e.length)}function qr(t){let e=B.default.decode(t);if(t=t.slice(B.default.decode.bytes),t.length!==e)throw new Error("inconsistent lengths");return F(t)}function Fs(t){let e;t[0]==="Q"||t[0]==="1"?e=Ie(A.decode(`z${t}`)).bytes:e=w.parse(t).multihash.bytes;let r=Uint8Array.from(B.default.encode(e.length));return z([r,e],r.length+e.length)}function Us(t){let e=Ts.decode(t),r=Uint8Array.from(B.default.encode(e.length));return z([r,e],r.length+e.length)}function Os(t){let e=B.default.decode(t),r=t.slice(B.default.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return"u"+F(r,"base64url")}function Is(t){let e=B.default.decode(t),r=t.slice(B.default.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return F(r,"base58btc")}function Ls(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let r=D.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=Ct(n);return z([r,o],r.length+o.length)}function Ns(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let r=D.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=Ct(n);return z([r,o],r.length+o.length)}function jr(t){let e=t.slice(0,t.length-2),r=t.slice(t.length-2),n=F(e,"base32"),o=Jr(r);return`${n}:${o}`}var ie=V(De(),1);function Ms(t){let e=[],r=t.split("/").slice(1);if(r.length===1&&r[0]==="")return[];for(let n=0;n<r.length;n++){let o=r[n],s=g(o);if(s.size===0){e.push([o]);continue}if(n++,n>=r.length)throw Xr("invalid address: "+t);if(s.path===!0){e.push([o,Pt(r.slice(n).join("/"))]);break}e.push([o,r[n]])}return e}function $s(t){let e=[];return t.map(r=>{let n=ke(r);return e.push(n.name),r.length>1&&r[1]!=null&&e.push(r[1]),null}),Pt(e.join("/"))}function Ds(t){return t.map(e=>{Array.isArray(e)||(e=[e]);let r=ke(e);return e.length>1?[r.code,Gr(r.code,e[1])]:[r.code]})}function Et(t){return t.map(e=>{let r=ke(e);return e[1]!=null?[r.code,Qr(r.code,e[1])]:[r.code]})}function St(t){return Re(z(t.map(e=>{let r=ke(e),n=Uint8Array.from(ie.default.encode(r.code));return e.length>1&&e[1]!=null&&(n=z([n,e[1]])),n})))}function At(t,e){return t.size>0?t.size/8:t.size===0?0:ie.default.decode(e)+(ie.default.decode.bytes??0)}function Be(t){let e=[],r=0;for(;r<t.length;){let n=ie.default.decode(t,r),o=ie.default.decode.bytes??0,s=g(n),i=At(s,t.slice(r+o));if(i===0){e.push([n]),r+=o;continue}let u=t.slice(r+o,r+o+i);if(r+=i+o,r>t.length)throw Xr("Invalid address Uint8Array: "+F(t,"base16"));e.push([n,u])}return e}function Tt(t){let e=Be(t),r=Et(e);return $s(r)}function Bs(t){t=Pt(t);let e=Ms(t),r=Ds(e);return St(r)}function Hr(t){return Bs(t)}function Re(t){let e=Rs(t);if(e!=null)throw e;return Uint8Array.from(t)}function Rs(t){try{Be(t)}catch(e){return e}}function Pt(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}function Xr(t){return new Error("Error parsing address: "+t)}function ke(t){return g(t[0])}var Ut=V(De(),1);var rn=V(Yr(),1);function en(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var ae=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Ft=function(t,e,r,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"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r},Ce,Ee,Se,tn,Ws=Symbol.for("nodejs.util.inspect.custom"),Vs=[g("dns").code,g("dns4").code,g("dns6").code,g("dnsaddr").code],_s=new Map,nn=Symbol.for("@multiformats/js-multiaddr/multiaddr");function qs(t){return!!t?.[nn]}var W=class{constructor(e){if(Ce.set(this,void 0),Ee.set(this,void 0),Se.set(this,void 0),this[tn]=!0,e==null&&(e=""),e instanceof Uint8Array)this.bytes=Re(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=Hr(e)}else if(qs(e))this.bytes=Re(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return ae(this,Ce,"f")==null&&Ft(this,Ce,Tt(this.bytes),"f"),ae(this,Ce,"f")}toJSON(){return this.toString()}toOptions(){let e,r,n,o,s="",i=g("tcp"),u=g("udp"),d=g("ip4"),h=g("ip6"),a=g("dns6"),c=g("ip6zone");for(let[v,m]of this.stringTuples())v===c.code&&(s=`%${m??""}`),Vs.includes(v)&&(r=i.name,o=443,n=`${m??""}${s}`,e=v===a.code?6:4),(v===i.code||v===u.code)&&(r=g(v).name,o=parseInt(m??"")),(v===d.code||v===h.code)&&(r=g(v).name,n=`${m??""}${s}`,e=v===h.code?6:4);if(e==null||r==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:r,port:o}}protos(){return this.protoCodes().map(e=>Object.assign({},g(e)))}protoCodes(){let e=[],r=this.bytes,n=0;for(;n<r.length;){let o=Ut.default.decode(r,n),s=Ut.default.decode.bytes??0,i=g(o),u=At(i,r.slice(n+s));n+=u+s,e.push(o)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return ae(this,Ee,"f")==null&&Ft(this,Ee,Be(this.bytes),"f"),ae(this,Ee,"f")}stringTuples(){return ae(this,Se,"f")==null&&Ft(this,Se,Et(this.tuples()),"f"),ae(this,Se,"f")}encapsulate(e){return e=new W(e),new W(this.toString()+e.toString())}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new W(n.slice(0,o))}decapsulateCode(e){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===e)return new W(St(r.slice(0,n)));return this}getPeerId(){try{let r=this.stringTuples().filter(n=>n[0]===ve.ipfs.code).pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?F(A.decode(`z${n}`),"base58btc"):F(w.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let e=null;try{e=this.stringTuples().filter(r=>g(r[0]).path===!0)[0][1],e==null&&(e=null)}catch{e=null}return e}equals(e){return en(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(s=>s.resolvable);if(r==null)return[this];let n=_s.get(r.name);if(n==null)throw(0,rn.default)(new Error(`no available resolver for ${r.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new W(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let r=(e??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[(Ce=new WeakMap,Ee=new WeakMap,Se=new WeakMap,tn=nn,Ws)](){return`Multiaddr(${Tt(this.bytes)})`}};function Ae(t){return new W(t)}var ze=(t,e)=>e,js=(t,e,r,n)=>{if(n!=null&&n.assumeHttp===!1)return`tcp://${t}:${e}`;let o="tcp",s=`:${e}`;return r[r.length-1].protocol==="tcp"&&(o=e==="443"?"https":"http",s=e==="443"||e==="80"?"":s),`${o}://${t}${s}`},Qs={ip4:ze,ip6:(t,e,r,n)=>n.length===1&&n[0].protocol==="ip6"?e:`[${e}]`,tcp:(t,e,r,n,o)=>n.some(s=>["http","https","ws","wss"].includes(s.protocol))?`${t}:${e}`:js(t,e,n,o),udp:(t,e)=>`udp://${t}:${e}`,dnsaddr:ze,dns4:ze,dns6:ze,ipfs:(t,e)=>`${t}/ipfs/${e}`,p2p:(t,e)=>`${t}/p2p/${e}`,http:t=>`http://${t}`,https:t=>`https://${t}`,ws:t=>`ws://${t}`,wss:t=>`wss://${t}`,"p2p-websocket-star":t=>`${t}/p2p-websocket-star`,"p2p-webrtc-star":t=>`${t}/p2p-webrtc-star`,"p2p-webrtc-direct":t=>`${t}/p2p-webrtc-direct`};function on(t,e){let r=Ae(t),n=r.toString().split("/").slice(1);return r.tuples().map(o=>({protocol:n.shift()??"",content:o[1]!=null?n.shift()??"":""})).reduce((o,s,i,u)=>{let d=Qs[s.protocol];if(d==null)throw new Error(`Unsupported protocol ${s.protocol}`);return d(o,s.content,i,u,e)},"")}var q=class extends Error{constructor(e="The operation was aborted"){super(e),this.code=q.code,this.type=q.type}static get code(){return"ABORT_ERR"}static get type(){return"aborted"}};function Ot(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var R=V(ln(),1);R.default.formatters.b=t=>t==null?"undefined":A.baseEncode(t);R.default.formatters.t=t=>t==null?"undefined":D.baseEncode(t);R.default.formatters.m=t=>t==null?"undefined":st.baseEncode(t);R.default.formatters.p=t=>t==null?"undefined":t.toString();R.default.formatters.c=t=>t==null?"undefined":t.toString();R.default.formatters.k=t=>t==null?"undefined":t.toString();function _e(t){return Object.assign((0,R.default)(t),{error:(0,R.default)(`${t}:error`),trace:(0,R.default)(`${t}:trace`)})}var pn=V(dn(),1),ii=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,hn=(0,pn.default)(),mn=ii&&!hn;var Ec=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!hn,bn=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,Sc=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+(()=>"_")()+"ENV"]==="test",Ac=typeof navigator<"u"&&navigator.product==="ReactNative";function wn(){throw new Error("WebSocket Servers can not be created in the browser!")}var Te=class extends Error{constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function gn(t){if(t!=null){if(typeof t[Symbol.iterator]=="function")return t[Symbol.iterator]();if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t.next=="function")return t}throw new Error("argument is not an iterator or iterable")}function It(t,e,r){let n=r??{},o=gn(t);async function*s(){let i,u=()=>{i?.()};for(e.addEventListener("abort",u);;){let d;try{if(e.aborted){let{abortMessage:a,abortCode:c}=n;throw new Te(a,c)}let h=new Promise((a,c)=>{i=()=>{let{abortMessage:p,abortCode:v}=n;c(new Te(p,v))}});d=await Promise.race([h,o.next()]),i=null}catch(h){e.removeEventListener("abort",u);let a=h.type==="aborted"&&e.aborted;if(a&&n.onAbort!=null&&await n.onAbort(t),typeof o.return=="function")try{let c=o.return();c instanceof Promise&&c.catch(p=>{n.onReturnError!=null&&n.onReturnError(p)})}catch(c){n.onReturnError!=null&&n.onReturnError(c)}if(a&&n.returnOnAbort===!0)return;throw h}if(d.done===!0)break;yield d.value}e.removeEventListener("abort",u)}return s()}var Lt=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Nt=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},yn=t=>globalThis.DOMException===void 0?new Nt(t):new DOMException(t),xn=t=>{let e=t.reason===void 0?yn("This operation was aborted."):t.reason;return e instanceof Error?e:yn(e)};function Mt(t,e){let{milliseconds:r,fallback:n,message:o,customTimers:s={setTimeout,clearTimeout}}=e,i,u=new Promise((d,h)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(r===Number.POSITIVE_INFINITY){d(t);return}if(e.signal){let{signal:c}=e;c.aborted&&h(xn(c)),c.addEventListener("abort",()=>{h(xn(c))})}let a=new Lt;i=s.setTimeout.call(void 0,()=>{if(n){try{d(n())}catch(c){h(c)}return}typeof t.cancel=="function"&&t.cancel(),o===!1?d():o instanceof Error?h(o):(a.message=o??`Promise timed out after ${r} milliseconds`,h(a))},r),(async()=>{try{d(await t)}catch(c){h(c)}finally{s.clearTimeout.call(void 0,i)}})()});return u.clear=()=>{s.clearTimeout.call(void 0,i),i=void 0},u}var vn=_e("libp2p:websockets:socket");function Cn(t,e,r){r=r??{};let n={async sink(o){r?.signal!=null&&(o=It(o,r.signal));try{await t.sink(o)}catch(s){s.type!=="aborted"&&vn.error(s)}},source:r.signal!=null?It(t.source,r.signal):t.source,remoteAddr:e,timeline:{open:Date.now()},async close(){let o=Date.now();try{await Mt(t.close(),{milliseconds:2e3})}catch{let{host:i,port:u}=n.remoteAddr.toOptions();vn("timeout closing stream to %s:%s after %dms, destroying it manually",i,u,Date.now()-o),t.destroy()}finally{n.timeline.close=Date.now()}}};return t.socket.addEventListener("close",()=>{n.timeline.close==null&&(n.timeline.close=Date.now())},{once:!0}),n}var ci=l("dns4"),ui=l("dns6"),li=l("dnsaddr"),Q=E(l("dns"),li,ci,ui),qe=E(l("ip4"),l("ip6")),de=E(f(qe,l("tcp")),f(Q,l("tcp"))),Bt=f(qe,l("udp")),fi=f(Bt,l("utp")),di=f(Bt,l("quic")),K=E(f(de,l("ws")),f(Q,l("ws"))),G=E(f(de,l("wss")),f(Q,l("wss")),f(de,l("tls"),l("ws")),f(Q,l("tls"),l("ws"))),$t=E(f(de,l("http")),f(qe,l("http")),f(Q,l("http"))),Dt=E(f(de,l("https")),f(qe,l("https")),f(Q,l("https"))),En=f(Bt,l("webrtc-direct"),l("certhash")),An=E(f(En,l("p2p")),En),Tn=E(f(K,l("p2p-webrtc-star"),l("p2p")),f(G,l("p2p-webrtc-star"),l("p2p")),f(K,l("p2p-webrtc-star")),f(G,l("p2p-webrtc-star"))),Wc=E(f(K,l("p2p-websocket-star"),l("p2p")),f(G,l("p2p-websocket-star"),l("p2p")),f(K,l("p2p-websocket-star")),f(G,l("p2p-websocket-star"))),Pn=E(f($t,l("p2p-webrtc-direct"),l("p2p")),f(Dt,l("p2p-webrtc-direct"),l("p2p")),f($t,l("p2p-webrtc-direct")),f(Dt,l("p2p-webrtc-direct"))),pe=E(K,G,$t,Dt,Tn,Pn,de,fi,di,Q,An),Vc=E(f(pe,l("p2p-stardust"),l("p2p")),f(pe,l("p2p-stardust"))),j=E(f(pe,l("p2p")),Tn,Pn,An,l("p2p")),Sn=E(f(j,l("p2p-circuit"),j),f(j,l("p2p-circuit")),f(l("p2p-circuit"),j),f(pe,l("p2p-circuit")),f(l("p2p-circuit"),pe),l("p2p-circuit")),Fn=()=>E(f(Sn,Fn),Sn),fe=Fn(),_c=E(f(fe,j,fe),f(j,fe),f(fe,j),fe,j);var qc=E(f(fe,l("webrtc")),f(pe,l("webrtc")),l("webrtc"));function Un(t){function e(r){let n;try{n=Ae(r)}catch{return!1}let o=t(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return e}function f(...t){function e(r){if(r.length<t.length)return null;let n=r;return t.some(o=>(n=typeof o=="function"?o().partialMatch(r):o.partialMatch(r),Array.isArray(n)&&(r=n),n===null)),n}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:Un(e),partialMatch:e}}function E(...t){function e(n){let o=null;return t.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:Un(e),partialMatch:e}}function l(t){let e=t;function r(o){let s;try{s=Ae(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===e}function n(o){return o.length===0?null:o[0]===e?o.slice(1):null}return{toString:function(){return e},matches:r,partialMatch:n}}function Ln(t){return t.filter(e=>{if(e.protoCodes().includes(290))return!1;let r=e.decapsulateCode(421);return K.matches(r)||G.matches(r)})}function Nn(t){return t.filter(e=>{if(e.protoCodes().includes(290))return!1;let r=e.decapsulateCode(421);return G.matches(r)})}var $n=Symbol.for("@libp2p/transport");var Mn;(function(t){t[t.FATAL_ALL=0]="FATAL_ALL",t[t.NO_FATAL=1]="NO_FATAL"})(Mn||(Mn={}));var J=_e("libp2p:websockets"),Rt=class{constructor(e){this.init=e}get[Symbol.toStringTag](){return"@libp2p/websockets"}get[$n](){return!0}async dial(e,r){J("dialing %s",e),r=r??{};let n=await this._connect(e,r),o=Cn(n,e);J("new outbound connection %s",o.remoteAddr);let s=await r.upgrader.upgradeOutbound(o);return J("outbound connection %s upgraded",o.remoteAddr),s}async _connect(e,r){if(r?.signal?.aborted===!0)throw new q;let n=e.toOptions();J("dialing %s:%s",n.host,n.port);let o=Ot(),s=h=>{J.error("connection error:",h),o.reject(h)},i=Sr(on(e),this.init);if(i.socket.on!=null?i.socket.on("error",s):i.socket.onerror=s,r.signal==null)return await Promise.race([i.connected(),o.promise]),J("connected %s",e),i;let u,d=new Promise((h,a)=>{if(u=()=>{a(new q),i.close().catch(c=>{J.error("error closing raw socket",c)})},r?.signal?.aborted===!0){u();return}r?.signal?.addEventListener("abort",u)});try{await Promise.race([d,o.promise,i.connected()])}finally{u!=null&&r?.signal?.removeEventListener("abort",u)}return J("connected %s",e),i}createListener(e){return wn({...this.init,...e})}filter(e){return e=Array.isArray(e)?e:[e],this.init?.filter!=null?this.init?.filter(e):mn||bn?Nn(e):Ln(e)}};function mi(t={}){return()=>new Rt(t)}return Wn(bi);})();
2
+ "use strict";var Libp2PWebsockets=(()=>{var Dn=Object.create;var Pe=Object.defineProperty;var Bn=Object.getOwnPropertyDescriptor;var Rn=Object.getOwnPropertyNames;var zn=Object.getPrototypeOf,Wn=Object.prototype.hasOwnProperty;var F=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),U=(t,e)=>{for(var r in e)Pe(t,r,{get:e[r],enumerable:!0})},_t=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Rn(e))!Wn.call(t,o)&&o!==r&&Pe(t,o,{get:()=>e[o],enumerable:!(n=Bn(e,o))||n.enumerable});return t};var H=(t,e,r)=>(r=t!=null?Dn(zn(t)):{},_t(e||!t||!t.__esModule?Pe(r,"default",{value:t,enumerable:!0}):r,t)),Vn=t=>_t(Pe({},"__esModule",{value:!0}),t);var jt=F(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});var He=class{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(e){if(this.isStopped)return;let r={value:e,done:!1};if(this.pullQueue.length){let n=this.pullQueue.shift();n&&n.resolve(r)}else this.pushQueue.push(Promise.resolve(r)),this.highWaterMark!==void 0&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(let e of this.pullQueue)e.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(e){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(let r of this.pullQueue)r.reject(e);this.pullQueue.length=0}else{let r=Promise.reject(e);r.catch(()=>{}),this.pushQueue.push(r)}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:e=>{let r=this.pushQueue.shift();return r?(this.lowWaterMark!==void 0&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),r):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((n,o)=>{this.pullQueue.push({resolve:n,reject:o})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}},Ie=class{constructor(e,{highWaterMark:r=100,lowWaterMark:n=1}={}){let o=new He;o.highWaterMark=r,o.lowWaterMark=n,o.removeCallback=e({push:s=>o.push(s),stop:()=>o.stop(),fail:s=>o.fail(s),on:(s,i)=>{o.eventHandlers[s]=i}})||(()=>{}),this[Symbol.asyncIterator]=()=>o[Symbol.asyncIterator](),Object.freeze(this)}};Fe.EventIterator=Ie;Fe.default=Ie});var Qt=F(me=>{"use strict";Object.defineProperty(me,"__esModule",{value:!0});var Je=jt();me.EventIterator=Je.EventIterator;function _n(t,e,r){return new Je.EventIterator(({push:n})=>(this.addEventListener(t,n,e),()=>this.removeEventListener(t,n,e)),r)}me.subscribe=_n;me.default=Je.EventIterator});var yt=F((Aa,xr)=>{"use strict";var Zo=typeof navigator<"u"&&navigator.product==="ReactNative";function Yo(){return Zo?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}var ve=self.URL,yr=Yo(),gt=class{constructor(e="",r=yr){this.super=new ve(e,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(e){this.super.hash=e}set host(e){this.super.host=e}set hostname(e){this.super.hostname=e}set href(e){this.super.href=e}set password(e){this.super.password=e}set pathname(e){this.super.pathname=e}set port(e){this.super.port=e}set protocol(e){this.super.protocol=e}set search(e){this.super.search=e}set username(e){this.super.username=e}static createObjectURL(e){return ve.createObjectURL(e)}static revokeObjectURL(e){ve.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function es(t){if(typeof t=="string")return new ve(t).toString();if(!(t instanceof ve)){let e=t.username&&t.password?`${t.username}:${t.password}@`:"",r=t.auth?t.auth+"@":"",n=t.port?":"+t.port:"",o=t.protocol?t.protocol+"//":"",s=t.host||"",i=t.hostname||"",u=t.search||(t.query?"?"+t.query:""),p=t.hash||"",h=t.pathname||"",a=t.path||h+u;return`${o}${e||r}${s||i+n}${a}${p}`}}xr.exports={URLWithLegacySupport:gt,URLSearchParams:self.URLSearchParams,defaultBase:yr,format:es}});var Er=F((Ta,Cr)=>{"use strict";var{URLWithLegacySupport:vr,format:ts}=yt();Cr.exports=(t,e={},r={},n)=>{let o=e.protocol?e.protocol.replace(":",""):"http";o=(r[o]||n||o)+":";let s;try{s=new vr(t)}catch{s={}}let i=Object.assign({},e,{protocol:o||s.protocol,host:e.host||s.host});return new vr(t,ts(i)).toString()}});var Ar=F((Pa,Sr)=>{"use strict";var{URLWithLegacySupport:rs,format:ns,URLSearchParams:os,defaultBase:ss}=yt(),is=Er();Sr.exports={URL:rs,URLSearchParams:os,format:ns,relative:is,defaultBase:ss}});var $r=F((qa,kr)=>{kr.exports=St;var Mr=128,hs=127,ms=~hs,ws=Math.pow(2,31);function St(t,e,r){if(Number.MAX_SAFE_INTEGER&&t>Number.MAX_SAFE_INTEGER)throw St.bytes=0,new RangeError("Could not encode varint");e=e||[],r=r||0;for(var n=r;t>=ws;)e[r++]=t&255|Mr,t/=128;for(;t&ms;)e[r++]=t&255|Mr,t>>>=7;return e[r]=t|0,St.bytes=r-n+1,e}});var Rr=F((ja,Br)=>{Br.exports=At;var bs=128,Dr=127;function At(t,n){var r=0,n=n||0,o=0,s=n,i,u=t.length;do{if(s>=u||o>49)throw At.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&Dr)<<o:(i&Dr)*Math.pow(2,o),o+=7}while(i>=bs);return At.bytes=s-n,r}});var Wr=F((Qa,zr)=>{var gs=Math.pow(2,7),ys=Math.pow(2,14),xs=Math.pow(2,21),vs=Math.pow(2,28),Cs=Math.pow(2,35),Es=Math.pow(2,42),Ss=Math.pow(2,49),As=Math.pow(2,56),Ts=Math.pow(2,63);zr.exports=function(t){return t<gs?1:t<ys?2:t<xs?3:t<vs?4:t<Cs?5:t<Es?6:t<Ss?7:t<As?8:t<Ts?9:10}});var De=F((Ga,Vr)=>{Vr.exports={encode:$r(),decode:Rr(),encodingLength:Wr()}});var sn=F((au,on)=>{var ue=1e3,le=ue*60,fe=le*60,X=fe*24,Ks=X*7,Zs=X*365.25;on.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return Ys(t);if(r==="number"&&isFinite(t))return e.long?ti(t):ei(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function Ys(t){if(t=String(t),!(t.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(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*Zs;case"weeks":case"week":case"w":return r*Ks;case"days":case"day":case"d":return r*X;case"hours":case"hour":case"hrs":case"hr":case"h":return r*fe;case"minutes":case"minute":case"mins":case"min":case"m":return r*le;case"seconds":case"second":case"secs":case"sec":case"s":return r*ue;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function ei(t){var e=Math.abs(t);return e>=X?Math.round(t/X)+"d":e>=fe?Math.round(t/fe)+"h":e>=le?Math.round(t/le)+"m":e>=ue?Math.round(t/ue)+"s":t+"ms"}function ti(t){var e=Math.abs(t);return e>=X?_e(t,e,X,"day"):e>=fe?_e(t,e,fe,"hour"):e>=le?_e(t,e,le,"minute"):e>=ue?_e(t,e,ue,"second"):t+" ms"}function _e(t,e,r,n){var o=e>=r*1.5;return Math.round(t/r)+" "+n+(o?"s":"")}});var cn=F((cu,an)=>{function ri(t){r.debug=r,r.default=r,r.coerce=p,r.disable=s,r.enable=o,r.enabled=i,r.humanize=sn(),r.destroy=h,Object.keys(t).forEach(a=>{r[a]=t[a]}),r.names=[],r.skips=[],r.formatters={};function e(a){let c=0;for(let d=0;d<a.length;d++)c=(c<<5)-c+a.charCodeAt(d),c|=0;return r.colors[Math.abs(c)%r.colors.length]}r.selectColor=e;function r(a){let c,d=null,v,m;function b(...x){if(!b.enabled)return;let C=b,T=Number(new Date),N=T-(c||T);C.diff=N,C.prev=c,C.curr=T,c=T,x[0]=r.coerce(x[0]),typeof x[0]!="string"&&x.unshift("%O");let S=0;x[0]=x[0].replace(/%([a-zA-Z%])/g,(O,I)=>{if(O==="%%")return"%";S++;let M=r.formatters[I];if(typeof M=="function"){let Z=x[S];O=M.call(C,Z),x.splice(S,1),S--}return O}),r.formatArgs.call(C,x),(C.log||r.log).apply(C,x)}return b.namespace=a,b.useColors=r.useColors(),b.color=r.selectColor(a),b.extend=n,b.destroy=r.destroy,Object.defineProperty(b,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(v!==r.namespaces&&(v=r.namespaces,m=r.enabled(a)),m),set:x=>{d=x}}),typeof r.init=="function"&&r.init(b),b}function n(a,c){let d=r(this.namespace+(typeof c>"u"?":":c)+a);return d.log=this.log,d}function o(a){r.save(a),r.namespaces=a,r.names=[],r.skips=[];let c,d=(typeof a=="string"?a:"").split(/[\s,]+/),v=d.length;for(c=0;c<v;c++)d[c]&&(a=d[c].replace(/\*/g,".*?"),a[0]==="-"?r.skips.push(new RegExp("^"+a.slice(1)+"$")):r.names.push(new RegExp("^"+a+"$")))}function s(){let a=[...r.names.map(u),...r.skips.map(u).map(c=>"-"+c)].join(",");return r.enable(""),a}function i(a){if(a[a.length-1]==="*")return!0;let c,d;for(c=0,d=r.skips.length;c<d;c++)if(r.skips[c].test(a))return!1;for(c=0,d=r.names.length;c<d;c++)if(r.names[c].test(a))return!0;return!1}function u(a){return a.toString().substring(2,a.toString().length-2).replace(/\.\*\?$/,"*")}function p(a){return a instanceof Error?a.stack||a.message:a}function h(){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 r.enable(r.load()),r}an.exports=ri});var un=F((L,qe)=>{L.formatArgs=oi;L.save=si;L.load=ii;L.useColors=ni;L.storage=ai();L.destroy=(()=>{let t=!1;return()=>{t||(t=!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`."))}})();L.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 ni(){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 oi(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+qe.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}L.log=console.debug||console.log||(()=>{});function si(t){try{t?L.storage.setItem("debug",t):L.storage.removeItem("debug")}catch{}}function ii(){let t;try{t=L.storage.getItem("debug")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function ai(){try{return localStorage}catch{}}qe.exports=cn()(L);var{formatters:ci}=qe.exports;ci.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var fn=F((du,ln)=>{function li(){return!!(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0)}ln.exports=li});var Ci={};U(Ci,{webSockets:()=>vi});var qt=WebSocket;var hr=H(Qt(),1);var et={};U(et,{identity:()=>Jn});function qn(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var u=t.length,p=t.charAt(0),h=Math.log(u)/Math.log(256),a=Math.log(256)/Math.log(u);function c(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var b=0,x=0,C=0,T=m.length;C!==T&&m[C]===0;)C++,b++;for(var N=(T-C)*a+1>>>0,S=new Uint8Array(N);C!==T;){for(var $=m[C],O=0,I=N-1;($!==0||O<x)&&I!==-1;I--,O++)$+=256*S[I]>>>0,S[I]=$%u>>>0,$=$/u>>>0;if($!==0)throw new Error("Non-zero carry");x=O,C++}for(var M=N-x;M!==N&&S[M]===0;)M++;for(var Z=p.repeat(b);M<N;++M)Z+=t.charAt(S[M]);return Z}function d(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var b=0;if(m[b]!==" "){for(var x=0,C=0;m[b]===p;)x++,b++;for(var T=(m.length-b)*h+1>>>0,N=new Uint8Array(T);m[b];){var S=r[m.charCodeAt(b)];if(S===255)return;for(var $=0,O=T-1;(S!==0||$<C)&&O!==-1;O--,$++)S+=u*N[O]>>>0,N[O]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");C=$,b++}if(m[b]!==" "){for(var I=T-C;I!==T&&N[I]===0;)I++;for(var M=new Uint8Array(x+(T-I)),Z=x;I!==T;)M[Z++]=N[I++];return M}}}function v(m){var b=d(m);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:c,decodeUnsafe:d,decode:v}}var jn=qn,Qn=jn,Gt=Qn;var Ii=new Uint8Array(0);var Ht=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},R=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var Jt=t=>new TextEncoder().encode(t),Xt=t=>new TextDecoder().decode(t);var Xe=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Ke=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Zt(this,e)}},Ze=class{constructor(e){this.decoders=e}or(e){return Zt(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Zt=(t,e)=>new Ze({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),Ye=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Xe(e,r,n),this.decoder=new Ke(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Y=({name:t,prefix:e,encode:r,decode:n})=>new Ye(t,e,r,n),V=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=Gt(r,e);return Y({prefix:t,name:e,encode:n,decode:s=>R(o(s))})},Gn=(t,e,r,n)=>{let o={};for(let a=0;a<e.length;++a)o[e[a]]=a;let s=t.length;for(;t[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),u=0,p=0,h=0;for(let a=0;a<s;++a){let c=o[t[a]];if(c===void 0)throw new SyntaxError(`Non-${n} character`);p=p<<r|c,u+=r,u>=8&&(u-=8,i[h++]=255&p>>u)}if(u>=r||255&p<<8-u)throw new SyntaxError("Unexpected end of data");return i},Hn=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,u=0;for(let p=0;p<t.length;++p)for(u=u<<8|t[p],i+=8;i>r;)i-=r,s+=e[o&u>>i];if(i&&(s+=e[o&u<<r-i]),n)for(;s.length*r&7;)s+="=";return s},y=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Y({prefix:e,name:t,encode(o){return Hn(o,n,r)},decode(o){return Gn(o,n,r,t)}});var Jn=Y({prefix:"\0",name:"identity",encode:t=>Xt(t),decode:t=>Jt(t)});var tt={};U(tt,{base2:()=>Xn});var Xn=y({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var rt={};U(rt,{base8:()=>Kn});var Kn=y({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var nt={};U(nt,{base10:()=>Zn});var Zn=V({prefix:"9",name:"base10",alphabet:"0123456789"});var ot={};U(ot,{base16:()=>Yn,base16upper:()=>eo});var Yn=y({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),eo=y({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var st={};U(st,{base32:()=>D,base32hex:()=>oo,base32hexpad:()=>io,base32hexpadupper:()=>ao,base32hexupper:()=>so,base32pad:()=>ro,base32padupper:()=>no,base32upper:()=>to,base32z:()=>co});var D=y({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),to=y({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ro=y({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),no=y({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),oo=y({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),so=y({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),io=y({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ao=y({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),co=y({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var it={};U(it,{base36:()=>uo,base36upper:()=>lo});var uo=V({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),lo=V({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var at={};U(at,{base58btc:()=>A,base58flickr:()=>fo});var A=V({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),fo=V({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ut={};U(ut,{base64:()=>ct,base64pad:()=>po,base64url:()=>ho,base64urlpad:()=>mo});var ct=y({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),po=y({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ho=y({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mo=y({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var lt={};U(lt,{base256emoji:()=>xo});var Yt=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),wo=Yt.reduce((t,e,r)=>(t[r]=e,t),[]),bo=Yt.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function go(t){return t.reduce((e,r)=>(e+=wo[r],e),"")}function yo(t){let e=[];for(let r of t){let n=bo[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var xo=Y({prefix:"\u{1F680}",name:"base256emoji",encode:go,decode:yo});var ht={};U(ht,{sha256:()=>Ro,sha512:()=>zo});var vo=rr,er=128,Co=127,Eo=~Co,So=Math.pow(2,31);function rr(t,e,r){e=e||[],r=r||0;for(var n=r;t>=So;)e[r++]=t&255|er,t/=128;for(;t&Eo;)e[r++]=t&255|er,t>>>=7;return e[r]=t|0,rr.bytes=r-n+1,e}var Ao=ft,To=128,tr=127;function ft(t,n){var r=0,n=n||0,o=0,s=n,i,u=t.length;do{if(s>=u)throw ft.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&tr)<<o:(i&tr)*Math.pow(2,o),o+=7}while(i>=To);return ft.bytes=s-n,r}var Po=Math.pow(2,7),Io=Math.pow(2,14),Fo=Math.pow(2,21),Uo=Math.pow(2,28),Lo=Math.pow(2,35),No=Math.pow(2,42),Oo=Math.pow(2,49),Mo=Math.pow(2,56),ko=Math.pow(2,63),$o=function(t){return t<Po?1:t<Io?2:t<Fo?3:t<Uo?4:t<Lo?5:t<No?6:t<Oo?7:t<Mo?8:t<ko?9:10},Do={encode:vo,decode:Ao,encodingLength:$o},Bo=Do,we=Bo;var be=(t,e=0)=>[we.decode(t,e),we.decode.bytes],ee=(t,e,r=0)=>(we.encode(t,e,r),e),te=t=>we.encodingLength(t);var J=(t,e)=>{let r=e.byteLength,n=te(t),o=n+te(r),s=new Uint8Array(o+r);return ee(t,s,0),ee(r,s,n),s.set(e,o),new re(t,r,e,s)},Le=t=>{let e=R(t),[r,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 re(r,o,i,e)},nr=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Ht(t.bytes,r.bytes)}},re=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var dt=({name:t,code:e,encode:r})=>new pt(t,e,r),pt=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?J(this.code,r):r.then(n=>J(this.code,n))}else throw Error("Unknown type, must be binary type")}};var sr=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Ro=dt({name:"sha2-256",code:18,encode:sr("SHA-256")}),zo=dt({name:"sha2-512",code:19,encode:sr("SHA-512")});var mt={};U(mt,{identity:()=>_o});var ir=0,Wo="identity",ar=R,Vo=t=>J(ir,ar(t)),_o={code:ir,name:Wo,encode:ar,digest:Vo};var Ji=new TextEncoder,Xi=new TextDecoder;var cr=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return Go(r,wt(t),e||A.encoder);default:return Ho(r,wt(t),e||D.encoder)}};var ur=new WeakMap,wt=t=>{let e=ur.get(t);if(e==null){let r=new Map;return ur.set(t,r),r}return e},g=class{constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==ge)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Jo)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return g.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=J(e,r);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,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&nr(e.multihash,n.multihash)}toString(e){return cr(this,e)}toJSON(){return{"/":cr(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof g)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new g(n,o,s,i||lr(n,o,s.bytes))}else if(r[Xo]===!0){let{version:n,multihash:o,code:s}=r,i=Le(o);return g.create(n,s,i)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==ge)throw new Error(`Version 0 CID must use dag-pb (code: ${ge}) block encoding`);return new g(e,r,n,n.bytes)}case 1:{let o=lr(e,r,n.bytes);return new g(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return g.create(0,ge,e)}static createV1(e,r){return g.create(1,e,r)}static decode(e){let[r,n]=g.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=g.inspectBytes(e),n=r.size-r.multihashSize,o=R(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new re(r.multihashCode,r.digestSize,s,o);return[r.version===0?g.createV0(i):g.createV1(r.codec,i),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[c,d]=be(e.subarray(r));return r+=d,c},o=n(),s=ge;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,u=n(),p=n(),h=r+p,a=h-i;return{version:o,codec:s,multihashCode:u,digestSize:p,multihashSize:a,size:h}}static parse(e,r){let[n,o]=Qo(e,r),s=g.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return wt(s).set(n,e),s}},Qo=(t,e)=>{switch(t[0]){case"Q":{let r=e||A;return[A.prefix,r.decode(`${A.prefix}${t}`)]}case A.prefix:{let r=e||A;return[A.prefix,r.decode(t)]}case D.prefix:{let r=e||D;return[D.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},Go=(t,e,r)=>{let{prefix:n}=r;if(n!==A.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o},Ho=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o},ge=112,Jo=18,lr=(t,e,r)=>{let n=te(t),o=n+te(e),s=new Uint8Array(o+r.byteLength);return ee(t,s,0),ee(e,s,n),s.set(r,o),s},Xo=Symbol.for("@ipld/js-cid/CID");var ye={...et,...tt,...rt,...nt,...ot,...st,...it,...at,...ut,...lt},ia={...ht,...mt};function oe(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Ne(t=0){return globalThis.Buffer?.allocUnsafe!=null?oe(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function pr(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var fr=pr("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),bt=pr("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Ne(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Ko={utf8:fr,"utf-8":fr,hex:ye.base16,latin1:bt,ascii:bt,binary:bt,...ye},Oe=Ko;function xe(t,e="utf8"){let r=Oe[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?oe(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function dr(t){return t instanceof ArrayBuffer||t?.constructor?.name==="ArrayBuffer"&&typeof t?.byteLength=="number"}var mr=t=>{t.binaryType="arraybuffer";let e=async()=>await new Promise((s,i)=>{if(n)return s();if(o!=null)return i(o);let u=a=>{t.removeEventListener("open",p),t.removeEventListener("error",h),a()},p=()=>u(s),h=a=>{u(()=>i(a.error??new Error(`connect ECONNREFUSED ${t.url}`)))};t.addEventListener("open",p),t.addEventListener("error",h)}),r=async function*(){let s=new hr.EventIterator(({push:i,stop:u,fail:p})=>{let h=c=>{let d=null;typeof c.data=="string"&&(d=xe(c.data)),dr(c.data)&&(d=new Uint8Array(c.data)),c.data instanceof Uint8Array&&(d=c.data),d!=null&&i(d)},a=c=>p(c.error??new Error("Socket error"));return t.addEventListener("message",h),t.addEventListener("error",a),t.addEventListener("close",u),()=>{t.removeEventListener("message",h),t.removeEventListener("error",a),t.removeEventListener("close",u)}},{highWaterMark:1/0});await e();for await(let i of s)yield dr(i)?new Uint8Array(i):i}(),n=t.readyState===1,o;return t.addEventListener("open",()=>{n=!0,o=null}),t.addEventListener("close",()=>{n=!1,o=null}),t.addEventListener("error",s=>{n||(o=s.error??new Error(`connect ECONNREFUSED ${t.url}`))}),Object.assign(r,{connected:e})};var wr=t=>{if(t.readyState>=2)throw new Error("socket closed");if(t.readyState!==1)return new Promise((e,r)=>{function n(){t.removeEventListener("open",o),t.removeEventListener("error",s)}function o(){n(),e()}function s(i){n(),r(i.error??new Error(`connect ECONNREFUSED ${t.url}`))}t.addEventListener("open",o),t.addEventListener("error",s)})};var br=(t,e)=>(e=e??{},e.closeOnEnd=e.closeOnEnd!==!1,async n=>{for await(let o of n){try{await wr(t)}catch(s){if(s.message==="socket closed")break;throw s}t.send(o)}if(e.closeOnEnd!=null&&t.readyState<=1)return await new Promise((o,s)=>{t.addEventListener("close",i=>{if(i.wasClean||i.code===1006)o();else{let u=Object.assign(new Error("ws error"),{event:i});s(u)}}),setTimeout(()=>t.close())})});var gr=(t,e)=>{e=e??{};let r=mr(t),n=e.remoteAddress,o=e.remotePort;if(t.url!=null)try{let i=new URL(t.url);n=i.hostname,o=parseInt(i.port,10)}catch{}if(n==null||o==null)throw new Error("Remote connection did not have address and/or port");return{sink:br(t,e),source:r,connected:async()=>await r.connected(),close:async()=>{(t.readyState===t.CONNECTING||t.readyState===t.OPEN)&&await new Promise(i=>{t.addEventListener("close",()=>{i()}),t.close()})},destroy:()=>{t.terminate!=null?t.terminate():t.close()},remoteAddress:n,remotePort:o,socket:t}};var Tr=H(Ar(),1),as={http:"ws",https:"wss"},cs="ws",Pr=(t,e)=>(0,Tr.relative)(t,e,as,cs);function Ir(t,e){let r=typeof window>"u"?"":window.location;e=e??{};let n=Pr(t,r.toString()),o=new qt(n,e.websocket);return gr(o,e)}var Me=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let r=this.index,n=e();return n===void 0&&(this.index=r),n}parseWith(e){let r=e();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let r=this.readChar();if(r===e)return r})}readSeparator(e,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,r,n,o){return this.readAtomically(()=>{let s=0,i=0,u=this.peekChar();if(u===void 0)return;let p=u==="0",h=2**(8*o)-1;for(;;){let a=this.readAtomically(()=>{let c=this.readChar();if(c===void 0)return;let d=Number.parseInt(c,e);if(!Number.isNaN(d))return d});if(a===void 0)break;if(s*=e,s+=a,s>h||(i+=1,r!==void 0&&i>r))return}if(i!==0)return!n&&p&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let r=0;r<e.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[r]=n}return e})}readIPv6Addr(){let e=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return r[o]=i[0],r[o+1]=i[1],r[o+2]=i[2],r[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];r[o]=s>>8,r[o+1]=s&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=e(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[u]=e(s.subarray(0,i));return r.set(s.subarray(0,u),16-u),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Fr=45,us=15,se=new Me;function xt(t){if(!(t.length>us))return se.new(t).parseWith(()=>se.readIPv4Addr())}function vt(t){if(!(t.length>Fr))return se.new(t).parseWith(()=>se.readIPv6Addr())}function ke(t){if(!(t.length>Fr))return se.new(t).parseWith(()=>se.readIPAddr())}function Ur(t){return!!xt(t)}function Lr(t){return!!vt(t)}function $e(t){return!!ke(t)}function P(t,e="utf8"){let r=Oe[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var Nr=Ur,ls=Lr,Ct=function(t){let e=0;if(t=t.toString().trim(),Nr(t)){let r=new Uint8Array(e+4);return t.split(/\./g).forEach(n=>{r[e++]=parseInt(n,10)&255}),r}if(ls(t)){let r=t.split(":",8),n;for(n=0;n<r.length;n++){let s=Nr(r[n]),i;s&&(i=Ct(r[n]),r[n]=P(i.slice(0,2),"base16")),i!=null&&++n<8&&r.splice(n,0,P(i.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let s=[n,1];for(n=9-r.length;n>0;n--)s.push("0");r.splice.apply(r,s)}let o=new Uint8Array(e+16);for(n=0;n<r.length;n++){let s=parseInt(r[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},Or=function(t,e=0,r){e=~~e,r=r??t.length-e;let n=new DataView(t.buffer);if(r===4){let o=[];for(let s=0;s<r;s++)o.push(t[e+s]);return o.join(".")}if(r===16){let o=[];for(let s=0;s<r;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Ce={},Et={},ps=[[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"]];ps.forEach(t=>{let e=ds(...t);Et[e.code]=e,Ce[e.name]=e});function ds(t,e,r,n,o){return{code:t,size:e,name:r,resolvable:!!n,path:!!o}}function w(t){if(typeof t=="number"){if(Et[t]!=null)return Et[t];throw new Error(`no protocol with code: ${t}`)}else if(typeof t=="string"){if(Ce[t]!=null)return Ce[t];throw new Error(`no protocol with name: ${t}`)}throw new Error(`invalid protocol id type: ${typeof t}`)}var B=H(De(),1);function z(t,e){e==null&&(e=t.reduce((o,s)=>o+s.length,0));let r=Ne(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return oe(r)}var nc=parseInt("0xFFFF",16),oc=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var kc=w("ip4"),$c=w("ip6"),Dc=w("ipcidr");function Jr(t,e){switch(w(t).code){case 4:case 41:return Ns(e);case 42:return Gr(e);case 6:case 273:case 33:case 132:return Kr(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Gr(e);case 421:return $s(e);case 444:return Hr(e);case 445:return Hr(e);case 466:return ks(e);default:return P(e,"base16")}}function Xr(t,e){switch(w(t).code){case 4:return jr(e);case 41:return jr(e);case 42:return Qr(e);case 6:case 273:case 33:case 132:return Pt(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Qr(e);case 421:return Os(e);case 444:return Ds(e);case 445:return Bs(e);case 466:return Ms(e);default:return xe(e,"base16")}}var Tt=Object.values(ye).map(t=>t.decoder),Ls=function(){let t=Tt[0].or(Tt[1]);return Tt.slice(2).forEach(e=>t=t.or(e)),t}();function jr(t){if(!$e(t))throw new Error("invalid ip address");return Ct(t)}function Ns(t){let e=Or(t,0,t.length);if(e==null)throw new Error("ipBuff is required");if(!$e(e))throw new Error("invalid ip address");return e}function Pt(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function Kr(t){return new DataView(t.buffer).getUint16(t.byteOffset)}function Qr(t){let e=xe(t),r=Uint8Array.from(B.default.encode(e.length));return z([r,e],r.length+e.length)}function Gr(t){let e=B.default.decode(t);if(t=t.slice(B.default.decode.bytes),t.length!==e)throw new Error("inconsistent lengths");return P(t)}function Os(t){let e;t[0]==="Q"||t[0]==="1"?e=Le(A.decode(`z${t}`)).bytes:e=g.parse(t).multihash.bytes;let r=Uint8Array.from(B.default.encode(e.length));return z([r,e],r.length+e.length)}function Ms(t){let e=Ls.decode(t),r=Uint8Array.from(B.default.encode(e.length));return z([r,e],r.length+e.length)}function ks(t){let e=B.default.decode(t),r=t.slice(B.default.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return"u"+P(r,"base64url")}function $s(t){let e=B.default.decode(t),r=t.slice(B.default.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return P(r,"base58btc")}function Ds(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let r=D.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=Pt(n);return z([r,o],r.length+o.length)}function Bs(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let r=D.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=Pt(n);return z([r,o],r.length+o.length)}function Hr(t){let e=t.slice(0,t.length-2),r=t.slice(t.length-2),n=P(e,"base32"),o=Kr(r);return`${n}:${o}`}var ie=H(De(),1);function Rs(t){let e=[],r=t.split("/").slice(1);if(r.length===1&&r[0]==="")return[];for(let n=0;n<r.length;n++){let o=r[n],s=w(o);if(s.size===0){e.push([o]);continue}if(n++,n>=r.length)throw Yr("invalid address: "+t);if(s.path===!0){e.push([o,Nt(r.slice(n).join("/"))]);break}e.push([o,r[n]])}return e}function zs(t){let e=[];return t.map(r=>{let n=ze(r);return e.push(n.name),r.length>1&&r[1]!=null&&e.push(r[1]),null}),Nt(e.join("/"))}function Ws(t){return t.map(e=>{Array.isArray(e)||(e=[e]);let r=ze(e);return e.length>1?[r.code,Xr(r.code,e[1])]:[r.code]})}function It(t){return t.map(e=>{let r=ze(e);return e[1]!=null?[r.code,Jr(r.code,e[1])]:[r.code]})}function Ft(t){return Re(z(t.map(e=>{let r=ze(e),n=Uint8Array.from(ie.default.encode(r.code));return e.length>1&&e[1]!=null&&(n=z([n,e[1]])),n})))}function Ut(t,e){return t.size>0?t.size/8:t.size===0?0:ie.default.decode(e)+(ie.default.decode.bytes??0)}function Be(t){let e=[],r=0;for(;r<t.length;){let n=ie.default.decode(t,r),o=ie.default.decode.bytes??0,s=w(n),i=Ut(s,t.slice(r+o));if(i===0){e.push([n]),r+=o;continue}let u=t.slice(r+o,r+o+i);if(r+=i+o,r>t.length)throw Yr("Invalid address Uint8Array: "+P(t,"base16"));e.push([n,u])}return e}function Lt(t){let e=Be(t),r=It(e);return zs(r)}function Vs(t){t=Nt(t);let e=Rs(t),r=Ws(e);return Ft(r)}function Zr(t){return Vs(t)}function Re(t){let e=_s(t);if(e!=null)throw e;return Uint8Array.from(t)}function _s(t){try{Be(t)}catch(e){return e}}function Nt(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}function Yr(t){return new Error("Error parsing address: "+t)}function ze(t){return w(t[0])}var Mt=H(De(),1);var _=class extends Error{constructor(e="The operation was aborted"){super(e),this.code=_.code,this.type=_.type}static get code(){return"ABORT_ERR"}static get type(){return"aborted"}},We=class extends Error{constructor(e,r,n){super(e),this.code=r,this.name=n?.name??"CodeError",this.props=n??{}}};function en(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var ce=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Ot=function(t,e,r,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"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r},Ee,Se,Ae,tn,js=Symbol.for("nodejs.util.inspect.custom"),Qs=[w("dns").code,w("dns4").code,w("dns6").code,w("dnsaddr").code],Gs=new Map,rn=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Hs(t){return!!t?.[rn]}var W=class{constructor(e){if(Ee.set(this,void 0),Se.set(this,void 0),Ae.set(this,void 0),this[tn]=!0,e==null&&(e=""),e instanceof Uint8Array)this.bytes=Re(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=Zr(e)}else if(Hs(e))this.bytes=Re(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return ce(this,Ee,"f")==null&&Ot(this,Ee,Lt(this.bytes),"f"),ce(this,Ee,"f")}toJSON(){return this.toString()}toOptions(){let e,r,n,o,s="",i=w("tcp"),u=w("udp"),p=w("ip4"),h=w("ip6"),a=w("dns6"),c=w("ip6zone");for(let[v,m]of this.stringTuples())v===c.code&&(s=`%${m??""}`),Qs.includes(v)&&(r=i.name,o=443,n=`${m??""}${s}`,e=v===a.code?6:4),(v===i.code||v===u.code)&&(r=w(v).name,o=parseInt(m??"")),(v===p.code||v===h.code)&&(r=w(v).name,n=`${m??""}${s}`,e=v===h.code?6:4);if(e==null||r==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:r,port:o}}protos(){return this.protoCodes().map(e=>Object.assign({},w(e)))}protoCodes(){let e=[],r=this.bytes,n=0;for(;n<r.length;){let o=Mt.default.decode(r,n),s=Mt.default.decode.bytes??0,i=w(o),u=Ut(i,r.slice(n+s));n+=u+s,e.push(o)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return ce(this,Se,"f")==null&&Ot(this,Se,Be(this.bytes),"f"),ce(this,Se,"f")}stringTuples(){return ce(this,Ae,"f")==null&&Ot(this,Ae,It(this.tuples()),"f"),ce(this,Ae,"f")}encapsulate(e){return e=new W(e),new W(this.toString()+e.toString())}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new W(n.slice(0,o))}decapsulateCode(e){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===e)return new W(Ft(r.slice(0,n)));return this}getPeerId(){try{let r=this.stringTuples().filter(n=>n[0]===Ce.ipfs.code).pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?P(A.decode(`z${n}`),"base58btc"):P(g.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let e=null;try{e=this.stringTuples().filter(r=>w(r[0]).path===!0)[0][1],e==null&&(e=null)}catch{e=null}return e}equals(e){return en(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(s=>s.resolvable);if(r==null)return[this];let n=Gs.get(r.name);if(n==null)throw new We(`no available resolver for ${r.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new W(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let r=(e??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[(Ee=new WeakMap,Se=new WeakMap,Ae=new WeakMap,tn=rn,js)](){return`Multiaddr(${Lt(this.bytes)})`}};function ae(t){return new W(t)}var Ve=(t,e)=>e,Js=(t,e,r,n)=>{if(n!=null&&n.assumeHttp===!1)return`tcp://${t}:${e}`;let o="tcp",s=`:${e}`;return r[r.length-1].protocol==="tcp"&&(o=e==="443"?"https":"http",s=e==="443"||e==="80"?"":s),`${o}://${t}${s}`},Xs={ip4:Ve,ip6:(t,e,r,n)=>n.length===1&&n[0].protocol==="ip6"?e:`[${e}]`,tcp:(t,e,r,n,o)=>n.some(s=>["http","https","ws","wss"].includes(s.protocol))?`${t}:${e}`:Js(t,e,n,o),udp:(t,e)=>`udp://${t}:${e}`,dnsaddr:Ve,dns4:Ve,dns6:Ve,ipfs:(t,e)=>`${t}/ipfs/${e}`,p2p:(t,e)=>`${t}/p2p/${e}`,http:t=>`http://${t}`,https:t=>`https://${t}`,ws:t=>`ws://${t}`,wss:t=>`wss://${t}`,"p2p-websocket-star":t=>`${t}/p2p-websocket-star`,"p2p-webrtc-star":t=>`${t}/p2p-webrtc-star`,"p2p-webrtc-direct":t=>`${t}/p2p-webrtc-direct`};function nn(t,e){let r=ae(t),n=r.toString().split("/").slice(1);return r.tuples().map(o=>({protocol:n.shift()??"",content:o[1]!=null?n.shift()??"":""})).reduce((o,s,i,u)=>{let p=Xs[s.protocol];if(p==null)throw new Error(`Unsupported protocol ${s.protocol}`);return p(o,s.content,i,u,e)},"")}function kt(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var k=H(un(),1);k.default.formatters.b=t=>t==null?"undefined":A.baseEncode(t);k.default.formatters.t=t=>t==null?"undefined":D.baseEncode(t);k.default.formatters.m=t=>t==null?"undefined":ct.baseEncode(t);k.default.formatters.p=t=>t==null?"undefined":t.toString();k.default.formatters.c=t=>t==null?"undefined":t.toString();k.default.formatters.k=t=>t==null?"undefined":t.toString();function ui(t){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=t,e.destroy=()=>!0,e.extend=()=>e,e}function je(t){let e=ui(`${t}:trace`);return k.default.enabled(`${t}:trace`)&&k.default.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(e=(0,k.default)(`${t}:trace`)),Object.assign((0,k.default)(t),{error:(0,k.default)(`${t}:error`),trace:e})}var pn=H(fn(),1),fi=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,dn=(0,pn.default)(),hn=fi&&!dn;var hu=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!dn,mn=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,mu=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+(()=>"_")()+"ENV"]==="test",wu=typeof navigator<"u"&&navigator.product==="ReactNative";function wn(){throw new Error("WebSocket Servers can not be created in the browser!")}var Te=class extends Error{constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function bn(t){if(t!=null){if(typeof t[Symbol.iterator]=="function")return t[Symbol.iterator]();if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t.next=="function")return t}throw new Error("argument is not an iterator or iterable")}function $t(t,e,r){let n=r??{},o=bn(t);async function*s(){let i,u=()=>{i?.()};for(e.addEventListener("abort",u);;){let p;try{if(e.aborted){let{abortMessage:a,abortCode:c}=n;throw new Te(a,c)}let h=new Promise((a,c)=>{i=()=>{let{abortMessage:d,abortCode:v}=n;c(new Te(d,v))}});p=await Promise.race([h,o.next()]),i=null}catch(h){e.removeEventListener("abort",u);let a=h.type==="aborted"&&e.aborted;if(a&&n.onAbort!=null&&await n.onAbort(t),typeof o.return=="function")try{let c=o.return();c instanceof Promise&&c.catch(d=>{n.onReturnError!=null&&n.onReturnError(d)})}catch(c){n.onReturnError!=null&&n.onReturnError(c)}if(a&&n.returnOnAbort===!0)return;throw h}if(p.done===!0)break;yield p.value}e.removeEventListener("abort",u)}return s()}var Dt=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Bt=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},gn=t=>globalThis.DOMException===void 0?new Bt(t):new DOMException(t),yn=t=>{let e=t.reason===void 0?gn("This operation was aborted."):t.reason;return e instanceof Error?e:gn(e)};function Rt(t,e){let{milliseconds:r,fallback:n,message:o,customTimers:s={setTimeout,clearTimeout}}=e,i,u=new Promise((p,h)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(r===Number.POSITIVE_INFINITY){p(t);return}if(e.signal){let{signal:c}=e;c.aborted&&h(yn(c)),c.addEventListener("abort",()=>{h(yn(c))})}let a=new Dt;i=s.setTimeout.call(void 0,()=>{if(n){try{p(n())}catch(c){h(c)}return}typeof t.cancel=="function"&&t.cancel(),o===!1?p():o instanceof Error?h(o):(a.message=o??`Promise timed out after ${r} milliseconds`,h(a))},r),(async()=>{try{p(await t)}catch(c){h(c)}finally{s.clearTimeout.call(void 0,i)}})()});return u.clear=()=>{s.clearTimeout.call(void 0,i),i=void 0},u}var xn=je("libp2p:websockets:socket");function vn(t,e,r){r=r??{};let n={async sink(o){r?.signal!=null&&(o=$t(o,r.signal));try{await t.sink(o)}catch(s){s.type!=="aborted"&&xn.error(s)}},source:r.signal!=null?$t(t.source,r.signal):t.source,remoteAddr:e,timeline:{open:Date.now()},async close(){let o=Date.now();try{await Rt(t.close(),{milliseconds:2e3})}catch{let{host:i,port:u}=n.remoteAddr.toOptions();xn("timeout closing stream to %s:%s after %dms, destroying it manually",i,u,Date.now()-o),t.destroy()}finally{n.timeline.close=Date.now()}}};return t.socket.addEventListener("close",()=>{n.timeline.close==null&&(n.timeline.close=Date.now())},{once:!0}),n}var di=l("dns4"),hi=l("dns6"),mi=l("dnsaddr"),j=E(l("dns"),mi,di,hi),Qe=E(l("ip4"),l("ip6")),de=E(f(Qe,l("tcp")),f(j,l("tcp"))),Ge=f(Qe,l("udp")),wi=f(Ge,l("utp")),bi=f(Ge,l("quic")),gi=f(Ge,l("quic-v1")),K=E(f(de,l("ws")),f(j,l("ws"))),Q=E(f(de,l("wss")),f(j,l("wss")),f(de,l("tls"),l("ws")),f(j,l("tls"),l("ws"))),zt=E(f(de,l("http")),f(Qe,l("http")),f(j,l("http"))),Wt=E(f(de,l("https")),f(Qe,l("https")),f(j,l("https"))),Cn=f(Ge,l("webrtc-direct"),l("certhash")),An=E(f(Cn,l("p2p")),Cn),En=f(gi,l("webtransport"),l("certhash"),l("certhash")),Tn=E(f(En,l("p2p")),En),Pn=E(f(K,l("p2p-webrtc-star"),l("p2p")),f(Q,l("p2p-webrtc-star"),l("p2p")),f(K,l("p2p-webrtc-star")),f(Q,l("p2p-webrtc-star"))),Nu=E(f(K,l("p2p-websocket-star"),l("p2p")),f(Q,l("p2p-websocket-star"),l("p2p")),f(K,l("p2p-websocket-star")),f(Q,l("p2p-websocket-star"))),In=E(f(zt,l("p2p-webrtc-direct"),l("p2p")),f(Wt,l("p2p-webrtc-direct"),l("p2p")),f(zt,l("p2p-webrtc-direct")),f(Wt,l("p2p-webrtc-direct"))),he=E(K,Q,zt,Wt,Pn,In,de,wi,bi,j,An,Tn),Ou=E(f(he,l("p2p-stardust"),l("p2p")),f(he,l("p2p-stardust"))),q=E(f(he,l("p2p")),Pn,In,An,Tn,l("p2p")),Sn=E(f(q,l("p2p-circuit"),q),f(q,l("p2p-circuit")),f(l("p2p-circuit"),q),f(he,l("p2p-circuit")),f(l("p2p-circuit"),he),l("p2p-circuit")),Fn=()=>E(f(Sn,Fn),Sn),pe=Fn(),Mu=E(f(pe,q,pe),f(q,pe),f(pe,q),pe,q);var ku=E(f(pe,l("webrtc")),f(he,l("webrtc")),l("webrtc"));function Un(t){function e(r){let n;try{n=ae(r)}catch{return!1}let o=t(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return e}function f(...t){function e(r){if(r.length<t.length)return null;let n=r;return t.some(o=>(n=typeof o=="function"?o().partialMatch(r):o.partialMatch(r),Array.isArray(n)&&(r=n),n===null)),n}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:Un(e),partialMatch:e}}function E(...t){function e(n){let o=null;return t.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:Un(e),partialMatch:e}}function l(t){let e=t;function r(o){let s;try{s=ae(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===e}function n(o){return o.length===0?null:o[0]===e?o.slice(1):null}return{toString:function(){return e},matches:r,partialMatch:n}}function On(t){return t.filter(e=>{if(e.protoCodes().includes(290))return!1;let r=e.decapsulateCode(421);return K.matches(r)||Q.matches(r)})}function Mn(t){return t.filter(e=>{if(e.protoCodes().includes(290))return!1;let r=e.decapsulateCode(421);return Q.matches(r)})}var $n=Symbol.for("@libp2p/transport");var kn;(function(t){t[t.FATAL_ALL=0]="FATAL_ALL",t[t.NO_FATAL=1]="NO_FATAL"})(kn||(kn={}));var G=je("libp2p:websockets"),Vt=class{constructor(e){this.init=e}get[Symbol.toStringTag](){return"@libp2p/websockets"}get[$n](){return!0}async dial(e,r){G("dialing %s",e),r=r??{};let n=await this._connect(e,r),o=vn(n,e);G("new outbound connection %s",o.remoteAddr);let s=await r.upgrader.upgradeOutbound(o);return G("outbound connection %s upgraded",o.remoteAddr),s}async _connect(e,r){if(r?.signal?.aborted===!0)throw new _;let n=e.toOptions();G("dialing %s:%s",n.host,n.port);let o=kt(),s=h=>{G.error("connection error:",h),o.reject(h)},i=Ir(nn(e),this.init);if(i.socket.on!=null?i.socket.on("error",s):i.socket.onerror=s,r.signal==null)return await Promise.race([i.connected(),o.promise]),G("connected %s",e),i;let u,p=new Promise((h,a)=>{if(u=()=>{a(new _),i.close().catch(c=>{G.error("error closing raw socket",c)})},r?.signal?.aborted===!0){u();return}r?.signal?.addEventListener("abort",u)});try{await Promise.race([p,o.promise,i.connected()])}finally{u!=null&&r?.signal?.removeEventListener("abort",u)}return G("connected %s",e),i}createListener(e){return wn({...this.init,...e})}filter(e){return e=Array.isArray(e)?e:[e],this.init?.filter!=null?this.init?.filter(e):hn||mn?Mn(e):On(e)}};function vi(t={}){return()=>new Vt(t)}return Vn(Ci);})();
3
3
  return Libp2PWebsockets}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/websockets",
3
- "version": "5.0.7",
3
+ "version": "5.0.9",
4
4
  "description": "JavaScript implementation of the WebSockets module that libp2p uses and that implements the interface-transport spec",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p-websockets#readme",
@@ -44,7 +44,7 @@
44
44
  ],
45
45
  "exports": {
46
46
  ".": {
47
- "types": "./src/index.d.ts",
47
+ "types": "./dist/src/index.d.ts",
48
48
  "import": "./dist/src/index.js"
49
49
  },
50
50
  "./filters": {
@@ -180,7 +180,7 @@
180
180
  "@types/ws": "^8.2.2",
181
181
  "aegir": "^38.1.7",
182
182
  "is-loopback-addr": "^2.0.1",
183
- "it-all": "^2.0.0",
183
+ "it-all": "^3.0.1",
184
184
  "it-drain": "^2.0.0",
185
185
  "it-goodbye": "^4.0.1",
186
186
  "it-pipe": "^2.0.3",