@libp2p/websockets 6.0.1 → 6.0.2

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 Bn=Object.create;var Fe=Object.defineProperty;var Rn=Object.getOwnPropertyDescriptor;var zn=Object.getOwnPropertyNames;var Wn=Object.getPrototypeOf,Vn=Object.prototype.hasOwnProperty;var F=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),U=(t,e)=>{for(var r in e)Fe(t,r,{get:e[r],enumerable:!0})},qt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of zn(e))!Vn.call(t,o)&&o!==r&&Fe(t,o,{get:()=>e[o],enumerable:!(n=Rn(e,o))||n.enumerable});return t};var X=(t,e,r)=>(r=t!=null?Bn(Wn(t)):{},qt(e||!t||!t.__esModule?Fe(r,"default",{value:t,enumerable:!0}):r,t)),_n=t=>qt(Fe({},"__esModule",{value:!0}),t);var Qt=F(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});var Xe=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}))}}},Ue=class{constructor(e,{highWaterMark:r=100,lowWaterMark:n=1}={}){let o=new Xe;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)}};Le.EventIterator=Ue;Le.default=Ue});var Gt=F(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});var Ke=Qt();be.EventIterator=Ke.EventIterator;function qn(t,e,r){return new Ke.EventIterator(({push:n})=>(this.addEventListener(t,n,e),()=>this.removeEventListener(t,n,e)),r)}be.subscribe=qn;be.default=Ke.EventIterator});var vt=F((Ta,vr)=>{"use strict";var Yo=typeof navigator<"u"&&navigator.product==="ReactNative";function es(){return Yo?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}var Ee=self.URL,xr=es(),xt=class{constructor(e="",r=xr){this.super=new Ee(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 Ee.createObjectURL(e)}static revokeObjectURL(e){Ee.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function ts(t){if(typeof t=="string")return new Ee(t).toString();if(!(t instanceof Ee)){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}`}}vr.exports={URLWithLegacySupport:xt,URLSearchParams:self.URLSearchParams,defaultBase:xr,format:ts}});var Sr=F((Pa,Er)=>{"use strict";var{URLWithLegacySupport:Cr,format:rs}=vt();Er.exports=(t,e={},r={},n)=>{let o=e.protocol?e.protocol.replace(":",""):"http";o=(r[o]||n||o)+":";let s;try{s=new Cr(t)}catch{s={}}let i=Object.assign({},e,{protocol:o||s.protocol,host:e.host||s.host});return new Cr(t,rs(i)).toString()}});var Tr=F((Ia,Ar)=>{"use strict";var{URLWithLegacySupport:ns,format:os,URLSearchParams:ss,defaultBase:is}=vt(),as=Sr();Ar.exports={URL:ns,URLSearchParams:ss,format:os,relative:as,defaultBase:is}});var Dr=F((ja,$r)=>{$r.exports=Tt;var kr=128,ms=127,ws=~ms,bs=Math.pow(2,31);function Tt(t,e,r){if(Number.MAX_SAFE_INTEGER&&t>Number.MAX_SAFE_INTEGER)throw Tt.bytes=0,new RangeError("Could not encode varint");e=e||[],r=r||0;for(var n=r;t>=bs;)e[r++]=t&255|kr,t/=128;for(;t&ws;)e[r++]=t&255|kr,t>>>=7;return e[r]=t|0,Tt.bytes=r-n+1,e}});var zr=F((Qa,Rr)=>{Rr.exports=Pt;var gs=128,Br=127;function Pt(t,n){var r=0,n=n||0,o=0,s=n,i,u=t.length;do{if(s>=u||o>49)throw Pt.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&Br)<<o:(i&Br)*Math.pow(2,o),o+=7}while(i>=gs);return Pt.bytes=s-n,r}});var Vr=F((Ga,Wr)=>{var ys=Math.pow(2,7),xs=Math.pow(2,14),vs=Math.pow(2,21),Cs=Math.pow(2,28),Es=Math.pow(2,35),Ss=Math.pow(2,42),As=Math.pow(2,49),Ts=Math.pow(2,56),Ps=Math.pow(2,63);Wr.exports=function(t){return t<ys?1:t<xs?2:t<vs?3:t<Cs?4:t<Es?5:t<Ss?6:t<As?7:t<Ts?8:t<Ps?9:10}});var Re=F((Ha,_r)=>{_r.exports={encode:Dr(),decode:zr(),encodingLength:Vr()}});var an=F((cu,sn)=>{var fe=1e3,pe=fe*60,de=pe*60,Z=de*24,Zs=Z*7,Ys=Z*365.25;sn.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return ei(t);if(r==="number"&&isFinite(t))return e.long?ri(t):ti(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function ei(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*Ys;case"weeks":case"week":case"w":return r*Zs;case"days":case"day":case"d":return r*Z;case"hours":case"hour":case"hrs":case"hr":case"h":return r*de;case"minutes":case"minute":case"mins":case"min":case"m":return r*pe;case"seconds":case"second":case"secs":case"sec":case"s":return r*fe;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function ti(t){var e=Math.abs(t);return e>=Z?Math.round(t/Z)+"d":e>=de?Math.round(t/de)+"h":e>=pe?Math.round(t/pe)+"m":e>=fe?Math.round(t/fe)+"s":t+"ms"}function ri(t){var e=Math.abs(t);return e>=Z?je(t,e,Z,"day"):e>=de?je(t,e,de,"hour"):e>=pe?je(t,e,pe,"minute"):e>=fe?je(t,e,fe,"second"):t+" ms"}function je(t,e,r,n){var o=e>=r*1.5;return Math.round(t/r)+" "+n+(o?"s":"")}});var un=F((uu,cn)=>{function ni(t){r.debug=r,r.default=r,r.coerce=p,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 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 ee=x[S];O=M.call(C,ee),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}cn.exports=ni});var ln=F((L,Qe)=>{L.formatArgs=si;L.save=ii;L.load=ai;L.useColors=oi;L.storage=ci();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 oi(){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 si(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 ii(t){try{t?L.storage.setItem("debug",t):L.storage.removeItem("debug")}catch{}}function ai(){let t;try{t=L.storage.getItem("debug")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function ci(){try{return localStorage}catch{}}Qe.exports=un()(L);var{formatters:ui}=Qe.exports;ui.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var pn=F((hu,fn)=>{function fi(){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=fi});var Ei={};U(Ei,{webSockets:()=>Ci});var jt=WebSocket;var mr=X(Gt(),1);var rt={};U(rt,{identity:()=>Xn});function jn(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 ee=p.repeat(b);M<N;++M)ee+=t.charAt(S[M]);return ee}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)),ee=x;I!==T;)M[ee++]=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 Qn=jn,Gn=Qn,Ht=Gn;var Fi=new Uint8Array(0);var Jt=(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 Xt=t=>new TextEncoder().encode(t),Kt=t=>new TextDecoder().decode(t);var Ze=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")}},Ye=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 Yt(this,e)}},et=class{constructor(e){this.decoders=e}or(e){return Yt(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`)}},Yt=(t,e)=>new et({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),tt=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ze(e,r,n),this.decoder=new Ye(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},te=({name:t,prefix:e,encode:r,decode:n})=>new tt(t,e,r,n),_=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=Ht(r,e);return te({prefix:t,name:e,encode:n,decode:s=>R(o(s))})},Hn=(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},Jn=(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})=>te({prefix:e,name:t,encode(o){return Jn(o,n,r)},decode(o){return Hn(o,n,r,t)}});var Xn=te({prefix:"\0",name:"identity",encode:t=>Kt(t),decode:t=>Xt(t)});var nt={};U(nt,{base2:()=>Kn});var Kn=y({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ot={};U(ot,{base8:()=>Zn});var Zn=y({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var st={};U(st,{base10:()=>Yn});var Yn=_({prefix:"9",name:"base10",alphabet:"0123456789"});var it={};U(it,{base16:()=>eo,base16upper:()=>to});var eo=y({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),to=y({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var at={};U(at,{base32:()=>D,base32hex:()=>so,base32hexpad:()=>ao,base32hexpadupper:()=>co,base32hexupper:()=>io,base32pad:()=>no,base32padupper:()=>oo,base32upper:()=>ro,base32z:()=>uo});var D=y({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ro=y({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),no=y({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),oo=y({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),so=y({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),io=y({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ao=y({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),co=y({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),uo=y({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ct={};U(ct,{base36:()=>lo,base36upper:()=>fo});var lo=_({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),fo=_({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ut={};U(ut,{base58btc:()=>A,base58flickr:()=>po});var A=_({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),po=_({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ft={};U(ft,{base64:()=>lt,base64pad:()=>ho,base64url:()=>mo,base64urlpad:()=>wo});var lt=y({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ho=y({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),mo=y({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wo=y({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var pt={};U(pt,{base256emoji:()=>vo});var er=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}"),bo=er.reduce((t,e,r)=>(t[r]=e,t),[]),go=er.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function yo(t){return t.reduce((e,r)=>(e+=bo[r],e),"")}function xo(t){let e=[];for(let r of t){let n=go[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var vo=te({prefix:"\u{1F680}",name:"base256emoji",encode:yo,decode:xo});var wt={};U(wt,{sha256:()=>zo,sha512:()=>Wo});var Co=nr,tr=128,Eo=127,So=~Eo,Ao=Math.pow(2,31);function nr(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Ao;)e[r++]=t&255|tr,t/=128;for(;t&So;)e[r++]=t&255|tr,t>>>=7;return e[r]=t|0,nr.bytes=r-n+1,e}var To=dt,Po=128,rr=127;function dt(t,n){var r=0,n=n||0,o=0,s=n,i,u=t.length;do{if(s>=u)throw dt.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&rr)<<o:(i&rr)*Math.pow(2,o),o+=7}while(i>=Po);return dt.bytes=s-n,r}var Io=Math.pow(2,7),Fo=Math.pow(2,14),Uo=Math.pow(2,21),Lo=Math.pow(2,28),No=Math.pow(2,35),Oo=Math.pow(2,42),Mo=Math.pow(2,49),ko=Math.pow(2,56),$o=Math.pow(2,63),Do=function(t){return t<Io?1:t<Fo?2:t<Uo?3:t<Lo?4:t<No?5:t<Oo?6:t<Mo?7:t<ko?8:t<$o?9:10},Bo={encode:Co,decode:To,encodingLength:Do},Ro=Bo,ge=Ro;var ye=(t,e=0)=>[ge.decode(t,e),ge.decode.bytes],re=(t,e,r=0)=>(ge.encode(t,e,r),e),ne=t=>ge.encodingLength(t);var K=(t,e)=>{let r=e.byteLength,n=ne(t),o=n+ne(r),s=new Uint8Array(o+r);return re(t,s,0),re(r,s,n),s.set(e,o),new oe(t,r,e,s)},Oe=t=>{let e=R(t),[r,n]=ye(e),[o,s]=ye(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new oe(r,o,i,e)},or=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Jt(t.bytes,r.bytes)}},oe=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var mt=({name:t,code:e,encode:r})=>new ht(t,e,r),ht=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?K(this.code,r):r.then(n=>K(this.code,n))}else throw Error("Unknown type, must be binary type")}};var ir=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),zo=mt({name:"sha2-256",code:18,encode:ir("SHA-256")}),Wo=mt({name:"sha2-512",code:19,encode:ir("SHA-512")});var bt={};U(bt,{identity:()=>qo});var ar=0,Vo="identity",cr=R,_o=t=>K(ar,cr(t)),qo={code:ar,name:Vo,encode:cr,digest:_o};var Xi=new TextEncoder,Ki=new TextDecoder;var ur=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return Ho(r,gt(t),e||A.encoder);default:return Jo(r,gt(t),e||D.encoder)}};var lr=new WeakMap,gt=t=>{let e=lr.get(t);if(e==null){let r=new Map;return lr.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!==xe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Xo)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=K(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&&or(e.multihash,n.multihash)}toString(e){return ur(this,e)}toJSON(){return{"/":ur(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||fr(n,o,s.bytes))}else if(r[Ko]===!0){let{version:n,multihash:o,code:s}=r,i=Oe(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!==xe)throw new Error(`Version 0 CID must use dag-pb (code: ${xe}) block encoding`);return new g(e,r,n,n.bytes)}case 1:{let o=fr(e,r,n.bytes);return new g(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return g.create(0,xe,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 oe(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]=ye(e.subarray(r));return r+=d,c},o=n(),s=xe;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]=Go(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 gt(s).set(n,e),s}},Go=(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)]}}},Ho=(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},Jo=(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},xe=112,Xo=18,fr=(t,e,r)=>{let n=ne(t),o=n+ne(e),s=new Uint8Array(o+r.byteLength);return re(t,s,0),re(e,s,n),s.set(r,o),s},Ko=Symbol.for("@ipld/js-cid/CID");var ve={...rt,...nt,...ot,...st,...it,...at,...ct,...ut,...ft,...pt},aa={...wt,...bt};function ie(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Me(t=0){return globalThis.Buffer?.allocUnsafe!=null?ie(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function dr(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var pr=dr("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),yt=dr("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=Me(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Zo={utf8:pr,"utf-8":pr,hex:ve.base16,latin1:yt,ascii:yt,binary:yt,...ve},ke=Zo;function Ce(t,e="utf8"){let r=ke[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?ie(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function hr(t){return t instanceof ArrayBuffer||t?.constructor?.name==="ArrayBuffer"&&typeof t?.byteLength=="number"}var wr=t=>{t.binaryType="arraybuffer";let e=async()=>{await new Promise((s,i)=>{if(n){s();return}if(o!=null){i(o);return}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 mr.EventIterator(({push:i,stop:u,fail:p})=>{let h=c=>{let d=null;typeof c.data=="string"&&(d=Ce(c.data)),hr(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 hr(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 br=async t=>{if(t.readyState>=2)throw new Error("socket closed");t.readyState!==1&&await 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 gr=(t,e)=>(e=e??{},e.closeOnEnd=e.closeOnEnd!==!1,async n=>{for await(let o of n){try{await br(t)}catch(s){if(s.message==="socket closed")break;throw s}t.send(o)}e.closeOnEnd!=null&&t.readyState<=1&&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 yr=(t,e)=>{e=e??{};let r=wr(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:gr(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 Pr=X(Tr(),1),cs={http:"ws",https:"wss"},us="ws",Ir=(t,e)=>(0,Pr.relative)(t,e,cs,us);function Fr(t,e){let r=typeof window>"u"?"":window.location;e=e??{};let n=Ir(t,r.toString()),o=new jt(n,e.websocket);return yr(o,e)}var $e=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 Ur=45,ls=15,ae=new $e;function Ct(t){if(!(t.length>ls))return ae.new(t).parseWith(()=>ae.readIPv4Addr())}function Et(t){if(!(t.length>Ur))return ae.new(t).parseWith(()=>ae.readIPv6Addr())}function De(t){if(!(t.length>Ur))return ae.new(t).parseWith(()=>ae.readIPAddr())}function Lr(t){return!!Ct(t)}function Nr(t){return!!Et(t)}function Be(t){return!!De(t)}function P(t,e="utf8"){let r=ke[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 Or=Lr,fs=Nr,St=function(t){let e=0;if(t=t.toString().trim(),Or(t)){let r=new Uint8Array(e+4);return t.split(/\./g).forEach(n=>{r[e++]=parseInt(n,10)&255}),r}if(fs(t)){let r=t.split(":",8),n;for(n=0;n<r.length;n++){let s=Or(r[n]),i;s&&(i=St(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")},Mr=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 Se={},At={},ds=[[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"]];ds.forEach(t=>{let e=hs(...t);At[e.code]=e,Se[e.name]=e});function hs(t,e,r,n,o){return{code:t,size:e,name:r,resolvable:!!n,path:!!o}}function w(t){if(typeof t=="number"){if(At[t]!=null)return At[t];throw new Error(`no protocol with code: ${t}`)}else if(typeof t=="string"){if(Se[t]!=null)return Se[t];throw new Error(`no protocol with name: ${t}`)}throw new Error(`invalid protocol id type: ${typeof t}`)}var B=X(Re(),1);function z(t,e){e==null&&(e=t.reduce((o,s)=>o+s.length,0));let r=Me(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return ie(r)}var oc=parseInt("0xFFFF",16),sc=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var $c=w("ip4"),Dc=w("ip6"),Bc=w("ipcidr");function Xr(t,e){switch(w(t).code){case 4:case 41:return Os(e);case 42:return Hr(e);case 6:case 273:case 33:case 132:return Zr(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Hr(e);case 421:return Ds(e);case 444:return Jr(e);case 445:return Jr(e);case 466:return $s(e);default:return P(e,"base16")}}function Kr(t,e){switch(w(t).code){case 4:return Qr(e);case 41:return Qr(e);case 42:return Gr(e);case 6:case 273:case 33:case 132:return Ft(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Gr(e);case 421:return Ms(e);case 444:return Bs(e);case 445:return Rs(e);case 466:return ks(e);default:return Ce(e,"base16")}}var It=Object.values(ve).map(t=>t.decoder),Ns=function(){let t=It[0].or(It[1]);return It.slice(2).forEach(e=>t=t.or(e)),t}();function Qr(t){if(!Be(t))throw new Error("invalid ip address");return St(t)}function Os(t){let e=Mr(t,0,t.length);if(e==null)throw new Error("ipBuff is required");if(!Be(e))throw new Error("invalid ip address");return e}function Ft(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function Zr(t){return new DataView(t.buffer).getUint16(t.byteOffset)}function Gr(t){let e=Ce(t),r=Uint8Array.from(B.default.encode(e.length));return z([r,e],r.length+e.length)}function Hr(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 Ms(t){let e;t[0]==="Q"||t[0]==="1"?e=Oe(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 ks(t){let e=Ns.decode(t),r=Uint8Array.from(B.default.encode(e.length));return z([r,e],r.length+e.length)}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"u"+P(r,"base64url")}function Ds(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 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!==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=Ft(n);return z([r,o],r.length+o.length)}function Rs(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=Ft(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=P(e,"base32"),o=Zr(r);return`${n}:${o}`}var ce=X(Re(),1);function zs(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 en("invalid address: "+t);if(s.path===!0){e.push([o,Mt(r.slice(n).join("/"))]);break}e.push([o,r[n]])}return e}function Ws(t){let e=[];return t.map(r=>{let n=Ve(r);return e.push(n.name),r.length>1&&r[1]!=null&&e.push(r[1]),null}),Mt(e.join("/"))}function Vs(t){return t.map(e=>{Array.isArray(e)||(e=[e]);let r=Ve(e);return e.length>1?[r.code,Kr(r.code,e[1])]:[r.code]})}function Ut(t){return t.map(e=>{let r=Ve(e);return e[1]!=null?[r.code,Xr(r.code,e[1])]:[r.code]})}function Lt(t){return We(z(t.map(e=>{let r=Ve(e),n=Uint8Array.from(ce.default.encode(r.code));return e.length>1&&e[1]!=null&&(n=z([n,e[1]])),n})))}function Nt(t,e){return t.size>0?t.size/8:t.size===0?0:ce.default.decode(e)+(ce.default.decode.bytes??0)}function ze(t){let e=[],r=0;for(;r<t.length;){let n=ce.default.decode(t,r),o=ce.default.decode.bytes??0,s=w(n),i=Nt(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 en("Invalid address Uint8Array: "+P(t,"base16"));e.push([n,u])}return e}function Ot(t){let e=ze(t),r=Ut(e);return Ws(r)}function _s(t){t=Mt(t);let e=zs(t),r=Vs(e);return Lt(r)}function Yr(t){return _s(t)}function We(t){let e=qs(t);if(e!=null)throw e;return Uint8Array.from(t)}function qs(t){try{ze(t)}catch(e){return e}}function Mt(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}function en(t){return new Error("Error parsing address: "+t)}function Ve(t){return w(t[0])}var kt=X(Re(),1);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"}},_e=class extends Error{constructor(e,r,n){super(e),this.code=r,this.name=n?.name??"CodeError",this.props=n??{}}};function tn(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 W=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)},le=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},Ae,Te,Pe,j,rn,Qs=Symbol.for("nodejs.util.inspect.custom"),Gs=[w("dns").code,w("dns4").code,w("dns6").code,w("dnsaddr").code],Hs=new Map,nn=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Js(t){return!!t?.[nn]}var V=class{constructor(e){if(Ae.set(this,void 0),Te.set(this,void 0),Pe.set(this,void 0),j.set(this,void 0),this[rn]=!0,e==null&&(e=""),e instanceof Uint8Array)this.bytes=We(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=Yr(e)}else if(Js(e))this.bytes=We(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return W(this,Ae,"f")==null&&le(this,Ae,Ot(this.bytes),"f"),W(this,Ae,"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??""}`),Gs.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=kt.default.decode(r,n),s=kt.default.decode.bytes??0,i=w(o),u=Nt(i,r.slice(n+s));n+=u+s,e.push(o)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return W(this,Te,"f")==null&&le(this,Te,ze(this.bytes),"f"),W(this,Te,"f")}stringTuples(){return W(this,Pe,"f")==null&&le(this,Pe,Ut(this.tuples()),"f"),W(this,Pe,"f")}encapsulate(e){return e=new V(e),new V(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 V(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 V(Lt(r.slice(0,n)));return this}getPeerId(){try{let r=this.stringTuples().filter(n=>n[0]===Se.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(){if(W(this,j,"f")===void 0)try{le(this,j,this.stringTuples().filter(e=>w(e[0]).path===!0)[0][1],"f"),W(this,j,"f")==null&&le(this,j,null,"f")}catch{le(this,j,null,"f")}return W(this,j,"f")}equals(e){return tn(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(s=>s.resolvable);if(r==null)return[this];let n=Hs.get(r.name);if(n==null)throw new _e(`no available resolver for ${r.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new V(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)}[(Ae=new WeakMap,Te=new WeakMap,Pe=new WeakMap,j=new WeakMap,rn=nn,Qs)](){return`Multiaddr(${Ot(this.bytes)})`}};function ue(t){return new V(t)}var qe=(t,e)=>e,Xs=(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}`},Ks={ip4:qe,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}`:Xs(t,e,n,o),udp:(t,e)=>`udp://${t}:${e}`,dnsaddr:qe,dns4:qe,dns6:qe,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=ue(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=Ks[s.protocol];if(p==null)throw new Error(`Unsupported protocol ${s.protocol}`);return p(o,s.content,i,u,e)},"")}function $t(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var k=X(ln(),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":lt.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 li(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 Ge(t){let e=li(`${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 dn=X(pn(),1),pi=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,hn=(0,dn.default)(),mn=pi&&!hn;var mu=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!hn,wn=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,wu=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+(()=>"_")()+"ENV"]==="test",bu=typeof navigator<"u"&&navigator.product==="ReactNative";function bn(){throw new Error("WebSocket Servers can not be created in the browser!")}var Ie=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 Dt(t,e,r){let n=r??{},o=gn(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 Ie(a,c)}let h=new Promise((a,c)=>{i=()=>{let{abortMessage:d,abortCode:v}=n;c(new Ie(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&&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 Bt=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Rt=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},yn=t=>globalThis.DOMException===void 0?new Rt(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 zt(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(xn(c)),c.addEventListener("abort",()=>{h(xn(c))})}let a=new Bt;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 vn=Ge("libp2p:websockets:socket");function Cn(t,e,r){r=r??{};let n={async sink(o){r?.signal!=null&&(o=Dt(o,r.signal));try{await t.sink(o)}catch(s){s.type!=="aborted"&&vn.error(s)}},source:r.signal!=null?Dt(t.source,r.signal):t.source,remoteAddr:e,timeline:{open:Date.now()},async close(){let o=Date.now();try{await zt(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 hi=l("dns4"),mi=l("dns6"),wi=l("dnsaddr"),G=E(l("dns"),wi,hi,mi),He=E(l("ip4"),l("ip6")),me=E(f(He,l("tcp")),f(G,l("tcp"))),Je=f(He,l("udp")),bi=f(Je,l("utp")),gi=f(Je,l("quic")),yi=f(Je,l("quic-v1")),Y=E(f(me,l("ws")),f(G,l("ws"))),H=E(f(me,l("wss")),f(G,l("wss")),f(me,l("tls"),l("ws")),f(G,l("tls"),l("ws"))),Wt=E(f(me,l("http")),f(He,l("http")),f(G,l("http"))),Vt=E(f(me,l("https")),f(He,l("https")),f(G,l("https"))),En=f(Je,l("webrtc-direct"),l("certhash")),Tn=E(f(En,l("p2p")),En),Sn=f(yi,l("webtransport"),l("certhash"),l("certhash")),Pn=E(f(Sn,l("p2p")),Sn),In=E(f(Y,l("p2p-webrtc-star"),l("p2p")),f(H,l("p2p-webrtc-star"),l("p2p")),f(Y,l("p2p-webrtc-star")),f(H,l("p2p-webrtc-star"))),Ou=E(f(Y,l("p2p-websocket-star"),l("p2p")),f(H,l("p2p-websocket-star"),l("p2p")),f(Y,l("p2p-websocket-star")),f(H,l("p2p-websocket-star"))),Fn=E(f(Wt,l("p2p-webrtc-direct"),l("p2p")),f(Vt,l("p2p-webrtc-direct"),l("p2p")),f(Wt,l("p2p-webrtc-direct")),f(Vt,l("p2p-webrtc-direct"))),we=E(Y,H,Wt,Vt,In,Fn,me,bi,gi,G,Tn,Pn),Mu=E(f(we,l("p2p-stardust"),l("p2p")),f(we,l("p2p-stardust"))),Q=E(f(we,l("p2p")),In,Fn,Tn,Pn,l("p2p")),An=E(f(Q,l("p2p-circuit"),Q),f(Q,l("p2p-circuit")),f(l("p2p-circuit"),Q),f(we,l("p2p-circuit")),f(l("p2p-circuit"),we),l("p2p-circuit")),Un=()=>E(f(An,Un),An),he=Un(),ku=E(f(he,Q,he),f(Q,he),f(he,Q),he,Q);var $u=E(f(he,l("webrtc")),f(we,l("webrtc")),l("webrtc"));function Ln(t){function e(r){let n;try{n=ue(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:Ln(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:Ln(e),partialMatch:e}}function l(t){let e=t;function r(o){let s;try{s=ue(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 Mn(t){return t.filter(e=>{if(e.protoCodes().includes(290))return!1;let r=e.decapsulateCode(421);return Y.matches(r)||H.matches(r)})}function kn(t){return t.filter(e=>{if(e.protoCodes().includes(290))return!1;let r=e.decapsulateCode(421);return H.matches(r)})}var Dn=Symbol.for("@libp2p/transport");var $n;(function(t){t[t.FATAL_ALL=0]="FATAL_ALL",t[t.NO_FATAL=1]="NO_FATAL"})($n||($n={}));var J=Ge("libp2p:websockets"),_t=class{constructor(e){this.init=e}get[Symbol.toStringTag](){return"@libp2p/websockets"}get[Dn](){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=$t(),s=h=>{J.error("connection error:",h),o.reject(h)},i=Fr(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,p=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([p,o.promise,i.connected()])}finally{u!=null&&r?.signal?.removeEventListener("abort",u)}return J("connected %s",e),i}createListener(e){return bn({...this.init,...e})}filter(e){return e=Array.isArray(e)?e:[e],this.init?.filter!=null?this.init?.filter(e):mn||wn?kn(e):Mn(e)}};function Ci(t={}){return()=>new _t(t)}return _n(Ei);})();
2
+ "use strict";var Libp2PWebsockets=(()=>{var Bn=Object.create;var me=Object.defineProperty;var Rn=Object.getOwnPropertyDescriptor;var zn=Object.getOwnPropertyNames;var Wn=Object.getPrototypeOf,Vn=Object.prototype.hasOwnProperty;var qn=(t,e,r)=>e in t?me(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var F=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),U=(t,e)=>{for(var r in e)me(t,r,{get:e[r],enumerable:!0})},Vt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of zn(e))!Vn.call(t,o)&&o!==r&&me(t,o,{get:()=>e[o],enumerable:!(n=Rn(e,o))||n.enumerable});return t};var H=(t,e,r)=>(r=t!=null?Bn(Wn(t)):{},Vt(e||!t||!t.__esModule?me(r,"default",{value:t,enumerable:!0}):r,t)),_n=t=>Vt(me({},"__esModule",{value:!0}),t);var Qe=(t,e,r)=>(qn(t,typeof e!="symbol"?e+"":e,r),r);var _t=F(Pe=>{"use strict";Object.defineProperty(Pe,"__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}))}}},Ae=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)}};Pe.EventIterator=Ae;Pe.default=Ae});var Qt=F(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});var He=_t();we.EventIterator=He.EventIterator;function Qn(t,e,r){return new He.EventIterator(({push:n})=>(this.addEventListener(t,n,e),()=>this.removeEventListener(t,n,e)),r)}we.subscribe=Qn;we.default=He.EventIterator});var bt=F((Aa,yr)=>{"use strict";var es=typeof navigator<"u"&&navigator.product==="ReactNative";function ts(){return es?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}var Ce=self.URL,gr=ts(),wt=class{constructor(e="",r=gr){this.super=new Ce(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 Ce.createObjectURL(e)}static revokeObjectURL(e){Ce.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function rs(t){if(typeof t=="string")return new Ce(t).toString();if(!(t instanceof Ce)){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||"",a=t.search||(t.query?"?"+t.query:""),p=t.hash||"",h=t.pathname||"",c=t.path||h+a;return`${o}${e||r}${s||i+n}${c}${p}`}}yr.exports={URLWithLegacySupport:wt,URLSearchParams:self.URLSearchParams,defaultBase:gr,format:rs}});var Cr=F((Pa,vr)=>{"use strict";var{URLWithLegacySupport:xr,format:ns}=bt();vr.exports=(t,e={},r={},n)=>{let o=e.protocol?e.protocol.replace(":",""):"http";o=(r[o]||n||o)+":";let s;try{s=new xr(t)}catch{s={}}let i=Object.assign({},e,{protocol:o||s.protocol,host:e.host||s.host});return new xr(t,ns(i)).toString()}});var Sr=F((Ta,Er)=>{"use strict";var{URLWithLegacySupport:os,format:ss,URLSearchParams:is,defaultBase:as}=bt(),cs=Cr();Er.exports={URL:os,URLSearchParams:is,format:ss,relative:cs,defaultBase:as}});var Lr=F((Ba,Ur)=>{Ur.exports=gt;var Fr=128,fs=127,ps=~fs,ds=Math.pow(2,31);function gt(t,e,r){if(Number.MAX_SAFE_INTEGER&&t>Number.MAX_SAFE_INTEGER)throw gt.bytes=0,new RangeError("Could not encode varint");e=e||[],r=r||0;for(var n=r;t>=ds;)e[r++]=t&255|Fr,t/=128;for(;t&ps;)e[r++]=t&255|Fr,t>>>=7;return e[r]=t|0,gt.bytes=r-n+1,e}});var kr=F((Ra,Or)=>{Or.exports=yt;var hs=128,Nr=127;function yt(t,n){var r=0,n=n||0,o=0,s=n,i,a=t.length;do{if(s>=a||o>49)throw yt.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&Nr)<<o:(i&Nr)*Math.pow(2,o),o+=7}while(i>=hs);return yt.bytes=s-n,r}});var Dr=F((za,$r)=>{var ms=Math.pow(2,7),ws=Math.pow(2,14),bs=Math.pow(2,21),gs=Math.pow(2,28),ys=Math.pow(2,35),xs=Math.pow(2,42),vs=Math.pow(2,49),Cs=Math.pow(2,56),Es=Math.pow(2,63);$r.exports=function(t){return t<ms?1:t<ws?2:t<bs?3:t<gs?4:t<ys?5:t<xs?6:t<vs?7:t<Cs?8:t<Es?9:10}});var Oe=F((Wa,Mr)=>{Mr.exports={encode:Lr(),decode:kr(),encodingLength:Dr()}});var an=F((cu,sn)=>{var le=1e3,fe=le*60,pe=fe*60,X=pe*24,Ks=X*7,Zs=X*365.25;sn.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*pe;case"minutes":case"minute":case"mins":case"min":case"m":return r*fe;case"seconds":case"second":case"secs":case"sec":case"s":return r*le;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>=pe?Math.round(t/pe)+"h":e>=fe?Math.round(t/fe)+"m":e>=le?Math.round(t/le)+"s":t+"ms"}function ti(t){var e=Math.abs(t);return e>=X?ze(t,e,X,"day"):e>=pe?ze(t,e,pe,"hour"):e>=fe?ze(t,e,fe,"minute"):e>=le?ze(t,e,le,"second"):t+" ms"}function ze(t,e,r,n){var o=e>=r*1.5;return Math.round(t/r)+" "+n+(o?"s":"")}});var un=F((uu,cn)=>{function ri(t){r.debug=r,r.default=r,r.coerce=p,r.disable=s,r.enable=o,r.enabled=i,r.humanize=an(),r.destroy=h,Object.keys(t).forEach(c=>{r[c]=t[c]}),r.names=[],r.skips=[],r.formatters={};function e(c){let l=0;for(let d=0;d<c.length;d++)l=(l<<5)-l+c.charCodeAt(d),l|=0;return r.colors[Math.abs(l)%r.colors.length]}r.selectColor=e;function r(c){let l,d=null,C,w;function b(...v){if(!b.enabled)return;let E=b,P=Number(new Date),k=P-(l||P);E.diff=k,E.prev=l,E.curr=P,l=P,v[0]=r.coerce(v[0]),typeof v[0]!="string"&&v.unshift("%O");let S=0;v[0]=v[0].replace(/%([a-zA-Z%])/g,($,I)=>{if($==="%%")return"%";S++;let D=r.formatters[I];if(typeof D=="function"){let ee=v[S];$=D.call(E,ee),v.splice(S,1),S--}return $}),r.formatArgs.call(E,v),(E.log||r.log).apply(E,v)}return b.namespace=c,b.useColors=r.useColors(),b.color=r.selectColor(c),b.extend=n,b.destroy=r.destroy,Object.defineProperty(b,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(C!==r.namespaces&&(C=r.namespaces,w=r.enabled(c)),w),set:v=>{d=v}}),typeof r.init=="function"&&r.init(b),b}function n(c,l){let d=r(this.namespace+(typeof l>"u"?":":l)+c);return d.log=this.log,d}function o(c){r.save(c),r.namespaces=c,r.names=[],r.skips=[];let l,d=(typeof c=="string"?c:"").split(/[\s,]+/),C=d.length;for(l=0;l<C;l++)d[l]&&(c=d[l].replace(/\*/g,".*?"),c[0]==="-"?r.skips.push(new RegExp("^"+c.slice(1)+"$")):r.names.push(new RegExp("^"+c+"$")))}function s(){let c=[...r.names.map(a),...r.skips.map(a).map(l=>"-"+l)].join(",");return r.enable(""),c}function i(c){if(c[c.length-1]==="*")return!0;let l,d;for(l=0,d=r.skips.length;l<d;l++)if(r.skips[l].test(c))return!1;for(l=0,d=r.names.length;l<d;l++)if(r.names[l].test(c))return!0;return!1}function a(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function p(c){return c instanceof Error?c.stack||c.message:c}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=ri});var ln=F((N,We)=>{N.formatArgs=oi;N.save=si;N.load=ii;N.useColors=ni;N.storage=ai();N.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`."))}})();N.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function 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 ":" ")+"+"+We.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)}N.log=console.debug||console.log||(()=>{});function si(t){try{t?N.storage.setItem("debug",t):N.storage.removeItem("debug")}catch{}}function ii(){let t;try{t=N.storage.getItem("debug")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function ai(){try{return localStorage}catch{}}We.exports=un()(N);var{formatters:ci}=We.exports;ci.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var pn=F((hu,fn)=>{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)}fn.exports=li});var Ci={};U(Ci,{webSockets:()=>vi});var qt=WebSocket;var dr=H(Qt(),1);var Ze={};U(Ze,{identity:()=>Kn});function jn(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 a=t.length,p=t.charAt(0),h=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function l(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var b=0,v=0,E=0,P=w.length;E!==P&&w[E]===0;)E++,b++;for(var k=(P-E)*c+1>>>0,S=new Uint8Array(k);E!==P;){for(var M=w[E],$=0,I=k-1;(M!==0||$<v)&&I!==-1;I--,$++)M+=256*S[I]>>>0,S[I]=M%a>>>0,M=M/a>>>0;if(M!==0)throw new Error("Non-zero carry");v=$,E++}for(var D=k-v;D!==k&&S[D]===0;)D++;for(var ee=p.repeat(b);D<k;++D)ee+=t.charAt(S[D]);return ee}function d(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var b=0;if(w[b]!==" "){for(var v=0,E=0;w[b]===p;)v++,b++;for(var P=(w.length-b)*h+1>>>0,k=new Uint8Array(P);w[b];){var S=r[w.charCodeAt(b)];if(S===255)return;for(var M=0,$=P-1;(S!==0||M<E)&&$!==-1;$--,M++)S+=a*k[$]>>>0,k[$]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");E=M,b++}if(w[b]!==" "){for(var I=P-E;I!==P&&k[I]===0;)I++;for(var D=new Uint8Array(v+(P-I)),ee=v;I!==P;)D[ee++]=k[I++];return D}}}function C(w){var b=d(w);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:d,decode:C}}var Hn=jn,Gn=Hn,jt=Gn;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},z=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 Gt=t=>new TextEncoder().encode(t),Jt=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 Kt(this,e)}},Xe=class{constructor(e){this.decoders=e}or(e){return Kt(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`)}},Kt=(t,e)=>new Xe({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),Ke=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)}},te=({name:t,prefix:e,encode:r,decode:n})=>new Ke(t,e,r,n),q=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=jt(r,e);return te({prefix:t,name:e,encode:n,decode:s=>z(o(s))})},Jn=(t,e,r,n)=>{let o={};for(let c=0;c<e.length;++c)o[e[c]]=c;let s=t.length;for(;t[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),a=0,p=0,h=0;for(let c=0;c<s;++c){let l=o[t[c]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);p=p<<r|l,a+=r,a>=8&&(a-=8,i[h++]=255&p>>a)}if(a>=r||255&p<<8-a)throw new SyntaxError("Unexpected end of data");return i},Xn=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let p=0;p<t.length;++p)for(a=a<<8|t[p],i+=8;i>r;)i-=r,s+=e[o&a>>i];if(i&&(s+=e[o&a<<r-i]),n)for(;s.length*r&7;)s+="=";return s},y=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>te({prefix:e,name:t,encode(o){return Xn(o,n,r)},decode(o){return Jn(o,n,r,t)}});var Kn=te({prefix:"\0",name:"identity",encode:t=>Jt(t),decode:t=>Gt(t)});var Ye={};U(Ye,{base2:()=>Zn});var Zn=y({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var et={};U(et,{base8:()=>Yn});var Yn=y({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var tt={};U(tt,{base10:()=>eo});var eo=q({prefix:"9",name:"base10",alphabet:"0123456789"});var rt={};U(rt,{base16:()=>to,base16upper:()=>ro});var to=y({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ro=y({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var nt={};U(nt,{base32:()=>B,base32hex:()=>io,base32hexpad:()=>co,base32hexpadupper:()=>uo,base32hexupper:()=>ao,base32pad:()=>oo,base32padupper:()=>so,base32upper:()=>no,base32z:()=>lo});var B=y({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),no=y({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),oo=y({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),so=y({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),io=y({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ao=y({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),co=y({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),uo=y({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),lo=y({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ot={};U(ot,{base36:()=>fo,base36upper:()=>po});var fo=q({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),po=q({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var st={};U(st,{base58btc:()=>A,base58flickr:()=>ho});var A=q({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ho=q({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var at={};U(at,{base64:()=>it,base64pad:()=>mo,base64url:()=>wo,base64urlpad:()=>bo});var it=y({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),mo=y({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),wo=y({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),bo=y({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ct={};U(ct,{base256emoji:()=>Co});var Zt=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}"),go=Zt.reduce((t,e,r)=>(t[r]=e,t),[]),yo=Zt.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function xo(t){return t.reduce((e,r)=>(e+=go[r],e),"")}function vo(t){let e=[];for(let r of t){let n=yo[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var Co=te({prefix:"\u{1F680}",name:"base256emoji",encode:xo,decode:vo});var pt={};U(pt,{sha256:()=>Wo,sha512:()=>Vo});var Eo=tr,Yt=128,So=127,Ao=~So,Po=Math.pow(2,31);function tr(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Po;)e[r++]=t&255|Yt,t/=128;for(;t&Ao;)e[r++]=t&255|Yt,t>>>=7;return e[r]=t|0,tr.bytes=r-n+1,e}var To=ut,Io=128,er=127;function ut(t,n){var r=0,n=n||0,o=0,s=n,i,a=t.length;do{if(s>=a)throw ut.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&er)<<o:(i&er)*Math.pow(2,o),o+=7}while(i>=Io);return ut.bytes=s-n,r}var Fo=Math.pow(2,7),Uo=Math.pow(2,14),Lo=Math.pow(2,21),No=Math.pow(2,28),Oo=Math.pow(2,35),ko=Math.pow(2,42),$o=Math.pow(2,49),Do=Math.pow(2,56),Mo=Math.pow(2,63),Bo=function(t){return t<Fo?1:t<Uo?2:t<Lo?3:t<No?4:t<Oo?5:t<ko?6:t<$o?7:t<Do?8:t<Mo?9:10},Ro={encode:Eo,decode:To,encodingLength:Bo},zo=Ro,be=zo;var ge=(t,e=0)=>[be.decode(t,e),be.decode.bytes],re=(t,e,r=0)=>(be.encode(t,e,r),e),ne=t=>be.encodingLength(t);var G=(t,e)=>{let r=e.byteLength,n=ne(t),o=n+ne(r),s=new Uint8Array(o+r);return re(t,s,0),re(r,s,n),s.set(e,o),new oe(t,r,e,s)},Ie=t=>{let e=z(t),[r,n]=ge(e),[o,s]=ge(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new oe(r,o,i,e)},rr=(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)}},oe=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var ft=({name:t,code:e,encode:r})=>new lt(t,e,r),lt=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?G(this.code,r):r.then(n=>G(this.code,n))}else throw Error("Unknown type, must be binary type")}};var or=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Wo=ft({name:"sha2-256",code:18,encode:or("SHA-256")}),Vo=ft({name:"sha2-512",code:19,encode:or("SHA-512")});var dt={};U(dt,{identity:()=>Qo});var sr=0,qo="identity",ir=z,_o=t=>G(sr,ir(t)),Qo={code:sr,name:qo,encode:ir,digest:_o};var Ji=new TextEncoder,Xi=new TextDecoder;var ar=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return Jo(r,ht(t),e||A.encoder);default:return Xo(r,ht(t),e||B.encoder)}};var cr=new WeakMap,ht=t=>{let e=cr.get(t);if(e==null){let r=new Map;return cr.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!==ye)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Ko)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=G(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&&rr(e.multihash,n.multihash)}toString(e){return ar(this,e)}toJSON(){return{"/":ar(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||ur(n,o,s.bytes))}else if(r[Zo]===!0){let{version:n,multihash:o,code:s}=r,i=Ie(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!==ye)throw new Error(`Version 0 CID must use dag-pb (code: ${ye}) block encoding`);return new g(e,r,n,n.bytes)}case 1:{let o=ur(e,r,n.bytes);return new g(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return g.create(0,ye,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=z(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 oe(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[l,d]=ge(e.subarray(r));return r+=d,l},o=n(),s=ye;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,a=n(),p=n(),h=r+p,c=h-i;return{version:o,codec:s,multihashCode:a,digestSize:p,multihashSize:c,size:h}}static parse(e,r){let[n,o]=Go(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 ht(s).set(n,e),s}},Go=(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 B.prefix:{let r=e||B;return[B.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)]}}},Jo=(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},Xo=(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},ye=112,Ko=18,ur=(t,e,r)=>{let n=ne(t),o=n+ne(e),s=new Uint8Array(o+r.byteLength);return re(t,s,0),re(e,s,n),s.set(r,o),s},Zo=Symbol.for("@ipld/js-cid/CID");var xe={...Ze,...Ye,...et,...tt,...rt,...nt,...ot,...st,...at,...ct},ia={...pt,...dt};function ie(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Fe(t=0){return globalThis.Buffer?.allocUnsafe!=null?ie(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function fr(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var lr=fr("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),mt=fr("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=Fe(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Yo={utf8:lr,"utf-8":lr,hex:xe.base16,latin1:mt,ascii:mt,binary:mt,...xe},Ue=Yo;function ve(t,e="utf8"){let r=Ue[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?ie(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function pr(t){return t instanceof ArrayBuffer||t?.constructor?.name==="ArrayBuffer"&&typeof t?.byteLength=="number"}var hr=t=>{t.binaryType="arraybuffer";let e=async()=>{await new Promise((s,i)=>{if(n){s();return}if(o!=null){i(o);return}let a=c=>{t.removeEventListener("open",p),t.removeEventListener("error",h),c()},p=()=>{a(s)},h=c=>{a(()=>{i(c.error??new Error(`connect ECONNREFUSED ${t.url}`))})};t.addEventListener("open",p),t.addEventListener("error",h)})},r=async function*(){let s=new dr.EventIterator(({push:i,stop:a,fail:p})=>{let h=l=>{let d=null;typeof l.data=="string"&&(d=ve(l.data)),pr(l.data)&&(d=new Uint8Array(l.data)),l.data instanceof Uint8Array&&(d=l.data),d!=null&&i(d)},c=l=>{p(l.error??new Error("Socket error"))};return t.addEventListener("message",h),t.addEventListener("error",c),t.addEventListener("close",a),()=>{t.removeEventListener("message",h),t.removeEventListener("error",c),t.removeEventListener("close",a)}},{highWaterMark:1/0});await e();for await(let i of s)yield pr(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 mr=async t=>{if(t.readyState>=2)throw new Error("socket closed");t.readyState!==1&&await 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 wr=(t,e)=>(e=e??{},e.closeOnEnd=e.closeOnEnd!==!1,async n=>{for await(let o of n){try{await mr(t)}catch(s){if(s.message==="socket closed")break;throw s}t.send(o)}e.closeOnEnd!=null&&t.readyState<=1&&await new Promise((o,s)=>{t.addEventListener("close",i=>{if(i.wasClean||i.code===1006)o();else{let a=Object.assign(new Error("ws error"),{event:i});s(a)}}),setTimeout(()=>{t.close()})})});var br=(t,e)=>{e=e??{};let r=hr(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:wr(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 Ar=H(Sr(),1),us={http:"ws",https:"wss"},ls="ws",Pr=(t,e)=>(0,Ar.relative)(t,e,us,ls);function Tr(t,e){let r=typeof window>"u"?"":window.location;e=e??{};let n=Pr(t,r.toString()),o=new qt(n,e.websocket);return br(o,e)}var Ne=class extends Error{code;type;constructor(e="The operation was aborted"){super(e),this.code=Ne.code,this.type=Ne.type}},J=Ne;Qe(J,"code","ABORT_ERR"),Qe(J,"type","aborted");var Le=class extends Error{code;props;constructor(e,r,n){super(e),this.code=r,this.name=n?.name??"CodeError",this.props=n??{}}};function Ir(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}function T(t,e="utf8"){let r=Ue[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 Lt=H(Oe(),1);function W(t,e){e==null&&(e=t.reduce((o,s)=>o+s.length,0));let r=Fe(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return ie(r)}var ce=H(Oe(),1);var ke=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,a=this.peekChar();if(a===void 0)return;let p=a==="0",h=2**(8*o)-1;for(;;){let c=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let d=Number.parseInt(l,e);if(!Number.isNaN(d))return d});if(c===void 0)break;if(s*=e,s+=c,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),[a]=e(s.subarray(0,i));return r.set(s.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Br=45,Ss=15,ae=new ke;function xt(t){if(!(t.length>Ss))return ae.new(t).parseWith(()=>ae.readIPv4Addr())}function vt(t){if(!(t.length>Br))return ae.new(t).parseWith(()=>ae.readIPv6Addr())}function $e(t){if(!(t.length>Br))return ae.new(t).parseWith(()=>ae.readIPAddr())}var ec=parseInt("0xFFFF",16),tc=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var R=H(Oe(),1);function Wr(t){return!!xt(t)}function Vr(t){return!!vt(t)}function De(t){return!!$e(t)}var qr=Wr,Fs=Vr,Ct=function(t){let e=0;if(t=t.toString().trim(),qr(t)){let r=new Uint8Array(e+4);return t.split(/\./g).forEach(n=>{r[e++]=parseInt(n,10)&255}),r}if(Fs(t)){let r=t.split(":",8),n;for(n=0;n<r.length;n++){let s=qr(r[n]),i;s&&(i=Ct(r[n]),r[n]=T(i.slice(0,2),"base16")),i!=null&&++n<8&&r.splice(n,0,T(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")},_r=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 Ee={},Et={},Ls=[[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"]];Ls.forEach(t=>{let e=Ns(...t);Et[e.code]=e,Ee[e.name]=e});function Ns(t,e,r,n,o){return{code:t,size:e,name:r,resolvable:!!n,path:!!o}}function m(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(Ee[t]!=null)return Ee[t];throw new Error(`no protocol with name: ${t}`)}throw new Error(`invalid protocol id type: ${typeof t}`)}var Bc=m("ip4"),Rc=m("ip6"),zc=m("ipcidr");function Jr(t,e){switch(m(t).code){case 4:case 41:return ks(e);case 42:return Hr(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 Hr(e);case 421:return Bs(e);case 444:return Gr(e);case 445:return Gr(e);case 466:return Ms(e);default:return T(e,"base16")}}function Xr(t,e){switch(m(t).code){case 4:return Qr(e);case 41:return Qr(e);case 42:return jr(e);case 6:case 273:case 33:case 132:return At(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return jr(e);case 421:return $s(e);case 444:return Rs(e);case 445:return zs(e);case 466:return Ds(e);default:return ve(e,"base16")}}var St=Object.values(xe).map(t=>t.decoder),Os=function(){let t=St[0].or(St[1]);return St.slice(2).forEach(e=>t=t.or(e)),t}();function Qr(t){if(!De(t))throw new Error("invalid ip address");return Ct(t)}function ks(t){let e=_r(t,0,t.length);if(e==null)throw new Error("ipBuff is required");if(!De(e))throw new Error("invalid ip address");return e}function At(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 jr(t){let e=ve(t),r=Uint8Array.from(R.default.encode(e.length));return W([r,e],r.length+e.length)}function Hr(t){let e=R.default.decode(t);if(t=t.slice(R.default.decode.bytes),t.length!==e)throw new Error("inconsistent lengths");return T(t)}function $s(t){let e;t[0]==="Q"||t[0]==="1"?e=Ie(A.decode(`z${t}`)).bytes:e=g.parse(t).multihash.bytes;let r=Uint8Array.from(R.default.encode(e.length));return W([r,e],r.length+e.length)}function Ds(t){let e=Os.decode(t),r=Uint8Array.from(R.default.encode(e.length));return W([r,e],r.length+e.length)}function Ms(t){let e=R.default.decode(t),r=t.slice(R.default.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return"u"+T(r,"base64url")}function Bs(t){let e=R.default.decode(t),r=t.slice(R.default.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return T(r,"base58btc")}function Rs(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=B.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=At(n);return W([r,o],r.length+o.length)}function zs(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=B.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=At(n);return W([r,o],r.length+o.length)}function Gr(t){let e=t.slice(0,t.length-2),r=t.slice(t.length-2),n=T(e,"base32"),o=Kr(r);return`${n}:${o}`}function Ws(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=m(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,Ut(r.slice(n).join("/"))]);break}e.push([o,r[n]])}return e}function Vs(t){let e=[];return t.map(r=>{let n=Re(r);return e.push(n.name),r.length>1&&r[1]!=null&&e.push(r[1]),null}),Ut(e.join("/"))}function qs(t){return t.map(e=>{Array.isArray(e)||(e=[e]);let r=Re(e);return e.length>1?[r.code,Xr(r.code,e[1])]:[r.code]})}function Pt(t){return t.map(e=>{let r=Re(e);return e[1]!=null?[r.code,Jr(r.code,e[1])]:[r.code]})}function Tt(t){return Be(W(t.map(e=>{let r=Re(e),n=Uint8Array.from(ce.default.encode(r.code));return e.length>1&&e[1]!=null&&(n=W([n,e[1]])),n})))}function It(t,e){return t.size>0?t.size/8:t.size===0?0:ce.default.decode(e)+(ce.default.decode.bytes??0)}function Me(t){let e=[],r=0;for(;r<t.length;){let n=ce.default.decode(t,r),o=ce.default.decode.bytes??0,s=m(n),i=It(s,t.slice(r+o));if(i===0){e.push([n]),r+=o;continue}let a=t.slice(r+o,r+o+i);if(r+=i+o,r>t.length)throw Yr("Invalid address Uint8Array: "+T(t,"base16"));e.push([n,a])}return e}function Ft(t){let e=Me(t),r=Pt(e);return Vs(r)}function _s(t){t=Ut(t);let e=Ws(t),r=qs(e);return Tt(r)}function Zr(t){return _s(t)}function Be(t){let e=Qs(t);if(e!=null)throw e;return Uint8Array.from(t)}function Qs(t){try{Me(t)}catch(e){return e}}function Ut(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}function Yr(t){return new Error("Error parsing address: "+t)}function Re(t){return m(t[0])}var Hs=Symbol.for("nodejs.util.inspect.custom"),Gs=[m("dns").code,m("dns4").code,m("dns6").code,m("dnsaddr").code],Js=new Map,en=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Xs(t){return!!t?.[en]}var V=class{bytes;#t;#r;#n;#e;[en]=!0;constructor(e){if(e==null&&(e=""),e instanceof Uint8Array)this.bytes=Be(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(Xs(e))this.bytes=Be(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return this.#t==null&&(this.#t=Ft(this.bytes)),this.#t}toJSON(){return this.toString()}toOptions(){let e,r,n,o,s="",i=m("tcp"),a=m("udp"),p=m("ip4"),h=m("ip6"),c=m("dns6"),l=m("ip6zone");for(let[C,w]of this.stringTuples())C===l.code&&(s=`%${w??""}`),Gs.includes(C)&&(r=i.name,o=443,n=`${w??""}${s}`,e=C===c.code?6:4),(C===i.code||C===a.code)&&(r=m(C).name,o=parseInt(w??"")),(C===p.code||C===h.code)&&(r=m(C).name,n=`${w??""}${s}`,e=C===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({},m(e)))}protoCodes(){let e=[],r=this.bytes,n=0;for(;n<r.length;){let o=Lt.default.decode(r,n),s=Lt.default.decode.bytes??0,i=m(o),a=It(i,r.slice(n+s));n+=a+s,e.push(o)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return this.#r==null&&(this.#r=Me(this.bytes)),this.#r}stringTuples(){return this.#n==null&&(this.#n=Pt(this.tuples())),this.#n}encapsulate(e){return e=new V(e),new V(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 V(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 V(Tt(r.slice(0,n)));return this}getPeerId(){try{let r=this.stringTuples().filter(n=>n[0]===Ee.ipfs.code).pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?T(A.decode(`z${n}`),"base58btc"):T(g.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){if(this.#e===void 0)try{this.#e=this.stringTuples().filter(e=>m(e[0]).path===!0)[0][1],this.#e==null&&(this.#e=null)}catch{this.#e=null}return this.#e}equals(e){return Ir(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(s=>s.resolvable);if(r==null)return[this];let n=Js.get(r.name);if(n==null)throw new Le(`no available resolver for ${r.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new V(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)}[Hs](){return`Multiaddr(${Ft(this.bytes)})`}};function ue(t){return new V(t)}function tn(t){let e;try{e=m("sni").code}catch{return null}for(let[r,n]of t)if(r===e&&n!==void 0)return n;return null}function rn(t){return t.some(([e,r])=>e===m("tls").code)}function L(t,e,r){let n=nn[m(t).name];if(n===void 0)throw new Error(`Can't interpret protocol ${m(t).name}`);let o=n(e,r);return t===m("ip6").code?`[${o}]`:o}var nn={ip4:(t,e)=>t,ip6:(t,e)=>e.length===0?t:`[${t}]`,tcp:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`tcp://${L(r[0],r[1]??"",e)}:${t}`},udp:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`udp://${L(r[0],r[1]??"",e)}:${t}`},dnsaddr:(t,e)=>t,dns4:(t,e)=>t,dns6:(t,e)=>t,dns:(t,e)=>t,ipfs:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${L(r[0],r[1]??"",e)}/ipfs/${t}`},p2p:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${L(r[0],r[1]??"",e)}/p2p/${t}`},http:(t,e)=>{let r=rn(e),n=tn(e);if(r&&n!==null)return`https://${n}`;let o=r?"https://":"http://",s=e.pop();if(s===void 0)throw new Error("Unexpected end of multiaddr");let i=L(s[0],s[1]??"",e);return i=i.replace("tcp://",""),`${o}${i}`},tls:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return L(r[0],r[1]??"",e)},sni:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return L(r[0],r[1]??"",e)},https:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");let n=L(r[0],r[1]??"",e);return n=n.replace("tcp://",""),`https://${n}`},ws:(t,e)=>{let r=rn(e),n=tn(e);if(r&&n!==null)return`wss://${n}`;let o=r?"wss://":"ws://",s=e.pop();if(s===void 0)throw new Error("Unexpected end of multiaddr");let i=L(s[0],s[1]??"",e);return i=i.replace("tcp://",""),`${o}${i}`},wss:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");let n=L(r[0],r[1]??"",e);return n=n.replace("tcp://",""),`wss://${n}`},"p2p-websocket-star":(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${L(r[0],r[1]??"",e)}/p2p-websocket-star`},"p2p-webrtc-star":(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${L(r[0],r[1]??"",e)}/p2p-webrtc-star`},"p2p-webrtc-direct":(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${L(r[0],r[1]??"",e)}/p2p-webrtc-direct`}};function on(t,e){let n=ue(t).stringTuples(),o=n.pop();if(o===void 0)throw new Error("Unexpected end of multiaddr");let s=m(o[0]),i=nn[s.name];if(i==null)throw new Error(`No interpreter found for ${s.name}`);let a=i(o[1]??"",n);return e?.assumeHttp!==!1&&o[0]===m("tcp").code&&(a=a.replace("tcp://","http://"),(o[1]==="443"||o[1]==="80")&&(o[1]==="443"&&(a=a.replace("http://","https://")),a=a.substring(0,a.lastIndexOf(":")))),a}function Nt(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var O=H(ln(),1);O.default.formatters.b=t=>t==null?"undefined":A.baseEncode(t);O.default.formatters.t=t=>t==null?"undefined":B.baseEncode(t);O.default.formatters.m=t=>t==null?"undefined":it.baseEncode(t);O.default.formatters.p=t=>t==null?"undefined":t.toString();O.default.formatters.c=t=>t==null?"undefined":t.toString();O.default.formatters.k=t=>t==null?"undefined":t.toString();O.default.formatters.a=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 Ve(t){let e=ui(`${t}:trace`);return O.default.enabled(`${t}:trace`)&&O.default.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(e=(0,O.default)(`${t}:trace`)),Object.assign((0,O.default)(t),{error:(0,O.default)(`${t}:error`),trace:e})}var dn=H(pn(),1),fi=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,hn=(0,dn.default)(),mn=fi&&!hn;var mu=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!hn,wn=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,wu=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+(()=>"_")()+"ENV"]==="test",bu=typeof navigator<"u"&&navigator.product==="ReactNative";function bn(){throw new Error("WebSocket Servers can not be created in the browser!")}var Se=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 Ot(t,e,r){let n=r??{},o=gn(t);async function*s(){let i,a=()=>{i?.()};for(e.addEventListener("abort",a);;){let p;try{if(e.aborted){let{abortMessage:c,abortCode:l}=n;throw new Se(c,l)}let h=new Promise((c,l)=>{i=()=>{let{abortMessage:d,abortCode:C}=n;l(new Se(d,C))}});p=await Promise.race([h,o.next()]),i=null}catch(h){e.removeEventListener("abort",a);let c=h.type==="aborted"&&e.aborted;if(c&&n.onAbort!=null&&n.onAbort(t),typeof o.return=="function")try{let l=o.return();l instanceof Promise&&l.catch(d=>{n.onReturnError!=null&&n.onReturnError(d)})}catch(l){n.onReturnError!=null&&n.onReturnError(l)}if(c&&n.returnOnAbort===!0)return;throw h}if(p.done===!0)break;yield p.value}e.removeEventListener("abort",a)}return s()}var kt=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},$t=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},yn=t=>globalThis.DOMException===void 0?new $t(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 Dt(t,e){let{milliseconds:r,fallback:n,message:o,customTimers:s={setTimeout,clearTimeout}}=e,i,a=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:l}=e;l.aborted&&h(xn(l)),l.addEventListener("abort",()=>{h(xn(l))})}let c=new kt;i=s.setTimeout.call(void 0,()=>{if(n){try{p(n())}catch(l){h(l)}return}typeof t.cancel=="function"&&t.cancel(),o===!1?p():o instanceof Error?h(o):(c.message=o??`Promise timed out after ${r} milliseconds`,h(c))},r),(async()=>{try{p(await t)}catch(l){h(l)}finally{s.clearTimeout.call(void 0,i)}})()});return a.clear=()=>{s.clearTimeout.call(void 0,i),i=void 0},a}var vn=Ve("libp2p:websockets:socket");function Cn(t,e,r){r=r??{};let n={async sink(o){r?.signal!=null&&(o=Ot(o,r.signal));try{await t.sink(o)}catch(s){s.type!=="aborted"&&vn.error(s)}},source:r.signal!=null?Ot(t.source,r.signal):t.source,remoteAddr:e,timeline:{open:Date.now()},async close(){let o=Date.now();try{await Dt(t.close(),{milliseconds:2e3})}catch{let{host:i,port:a}=n.remoteAddr.toOptions();vn("timeout closing stream to %s:%s after %dms, destroying it manually",i,a,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=u("dns4"),hi=u("dns6"),mi=u("dnsaddr"),Q=x(u("dns"),mi,di,hi),qe=x(u("ip4"),u("ip6")),de=x(f(qe,u("tcp")),f(Q,u("tcp"))),_e=f(qe,u("udp")),wi=f(_e,u("utp")),bi=f(_e,u("quic")),gi=f(_e,u("quic-v1")),Mt=x(f(de,u("ws")),f(Q,u("ws"))),he=x(f(Mt,u("p2p")),Mt),Bt=x(f(de,u("wss")),f(Q,u("wss")),f(de,u("tls"),u("ws")),f(Q,u("tls"),u("ws"))),Z=x(f(Bt,u("p2p")),Bt),Rt=x(f(de,u("http")),f(qe,u("http")),f(Q,u("http"))),zt=x(f(de,u("https")),f(qe,u("https")),f(Q,u("https"))),En=f(_e,u("webrtc-direct"),u("certhash")),Pn=x(f(En,u("p2p")),En),Sn=f(gi,u("webtransport"),u("certhash"),u("certhash")),Tn=x(f(Sn,u("p2p")),Sn),In=x(f(he,u("p2p-webrtc-star"),u("p2p")),f(Z,u("p2p-webrtc-star"),u("p2p")),f(he,u("p2p-webrtc-star")),f(Z,u("p2p-webrtc-star"))),Ou=x(f(he,u("p2p-websocket-star"),u("p2p")),f(Z,u("p2p-websocket-star"),u("p2p")),f(he,u("p2p-websocket-star")),f(Z,u("p2p-websocket-star"))),Fn=x(f(Rt,u("p2p-webrtc-direct"),u("p2p")),f(zt,u("p2p-webrtc-direct"),u("p2p")),f(Rt,u("p2p-webrtc-direct")),f(zt,u("p2p-webrtc-direct"))),Y=x(Mt,Bt,Rt,zt,In,Fn,de,wi,bi,Q,Pn,Tn),ku=x(f(Y,u("p2p-stardust"),u("p2p")),f(Y,u("p2p-stardust"))),_=x(f(Y,u("p2p")),In,Fn,Pn,Tn,u("p2p")),An=x(f(_,u("p2p-circuit"),_),f(_,u("p2p-circuit")),f(u("p2p-circuit"),_),f(Y,u("p2p-circuit")),f(u("p2p-circuit"),Y),u("p2p-circuit")),Un=()=>x(f(An,Un),An),K=Un(),$u=x(f(K,_,K),f(_,K),f(K,_),K,_);var Du=x(f(K,u("webrtc"),u("p2p")),f(K,u("webrtc")),f(Y,u("webrtc"),u("p2p")),f(Y,u("webrtc")),u("webrtc"));function Ln(t){function e(r){let n;try{n=ue(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:Ln(e),partialMatch:e}}function x(...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:Ln(e),partialMatch:e}}function u(t){let e=t;function r(o){let s;try{s=ue(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 kn(t){return t.filter(e=>{if(e.protoCodes().includes(290))return!1;let r=e.decapsulateCode(421);return he.matches(r)||Z.matches(r)})}function $n(t){return t.filter(e=>{if(e.protoCodes().includes(290))return!1;let r=e.decapsulateCode(421);return Z.matches(r)})}var Mn=Symbol.for("@libp2p/transport");var Dn;(function(t){t[t.FATAL_ALL=0]="FATAL_ALL",t[t.NO_FATAL=1]="NO_FATAL"})(Dn||(Dn={}));var j=Ve("libp2p:websockets"),Wt=class{constructor(e){this.init=e}get[Symbol.toStringTag](){return"@libp2p/websockets"}get[Mn](){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 J;let n=e.toOptions();j("dialing %s:%s",n.host,n.port);let o=Nt(),s=h=>{j.error("connection error:",h),o.reject(h)},i=Tr(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 a,p=new Promise((h,c)=>{if(a=()=>{c(new J),i.close().catch(l=>{j.error("error closing raw socket",l)})},r?.signal?.aborted===!0){a();return}r?.signal?.addEventListener("abort",a)});try{await Promise.race([p,o.promise,i.connected()])}finally{a!=null&&r?.signal?.removeEventListener("abort",a)}return j("connected %s",e),i}createListener(e){return bn({...this.init,...e})}filter(e){return e=Array.isArray(e)?e:[e],this.init?.filter!=null?this.init?.filter(e):mn||wn?$n(e):kn(e)}};function vi(t={}){return()=>new Wt(t)}return _n(Ci);})();
3
3
  return Libp2PWebsockets}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/websockets",
3
- "version": "6.0.1",
3
+ "version": "6.0.2",
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",
@@ -167,6 +167,7 @@
167
167
  "@multiformats/mafmt": "^12.0.0",
168
168
  "@multiformats/multiaddr": "^12.0.0",
169
169
  "@multiformats/multiaddr-to-uri": "^9.0.2",
170
+ "@types/ws": "^8.5.4",
170
171
  "abortable-iterator": "^5.0.0",
171
172
  "it-ws": "^6.0.0",
172
173
  "p-defer": "^4.0.0",
@@ -177,7 +178,6 @@
177
178
  "devDependencies": {
178
179
  "@libp2p/interface-mocks": "^11.0.0",
179
180
  "@libp2p/interface-transport-compliance-tests": "^4.0.0",
180
- "@types/ws": "^8.2.2",
181
181
  "aegir": "^38.1.7",
182
182
  "is-loopback-addr": "^2.0.1",
183
183
  "it-all": "^3.0.1",