@libp2p/dcutr 3.0.20-29797a5bb → 3.0.20-5b8813abc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,4 +1,4 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PDcutr = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PDcutr=(()=>{var Oo=Object.create;var qe=Object.defineProperty;var Uo=Object.getOwnPropertyDescriptor;var Fo=Object.getOwnPropertyNames;var Bo=Object.getPrototypeOf,Mo=Object.prototype.hasOwnProperty;var Et=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),N=(r,e)=>{for(var t in e)qe(r,t,{get:e[t],enumerable:!0})},nn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Fo(e))!Mo.call(r,o)&&o!==t&&qe(r,o,{get:()=>e[o],enumerable:!(n=Uo(e,o))||n.enumerable});return r};var Ro=(r,e,t)=>(t=r!=null?Oo(Bo(r)):{},nn(e||!r||!r.__esModule?qe(t,"default",{value:r,enumerable:!0}):t,r)),ko=r=>nn(qe({},"__esModule",{value:!0}),r);var hr=Et(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Ee.Netmask4Impl=void 0;Ee.ip2long=ye;Ee.long2ip=V;function V(r){let e=(r&-16777216)>>>24,t=(r&255<<16)>>>16,n=(r&65280)>>>8,o=r&255;return[e,t,n,o].join(".")}var li=48,fi=97,hi=65;function di(r){let e=0,t=10,n="9",o=0;r.length>1&&r[o]==="0"&&(r[o+1]==="x"||r[o+1]==="X"?(o+=2,t=16):"0"<=r[o+1]&&r[o+1]<="9"&&(o++,t=8,n="7"));let s=o;for(;o<r.length;){if("0"<=r[o]&&r[o]<=n)e=e*t+(r.charCodeAt(o)-li)>>>0;else if(t===16)if("a"<=r[o]&&r[o]<="f")e=e*t+(10+r.charCodeAt(o)-fi)>>>0;else if("A"<=r[o]&&r[o]<="F")e=e*t+(10+r.charCodeAt(o)-hi)>>>0;else break;else break;if(e>4294967295)throw new Error("too large");o++}if(o===s)throw new Error("empty octet");return[e,o]}function ye(r){let e=[];for(let t=0;t<=3&&r.length!==0;t++){if(t>0){if(r[0]!==".")throw new Error("Invalid IP");r=r.substring(1)}let[n,o]=di(r);r=r.substring(o),e.push(n)}if(r.length!==0)throw new Error("Invalid IP");switch(e.length){case 1:if(e[0]>4294967295)throw new Error("Invalid IP");return e[0]>>>0;case 2:if(e[0]>255||e[1]>16777215)throw new Error("Invalid IP");return(e[0]<<24|e[1])>>>0;case 3:if(e[0]>255||e[1]>255||e[2]>65535)throw new Error("Invalid IP");return(e[0]<<24|e[1]<<16|e[2])>>>0;case 4:if(e[0]>255||e[1]>255||e[2]>255||e[3]>255)throw new Error("Invalid IP");return(e[0]<<24|e[1]<<16|e[2]<<8|e[3])>>>0;default:throw new Error("Invalid IP")}}var fr=class r{constructor(e,t){if(typeof e!="string")throw new Error("Missing `net' parameter");let n=t;if(!n){let o=e.split("/",2);e=o[0],n=o[1]}if(n||(n=32),typeof n=="string"&&n.indexOf(".")>-1){try{this.maskLong=ye(n)}catch{throw new Error("Invalid mask: "+n)}this.bitmask=NaN;for(let o=32;o>=0;o--)if(this.maskLong===4294967295<<32-o>>>0){this.bitmask=o;break}}else if(n||n===0)this.bitmask=parseInt(n,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(ye(e)&this.maskLong)>>>0}catch{throw new Error("Invalid net address: "+e)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+n);this.size=Math.pow(2,32-this.bitmask),this.base=V(this.netLong),this.mask=V(this.maskLong),this.hostmask=V(~this.maskLong),this.first=this.bitmask<=30?V(this.netLong+1):this.base,this.last=this.bitmask<=30?V(this.netLong+this.size-2):V(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?V(this.netLong+this.size-1):void 0}contains(e){return typeof e=="string"&&(e.indexOf("/")>0||e.split(".").length!==4)&&(e=new r(e)),e instanceof r?this.contains(e.base)&&this.contains(e.broadcast||e.last):(ye(e)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0}next(e=1){return new r(V(this.netLong+this.size*e),this.mask)}forEach(e){let t=ye(this.first),n=ye(this.last),o=0;for(;t<=n;)e(V(t),t,o),o++,t++}toString(){return this.base+"/"+this.bitmask}};Ee.Netmask4Impl=fr});var Hn=Et(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.Netmask6Impl=void 0;Ie.ip6bigint=pr;Ie.bigint2ip6=ie;var pi=hr(),dr=(1n<<128n)-1n;function pr(r){let e=r.indexOf("%");e!==-1&&(r=r.substring(0,e));let t=r.lastIndexOf(":");if(t!==-1&&r.indexOf(".",t)!==-1){let n=r.substring(t+1),o=(0,pi.ip2long)(n),s=r.substring(0,t+1)+"0:0";return Xn(s)&~0xffffffffn|BigInt(o)}return Xn(r)}function Xn(r){let e=r.indexOf("::"),t;if(e!==-1){let o=r.substring(0,e),s=r.substring(e+2),i=o===""?[]:o.split(":"),a=s===""?[]:s.split(":"),c=8-i.length-a.length;if(c<0)throw new Error("Invalid IPv6: too many groups");t=[...i,...Array(c).fill("0"),...a]}else t=r.split(":");if(t.length!==8)throw new Error("Invalid IPv6: expected 8 groups, got "+t.length);let n=0n;for(let o=0;o<8;o++){let s=t[o];if(s.length===0||s.length>4)throw new Error('Invalid IPv6: bad group "'+s+'"');let i=parseInt(s,16);if(isNaN(i)||i<0||i>65535)throw new Error('Invalid IPv6: bad group "'+s+'"');n=n<<16n|BigInt(i)}return n}function ie(r){if(r<0n||r>dr)throw new Error("Invalid IPv6 address value");let e=[];for(let i=0;i<8;i++)e.unshift(Number(r&0xffffn)),r>>=16n;let t=-1,n=0,o=-1,s=0;for(let i=0;i<8;i++)e[i]===0?o===-1?(o=i,s=1):s++:(s>n&&s>=2&&(t=o,n=s),o=-1,s=0);if(s>n&&s>=2&&(t=o,n=s),t!==-1&&t+n===8&&t>0)return e.slice(0,t).map(a=>a.toString(16)).join(":")+"::";if(t===0)return"::"+e.slice(n).map(a=>a.toString(16)).join(":");if(t>0){let i=e.slice(0,t).map(c=>c.toString(16)),a=e.slice(t+n).map(c=>c.toString(16));return i.join(":")+"::"+a.join(":")}else return e.map(i=>i.toString(16)).join(":")}var mr=class r{constructor(e,t){if(typeof e!="string")throw new Error("Missing `net' parameter");let n=t;if(n==null){let o=e.indexOf("/");o!==-1?(n=parseInt(e.substring(o+1),10),e=e.substring(0,o)):n=128}if(isNaN(n)||n<0||n>128)throw new Error("Invalid mask for IPv6: "+n);this.bitmask=n,this.bitmask===0?this.maskBigint=0n:this.maskBigint=dr>>BigInt(128-this.bitmask)<<BigInt(128-this.bitmask);try{this.netBigint=pr(e)&this.maskBigint}catch{throw new Error("Invalid IPv6 net address: "+e)}this.size=Number(1n<<BigInt(128-this.bitmask)),this.base=ie(this.netBigint),this.mask=ie(this.maskBigint),this.hostmask=ie(~this.maskBigint&dr),this.first=this.base,this.last=ie(this.netBigint+(1n<<BigInt(128-this.bitmask))-1n),this.broadcast=void 0}contains(e){return typeof e=="string"&&e.indexOf("/")>0&&(e=new r(e)),e instanceof r?this.contains(e.base)&&this.contains(e.last):(pr(e)&this.maskBigint)===this.netBigint}next(e=1){let t=1n<<BigInt(128-this.bitmask);return new r(ie(this.netBigint+t*BigInt(e)),this.bitmask)}forEach(e){let t=this.netBigint,n=1n<<BigInt(128-this.bitmask),o=this.netBigint+n-1n,s=0;for(;t<=o;)e(ie(t),Number(t),s),s++,t++}toString(){return this.base+"/"+this.bitmask}};Ie.Netmask6Impl=mr});var Yn=Et(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.long2ip=ee.ip2long=ee.Netmask=void 0;var rt=hr();Object.defineProperty(ee,"ip2long",{enumerable:!0,get:function(){return rt.ip2long}});Object.defineProperty(ee,"long2ip",{enumerable:!0,get:function(){return rt.long2ip}});var mi=Hn(),gr=class r{constructor(e,t){if(typeof e!="string")throw new Error("Missing `net' parameter");(e.indexOf("/")!==-1?e.substring(0,e.indexOf("/")):e).indexOf(":")!==-1?this._impl=new mi.Netmask6Impl(e,t):this._impl=new rt.Netmask4Impl(e,t),this.base=this._impl.base,this.mask=this._impl.mask,this.hostmask=this._impl.hostmask,this.bitmask=this._impl.bitmask,this.size=this._impl.size,this.first=this._impl.first,this.last=this._impl.last,this.broadcast=this._impl.broadcast,this._impl instanceof rt.Netmask4Impl?(this.maskLong=this._impl.maskLong,this.netLong=this._impl.netLong):(this.maskLong=0,this.netLong=0)}contains(e){return typeof e=="string"&&(e.indexOf("/")>0?e=new r(e):e.indexOf(":")===-1&&e.split(".").length!==4&&(e=new r(e))),e instanceof r?this.contains(e.base)&&this.contains(e.broadcast||e.last):this._impl.contains(e)}next(e=1){let t=this._impl.next(e);return new r(t.base,t.bitmask)}forEach(e){this._impl.forEach(e)}toString(){return this._impl.toString()}};ee.Netmask=gr});var ma={};N(ma,{dcutr:()=>pa,multicodec:()=>Te});var fe=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}};var W=class extends Error{static name="InvalidMessageError";constructor(e="Invalid message"){super(e),this.name="InvalidMessageError"}};var on=Symbol.for("@libp2p/service-dependencies");var Dt={};N(Dt,{base58btc:()=>z,base58flickr:()=>qo});var Wa=new Uint8Array(0);function sn(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function j(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function an(r){return new TextEncoder().encode(r)}function cn(r){return new TextDecoder().decode(r)}function zo(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var a=r.length,c=r.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function f(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var S=0,te=0,O=0,M=b.length;O!==M&&b[O]===0;)O++,S++;for(var R=(M-O)*u+1>>>0,P=new Uint8Array(R);O!==M;){for(var k=b[O],Y=0,U=R-1;(k!==0||Y<te)&&U!==-1;U--,Y++)k+=256*P[U]>>>0,P[U]=k%a>>>0,k=k/a>>>0;if(k!==0)throw new Error("Non-zero carry");te=Y,O++}for(var $=R-te;$!==R&&P[$]===0;)$++;for(var Ge=c.repeat(S);$<R;++$)Ge+=r.charAt(P[$]);return Ge}function d(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var S=0;if(b[S]!==" "){for(var te=0,O=0;b[S]===c;)te++,S++;for(var M=(b.length-S)*l+1>>>0,R=new Uint8Array(M);b[S];){var P=t[b.charCodeAt(S)];if(P===255)return;for(var k=0,Y=M-1;(P!==0||k<O)&&Y!==-1;Y--,k++)P+=a*R[Y]>>>0,R[Y]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");O=k,S++}if(b[S]!==" "){for(var U=M-O;U!==M&&R[U]===0;)U++;for(var $=new Uint8Array(te+(M-U)),Ge=te;U!==M;)$[Ge++]=R[U++];return $}}}function g(b){var S=d(b);if(S)return S;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:d,decode:g}}var Vo=zo,$o=Vo,ln=$o;var It=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},vt=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,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 fn(this,e)}},Ct=class{decoders;constructor(e){this.decoders=e}or(e){return fn(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function fn(r,e){return new Ct({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var St=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new It(e,t,n),this.decoder=new vt(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function he({name:r,prefix:e,encode:t,decode:n}){return new St(r,e,t,n)}function Q({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=ln(t,r);return he({prefix:e,name:r,encode:n,decode:s=>j(o(s))})}function Wo(r,e,t,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),i=0,a=0,c=0;for(let l=0;l<o;++l){let u=e[r[l]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<t|u,i+=t,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=t||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function jo(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<<t-i]),n)for(;(s.length*t&7)!==0;)s+="=";return s}function Go(r){let e={};for(let t=0;t<r.length;++t)e[r[t]]=t;return e}function I({name:r,prefix:e,bitsPerChar:t,alphabet:n}){let o=Go(n);return he({prefix:e,name:r,encode(s){return jo(s,n,t)},decode(s){return Wo(s,o,t,r)}})}var z=Q({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),qo=Q({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var At={};N(At,{base32:()=>J,base32hex:()=>Qo,base32hexpad:()=>Ko,base32hexpadupper:()=>Zo,base32hexupper:()=>Jo,base32pad:()=>Ho,base32padupper:()=>Yo,base32upper:()=>Xo,base32z:()=>es});var J=I({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Xo=I({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ho=I({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Yo=I({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Qo=I({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Jo=I({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ko=I({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zo=I({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),es=I({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Tt={};N(Tt,{base36:()=>Le,base36upper:()=>ts});var Le=Q({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ts=Q({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var rs=pn,hn=128,ns=127,os=~ns,ss=Math.pow(2,31);function pn(r,e,t){e=e||[],t=t||0;for(var n=t;r>=ss;)e[t++]=r&255|hn,r/=128;for(;r&os;)e[t++]=r&255|hn,r>>>=7;return e[t]=r|0,pn.bytes=t-n+1,e}var is=Lt,as=128,dn=127;function Lt(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Lt.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&dn)<<o:(i&dn)*Math.pow(2,o),o+=7}while(i>=as);return Lt.bytes=s-n,t}var cs=Math.pow(2,7),us=Math.pow(2,14),ls=Math.pow(2,21),fs=Math.pow(2,28),hs=Math.pow(2,35),ds=Math.pow(2,42),ps=Math.pow(2,49),ms=Math.pow(2,56),gs=Math.pow(2,63),bs=function(r){return r<cs?1:r<us?2:r<ls?3:r<fs?4:r<hs?5:r<ds?6:r<ps?7:r<ms?8:r<gs?9:10},xs={encode:rs,decode:is,encodingLength:bs},ws=xs,Ne=ws;function _e(r,e=0){return[Ne.decode(r,e),Ne.decode.bytes]}function de(r,e,t=0){return Ne.encode(r,e,t),e}function pe(r){return Ne.encodingLength(r)}function ge(r,e){let t=e.byteLength,n=pe(r),o=n+pe(t),s=new Uint8Array(o+t);return de(r,s,0),de(t,s,n),s.set(e,o),new me(r,t,e,s)}function mn(r){let e=j(r),[t,n]=_e(e),[o,s]=_e(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new me(t,o,i,e)}function gn(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&sn(r.bytes,t.bytes)}}var me=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};function bn(r,e){let{bytes:t,version:n}=r;return n===0?Es(t,Nt(r),e??z.encoder):Is(t,Nt(r),e??J.encoder)}var xn=new WeakMap;function Nt(r){let e=xn.get(r);if(e==null){let t=new Map;return xn.set(r,t),t}return e}var be=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Oe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==vs)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=ge(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&gn(e.multihash,n.multihash)}toString(e){return bn(this,e)}toJSON(){return{"/":bn(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new r(n,o,s,i??wn(n,o,s.bytes))}else if(t[Cs]===!0){let{version:n,multihash:o,code:s}=t,i=mn(o);return r.create(n,s,i)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Oe)throw new Error(`Version 0 CID must use dag-pb (code: ${Oe}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=wn(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Oe,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=j(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new me(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[f,d]=_e(e.subarray(t));return t+=d,f},o=n(),s=Oe;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),c=n(),l=t+c,u=l-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:l}}static parse(e,t){let[n,o]=ys(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Nt(s).set(n,e),s}};function ys(r,e){switch(r[0]){case"Q":{let t=e??z;return[z.prefix,t.decode(`${z.prefix}${r}`)]}case z.prefix:{let t=e??z;return[z.prefix,t.decode(r)]}case J.prefix:{let t=e??J;return[J.prefix,t.decode(r)]}case Le.prefix:{let t=e??Le;return[Le.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Es(r,e,t){let{prefix:n}=t;if(n!==z.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o}function Is(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o}var Oe=112,vs=18;function wn(r,e,t){let n=pe(r),o=n+pe(e),s=new Uint8Array(o+t.byteLength);return de(r,s,0),de(e,s,n),s.set(t,o),s}var Cs=Symbol.for("@ipld/js-cid/CID");var _t={};N(_t,{identity:()=>As});var yn=0,Ss="identity",En=j;function Ds(r,e){if(e?.truncate!=null&&e.truncate!==r.byteLength){if(e.truncate<0||e.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e.truncate)}return ge(yn,En(r))}var As={code:yn,name:Ss,encode:En,digest:Ds};function G(r=0){return new Uint8Array(r)}function Ue(r=0){return new Uint8Array(r)}function Pt(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=Ue(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function In(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var Cn=Symbol.for("@achingbrain/uint8arraylist");function vn(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let o=t+n.byteLength;if(e<o)return{buf:n,index:e-t};t=o}throw new RangeError("index is out of bounds")}function He(r){return!!r?.[Cn]}var re=class r{bufs;length;[Cn]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(He(n)){t+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(He(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=vn(this.bufs,e);return t.buf[t.index]}set(e,t){let n=vn(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(He(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:o}=this._subList(e,t);return Pt(n,o)}subarray(e,t){let{bufs:n,length:o}=this._subList(e,t);return n.length===1?n[0]:Pt(n,o)}sublist(e,t){let{bufs:n,length:o}=this._subList(e,t),s=new r;return s.length=o,s.bufs=n,s}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,c=a+i.byteLength;if(o=c,e>=c)continue;let l=e>=a&&e<c,u=t>a&&t<=c;if(l&&u){if(e===a&&t===c){n.push(i);break}let f=e-a;n.push(i.subarray(f,f+(t-e)));break}if(l){if(e===0){n.push(i);continue}n.push(i.subarray(e-a));continue}if(u){if(t===c){n.push(i);break}n.push(i.subarray(0,t-a));break}n.push(i)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!He(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let f=0;f<s;f++)i[f]=-1;for(let f=0;f<o;f++)i[n[f]]=f;let a=i,c=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=t;f<=c;f+=u){u=0;for(let d=l;d>=0;d--){let g=this.get(f+d);if(n[d]!==g){u=Math.max(1,d-a[g]);break}}if(u===0)return f}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=Ue(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let o=G(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,t,n),this.write(o,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let o=G(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,t,n),this.write(o,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let o=G(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,t,n),this.write(o,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=Ue(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let o=G(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,t,n),this.write(o,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let o=G(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,t,n),this.write(o,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let o=G(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,t,n),this.write(o,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let o=G(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,t,n),this.write(o,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let o=G(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,t,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof r)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!In(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new r;return n.bufs=e,t==null&&(t=e.reduce((o,s)=>o+s.byteLength,0)),n.length=t,n}};function Sn(r=0){return new Uint8Array(r)}var Ts=Math.pow(2,7),Ls=Math.pow(2,14),Ns=Math.pow(2,21),Ot=Math.pow(2,28),Ut=Math.pow(2,35),Ft=Math.pow(2,42),Bt=Math.pow(2,49),x=128,D=127;function L(r){if(r<Ts)return 1;if(r<Ls)return 2;if(r<Ns)return 3;if(r<Ot)return 4;if(r<Ut)return 5;if(r<Ft)return 6;if(r<Bt)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function xe(r,e,t=0){switch(L(r)){case 8:e[t++]=r&255|x,r/=128;case 7:e[t++]=r&255|x,r/=128;case 6:e[t++]=r&255|x,r/=128;case 5:e[t++]=r&255|x,r/=128;case 4:e[t++]=r&255|x,r>>>=7;case 3:e[t++]=r&255|x,r>>>=7;case 2:e[t++]=r&255|x,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function _s(r,e,t=0){switch(L(r)){case 8:e.set(t++,r&255|x),r/=128;case 7:e.set(t++,r&255|x),r/=128;case 6:e.set(t++,r&255|x),r/=128;case 5:e.set(t++,r&255|x),r/=128;case 4:e.set(t++,r&255|x),r>>>=7;case 3:e.set(t++,r&255|x),r>>>=7;case 2:e.set(t++,r&255|x),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function Mt(r,e){let t=r[e],n=0;if(n+=t&D,t<x||(t=r[e+1],n+=(t&D)<<7,t<x)||(t=r[e+2],n+=(t&D)<<14,t<x)||(t=r[e+3],n+=(t&D)<<21,t<x)||(t=r[e+4],n+=(t&D)*Ot,t<x)||(t=r[e+5],n+=(t&D)*Ut,t<x)||(t=r[e+6],n+=(t&D)*Ft,t<x)||(t=r[e+7],n+=(t&D)*Bt,t<x))return n;throw new RangeError("Could not decode varint")}function Ps(r,e){let t=r.get(e),n=0;if(n+=t&D,t<x||(t=r.get(e+1),n+=(t&D)<<7,t<x)||(t=r.get(e+2),n+=(t&D)<<14,t<x)||(t=r.get(e+3),n+=(t&D)<<21,t<x)||(t=r.get(e+4),n+=(t&D)*Ot,t<x)||(t=r.get(e+5),n+=(t&D)*Ut,t<x)||(t=r.get(e+6),n+=(t&D)*Ft,t<x)||(t=r.get(e+7),n+=(t&D)*Bt,t<x))return n;throw new RangeError("Could not decode varint")}function Dn(r,e,t=0){return e==null&&(e=Sn(L(r))),e instanceof Uint8Array?xe(r,e,t):_s(r,e,t)}function Fe(r,e=0){return r instanceof Uint8Array?Mt(r,e):Ps(r,e)}var Rt=new Float32Array([-0]),K=new Uint8Array(Rt.buffer);function Tn(r,e,t){Rt[0]=r,e[t]=K[0],e[t+1]=K[1],e[t+2]=K[2],e[t+3]=K[3]}function Ln(r,e){return K[0]=r[e],K[1]=r[e+1],K[2]=r[e+2],K[3]=r[e+3],Rt[0]}var kt=new Float64Array([-0]),A=new Uint8Array(kt.buffer);function Nn(r,e,t){kt[0]=r,e[t]=A[0],e[t+1]=A[1],e[t+2]=A[2],e[t+3]=A[3],e[t+4]=A[4],e[t+5]=A[5],e[t+6]=A[6],e[t+7]=A[7]}function _n(r,e){return A[0]=r[e],A[1]=r[e+1],A[2]=r[e+2],A[3]=r[e+3],A[4]=r[e+4],A[5]=r[e+5],A[6]=r[e+6],A[7]=r[e+7],kt[0]}var Os=BigInt(Number.MAX_SAFE_INTEGER),Us=BigInt(Number.MIN_SAFE_INTEGER),_=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return ne;if(e<Os&&e>Us)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,o=e-(n<<32n);return t&&(n=~n|0n,o=~o|0n,++o>Pn&&(o=0n,++n>Pn&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return ne;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):ne}},ne=new _(0,0);ne.toBigInt=function(){return 0n};ne.zzEncode=ne.zzDecode=function(){return this};ne.length=function(){return 1};var Pn=4294967296n;function On(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Un(r,e,t){if(t-e<1)return"";let o,s=[],i=0,a;for(;e<t;)a=r[e++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function zt(r,e,t){let n=t,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128);return t-n}function F(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Ye(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var Vt=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,F(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw F(this,4);return Ye(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw F(this,4);return Ye(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw F(this,4);let e=Ln(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw F(this,4);let e=_n(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw F(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Un(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw F(this,e);this.pos+=e}else do if(this.pos>=this.len)throw F(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new _(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw F(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw F(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw F(this,8);let e=Ye(this.buf,this.pos+=4),t=Ye(this.buf,this.pos+=4);return new _(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=Mt(this.buf,this.pos);return this.pos+=L(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Be(r){return new Vt(r instanceof Uint8Array?r:r.subarray())}function $t(r,e,t){let n=Be(r);return e.decode(n,void 0,t)}function oe(r=0){return new Uint8Array(r)}var Wt={};N(Wt,{base10:()=>Fs});var Fs=Q({prefix:"9",name:"base10",alphabet:"0123456789"});var jt={};N(jt,{base16:()=>Bs,base16upper:()=>Ms});var Bs=I({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ms=I({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Gt={};N(Gt,{base2:()=>Rs});var Rs=I({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var qt={};N(qt,{base256emoji:()=>Ws});var Bn=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}"),ks=Bn.reduce((r,e,t)=>(r[t]=e,r),[]),zs=Bn.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function Vs(r){return r.reduce((e,t)=>(e+=ks[t],e),"")}function $s(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=zs[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var Ws=he({prefix:"\u{1F680}",name:"base256emoji",encode:Vs,decode:$s});var Ht={};N(Ht,{base64:()=>js,base64pad:()=>Gs,base64url:()=>Xt,base64urlpad:()=>qs});var js=I({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Gs=I({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Xt=I({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),qs=I({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Yt={};N(Yt,{base8:()=>Xs});var Xs=I({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Qt={};N(Qt,{identity:()=>Hs});var Hs=he({prefix:"\0",name:"identity",encode:r=>cn(r),decode:r=>an(r)});var Mc=new TextEncoder,Rc=new TextDecoder;var Zt={};N(Zt,{sha256:()=>Ks,sha512:()=>Zs});var Js=20;function Kt({name:r,code:e,encode:t,minDigestLength:n,maxDigestLength:o}){return new Jt(r,e,t,n,o)}var Jt=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,t,n,o,s){this.name=e,this.code=t,this.encode=n,this.minDigestLength=o??Js,this.maxDigestLength=s}digest(e,t){if(t?.truncate!=null){if(t.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&t.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?Mn(n,this.code,t?.truncate):n.then(o=>Mn(o,this.code,t?.truncate))}else throw Error("Unknown type, must be binary type")}};function Mn(r,e,t){if(t!=null&&t!==r.byteLength){if(t>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t)}return ge(e,r)}function kn(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Ks=Kt({name:"sha2-256",code:18,encode:kn("SHA-256")}),Zs=Kt({name:"sha2-512",code:19,encode:kn("SHA-512")});var Z={...Qt,...Gt,...Yt,...Wt,...jt,...At,...Tt,...Dt,...Ht,...qt},Qc={...Zt,..._t};function Vn(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var zn=Vn("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),er=Vn("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=oe(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),ei={utf8:zn,"utf-8":zn,hex:Z.base16,latin1:er,ascii:er,binary:er,...Z},$n=ei;function Wn(r,e="utf8"){let t=$n[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function tr(r){let e=r??8192,t=e>>>1,n,o=e;return function(i){if(i<1||i>t)return oe(i);o+i>e&&(n=oe(e),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var se=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function rr(){}var or=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},ti=tr();function ri(r){return globalThis.Buffer!=null?oe(r):ti(r)}var Re=class{len;head;tail;states;constructor(){this.len=0,this.head=new se(rr,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new se(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new sr((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Qe,10,_.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=_.fromBigInt(e);return this._push(Qe,t.length(),t)}uint64Number(e){return this._push(xe,L(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=_.fromBigInt(e).zzEncode();return this._push(Qe,t.length(),t)}sint64Number(e){let t=_.fromNumber(e).zzEncode();return this._push(Qe,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(nr,1,e?1:0)}fixed32(e){return this._push(Me,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=_.fromBigInt(e);return this._push(Me,4,t.lo)._push(Me,4,t.hi)}fixed64Number(e){let t=_.fromNumber(e);return this._push(Me,4,t.lo)._push(Me,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(Tn,4,e)}double(e){return this._push(Nn,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(nr,1,0):this.uint32(t)._push(oi,t,e)}string(e){let t=On(e);return t!==0?this.uint32(t)._push(zt,t,e):this._push(nr,1,0)}fork(){return this.states=new or(this),this.head=this.tail=new se(rr,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new se(rr,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=ri(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function nr(r,e,t){e[t]=r&255}function ni(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var sr=class extends se{next;constructor(e,t){super(ni,e,t),this.next=void 0}};function Qe(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function Me(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function oi(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(Re.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(si,e,r),this},Re.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(ii,e,r),this});function si(r,e,t){e.set(r,t)}function ii(r,e,t){r.length<40?zt(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(Wn(r),t)}function ir(){return new Re}function ar(r,e){let t=ir();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}function*cr(r,e,t){let n=Be(r);yield*e.stream(n,void 0,"$",t)}var Je={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function Ke(r,e,t,n,o){return{name:r,type:e,encode:t,decode:n,stream:o}}function ur(r){function e(s){if(r[s.toString()]==null)throw new Error("Invalid enum value");return r[s]}let t=function(i,a){let c=e(i);a.int32(c)},n=function(i){let a=i.int32();return e(a)},o=function*(i){let a=i.int32();yield e(a)};return Ke("enum",Je.VARINT,t,n,o)}function lr(r,e,t){return Ke("message",Je.LENGTH_DELIMITED,r,e,t)}var ke=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};function ai(r){let e=r.getComponents(),t={},n=0;return e[n]?.name==="ip6zone"&&(t.zone=`${e[n].value}`,n++),e[n]?.name==="ip4"||e[n]?.name==="ip6"||e[n]?.name==="dns"||e[n]?.name==="dns4"||e[n]?.name==="dns6"?(t.type=e[n].name,t.host=e[n].value,n++):e[n]?.name==="dnsaddr"&&(t.type=e[n].name,t.host=`_dnsaddr.${e[n].value}`,n++),(e[n]?.name==="tcp"||e[n]?.name==="udp")&&(t.protocol=e[n].name==="tcp"?"tcp":"udp",t.port=parseInt(`${e[n].value}`),n++),e[n]?.name==="ipcidr"&&(t.type==="ip4"?t.cidr=parseInt(`${e[n].value}`):t.type==="ip6"&&(t.cidr=`${e[n].value}`),n++),t.type==null||t.host==null?null:(e[n]?.name==="tls"&&e[n+1]?.name==="sni"&&(t.sni=e[n+1].value,n+=2),t)}function jn(r){let e=ai(r);if(e==null)throw new fe(`Multiaddr ${r} was not an IPv4, IPv6, DNS, DNS4, DNS6 or DNSADDR address`);return e}var Ze=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let d=Number.parseInt(f,e);if(!Number.isNaN(d))return d});if(u===void 0)break;if(s*=e,s+=u,s>l||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return t[o]=i[0],t[o+1]=i[1],t[o+2]=i[2],t[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];t[o]=s>>8,t[o+1]=s&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=e(s.subarray(0,i));return t.set(s.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var ci=45,ui=15,et=new Ze;function Gn(r){if(!(r.length>ui))return et.new(r).parseWith(()=>et.readIPv4Addr())}function qn(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>ci))return et.new(r).parseWith(()=>et.readIPv6Addr())}function we(r){return!!Gn(r)}function tt(r){return!!qn(r)}var Qn=Ro(Yn(),1),gi=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],bi=gi.map(r=>new Qn.Netmask(r));function br(r){for(let e of bi)if(e.contains(r))return!0;return!1}function xi(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function wi(r){let e=r.split(":");if(e.length<2)return!1;let t=e[e.length-1].padStart(4,"0"),n=e[e.length-2].padStart(4,"0"),o=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(t.substring(0,2),16)}.${parseInt(t.substring(2),16)}`;return br(o)}function yi(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function Ei(r){let e=r.split(":"),t=e[e.length-1];return br(t)}function Ii(r){return/^::$/.test(r)||/^::1$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function Jn(r){if(we(r))return br(r);if(xi(r))return wi(r);if(yi(r))return Ei(r);if(tt(r))return Ii(r)}function Kn(r){try{let e=jn(r);switch(e.type){case"ip4":case"ip6":return Jn(e.host)??!1;default:return e.host==="localhost"}}catch{return!1}}function Zn(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function nt(r=0){return new Uint8Array(r)}function ze(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=nt(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function to(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var eo=to("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),xr=to("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=nt(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),vi={utf8:eo,"utf-8":eo,hex:Z.base16,latin1:xr,ascii:xr,binary:xr,...Z},ot=vi;function Ve(r,e="utf8"){let t=ot[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function ae(r,e="utf8"){let t=ot[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var C=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},q=class extends Error{static name="ValidationError";name="ValidationError"},st=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},it=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function yr(r){return e=>ae(e,r)}function Er(r){return e=>Ve(e,r)}function ve(r){return new DataView(r.buffer).getUint16(r.byteOffset).toString()}function ce(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof r=="string"?parseInt(r):r),new Uint8Array(e)}function ro(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=Ve(e[0],"base32"),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ce(n);return ze([t,o],t.length+o.length)}function no(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=J.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=ce(n);return ze([t,o],t.length+o.length)}function Ir(r){let e=r.subarray(0,r.length-2),t=r.subarray(r.length-2),n=ae(e,"base32"),o=ve(t);return`${n}:${o}`}var vr=function(r){r=r.toString().trim();let e=new Uint8Array(4);return r.split(/\./g).forEach((t,n)=>{let o=parseInt(t,10);if(isNaN(o)||o<0||o>255)throw new C("Invalid byte value in IP address");e[n]=o}),e},oo=function(r){let e=0;r=r.toString().trim();let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=we(t[n]),i;s&&(i=vr(t[n]),t[n]=ae(i.subarray(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,ae(i.subarray(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let s=[n,1];for(n=9-t.length;n>0;n--)s.push("0");t.splice.apply(t,s)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){t[n]===""&&(t[n]="0");let s=parseInt(t[n],16);if(isNaN(s)||s<0||s>65535)throw new C("Invalid byte value in IP address");o[e++]=s>>8&255,o[e++]=s&255}return o},so=function(r){if(r.byteLength!==4)throw new C("IPv4 address was incorrect length");let e=[];for(let t=0;t<r.byteLength;t++)e.push(r[t]);return e.join(".")},io=function(r){if(r.byteLength!==16)throw new C("IPv6 address was incorrect length");let e=[];for(let n=0;n<r.byteLength;n+=2){let o=r[n],s=r[n+1],i=`${o.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`;e.push(i)}let t=e.join(":");try{let n=new URL(`http://[${t}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new C(`Invalid IPv6 address "${t}"`)}};function ao(r){try{let e=new URL(`http://[${r}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new C(`Invalid IPv6 address "${r}"`)}}var wr=Object.values(Z).map(r=>r.decoder),Ci=(function(){let r=wr[0].or(wr[1]);return wr.slice(2).forEach(e=>r=r.or(e)),r})();function co(r){return Ci.decode(r)}function uo(r){return e=>r.encoder.encode(e)}function Si(r){if(parseInt(r).toString()!==r)throw new q("Value must be an integer")}function Di(r){if(r<0)throw new q("Value must be a positive integer, or zero")}function Ai(r){return e=>{if(e>r)throw new q(`Value must be smaller than or equal to ${r}`)}}function Ti(...r){return e=>{for(let t of r)t(e)}}var $e=Ti(Si,Di,Ai(65535));var v=-1,Cr=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(e){let t;if(typeof e=="string"?t=this.protocolsByName.get(e):t=this.protocolsByCode.get(e),t==null)throw new it(`Protocol ${e} was unknown`);return t}addProtocol(e){this.protocolsByCode.set(e.code,e),this.protocolsByName.set(e.name,e),e.aliases?.forEach(t=>{this.protocolsByName.set(t,e)})}removeProtocol(e){let t=this.protocolsByCode.get(e);t!=null&&(this.protocolsByCode.delete(t.code),this.protocolsByName.delete(t.name),t.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},H=new Cr,$i=[{code:4,name:"ip4",size:32,valueToBytes:vr,bytesToValue:so,validate:r=>{if(!we(r))throw new q(`Invalid IPv4 address "${r}"`)}},{code:6,name:"tcp",size:16,valueToBytes:ce,bytesToValue:ve,validate:$e},{code:273,name:"udp",size:16,valueToBytes:ce,bytesToValue:ve,validate:$e},{code:33,name:"dccp",size:16,valueToBytes:ce,bytesToValue:ve,validate:$e},{code:41,name:"ip6",size:128,valueToBytes:oo,bytesToValue:io,stringToValue:ao,validate:r=>{if(!tt(r))throw new q(`Invalid IPv6 address "${r}"`)}},{code:42,name:"ip6zone",size:v},{code:43,name:"ipcidr",size:8,bytesToValue:yr("base10"),valueToBytes:Er("base10")},{code:53,name:"dns",size:v},{code:54,name:"dns4",size:v},{code:55,name:"dns6",size:v},{code:56,name:"dnsaddr",size:v},{code:132,name:"sctp",size:16,valueToBytes:ce,bytesToValue:ve,validate:$e},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:v,stringToValue:r=>decodeURIComponent(r),valueToString:r=>encodeURIComponent(r)},{code:421,name:"p2p",aliases:["ipfs"],size:v,bytesToValue:yr("base58btc"),valueToBytes:r=>r.startsWith("Q")||r.startsWith("1")?Er("base58btc")(r):be.parse(r).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:Ir,valueToBytes:ro},{code:445,name:"onion3",size:296,bytesToValue:Ir,valueToBytes:no},{code:446,name:"garlic64",size:v},{code:447,name:"garlic32",size:v},{code:448,name:"tls"},{code:449,name:"sni",size:v},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:v,bytesToValue:uo(Xt),valueToBytes:co},{code:480,name:"http"},{code:481,name:"http-path",size:v,stringToValue:r=>`/${decodeURIComponent(r)}`,valueToString:r=>encodeURIComponent(r.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:v}];$i.forEach(r=>{H.addProtocol(r)});function lo(r){let e=[],t=0;for(;t<r.length;){let n=Fe(r,t),o=H.getProtocol(n),s=L(n),i=Wi(o,r,t+s),a=0;i>0&&o.size===v&&(a=L(i));let c=s+a+i,l={code:n,name:o.name,bytes:r.subarray(t,t+c)};if(i>0){let u=t+s+a,f=r.subarray(u,u+i);l.value=o.bytesToValue?.(f)??ae(f)}e.push(l),t+=c}return e}function fo(r){let e=0,t=[];for(let n of r){if(n.bytes==null){let o=H.getProtocol(n.code),s=L(n.code),i,a=0,c=0;n.value!=null&&(i=o.valueToBytes?.(n.value)??Ve(n.value),a=i.byteLength,o.size===v&&(c=L(a)));let l=new Uint8Array(s+c+a),u=0;xe(n.code,l,u),u+=s,i!=null&&(o.size===v&&(xe(a,l,u),u+=c),l.set(i,u)),n.bytes=l}t.push(n.bytes),e+=n.bytes.byteLength}return ze(t,e)}function ho(r){if(r.charAt(0)!=="/")throw new C('String multiaddr must start with "/"');let e=[],t="protocol",n="",o="";for(let s=1;s<r.length;s++){let i=r.charAt(s);i!=="/"&&(t==="protocol"?o+=r.charAt(s):n+=r.charAt(s));let a=s===r.length-1;if(i==="/"||a){let c=H.getProtocol(o);if(t==="protocol"){if(c.size==null||c.size===0){e.push({code:c.code,name:c.name}),n="",o="",t="protocol";continue}else if(a)throw new C(`Component ${o} was missing value`);t="value"}else if(t==="value"){let l={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new C(`Component ${o} was missing value`);l.value=c.stringToValue?.(n)??n}e.push(l),n="",o="",t="protocol"}}}if(o!==""&&n!=="")throw new C("Incomplete multiaddr");return e}function po(r){return`/${r.flatMap(e=>{if(e.value==null)return e.name;let t=H.getProtocol(e.code);if(t==null)throw new C(`Unknown protocol code ${e.code}`);return[e.name,t.valueToString?.(e.value)??e.value]}).join("/")}`}function Wi(r,e,t){return r.size==null||r.size===0?0:r.size>0?r.size/8:Fe(e,t)}var ji=Symbol.for("nodejs.util.inspect.custom"),Vr=Symbol.for("@multiformats/multiaddr");function Gi(r){if(r==null&&(r="/"),mo(r))return r.getComponents();if(r instanceof Uint8Array)return lo(r);if(typeof r=="string")return r=r.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),r===""&&(r="/"),ho(r);if(Array.isArray(r))return r;throw new C("Must be a string, Uint8Array, Component[], or another Multiaddr")}var ht=class r{[Vr]=!0;#e;#t;#r;constructor(e="/",t={}){this.#e=Gi(e),t.validate!==!1&&qi(this)}get bytes(){return this.#r==null&&(this.#r=fo(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=po(this.#e)),this.#t}toJSON(){return this.toString()}getComponents(){return[...this.#e.map(e=>({...e}))]}encapsulate(e){let t=new r(e);return new r([...this.#e,...t.getComponents()],{validate:!1})}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new st(`Address ${this.toString()} does not contain subaddress: ${t}`);return new r(n.slice(0,o),{validate:!1})}decapsulateCode(e){let t;for(let n=this.#e.length-1;n>-1;n--)if(this.#e[n].code===e){t=n;break}return new r(this.#e.slice(0,t),{validate:!1})}equals(e){return Zn(this.bytes,e.bytes)}[ji](){return`Multiaddr(${this.toString()})`}};function qi(r){r.getComponents().forEach(e=>{let t=H.getProtocol(e.code);e.value!=null&&t.validate?.(e.value)})}function mo(r){return!!r?.[Vr]}function $r(r){return new ht(r)}var y=r=>({match:e=>{let t=e[0];return t==null||t.code!==r||t.value!=null?!1:e.slice(1)}}),h=(r,e)=>({match:t=>{let n=t[0];return n?.code!==r||n.value==null||e!=null&&n.value!==e?!1:t.slice(1)}}),go=r=>({match:e=>r.match(e)===!1?e:!1}),p=r=>({match:e=>{let t=r.match(e);return t===!1?e:t}}),T=(...r)=>({match:e=>{let t;for(let n of r){let o=n.match(e);o!==!1&&(t==null||o.length<t.length)&&(t=o)}return t??!1}}),m=(...r)=>({match:e=>{for(let t of r){let n=t.match(e);if(n===!1)return!1;e=n}return e}});function E(...r){function e(o){if(o==null)return!1;let s=o.getComponents();for(let i of r){let a=i.match(s);if(a===!1)return!1;s=a}return s}function t(o){return e(o)!==!1}function n(o){let s=e(o);return s===!1?!1:s.length===0}return{matchers:r,matches:t,exactMatch:n}}var Xi=h(421),jl=E(Xi),pt=h(54),mt=h(55),gt=h(56),jr=h(53),Gl=E(pt,p(h(421))),ql=E(mt,p(h(421))),Xl=E(gt,p(h(421))),bo=E(T(jr,gt,pt,mt),p(h(421))),xo=m(h(4),p(h(43))),wo=m(p(h(42)),h(41),p(h(43))),Gr=T(xo,wo),Ae=T(Gr,jr,pt,mt,gt),Hl=E(T(Gr,m(T(jr,gt,pt,mt),p(h(421))))),Yl=E(xo),Ql=E(wo),yo=E(Gr),qr=m(Ae,h(6)),We=m(Ae,h(273)),Jl=E(m(qr,p(h(421)))),Kl=E(We),Xr=m(We,y(460),p(h(421))),bt=m(We,y(461),p(h(421))),Hi=T(Xr,bt),Zl=E(Xr),ef=E(bt),Wr=T(Ae,qr,We,Xr,bt),Eo=T(m(Wr,y(477),p(h(421)))),tf=E(Eo),Io=T(m(Wr,y(478),p(h(421))),m(Wr,y(448),p(h(449)),y(477),p(h(421)))),rf=E(Io),vo=m(We,y(280),p(h(466)),p(h(466)),p(h(421))),nf=E(vo),Co=m(bt,y(465),p(h(466)),p(h(466)),p(h(421))),of=E(Co),dt=T(Eo,Io,m(qr,p(h(421))),m(Hi,p(h(421))),m(Ae,p(h(421))),vo,Co,h(421)),sf=E(dt),Yi=m(p(dt),y(290),go(y(281)),p(h(421))),je=E(Yi),Qi=T(m(dt,y(290),y(281),p(h(421))),m(dt,y(281),p(h(421))),m(y(281),p(h(421)))),af=E(Qi),Ji=m(Ae,T(m(h(6,"80")),m(h(6),y(480)),y(480)),p(h(481)),p(h(421))),cf=E(Ji),Ki=m(Ae,T(m(h(6,"443")),m(h(6,"443"),y(480)),m(h(6),y(443)),m(h(6),y(448),y(480)),m(y(448),y(480)),y(448),y(443)),p(h(481)),p(h(421))),uf=E(Ki),Zi=T(m(h(777),p(h(421)))),lf=E(Zi),ea=T(m(h(400),p(h(421)))),ff=E(ea);var Hr=class r extends Error{name="TimeoutError";constructor(e,t){super(e,t),Error.captureStackTrace?.(this,r)}},So=r=>r.reason??new DOMException("This operation was aborted.","AbortError");function Yr(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:s={setTimeout,clearTimeout},signal:i}=e,a,c,u=new Promise((f,d)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(i?.aborted){d(So(i));return}if(i&&(c=()=>{d(So(i))},i.addEventListener("abort",c,{once:!0})),r.then(f,d),t===Number.POSITIVE_INFINITY)return;let g=new Hr;a=s.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(b){d(b)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?f():o instanceof Error?d(o):(g.message=o??`Promise timed out after ${t} milliseconds`,d(g))},t)}).finally(()=>{u.clear(),c&&i&&i.removeEventListener("abort",c)});return u.clear=()=>{s.clearTimeout.call(void 0,a),a=void 0},u}var ta=r=>{let e=r.addEventListener||r.on||r.addListener,t=r.removeEventListener||r.off||r.removeListener;if(!e||!t)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(r),removeListener:t.bind(r)}};function ra(r,e,t){let n,o=new Promise((s,i)=>{if(t={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...t},!(t.count>=0&&(t.count===Number.POSITIVE_INFINITY||Number.isInteger(t.count))))throw new TypeError("The `count` option should be at least 0 or more");t.signal?.throwIfAborted();let a=[e].flat(),c=[],{addListener:l,removeListener:u}=ta(r),f=async(...g)=>{let b=t.multiArgs?g:g[0];if(t.filter)try{if(!await t.filter(b))return}catch(S){n(),i(S);return}c.push(b),t.count===c.length&&(n(),s(c))},d=(...g)=>{n(),i(t.rejectionMultiArgs?g:g[0])};n=()=>{for(let g of a)u(g,f);for(let g of t.rejectionEvents)a.includes(g)||u(g,d)};for(let g of a)l(g,f);for(let g of t.rejectionEvents)a.includes(g)||l(g,d);t.signal&&t.signal.addEventListener("abort",()=>{d(t.signal.reason)},{once:!0}),t.resolveImmediately&&s(c)});if(o.cancel=n,typeof t.timeout=="number"){let s=Yr(o,{milliseconds:t.timeout});return s.cancel=()=>{n(),s.clear()},s}return o}function Do(r,e,t){typeof t=="function"&&(t={filter:t}),t={...t,count:1,resolveImmediately:!1};let n=ra(r,e,t),o=n.then(s=>s[0]);return o.cancel=n.cancel,o}var le=class extends Error{static name="UnexpectedEOFError";name="UnexpectedEOFError"};function na(r){return r.reason}async function Qr(r,e,t){if(e==null)return r;let n=t?.translateError??na;if(e.aborted)return r.catch(()=>{}),Promise.reject(n(e));let o;try{return await Promise.race([r,new Promise((s,i)=>{o=()=>{i(n(e))},e.addEventListener("abort",o)})])}finally{o!=null&&e.removeEventListener("abort",o)}}var sa=4194304,xt=class extends Error{static name="UnwrappedError";name="UnwrappedError"},Kr=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Zr=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},en=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function ia(r){return typeof r?.closeRead=="function"}function aa(r){return typeof r?.close=="function"}function Jr(r){return ia(r)?r.remoteWriteStatus!=="writable"&&r.readBufferLength===0:aa(r)?r.status!=="open":!1}function ca(r){return r?.addEventListener!=null&&r?.removeEventListener!=null&&r?.send!=null&&r?.push!=null&&r?.log!=null}function ua(r,e){let t=e?.maxBufferSize??sa,n=new re,o,s=!1;if(!ca(r))throw new fe("Argument should be a Stream or a Multiaddr");let i=u=>{if(n.append(u.data),n.byteLength>t){let f=n.byteLength;n.consume(n.byteLength),o?.reject(new Error(`Read buffer overflow - ${f} > ${t}`))}o?.resolve()};r.addEventListener("message",i);let a=u=>{u.error!=null?o?.reject(u.error):o?.resolve()};r.addEventListener("close",a);let c=()=>{o?.resolve()};r.addEventListener("remoteCloseWrite",c);let l={readBuffer:n,async read(u){if(s===!0)throw new xt("Stream was unwrapped");if(Jr(r)){if(n.byteLength===0&&u?.bytes==null)return null;if(u?.bytes!=null&&n.byteLength<u.bytes)throw r.log.error("closed after reading %d/%d bytes",n.byteLength,u.bytes),new le(`Unexpected EOF - stream closed after reading ${n.byteLength}/${u.bytes} bytes`)}let f=u?.bytes??1;for(o=Promise.withResolvers();;){if(n.byteLength>=f){o.resolve();break}if(await Qr(o.promise,u?.signal),Jr(r)){if(n.byteLength===0&&u?.bytes==null)return null;break}o=Promise.withResolvers()}let d=u?.bytes??n.byteLength;if(n.byteLength<d){if(Jr(r))throw r.log.error("closed while reading %d/%d bytes",n.byteLength,d),new le(`Unexpected EOF - stream closed while reading ${n.byteLength}/${d} bytes`);return l.read(u)}let g=n.sublist(0,d);return n.consume(d),g},async write(u,f){if(s===!0)throw new xt("Stream was unwrapped");r.send(u)||await Do(r,"drain",{signal:f?.signal,rejectionEvents:["close"]})},unwrap(){return s||(s=!0,r.removeEventListener("message",i),r.removeEventListener("close",a),r.removeEventListener("remoteCloseWrite",c),n.byteLength>0&&(r.log("stream unwrapped with %d unread bytes",n.byteLength),r.unshift(n))),r}};return l}function la(r,e={}){let t=ua(r,e);e.maxDataLength!=null&&e.maxLengthLength==null&&(e.maxLengthLength=L(e.maxDataLength));let n=e?.lengthDecoder??Fe,o=e?.lengthEncoder??Dn;return{async read(i){let a=-1,c=new re;for(;;){let u=await t.read({...i,bytes:1});if(u==null)break;c.append(u);try{a=n(c)}catch(f){if(f instanceof RangeError)continue;throw f}if(a<0)throw new Kr("Invalid message length");if(e?.maxLengthLength!=null&&c.byteLength>e.maxLengthLength)throw new en(`Message length length too long - ${c.byteLength} > ${e.maxLengthLength}`);if(a>-1)break}if(e?.maxDataLength!=null&&a>e.maxDataLength)throw new Zr(`Message length too long - ${a} > ${e.maxDataLength}`);let l=await t.read({...i,bytes:a});if(l==null)throw r.log.error("tried to read %d bytes but the stream closed",a),new le(`Unexpected EOF - tried to read ${a} bytes but the stream closed`);if(l.byteLength!==a)throw r.log.error("read %d/%d bytes before the stream closed",l.byteLength,a),new le(`Unexpected EOF - read ${l.byteLength}/${a} bytes before the stream closed`);return l},async write(i,a){await t.write(new re(o(i.byteLength),i),a)},async writeV(i,a){let c=new re(...i.flatMap(l=>[o(l.byteLength),l]));await t.write(c,a)},unwrap(){return t.unwrap()}}}function tn(r,e){let t=la(r,e),n={read:async(o,s)=>{let i=await t.read(s);return o.decode(i)},write:async(o,s,i)=>{await t.write(s.encode(o),i)},writeV:async(o,s,i)=>{await t.writeV(o.map(a=>s.encode(a)),i)},pb:o=>({read:async s=>n.read(o,s),write:async(s,i)=>n.write(s,o,i),writeV:async(s,i)=>n.writeV(s,o,i),unwrap:()=>n}),unwrap:()=>t.unwrap()};return n}var Ao=Symbol.for("sindresorhus/unlimited-timeout#brand");function To(r,e,...t){if(typeof r!="function")throw new TypeError("Expected callback to be a function");e??=0,e=Number(e);let n=!1,o={[Ao]:!0,id:void 0,cleared:!1,ref(){return n=!1,o.id?.ref?.(),o},unref(){return n=!0,o.id?.unref?.(),o}};if(e===Number.POSITIVE_INFINITY||e>Number.MAX_SAFE_INTEGER)return o;(!Number.isFinite(e)||e<0)&&(e=0);let s=performance.now()+e,i=a=>{o.cleared||(a<=2147483647?(o.id=globalThis.setTimeout(()=>{o.cleared||r(...t)},a),n&&o.id?.unref?.()):(o.id=globalThis.setTimeout(()=>{let c=performance.now(),l=Math.max(0,s-c);i(l)},2147483647),n&&o.id?.unref?.()))};return i(e),o}function Lo(r){!r||typeof r!="object"||!r[Ao]||(r.cleared=!0,r.id!==void 0&&(globalThis.clearTimeout(r.id),r.id=void 0))}var fa=new WeakMap;function ha({clearTimeout:r,setTimeout:e}={}){return(t,{value:n,signal:o}={})=>{if(o?.aborted)return Promise.reject(o.reason);let s,i,a,c=r??clearTimeout,l=()=>{c(s),a(o.reason)},u=()=>{o&&o.removeEventListener("abort",l)},f=new Promise((d,g)=>{i=()=>{u(),d(n)},a=g,s=(e??setTimeout)(i,t)});return o&&o.addEventListener("abort",l,{once:!0}),fa.set(f,()=>{c(s),s=null,i()}),f}}var da=ha({setTimeout:To,clearTimeout:Lo}),No=da;var B;(function(r){let e;(function(a){a.UNUSED="UNUSED",a.CONNECT="CONNECT",a.SYNC="SYNC"})(e=r.Type||(r.Type={}));let t;(function(a){a[a.UNUSED=0]="UNUSED",a[a.CONNECT=100]="CONNECT",a[a.SYNC=300]="SYNC"})(t||(t={})),(function(a){a.codec=()=>ur(t)})(e=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=lr((a,c,l={})=>{if(l.lengthDelimited!==!1&&c.fork(),a.type!=null&&(c.uint32(8),r.Type.codec().encode(a.type,c)),a.observedAddresses!=null&&a.observedAddresses.length>0)for(let u of a.observedAddresses)c.uint32(18),c.bytes(u);l.lengthDelimited!==!1&&c.ldelim()},(a,c,l={})=>{let u={observedAddresses:[]},f=c==null?a.len:a.pos+c;for(;a.pos<f;){let d=a.uint32();switch(d>>>3){case 1:{u.type=r.Type.codec().decode(a);break}case 2:{if(l.limits?.observedAddresses!=null&&u.observedAddresses.length===l.limits.observedAddresses)throw new ke('Decode error - repeated field "observedAddresses" had too many elements');u.observedAddresses.push(a.bytes());break}default:{a.skipType(d&7);break}}}return u},function*(a,c,l,u={}){let f={observedAddresses:0},d=c==null?a.len:a.pos+c;for(;a.pos<d;){let g=a.uint32();switch(g>>>3){case 1:{yield{field:`${l}.type`,value:r.Type.codec().decode(a)};break}case 2:{if(u.limits?.observedAddresses!=null&&f.observedAddresses===u.limits.observedAddresses)throw new ke('Streaming decode error - repeated field "observedAddresses" had too many elements');yield{field:`${l}.observedAddresses[]`,index:f.observedAddresses,value:a.bytes()},f.observedAddresses++;break}default:{a.skipType(g&7);break}}}})),n);function o(a){return ar(a,r.codec())}r.encode=o;function s(a,c){return $t(a,r.codec(),c)}r.decode=s;function i(a,c){return cr(a,r.codec(),c)}r.stream=i})(B||(B={}));function rn(r,e){return je.matches(r)||e.dialTransportForMultiaddr(r)==null?!1:bo.matches(r)?!0:yo.matches(r)?!Kn(r):!1}var _o=1024*4,Po=100,wt={timeout:5e3,retries:3,maxInboundStreams:1,maxOutboundStreams:1},yt=class{started;timeout;retries;maxInboundStreams;maxOutboundStreams;peerStore;registrar;connectionManager;addressManager;transportManager;topologyId;log;constructor(e,t){this.log=e.logger.forComponent("libp2p:dcutr"),this.started=!1,this.peerStore=e.peerStore,this.registrar=e.registrar,this.addressManager=e.addressManager,this.connectionManager=e.connectionManager,this.transportManager=e.transportManager,this.timeout=t.timeout??wt.timeout,this.retries=t.retries??wt.retries,this.maxInboundStreams=t.maxInboundStreams??wt.maxInboundStreams,this.maxOutboundStreams=t.maxOutboundStreams??wt.maxOutboundStreams,this.handleIncomingUpgrade=this.handleIncomingUpgrade.bind(this)}[Symbol.toStringTag]="@libp2p/dcutr";[on]=["@libp2p/identify"];isStarted(){return this.started}async start(){this.started||(this.topologyId=await this.registrar.register(Te,{notifyOnLimitedConnection:!0,onConnect:(e,t)=>{je.exactMatch(t.remoteAddr)&&t.direction==="inbound"&&this.upgradeInbound(t).catch(n=>{this.log.error("error during outgoing DCUtR attempt - %e",n)})}}),await this.registrar.handle(Te,this.handleIncomingUpgrade,{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnLimitedConnection:!0}),this.started=!0)}async stop(){await this.registrar.unhandle(Te),this.topologyId!=null&&this.registrar.unregister(this.topologyId),this.started=!1}async upgradeInbound(e){if(await this.attemptUnilateralConnectionUpgrade(e))return;let t;for(let n=0;n<this.retries;n++){let o={signal:AbortSignal.timeout(this.timeout)};try{t=await e.newStream([Te],{signal:o.signal,runOnLimitedConnection:!0});let s=tn(t,{maxDataLength:_o}).pb(B);this.log("B sending connect to %p",e.remotePeer);let i=Date.now();await s.write({type:B.Type.CONNECT,observedAddresses:this.addressManager.getAddresses().map(f=>f.bytes)},o),this.log("B receiving connect from %p",e.remotePeer);let a=await s.read(o);if(a.type!==B.Type.CONNECT)throw this.log("A sent wrong message type"),new W("DCUtR message type was incorrect");let c=this.getDialableMultiaddrs(a.observedAddresses);if(c.length===0)throw this.log("A did not have any dialable multiaddrs"),new W("DCUtR connect message had no multiaddrs");let l=Date.now()-i;this.log("A sending sync, rtt %dms",l),await s.write({type:B.Type.SYNC,observedAddresses:[]},o),this.log("A waiting for half RTT"),await No(l/2),this.log("B dialing",c);let u=await this.connectionManager.openConnection(c,{signal:o.signal,priority:Po,force:!0,initiator:!1});this.log("DCUtR to %p succeeded to address %a, closing relayed connection",e.remotePeer,u.remoteAddr),await e.close(o);break}catch(s){if(this.log.error("error while attempting DCUtR on attempt %d of %d - %e",n+1,this.retries,s),t?.abort(s),n===this.retries)throw s}finally{t!=null&&await t.close(o)}}}async attemptUnilateralConnectionUpgrade(e){let n=(await this.peerStore.get(e.remotePeer)).addresses.map(o=>{let s=o.multiaddr;return s.getComponents().find(i=>i.code===421)?.value==null?s.encapsulate(`/p2p/${e.remotePeer}`):s}).filter(o=>rn(o,this.transportManager));if(n.length>0){let o=AbortSignal.timeout(this.timeout);try{this.log("attempting unilateral connection upgrade to %a",n);let s=await this.connectionManager.openConnection(n,{signal:o,force:!0});if(je.exactMatch(s.remoteAddr))throw new Error("Could not open a new, non-limited, connection");return this.log("unilateral connection upgrade to %p succeeded via %a, closing relayed connection",e.remotePeer,s.remoteAddr),await e.close({signal:o}),!0}catch(s){this.log.error("unilateral connection upgrade to %p on addresses %a failed - %e",e.remotePeer,n,s)}}else this.log("peer %p has no public addresses, not attempting unilateral connection upgrade",e.remotePeer);return!1}async handleIncomingUpgrade(e,t){let n={signal:AbortSignal.timeout(this.timeout)},o=tn(e,{maxDataLength:_o}).pb(B);this.log("A receiving connect");let s=await o.read(n);if(s.type!==B.Type.CONNECT)throw this.log("B sent wrong message type"),new W("DCUtR message type was incorrect");if(s.observedAddresses.length===0)throw this.log("B sent no multiaddrs"),new W("DCUtR connect message had no multiaddrs");let i=this.getDialableMultiaddrs(s.observedAddresses);if(i.length===0)throw this.log("B had no dialable multiaddrs in %o",s.observedAddresses.map(l=>$r(l))),new W("DCUtR connect message had no dialable multiaddrs");if(this.log("A sending connect"),await o.write({type:B.Type.CONNECT,observedAddresses:this.addressManager.getAddresses().map(l=>l.bytes)}),this.log("A receiving sync"),(await o.read(n)).type!==B.Type.SYNC)throw new W("DCUtR message type was incorrect");this.log("A dialing",i);let c=await this.connectionManager.openConnection(i,{signal:n.signal,priority:Po,force:!0});this.log("DCUtR to %p succeeded via %a, closing relayed connection",t.remotePeer,c.remoteAddr),await t.close(n),await e.close(n)}getDialableMultiaddrs(e){let t=[];for(let n of e)if(!(n==null||n.length===0))try{let o=$r(n);if(!rn(o,this.transportManager))continue;t.push(o)}catch{}return t}};var Te="/libp2p/dcutr";function pa(r={}){return e=>new yt(e,r)}return ko(ma);})();
2
+ "use strict";var Libp2PDcutr=(()=>{var ts=Object.create;var dt=Object.defineProperty;var rs=Object.getOwnPropertyDescriptor;var ns=Object.getOwnPropertyNames;var os=Object.getPrototypeOf,is=Object.prototype.hasOwnProperty;var Wt=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),I=(r,e)=>{for(var t in e)dt(r,t,{get:e[t],enumerable:!0})},to=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ns(e))!is.call(r,o)&&o!==t&&dt(r,o,{get:()=>e[o],enumerable:!(n=rs(e,o))||n.enumerable});return r};var ss=(r,e,t)=>(t=r!=null?ts(os(r)):{},to(e||!r||!r.__esModule?dt(t,"default",{value:r,enumerable:!0}):t,r)),as=r=>to(dt({},"__esModule",{value:!0}),r);var en=Wt(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});Me.Netmask4Impl=void 0;Me.ip2long=Be;Me.long2ip=H;function H(r){let e=(r&-16777216)>>>24,t=(r&255<<16)>>>16,n=(r&65280)>>>8,o=r&255;return[e,t,n,o].join(".")}var $c=48,Wc=97,jc=65;function Gc(r){let e=0,t=10,n="9",o=0;r.length>1&&r[o]==="0"&&(r[o+1]==="x"||r[o+1]==="X"?(o+=2,t=16):"0"<=r[o+1]&&r[o+1]<="9"&&(o++,t=8,n="7"));let i=o;for(;o<r.length;){if("0"<=r[o]&&r[o]<=n)e=e*t+(r.charCodeAt(o)-$c)>>>0;else if(t===16)if("a"<=r[o]&&r[o]<="f")e=e*t+(10+r.charCodeAt(o)-Wc)>>>0;else if("A"<=r[o]&&r[o]<="F")e=e*t+(10+r.charCodeAt(o)-jc)>>>0;else break;else break;if(e>4294967295)throw new Error("too large");o++}if(o===i)throw new Error("empty octet");return[e,o]}function Be(r){let e=[];for(let t=0;t<=3&&r.length!==0;t++){if(t>0){if(r[0]!==".")throw new Error("Invalid IP");r=r.substring(1)}let[n,o]=Gc(r);r=r.substring(o),e.push(n)}if(r.length!==0)throw new Error("Invalid IP");switch(e.length){case 1:if(e[0]>4294967295)throw new Error("Invalid IP");return e[0]>>>0;case 2:if(e[0]>255||e[1]>16777215)throw new Error("Invalid IP");return(e[0]<<24|e[1])>>>0;case 3:if(e[0]>255||e[1]>255||e[2]>65535)throw new Error("Invalid IP");return(e[0]<<24|e[1]<<16|e[2])>>>0;case 4:if(e[0]>255||e[1]>255||e[2]>255||e[3]>255)throw new Error("Invalid IP");return(e[0]<<24|e[1]<<16|e[2]<<8|e[3])>>>0;default:throw new Error("Invalid IP")}}var Zr=class r{constructor(e,t){if(typeof e!="string")throw new Error("Missing `net' parameter");let n=t;if(!n){let o=e.split("/",2);e=o[0],n=o[1]}if(n||(n=32),typeof n=="string"&&n.indexOf(".")>-1){try{this.maskLong=Be(n)}catch{throw new Error("Invalid mask: "+n)}this.bitmask=NaN;for(let o=32;o>=0;o--)if(this.maskLong===4294967295<<32-o>>>0){this.bitmask=o;break}}else if(n||n===0)this.bitmask=parseInt(n,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(Be(e)&this.maskLong)>>>0}catch{throw new Error("Invalid net address: "+e)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+n);this.size=Math.pow(2,32-this.bitmask),this.base=H(this.netLong),this.mask=H(this.maskLong),this.hostmask=H(~this.maskLong),this.first=this.bitmask<=30?H(this.netLong+1):this.base,this.last=this.bitmask<=30?H(this.netLong+this.size-2):H(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?H(this.netLong+this.size-1):void 0}contains(e){return typeof e=="string"&&(e.indexOf("/")>0||e.split(".").length!==4)&&(e=new r(e)),e instanceof r?this.contains(e.base)&&this.contains(e.broadcast||e.last):(Be(e)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0}next(e=1){return new r(H(this.netLong+this.size*e),this.mask)}forEach(e){let t=Be(this.first),n=Be(this.last),o=0;for(;t<=n;)e(H(t),t,o),o++,t++}toString(){return this.base+"/"+this.bitmask}};Me.Netmask4Impl=Zr});var xi=Wt(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Re.Netmask6Impl=void 0;Re.ip6bigint=rn;Re.bigint2ip6=ge;var qc=en(),tn=(1n<<128n)-1n;function rn(r){let e=r.indexOf("%");e!==-1&&(r=r.substring(0,e));let t=r.lastIndexOf(":");if(t!==-1&&r.indexOf(".",t)!==-1){let n=r.substring(t+1),o=(0,qc.ip2long)(n),i=r.substring(0,t+1)+"0:0";return gi(i)&~0xffffffffn|BigInt(o)}return gi(r)}function gi(r){let e=r.indexOf("::"),t;if(e!==-1){let o=r.substring(0,e),i=r.substring(e+2),s=o===""?[]:o.split(":"),a=i===""?[]:i.split(":"),c=8-s.length-a.length;if(c<0)throw new Error("Invalid IPv6: too many groups");t=[...s,...Array(c).fill("0"),...a]}else t=r.split(":");if(t.length!==8)throw new Error("Invalid IPv6: expected 8 groups, got "+t.length);let n=0n;for(let o=0;o<8;o++){let i=t[o];if(i.length===0||i.length>4)throw new Error('Invalid IPv6: bad group "'+i+'"');let s=parseInt(i,16);if(isNaN(s)||s<0||s>65535)throw new Error('Invalid IPv6: bad group "'+i+'"');n=n<<16n|BigInt(s)}return n}function ge(r){if(r<0n||r>tn)throw new Error("Invalid IPv6 address value");let e=[];for(let s=0;s<8;s++)e.unshift(Number(r&0xffffn)),r>>=16n;let t=-1,n=0,o=-1,i=0;for(let s=0;s<8;s++)e[s]===0?o===-1?(o=s,i=1):i++:(i>n&&i>=2&&(t=o,n=i),o=-1,i=0);if(i>n&&i>=2&&(t=o,n=i),t!==-1&&t+n===8&&t>0)return e.slice(0,t).map(a=>a.toString(16)).join(":")+"::";if(t===0)return"::"+e.slice(n).map(a=>a.toString(16)).join(":");if(t>0){let s=e.slice(0,t).map(c=>c.toString(16)),a=e.slice(t+n).map(c=>c.toString(16));return s.join(":")+"::"+a.join(":")}else return e.map(s=>s.toString(16)).join(":")}var nn=class r{constructor(e,t){if(typeof e!="string")throw new Error("Missing `net' parameter");let n=t;if(n==null){let o=e.indexOf("/");o!==-1?(n=parseInt(e.substring(o+1),10),e=e.substring(0,o)):n=128}if(isNaN(n)||n<0||n>128)throw new Error("Invalid mask for IPv6: "+n);this.bitmask=n,this.bitmask===0?this.maskBigint=0n:this.maskBigint=tn>>BigInt(128-this.bitmask)<<BigInt(128-this.bitmask);try{this.netBigint=rn(e)&this.maskBigint}catch{throw new Error("Invalid IPv6 net address: "+e)}this.size=Number(1n<<BigInt(128-this.bitmask)),this.base=ge(this.netBigint),this.mask=ge(this.maskBigint),this.hostmask=ge(~this.maskBigint&tn),this.first=this.base,this.last=ge(this.netBigint+(1n<<BigInt(128-this.bitmask))-1n),this.broadcast=void 0}contains(e){return typeof e=="string"&&e.indexOf("/")>0&&(e=new r(e)),e instanceof r?this.contains(e.base)&&this.contains(e.last):(rn(e)&this.maskBigint)===this.netBigint}next(e=1){let t=1n<<BigInt(128-this.bitmask);return new r(ge(this.netBigint+t*BigInt(e)),this.bitmask)}forEach(e){let t=this.netBigint,n=1n<<BigInt(128-this.bitmask),o=this.netBigint+n-1n,i=0;for(;t<=o;)e(ge(t),Number(t),i),i++,t++}toString(){return this.base+"/"+this.bitmask}};Re.Netmask6Impl=nn});var bi=Wt(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.long2ip=he.ip2long=he.Netmask=void 0;var St=en();Object.defineProperty(he,"ip2long",{enumerable:!0,get:function(){return St.ip2long}});Object.defineProperty(he,"long2ip",{enumerable:!0,get:function(){return St.long2ip}});var Xc=xi(),on=class r{constructor(e,t){if(typeof e!="string")throw new Error("Missing `net' parameter");(e.indexOf("/")!==-1?e.substring(0,e.indexOf("/")):e).indexOf(":")!==-1?this._impl=new Xc.Netmask6Impl(e,t):this._impl=new St.Netmask4Impl(e,t),this.base=this._impl.base,this.mask=this._impl.mask,this.hostmask=this._impl.hostmask,this.bitmask=this._impl.bitmask,this.size=this._impl.size,this.first=this._impl.first,this.last=this._impl.last,this.broadcast=this._impl.broadcast,this._impl instanceof St.Netmask4Impl?(this.maskLong=this._impl.maskLong,this.netLong=this._impl.netLong):(this.maskLong=0,this.netLong=0)}contains(e){return typeof e=="string"&&(e.indexOf("/")>0?e=new r(e):e.indexOf(":")===-1&&e.split(".").length!==4&&(e=new r(e))),e instanceof r?this.contains(e.base)&&this.contains(e.broadcast||e.last):this._impl.contains(e)}next(e=1){let t=this._impl.next(e);return new r(t.base,t.bitmask)}forEach(e){this._impl.forEach(e)}toString(){return this._impl.toString()}};he.Netmask=on});var sh={};I(sh,{dcutr:()=>ih,multicodec:()=>Ge});var ye=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}};var J=class extends Error{static name="InvalidMessageError";constructor(e="Invalid message"){super(e),this.name="InvalidMessageError"}};var ro=Symbol.for("@libp2p/service-dependencies");function cs(r){return r.buffer instanceof ArrayBuffer}function jt(r){return cs(r)?r:r.slice()}var Qt={};I(Qt,{base58btc:()=>q,base58flickr:()=>gs});var _h=new Uint8Array(0);function no(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function Y(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return le(r);if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return le(new Uint8Array(r.buffer,r.byteOffset,r.byteLength));throw new Error("Unknown type, must be binary type")}function oo(r){return new TextEncoder().encode(r)}function io(r){return new TextDecoder().decode(r)}function us(r){return r?.buffer instanceof ArrayBuffer}function le(r){return us(r)?r:r.slice()}function hs(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=o}var a=r.length,c=r.charAt(0),h=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var b=0,V=0,A=0,N=f.length;A!==N&&f[A]===0;)A++,b++;for(var P=(N-A)*u+1>>>0,E=new Uint8Array(P);A!==N;){for(var F=f[A],_=0,S=P-1;(F!==0||_<V)&&S!==-1;S--,_++)F+=256*E[S]>>>0,E[S]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");V=_,A++}for(var U=P-V;U!==P&&E[U]===0;)U++;for(var Q=c.repeat(b);U<P;++U)Q+=r.charAt(E[U]);return Q}function p(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var b=0;if(f[b]!==" "){for(var V=0,A=0;f[b]===c;)V++,b++;for(var N=(f.length-b)*h+1>>>0,P=new Uint8Array(N);f[b];){var E=t[f.charCodeAt(b)];if(E===255)return;for(var F=0,_=N-1;(E!==0||F<A)&&_!==-1;_--,F++)E+=a*P[_]>>>0,P[_]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");A=F,b++}if(f[b]!==" "){for(var S=N-A;S!==N&&P[S]===0;)S++;for(var U=new Uint8Array(V+(N-S)),Q=V;S!==N;)U[Q++]=P[S++];return U}}}function g(f){var b=p(f);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:g}}var ls=hs,fs=ls,ao=fs;var Gt=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},qt=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,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 co(this,e)}},Xt=class{decoders;constructor(e){this.decoders=e}or(e){return co(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function co(r,e){return new Xt({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Ht=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Gt(e,t,n),this.decoder=new qt(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Ee({name:r,prefix:e,encode:t,decode:n}){return new Ht(r,e,t,n)}function ne({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=ao(t,r);return Ee({prefix:e,name:r,encode:n,decode:i=>Y(o(i))})}function ds(r,e,t,n){let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*t/8|0),s=0,a=0,c=0;for(let h=0;h<o;++h){let u=e[r[h]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<t|u,s+=t,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=t||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function ps(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,i="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>t;)s-=t,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<t-s]),n)for(;(i.length*t&7)!==0;)i+="=";return i}function ms(r){let e={};for(let t=0;t<r.length;++t)e[r[t]]=t;return e}function T({name:r,prefix:e,bitsPerChar:t,alphabet:n}){let o=ms(n);return Ee({prefix:e,name:r,encode(i){return ps(i,n,t)},decode(i){return ds(i,o,t,r)}})}var q=ne({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),gs=ne({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Jt={};I(Jt,{base32:()=>oe,base32hex:()=>ys,base32hexpad:()=>Is,base32hexpadupper:()=>Cs,base32hexupper:()=>Es,base32pad:()=>bs,base32padupper:()=>ws,base32upper:()=>xs,base32z:()=>vs});var oe=T({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),xs=T({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bs=T({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ws=T({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ys=T({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Es=T({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Is=T({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Cs=T({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vs=T({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Yt={};I(Yt,{base36:()=>qe,base36upper:()=>As});var qe=ne({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),As=ne({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ss=lo,uo=128,Ds=127,Ts=~Ds,Ls=Math.pow(2,31);function lo(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Ls;)e[t++]=r&255|uo,r/=128;for(;r&Ts;)e[t++]=r&255|uo,r>>>=7;return e[t]=r|0,lo.bytes=t-n+1,e}var Ns=Kt,Ps=128,ho=127;function Kt(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw Kt.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&ho)<<o:(s&ho)*Math.pow(2,o),o+=7}while(s>=Ps);return Kt.bytes=i-n,t}var Fs=Math.pow(2,7),Us=Math.pow(2,14),Os=Math.pow(2,21),_s=Math.pow(2,28),Bs=Math.pow(2,35),Ms=Math.pow(2,42),Rs=Math.pow(2,49),ks=Math.pow(2,56),zs=Math.pow(2,63),Vs=function(r){return r<Fs?1:r<Us?2:r<Os?3:r<_s?4:r<Bs?5:r<Ms?6:r<Rs?7:r<ks?8:r<zs?9:10},$s={encode:Ss,decode:Ns,encodingLength:Vs},Ws=$s,Xe=Ws;function He(r,e=0){return[Xe.decode(r,e),Xe.decode.bytes]}function Ie(r,e,t=0){return Xe.encode(r,e,t),e}function Ce(r){return Xe.encodingLength(r)}function Ae(r,e){let t=e.byteLength,n=Ce(r),o=n+Ce(t),i=new Uint8Array(o+t);return Ie(r,i,0),Ie(t,i,n),i.set(e,o),new ve(r,t,e,i)}function fo(r){let e=Y(r),[t,n]=He(e),[o,i]=He(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new ve(t,o,s,e)}function po(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&no(r.bytes,t.bytes)}}var ve=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=le(n),this.bytes=le(o)}};function mo(r,e){let{bytes:t,version:n}=r;return n===0?Gs(t,Zt(r),e??q.encoder):qs(t,Zt(r),e??oe.encoder)}var go=new WeakMap;function Zt(r){let e=go.get(r);if(e==null){let t=new Map;return go.set(r,t),t}return e}var Se=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=le(o),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Je)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Xs)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=Ae(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&po(e.multihash,n.multihash)}toString(e){return mo(this,e)}toJSON(){return{"/":mo(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:i,bytes:s}=t;return new r(n,o,i,s??xo(n,o,i.bytes))}else if(t[Hs]===!0){let{version:n,multihash:o,code:i}=t,s=fo(o);return r.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Je)throw new Error(`Version 0 CID must use dag-pb (code: ${Je}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=xo(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Je,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=Y(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new ve(t.multihashCode,t.digestSize,i,o);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,p]=He(e.subarray(t));return t+=p,l},o=n(),i=Je;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,a=n(),c=n(),h=t+c,u=h-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:h}}static parse(e,t){let[n,o]=js(e,t),i=r.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Zt(i).set(n,e),i}};function js(r,e){switch(r[0]){case"Q":{let t=e??q;return[q.prefix,t.decode(`${q.prefix}${r}`)]}case q.prefix:{let t=e??q;return[q.prefix,t.decode(r)]}case oe.prefix:{let t=e??oe;return[oe.prefix,t.decode(r)]}case qe.prefix:{let t=e??qe;return[qe.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Gs(r,e,t){let{prefix:n}=t;if(n!==q.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o}function qs(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o}var Je=112,Xs=18;function xo(r,e,t){let n=Ce(r),o=n+Ce(e),i=new Uint8Array(o+t.byteLength);return Ie(r,i,0),Ie(e,i,n),i.set(t,o),i}var Hs=Symbol.for("@ipld/js-cid/CID");var er={};I(er,{identity:()=>Ys});var bo=0,Qs="identity",wo=Y;function Js(r,e){if(e?.truncate!=null&&e.truncate!==r.byteLength){if(e.truncate<0||e.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e.truncate)}return Ae(bo,wo(r))}var Ys={code:bo,name:Qs,encode:wo,digest:Js};function tr(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function K(r=0){return new Uint8Array(r)}function Ye(r=0){return new Uint8Array(r)}function rr(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=Ye(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function yo(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var Io=Symbol.for("@achingbrain/uint8arraylist");function Eo(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let o=t+n.byteLength;if(e<o)return{buf:n,index:e-t};t=o}throw new RangeError("index is out of bounds")}function mt(r){return!!r?.[Io]}var fe=class r{bufs;length;[Io]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(mt(n)){t+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(mt(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=Eo(this.bufs,e);return t.buf[t.index]}set(e,t){let n=Eo(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(mt(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:o}=this._subList(e,t);return rr(n,o)}subarray(e,t){let{bufs:n,length:o}=this._subList(e,t);return n.length===1?n[0]:rr(n,o)}sublist(e,t){let{bufs:n,length:o}=this._subList(e,t),i=new r;return i.length=o,i.bufs=n,i}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,e>=c)continue;let h=e>=a&&e<c,u=t>a&&t<=c;if(h&&u){if(e===a&&t===c){n.push(s);break}let l=e-a;n.push(s.subarray(l,l+(t-e)));break}if(h){if(e===0){n.push(s);continue}n.push(s.subarray(e-a));continue}if(u){if(t===c){n.push(s);break}n.push(s.subarray(0,t-a));break}n.push(s)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!mt(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let a=s,c=this.byteLength-n.byteLength,h=n.byteLength-1,u;for(let l=t;l<=c;l+=u){u=0;for(let p=h;p>=0;p--){let g=this.get(l+p);if(n[p]!==g){u=Math.max(1,p-a[g]);break}}if(u===0)return l}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=Ye(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let o=K(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,t,n),this.write(o,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let o=K(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,t,n),this.write(o,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let o=K(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,t,n),this.write(o,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=Ye(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let o=K(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,t,n),this.write(o,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let o=K(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,t,n),this.write(o,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let o=K(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,t,n),this.write(o,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let o=K(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,t,n),this.write(o,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let o=K(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,t,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof r)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!yo(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new r;return n.bufs=e,t==null&&(t=e.reduce((o,i)=>o+i.byteLength,0)),n.length=t,n}};var nr={};I(nr,{base10:()=>Ks});var Ks=ne({prefix:"9",name:"base10",alphabet:"0123456789"});var or={};I(or,{base16:()=>Zs,base16upper:()=>ea});var Zs=T({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ea=T({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ir={};I(ir,{base2:()=>ta});var ta=T({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var sr={};I(sr,{base256emoji:()=>sa});var Co=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}"),ra=Co.reduce((r,e,t)=>(r[t]=e,r),[]),na=Co.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function oa(r){return r.reduce((e,t)=>(e+=ra[t],e),"")}function ia(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=na[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var sa=Ee({prefix:"\u{1F680}",name:"base256emoji",encode:oa,decode:ia});var cr={};I(cr,{base64:()=>aa,base64pad:()=>ca,base64url:()=>ar,base64urlpad:()=>ua});var aa=T({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ca=T({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ar=T({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ua=T({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ur={};I(ur,{base8:()=>ha});var ha=T({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var hr={};I(hr,{identity:()=>la});var la=Ee({prefix:"\0",name:"identity",encode:r=>io(r),decode:r=>oo(r)});var wl=new TextEncoder,yl=new TextDecoder;var dr={};I(dr,{sha256:()=>ma,sha512:()=>ga});var pa=20;function fr({name:r,code:e,encode:t,minDigestLength:n,maxDigestLength:o}){return new lr(r,e,t,n,o)}var lr=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,t,n,o,i){this.name=e,this.code=t,this.encode=n,this.minDigestLength=o??pa,this.maxDigestLength=i}digest(e,t){if(t?.truncate!=null){if(t.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&t.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?vo(n,this.code,t?.truncate):n.then(o=>vo(o,this.code,t?.truncate))}else throw Error("Unknown type, must be binary type")}};function vo(r,e,t){if(t!=null&&t!==r.byteLength){if(t>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t)}return Ae(e,r)}function So(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var ma=fr({name:"sha2-256",code:18,encode:So("SHA-256")}),ga=fr({name:"sha2-512",code:19,encode:So("SHA-512")});var Ke={...hr,...ir,...ur,...nr,...or,...Jt,...Yt,...Qt,...cr,...sr},Fl={...dr,...er};function de(r=0){return new Uint8Array(r)}function To(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Do=To("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),pr=To("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=de(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),xa={utf8:Do,"utf-8":Do,hex:Ke.base16,latin1:pr,ascii:pr,binary:pr,...Ke},gt=xa;function De(r,e="utf8"){let t=gt[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function ie(r,e="utf8"){let t=gt[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}function ba(r){return r?.buffer instanceof ArrayBuffer}function mr(r){if(ba(r))return r;let e=r.slice();return new Uint8Array(e.buffer,0,e.byteLength)}function Te(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=de(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return mr(t)}function se(r=0){return new Uint8Array(r)}var wa=Math.pow(2,7),ya=Math.pow(2,14),Ea=Math.pow(2,21),Lo=Math.pow(2,28),No=Math.pow(2,35),Po=Math.pow(2,42),Fo=Math.pow(2,49),$=128,ae=127;function Ze(r){if(r<wa)return 1;if(r<ya)return 2;if(r<Ea)return 3;if(r<Lo)return 4;if(r<No)return 5;if(r<Po)return 6;if(r<Fo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Uo(r,e,t=0){switch(Ze(r)){case 8:e[t++]=r&255|$,r/=128;case 7:e[t++]=r&255|$,r/=128;case 6:e[t++]=r&255|$,r/=128;case 5:e[t++]=r&255|$,r/=128;case 4:e[t++]=r&255|$,r>>>=7;case 3:e[t++]=r&255|$,r>>>=7;case 2:e[t++]=r&255|$,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Oo(r,e){let t=r[e],n=0;if(n+=t&ae,t<$||(t=r[e+1],n+=(t&ae)<<7,t<$)||(t=r[e+2],n+=(t&ae)<<14,t<$)||(t=r[e+3],n+=(t&ae)<<21,t<$)||(t=r[e+4],n+=(t&ae)*Lo,t<$)||(t=r[e+5],n+=(t&ae)*No,t<$)||(t=r[e+6],n+=(t&ae)*Po,t<$)||(t=r[e+7],n+=(t&ae)*Fo,t<$))return n;throw new RangeError("Could not decode varint")}var gr=new Float32Array([-0]),ce=new Uint8Array(gr.buffer);function _o(r,e,t){gr[0]=r,e[t]=ce[0],e[t+1]=ce[1],e[t+2]=ce[2],e[t+3]=ce[3]}function Bo(r,e){return ce[0]=r[e],ce[1]=r[e+1],ce[2]=r[e+2],ce[3]=r[e+3],gr[0]}var xr=new Float64Array([-0]),M=new Uint8Array(xr.buffer);function Mo(r,e,t){xr[0]=r,e[t]=M[0],e[t+1]=M[1],e[t+2]=M[2],e[t+3]=M[3],e[t+4]=M[4],e[t+5]=M[5],e[t+6]=M[6],e[t+7]=M[7]}function Ro(r,e){return M[0]=r[e],M[1]=r[e+1],M[2]=r[e+2],M[3]=r[e+3],M[4]=r[e+4],M[5]=r[e+5],M[6]=r[e+6],M[7]=r[e+7],xr[0]}var Ia=BigInt(Number.MAX_SAFE_INTEGER),Ca=BigInt(Number.MIN_SAFE_INTEGER),W=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return pe;if(e<Ia&&e>Ca)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,o=e-(n<<32n);return t&&(n=~n|0n,o=~o|0n,++o>ko&&(o=0n,++n>ko&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return pe;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):pe}},pe=new W(0,0);pe.toBigInt=function(){return 0n};pe.zzEncode=pe.zzDecode=function(){return this};pe.length=function(){return 1};var ko=4294967296n;function zo(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Vo(r,e,t){if(t-e<1)return"";let o,i=[],s=0,a;for(;e<t;)a=r[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function br(r,e,t){let n=t,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128);return t-n}function j(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function xt(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var wr=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,j(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw j(this,4);return xt(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw j(this,4);return xt(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw j(this,4);let e=Bo(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw j(this,4);let e=Ro(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw j(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Vo(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw j(this,e);this.pos+=e}else do if(this.pos>=this.len)throw j(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new W(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw j(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw j(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw j(this,8);let e=xt(this.buf,this.pos+=4),t=xt(this.buf,this.pos+=4);return new W(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=Oo(this.buf,this.pos);return this.pos+=Ze(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function et(r){return new wr(r instanceof Uint8Array?r:r.subarray())}function yr(r,e,t){let n=et(r);return e.decode(n,void 0,t)}var Ar={};I(Ar,{base10:()=>Na});var nf=new Uint8Array(0);function Wo(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function Z(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function jo(r){return new TextEncoder().encode(r)}function Go(r){return new TextDecoder().decode(r)}function va(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=o}var a=r.length,c=r.charAt(0),h=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var b=0,V=0,A=0,N=f.length;A!==N&&f[A]===0;)A++,b++;for(var P=(N-A)*u+1>>>0,E=new Uint8Array(P);A!==N;){for(var F=f[A],_=0,S=P-1;(F!==0||_<V)&&S!==-1;S--,_++)F+=256*E[S]>>>0,E[S]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");V=_,A++}for(var U=P-V;U!==P&&E[U]===0;)U++;for(var Q=c.repeat(b);U<P;++U)Q+=r.charAt(E[U]);return Q}function p(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var b=0;if(f[b]!==" "){for(var V=0,A=0;f[b]===c;)V++,b++;for(var N=(f.length-b)*h+1>>>0,P=new Uint8Array(N);f[b];){var E=t[f.charCodeAt(b)];if(E===255)return;for(var F=0,_=N-1;(E!==0||F<A)&&_!==-1;_--,F++)E+=a*P[_]>>>0,P[_]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");A=F,b++}if(f[b]!==" "){for(var S=N-A;S!==N&&P[S]===0;)S++;for(var U=new Uint8Array(V+(N-S)),Q=V;S!==N;)U[Q++]=P[S++];return U}}}function g(f){var b=p(f);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:g}}var Aa=va,Sa=Aa,Xo=Sa;var Er=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Ir=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,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 Ho(this,e)}},Cr=class{decoders;constructor(e){this.decoders=e}or(e){return Ho(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ho(r,e){return new Cr({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var vr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Er(e,t,n),this.decoder=new Ir(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Le({name:r,prefix:e,encode:t,decode:n}){return new vr(r,e,t,n)}function ue({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=Xo(t,r);return Le({prefix:e,name:r,encode:n,decode:i=>Z(o(i))})}function Da(r,e,t,n){let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*t/8|0),s=0,a=0,c=0;for(let h=0;h<o;++h){let u=e[r[h]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<t|u,s+=t,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=t||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function Ta(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,i="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>t;)s-=t,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<t-s]),n)for(;(i.length*t&7)!==0;)i+="=";return i}function La(r){let e={};for(let t=0;t<r.length;++t)e[r[t]]=t;return e}function L({name:r,prefix:e,bitsPerChar:t,alphabet:n}){let o=La(n);return Le({prefix:e,name:r,encode(i){return Ta(i,n,t)},decode(i){return Da(i,o,t,r)}})}var Na=ue({prefix:"9",name:"base10",alphabet:"0123456789"});var Sr={};I(Sr,{base16:()=>Pa,base16upper:()=>Fa});var Pa=L({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Fa=L({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Dr={};I(Dr,{base2:()=>Ua});var Ua=L({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Tr={};I(Tr,{base256emoji:()=>Ra});var Qo=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}"),Oa=Qo.reduce((r,e,t)=>(r[t]=e,r),[]),_a=Qo.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function Ba(r){return r.reduce((e,t)=>(e+=Oa[t],e),"")}function Ma(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=_a[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var Ra=Le({prefix:"\u{1F680}",name:"base256emoji",encode:Ba,decode:Ma});var Lr={};I(Lr,{base32:()=>Ne,base32hex:()=>$a,base32hexpad:()=>ja,base32hexpadupper:()=>Ga,base32hexupper:()=>Wa,base32pad:()=>za,base32padupper:()=>Va,base32upper:()=>ka,base32z:()=>qa});var Ne=L({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ka=L({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),za=L({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Va=L({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),$a=L({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Wa=L({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ja=L({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ga=L({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),qa=L({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Nr={};I(Nr,{base36:()=>tt,base36upper:()=>Xa});var tt=ue({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Xa=ue({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Pr={};I(Pr,{base58btc:()=>X,base58flickr:()=>Ha});var X=ue({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ha=ue({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Fr={};I(Fr,{base64:()=>Qa,base64pad:()=>Ja,base64url:()=>Ya,base64urlpad:()=>Ka});var Qa=L({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ja=L({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ya=L({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ka=L({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ur={};I(Ur,{base8:()=>Za});var Za=L({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Or={};I(Or,{identity:()=>ec});var ec=Le({prefix:"\0",name:"identity",encode:r=>Go(r),decode:r=>jo(r)});var yf=new TextEncoder,Ef=new TextDecoder;var Br={};I(Br,{identity:()=>Cc});var nc=Ko,Jo=128,oc=127,ic=~oc,sc=Math.pow(2,31);function Ko(r,e,t){e=e||[],t=t||0;for(var n=t;r>=sc;)e[t++]=r&255|Jo,r/=128;for(;r&ic;)e[t++]=r&255|Jo,r>>>=7;return e[t]=r|0,Ko.bytes=t-n+1,e}var ac=_r,cc=128,Yo=127;function _r(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw _r.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&Yo)<<o:(s&Yo)*Math.pow(2,o),o+=7}while(s>=cc);return _r.bytes=i-n,t}var uc=Math.pow(2,7),hc=Math.pow(2,14),lc=Math.pow(2,21),fc=Math.pow(2,28),dc=Math.pow(2,35),pc=Math.pow(2,42),mc=Math.pow(2,49),gc=Math.pow(2,56),xc=Math.pow(2,63),bc=function(r){return r<uc?1:r<hc?2:r<lc?3:r<fc?4:r<dc?5:r<pc?6:r<mc?7:r<gc?8:r<xc?9:10},wc={encode:nc,decode:ac,encodingLength:bc},yc=wc,rt=yc;function nt(r,e=0){return[rt.decode(r,e),rt.decode.bytes]}function Pe(r,e,t=0){return rt.encode(r,e,t),e}function Fe(r){return rt.encodingLength(r)}function Oe(r,e){let t=e.byteLength,n=Fe(r),o=n+Fe(t),i=new Uint8Array(o+t);return Pe(r,i,0),Pe(t,i,n),i.set(e,o),new Ue(r,t,e,i)}function Zo(r){let e=Z(r),[t,n]=nt(e),[o,i]=nt(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Ue(t,o,s,e)}function ei(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Wo(r.bytes,t.bytes)}}var Ue=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var ti=0,Ec="identity",ri=Z;function Ic(r,e){if(e?.truncate!=null&&e.truncate!==r.byteLength){if(e.truncate<0||e.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e.truncate)}return Oe(ti,ri(r))}var Cc={code:ti,name:Ec,encode:ri,digest:Ic};var kr={};I(kr,{sha256:()=>Ac,sha512:()=>Sc});var vc=20;function Rr({name:r,code:e,encode:t,minDigestLength:n,maxDigestLength:o}){return new Mr(r,e,t,n,o)}var Mr=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,t,n,o,i){this.name=e,this.code=t,this.encode=n,this.minDigestLength=o??vc,this.maxDigestLength=i}digest(e,t){if(t?.truncate!=null){if(t.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&t.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?ni(n,this.code,t?.truncate):n.then(o=>ni(o,this.code,t?.truncate))}else throw Error("Unknown type, must be binary type")}};function ni(r,e,t){if(t!=null&&t!==r.byteLength){if(t>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t)}return Oe(e,r)}function ii(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Ac=Rr({name:"sha2-256",code:18,encode:ii("SHA-256")}),Sc=Rr({name:"sha2-512",code:19,encode:ii("SHA-512")});function si(r,e){let{bytes:t,version:n}=r;return n===0?Tc(t,zr(r),e??X.encoder):Lc(t,zr(r),e??Ne.encoder)}var ai=new WeakMap;function zr(r){let e=ai.get(r);if(e==null){let t=new Map;return ai.set(r,t),t}return e}var wt=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==it)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Nc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=Oe(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&ei(e.multihash,n.multihash)}toString(e){return si(this,e)}toJSON(){return{"/":si(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:i,bytes:s}=t;return new r(n,o,i,s??ci(n,o,i.bytes))}else if(t[Pc]===!0){let{version:n,multihash:o,code:i}=t,s=Zo(o);return r.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==it)throw new Error(`Version 0 CID must use dag-pb (code: ${it}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=ci(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,it,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=Z(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new Ue(t.multihashCode,t.digestSize,i,o);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,p]=nt(e.subarray(t));return t+=p,l},o=n(),i=it;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,a=n(),c=n(),h=t+c,u=h-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:h}}static parse(e,t){let[n,o]=Dc(e,t),i=r.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return zr(i).set(n,e),i}};function Dc(r,e){switch(r[0]){case"Q":{let t=e??X;return[X.prefix,t.decode(`${X.prefix}${r}`)]}case X.prefix:{let t=e??X;return[X.prefix,t.decode(r)]}case Ne.prefix:{let t=e??Ne;return[Ne.prefix,t.decode(r)]}case tt.prefix:{let t=e??tt;return[tt.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Tc(r,e,t){let{prefix:n}=t;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o}function Lc(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o}var it=112,Nc=18;function ci(r,e,t){let n=Fe(r),o=n+Fe(e),i=new Uint8Array(o+t.byteLength);return Pe(r,i,0),Pe(e,i,n),i.set(t,o),i}var Pc=Symbol.for("@ipld/js-cid/CID");var Vr={...Or,...Dr,...Ur,...Ar,...Sr,...Lr,...Nr,...Pr,...Fr,...Tr},Wf={...kr,...Br};function hi(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var ui=hi("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),$r=hi("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=se(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Fc={utf8:ui,"utf-8":ui,hex:Vr.base16,latin1:$r,ascii:$r,binary:$r,...Vr},li=Fc;function fi(r,e="utf8"){let t=li[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function Wr(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return se(s);o+s>e&&(n=se(e),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var me=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function jr(){}var qr=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Uc=Wr();function Oc(r){return globalThis.Buffer!=null?se(r):Uc(r)}var at=class{len;head;tail;states;constructor(){this.len=0,this.head=new me(jr,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new me(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Xr((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(yt,10,W.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=W.fromBigInt(e);return this._push(yt,t.length(),t)}uint64Number(e){return this._push(Uo,Ze(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=W.fromBigInt(e).zzEncode();return this._push(yt,t.length(),t)}sint64Number(e){let t=W.fromNumber(e).zzEncode();return this._push(yt,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Gr,1,e?1:0)}fixed32(e){return this._push(st,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=W.fromBigInt(e);return this._push(st,4,t.lo)._push(st,4,t.hi)}fixed64Number(e){let t=W.fromNumber(e);return this._push(st,4,t.lo)._push(st,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(_o,4,e)}double(e){return this._push(Mo,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Gr,1,0):this.uint32(t)._push(Bc,t,e)}string(e){let t=zo(e);return t!==0?this.uint32(t)._push(br,t,e):this._push(Gr,1,0)}fork(){return this.states=new qr(this),this.head=this.tail=new me(jr,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new me(jr,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=Oc(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Gr(r,e,t){e[t]=r&255}function _c(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Xr=class extends me{next;constructor(e,t){super(_c,e,t),this.next=void 0}};function yt(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function st(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function Bc(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(at.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(Mc,e,r),this},at.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(Rc,e,r),this});function Mc(r,e,t){e.set(r,t)}function Rc(r,e,t){r.length<40?br(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(fi(r),t)}function Hr(){return new at}function Qr(r,e){let t=Hr();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}function*Jr(r,e,t){let n=et(r);yield*e.stream(n,void 0,"$",t)}var Et={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function It(r,e,t,n,o){return{name:r,type:e,encode:t,decode:n,stream:o}}function Yr(r){function e(i){if(r[i.toString()]==null)throw new Error("Invalid enum value");return r[i]}let t=function(s,a){let c=e(s);a.int32(c)},n=function(s){let a=s.int32();return e(a)},o=function*(s){let a=s.int32();yield e(a)};return It("enum",Et.VARINT,t,n,o)}function Kr(r,e,t){return It("message",Et.LENGTH_DELIMITED,r,e,t)}var ct=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};function kc(r){let e=r.getComponents(),t={},n=0;return e[n]?.name==="ip6zone"&&(t.zone=`${e[n].value}`,n++),e[n]?.name==="ip4"||e[n]?.name==="ip6"||e[n]?.name==="dns"||e[n]?.name==="dns4"||e[n]?.name==="dns6"?(t.type=e[n].name,t.host=e[n].value,n++):e[n]?.name==="dnsaddr"&&(t.type=e[n].name,t.host=`_dnsaddr.${e[n].value}`,n++),(e[n]?.name==="tcp"||e[n]?.name==="udp")&&(t.protocol=e[n].name==="tcp"?"tcp":"udp",t.port=parseInt(`${e[n].value}`),n++),e[n]?.name==="ipcidr"&&(t.type==="ip4"?t.cidr=parseInt(`${e[n].value}`):t.type==="ip6"&&(t.cidr=`${e[n].value}`),n++),t.type==null||t.host==null?null:(e[n]?.name==="tls"&&e[n+1]?.name==="sni"&&(t.sni=e[n+1].value,n+=2),t)}function di(r){let e=kc(r);if(e==null)throw new ye(`Multiaddr ${r} was not an IPv4, IPv6, DNS, DNS4, DNS6 or DNSADDR address`);return e}var Ct=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",h=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let p=Number.parseInt(l,e);if(!Number.isNaN(p))return p});if(u===void 0)break;if(i*=e,i+=u,i>h||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2],t[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];t[o]=i>>8,t[o+1]=i&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=e(i.subarray(0,s));return t.set(i.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var zc=45,Vc=15,vt=new Ct;function pi(r){if(!(r.length>Vc))return vt.new(r).parseWith(()=>vt.readIPv4Addr())}function mi(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>zc))return vt.new(r).parseWith(()=>vt.readIPv6Addr())}function _e(r){return!!pi(r)}function At(r){return!!mi(r)}var wi=ss(bi(),1),Hc=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],Qc=Hc.map(r=>new wi.Netmask(r));function sn(r){for(let e of Qc)if(e.contains(r))return!0;return!1}function Jc(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function Yc(r){let e=r.split(":");if(e.length<2)return!1;let t=e[e.length-1].padStart(4,"0"),n=e[e.length-2].padStart(4,"0"),o=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(t.substring(0,2),16)}.${parseInt(t.substring(2),16)}`;return sn(o)}function Kc(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function Zc(r){let e=r.split(":"),t=e[e.length-1];return sn(t)}function eu(r){return/^::$/.test(r)||/^::1$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function yi(r){if(_e(r))return sn(r);if(Jc(r))return Yc(r);if(Kc(r))return Zc(r);if(At(r))return eu(r)}function Ei(r){try{let e=di(r);switch(e.type){case"ip4":case"ip6":return yi(e.host)??!1;default:return e.host==="localhost"}}catch{return!1}}var tu=Math.pow(2,7),ru=Math.pow(2,14),nu=Math.pow(2,21),an=Math.pow(2,28),cn=Math.pow(2,35),un=Math.pow(2,42),hn=Math.pow(2,49),D=128,R=127;function ke(r){if(r<tu)return 1;if(r<ru)return 2;if(r<nu)return 3;if(r<an)return 4;if(r<cn)return 5;if(r<un)return 6;if(r<hn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ln(r,e,t=0){switch(ke(r)){case 8:e[t++]=r&255|D,r/=128;case 7:e[t++]=r&255|D,r/=128;case 6:e[t++]=r&255|D,r/=128;case 5:e[t++]=r&255|D,r/=128;case 4:e[t++]=r&255|D,r>>>=7;case 3:e[t++]=r&255|D,r>>>=7;case 2:e[t++]=r&255|D,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function ou(r,e){let t=r[e],n=0;if(n+=t&R,t<D||(t=r[e+1],n+=(t&R)<<7,t<D)||(t=r[e+2],n+=(t&R)<<14,t<D)||(t=r[e+3],n+=(t&R)<<21,t<D)||(t=r[e+4],n+=(t&R)*an,t<D)||(t=r[e+5],n+=(t&R)*cn,t<D)||(t=r[e+6],n+=(t&R)*un,t<D)||(t=r[e+7],n+=(t&R)*hn,t<D))return n;throw new RangeError("Could not decode varint")}function iu(r,e){let t=r.get(e),n=0;if(n+=t&R,t<D||(t=r.get(e+1),n+=(t&R)<<7,t<D)||(t=r.get(e+2),n+=(t&R)<<14,t<D)||(t=r.get(e+3),n+=(t&R)<<21,t<D)||(t=r.get(e+4),n+=(t&R)*an,t<D)||(t=r.get(e+5),n+=(t&R)*cn,t<D)||(t=r.get(e+6),n+=(t&R)*un,t<D)||(t=r.get(e+7),n+=(t&R)*hn,t<D))return n;throw new RangeError("Could not decode varint")}function fn(r,e=0){return r instanceof Uint8Array?ou(r,e):iu(r,e)}var B=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},ee=class extends Error{static name="ValidationError";name="ValidationError"},Dt=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Tt=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function pn(r){return e=>ie(e,r)}function mn(r){return e=>De(e,r)}function ze(r){return new DataView(r.buffer).getUint16(r.byteOffset).toString()}function xe(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof r=="string"?parseInt(r):r),new Uint8Array(e)}function Ii(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=De(e[0],"base32"),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=xe(n);return Te([t,o],t.length+o.length)}function Ci(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=oe.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=xe(n);return Te([t,o],t.length+o.length)}function gn(r){let e=r.subarray(0,r.length-2),t=r.subarray(r.length-2),n=ie(e,"base32"),o=ze(t);return`${n}:${o}`}var xn=function(r){r=r.toString().trim();let e=new Uint8Array(4);return r.split(/\./g).forEach((t,n)=>{let o=parseInt(t,10);if(isNaN(o)||o<0||o>255)throw new B("Invalid byte value in IP address");e[n]=o}),e},vi=function(r){let e=0;r=r.toString().trim();let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=_e(t[n]),s;i&&(s=xn(t[n]),t[n]=ie(s.subarray(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,ie(s.subarray(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let i=[n,1];for(n=9-t.length;n>0;n--)i.push("0");t.splice.apply(t,i)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){t[n]===""&&(t[n]="0");let i=parseInt(t[n],16);if(isNaN(i)||i<0||i>65535)throw new B("Invalid byte value in IP address");o[e++]=i>>8&255,o[e++]=i&255}return o},Ai=function(r){if(r.byteLength!==4)throw new B("IPv4 address was incorrect length");let e=[];for(let t=0;t<r.byteLength;t++)e.push(r[t]);return e.join(".")},Si=function(r){if(r.byteLength!==16)throw new B("IPv6 address was incorrect length");let e=[];for(let n=0;n<r.byteLength;n+=2){let o=r[n],i=r[n+1],s=`${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`;e.push(s)}let t=e.join(":");try{let n=new URL(`http://[${t}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new B(`Invalid IPv6 address "${t}"`)}};function Di(r){try{let e=new URL(`http://[${r}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new B(`Invalid IPv6 address "${r}"`)}}var dn=Object.values(Ke).map(r=>r.decoder),au=(function(){let r=dn[0].or(dn[1]);return dn.slice(2).forEach(e=>r=r.or(e)),r})();function Ti(r){return au.decode(r)}function Li(r){return e=>r.encoder.encode(e)}function cu(r){if(parseInt(r).toString()!==r)throw new ee("Value must be an integer")}function uu(r){if(r<0)throw new ee("Value must be a positive integer, or zero")}function hu(r){return e=>{if(e>r)throw new ee(`Value must be smaller than or equal to ${r}`)}}function lu(...r){return e=>{for(let t of r)t(e)}}var ut=lu(cu,uu,hu(65535));var O=-1,bn=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(e){let t;if(typeof e=="string"?t=this.protocolsByName.get(e):t=this.protocolsByCode.get(e),t==null)throw new Tt(`Protocol ${e} was unknown`);return t}addProtocol(e){this.protocolsByCode.set(e.code,e),this.protocolsByName.set(e.name,e),e.aliases?.forEach(t=>{this.protocolsByName.set(t,e)})}removeProtocol(e){let t=this.protocolsByCode.get(e);t!=null&&(this.protocolsByCode.delete(t.code),this.protocolsByName.delete(t.name),t.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},re=new bn,Au=[{code:4,name:"ip4",size:32,valueToBytes:xn,bytesToValue:Ai,validate:r=>{if(!_e(r))throw new ee(`Invalid IPv4 address "${r}"`)}},{code:6,name:"tcp",size:16,valueToBytes:xe,bytesToValue:ze,validate:ut},{code:273,name:"udp",size:16,valueToBytes:xe,bytesToValue:ze,validate:ut},{code:33,name:"dccp",size:16,valueToBytes:xe,bytesToValue:ze,validate:ut},{code:41,name:"ip6",size:128,valueToBytes:vi,bytesToValue:Si,stringToValue:Di,validate:r=>{if(!At(r))throw new ee(`Invalid IPv6 address "${r}"`)}},{code:42,name:"ip6zone",size:O},{code:43,name:"ipcidr",size:8,bytesToValue:pn("base10"),valueToBytes:mn("base10")},{code:53,name:"dns",size:O},{code:54,name:"dns4",size:O},{code:55,name:"dns6",size:O},{code:56,name:"dnsaddr",size:O},{code:132,name:"sctp",size:16,valueToBytes:xe,bytesToValue:ze,validate:ut},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:O,stringToValue:r=>decodeURIComponent(r),valueToString:r=>encodeURIComponent(r)},{code:421,name:"p2p",aliases:["ipfs"],size:O,bytesToValue:pn("base58btc"),valueToBytes:r=>r.startsWith("Q")||r.startsWith("1")?mn("base58btc")(r):Se.parse(r).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:gn,valueToBytes:Ii},{code:445,name:"onion3",size:296,bytesToValue:gn,valueToBytes:Ci},{code:446,name:"garlic64",size:O},{code:447,name:"garlic32",size:O},{code:448,name:"tls"},{code:449,name:"sni",size:O},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:O,bytesToValue:Li(ar),valueToBytes:Ti},{code:480,name:"http"},{code:481,name:"http-path",size:O,stringToValue:r=>`/${decodeURIComponent(r)}`,valueToString:r=>encodeURIComponent(r.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:O}];Au.forEach(r=>{re.addProtocol(r)});function Ni(r){let e=[],t=0;for(;t<r.length;){let n=fn(r,t),o=re.getProtocol(n),i=ke(n),s=Su(o,r,t+i),a=0;s>0&&o.size===O&&(a=ke(s));let c=i+a+s,h={code:n,name:o.name,bytes:jt(r.subarray(t,t+c))};if(s>0){let u=t+i+a,l=r.subarray(u,u+s);h.value=o.bytesToValue?.(l)??ie(l)}e.push(h),t+=c}return e}function Pi(r){let e=0,t=[];for(let n of r){if(n.bytes==null){let o=re.getProtocol(n.code),i=ke(n.code),s,a=0,c=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??De(n.value),a=s.byteLength,o.size===O&&(c=ke(a)));let h=new Uint8Array(i+c+a),u=0;ln(n.code,h,u),u+=i,s!=null&&(o.size===O&&(ln(a,h,u),u+=c),h.set(s,u)),n.bytes=h}t.push(n.bytes),e+=n.bytes.byteLength}return Te(t,e)}function Fi(r){if(r.charAt(0)!=="/")throw new B('String multiaddr must start with "/"');let e=[],t="protocol",n="",o="";for(let i=1;i<r.length;i++){let s=r.charAt(i);s!=="/"&&(t==="protocol"?o+=r.charAt(i):n+=r.charAt(i));let a=i===r.length-1;if(s==="/"||a){let c=re.getProtocol(o);if(t==="protocol"){if(c.size==null||c.size===0){e.push({code:c.code,name:c.name}),n="",o="",t="protocol";continue}else if(a)throw new B(`Component ${o} was missing value`);t="value"}else if(t==="value"){let h={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new B(`Component ${o} was missing value`);h.value=c.stringToValue?.(n)??n}e.push(h),n="",o="",t="protocol"}}}if(o!==""&&n!=="")throw new B("Incomplete multiaddr");return e}function Ui(r){return`/${r.flatMap(e=>{if(e.value==null)return e.name;let t=re.getProtocol(e.code);if(t==null)throw new B(`Unknown protocol code ${e.code}`);return[e.name,t.valueToString?.(e.value)??e.value]}).join("/")}`}function Su(r,e,t){return r.size==null||r.size===0?0:r.size>0?r.size/8:fn(e,t)}var Du=Symbol.for("nodejs.util.inspect.custom"),_n=Symbol.for("@multiformats/multiaddr");function Tu(r){if(r==null&&(r="/"),Oi(r))return r.getComponents();if(r instanceof Uint8Array)return Ni(r);if(typeof r=="string")return r=r.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),r===""&&(r="/"),Fi(r);if(Array.isArray(r))return r;throw new B("Must be a string, Uint8Array, Component[], or another Multiaddr")}var Ot=class r{[_n]=!0;#e;#t;#r;constructor(e="/",t={}){this.#e=Tu(e),t.validate!==!1&&Lu(this)}get bytes(){return this.#r==null&&(this.#r=Pi(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=Ui(this.#e)),this.#t}toJSON(){return this.toString()}getComponents(){return[...this.#e.map(e=>({...e}))]}encapsulate(e){let t=new r(e);return new r([...this.#e,...t.getComponents()],{validate:!1})}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Dt(`Address ${this.toString()} does not contain subaddress: ${t}`);return new r(n.slice(0,o),{validate:!1})}decapsulateCode(e){let t;for(let n=this.#e.length-1;n>-1;n--)if(this.#e[n].code===e){t=n;break}return new r(this.#e.slice(0,t),{validate:!1})}equals(e){return tr(this.bytes,e.bytes)}[Du](){return`Multiaddr(${this.toString()})`}};function Lu(r){r.getComponents().forEach(e=>{let t=re.getProtocol(e.code);e.value!=null&&t.validate?.(e.value)})}function Oi(r){return!!r?.[_n]}function Bn(r){return new Ot(r)}var C=r=>({match:e=>{let t=e[0];return t==null||t.code!==r||t.value!=null?!1:e.slice(1)}}),d=(r,e)=>({match:t=>{let n=t[0];return n?.code!==r||n.value==null||e!=null&&n.value!==e?!1:t.slice(1)}}),_i=r=>({match:e=>r.match(e)===!1?e:!1}),m=r=>({match:e=>{let t=r.match(e);return t===!1?e:t}}),k=(...r)=>({match:e=>{let t;for(let n of r){let o=n.match(e);o!==!1&&(t==null||o.length<t.length)&&(t=o)}return t??!1}}),x=(...r)=>({match:e=>{for(let t of r){let n=t.match(e);if(n===!1)return!1;e=n}return e}});function v(...r){function e(o){if(o==null)return!1;let i=o.getComponents();for(let s of r){let a=s.match(i);if(a===!1)return!1;i=a}return i}function t(o){return e(o)!==!1}function n(o){let i=e(o);return i===!1?!1:i.length===0}return{matchers:r,matches:t,exactMatch:n}}var Nu=d(421),jp=v(Nu),Bt=d(54),Mt=d(55),Rt=d(56),Rn=d(53),Gp=v(Bt,m(d(421))),qp=v(Mt,m(d(421))),Xp=v(Rt,m(d(421))),Bi=v(k(Rn,Rt,Bt,Mt),m(d(421))),Mi=x(d(4),m(d(43))),Ri=x(m(d(42)),d(41),m(d(43))),kn=k(Mi,Ri),je=k(kn,Rn,Bt,Mt,Rt),Hp=v(k(kn,x(k(Rn,Rt,Bt,Mt),m(d(421))))),Qp=v(Mi),Jp=v(Ri),ki=v(kn),zn=x(je,d(6)),ht=x(je,d(273)),Yp=v(x(zn,m(d(421)))),Kp=v(ht),Vn=x(ht,C(460),m(d(421))),kt=x(ht,C(461),m(d(421))),Pu=k(Vn,kt),Zp=v(Vn),em=v(kt),Mn=k(je,zn,ht,Vn,kt),zi=k(x(Mn,C(477),m(d(421)))),tm=v(zi),Vi=k(x(Mn,C(478),m(d(421))),x(Mn,C(448),m(d(449)),C(477),m(d(421)))),rm=v(Vi),$i=x(ht,C(280),m(d(466)),m(d(466)),m(d(421))),nm=v($i),Wi=x(kt,C(465),m(d(466)),m(d(466)),m(d(421))),om=v(Wi),_t=k(zi,Vi,x(zn,m(d(421))),x(Pu,m(d(421))),x(je,m(d(421))),$i,Wi,d(421)),im=v(_t),Fu=x(m(_t),C(290),_i(C(281)),m(d(421))),lt=v(Fu),Uu=k(x(_t,C(290),C(281),m(d(421))),x(_t,C(281),m(d(421))),x(C(281),m(d(421)))),sm=v(Uu),Ou=x(je,k(x(d(6,"80")),x(d(6),C(480)),C(480)),m(d(481)),m(d(421))),am=v(Ou),_u=x(je,k(x(d(6,"443")),x(d(6,"443"),C(480)),x(d(6),C(443)),x(d(6),C(448),C(480)),x(C(448),C(480)),C(448),C(443)),m(d(481)),m(d(421))),cm=v(_u),Bu=k(x(d(777),m(d(421)))),um=v(Bu),Mu=k(x(d(400),m(d(421)))),hm=v(Mu);var $n=class r extends Error{name="TimeoutError";constructor(e,t){super(e,t),Error.captureStackTrace?.(this,r)}},ji=r=>r.reason??new DOMException("This operation was aborted.","AbortError");function Wn(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout},signal:s}=e,a,c,u=new Promise((l,p)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(s?.aborted){p(ji(s));return}if(s&&(c=()=>{p(ji(s))},s.addEventListener("abort",c,{once:!0})),r.then(l,p),t===Number.POSITIVE_INFINITY)return;let g=new $n;a=i.setTimeout.call(void 0,()=>{if(n){try{l(n())}catch(f){p(f)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?l():o instanceof Error?p(o):(g.message=o??`Promise timed out after ${t} milliseconds`,p(g))},t)}).finally(()=>{u.clear(),c&&s&&s.removeEventListener("abort",c)});return u.clear=()=>{i.clearTimeout.call(void 0,a),a=void 0},u}var Ru=r=>{let e=r.addEventListener||r.on||r.addListener,t=r.removeEventListener||r.off||r.removeListener;if(!e||!t)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(r),removeListener:t.bind(r)}};function ku(r,e,t){let n,o=new Promise((i,s)=>{if(t={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...t},!(t.count>=0&&(t.count===Number.POSITIVE_INFINITY||Number.isInteger(t.count))))throw new TypeError("The `count` option should be at least 0 or more");t.signal?.throwIfAborted();let a=[e].flat(),c=[],{addListener:h,removeListener:u}=Ru(r),l=async(...g)=>{let f=t.multiArgs?g:g[0];if(t.filter)try{if(!await t.filter(f))return}catch(b){n(),s(b);return}c.push(f),t.count===c.length&&(n(),i(c))},p=(...g)=>{n(),s(t.rejectionMultiArgs?g:g[0])};n=()=>{for(let g of a)u(g,l);for(let g of t.rejectionEvents)a.includes(g)||u(g,p)};for(let g of a)h(g,l);for(let g of t.rejectionEvents)a.includes(g)||h(g,p);t.signal&&t.signal.addEventListener("abort",()=>{p(t.signal.reason)},{once:!0}),t.resolveImmediately&&i(c)});if(o.cancel=n,typeof t.timeout=="number"){let i=Wn(o,{milliseconds:t.timeout});return i.cancel=()=>{n(),i.clear()},i}return o}function Gi(r,e,t){typeof t=="function"&&(t={filter:t}),t={...t,count:1,resolveImmediately:!1};let n=ku(r,e,t),o=n.then(i=>i[0]);return o.cancel=n.cancel,o}var we=class extends Error{static name="UnexpectedEOFError";name="UnexpectedEOFError"};function zu(r){return r.reason}async function jn(r,e,t){if(e==null)return r;let n=t?.translateError??zu;if(e.aborted)return r.catch(()=>{}),Promise.reject(n(e));let o;try{return await Promise.race([r,new Promise((i,s)=>{o=()=>{s(n(e))},e.addEventListener("abort",o)})])}finally{o!=null&&e.removeEventListener("abort",o)}}function qi(r=0){return new Uint8Array(r)}var Vu=Math.pow(2,7),$u=Math.pow(2,14),Wu=Math.pow(2,21),Gn=Math.pow(2,28),qn=Math.pow(2,35),Xn=Math.pow(2,42),Hn=Math.pow(2,49),y=128,z=127;function ft(r){if(r<Vu)return 1;if(r<$u)return 2;if(r<Wu)return 3;if(r<Gn)return 4;if(r<qn)return 5;if(r<Xn)return 6;if(r<Hn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ju(r,e,t=0){switch(ft(r)){case 8:e[t++]=r&255|y,r/=128;case 7:e[t++]=r&255|y,r/=128;case 6:e[t++]=r&255|y,r/=128;case 5:e[t++]=r&255|y,r/=128;case 4:e[t++]=r&255|y,r>>>=7;case 3:e[t++]=r&255|y,r>>>=7;case 2:e[t++]=r&255|y,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Gu(r,e,t=0){switch(ft(r)){case 8:e.set(t++,r&255|y),r/=128;case 7:e.set(t++,r&255|y),r/=128;case 6:e.set(t++,r&255|y),r/=128;case 5:e.set(t++,r&255|y),r/=128;case 4:e.set(t++,r&255|y),r>>>=7;case 3:e.set(t++,r&255|y),r>>>=7;case 2:e.set(t++,r&255|y),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function qu(r,e){let t=r[e],n=0;if(n+=t&z,t<y||(t=r[e+1],n+=(t&z)<<7,t<y)||(t=r[e+2],n+=(t&z)<<14,t<y)||(t=r[e+3],n+=(t&z)<<21,t<y)||(t=r[e+4],n+=(t&z)*Gn,t<y)||(t=r[e+5],n+=(t&z)*qn,t<y)||(t=r[e+6],n+=(t&z)*Xn,t<y)||(t=r[e+7],n+=(t&z)*Hn,t<y))return n;throw new RangeError("Could not decode varint")}function Xu(r,e){let t=r.get(e),n=0;if(n+=t&z,t<y||(t=r.get(e+1),n+=(t&z)<<7,t<y)||(t=r.get(e+2),n+=(t&z)<<14,t<y)||(t=r.get(e+3),n+=(t&z)<<21,t<y)||(t=r.get(e+4),n+=(t&z)*Gn,t<y)||(t=r.get(e+5),n+=(t&z)*qn,t<y)||(t=r.get(e+6),n+=(t&z)*Xn,t<y)||(t=r.get(e+7),n+=(t&z)*Hn,t<y))return n;throw new RangeError("Could not decode varint")}function Xi(r,e,t=0){return e==null&&(e=qi(ft(r))),e instanceof Uint8Array?ju(r,e,t):Gu(r,e,t)}function Hi(r,e=0){return r instanceof Uint8Array?qu(r,e):Xu(r,e)}var Ju=4194304,zt=class extends Error{static name="UnwrappedError";name="UnwrappedError"},Jn=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Yn=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Kn=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function Yu(r){return typeof r?.closeRead=="function"}function Ku(r){return typeof r?.close=="function"}function Qn(r){return Yu(r)?r.remoteWriteStatus!=="writable"&&r.readBufferLength===0:Ku(r)?r.status!=="open":!1}function Zu(r){return r?.addEventListener!=null&&r?.removeEventListener!=null&&r?.send!=null&&r?.push!=null&&r?.log!=null}function eh(r,e){let t=e?.maxBufferSize??Ju,n=new fe,o,i=!1;if(!Zu(r))throw new ye("Argument should be a Stream or a Multiaddr");let s=u=>{if(n.append(u.data),n.byteLength>t){let l=n.byteLength;n.consume(n.byteLength),o?.reject(new Error(`Read buffer overflow - ${l} > ${t}`))}o?.resolve()};r.addEventListener("message",s);let a=u=>{u.error!=null?o?.reject(u.error):o?.resolve()};r.addEventListener("close",a);let c=()=>{o?.resolve()};r.addEventListener("remoteCloseWrite",c);let h={readBuffer:n,async read(u){if(i===!0)throw new zt("Stream was unwrapped");if(Qn(r)){if(n.byteLength===0&&u?.bytes==null)return null;if(u?.bytes!=null&&n.byteLength<u.bytes)throw r.log.error("closed after reading %d/%d bytes",n.byteLength,u.bytes),new we(`Unexpected EOF - stream closed after reading ${n.byteLength}/${u.bytes} bytes`)}let l=u?.bytes??1;for(o=Promise.withResolvers();;){if(n.byteLength>=l){o.resolve();break}if(await jn(o.promise,u?.signal),Qn(r)){if(n.byteLength===0&&u?.bytes==null)return null;break}o=Promise.withResolvers()}let p=u?.bytes??n.byteLength;if(n.byteLength<p){if(Qn(r))throw r.log.error("closed while reading %d/%d bytes",n.byteLength,p),new we(`Unexpected EOF - stream closed while reading ${n.byteLength}/${p} bytes`);return h.read(u)}let g=n.sublist(0,p);return n.consume(p),g},async write(u,l){if(i===!0)throw new zt("Stream was unwrapped");r.send(u)||await Gi(r,"drain",{signal:l?.signal,rejectionEvents:["close"]})},unwrap(){return i||(i=!0,r.removeEventListener("message",s),r.removeEventListener("close",a),r.removeEventListener("remoteCloseWrite",c),n.byteLength>0&&(r.log("stream unwrapped with %d unread bytes",n.byteLength),r.unshift(n))),r}};return h}function th(r,e={}){let t=eh(r,e);e.maxDataLength!=null&&e.maxLengthLength==null&&(e.maxLengthLength=ft(e.maxDataLength));let n=e?.lengthDecoder??Hi,o=e?.lengthEncoder??Xi;return{async read(s){let a=-1,c=new fe;for(;;){let u=await t.read({...s,bytes:1});if(u==null)break;c.append(u);try{a=n(c)}catch(l){if(l instanceof RangeError)continue;throw l}if(a<0)throw new Jn("Invalid message length");if(e?.maxLengthLength!=null&&c.byteLength>e.maxLengthLength)throw new Kn(`Message length length too long - ${c.byteLength} > ${e.maxLengthLength}`);if(a>-1)break}if(e?.maxDataLength!=null&&a>e.maxDataLength)throw new Yn(`Message length too long - ${a} > ${e.maxDataLength}`);let h=await t.read({...s,bytes:a});if(h==null)throw r.log.error("tried to read %d bytes but the stream closed",a),new we(`Unexpected EOF - tried to read ${a} bytes but the stream closed`);if(h.byteLength!==a)throw r.log.error("read %d/%d bytes before the stream closed",h.byteLength,a),new we(`Unexpected EOF - read ${h.byteLength}/${a} bytes before the stream closed`);return h},async write(s,a){await t.write(new fe(o(s.byteLength),s),a)},async writeV(s,a){let c=new fe(...s.flatMap(h=>[o(h.byteLength),h]));await t.write(c,a)},unwrap(){return t.unwrap()}}}function Zn(r,e){let t=th(r,e),n={read:async(o,i)=>{let s=await t.read(i);return o.decode(s)},write:async(o,i,s)=>{await t.write(i.encode(o),s)},writeV:async(o,i,s)=>{await t.writeV(o.map(a=>i.encode(a)),s)},pb:o=>({read:async i=>n.read(o,i),write:async(i,s)=>n.write(i,o,s),writeV:async(i,s)=>n.writeV(i,o,s),unwrap:()=>n}),unwrap:()=>t.unwrap()};return n}var Qi=Symbol.for("sindresorhus/unlimited-timeout#brand");function Ji(r,e,...t){if(typeof r!="function")throw new TypeError("Expected callback to be a function");e??=0,e=Number(e);let n=!1,o={[Qi]:!0,id:void 0,cleared:!1,ref(){return n=!1,o.id?.ref?.(),o},unref(){return n=!0,o.id?.unref?.(),o}};if(e===Number.POSITIVE_INFINITY||e>Number.MAX_SAFE_INTEGER)return o;(!Number.isFinite(e)||e<0)&&(e=0);let i=performance.now()+e,s=a=>{o.cleared||(a<=2147483647?(o.id=globalThis.setTimeout(()=>{o.cleared||r(...t)},a),n&&o.id?.unref?.()):(o.id=globalThis.setTimeout(()=>{let c=performance.now(),h=Math.max(0,i-c);s(h)},2147483647),n&&o.id?.unref?.()))};return s(e),o}function Yi(r){!r||typeof r!="object"||!r[Qi]||(r.cleared=!0,r.id!==void 0&&(globalThis.clearTimeout(r.id),r.id=void 0))}var rh=new WeakMap;function nh({clearTimeout:r,setTimeout:e}={}){return(t,{value:n,signal:o}={})=>{if(o?.aborted)return Promise.reject(o.reason);let i,s,a,c=r??clearTimeout,h=()=>{c(i),a(o.reason)},u=()=>{o&&o.removeEventListener("abort",h)},l=new Promise((p,g)=>{s=()=>{u(),p(n)},a=g,i=(e??setTimeout)(s,t)});return o&&o.addEventListener("abort",h,{once:!0}),rh.set(l,()=>{c(i),i=null,s()}),l}}var oh=nh({setTimeout:Ji,clearTimeout:Yi}),Ki=oh;var G;(function(r){let e;(function(a){a.UNUSED="UNUSED",a.CONNECT="CONNECT",a.SYNC="SYNC"})(e=r.Type||(r.Type={}));let t;(function(a){a[a.UNUSED=0]="UNUSED",a[a.CONNECT=100]="CONNECT",a[a.SYNC=300]="SYNC"})(t||(t={})),(function(a){a.codec=()=>Yr(t)})(e=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=Kr((a,c,h={})=>{if(h.lengthDelimited!==!1&&c.fork(),a.type!=null&&(c.uint32(8),r.Type.codec().encode(a.type,c)),a.observedAddresses!=null&&a.observedAddresses.length>0)for(let u of a.observedAddresses)c.uint32(18),c.bytes(u);h.lengthDelimited!==!1&&c.ldelim()},(a,c,h={})=>{let u={observedAddresses:[]},l=c==null?a.len:a.pos+c;for(;a.pos<l;){let p=a.uint32();switch(p>>>3){case 1:{u.type=r.Type.codec().decode(a);break}case 2:{if(h.limits?.observedAddresses!=null&&u.observedAddresses.length===h.limits.observedAddresses)throw new ct('Decode error - repeated field "observedAddresses" had too many elements');u.observedAddresses.push(a.bytes());break}default:{a.skipType(p&7);break}}}return u},function*(a,c,h,u={}){let l={observedAddresses:0},p=c==null?a.len:a.pos+c;for(;a.pos<p;){let g=a.uint32();switch(g>>>3){case 1:{yield{field:`${h}.type`,value:r.Type.codec().decode(a)};break}case 2:{if(u.limits?.observedAddresses!=null&&l.observedAddresses===u.limits.observedAddresses)throw new ct('Streaming decode error - repeated field "observedAddresses" had too many elements');yield{field:`${h}.observedAddresses[]`,index:l.observedAddresses,value:a.bytes()},l.observedAddresses++;break}default:{a.skipType(g&7);break}}}})),n);function o(a){return Qr(a,r.codec())}r.encode=o;function i(a,c){return yr(a,r.codec(),c)}r.decode=i;function s(a,c){return Jr(a,r.codec(),c)}r.stream=s})(G||(G={}));function eo(r,e){return lt.matches(r)||e.dialTransportForMultiaddr(r)==null?!1:Bi.matches(r)?!0:ki.matches(r)?!Ei(r):!1}var Zi=1024*4,es=100,Vt={timeout:5e3,retries:3,maxInboundStreams:1,maxOutboundStreams:1},$t=class{started;timeout;retries;maxInboundStreams;maxOutboundStreams;peerStore;registrar;connectionManager;addressManager;transportManager;topologyId;log;constructor(e,t){this.log=e.logger.forComponent("libp2p:dcutr"),this.started=!1,this.peerStore=e.peerStore,this.registrar=e.registrar,this.addressManager=e.addressManager,this.connectionManager=e.connectionManager,this.transportManager=e.transportManager,this.timeout=t.timeout??Vt.timeout,this.retries=t.retries??Vt.retries,this.maxInboundStreams=t.maxInboundStreams??Vt.maxInboundStreams,this.maxOutboundStreams=t.maxOutboundStreams??Vt.maxOutboundStreams,this.handleIncomingUpgrade=this.handleIncomingUpgrade.bind(this)}[Symbol.toStringTag]="@libp2p/dcutr";[ro]=["@libp2p/identify"];isStarted(){return this.started}async start(){this.started||(this.topologyId=await this.registrar.register(Ge,{notifyOnLimitedConnection:!0,onConnect:(e,t)=>{lt.exactMatch(t.remoteAddr)&&t.direction==="inbound"&&this.upgradeInbound(t).catch(n=>{this.log.error("error during outgoing DCUtR attempt - %e",n)})}}),await this.registrar.handle(Ge,this.handleIncomingUpgrade,{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnLimitedConnection:!0}),this.started=!0)}async stop(){await this.registrar.unhandle(Ge),this.topologyId!=null&&this.registrar.unregister(this.topologyId),this.started=!1}async upgradeInbound(e){if(await this.attemptUnilateralConnectionUpgrade(e))return;let t;for(let n=0;n<this.retries;n++){let o={signal:AbortSignal.timeout(this.timeout)};try{t=await e.newStream([Ge],{signal:o.signal,runOnLimitedConnection:!0});let i=Zn(t,{maxDataLength:Zi}).pb(G);this.log("B sending connect to %p",e.remotePeer);let s=Date.now();await i.write({type:G.Type.CONNECT,observedAddresses:this.addressManager.getAddresses().map(l=>l.bytes)},o),this.log("B receiving connect from %p",e.remotePeer);let a=await i.read(o);if(a.type!==G.Type.CONNECT)throw this.log("A sent wrong message type"),new J("DCUtR message type was incorrect");let c=this.getDialableMultiaddrs(a.observedAddresses);if(c.length===0)throw this.log("A did not have any dialable multiaddrs"),new J("DCUtR connect message had no multiaddrs");let h=Date.now()-s;this.log("A sending sync, rtt %dms",h),await i.write({type:G.Type.SYNC,observedAddresses:[]},o),this.log("A waiting for half RTT"),await Ki(h/2),this.log("B dialing",c);let u=await this.connectionManager.openConnection(c,{signal:o.signal,priority:es,force:!0,initiator:!1});this.log("DCUtR to %p succeeded to address %a, closing relayed connection",e.remotePeer,u.remoteAddr),await e.close(o);break}catch(i){if(this.log.error("error while attempting DCUtR on attempt %d of %d - %e",n+1,this.retries,i),t?.abort(i),n===this.retries)throw i}finally{t!=null&&await t.close(o)}}}async attemptUnilateralConnectionUpgrade(e){let n=(await this.peerStore.get(e.remotePeer)).addresses.map(o=>{let i=o.multiaddr;return i.getComponents().find(s=>s.code===421)?.value==null?i.encapsulate(`/p2p/${e.remotePeer}`):i}).filter(o=>eo(o,this.transportManager));if(n.length>0){let o=AbortSignal.timeout(this.timeout);try{this.log("attempting unilateral connection upgrade to %a",n);let i=await this.connectionManager.openConnection(n,{signal:o,force:!0});if(lt.exactMatch(i.remoteAddr))throw new Error("Could not open a new, non-limited, connection");return this.log("unilateral connection upgrade to %p succeeded via %a, closing relayed connection",e.remotePeer,i.remoteAddr),await e.close({signal:o}),!0}catch(i){this.log.error("unilateral connection upgrade to %p on addresses %a failed - %e",e.remotePeer,n,i)}}else this.log("peer %p has no public addresses, not attempting unilateral connection upgrade",e.remotePeer);return!1}async handleIncomingUpgrade(e,t){let n={signal:AbortSignal.timeout(this.timeout)},o=Zn(e,{maxDataLength:Zi}).pb(G);this.log("A receiving connect");let i=await o.read(n);if(i.type!==G.Type.CONNECT)throw this.log("B sent wrong message type"),new J("DCUtR message type was incorrect");if(i.observedAddresses.length===0)throw this.log("B sent no multiaddrs"),new J("DCUtR connect message had no multiaddrs");let s=this.getDialableMultiaddrs(i.observedAddresses);if(s.length===0)throw this.log("B had no dialable multiaddrs in %o",i.observedAddresses.map(h=>Bn(h))),new J("DCUtR connect message had no dialable multiaddrs");if(this.log("A sending connect"),await o.write({type:G.Type.CONNECT,observedAddresses:this.addressManager.getAddresses().map(h=>h.bytes)}),this.log("A receiving sync"),(await o.read(n)).type!==G.Type.SYNC)throw new J("DCUtR message type was incorrect");this.log("A dialing",s);let c=await this.connectionManager.openConnection(s,{signal:n.signal,priority:es,force:!0});this.log("DCUtR to %p succeeded via %a, closing relayed connection",t.remotePeer,c.remoteAddr),await t.close(n),await e.close(n)}getDialableMultiaddrs(e){let t=[];for(let n of e)if(!(n==null||n.length===0))try{let o=Bn(n);if(!eo(o,this.transportManager))continue;t.push(o)}catch{}return t}};var Ge="/libp2p/dcutr";function ih(r={}){return e=>new $t(e,r)}return as(sh);})();
3
3
  return Libp2PDcutr}));
4
4
  //# sourceMappingURL=index.min.js.map