@libp2p/daemon-client 7.0.0 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -37
- package/dist/index.min.js +4 -4
- package/dist/src/index.d.ts +18 -18
- package/dist/src/index.d.ts.map +1 -1
- package/dist/typedoc-urls.json +8 -1
- package/package.json +6 -5
- package/src/index.ts +18 -18
package/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# @libp2p/daemon-client <!-- omit in toc -->
|
|
2
|
-
|
|
3
1
|
[](http://libp2p.io/)
|
|
4
2
|
[](https://discuss.libp2p.io)
|
|
5
3
|
[](https://codecov.io/gh/libp2p/js-libp2p-daemon)
|
|
@@ -7,37 +5,26 @@
|
|
|
7
5
|
|
|
8
6
|
> libp2p-daemon client implementation
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- [Install](#install)
|
|
13
|
-
- [Specs](#specs)
|
|
14
|
-
- [Usage](#usage)
|
|
15
|
-
- [Run a daemon process](#run-a-daemon-process)
|
|
16
|
-
- [Interact with the daemon process using the client](#interact-with-the-daemon-process-using-the-client)
|
|
17
|
-
- [API](#api)
|
|
18
|
-
- [License](#license)
|
|
19
|
-
- [Contribution](#contribution)
|
|
20
|
-
|
|
21
|
-
## Install
|
|
8
|
+
# Install
|
|
22
9
|
|
|
23
10
|
```console
|
|
24
11
|
$ npm i @libp2p/daemon-client
|
|
25
12
|
```
|
|
26
13
|
|
|
27
|
-
|
|
14
|
+
# Specs
|
|
28
15
|
|
|
29
16
|
The specs for the daemon are currently housed in the go implementation. You can read them at [libp2p/go-libp2p-daemon](https://github.com/libp2p/go-libp2p-daemon/blob/master/specs/README.md)
|
|
30
17
|
|
|
31
|
-
|
|
18
|
+
# Usage
|
|
32
19
|
|
|
33
|
-
|
|
20
|
+
## Run a daemon process
|
|
34
21
|
|
|
35
22
|
There are currently two implementations of the `libp2p-daemon`:
|
|
36
23
|
|
|
37
24
|
- [js-libp2p-daemon](https://github.com/libp2p/js-libp2p-daemon)
|
|
38
25
|
- [go-libp2p-daemon](https://github.com/libp2p/go-libp2p-daemon)
|
|
39
26
|
|
|
40
|
-
|
|
27
|
+
## Interact with the daemon process using the client
|
|
41
28
|
|
|
42
29
|
```js
|
|
43
30
|
import { createClient } from '@libp2p/daemon-client'
|
|
@@ -58,30 +45,17 @@ try {
|
|
|
58
45
|
await client.close()
|
|
59
46
|
```
|
|
60
47
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
- [`identify`](API.md#identify)
|
|
67
|
-
- [`listPeers`](API.md#listPeers)
|
|
68
|
-
- [`openStream`](API.md#openStream)
|
|
69
|
-
- [`registerStream`](API.md#registerStream)
|
|
70
|
-
- [`dht.put`](API.md#dht.put)
|
|
71
|
-
- [`dht.get`](API.md#dht.get)
|
|
72
|
-
- [`dht.findPeer`](API.md#dht.findPeer)
|
|
73
|
-
- [`dht.provide`](API.md#dht.provide)
|
|
74
|
-
- [`dht.findProviders`](API.md#dht.findProviders)
|
|
75
|
-
- [`dht.getClosestPeers`](API.md#dht.getClosestPeers)
|
|
76
|
-
- [`dht.getPublicKey`](API.md#dht.getPublicKey)
|
|
77
|
-
|
|
78
|
-
## License
|
|
48
|
+
# API Docs
|
|
49
|
+
|
|
50
|
+
- <https://libp2p.github.io/js-libp2p-daemon/modules/_libp2p_daemon_client.html>
|
|
51
|
+
|
|
52
|
+
# License
|
|
79
53
|
|
|
80
54
|
Licensed under either of
|
|
81
55
|
|
|
82
56
|
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
|
83
57
|
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
|
84
58
|
|
|
85
|
-
|
|
59
|
+
# Contribution
|
|
86
60
|
|
|
87
61
|
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
|
package/dist/index.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PDaemonClient = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PDaemonClient=(()=>{var hh=Object.create;var Jr=Object.defineProperty;var ph=Object.getOwnPropertyDescriptor;var dh=Object.getOwnPropertyNames;var mh=Object.getPrototypeOf,gh=Object.prototype.hasOwnProperty;var Bt=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var F=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),U=(r,t)=>{for(var e in t)Jr(r,e,{get:t[e],enumerable:!0})},Gs=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of dh(t))!gh.call(r,o)&&o!==e&&Jr(r,o,{get:()=>t[o],enumerable:!(n=ph(t,o))||n.enumerable});return r};var H=(r,t,e)=>(e=r!=null?hh(mh(r)):{},Gs(t||!r||!r.__esModule?Jr(e,"default",{value:r,enumerable:!0}):e,r)),bh=r=>Gs(Jr({},"__esModule",{value:!0}),r);var qs=F((Tb,Hs)=>{"use strict";Hs.exports=yh;function yh(r,t){for(var e=new Array(arguments.length-1),n=0,o=2,i=!0;o<arguments.length;)e[n++]=arguments[o++];return new Promise(function(u,l){e[n]=function(h){if(i)if(i=!1,h)l(h);else{for(var g=new Array(arguments.length-1),w=0;w<g.length;)g[w++]=arguments[w];u.apply(null,g)}};try{r.apply(t||null,e)}catch(m){i&&(i=!1,l(m))}})}});var Ys=F(Js=>{"use strict";var Yr=Js;Yr.length=function(t){var e=t.length;if(!e)return 0;for(var n=0;--e%4>1&&t.charAt(e)==="=";)++n;return Math.ceil(t.length*3)/4-n};var Be=new Array(64),js=new Array(123);for(Nt=0;Nt<64;)js[Be[Nt]=Nt<26?Nt+65:Nt<52?Nt+71:Nt<62?Nt-4:Nt-59|43]=Nt++;var Nt;Yr.encode=function(t,e,n){for(var o=null,i=[],s=0,u=0,l;e<n;){var m=t[e++];switch(u){case 0:i[s++]=Be[m>>2],l=(m&3)<<4,u=1;break;case 1:i[s++]=Be[l|m>>4],l=(m&15)<<2,u=2;break;case 2:i[s++]=Be[l|m>>6],i[s++]=Be[m&63],u=0;break}s>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,i)),s=0)}return u&&(i[s++]=Be[l],i[s++]=61,u===1&&(i[s++]=61)),o?(s&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))};var Ks="invalid encoding";Yr.decode=function(t,e,n){for(var o=n,i=0,s,u=0;u<t.length;){var l=t.charCodeAt(u++);if(l===61&&i>1)break;if((l=js[l])===void 0)throw Error(Ks);switch(i){case 0:s=l,i=1;break;case 1:e[n++]=s<<2|(l&48)>>4,s=l,i=2;break;case 2:e[n++]=(s&15)<<4|(l&60)>>2,s=l,i=3;break;case 3:e[n++]=(s&3)<<6|l,i=0;break}}if(i===1)throw Error(Ks);return n-o};Yr.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}});var Ws=F((Cb,Xs)=>{"use strict";Xs.exports=Xr;function Xr(){this._listeners={}}Xr.prototype.on=function(t,e,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:n||this}),this};Xr.prototype.off=function(t,e){if(t===void 0)this._listeners={};else if(e===void 0)this._listeners[t]=[];else for(var n=this._listeners[t],o=0;o<n.length;)n[o].fn===e?n.splice(o,1):++o;return this};Xr.prototype.emit=function(t){var e=this._listeners[t];if(e){for(var n=[],o=1;o<arguments.length;)n.push(arguments[o++]);for(o=0;o<e.length;)e[o].fn.apply(e[o++].ctx,n)}return this}});var oa=F((Db,na)=>{"use strict";na.exports=Zs(Zs);function Zs(r){return typeof Float32Array<"u"?function(){var t=new Float32Array([-0]),e=new Uint8Array(t.buffer),n=e[3]===128;function o(l,m,h){t[0]=l,m[h]=e[0],m[h+1]=e[1],m[h+2]=e[2],m[h+3]=e[3]}function i(l,m,h){t[0]=l,m[h]=e[3],m[h+1]=e[2],m[h+2]=e[1],m[h+3]=e[0]}r.writeFloatLE=n?o:i,r.writeFloatBE=n?i:o;function s(l,m){return e[0]=l[m],e[1]=l[m+1],e[2]=l[m+2],e[3]=l[m+3],t[0]}function u(l,m){return e[3]=l[m],e[2]=l[m+1],e[1]=l[m+2],e[0]=l[m+3],t[0]}r.readFloatLE=n?s:u,r.readFloatBE=n?u:s}():function(){function t(n,o,i,s){var u=o<0?1:0;if(u&&(o=-o),o===0)n(1/o>0?0:2147483648,i,s);else if(isNaN(o))n(2143289344,i,s);else if(o>34028234663852886e22)n((u<<31|2139095040)>>>0,i,s);else if(o<11754943508222875e-54)n((u<<31|Math.round(o/1401298464324817e-60))>>>0,i,s);else{var l=Math.floor(Math.log(o)/Math.LN2),m=Math.round(o*Math.pow(2,-l)*8388608)&8388607;n((u<<31|l+127<<23|m)>>>0,i,s)}}r.writeFloatLE=t.bind(null,Qs),r.writeFloatBE=t.bind(null,ta);function e(n,o,i){var s=n(o,i),u=(s>>31)*2+1,l=s>>>23&255,m=s&8388607;return l===255?m?NaN:u*(1/0):l===0?u*1401298464324817e-60*m:u*Math.pow(2,l-150)*(m+8388608)}r.readFloatLE=e.bind(null,ea),r.readFloatBE=e.bind(null,ra)}(),typeof Float64Array<"u"?function(){var t=new Float64Array([-0]),e=new Uint8Array(t.buffer),n=e[7]===128;function o(l,m,h){t[0]=l,m[h]=e[0],m[h+1]=e[1],m[h+2]=e[2],m[h+3]=e[3],m[h+4]=e[4],m[h+5]=e[5],m[h+6]=e[6],m[h+7]=e[7]}function i(l,m,h){t[0]=l,m[h]=e[7],m[h+1]=e[6],m[h+2]=e[5],m[h+3]=e[4],m[h+4]=e[3],m[h+5]=e[2],m[h+6]=e[1],m[h+7]=e[0]}r.writeDoubleLE=n?o:i,r.writeDoubleBE=n?i:o;function s(l,m){return e[0]=l[m],e[1]=l[m+1],e[2]=l[m+2],e[3]=l[m+3],e[4]=l[m+4],e[5]=l[m+5],e[6]=l[m+6],e[7]=l[m+7],t[0]}function u(l,m){return e[7]=l[m],e[6]=l[m+1],e[5]=l[m+2],e[4]=l[m+3],e[3]=l[m+4],e[2]=l[m+5],e[1]=l[m+6],e[0]=l[m+7],t[0]}r.readDoubleLE=n?s:u,r.readDoubleBE=n?u:s}():function(){function t(n,o,i,s,u,l){var m=s<0?1:0;if(m&&(s=-s),s===0)n(0,u,l+o),n(1/s>0?0:2147483648,u,l+i);else if(isNaN(s))n(0,u,l+o),n(2146959360,u,l+i);else if(s>17976931348623157e292)n(0,u,l+o),n((m<<31|2146435072)>>>0,u,l+i);else{var h;if(s<22250738585072014e-324)h=s/5e-324,n(h>>>0,u,l+o),n((m<<31|h/4294967296)>>>0,u,l+i);else{var g=Math.floor(Math.log(s)/Math.LN2);g===1024&&(g=1023),h=s*Math.pow(2,-g),n(h*4503599627370496>>>0,u,l+o),n((m<<31|g+1023<<20|h*1048576&1048575)>>>0,u,l+i)}}}r.writeDoubleLE=t.bind(null,Qs,0,4),r.writeDoubleBE=t.bind(null,ta,4,0);function e(n,o,i,s,u){var l=n(s,u+o),m=n(s,u+i),h=(m>>31)*2+1,g=m>>>20&2047,w=4294967296*(m&1048575)+l;return g===2047?w?NaN:h*(1/0):g===0?h*5e-324*w:h*Math.pow(2,g-1075)*(w+4503599627370496)}r.readDoubleLE=e.bind(null,ea,0,4),r.readDoubleBE=e.bind(null,ra,4,0)}(),r}function Qs(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function ta(r,t,e){t[e]=r>>>24,t[e+1]=r>>>16&255,t[e+2]=r>>>8&255,t[e+3]=r&255}function ea(r,t){return(r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24)>>>0}function ra(r,t){return(r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3])>>>0}});var ia=F((exports,module)=>{"use strict";module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(r){}return null}});var aa=F(sa=>{"use strict";var eo=sa;eo.length=function(t){for(var e=0,n=0,o=0;o<t.length;++o)n=t.charCodeAt(o),n<128?e+=1:n<2048?e+=2:(n&64512)===55296&&(t.charCodeAt(o+1)&64512)===56320?(++o,e+=4):e+=3;return e};eo.read=function(t,e,n){var o=n-e;if(o<1)return"";for(var i=null,s=[],u=0,l;e<n;)l=t[e++],l<128?s[u++]=l:l>191&&l<224?s[u++]=(l&31)<<6|t[e++]&63:l>239&&l<365?(l=((l&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,s[u++]=55296+(l>>10),s[u++]=56320+(l&1023)):s[u++]=(l&15)<<12|(t[e++]&63)<<6|t[e++]&63,u>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),u=0);return i?(u&&i.push(String.fromCharCode.apply(String,s.slice(0,u))),i.join("")):String.fromCharCode.apply(String,s.slice(0,u))};eo.write=function(t,e,n){for(var o=n,i,s,u=0;u<t.length;++u)i=t.charCodeAt(u),i<128?e[n++]=i:i<2048?(e[n++]=i>>6|192,e[n++]=i&63|128):(i&64512)===55296&&((s=t.charCodeAt(u+1))&64512)===56320?(i=65536+((i&1023)<<10)+(s&1023),++u,e[n++]=i>>18|240,e[n++]=i>>12&63|128,e[n++]=i>>6&63|128,e[n++]=i&63|128):(e[n++]=i>>12|224,e[n++]=i>>6&63|128,e[n++]=i&63|128);return n-o}});var fa=F((_b,ca)=>{"use strict";ca.exports=wh;function wh(r,t,e){var n=e||8192,o=n>>>1,i=null,s=n;return function(l){if(l<1||l>o)return r(l);s+l>n&&(i=r(n),s=0);var m=t.call(i,s,s+=l);return s&7&&(s=(s|7)+1),m}}});var la=F((Bb,ua)=>{"use strict";ua.exports=rt;var yr=me();function rt(r,t){this.lo=r>>>0,this.hi=t>>>0}var de=rt.zero=new rt(0,0);de.toNumber=function(){return 0};de.zzEncode=de.zzDecode=function(){return this};de.length=function(){return 1};var Eh=rt.zeroHash="\0\0\0\0\0\0\0\0";rt.fromNumber=function(t){if(t===0)return de;var e=t<0;e&&(t=-t);var n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new rt(n,o)};rt.from=function(t){if(typeof t=="number")return rt.fromNumber(t);if(yr.isString(t))if(yr.Long)t=yr.Long.fromString(t);else return rt.fromNumber(parseInt(t,10));return t.low||t.high?new rt(t.low>>>0,t.high>>>0):de};rt.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var e=~this.lo+1>>>0,n=~this.hi>>>0;return e||(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296};rt.prototype.toLong=function(t){return yr.Long?new yr.Long(this.lo|0,this.hi|0,!!t):{low:this.lo|0,high:this.hi|0,unsigned:!!t}};var te=String.prototype.charCodeAt;rt.fromHash=function(t){return t===Eh?de:new rt((te.call(t,0)|te.call(t,1)<<8|te.call(t,2)<<16|te.call(t,3)<<24)>>>0,(te.call(t,4)|te.call(t,5)<<8|te.call(t,6)<<16|te.call(t,7)<<24)>>>0)};rt.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};rt.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this};rt.prototype.zzDecode=function(){var t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this};rt.prototype.length=function(){var t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}});var me=F(ro=>{"use strict";var L=ro;L.asPromise=qs();L.base64=Ys();L.EventEmitter=Ws();L.float=oa();L.inquire=ia();L.utf8=aa();L.pool=fa();L.LongBits=la();L.isNode=!!(typeof globalThis<"u"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);L.global=L.isNode&&globalThis||typeof window<"u"&&window||typeof self<"u"&&self||ro;L.emptyArray=Object.freeze?Object.freeze([]):[];L.emptyObject=Object.freeze?Object.freeze({}):{};L.isInteger=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};L.isString=function(t){return typeof t=="string"||t instanceof String};L.isObject=function(t){return t&&typeof t=="object"};L.isset=L.isSet=function(t,e){var n=t[e];return n!=null&&t.hasOwnProperty(e)?typeof n!="object"||(Array.isArray(n)?n.length:Object.keys(n).length)>0:!1};L.Buffer=function(){try{var r=L.inquire("buffer").Buffer;return r.prototype.utf8Write?r:null}catch{return null}}();L._Buffer_from=null;L._Buffer_allocUnsafe=null;L.newBuffer=function(t){return typeof t=="number"?L.Buffer?L._Buffer_allocUnsafe(t):new L.Array(t):L.Buffer?L._Buffer_from(t):typeof Uint8Array>"u"?t:new Uint8Array(t)};L.Array=typeof Uint8Array<"u"?Uint8Array:Array;L.Long=L.global.dcodeIO&&L.global.dcodeIO.Long||L.global.Long||L.inquire("long");L.key2Re=/^true|false|0|1$/;L.key32Re=/^-?(?:0|[1-9][0-9]*)$/;L.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;L.longToHash=function(t){return t?L.LongBits.from(t).toHash():L.LongBits.zeroHash};L.longFromHash=function(t,e){var n=L.LongBits.fromHash(t);return L.Long?L.Long.fromBits(n.lo,n.hi,e):n.toNumber(!!e)};function ha(r,t,e){for(var n=Object.keys(t),o=0;o<n.length;++o)(r[n[o]]===void 0||!e)&&(r[n[o]]=t[n[o]]);return r}L.merge=ha;L.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)};function pa(r){function t(e,n){if(!(this instanceof t))return new t(e,n);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:new Error().stack||""}),n&&ha(this,n)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return r},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}L.newError=pa;L.ProtocolError=pa("ProtocolError");L.oneOfGetter=function(t){for(var e={},n=0;n<t.length;++n)e[t[n]]=1;return function(){for(var o=Object.keys(this),i=o.length-1;i>-1;--i)if(e[o[i]]===1&&this[o[i]]!==void 0&&this[o[i]]!==null)return o[i]}};L.oneOfSetter=function(t){return function(e){for(var n=0;n<t.length;++n)t[n]!==e&&delete this[t[n]]}};L.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};L._configure=function(){var r=L.Buffer;if(!r){L._Buffer_from=L._Buffer_allocUnsafe=null;return}L._Buffer_from=r.from!==Uint8Array.from&&r.from||function(e,n){return new r(e,n)},L._Buffer_allocUnsafe=r.allocUnsafe||function(e){return new r(e)}}});var io=F((Lb,ya)=>{"use strict";ya.exports=Y;var Ut=me(),oo,ga=Ut.LongBits,vh=Ut.utf8;function Lt(r,t){return RangeError("index out of range: "+r.pos+" + "+(t||1)+" > "+r.len)}function Y(r){this.buf=r,this.pos=0,this.len=r.length}var da=typeof Uint8Array<"u"?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new Y(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new Y(t);throw Error("illegal buffer")},ba=function(){return Ut.Buffer?function(e){return(Y.create=function(o){return Ut.Buffer.isBuffer(o)?new oo(o):da(o)})(e)}:da};Y.create=ba();Y.prototype._slice=Ut.Array.prototype.subarray||Ut.Array.prototype.slice;Y.prototype.uint32=function(){var t=4294967295;return function(){if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Lt(this,10);return t}}();Y.prototype.int32=function(){return this.uint32()|0};Y.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(t&1)|0};function no(){var r=new ga(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(r.lo=(r.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return r;if(r.lo=(r.lo|(this.buf[this.pos]&127)<<28)>>>0,r.hi=(r.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return r;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw Lt(this);if(r.lo=(r.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return r}return r.lo=(r.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,r}if(this.len-this.pos>4){for(;t<5;++t)if(r.hi=(r.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return r}else for(;t<5;++t){if(this.pos>=this.len)throw Lt(this);if(r.hi=(r.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return r}throw Error("invalid varint encoding")}Y.prototype.bool=function(){return this.uint32()!==0};function Wr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}Y.prototype.fixed32=function(){if(this.pos+4>this.len)throw Lt(this,4);return Wr(this.buf,this.pos+=4)};Y.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Lt(this,4);return Wr(this.buf,this.pos+=4)|0};function ma(){if(this.pos+8>this.len)throw Lt(this,8);return new ga(Wr(this.buf,this.pos+=4),Wr(this.buf,this.pos+=4))}Y.prototype.float=function(){if(this.pos+4>this.len)throw Lt(this,4);var t=Ut.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};Y.prototype.double=function(){if(this.pos+8>this.len)throw Lt(this,4);var t=Ut.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};Y.prototype.bytes=function(){var t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Lt(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(e,n):e===n?new this.buf.constructor(0):this._slice.call(this.buf,e,n)};Y.prototype.string=function(){var t=this.bytes();return vh.read(t,0,t.length)};Y.prototype.skip=function(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Lt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Lt(this);while(this.buf[this.pos++]&128);return this};Y.prototype.skipType=function(r){switch(r){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(r=this.uint32()&7)!==4;)this.skipType(r);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+r+" at offset "+this.pos)}return this};Y._configure=function(r){oo=r,Y.create=ba(),oo._configure();var t=Ut.Long?"toLong":"toNumber";Ut.merge(Y.prototype,{int64:function(){return no.call(this)[t](!1)},uint64:function(){return no.call(this)[t](!0)},sint64:function(){return no.call(this).zzDecode()[t](!1)},fixed64:function(){return ma.call(this)[t](!0)},sfixed64:function(){return ma.call(this)[t](!1)}})}});var xa=F((Ob,va)=>{"use strict";va.exports=ge;var Ea=io();(ge.prototype=Object.create(Ea.prototype)).constructor=ge;var wa=me();function ge(r){Ea.call(this,r)}ge._configure=function(){wa.Buffer&&(ge.prototype._slice=wa.Buffer.prototype.slice)};ge.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))};ge._configure()});var ho=F((kb,Ia)=>{"use strict";Ia.exports=z;var vt=me(),so,Zr=vt.LongBits,Sa=vt.base64,Aa=vt.utf8;function wr(r,t,e){this.fn=r,this.len=t,this.next=void 0,this.val=e}function co(){}function xh(r){this.head=r.head,this.tail=r.tail,this.len=r.len,this.next=r.states}function z(){this.len=0,this.head=new wr(co,0,0),this.tail=this.head,this.states=null}var Ta=function(){return vt.Buffer?function(){return(z.create=function(){return new so})()}:function(){return new z}};z.create=Ta();z.alloc=function(t){return new vt.Array(t)};vt.Array!==Array&&(z.alloc=vt.pool(z.alloc,vt.Array.prototype.subarray));z.prototype._push=function(t,e,n){return this.tail=this.tail.next=new wr(t,e,n),this.len+=e,this};function fo(r,t,e){t[e]=r&255}function Sh(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}function uo(r,t){this.len=r,this.next=void 0,this.val=t}uo.prototype=Object.create(wr.prototype);uo.prototype.fn=Sh;z.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new uo((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};z.prototype.int32=function(t){return t<0?this._push(lo,10,Zr.fromNumber(t)):this.uint32(t)};z.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)};function lo(r,t,e){for(;r.hi;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}z.prototype.uint64=function(t){var e=Zr.from(t);return this._push(lo,e.length(),e)};z.prototype.int64=z.prototype.uint64;z.prototype.sint64=function(t){var e=Zr.from(t).zzEncode();return this._push(lo,e.length(),e)};z.prototype.bool=function(t){return this._push(fo,1,t?1:0)};function ao(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}z.prototype.fixed32=function(t){return this._push(ao,4,t>>>0)};z.prototype.sfixed32=z.prototype.fixed32;z.prototype.fixed64=function(t){var e=Zr.from(t);return this._push(ao,4,e.lo)._push(ao,4,e.hi)};z.prototype.sfixed64=z.prototype.fixed64;z.prototype.float=function(t){return this._push(vt.float.writeFloatLE,4,t)};z.prototype.double=function(t){return this._push(vt.float.writeDoubleLE,8,t)};var Ah=vt.Array.prototype.set?function(t,e,n){e.set(t,n)}:function(t,e,n){for(var o=0;o<t.length;++o)e[n+o]=t[o]};z.prototype.bytes=function(t){var e=t.length>>>0;if(!e)return this._push(fo,1,0);if(vt.isString(t)){var n=z.alloc(e=Sa.length(t));Sa.decode(t,n,0),t=n}return this.uint32(e)._push(Ah,e,t)};z.prototype.string=function(t){var e=Aa.length(t);return e?this.uint32(e)._push(Aa.write,e,t):this._push(fo,1,0)};z.prototype.fork=function(){return this.states=new xh(this),this.head=this.tail=new wr(co,0,0),this.len=0,this};z.prototype.reset=function(){return this.states?(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 wr(co,0,0),this.len=0),this};z.prototype.ldelim=function(){var t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=t.next,this.tail=e,this.len+=n),this};z.prototype.finish=function(){for(var t=this.head.next,e=this.constructor.alloc(this.len),n=0;t;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e};z._configure=function(r){so=r,z.create=Ta(),so._configure()}});var Ra=F((Pb,Da)=>{"use strict";Da.exports=Mt;var Ca=ho();(Mt.prototype=Object.create(Ca.prototype)).constructor=Mt;var ee=me();function Mt(){Ca.call(this)}Mt._configure=function(){Mt.alloc=ee._Buffer_allocUnsafe,Mt.writeBytesBuffer=ee.Buffer&&ee.Buffer.prototype instanceof Uint8Array&&ee.Buffer.prototype.set.name==="set"?function(t,e,n){e.set(t,n)}:function(t,e,n){if(t.copy)t.copy(e,n,0,t.length);else for(var o=0;o<t.length;)e[n++]=t[o++]}};Mt.prototype.bytes=function(t){ee.isString(t)&&(t=ee._Buffer_from(t,"base64"));var e=t.length>>>0;return this.uint32(e),e&&this._push(Mt.writeBytesBuffer,e,t),this};function Th(r,t,e){r.length<40?ee.utf8.write(r,t,e):t.utf8Write?t.utf8Write(r,e):t.write(r,e)}Mt.prototype.string=function(t){var e=ee.Buffer.byteLength(t);return this.uint32(e),e&&this._push(Th,e,t),this};Mt._configure()});var ka=F((ey,Oa)=>{var Oe=1e3,ke=Oe*60,Pe=ke*60,be=Pe*24,Rh=be*7,_h=be*365.25;Oa.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return Bh(r);if(e==="number"&&isFinite(r))return t.long?Lh(r):Nh(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Bh(r){if(r=String(r),!(r.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(t){var e=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return e*_h;case"weeks":case"week":case"w":return e*Rh;case"days":case"day":case"d":return e*be;case"hours":case"hour":case"hrs":case"hr":case"h":return e*Pe;case"minutes":case"minute":case"mins":case"min":case"m":return e*ke;case"seconds":case"second":case"secs":case"sec":case"s":return e*Oe;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function Nh(r){var t=Math.abs(r);return t>=be?Math.round(r/be)+"d":t>=Pe?Math.round(r/Pe)+"h":t>=ke?Math.round(r/ke)+"m":t>=Oe?Math.round(r/Oe)+"s":r+"ms"}function Lh(r){var t=Math.abs(r);return t>=be?hn(r,t,be,"day"):t>=Pe?hn(r,t,Pe,"hour"):t>=ke?hn(r,t,ke,"minute"):t>=Oe?hn(r,t,Oe,"second"):r+" ms"}function hn(r,t,e,n){var o=t>=e*1.5;return Math.round(r/e)+" "+n+(o?"s":"")}});var yo=F((ry,Pa)=>{function Oh(r){e.debug=e,e.default=e,e.coerce=l,e.disable=i,e.enable=o,e.enabled=s,e.humanize=ka(),e.destroy=m,Object.keys(r).forEach(h=>{e[h]=r[h]}),e.names=[],e.skips=[],e.formatters={};function t(h){let g=0;for(let w=0;w<h.length;w++)g=(g<<5)-g+h.charCodeAt(w),g|=0;return e.colors[Math.abs(g)%e.colors.length]}e.selectColor=t;function e(h){let g,w=null,I,p;function y(...x){if(!y.enabled)return;let v=y,S=Number(new Date),C=S-(g||S);v.diff=C,v.prev=g,v.curr=S,g=S,x[0]=e.coerce(x[0]),typeof x[0]!="string"&&x.unshift("%O");let D=0;x[0]=x[0].replace(/%([a-zA-Z%])/g,(P,B)=>{if(P==="%%")return"%";D++;let O=e.formatters[B];if(typeof O=="function"){let V=x[D];P=O.call(v,V),x.splice(D,1),D--}return P}),e.formatArgs.call(v,x),(v.log||e.log).apply(v,x)}return y.namespace=h,y.useColors=e.useColors(),y.color=e.selectColor(h),y.extend=n,y.destroy=e.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>w!==null?w:(I!==e.namespaces&&(I=e.namespaces,p=e.enabled(h)),p),set:x=>{w=x}}),typeof e.init=="function"&&e.init(y),y}function n(h,g){let w=e(this.namespace+(typeof g>"u"?":":g)+h);return w.log=this.log,w}function o(h){e.save(h),e.namespaces=h,e.names=[],e.skips=[];let g,w=(typeof h=="string"?h:"").split(/[\s,]+/),I=w.length;for(g=0;g<I;g++)w[g]&&(h=w[g].replace(/\*/g,".*?"),h[0]==="-"?e.skips.push(new RegExp("^"+h.slice(1)+"$")):e.names.push(new RegExp("^"+h+"$")))}function i(){let h=[...e.names.map(u),...e.skips.map(u).map(g=>"-"+g)].join(",");return e.enable(""),h}function s(h){if(h[h.length-1]==="*")return!0;let g,w;for(g=0,w=e.skips.length;g<w;g++)if(e.skips[g].test(h))return!1;for(g=0,w=e.names.length;g<w;g++)if(e.names[g].test(h))return!0;return!1}function u(h){return h.toString().substring(2,h.toString().length-2).replace(/\.\*\?$/,"*")}function l(h){return h instanceof Error?h.stack||h.message:h}function m(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return e.enable(e.load()),e}Pa.exports=Oh});var Ua=F((mt,pn)=>{mt.formatArgs=Ph;mt.save=Uh;mt.load=Mh;mt.useColors=kh;mt.storage=Fh();mt.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();mt.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function kh(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Ph(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+pn.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(e++,o==="%c"&&(n=e))}),r.splice(n,0,t)}mt.log=console.debug||console.log||(()=>{});function Uh(r){try{r?mt.storage.setItem("debug",r):mt.storage.removeItem("debug")}catch{}}function Mh(){let r;try{r=mt.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Fh(){try{return localStorage}catch{}}pn.exports=yo()(mt);var{formatters:zh}=pn.exports;zh.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Fa=F((ny,Ma)=>{"use strict";Ma.exports=(r,t)=>{t=t||process.argv;let e=r.startsWith("-")?"":r.length===1?"-":"--",n=t.indexOf(e+r),o=t.indexOf("--");return n!==-1&&(o===-1?!0:n<o)}});var Va=F((oy,za)=>{"use strict";var Vh=Bt("os"),kt=Fa(),ot=process.env,Ue;kt("no-color")||kt("no-colors")||kt("color=false")?Ue=!1:(kt("color")||kt("colors")||kt("color=true")||kt("color=always"))&&(Ue=!0);"FORCE_COLOR"in ot&&(Ue=ot.FORCE_COLOR.length===0||parseInt(ot.FORCE_COLOR,10)!==0);function $h(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Gh(r){if(Ue===!1)return 0;if(kt("color=16m")||kt("color=full")||kt("color=truecolor"))return 3;if(kt("color=256"))return 2;if(r&&!r.isTTY&&Ue!==!0)return 0;let t=Ue?1:0;if(process.platform==="win32"){let e=Vh.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in ot)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in ot)||ot.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in ot)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(ot.TEAMCITY_VERSION)?1:0;if(ot.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in ot){let e=parseInt((ot.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(ot.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(ot.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(ot.TERM)||"COLORTERM"in ot?1:(ot.TERM==="dumb",t)}function wo(r){let t=Gh(r);return $h(t)}za.exports={supportsColor:wo,stdout:wo(process.stdout),stderr:wo(process.stderr)}});var Ga=F((nt,mn)=>{var Hh=Bt("tty"),dn=Bt("util");nt.init=Wh;nt.log=Jh;nt.formatArgs=Kh;nt.save=Yh;nt.load=Xh;nt.useColors=qh;nt.destroy=dn.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");nt.colors=[6,2,3,4,5,1];try{let r=Va();r&&(r.stderr||r).level>=2&&(nt.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}nt.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,t)=>{let e=t.substring(6).toLowerCase().replace(/_([a-z])/g,(o,i)=>i.toUpperCase()),n=process.env[t];return/^(yes|on|true|enabled)$/i.test(n)?n=!0:/^(no|off|false|disabled)$/i.test(n)?n=!1:n==="null"?n=null:n=Number(n),r[e]=n,r},{});function qh(){return"colors"in nt.inspectOpts?!!nt.inspectOpts.colors:Hh.isatty(process.stderr.fd)}function Kh(r){let{namespace:t,useColors:e}=this;if(e){let n=this.color,o="\x1B[3"+(n<8?n:"8;5;"+n),i=` ${o};1m${t} \x1B[0m`;r[0]=i+r[0].split(`
|
|
2
|
+
"use strict";var Libp2PDaemonClient=(()=>{var no=Object.create;var ye=Object.defineProperty;var io=Object.getOwnPropertyDescriptor;var oo=Object.getOwnPropertyNames;var so=Object.getPrototypeOf,co=Object.prototype.hasOwnProperty;var ft=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var $=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),J=(r,t)=>{for(var e in t)ye(r,e,{get:t[e],enumerable:!0})},In=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of oo(t))!co.call(r,n)&&n!==e&&ye(r,n,{get:()=>t[n],enumerable:!(i=io(t,n))||i.enumerable});return r};var Et=(r,t,e)=>(e=r!=null?no(so(r)):{},In(t||!r||!r.__esModule?ye(e,"default",{value:r,enumerable:!0}):e,r)),ao=r=>In(ye({},"__esModule",{value:!0}),r);var Zn=$((wl,Qn)=>{var Kt=1e3,Yt=Kt*60,Wt=Yt*60,Nt=Wt*24,As=Nt*7,Cs=Nt*365.25;Qn.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return Ts(r);if(e==="number"&&isFinite(r))return t.long?vs(r):Ss(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Ts(r){if(r=String(r),!(r.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(t){var e=parseFloat(t[1]),i=(t[2]||"ms").toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return e*Cs;case"weeks":case"week":case"w":return e*As;case"days":case"day":case"d":return e*Nt;case"hours":case"hour":case"hrs":case"hr":case"h":return e*Wt;case"minutes":case"minute":case"mins":case"min":case"m":return e*Yt;case"seconds":case"second":case"secs":case"sec":case"s":return e*Kt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function Ss(r){var t=Math.abs(r);return t>=Nt?Math.round(r/Nt)+"d":t>=Wt?Math.round(r/Wt)+"h":t>=Yt?Math.round(r/Yt)+"m":t>=Kt?Math.round(r/Kt)+"s":r+"ms"}function vs(r){var t=Math.abs(r);return t>=Nt?ke(r,t,Nt,"day"):t>=Wt?ke(r,t,Wt,"hour"):t>=Yt?ke(r,t,Yt,"minute"):t>=Kt?ke(r,t,Kt,"second"):r+" ms"}function ke(r,t,e,i){var n=t>=e*1.5;return Math.round(r/e)+" "+i+(n?"s":"")}});var Fr=$((xl,qn)=>{function Rs(r){e.debug=e,e.default=e,e.coerce=a,e.disable=o,e.enable=n,e.enabled=s,e.humanize=Zn(),e.destroy=p,Object.keys(r).forEach(u=>{e[u]=r[u]}),e.names=[],e.skips=[],e.formatters={};function t(u){let d=0;for(let h=0;h<u.length;h++)d=(d<<5)-d+u.charCodeAt(h),d|=0;return e.colors[Math.abs(d)%e.colors.length]}e.selectColor=t;function e(u){let d,h=null,w,g;function x(...y){if(!x.enabled)return;let E=x,C=Number(new Date),L=C-(d||C);E.diff=L,E.prev=d,E.curr=C,d=C,y[0]=e.coerce(y[0]),typeof y[0]!="string"&&y.unshift("%O");let P=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,(q,X)=>{if(q==="%%")return"%";P++;let j=e.formatters[X];if(typeof j=="function"){let Bt=y[P];q=j.call(E,Bt),y.splice(P,1),P--}return q}),e.formatArgs.call(E,y),(E.log||e.log).apply(E,y)}return x.namespace=u,x.useColors=e.useColors(),x.color=e.selectColor(u),x.extend=i,x.destroy=e.destroy,Object.defineProperty(x,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(w!==e.namespaces&&(w=e.namespaces,g=e.enabled(u)),g),set:y=>{h=y}}),typeof e.init=="function"&&e.init(x),x}function i(u,d){let h=e(this.namespace+(typeof d>"u"?":":d)+u);return h.log=this.log,h}function n(u){e.save(u),e.namespaces=u,e.names=[],e.skips=[];let d,h=(typeof u=="string"?u:"").split(/[\s,]+/),w=h.length;for(d=0;d<w;d++)h[d]&&(u=h[d].replace(/\*/g,".*?"),u[0]==="-"?e.skips.push(new RegExp("^"+u.slice(1)+"$")):e.names.push(new RegExp("^"+u+"$")))}function o(){let u=[...e.names.map(c),...e.skips.map(c).map(d=>"-"+d)].join(",");return e.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let d,h;for(d=0,h=e.skips.length;d<h;d++)if(e.skips[d].test(u))return!1;for(d=0,h=e.names.length;d<h;d++)if(e.names[d].test(u))return!0;return!1}function c(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function a(u){return u instanceof Error?u.stack||u.message:u}function p(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return e.enable(e.load()),e}qn.exports=Rs});var jn=$((Q,Ue)=>{Q.formatArgs=_s;Q.save=Ls;Q.load=Ns;Q.useColors=Ds;Q.storage=Ps();Q.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Q.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Ds(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function _s(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Ue.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,i=0;r[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(e++,n==="%c"&&(i=e))}),r.splice(i,0,t)}Q.log=console.debug||console.log||(()=>{});function Ls(r){try{r?Q.storage.setItem("debug",r):Q.storage.removeItem("debug")}catch{}}function Ns(){let r;try{r=Q.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Ps(){try{return localStorage}catch{}}Ue.exports=Fr()(Q);var{formatters:Os}=Ue.exports;Os.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var ei=$((Il,ti)=>{"use strict";ti.exports=(r,t)=>{t=t||process.argv;let e=r.startsWith("-")?"":r.length===1?"-":"--",i=t.indexOf(e+r),n=t.indexOf("--");return i!==-1&&(n===-1?!0:i<n)}});var ni=$((Al,ri)=>{"use strict";var ks=ft("os"),at=ei(),B=process.env,Xt;at("no-color")||at("no-colors")||at("color=false")?Xt=!1:(at("color")||at("colors")||at("color=true")||at("color=always"))&&(Xt=!0);"FORCE_COLOR"in B&&(Xt=B.FORCE_COLOR.length===0||parseInt(B.FORCE_COLOR,10)!==0);function Us(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Fs(r){if(Xt===!1)return 0;if(at("color=16m")||at("color=full")||at("color=truecolor"))return 3;if(at("color=256"))return 2;if(r&&!r.isTTY&&Xt!==!0)return 0;let t=Xt?1:0;if(process.platform==="win32"){let e=ks.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in B)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in B)||B.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in B)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(B.TEAMCITY_VERSION)?1:0;if(B.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in B){let e=parseInt((B.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(B.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(B.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(B.TERM)||"COLORTERM"in B?1:(B.TERM==="dumb",t)}function Br(r){let t=Fs(r);return Us(t)}ri.exports={supportsColor:Br,stdout:Br(process.stdout),stderr:Br(process.stderr)}});var oi=$((k,Be)=>{var Bs=ft("tty"),Fe=ft("util");k.init=Ks;k.log=$s;k.formatArgs=Vs;k.save=zs;k.load=Hs;k.useColors=Ms;k.destroy=Fe.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");k.colors=[6,2,3,4,5,1];try{let r=ni();r&&(r.stderr||r).level>=2&&(k.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}k.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,t)=>{let e=t.substring(6).toLowerCase().replace(/_([a-z])/g,(n,o)=>o.toUpperCase()),i=process.env[t];return/^(yes|on|true|enabled)$/i.test(i)?i=!0:/^(no|off|false|disabled)$/i.test(i)?i=!1:i==="null"?i=null:i=Number(i),r[e]=i,r},{});function Ms(){return"colors"in k.inspectOpts?!!k.inspectOpts.colors:Bs.isatty(process.stderr.fd)}function Vs(r){let{namespace:t,useColors:e}=this;if(e){let i=this.color,n="\x1B[3"+(i<8?i:"8;5;"+i),o=` ${n};1m${t} \x1B[0m`;r[0]=o+r[0].split(`
|
|
3
3
|
`).join(`
|
|
4
|
-
`+
|
|
5
|
-
`)}function
|
|
6
|
-
`).map(t=>t.trim()).join(" ")};$a.O=function(r){return this.inspectOpts.colors=this.useColors,dn.inspect(r,this.inspectOpts)}});var Ha=F((iy,Eo)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Eo.exports=Ua():Eo.exports=Ga()});var sc=F((dw,ic)=>{"use strict";function oc(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function dp(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return oc(r,e)}catch{e.message=r.message,e.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),oc(new o,e)}}ic.exports=dp});var hf=F((x1,lf)=>{lf.exports=_i;var uf=128,b0=127,y0=~b0,w0=Math.pow(2,31);function _i(r,t,e){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw _i.bytes=0,new RangeError("Could not encode varint");t=t||[],e=e||0;for(var n=e;r>=w0;)t[e++]=r&255|uf,r/=128;for(;r&y0;)t[e++]=r&255|uf,r>>>=7;return t[e]=r|0,_i.bytes=e-n+1,t}});var mf=F((S1,df)=>{df.exports=Bi;var E0=128,pf=127;function Bi(r,n){var e=0,n=n||0,o=0,i=n,s,u=r.length;do{if(i>=u||o>49)throw Bi.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&pf)<<o:(s&pf)*Math.pow(2,o),o+=7}while(s>=E0);return Bi.bytes=i-n,e}});var bf=F((A1,gf)=>{var v0=Math.pow(2,7),x0=Math.pow(2,14),S0=Math.pow(2,21),A0=Math.pow(2,28),T0=Math.pow(2,35),I0=Math.pow(2,42),C0=Math.pow(2,49),D0=Math.pow(2,56),R0=Math.pow(2,63);gf.exports=function(r){return r<v0?1:r<x0?2:r<S0?3:r<A0?4:r<T0?5:r<I0?6:r<C0?7:r<D0?8:r<R0?9:10}});var Ni=F((T1,yf)=>{yf.exports={encode:hf(),decode:mf(),encodingLength:bf()}});var us=F((zn,Jf)=>{(function(){var r,t=0xdeadbeefcafe,e=(t&16777215)==15715070;function n(a,c,f){a!=null&&(typeof a=="number"?this.fromNumber(a,c,f):c==null&&typeof a!="string"?this.fromString(a,256):this.fromString(a,c))}function o(){return new n(null)}function i(a,c,f,d,b,E){for(;--E>=0;){var T=c*this[a++]+f[d]+b;b=Math.floor(T/67108864),f[d++]=T&67108863}return b}function s(a,c,f,d,b,E){for(var T=c&32767,_=c>>15;--E>=0;){var G=this[a]&32767,et=this[a++]>>15,Et=_*G+et*T;G=T*G+((Et&32767)<<15)+f[d]+(b&1073741823),b=(G>>>30)+(Et>>>15)+_*et+(b>>>30),f[d++]=G&1073741823}return b}function u(a,c,f,d,b,E){for(var T=c&16383,_=c>>14;--E>=0;){var G=this[a]&16383,et=this[a++]>>14,Et=_*G+et*T;G=T*G+((Et&16383)<<14)+f[d]+b,b=(G>>28)+(Et>>14)+_*et,f[d++]=G&268435455}return b}var l=typeof navigator<"u";l&&e&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=s,r=30):l&&e&&navigator.appName!="Netscape"?(n.prototype.am=i,r=26):(n.prototype.am=u,r=28),n.prototype.DB=r,n.prototype.DM=(1<<r)-1,n.prototype.DV=1<<r;var m=52;n.prototype.FV=Math.pow(2,m),n.prototype.F1=m-r,n.prototype.F2=2*r-m;var h="0123456789abcdefghijklmnopqrstuvwxyz",g=new Array,w,I;for(w="0".charCodeAt(0),I=0;I<=9;++I)g[w++]=I;for(w="a".charCodeAt(0),I=10;I<36;++I)g[w++]=I;for(w="A".charCodeAt(0),I=10;I<36;++I)g[w++]=I;function p(a){return h.charAt(a)}function y(a,c){var f=g[a.charCodeAt(c)];return f??-1}function x(a){for(var c=this.t-1;c>=0;--c)a[c]=this[c];a.t=this.t,a.s=this.s}function v(a){this.t=1,this.s=a<0?-1:0,a>0?this[0]=a:a<-1?this[0]=a+this.DV:this.t=0}function S(a){var c=o();return c.fromInt(a),c}function C(a,c){var f;if(c==16)f=4;else if(c==8)f=3;else if(c==256)f=8;else if(c==2)f=1;else if(c==32)f=5;else if(c==4)f=2;else{this.fromRadix(a,c);return}this.t=0,this.s=0;for(var d=a.length,b=!1,E=0;--d>=0;){var T=f==8?a[d]&255:y(a,d);if(T<0){a.charAt(d)=="-"&&(b=!0);continue}b=!1,E==0?this[this.t++]=T:E+f>this.DB?(this[this.t-1]|=(T&(1<<this.DB-E)-1)<<E,this[this.t++]=T>>this.DB-E):this[this.t-1]|=T<<E,E+=f,E>=this.DB&&(E-=this.DB)}f==8&&a[0]&128&&(this.s=-1,E>0&&(this[this.t-1]|=(1<<this.DB-E)-1<<E)),this.clamp(),b&&n.ZERO.subTo(this,this)}function D(){for(var a=this.s&this.DM;this.t>0&&this[this.t-1]==a;)--this.t}function N(a){if(this.s<0)return"-"+this.negate().toString(a);var c;if(a==16)c=4;else if(a==8)c=3;else if(a==2)c=1;else if(a==32)c=5;else if(a==4)c=2;else return this.toRadix(a);var f=(1<<c)-1,d,b=!1,E="",T=this.t,_=this.DB-T*this.DB%c;if(T-- >0)for(_<this.DB&&(d=this[T]>>_)>0&&(b=!0,E=p(d));T>=0;)_<c?(d=(this[T]&(1<<_)-1)<<c-_,d|=this[--T]>>(_+=this.DB-c)):(d=this[T]>>(_-=c)&f,_<=0&&(_+=this.DB,--T)),d>0&&(b=!0),b&&(E+=p(d));return b?E:"0"}function P(){var a=o();return n.ZERO.subTo(this,a),a}function B(){return this.s<0?this.negate():this}function O(a){var c=this.s-a.s;if(c!=0)return c;var f=this.t;if(c=f-a.t,c!=0)return this.s<0?-c:c;for(;--f>=0;)if((c=this[f]-a[f])!=0)return c;return 0}function V(a){var c=1,f;return(f=a>>>16)!=0&&(a=f,c+=16),(f=a>>8)!=0&&(a=f,c+=8),(f=a>>4)!=0&&(a=f,c+=4),(f=a>>2)!=0&&(a=f,c+=2),(f=a>>1)!=0&&(a=f,c+=1),c}function Nu(){return this.t<=0?0:this.DB*(this.t-1)+V(this[this.t-1]^this.s&this.DM)}function Lu(a,c){var f;for(f=this.t-1;f>=0;--f)c[f+a]=this[f];for(f=a-1;f>=0;--f)c[f]=0;c.t=this.t+a,c.s=this.s}function Ou(a,c){for(var f=a;f<this.t;++f)c[f-a]=this[f];c.t=Math.max(this.t-a,0),c.s=this.s}function ku(a,c){var f=a%this.DB,d=this.DB-f,b=(1<<d)-1,E=Math.floor(a/this.DB),T=this.s<<f&this.DM,_;for(_=this.t-1;_>=0;--_)c[_+E+1]=this[_]>>d|T,T=(this[_]&b)<<f;for(_=E-1;_>=0;--_)c[_]=0;c[E]=T,c.t=this.t+E+1,c.s=this.s,c.clamp()}function Pu(a,c){c.s=this.s;var f=Math.floor(a/this.DB);if(f>=this.t){c.t=0;return}var d=a%this.DB,b=this.DB-d,E=(1<<d)-1;c[0]=this[f]>>d;for(var T=f+1;T<this.t;++T)c[T-f-1]|=(this[T]&E)<<b,c[T-f]=this[T]>>d;d>0&&(c[this.t-f-1]|=(this.s&E)<<b),c.t=this.t-f,c.clamp()}function Uu(a,c){for(var f=0,d=0,b=Math.min(a.t,this.t);f<b;)d+=this[f]-a[f],c[f++]=d&this.DM,d>>=this.DB;if(a.t<this.t){for(d-=a.s;f<this.t;)d+=this[f],c[f++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;f<a.t;)d-=a[f],c[f++]=d&this.DM,d>>=this.DB;d-=a.s}c.s=d<0?-1:0,d<-1?c[f++]=this.DV+d:d>0&&(c[f++]=d),c.t=f,c.clamp()}function Mu(a,c){var f=this.abs(),d=a.abs(),b=f.t;for(c.t=b+d.t;--b>=0;)c[b]=0;for(b=0;b<d.t;++b)c[b+f.t]=f.am(0,d[b],c,b,0,f.t);c.s=0,c.clamp(),this.s!=a.s&&n.ZERO.subTo(c,c)}function Fu(a){for(var c=this.abs(),f=a.t=2*c.t;--f>=0;)a[f]=0;for(f=0;f<c.t-1;++f){var d=c.am(f,c[f],a,2*f,0,1);(a[f+c.t]+=c.am(f+1,2*c[f],a,2*f+1,d,c.t-f-1))>=c.DV&&(a[f+c.t]-=c.DV,a[f+c.t+1]=1)}a.t>0&&(a[a.t-1]+=c.am(f,c[f],a,2*f,0,1)),a.s=0,a.clamp()}function zu(a,c,f){var d=a.abs();if(!(d.t<=0)){var b=this.abs();if(b.t<d.t){c?.fromInt(0),f!=null&&this.copyTo(f);return}f==null&&(f=o());var E=o(),T=this.s,_=a.s,G=this.DB-V(d[d.t-1]);G>0?(d.lShiftTo(G,E),b.lShiftTo(G,f)):(d.copyTo(E),b.copyTo(f));var et=E.t,Et=E[et-1];if(Et!=0){var dt=Et*(1<<this.F1)+(et>1?E[et-2]>>this.F2:0),qt=this.FV/dt,Kr=(1<<this.F1)/dt,Rt=1<<this.F2,_t=f.t,jr=_t-et,Qt=c??o();for(E.dlShiftTo(jr,Qt),f.compareTo(Qt)>=0&&(f[f.t++]=1,f.subTo(Qt,f)),n.ONE.dlShiftTo(et,Qt),Qt.subTo(E,E);E.t<et;)E[E.t++]=0;for(;--jr>=0;){var to=f[--_t]==Et?this.DM:Math.floor(f[_t]*qt+(f[_t-1]+Rt)*Kr);if((f[_t]+=E.am(0,to,f,jr,0,et))<to)for(E.dlShiftTo(jr,Qt),f.subTo(Qt,f);f[_t]<--to;)f.subTo(Qt,f)}c!=null&&(f.drShiftTo(et,c),T!=_&&n.ZERO.subTo(c,c)),f.t=et,f.clamp(),G>0&&f.rShiftTo(G,f),T<0&&n.ZERO.subTo(f,f)}}}function Vu(a){var c=o();return this.abs().divRemTo(a,null,c),this.s<0&&c.compareTo(n.ZERO)>0&&a.subTo(c,c),c}function le(a){this.m=a}function $u(a){return a.s<0||a.compareTo(this.m)>=0?a.mod(this.m):a}function Gu(a){return a}function Hu(a){a.divRemTo(this.m,null,a)}function qu(a,c,f){a.multiplyTo(c,f),this.reduce(f)}function Ku(a,c){a.squareTo(c),this.reduce(c)}le.prototype.convert=$u,le.prototype.revert=Gu,le.prototype.reduce=Hu,le.prototype.mulTo=qu,le.prototype.sqrTo=Ku;function ju(){if(this.t<1)return 0;var a=this[0];if(!(a&1))return 0;var c=a&3;return c=c*(2-(a&15)*c)&15,c=c*(2-(a&255)*c)&255,c=c*(2-((a&65535)*c&65535))&65535,c=c*(2-a*c%this.DV)%this.DV,c>0?this.DV-c:-c}function he(a){this.m=a,this.mp=a.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<a.DB-15)-1,this.mt2=2*a.t}function Ju(a){var c=o();return a.abs().dlShiftTo(this.m.t,c),c.divRemTo(this.m,null,c),a.s<0&&c.compareTo(n.ZERO)>0&&this.m.subTo(c,c),c}function Yu(a){var c=o();return a.copyTo(c),this.reduce(c),c}function Xu(a){for(;a.t<=this.mt2;)a[a.t++]=0;for(var c=0;c<this.m.t;++c){var f=a[c]&32767,d=f*this.mpl+((f*this.mph+(a[c]>>15)*this.mpl&this.um)<<15)&a.DM;for(f=c+this.m.t,a[f]+=this.m.am(0,d,a,c,0,this.m.t);a[f]>=a.DV;)a[f]-=a.DV,a[++f]++}a.clamp(),a.drShiftTo(this.m.t,a),a.compareTo(this.m)>=0&&a.subTo(this.m,a)}function Wu(a,c){a.squareTo(c),this.reduce(c)}function Zu(a,c,f){a.multiplyTo(c,f),this.reduce(f)}he.prototype.convert=Ju,he.prototype.revert=Yu,he.prototype.reduce=Xu,he.prototype.mulTo=Zu,he.prototype.sqrTo=Wu;function Qu(){return(this.t>0?this[0]&1:this.s)==0}function tl(a,c){if(a>4294967295||a<1)return n.ONE;var f=o(),d=o(),b=c.convert(this),E=V(a)-1;for(b.copyTo(f);--E>=0;)if(c.sqrTo(f,d),(a&1<<E)>0)c.mulTo(d,b,f);else{var T=f;f=d,d=T}return c.revert(f)}function el(a,c){var f;return a<256||c.isEven()?f=new le(c):f=new he(c),this.exp(a,f)}n.prototype.copyTo=x,n.prototype.fromInt=v,n.prototype.fromString=C,n.prototype.clamp=D,n.prototype.dlShiftTo=Lu,n.prototype.drShiftTo=Ou,n.prototype.lShiftTo=ku,n.prototype.rShiftTo=Pu,n.prototype.subTo=Uu,n.prototype.multiplyTo=Mu,n.prototype.squareTo=Fu,n.prototype.divRemTo=zu,n.prototype.invDigit=ju,n.prototype.isEven=Qu,n.prototype.exp=tl,n.prototype.toString=N,n.prototype.negate=P,n.prototype.abs=B,n.prototype.compareTo=O,n.prototype.bitLength=Nu,n.prototype.mod=Vu,n.prototype.modPowInt=el,n.ZERO=S(0),n.ONE=S(1);function rl(){var a=o();return this.copyTo(a),a}function nl(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}function ol(){return this.t==0?this.s:this[0]<<24>>24}function il(){return this.t==0?this.s:this[0]<<16>>16}function sl(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function al(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function cl(a){if(a==null&&(a=10),this.signum()==0||a<2||a>36)return"0";var c=this.chunkSize(a),f=Math.pow(a,c),d=S(f),b=o(),E=o(),T="";for(this.divRemTo(d,b,E);b.signum()>0;)T=(f+E.intValue()).toString(a).substr(1)+T,b.divRemTo(d,b,E);return E.intValue().toString(a)+T}function fl(a,c){this.fromInt(0),c==null&&(c=10);for(var f=this.chunkSize(c),d=Math.pow(c,f),b=!1,E=0,T=0,_=0;_<a.length;++_){var G=y(a,_);if(G<0){a.charAt(_)=="-"&&this.signum()==0&&(b=!0);continue}T=c*T+G,++E>=f&&(this.dMultiply(d),this.dAddOffset(T,0),E=0,T=0)}E>0&&(this.dMultiply(Math.pow(c,E)),this.dAddOffset(T,0)),b&&n.ZERO.subTo(this,this)}function ul(a,c,f){if(typeof c=="number")if(a<2)this.fromInt(1);else for(this.fromNumber(a,f),this.testBit(a-1)||this.bitwiseTo(n.ONE.shiftLeft(a-1),Xn,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(c);)this.dAddOffset(2,0),this.bitLength()>a&&this.subTo(n.ONE.shiftLeft(a-1),this);else{var d=new Array,b=a&7;d.length=(a>>3)+1,c.nextBytes(d),b>0?d[0]&=(1<<b)-1:d[0]=0,this.fromString(d,256)}}function ll(){var a=this.t,c=new Array;c[0]=this.s;var f=this.DB-a*this.DB%8,d,b=0;if(a-- >0)for(f<this.DB&&(d=this[a]>>f)!=(this.s&this.DM)>>f&&(c[b++]=d|this.s<<this.DB-f);a>=0;)f<8?(d=(this[a]&(1<<f)-1)<<8-f,d|=this[--a]>>(f+=this.DB-8)):(d=this[a]>>(f-=8)&255,f<=0&&(f+=this.DB,--a)),d&128&&(d|=-256),b==0&&(this.s&128)!=(d&128)&&++b,(b>0||d!=this.s)&&(c[b++]=d);return c}function hl(a){return this.compareTo(a)==0}function pl(a){return this.compareTo(a)<0?this:a}function dl(a){return this.compareTo(a)>0?this:a}function ml(a,c,f){var d,b,E=Math.min(a.t,this.t);for(d=0;d<E;++d)f[d]=c(this[d],a[d]);if(a.t<this.t){for(b=a.s&this.DM,d=E;d<this.t;++d)f[d]=c(this[d],b);f.t=this.t}else{for(b=this.s&this.DM,d=E;d<a.t;++d)f[d]=c(b,a[d]);f.t=a.t}f.s=c(this.s,a.s),f.clamp()}function gl(a,c){return a&c}function bl(a){var c=o();return this.bitwiseTo(a,gl,c),c}function Xn(a,c){return a|c}function yl(a){var c=o();return this.bitwiseTo(a,Xn,c),c}function Us(a,c){return a^c}function wl(a){var c=o();return this.bitwiseTo(a,Us,c),c}function Ms(a,c){return a&~c}function El(a){var c=o();return this.bitwiseTo(a,Ms,c),c}function vl(){for(var a=o(),c=0;c<this.t;++c)a[c]=this.DM&~this[c];return a.t=this.t,a.s=~this.s,a}function xl(a){var c=o();return a<0?this.rShiftTo(-a,c):this.lShiftTo(a,c),c}function Sl(a){var c=o();return a<0?this.lShiftTo(-a,c):this.rShiftTo(a,c),c}function Al(a){if(a==0)return-1;var c=0;return a&65535||(a>>=16,c+=16),a&255||(a>>=8,c+=8),a&15||(a>>=4,c+=4),a&3||(a>>=2,c+=2),a&1||++c,c}function Tl(){for(var a=0;a<this.t;++a)if(this[a]!=0)return a*this.DB+Al(this[a]);return this.s<0?this.t*this.DB:-1}function Il(a){for(var c=0;a!=0;)a&=a-1,++c;return c}function Cl(){for(var a=0,c=this.s&this.DM,f=0;f<this.t;++f)a+=Il(this[f]^c);return a}function Dl(a){var c=Math.floor(a/this.DB);return c>=this.t?this.s!=0:(this[c]&1<<a%this.DB)!=0}function Rl(a,c){var f=n.ONE.shiftLeft(a);return this.bitwiseTo(f,c,f),f}function _l(a){return this.changeBit(a,Xn)}function Bl(a){return this.changeBit(a,Ms)}function Nl(a){return this.changeBit(a,Us)}function Ll(a,c){for(var f=0,d=0,b=Math.min(a.t,this.t);f<b;)d+=this[f]+a[f],c[f++]=d&this.DM,d>>=this.DB;if(a.t<this.t){for(d+=a.s;f<this.t;)d+=this[f],c[f++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;f<a.t;)d+=a[f],c[f++]=d&this.DM,d>>=this.DB;d+=a.s}c.s=d<0?-1:0,d>0?c[f++]=d:d<-1&&(c[f++]=this.DV+d),c.t=f,c.clamp()}function Ol(a){var c=o();return this.addTo(a,c),c}function kl(a){var c=o();return this.subTo(a,c),c}function Pl(a){var c=o();return this.multiplyTo(a,c),c}function Ul(){var a=o();return this.squareTo(a),a}function Ml(a){var c=o();return this.divRemTo(a,c,null),c}function Fl(a){var c=o();return this.divRemTo(a,null,c),c}function zl(a){var c=o(),f=o();return this.divRemTo(a,c,f),new Array(c,f)}function Vl(a){this[this.t]=this.am(0,a-1,this,0,0,this.t),++this.t,this.clamp()}function $l(a,c){if(a!=0){for(;this.t<=c;)this[this.t++]=0;for(this[c]+=a;this[c]>=this.DV;)this[c]-=this.DV,++c>=this.t&&(this[this.t++]=0),++this[c]}}function br(){}function Fs(a){return a}function Gl(a,c,f){a.multiplyTo(c,f)}function Hl(a,c){a.squareTo(c)}br.prototype.convert=Fs,br.prototype.revert=Fs,br.prototype.mulTo=Gl,br.prototype.sqrTo=Hl;function ql(a){return this.exp(a,new br)}function Kl(a,c,f){var d=Math.min(this.t+a.t,c);for(f.s=0,f.t=d;d>0;)f[--d]=0;var b;for(b=f.t-this.t;d<b;++d)f[d+this.t]=this.am(0,a[d],f,d,0,this.t);for(b=Math.min(a.t,c);d<b;++d)this.am(0,a[d],f,d,0,c-d);f.clamp()}function jl(a,c,f){--c;var d=f.t=this.t+a.t-c;for(f.s=0;--d>=0;)f[d]=0;for(d=Math.max(c-this.t,0);d<a.t;++d)f[this.t+d-c]=this.am(c-d,a[d],f,0,0,this.t+d-c);f.clamp(),f.drShiftTo(1,f)}function pe(a){this.r2=o(),this.q3=o(),n.ONE.dlShiftTo(2*a.t,this.r2),this.mu=this.r2.divide(a),this.m=a}function Jl(a){if(a.s<0||a.t>2*this.m.t)return a.mod(this.m);if(a.compareTo(this.m)<0)return a;var c=o();return a.copyTo(c),this.reduce(c),c}function Yl(a){return a}function Xl(a){for(a.drShiftTo(this.m.t-1,this.r2),a.t>this.m.t+1&&(a.t=this.m.t+1,a.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);a.compareTo(this.r2)<0;)a.dAddOffset(1,this.m.t+1);for(a.subTo(this.r2,a);a.compareTo(this.m)>=0;)a.subTo(this.m,a)}function Wl(a,c){a.squareTo(c),this.reduce(c)}function Zl(a,c,f){a.multiplyTo(c,f),this.reduce(f)}pe.prototype.convert=Jl,pe.prototype.revert=Yl,pe.prototype.reduce=Xl,pe.prototype.mulTo=Zl,pe.prototype.sqrTo=Wl;function Ql(a,c){var f=a.bitLength(),d,b=S(1),E;if(f<=0)return b;f<18?d=1:f<48?d=3:f<144?d=4:f<768?d=5:d=6,f<8?E=new le(c):c.isEven()?E=new pe(c):E=new he(c);var T=new Array,_=3,G=d-1,et=(1<<d)-1;if(T[1]=E.convert(this),d>1){var Et=o();for(E.sqrTo(T[1],Et);_<=et;)T[_]=o(),E.mulTo(Et,T[_-2],T[_]),_+=2}var dt=a.t-1,qt,Kr=!0,Rt=o(),_t;for(f=V(a[dt])-1;dt>=0;){for(f>=G?qt=a[dt]>>f-G&et:(qt=(a[dt]&(1<<f+1)-1)<<G-f,dt>0&&(qt|=a[dt-1]>>this.DB+f-G)),_=d;!(qt&1);)qt>>=1,--_;if((f-=_)<0&&(f+=this.DB,--dt),Kr)T[qt].copyTo(b),Kr=!1;else{for(;_>1;)E.sqrTo(b,Rt),E.sqrTo(Rt,b),_-=2;_>0?E.sqrTo(b,Rt):(_t=b,b=Rt,Rt=_t),E.mulTo(Rt,T[qt],b)}for(;dt>=0&&!(a[dt]&1<<f);)E.sqrTo(b,Rt),_t=b,b=Rt,Rt=_t,--f<0&&(f=this.DB-1,--dt)}return E.revert(b)}function th(a){var c=this.s<0?this.negate():this.clone(),f=a.s<0?a.negate():a.clone();if(c.compareTo(f)<0){var d=c;c=f,f=d}var b=c.getLowestSetBit(),E=f.getLowestSetBit();if(E<0)return c;for(b<E&&(E=b),E>0&&(c.rShiftTo(E,c),f.rShiftTo(E,f));c.signum()>0;)(b=c.getLowestSetBit())>0&&c.rShiftTo(b,c),(b=f.getLowestSetBit())>0&&f.rShiftTo(b,f),c.compareTo(f)>=0?(c.subTo(f,c),c.rShiftTo(1,c)):(f.subTo(c,f),f.rShiftTo(1,f));return E>0&&f.lShiftTo(E,f),f}function eh(a){if(a<=0)return 0;var c=this.DV%a,f=this.s<0?a-1:0;if(this.t>0)if(c==0)f=this[0]%a;else for(var d=this.t-1;d>=0;--d)f=(c*f+this[d])%a;return f}function rh(a){var c=a.isEven();if(this.isEven()&&c||a.signum()==0)return n.ZERO;for(var f=a.clone(),d=this.clone(),b=S(1),E=S(0),T=S(0),_=S(1);f.signum()!=0;){for(;f.isEven();)f.rShiftTo(1,f),c?((!b.isEven()||!E.isEven())&&(b.addTo(this,b),E.subTo(a,E)),b.rShiftTo(1,b)):E.isEven()||E.subTo(a,E),E.rShiftTo(1,E);for(;d.isEven();)d.rShiftTo(1,d),c?((!T.isEven()||!_.isEven())&&(T.addTo(this,T),_.subTo(a,_)),T.rShiftTo(1,T)):_.isEven()||_.subTo(a,_),_.rShiftTo(1,_);f.compareTo(d)>=0?(f.subTo(d,f),c&&b.subTo(T,b),E.subTo(_,E)):(d.subTo(f,d),c&&T.subTo(b,T),_.subTo(E,_))}if(d.compareTo(n.ONE)!=0)return n.ZERO;if(_.compareTo(a)>=0)return _.subtract(a);if(_.signum()<0)_.addTo(a,_);else return _;return _.signum()<0?_.add(a):_}var ft=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],nh=(1<<26)/ft[ft.length-1];function oh(a){var c,f=this.abs();if(f.t==1&&f[0]<=ft[ft.length-1]){for(c=0;c<ft.length;++c)if(f[0]==ft[c])return!0;return!1}if(f.isEven())return!1;for(c=1;c<ft.length;){for(var d=ft[c],b=c+1;b<ft.length&&d<nh;)d*=ft[b++];for(d=f.modInt(d);c<b;)if(d%ft[c++]==0)return!1}return f.millerRabin(a)}function ih(a){var c=this.subtract(n.ONE),f=c.getLowestSetBit();if(f<=0)return!1;var d=c.shiftRight(f);a=a+1>>1,a>ft.length&&(a=ft.length);for(var b=o(),E=0;E<a;++E){b.fromInt(ft[Math.floor(Math.random()*ft.length)]);var T=b.modPow(d,this);if(T.compareTo(n.ONE)!=0&&T.compareTo(c)!=0){for(var _=1;_++<f&&T.compareTo(c)!=0;)if(T=T.modPowInt(2,this),T.compareTo(n.ONE)==0)return!1;if(T.compareTo(c)!=0)return!1}}return!0}n.prototype.chunkSize=sl,n.prototype.toRadix=cl,n.prototype.fromRadix=fl,n.prototype.fromNumber=ul,n.prototype.bitwiseTo=ml,n.prototype.changeBit=Rl,n.prototype.addTo=Ll,n.prototype.dMultiply=Vl,n.prototype.dAddOffset=$l,n.prototype.multiplyLowerTo=Kl,n.prototype.multiplyUpperTo=jl,n.prototype.modInt=eh,n.prototype.millerRabin=ih,n.prototype.clone=rl,n.prototype.intValue=nl,n.prototype.byteValue=ol,n.prototype.shortValue=il,n.prototype.signum=al,n.prototype.toByteArray=ll,n.prototype.equals=hl,n.prototype.min=pl,n.prototype.max=dl,n.prototype.and=bl,n.prototype.or=yl,n.prototype.xor=wl,n.prototype.andNot=El,n.prototype.not=vl,n.prototype.shiftLeft=xl,n.prototype.shiftRight=Sl,n.prototype.getLowestSetBit=Tl,n.prototype.bitCount=Cl,n.prototype.testBit=Dl,n.prototype.setBit=_l,n.prototype.clearBit=Bl,n.prototype.flipBit=Nl,n.prototype.add=Ol,n.prototype.subtract=kl,n.prototype.multiply=Pl,n.prototype.divide=Ml,n.prototype.remainder=Fl,n.prototype.divideAndRemainder=zl,n.prototype.modPow=Ql,n.prototype.modInverse=rh,n.prototype.pow=ql,n.prototype.gcd=th,n.prototype.isProbablePrime=oh,n.prototype.square=Ul,n.prototype.Barrett=pe;var qr,pt,tt;function sh(a){pt[tt++]^=a&255,pt[tt++]^=a>>8&255,pt[tt++]^=a>>16&255,pt[tt++]^=a>>24&255,tt>=Qn&&(tt-=Qn)}function zs(){sh(new Date().getTime())}if(pt==null){pt=new Array,tt=0;var Dt;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var Vs=new Uint8Array(32);for(window.crypto.getRandomValues(Vs),Dt=0;Dt<32;++Dt)pt[tt++]=Vs[Dt]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var $s=window.crypto.random(32);for(Dt=0;Dt<$s.length;++Dt)pt[tt++]=$s.charCodeAt(Dt)&255}}for(;tt<Qn;)Dt=Math.floor(65536*Math.random()),pt[tt++]=Dt>>>8,pt[tt++]=Dt&255;tt=0,zs()}function ah(){if(qr==null){for(zs(),qr=lh(),qr.init(pt),tt=0;tt<pt.length;++tt)pt[tt]=0;tt=0}return qr.next()}function ch(a){var c;for(c=0;c<a.length;++c)a[c]=ah()}function Wn(){}Wn.prototype.nextBytes=ch;function Zn(){this.i=0,this.j=0,this.S=new Array}function fh(a){var c,f,d;for(c=0;c<256;++c)this.S[c]=c;for(f=0,c=0;c<256;++c)f=f+this.S[c]+a[c%a.length]&255,d=this.S[c],this.S[c]=this.S[f],this.S[f]=d;this.i=0,this.j=0}function uh(){var a;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,a=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=a,this.S[a+this.S[this.i]&255]}Zn.prototype.init=fh,Zn.prototype.next=uh;function lh(){return new Zn}var Qn=256;typeof zn<"u"?zn=Jf.exports={default:n,BigInteger:n,SecureRandom:Wn}:this.jsbn={BigInteger:n,SecureRandom:Wn}}).call(zn)});var Mr=F(Vn=>{(function(){"use strict";var r={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function t(s){return n(i(s),arguments)}function e(s,u){return t.apply(null,[s].concat(u||[]))}function n(s,u){var l=1,m=s.length,h,g="",w,I,p,y,x,v,S,C;for(w=0;w<m;w++)if(typeof s[w]=="string")g+=s[w];else if(typeof s[w]=="object"){if(p=s[w],p.keys)for(h=u[l],I=0;I<p.keys.length;I++){if(h==null)throw new Error(t('[sprintf] Cannot access property "%s" of undefined value "%s"',p.keys[I],p.keys[I-1]));h=h[p.keys[I]]}else p.param_no?h=u[p.param_no]:h=u[l++];if(r.not_type.test(p.type)&&r.not_primitive.test(p.type)&&h instanceof Function&&(h=h()),r.numeric_arg.test(p.type)&&typeof h!="number"&&isNaN(h))throw new TypeError(t("[sprintf] expecting number but found %T",h));switch(r.number.test(p.type)&&(S=h>=0),p.type){case"b":h=parseInt(h,10).toString(2);break;case"c":h=String.fromCharCode(parseInt(h,10));break;case"d":case"i":h=parseInt(h,10);break;case"j":h=JSON.stringify(h,null,p.width?parseInt(p.width):0);break;case"e":h=p.precision?parseFloat(h).toExponential(p.precision):parseFloat(h).toExponential();break;case"f":h=p.precision?parseFloat(h).toFixed(p.precision):parseFloat(h);break;case"g":h=p.precision?String(Number(h.toPrecision(p.precision))):parseFloat(h);break;case"o":h=(parseInt(h,10)>>>0).toString(8);break;case"s":h=String(h),h=p.precision?h.substring(0,p.precision):h;break;case"t":h=String(!!h),h=p.precision?h.substring(0,p.precision):h;break;case"T":h=Object.prototype.toString.call(h).slice(8,-1).toLowerCase(),h=p.precision?h.substring(0,p.precision):h;break;case"u":h=parseInt(h,10)>>>0;break;case"v":h=h.valueOf(),h=p.precision?h.substring(0,p.precision):h;break;case"x":h=(parseInt(h,10)>>>0).toString(16);break;case"X":h=(parseInt(h,10)>>>0).toString(16).toUpperCase();break}r.json.test(p.type)?g+=h:(r.number.test(p.type)&&(!S||p.sign)?(C=S?"+":"-",h=h.toString().replace(r.sign,"")):C="",x=p.pad_char?p.pad_char==="0"?"0":p.pad_char.charAt(1):" ",v=p.width-(C+h).length,y=p.width&&v>0?x.repeat(v):"",g+=p.align?C+h+y:x==="0"?C+y+h:y+C+h)}return g}var o=Object.create(null);function i(s){if(o[s])return o[s];for(var u=s,l,m=[],h=0;u;){if((l=r.text.exec(u))!==null)m.push(l[0]);else if((l=r.modulo.exec(u))!==null)m.push("%");else if((l=r.placeholder.exec(u))!==null){if(l[2]){h|=1;var g=[],w=l[2],I=[];if((I=r.key.exec(w))!==null)for(g.push(I[1]);(w=w.substring(I[0].length))!=="";)if((I=r.key_access.exec(w))!==null)g.push(I[1]);else if((I=r.index_access.exec(w))!==null)g.push(I[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");l[2]=g}else h|=2;if(h===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");m.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");u=u.substring(l[0].length)}return o[s]=m}typeof Vn<"u"&&(Vn.sprintf=t,Vn.vsprintf=e),typeof window<"u"&&(window.sprintf=t,window.vsprintf=e,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:e}}))})()});var qn=F((Fv,iu)=>{iu.exports=r=>{if(r[Symbol.asyncIterator])return r;if(r.getReader)return async function*(){let t=r.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}}();throw new Error("unknown stream")}});var au=F((zv,su)=>{su.exports=function(t){if(t){if(typeof t[Symbol.iterator]=="function")return t[Symbol.iterator]();if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t.next=="function")return t}throw new Error("argument is not an iterator or iterable")}});var vs=F((Vv,cu)=>{var Lg=au();cu.exports=r=>async t=>{t=Lg(t);let e=v=>{typeof v.return=="function"&&v.return()},n=null,o=null,i=v=>{n=v,o&&o(v),e(t)},s=null,u=!1,l=()=>{u=!0,s&&s()},m=null,h=!1,g=()=>{h=!0,m&&m()},w=null,I=()=>{w&&w()},p=()=>new Promise((v,S)=>{s=w=v,o=S,r.once("drain",I)}),y=()=>(e(t),new Promise((v,S)=>{if(u||h||n)return v();m=s=v,o=S})),x=()=>{r.removeListener("error",i),r.removeListener("close",l),r.removeListener("finish",g),r.removeListener("drain",I)};r.once("error",i),r.once("close",l),r.once("finish",g);try{for await(let v of t){if(!r.writable||r.destroyed||n)break;r.write(v)===!1&&await p()}}catch(v){n||r.destroy(),n=v}try{if(r.writable&&r.end(),await y(),n)throw n}finally{x()}}});var xs=F(($v,fu)=>{var Og=vs(),kg=qn();fu.exports=r=>({sink:Og(r),source:kg(r)})});var lu=F((Gv,uu)=>{var Pg=xs();uu.exports=r=>async function*(t){let e=Pg(r),n;if(e.sink(t).catch(o=>{n=o}),yield*e.source,n)throw n}});var hu=F((Hv,lr)=>{lr.exports=qn();lr.exports.source=qn();lr.exports.sink=vs();lr.exports.transform=lu();lr.exports.duplex=xs()});var Sb={};U(Sb,{createClient:()=>xb});var po=H(io(),1),_a=H(xa(),1),Ba=H(me(),1),mo=H(ho(),1),Na=H(Ra(),1);function Ih(){Ba.default._configure(),po.default._configure(_a.default),mo.default._configure(Na.default)}Ih();var La=["uint64","int64","sint64","fixed64","sfixed64"];function Ch(r){for(let t of La){if(r[t]==null)continue;let e=r[t];r[t]=function(){return BigInt(e.call(this).toString())}}return r}function go(r){return Ch(new po.default(r))}function Dh(r){for(let t of La){if(r[t]==null)continue;let e=r[t];r[t]=function(n){return e.call(this,n.toString())}}return r}function bo(){return Dh(mo.default.create())}function W(r,t){let e=go(r instanceof Uint8Array?r:r.subarray());return t.decode(e)}function Z(r,t){let e=bo();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Ne;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Ne||(Ne={}));function Qr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Kt(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(i,s){let u=t(i);s.int32(u)},n=function(i){let s=i.int32();return t(s)};return Qr("enum",Ne.VARINT,e,n)}function Q(r,t){return Qr("message",Ne.LENGTH_DELIMITED,r,t)}var q;(function(r){let t;(function(o){o.IDENTIFY="IDENTIFY",o.CONNECT="CONNECT",o.STREAM_OPEN="STREAM_OPEN",o.STREAM_HANDLER="STREAM_HANDLER",o.DHT="DHT",o.LIST_PEERS="LIST_PEERS",o.CONNMANAGER="CONNMANAGER",o.DISCONNECT="DISCONNECT",o.PUBSUB="PUBSUB",o.PEERSTORE="PEERSTORE"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.IDENTIFY=0]="IDENTIFY",o[o.CONNECT=1]="CONNECT",o[o.STREAM_OPEN=2]="STREAM_OPEN",o[o.STREAM_HANDLER=3]="STREAM_HANDLER",o[o.DHT=4]="DHT",o[o.LIST_PEERS=5]="LIST_PEERS",o[o.CONNMANAGER=6]="CONNMANAGER",o[o.DISCONNECT=7]="DISCONNECT",o[o.PUBSUB=8]="PUBSUB",o[o.PEERSTORE=9]="PEERSTORE"})(e||(e={})),function(o){o.codec=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=Q((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.connect!=null&&(i.uint32(18),en.codec().encode(o.connect,i)),o.streamOpen!=null&&(i.uint32(26),rn.codec().encode(o.streamOpen,i)),o.streamHandler!=null&&(i.uint32(34),nn.codec().encode(o.streamHandler,i)),o.dht!=null&&(i.uint32(42),xt.codec().encode(o.dht,i)),o.connManager!=null&&(i.uint32(50),sn.codec().encode(o.connManager,i)),o.disconnect!=null&&(i.uint32(58),an.codec().encode(o.disconnect,i)),o.pubsub!=null&&(i.uint32(66),jt.codec().encode(o.pubsub,i)),o.peerStore!=null&&(i.uint32(74),un.codec().encode(o.peerStore,i)),s.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let s={},u=i==null?o.len:o.pos+i;for(;o.pos<u;){let l=o.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(o);break;case 2:s.connect=en.codec().decode(o,o.uint32());break;case 3:s.streamOpen=rn.codec().decode(o,o.uint32());break;case 4:s.streamHandler=nn.codec().decode(o,o.uint32());break;case 5:s.dht=xt.codec().decode(o,o.uint32());break;case 6:s.connManager=sn.codec().decode(o,o.uint32());break;case 7:s.disconnect=an.codec().decode(o,o.uint32());break;case 8:s.pubsub=jt.codec().decode(o,o.uint32());break;case 9:s.peerStore=un.codec().decode(o,o.uint32());break;default:o.skipType(l&7);break}}return s})),n),r.encode=o=>Z(o,r.codec()),r.decode=o=>W(o,r.codec())})(q||(q={}));var M;(function(r){let t;(function(o){o.OK="OK",o.ERROR="ERROR"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.OK=0]="OK",o[o.ERROR=1]="ERROR"})(e||(e={})),function(o){o.codec=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=Q((o,i,s={})=>{if(s.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.error!=null&&(i.uint32(18),on.codec().encode(o.error,i)),o.streamInfo!=null&&(i.uint32(26),Le.codec().encode(o.streamInfo,i)),o.identify!=null&&(i.uint32(34),tn.codec().encode(o.identify,i)),o.dht!=null&&(i.uint32(42),Ot.codec().encode(o.dht,i)),o.peers!=null)for(let u of o.peers)i.uint32(50),re.codec().encode(u,i);o.pubsub!=null&&(i.uint32(58),fn.codec().encode(o.pubsub,i)),o.peerStore!=null&&(i.uint32(66),ln.codec().encode(o.peerStore,i)),s.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let s={peers:[]},u=i==null?o.len:o.pos+i;for(;o.pos<u;){let l=o.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(o);break;case 2:s.error=on.codec().decode(o,o.uint32());break;case 3:s.streamInfo=Le.codec().decode(o,o.uint32());break;case 4:s.identify=tn.codec().decode(o,o.uint32());break;case 5:s.dht=Ot.codec().decode(o,o.uint32());break;case 6:s.peers.push(re.codec().decode(o,o.uint32()));break;case 7:s.pubsub=fn.codec().decode(o,o.uint32());break;case 8:s.peerStore=ln.codec().decode(o,o.uint32());break;default:o.skipType(l&7);break}}return s})),n),r.encode=o=>Z(o,r.codec()),r.decode=o=>W(o,r.codec())})(M||(M={}));var tn;(function(r){let t;r.codec=()=>(t==null&&(t=Q((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.id!=null&&e.id.byteLength>0&&(n.uint32(10),n.bytes(e.id)),e.addrs!=null)for(let i of e.addrs)n.uint32(18),n.bytes(i);o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={id:new Uint8Array(0),addrs:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.id=e.bytes();break;case 2:o.addrs.push(e.bytes());break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>Z(e,r.codec()),r.decode=e=>W(e,r.codec())})(tn||(tn={}));var en;(function(r){let t;r.codec=()=>(t==null&&(t=Q((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.addrs!=null)for(let i of e.addrs)n.uint32(18),n.bytes(i);e.timeout!=null&&(n.uint32(24),n.int64(e.timeout)),o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={peer:new Uint8Array(0),addrs:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.peer=e.bytes();break;case 2:o.addrs.push(e.bytes());break;case 3:o.timeout=e.int64();break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>Z(e,r.codec()),r.decode=e=>W(e,r.codec())})(en||(en={}));var rn;(function(r){let t;r.codec=()=>(t==null&&(t=Q((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.proto!=null)for(let i of e.proto)n.uint32(18),n.string(i);e.timeout!=null&&(n.uint32(24),n.int64(e.timeout)),o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={peer:new Uint8Array(0),proto:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.peer=e.bytes();break;case 2:o.proto.push(e.string());break;case 3:o.timeout=e.int64();break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>Z(e,r.codec()),r.decode=e=>W(e,r.codec())})(rn||(rn={}));var nn;(function(r){let t;r.codec=()=>(t==null&&(t=Q((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.addr!=null&&e.addr.byteLength>0&&(n.uint32(10),n.bytes(e.addr)),e.proto!=null)for(let i of e.proto)n.uint32(18),n.string(i);o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={addr:new Uint8Array(0),proto:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.addr=e.bytes();break;case 2:o.proto.push(e.string());break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>Z(e,r.codec()),r.decode=e=>W(e,r.codec())})(nn||(nn={}));var on;(function(r){let t;r.codec=()=>(t==null&&(t=Q((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.msg!=null&&e.msg!==""&&(n.uint32(10),n.string(e.msg)),o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={msg:""},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.msg=e.string();break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>Z(e,r.codec()),r.decode=e=>W(e,r.codec())})(on||(on={}));var Le;(function(r){let t;r.codec=()=>(t==null&&(t=Q((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),e.addr!=null&&e.addr.byteLength>0&&(n.uint32(18),n.bytes(e.addr)),e.proto!=null&&e.proto!==""&&(n.uint32(26),n.string(e.proto)),o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={peer:new Uint8Array(0),addr:new Uint8Array(0),proto:""},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.peer=e.bytes();break;case 2:o.addr=e.bytes();break;case 3:o.proto=e.string();break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>Z(e,r.codec()),r.decode=e=>W(e,r.codec())})(Le||(Le={}));var xt;(function(r){let t;(function(o){o.FIND_PEER="FIND_PEER",o.FIND_PEERS_CONNECTED_TO_PEER="FIND_PEERS_CONNECTED_TO_PEER",o.FIND_PROVIDERS="FIND_PROVIDERS",o.GET_CLOSEST_PEERS="GET_CLOSEST_PEERS",o.GET_PUBLIC_KEY="GET_PUBLIC_KEY",o.GET_VALUE="GET_VALUE",o.SEARCH_VALUE="SEARCH_VALUE",o.PUT_VALUE="PUT_VALUE",o.PROVIDE="PROVIDE"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.FIND_PEER=0]="FIND_PEER",o[o.FIND_PEERS_CONNECTED_TO_PEER=1]="FIND_PEERS_CONNECTED_TO_PEER",o[o.FIND_PROVIDERS=2]="FIND_PROVIDERS",o[o.GET_CLOSEST_PEERS=3]="GET_CLOSEST_PEERS",o[o.GET_PUBLIC_KEY=4]="GET_PUBLIC_KEY",o[o.GET_VALUE=5]="GET_VALUE",o[o.SEARCH_VALUE=6]="SEARCH_VALUE",o[o.PUT_VALUE=7]="PUT_VALUE",o[o.PROVIDE=8]="PROVIDE"})(e||(e={})),function(o){o.codec=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=Q((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.peer!=null&&(i.uint32(18),i.bytes(o.peer)),o.cid!=null&&(i.uint32(26),i.bytes(o.cid)),o.key!=null&&(i.uint32(34),i.bytes(o.key)),o.value!=null&&(i.uint32(42),i.bytes(o.value)),o.count!=null&&(i.uint32(48),i.int32(o.count)),o.timeout!=null&&(i.uint32(56),i.int64(o.timeout)),s.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let s={},u=i==null?o.len:o.pos+i;for(;o.pos<u;){let l=o.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(o);break;case 2:s.peer=o.bytes();break;case 3:s.cid=o.bytes();break;case 4:s.key=o.bytes();break;case 5:s.value=o.bytes();break;case 6:s.count=o.int32();break;case 7:s.timeout=o.int64();break;default:o.skipType(l&7);break}}return s})),n),r.encode=o=>Z(o,r.codec()),r.decode=o=>W(o,r.codec())})(xt||(xt={}));var Ot;(function(r){let t;(function(o){o.BEGIN="BEGIN",o.VALUE="VALUE",o.END="END"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.BEGIN=0]="BEGIN",o[o.VALUE=1]="VALUE",o[o.END=2]="END"})(e||(e={})),function(o){o.codec=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=Q((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.peer!=null&&(i.uint32(18),re.codec().encode(o.peer,i)),o.value!=null&&(i.uint32(26),i.bytes(o.value)),s.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let s={},u=i==null?o.len:o.pos+i;for(;o.pos<u;){let l=o.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(o);break;case 2:s.peer=re.codec().decode(o,o.uint32());break;case 3:s.value=o.bytes();break;default:o.skipType(l&7);break}}return s})),n),r.encode=o=>Z(o,r.codec()),r.decode=o=>W(o,r.codec())})(Ot||(Ot={}));var re;(function(r){let t;r.codec=()=>(t==null&&(t=Q((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.id!=null&&e.id.byteLength>0&&(n.uint32(10),n.bytes(e.id)),e.addrs!=null)for(let i of e.addrs)n.uint32(18),n.bytes(i);o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={id:new Uint8Array(0),addrs:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.id=e.bytes();break;case 2:o.addrs.push(e.bytes());break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>Z(e,r.codec()),r.decode=e=>W(e,r.codec())})(re||(re={}));var sn;(function(r){let t;(function(o){o.TAG_PEER="TAG_PEER",o.UNTAG_PEER="UNTAG_PEER",o.TRIM="TRIM"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.TAG_PEER=0]="TAG_PEER",o[o.UNTAG_PEER=1]="UNTAG_PEER",o[o.TRIM=2]="TRIM"})(e||(e={})),function(o){o.codec=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=Q((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.peer!=null&&(i.uint32(18),i.bytes(o.peer)),o.tag!=null&&(i.uint32(26),i.string(o.tag)),o.weight!=null&&(i.uint32(32),i.int64(o.weight)),s.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let s={},u=i==null?o.len:o.pos+i;for(;o.pos<u;){let l=o.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(o);break;case 2:s.peer=o.bytes();break;case 3:s.tag=o.string();break;case 4:s.weight=o.int64();break;default:o.skipType(l&7);break}}return s})),n),r.encode=o=>Z(o,r.codec()),r.decode=o=>W(o,r.codec())})(sn||(sn={}));var an;(function(r){let t;r.codec=()=>(t==null&&(t=Q((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.peer!=null&&e.peer.byteLength>0&&(n.uint32(10),n.bytes(e.peer)),o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={peer:new Uint8Array(0)},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.peer=e.bytes();break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>Z(e,r.codec()),r.decode=e=>W(e,r.codec())})(an||(an={}));var jt;(function(r){let t;(function(o){o.GET_TOPICS="GET_TOPICS",o.LIST_PEERS="LIST_PEERS",o.PUBLISH="PUBLISH",o.SUBSCRIBE="SUBSCRIBE"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.GET_TOPICS=0]="GET_TOPICS",o[o.LIST_PEERS=1]="LIST_PEERS",o[o.PUBLISH=2]="PUBLISH",o[o.SUBSCRIBE=3]="SUBSCRIBE"})(e||(e={})),function(o){o.codec=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=Q((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.topic!=null&&(i.uint32(18),i.string(o.topic)),o.data!=null&&(i.uint32(26),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let s={},u=i==null?o.len:o.pos+i;for(;o.pos<u;){let l=o.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(o);break;case 2:s.topic=o.string();break;case 3:s.data=o.bytes();break;default:o.skipType(l&7);break}}return s})),n),r.encode=o=>Z(o,r.codec()),r.decode=o=>W(o,r.codec())})(jt||(jt={}));var cn;(function(r){let t;r.codec=()=>(t==null&&(t=Q((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.from!=null&&(n.uint32(10),n.bytes(e.from)),e.data!=null&&(n.uint32(18),n.bytes(e.data)),e.seqno!=null&&(n.uint32(26),n.bytes(e.seqno)),e.topicIDs!=null)for(let i of e.topicIDs)n.uint32(34),n.string(i);e.signature!=null&&(n.uint32(42),n.bytes(e.signature)),e.key!=null&&(n.uint32(50),n.bytes(e.key)),o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={topicIDs:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.from=e.bytes();break;case 2:o.data=e.bytes();break;case 3:o.seqno=e.bytes();break;case 4:o.topicIDs.push(e.string());break;case 5:o.signature=e.bytes();break;case 6:o.key=e.bytes();break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>Z(e,r.codec()),r.decode=e=>W(e,r.codec())})(cn||(cn={}));var fn;(function(r){let t;r.codec=()=>(t==null&&(t=Q((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.topics!=null)for(let i of e.topics)n.uint32(10),n.string(i);if(e.peerIDs!=null)for(let i of e.peerIDs)n.uint32(18),n.bytes(i);o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={topics:[],peerIDs:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.topics.push(e.string());break;case 2:o.peerIDs.push(e.bytes());break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>Z(e,r.codec()),r.decode=e=>W(e,r.codec())})(fn||(fn={}));var un;(function(r){let t;(function(o){o.UNSPECIFIED="UNSPECIFIED",o.GET_PROTOCOLS="GET_PROTOCOLS",o.GET_PEER_INFO="GET_PEER_INFO"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.UNSPECIFIED=0]="UNSPECIFIED",o[o.GET_PROTOCOLS=1]="GET_PROTOCOLS",o[o.GET_PEER_INFO=2]="GET_PEER_INFO"})(e||(e={})),function(o){o.codec=()=>Kt(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=Q((o,i,s={})=>{if(s.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.id!=null&&(i.uint32(18),i.bytes(o.id)),o.protos!=null)for(let u of o.protos)i.uint32(26),i.string(u);s.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let s={protos:[]},u=i==null?o.len:o.pos+i;for(;o.pos<u;){let l=o.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(o);break;case 2:s.id=o.bytes();break;case 3:s.protos.push(o.string());break;default:o.skipType(l&7);break}}return s})),n),r.encode=o=>Z(o,r.codec()),r.decode=o=>W(o,r.codec())})(un||(un={}));var ln;(function(r){let t;r.codec=()=>(t==null&&(t=Q((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.peer!=null&&(n.uint32(10),re.codec().encode(e.peer,n)),e.protos!=null)for(let i of e.protos)n.uint32(18),n.string(i);o.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let o={protos:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let s=e.uint32();switch(s>>>3){case 1:o.peer=re.codec().decode(e,e.uint32());break;case 2:o.protos.push(e.string());break;default:e.skipType(s&7);break}}return o})),t),r.encode=e=>Z(e,r.codec()),r.decode=e=>W(e,r.codec())})(ln||(ln={}));var gt=H(Ha(),1);function Zh(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var u=r.length,l=r.charAt(0),m=Math.log(u)/Math.log(256),h=Math.log(256)/Math.log(u);function g(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,x=0,v=0,S=p.length;v!==S&&p[v]===0;)v++,y++;for(var C=(S-v)*h+1>>>0,D=new Uint8Array(C);v!==S;){for(var N=p[v],P=0,B=C-1;(N!==0||P<x)&&B!==-1;B--,P++)N+=256*D[B]>>>0,D[B]=N%u>>>0,N=N/u>>>0;if(N!==0)throw new Error("Non-zero carry");x=P,v++}for(var O=C-x;O!==C&&D[O]===0;)O++;for(var V=l.repeat(y);O<C;++O)V+=r.charAt(D[O]);return V}function w(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var x=0,v=0;p[y]===l;)x++,y++;for(var S=(p.length-y)*m+1>>>0,C=new Uint8Array(S);p[y];){var D=e[p.charCodeAt(y)];if(D===255)return;for(var N=0,P=S-1;(D!==0||N<v)&&P!==-1;P--,N++)D+=u*C[P]>>>0,C[P]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");v=N,y++}if(p[y]!==" "){for(var B=S-v;B!==S&&C[B]===0;)B++;for(var O=new Uint8Array(x+(S-B)),V=x;B!==S;)O[V++]=C[B++];return O}}}function I(p){var y=w(p);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:w,decode:I}}var Qh=Zh,tp=Qh,qa=tp;var ay=new Uint8Array(0);var Ka=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var vo=class{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},xo=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return ja(this,t)}},So=class{constructor(t){this.decoders=t}or(t){return ja(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},ja=(r,t)=>new So({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Ao=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new vo(t,e,n),this.decoder=new xo(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Ja=({name:r,prefix:t,encode:e,decode:n})=>new Ao(r,t,e,n),To=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=qa(e,t);return Ja({prefix:r,name:t,encode:n,decode:i=>Ka(o(i))})},ep=(r,t,e,n)=>{let o={};for(let h=0;h<t.length;++h)o[t[h]]=h;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),u=0,l=0,m=0;for(let h=0;h<i;++h){let g=o[r[h]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|g,u+=e,u>=8&&(u-=8,s[m++]=255&l>>u)}if(u>=e||255&l<<8-u)throw new SyntaxError("Unexpected end of data");return s},rp=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,u=0;for(let l=0;l<r.length;++l)for(u=u<<8|r[l],s+=8;s>e;)s-=e,i+=t[o&u>>s];if(s&&(i+=t[o&u<<e-s]),n)for(;i.length*e&7;)i+="=";return i},ut=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Ja({prefix:t,name:r,encode(o){return rp(o,n,e)},decode(o){return ep(o,n,e,r)}});var Ya=ut({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),py=ut({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),dy=ut({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),my=ut({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),gy=ut({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),by=ut({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),yy=ut({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),wy=ut({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ey=ut({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Xa=To({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Sy=To({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Wa=ut({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Iy=ut({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Cy=ut({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Dy=ut({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});gt.default.formatters.b=r=>r==null?"undefined":Xa.baseEncode(r);gt.default.formatters.t=r=>r==null?"undefined":Ya.baseEncode(r);gt.default.formatters.m=r=>r==null?"undefined":Wa.baseEncode(r);gt.default.formatters.p=r=>r==null?"undefined":r.toString();gt.default.formatters.c=r=>r==null?"undefined":r.toString();gt.default.formatters.k=r=>r==null?"undefined":r.toString();gt.default.formatters.a=r=>r==null?"undefined":r.toString();function np(r){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=r,t.destroy=()=>!0,t.extend=()=>t,t}function St(r){let t=np(`${r}:trace`);return gt.default.enabled(`${r}:trace`)&>.default.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=(0,gt.default)(`${r}:trace`)),Object.assign((0,gt.default)(r),{error:(0,gt.default)(`${r}:error`),trace:t})}function ye(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Jt(r=0){return globalThis.Buffer?.alloc!=null?ye(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function Pt(r=0){return globalThis.Buffer?.allocUnsafe!=null?ye(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function At(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=Pt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return ye(e)}function we(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var Qa=Symbol.for("@achingbrain/uint8arraylist");function Za(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function gn(r){return!!r?.[Qa]}var Ft=class r{constructor(...t){Object.defineProperty(this,Qa,{value:!0}),this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(gn(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(gn(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Za(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Za(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(gn(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return At(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:At(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),i=new r;return i.length=o,i.bufs=n,i}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===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],u=o,l=u+s.byteLength;if(o=l,t>=l)continue;let m=t>=u&&t<l,h=e>u&&e<=l;if(m&&h){if(t===u&&e===l){n.push(s);break}let g=t-u;n.push(s.subarray(g,g+(e-t)));break}if(m){if(t===0){n.push(s);continue}n.push(s.subarray(t-u));continue}if(h){if(e===l){n.push(s);break}n.push(s.subarray(0,e-u));break}n.push(s)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!gn(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;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 g=0;g<i;g++)s[g]=-1;for(let g=0;g<o;g++)s[n[g]]=g;let u=s,l=this.byteLength-n.byteLength,m=n.byteLength-1,h;for(let g=e;g<=l;g+=h){h=0;for(let w=m;w>=0;w--){let I=this.get(g+w);if(n[w]!==I){h=Math.max(1,w-u[I]);break}}if(h===0)return g}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=Pt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=Jt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=Jt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=Jt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=Pt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=Jt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=Jt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=Jt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=Jt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=Jt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!we(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,i)=>o+i.byteLength,0)),n.length=e,n}};function tc(r){let t=async function*(){let e=yield,n=new Ft;for await(let o of r){if(e==null){n.append(o),e=yield n,n=new Ft;continue}for(n.append(o);n.length>=e;){let i=n.sublist(0,e);if(n.consume(e),e=yield i,e==null){n.length>0&&(e=yield n,n=new Ft);break}}}if(e!=null)throw Object.assign(new Error(`stream ended before ${e} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return t.next(),t}function Me(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var bn=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||t-1&t)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},Fe=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new bn(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new bn(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var Io=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function ec(r={}){return op(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function op(r,t){t=t??{};let e=t.onEnd,n=new Fe,o,i,s,u=Me(),l=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((x,v)=>{i=S=>{i=null,n.push(S);try{x(r(n))}catch(C){v(C)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{u.resolve(),u=Me()})}},m=x=>i!=null?i(x):(n.push(x),o),h=x=>(n=new Fe,i!=null?i({error:x}):(n.push({error:x}),o)),g=x=>{if(s)return o;if(t?.objectMode!==!0&&x?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return m({done:!1,value:x})},w=x=>s?o:(s=!0,x!=null?h(x):m({done:!0})),I=()=>(n=new Fe,w(),{done:!0}),p=x=>(w(x),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:l,return:I,throw:p,push:g,end:w,get readableLength(){return n.size},onEmpty:async x=>{let v=x?.signal;if(v?.throwIfAborted(),n.isEmpty())return;let S,C;v!=null&&(S=new Promise((D,N)=>{C=()=>{N(new Io)},v.addEventListener("abort",C)}));try{await Promise.race([u.promise,S])}finally{C!=null&&v!=null&&v?.removeEventListener("abort",C)}}},e==null)return o;let y=o;return o={[Symbol.asyncIterator](){return this},next(){return y.next()},throw(x){return y.throw(x),e!=null&&(e(x),e=void 0),{done:!0}},return(){return y.return(),e!=null&&(e(),e=void 0),{done:!0}},push:g,end(x){return y.end(x),e!=null&&(e(x),e=void 0),o},get readableLength(){return y.readableLength}},o}function rc(r){let t=ec(),e=tc(r.source),n=Me(),o,i=r.sink(async function*(){yield*t,yield*await n.promise}());return i.catch(u=>{o=u}),{reader:e,writer:t,stream:{sink:async u=>{if(o!=null){await Promise.reject(o);return}n.resolve(u),await i},source:e},rest:()=>t.end(),write:t.push,read:async()=>{let u=await e.next();if(u.value!=null)return u.value}}}function yn(r){return r instanceof Uint8Array?{get(t){return r[t]},set(t,e){r[t]=e}}:{get(t){return r.get(t)},set(t,e){r.set(t,e)}}}var nc=4294967296,Er=class r{constructor(t=0,e=0){this.hi=t,this.lo=e}toBigInt(t){if(t===!0)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toNumber(t){return Number(this.toBigInt(t))}zzDecode(){let t=-(this.lo&1),e=((this.lo>>>1|this.hi<<31)^t)>>>0,n=(this.hi>>>1^t)>>>0;return new r(n,e)}zzEncode(){let t=this.hi>>31,e=((this.hi<<1|this.lo>>>31)^t)>>>0,n=(this.lo<<1^t)>>>0;return new r(e,n)}toBytes(t,e=0){let n=yn(t);for(;this.hi>0;)n.set(e++,this.lo&127|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)n.set(e++,this.lo&127|128),this.lo=this.lo>>>7;n.set(e++,this.lo)}static fromBigInt(t){if(t===0n)return new r;let e=t<0;e&&(t=-t);let n=Number(t>>32n)|0,o=Number(t-(BigInt(n)<<32n))|0;return e&&(n=~n>>>0,o=~o>>>0,++o>nc&&(o=0,++n>nc&&(n=0))),new r(n,o)}static fromNumber(t){if(t===0)return new r;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(o,n)}static fromBytes(t,e=0){let n=yn(t),o=new r,i=0;if(t.length-e>4){for(;i<4;++i)if(o.lo=(o.lo|(n.get(e)&127)<<i*7)>>>0,n.get(e++)<128)return o;if(o.lo=(o.lo|(n.get(e)&127)<<28)>>>0,o.hi=(o.hi|(n.get(e)&127)>>4)>>>0,n.get(e++)<128)return o;i=0}else for(;i<4;++i){if(e>=t.length)throw RangeError(`index out of range: ${e} > ${t.length}`);if(o.lo=(o.lo|(n.get(e)&127)<<i*7)>>>0,n.get(e++)<128)return o}if(t.length-e>4){for(;i<5;++i)if(o.hi=(o.hi|(n.get(e)&127)<<i*7+3)>>>0,n.get(e++)<128)return o}else if(e<t.byteLength)for(;i<5;++i){if(e>=t.length)throw RangeError(`index out of range: ${e} > ${t.length}`);if(o.hi=(o.hi|(n.get(e)&127)<<i*7+3)>>>0,n.get(e++)<128)return o}throw RangeError("invalid varint encoding")}};var ip=Math.pow(2,7),sp=Math.pow(2,14),ap=Math.pow(2,21),cp=Math.pow(2,28),fp=Math.pow(2,35),up=Math.pow(2,42),lp=Math.pow(2,49),hp=Math.pow(2,56),pp=Math.pow(2,63),Ee={encodingLength(r){return r<ip?1:r<sp?2:r<ap?3:r<cp?4:r<fp?5:r<up?6:r<lp?7:r<hp?8:r<pp?9:10},encode(r,t,e=0){if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return t==null&&(t=Pt(Ee.encodingLength(r))),Er.fromNumber(r).toBytes(t,e),t},decode(r,t=0){return Er.fromBytes(r,t).toNumber(!0)}};function wn(r){return r[Symbol.asyncIterator]!=null}var En=r=>{let t=Ee.encodingLength(r),e=Pt(t);return Ee.encode(r,e),En.bytes=t,e};En.bytes=0;function vn(r,t){t=t??{};let e=t.lengthEncoder??En;function*n(o){let i=e(o.byteLength);i instanceof Uint8Array?yield i:yield*i,o instanceof Uint8Array?yield o:yield*o}return wn(r)?async function*(){for await(let o of r)yield*n(o)}():function*(){for(let o of r)yield*n(o)}()}vn.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??En;return new Ft(e(r.byteLength),r)};var ze=H(sc(),1);var mp=8,gp=1024*1024*4,ve;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(ve||(ve={}));var Co=r=>{let t=Ee.decode(r);return Co.bytes=Ee.encodingLength(t),t};Co.bytes=0;function vr(r,t){let e=new Ft,n=ve.LENGTH,o=-1,i=t?.lengthDecoder??Co,s=t?.maxLengthLength??mp,u=t?.maxDataLength??gp;function*l(){for(;e.byteLength>0;){if(n===ve.LENGTH)try{if(o=i(e),o<0)throw(0,ze.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>u)throw(0,ze.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let m=i.bytes;e.consume(m),t?.onLength!=null&&t.onLength(o),n=ve.DATA}catch(m){if(m instanceof RangeError){if(e.byteLength>s)throw(0,ze.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw m}if(n===ve.DATA){if(e.byteLength<o)break;let m=e.sublist(0,o);e.consume(o),t?.onData!=null&&t.onData(m),yield m,n=ve.LENGTH}}}return wn(r)?async function*(){for await(let m of r)e.append(m),yield*l();if(e.byteLength>0)throw(0,ze.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let m of r)e.append(m),yield*l();if(e.byteLength>0)throw(0,ze.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}vr.fromReader=(r,t)=>{let e=1,n=async function*(){for(;;)try{let{done:i,value:s}=await r.next(e);if(i===!0)return;s!=null&&(yield s)}catch(i){if(i.code==="ERR_UNDER_READ")return{done:!0,value:null};throw i}finally{e=1}}();return vr(n,{...t??{},onLength:i=>{e=i}})};var Do=St("libp2p:daemon-protocol:stream-handler"),xr=class{stream;shake;decoder;constructor(t){let{stream:e,maxLength:n}=t;this.stream=e,this.shake=rc(this.stream),this.decoder=vr.fromReader(this.shake.reader,{maxDataLength:n??4096})}async read(){let t=await this.decoder.next();if(t.value!=null)return t.value.subarray();Do("read received no value, closing stream"),await this.close()}write(t){Do("write message"),this.shake.write(vn.single(t).subarray())}rest(){return this.shake.rest(),this.shake.stream}async close(){Do("closing the stream"),await this.rest().sink([])}};var Ro={upgradeInbound:async r=>r,upgradeOutbound:async r=>r};var Ve=class r extends Error{code;type;constructor(t="The operation was aborted"){super(t),this.code=r.code,this.type=r.type}static code="ABORT_ERR";static type="aborted"},A=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var _o=Symbol.for("@libp2p/peer-id");function $e(r){return r!=null&&!!r[_o]}var ko={};U(ko,{base58btc:()=>bt,base58flickr:()=>Sp});function yp(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var u=r.length,l=r.charAt(0),m=Math.log(u)/Math.log(256),h=Math.log(256)/Math.log(u);function g(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,x=0,v=0,S=p.length;v!==S&&p[v]===0;)v++,y++;for(var C=(S-v)*h+1>>>0,D=new Uint8Array(C);v!==S;){for(var N=p[v],P=0,B=C-1;(N!==0||P<x)&&B!==-1;B--,P++)N+=256*D[B]>>>0,D[B]=N%u>>>0,N=N/u>>>0;if(N!==0)throw new Error("Non-zero carry");x=P,v++}for(var O=C-x;O!==C&&D[O]===0;)O++;for(var V=l.repeat(y);O<C;++O)V+=r.charAt(D[O]);return V}function w(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var x=0,v=0;p[y]===l;)x++,y++;for(var S=(p.length-y)*m+1>>>0,C=new Uint8Array(S);p[y];){var D=e[p.charCodeAt(y)];if(D===255)return;for(var N=0,P=S-1;(D!==0||N<v)&&P!==-1;P--,N++)D+=u*C[P]>>>0,C[P]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");v=N,y++}if(p[y]!==" "){for(var B=S-v;B!==S&&C[B]===0;)B++;for(var O=new Uint8Array(x+(S-B)),V=x;B!==S;)O[V++]=C[B++];return O}}}function I(p){var y=w(p);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:w,decode:I}}var wp=yp,Ep=wp,ac=Ep;var Dw=new Uint8Array(0);var cc=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0},Tt=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var fc=r=>new TextEncoder().encode(r),uc=r=>new TextDecoder().decode(r);var Bo=class{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},No=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return hc(this,t)}},Lo=class{constructor(t){this.decoders=t}or(t){return hc(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},hc=(r,t)=>new Lo({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Oo=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Bo(t,e,n),this.decoder=new No(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Ge=({name:r,prefix:t,encode:e,decode:n})=>new Oo(r,t,e,n),ne=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=ac(e,t);return Ge({prefix:r,name:t,encode:n,decode:i=>Tt(o(i))})},vp=(r,t,e,n)=>{let o={};for(let h=0;h<t.length;++h)o[t[h]]=h;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),u=0,l=0,m=0;for(let h=0;h<i;++h){let g=o[r[h]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|g,u+=e,u>=8&&(u-=8,s[m++]=255&l>>u)}if(u>=e||255&l<<8-u)throw new SyntaxError("Unexpected end of data");return s},xp=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,u=0;for(let l=0;l<r.length;++l)for(u=u<<8|r[l],s+=8;s>e;)s-=e,i+=t[o&u>>s];if(s&&(i+=t[o&u<<e-s]),n)for(;i.length*e&7;)i+="=";return i},K=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Ge({prefix:t,name:r,encode(o){return xp(o,n,e)},decode(o){return vp(o,n,e,r)}});var bt=ne({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Sp=ne({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Po={};U(Po,{identity:()=>Ap});var Ap=Ge({prefix:"\0",name:"identity",encode:r=>uc(r),decode:r=>fc(r)});var Uo={};U(Uo,{base2:()=>Tp});var Tp=K({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Mo={};U(Mo,{base8:()=>Ip});var Ip=K({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Fo={};U(Fo,{base10:()=>Cp});var Cp=ne({prefix:"9",name:"base10",alphabet:"0123456789"});var zo={};U(zo,{base16:()=>Dp,base16upper:()=>Rp});var Dp=K({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Rp=K({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Vo={};U(Vo,{base32:()=>He,base32hex:()=>Lp,base32hexpad:()=>kp,base32hexpadupper:()=>Pp,base32hexupper:()=>Op,base32pad:()=>Bp,base32padupper:()=>Np,base32upper:()=>_p,base32z:()=>Up});var He=K({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),_p=K({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Bp=K({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Np=K({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Lp=K({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Op=K({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),kp=K({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Pp=K({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Up=K({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var $o={};U($o,{base36:()=>Mp,base36upper:()=>Fp});var Mp=ne({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Fp=ne({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Go={};U(Go,{base64:()=>zp,base64pad:()=>Vp,base64url:()=>$p,base64urlpad:()=>Gp});var zp=K({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Vp=K({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),$p=K({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Gp=K({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ho={};U(Ho,{base256emoji:()=>Jp});var pc=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}"),Hp=pc.reduce((r,t,e)=>(r[e]=t,r),[]),qp=pc.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Kp(r){return r.reduce((t,e)=>(t+=Hp[e],t),"")}function jp(r){let t=[];for(let e of r){let n=qp[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var Jp=Ge({prefix:"\u{1F680}",name:"base256emoji",encode:Kp,decode:jp});var Yo={};U(Yo,{sha256:()=>Sn,sha512:()=>pd});var Jo=H(Bt("crypto"),1);var Yp=gc,dc=128,Xp=127,Wp=~Xp,Zp=Math.pow(2,31);function gc(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Zp;)t[e++]=r&255|dc,r/=128;for(;r&Wp;)t[e++]=r&255|dc,r>>>=7;return t[e]=r|0,gc.bytes=e-n+1,t}var Qp=qo,td=128,mc=127;function qo(r,n){var e=0,n=n||0,o=0,i=n,s,u=r.length;do{if(i>=u)throw qo.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&mc)<<o:(s&mc)*Math.pow(2,o),o+=7}while(s>=td);return qo.bytes=i-n,e}var ed=Math.pow(2,7),rd=Math.pow(2,14),nd=Math.pow(2,21),od=Math.pow(2,28),id=Math.pow(2,35),sd=Math.pow(2,42),ad=Math.pow(2,49),cd=Math.pow(2,56),fd=Math.pow(2,63),ud=function(r){return r<ed?1:r<rd?2:r<nd?3:r<od?4:r<id?5:r<sd?6:r<ad?7:r<cd?8:r<fd?9:10},ld={encode:Yp,decode:Qp,encodingLength:ud},hd=ld,Sr=hd;var Ar=(r,t=0)=>[Sr.decode(r,t),Sr.decode.bytes],qe=(r,t,e=0)=>(Sr.encode(r,t,e),t),Ke=r=>Sr.encodingLength(r);var oe=(r,t)=>{let e=t.byteLength,n=Ke(r),o=n+Ke(e),i=new Uint8Array(o+e);return qe(r,i,0),qe(e,i,n),i.set(t,o),new je(r,e,t,i)},Tr=r=>{let t=Tt(r),[e,n]=Ar(t),[o,i]=Ar(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new je(e,o,s,t)},bc=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&cc(r.bytes,e.bytes)}},je=class{constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var jo=({name:r,code:t,encode:e})=>new Ko(r,t,e),Ko=class{constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?oe(this.code,e):e.then(n=>oe(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Sn=jo({name:"sha2-256",code:18,encode:r=>Tt(Jo.default.createHash("sha256").update(r).digest())}),pd=jo({name:"sha2-512",code:19,encode:r=>Tt(Jo.default.createHash("sha512").update(r).digest())});var Xo={};U(Xo,{identity:()=>An});var wc=0,dd="identity",Ec=Tt,md=r=>oe(wc,Ec(r)),An={code:wc,name:dd,encode:Ec,digest:md};var Xw=new TextEncoder,Ww=new TextDecoder;var vc=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return wd(e,Wo(r),t||bt.encoder);default:return Ed(e,Wo(r),t||He.encoder)}};var xc=new WeakMap,Wo=r=>{let t=xc.get(r);if(t==null){let e=new Map;return xc.set(r,e),e}return t},xe=class r{constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Ir)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==vd)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=oe(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&bc(t.multihash,n.multihash)}toString(t){return vc(this,t)}toJSON(){return{"/":vc(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:i,bytes:s}=e;return new r(n,o,i,s||Sc(n,o,i.bytes))}else if(e[xd]===!0){let{version:n,multihash:o,code:i}=e,s=Tr(o);return r.create(n,i,s)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Ir)throw new Error(`Version 0 CID must use dag-pb (code: ${Ir}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Sc(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Ir,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=Tt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),s=new je(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[g,w]=Ar(t.subarray(e));return e+=w,g},o=n(),i=Ir;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=e,u=n(),l=n(),m=e+l,h=m-s;return{version:o,codec:i,multihashCode:u,digestSize:l,multihashSize:h,size:m}}static parse(t,e){let[n,o]=yd(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Wo(i).set(n,t),i}},yd=(r,t)=>{switch(r[0]){case"Q":{let e=t||bt;return[bt.prefix,e.decode(`${bt.prefix}${r}`)]}case bt.prefix:{let e=t||bt;return[bt.prefix,e.decode(r)]}case He.prefix:{let e=t||He;return[He.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},wd=(r,t,e)=>{let{prefix:n}=e;if(n!==bt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o},Ed=(r,t,e)=>{let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o},Ir=112,vd=18,Sc=(r,t,e)=>{let n=Ke(r),o=n+Ke(t),i=new Uint8Array(o+e.byteLength);return qe(r,i,0),qe(t,i,n),i.set(e,o),i},xd=Symbol.for("@ipld/js-cid/CID");var Zo={...Po,...Uo,...Mo,...Fo,...zo,...Vo,...$o,...ko,...Go,...Ho},a2={...Yo,...Xo};var Sd=Symbol.for("nodejs.util.inspect.custom"),Ac=Object.values(Zo).map(r=>r.decoder).reduce((r,t)=>r.or(t),Zo.identity.decoder),Tc=114,Ic=36,Cc=37,Cr=class{type;multihash;privateKey;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[_o]=!0;toString(){return this.string==null&&(this.string=bt.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return xe.createV1(Tc,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t instanceof Uint8Array)return we(this.multihash.bytes,t);if(typeof t=="string")return Ad(t).equals(this);if(t?.multihash?.bytes!=null)return we(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Sd](){return`PeerId(${this.toString()})`}},Dr=class extends Cr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Rr=class extends Cr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.multihash.digest}},_r=class extends Cr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.multihash.digest}};function Ad(r,t){if(t=t??Ac,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=Tr(bt.decode(`z${r}`));return r.startsWith("12D")?new Rr({multihash:e}):r.startsWith("16U")?new _r({multihash:e}):new Dr({multihash:e})}return zt(Ac.decode(r))}function zt(r){try{let t=Tr(r);if(t.code===An.code){if(t.digest.length===Ic)return new Rr({multihash:t});if(t.digest.length===Cc)return new _r({multihash:t})}if(t.code===Sn.code)return new Dr({multihash:t})}catch{return Td(xe.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Td(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Tc)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===Sn.code)return new Dr({multihash:r.multihash});if(t.code===An.code){if(t.digest.length===Ic)return new Rr({multihash:r.multihash});if(t.digest.length===Cc)return new _r({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var gu=H(Bt("net"),1);var Rc=Symbol.for("@libp2p/transport");var Dc;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Dc||(Dc={}));var Tn=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var ni={};U(ni,{base58btc:()=>lt,base58flickr:()=>Bd});function Id(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var u=r.length,l=r.charAt(0),m=Math.log(u)/Math.log(256),h=Math.log(256)/Math.log(u);function g(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,x=0,v=0,S=p.length;v!==S&&p[v]===0;)v++,y++;for(var C=(S-v)*h+1>>>0,D=new Uint8Array(C);v!==S;){for(var N=p[v],P=0,B=C-1;(N!==0||P<x)&&B!==-1;B--,P++)N+=256*D[B]>>>0,D[B]=N%u>>>0,N=N/u>>>0;if(N!==0)throw new Error("Non-zero carry");x=P,v++}for(var O=C-x;O!==C&&D[O]===0;)O++;for(var V=l.repeat(y);O<C;++O)V+=r.charAt(D[O]);return V}function w(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var x=0,v=0;p[y]===l;)x++,y++;for(var S=(p.length-y)*m+1>>>0,C=new Uint8Array(S);p[y];){var D=e[p.charCodeAt(y)];if(D===255)return;for(var N=0,P=S-1;(D!==0||N<v)&&P!==-1;P--,N++)D+=u*C[P]>>>0,C[P]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");v=N,y++}if(p[y]!==" "){for(var B=S-v;B!==S&&C[B]===0;)B++;for(var O=new Uint8Array(x+(S-B)),V=x;B!==S;)O[V++]=C[B++];return O}}}function I(p){var y=w(p);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:w,decode:I}}var Cd=Id,Dd=Cd,_c=Dd;var v2=new Uint8Array(0);var Bc=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0},It=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var Nc=r=>new TextEncoder().encode(r),Lc=r=>new TextDecoder().decode(r);var Qo=class{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},ti=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return kc(this,t)}},ei=class{constructor(t){this.decoders=t}or(t){return kc(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},kc=(r,t)=>new ei({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),ri=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Qo(t,e,n),this.decoder=new ti(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Ye=({name:r,prefix:t,encode:e,decode:n})=>new ri(r,t,e,n),ie=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=_c(e,t);return Ye({prefix:r,name:t,encode:n,decode:i=>It(o(i))})},Rd=(r,t,e,n)=>{let o={};for(let h=0;h<t.length;++h)o[t[h]]=h;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),u=0,l=0,m=0;for(let h=0;h<i;++h){let g=o[r[h]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|g,u+=e,u>=8&&(u-=8,s[m++]=255&l>>u)}if(u>=e||255&l<<8-u)throw new SyntaxError("Unexpected end of data");return s},_d=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,u=0;for(let l=0;l<r.length;++l)for(u=u<<8|r[l],s+=8;s>e;)s-=e,i+=t[o&u>>s];if(s&&(i+=t[o&u<<e-s]),n)for(;i.length*e&7;)i+="=";return i},j=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Ye({prefix:t,name:r,encode(o){return _d(o,n,e)},decode(o){return Rd(o,n,e,r)}});var lt=ie({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Bd=ie({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Nd=Mc,Pc=128,Ld=127,Od=~Ld,kd=Math.pow(2,31);function Mc(r,t,e){t=t||[],e=e||0;for(var n=e;r>=kd;)t[e++]=r&255|Pc,r/=128;for(;r&Od;)t[e++]=r&255|Pc,r>>>=7;return t[e]=r|0,Mc.bytes=e-n+1,t}var Pd=oi,Ud=128,Uc=127;function oi(r,n){var e=0,n=n||0,o=0,i=n,s,u=r.length;do{if(i>=u)throw oi.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&Uc)<<o:(s&Uc)*Math.pow(2,o),o+=7}while(s>=Ud);return oi.bytes=i-n,e}var Md=Math.pow(2,7),Fd=Math.pow(2,14),zd=Math.pow(2,21),Vd=Math.pow(2,28),$d=Math.pow(2,35),Gd=Math.pow(2,42),Hd=Math.pow(2,49),qd=Math.pow(2,56),Kd=Math.pow(2,63),jd=function(r){return r<Md?1:r<Fd?2:r<zd?3:r<Vd?4:r<$d?5:r<Gd?6:r<Hd?7:r<qd?8:r<Kd?9:10},Jd={encode:Nd,decode:Pd,encodingLength:jd},Yd=Jd,Br=Yd;var Nr=(r,t=0)=>[Br.decode(r,t),Br.decode.bytes],Xe=(r,t,e=0)=>(Br.encode(r,t,e),t),We=r=>Br.encodingLength(r);var Se=(r,t)=>{let e=t.byteLength,n=We(r),o=n+We(e),i=new Uint8Array(o+e);return Xe(r,i,0),Xe(e,i,n),i.set(t,o),new Ze(r,e,t,i)},Cn=r=>{let t=It(r),[e,n]=Nr(t),[o,i]=Nr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Ze(e,o,s,t)},Fc=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Bc(r.bytes,e.bytes)}},Ze=class{constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var ii={};U(ii,{base32:()=>Yt,base32hex:()=>Qd,base32hexpad:()=>em,base32hexpadupper:()=>rm,base32hexupper:()=>tm,base32pad:()=>Wd,base32padupper:()=>Zd,base32upper:()=>Xd,base32z:()=>nm});var Yt=j({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Xd=j({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Wd=j({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Zd=j({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Qd=j({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),tm=j({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),em=j({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),rm=j({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),nm=j({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var zc=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return im(e,si(r),t||lt.encoder);default:return sm(e,si(r),t||Yt.encoder)}};var Vc=new WeakMap,si=r=>{let t=Vc.get(r);if(t==null){let e=new Map;return Vc.set(r,e),e}return t},se=class r{constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Lr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==am)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Se(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&Fc(t.multihash,n.multihash)}toString(t){return zc(this,t)}toJSON(){return{"/":zc(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:i,bytes:s}=e;return new r(n,o,i,s||$c(n,o,i.bytes))}else if(e[cm]===!0){let{version:n,multihash:o,code:i}=e,s=Cn(o);return r.create(n,i,s)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Lr)throw new Error(`Version 0 CID must use dag-pb (code: ${Lr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=$c(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Lr,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=It(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),s=new Ze(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[g,w]=Nr(t.subarray(e));return e+=w,g},o=n(),i=Lr;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=e,u=n(),l=n(),m=e+l,h=m-s;return{version:o,codec:i,multihashCode:u,digestSize:l,multihashSize:h,size:m}}static parse(t,e){let[n,o]=om(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return si(i).set(n,t),i}},om=(r,t)=>{switch(r[0]){case"Q":{let e=t||lt;return[lt.prefix,e.decode(`${lt.prefix}${r}`)]}case lt.prefix:{let e=t||lt;return[lt.prefix,e.decode(r)]}case Yt.prefix:{let e=t||Yt;return[Yt.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},im=(r,t,e)=>{let{prefix:n}=e;if(n!==lt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o},sm=(r,t,e)=>{let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o},Lr=112,am=18,$c=(r,t,e)=>{let n=We(r),o=n+We(t),i=new Uint8Array(o+e.byteLength);return Xe(r,i,0),Xe(t,i,n),i.set(e,o),i},cm=Symbol.for("@ipld/js-cid/CID");var li={};U(li,{identity:()=>dm});function fm(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var u=r.length,l=r.charAt(0),m=Math.log(u)/Math.log(256),h=Math.log(256)/Math.log(u);function g(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,x=0,v=0,S=p.length;v!==S&&p[v]===0;)v++,y++;for(var C=(S-v)*h+1>>>0,D=new Uint8Array(C);v!==S;){for(var N=p[v],P=0,B=C-1;(N!==0||P<x)&&B!==-1;B--,P++)N+=256*D[B]>>>0,D[B]=N%u>>>0,N=N/u>>>0;if(N!==0)throw new Error("Non-zero carry");x=P,v++}for(var O=C-x;O!==C&&D[O]===0;)O++;for(var V=l.repeat(y);O<C;++O)V+=r.charAt(D[O]);return V}function w(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var x=0,v=0;p[y]===l;)x++,y++;for(var S=(p.length-y)*m+1>>>0,C=new Uint8Array(S);p[y];){var D=e[p.charCodeAt(y)];if(D===255)return;for(var N=0,P=S-1;(D!==0||N<v)&&P!==-1;P--,N++)D+=u*C[P]>>>0,C[P]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");v=N,y++}if(p[y]!==" "){for(var B=S-v;B!==S&&C[B]===0;)B++;for(var O=new Uint8Array(x+(S-B)),V=x;B!==S;)O[V++]=C[B++];return O}}}function I(p){var y=w(p);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:w,decode:I}}var um=fm,lm=um,Gc=lm;var P2=new Uint8Array(0);var Hc=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0},Ct=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var qc=r=>new TextEncoder().encode(r),Kc=r=>new TextDecoder().decode(r);var ai=class{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},ci=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Jc(this,t)}},fi=class{constructor(t){this.decoders=t}or(t){return Jc(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Jc=(r,t)=>new fi({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),ui=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new ai(t,e,n),this.decoder=new ci(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},tr=({name:r,prefix:t,encode:e,decode:n})=>new ui(r,t,e,n),ae=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=Gc(e,t);return tr({prefix:r,name:t,encode:n,decode:i=>Ct(o(i))})},hm=(r,t,e,n)=>{let o={};for(let h=0;h<t.length;++h)o[t[h]]=h;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),u=0,l=0,m=0;for(let h=0;h<i;++h){let g=o[r[h]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|g,u+=e,u>=8&&(u-=8,s[m++]=255&l>>u)}if(u>=e||255&l<<8-u)throw new SyntaxError("Unexpected end of data");return s},pm=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,u=0;for(let l=0;l<r.length;++l)for(u=u<<8|r[l],s+=8;s>e;)s-=e,i+=t[o&u>>s];if(s&&(i+=t[o&u<<e-s]),n)for(;i.length*e&7;)i+="=";return i},J=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>tr({prefix:t,name:r,encode(o){return pm(o,n,e)},decode(o){return hm(o,n,e,r)}});var dm=tr({prefix:"\0",name:"identity",encode:r=>Kc(r),decode:r=>qc(r)});var hi={};U(hi,{base2:()=>mm});var mm=J({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var pi={};U(pi,{base8:()=>gm});var gm=J({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var di={};U(di,{base10:()=>bm});var bm=ae({prefix:"9",name:"base10",alphabet:"0123456789"});var mi={};U(mi,{base16:()=>ym,base16upper:()=>wm});var ym=J({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),wm=J({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var gi={};U(gi,{base32:()=>er,base32hex:()=>Sm,base32hexpad:()=>Tm,base32hexpadupper:()=>Im,base32hexupper:()=>Am,base32pad:()=>vm,base32padupper:()=>xm,base32upper:()=>Em,base32z:()=>Cm});var er=J({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Em=J({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),vm=J({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),xm=J({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Sm=J({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Am=J({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Tm=J({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Im=J({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Cm=J({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var bi={};U(bi,{base36:()=>Dm,base36upper:()=>Rm});var Dm=ae({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Rm=ae({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var yi={};U(yi,{base58btc:()=>Vt,base58flickr:()=>_m});var Vt=ae({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),_m=ae({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var wi={};U(wi,{base64:()=>Bm,base64pad:()=>Nm,base64url:()=>Lm,base64urlpad:()=>Om});var Bm=J({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Nm=J({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Lm=J({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Om=J({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ei={};U(Ei,{base256emoji:()=>Fm});var Yc=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}"),km=Yc.reduce((r,t,e)=>(r[e]=t,r),[]),Pm=Yc.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Um(r){return r.reduce((t,e)=>(t+=km[e],t),"")}function Mm(r){let t=[];for(let e of r){let n=Pm[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var Fm=tr({prefix:"\u{1F680}",name:"base256emoji",encode:Um,decode:Mm});var Ti={};U(Ti,{sha256:()=>o0,sha512:()=>i0});var Ai=H(Bt("crypto"),1);var zm=Zc,Xc=128,Vm=127,$m=~Vm,Gm=Math.pow(2,31);function Zc(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Gm;)t[e++]=r&255|Xc,r/=128;for(;r&$m;)t[e++]=r&255|Xc,r>>>=7;return t[e]=r|0,Zc.bytes=e-n+1,t}var Hm=vi,qm=128,Wc=127;function vi(r,n){var e=0,n=n||0,o=0,i=n,s,u=r.length;do{if(i>=u)throw vi.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&Wc)<<o:(s&Wc)*Math.pow(2,o),o+=7}while(s>=qm);return vi.bytes=i-n,e}var Km=Math.pow(2,7),jm=Math.pow(2,14),Jm=Math.pow(2,21),Ym=Math.pow(2,28),Xm=Math.pow(2,35),Wm=Math.pow(2,42),Zm=Math.pow(2,49),Qm=Math.pow(2,56),t0=Math.pow(2,63),e0=function(r){return r<Km?1:r<jm?2:r<Jm?3:r<Ym?4:r<Xm?5:r<Wm?6:r<Zm?7:r<Qm?8:r<t0?9:10},r0={encode:zm,decode:Hm,encodingLength:e0},n0=r0,Or=n0;var kr=(r,t=0)=>[Or.decode(r,t),Or.decode.bytes],rr=(r,t,e=0)=>(Or.encode(r,t,e),t),nr=r=>Or.encodingLength(r);var Ae=(r,t)=>{let e=t.byteLength,n=nr(r),o=n+nr(e),i=new Uint8Array(o+e);return rr(r,i,0),rr(e,i,n),i.set(t,o),new or(r,e,t,i)},Qc=r=>{let t=Ct(r),[e,n]=kr(t),[o,i]=kr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new or(e,o,s,t)},tf=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Hc(r.bytes,e.bytes)}},or=class{constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var Si=({name:r,code:t,encode:e})=>new xi(r,t,e),xi=class{constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Ae(this.code,e):e.then(n=>Ae(this.code,n))}else throw Error("Unknown type, must be binary type")}};var o0=Si({name:"sha2-256",code:18,encode:r=>Ct(Ai.default.createHash("sha256").update(r).digest())}),i0=Si({name:"sha2-512",code:19,encode:r=>Ct(Ai.default.createHash("sha512").update(r).digest())});var Ii={};U(Ii,{identity:()=>c0});var rf=0,s0="identity",nf=Ct,a0=r=>Ae(rf,nf(r)),c0={code:rf,name:s0,encode:nf,digest:a0};var o1=new TextEncoder,i1=new TextDecoder;var of=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return h0(e,Ci(r),t||Vt.encoder);default:return p0(e,Ci(r),t||er.encoder)}};var sf=new WeakMap,Ci=r=>{let t=sf.get(r);if(t==null){let e=new Map;return sf.set(r,e),e}return t},Rn=class r{constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Ur)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==d0)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Ae(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&tf(t.multihash,n.multihash)}toString(t){return of(this,t)}toJSON(){return{"/":of(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:i,bytes:s}=e;return new r(n,o,i,s||af(n,o,i.bytes))}else if(e[m0]===!0){let{version:n,multihash:o,code:i}=e,s=Qc(o);return r.create(n,i,s)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Ur)throw new Error(`Version 0 CID must use dag-pb (code: ${Ur}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=af(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Ur,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=Ct(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),s=new or(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[g,w]=kr(t.subarray(e));return e+=w,g},o=n(),i=Ur;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=e,u=n(),l=n(),m=e+l,h=m-s;return{version:o,codec:i,multihashCode:u,digestSize:l,multihashSize:h,size:m}}static parse(t,e){let[n,o]=l0(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ci(i).set(n,t),i}},l0=(r,t)=>{switch(r[0]){case"Q":{let e=t||Vt;return[Vt.prefix,e.decode(`${Vt.prefix}${r}`)]}case Vt.prefix:{let e=t||Vt;return[Vt.prefix,e.decode(r)]}case er.prefix:{let e=t||er;return[er.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},h0=(r,t,e)=>{let{prefix:n}=e;if(n!==Vt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o},p0=(r,t,e)=>{let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o},Ur=112,d0=18,af=(r,t,e)=>{let n=nr(r),o=n+nr(t),i=new Uint8Array(o+e.byteLength);return rr(r,i,0),rr(t,i,n),i.set(e,o),i},m0=Symbol.for("@ipld/js-cid/CID");var Di={...li,...hi,...pi,...di,...mi,...gi,...bi,...yi,...wi,...Ei},m1={...Ti,...Ii};function ff(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var cf=ff("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ri=ff("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=Pt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),g0={utf8:cf,"utf-8":cf,hex:Di.base16,latin1:Ri,ascii:Ri,binary:Ri,...Di},_n=g0;function ht(r,t="utf8"){let e=_n[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}var sr=H(Ni(),1);var Bn=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let i=0,s=0,u=this.peekChar();if(u===void 0)return;let l=u==="0",m=2**(8*o)-1;for(;;){let h=this.readAtomically(()=>{let g=this.readChar();if(g===void 0)return;let w=Number.parseInt(g,t);if(!Number.isNaN(w))return w});if(h===void 0)break;if(i*=t,i+=h,i>m||(s+=1,e!==void 0&&s>e))return}if(s!==0)return!n&&l&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return e[o]=s[0],e[o+1]=s[1],e[o+2]=s[2],e[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];e[o]=i>>8,e[o+1]=i&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[u]=t(i.subarray(0,s));return e.set(i.subarray(0,u),16-u),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var D1=new Bn;var P1=parseInt("0xFFFF",16),U1=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var Li={};U(Li,{identity:()=>k0});var k0=Ye({prefix:"\0",name:"identity",encode:r=>Lc(r),decode:r=>Nc(r)});var Oi={};U(Oi,{base2:()=>P0});var P0=j({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ki={};U(ki,{base8:()=>U0});var U0=j({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Pi={};U(Pi,{base10:()=>M0});var M0=ie({prefix:"9",name:"base10",alphabet:"0123456789"});var Ui={};U(Ui,{base16:()=>F0,base16upper:()=>z0});var F0=j({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),z0=j({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Mi={};U(Mi,{base36:()=>V0,base36upper:()=>$0});var V0=ie({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),$0=ie({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Fi={};U(Fi,{base64:()=>G0,base64pad:()=>H0,base64url:()=>q0,base64urlpad:()=>K0});var G0=j({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),H0=j({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),q0=j({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),K0=j({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var zi={};U(zi,{base256emoji:()=>W0});var vf=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}"),j0=vf.reduce((r,t,e)=>(r[e]=t,r),[]),J0=vf.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Y0(r){return r.reduce((t,e)=>(t+=j0[e],t),"")}function X0(r){let t=[];for(let e of r){let n=J0[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var W0=Ye({prefix:"\u{1F680}",name:"base256emoji",encode:Y0,decode:X0});var Hi={};U(Hi,{sha256:()=>Z0,sha512:()=>Q0});var Gi=H(Bt("crypto"),1);var $i=({name:r,code:t,encode:e})=>new Vi(r,t,e),Vi=class{constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Se(this.code,e):e.then(n=>Se(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Z0=$i({name:"sha2-256",code:18,encode:r=>It(Gi.default.createHash("sha256").update(r).digest())}),Q0=$i({name:"sha2-512",code:19,encode:r=>It(Gi.default.createHash("sha512").update(r).digest())});var qi={};U(qi,{identity:()=>rg});var Sf=0,tg="identity",Af=It,eg=r=>Se(Sf,Af(r)),rg={code:Sf,name:tg,encode:Af,digest:eg};var EE=new TextEncoder,vE=new TextDecoder;var Tf={...Li,...Oi,...ki,...Pi,...Ui,...ii,...Mi,...ni,...Fi,...zi},IE={...Hi,...qi};function Ki(r,t="utf8"){let e=_n[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?ye(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}var $t=H(Ni(),1);var ce=Bt("node:net");function Nn(r){return!!(0,ce.isIP)(r)}var If=ce.isIPv4,ig=ce.isIPv6,ji=function(r){let t=0;if(r=r.toString().trim(),If(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(ig(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=If(e[n]),s;i&&(s=ji(e[n]),e[n]=ht(s.slice(0,2),"base16")),s!=null&&++n<8&&e.splice(n,0,ht(s.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let i=[n,1];for(n=9-e.length;n>0;n--)i.push("0");e.splice.apply(e,i)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let i=parseInt(e[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},Cf=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let i=0;i<e;i++)o.push(r[t+i]);return o.join(".")}if(e===16){let o=[];for(let i=0;i<e;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var ir={},Ji={},ag=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];ag.forEach(r=>{let t=cg(...r);Ji[t.code]=t,ir[t.name]=t});function cg(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function $(r){if(typeof r=="number"){if(Ji[r]!=null)return Ji[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(ir[r]!=null)return ir[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var qE=$("ip4"),KE=$("ip6"),jE=$("ipcidr");function Xi(r,t){switch($(r).code){case 4:case 41:return ug(t);case 42:return _f(t);case 6:case 273:case 33:case 132:return Nf(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return _f(t);case 421:return dg(t);case 444:return Bf(t);case 445:return Bf(t);case 466:return pg(t);default:return ht(t,"base16")}}function Wi(r,t){switch($(r).code){case 4:return Df(t);case 41:return Df(t);case 42:return Rf(t);case 6:case 273:case 33:case 132:return Zi(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Rf(t);case 421:return lg(t);case 444:return mg(t);case 445:return gg(t);case 466:return hg(t);default:return Ki(t,"base16")}}var Yi=Object.values(Tf).map(r=>r.decoder),fg=function(){let r=Yi[0].or(Yi[1]);return Yi.slice(2).forEach(t=>r=r.or(t)),r}();function Df(r){if(!Nn(r))throw new Error("invalid ip address");return ji(r)}function ug(r){let t=Cf(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Nn(t))throw new Error("invalid ip address");return t}function Zi(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Nf(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Rf(r){let t=Ki(r),e=Uint8Array.from($t.default.encode(t.length));return At([e,t],e.length+t.length)}function _f(r){let t=$t.default.decode(r);if(r=r.slice($t.default.decode.bytes),r.length!==t)throw new Error("inconsistent lengths");return ht(r)}function lg(r){let t;r[0]==="Q"||r[0]==="1"?t=Cn(lt.decode(`z${r}`)).bytes:t=se.parse(r).multihash.bytes;let e=Uint8Array.from($t.default.encode(t.length));return At([e,t],e.length+t.length)}function hg(r){let t=fg.decode(r),e=Uint8Array.from($t.default.encode(t.length));return At([e,t],e.length+t.length)}function pg(r){let t=$t.default.decode(r),e=r.slice($t.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return"u"+ht(e,"base64url")}function dg(r){let t=$t.default.decode(r),e=r.slice($t.default.decode.bytes);if(e.length!==t)throw new Error("inconsistent lengths");return ht(e,"base58btc")}function mg(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Yt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Zi(n);return At([e,o],e.length+o.length)}function gg(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Yt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Zi(n);return At([e,o],e.length+o.length)}function Bf(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=ht(t,"base32"),o=Nf(e);return`${n}:${o}`}function Lf(r){r=Qi(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let s=o[i],u=$(s);if(u.size===0){t.push([u.code]),e.push([u.code]);continue}if(i++,i>=o.length)throw kf("invalid address: "+r);if(u.path===!0){n=Qi(o.slice(i).join("/")),t.push([u.code,Wi(u.code,n)]),e.push([u.code,n]);break}let l=Wi(u.code,o[i]);t.push([u.code,l]),e.push([u.code,Xi(u.code,l)])}return{string:Of(e),bytes:es(t),tuples:t,stringTuples:e,path:n}}function ts(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=sr.default.decode(r,o),s=sr.default.decode.bytes??0,u=$(i),l=bg(u,r.slice(o+s));if(l===0){t.push([i]),e.push([i]),o+=s;continue}let m=r.slice(o+s,o+s+l);if(o+=l+s,o>r.length)throw kf("Invalid address Uint8Array: "+ht(r,"base16"));t.push([i,m]);let h=Xi(i,m);if(e.push([i,h]),u.path===!0){n=h;break}}return{bytes:Uint8Array.from(r),string:Of(e),tuples:t,stringTuples:e,path:n}}function Of(r){let t=[];return r.map(e=>{let n=$(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Qi(t.join("/"))}function es(r){return At(r.map(t=>{let e=$(t[0]),n=Uint8Array.from(sr.default.encode(e.code));return t.length>1&&t[1]!=null&&(n=At([n,t[1]])),n}))}function bg(r,t){return r.size>0?r.size/8:r.size===0?0:sr.default.decode(t)+(sr.default.decode.bytes??0)}function Qi(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function kf(r){return new Error("Error parsing address: "+r)}var yg=Symbol.for("nodejs.util.inspect.custom"),wg=[$("dns").code,$("dns4").code,$("dns6").code,$("dnsaddr").code],Eg=new Map,Pf=Symbol.for("@multiformats/js-multiaddr/multiaddr");function ns(r){return!!r?.[Pf]}var rs=class r{bytes;#t;#e;#r;#n;[Pf]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=ts(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Lf(t)}else if(ns(t))e=ts(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,i="",s=$("tcp"),u=$("udp"),l=$("ip4"),m=$("ip6"),h=$("dns6"),g=$("ip6zone");for(let[I,p]of this.stringTuples())I===g.code&&(i=`%${p??""}`),wg.includes(I)&&(e=s.name,o=443,n=`${p??""}${i}`,t=I===h.code?6:4),(I===s.code||I===u.code)&&(e=$(I).name,o=parseInt(p??"")),(I===l.code||I===m.code)&&(e=$(I).name,n=`${p??""}${i}`,t=I===m.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},$(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>$(t).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(es(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===ir.p2p.code&&t.push([n,o]),n===ir["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?ht(lt.decode(`z${n}`),"base58btc"):ht(se.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return we(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=Eg.get(e.name);if(n==null)throw new Tn(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(i=>new r(i))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[yg](){return`Multiaddr(${this.#t})`}};function it(r){return new rs(r)}var vg=R("dns4"),xg=R("dns6"),Sg=R("dnsaddr"),Ie=X(R("dns"),Sg,vg,xg),kn=X(R("ip4"),R("ip6")),ue=X(k(kn,R("tcp")),k(Ie,R("tcp"))),Pn=k(kn,R("udp")),Ag=k(Pn,R("utp")),Tg=k(Pn,R("quic")),Ig=k(Pn,R("quic-v1")),os=X(k(ue,R("ws")),k(Ie,R("ws"))),Ln=X(k(os,R("p2p")),os),is=X(k(ue,R("wss")),k(Ie,R("wss")),k(ue,R("tls"),R("ws")),k(Ie,R("tls"),R("ws"))),On=X(k(is,R("p2p")),is),ss=X(k(ue,R("http")),k(kn,R("http")),k(Ie,R("http"))),as=X(k(ue,R("https")),k(kn,R("https")),k(Ie,R("https"))),Uf=k(Pn,R("webrtc-direct"),R("certhash")),zf=X(k(Uf,R("p2p")),Uf),Mf=k(Ig,R("webtransport"),R("certhash"),R("certhash")),Vf=X(k(Mf,R("p2p")),Mf),$f=X(k(Ln,R("p2p-webrtc-star"),R("p2p")),k(On,R("p2p-webrtc-star"),R("p2p")),k(Ln,R("p2p-webrtc-star")),k(On,R("p2p-webrtc-star"))),mv=X(k(Ln,R("p2p-websocket-star"),R("p2p")),k(On,R("p2p-websocket-star"),R("p2p")),k(Ln,R("p2p-websocket-star")),k(On,R("p2p-websocket-star"))),Gf=X(k(ss,R("p2p-webrtc-direct"),R("p2p")),k(as,R("p2p-webrtc-direct"),R("p2p")),k(ss,R("p2p-webrtc-direct")),k(as,R("p2p-webrtc-direct"))),Ce=X(os,is,ss,as,$f,Gf,ue,Ag,Tg,Ie,zf,Vf),gv=X(k(Ce,R("p2p-stardust"),R("p2p")),k(Ce,R("p2p-stardust"))),fe=X(k(Ce,R("p2p")),$f,Gf,zf,Vf,R("p2p")),Ff=X(k(fe,R("p2p-circuit"),fe),k(fe,R("p2p-circuit")),k(R("p2p-circuit"),fe),k(Ce,R("p2p-circuit")),k(R("p2p-circuit"),Ce),R("p2p-circuit")),Hf=()=>X(k(Ff,Hf),Ff),Te=Hf(),bv=X(k(Te,fe,Te),k(fe,Te),k(Te,fe),Te,fe);var yv=X(k(Te,R("webrtc"),R("p2p")),k(Te,R("webrtc")),k(Ce,R("webrtc"),R("p2p")),k(Ce,R("webrtc")),R("webrtc"));function qf(r){function t(e){let n;try{n=it(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function k(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(o=>(n=typeof o=="function"?o().partialMatch(e):o.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:qf(t),partialMatch:t}}function X(...r){function t(n){let o=null;return r.some(i=>{let s=typeof i=="function"?i().partialMatch(n):i.partialMatch(n);return s!=null?(o=s,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:qf(t),partialMatch:t}}function R(r){let t=r;function e(o){let i;try{i=it(o)}catch{return!1}let s=i.protoNames();return s.length===1&&s[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var mu=H(Bt("net"),1);var Un=class extends EventTarget{#t=new Map;listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:i})=>i!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e){return this.dispatchEvent(new ar(t,e))}},cs=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},ar=globalThis.CustomEvent??cs;function Mn(r){return this.subnetMask<r.subnetMask?!1:this.mask(r.subnetMask)===r.mask()}function Fn(r){return function(){return this.addressMinusSuffix!==this.correctForm()?!1:this.subnetMask===r&&!this.parsedSubnet?!0:this.parsedSubnet===String(this.subnetMask)}}var cr=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g,fs=/\/\d{1,2}$/;var st=class extends Error{constructor(t,e){super(t),this.name="AddressError",e!==null&&(this.parseMessage=e)}};var fr=H(us(),1),De=H(Mr(),1),yt=class r{constructor(t){this.groups=4,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=Fn(32),this.isInSubnet=Mn,this.address=t;let e=fs.exec(t);if(e){if(this.parsedSubnet=e[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,this.subnetMask<0||this.subnetMask>32)throw new st("Invalid subnet mask.");t=t.replace(fs,"")}this.addressMinusSuffix=t,this.parsedAddress=this.parse(t)}static isValid(t){try{return new r(t),!0}catch{return!1}}parse(t){let e=t.split(".");if(!t.match(cr))throw new st("Invalid IPv4 address.");return e}correctForm(){return this.parsedAddress.map(t=>parseInt(t,10)).join(".")}static fromHex(t){let e=t.replace(/:/g,"").padStart(8,"0"),n=[],o;for(o=0;o<8;o+=2){let i=e.slice(o,o+2);n.push(parseInt(i,16))}return new r(n.join("."))}static fromInteger(t){return r.fromHex(t.toString(16))}static fromArpa(t){let n=t.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join(".");return new r(n)}toHex(){return this.parsedAddress.map(t=>(0,De.sprintf)("%02x",parseInt(t,10))).join(":")}toArray(){return this.parsedAddress.map(t=>parseInt(t,10))}toGroup6(){let t=[],e;for(e=0;e<4;e+=2){let n=(0,De.sprintf)("%02x%02x",parseInt(this.parsedAddress[e],10),parseInt(this.parsedAddress[e+1],10));t.push((0,De.sprintf)("%x",parseInt(n,16)))}return t.join(":")}bigInteger(){return new fr.BigInteger(this.parsedAddress.map(t=>(0,De.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new fr.BigInteger(this.mask()+"0".repeat(32-this.subnetMask),2)}startAddress(){return r.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new fr.BigInteger("1");return r.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new fr.BigInteger(this.mask()+"1".repeat(32-this.subnetMask),2)}endAddress(){return r.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new fr.BigInteger("1");return r.fromBigInteger(this._endAddress().subtract(t))}static fromBigInteger(t){return r.fromInteger(parseInt(t.toString(),10))}mask(t){return t===void 0&&(t=this.subnetMask),this.getBitsBase2(0,t)}getBitsBase2(t,e){return this.binaryZeroPad().slice(t,e)}reverseForm(t){t||(t={});let e=this.correctForm().split(".").reverse().join(".");return t.omitSuffix?e:(0,De.sprintf)("%s.in-addr.arpa.",e)}isMulticast(){return this.isInSubnet(new r("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(32,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(cr,(0,De.sprintf)('<span class="hover-group group-v4 group-6">%s</span>.<span class="hover-group group-v4 group-7">%s</span>',t.slice(0,2).join("."),t.slice(2,4).join(".")))}};var Xf={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},ls={"ff01::1/128":"Multicast (All nodes on this interface)","ff01::2/128":"Multicast (All routers on this interface)","ff02::1/128":"Multicast (All nodes on this link)","ff02::2/128":"Multicast (All routers on this link)","ff05::2/128":"Multicast (All routers in this site)","ff02::5/128":"Multicast (OSPFv3 AllSPF routers)","ff02::6/128":"Multicast (OSPFv3 AllDR routers)","ff02::9/128":"Multicast (RIP routers)","ff02::a/128":"Multicast (EIGRP routers)","ff02::d/128":"Multicast (PIM routers)","ff02::16/128":"Multicast (MLDv2 reports)","ff01::fb/128":"Multicast (mDNSv6)","ff02::fb/128":"Multicast (mDNSv6)","ff05::fb/128":"Multicast (mDNSv6)","ff02::1:2/128":"Multicast (All DHCP servers and relay agents on this link)","ff05::1:2/128":"Multicast (All DHCP servers and relay agents in this site)","ff02::1:3/128":"Multicast (All DHCP servers on this link)","ff05::1:3/128":"Multicast (All DHCP servers in this site)","::/128":"Unspecified","::1/128":"Loopback","ff00::/8":"Multicast","fe80::/10":"Link-local unicast"},hs=/([^0-9a-f:/%])/gi,ps=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,ds=/\/\d{1,3}(?=%|$)/,ms=/%.*$/,Wf=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),Zf=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);var tu=H(Mr(),1);function Dg(r){return r.replace(/^(0+)/,'<span class="zero">$1</span>')}function $n(r,t=0){return r.split(":").map((n,o)=>/group-v4/.test(n)?n:(0,tu.sprintf)('<span class="hover-group group-%d">%s</span>',o+t,Dg(n)))}var _e=H(Mr(),1);function bs(r){return(0,_e.sprintf)("(%s)",r.join("|"))}function gs(r){return r.length<4?(0,_e.sprintf)("0{0,%d}%s",4-r.length,r):r}var ys="[^A-Fa-f0-9:]";function Gn(r){let t=[];r.forEach((n,o)=>{parseInt(n,16)===0&&t.push(o)});let e=t.map(n=>r.map((o,i)=>{if(i===n){let s=i===0||i===8-1?":":"";return bs([gs(o),s])}return gs(o)}).join(":"));return e.push(r.map(gs).join(":")),bs(e)}function ws(r,t,e){let n=t?"":":",o=e?"":":",i=[];!t&&!e&&i.push("::"),t&&e&&i.push(""),(e&&!t||!e&&t)&&i.push(":"),i.push((0,_e.sprintf)("%s(:0{1,4}){1,%d}",n,r-1)),i.push((0,_e.sprintf)("(0{1,4}:){1,%d}%s",r-1,o)),i.push((0,_e.sprintf)("(0{1,4}:){%d}0{1,4}",r-1));for(let s=1;s<r-1;s++)for(let u=1;u<r-s;u++)i.push((0,_e.sprintf)("(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}",u,r-u-s-1));return bs(i)}var at=H(us(),1),ct=H(Mr(),1);function Hn(r){if(!r)throw new Error("Assertion failed.")}function Rg(r){let t=/(\d+)(\d{3})/;for(;t.test(r);)r=r.replace(t,"$1,$2");return r}function _g(r){return r=r.replace(/^(0{1,})([1-9]+)$/,'<span class="parse-error">$1</span>$2'),r=r.replace(/^(0{1,})(0)$/,'<span class="parse-error">$1</span>$2'),r}function Bg(r,t){let e=[],n=[],o;for(o=0;o<r.length;o++)o<t[0]?e.push(r[o]):o>t[1]&&n.push(r[o]);return e.concat(["compact"]).concat(n)}function ru(r){return(0,ct.sprintf)("%04x",parseInt(r,16))}function nu(r){return r&255}var Fr=class r{constructor(t,e){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=Mn,this.isCorrect=Fn(128),e===void 0?this.groups=8:this.groups=e,this.address=t;let n=ds.exec(t);if(n){if(this.parsedSubnet=n[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,Number.isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>128)throw new st("Invalid subnet mask.");t=t.replace(ds,"")}else if(/\//.test(t))throw new st("Invalid subnet mask.");let o=ms.exec(t);o&&(this.zone=o[0],t=t.replace(ms,"")),this.addressMinusSuffix=t,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new r(t),!0}catch{return!1}}static fromBigInteger(t){let e=t.toString(16).padStart(32,"0"),n=[],o;for(o=0;o<8;o++)n.push(e.slice(o*4,(o+1)*4));return new r(n.join(":"))}static fromURL(t){let e,n=null,o;if(t.indexOf("[")!==-1&&t.indexOf("]:")!==-1){if(o=Zf.exec(t),o===null)return{error:"failed to parse address with port",address:null,port:null};e=o[1],n=o[2]}else if(t.indexOf("/")!==-1){if(t=t.replace(/^[a-z0-9]+:\/\//,""),o=Wf.exec(t),o===null)return{error:"failed to parse address from URL",address:null,port:null};e=o[1]}else e=t;return n?(n=parseInt(n,10),(n<0||n>65536)&&(n=null)):n=null,{address:new r(e),port:n}}static fromAddress4(t){let e=new yt(t),n=128-(32-e.subnetMask);return new r(`::ffff:${e.correctForm()}/${n}`)}static fromArpa(t){let e=t.replace(/(\.ip6\.arpa)?\.$/,""),n=7;if(e.length!==63)throw new st("Invalid 'ip6.arpa' form.");let o=e.split(".").reverse();for(let i=n;i>0;i--){let s=i*4;o.splice(s,0,":")}return e=o.join(""),new r(e)}microsoftTranscription(){return(0,ct.sprintf)("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))}mask(t=this.subnetMask){return this.getBitsBase2(0,t)}possibleSubnets(t=128){let e=128-this.subnetMask,n=Math.abs(t-128),o=e-n;return o<0?"0":Rg(new at.BigInteger("2",10).pow(o).toString(10))}_startAddress(){return new at.BigInteger(this.mask()+"0".repeat(128-this.subnetMask),2)}startAddress(){return r.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new at.BigInteger("1");return r.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new at.BigInteger(this.mask()+"1".repeat(128-this.subnetMask),2)}endAddress(){return r.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new at.BigInteger("1");return r.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=Xf[this.getBits(12,16).intValue()];return this.getType()==="Global unicast"&&t!=="Link local"&&(t="Global"),t||"Unknown"}getType(){for(let t of Object.keys(ls))if(this.isInSubnet(new r(t)))return ls[t];return"Global unicast"}getBits(t,e){return new at.BigInteger(this.getBitsBase2(t,e),2)}getBitsBase2(t,e){return this.binaryZeroPad().slice(t,e)}getBitsBase16(t,e){let n=e-t;if(n%4!==0)throw new Error("Length of bits to retrieve must be divisible by four");return this.getBits(t,e).toString(16).padStart(n/4,"0")}getBitsPastSubnet(){return this.getBitsBase2(this.subnetMask,128)}reverseForm(t){t||(t={});let e=Math.floor(this.subnetMask/4),n=this.canonicalForm().replace(/:/g,"").split("").slice(0,e).reverse().join(".");return e>0?t.omitSuffix?n:(0,ct.sprintf)("%s.ip6.arpa.",n):t.omitSuffix?"":"ip6.arpa."}correctForm(){let t,e=[],n=0,o=[];for(t=0;t<this.parsedAddress.length;t++){let u=parseInt(this.parsedAddress[t],16);u===0&&n++,u!==0&&n>0&&(n>1&&o.push([t-n,t-1]),n=0)}n>1&&o.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let i=o.map(u=>u[1]-u[0]+1);if(o.length>0){let u=i.indexOf(Math.max(...i));e=Bg(this.parsedAddress,o[u])}else e=this.parsedAddress;for(t=0;t<e.length;t++)e[t]!=="compact"&&(e[t]=parseInt(e[t],16).toString(16));let s=e.join(":");return s=s.replace(/^compact$/,"::"),s=s.replace(/^compact|compact$/,":"),s=s.replace(/compact/,""),s}binaryZeroPad(){return this.bigInteger().toString(2).padStart(128,"0")}parse4in6(t){let e=t.split(":"),o=e.slice(-1)[0].match(cr);if(o){this.parsedAddress4=o[0],this.address4=new yt(this.parsedAddress4);for(let i=0;i<this.address4.groups;i++)if(/^0[0-9]+/.test(this.address4.parsedAddress[i]))throw new st("IPv4 addresses can't have leading zeroes.",t.replace(cr,this.address4.parsedAddress.map(_g).join(".")));this.v4=!0,e[e.length-1]=this.address4.toGroup6(),t=e.join(":")}return t}parse(t){t=this.parse4in6(t);let e=t.match(hs);if(e)throw new st((0,ct.sprintf)("Bad character%s detected in address: %s",e.length>1?"s":"",e.join("")),t.replace(hs,'<span class="parse-error">$1</span>'));let n=t.match(ps);if(n)throw new st((0,ct.sprintf)("Address failed regex: %s",n.join("")),t.replace(ps,'<span class="parse-error">$1</span>'));let o=[],i=t.split("::");if(i.length===2){let s=i[0].split(":"),u=i[1].split(":");s.length===1&&s[0]===""&&(s=[]),u.length===1&&u[0]===""&&(u=[]);let l=this.groups-(s.length+u.length);if(!l)throw new st("Error parsing groups");this.elidedGroups=l,this.elisionBegin=s.length,this.elisionEnd=s.length+this.elidedGroups,o=o.concat(s);for(let m=0;m<l;m++)o.push("0");o=o.concat(u)}else if(i.length===1)o=t.split(":"),this.elidedGroups=0;else throw new st("Too many :: groups found");if(o=o.map(s=>(0,ct.sprintf)("%x",parseInt(s,16))),o.length!==this.groups)throw new st("Incorrect number of groups found");return o}canonicalForm(){return this.parsedAddress.map(ru).join(":")}decimal(){return this.parsedAddress.map(t=>(0,ct.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new at.BigInteger(this.parsedAddress.map(ru).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return yt.fromHex(new at.BigInteger(t.slice(96,128).join(""),2).toString(16))}to4in6(){let t=this.to4(),n=new r(this.parsedAddress.slice(0,6).join(":"),6).correctForm(),o="";return/:$/.test(n)||(o=":"),n+o+t.address}inspectTeredo(){let t=this.getBitsBase16(0,32),e=this.getBits(80,96).xor(new at.BigInteger("ffff",16)).toString(),n=yt.fromHex(this.getBitsBase16(32,64)),o=yt.fromHex(this.getBits(96,128).xor(new at.BigInteger("ffffffff",16)).toString(16)),i=this.getBits(64,80),s=this.getBitsBase2(64,80),u=i.testBit(15),l=i.testBit(14),m=i.testBit(8),h=i.testBit(9),g=new at.BigInteger(s.slice(2,6)+s.slice(8,16),2).toString(10);return{prefix:(0,ct.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:o.address,flags:s,coneNat:u,microsoft:{reserved:l,universalLocal:h,groupIndividual:m,nonce:g},udpPort:e}}inspect6to4(){let t=this.getBitsBase16(0,16),e=yt.fromHex(this.getBitsBase16(16,48));return{prefix:(0,ct.sprintf)("%s",t.slice(0,4)),gateway:e.address}}to6to4(){if(!this.is4())return null;let t=["2002",this.getBitsBase16(96,112),this.getBitsBase16(112,128),"","/16"].join(":");return new r(t)}toByteArray(){let t=this.bigInteger().toByteArray();return t.length===17&&t[0]===0?t.slice(1):t}toUnsignedByteArray(){return this.toByteArray().map(nu)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(nu))}static fromUnsignedByteArray(t){let e=new at.BigInteger("256",10),n=new at.BigInteger("0",10),o=new at.BigInteger("1",10);for(let i=t.length-1;i>=0;i--)n=n.add(o.multiply(new at.BigInteger(t[i].toString(10),10))),o=o.multiply(e);return r.fromBigInteger(n)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){return this.getBitsBase2(0,64)==="1111111010000000000000000000000000000000000000000000000000000000"}isMulticast(){return this.getType()==="Multicast"}is4(){return this.v4}isTeredo(){return this.isInSubnet(new r("2001::/32"))}is6to4(){return this.isInSubnet(new r("2002::/16"))}isLoopback(){return this.getType()==="Loopback"}href(t){return t===void 0?t="":t=(0,ct.sprintf)(":%s",t),(0,ct.sprintf)("http://[%s]%s/",this.correctForm(),t)}link(t){t||(t={}),t.className===void 0&&(t.className=""),t.prefix===void 0&&(t.prefix="/#address="),t.v4===void 0&&(t.v4=!1);let e=this.correctForm;return t.v4&&(e=this.to4in6),t.className?(0,ct.sprintf)('<a href="%1$s%2$s" class="%3$s">%2$s</a>',t.prefix,e.call(this),t.className):(0,ct.sprintf)('<a href="%1$s%2$s">%2$s</a>',t.prefix,e.call(this))}group(){if(this.elidedGroups===0)return $n(this.address).join(":");Hn(typeof this.elidedGroups=="number"),Hn(typeof this.elisionBegin=="number");let t=[],[e,n]=this.address.split("::");e.length?t.push(...$n(e)):t.push("");let o=["hover-group"];for(let i=this.elisionBegin;i<this.elisionBegin+this.elidedGroups;i++)o.push((0,ct.sprintf)("group-%d",i));return t.push((0,ct.sprintf)('<span class="%s"></span>',o.join(" "))),n.length?t.push(...$n(n,this.elisionEnd)):t.push(""),this.is4()&&(Hn(this.address4 instanceof yt),t.pop(),t.push(this.address4.groupForV6())),t.join(":")}regularExpressionString(t=!1){let e=[],n=new r(this.correctForm());if(n.elidedGroups===0)e.push(Gn(n.parsedAddress));else if(n.elidedGroups===8)e.push(ws(8));else{let o=n.address.split("::");o[0].length&&e.push(Gn(o[0].split(":"))),Hn(typeof n.elidedGroups=="number"),e.push(ws(n.elidedGroups,o[0].length!==0,o[1].length!==0)),o[1].length&&e.push(Gn(o[1].split(":"))),e=[e.join(":")]}return t||(e=["(?=^|",ys,"|[^\\w\\:])(",...e,")(?=[^\\w\\:]|",ys,"|$)"]),e.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};var Ng=St("libp2p:ip-port-to-multiaddr"),Es={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function ou(r,t){if(typeof r!="string")throw new A(`invalid ip provided: ${r}`,Es.ERR_INVALID_IP_PARAMETER);if(typeof t=="string"&&(t=parseInt(t)),isNaN(t))throw new A(`invalid port provided: ${t}`,Es.ERR_INVALID_PORT_PARAMETER);try{return new yt(r),it(`/ip4/${r}/tcp/${t}`)}catch{}try{let e=new Fr(r);return e.is4()?it(`/ip4/${e.to4().correctForm()}/tcp/${t}`):it(`/ip6/${r}/tcp/${t}`)}catch{let n=`invalid ip:port for creating a multiaddr: ${r}:${t}`;throw Ng.error(n),new A(n,Es.ERR_INVALID_IP)}}var du=H(hu(),1);var Ss=H(Bt("os"),1),pu=H(Bt("path"),1);var Ug={ip4:"IPv4",ip6:"IPv6"};function hr(r,t={}){let e=r.getPath();return e!=null?Ss.default.platform()==="win32"?{path:pu.default.join("\\\\.\\pipe\\",e)}:{path:e}:{...r.toOptions(),...t}}function As(r,t,e){let n=o=>it(`/${r}/${o}/tcp/${e}`);return(Mg(t)?zg(Ug[r]):[t]).map(n)}function Mg(r){return["0.0.0.0","::"].includes(r)}var Fg=Ss.default.networkInterfaces();function zg(r){let t=[];for(let[,e]of Object.entries(Fg))if(e!=null)for(let n of e)n.family===r&&t.push(n.address);return t}var Gt=St("libp2p:tcp:socket"),Kn=(r,t)=>{let e=t.metrics,n=t.metricPrefix??"",o=t.socketInactivityTimeout??3e5,i=t.socketCloseTimeout??500;t.listeningAddr?.getPath()!=null&&(t.remoteAddr=t.listeningAddr),t.remoteAddr?.getPath()!=null&&(t.localAddr=t.remoteAddr);let s;if(t.remoteAddr!=null)s=t.remoteAddr;else{if(r.remoteAddress==null||r.remotePort==null)throw new A("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");s=ou(r.remoteAddress,r.remotePort)}let u=hr(s),l=u.path??`${u.host??""}:${u.port??""}`,{sink:m,source:h}=du.default.duplex(r);r.setTimeout(o,()=>{Gt("%s socket read timeout",l),e?.increment({[`${n}timeout`]:!0});let w;r.readable&&(w=new A("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),r.destroy(w)}),r.once("close",()=>{Gt("%s socket close",l),e?.increment({[`${n}close`]:!0}),g.timeline.close==null&&(g.timeline.close=Date.now())}),r.once("end",()=>{Gt("%s socket end",l),e?.increment({[`${n}end`]:!0})});let g={async sink(w){try{await m(w)}catch(I){I.type!=="aborted"&&Gt(I)}r.end()},source:h,remoteAddr:s,timeline:{open:Date.now()},async close(w={}){if(r.destroyed){Gt("%s socket was already destroyed when trying to close",l);return}w.signal=w.signal??AbortSignal.timeout(i);try{Gt("%s closing socket",l),await new Promise((I,p)=>{r.once("close",()=>{Gt("%s socket closed",l),I()}),r.once("error",y=>{Gt("%s socket error",l,y),g.timeline.close==null&&(g.timeline.close=Date.now()),p(y)}),r.setTimeout(i),r.end(),r.writableLength>0?r.once("drain",()=>{Gt("%s socket drained",l),r.destroy()}):r.destroy()})}catch(I){this.abort(I)}},abort:w=>{Gt("%s socket abort due to error",l,w),r.destroy(w)}};return g};var wt=St("libp2p:tcp:listener");async function Ts(r){try{await r.close()}catch(t){wt.error("an error occurred closing the connection",t)}}var Gg=1,Hg=0,jn=class extends Un{context;server;connections=new Set;status={started:!1};metrics;addr;constructor(t){if(super(),this.context=t,t.keepAlive=t.keepAlive??!0,this.addr="unknown",this.server=mu.default.createServer(t,this.onSocket.bind(this)),t.maxConnections!==void 0&&(this.server.maxConnections=t.maxConnections),t.closeServerOnMaxConnections!=null&&t.closeServerOnMaxConnections.closeAbove<t.closeServerOnMaxConnections.listenBelow)throw Error("closeAbove must be >= listenBelow");this.server.on("listening",()=>{if(t.metrics!=null){let e=this.server.address();e==null?this.addr="unknown":typeof e=="string"?this.addr=e:this.addr=`${e.address}:${e.port}`,t.metrics?.registerMetricGroup("libp2p_tcp_inbound_connections_total",{label:"address",help:"Current active connections in TCP listener",calculate:()=>({[this.addr]:this.connections.size})}),this.metrics={status:t.metrics.registerMetricGroup("libp2p_tcp_listener_status_info",{label:"address",help:"Current status of the TCP listener socket"}),errors:t.metrics.registerMetricGroup("libp2p_tcp_listener_errors_total",{label:"address",help:"Total count of TCP listener errors by type"}),events:t.metrics.registerMetricGroup("libp2p_tcp_listener_events_total",{label:"address",help:"Total count of TCP listener events by type"})},this.metrics?.status.update({[this.addr]:Gg})}this.dispatchEvent(new ar("listening"))}).on("error",e=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new ar("error",{detail:e}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:Hg}),this.dispatchEvent(new ar("close"))})}onSocket(t){t.on("error",n=>{wt("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let e;try{e=Kn(t,{listeningAddr:this.status.started?this.status.listeningAddr:void 0,socketInactivityTimeout:this.context.socketInactivityTimeout,socketCloseTimeout:this.context.socketCloseTimeout,metrics:this.metrics?.events,metricPrefix:`${this.addr} `})}catch(n){wt.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}wt("new inbound connection %s",e.remoteAddr);try{this.context.upgrader.upgradeInbound(e).then(n=>{wt("inbound connection upgraded %s",e.remoteAddr),this.connections.add(e),t.once("close",()=>{this.connections.delete(e),this.context.closeServerOnMaxConnections!=null&&this.connections.size<this.context.closeServerOnMaxConnections.listenBelow&&this.netListen().catch(o=>{wt.error("error attempting to listen server once connection count under limit",o),this.context.closeServerOnMaxConnections?.onListenError?.(o)})}),this.context.handler!=null&&this.context.handler(n),this.context.closeServerOnMaxConnections!=null&&this.connections.size>=this.context.closeServerOnMaxConnections.closeAbove&&this.netClose(),this.dispatchEvent(new ar("connection",{detail:n}))}).catch(async n=>{wt.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await Ts(e)}).catch(n=>{wt.error("closing inbound connection failed",n)})}catch(n){wt.error("inbound connection failed",n),Ts(e).catch(o=>{wt.error("closing inbound connection failed",o),this.metrics?.errors.increment({[`${this.addr} inbound_closing_failed`]:!0})})}}getAddrs(){if(!this.status.started)return[];let t=[],e=this.server.address(),{listeningAddr:n,peerId:o}=this.status;if(e==null)return[];if(typeof e=="string")t=[n];else try{n.toString().startsWith("/ip4")?t=t.concat(As("ip4",e.address,e.port)):e.family==="IPv6"&&(t=t.concat(As("ip6",e.address,e.port)))}catch(i){wt.error("could not turn %s:%s into multiaddr",e.address,e.port,i)}return t.map(i=>o!=null?i.encapsulate(`/p2p/${o}`):i)}async listen(t){if(this.status.started)throw Error("server is already listening");let e=t.getPeerId(),n=e==null?t.decapsulateCode(421):t,{backlog:o}=this.context;this.status={started:!0,listeningAddr:n,peerId:e,netConfig:hr(n,{backlog:o})},await this.netListen()}async close(){await Promise.all(Array.from(this.connections.values()).map(async t=>{await Ts(t)})),this.netClose()}async netListen(){if(!this.status.started||this.server.listening)return;let t=this.status.netConfig;await new Promise((e,n)=>{this.server.once("error",n),this.server.listen(t,e)}),wt("Listening on %s",this.server.address())}netClose(){!this.status.started||!this.server.listening||(wt("Closing server on %s",this.server.address()),this.server.close())}};var Wt=St("libp2p:tcp"),Cs=class{opts;metrics;components;constructor(t,e={}){this.opts=e,this.components=t,t.metrics!=null&&(this.metrics={dialerEvents:t.metrics.registerCounterGroup("libp2p_tcp_dialer_events_total",{label:"event",help:"Total count of TCP dialer events by type"})})}[Rc]=!0;[Symbol.toStringTag]="@libp2p/tcp";async dial(t,e){e.keepAlive=e.keepAlive??!0;let n=await this._connect(t,e);n.on("error",u=>{Wt("socket error",u)});let o=Kn(n,{remoteAddr:t,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents}),i=()=>{o.close().catch(u=>{Wt.error("Error closing maConn after abort",u)})};e.signal?.addEventListener("abort",i,{once:!0}),Wt("new outbound connection %s",o.remoteAddr);let s=await e.upgrader.upgradeOutbound(o);if(Wt("outbound connection %s upgraded",o.remoteAddr),e.signal?.removeEventListener("abort",i),e.signal?.aborted===!0)throw s.close().catch(u=>{Wt.error("Error closing conn after abort",u)}),new Ve;return s}async _connect(t,e){if(e.signal?.aborted===!0)throw new Ve;return new Promise((n,o)=>{let i=Date.now(),s=hr(t),u=s.path??`${s.host??""}:${s.port}`;Wt("dialing %j",s);let l=gu.default.connect(s),m=p=>{p.message=`connection error ${u}: ${p.message}`,this.metrics?.dialerEvents.increment({error:!0}),I(p)},h=()=>{Wt("connection timeout %s",u),this.metrics?.dialerEvents.increment({timeout:!0});let p=new A(`connection timeout after ${Date.now()-i}ms`,"ERR_CONNECT_TIMEOUT");l.emit("error",p)},g=()=>{Wt("connection opened %j",s),this.metrics?.dialerEvents.increment({connect:!0}),I()},w=()=>{Wt("connection aborted %j",s),this.metrics?.dialerEvents.increment({abort:!0}),l.destroy(),I(new Ve)},I=p=>{if(l.removeListener("error",m),l.removeListener("timeout",h),l.removeListener("connect",g),e.signal!=null&&e.signal.removeEventListener("abort",w),p!=null){o(p);return}n(l)};l.on("error",m),l.on("timeout",h),l.on("connect",g),e.signal!=null&&e.signal.addEventListener("abort",w)})}createListener(t){return new jn({...t,maxConnections:this.opts.maxConnections,backlog:this.opts.backlog,closeServerOnMaxConnections:this.opts.closeServerOnMaxConnections,socketInactivityTimeout:this.opts.inboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.components.metrics})}filter(t){return t=Array.isArray(t)?t:[t],t.filter(e=>e.protoCodes().includes(290)?!1:e.protoCodes().includes(400)?!0:ue.matches(e.decapsulateCode(421)))}};function bu(r={}){return(t={})=>new Cs(t,r)}var jg=Eu,yu=128,Jg=127,Yg=~Jg,Xg=Math.pow(2,31);function Eu(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Xg;)t[e++]=r&255|yu,r/=128;for(;r&Yg;)t[e++]=r&255|yu,r>>>=7;return t[e]=r|0,Eu.bytes=e-n+1,t}var Wg=Ds,Zg=128,wu=127;function Ds(r,n){var e=0,n=n||0,o=0,i=n,s,u=r.length;do{if(i>=u)throw Ds.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&wu)<<o:(s&wu)*Math.pow(2,o),o+=7}while(s>=Zg);return Ds.bytes=i-n,e}var Qg=Math.pow(2,7),tb=Math.pow(2,14),eb=Math.pow(2,21),rb=Math.pow(2,28),nb=Math.pow(2,35),ob=Math.pow(2,42),ib=Math.pow(2,49),sb=Math.pow(2,56),ab=Math.pow(2,63),cb=function(r){return r<Qg?1:r<tb?2:r<eb?3:r<rb?4:r<nb?5:r<ob?6:r<ib?7:r<sb?8:r<ab?9:10},fb={encode:jg,decode:Wg,encodingLength:cb},ub=fb,zr=ub;var Vr=(r,t=0)=>[zr.decode(r,t),zr.decode.bytes],pr=(r,t,e=0)=>(zr.encode(r,t,e),t),dr=r=>zr.encodingLength(r);var mx=new Uint8Array(0);var xu=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0},mr=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var Su=(r,t)=>{let e=t.byteLength,n=dr(r),o=n+dr(e),i=new Uint8Array(o+e);return pr(r,i,0),pr(e,i,n),i.set(t,o),new gr(r,e,t,i)},Au=r=>{let t=mr(r),[e,n]=Vr(t),[o,i]=Vr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new gr(e,o,s,t)},Tu=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&xu(r.bytes,e.bytes)}},gr=class{constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function hb(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var u=r.length,l=r.charAt(0),m=Math.log(u)/Math.log(256),h=Math.log(256)/Math.log(u);function g(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,x=0,v=0,S=p.length;v!==S&&p[v]===0;)v++,y++;for(var C=(S-v)*h+1>>>0,D=new Uint8Array(C);v!==S;){for(var N=p[v],P=0,B=C-1;(N!==0||P<x)&&B!==-1;B--,P++)N+=256*D[B]>>>0,D[B]=N%u>>>0,N=N/u>>>0;if(N!==0)throw new Error("Non-zero carry");x=P,v++}for(var O=C-x;O!==C&&D[O]===0;)O++;for(var V=l.repeat(y);O<C;++O)V+=r.charAt(D[O]);return V}function w(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var x=0,v=0;p[y]===l;)x++,y++;for(var S=(p.length-y)*m+1>>>0,C=new Uint8Array(S);p[y];){var D=e[p.charCodeAt(y)];if(D===255)return;for(var N=0,P=S-1;(D!==0||N<v)&&P!==-1;P--,N++)D+=u*C[P]>>>0,C[P]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");v=N,y++}if(p[y]!==" "){for(var B=S-v;B!==S&&C[B]===0;)B++;for(var O=new Uint8Array(x+(S-B)),V=x;B!==S;)O[V++]=C[B++];return O}}}function I(p){var y=w(p);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:w,decode:I}}var pb=hb,db=pb,Iu=db;var Rs=class{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},_s=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Cu(this,t)}},Bs=class{constructor(t){this.decoders=t}or(t){return Cu(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Cu=(r,t)=>new Bs({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Ns=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Rs(t,e,n),this.decoder=new _s(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Du=({name:r,prefix:t,encode:e,decode:n})=>new Ns(r,t,e,n),Ls=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=Iu(e,t);return Du({prefix:r,name:t,encode:n,decode:i=>mr(o(i))})},mb=(r,t,e,n)=>{let o={};for(let h=0;h<t.length;++h)o[t[h]]=h;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),u=0,l=0,m=0;for(let h=0;h<i;++h){let g=o[r[h]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|g,u+=e,u>=8&&(u-=8,s[m++]=255&l>>u)}if(u>=e||255&l<<8-u)throw new SyntaxError("Unexpected end of data");return s},gb=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,u=0;for(let l=0;l<r.length;++l)for(u=u<<8|r[l],s+=8;s>e;)s-=e,i+=t[o&u>>s];if(s&&(i+=t[o&u<<e-s]),n)for(;i.length*e&7;)i+="=";return i},Ht=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Du({prefix:t,name:r,encode(o){return gb(o,n,e)},decode(o){return mb(o,n,e,r)}});var Zt=Ls({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Sx=Ls({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var $r=Ht({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ix=Ht({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Cx=Ht({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Dx=Ht({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Rx=Ht({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),_x=Ht({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Bx=Ht({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Nx=Ht({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Lx=Ht({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ru=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return yb(e,Os(r),t||Zt.encoder);default:return wb(e,Os(r),t||$r.encoder)}};var _u=new WeakMap,Os=r=>{let t=_u.get(r);if(t==null){let e=new Map;return _u.set(r,e),e}return t},Hr=class r{constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Gr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Eb)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Su(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&Tu(t.multihash,n.multihash)}toString(t){return Ru(this,t)}toJSON(){return{"/":Ru(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:i,bytes:s}=e;return new r(n,o,i,s||Bu(n,o,i.bytes))}else if(e[vb]===!0){let{version:n,multihash:o,code:i}=e,s=Au(o);return r.create(n,i,s)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Gr)throw new Error(`Version 0 CID must use dag-pb (code: ${Gr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Bu(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Gr,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=mr(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),s=new gr(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[g,w]=Vr(t.subarray(e));return e+=w,g},o=n(),i=Gr;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=e,u=n(),l=n(),m=e+l,h=m-s;return{version:o,codec:i,multihashCode:u,digestSize:l,multihashSize:h,size:m}}static parse(t,e){let[n,o]=bb(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Os(i).set(n,t),i}},bb=(r,t)=>{switch(r[0]){case"Q":{let e=t||Zt;return[Zt.prefix,e.decode(`${Zt.prefix}${r}`)]}case Zt.prefix:{let e=t||Zt;return[Zt.prefix,e.decode(r)]}case $r.prefix:{let e=t||$r;return[$r.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},yb=(r,t,e)=>{let{prefix:n}=e;if(n!==Zt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o},wb=(r,t,e)=>{let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o},Gr=112,Eb=18,Bu=(r,t,e)=>{let n=dr(r),o=n+dr(t),i=new Uint8Array(o+e.byteLength);return pr(r,i,0),pr(t,i,n),i.set(e,o),i},vb=Symbol.for("@ipld/js-cid/CID");var Jn=class{client;constructor(t){this.client=t}async put(t,e){if(!(t instanceof Uint8Array))throw new A("invalid key received","ERR_INVALID_KEY");if(!(e instanceof Uint8Array))throw new A("value received is not a Uint8Array","ERR_INVALID_VALUE");let n=await this.client.send({type:q.Type.DHT,dht:{type:xt.Type.PUT_VALUE,key:t,value:e}}),o=await n.read();if(o==null)throw new A("Empty response from remote","ERR_EMPTY_RESPONSE");let i=M.decode(o);if(await n.close(),i.type!==M.Type.OK)throw new A(i.error?.msg??"DHT put failed","ERR_DHT_PUT_FAILED")}async get(t){if(!(t instanceof Uint8Array))throw new A("invalid key received","ERR_INVALID_KEY");let e=await this.client.send({type:q.Type.DHT,dht:{type:xt.Type.GET_VALUE,key:t}}),n=await e.read();if(n==null)throw new A("Empty response from remote","ERR_EMPTY_RESPONSE");let o=M.decode(n);if(await e.close(),o.type!==M.Type.OK)throw new A(o.error?.msg??"DHT get failed","ERR_DHT_GET_FAILED");if(o.dht==null||o.dht.value==null)throw new A("Invalid DHT get response","ERR_DHT_GET_FAILED");return o.dht.value}async findPeer(t){if(!$e(t))throw new A("invalid peer id received","ERR_INVALID_PEER_ID");let e=await this.client.send({type:q.Type.DHT,dht:{type:xt.Type.FIND_PEER,peer:t.toBytes()}}),n=await e.read();if(n==null)throw new A("Empty response from remote","ERR_EMPTY_RESPONSE");let o=M.decode(n);if(await e.close(),o.type!==M.Type.OK)throw new A(o.error?.msg??"DHT find peer failed","ERR_DHT_FIND_PEER_FAILED");if(o.dht==null||o.dht.peer==null||o.dht.peer.addrs==null)throw new A("Invalid response","ERR_DHT_FIND_PEER_FAILED");return{id:zt(o.dht.peer.id),multiaddrs:o.dht.peer.addrs.map(i=>it(i)),protocols:[]}}async provide(t){if(t==null||Hr.asCID(t)==null)throw new A("invalid cid received","ERR_INVALID_CID");let e=await this.client.send({type:q.Type.DHT,dht:{type:xt.Type.PROVIDE,cid:t.bytes}}),n=await e.read();if(n==null)throw new A("Empty response from remote","ERR_EMPTY_RESPONSE");let o=M.decode(n);if(await e.close(),o.type!==M.Type.OK)throw new A(o.error?.msg??"DHT provide failed","ERR_DHT_PROVIDE_FAILED")}async*findProviders(t,e=1){if(t==null||Hr.asCID(t)==null)throw new A("invalid cid received","ERR_INVALID_CID");let n=await this.client.send({type:q.Type.DHT,dht:{type:xt.Type.FIND_PROVIDERS,cid:t.bytes,count:e}}),o=await n.read();if(o==null)throw new A("Empty response from remote","ERR_EMPTY_RESPONSE");let i=M.decode(o);if(i.type!==M.Type.OK)throw await n.close(),new A(i.error?.msg??"DHT find providers failed","ERR_DHT_FIND_PROVIDERS_FAILED");for(;;){if(o=await n.read(),o==null)throw new A("Empty response from remote","ERR_EMPTY_RESPONSE");let s=Ot.decode(o);if(s.type===Ot.Type.END){await n.close();return}if(s.type===Ot.Type.VALUE&&s.peer!=null&&s.peer?.addrs!=null)yield{id:zt(s.peer.id),multiaddrs:s.peer.addrs.map(u=>it(u)),protocols:[]};else throw await n.close(),new A("unexpected message received","ERR_UNEXPECTED_MESSAGE_RECEIVED")}}async*getClosestPeers(t){if(!(t instanceof Uint8Array))throw new A("invalid key received","ERR_INVALID_KEY");let e=await this.client.send({type:q.Type.DHT,dht:{type:xt.Type.GET_CLOSEST_PEERS,key:t}}),n=await e.read();if(n==null)throw new A("Empty response from remote","ERR_EMPTY_RESPONSE");let o=M.decode(n);if(o.type!==M.Type.OK)throw await e.close(),new A(o.error?.msg??"DHT find providers failed","ERR_DHT_FIND_PROVIDERS_FAILED");for(;;){if(n=await e.read(),n==null)throw new A("Empty response from remote","ERR_EMPTY_RESPONSE");let i=Ot.decode(n);if(i.type===Ot.Type.END){await e.close();return}if(i.type===Ot.Type.VALUE&&i.value!=null)yield{id:zt(i.value),multiaddrs:[],protocols:[]};else throw await e.close(),new A("unexpected message received","ERR_UNEXPECTED_MESSAGE_RECEIVED")}}async getPublicKey(t){if(!$e(t))throw new A("invalid peer id received","ERR_INVALID_PEER_ID");let e=await this.client.send({type:q.Type.DHT,dht:{type:xt.Type.GET_PUBLIC_KEY,peer:t.toBytes()}}),n=await e.read();if(n==null)throw new A("Empty response from remote","ERR_EMPTY_RESPONSE");let o=M.decode(n);if(await e.close(),o.type!==M.Type.OK)throw new A(o.error?.msg??"DHT get public key failed","ERR_DHT_GET_PUBLIC_KEY_FAILED");if(o.dht==null)throw new A("Invalid response","ERR_DHT_GET_PUBLIC_KEY_FAILED");return o.dht.value}};var Yn=class{client;constructor(t){this.client=t}async getTopics(){let t=await this.client.send({type:q.Type.PUBSUB,pubsub:{type:jt.Type.GET_TOPICS}}),e=await t.read();if(e==null)throw new A("Empty response from remote","ERR_EMPTY_RESPONSE");let n=M.decode(e);if(await t.close(),n.type!==M.Type.OK)throw new A(n.error?.msg??"Pubsub get topics failed","ERR_PUBSUB_GET_TOPICS_FAILED");if(n.pubsub==null||n.pubsub.topics==null)throw new A("Invalid response","ERR_PUBSUB_GET_TOPICS_FAILED");return n.pubsub.topics}async publish(t,e){if(typeof t!="string")throw new A("invalid topic received","ERR_INVALID_TOPIC");if(!(e instanceof Uint8Array))throw new A("data received is not a Uint8Array","ERR_INVALID_DATA");let n=await this.client.send({type:q.Type.PUBSUB,pubsub:{type:jt.Type.PUBLISH,topic:t,data:e}}),o=await n.read();if(o==null)throw new A("Empty response from remote","ERR_EMPTY_RESPONSE");let i=M.decode(o);if(await n.close(),i.type!==M.Type.OK)throw new A(i.error?.msg??"Pubsub publish failed","ERR_PUBSUB_PUBLISH_FAILED")}async subscribe(t){if(typeof t!="string")throw new A("invalid topic received","ERR_INVALID_TOPIC");let e=await this.client.send({type:q.Type.PUBSUB,pubsub:{type:jt.Type.SUBSCRIBE,topic:t}}),n=await e.read();if(n==null)throw new A("Empty response from remote","ERR_EMPTY_RESPONSE");let o=M.decode(n);if(o.type!==M.Type.OK)throw new A(o.error?.msg??"Pubsub publish failed","ERR_PUBSUB_PUBLISH_FAILED");let i=!0;return{async*messages(){for(;i;){if(n=await e.read(),n==null)throw new A("Empty response from remote","ERR_EMPTY_RESPONSE");yield cn.decode(n)}},async cancel(){i=!1,await e.close()}}}async getSubscribers(t){if(typeof t!="string")throw new A("invalid topic received","ERR_INVALID_TOPIC");let e=await this.client.send({type:q.Type.PUBSUB,pubsub:{type:jt.Type.LIST_PEERS,topic:t}}),n=await e.read();if(n==null)throw new A("Empty response from remote","ERR_EMPTY_RESPONSE");let o=M.decode(n);if(await e.close(),o.type!==M.Type.OK)throw new A(o.error?.msg??"Pubsub get subscribers failed","ERR_PUBSUB_GET_SUBSCRIBERS_FAILED");if(o.pubsub==null||o.pubsub.topics==null)throw new A("Invalid response","ERR_PUBSUB_GET_SUBSCRIBERS_FAILED");return o.pubsub.peerIDs.map(i=>zt(i))}};var ks=St("libp2p:daemon-client"),Ps=class{multiaddr;dht;pubsub;tcp;constructor(t){this.multiaddr=t,this.tcp=bu()(),this.dht=new Jn(this),this.pubsub=new Yn(this)}async connectDaemon(){return this.tcp.dial(this.multiaddr,{upgrader:Ro})}async send(t){let e=await this.connectDaemon(),n=t.pubsub?.type??t.dht?.type??t.peerStore?.type??"";ks("send",t.type,n);let o=new xr({stream:e});return o.write(q.encode(t)),o}async connect(t,e){if(!$e(t))throw new A("invalid peer id received","ERR_INVALID_PEER_ID");if(!Array.isArray(e))throw new A("addrs received are not in an array","ERR_INVALID_ADDRS_TYPE");e.forEach(s=>{if(!ns(s))throw new A("received an address that is not a multiaddr","ERR_NO_MULTIADDR_RECEIVED")});let n=await this.send({type:q.Type.CONNECT,connect:{peer:t.toBytes(),addrs:e.map(s=>s.bytes)}}),o=await n.read();if(o==null)throw new A("unspecified","ERR_CONNECT_FAILED");let i=M.decode(o);if(i.type!==M.Type.OK){let s=i.error??{msg:"unspecified"};throw new A(s.msg??"unspecified","ERR_CONNECT_FAILED")}await n.close()}async identify(){let t=await this.send({type:q.Type.IDENTIFY}),e=await t.read();if(e==null)throw new A("Empty response from remote","ERR_EMPTY_RESPONSE");let n=M.decode(e);if(n.type!==M.Type.OK)throw new A(n.error?.msg??"Identify failed","ERR_IDENTIFY_FAILED");if(n.identify==null||n.identify.addrs==null)throw new A("Invalid response","ERR_IDENTIFY_FAILED");let o=zt(n.identify?.id),i=n.identify.addrs.map(s=>it(s));return await t.close(),{peerId:o,addrs:i}}async listPeers(){let t=await this.send({type:q.Type.LIST_PEERS}),e=await t.read();if(e==null)throw new A("Empty response from remote","ERR_EMPTY_RESPONSE");let n=M.decode(e);if(n.type!==M.Type.OK)throw new A(n.error?.msg??"List peers failed","ERR_LIST_PEERS_FAILED");return await t.close(),n.peers.map(o=>zt(o.id))}async openStream(t,e){if(!$e(t))throw new A("invalid peer id received","ERR_INVALID_PEER_ID");if(typeof e!="string")throw new A("invalid protocol received","ERR_INVALID_PROTOCOL");let n=await this.send({type:q.Type.STREAM_OPEN,streamOpen:{peer:t.toBytes(),proto:[e]}}),o=await n.read();if(o==null)throw new A("Empty response from remote","ERR_EMPTY_RESPONSE");let i=M.decode(o);if(i.type!==M.Type.OK)throw await n.close(),new A(i.error?.msg??"Open stream failed","ERR_OPEN_STREAM_FAILED");return n.rest()}async registerStreamHandler(t,e){if(typeof t!="string")throw new A("invalid protocol received","ERR_INVALID_PROTOCOL");let n=this.tcp.createListener({upgrader:Ro,handler:l=>{Promise.resolve().then(async()=>{let m=new xr({stream:l}),h=await m.read();if(h==null)throw new A("Could not read open stream response","ERR_OPEN_STREAM_FAILED");if(Le.decode(h).proto!==t)throw new A("Incorrect protocol","ERR_OPEN_STREAM_FAILED");await e(m.rest())}).finally(()=>{l.close().catch(m=>{ks.error(m)}),n.close().catch(m=>{ks.error(m)})})}});await n.listen(it("/ip4/127.0.0.1/tcp/0"));let o=n.getAddrs()[0];if(o==null)throw new A("Could not listen on port","ERR_REGISTER_STREAM_HANDLER_FAILED");let i=await this.send({type:q.Type.STREAM_HANDLER,streamHandler:{addr:o.bytes,proto:[t]}}),s=await i.read();if(s==null)throw new A("Empty response from remote","ERR_EMPTY_RESPONSE");let u=M.decode(s);if(await i.close(),u.type!==M.Type.OK)throw new A(u.error?.msg??"Register stream handler failed","ERR_REGISTER_STREAM_HANDLER_FAILED")}};function xb(r){return new Ps(r)}return bh(Sb);})();
|
|
4
|
+
`+o),r.push(n+"m+"+Be.exports.humanize(this.diff)+"\x1B[0m")}else r[0]=Gs()+t+" "+r[0]}function Gs(){return k.inspectOpts.hideDate?"":new Date().toISOString()+" "}function $s(...r){return process.stderr.write(Fe.format(...r)+`
|
|
5
|
+
`)}function zs(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function Hs(){return process.env.DEBUG}function Ks(r){r.inspectOpts={};let t=Object.keys(k.inspectOpts);for(let e=0;e<t.length;e++)r.inspectOpts[t[e]]=k.inspectOpts[t[e]]}Be.exports=Fr()(k);var{formatters:ii}=Be.exports;ii.o=function(r){return this.inspectOpts.colors=this.useColors,Fe.inspect(r,this.inspectOpts).split(`
|
|
6
|
+
`).map(t=>t.trim()).join(" ")};ii.O=function(r){return this.inspectOpts.colors=this.useColors,Fe.inspect(r,this.inspectOpts)}});var si=$((Cl,Mr)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Mr.exports=jn():Mr.exports=oi()});var pi=$((tu,hi)=>{"use strict";function fi(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function ec(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return fi(r,e)}catch{e.message=r.message,e.stack=r.stack;let n=function(){};return n.prototype=Object.create(Object.getPrototypeOf(r)),fi(new n,e)}}hi.exports=ec});var qe=$((tf,Hi)=>{Hi.exports=r=>{if(r[Symbol.asyncIterator])return r;if(r.getReader)return async function*(){let t=r.getReader();try{for(;;){let{done:e,value:i}=await t.read();if(e)return;yield i}}finally{t.releaseLock()}}();throw new Error("unknown stream")}});var Yi=$((ef,Ki)=>{Ki.exports=function(t){if(t){if(typeof t[Symbol.iterator]=="function")return t[Symbol.iterator]();if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t.next=="function")return t}throw new Error("argument is not an iterator or iterable")}});var hn=$((rf,Wi)=>{var Fc=Yi();Wi.exports=r=>async t=>{t=Fc(t);let e=E=>{typeof E.return=="function"&&E.return()},i=null,n=null,o=E=>{i=E,n&&n(E),e(t)},s=null,c=!1,a=()=>{c=!0,s&&s()},p=null,u=!1,d=()=>{u=!0,p&&p()},h=null,w=()=>{h&&h()},g=()=>new Promise((E,C)=>{s=h=E,n=C,r.once("drain",w)}),x=()=>(e(t),new Promise((E,C)=>{if(c||u||i)return E();p=s=E,n=C})),y=()=>{r.removeListener("error",o),r.removeListener("close",a),r.removeListener("finish",d),r.removeListener("drain",w)};r.once("error",o),r.once("close",a),r.once("finish",d);try{for await(let E of t){if(!r.writable||r.destroyed||i)break;r.write(E)===!1&&await g()}}catch(E){i||r.destroy(),i=E}try{if(r.writable&&r.end(),await x(),i)throw i}finally{y()}}});var pn=$((nf,Xi)=>{var Bc=hn(),Mc=qe();Xi.exports=r=>({sink:Bc(r),source:Mc(r)})});var Qi=$((of,Ji)=>{var Vc=pn();Ji.exports=r=>async function*(t){let e=Vc(r),i;if(e.sink(t).catch(n=>{i=n}),yield*e.source,i)throw i}});var Zi=$((sf,re)=>{re.exports=qe();re.exports.source=qe();re.exports.sink=hn();re.exports.transform=Qi();re.exports.duplex=pn()});var Qc={};J(Qc,{createClient:()=>Jc});var nr=new Float32Array([-0]),bt=new Uint8Array(nr.buffer);function An(r,t,e){nr[0]=r,t[e]=bt[0],t[e+1]=bt[1],t[e+2]=bt[2],t[e+3]=bt[3]}function Cn(r,t){return bt[0]=r[t],bt[1]=r[t+1],bt[2]=r[t+2],bt[3]=r[t+3],nr[0]}var ir=new Float64Array([-0]),U=new Uint8Array(ir.buffer);function Tn(r,t,e){ir[0]=r,t[e]=U[0],t[e+1]=U[1],t[e+2]=U[2],t[e+3]=U[3],t[e+4]=U[4],t[e+5]=U[5],t[e+6]=U[6],t[e+7]=U[7]}function Sn(r,t){return U[0]=r[t],U[1]=r[t+1],U[2]=r[t+2],U[3]=r[t+3],U[4]=r[t+4],U[5]=r[t+5],U[6]=r[t+6],U[7]=r[t+7],ir[0]}var lo=BigInt(Number.MAX_SAFE_INTEGER),uo=BigInt(Number.MIN_SAFE_INTEGER),z=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,i=~this.hi>>>0;return e===0&&(i=i+1>>>0),-(e+i*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,i=~this.hi>>>0;return e===0&&(i=i+1>>>0),-(BigInt(e)+(BigInt(i)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,i=this.hi>>>24;return i===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:i<128?9:10}static fromBigInt(t){if(t===0n)return vt;if(t<lo&&t>uo)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let i=t>>32n,n=t-(i<<32n);return e&&(i=~i|0n,n=~n|0n,++n>vn&&(n=0n,++i>vn&&(i=0n))),new r(Number(n),Number(i))}static fromNumber(t){if(t===0)return vt;let e=t<0;e&&(t=-t);let i=t>>>0,n=(t-i)/4294967296>>>0;return e&&(n=~n>>>0,i=~i>>>0,++i>4294967295&&(i=0,++n>4294967295&&(n=0))),new r(i,n)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):vt}},vt=new z(0,0);vt.toBigInt=function(){return 0n};vt.zzEncode=vt.zzDecode=function(){return this};vt.length=function(){return 1};var vn=4294967296n;function Rn(r){let t=0,e=0;for(let i=0;i<r.length;++i)e=r.charCodeAt(i),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(i+1)&64512)===56320?(++i,t+=4):t+=3;return t}function Dn(r,t,e){if(e-t<1)return"";let n,o=[],s=0,c;for(;t<e;)c=r[t++],c<128?o[s++]=c:c>191&&c<224?o[s++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,o[s++]=55296+(c>>10),o[s++]=56320+(c&1023)):o[s++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,s>8191&&((n??(n=[])).push(String.fromCharCode.apply(String,o)),s=0);return n!=null?(s>0&&n.push(String.fromCharCode.apply(String,o.slice(0,s))),n.join("")):String.fromCharCode.apply(String,o.slice(0,s))}function or(r,t,e){let i=e,n,o;for(let s=0;s<r.length;++s)n=r.charCodeAt(s),n<128?t[e++]=n:n<2048?(t[e++]=n>>6|192,t[e++]=n&63|128):(n&64512)===55296&&((o=r.charCodeAt(s+1))&64512)===56320?(n=65536+((n&1023)<<10)+(o&1023),++s,t[e++]=n>>18|240,t[e++]=n>>12&63|128,t[e++]=n>>6&63|128,t[e++]=n&63|128):(t[e++]=n>>12|224,t[e++]=n>>6&63|128,t[e++]=n&63|128);return e-i}function ot(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Ee(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var sr=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,ot(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw ot(this,4);return Ee(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw ot(this,4);return Ee(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw ot(this,4);let t=Cn(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw ot(this,4);let t=Sn(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,i=this.pos+t;if(i>this.len)throw ot(this,t);return this.pos+=t,e===i?new Uint8Array(0):this.buf.subarray(e,i)}string(){let t=this.bytes();return Dn(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw ot(this,t);this.pos+=t}else do if(this.pos>=this.len)throw ot(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new z(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw ot(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw ot(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw ot(this,8);let t=Ee(this.buf,this.pos+=4),e=Ee(this.buf,this.pos+=4);return new z(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){return this.readLongVarint().toNumber(!0)}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 cr(r){return new sr(r instanceof Uint8Array?r:r.subarray())}function R(r,t){let e=cr(r);return t.decode(e)}function Rt(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function ht(r=0){return globalThis.Buffer?.alloc!=null?Rt(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function F(r=0){return globalThis.Buffer?.allocUnsafe!=null?Rt(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}var fr={};J(fr,{base10:()=>yo});function fo(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),i=0;i<e.length;i++)e[i]=255;for(var n=0;n<r.length;n++){var o=r.charAt(n),s=o.charCodeAt(0);if(e[s]!==255)throw new TypeError(o+" is ambiguous");e[s]=n}var c=r.length,a=r.charAt(0),p=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function d(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var x=0,y=0,E=0,C=g.length;E!==C&&g[E]===0;)E++,x++;for(var L=(C-E)*u+1>>>0,P=new Uint8Array(L);E!==C;){for(var W=g[E],q=0,X=L-1;(W!==0||q<y)&&X!==-1;X--,q++)W+=256*P[X]>>>0,P[X]=W%c>>>0,W=W/c>>>0;if(W!==0)throw new Error("Non-zero carry");y=q,E++}for(var j=L-y;j!==L&&P[j]===0;)j++;for(var Bt=a.repeat(x);j<L;++j)Bt+=r.charAt(P[j]);return Bt}function h(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var x=0;if(g[x]!==" "){for(var y=0,E=0;g[x]===a;)y++,x++;for(var C=(g.length-x)*p+1>>>0,L=new Uint8Array(C);g[x];){var P=e[g.charCodeAt(x)];if(P===255)return;for(var W=0,q=C-1;(P!==0||W<E)&&q!==-1;q--,W++)P+=c*L[q]>>>0,L[q]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");E=W,x++}if(g[x]!==" "){for(var X=C-E;X!==C&&L[X]===0;)X++;for(var j=new Uint8Array(y+(C-X)),Bt=y;X!==C;)j[Bt++]=L[X++];return j}}}function w(g){var x=h(g);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:d,decodeUnsafe:h,decode:w}}var ho=fo,po=ho,Ln=po;var la=new Uint8Array(0);var Nn=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0},tt=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var Pn=r=>new TextEncoder().encode(r),On=r=>new TextDecoder().decode(r);var ar=class{constructor(t,e,i){this.name=t,this.prefix=e,this.baseEncode=i}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},lr=class{constructor(t,e,i){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=i}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Un(this,t)}},ur=class{constructor(t){this.decoders=t}or(t){return Un(this,t)}decode(t){let e=t[0],i=this.decoders[e];if(i)return i.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Un=(r,t)=>new ur({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),dr=class{constructor(t,e,i,n){this.name=t,this.prefix=e,this.baseEncode=i,this.baseDecode=n,this.encoder=new ar(t,e,i),this.decoder=new lr(t,e,n)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Mt=({name:r,prefix:t,encode:e,decode:i})=>new dr(r,t,e,i),wt=({prefix:r,name:t,alphabet:e})=>{let{encode:i,decode:n}=Ln(e,t);return Mt({prefix:r,name:t,encode:i,decode:o=>tt(n(o))})},mo=(r,t,e,i)=>{let n={};for(let u=0;u<t.length;++u)n[t[u]]=u;let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),c=0,a=0,p=0;for(let u=0;u<o;++u){let d=n[r[u]];if(d===void 0)throw new SyntaxError(`Non-${i} character`);a=a<<e|d,c+=e,c>=8&&(c-=8,s[p++]=255&a>>c)}if(c>=e||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return s},go=(r,t,e)=>{let i=t[t.length-1]==="=",n=(1<<e)-1,o="",s=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],s+=8;s>e;)s-=e,o+=t[n&c>>s];if(s&&(o+=t[n&c<<e-s]),i)for(;o.length*e&7;)o+="=";return o},T=({name:r,prefix:t,bitsPerChar:e,alphabet:i})=>Mt({prefix:t,name:r,encode(n){return go(n,i,e)},decode(n){return mo(n,i,e,r)}});var yo=wt({prefix:"9",name:"base10",alphabet:"0123456789"});var hr={};J(hr,{base16:()=>Eo,base16upper:()=>bo});var Eo=T({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),bo=T({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var pr={};J(pr,{base2:()=>wo});var wo=T({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var mr={};J(mr,{base256emoji:()=>To});var Fn=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}"),xo=Fn.reduce((r,t,e)=>(r[e]=t,r),[]),Io=Fn.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Ao(r){return r.reduce((t,e)=>(t+=xo[e],t),"")}function Co(r){let t=[];for(let e of r){let i=Io[e.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(i)}return new Uint8Array(t)}var To=Mt({prefix:"\u{1F680}",name:"base256emoji",encode:Ao,decode:Co});var gr={};J(gr,{base32:()=>st,base32hex:()=>Do,base32hexpad:()=>Lo,base32hexpadupper:()=>No,base32hexupper:()=>_o,base32pad:()=>vo,base32padupper:()=>Ro,base32upper:()=>So,base32z:()=>Po});var st=T({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),So=T({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),vo=T({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ro=T({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Do=T({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),_o=T({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Lo=T({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),No=T({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Po=T({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var yr={};J(yr,{base36:()=>Oo,base36upper:()=>ko});var Oo=wt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ko=wt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Er={};J(Er,{base58btc:()=>N,base58flickr:()=>Uo});var N=wt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Uo=wt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var wr={};J(wr,{base64:()=>br,base64pad:()=>Fo,base64url:()=>Bo,base64urlpad:()=>Mo});var br=T({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Fo=T({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Bo=T({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Mo=T({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var xr={};J(xr,{base8:()=>Vo});var Vo=T({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ir={};J(Ir,{identity:()=>Go});var Go=Mt({prefix:"\0",name:"identity",encode:r=>On(r),decode:r=>Pn(r)});var Ca=new TextEncoder,Ta=new TextDecoder;var Cr={};J(Cr,{identity:()=>we});var Ho=Vn,Bn=128,Ko=127,Yo=~Ko,Wo=Math.pow(2,31);function Vn(r,t,e){t=t||[],e=e||0;for(var i=e;r>=Wo;)t[e++]=r&255|Bn,r/=128;for(;r&Yo;)t[e++]=r&255|Bn,r>>>=7;return t[e]=r|0,Vn.bytes=e-i+1,t}var Xo=Ar,Jo=128,Mn=127;function Ar(r,i){var e=0,i=i||0,n=0,o=i,s,c=r.length;do{if(o>=c)throw Ar.bytes=0,new RangeError("Could not decode varint");s=r[o++],e+=n<28?(s&Mn)<<n:(s&Mn)*Math.pow(2,n),n+=7}while(s>=Jo);return Ar.bytes=o-i,e}var Qo=Math.pow(2,7),Zo=Math.pow(2,14),qo=Math.pow(2,21),jo=Math.pow(2,28),ts=Math.pow(2,35),es=Math.pow(2,42),rs=Math.pow(2,49),ns=Math.pow(2,56),is=Math.pow(2,63),os=function(r){return r<Qo?1:r<Zo?2:r<qo?3:r<jo?4:r<ts?5:r<es?6:r<rs?7:r<ns?8:r<is?9:10},ss={encode:Ho,decode:Xo,encodingLength:os},cs=ss,ie=cs;var oe=(r,t=0)=>[ie.decode(r,t),ie.decode.bytes],Vt=(r,t,e=0)=>(ie.encode(r,t,e),t),Gt=r=>ie.encodingLength(r);var xt=(r,t)=>{let e=t.byteLength,i=Gt(r),n=i+Gt(e),o=new Uint8Array(n+e);return Vt(r,o,0),Vt(e,o,i),o.set(t,n),new $t(r,e,t,o)},Dt=r=>{let t=tt(r),[e,i]=oe(t),[n,o]=oe(t.subarray(i)),s=t.subarray(i+o);if(s.byteLength!==n)throw new Error("Incorrect length");return new $t(e,n,s,t)},Gn=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Nn(r.bytes,e.bytes)}},$t=class{constructor(t,e,i,n){this.code=t,this.size=e,this.digest=i,this.bytes=n}};var $n=0,as="identity",zn=tt,ls=r=>xt($n,zn(r)),we={code:$n,name:as,encode:zn,digest:ls};var Rr={};J(Rr,{sha256:()=>xe,sha512:()=>us});var vr=Et(ft("crypto"),1);var Sr=({name:r,code:t,encode:e})=>new Tr(r,t,e),Tr=class{constructor(t,e,i){this.name=t,this.code=e,this.encode=i}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?xt(this.code,e):e.then(i=>xt(this.code,i))}else throw Error("Unknown type, must be binary type")}};var xe=Sr({name:"sha2-256",code:18,encode:r=>tt(vr.default.createHash("sha256").update(r).digest())}),us=Sr({name:"sha2-512",code:19,encode:r=>tt(vr.default.createHash("sha512").update(r).digest())});var Kn=(r,t)=>{let{bytes:e,version:i}=r;switch(i){case 0:return fs(e,Dr(r),t||N.encoder);default:return hs(e,Dr(r),t||st.encoder)}};var Yn=new WeakMap,Dr=r=>{let t=Yn.get(r);if(t==null){let e=new Map;return Yn.set(r,e),e}return t},H=class r{constructor(t,e,i,n){this.code=e,this.version=t,this.multihash=i,this.bytes=n,this["/"]=n}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==se)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==ps)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,i=xt(t,e);return r.createV1(this.code,i)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let i=e;return i&&t.code===i.code&&t.version===i.version&&Gn(t.multihash,i.multihash)}toString(t){return Kn(this,t)}toJSON(){return{"/":Kn(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:i,code:n,multihash:o,bytes:s}=e;return new r(i,n,o,s||Wn(i,n,o.bytes))}else if(e[ms]===!0){let{version:i,multihash:n,code:o}=e,s=Dt(n);return r.create(i,o,s)}else return null}static create(t,e,i){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(i.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==se)throw new Error(`Version 0 CID must use dag-pb (code: ${se}) block encoding`);return new r(t,e,i,i.bytes)}case 1:{let n=Wn(t,e,i.bytes);return new r(t,e,i,n)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,se,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,i]=r.decodeFirst(t);if(i.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),i=e.size-e.multihashSize,n=tt(t.subarray(i,i+e.multihashSize));if(n.byteLength!==e.multihashSize)throw new Error("Incorrect length");let o=n.subarray(e.multihashSize-e.digestSize),s=new $t(e.multihashCode,e.digestSize,o,n);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,i=()=>{let[d,h]=oe(t.subarray(e));return e+=h,d},n=i(),o=se;if(n===18?(n=0,e=0):o=i(),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let s=e,c=i(),a=i(),p=e+a,u=p-s;return{version:n,codec:o,multihashCode:c,digestSize:a,multihashSize:u,size:p}}static parse(t,e){let[i,n]=ds(t,e),o=r.decode(n);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Dr(o).set(i,t),o}},ds=(r,t)=>{switch(r[0]){case"Q":{let e=t||N;return[N.prefix,e.decode(`${N.prefix}${r}`)]}case N.prefix:{let e=t||N;return[N.prefix,e.decode(r)]}case st.prefix:{let e=t||st;return[st.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},fs=(r,t,e)=>{let{prefix:i}=e;if(i!==N.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let n=t.get(i);if(n==null){let o=e.encode(r).slice(1);return t.set(i,o),o}else return n},hs=(r,t,e)=>{let{prefix:i}=e,n=t.get(i);if(n==null){let o=e.encode(r);return t.set(i,o),o}else return n},se=112,ps=18,Wn=(r,t,e)=>{let i=Gt(r),n=i+Gt(t),o=new Uint8Array(n+e.byteLength);return Vt(r,o,0),Vt(t,o,i),o.set(e,n),o},ms=Symbol.for("@ipld/js-cid/CID");var It={...Ir,...pr,...xr,...fr,...hr,...gr,...yr,...Er,...wr,...mr},$a={...Rr,...Cr};function Jn(r,t,e,i){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:i}}}var Xn=Jn("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),_r=Jn("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=F(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),gs={utf8:Xn,"utf-8":Xn,hex:It.base16,latin1:_r,ascii:_r,binary:_r,...It},Ie=gs;function ce(r,t="utf8"){let e=Ie[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Rt(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function Lr(r){let t=r??8192,e=t>>>1,i,n=t;return function(s){if(s<1||s>e)return F(s);n+s>t&&(i=F(t),n=0);let c=i.subarray(n,n+=s);return n&7&&(n=(n|7)+1),c}}var Lt=class{fn;len;next;val;constructor(t,e,i){this.fn=t,this.len=e,this.next=void 0,this.val=i}};function Nr(){}var Or=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},ys=Lr();function Es(r){return globalThis.Buffer!=null?F(r):ys(r)}var ue=class{len;head;tail;states;constructor(){this.len=0,this.head=new Lt(Nr,0,0),this.tail=this.head,this.states=null}_push(t,e,i){return this.tail=this.tail.next=new Lt(t,e,i),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new kr((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(ae,10,z.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=z.fromBigInt(t);return this._push(ae,e.length(),e)}uint64Number(t){let e=z.fromNumber(t);return this._push(ae,e.length(),e)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=z.fromBigInt(t).zzEncode();return this._push(ae,e.length(),e)}sint64Number(t){let e=z.fromNumber(t).zzEncode();return this._push(ae,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Pr,1,t?1:0)}fixed32(t){return this._push(le,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=z.fromBigInt(t);return this._push(le,4,e.lo)._push(le,4,e.hi)}fixed64Number(t){let e=z.fromNumber(t);return this._push(le,4,e.lo)._push(le,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(An,4,t)}double(t){return this._push(Tn,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Pr,1,0):this.uint32(e)._push(ws,e,t)}string(t){let e=Rn(t);return e!==0?this.uint32(e)._push(or,e,t):this._push(Pr,1,0)}fork(){return this.states=new Or(this),this.head=this.tail=new Lt(Nr,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 Lt(Nr,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,i=this.len;return this.reset().uint32(i),i!==0&&(this.tail.next=t.next,this.tail=e,this.len+=i),this}finish(){let t=this.head.next,e=Es(this.len),i=0;for(;t!=null;)t.fn(t.val,e,i),i+=t.len,t=t.next;return e}};function Pr(r,t,e){t[e]=r&255}function bs(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var kr=class extends Lt{next;constructor(t,e){super(bs,t,e),this.next=void 0}};function ae(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function le(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function ws(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(ue.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(xs,t,r),this},ue.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Is,t,r),this});function xs(r,t,e){t.set(r,e)}function Is(r,t,e){r.length<40?or(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(ce(r),e)}function Ur(){return new ue}function D(r,t){let e=Ur();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var zt;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(zt||(zt={}));function Ae(r,t,e,i){return{name:r,type:t,encode:e,decode:i}}function pt(r){function t(n){if(r[n.toString()]==null)throw new Error("Invalid enum value");return r[n]}let e=function(o,s){let c=t(o);s.int32(c)},i=function(o){let s=o.int32();return t(s)};return Ae("enum",zt.VARINT,e,i)}function _(r,t){return Ae("message",zt.LENGTH_DELIMITED,r,t)}var S;(function(r){let t;(function(n){n.IDENTIFY="IDENTIFY",n.CONNECT="CONNECT",n.STREAM_OPEN="STREAM_OPEN",n.STREAM_HANDLER="STREAM_HANDLER",n.DHT="DHT",n.LIST_PEERS="LIST_PEERS",n.CONNMANAGER="CONNMANAGER",n.DISCONNECT="DISCONNECT",n.PUBSUB="PUBSUB",n.PEERSTORE="PEERSTORE"})(t=r.Type||(r.Type={}));let e;(function(n){n[n.IDENTIFY=0]="IDENTIFY",n[n.CONNECT=1]="CONNECT",n[n.STREAM_OPEN=2]="STREAM_OPEN",n[n.STREAM_HANDLER=3]="STREAM_HANDLER",n[n.DHT=4]="DHT",n[n.LIST_PEERS=5]="LIST_PEERS",n[n.CONNMANAGER=6]="CONNMANAGER",n[n.DISCONNECT=7]="DISCONNECT",n[n.PUBSUB=8]="PUBSUB",n[n.PEERSTORE=9]="PEERSTORE"})(e||(e={})),function(n){n.codec=()=>pt(e)}(t=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=_((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.connect!=null&&(o.uint32(18),Te.codec().encode(n.connect,o)),n.streamOpen!=null&&(o.uint32(26),Se.codec().encode(n.streamOpen,o)),n.streamHandler!=null&&(o.uint32(34),ve.codec().encode(n.streamHandler,o)),n.dht!=null&&(o.uint32(42),et.codec().encode(n.dht,o)),n.connManager!=null&&(o.uint32(50),De.codec().encode(n.connManager,o)),n.disconnect!=null&&(o.uint32(58),_e.codec().encode(n.disconnect,o)),n.pubsub!=null&&(o.uint32(66),mt.codec().encode(n.pubsub,o)),n.peerStore!=null&&(o.uint32(74),Pe.codec().encode(n.peerStore,o)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let a=n.uint32();switch(a>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.connect=Te.codec().decode(n,n.uint32());break;case 3:s.streamOpen=Se.codec().decode(n,n.uint32());break;case 4:s.streamHandler=ve.codec().decode(n,n.uint32());break;case 5:s.dht=et.codec().decode(n,n.uint32());break;case 6:s.connManager=De.codec().decode(n,n.uint32());break;case 7:s.disconnect=_e.codec().decode(n,n.uint32());break;case 8:s.pubsub=mt.codec().decode(n,n.uint32());break;case 9:s.peerStore=Pe.codec().decode(n,n.uint32());break;default:n.skipType(a&7);break}}return s})),i),r.encode=n=>D(n,r.codec()),r.decode=n=>R(n,r.codec())})(S||(S={}));var b;(function(r){let t;(function(n){n.OK="OK",n.ERROR="ERROR"})(t=r.Type||(r.Type={}));let e;(function(n){n[n.OK=0]="OK",n[n.ERROR=1]="ERROR"})(e||(e={})),function(n){n.codec=()=>pt(e)}(t=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=_((n,o,s={})=>{if(s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.error!=null&&(o.uint32(18),Re.codec().encode(n.error,o)),n.streamInfo!=null&&(o.uint32(26),Ht.codec().encode(n.streamInfo,o)),n.identify!=null&&(o.uint32(34),Ce.codec().encode(n.identify,o)),n.dht!=null&&(o.uint32(42),ct.codec().encode(n.dht,o)),n.peers!=null)for(let c of n.peers)o.uint32(50),At.codec().encode(c,o);n.pubsub!=null&&(o.uint32(58),Ne.codec().encode(n.pubsub,o)),n.peerStore!=null&&(o.uint32(66),Oe.codec().encode(n.peerStore,o)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={peers:[]},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let a=n.uint32();switch(a>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.error=Re.codec().decode(n,n.uint32());break;case 3:s.streamInfo=Ht.codec().decode(n,n.uint32());break;case 4:s.identify=Ce.codec().decode(n,n.uint32());break;case 5:s.dht=ct.codec().decode(n,n.uint32());break;case 6:s.peers.push(At.codec().decode(n,n.uint32()));break;case 7:s.pubsub=Ne.codec().decode(n,n.uint32());break;case 8:s.peerStore=Oe.codec().decode(n,n.uint32());break;default:n.skipType(a&7);break}}return s})),i),r.encode=n=>D(n,r.codec()),r.decode=n=>R(n,r.codec())})(b||(b={}));var Ce;(function(r){let t;r.codec=()=>(t==null&&(t=_((e,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),e.id!=null&&e.id.byteLength>0&&(i.uint32(10),i.bytes(e.id)),e.addrs!=null)for(let o of e.addrs)i.uint32(18),i.bytes(o);n.lengthDelimited!==!1&&i.ldelim()},(e,i)=>{let n={id:new Uint8Array(0),addrs:[]},o=i==null?e.len:e.pos+i;for(;e.pos<o;){let s=e.uint32();switch(s>>>3){case 1:n.id=e.bytes();break;case 2:n.addrs.push(e.bytes());break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(Ce||(Ce={}));var Te;(function(r){let t;r.codec=()=>(t==null&&(t=_((e,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),e.peer!=null&&e.peer.byteLength>0&&(i.uint32(10),i.bytes(e.peer)),e.addrs!=null)for(let o of e.addrs)i.uint32(18),i.bytes(o);e.timeout!=null&&(i.uint32(24),i.int64(e.timeout)),n.lengthDelimited!==!1&&i.ldelim()},(e,i)=>{let n={peer:new Uint8Array(0),addrs:[]},o=i==null?e.len:e.pos+i;for(;e.pos<o;){let s=e.uint32();switch(s>>>3){case 1:n.peer=e.bytes();break;case 2:n.addrs.push(e.bytes());break;case 3:n.timeout=e.int64();break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(Te||(Te={}));var Se;(function(r){let t;r.codec=()=>(t==null&&(t=_((e,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),e.peer!=null&&e.peer.byteLength>0&&(i.uint32(10),i.bytes(e.peer)),e.proto!=null)for(let o of e.proto)i.uint32(18),i.string(o);e.timeout!=null&&(i.uint32(24),i.int64(e.timeout)),n.lengthDelimited!==!1&&i.ldelim()},(e,i)=>{let n={peer:new Uint8Array(0),proto:[]},o=i==null?e.len:e.pos+i;for(;e.pos<o;){let s=e.uint32();switch(s>>>3){case 1:n.peer=e.bytes();break;case 2:n.proto.push(e.string());break;case 3:n.timeout=e.int64();break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(Se||(Se={}));var ve;(function(r){let t;r.codec=()=>(t==null&&(t=_((e,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),e.addr!=null&&e.addr.byteLength>0&&(i.uint32(10),i.bytes(e.addr)),e.proto!=null)for(let o of e.proto)i.uint32(18),i.string(o);n.lengthDelimited!==!1&&i.ldelim()},(e,i)=>{let n={addr:new Uint8Array(0),proto:[]},o=i==null?e.len:e.pos+i;for(;e.pos<o;){let s=e.uint32();switch(s>>>3){case 1:n.addr=e.bytes();break;case 2:n.proto.push(e.string());break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(ve||(ve={}));var Re;(function(r){let t;r.codec=()=>(t==null&&(t=_((e,i,n={})=>{n.lengthDelimited!==!1&&i.fork(),e.msg!=null&&e.msg!==""&&(i.uint32(10),i.string(e.msg)),n.lengthDelimited!==!1&&i.ldelim()},(e,i)=>{let n={msg:""},o=i==null?e.len:e.pos+i;for(;e.pos<o;){let s=e.uint32();switch(s>>>3){case 1:n.msg=e.string();break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(Re||(Re={}));var Ht;(function(r){let t;r.codec=()=>(t==null&&(t=_((e,i,n={})=>{n.lengthDelimited!==!1&&i.fork(),e.peer!=null&&e.peer.byteLength>0&&(i.uint32(10),i.bytes(e.peer)),e.addr!=null&&e.addr.byteLength>0&&(i.uint32(18),i.bytes(e.addr)),e.proto!=null&&e.proto!==""&&(i.uint32(26),i.string(e.proto)),n.lengthDelimited!==!1&&i.ldelim()},(e,i)=>{let n={peer:new Uint8Array(0),addr:new Uint8Array(0),proto:""},o=i==null?e.len:e.pos+i;for(;e.pos<o;){let s=e.uint32();switch(s>>>3){case 1:n.peer=e.bytes();break;case 2:n.addr=e.bytes();break;case 3:n.proto=e.string();break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(Ht||(Ht={}));var et;(function(r){let t;(function(n){n.FIND_PEER="FIND_PEER",n.FIND_PEERS_CONNECTED_TO_PEER="FIND_PEERS_CONNECTED_TO_PEER",n.FIND_PROVIDERS="FIND_PROVIDERS",n.GET_CLOSEST_PEERS="GET_CLOSEST_PEERS",n.GET_PUBLIC_KEY="GET_PUBLIC_KEY",n.GET_VALUE="GET_VALUE",n.SEARCH_VALUE="SEARCH_VALUE",n.PUT_VALUE="PUT_VALUE",n.PROVIDE="PROVIDE"})(t=r.Type||(r.Type={}));let e;(function(n){n[n.FIND_PEER=0]="FIND_PEER",n[n.FIND_PEERS_CONNECTED_TO_PEER=1]="FIND_PEERS_CONNECTED_TO_PEER",n[n.FIND_PROVIDERS=2]="FIND_PROVIDERS",n[n.GET_CLOSEST_PEERS=3]="GET_CLOSEST_PEERS",n[n.GET_PUBLIC_KEY=4]="GET_PUBLIC_KEY",n[n.GET_VALUE=5]="GET_VALUE",n[n.SEARCH_VALUE=6]="SEARCH_VALUE",n[n.PUT_VALUE=7]="PUT_VALUE",n[n.PROVIDE=8]="PROVIDE"})(e||(e={})),function(n){n.codec=()=>pt(e)}(t=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=_((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),o.bytes(n.peer)),n.cid!=null&&(o.uint32(26),o.bytes(n.cid)),n.key!=null&&(o.uint32(34),o.bytes(n.key)),n.value!=null&&(o.uint32(42),o.bytes(n.value)),n.count!=null&&(o.uint32(48),o.int32(n.count)),n.timeout!=null&&(o.uint32(56),o.int64(n.timeout)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let a=n.uint32();switch(a>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.peer=n.bytes();break;case 3:s.cid=n.bytes();break;case 4:s.key=n.bytes();break;case 5:s.value=n.bytes();break;case 6:s.count=n.int32();break;case 7:s.timeout=n.int64();break;default:n.skipType(a&7);break}}return s})),i),r.encode=n=>D(n,r.codec()),r.decode=n=>R(n,r.codec())})(et||(et={}));var ct;(function(r){let t;(function(n){n.BEGIN="BEGIN",n.VALUE="VALUE",n.END="END"})(t=r.Type||(r.Type={}));let e;(function(n){n[n.BEGIN=0]="BEGIN",n[n.VALUE=1]="VALUE",n[n.END=2]="END"})(e||(e={})),function(n){n.codec=()=>pt(e)}(t=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=_((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),At.codec().encode(n.peer,o)),n.value!=null&&(o.uint32(26),o.bytes(n.value)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let a=n.uint32();switch(a>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.peer=At.codec().decode(n,n.uint32());break;case 3:s.value=n.bytes();break;default:n.skipType(a&7);break}}return s})),i),r.encode=n=>D(n,r.codec()),r.decode=n=>R(n,r.codec())})(ct||(ct={}));var At;(function(r){let t;r.codec=()=>(t==null&&(t=_((e,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),e.id!=null&&e.id.byteLength>0&&(i.uint32(10),i.bytes(e.id)),e.addrs!=null)for(let o of e.addrs)i.uint32(18),i.bytes(o);n.lengthDelimited!==!1&&i.ldelim()},(e,i)=>{let n={id:new Uint8Array(0),addrs:[]},o=i==null?e.len:e.pos+i;for(;e.pos<o;){let s=e.uint32();switch(s>>>3){case 1:n.id=e.bytes();break;case 2:n.addrs.push(e.bytes());break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(At||(At={}));var De;(function(r){let t;(function(n){n.TAG_PEER="TAG_PEER",n.UNTAG_PEER="UNTAG_PEER",n.TRIM="TRIM"})(t=r.Type||(r.Type={}));let e;(function(n){n[n.TAG_PEER=0]="TAG_PEER",n[n.UNTAG_PEER=1]="UNTAG_PEER",n[n.TRIM=2]="TRIM"})(e||(e={})),function(n){n.codec=()=>pt(e)}(t=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=_((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),o.bytes(n.peer)),n.tag!=null&&(o.uint32(26),o.string(n.tag)),n.weight!=null&&(o.uint32(32),o.int64(n.weight)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let a=n.uint32();switch(a>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.peer=n.bytes();break;case 3:s.tag=n.string();break;case 4:s.weight=n.int64();break;default:n.skipType(a&7);break}}return s})),i),r.encode=n=>D(n,r.codec()),r.decode=n=>R(n,r.codec())})(De||(De={}));var _e;(function(r){let t;r.codec=()=>(t==null&&(t=_((e,i,n={})=>{n.lengthDelimited!==!1&&i.fork(),e.peer!=null&&e.peer.byteLength>0&&(i.uint32(10),i.bytes(e.peer)),n.lengthDelimited!==!1&&i.ldelim()},(e,i)=>{let n={peer:new Uint8Array(0)},o=i==null?e.len:e.pos+i;for(;e.pos<o;){let s=e.uint32();switch(s>>>3){case 1:n.peer=e.bytes();break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(_e||(_e={}));var mt;(function(r){let t;(function(n){n.GET_TOPICS="GET_TOPICS",n.LIST_PEERS="LIST_PEERS",n.PUBLISH="PUBLISH",n.SUBSCRIBE="SUBSCRIBE"})(t=r.Type||(r.Type={}));let e;(function(n){n[n.GET_TOPICS=0]="GET_TOPICS",n[n.LIST_PEERS=1]="LIST_PEERS",n[n.PUBLISH=2]="PUBLISH",n[n.SUBSCRIBE=3]="SUBSCRIBE"})(e||(e={})),function(n){n.codec=()=>pt(e)}(t=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=_((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.topic!=null&&(o.uint32(18),o.string(n.topic)),n.data!=null&&(o.uint32(26),o.bytes(n.data)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let a=n.uint32();switch(a>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.topic=n.string();break;case 3:s.data=n.bytes();break;default:n.skipType(a&7);break}}return s})),i),r.encode=n=>D(n,r.codec()),r.decode=n=>R(n,r.codec())})(mt||(mt={}));var Le;(function(r){let t;r.codec=()=>(t==null&&(t=_((e,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),e.from!=null&&(i.uint32(10),i.bytes(e.from)),e.data!=null&&(i.uint32(18),i.bytes(e.data)),e.seqno!=null&&(i.uint32(26),i.bytes(e.seqno)),e.topicIDs!=null)for(let o of e.topicIDs)i.uint32(34),i.string(o);e.signature!=null&&(i.uint32(42),i.bytes(e.signature)),e.key!=null&&(i.uint32(50),i.bytes(e.key)),n.lengthDelimited!==!1&&i.ldelim()},(e,i)=>{let n={topicIDs:[]},o=i==null?e.len:e.pos+i;for(;e.pos<o;){let s=e.uint32();switch(s>>>3){case 1:n.from=e.bytes();break;case 2:n.data=e.bytes();break;case 3:n.seqno=e.bytes();break;case 4:n.topicIDs.push(e.string());break;case 5:n.signature=e.bytes();break;case 6:n.key=e.bytes();break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(Le||(Le={}));var Ne;(function(r){let t;r.codec=()=>(t==null&&(t=_((e,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),e.topics!=null)for(let o of e.topics)i.uint32(10),i.string(o);if(e.peerIDs!=null)for(let o of e.peerIDs)i.uint32(18),i.bytes(o);n.lengthDelimited!==!1&&i.ldelim()},(e,i)=>{let n={topics:[],peerIDs:[]},o=i==null?e.len:e.pos+i;for(;e.pos<o;){let s=e.uint32();switch(s>>>3){case 1:n.topics.push(e.string());break;case 2:n.peerIDs.push(e.bytes());break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(Ne||(Ne={}));var Pe;(function(r){let t;(function(n){n.UNSPECIFIED="UNSPECIFIED",n.GET_PROTOCOLS="GET_PROTOCOLS",n.GET_PEER_INFO="GET_PEER_INFO"})(t=r.Type||(r.Type={}));let e;(function(n){n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.GET_PROTOCOLS=1]="GET_PROTOCOLS",n[n.GET_PEER_INFO=2]="GET_PEER_INFO"})(e||(e={})),function(n){n.codec=()=>pt(e)}(t=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=_((n,o,s={})=>{if(s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.id!=null&&(o.uint32(18),o.bytes(n.id)),n.protos!=null)for(let c of n.protos)o.uint32(26),o.string(c);s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={protos:[]},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let a=n.uint32();switch(a>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.id=n.bytes();break;case 3:s.protos.push(n.string());break;default:n.skipType(a&7);break}}return s})),i),r.encode=n=>D(n,r.codec()),r.decode=n=>R(n,r.codec())})(Pe||(Pe={}));var Oe;(function(r){let t;r.codec=()=>(t==null&&(t=_((e,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),e.peer!=null&&(i.uint32(10),At.codec().encode(e.peer,i)),e.protos!=null)for(let o of e.protos)i.uint32(18),i.string(o);n.lengthDelimited!==!1&&i.ldelim()},(e,i)=>{let n={protos:[]},o=i==null?e.len:e.pos+i;for(;e.pos<o;){let s=e.uint32();switch(s>>>3){case 1:n.peer=At.codec().decode(e,e.uint32());break;case 2:n.protos.push(e.string());break;default:e.skipType(s&7);break}}return n})),t),r.encode=e=>D(e,r.codec()),r.decode=e=>R(e,r.codec())})(Oe||(Oe={}));var Z=Et(si(),1);Z.default.formatters.b=r=>r==null?"undefined":N.baseEncode(r);Z.default.formatters.t=r=>r==null?"undefined":st.baseEncode(r);Z.default.formatters.m=r=>r==null?"undefined":br.baseEncode(r);Z.default.formatters.p=r=>r==null?"undefined":r.toString();Z.default.formatters.c=r=>r==null?"undefined":r.toString();Z.default.formatters.k=r=>r==null?"undefined":r.toString();Z.default.formatters.a=r=>r==null?"undefined":r.toString();function Ys(r){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=r,t.destroy=()=>!0,t.extend=()=>t,t}function rt(r){let t=Ys(`${r}:trace`);return Z.default.enabled(`${r}:trace`)&&Z.default.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=(0,Z.default)(`${r}:trace`)),Object.assign((0,Z.default)(r),{error:(0,Z.default)(`${r}:error`),trace:t})}function nt(r,t){t==null&&(t=r.reduce((n,o)=>n+o.length,0));let e=F(t),i=0;for(let n of r)e.set(n,i),i+=n.length;return Rt(e)}function Pt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var ai=Symbol.for("@achingbrain/uint8arraylist");function ci(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let i of r){let n=e+i.byteLength;if(t<n)return{buf:i,index:t-e};e=n}throw new RangeError("index is out of bounds")}function Me(r){return!!r?.[ai]}var lt=class r{constructor(...t){Object.defineProperty(this,ai,{value:!0}),this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let i of t)if(i instanceof Uint8Array)e+=i.byteLength,this.bufs.push(i);else if(Me(i))e+=i.byteLength,this.bufs.push(...i.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let i of t.reverse())if(i instanceof Uint8Array)e+=i.byteLength,this.bufs.unshift(i);else if(Me(i))e+=i.byteLength,this.bufs.unshift(...i.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=ci(this.bufs,t);return e.buf[e.index]}set(t,e){let i=ci(this.bufs,t);i.buf[i.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let i=0;i<t.length;i++)this.set(e+i,t[i]);else if(Me(t))for(let i=0;i<t.length;i++)this.set(e+i,t.get(i));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:i,length:n}=this._subList(t,e);return nt(i,n)}subarray(t,e){let{bufs:i,length:n}=this._subList(t,e);return i.length===1?i[0]:nt(i,n)}sublist(t,e){let{bufs:i,length:n}=this._subList(t,e),o=new r;return o.length=n,o.bufs=i,o}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:[...this.bufs],length:this.length};let i=[],n=0;for(let o=0;o<this.bufs.length;o++){let s=this.bufs[o],c=n,a=c+s.byteLength;if(n=a,t>=a)continue;let p=t>=c&&t<a,u=e>c&&e<=a;if(p&&u){if(t===c&&e===a){i.push(s);break}let d=t-c;i.push(s.subarray(d,d+(e-t)));break}if(p){if(t===0){i.push(s);continue}i.push(s.subarray(t-c));continue}if(u){if(e===a){i.push(s);break}i.push(s.subarray(0,e-c));break}i.push(s)}return{bufs:i,length:e-t}}indexOf(t,e=0){if(!Me(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let i=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let n=i.byteLength;if(n===0)throw new TypeError("search must be at least 1 byte long");let o=256,s=new Int32Array(o);for(let d=0;d<o;d++)s[d]=-1;for(let d=0;d<n;d++)s[i[d]]=d;let c=s,a=this.byteLength-i.byteLength,p=i.byteLength-1,u;for(let d=e;d<=a;d+=u){u=0;for(let h=p;h>=0;h--){let w=this.get(d+h);if(i[h]!==w){u=Math.max(1,h-c[w]);break}}if(u===0)return d}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let i=F(1);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt8(0,e),this.write(i,t)}getInt16(t,e){let i=this.subarray(t,t+2);return new DataView(i.buffer,i.byteOffset,i.byteLength).getInt16(0,e)}setInt16(t,e,i){let n=ht(2);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt16(0,e,i),this.write(n,t)}getInt32(t,e){let i=this.subarray(t,t+4);return new DataView(i.buffer,i.byteOffset,i.byteLength).getInt32(0,e)}setInt32(t,e,i){let n=ht(4);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt32(0,e,i),this.write(n,t)}getBigInt64(t,e){let i=this.subarray(t,t+8);return new DataView(i.buffer,i.byteOffset,i.byteLength).getBigInt64(0,e)}setBigInt64(t,e,i){let n=ht(8);new DataView(n.buffer,n.byteOffset,n.byteLength).setBigInt64(0,e,i),this.write(n,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let i=F(1);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint8(0,e),this.write(i,t)}getUint16(t,e){let i=this.subarray(t,t+2);return new DataView(i.buffer,i.byteOffset,i.byteLength).getUint16(0,e)}setUint16(t,e,i){let n=ht(2);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint16(0,e,i),this.write(n,t)}getUint32(t,e){let i=this.subarray(t,t+4);return new DataView(i.buffer,i.byteOffset,i.byteLength).getUint32(0,e)}setUint32(t,e,i){let n=ht(4);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint32(0,e,i),this.write(n,t)}getBigUint64(t,e){let i=this.subarray(t,t+8);return new DataView(i.buffer,i.byteOffset,i.byteLength).getBigUint64(0,e)}setBigUint64(t,e,i){let n=ht(8);new DataView(n.buffer,n.byteOffset,n.byteLength).setBigUint64(0,e,i),this.write(n,t)}getFloat32(t,e){let i=this.subarray(t,t+4);return new DataView(i.buffer,i.byteOffset,i.byteLength).getFloat32(0,e)}setFloat32(t,e,i){let n=ht(4);new DataView(n.buffer,n.byteOffset,n.byteLength).setFloat32(0,e,i),this.write(n,t)}getFloat64(t,e){let i=this.subarray(t,t+8);return new DataView(i.buffer,i.byteOffset,i.byteLength).getFloat64(0,e)}setFloat64(t,e,i){let n=ht(8);new DataView(n.buffer,n.byteOffset,n.byteLength).setFloat64(0,e,i),this.write(n,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!Pt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let i=new r;return i.bufs=t,e==null&&(e=t.reduce((n,o)=>n+o.byteLength,0)),i.length=e,i}};function li(r){let t=async function*(){let e=yield,i=new lt;for await(let n of r){if(e==null){i.append(n),e=yield i,i=new lt;continue}for(i.append(n);i.length>=e;){let o=i.sublist(0,e);if(i.consume(e),e=yield o,e==null){i.length>0&&(e=yield i,i=new lt);break}}}if(e!=null)throw Object.assign(new Error(`stream ended before ${e} bytes became available`),{code:"ERR_UNDER_READ",buffer:i})}();return t.next(),t}function Jt(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Ve=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||t-1&t)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},Qt=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new Ve(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new Ve(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var Vr=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function ui(r={}){return Ws(e=>{let i=e.shift();if(i==null)return{done:!0};if(i.error!=null)throw i.error;return{done:i.done===!0,value:i.value}},r)}function Ws(r,t){t=t??{};let e=t.onEnd,i=new Qt,n,o,s,c=Jt(),a=async()=>{try{return i.isEmpty()?s?{done:!0}:await new Promise((y,E)=>{o=C=>{o=null,i.push(C);try{y(r(i))}catch(L){E(L)}return n}}):r(i)}finally{i.isEmpty()&&queueMicrotask(()=>{c.resolve(),c=Jt()})}},p=y=>o!=null?o(y):(i.push(y),n),u=y=>(i=new Qt,o!=null?o({error:y}):(i.push({error:y}),n)),d=y=>{if(s)return n;if(t?.objectMode!==!0&&y?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return p({done:!1,value:y})},h=y=>s?n:(s=!0,y!=null?u(y):p({done:!0})),w=()=>(i=new Qt,h(),{done:!0}),g=y=>(h(y),{done:!0});if(n={[Symbol.asyncIterator](){return this},next:a,return:w,throw:g,push:d,end:h,get readableLength(){return i.size},onEmpty:async y=>{let E=y?.signal;if(E?.throwIfAborted(),i.isEmpty())return;let C,L;E!=null&&(C=new Promise((P,W)=>{L=()=>{W(new Vr)},E.addEventListener("abort",L)}));try{await Promise.race([c.promise,C])}finally{L!=null&&E!=null&&E?.removeEventListener("abort",L)}}},e==null)return n;let x=n;return n={[Symbol.asyncIterator](){return this},next(){return x.next()},throw(y){return x.throw(y),e!=null&&(e(y),e=void 0),{done:!0}},return(){return x.return(),e!=null&&(e(),e=void 0),{done:!0}},push:d,end(y){return x.end(y),e!=null&&(e(y),e=void 0),n},get readableLength(){return x.readableLength}},n}function di(r){let t=ui(),e=li(r.source),i=Jt(),n,o=r.sink(async function*(){yield*t,yield*await i.promise}());return o.catch(c=>{n=c}),{reader:e,writer:t,stream:{sink:async c=>{if(n!=null){await Promise.reject(n);return}i.resolve(c),await o},source:e},rest:()=>t.end(),write:t.push,read:async()=>{let c=await e.next();if(c.value!=null)return c.value}}}var Xs=Math.pow(2,7),Js=Math.pow(2,14),Qs=Math.pow(2,21),Gr=Math.pow(2,28),$r=Math.pow(2,35),zr=Math.pow(2,42),Hr=Math.pow(2,49),I=128,M=127;function K(r){if(r<Xs)return 1;if(r<Js)return 2;if(r<Qs)return 3;if(r<Gr)return 4;if(r<$r)return 5;if(r<zr)return 6;if(r<Hr)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Zs(r,t,e=0){switch(K(r)){case 8:t[e++]=r&255|I,r/=128;case 7:t[e++]=r&255|I,r/=128;case 6:t[e++]=r&255|I,r/=128;case 5:t[e++]=r&255|I,r/=128;case 4:t[e++]=r&255|I,r>>>=7;case 3:t[e++]=r&255|I,r>>>=7;case 2:t[e++]=r&255|I,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function qs(r,t,e=0){switch(K(r)){case 8:t.set(e++,r&255|I),r/=128;case 7:t.set(e++,r&255|I),r/=128;case 6:t.set(e++,r&255|I),r/=128;case 5:t.set(e++,r&255|I),r/=128;case 4:t.set(e++,r&255|I),r>>>=7;case 3:t.set(e++,r&255|I),r>>>=7;case 2:t.set(e++,r&255|I),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function js(r,t){let e=r[t],i=0;if(i+=e&M,e<I||(e=r[t+1],i+=(e&M)<<7,e<I)||(e=r[t+2],i+=(e&M)<<14,e<I)||(e=r[t+3],i+=(e&M)<<21,e<I)||(e=r[t+4],i+=(e&M)*Gr,e<I)||(e=r[t+5],i+=(e&M)*$r,e<I)||(e=r[t+6],i+=(e&M)*zr,e<I)||(e=r[t+7],i+=(e&M)*Hr,e<I))return i;throw new RangeError("Could not decode varint")}function tc(r,t){let e=r.get(t),i=0;if(i+=e&M,e<I||(e=r.get(t+1),i+=(e&M)<<7,e<I)||(e=r.get(t+2),i+=(e&M)<<14,e<I)||(e=r.get(t+3),i+=(e&M)<<21,e<I)||(e=r.get(t+4),i+=(e&M)*Gr,e<I)||(e=r.get(t+5),i+=(e&M)*$r,e<I)||(e=r.get(t+6),i+=(e&M)*zr,e<I)||(e=r.get(t+7),i+=(e&M)*Hr,e<I))return i;throw new RangeError("Could not decode varint")}function Ct(r,t,e=0){return t==null&&(t=F(K(r))),t instanceof Uint8Array?Zs(r,t,e):qs(r,t,e)}function gt(r,t=0){return r instanceof Uint8Array?js(r,t):tc(r,t)}function $e(r){return r[Symbol.asyncIterator]!=null}var ze=r=>{let t=K(r),e=F(t);return Ct(r,e),ze.bytes=t,e};ze.bytes=0;function He(r,t){t=t??{};let e=t.lengthEncoder??ze;function*i(n){let o=e(n.byteLength);o instanceof Uint8Array?yield o:yield*o,n instanceof Uint8Array?yield n:yield*n}return $e(r)?async function*(){for await(let n of r)yield*i(n)}():function*(){for(let n of r)yield*i(n)}()}He.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??ze;return new lt(e(r.byteLength),r)};var Zt=Et(pi(),1);var rc=8,nc=1024*1024*4,Ot;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Ot||(Ot={}));var Kr=r=>{let t=gt(r);return Kr.bytes=K(t),t};Kr.bytes=0;function de(r,t){let e=new lt,i=Ot.LENGTH,n=-1,o=t?.lengthDecoder??Kr,s=t?.maxLengthLength??rc,c=t?.maxDataLength??nc;function*a(){for(;e.byteLength>0;){if(i===Ot.LENGTH)try{if(n=o(e),n<0)throw(0,Zt.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(n>c)throw(0,Zt.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let p=o.bytes;e.consume(p),t?.onLength!=null&&t.onLength(n),i=Ot.DATA}catch(p){if(p instanceof RangeError){if(e.byteLength>s)throw(0,Zt.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw p}if(i===Ot.DATA){if(e.byteLength<n)break;let p=e.sublist(0,n);e.consume(n),t?.onData!=null&&t.onData(p),yield p,i=Ot.LENGTH}}}return $e(r)?async function*(){for await(let p of r)e.append(p),yield*a();if(e.byteLength>0)throw(0,Zt.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let p of r)e.append(p),yield*a();if(e.byteLength>0)throw(0,Zt.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}de.fromReader=(r,t)=>{let e=1,i=async function*(){for(;;)try{let{done:o,value:s}=await r.next(e);if(o===!0)return;s!=null&&(yield s)}catch(o){if(o.code==="ERR_UNDER_READ")return{done:!0,value:null};throw o}finally{e=1}}();return de(i,{...t??{},onLength:o=>{e=o}})};var Yr=rt("libp2p:daemon-protocol:stream-handler"),fe=class{stream;shake;decoder;constructor(t){let{stream:e,maxLength:i}=t;this.stream=e,this.shake=di(this.stream),this.decoder=de.fromReader(this.shake.reader,{maxDataLength:i??4096})}async read(){let t=await this.decoder.next();if(t.value!=null)return t.value.subarray();Yr("read received no value, closing stream"),await this.close()}write(t){Yr("write message"),this.shake.write(He.single(t).subarray())}rest(){return this.shake.rest(),this.shake.stream}async close(){Yr("closing the stream"),await this.rest().sink([])}};var Wr={upgradeInbound:async r=>r,upgradeOutbound:async r=>r};var qt=class r extends Error{code;type;constructor(t="The operation was aborted"){super(t),this.code=r.code,this.type=r.type}static code="ABORT_ERR";static type="aborted"},l=class extends Error{code;props;constructor(t,e,i){super(t),this.code=e,this.name=i?.name??"CodeError",this.props=i??{}}};var Xr=Symbol.for("@libp2p/peer-id");function jt(r){return r!=null&&!!r[Xr]}var oc=Symbol.for("nodejs.util.inspect.custom"),mi=Object.values(It).map(r=>r.decoder).reduce((r,t)=>r.or(t),It.identity.decoder),gi=114,yi=36,Ei=37,he=class{type;multihash;privateKey;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Xr]=!0;toString(){return this.string==null&&(this.string=N.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return H.createV1(gi,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t instanceof Uint8Array)return Pt(this.multihash.bytes,t);if(typeof t=="string")return sc(t).equals(this);if(t?.multihash?.bytes!=null)return Pt(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[oc](){return`PeerId(${this.toString()})`}},pe=class extends he{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},me=class extends he{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.multihash.digest}},ge=class extends he{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.multihash.digest}};function sc(r,t){if(t=t??mi,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=Dt(N.decode(`z${r}`));return r.startsWith("12D")?new me({multihash:e}):r.startsWith("16U")?new ge({multihash:e}):new pe({multihash:e})}return ut(mi.decode(r))}function ut(r){try{let t=Dt(r);if(t.code===we.code){if(t.digest.length===yi)return new me({multihash:t});if(t.digest.length===Ei)return new ge({multihash:t})}if(t.code===xe.code)return new pe({multihash:t})}catch{return cc(H.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function cc(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==gi)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===xe.code)return new pe({multihash:r.multihash});if(t.code===we.code){if(t.digest.length===yi)return new me({multihash:r.multihash});if(t.digest.length===Ei)return new ge({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var eo=Et(ft("net"),1);var wi=Symbol.for("@libp2p/transport");var bi;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(bi||(bi={}));function Y(r,t="utf8"){let e=Ie[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}var Ke=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,i=t();return i===void 0&&(this.index=e),i}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,i){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return i()})}readNumber(t,e,i,n){return this.readAtomically(()=>{let o=0,s=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",p=2**(8*n)-1;for(;;){let u=this.readAtomically(()=>{let d=this.readChar();if(d===void 0)return;let h=Number.parseInt(d,t);if(!Number.isNaN(h))return h});if(u===void 0)break;if(o*=t,o+=u,o>p||(s+=1,e!==void 0&&s>e))return}if(s!==0)return!i&&a&&s>1?void 0:o})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let i=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(i===void 0)return;t[e]=i}return t})}readIPv6Addr(){let t=e=>{for(let i=0;i<e.length/2;i++){let n=i*2;if(i<e.length-3){let s=this.readSeparator(":",i,()=>this.readIPv4Addr());if(s!==void 0)return e[n]=s[0],e[n+1]=s[1],e[n+2]=s[2],e[n+3]=s[3],[n+4,!0]}let o=this.readSeparator(":",i,()=>this.readNumber(16,4,!0,2));if(o===void 0)return[n,!1];e[n]=o>>8,e[n+1]=o&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[i,n]=t(e);if(i===16)return e;if(n||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),s=16-(i+2),[c]=t(o.subarray(0,s));return e.set(o.subarray(0,c),16-c),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Su=new Ke;var Ou=parseInt("0xFFFF",16),ku=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var it=ft("node:net");function Ye(r){return!!(0,it.isIP)(r)}var Ai=it.isIPv4,hc=it.isIPv6,Jr=function(r){let t=0;if(r=r.toString().trim(),Ai(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(i=>{e[t++]=parseInt(i,10)&255}),e}if(hc(r)){let e=r.split(":",8),i;for(i=0;i<e.length;i++){let o=Ai(e[i]),s;o&&(s=Jr(e[i]),e[i]=Y(s.slice(0,2),"base16")),s!=null&&++i<8&&e.splice(i,0,Y(s.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(i=0;i<e.length&&e[i]!=="";i++);let o=[i,1];for(i=9-e.length;i>0;i--)o.push("0");e.splice.apply(e,o)}let n=new Uint8Array(t+16);for(i=0;i<e.length;i++){let o=parseInt(e[i],16);n[t++]=o>>8&255,n[t++]=o&255}return n}throw new Error("invalid ip address")},Ci=function(r,t=0,e){t=~~t,e=e??r.length-t;let i=new DataView(r.buffer);if(e===4){let n=[];for(let o=0;o<e;o++)n.push(r[t+o]);return n.join(".")}if(e===16){let n=[];for(let o=0;o<e;o+=2)n.push(i.getUint16(t+o).toString(16));return n.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var te={},Qr={},mc=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];mc.forEach(r=>{let t=gc(...r);Qr[t.code]=t,te[t.name]=t});function gc(r,t,e,i,n){return{code:r,size:t,name:e,resolvable:!!i,path:!!n}}function A(r){if(typeof r=="number"){if(Qr[r]!=null)return Qr[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(te[r]!=null)return te[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var bd=A("ip4"),wd=A("ip6"),xd=A("ipcidr");function qr(r,t){switch(A(r).code){case 4:case 41:return Ec(t);case 42:return vi(t);case 6:case 273:case 33:case 132:return Di(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return vi(t);case 421:return Ic(t);case 444:return Ri(t);case 445:return Ri(t);case 466:return xc(t);default:return Y(t,"base16")}}function jr(r,t){switch(A(r).code){case 4:return Ti(t);case 41:return Ti(t);case 42:return Si(t);case 6:case 273:case 33:case 132:return tn(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Si(t);case 421:return bc(t);case 444:return Ac(t);case 445:return Cc(t);case 466:return wc(t);default:return ce(t,"base16")}}var Zr=Object.values(It).map(r=>r.decoder),yc=function(){let r=Zr[0].or(Zr[1]);return Zr.slice(2).forEach(t=>r=r.or(t)),r}();function Ti(r){if(!Ye(r))throw new Error("invalid ip address");return Jr(r)}function Ec(r){let t=Ci(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Ye(t))throw new Error("invalid ip address");return t}function tn(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Di(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Si(r){let t=ce(r),e=Uint8Array.from(Ct(t.length));return nt([e,t],e.length+t.length)}function vi(r){let t=gt(r);if(r=r.slice(K(t)),r.length!==t)throw new Error("inconsistent lengths");return Y(r)}function bc(r){let t;r[0]==="Q"||r[0]==="1"?t=Dt(N.decode(`z${r}`)).bytes:t=H.parse(r).multihash.bytes;let e=Uint8Array.from(Ct(t.length));return nt([e,t],e.length+t.length)}function wc(r){let t=yc.decode(r),e=Uint8Array.from(Ct(t.length));return nt([e,t],e.length+t.length)}function xc(r){let t=gt(r),e=r.slice(K(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+Y(e,"base64url")}function Ic(r){let t=gt(r),e=r.slice(K(t));if(e.length!==t)throw new Error("inconsistent lengths");return Y(e,"base58btc")}function Ac(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=st.decode("b"+t[0]),i=parseInt(t[1],10);if(i<1||i>65536)throw new Error("Port number is not in range(1, 65536)");let n=tn(i);return nt([e,n],e.length+n.length)}function Cc(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=st.decode(`b${t[0]}`),i=parseInt(t[1],10);if(i<1||i>65536)throw new Error("Port number is not in range(1, 65536)");let n=tn(i);return nt([e,n],e.length+n.length)}function Ri(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),i=Y(t,"base32"),n=Di(e);return`${i}:${n}`}function _i(r){r=en(r);let t=[],e=[],i=null,n=r.split("/").slice(1);if(n.length===1&&n[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<n.length;o++){let s=n[o],c=A(s);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(o++,o>=n.length)throw Ni("invalid address: "+r);if(c.path===!0){i=en(n.slice(o).join("/")),t.push([c.code,jr(c.code,i)]),e.push([c.code,i]);break}let a=jr(c.code,n[o]);t.push([c.code,a]),e.push([c.code,qr(c.code,a)])}return{string:Li(e),bytes:nn(t),tuples:t,stringTuples:e,path:i}}function rn(r){let t=[],e=[],i=null,n=0;for(;n<r.length;){let o=gt(r,n),s=K(o),c=A(o),a=Tc(c,r.slice(n+s));if(a===0){t.push([o]),e.push([o]),n+=s;continue}let p=r.slice(n+s,n+s+a);if(n+=a+s,n>r.length)throw Ni("Invalid address Uint8Array: "+Y(r,"base16"));t.push([o,p]);let u=qr(o,p);if(e.push([o,u]),c.path===!0){i=u;break}}return{bytes:Uint8Array.from(r),string:Li(e),tuples:t,stringTuples:e,path:i}}function Li(r){let t=[];return r.map(e=>{let i=A(e[0]);return t.push(i.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),en(t.join("/"))}function nn(r){return nt(r.map(t=>{let e=A(t[0]),i=Uint8Array.from(Ct(e.code));return t.length>1&&t[1]!=null&&(i=nt([i,t[1]])),i}))}function Tc(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=gt(t instanceof Uint8Array?t:Uint8Array.from(t));return e+K(e)}}function en(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Ni(r){return new Error("Error parsing address: "+r)}var Sc=Symbol.for("nodejs.util.inspect.custom"),vc=[A("dns").code,A("dns4").code,A("dns6").code,A("dnsaddr").code],Rc=new Map,Pi=Symbol.for("@multiformats/js-multiaddr/multiaddr");function sn(r){return!!r?.[Pi]}var on=class r{bytes;#t;#e;#r;#n;[Pi]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=rn(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=_i(t)}else if(sn(t))e=rn(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,i,n,o="",s=A("tcp"),c=A("udp"),a=A("ip4"),p=A("ip6"),u=A("dns6"),d=A("ip6zone");for(let[w,g]of this.stringTuples())w===d.code&&(o=`%${g??""}`),vc.includes(w)&&(e=s.name,n=443,i=`${g??""}${o}`,t=w===u.code?6:4),(w===s.code||w===c.code)&&(e=A(w).name,n=parseInt(g??"")),(w===a.code||w===p.code)&&(e=A(w).name,i=`${g??""}${o}`,t=w===p.code?6:4);if(t==null||e==null||i==null||n==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:i,transport:e,port:n}}protos(){return this.#e.map(([t])=>Object.assign({},A(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>A(t).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),i=this.toString(),n=i.lastIndexOf(e);if(n<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(i.slice(0,n))}decapsulateCode(t){let e=this.tuples();for(let i=e.length-1;i>=0;i--)if(e[i][0]===t)return new r(nn(e.slice(0,i)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([i,n])=>{i===te.p2p.code&&t.push([i,n]),i===te["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let i=e[1];return i[0]==="Q"||i[0]==="1"?Y(N.decode(`z${i}`),"base58btc"):Y(H.parse(i).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Pt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(o=>o.resolvable);if(e==null)return[this];let i=Rc.get(e.name);if(i==null)throw new l(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await i(this,t)).map(o=>new r(o))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[Sc](){return`Multiaddr(${this.#t})`}};function V(r){return new on(r)}var Dc=f("dns4"),_c=f("dns6"),Lc=f("dnsaddr"),Ut=v(f("dns"),Lc,Dc,_c),Je=v(f("ip4"),f("ip6")),St=v(m(Je,f("tcp")),m(Ut,f("tcp"))),Qe=m(Je,f("udp")),Nc=m(Qe,f("utp")),Pc=m(Qe,f("quic")),Oc=m(Qe,f("quic-v1")),cn=v(m(St,f("ws")),m(Ut,f("ws"))),We=v(m(cn,f("p2p")),cn),an=v(m(St,f("wss")),m(Ut,f("wss")),m(St,f("tls"),f("ws")),m(Ut,f("tls"),f("ws"))),Xe=v(m(an,f("p2p")),an),ln=v(m(St,f("http")),m(Je,f("http")),m(Ut,f("http"))),un=v(m(St,f("https")),m(Je,f("https")),m(Ut,f("https"))),Oi=m(Qe,f("webrtc-direct"),f("certhash")),Fi=v(m(Oi,f("p2p")),Oi),ki=m(Oc,f("webtransport"),f("certhash"),f("certhash")),Bi=v(m(ki,f("p2p")),ki),Mi=v(m(We,f("p2p-webrtc-star"),f("p2p")),m(Xe,f("p2p-webrtc-star"),f("p2p")),m(We,f("p2p-webrtc-star")),m(Xe,f("p2p-webrtc-star"))),zd=v(m(We,f("p2p-websocket-star"),f("p2p")),m(Xe,f("p2p-websocket-star"),f("p2p")),m(We,f("p2p-websocket-star")),m(Xe,f("p2p-websocket-star"))),Vi=v(m(ln,f("p2p-webrtc-direct"),f("p2p")),m(un,f("p2p-webrtc-direct"),f("p2p")),m(ln,f("p2p-webrtc-direct")),m(un,f("p2p-webrtc-direct"))),Ft=v(cn,an,ln,un,Mi,Vi,St,Nc,Pc,Ut,Fi,Bi),Hd=v(m(Ft,f("p2p-stardust"),f("p2p")),m(Ft,f("p2p-stardust"))),Tt=v(m(Ft,f("p2p")),Mi,Vi,Fi,Bi,f("p2p")),Ui=v(m(Tt,f("p2p-circuit"),Tt),m(Tt,f("p2p-circuit")),m(f("p2p-circuit"),Tt),m(Ft,f("p2p-circuit")),m(f("p2p-circuit"),Ft),f("p2p-circuit")),Gi=()=>v(m(Ui,Gi),Ui),kt=Gi(),Kd=v(m(kt,Tt,kt),m(Tt,kt),m(kt,Tt),kt,Tt);var Yd=v(m(kt,f("webrtc"),f("p2p")),m(kt,f("webrtc")),m(Ft,f("webrtc"),f("p2p")),m(Ft,f("webrtc")),f("webrtc"));function $i(r){function t(e){let i;try{i=V(e)}catch{return!1}let n=r(i.protoNames());return n===null?!1:n===!0||n===!1?n:n.length===0}return t}function m(...r){function t(e){if(e.length<r.length)return null;let i=e;return r.some(n=>(i=typeof n=="function"?n().partialMatch(e):n.partialMatch(e),Array.isArray(i)&&(e=i),i===null)),i}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:$i(t),partialMatch:t}}function v(...r){function t(i){let n=null;return r.some(o=>{let s=typeof o=="function"?o().partialMatch(i):o.partialMatch(i);return s!=null?(n=s,!0):!1}),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:$i(t),partialMatch:t}}function f(r){let t=r;function e(n){let o;try{o=V(n)}catch{return!1}let s=o.protoNames();return s.length===1&&s[0]===t}function i(n){return n.length===0?null:n[0]===t?n.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:i}}var to=Et(ft("net"),1);var Ze=class extends EventTarget{#t=new Map;listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,i){super.addEventListener(t,e,i);let n=this.#t.get(t);n==null&&(n=[],this.#t.set(t,n)),n.push({callback:e,once:(i!==!0&&i!==!1&&i?.once)??!1})}removeEventListener(t,e,i){super.removeEventListener(t.toString(),e??null,i);let n=this.#t.get(t);n!=null&&(n=n.filter(({callback:o})=>o!==e),this.#t.set(t,n))}dispatchEvent(t){let e=super.dispatchEvent(t),i=this.#t.get(t.type);return i==null||(i=i.filter(({once:n})=>!n),this.#t.set(t.type,i)),e}safeDispatchEvent(t,e){return this.dispatchEvent(new ee(t,e))}},dn=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},ee=globalThis.CustomEvent??dn;var Uc=rt("libp2p:ip-port-to-multiaddr"),fn={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};function zi(r,t){if(typeof r!="string")throw new l(`invalid ip provided: ${r}`,fn.ERR_INVALID_IP_PARAMETER);if(typeof t=="string"&&(t=parseInt(t)),isNaN(t))throw new l(`invalid port provided: ${t}`,fn.ERR_INVALID_PORT_PARAMETER);if((0,it.isIPv4)(r))return V(`/ip4/${r}/tcp/${t}`);if((0,it.isIPv6)(r))return V(`/ip6/${r}/tcp/${t}`);let e=`invalid ip:port for creating a multiaddr: ${r}:${t}`;throw Uc.error(e),new l(e,fn.ERR_INVALID_IP)}var ji=Et(Zi(),1);var mn=Et(ft("os"),1),qi=Et(ft("path"),1);var Gc={ip4:"IPv4",ip6:"IPv6"};function ne(r,t={}){let e=r.getPath();return e!=null?mn.default.platform()==="win32"?{path:qi.default.join("\\\\.\\pipe\\",e)}:{path:e}:{...r.toOptions(),...t}}function gn(r,t,e){let i=n=>V(`/${r}/${n}/tcp/${e}`);return($c(t)?Hc(Gc[r]):[t]).map(i)}function $c(r){return["0.0.0.0","::"].includes(r)}var zc=mn.default.networkInterfaces();function Hc(r){let t=[];for(let[,e]of Object.entries(zc))if(e!=null)for(let i of e)i.family===r&&t.push(i.address);return t}var dt=rt("libp2p:tcp:socket"),je=(r,t)=>{let e=t.metrics,i=t.metricPrefix??"",n=t.socketInactivityTimeout??3e5,o=t.socketCloseTimeout??500;t.listeningAddr?.getPath()!=null&&(t.remoteAddr=t.listeningAddr),t.remoteAddr?.getPath()!=null&&(t.localAddr=t.remoteAddr);let s;if(t.remoteAddr!=null)s=t.remoteAddr;else{if(r.remoteAddress==null||r.remotePort==null)throw new l("Could not determine remote address or port","ERR_NO_REMOTE_ADDRESS");s=zi(r.remoteAddress,r.remotePort)}let c=ne(s),a=c.path??`${c.host??""}:${c.port??""}`,{sink:p,source:u}=ji.default.duplex(r);r.setTimeout(n,()=>{dt("%s socket read timeout",a),e?.increment({[`${i}timeout`]:!0});let h;r.readable&&(h=new l("Socket read timeout","ERR_SOCKET_READ_TIMEOUT")),r.destroy(h)}),r.once("close",()=>{dt("%s socket close",a),e?.increment({[`${i}close`]:!0}),d.timeline.close==null&&(d.timeline.close=Date.now())}),r.once("end",()=>{dt("%s socket end",a),e?.increment({[`${i}end`]:!0})});let d={async sink(h){try{await p(h)}catch(w){w.type!=="aborted"&&dt(w)}r.end()},source:u,remoteAddr:s,timeline:{open:Date.now()},async close(h={}){if(r.destroyed){dt("%s socket was already destroyed when trying to close",a);return}h.signal=h.signal??AbortSignal.timeout(o);try{dt("%s closing socket",a),await new Promise((w,g)=>{r.once("close",()=>{dt("%s socket closed",a),w()}),r.once("error",x=>{dt("%s socket error",a,x),d.timeline.close==null&&(d.timeline.close=Date.now()),g(x)}),r.setTimeout(o),r.end(),r.writableLength>0?r.once("drain",()=>{dt("%s socket drained",a),r.destroy()}):r.destroy()})}catch(w){this.abort(w)}},abort:h=>{dt("%s socket abort due to error",a,h),r.destroy(h)}};return d};var G=rt("libp2p:tcp:listener");async function yn(r){try{await r.close()}catch(t){G.error("an error occurred closing the connection",t)}}var O;(function(r){r[r.INACTIVE=0]="INACTIVE",r[r.ACTIVE=1]="ACTIVE",r[r.PAUSED=2]="PAUSED"})(O||(O={}));var tr=class extends Ze{context;server;connections=new Set;status={code:O.INACTIVE};metrics;addr;constructor(t){if(super(),this.context=t,t.keepAlive=t.keepAlive??!0,this.addr="unknown",this.server=to.default.createServer(t,this.onSocket.bind(this)),t.maxConnections!==void 0&&(this.server.maxConnections=t.maxConnections),t.closeServerOnMaxConnections!=null&&t.closeServerOnMaxConnections.closeAbove<t.closeServerOnMaxConnections.listenBelow)throw new l("closeAbove must be >= listenBelow","ERROR_CONNECTION_LIMITS");this.server.on("listening",()=>{if(t.metrics!=null){let e=this.server.address();e==null?this.addr="unknown":typeof e=="string"?this.addr=e:this.addr=`${e.address}:${e.port}`,t.metrics?.registerMetricGroup("libp2p_tcp_inbound_connections_total",{label:"address",help:"Current active connections in TCP listener",calculate:()=>({[this.addr]:this.connections.size})}),this.metrics={status:t.metrics.registerMetricGroup("libp2p_tcp_listener_status_info",{label:"address",help:"Current status of the TCP listener socket"}),errors:t.metrics.registerMetricGroup("libp2p_tcp_listener_errors_total",{label:"address",help:"Total count of TCP listener errors by type"}),events:t.metrics.registerMetricGroup("libp2p_tcp_listener_events_total",{label:"address",help:"Total count of TCP listener events by type"})},this.metrics?.status.update({[this.addr]:O.ACTIVE})}this.dispatchEvent(new ee("listening"))}).on("error",e=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.dispatchEvent(new ee("error",{detail:e}))}).on("close",()=>{this.metrics?.status.update({[this.addr]:this.status.code}),this.status.code!==O.PAUSED&&this.dispatchEvent(new ee("close"))})}onSocket(t){if(this.status.code!==O.ACTIVE)throw new l("Server is is not listening yet","ERR_SERVER_NOT_RUNNING");t.on("error",i=>{G("socket error",i),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let e;try{e=je(t,{listeningAddr:this.status.listeningAddr,socketInactivityTimeout:this.context.socketInactivityTimeout,socketCloseTimeout:this.context.socketCloseTimeout,metrics:this.metrics?.events,metricPrefix:`${this.addr} `})}catch(i){G.error("inbound connection failed",i),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}G("new inbound connection %s",e.remoteAddr);try{this.context.upgrader.upgradeInbound(e).then(i=>{G("inbound connection upgraded %s",e.remoteAddr),this.connections.add(e),t.once("close",()=>{this.connections.delete(e),this.context.closeServerOnMaxConnections!=null&&this.connections.size<this.context.closeServerOnMaxConnections.listenBelow&&this.resume().catch(n=>{G.error("error attempting to listen server once connection count under limit",n),this.context.closeServerOnMaxConnections?.onListenError?.(n)})}),this.context.handler!=null&&this.context.handler(i),this.context.closeServerOnMaxConnections!=null&&this.connections.size>=this.context.closeServerOnMaxConnections.closeAbove&&this.pause(!1).catch(n=>{G.error("error attempting to close server once connection count over limit",n)}),this.dispatchEvent(new ee("connection",{detail:i}))}).catch(async i=>{G.error("inbound connection failed",i),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),await yn(e)}).catch(i=>{G.error("closing inbound connection failed",i)})}catch(i){G.error("inbound connection failed",i),yn(e).catch(n=>{G.error("closing inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_closing_failed`]:!0})})}}getAddrs(){if(this.status.code===O.INACTIVE)return[];let t=[],e=this.server.address(),{listeningAddr:i,peerId:n}=this.status;if(e==null)return[];if(typeof e=="string")t=[i];else try{i.toString().startsWith("/ip4")?t=t.concat(gn("ip4",e.address,e.port)):e.family==="IPv6"&&(t=t.concat(gn("ip6",e.address,e.port)))}catch(o){G.error("could not turn %s:%s into multiaddr",e.address,e.port,o)}return t.map(o=>n!=null?o.encapsulate(`/p2p/${n}`):o)}async listen(t){if(this.status.code===O.ACTIVE||this.status.code===O.PAUSED)throw new l("server is already listening","ERR_SERVER_ALREADY_LISTENING");let e=t.getPeerId(),i=e==null?t.decapsulateCode(421):t,{backlog:n}=this.context;try{this.status={code:O.ACTIVE,listeningAddr:i,peerId:e,netConfig:ne(i,{backlog:n})},await this.resume()}catch(o){throw this.status={code:O.INACTIVE},o}}async close(){await Promise.all([Promise.all(Array.from(this.connections.values()).map(async t=>yn(t))),this.pause(!0).catch(t=>{G.error("error attempting to close server once connection count over limit",t)})])}async resume(){if(this.server.listening||this.status.code===O.INACTIVE)return;let t=this.status.netConfig;await new Promise((e,i)=>{this.server.once("error",i),this.server.listen(t,e)}),this.status={...this.status,code:O.ACTIVE},G("Listening on %s",this.server.address())}async pause(t){if(!this.server.listening&&this.status.code===O.PAUSED&&t){this.status={code:O.INACTIVE};return}!this.server.listening||this.status.code!==O.ACTIVE||(G("Closing server on %s",this.server.address()),this.status=t?{code:O.INACTIVE}:{...this.status,code:O.PAUSED},await new Promise((e,i)=>{this.server.close(n=>{n!=null?i(n):e()})}))}};var yt=rt("libp2p:tcp"),bn=class{opts;metrics;components;constructor(t,e={}){this.opts=e,this.components=t,t.metrics!=null&&(this.metrics={dialerEvents:t.metrics.registerCounterGroup("libp2p_tcp_dialer_events_total",{label:"event",help:"Total count of TCP dialer events by type"})})}[wi]=!0;[Symbol.toStringTag]="@libp2p/tcp";async dial(t,e){e.keepAlive=e.keepAlive??!0;let i=await this._connect(t,e);i.on("error",c=>{yt("socket error",c)});let n=je(i,{remoteAddr:t,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents}),o=()=>{n.close().catch(c=>{yt.error("Error closing maConn after abort",c)})};e.signal?.addEventListener("abort",o,{once:!0}),yt("new outbound connection %s",n.remoteAddr);let s=await e.upgrader.upgradeOutbound(n);if(yt("outbound connection %s upgraded",n.remoteAddr),e.signal?.removeEventListener("abort",o),e.signal?.aborted===!0)throw s.close().catch(c=>{yt.error("Error closing conn after abort",c)}),new qt;return s}async _connect(t,e){if(e.signal?.aborted===!0)throw new qt;return new Promise((i,n)=>{let o=Date.now(),s=ne(t),c=s.path??`${s.host??""}:${s.port}`;yt("dialing %j",s);let a=eo.default.connect(s),p=g=>{g.message=`connection error ${c}: ${g.message}`,this.metrics?.dialerEvents.increment({error:!0}),w(g)},u=()=>{yt("connection timeout %s",c),this.metrics?.dialerEvents.increment({timeout:!0});let g=new l(`connection timeout after ${Date.now()-o}ms`,"ERR_CONNECT_TIMEOUT");a.emit("error",g)},d=()=>{yt("connection opened %j",s),this.metrics?.dialerEvents.increment({connect:!0}),w()},h=()=>{yt("connection aborted %j",s),this.metrics?.dialerEvents.increment({abort:!0}),a.destroy(),w(new qt)},w=g=>{if(a.removeListener("error",p),a.removeListener("timeout",u),a.removeListener("connect",d),e.signal!=null&&e.signal.removeEventListener("abort",h),g!=null){n(g);return}i(a)};a.on("error",p),a.on("timeout",u),a.on("connect",d),e.signal!=null&&e.signal.addEventListener("abort",h)})}createListener(t){return new tr({...t,maxConnections:this.opts.maxConnections,backlog:this.opts.backlog,closeServerOnMaxConnections:this.opts.closeServerOnMaxConnections,socketInactivityTimeout:this.opts.inboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.components.metrics})}filter(t){return t=Array.isArray(t)?t:[t],t.filter(e=>e.protoCodes().includes(290)?!1:e.protoCodes().includes(400)?!0:St.matches(e.decapsulateCode(421)))}};function ro(r={}){return(t={})=>new bn(t,r)}var er=class{client;constructor(t){this.client=t}async put(t,e){if(!(t instanceof Uint8Array))throw new l("invalid key received","ERR_INVALID_KEY");if(!(e instanceof Uint8Array))throw new l("value received is not a Uint8Array","ERR_INVALID_VALUE");let i=await this.client.send({type:S.Type.DHT,dht:{type:et.Type.PUT_VALUE,key:t,value:e}}),n=await i.read();if(n==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let o=b.decode(n);if(await i.close(),o.type!==b.Type.OK)throw new l(o.error?.msg??"DHT put failed","ERR_DHT_PUT_FAILED")}async get(t){if(!(t instanceof Uint8Array))throw new l("invalid key received","ERR_INVALID_KEY");let e=await this.client.send({type:S.Type.DHT,dht:{type:et.Type.GET_VALUE,key:t}}),i=await e.read();if(i==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let n=b.decode(i);if(await e.close(),n.type!==b.Type.OK)throw new l(n.error?.msg??"DHT get failed","ERR_DHT_GET_FAILED");if(n.dht==null||n.dht.value==null)throw new l("Invalid DHT get response","ERR_DHT_GET_FAILED");return n.dht.value}async findPeer(t){if(!jt(t))throw new l("invalid peer id received","ERR_INVALID_PEER_ID");let e=await this.client.send({type:S.Type.DHT,dht:{type:et.Type.FIND_PEER,peer:t.toBytes()}}),i=await e.read();if(i==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let n=b.decode(i);if(await e.close(),n.type!==b.Type.OK)throw new l(n.error?.msg??"DHT find peer failed","ERR_DHT_FIND_PEER_FAILED");if(n.dht==null||n.dht.peer==null||n.dht.peer.addrs==null)throw new l("Invalid response","ERR_DHT_FIND_PEER_FAILED");return{id:ut(n.dht.peer.id),multiaddrs:n.dht.peer.addrs.map(o=>V(o)),protocols:[]}}async provide(t){if(t==null||H.asCID(t)==null)throw new l("invalid cid received","ERR_INVALID_CID");let e=await this.client.send({type:S.Type.DHT,dht:{type:et.Type.PROVIDE,cid:t.bytes}}),i=await e.read();if(i==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let n=b.decode(i);if(await e.close(),n.type!==b.Type.OK)throw new l(n.error?.msg??"DHT provide failed","ERR_DHT_PROVIDE_FAILED")}async*findProviders(t,e=1){if(t==null||H.asCID(t)==null)throw new l("invalid cid received","ERR_INVALID_CID");let i=await this.client.send({type:S.Type.DHT,dht:{type:et.Type.FIND_PROVIDERS,cid:t.bytes,count:e}}),n=await i.read();if(n==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let o=b.decode(n);if(o.type!==b.Type.OK)throw await i.close(),new l(o.error?.msg??"DHT find providers failed","ERR_DHT_FIND_PROVIDERS_FAILED");for(;;){if(n=await i.read(),n==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let s=ct.decode(n);if(s.type===ct.Type.END){await i.close();return}if(s.type===ct.Type.VALUE&&s.peer!=null&&s.peer?.addrs!=null)yield{id:ut(s.peer.id),multiaddrs:s.peer.addrs.map(c=>V(c)),protocols:[]};else throw await i.close(),new l("unexpected message received","ERR_UNEXPECTED_MESSAGE_RECEIVED")}}async*getClosestPeers(t){if(!(t instanceof Uint8Array))throw new l("invalid key received","ERR_INVALID_KEY");let e=await this.client.send({type:S.Type.DHT,dht:{type:et.Type.GET_CLOSEST_PEERS,key:t}}),i=await e.read();if(i==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let n=b.decode(i);if(n.type!==b.Type.OK)throw await e.close(),new l(n.error?.msg??"DHT find providers failed","ERR_DHT_FIND_PROVIDERS_FAILED");for(;;){if(i=await e.read(),i==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let o=ct.decode(i);if(o.type===ct.Type.END){await e.close();return}if(o.type===ct.Type.VALUE&&o.value!=null)yield{id:ut(o.value),multiaddrs:[],protocols:[]};else throw await e.close(),new l("unexpected message received","ERR_UNEXPECTED_MESSAGE_RECEIVED")}}async getPublicKey(t){if(!jt(t))throw new l("invalid peer id received","ERR_INVALID_PEER_ID");let e=await this.client.send({type:S.Type.DHT,dht:{type:et.Type.GET_PUBLIC_KEY,peer:t.toBytes()}}),i=await e.read();if(i==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let n=b.decode(i);if(await e.close(),n.type!==b.Type.OK)throw new l(n.error?.msg??"DHT get public key failed","ERR_DHT_GET_PUBLIC_KEY_FAILED");if(n.dht==null)throw new l("Invalid response","ERR_DHT_GET_PUBLIC_KEY_FAILED");return n.dht.value}};var rr=class{client;constructor(t){this.client=t}async getTopics(){let t=await this.client.send({type:S.Type.PUBSUB,pubsub:{type:mt.Type.GET_TOPICS}}),e=await t.read();if(e==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let i=b.decode(e);if(await t.close(),i.type!==b.Type.OK)throw new l(i.error?.msg??"Pubsub get topics failed","ERR_PUBSUB_GET_TOPICS_FAILED");if(i.pubsub==null||i.pubsub.topics==null)throw new l("Invalid response","ERR_PUBSUB_GET_TOPICS_FAILED");return i.pubsub.topics}async publish(t,e){if(typeof t!="string")throw new l("invalid topic received","ERR_INVALID_TOPIC");if(!(e instanceof Uint8Array))throw new l("data received is not a Uint8Array","ERR_INVALID_DATA");let i=await this.client.send({type:S.Type.PUBSUB,pubsub:{type:mt.Type.PUBLISH,topic:t,data:e}}),n=await i.read();if(n==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let o=b.decode(n);if(await i.close(),o.type!==b.Type.OK)throw new l(o.error?.msg??"Pubsub publish failed","ERR_PUBSUB_PUBLISH_FAILED")}async subscribe(t){if(typeof t!="string")throw new l("invalid topic received","ERR_INVALID_TOPIC");let e=await this.client.send({type:S.Type.PUBSUB,pubsub:{type:mt.Type.SUBSCRIBE,topic:t}}),i=await e.read();if(i==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let n=b.decode(i);if(n.type!==b.Type.OK)throw new l(n.error?.msg??"Pubsub publish failed","ERR_PUBSUB_PUBLISH_FAILED");let o=!0;return{async*messages(){for(;o;){if(i=await e.read(),i==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");yield Le.decode(i)}},async cancel(){o=!1,await e.close()}}}async getSubscribers(t){if(typeof t!="string")throw new l("invalid topic received","ERR_INVALID_TOPIC");let e=await this.client.send({type:S.Type.PUBSUB,pubsub:{type:mt.Type.LIST_PEERS,topic:t}}),i=await e.read();if(i==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let n=b.decode(i);if(await e.close(),n.type!==b.Type.OK)throw new l(n.error?.msg??"Pubsub get subscribers failed","ERR_PUBSUB_GET_SUBSCRIBERS_FAILED");if(n.pubsub==null||n.pubsub.topics==null)throw new l("Invalid response","ERR_PUBSUB_GET_SUBSCRIBERS_FAILED");return n.pubsub.peerIDs.map(o=>ut(o))}};var wn=rt("libp2p:daemon-client"),xn=class{multiaddr;dht;pubsub;tcp;constructor(t){this.multiaddr=t,this.tcp=ro()(),this.dht=new er(this),this.pubsub=new rr(this)}async connectDaemon(){return this.tcp.dial(this.multiaddr,{upgrader:Wr})}async send(t){let e=await this.connectDaemon(),i=t.pubsub?.type??t.dht?.type??t.peerStore?.type??"";wn("send",t.type,i);let n=new fe({stream:e});return n.write(S.encode(t)),n}async connect(t,e){if(!jt(t))throw new l("invalid peer id received","ERR_INVALID_PEER_ID");if(!Array.isArray(e))throw new l("addrs received are not in an array","ERR_INVALID_ADDRS_TYPE");e.forEach(s=>{if(!sn(s))throw new l("received an address that is not a multiaddr","ERR_NO_MULTIADDR_RECEIVED")});let i=await this.send({type:S.Type.CONNECT,connect:{peer:t.toBytes(),addrs:e.map(s=>s.bytes)}}),n=await i.read();if(n==null)throw new l("unspecified","ERR_CONNECT_FAILED");let o=b.decode(n);if(o.type!==b.Type.OK){let s=o.error??{msg:"unspecified"};throw new l(s.msg??"unspecified","ERR_CONNECT_FAILED")}await i.close()}async identify(){let t=await this.send({type:S.Type.IDENTIFY}),e=await t.read();if(e==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let i=b.decode(e);if(i.type!==b.Type.OK)throw new l(i.error?.msg??"Identify failed","ERR_IDENTIFY_FAILED");if(i.identify==null||i.identify.addrs==null)throw new l("Invalid response","ERR_IDENTIFY_FAILED");let n=ut(i.identify?.id),o=i.identify.addrs.map(s=>V(s));return await t.close(),{peerId:n,addrs:o}}async listPeers(){let t=await this.send({type:S.Type.LIST_PEERS}),e=await t.read();if(e==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let i=b.decode(e);if(i.type!==b.Type.OK)throw new l(i.error?.msg??"List peers failed","ERR_LIST_PEERS_FAILED");return await t.close(),i.peers.map(n=>ut(n.id))}async openStream(t,e){if(!jt(t))throw new l("invalid peer id received","ERR_INVALID_PEER_ID");if(typeof e!="string")throw new l("invalid protocol received","ERR_INVALID_PROTOCOL");let i=await this.send({type:S.Type.STREAM_OPEN,streamOpen:{peer:t.toBytes(),proto:[e]}}),n=await i.read();if(n==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let o=b.decode(n);if(o.type!==b.Type.OK)throw await i.close(),new l(o.error?.msg??"Open stream failed","ERR_OPEN_STREAM_FAILED");return i.rest()}async registerStreamHandler(t,e){if(typeof t!="string")throw new l("invalid protocol received","ERR_INVALID_PROTOCOL");let i=this.tcp.createListener({upgrader:Wr,handler:a=>{Promise.resolve().then(async()=>{let p=new fe({stream:a}),u=await p.read();if(u==null)throw new l("Could not read open stream response","ERR_OPEN_STREAM_FAILED");if(Ht.decode(u).proto!==t)throw new l("Incorrect protocol","ERR_OPEN_STREAM_FAILED");await e(p.rest())}).finally(()=>{a.close().catch(p=>{wn.error(p)}),i.close().catch(p=>{wn.error(p)})})}});await i.listen(V("/ip4/127.0.0.1/tcp/0"));let n=i.getAddrs()[0];if(n==null)throw new l("Could not listen on port","ERR_REGISTER_STREAM_HANDLER_FAILED");let o=await this.send({type:S.Type.STREAM_HANDLER,streamHandler:{addr:n.bytes,proto:[t]}}),s=await o.read();if(s==null)throw new l("Empty response from remote","ERR_EMPTY_RESPONSE");let c=b.decode(s);if(await o.close(),c.type!==b.Type.OK)throw new l(c.error?.msg??"Register stream handler failed","ERR_REGISTER_STREAM_HANDLER_FAILED")}};function Jc(r){return new xn(r)}return ao(Qc);})();
|
|
7
7
|
return Libp2PDaemonClient}));
|
package/dist/src/index.d.ts
CHANGED
|
@@ -14,32 +14,32 @@ export interface StreamHandlerFunction {
|
|
|
14
14
|
(stream: Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>, Source<Uint8Array>, Promise<void>>): Promise<void>;
|
|
15
15
|
}
|
|
16
16
|
export interface DHTClient {
|
|
17
|
-
put
|
|
18
|
-
get
|
|
19
|
-
provide
|
|
20
|
-
findProviders
|
|
21
|
-
findPeer
|
|
22
|
-
getClosestPeers
|
|
17
|
+
put(key: Uint8Array, value: Uint8Array): Promise<void>;
|
|
18
|
+
get(key: Uint8Array): Promise<Uint8Array>;
|
|
19
|
+
provide(cid: CID): Promise<void>;
|
|
20
|
+
findProviders(cid: CID, count?: number): AsyncIterable<PeerInfo>;
|
|
21
|
+
findPeer(peerId: PeerId): Promise<PeerInfo>;
|
|
22
|
+
getClosestPeers(key: Uint8Array): AsyncIterable<PeerInfo>;
|
|
23
23
|
}
|
|
24
24
|
export interface Subscription {
|
|
25
|
-
messages
|
|
26
|
-
cancel
|
|
25
|
+
messages(): AsyncIterable<PSMessage>;
|
|
26
|
+
cancel(): Promise<void>;
|
|
27
27
|
}
|
|
28
28
|
export interface PubSubClient {
|
|
29
|
-
publish
|
|
30
|
-
subscribe
|
|
31
|
-
getTopics
|
|
32
|
-
getSubscribers
|
|
29
|
+
publish(topic: string, data: Uint8Array): Promise<void>;
|
|
30
|
+
subscribe(topic: string): Promise<Subscription>;
|
|
31
|
+
getTopics(): Promise<string[]>;
|
|
32
|
+
getSubscribers(topic: string): Promise<PeerId[]>;
|
|
33
33
|
}
|
|
34
34
|
export interface DaemonClient {
|
|
35
|
-
identify
|
|
36
|
-
listPeers
|
|
37
|
-
connect
|
|
35
|
+
identify(): Promise<IdentifyResult>;
|
|
36
|
+
listPeers(): Promise<PeerId[]>;
|
|
37
|
+
connect(peerId: PeerId, addrs: Multiaddr[]): Promise<void>;
|
|
38
38
|
dht: DHTClient;
|
|
39
39
|
pubsub: PubSubClient;
|
|
40
|
-
send
|
|
41
|
-
openStream
|
|
42
|
-
registerStreamHandler
|
|
40
|
+
send(request: Request): Promise<StreamHandler>;
|
|
41
|
+
openStream(peerId: PeerId, protocol: string): Promise<Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>, Source<Uint8Array>, Promise<void>>>;
|
|
42
|
+
registerStreamHandler(protocol: string, handler: StreamHandlerFunction): Promise<void>;
|
|
43
43
|
}
|
|
44
44
|
export declare function createClient(multiaddr: Multiaddr): DaemonClient;
|
|
45
45
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,OAAO,EAAwB,MAAM,yBAAyB,CAAA;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AAGtE,OAAO,EAAY,KAAK,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAQjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAqQpD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,SAAS,EAAE,CAAA;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,UAAU,GAAG,cAAc,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAChH;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,OAAO,EAAwB,MAAM,yBAAyB,CAAA;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AAGtE,OAAO,EAAY,KAAK,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAQjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAqQpD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,SAAS,EAAE,CAAA;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,UAAU,GAAG,cAAc,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAChH;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACtD,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IACzC,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAChC,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAA;IAChE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC3C,eAAe,CAAC,GAAG,EAAE,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAA;CAC1D;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,IAAI,aAAa,CAAC,SAAS,CAAC,CAAA;IACpC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACvD,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;IAC/C,SAAS,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAC9B,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;CACjD;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC,CAAA;IACnC,SAAS,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAC9B,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1D,GAAG,EAAE,SAAS,CAAA;IACd,MAAM,EAAE,YAAY,CAAA;IAEpB,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;IAC9C,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,GAAG,cAAc,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAC7I,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACvF;AAED,wBAAgB,YAAY,CAAE,SAAS,EAAE,SAAS,GAAG,YAAY,CAEhE"}
|
package/dist/typedoc-urls.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"DHTClient": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.DHTClient.html",
|
|
3
|
+
".:DHTClient": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.DHTClient.html",
|
|
3
4
|
"DaemonClient": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.DaemonClient.html",
|
|
5
|
+
".:DaemonClient": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.DaemonClient.html",
|
|
4
6
|
"IdentifyResult": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.IdentifyResult.html",
|
|
7
|
+
".:IdentifyResult": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.IdentifyResult.html",
|
|
5
8
|
"PubSubClient": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.PubSubClient.html",
|
|
9
|
+
".:PubSubClient": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.PubSubClient.html",
|
|
6
10
|
"StreamHandlerFunction": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.StreamHandlerFunction.html",
|
|
11
|
+
".:StreamHandlerFunction": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.StreamHandlerFunction.html",
|
|
7
12
|
"Subscription": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.Subscription.html",
|
|
8
|
-
"
|
|
13
|
+
".:Subscription": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_client.Subscription.html",
|
|
14
|
+
"createClient": "https://libp2p.github.io/js-libp2p-daemon/functions/_libp2p_daemon_client.createClient.html",
|
|
15
|
+
".:createClient": "https://libp2p.github.io/js-libp2p-daemon/functions/_libp2p_daemon_client.createClient.html"
|
|
9
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/daemon-client",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.2",
|
|
4
4
|
"description": "libp2p-daemon client implementation",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p-daemon/tree/master/packages/libp2p-daemon-client#readme",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"eslintConfig": {
|
|
32
32
|
"extends": "ipfs",
|
|
33
33
|
"parserOptions": {
|
|
34
|
+
"project": true,
|
|
34
35
|
"sourceType": "module"
|
|
35
36
|
}
|
|
36
37
|
},
|
|
@@ -130,7 +131,7 @@
|
|
|
130
131
|
"release": "aegir release"
|
|
131
132
|
},
|
|
132
133
|
"dependencies": {
|
|
133
|
-
"@chainsafe/libp2p-gossipsub": "^
|
|
134
|
+
"@chainsafe/libp2p-gossipsub": "^10.0.0",
|
|
134
135
|
"@libp2p/daemon-protocol": "^5.0.0",
|
|
135
136
|
"@libp2p/interface": "^0.1.0",
|
|
136
137
|
"@libp2p/kad-dht": "^10.0.0",
|
|
@@ -145,11 +146,11 @@
|
|
|
145
146
|
"devDependencies": {
|
|
146
147
|
"@libp2p/daemon-server": "^6.0.0",
|
|
147
148
|
"@libp2p/interface-compliance-tests": "^4.0.0",
|
|
148
|
-
"aegir": "^
|
|
149
|
+
"aegir": "^41.1.6",
|
|
149
150
|
"it-all": "^3.0.1",
|
|
150
151
|
"it-pipe": "^3.0.1",
|
|
151
|
-
"sinon": "^
|
|
152
|
-
"sinon-ts": "^
|
|
152
|
+
"sinon": "^17.0.1",
|
|
153
|
+
"sinon-ts": "^2.0.0",
|
|
153
154
|
"uint8arrays": "^4.0.4"
|
|
154
155
|
}
|
|
155
156
|
}
|
package/src/index.ts
CHANGED
|
@@ -286,36 +286,36 @@ export interface StreamHandlerFunction {
|
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
export interface DHTClient {
|
|
289
|
-
put
|
|
290
|
-
get
|
|
291
|
-
provide
|
|
292
|
-
findProviders
|
|
293
|
-
findPeer
|
|
294
|
-
getClosestPeers
|
|
289
|
+
put(key: Uint8Array, value: Uint8Array): Promise<void>
|
|
290
|
+
get(key: Uint8Array): Promise<Uint8Array>
|
|
291
|
+
provide(cid: CID): Promise<void>
|
|
292
|
+
findProviders(cid: CID, count?: number): AsyncIterable<PeerInfo>
|
|
293
|
+
findPeer(peerId: PeerId): Promise<PeerInfo>
|
|
294
|
+
getClosestPeers(key: Uint8Array): AsyncIterable<PeerInfo>
|
|
295
295
|
}
|
|
296
296
|
|
|
297
297
|
export interface Subscription {
|
|
298
|
-
messages
|
|
299
|
-
cancel
|
|
298
|
+
messages(): AsyncIterable<PSMessage>
|
|
299
|
+
cancel(): Promise<void>
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
export interface PubSubClient {
|
|
303
|
-
publish
|
|
304
|
-
subscribe
|
|
305
|
-
getTopics
|
|
306
|
-
getSubscribers
|
|
303
|
+
publish(topic: string, data: Uint8Array): Promise<void>
|
|
304
|
+
subscribe(topic: string): Promise<Subscription>
|
|
305
|
+
getTopics(): Promise<string[]>
|
|
306
|
+
getSubscribers(topic: string): Promise<PeerId[]>
|
|
307
307
|
}
|
|
308
308
|
|
|
309
309
|
export interface DaemonClient {
|
|
310
|
-
identify
|
|
311
|
-
listPeers
|
|
312
|
-
connect
|
|
310
|
+
identify(): Promise<IdentifyResult>
|
|
311
|
+
listPeers(): Promise<PeerId[]>
|
|
312
|
+
connect(peerId: PeerId, addrs: Multiaddr[]): Promise<void>
|
|
313
313
|
dht: DHTClient
|
|
314
314
|
pubsub: PubSubClient
|
|
315
315
|
|
|
316
|
-
send
|
|
317
|
-
openStream
|
|
318
|
-
registerStreamHandler
|
|
316
|
+
send(request: Request): Promise<StreamHandler>
|
|
317
|
+
openStream(peerId: PeerId, protocol: string): Promise<Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>, Source<Uint8Array>, Promise<void>>>
|
|
318
|
+
registerStreamHandler(protocol: string, handler: StreamHandlerFunction): Promise<void>
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
export function createClient (multiaddr: Multiaddr): DaemonClient {
|