@libp2p/mdns 10.0.15 → 10.0.16-28e51652a

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 CHANGED
@@ -1,3 +1,5 @@
1
+ # @libp2p/mdns
2
+
1
3
  [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
2
4
  [![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
3
5
  [![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p)
@@ -7,77 +9,92 @@
7
9
 
8
10
  # About
9
11
 
12
+ <!--
13
+
14
+ !IMPORTANT!
15
+
16
+ Everything in this README between "# About" and "# Install" is automatically
17
+ generated and will be overwritten the next time the doc generator is run.
18
+
19
+ To make changes to this section, please update the @packageDocumentation section
20
+ of src/index.js or src/index.ts
21
+
22
+ To experiment with formatting, please run "npm run docs" from the root of this
23
+ repo and examine the changes made.
24
+
25
+ -->
26
+
10
27
  A peer discover mechanism that uses [mDNS](https://datatracker.ietf.org/doc/html/rfc6762) to discover peers on the local network.
11
28
 
12
- ## Example
29
+ ## Example - Use with libp2p
13
30
 
14
31
  ```TypeScript
32
+ import { createLibp2p } from 'libp2p'
15
33
  import { mdns } from '@libp2p/mdns'
16
34
 
17
- const options = {
35
+ const libp2p = await createLibp2p({
18
36
  peerDiscovery: [
19
37
  mdns()
20
38
  ]
21
- }
22
-
23
- const libp2p = await createLibp2p(options)
24
-
25
- libp2p.on('peer:discovery', function (peerId) {
26
- console.log('found peer: ', peerId.toB58String())
27
39
  })
28
40
 
29
- await libp2p.start()
41
+ libp2p.addEventListener('peer:discovery', (evt) => {
42
+ console.log('found peer: ', evt.detail.toString())
43
+ })
30
44
  ```
31
45
 
32
46
  ## MDNS messages
33
47
 
34
48
  A query is sent to discover the libp2p nodes on the local network
35
49
 
36
- ```js
50
+ ```JSON
37
51
  {
38
- type: 'query',
39
- questions: [ { name: '_p2p._udp.local', type: 'PTR' } ]
52
+ "type": "query",
53
+ "questions": [{
54
+ "name": "_p2p._udp.local",
55
+ "type": "PTR"
56
+ }]
40
57
  }
41
58
  ```
42
59
 
43
60
  When a query is detected, each libp2p node sends an answer about itself
44
61
 
45
- ```js
62
+ ```JSON
46
63
  [{
47
- name: '_p2p._udp.local',
48
- type: 'PTR',
49
- class: 'IN',
50
- ttl: 120,
51
- data: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local'
64
+ "name": "_p2p._udp.local",
65
+ "type": "PTR",
66
+ "class": "IN",
67
+ "ttl": 120,
68
+ "data": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local"
52
69
  }, {
53
- name: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local',
54
- type: 'SRV',
55
- class: 'IN',
56
- ttl: 120,
57
- data: {
58
- priority: 10,
59
- weight: 1,
60
- port: '20002',
61
- target: 'LAPTOP-G5LJ7VN9'
70
+ "name": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local",
71
+ "type": "SRV",
72
+ "class": "IN",
73
+ "ttl": 120,
74
+ "data": {
75
+ "priority": 10,
76
+ "weight": 1,
77
+ "port": "20002",
78
+ "target": "LAPTOP-G5LJ7VN9"
62
79
  }
63
80
  }, {
64
- name: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local',
65
- type: 'TXT',
66
- class: 'IN',
67
- ttl: 120,
68
- data: ['QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK']
81
+ "name": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local",
82
+ "type": "TXT",
83
+ "class": "IN",
84
+ "ttl": 120,
85
+ "data": ["QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK"]
69
86
  }, {
70
- name: 'LAPTOP-G5LJ7VN9',
71
- type: 'A',
72
- class: 'IN',
73
- ttl: 120,
74
- data: '127.0.0.1'
87
+ "name": "LAPTOP-G5LJ7VN9",
88
+ "type": "A",
89
+ "class": "IN",
90
+ "ttl": 120,
91
+ "data": "127.0.0.1"
75
92
  }, {
76
- name: 'LAPTOP-G5LJ7VN9',
77
- type: 'AAAA',
78
- class: 'IN',
79
- ttl: 120,
80
- data: '::1'
93
+ "name": "LAPTOP-G5LJ7VN9",
94
+ "type": "AAAA",
95
+ "class": "IN",
96
+ "ttl": 120,
97
+ "data": "::1"
81
98
  }]
82
99
  ```
83
100
 
package/dist/index.min.js CHANGED
@@ -1,3 +1,3 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PMdns = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PMdns=(()=>{var Et=Object.create;var je=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var xt=Object.getOwnPropertyNames;var vt=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty;var Le=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var G=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),k=(r,e)=>{for(var n in e)je(r,n,{get:e[n],enumerable:!0})},on=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of xt(e))!At.call(r,i)&&i!==n&&je(r,i,{get:()=>e[i],enumerable:!(t=It(e,i))||t.enumerable});return r};var ir=(r,e,n)=>(n=r!=null?Et(vt(r)):{},on(e||!r||!r.__esModule?je(n,"default",{value:r,enumerable:!0}):n,r)),Ut=r=>on(je({},"__esModule",{value:!0}),r);var an=G(sr=>{"use strict";sr.toString=function(r){switch(r){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+r};sr.toType=function(r){switch(r.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":return 255;case"*":return 255}return r.toUpperCase().startsWith("UNKNOWN_")?parseInt(r.slice(8)):0}});var dn=G(ar=>{"use strict";ar.toString=function(r){switch(r){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+r};ar.toRcode=function(r){switch(r.toUpperCase()){case"NOERROR":return 0;case"FORMERR":return 1;case"SERVFAIL":return 2;case"NXDOMAIN":return 3;case"NOTIMP":return 4;case"REFUSED":return 5;case"YXDOMAIN":return 6;case"YXRRSET":return 7;case"NXRRSET":return 8;case"NOTAUTH":return 9;case"NOTZONE":return 10;case"RCODE_11":return 11;case"RCODE_12":return 12;case"RCODE_13":return 13;case"RCODE_14":return 14;case"RCODE_15":return 15}return 0}});var ln=G(dr=>{"use strict";dr.toString=function(r){switch(r){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+r};dr.toOpcode=function(r){switch(r.toUpperCase()){case"QUERY":return 0;case"IQUERY":return 1;case"STATUS":return 2;case"OPCODE_3":return 3;case"NOTIFY":return 4;case"UPDATE":return 5;case"OPCODE_6":return 6;case"OPCODE_7":return 7;case"OPCODE_8":return 8;case"OPCODE_9":return 9;case"OPCODE_10":return 10;case"OPCODE_11":return 11;case"OPCODE_12":return 12;case"OPCODE_13":return 13;case"OPCODE_14":return 14;case"OPCODE_15":return 15}return 0}});var un=G(lr=>{"use strict";lr.toString=function(r){switch(r){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+r};lr.toClass=function(r){switch(r.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}});var hn=G(ur=>{"use strict";ur.toString=function(r){switch(r){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}return r<0?null:`OPTION_${r}`};ur.toCode=function(r){if(typeof r=="number")return r;if(!r)return-1;switch(r.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}let e=r.match(/_(\d+)$/);return e?parseInt(e[1],10):-1}});var mn=G((gn,hr)=>{var pn=function(r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.decode=l,r.encode=m,r.familyOf=d,r.name=void 0,r.sizeOf=a,r.v6=r.v4=void 0;let e=/^(\d{1,3}\.){3,3}\d{1,3}$/,n=4,t=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,i=16,o={name:"v4",size:n,isFormat:u=>e.test(u),encode(u,p,s){s=~~s,p=p||new Uint8Array(s+n);let y=u.length,v=0;for(let U=0;U<y;){let L=u.charCodeAt(U++);L===46?(p[s++]=v,v=0):v=v*10+(L-48)}return p[s]=v,p},decode(u,p){return p=~~p,`${u[p++]}.${u[p++]}.${u[p++]}.${u[p]}`}};r.v4=o;let c={name:"v6",size:i,isFormat:u=>u.length>0&&t.test(u),encode(u,p,s){s=~~s;let y=s+i,v=-1,U=0,L=0,B=!0,T=!1;p=p||new Uint8Array(s+i);for(let b=0;b<u.length;b++){let C=u.charCodeAt(b);C===58?(B?v!==-1?(s<y&&(p[s]=0),s<y-1&&(p[s+1]=0),s+=2):s<y&&(v=s):(T===!0?(s<y&&(p[s]=L),s++):(s<y&&(p[s]=U>>8),s<y-1&&(p[s+1]=U&255),s+=2),U=0,L=0),B=!0,T=!1):C===46?(s<y&&(p[s]=L),s++,L=0,U=0,B=!1,T=!0):(B=!1,C>=97?C-=87:C>=65?C-=55:(C-=48,L=L*10+C),U=(U<<4)+C)}if(B===!1)T===!0?(s<y&&(p[s]=L),s++):(s<y&&(p[s]=U>>8),s<y-1&&(p[s+1]=U&255),s+=2);else if(v===0)s<y&&(p[s]=0),s<y-1&&(p[s+1]=0),s+=2;else if(v!==-1){s+=2;for(let b=Math.min(s-1,y-1);b>=v+2;b--)p[b]=p[b-2];p[v]=0,p[v+1]=0,v=s}if(v!==s&&v!==-1)for(s>y-2&&(s=y-2);y>v;)p[--y]=s<y&&s>v?p[--s]:0;else for(;s<y;)p[s++]=0;return p},decode(u,p){p=~~p;let s="";for(let y=0;y<i;y+=2)y!==0&&(s+=":"),s+=(u[p+y]<<8|u[p+y+1]).toString(16);return s.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};r.v6=c;let h="ip";r.name=h;function a(u){if(o.isFormat(u))return o.size;if(c.isFormat(u))return c.size;throw Error(`Invalid ip address: ${u}`)}function d(u){return a(u)===o.size?1:2}function m(u,p,s){s=~~s;let y=a(u);return typeof p=="function"&&(p=p(s+y)),y===o.size?o.encode(u,p,s):c.encode(u,p,s)}function l(u,p,s){if(p=~~p,s=s||u.length-p,s===o.size)return o.decode(u,p,s);if(s===c.size)return c.decode(u,p,s);throw Error(`Invalid buffer size needs to be ${o.size} for v4 or ${c.size} for v6.`)}return"default"in r?r.default:r}({});typeof define=="function"&&define.amd?define([],function(){return pn}):typeof hr=="object"&&typeof gn=="object"&&(hr.exports=pn)});var En=G(w=>{"use strict";var E=Le("buffer").Buffer,pe=an(),St=dn(),Lt=ln(),Qe=un(),pr=hn(),xe=mn(),bt=0,yn=32768,gr=32768,Ct=~gr,wn=32768,Ot=~wn,g=w.name={};g.encode=function(r,e,n,{mail:t=!1}={}){e||(e=E.alloc(g.encodingLength(r))),n||(n=0);let i=n,o=r.replace(/^\.|\.$/gm,"");if(o.length){let c=[];if(t){let h="";o.split(".").forEach(a=>{a.endsWith("\\")?h+=(h.length?".":"")+a.slice(0,-1):c.length===0&&h.length?c.push(h+"."+a):c.push(a)})}else c=o.split(".");for(let h=0;h<c.length;h++){let a=e.write(c[h],n+1);e[n]=a,n+=a+1}}return e[n++]=0,g.encode.bytes=n-i,e};g.encode.bytes=0;g.decode=function(r,e,{mail:n=!1}={}){e||(e=0);let t=[],i=e,o=0,c=0,h=!1;for(;;){if(e>=r.length)throw new Error("Cannot decode name (buffer overflow)");let a=r[e++];if(c+=h?0:1,a===0)break;if(a&192)if((a&192)===192){if(e+1>r.length)throw new Error("Cannot decode name (buffer overflow)");let d=r.readUInt16BE(e-1)-49152;if(d>=i)throw new Error("Cannot decode name (bad pointer)");e=d,i=d,c+=h?0:1,h=!0}else throw new Error("Cannot decode name (bad label)");else{if(e+a>r.length)throw new Error("Cannot decode name (buffer overflow)");if(o+=a+1,o>254)throw new Error("Cannot decode name (name too long)");let d=r.toString("utf-8",e,e+a);n&&(d=d.replace(/\./g,"\\.")),t.push(d),e+=a,c+=h?0:a}}return g.decode.bytes=c,t.length===0?".":t.join(".")};g.decode.bytes=0;g.encodingLength=function(r){return r==="."||r===".."?1:E.byteLength(r.replace(/^\.|\.$/gm,""))+2};var I={};I.encode=function(r,e,n){e||(e=E.alloc(I.encodingLength(r))),n||(n=0);let t=e.write(r,n+1);return e[n]=t,I.encode.bytes=t+1,e};I.encode.bytes=0;I.decode=function(r,e){e||(e=0);let n=r[e],t=r.toString("utf-8",e+1,e+1+n);return I.decode.bytes=n+1,t};I.decode.bytes=0;I.encodingLength=function(r){return E.byteLength(r)+1};var X={};X.encode=function(r,e,n){e||(e=X.encodingLength(r)),n||(n=0);let t=(r.flags||0)&32767,i=r.type==="response"?yn:bt;return e.writeUInt16BE(r.id||0,n),e.writeUInt16BE(t|i,n+2),e.writeUInt16BE(r.questions.length,n+4),e.writeUInt16BE(r.answers.length,n+6),e.writeUInt16BE(r.authorities.length,n+8),e.writeUInt16BE(r.additionals.length,n+10),e};X.encode.bytes=12;X.decode=function(r,e){if(e||(e=0),r.length<12)throw new Error("Header must be 12 bytes");let n=r.readUInt16BE(e+2);return{id:r.readUInt16BE(e),type:n&yn?"response":"query",flags:n&32767,flag_qr:(n>>15&1)===1,opcode:Lt.toString(n>>11&15),flag_aa:(n>>10&1)===1,flag_tc:(n>>9&1)===1,flag_rd:(n>>8&1)===1,flag_ra:(n>>7&1)===1,flag_z:(n>>6&1)===1,flag_ad:(n>>5&1)===1,flag_cd:(n>>4&1)===1,rcode:St.toString(n&15),questions:new Array(r.readUInt16BE(e+4)),answers:new Array(r.readUInt16BE(e+6)),authorities:new Array(r.readUInt16BE(e+8)),additionals:new Array(r.readUInt16BE(e+10))}};X.decode.bytes=12;X.encodingLength=function(){return 12};var ie=w.unknown={};ie.encode=function(r,e,n){return e||(e=E.alloc(ie.encodingLength(r))),n||(n=0),e.writeUInt16BE(r.length,n),r.copy(e,n+2),ie.encode.bytes=r.length+2,e};ie.encode.bytes=0;ie.decode=function(r,e){e||(e=0);let n=r.readUInt16BE(e),t=r.slice(e+2,e+2+n);return ie.decode.bytes=n+2,t};ie.decode.bytes=0;ie.encodingLength=function(r){return r.length+2};var oe=w.ns={};oe.encode=function(r,e,n){return e||(e=E.alloc(oe.encodingLength(r))),n||(n=0),g.encode(r,e,n+2),e.writeUInt16BE(g.encode.bytes,n),oe.encode.bytes=g.encode.bytes+2,e};oe.encode.bytes=0;oe.decode=function(r,e){e||(e=0);let n=r.readUInt16BE(e),t=g.decode(r,e+2);return oe.decode.bytes=n+2,t};oe.decode.bytes=0;oe.encodingLength=function(r){return g.encodingLength(r)+2};var ce=w.soa={};ce.encode=function(r,e,n){e||(e=E.alloc(ce.encodingLength(r))),n||(n=0);let t=n;return n+=2,g.encode(r.mname,e,n),n+=g.encode.bytes,g.encode(r.rname,e,n,{mail:!0}),n+=g.encode.bytes,e.writeUInt32BE(r.serial||0,n),n+=4,e.writeUInt32BE(r.refresh||0,n),n+=4,e.writeUInt32BE(r.retry||0,n),n+=4,e.writeUInt32BE(r.expire||0,n),n+=4,e.writeUInt32BE(r.minimum||0,n),n+=4,e.writeUInt16BE(n-t-2,t),ce.encode.bytes=n-t,e};ce.encode.bytes=0;ce.decode=function(r,e){e||(e=0);let n=e,t={};return e+=2,t.mname=g.decode(r,e),e+=g.decode.bytes,t.rname=g.decode(r,e,{mail:!0}),e+=g.decode.bytes,t.serial=r.readUInt32BE(e),e+=4,t.refresh=r.readUInt32BE(e),e+=4,t.retry=r.readUInt32BE(e),e+=4,t.expire=r.readUInt32BE(e),e+=4,t.minimum=r.readUInt32BE(e),e+=4,ce.decode.bytes=e-n,t};ce.decode.bytes=0;ce.encodingLength=function(r){return 22+g.encodingLength(r.mname)+g.encodingLength(r.rname)};var se=w.txt={};se.encode=function(r,e,n){Array.isArray(r)||(r=[r]);for(let i=0;i<r.length;i++)if(typeof r[i]=="string"&&(r[i]=E.from(r[i])),!E.isBuffer(r[i]))throw new Error("Must be a Buffer");e||(e=E.alloc(se.encodingLength(r))),n||(n=0);let t=n;return n+=2,r.forEach(function(i){e[n++]=i.length,i.copy(e,n,0,i.length),n+=i.length}),e.writeUInt16BE(n-t-2,t),se.encode.bytes=n-t,e};se.encode.bytes=0;se.decode=function(r,e){e||(e=0);let n=e,t=r.readUInt16BE(e);e+=2;let i=[];for(;t>0;){let o=r[e++];if(--t,t<o)throw new Error("Buffer overflow");i.push(r.slice(e,e+o)),e+=o,t-=o}return se.decode.bytes=e-n,i};se.decode.bytes=0;se.encodingLength=function(r){Array.isArray(r)||(r=[r]);let e=2;return r.forEach(function(n){typeof n=="string"?e+=E.byteLength(n)+1:e+=n.length+1}),e};var ae=w.null={};ae.encode=function(r,e,n){e||(e=E.alloc(ae.encodingLength(r))),n||(n=0),typeof r=="string"&&(r=E.from(r)),r||(r=E.alloc(0));let t=n;n+=2;let i=r.length;return r.copy(e,n,0,i),n+=i,e.writeUInt16BE(n-t-2,t),ae.encode.bytes=n-t,e};ae.encode.bytes=0;ae.decode=function(r,e){e||(e=0);let n=e,t=r.readUInt16BE(e);e+=2;let i=r.slice(e,e+t);return e+=t,ae.decode.bytes=e-n,i};ae.decode.bytes=0;ae.encodingLength=function(r){return r?(E.isBuffer(r)?r.length:E.byteLength(r))+2:2};var de=w.hinfo={};de.encode=function(r,e,n){e||(e=E.alloc(de.encodingLength(r))),n||(n=0);let t=n;return n+=2,I.encode(r.cpu,e,n),n+=I.encode.bytes,I.encode(r.os,e,n),n+=I.encode.bytes,e.writeUInt16BE(n-t-2,t),de.encode.bytes=n-t,e};de.encode.bytes=0;de.decode=function(r,e){e||(e=0);let n=e,t={};return e+=2,t.cpu=I.decode(r,e),e+=I.decode.bytes,t.os=I.decode(r,e),e+=I.decode.bytes,de.decode.bytes=e-n,t};de.decode.bytes=0;de.encodingLength=function(r){return I.encodingLength(r.cpu)+I.encodingLength(r.os)+2};var H=w.ptr={},Tt=w.cname=H,Nt=w.dname=H;H.encode=function(r,e,n){return e||(e=E.alloc(H.encodingLength(r))),n||(n=0),g.encode(r,e,n+2),e.writeUInt16BE(g.encode.bytes,n),H.encode.bytes=g.encode.bytes+2,e};H.encode.bytes=0;H.decode=function(r,e){e||(e=0);let n=g.decode(r,e+2);return H.decode.bytes=g.decode.bytes+2,n};H.decode.bytes=0;H.encodingLength=function(r){return g.encodingLength(r)+2};var le=w.srv={};le.encode=function(r,e,n){e||(e=E.alloc(le.encodingLength(r))),n||(n=0),e.writeUInt16BE(r.priority||0,n+2),e.writeUInt16BE(r.weight||0,n+4),e.writeUInt16BE(r.port||0,n+6),g.encode(r.target,e,n+8);let t=g.encode.bytes+6;return e.writeUInt16BE(t,n),le.encode.bytes=t+2,e};le.encode.bytes=0;le.decode=function(r,e){e||(e=0);let n=r.readUInt16BE(e),t={};return t.priority=r.readUInt16BE(e+2),t.weight=r.readUInt16BE(e+4),t.port=r.readUInt16BE(e+6),t.target=g.decode(r,e+8),le.decode.bytes=n+2,t};le.decode.bytes=0;le.encodingLength=function(r){return 8+g.encodingLength(r.target)};var M=w.caa={};M.ISSUER_CRITICAL=128;M.encode=function(r,e,n){let t=M.encodingLength(r);return e||(e=E.alloc(M.encodingLength(r))),n||(n=0),r.issuerCritical&&(r.flags=M.ISSUER_CRITICAL),e.writeUInt16BE(t-2,n),n+=2,e.writeUInt8(r.flags||0,n),n+=1,I.encode(r.tag,e,n),n+=I.encode.bytes,e.write(r.value,n),n+=E.byteLength(r.value),M.encode.bytes=t,e};M.encode.bytes=0;M.decode=function(r,e){e||(e=0);let n=r.readUInt16BE(e);e+=2;let t=e,i={};return i.flags=r.readUInt8(e),e+=1,i.tag=I.decode(r,e),e+=I.decode.bytes,i.value=r.toString("utf-8",e,t+n),i.issuerCritical=!!(i.flags&M.ISSUER_CRITICAL),M.decode.bytes=n+2,i};M.decode.bytes=0;M.encodingLength=function(r){return I.encodingLength(r.tag)+I.encodingLength(r.value)+2};var ye=w.mx={};ye.encode=function(r,e,n){e||(e=E.alloc(ye.encodingLength(r))),n||(n=0);let t=n;return n+=2,e.writeUInt16BE(r.preference||0,n),n+=2,g.encode(r.exchange,e,n),n+=g.encode.bytes,e.writeUInt16BE(n-t-2,t),ye.encode.bytes=n-t,e};ye.encode.bytes=0;ye.decode=function(r,e){e||(e=0);let n=e,t={};return e+=2,t.preference=r.readUInt16BE(e),e+=2,t.exchange=g.decode(r,e),e+=g.decode.bytes,ye.decode.bytes=e-n,t};ye.encodingLength=function(r){return 4+g.encodingLength(r.exchange)};var ue=w.a={};ue.encode=function(r,e,n){return e||(e=E.alloc(ue.encodingLength(r))),n||(n=0),e.writeUInt16BE(4,n),n+=2,xe.v4.encode(r,e,n),ue.encode.bytes=6,e};ue.encode.bytes=0;ue.decode=function(r,e){e||(e=0),e+=2;let n=xe.v4.decode(r,e);return ue.decode.bytes=6,n};ue.decode.bytes=0;ue.encodingLength=function(){return 6};var he=w.aaaa={};he.encode=function(r,e,n){return e||(e=E.alloc(he.encodingLength(r))),n||(n=0),e.writeUInt16BE(16,n),n+=2,xe.v6.encode(r,e,n),he.encode.bytes=18,e};he.encode.bytes=0;he.decode=function(r,e){e||(e=0),e+=2;let n=xe.v6.decode(r,e);return he.decode.bytes=18,n};he.decode.bytes=0;he.encodingLength=function(){return 18};var R=w.option={};R.encode=function(r,e,n){e||(e=E.alloc(R.encodingLength(r))),n||(n=0);let t=n,i=pr.toCode(r.code);if(e.writeUInt16BE(i,n),n+=2,r.data)e.writeUInt16BE(r.data.length,n),n+=2,r.data.copy(e,n),n+=r.data.length;else switch(i){case 8:let o=r.sourcePrefixLength||0,c=r.family||xe.familyOf(r.ip),h=xe.encode(r.ip,E.alloc),a=Math.ceil(o/8);e.writeUInt16BE(a+4,n),n+=2,e.writeUInt16BE(c,n),n+=2,e.writeUInt8(o,n++),e.writeUInt8(r.scopePrefixLength||0,n++),h.copy(e,n,0,a),n+=a;break;case 11:r.timeout?(e.writeUInt16BE(2,n),n+=2,e.writeUInt16BE(r.timeout,n),n+=2):(e.writeUInt16BE(0,n),n+=2);break;case 12:let d=r.length||0;e.writeUInt16BE(d,n),n+=2,e.fill(0,n,n+d),n+=d;break;case 14:let m=r.tags.length*2;e.writeUInt16BE(m,n),n+=2;for(let l of r.tags)e.writeUInt16BE(l,n),n+=2;break;default:throw new Error(`Unknown roption code: ${r.code}`)}return R.encode.bytes=n-t,e};R.encode.bytes=0;R.decode=function(r,e){e||(e=0);let n={};n.code=r.readUInt16BE(e),n.type=pr.toString(n.code),e+=2;let t=r.readUInt16BE(e);switch(e+=2,n.data=r.slice(e,e+t),n.code){case 8:n.family=r.readUInt16BE(e),e+=2,n.sourcePrefixLength=r.readUInt8(e++),n.scopePrefixLength=r.readUInt8(e++);let i=E.alloc(n.family===1?4:16);r.copy(i,0,e,e+t-4),n.ip=xe.decode(i);break;case 11:t>0&&(n.timeout=r.readUInt16BE(e),e+=2);break;case 14:n.tags=[];for(let o=0;o<t;o+=2)n.tags.push(r.readUInt16BE(e)),e+=2}return R.decode.bytes=t+4,n};R.decode.bytes=0;R.encodingLength=function(r){if(r.data)return r.data.length+4;switch(pr.toCode(r.code)){case 8:let n=r.sourcePrefixLength||0;return Math.ceil(n/8)+8;case 11:return typeof r.timeout=="number"?6:4;case 12:return r.length+4;case 14:return 4+r.tags.length*2}throw new Error(`Unknown roption code: ${r.code}`)};var q=w.opt={};q.encode=function(r,e,n){e||(e=E.alloc(q.encodingLength(r))),n||(n=0);let t=n,i=be(r,R);return e.writeUInt16BE(i,n),n=Fe(r,R,e,n+2),q.encode.bytes=n-t,e};q.encode.bytes=0;q.decode=function(r,e){e||(e=0);let n=e,t=[],i=r.readUInt16BE(e);e+=2;let o=0;for(;i>0;)t[o++]=R.decode(r,e),e+=R.decode.bytes,i-=R.decode.bytes;return q.decode.bytes=e-n,t};q.decode.bytes=0;q.encodingLength=function(r){return 2+be(r||[],R)};var F=w.dnskey={};F.PROTOCOL_DNSSEC=3;F.ZONE_KEY=128;F.SECURE_ENTRYPOINT=32768;F.encode=function(r,e,n){e||(e=E.alloc(F.encodingLength(r))),n||(n=0);let t=n,i=r.key;if(!E.isBuffer(i))throw new Error("Key must be a Buffer");return n+=2,e.writeUInt16BE(r.flags,n),n+=2,e.writeUInt8(F.PROTOCOL_DNSSEC,n),n+=1,e.writeUInt8(r.algorithm,n),n+=1,i.copy(e,n,0,i.length),n+=i.length,F.encode.bytes=n-t,e.writeUInt16BE(F.encode.bytes-2,t),e};F.encode.bytes=0;F.decode=function(r,e){e||(e=0);let n=e;var t={},i=r.readUInt16BE(e);if(e+=2,t.flags=r.readUInt16BE(e),e+=2,r.readUInt8(e)!==F.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,t.algorithm=r.readUInt8(e),e+=1,t.key=r.slice(e,n+i+2),e+=t.key.length,F.decode.bytes=e-n,t};F.decode.bytes=0;F.encodingLength=function(r){return 6+E.byteLength(r.key)};var Q=w.rrsig={};Q.encode=function(r,e,n){e||(e=E.alloc(Q.encodingLength(r))),n||(n=0);let t=n,i=r.signature;if(!E.isBuffer(i))throw new Error("Signature must be a Buffer");return n+=2,e.writeUInt16BE(pe.toType(r.typeCovered),n),n+=2,e.writeUInt8(r.algorithm,n),n+=1,e.writeUInt8(r.labels,n),n+=1,e.writeUInt32BE(r.originalTTL,n),n+=4,e.writeUInt32BE(r.expiration,n),n+=4,e.writeUInt32BE(r.inception,n),n+=4,e.writeUInt16BE(r.keyTag,n),n+=2,g.encode(r.signersName,e,n),n+=g.encode.bytes,i.copy(e,n,0,i.length),n+=i.length,Q.encode.bytes=n-t,e.writeUInt16BE(Q.encode.bytes-2,t),e};Q.encode.bytes=0;Q.decode=function(r,e){e||(e=0);let n=e;var t={},i=r.readUInt16BE(e);return e+=2,t.typeCovered=pe.toString(r.readUInt16BE(e)),e+=2,t.algorithm=r.readUInt8(e),e+=1,t.labels=r.readUInt8(e),e+=1,t.originalTTL=r.readUInt32BE(e),e+=4,t.expiration=r.readUInt32BE(e),e+=4,t.inception=r.readUInt32BE(e),e+=4,t.keyTag=r.readUInt16BE(e),e+=2,t.signersName=g.decode(r,e),e+=g.decode.bytes,t.signature=r.slice(e,n+i+2),e+=t.signature.length,Q.decode.bytes=e-n,t};Q.decode.bytes=0;Q.encodingLength=function(r){return 20+g.encodingLength(r.signersName)+E.byteLength(r.signature)};var W=w.rp={};W.encode=function(r,e,n){e||(e=E.alloc(W.encodingLength(r))),n||(n=0);let t=n;return n+=2,g.encode(r.mbox||".",e,n,{mail:!0}),n+=g.encode.bytes,g.encode(r.txt||".",e,n),n+=g.encode.bytes,W.encode.bytes=n-t,e.writeUInt16BE(W.encode.bytes-2,t),e};W.encode.bytes=0;W.decode=function(r,e){e||(e=0);let n=e,t={};return e+=2,t.mbox=g.decode(r,e,{mail:!0})||".",e+=g.decode.bytes,t.txt=g.decode(r,e)||".",e+=g.decode.bytes,W.decode.bytes=e-n,t};W.decode.bytes=0;W.encodingLength=function(r){return 2+g.encodingLength(r.mbox||".")+g.encodingLength(r.txt||".")};var O={};O.encode=function(r,e,n){e||(e=E.alloc(O.encodingLength(r))),n||(n=0);let t=n;for(var i=[],o=0;o<r.length;o++){var c=pe.toType(r[o]);i[c>>8]===void 0&&(i[c>>8]=[]),i[c>>8][c>>3&31]|=1<<7-(c&7)}for(o=0;o<i.length;o++)if(i[o]!==void 0){var h=E.from(i[o]);e.writeUInt8(o,n),n+=1,e.writeUInt8(h.length,n),n+=1,h.copy(e,n),n+=h.length}return O.encode.bytes=n-t,e};O.encode.bytes=0;O.decode=function(r,e,n){e||(e=0);let t=e;for(var i=[];e-t<n;){var o=r.readUInt8(e);e+=1;var c=r.readUInt8(e);e+=1;for(var h=0;h<c;h++)for(var a=r.readUInt8(e+h),d=0;d<8;d++)if(a&1<<7-d){var m=pe.toString(o<<8|h<<3|d);i.push(m)}e+=c}return O.decode.bytes=e-t,i};O.decode.bytes=0;O.encodingLength=function(r){for(var e=[],n=0;n<r.length;n++){var t=pe.toType(r[n]);e[t>>8]=Math.max(e[t>>8]||0,t&255)}var i=0;for(n=0;n<e.length;n++)e[n]!==void 0&&(i+=2+Math.ceil((e[n]+1)/8));return i};var J=w.nsec={};J.encode=function(r,e,n){e||(e=E.alloc(J.encodingLength(r))),n||(n=0);let t=n;return n+=2,g.encode(r.nextDomain,e,n),n+=g.encode.bytes,O.encode(r.rrtypes,e,n),n+=O.encode.bytes,J.encode.bytes=n-t,e.writeUInt16BE(J.encode.bytes-2,t),e};J.encode.bytes=0;J.decode=function(r,e){e||(e=0);let n=e;var t={},i=r.readUInt16BE(e);return e+=2,t.nextDomain=g.decode(r,e),e+=g.decode.bytes,t.rrtypes=O.decode(r,e,i-(e-n)),e+=O.decode.bytes,J.decode.bytes=e-n,t};J.decode.bytes=0;J.encodingLength=function(r){return 2+g.encodingLength(r.nextDomain)+O.encodingLength(r.rrtypes)};var Z=w.nsec3={};Z.encode=function(r,e,n){e||(e=E.alloc(Z.encodingLength(r))),n||(n=0);let t=n,i=r.salt;if(!E.isBuffer(i))throw new Error("salt must be a Buffer");let o=r.nextDomain;if(!E.isBuffer(o))throw new Error("nextDomain must be a Buffer");return n+=2,e.writeUInt8(r.algorithm,n),n+=1,e.writeUInt8(r.flags,n),n+=1,e.writeUInt16BE(r.iterations,n),n+=2,e.writeUInt8(i.length,n),n+=1,i.copy(e,n,0,i.length),n+=i.length,e.writeUInt8(o.length,n),n+=1,o.copy(e,n,0,o.length),n+=o.length,O.encode(r.rrtypes,e,n),n+=O.encode.bytes,Z.encode.bytes=n-t,e.writeUInt16BE(Z.encode.bytes-2,t),e};Z.encode.bytes=0;Z.decode=function(r,e){e||(e=0);let n=e;var t={},i=r.readUInt16BE(e);e+=2,t.algorithm=r.readUInt8(e),e+=1,t.flags=r.readUInt8(e),e+=1,t.iterations=r.readUInt16BE(e),e+=2;let o=r.readUInt8(e);e+=1,t.salt=r.slice(e,e+o),e+=o;let c=r.readUInt8(e);return e+=1,t.nextDomain=r.slice(e,e+c),e+=c,t.rrtypes=O.decode(r,e,i-(e-n)),e+=O.decode.bytes,Z.decode.bytes=e-n,t};Z.decode.bytes=0;Z.encodingLength=function(r){return 8+r.salt.length+r.nextDomain.length+O.encodingLength(r.rrtypes)};var f=w.ds={};f.encode=function(r,e,n){e||(e=E.alloc(f.encodingLength(r))),n||(n=0);let t=n,i=r.digest;if(!E.isBuffer(i))throw new Error("Digest must be a Buffer");return n+=2,e.writeUInt16BE(r.keyTag,n),n+=2,e.writeUInt8(r.algorithm,n),n+=1,e.writeUInt8(r.digestType,n),n+=1,i.copy(e,n,0,i.length),n+=i.length,f.encode.bytes=n-t,e.writeUInt16BE(f.encode.bytes-2,t),e};f.encode.bytes=0;f.decode=function(r,e){e||(e=0);let n=e;var t={},i=r.readUInt16BE(e);return e+=2,t.keyTag=r.readUInt16BE(e),e+=2,t.algorithm=r.readUInt8(e),e+=1,t.digestType=r.readUInt8(e),e+=1,t.digest=r.slice(e,n+i+2),e+=t.digest.length,f.decode.bytes=e-n,t};f.decode.bytes=0;f.encodingLength=function(r){return 6+E.byteLength(r.digest)};var z=w.sshfp={};z.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};z.encode=function(e,n,t){n||(n=E.alloc(z.encodingLength(e))),t||(t=0);let i=t;t+=2,n[t]=e.algorithm,t+=1,n[t]=e.hash,t+=1;let o=E.from(e.fingerprint.toUpperCase(),"hex");if(o.length!==z.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return o.copy(n,t),t+=o.byteLength,z.encode.bytes=t-i,n.writeUInt16BE(z.encode.bytes-2,i),n};z.encode.bytes=0;z.decode=function(e,n){n||(n=0);let t=n,i={};n+=2,i.algorithm=e[n],n+=1,i.hash=e[n],n+=1;let o=z.getFingerprintLengthForHashType(i.hash);return i.fingerprint=e.slice(n,n+o).toString("hex").toUpperCase(),n+=o,z.decode.bytes=n-t,i};z.decode.bytes=0;z.encodingLength=function(r){return 4+E.from(r.fingerprint,"hex").byteLength};var ee=w.naptr={};ee.encode=function(r,e,n){e||(e=E.alloc(ee.encodingLength(r))),n||(n=0);let t=n;return n+=2,e.writeUInt16BE(r.order||0,n),n+=2,e.writeUInt16BE(r.preference||0,n),n+=2,I.encode(r.flags,e,n),n+=I.encode.bytes,I.encode(r.services,e,n),n+=I.encode.bytes,I.encode(r.regexp,e,n),n+=I.encode.bytes,g.encode(r.replacement,e,n),n+=g.encode.bytes,ee.encode.bytes=n-t,e.writeUInt16BE(ee.encode.bytes-2,t),e};ee.encode.bytes=0;ee.decode=function(r,e){e||(e=0);let n=e,t={};return e+=2,t.order=r.readUInt16BE(e),e+=2,t.preference=r.readUInt16BE(e),e+=2,t.flags=I.decode(r,e),e+=I.decode.bytes,t.services=I.decode(r,e),e+=I.decode.bytes,t.regexp=I.decode(r,e),e+=I.decode.bytes,t.replacement=g.decode(r,e),e+=g.decode.bytes,ee.decode.bytes=e-n,t};ee.decode.bytes=0;ee.encodingLength=function(r){return I.encodingLength(r.flags)+I.encodingLength(r.services)+I.encodingLength(r.regexp)+g.encodingLength(r.replacement)+6};var re=w.tlsa={};re.encode=function(r,e,n){e||(e=E.alloc(re.encodingLength(r))),n||(n=0);let t=n,i=r.certificate;if(!E.isBuffer(i))throw new Error("Certificate must be a Buffer");return n+=2,e.writeUInt8(r.usage,n),n+=1,e.writeUInt8(r.selector,n),n+=1,e.writeUInt8(r.matchingType,n),n+=1,i.copy(e,n,0,i.length),n+=i.length,re.encode.bytes=n-t,e.writeUInt16BE(re.encode.bytes-2,t),e};re.encode.bytes=0;re.decode=function(r,e){e||(e=0);let n=e,t={},i=r.readUInt16BE(e);return e+=2,t.usage=r.readUInt8(e),e+=1,t.selector=r.readUInt8(e),e+=1,t.matchingType=r.readUInt8(e),e+=1,t.certificate=r.slice(e,n+i+2),e+=t.certificate.length,re.decode.bytes=e-n,t};re.decode.bytes=0;re.encodingLength=function(r){return 5+E.byteLength(r.certificate)};var mr=w.record=function(r){switch(r.toUpperCase()){case"A":return ue;case"PTR":return H;case"CNAME":return Tt;case"DNAME":return Nt;case"TXT":return se;case"NULL":return ae;case"AAAA":return he;case"SRV":return le;case"HINFO":return de;case"CAA":return M;case"NS":return oe;case"SOA":return ce;case"MX":return ye;case"OPT":return q;case"DNSKEY":return F;case"RRSIG":return Q;case"RP":return W;case"NSEC":return J;case"NSEC3":return Z;case"SSHFP":return z;case"DS":return f;case"NAPTR":return ee;case"TLSA":return re}return ie},N=w.answer={};N.encode=function(r,e,n){e||(e=E.alloc(N.encodingLength(r))),n||(n=0);let t=n;if(g.encode(r.name,e,n),n+=g.encode.bytes,e.writeUInt16BE(pe.toType(r.type),n),r.type.toUpperCase()==="OPT"){if(r.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(r.udpPayloadSize||4096,n+2),e.writeUInt8(r.extendedRcode||0,n+4),e.writeUInt8(r.ednsVersion||0,n+5),e.writeUInt16BE(r.flags||0,n+6),n+=8,q.encode(r.options||[],e,n),n+=q.encode.bytes}else{let i=Qe.toClass(r.class===void 0?"IN":r.class);r.flush&&(i|=gr),e.writeUInt16BE(i,n+2),e.writeUInt32BE(r.ttl||0,n+4),n+=8;let o=mr(r.type);o.encode(r.data,e,n),n+=o.encode.bytes}return N.encode.bytes=n-t,e};N.encode.bytes=0;N.decode=function(r,e){e||(e=0);let n={},t=e;if(n.name=g.decode(r,e),e+=g.decode.bytes,n.type=pe.toString(r.readUInt16BE(e)),n.type==="OPT")n.udpPayloadSize=r.readUInt16BE(e+2),n.extendedRcode=r.readUInt8(e+4),n.ednsVersion=r.readUInt8(e+5),n.flags=r.readUInt16BE(e+6),n.flag_do=(n.flags>>15&1)===1,n.options=q.decode(r,e+8),e+=8+q.decode.bytes;else{let i=r.readUInt16BE(e+2);n.ttl=r.readUInt32BE(e+4),n.class=Qe.toString(i&Ct),n.flush=!!(i&gr);let o=mr(n.type);n.data=o.decode(r,e+8),e+=8+o.decode.bytes}return N.decode.bytes=e-t,n};N.decode.bytes=0;N.encodingLength=function(r){let e=r.data!==null&&r.data!==void 0?r.data:r.options;return g.encodingLength(r.name)+8+mr(r.type).encodingLength(e)};var j=w.question={};j.encode=function(r,e,n){e||(e=E.alloc(j.encodingLength(r))),n||(n=0);let t=n;return g.encode(r.name,e,n),n+=g.encode.bytes,e.writeUInt16BE(pe.toType(r.type),n),n+=2,e.writeUInt16BE(Qe.toClass(r.class===void 0?"IN":r.class),n),n+=2,j.encode.bytes=n-t,r};j.encode.bytes=0;j.decode=function(r,e){e||(e=0);let n=e,t={};return t.name=g.decode(r,e),e+=g.decode.bytes,t.type=pe.toString(r.readUInt16BE(e)),e+=2,t.class=Qe.toString(r.readUInt16BE(e)),e+=2,!!(t.class&wn)&&(t.class&=Ot),j.decode.bytes=e-n,t};j.decode.bytes=0;j.encodingLength=function(r){return g.encodingLength(r.name)+4};w.AUTHORITATIVE_ANSWER=1024;w.TRUNCATED_RESPONSE=512;w.RECURSION_DESIRED=256;w.RECURSION_AVAILABLE=128;w.AUTHENTIC_DATA=32;w.CHECKING_DISABLED=16;w.DNSSEC_OK=32768;w.encode=function(r,e,n){let t=!e;t&&(e=E.alloc(w.encodingLength(r))),n||(n=0);let i=n;return r.questions||(r.questions=[]),r.answers||(r.answers=[]),r.authorities||(r.authorities=[]),r.additionals||(r.additionals=[]),X.encode(r,e,n),n+=X.encode.bytes,n=Fe(r.questions,j,e,n),n=Fe(r.answers,N,e,n),n=Fe(r.authorities,N,e,n),n=Fe(r.additionals,N,e,n),w.encode.bytes=n-i,t&&w.encode.bytes!==e.length?e.slice(0,w.encode.bytes):e};w.encode.bytes=0;w.decode=function(r,e){e||(e=0);let n=e,t=X.decode(r,e);return e+=X.decode.bytes,e=Ge(t.questions,j,r,e),e=Ge(t.answers,N,r,e),e=Ge(t.authorities,N,r,e),e=Ge(t.additionals,N,r,e),w.decode.bytes=e-n,t};w.decode.bytes=0;w.encodingLength=function(r){return X.encodingLength(r)+be(r.questions||[],j)+be(r.answers||[],N)+be(r.authorities||[],N)+be(r.additionals||[],N)};w.streamEncode=function(r){let e=w.encode(r),n=E.alloc(2);n.writeUInt16BE(e.byteLength);let t=E.concat([n,e]);return w.streamEncode.bytes=t.byteLength,t};w.streamEncode.bytes=0;w.streamDecode=function(r){let e=r.readUInt16BE(0);if(r.byteLength<e+2)return null;let n=w.decode(r.slice(2));return w.streamDecode.bytes=w.decode.bytes,n};w.streamDecode.bytes=0;function be(r,e){let n=0;for(let t=0;t<r.length;t++)n+=e.encodingLength(r[t]);return n}function Fe(r,e,n,t){for(let i=0;i<r.length;i++)e.encode(r[i],n,t),t+=e.encode.bytes;return t}function Ge(r,e,n,t){for(let i=0;i<r.length;i++)r[i]=e.decode(n,t),t+=e.decode.bytes;return t}});var vn=G((Ho,xn)=>{"use strict";var In=_t;process.nextTick(Rt,42);xn.exports=Pt;function Pt(r){var e=t;return n;function n(i){e(i||Dt)}function t(i){var o=[i];e=c,r(h);function c(a){o.push(a)}function h(a){var d=arguments;for(e=Bt(a)?t:m;o.length;)m(o.shift());function m(l){In(Ft,l,d)}}}}function Bt(r){return Object.prototype.toString.call(r)==="[object Error]"}function Dt(){}function Ft(r,e){r.apply(null,e)}function Rt(r){r===42&&(In=process.nextTick)}function _t(r,e,n){process.nextTick(function(){r(e,n)})}});var Sn=G((jo,Un)=>{var yr=En(),kt=Le("dgram"),Mt=vn(),zt=Le("events"),Er=Le("os"),wr=function(){};Un.exports=function(r){r||(r={});var e=new zt.EventEmitter,n=typeof r.port=="number"?r.port:5353,t=r.type||"udp4",i=r.ip||r.host||(t==="udp4"?"224.0.0.251":null),o={address:i,port:n},c={},h=!1,a=null;if(t==="udp6"&&(!i||!r.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var d=r.socket||kt.createSocket({type:t,reuseAddr:r.reuseAddr!==!1,toString:function(){return t}});d.on("error",function(l){l.code==="EACCES"||l.code==="EADDRINUSE"?e.emit("error",l):e.emit("warning",l)}),d.on("message",function(l,u){try{l=yr.decode(l)}catch(p){e.emit("warning",p);return}e.emit("packet",l,u),l.type==="query"&&e.emit("query",l,u),l.type==="response"&&e.emit("response",l,u)}),d.on("listening",function(){n||(n=o.port=d.address().port),r.multicast!==!1&&(e.update(),a=setInterval(e.update,5e3),d.setMulticastTTL(r.ttl||255),d.setMulticastLoopback(r.loopback!==!1))});var m=Mt(function(l){if(!n||r.bind===!1)return l(null);d.once("error",l),d.bind(n,r.bind||r.interface,function(){d.removeListener("error",l),l(null)})});return m(function(l){if(l)return e.emit("error",l);e.emit("ready")}),e.send=function(l,u,p){if(typeof u=="function")return e.send(l,null,u);p||(p=wr),u?!u.host&&!u.address&&(u.address=o.address):u=o,m(s);function s(y){if(h)return p();if(y)return p(y);var v=yr.encode(l);d.send(v,0,v.length,u.port,u.address||u.host,p)}},e.response=e.respond=function(l,u,p){Array.isArray(l)&&(l={answers:l}),l.type="response",l.flags=(l.flags||0)|yr.AUTHORITATIVE_ANSWER,e.send(l,u,p)},e.query=function(l,u,p,s){if(typeof u=="function")return e.query(l,null,null,u);if(typeof u=="object"&&u&&u.port)return e.query(l,null,u,p);if(typeof p=="function")return e.query(l,u,null,p);s||(s=wr),typeof l=="string"&&(l=[{name:l,type:u||"ANY"}]),Array.isArray(l)&&(l={type:"query",questions:l}),l.type="query",e.send(l,p,s)},e.destroy=function(l){if(l||(l=wr),h)return process.nextTick(l);h=!0,clearInterval(a);for(var u in c)try{d.dropMembership(i,u)}catch{}c={},d.close(l)},e.update=function(){for(var l=r.interface?[].concat(r.interface):$t(),u=!1,p=0;p<l.length;p++){var s=l[p];if(!c[s])try{d.addMembership(i,s),c[s]=!0,u=!0}catch(y){e.emit("warning",y)}}if(u){if(d.setMulticastInterface)try{d.setMulticastInterface(r.interface||qt())}catch(y){e.emit("warning",y)}e.emit("networkInterface")}},e};function qt(){for(var r=Er.networkInterfaces(),e=Object.keys(r),n=0;n<e.length;n++)for(var t=r[e[n]],i=0;i<t.length;i++){var o=t[i];if(An(o.family)&&!o.internal)return Er.platform()==="darwin"&&e[n]==="en0"?o.address:"0.0.0.0"}return"127.0.0.1"}function $t(){for(var r=Er.networkInterfaces(),e=Object.keys(r),n=[],t=0;t<e.length;t++)for(var i=r[e[t]],o=0;o<i.length;o++){var c=i[o];if(An(c.family)){n.push(c.address);break}}return n}function An(r){return r===4||r==="IPv4"}});var Xn=G(Ke=>{(function(){var r,e,n,t,i,o,c,h;h=function(a){var d,m,l,u;return d=(a&255<<24)>>>24,m=(a&255<<16)>>>16,l=(a&65280)>>>8,u=a&255,[d,m,l,u].join(".")},c=function(a){var d,m,l,u,p,s;for(d=[],l=u=0;u<=3&&a.length!==0;l=++u){if(l>0){if(a[0]!==".")throw new Error("Invalid IP");a=a.substring(1)}s=e(a),p=s[0],m=s[1],a=a.substring(m),d.push(p)}if(a.length!==0)throw new Error("Invalid IP");switch(d.length){case 1:if(d[0]>4294967295)throw new Error("Invalid IP");return d[0]>>>0;case 2:if(d[0]>255||d[1]>16777215)throw new Error("Invalid IP");return(d[0]<<24|d[1])>>>0;case 3:if(d[0]>255||d[1]>255||d[2]>65535)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2])>>>0;case 4:if(d[0]>255||d[1]>255||d[2]>255||d[3]>255)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2]<<8|d[3])>>>0;default:throw new Error("Invalid IP")}},n=function(a){return a.charCodeAt(0)},t=n("0"),o=n("a"),i=n("A"),e=function(a){var d,m,l,u,p;for(u=0,d=10,m="9",l=0,a.length>1&&a[l]==="0"&&(a[l+1]==="x"||a[l+1]==="X"?(l+=2,d=16):"0"<=a[l+1]&&a[l+1]<="9"&&(l++,d=8,m="7")),p=l;l<a.length;){if("0"<=a[l]&&a[l]<=m)u=u*d+(n(a[l])-t)>>>0;else if(d===16)if("a"<=a[l]&&a[l]<="f")u=u*d+(10+n(a[l])-o)>>>0;else if("A"<=a[l]&&a[l]<="F")u=u*d+(10+n(a[l])-i)>>>0;else break;else break;if(u>4294967295)throw new Error("too large");l++}if(l===p)throw new Error("empty octet");return[u,l]},r=function(){function a(d,m){var l,u,p,s;if(typeof d!="string")throw new Error("Missing `net' parameter");if(m||(s=d.split("/",2),d=s[0],m=s[1]),m||(m=32),typeof m=="string"&&m.indexOf(".")>-1){try{this.maskLong=c(m)}catch(y){throw l=y,new Error("Invalid mask: "+m)}for(u=p=32;p>=0;u=--p)if(this.maskLong===4294967295<<32-u>>>0){this.bitmask=u;break}}else if(m||m===0)this.bitmask=parseInt(m,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(c(d)&this.maskLong)>>>0}catch(y){throw l=y,new Error("Invalid net address: "+d)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+m);this.size=Math.pow(2,32-this.bitmask),this.base=h(this.netLong),this.mask=h(this.maskLong),this.hostmask=h(~this.maskLong),this.first=this.bitmask<=30?h(this.netLong+1):this.base,this.last=this.bitmask<=30?h(this.netLong+this.size-2):h(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?h(this.netLong+this.size-1):void 0}return a.prototype.contains=function(d){return typeof d=="string"&&(d.indexOf("/")>0||d.split(".").length!==4)&&(d=new a(d)),d instanceof a?this.contains(d.base)&&this.contains(d.broadcast||d.last):(c(d)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},a.prototype.next=function(d){return d==null&&(d=1),new a(h(this.netLong+this.size*d),this.mask)},a.prototype.forEach=function(d){var m,l,u;for(u=c(this.first),l=c(this.last),m=0;u<=l;)d(h(u),u,m),m++,u++},a.prototype.toString=function(){return this.base+"/"+this.bitmask},a}(),Ke.ip2long=c,Ke.long2ip=h,Ke.Netmask=r}).call(Ke)});var Bo={};k(Bo,{mdns:()=>Po});var cn=Symbol.for("@libp2p/peer-discovery");var sn=Symbol.for("@libp2p/peer-id");var Xe=class extends Error{code;props;constructor(e,n,t){super(e),this.code=n,this.name=t?.name??"CodeError",this.props=t??{}}};var Ye=class extends EventTarget{#e=new Map;listenerCount(e){let n=this.#e.get(e);return n==null?0:n.length}addEventListener(e,n,t){super.addEventListener(e,n,t);let i=this.#e.get(e);i==null&&(i=[],this.#e.set(e,i)),i.push({callback:n,once:(t!==!0&&t!==!1&&t?.once)??!1})}removeEventListener(e,n,t){super.removeEventListener(e.toString(),n??null,t);let i=this.#e.get(e);i!=null&&(i=i.filter(({callback:o})=>o!==n),this.#e.set(e,i))}dispatchEvent(e){let n=super.dispatchEvent(e),t=this.#e.get(e.type);return t==null||(t=t.filter(({once:i})=>!i),this.#e.set(e.type,t)),n}safeDispatchEvent(e,n={}){return this.dispatchEvent(new cr(e,n))}},or=class extends Event{detail;constructor(e,n){super(e,n),this.detail=n?.detail}},cr=globalThis.CustomEvent??or;var wt=ir(Sn(),1);var Ur={};k(Ur,{base58btc:()=>P,base58flickr:()=>Yt});var Xo=new Uint8Array(0);function Ln(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let n=0;n<r.byteLength;n++)if(r[n]!==e[n])return!1;return!0}function $(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function bn(r){return new TextEncoder().encode(r)}function Cn(r){return new TextDecoder().decode(r)}function Vt(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),t=0;t<n.length;t++)n[t]=255;for(var i=0;i<r.length;i++){var o=r.charAt(i),c=o.charCodeAt(0);if(n[c]!==255)throw new TypeError(o+" is ambiguous");n[c]=i}var h=r.length,a=r.charAt(0),d=Math.log(h)/Math.log(256),m=Math.log(256)/Math.log(h);function l(s){if(s instanceof Uint8Array||(ArrayBuffer.isView(s)?s=new Uint8Array(s.buffer,s.byteOffset,s.byteLength):Array.isArray(s)&&(s=Uint8Array.from(s))),!(s instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(s.length===0)return"";for(var y=0,v=0,U=0,L=s.length;U!==L&&s[U]===0;)U++,y++;for(var B=(L-U)*m+1>>>0,T=new Uint8Array(B);U!==L;){for(var b=s[U],C=0,K=B-1;(b!==0||C<v)&&K!==-1;K--,C++)b+=256*T[K]>>>0,T[K]=b%h>>>0,b=b/h>>>0;if(b!==0)throw new Error("Non-zero carry");v=C,U++}for(var te=B-v;te!==B&&T[te]===0;)te++;for(var He=a.repeat(y);te<B;++te)He+=r.charAt(T[te]);return He}function u(s){if(typeof s!="string")throw new TypeError("Expected String");if(s.length===0)return new Uint8Array;var y=0;if(s[y]!==" "){for(var v=0,U=0;s[y]===a;)v++,y++;for(var L=(s.length-y)*d+1>>>0,B=new Uint8Array(L);s[y];){var T=n[s.charCodeAt(y)];if(T===255)return;for(var b=0,C=L-1;(T!==0||b<U)&&C!==-1;C--,b++)T+=h*B[C]>>>0,B[C]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");U=b,y++}if(s[y]!==" "){for(var K=L-U;K!==L&&B[K]===0;)K++;for(var te=new Uint8Array(v+(L-K)),He=v;K!==L;)te[He++]=B[K++];return te}}}function p(s){var y=u(s);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:u,decode:p}}var Kt=Vt,Ht=Kt,Tn=Ht;var Ir=class{name;prefix;baseEncode;constructor(e,n,t){this.name=e,this.prefix=n,this.baseEncode=t}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},xr=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,n,t){if(this.name=e,this.prefix=n,n.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n.codePointAt(0),this.baseDecode=t}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Nn(this,e)}},vr=class{decoders;constructor(e){this.decoders=e}or(e){return Nn(this,e)}decode(e){let n=e[0],t=this.decoders[n];if(t!=null)return t.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Nn(r,e){return new vr({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Ar=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,n,t,i){this.name=e,this.prefix=n,this.baseEncode=t,this.baseDecode=i,this.encoder=new Ir(e,n,t),this.decoder=new xr(e,n,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Ce({name:r,prefix:e,encode:n,decode:t}){return new Ar(r,e,n,t)}function we({name:r,prefix:e,alphabet:n}){let{encode:t,decode:i}=Tn(n,r);return Ce({prefix:e,name:r,encode:t,decode:o=>$(i(o))})}function jt(r,e,n,t){let i={};for(let m=0;m<e.length;++m)i[e[m]]=m;let o=r.length;for(;r[o-1]==="=";)--o;let c=new Uint8Array(o*n/8|0),h=0,a=0,d=0;for(let m=0;m<o;++m){let l=i[r[m]];if(l===void 0)throw new SyntaxError(`Non-${t} character`);a=a<<n|l,h+=n,h>=8&&(h-=8,c[d++]=255&a>>h)}if(h>=n||255&a<<8-h)throw new SyntaxError("Unexpected end of data");return c}function Xt(r,e,n){let t=e[e.length-1]==="=",i=(1<<n)-1,o="",c=0,h=0;for(let a=0;a<r.length;++a)for(h=h<<8|r[a],c+=8;c>n;)c-=n,o+=e[i&h>>c];if(c!==0&&(o+=e[i&h<<n-c]),t)for(;o.length*n&7;)o+="=";return o}function S({name:r,prefix:e,bitsPerChar:n,alphabet:t}){return Ce({prefix:e,name:r,encode(i){return Xt(i,t,n)},decode(i){return jt(i,t,n,r)}})}var P=we({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Yt=we({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Sr={};k(Sr,{base10:()=>Gt});var Gt=we({prefix:"9",name:"base10",alphabet:"0123456789"});var Lr={};k(Lr,{base16:()=>Qt,base16upper:()=>Wt});var Qt=S({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Wt=S({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var br={};k(br,{base2:()=>Jt});var Jt=S({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Cr={};k(Cr,{base256emoji:()=>ni});var Pn=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}"),Zt=Pn.reduce((r,e,n)=>(r[n]=e,r),[]),ft=Pn.reduce((r,e,n)=>(r[e.codePointAt(0)]=n,r),[]);function ei(r){return r.reduce((e,n)=>(e+=Zt[n],e),"")}function ri(r){let e=[];for(let n of r){let t=ft[n.codePointAt(0)];if(t===void 0)throw new Error(`Non-base256emoji character: ${n}`);e.push(t)}return new Uint8Array(e)}var ni=Ce({prefix:"\u{1F680}",name:"base256emoji",encode:ei,decode:ri});var Or={};k(Or,{base32:()=>ge,base32hex:()=>ci,base32hexpad:()=>ai,base32hexpadupper:()=>di,base32hexupper:()=>si,base32pad:()=>ii,base32padupper:()=>oi,base32upper:()=>ti,base32z:()=>li});var ge=S({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ti=S({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ii=S({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),oi=S({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ci=S({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),si=S({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ai=S({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),di=S({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),li=S({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Tr={};k(Tr,{base36:()=>ui,base36upper:()=>hi});var ui=we({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),hi=we({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Nr={};k(Nr,{base64:()=>pi,base64pad:()=>gi,base64url:()=>mi,base64urlpad:()=>yi});var pi=S({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),gi=S({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),mi=S({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),yi=S({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Pr={};k(Pr,{base8:()=>wi});var wi=S({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Br={};k(Br,{identity:()=>Ei});var Ei=Ce({prefix:"\0",name:"identity",encode:r=>Cn(r),decode:r=>bn(r)});var ac=new TextEncoder,dc=new TextDecoder;var Fr={};k(Fr,{identity:()=>Je});var vi=Fn,Bn=128,Ai=127,Ui=~Ai,Si=Math.pow(2,31);function Fn(r,e,n){e=e||[],n=n||0;for(var t=n;r>=Si;)e[n++]=r&255|Bn,r/=128;for(;r&Ui;)e[n++]=r&255|Bn,r>>>=7;return e[n]=r|0,Fn.bytes=n-t+1,e}var Li=Dr,bi=128,Dn=127;function Dr(r,t){var n=0,t=t||0,i=0,o=t,c,h=r.length;do{if(o>=h)throw Dr.bytes=0,new RangeError("Could not decode varint");c=r[o++],n+=i<28?(c&Dn)<<i:(c&Dn)*Math.pow(2,i),i+=7}while(c>=bi);return Dr.bytes=o-t,n}var Ci=Math.pow(2,7),Oi=Math.pow(2,14),Ti=Math.pow(2,21),Ni=Math.pow(2,28),Pi=Math.pow(2,35),Bi=Math.pow(2,42),Di=Math.pow(2,49),Fi=Math.pow(2,56),Ri=Math.pow(2,63),_i=function(r){return r<Ci?1:r<Oi?2:r<Ti?3:r<Ni?4:r<Pi?5:r<Bi?6:r<Di?7:r<Fi?8:r<Ri?9:10},ki={encode:vi,decode:Li,encodingLength:_i},Mi=ki,Re=Mi;function _e(r,e=0){return[Re.decode(r,e),Re.decode.bytes]}function Oe(r,e,n=0){return Re.encode(r,e,n),e}function Te(r){return Re.encodingLength(r)}function Ee(r,e){let n=e.byteLength,t=Te(r),i=t+Te(n),o=new Uint8Array(i+n);return Oe(r,o,0),Oe(n,o,t),o.set(e,i),new Ne(r,n,e,o)}function ve(r){let e=$(r),[n,t]=_e(e),[i,o]=_e(e.subarray(t)),c=e.subarray(t+o);if(c.byteLength!==i)throw new Error("Incorrect length");return new Ne(n,i,c,e)}function Rn(r,e){if(r===e)return!0;{let n=e;return r.code===n.code&&r.size===n.size&&n.bytes instanceof Uint8Array&&Ln(r.bytes,n.bytes)}}var Ne=class{code;size;digest;bytes;constructor(e,n,t,i){this.code=e,this.size=n,this.digest=t,this.bytes=i}};var _n=0,zi="identity",kn=$;function qi(r){return Ee(_n,kn(r))}var Je={code:_n,name:zi,encode:kn,digest:qi};var Mr={};k(Mr,{sha256:()=>Ze,sha512:()=>$i});var kr=ir(Le("crypto"),1);function _r({name:r,code:e,encode:n}){return new Rr(r,e,n)}var Rr=class{name;code;encode;constructor(e,n,t){this.name=e,this.code=n,this.encode=t}digest(e){if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?Ee(this.code,n):n.then(t=>Ee(this.code,t))}else throw Error("Unknown type, must be binary type")}};var Ze=_r({name:"sha2-256",code:18,encode:r=>$(kr.default.createHash("sha256").update(r).digest())}),$i=_r({name:"sha2-512",code:19,encode:r=>$(kr.default.createHash("sha512").update(r).digest())});function zn(r,e){let{bytes:n,version:t}=r;switch(t){case 0:return Ki(n,zr(r),e??P.encoder);default:return Hi(n,zr(r),e??ge.encoder)}}var qn=new WeakMap;function zr(r){let e=qn.get(r);if(e==null){let n=new Map;return qn.set(r,n),n}return e}var Y=class r{code;version;multihash;bytes;"/";constructor(e,n,t,i){this.code=n,this.version=e,this.multihash=t,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:n}=this;if(e!==ke)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(n.code!==ji)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(n)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:n}=this.multihash,t=Ee(e,n);return r.createV1(this.code,t)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,n){let t=n;return t!=null&&e.code===t.code&&e.version===t.version&&Rn(e.multihash,t.multihash)}toString(e){return zn(this,e)}toJSON(){return{"/":zn(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let n=e;if(n instanceof r)return n;if(n["/"]!=null&&n["/"]===n.bytes||n.asCID===n){let{version:t,code:i,multihash:o,bytes:c}=n;return new r(t,i,o,c??$n(t,i,o.bytes))}else if(n[Xi]===!0){let{version:t,multihash:i,code:o}=n,c=ve(i);return r.create(t,o,c)}else return null}static create(e,n,t){if(typeof n!="number")throw new Error("String codecs are no longer supported");if(!(t.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(n!==ke)throw new Error(`Version 0 CID must use dag-pb (code: ${ke}) block encoding`);return new r(e,n,t,t.bytes)}case 1:{let i=$n(e,n,t.bytes);return new r(e,n,t,i)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,ke,e)}static createV1(e,n){return r.create(1,e,n)}static decode(e){let[n,t]=r.decodeFirst(e);if(t.length!==0)throw new Error("Incorrect length");return n}static decodeFirst(e){let n=r.inspectBytes(e),t=n.size-n.multihashSize,i=$(e.subarray(t,t+n.multihashSize));if(i.byteLength!==n.multihashSize)throw new Error("Incorrect length");let o=i.subarray(n.multihashSize-n.digestSize),c=new Ne(n.multihashCode,n.digestSize,o,i);return[n.version===0?r.createV0(c):r.createV1(n.codec,c),e.subarray(n.size)]}static inspectBytes(e){let n=0,t=()=>{let[l,u]=_e(e.subarray(n));return n+=u,l},i=t(),o=ke;if(i===18?(i=0,n=0):o=t(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let c=n,h=t(),a=t(),d=n+a,m=d-c;return{version:i,codec:o,multihashCode:h,digestSize:a,multihashSize:m,size:d}}static parse(e,n){let[t,i]=Vi(e,n),o=r.decode(i);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return zr(o).set(t,e),o}};function Vi(r,e){switch(r[0]){case"Q":{let n=e??P;return[P.prefix,n.decode(`${P.prefix}${r}`)]}case P.prefix:{let n=e??P;return[P.prefix,n.decode(r)]}case ge.prefix:{let n=e??ge;return[ge.prefix,n.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Ki(r,e,n){let{prefix:t}=n;if(t!==P.prefix)throw Error(`Cannot string encode V0 in ${n.name} encoding`);let i=e.get(t);if(i==null){let o=n.encode(r).slice(1);return e.set(t,o),o}else return i}function Hi(r,e,n){let{prefix:t}=n,i=e.get(t);if(i==null){let o=n.encode(r);return e.set(t,o),o}else return i}var ke=112,ji=18;function $n(r,e,n){let t=Te(r),i=t+Te(e),o=new Uint8Array(i+n.byteLength);return Oe(r,o,0),Oe(e,o,t),o.set(n,i),o}var Xi=Symbol.for("@ipld/js-cid/CID");var Ie={...Br,...br,...Pr,...Sr,...Lr,...Or,...Tr,...Ur,...Nr,...Cr},Pc={...Mr,...Fr};function Me(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let n=0;n<r.byteLength;n++)if(r[n]!==e[n])return!1;return!0}var Yi=Symbol.for("nodejs.util.inspect.custom"),Vn=Object.values(Ie).map(r=>r.decoder).reduce((r,e)=>r.or(e),Ie.identity.decoder),Kn=114,Hn=36,jn=37,ze=class{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[sn]=!0;toString(){return this.string==null&&(this.string=P.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Y.createV1(Kn,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return Me(this.multihash.bytes,e);if(typeof e=="string")return qr(e).equals(this);if(e?.multihash?.bytes!=null)return Me(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[Yi](){return`PeerId(${this.toString()})`}},qe=class extends ze{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},$e=class extends ze{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Ve=class extends ze{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function qr(r,e){if(e=e??Vn,r.charAt(0)==="1"||r.charAt(0)==="Q"){let n=ve(P.decode(`z${r}`));return r.startsWith("12D")?new $e({multihash:n}):r.startsWith("16U")?new Ve({multihash:n}):new qe({multihash:n})}return Gi(Vn.decode(r))}function Gi(r){try{let e=ve(r);if(e.code===Je.code){if(e.digest.length===Hn)return new $e({multihash:e});if(e.digest.length===jn)return new Ve({multihash:e})}if(e.code===Ze.code)return new qe({multihash:e})}catch{return Qi(Y.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Qi(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Kn)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===Ze.code)return new qe({multihash:r.multihash});if(e.code===Je.code){if(e.digest.length===Hn)return new $e({multihash:r.multihash});if(e.digest.length===jn)return new Ve({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var V=Le("node:net");function fe(r){return!!(0,V.isIP)(r)}var Yn=ir(Xn(),1),Wi=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],Ji=Wi.map(r=>new Yn.Netmask(r));function Zi(r){for(let e of Ji)if(e.contains(r))return!0;return!1}function fi(r){return/^::$/.test(r)||/^::1$/.test(r)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function Gn(r){return(0,V.isIPv4)(r)?Zi(r):(0,V.isIPv6)(r)?fi(r):void 0}function Qn(r){try{let{address:e}=r.nodeAddress();return!!Gn(e)}catch{return!0}}function Ue(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Pe(r=0){return globalThis.Buffer?.allocUnsafe!=null?Ue(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Jn(r,e,n,t){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:n},decoder:{decode:t}}}var Wn=Jn("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),$r=Jn("ascii","a",r=>{let e="a";for(let n=0;n<r.length;n++)e+=String.fromCharCode(r[n]);return e},r=>{r=r.substring(1);let e=Pe(r.length);for(let n=0;n<r.length;n++)e[n]=r.charCodeAt(n);return e}),eo={utf8:Wn,"utf-8":Wn,hex:Ie.base16,latin1:$r,ascii:$r,binary:$r,...Ie},er=eo;function _(r,e="utf8"){let n=er[e];if(n==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):n.encoder.encode(r).substring(1)}var ro=Math.pow(2,7),no=Math.pow(2,14),to=Math.pow(2,21),Vr=Math.pow(2,28),Kr=Math.pow(2,35),Hr=Math.pow(2,42),jr=Math.pow(2,49),x=128,D=127;function ne(r){if(r<ro)return 1;if(r<no)return 2;if(r<to)return 3;if(r<Vr)return 4;if(r<Kr)return 5;if(r<Hr)return 6;if(r<jr)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function io(r,e,n=0){switch(ne(r)){case 8:e[n++]=r&255|x,r/=128;case 7:e[n++]=r&255|x,r/=128;case 6:e[n++]=r&255|x,r/=128;case 5:e[n++]=r&255|x,r/=128;case 4:e[n++]=r&255|x,r>>>=7;case 3:e[n++]=r&255|x,r>>>=7;case 2:e[n++]=r&255|x,r>>>=7;case 1:{e[n++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function oo(r,e,n=0){switch(ne(r)){case 8:e.set(n++,r&255|x),r/=128;case 7:e.set(n++,r&255|x),r/=128;case 6:e.set(n++,r&255|x),r/=128;case 5:e.set(n++,r&255|x),r/=128;case 4:e.set(n++,r&255|x),r>>>=7;case 3:e.set(n++,r&255|x),r>>>=7;case 2:e.set(n++,r&255|x),r>>>=7;case 1:{e.set(n++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function co(r,e){let n=r[e],t=0;if(t+=n&D,n<x||(n=r[e+1],t+=(n&D)<<7,n<x)||(n=r[e+2],t+=(n&D)<<14,n<x)||(n=r[e+3],t+=(n&D)<<21,n<x)||(n=r[e+4],t+=(n&D)*Vr,n<x)||(n=r[e+5],t+=(n&D)*Kr,n<x)||(n=r[e+6],t+=(n&D)*Hr,n<x)||(n=r[e+7],t+=(n&D)*jr,n<x))return t;throw new RangeError("Could not decode varint")}function so(r,e){let n=r.get(e),t=0;if(t+=n&D,n<x||(n=r.get(e+1),t+=(n&D)<<7,n<x)||(n=r.get(e+2),t+=(n&D)<<14,n<x)||(n=r.get(e+3),t+=(n&D)<<21,n<x)||(n=r.get(e+4),t+=(n&D)*Vr,n<x)||(n=r.get(e+5),t+=(n&D)*Kr,n<x)||(n=r.get(e+6),t+=(n&D)*Hr,n<x)||(n=r.get(e+7),t+=(n&D)*jr,n<x))return t;throw new RangeError("Could not decode varint")}function Be(r,e,n=0){return e==null&&(e=Pe(ne(r))),e instanceof Uint8Array?io(r,e,n):oo(r,e,n)}function Se(r,e=0){return r instanceof Uint8Array?co(r,e):so(r,e)}function me(r,e){if(globalThis.Buffer!=null)return Ue(globalThis.Buffer.concat(r,e));e==null&&(e=r.reduce((i,o)=>i+o.length,0));let n=Pe(e),t=0;for(let i of r)n.set(i,t),t+=i.length;return Ue(n)}var rr=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let n=this.index,t=e();return t===void 0&&(this.index=n),t}parseWith(e){let n=e();if(this.index===this.input.length)return n}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let n=this.readChar();if(n===e)return n})}readSeparator(e,n,t){return this.readAtomically(()=>{if(!(n>0&&this.readGivenChar(e)===void 0))return t()})}readNumber(e,n,t,i){return this.readAtomically(()=>{let o=0,c=0,h=this.peekChar();if(h===void 0)return;let a=h==="0",d=2**(8*i)-1;for(;;){let m=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let u=Number.parseInt(l,e);if(!Number.isNaN(u))return u});if(m===void 0)break;if(o*=e,o+=m,o>d||(c+=1,n!==void 0&&c>n))return}if(c!==0)return!t&&a&&c>1?void 0:o})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let n=0;n<e.length;n++){let t=this.readSeparator(".",n,()=>this.readNumber(10,3,!1,1));if(t===void 0)return;e[n]=t}return e})}readIPv6Addr(){let e=n=>{for(let t=0;t<n.length/2;t++){let i=t*2;if(t<n.length-3){let c=this.readSeparator(":",t,()=>this.readIPv4Addr());if(c!==void 0)return n[i]=c[0],n[i+1]=c[1],n[i+2]=c[2],n[i+3]=c[3],[i+4,!0]}let o=this.readSeparator(":",t,()=>this.readNumber(16,4,!0,2));if(o===void 0)return[i,!1];n[i]=o>>8,n[i+1]=o&255}return[n.length,!1]};return this.readAtomically(()=>{let n=new Uint8Array(16),[t,i]=e(n);if(t===16)return n;if(i||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),c=16-(t+2),[h]=e(o.subarray(0,c));return n.set(o.subarray(0,h),16-h),n})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var as=new rr;var ys=parseInt("0xFFFF",16),ws=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Xr(r,e="utf8"){let n=er[e];if(n==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Ue(globalThis.Buffer.from(r,"utf-8")):n.decoder.decode(`${n.prefix}${r}`)}var rt=V.isIPv4,go=V.isIPv6,Yr=function(r){let e=0;if(r=r.toString().trim(),rt(r)){let n=new Uint8Array(e+4);return r.split(/\./g).forEach(t=>{n[e++]=parseInt(t,10)&255}),n}if(go(r)){let n=r.split(":",8),t;for(t=0;t<n.length;t++){let o=rt(n[t]),c;o&&(c=Yr(n[t]),n[t]=_(c.slice(0,2),"base16")),c!=null&&++t<8&&n.splice(t,0,_(c.slice(2,4),"base16"))}if(n[0]==="")for(;n.length<8;)n.unshift("0");else if(n[n.length-1]==="")for(;n.length<8;)n.push("0");else if(n.length<8){for(t=0;t<n.length&&n[t]!=="";t++);let o=[t,1];for(t=9-n.length;t>0;t--)o.push("0");n.splice.apply(n,o)}let i=new Uint8Array(e+16);for(t=0;t<n.length;t++){let o=parseInt(n[t],16);i[e++]=o>>8&255,i[e++]=o&255}return i}throw new Error("invalid ip address")},nt=function(r,e=0,n){e=~~e,n=n??r.length-e;let t=new DataView(r.buffer);if(n===4){let i=[];for(let o=0;o<n;o++)i.push(r[e+o]);return i.join(".")}if(n===16){let i=[];for(let o=0;o<n;o+=2)i.push(t.getUint16(e+o).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var De={},Gr={},yo=[[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"]];yo.forEach(r=>{let e=wo(...r);Gr[e.code]=e,De[e.name]=e});function wo(r,e,n,t,i){return{code:r,size:e,name:n,resolvable:!!t,path:!!i}}function A(r){if(typeof r=="number"){if(Gr[r]!=null)return Gr[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(De[r]!=null)return De[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var ta=A("ip4"),ia=A("ip6"),oa=A("ipcidr");function Wr(r,e){switch(A(r).code){case 4:case 41:return Io(e);case 42:return ot(e);case 6:case 273:case 33:case 132:return st(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ot(e);case 421:return Uo(e);case 444:return ct(e);case 445:return ct(e);case 466:return Ao(e);default:return _(e,"base16")}}function Jr(r,e){switch(A(r).code){case 4:return tt(e);case 41:return tt(e);case 42:return it(e);case 6:case 273:case 33:case 132:return Zr(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return it(e);case 421:return xo(e);case 444:return So(e);case 445:return Lo(e);case 466:return vo(e);default:return Xr(e,"base16")}}var Qr=Object.values(Ie).map(r=>r.decoder),Eo=function(){let r=Qr[0].or(Qr[1]);return Qr.slice(2).forEach(e=>r=r.or(e)),r}();function tt(r){if(!fe(r))throw new Error("invalid ip address");return Yr(r)}function Io(r){let e=nt(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!fe(e))throw new Error("invalid ip address");return e}function Zr(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function st(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function it(r){let e=Xr(r),n=Uint8Array.from(Be(e.length));return me([n,e],n.length+e.length)}function ot(r){let e=Se(r);if(r=r.slice(ne(e)),r.length!==e)throw new Error("inconsistent lengths");return _(r)}function xo(r){let e;r[0]==="Q"||r[0]==="1"?e=ve(P.decode(`z${r}`)).bytes:e=Y.parse(r).multihash.bytes;let n=Uint8Array.from(Be(e.length));return me([n,e],n.length+e.length)}function vo(r){let e=Eo.decode(r),n=Uint8Array.from(Be(e.length));return me([n,e],n.length+e.length)}function Ao(r){let e=Se(r),n=r.slice(ne(e));if(n.length!==e)throw new Error("inconsistent lengths");return"u"+_(n,"base64url")}function Uo(r){let e=Se(r),n=r.slice(ne(e));if(n.length!==e)throw new Error("inconsistent lengths");return _(n,"base58btc")}function So(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let n=ge.decode("b"+e[0]),t=parseInt(e[1],10);if(t<1||t>65536)throw new Error("Port number is not in range(1, 65536)");let i=Zr(t);return me([n,i],n.length+i.length)}function Lo(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let n=ge.decode(`b${e[0]}`),t=parseInt(e[1],10);if(t<1||t>65536)throw new Error("Port number is not in range(1, 65536)");let i=Zr(t);return me([n,i],n.length+i.length)}function ct(r){let e=r.slice(0,r.length-2),n=r.slice(r.length-2),t=_(e,"base32"),i=st(n);return`${t}:${i}`}function at(r){r=fr(r);let e=[],n=[],t=null,i=r.split("/").slice(1);if(i.length===1&&i[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<i.length;o++){let c=i[o],h=A(c);if(h.size===0){e.push([h.code]),n.push([h.code]);continue}if(o++,o>=i.length)throw lt("invalid address: "+r);if(h.path===!0){t=fr(i.slice(o).join("/")),e.push([h.code,Jr(h.code,t)]),n.push([h.code,t]);break}let a=Jr(h.code,i[o]);e.push([h.code,a]),n.push([h.code,Wr(h.code,a)])}return{string:dt(n),bytes:rn(e),tuples:e,stringTuples:n,path:t}}function en(r){let e=[],n=[],t=null,i=0;for(;i<r.length;){let o=Se(r,i),c=ne(o),h=A(o),a=bo(h,r.slice(i+c));if(a===0){e.push([o]),n.push([o]),i+=c;continue}let d=r.slice(i+c,i+c+a);if(i+=a+c,i>r.length)throw lt("Invalid address Uint8Array: "+_(r,"base16"));e.push([o,d]);let m=Wr(o,d);if(n.push([o,m]),h.path===!0){t=m;break}}return{bytes:Uint8Array.from(r),string:dt(n),tuples:e,stringTuples:n,path:t}}function dt(r){let e=[];return r.map(n=>{let t=A(n[0]);return e.push(t.name),n.length>1&&n[1]!=null&&e.push(n[1]),null}),fr(e.join("/"))}function rn(r){return me(r.map(e=>{let n=A(e[0]),t=Uint8Array.from(Be(n.code));return e.length>1&&e[1]!=null&&(t=me([t,e[1]])),t}))}function bo(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let n=Se(e instanceof Uint8Array?e:Uint8Array.from(e));return n+ne(n)}}function fr(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function lt(r){return new Error("Error parsing address: "+r)}var Co=Symbol.for("nodejs.util.inspect.custom"),nn=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Oo=[A("dns").code,A("dns4").code,A("dns6").code,A("dnsaddr").code],nr=class r{bytes;#e;#r;#n;#t;[nn]=!0;constructor(e){e==null&&(e="");let n;if(e instanceof Uint8Array)n=en(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);n=at(e)}else if(ht(e))n=en(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=n.bytes,this.#e=n.string,this.#r=n.tuples,this.#n=n.stringTuples,this.#t=n.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,n,t,i,o="",c=A("tcp"),h=A("udp"),a=A("ip4"),d=A("ip6"),m=A("dns6"),l=A("ip6zone");for(let[p,s]of this.stringTuples())p===l.code&&(o=`%${s??""}`),Oo.includes(p)&&(n=c.name,i=443,t=`${s??""}${o}`,e=p===m.code?6:4),(p===c.code||p===h.code)&&(n=A(p).name,i=parseInt(s??"")),(p===a.code||p===d.code)&&(n=A(p).name,t=`${s??""}${o}`,e=p===d.code?6:4);if(e==null||n==null||t==null||i==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:t,transport:n,port:i}}protos(){return this.#r.map(([e])=>Object.assign({},A(e)))}protoCodes(){return this.#r.map(([e])=>e)}protoNames(){return this.#r.map(([e])=>A(e).name)}tuples(){return this.#r}stringTuples(){return this.#n}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let n=e.toString(),t=this.toString(),i=t.lastIndexOf(n);if(i<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(t.slice(0,i))}decapsulateCode(e){let n=this.tuples();for(let t=n.length-1;t>=0;t--)if(n[t][0]===e)return new r(rn(n.slice(0,t)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([t,i])=>{t===De.p2p.code&&e.push([t,i]),t===De["p2p-circuit"].code&&(e=[])});let n=e.pop();if(n?.[1]!=null){let t=n[1];return t[0]==="Q"||t[0]==="1"?_(P.decode(`z${t}`),"base58btc"):_(Y.parse(t).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#t}equals(e){return Me(this.bytes,e.bytes)}async resolve(e){let n=this.protos().find(o=>o.resolvable);if(n==null)return[this];let t=ut.get(n.name);if(t==null)throw new Xe(`no available resolver for ${n.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await t(this,e)).map(o=>new r(o))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let n=(e??this).protos();return!(n.length!==2||n[0].code!==4&&n[0].code!==41||n[1].code!==6&&n[1].code!==273)}[Co](){return`Multiaddr(${this.#e})`}};var ut=new Map;function ht(r){return!!r?.[nn]}function tn(r){return new nr(r)}function pt(r,e,n,t){let i=()=>{t?.log.trace("query",e),r.query({questions:[{name:e,type:"PTR"}]})};return i(),setInterval(i,n)}function gt(r,e,n,t){if(r.answers==null)return;let i,o=[];if(r.answers.forEach(c=>{switch(c.type){case"PTR":i=c;break;case"TXT":o.push(c);break;default:break}}),r.additionals.forEach(c=>{switch(c.type){case"TXT":o.push(c);break;default:break}}),!(i==null||i?.name!==n||o.length===0||i.data.startsWith(e)))try{let c=o.flatMap(a=>a.data).filter(a=>a.toString().startsWith("dnsaddr=")).map(a=>tn(a.toString().substring(8))),h=c[0].getPeerId();if(h==null)throw new Error("Multiaddr doesn't contain PeerId");return t?.log("peer found %p",h),{id:qr(h),multiaddrs:c.map(a=>a.decapsulateCode(A("p2p").code))}}catch(c){t?.log.error("failed to parse mdns response",c)}}function mt(r,e,n,t,i,o,c){if(!o){c?.log("not responding to mDNS query as broadcast mode is false");return}if(t.length!==0&&r.questions[0]!=null&&r.questions[0].name===i){let h=[];h.push({name:i,type:"PTR",class:"IN",ttl:120,data:n+"."+i}),t.filter(To).forEach(a=>{let d="dnsaddr="+a.toString();if(d.length>255){c?.log("multiaddr %a is too long to use in mDNS query response",a);return}if(a.getPeerId()==null){c?.log("multiaddr %a did not have a peer ID so cannot be used in mDNS query response",a);return}h.push({name:n+"."+i,type:"TXT",class:"IN",ttl:120,data:d})}),c?.log.trace("responding to query"),e.respond(h)}}function To(r){return!!Qn(r)}function yt(r){let e="",n="abcdefghijklmnopqrstuvwxyz0123456789";for(let t=0;t<r;t++)e+=n.charAt(Math.floor(Math.random()*n.length));return e}var tr=class extends Ye{mdns;log;broadcast;interval;serviceTag;peerName;port;ip;_queryInterval;components;constructor(e,n={}){if(super(),this.log=e.logger.forComponent("libp2p:mdns"),this.broadcast=n.broadcast!==!1,this.interval=n.interval??1e3*10,this.serviceTag=n.serviceTag??"_p2p._udp.local",this.ip=n.ip??"224.0.0.251",this.peerName=n.peerName??yt(63),this.peerName.length>=64)throw new Error("Peer name should be less than 64 chars long");this.port=n.port??5353,this.components=e,this._queryInterval=null,this._onMdnsQuery=this._onMdnsQuery.bind(this),this._onMdnsResponse=this._onMdnsResponse.bind(this),this._onMdnsWarning=this._onMdnsWarning.bind(this),this._onMdnsError=this._onMdnsError.bind(this)}[cn]=this;[Symbol.toStringTag]="@libp2p/mdns";isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,wt.default)({port:this.port,ip:this.ip}),this.mdns.on("query",this._onMdnsQuery),this.mdns.on("response",this._onMdnsResponse),this.mdns.on("warning",this._onMdnsWarning),this.mdns.on("error",this._onMdnsError),this._queryInterval=pt(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),mt(e,this.mdns,this.peerName,this.components.addressManager.getAddresses(),this.serviceTag,this.broadcast,{log:this.log}))}_onMdnsResponse(e){this.log.trace("received mDNS query response");try{let n=gt(e,this.peerName,this.serviceTag,{log:this.log});n!=null&&(this.log("discovered peer in mDNS query response %p",n.id),this.dispatchEvent(new cr("peer",{detail:n})))}catch(n){this.log.error("Error processing peer response",n)}}_onMdnsWarning(e){this.log.error("mdns warning",e)}_onMdnsError(e){this.log.error("mdns error",e)}async stop(){this.mdns!=null&&(this.mdns.removeListener("query",this._onMdnsQuery),this.mdns.removeListener("response",this._onMdnsResponse),this.mdns.removeListener("warning",this._onMdnsWarning),this.mdns.removeListener("error",this._onMdnsError),this._queryInterval!=null&&(clearInterval(this._queryInterval),this._queryInterval=null),await new Promise(e=>{this.mdns!=null?this.mdns.destroy(e):e()}),this.mdns=void 0)}};function Po(r={}){return e=>new tr(e,r)}return Ut(Bo);})();
2
+ "use strict";var Libp2PMdns=(()=>{var xt=Object.create;var je=Object.defineProperty;var vt=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var Ut=Object.getPrototypeOf,St=Object.prototype.hasOwnProperty;var xe=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var G=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),k=(r,e)=>{for(var n in e)je(r,n,{get:e[n],enumerable:!0})},on=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of At(e))!St.call(r,i)&&i!==n&&je(r,i,{get:()=>e[i],enumerable:!(t=vt(e,i))||t.enumerable});return r};var ir=(r,e,n)=>(n=r!=null?xt(Ut(r)):{},on(e||!r||!r.__esModule?je(n,"default",{value:r,enumerable:!0}):n,r)),Lt=r=>on(je({},"__esModule",{value:!0}),r);var ln=G(sr=>{"use strict";sr.toString=function(r){switch(r){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+r};sr.toType=function(r){switch(r.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":return 255;case"*":return 255}return r.toUpperCase().startsWith("UNKNOWN_")?parseInt(r.slice(8)):0}});var un=G(ar=>{"use strict";ar.toString=function(r){switch(r){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+r};ar.toRcode=function(r){switch(r.toUpperCase()){case"NOERROR":return 0;case"FORMERR":return 1;case"SERVFAIL":return 2;case"NXDOMAIN":return 3;case"NOTIMP":return 4;case"REFUSED":return 5;case"YXDOMAIN":return 6;case"YXRRSET":return 7;case"NXRRSET":return 8;case"NOTAUTH":return 9;case"NOTZONE":return 10;case"RCODE_11":return 11;case"RCODE_12":return 12;case"RCODE_13":return 13;case"RCODE_14":return 14;case"RCODE_15":return 15}return 0}});var hn=G(dr=>{"use strict";dr.toString=function(r){switch(r){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+r};dr.toOpcode=function(r){switch(r.toUpperCase()){case"QUERY":return 0;case"IQUERY":return 1;case"STATUS":return 2;case"OPCODE_3":return 3;case"NOTIFY":return 4;case"UPDATE":return 5;case"OPCODE_6":return 6;case"OPCODE_7":return 7;case"OPCODE_8":return 8;case"OPCODE_9":return 9;case"OPCODE_10":return 10;case"OPCODE_11":return 11;case"OPCODE_12":return 12;case"OPCODE_13":return 13;case"OPCODE_14":return 14;case"OPCODE_15":return 15}return 0}});var pn=G(lr=>{"use strict";lr.toString=function(r){switch(r){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+r};lr.toClass=function(r){switch(r.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}});var gn=G(ur=>{"use strict";ur.toString=function(r){switch(r){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}return r<0?null:`OPTION_${r}`};ur.toCode=function(r){if(typeof r=="number")return r;if(!r)return-1;switch(r.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}let e=r.match(/_(\d+)$/);return e?parseInt(e[1],10):-1}});var wn=G((yn,hr)=>{var mn=function(r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.decode=l,r.encode=m,r.familyOf=d,r.name=void 0,r.sizeOf=a,r.v6=r.v4=void 0;let e=/^(\d{1,3}\.){3,3}\d{1,3}$/,n=4,t=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,i=16,o={name:"v4",size:n,isFormat:u=>e.test(u),encode(u,p,s){s=~~s,p=p||new Uint8Array(s+n);let y=u.length,v=0;for(let U=0;U<y;){let L=u.charCodeAt(U++);L===46?(p[s++]=v,v=0):v=v*10+(L-48)}return p[s]=v,p},decode(u,p){return p=~~p,`${u[p++]}.${u[p++]}.${u[p++]}.${u[p]}`}};r.v4=o;let c={name:"v6",size:i,isFormat:u=>u.length>0&&t.test(u),encode(u,p,s){s=~~s;let y=s+i,v=-1,U=0,L=0,B=!0,T=!1;p=p||new Uint8Array(s+i);for(let b=0;b<u.length;b++){let C=u.charCodeAt(b);C===58?(B?v!==-1?(s<y&&(p[s]=0),s<y-1&&(p[s+1]=0),s+=2):s<y&&(v=s):(T===!0?(s<y&&(p[s]=L),s++):(s<y&&(p[s]=U>>8),s<y-1&&(p[s+1]=U&255),s+=2),U=0,L=0),B=!0,T=!1):C===46?(s<y&&(p[s]=L),s++,L=0,U=0,B=!1,T=!0):(B=!1,C>=97?C-=87:C>=65?C-=55:(C-=48,L=L*10+C),U=(U<<4)+C)}if(B===!1)T===!0?(s<y&&(p[s]=L),s++):(s<y&&(p[s]=U>>8),s<y-1&&(p[s+1]=U&255),s+=2);else if(v===0)s<y&&(p[s]=0),s<y-1&&(p[s+1]=0),s+=2;else if(v!==-1){s+=2;for(let b=Math.min(s-1,y-1);b>=v+2;b--)p[b]=p[b-2];p[v]=0,p[v+1]=0,v=s}if(v!==s&&v!==-1)for(s>y-2&&(s=y-2);y>v;)p[--y]=s<y&&s>v?p[--s]:0;else for(;s<y;)p[s++]=0;return p},decode(u,p){p=~~p;let s="";for(let y=0;y<i;y+=2)y!==0&&(s+=":"),s+=(u[p+y]<<8|u[p+y+1]).toString(16);return s.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};r.v6=c;let h="ip";r.name=h;function a(u){if(o.isFormat(u))return o.size;if(c.isFormat(u))return c.size;throw Error(`Invalid ip address: ${u}`)}function d(u){return a(u)===o.size?1:2}function m(u,p,s){s=~~s;let y=a(u);return typeof p=="function"&&(p=p(s+y)),y===o.size?o.encode(u,p,s):c.encode(u,p,s)}function l(u,p,s){if(p=~~p,s=s||u.length-p,s===o.size)return o.decode(u,p,s);if(s===c.size)return c.decode(u,p,s);throw Error(`Invalid buffer size needs to be ${o.size} for v4 or ${c.size} for v6.`)}return"default"in r?r.default:r}({});typeof define=="function"&&define.amd?define([],function(){return mn}):typeof hr=="object"&&typeof yn=="object"&&(hr.exports=mn)});var xn=G(w=>{"use strict";var E=xe("buffer").Buffer,pe=ln(),bt=un(),Ct=hn(),Qe=pn(),pr=gn(),ve=wn(),Ot=0,En=32768,gr=32768,Tt=~gr,In=32768,Nt=~In,g=w.name={};g.encode=function(r,e,n,{mail:t=!1}={}){e||(e=E.alloc(g.encodingLength(r))),n||(n=0);let i=n,o=r.replace(/^\.|\.$/gm,"");if(o.length){let c=[];if(t){let h="";o.split(".").forEach(a=>{a.endsWith("\\")?h+=(h.length?".":"")+a.slice(0,-1):c.length===0&&h.length?c.push(h+"."+a):c.push(a)})}else c=o.split(".");for(let h=0;h<c.length;h++){let a=e.write(c[h],n+1);e[n]=a,n+=a+1}}return e[n++]=0,g.encode.bytes=n-i,e};g.encode.bytes=0;g.decode=function(r,e,{mail:n=!1}={}){e||(e=0);let t=[],i=e,o=0,c=0,h=!1;for(;;){if(e>=r.length)throw new Error("Cannot decode name (buffer overflow)");let a=r[e++];if(c+=h?0:1,a===0)break;if(a&192)if((a&192)===192){if(e+1>r.length)throw new Error("Cannot decode name (buffer overflow)");let d=r.readUInt16BE(e-1)-49152;if(d>=i)throw new Error("Cannot decode name (bad pointer)");e=d,i=d,c+=h?0:1,h=!0}else throw new Error("Cannot decode name (bad label)");else{if(e+a>r.length)throw new Error("Cannot decode name (buffer overflow)");if(o+=a+1,o>254)throw new Error("Cannot decode name (name too long)");let d=r.toString("utf-8",e,e+a);n&&(d=d.replace(/\./g,"\\.")),t.push(d),e+=a,c+=h?0:a}}return g.decode.bytes=c,t.length===0?".":t.join(".")};g.decode.bytes=0;g.encodingLength=function(r){return r==="."||r===".."?1:E.byteLength(r.replace(/^\.|\.$/gm,""))+2};var I={};I.encode=function(r,e,n){e||(e=E.alloc(I.encodingLength(r))),n||(n=0);let t=e.write(r,n+1);return e[n]=t,I.encode.bytes=t+1,e};I.encode.bytes=0;I.decode=function(r,e){e||(e=0);let n=r[e],t=r.toString("utf-8",e+1,e+1+n);return I.decode.bytes=n+1,t};I.decode.bytes=0;I.encodingLength=function(r){return E.byteLength(r)+1};var X={};X.encode=function(r,e,n){e||(e=X.encodingLength(r)),n||(n=0);let t=(r.flags||0)&32767,i=r.type==="response"?En:Ot;return e.writeUInt16BE(r.id||0,n),e.writeUInt16BE(t|i,n+2),e.writeUInt16BE(r.questions.length,n+4),e.writeUInt16BE(r.answers.length,n+6),e.writeUInt16BE(r.authorities.length,n+8),e.writeUInt16BE(r.additionals.length,n+10),e};X.encode.bytes=12;X.decode=function(r,e){if(e||(e=0),r.length<12)throw new Error("Header must be 12 bytes");let n=r.readUInt16BE(e+2);return{id:r.readUInt16BE(e),type:n&En?"response":"query",flags:n&32767,flag_qr:(n>>15&1)===1,opcode:Ct.toString(n>>11&15),flag_aa:(n>>10&1)===1,flag_tc:(n>>9&1)===1,flag_rd:(n>>8&1)===1,flag_ra:(n>>7&1)===1,flag_z:(n>>6&1)===1,flag_ad:(n>>5&1)===1,flag_cd:(n>>4&1)===1,rcode:bt.toString(n&15),questions:new Array(r.readUInt16BE(e+4)),answers:new Array(r.readUInt16BE(e+6)),authorities:new Array(r.readUInt16BE(e+8)),additionals:new Array(r.readUInt16BE(e+10))}};X.decode.bytes=12;X.encodingLength=function(){return 12};var ie=w.unknown={};ie.encode=function(r,e,n){return e||(e=E.alloc(ie.encodingLength(r))),n||(n=0),e.writeUInt16BE(r.length,n),r.copy(e,n+2),ie.encode.bytes=r.length+2,e};ie.encode.bytes=0;ie.decode=function(r,e){e||(e=0);let n=r.readUInt16BE(e),t=r.slice(e+2,e+2+n);return ie.decode.bytes=n+2,t};ie.decode.bytes=0;ie.encodingLength=function(r){return r.length+2};var oe=w.ns={};oe.encode=function(r,e,n){return e||(e=E.alloc(oe.encodingLength(r))),n||(n=0),g.encode(r,e,n+2),e.writeUInt16BE(g.encode.bytes,n),oe.encode.bytes=g.encode.bytes+2,e};oe.encode.bytes=0;oe.decode=function(r,e){e||(e=0);let n=r.readUInt16BE(e),t=g.decode(r,e+2);return oe.decode.bytes=n+2,t};oe.decode.bytes=0;oe.encodingLength=function(r){return g.encodingLength(r)+2};var ce=w.soa={};ce.encode=function(r,e,n){e||(e=E.alloc(ce.encodingLength(r))),n||(n=0);let t=n;return n+=2,g.encode(r.mname,e,n),n+=g.encode.bytes,g.encode(r.rname,e,n,{mail:!0}),n+=g.encode.bytes,e.writeUInt32BE(r.serial||0,n),n+=4,e.writeUInt32BE(r.refresh||0,n),n+=4,e.writeUInt32BE(r.retry||0,n),n+=4,e.writeUInt32BE(r.expire||0,n),n+=4,e.writeUInt32BE(r.minimum||0,n),n+=4,e.writeUInt16BE(n-t-2,t),ce.encode.bytes=n-t,e};ce.encode.bytes=0;ce.decode=function(r,e){e||(e=0);let n=e,t={};return e+=2,t.mname=g.decode(r,e),e+=g.decode.bytes,t.rname=g.decode(r,e,{mail:!0}),e+=g.decode.bytes,t.serial=r.readUInt32BE(e),e+=4,t.refresh=r.readUInt32BE(e),e+=4,t.retry=r.readUInt32BE(e),e+=4,t.expire=r.readUInt32BE(e),e+=4,t.minimum=r.readUInt32BE(e),e+=4,ce.decode.bytes=e-n,t};ce.decode.bytes=0;ce.encodingLength=function(r){return 22+g.encodingLength(r.mname)+g.encodingLength(r.rname)};var se=w.txt={};se.encode=function(r,e,n){Array.isArray(r)||(r=[r]);for(let i=0;i<r.length;i++)if(typeof r[i]=="string"&&(r[i]=E.from(r[i])),!E.isBuffer(r[i]))throw new Error("Must be a Buffer");e||(e=E.alloc(se.encodingLength(r))),n||(n=0);let t=n;return n+=2,r.forEach(function(i){e[n++]=i.length,i.copy(e,n,0,i.length),n+=i.length}),e.writeUInt16BE(n-t-2,t),se.encode.bytes=n-t,e};se.encode.bytes=0;se.decode=function(r,e){e||(e=0);let n=e,t=r.readUInt16BE(e);e+=2;let i=[];for(;t>0;){let o=r[e++];if(--t,t<o)throw new Error("Buffer overflow");i.push(r.slice(e,e+o)),e+=o,t-=o}return se.decode.bytes=e-n,i};se.decode.bytes=0;se.encodingLength=function(r){Array.isArray(r)||(r=[r]);let e=2;return r.forEach(function(n){typeof n=="string"?e+=E.byteLength(n)+1:e+=n.length+1}),e};var ae=w.null={};ae.encode=function(r,e,n){e||(e=E.alloc(ae.encodingLength(r))),n||(n=0),typeof r=="string"&&(r=E.from(r)),r||(r=E.alloc(0));let t=n;n+=2;let i=r.length;return r.copy(e,n,0,i),n+=i,e.writeUInt16BE(n-t-2,t),ae.encode.bytes=n-t,e};ae.encode.bytes=0;ae.decode=function(r,e){e||(e=0);let n=e,t=r.readUInt16BE(e);e+=2;let i=r.slice(e,e+t);return e+=t,ae.decode.bytes=e-n,i};ae.decode.bytes=0;ae.encodingLength=function(r){return r?(E.isBuffer(r)?r.length:E.byteLength(r))+2:2};var de=w.hinfo={};de.encode=function(r,e,n){e||(e=E.alloc(de.encodingLength(r))),n||(n=0);let t=n;return n+=2,I.encode(r.cpu,e,n),n+=I.encode.bytes,I.encode(r.os,e,n),n+=I.encode.bytes,e.writeUInt16BE(n-t-2,t),de.encode.bytes=n-t,e};de.encode.bytes=0;de.decode=function(r,e){e||(e=0);let n=e,t={};return e+=2,t.cpu=I.decode(r,e),e+=I.decode.bytes,t.os=I.decode(r,e),e+=I.decode.bytes,de.decode.bytes=e-n,t};de.decode.bytes=0;de.encodingLength=function(r){return I.encodingLength(r.cpu)+I.encodingLength(r.os)+2};var H=w.ptr={},Pt=w.cname=H,Bt=w.dname=H;H.encode=function(r,e,n){return e||(e=E.alloc(H.encodingLength(r))),n||(n=0),g.encode(r,e,n+2),e.writeUInt16BE(g.encode.bytes,n),H.encode.bytes=g.encode.bytes+2,e};H.encode.bytes=0;H.decode=function(r,e){e||(e=0);let n=g.decode(r,e+2);return H.decode.bytes=g.decode.bytes+2,n};H.decode.bytes=0;H.encodingLength=function(r){return g.encodingLength(r)+2};var le=w.srv={};le.encode=function(r,e,n){e||(e=E.alloc(le.encodingLength(r))),n||(n=0),e.writeUInt16BE(r.priority||0,n+2),e.writeUInt16BE(r.weight||0,n+4),e.writeUInt16BE(r.port||0,n+6),g.encode(r.target,e,n+8);let t=g.encode.bytes+6;return e.writeUInt16BE(t,n),le.encode.bytes=t+2,e};le.encode.bytes=0;le.decode=function(r,e){e||(e=0);let n=r.readUInt16BE(e),t={};return t.priority=r.readUInt16BE(e+2),t.weight=r.readUInt16BE(e+4),t.port=r.readUInt16BE(e+6),t.target=g.decode(r,e+8),le.decode.bytes=n+2,t};le.decode.bytes=0;le.encodingLength=function(r){return 8+g.encodingLength(r.target)};var M=w.caa={};M.ISSUER_CRITICAL=128;M.encode=function(r,e,n){let t=M.encodingLength(r);return e||(e=E.alloc(M.encodingLength(r))),n||(n=0),r.issuerCritical&&(r.flags=M.ISSUER_CRITICAL),e.writeUInt16BE(t-2,n),n+=2,e.writeUInt8(r.flags||0,n),n+=1,I.encode(r.tag,e,n),n+=I.encode.bytes,e.write(r.value,n),n+=E.byteLength(r.value),M.encode.bytes=t,e};M.encode.bytes=0;M.decode=function(r,e){e||(e=0);let n=r.readUInt16BE(e);e+=2;let t=e,i={};return i.flags=r.readUInt8(e),e+=1,i.tag=I.decode(r,e),e+=I.decode.bytes,i.value=r.toString("utf-8",e,t+n),i.issuerCritical=!!(i.flags&M.ISSUER_CRITICAL),M.decode.bytes=n+2,i};M.decode.bytes=0;M.encodingLength=function(r){return I.encodingLength(r.tag)+I.encodingLength(r.value)+2};var ye=w.mx={};ye.encode=function(r,e,n){e||(e=E.alloc(ye.encodingLength(r))),n||(n=0);let t=n;return n+=2,e.writeUInt16BE(r.preference||0,n),n+=2,g.encode(r.exchange,e,n),n+=g.encode.bytes,e.writeUInt16BE(n-t-2,t),ye.encode.bytes=n-t,e};ye.encode.bytes=0;ye.decode=function(r,e){e||(e=0);let n=e,t={};return e+=2,t.preference=r.readUInt16BE(e),e+=2,t.exchange=g.decode(r,e),e+=g.decode.bytes,ye.decode.bytes=e-n,t};ye.encodingLength=function(r){return 4+g.encodingLength(r.exchange)};var ue=w.a={};ue.encode=function(r,e,n){return e||(e=E.alloc(ue.encodingLength(r))),n||(n=0),e.writeUInt16BE(4,n),n+=2,ve.v4.encode(r,e,n),ue.encode.bytes=6,e};ue.encode.bytes=0;ue.decode=function(r,e){e||(e=0),e+=2;let n=ve.v4.decode(r,e);return ue.decode.bytes=6,n};ue.decode.bytes=0;ue.encodingLength=function(){return 6};var he=w.aaaa={};he.encode=function(r,e,n){return e||(e=E.alloc(he.encodingLength(r))),n||(n=0),e.writeUInt16BE(16,n),n+=2,ve.v6.encode(r,e,n),he.encode.bytes=18,e};he.encode.bytes=0;he.decode=function(r,e){e||(e=0),e+=2;let n=ve.v6.decode(r,e);return he.decode.bytes=18,n};he.decode.bytes=0;he.encodingLength=function(){return 18};var R=w.option={};R.encode=function(r,e,n){e||(e=E.alloc(R.encodingLength(r))),n||(n=0);let t=n,i=pr.toCode(r.code);if(e.writeUInt16BE(i,n),n+=2,r.data)e.writeUInt16BE(r.data.length,n),n+=2,r.data.copy(e,n),n+=r.data.length;else switch(i){case 8:let o=r.sourcePrefixLength||0,c=r.family||ve.familyOf(r.ip),h=ve.encode(r.ip,E.alloc),a=Math.ceil(o/8);e.writeUInt16BE(a+4,n),n+=2,e.writeUInt16BE(c,n),n+=2,e.writeUInt8(o,n++),e.writeUInt8(r.scopePrefixLength||0,n++),h.copy(e,n,0,a),n+=a;break;case 11:r.timeout?(e.writeUInt16BE(2,n),n+=2,e.writeUInt16BE(r.timeout,n),n+=2):(e.writeUInt16BE(0,n),n+=2);break;case 12:let d=r.length||0;e.writeUInt16BE(d,n),n+=2,e.fill(0,n,n+d),n+=d;break;case 14:let m=r.tags.length*2;e.writeUInt16BE(m,n),n+=2;for(let l of r.tags)e.writeUInt16BE(l,n),n+=2;break;default:throw new Error(`Unknown roption code: ${r.code}`)}return R.encode.bytes=n-t,e};R.encode.bytes=0;R.decode=function(r,e){e||(e=0);let n={};n.code=r.readUInt16BE(e),n.type=pr.toString(n.code),e+=2;let t=r.readUInt16BE(e);switch(e+=2,n.data=r.slice(e,e+t),n.code){case 8:n.family=r.readUInt16BE(e),e+=2,n.sourcePrefixLength=r.readUInt8(e++),n.scopePrefixLength=r.readUInt8(e++);let i=E.alloc(n.family===1?4:16);r.copy(i,0,e,e+t-4),n.ip=ve.decode(i);break;case 11:t>0&&(n.timeout=r.readUInt16BE(e),e+=2);break;case 14:n.tags=[];for(let o=0;o<t;o+=2)n.tags.push(r.readUInt16BE(e)),e+=2}return R.decode.bytes=t+4,n};R.decode.bytes=0;R.encodingLength=function(r){if(r.data)return r.data.length+4;switch(pr.toCode(r.code)){case 8:let n=r.sourcePrefixLength||0;return Math.ceil(n/8)+8;case 11:return typeof r.timeout=="number"?6:4;case 12:return r.length+4;case 14:return 4+r.tags.length*2}throw new Error(`Unknown roption code: ${r.code}`)};var q=w.opt={};q.encode=function(r,e,n){e||(e=E.alloc(q.encodingLength(r))),n||(n=0);let t=n,i=be(r,R);return e.writeUInt16BE(i,n),n=Fe(r,R,e,n+2),q.encode.bytes=n-t,e};q.encode.bytes=0;q.decode=function(r,e){e||(e=0);let n=e,t=[],i=r.readUInt16BE(e);e+=2;let o=0;for(;i>0;)t[o++]=R.decode(r,e),e+=R.decode.bytes,i-=R.decode.bytes;return q.decode.bytes=e-n,t};q.decode.bytes=0;q.encodingLength=function(r){return 2+be(r||[],R)};var F=w.dnskey={};F.PROTOCOL_DNSSEC=3;F.ZONE_KEY=128;F.SECURE_ENTRYPOINT=32768;F.encode=function(r,e,n){e||(e=E.alloc(F.encodingLength(r))),n||(n=0);let t=n,i=r.key;if(!E.isBuffer(i))throw new Error("Key must be a Buffer");return n+=2,e.writeUInt16BE(r.flags,n),n+=2,e.writeUInt8(F.PROTOCOL_DNSSEC,n),n+=1,e.writeUInt8(r.algorithm,n),n+=1,i.copy(e,n,0,i.length),n+=i.length,F.encode.bytes=n-t,e.writeUInt16BE(F.encode.bytes-2,t),e};F.encode.bytes=0;F.decode=function(r,e){e||(e=0);let n=e;var t={},i=r.readUInt16BE(e);if(e+=2,t.flags=r.readUInt16BE(e),e+=2,r.readUInt8(e)!==F.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,t.algorithm=r.readUInt8(e),e+=1,t.key=r.slice(e,n+i+2),e+=t.key.length,F.decode.bytes=e-n,t};F.decode.bytes=0;F.encodingLength=function(r){return 6+E.byteLength(r.key)};var Q=w.rrsig={};Q.encode=function(r,e,n){e||(e=E.alloc(Q.encodingLength(r))),n||(n=0);let t=n,i=r.signature;if(!E.isBuffer(i))throw new Error("Signature must be a Buffer");return n+=2,e.writeUInt16BE(pe.toType(r.typeCovered),n),n+=2,e.writeUInt8(r.algorithm,n),n+=1,e.writeUInt8(r.labels,n),n+=1,e.writeUInt32BE(r.originalTTL,n),n+=4,e.writeUInt32BE(r.expiration,n),n+=4,e.writeUInt32BE(r.inception,n),n+=4,e.writeUInt16BE(r.keyTag,n),n+=2,g.encode(r.signersName,e,n),n+=g.encode.bytes,i.copy(e,n,0,i.length),n+=i.length,Q.encode.bytes=n-t,e.writeUInt16BE(Q.encode.bytes-2,t),e};Q.encode.bytes=0;Q.decode=function(r,e){e||(e=0);let n=e;var t={},i=r.readUInt16BE(e);return e+=2,t.typeCovered=pe.toString(r.readUInt16BE(e)),e+=2,t.algorithm=r.readUInt8(e),e+=1,t.labels=r.readUInt8(e),e+=1,t.originalTTL=r.readUInt32BE(e),e+=4,t.expiration=r.readUInt32BE(e),e+=4,t.inception=r.readUInt32BE(e),e+=4,t.keyTag=r.readUInt16BE(e),e+=2,t.signersName=g.decode(r,e),e+=g.decode.bytes,t.signature=r.slice(e,n+i+2),e+=t.signature.length,Q.decode.bytes=e-n,t};Q.decode.bytes=0;Q.encodingLength=function(r){return 20+g.encodingLength(r.signersName)+E.byteLength(r.signature)};var W=w.rp={};W.encode=function(r,e,n){e||(e=E.alloc(W.encodingLength(r))),n||(n=0);let t=n;return n+=2,g.encode(r.mbox||".",e,n,{mail:!0}),n+=g.encode.bytes,g.encode(r.txt||".",e,n),n+=g.encode.bytes,W.encode.bytes=n-t,e.writeUInt16BE(W.encode.bytes-2,t),e};W.encode.bytes=0;W.decode=function(r,e){e||(e=0);let n=e,t={};return e+=2,t.mbox=g.decode(r,e,{mail:!0})||".",e+=g.decode.bytes,t.txt=g.decode(r,e)||".",e+=g.decode.bytes,W.decode.bytes=e-n,t};W.decode.bytes=0;W.encodingLength=function(r){return 2+g.encodingLength(r.mbox||".")+g.encodingLength(r.txt||".")};var O={};O.encode=function(r,e,n){e||(e=E.alloc(O.encodingLength(r))),n||(n=0);let t=n;for(var i=[],o=0;o<r.length;o++){var c=pe.toType(r[o]);i[c>>8]===void 0&&(i[c>>8]=[]),i[c>>8][c>>3&31]|=1<<7-(c&7)}for(o=0;o<i.length;o++)if(i[o]!==void 0){var h=E.from(i[o]);e.writeUInt8(o,n),n+=1,e.writeUInt8(h.length,n),n+=1,h.copy(e,n),n+=h.length}return O.encode.bytes=n-t,e};O.encode.bytes=0;O.decode=function(r,e,n){e||(e=0);let t=e;for(var i=[];e-t<n;){var o=r.readUInt8(e);e+=1;var c=r.readUInt8(e);e+=1;for(var h=0;h<c;h++)for(var a=r.readUInt8(e+h),d=0;d<8;d++)if(a&1<<7-d){var m=pe.toString(o<<8|h<<3|d);i.push(m)}e+=c}return O.decode.bytes=e-t,i};O.decode.bytes=0;O.encodingLength=function(r){for(var e=[],n=0;n<r.length;n++){var t=pe.toType(r[n]);e[t>>8]=Math.max(e[t>>8]||0,t&255)}var i=0;for(n=0;n<e.length;n++)e[n]!==void 0&&(i+=2+Math.ceil((e[n]+1)/8));return i};var J=w.nsec={};J.encode=function(r,e,n){e||(e=E.alloc(J.encodingLength(r))),n||(n=0);let t=n;return n+=2,g.encode(r.nextDomain,e,n),n+=g.encode.bytes,O.encode(r.rrtypes,e,n),n+=O.encode.bytes,J.encode.bytes=n-t,e.writeUInt16BE(J.encode.bytes-2,t),e};J.encode.bytes=0;J.decode=function(r,e){e||(e=0);let n=e;var t={},i=r.readUInt16BE(e);return e+=2,t.nextDomain=g.decode(r,e),e+=g.decode.bytes,t.rrtypes=O.decode(r,e,i-(e-n)),e+=O.decode.bytes,J.decode.bytes=e-n,t};J.decode.bytes=0;J.encodingLength=function(r){return 2+g.encodingLength(r.nextDomain)+O.encodingLength(r.rrtypes)};var Z=w.nsec3={};Z.encode=function(r,e,n){e||(e=E.alloc(Z.encodingLength(r))),n||(n=0);let t=n,i=r.salt;if(!E.isBuffer(i))throw new Error("salt must be a Buffer");let o=r.nextDomain;if(!E.isBuffer(o))throw new Error("nextDomain must be a Buffer");return n+=2,e.writeUInt8(r.algorithm,n),n+=1,e.writeUInt8(r.flags,n),n+=1,e.writeUInt16BE(r.iterations,n),n+=2,e.writeUInt8(i.length,n),n+=1,i.copy(e,n,0,i.length),n+=i.length,e.writeUInt8(o.length,n),n+=1,o.copy(e,n,0,o.length),n+=o.length,O.encode(r.rrtypes,e,n),n+=O.encode.bytes,Z.encode.bytes=n-t,e.writeUInt16BE(Z.encode.bytes-2,t),e};Z.encode.bytes=0;Z.decode=function(r,e){e||(e=0);let n=e;var t={},i=r.readUInt16BE(e);e+=2,t.algorithm=r.readUInt8(e),e+=1,t.flags=r.readUInt8(e),e+=1,t.iterations=r.readUInt16BE(e),e+=2;let o=r.readUInt8(e);e+=1,t.salt=r.slice(e,e+o),e+=o;let c=r.readUInt8(e);return e+=1,t.nextDomain=r.slice(e,e+c),e+=c,t.rrtypes=O.decode(r,e,i-(e-n)),e+=O.decode.bytes,Z.decode.bytes=e-n,t};Z.decode.bytes=0;Z.encodingLength=function(r){return 8+r.salt.length+r.nextDomain.length+O.encodingLength(r.rrtypes)};var f=w.ds={};f.encode=function(r,e,n){e||(e=E.alloc(f.encodingLength(r))),n||(n=0);let t=n,i=r.digest;if(!E.isBuffer(i))throw new Error("Digest must be a Buffer");return n+=2,e.writeUInt16BE(r.keyTag,n),n+=2,e.writeUInt8(r.algorithm,n),n+=1,e.writeUInt8(r.digestType,n),n+=1,i.copy(e,n,0,i.length),n+=i.length,f.encode.bytes=n-t,e.writeUInt16BE(f.encode.bytes-2,t),e};f.encode.bytes=0;f.decode=function(r,e){e||(e=0);let n=e;var t={},i=r.readUInt16BE(e);return e+=2,t.keyTag=r.readUInt16BE(e),e+=2,t.algorithm=r.readUInt8(e),e+=1,t.digestType=r.readUInt8(e),e+=1,t.digest=r.slice(e,n+i+2),e+=t.digest.length,f.decode.bytes=e-n,t};f.decode.bytes=0;f.encodingLength=function(r){return 6+E.byteLength(r.digest)};var z=w.sshfp={};z.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};z.encode=function(e,n,t){n||(n=E.alloc(z.encodingLength(e))),t||(t=0);let i=t;t+=2,n[t]=e.algorithm,t+=1,n[t]=e.hash,t+=1;let o=E.from(e.fingerprint.toUpperCase(),"hex");if(o.length!==z.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return o.copy(n,t),t+=o.byteLength,z.encode.bytes=t-i,n.writeUInt16BE(z.encode.bytes-2,i),n};z.encode.bytes=0;z.decode=function(e,n){n||(n=0);let t=n,i={};n+=2,i.algorithm=e[n],n+=1,i.hash=e[n],n+=1;let o=z.getFingerprintLengthForHashType(i.hash);return i.fingerprint=e.slice(n,n+o).toString("hex").toUpperCase(),n+=o,z.decode.bytes=n-t,i};z.decode.bytes=0;z.encodingLength=function(r){return 4+E.from(r.fingerprint,"hex").byteLength};var ee=w.naptr={};ee.encode=function(r,e,n){e||(e=E.alloc(ee.encodingLength(r))),n||(n=0);let t=n;return n+=2,e.writeUInt16BE(r.order||0,n),n+=2,e.writeUInt16BE(r.preference||0,n),n+=2,I.encode(r.flags,e,n),n+=I.encode.bytes,I.encode(r.services,e,n),n+=I.encode.bytes,I.encode(r.regexp,e,n),n+=I.encode.bytes,g.encode(r.replacement,e,n),n+=g.encode.bytes,ee.encode.bytes=n-t,e.writeUInt16BE(ee.encode.bytes-2,t),e};ee.encode.bytes=0;ee.decode=function(r,e){e||(e=0);let n=e,t={};return e+=2,t.order=r.readUInt16BE(e),e+=2,t.preference=r.readUInt16BE(e),e+=2,t.flags=I.decode(r,e),e+=I.decode.bytes,t.services=I.decode(r,e),e+=I.decode.bytes,t.regexp=I.decode(r,e),e+=I.decode.bytes,t.replacement=g.decode(r,e),e+=g.decode.bytes,ee.decode.bytes=e-n,t};ee.decode.bytes=0;ee.encodingLength=function(r){return I.encodingLength(r.flags)+I.encodingLength(r.services)+I.encodingLength(r.regexp)+g.encodingLength(r.replacement)+6};var re=w.tlsa={};re.encode=function(r,e,n){e||(e=E.alloc(re.encodingLength(r))),n||(n=0);let t=n,i=r.certificate;if(!E.isBuffer(i))throw new Error("Certificate must be a Buffer");return n+=2,e.writeUInt8(r.usage,n),n+=1,e.writeUInt8(r.selector,n),n+=1,e.writeUInt8(r.matchingType,n),n+=1,i.copy(e,n,0,i.length),n+=i.length,re.encode.bytes=n-t,e.writeUInt16BE(re.encode.bytes-2,t),e};re.encode.bytes=0;re.decode=function(r,e){e||(e=0);let n=e,t={},i=r.readUInt16BE(e);return e+=2,t.usage=r.readUInt8(e),e+=1,t.selector=r.readUInt8(e),e+=1,t.matchingType=r.readUInt8(e),e+=1,t.certificate=r.slice(e,n+i+2),e+=t.certificate.length,re.decode.bytes=e-n,t};re.decode.bytes=0;re.encodingLength=function(r){return 5+E.byteLength(r.certificate)};var mr=w.record=function(r){switch(r.toUpperCase()){case"A":return ue;case"PTR":return H;case"CNAME":return Pt;case"DNAME":return Bt;case"TXT":return se;case"NULL":return ae;case"AAAA":return he;case"SRV":return le;case"HINFO":return de;case"CAA":return M;case"NS":return oe;case"SOA":return ce;case"MX":return ye;case"OPT":return q;case"DNSKEY":return F;case"RRSIG":return Q;case"RP":return W;case"NSEC":return J;case"NSEC3":return Z;case"SSHFP":return z;case"DS":return f;case"NAPTR":return ee;case"TLSA":return re}return ie},N=w.answer={};N.encode=function(r,e,n){e||(e=E.alloc(N.encodingLength(r))),n||(n=0);let t=n;if(g.encode(r.name,e,n),n+=g.encode.bytes,e.writeUInt16BE(pe.toType(r.type),n),r.type.toUpperCase()==="OPT"){if(r.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(r.udpPayloadSize||4096,n+2),e.writeUInt8(r.extendedRcode||0,n+4),e.writeUInt8(r.ednsVersion||0,n+5),e.writeUInt16BE(r.flags||0,n+6),n+=8,q.encode(r.options||[],e,n),n+=q.encode.bytes}else{let i=Qe.toClass(r.class===void 0?"IN":r.class);r.flush&&(i|=gr),e.writeUInt16BE(i,n+2),e.writeUInt32BE(r.ttl||0,n+4),n+=8;let o=mr(r.type);o.encode(r.data,e,n),n+=o.encode.bytes}return N.encode.bytes=n-t,e};N.encode.bytes=0;N.decode=function(r,e){e||(e=0);let n={},t=e;if(n.name=g.decode(r,e),e+=g.decode.bytes,n.type=pe.toString(r.readUInt16BE(e)),n.type==="OPT")n.udpPayloadSize=r.readUInt16BE(e+2),n.extendedRcode=r.readUInt8(e+4),n.ednsVersion=r.readUInt8(e+5),n.flags=r.readUInt16BE(e+6),n.flag_do=(n.flags>>15&1)===1,n.options=q.decode(r,e+8),e+=8+q.decode.bytes;else{let i=r.readUInt16BE(e+2);n.ttl=r.readUInt32BE(e+4),n.class=Qe.toString(i&Tt),n.flush=!!(i&gr);let o=mr(n.type);n.data=o.decode(r,e+8),e+=8+o.decode.bytes}return N.decode.bytes=e-t,n};N.decode.bytes=0;N.encodingLength=function(r){let e=r.data!==null&&r.data!==void 0?r.data:r.options;return g.encodingLength(r.name)+8+mr(r.type).encodingLength(e)};var j=w.question={};j.encode=function(r,e,n){e||(e=E.alloc(j.encodingLength(r))),n||(n=0);let t=n;return g.encode(r.name,e,n),n+=g.encode.bytes,e.writeUInt16BE(pe.toType(r.type),n),n+=2,e.writeUInt16BE(Qe.toClass(r.class===void 0?"IN":r.class),n),n+=2,j.encode.bytes=n-t,r};j.encode.bytes=0;j.decode=function(r,e){e||(e=0);let n=e,t={};return t.name=g.decode(r,e),e+=g.decode.bytes,t.type=pe.toString(r.readUInt16BE(e)),e+=2,t.class=Qe.toString(r.readUInt16BE(e)),e+=2,!!(t.class&In)&&(t.class&=Nt),j.decode.bytes=e-n,t};j.decode.bytes=0;j.encodingLength=function(r){return g.encodingLength(r.name)+4};w.AUTHORITATIVE_ANSWER=1024;w.TRUNCATED_RESPONSE=512;w.RECURSION_DESIRED=256;w.RECURSION_AVAILABLE=128;w.AUTHENTIC_DATA=32;w.CHECKING_DISABLED=16;w.DNSSEC_OK=32768;w.encode=function(r,e,n){let t=!e;t&&(e=E.alloc(w.encodingLength(r))),n||(n=0);let i=n;return r.questions||(r.questions=[]),r.answers||(r.answers=[]),r.authorities||(r.authorities=[]),r.additionals||(r.additionals=[]),X.encode(r,e,n),n+=X.encode.bytes,n=Fe(r.questions,j,e,n),n=Fe(r.answers,N,e,n),n=Fe(r.authorities,N,e,n),n=Fe(r.additionals,N,e,n),w.encode.bytes=n-i,t&&w.encode.bytes!==e.length?e.slice(0,w.encode.bytes):e};w.encode.bytes=0;w.decode=function(r,e){e||(e=0);let n=e,t=X.decode(r,e);return e+=X.decode.bytes,e=Ge(t.questions,j,r,e),e=Ge(t.answers,N,r,e),e=Ge(t.authorities,N,r,e),e=Ge(t.additionals,N,r,e),w.decode.bytes=e-n,t};w.decode.bytes=0;w.encodingLength=function(r){return X.encodingLength(r)+be(r.questions||[],j)+be(r.answers||[],N)+be(r.authorities||[],N)+be(r.additionals||[],N)};w.streamEncode=function(r){let e=w.encode(r),n=E.alloc(2);n.writeUInt16BE(e.byteLength);let t=E.concat([n,e]);return w.streamEncode.bytes=t.byteLength,t};w.streamEncode.bytes=0;w.streamDecode=function(r){let e=r.readUInt16BE(0);if(r.byteLength<e+2)return null;let n=w.decode(r.slice(2));return w.streamDecode.bytes=w.decode.bytes,n};w.streamDecode.bytes=0;function be(r,e){let n=0;for(let t=0;t<r.length;t++)n+=e.encodingLength(r[t]);return n}function Fe(r,e,n,t){for(let i=0;i<r.length;i++)e.encode(r[i],n,t),t+=e.encode.bytes;return t}function Ge(r,e,n,t){for(let i=0;i<r.length;i++)r[i]=e.decode(n,t),t+=e.decode.bytes;return t}});var Un=G((Go,An)=>{"use strict";var vn=Mt;process.nextTick(kt,42);An.exports=Dt;function Dt(r){var e=t;return n;function n(i){e(i||Rt)}function t(i){var o=[i];e=c,r(h);function c(a){o.push(a)}function h(a){var d=arguments;for(e=Ft(a)?t:m;o.length;)m(o.shift());function m(l){vn(_t,l,d)}}}}function Ft(r){return Object.prototype.toString.call(r)==="[object Error]"}function Rt(){}function _t(r,e){r.apply(null,e)}function kt(r){r===42&&(vn=process.nextTick)}function Mt(r,e,n){process.nextTick(function(){r(e,n)})}});var bn=G((Qo,Ln)=>{var yr=xn(),zt=xe("dgram"),qt=Un(),$t=xe("events"),Er=xe("os"),wr=function(){};Ln.exports=function(r){r||(r={});var e=new $t.EventEmitter,n=typeof r.port=="number"?r.port:5353,t=r.type||"udp4",i=r.ip||r.host||(t==="udp4"?"224.0.0.251":null),o={address:i,port:n},c={},h=!1,a=null;if(t==="udp6"&&(!i||!r.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var d=r.socket||zt.createSocket({type:t,reuseAddr:r.reuseAddr!==!1,toString:function(){return t}});d.on("error",function(l){l.code==="EACCES"||l.code==="EADDRINUSE"?e.emit("error",l):e.emit("warning",l)}),d.on("message",function(l,u){try{l=yr.decode(l)}catch(p){e.emit("warning",p);return}e.emit("packet",l,u),l.type==="query"&&e.emit("query",l,u),l.type==="response"&&e.emit("response",l,u)}),d.on("listening",function(){n||(n=o.port=d.address().port),r.multicast!==!1&&(e.update(),a=setInterval(e.update,5e3),d.setMulticastTTL(r.ttl||255),d.setMulticastLoopback(r.loopback!==!1))});var m=qt(function(l){if(!n||r.bind===!1)return l(null);d.once("error",l),d.bind(n,r.bind||r.interface,function(){d.removeListener("error",l),l(null)})});return m(function(l){if(l)return e.emit("error",l);e.emit("ready")}),e.send=function(l,u,p){if(typeof u=="function")return e.send(l,null,u);p||(p=wr),u?!u.host&&!u.address&&(u.address=o.address):u=o,m(s);function s(y){if(h)return p();if(y)return p(y);var v=yr.encode(l);d.send(v,0,v.length,u.port,u.address||u.host,p)}},e.response=e.respond=function(l,u,p){Array.isArray(l)&&(l={answers:l}),l.type="response",l.flags=(l.flags||0)|yr.AUTHORITATIVE_ANSWER,e.send(l,u,p)},e.query=function(l,u,p,s){if(typeof u=="function")return e.query(l,null,null,u);if(typeof u=="object"&&u&&u.port)return e.query(l,null,u,p);if(typeof p=="function")return e.query(l,u,null,p);s||(s=wr),typeof l=="string"&&(l=[{name:l,type:u||"ANY"}]),Array.isArray(l)&&(l={type:"query",questions:l}),l.type="query",e.send(l,p,s)},e.destroy=function(l){if(l||(l=wr),h)return process.nextTick(l);h=!0,clearInterval(a);for(var u in c)try{d.dropMembership(i,u)}catch{}c={},d.close(l)},e.update=function(){for(var l=r.interface?[].concat(r.interface):Kt(),u=!1,p=0;p<l.length;p++){var s=l[p];if(!c[s])try{d.addMembership(i,s),c[s]=!0,u=!0}catch(y){e.emit("warning",y)}}if(u){if(d.setMulticastInterface)try{d.setMulticastInterface(r.interface||Vt())}catch(y){e.emit("warning",y)}e.emit("networkInterface")}},e};function Vt(){for(var r=Er.networkInterfaces(),e=Object.keys(r),n=0;n<e.length;n++)for(var t=r[e[n]],i=0;i<t.length;i++){var o=t[i];if(Sn(o.family)&&!o.internal)return Er.platform()==="darwin"&&e[n]==="en0"?o.address:"0.0.0.0"}return"127.0.0.1"}function Kt(){for(var r=Er.networkInterfaces(),e=Object.keys(r),n=[],t=0;t<e.length;t++)for(var i=r[e[t]],o=0;o<i.length;o++){var c=i[o];if(Sn(c.family)){n.push(c.address);break}}return n}function Sn(r){return r===4||r==="IPv4"}});var Gn=G(Ke=>{(function(){var r,e,n,t,i,o,c,h;h=function(a){var d,m,l,u;return d=(a&255<<24)>>>24,m=(a&255<<16)>>>16,l=(a&65280)>>>8,u=a&255,[d,m,l,u].join(".")},c=function(a){var d,m,l,u,p,s;for(d=[],l=u=0;u<=3&&a.length!==0;l=++u){if(l>0){if(a[0]!==".")throw new Error("Invalid IP");a=a.substring(1)}s=e(a),p=s[0],m=s[1],a=a.substring(m),d.push(p)}if(a.length!==0)throw new Error("Invalid IP");switch(d.length){case 1:if(d[0]>4294967295)throw new Error("Invalid IP");return d[0]>>>0;case 2:if(d[0]>255||d[1]>16777215)throw new Error("Invalid IP");return(d[0]<<24|d[1])>>>0;case 3:if(d[0]>255||d[1]>255||d[2]>65535)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2])>>>0;case 4:if(d[0]>255||d[1]>255||d[2]>255||d[3]>255)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2]<<8|d[3])>>>0;default:throw new Error("Invalid IP")}},n=function(a){return a.charCodeAt(0)},t=n("0"),o=n("a"),i=n("A"),e=function(a){var d,m,l,u,p;for(u=0,d=10,m="9",l=0,a.length>1&&a[l]==="0"&&(a[l+1]==="x"||a[l+1]==="X"?(l+=2,d=16):"0"<=a[l+1]&&a[l+1]<="9"&&(l++,d=8,m="7")),p=l;l<a.length;){if("0"<=a[l]&&a[l]<=m)u=u*d+(n(a[l])-t)>>>0;else if(d===16)if("a"<=a[l]&&a[l]<="f")u=u*d+(10+n(a[l])-o)>>>0;else if("A"<=a[l]&&a[l]<="F")u=u*d+(10+n(a[l])-i)>>>0;else break;else break;if(u>4294967295)throw new Error("too large");l++}if(l===p)throw new Error("empty octet");return[u,l]},r=function(){function a(d,m){var l,u,p,s;if(typeof d!="string")throw new Error("Missing `net' parameter");if(m||(s=d.split("/",2),d=s[0],m=s[1]),m||(m=32),typeof m=="string"&&m.indexOf(".")>-1){try{this.maskLong=c(m)}catch(y){throw l=y,new Error("Invalid mask: "+m)}for(u=p=32;p>=0;u=--p)if(this.maskLong===4294967295<<32-u>>>0){this.bitmask=u;break}}else if(m||m===0)this.bitmask=parseInt(m,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(c(d)&this.maskLong)>>>0}catch(y){throw l=y,new Error("Invalid net address: "+d)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+m);this.size=Math.pow(2,32-this.bitmask),this.base=h(this.netLong),this.mask=h(this.maskLong),this.hostmask=h(~this.maskLong),this.first=this.bitmask<=30?h(this.netLong+1):this.base,this.last=this.bitmask<=30?h(this.netLong+this.size-2):h(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?h(this.netLong+this.size-1):void 0}return a.prototype.contains=function(d){return typeof d=="string"&&(d.indexOf("/")>0||d.split(".").length!==4)&&(d=new a(d)),d instanceof a?this.contains(d.base)&&this.contains(d.broadcast||d.last):(c(d)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},a.prototype.next=function(d){return d==null&&(d=1),new a(h(this.netLong+this.size*d),this.mask)},a.prototype.forEach=function(d){var m,l,u;for(u=c(this.first),l=c(this.last),m=0;u<=l;)d(h(u),u,m),m++,u++},a.prototype.toString=function(){return this.base+"/"+this.bitmask},a}(),Ke.ip2long=c,Ke.long2ip=h,Ke.Netmask=r}).call(Ke)});var Fo={};k(Fo,{mdns:()=>Do});var cn=Symbol.for("@libp2p/peer-discovery");var sn=Symbol.for("@libp2p/peer-id");var Xe=class extends Error{code;props;constructor(e,n,t){super(e),this.code=n,this.name=t?.name??"CodeError",this.props=t??{}}};var an=xe("events"),dn=(r,...e)=>{try{(0,an.setMaxListeners)(r,...e)}catch{}};var Ye=class extends EventTarget{#e=new Map;constructor(){super(),dn(1/0,this)}listenerCount(e){let n=this.#e.get(e);return n==null?0:n.length}addEventListener(e,n,t){super.addEventListener(e,n,t);let i=this.#e.get(e);i==null&&(i=[],this.#e.set(e,i)),i.push({callback:n,once:(t!==!0&&t!==!1&&t?.once)??!1})}removeEventListener(e,n,t){super.removeEventListener(e.toString(),n??null,t);let i=this.#e.get(e);i!=null&&(i=i.filter(({callback:o})=>o!==n),this.#e.set(e,i))}dispatchEvent(e){let n=super.dispatchEvent(e),t=this.#e.get(e.type);return t==null||(t=t.filter(({once:i})=>!i),this.#e.set(e.type,t)),n}safeDispatchEvent(e,n={}){return this.dispatchEvent(new cr(e,n))}},or=class extends Event{detail;constructor(e,n){super(e,n),this.detail=n?.detail}},cr=globalThis.CustomEvent??or;var It=ir(bn(),1);var Ur={};k(Ur,{base58btc:()=>P,base58flickr:()=>Qt});var Wo=new Uint8Array(0);function Cn(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let n=0;n<r.byteLength;n++)if(r[n]!==e[n])return!1;return!0}function $(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function On(r){return new TextEncoder().encode(r)}function Tn(r){return new TextDecoder().decode(r)}function Ht(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),t=0;t<n.length;t++)n[t]=255;for(var i=0;i<r.length;i++){var o=r.charAt(i),c=o.charCodeAt(0);if(n[c]!==255)throw new TypeError(o+" is ambiguous");n[c]=i}var h=r.length,a=r.charAt(0),d=Math.log(h)/Math.log(256),m=Math.log(256)/Math.log(h);function l(s){if(s instanceof Uint8Array||(ArrayBuffer.isView(s)?s=new Uint8Array(s.buffer,s.byteOffset,s.byteLength):Array.isArray(s)&&(s=Uint8Array.from(s))),!(s instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(s.length===0)return"";for(var y=0,v=0,U=0,L=s.length;U!==L&&s[U]===0;)U++,y++;for(var B=(L-U)*m+1>>>0,T=new Uint8Array(B);U!==L;){for(var b=s[U],C=0,K=B-1;(b!==0||C<v)&&K!==-1;K--,C++)b+=256*T[K]>>>0,T[K]=b%h>>>0,b=b/h>>>0;if(b!==0)throw new Error("Non-zero carry");v=C,U++}for(var te=B-v;te!==B&&T[te]===0;)te++;for(var He=a.repeat(y);te<B;++te)He+=r.charAt(T[te]);return He}function u(s){if(typeof s!="string")throw new TypeError("Expected String");if(s.length===0)return new Uint8Array;var y=0;if(s[y]!==" "){for(var v=0,U=0;s[y]===a;)v++,y++;for(var L=(s.length-y)*d+1>>>0,B=new Uint8Array(L);s[y];){var T=n[s.charCodeAt(y)];if(T===255)return;for(var b=0,C=L-1;(T!==0||b<U)&&C!==-1;C--,b++)T+=h*B[C]>>>0,B[C]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");U=b,y++}if(s[y]!==" "){for(var K=L-U;K!==L&&B[K]===0;)K++;for(var te=new Uint8Array(v+(L-K)),He=v;K!==L;)te[He++]=B[K++];return te}}}function p(s){var y=u(s);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:u,decode:p}}var jt=Ht,Xt=jt,Pn=Xt;var Ir=class{name;prefix;baseEncode;constructor(e,n,t){this.name=e,this.prefix=n,this.baseEncode=t}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},xr=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,n,t){if(this.name=e,this.prefix=n,n.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n.codePointAt(0),this.baseDecode=t}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Bn(this,e)}},vr=class{decoders;constructor(e){this.decoders=e}or(e){return Bn(this,e)}decode(e){let n=e[0],t=this.decoders[n];if(t!=null)return t.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Bn(r,e){return new vr({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Ar=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,n,t,i){this.name=e,this.prefix=n,this.baseEncode=t,this.baseDecode=i,this.encoder=new Ir(e,n,t),this.decoder=new xr(e,n,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Ce({name:r,prefix:e,encode:n,decode:t}){return new Ar(r,e,n,t)}function we({name:r,prefix:e,alphabet:n}){let{encode:t,decode:i}=Pn(n,r);return Ce({prefix:e,name:r,encode:t,decode:o=>$(i(o))})}function Yt(r,e,n,t){let i={};for(let m=0;m<e.length;++m)i[e[m]]=m;let o=r.length;for(;r[o-1]==="=";)--o;let c=new Uint8Array(o*n/8|0),h=0,a=0,d=0;for(let m=0;m<o;++m){let l=i[r[m]];if(l===void 0)throw new SyntaxError(`Non-${t} character`);a=a<<n|l,h+=n,h>=8&&(h-=8,c[d++]=255&a>>h)}if(h>=n||255&a<<8-h)throw new SyntaxError("Unexpected end of data");return c}function Gt(r,e,n){let t=e[e.length-1]==="=",i=(1<<n)-1,o="",c=0,h=0;for(let a=0;a<r.length;++a)for(h=h<<8|r[a],c+=8;c>n;)c-=n,o+=e[i&h>>c];if(c!==0&&(o+=e[i&h<<n-c]),t)for(;o.length*n&7;)o+="=";return o}function S({name:r,prefix:e,bitsPerChar:n,alphabet:t}){return Ce({prefix:e,name:r,encode(i){return Gt(i,t,n)},decode(i){return Yt(i,t,n,r)}})}var P=we({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Qt=we({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Sr={};k(Sr,{base10:()=>Wt});var Wt=we({prefix:"9",name:"base10",alphabet:"0123456789"});var Lr={};k(Lr,{base16:()=>Jt,base16upper:()=>Zt});var Jt=S({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Zt=S({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var br={};k(br,{base2:()=>ft});var ft=S({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Cr={};k(Cr,{base256emoji:()=>ii});var Dn=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}"),ei=Dn.reduce((r,e,n)=>(r[n]=e,r),[]),ri=Dn.reduce((r,e,n)=>(r[e.codePointAt(0)]=n,r),[]);function ni(r){return r.reduce((e,n)=>(e+=ei[n],e),"")}function ti(r){let e=[];for(let n of r){let t=ri[n.codePointAt(0)];if(t===void 0)throw new Error(`Non-base256emoji character: ${n}`);e.push(t)}return new Uint8Array(e)}var ii=Ce({prefix:"\u{1F680}",name:"base256emoji",encode:ni,decode:ti});var Or={};k(Or,{base32:()=>ge,base32hex:()=>ai,base32hexpad:()=>li,base32hexpadupper:()=>ui,base32hexupper:()=>di,base32pad:()=>ci,base32padupper:()=>si,base32upper:()=>oi,base32z:()=>hi});var ge=S({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),oi=S({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ci=S({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),si=S({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ai=S({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),di=S({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),li=S({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ui=S({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),hi=S({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Tr={};k(Tr,{base36:()=>pi,base36upper:()=>gi});var pi=we({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),gi=we({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Nr={};k(Nr,{base64:()=>mi,base64pad:()=>yi,base64url:()=>wi,base64urlpad:()=>Ei});var mi=S({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),yi=S({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),wi=S({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ei=S({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Pr={};k(Pr,{base8:()=>Ii});var Ii=S({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Br={};k(Br,{identity:()=>xi});var xi=Ce({prefix:"\0",name:"identity",encode:r=>Tn(r),decode:r=>On(r)});var hc=new TextEncoder,pc=new TextDecoder;var Fr={};k(Fr,{identity:()=>Je});var Ui=_n,Fn=128,Si=127,Li=~Si,bi=Math.pow(2,31);function _n(r,e,n){e=e||[],n=n||0;for(var t=n;r>=bi;)e[n++]=r&255|Fn,r/=128;for(;r&Li;)e[n++]=r&255|Fn,r>>>=7;return e[n]=r|0,_n.bytes=n-t+1,e}var Ci=Dr,Oi=128,Rn=127;function Dr(r,t){var n=0,t=t||0,i=0,o=t,c,h=r.length;do{if(o>=h)throw Dr.bytes=0,new RangeError("Could not decode varint");c=r[o++],n+=i<28?(c&Rn)<<i:(c&Rn)*Math.pow(2,i),i+=7}while(c>=Oi);return Dr.bytes=o-t,n}var Ti=Math.pow(2,7),Ni=Math.pow(2,14),Pi=Math.pow(2,21),Bi=Math.pow(2,28),Di=Math.pow(2,35),Fi=Math.pow(2,42),Ri=Math.pow(2,49),_i=Math.pow(2,56),ki=Math.pow(2,63),Mi=function(r){return r<Ti?1:r<Ni?2:r<Pi?3:r<Bi?4:r<Di?5:r<Fi?6:r<Ri?7:r<_i?8:r<ki?9:10},zi={encode:Ui,decode:Ci,encodingLength:Mi},qi=zi,Re=qi;function _e(r,e=0){return[Re.decode(r,e),Re.decode.bytes]}function Oe(r,e,n=0){return Re.encode(r,e,n),e}function Te(r){return Re.encodingLength(r)}function Ee(r,e){let n=e.byteLength,t=Te(r),i=t+Te(n),o=new Uint8Array(i+n);return Oe(r,o,0),Oe(n,o,t),o.set(e,i),new Ne(r,n,e,o)}function Ae(r){let e=$(r),[n,t]=_e(e),[i,o]=_e(e.subarray(t)),c=e.subarray(t+o);if(c.byteLength!==i)throw new Error("Incorrect length");return new Ne(n,i,c,e)}function kn(r,e){if(r===e)return!0;{let n=e;return r.code===n.code&&r.size===n.size&&n.bytes instanceof Uint8Array&&Cn(r.bytes,n.bytes)}}var Ne=class{code;size;digest;bytes;constructor(e,n,t,i){this.code=e,this.size=n,this.digest=t,this.bytes=i}};var Mn=0,$i="identity",zn=$;function Vi(r){return Ee(Mn,zn(r))}var Je={code:Mn,name:$i,encode:zn,digest:Vi};var Mr={};k(Mr,{sha256:()=>Ze,sha512:()=>Ki});var kr=ir(xe("crypto"),1);function _r({name:r,code:e,encode:n}){return new Rr(r,e,n)}var Rr=class{name;code;encode;constructor(e,n,t){this.name=e,this.code=n,this.encode=t}digest(e){if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?Ee(this.code,n):n.then(t=>Ee(this.code,t))}else throw Error("Unknown type, must be binary type")}};var Ze=_r({name:"sha2-256",code:18,encode:r=>$(kr.default.createHash("sha256").update(r).digest())}),Ki=_r({name:"sha2-512",code:19,encode:r=>$(kr.default.createHash("sha512").update(r).digest())});function $n(r,e){let{bytes:n,version:t}=r;switch(t){case 0:return ji(n,zr(r),e??P.encoder);default:return Xi(n,zr(r),e??ge.encoder)}}var Vn=new WeakMap;function zr(r){let e=Vn.get(r);if(e==null){let n=new Map;return Vn.set(r,n),n}return e}var Y=class r{code;version;multihash;bytes;"/";constructor(e,n,t,i){this.code=n,this.version=e,this.multihash=t,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:n}=this;if(e!==ke)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(n.code!==Yi)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(n)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:n}=this.multihash,t=Ee(e,n);return r.createV1(this.code,t)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,n){let t=n;return t!=null&&e.code===t.code&&e.version===t.version&&kn(e.multihash,t.multihash)}toString(e){return $n(this,e)}toJSON(){return{"/":$n(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let n=e;if(n instanceof r)return n;if(n["/"]!=null&&n["/"]===n.bytes||n.asCID===n){let{version:t,code:i,multihash:o,bytes:c}=n;return new r(t,i,o,c??Kn(t,i,o.bytes))}else if(n[Gi]===!0){let{version:t,multihash:i,code:o}=n,c=Ae(i);return r.create(t,o,c)}else return null}static create(e,n,t){if(typeof n!="number")throw new Error("String codecs are no longer supported");if(!(t.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(n!==ke)throw new Error(`Version 0 CID must use dag-pb (code: ${ke}) block encoding`);return new r(e,n,t,t.bytes)}case 1:{let i=Kn(e,n,t.bytes);return new r(e,n,t,i)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,ke,e)}static createV1(e,n){return r.create(1,e,n)}static decode(e){let[n,t]=r.decodeFirst(e);if(t.length!==0)throw new Error("Incorrect length");return n}static decodeFirst(e){let n=r.inspectBytes(e),t=n.size-n.multihashSize,i=$(e.subarray(t,t+n.multihashSize));if(i.byteLength!==n.multihashSize)throw new Error("Incorrect length");let o=i.subarray(n.multihashSize-n.digestSize),c=new Ne(n.multihashCode,n.digestSize,o,i);return[n.version===0?r.createV0(c):r.createV1(n.codec,c),e.subarray(n.size)]}static inspectBytes(e){let n=0,t=()=>{let[l,u]=_e(e.subarray(n));return n+=u,l},i=t(),o=ke;if(i===18?(i=0,n=0):o=t(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let c=n,h=t(),a=t(),d=n+a,m=d-c;return{version:i,codec:o,multihashCode:h,digestSize:a,multihashSize:m,size:d}}static parse(e,n){let[t,i]=Hi(e,n),o=r.decode(i);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return zr(o).set(t,e),o}};function Hi(r,e){switch(r[0]){case"Q":{let n=e??P;return[P.prefix,n.decode(`${P.prefix}${r}`)]}case P.prefix:{let n=e??P;return[P.prefix,n.decode(r)]}case ge.prefix:{let n=e??ge;return[ge.prefix,n.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function ji(r,e,n){let{prefix:t}=n;if(t!==P.prefix)throw Error(`Cannot string encode V0 in ${n.name} encoding`);let i=e.get(t);if(i==null){let o=n.encode(r).slice(1);return e.set(t,o),o}else return i}function Xi(r,e,n){let{prefix:t}=n,i=e.get(t);if(i==null){let o=n.encode(r);return e.set(t,o),o}else return i}var ke=112,Yi=18;function Kn(r,e,n){let t=Te(r),i=t+Te(e),o=new Uint8Array(i+n.byteLength);return Oe(r,o,0),Oe(e,o,t),o.set(n,i),o}var Gi=Symbol.for("@ipld/js-cid/CID");var Ie={...Br,...br,...Pr,...Sr,...Lr,...Or,...Tr,...Ur,...Nr,...Cr},Rc={...Mr,...Fr};function Me(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let n=0;n<r.byteLength;n++)if(r[n]!==e[n])return!1;return!0}var Qi=Symbol.for("nodejs.util.inspect.custom"),Hn=Object.values(Ie).map(r=>r.decoder).reduce((r,e)=>r.or(e),Ie.identity.decoder),jn=114,Xn=36,Yn=37,ze=class{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[sn]=!0;toString(){return this.string==null&&(this.string=P.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Y.createV1(jn,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return Me(this.multihash.bytes,e);if(typeof e=="string")return qr(e).equals(this);if(e?.multihash?.bytes!=null)return Me(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[Qi](){return`PeerId(${this.toString()})`}},qe=class extends ze{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},$e=class extends ze{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Ve=class extends ze{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function qr(r,e){if(e=e??Hn,r.charAt(0)==="1"||r.charAt(0)==="Q"){let n=Ae(P.decode(`z${r}`));return r.startsWith("12D")?new $e({multihash:n}):r.startsWith("16U")?new Ve({multihash:n}):new qe({multihash:n})}return Wi(Hn.decode(r))}function Wi(r){try{let e=Ae(r);if(e.code===Je.code){if(e.digest.length===Xn)return new $e({multihash:e});if(e.digest.length===Yn)return new Ve({multihash:e})}if(e.code===Ze.code)return new qe({multihash:e})}catch{return Ji(Y.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Ji(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==jn)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===Ze.code)return new qe({multihash:r.multihash});if(e.code===Je.code){if(e.digest.length===Xn)return new $e({multihash:r.multihash});if(e.digest.length===Yn)return new Ve({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var V=xe("node:net");function fe(r){return!!(0,V.isIP)(r)}var Qn=ir(Gn(),1),Zi=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],fi=Zi.map(r=>new Qn.Netmask(r));function eo(r){for(let e of fi)if(e.contains(r))return!0;return!1}function ro(r){return/^::$/.test(r)||/^::1$/.test(r)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function Wn(r){return(0,V.isIPv4)(r)?eo(r):(0,V.isIPv6)(r)?ro(r):void 0}function Jn(r){try{let{address:e}=r.nodeAddress();return!!Wn(e)}catch{return!0}}function Se(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Pe(r=0){return globalThis.Buffer?.allocUnsafe!=null?Se(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function fn(r,e,n,t){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:n},decoder:{decode:t}}}var Zn=fn("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),$r=fn("ascii","a",r=>{let e="a";for(let n=0;n<r.length;n++)e+=String.fromCharCode(r[n]);return e},r=>{r=r.substring(1);let e=Pe(r.length);for(let n=0;n<r.length;n++)e[n]=r.charCodeAt(n);return e}),no={utf8:Zn,"utf-8":Zn,hex:Ie.base16,latin1:$r,ascii:$r,binary:$r,...Ie},er=no;function _(r,e="utf8"){let n=er[e];if(n==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):n.encoder.encode(r).substring(1)}var to=Math.pow(2,7),io=Math.pow(2,14),oo=Math.pow(2,21),Vr=Math.pow(2,28),Kr=Math.pow(2,35),Hr=Math.pow(2,42),jr=Math.pow(2,49),x=128,D=127;function ne(r){if(r<to)return 1;if(r<io)return 2;if(r<oo)return 3;if(r<Vr)return 4;if(r<Kr)return 5;if(r<Hr)return 6;if(r<jr)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function co(r,e,n=0){switch(ne(r)){case 8:e[n++]=r&255|x,r/=128;case 7:e[n++]=r&255|x,r/=128;case 6:e[n++]=r&255|x,r/=128;case 5:e[n++]=r&255|x,r/=128;case 4:e[n++]=r&255|x,r>>>=7;case 3:e[n++]=r&255|x,r>>>=7;case 2:e[n++]=r&255|x,r>>>=7;case 1:{e[n++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function so(r,e,n=0){switch(ne(r)){case 8:e.set(n++,r&255|x),r/=128;case 7:e.set(n++,r&255|x),r/=128;case 6:e.set(n++,r&255|x),r/=128;case 5:e.set(n++,r&255|x),r/=128;case 4:e.set(n++,r&255|x),r>>>=7;case 3:e.set(n++,r&255|x),r>>>=7;case 2:e.set(n++,r&255|x),r>>>=7;case 1:{e.set(n++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function ao(r,e){let n=r[e],t=0;if(t+=n&D,n<x||(n=r[e+1],t+=(n&D)<<7,n<x)||(n=r[e+2],t+=(n&D)<<14,n<x)||(n=r[e+3],t+=(n&D)<<21,n<x)||(n=r[e+4],t+=(n&D)*Vr,n<x)||(n=r[e+5],t+=(n&D)*Kr,n<x)||(n=r[e+6],t+=(n&D)*Hr,n<x)||(n=r[e+7],t+=(n&D)*jr,n<x))return t;throw new RangeError("Could not decode varint")}function lo(r,e){let n=r.get(e),t=0;if(t+=n&D,n<x||(n=r.get(e+1),t+=(n&D)<<7,n<x)||(n=r.get(e+2),t+=(n&D)<<14,n<x)||(n=r.get(e+3),t+=(n&D)<<21,n<x)||(n=r.get(e+4),t+=(n&D)*Vr,n<x)||(n=r.get(e+5),t+=(n&D)*Kr,n<x)||(n=r.get(e+6),t+=(n&D)*Hr,n<x)||(n=r.get(e+7),t+=(n&D)*jr,n<x))return t;throw new RangeError("Could not decode varint")}function Be(r,e,n=0){return e==null&&(e=Pe(ne(r))),e instanceof Uint8Array?co(r,e,n):so(r,e,n)}function Le(r,e=0){return r instanceof Uint8Array?ao(r,e):lo(r,e)}function me(r,e){if(globalThis.Buffer!=null)return Se(globalThis.Buffer.concat(r,e));e==null&&(e=r.reduce((i,o)=>i+o.length,0));let n=Pe(e),t=0;for(let i of r)n.set(i,t),t+=i.length;return Se(n)}var rr=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let n=this.index,t=e();return t===void 0&&(this.index=n),t}parseWith(e){let n=e();if(this.index===this.input.length)return n}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let n=this.readChar();if(n===e)return n})}readSeparator(e,n,t){return this.readAtomically(()=>{if(!(n>0&&this.readGivenChar(e)===void 0))return t()})}readNumber(e,n,t,i){return this.readAtomically(()=>{let o=0,c=0,h=this.peekChar();if(h===void 0)return;let a=h==="0",d=2**(8*i)-1;for(;;){let m=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let u=Number.parseInt(l,e);if(!Number.isNaN(u))return u});if(m===void 0)break;if(o*=e,o+=m,o>d||(c+=1,n!==void 0&&c>n))return}if(c!==0)return!t&&a&&c>1?void 0:o})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let n=0;n<e.length;n++){let t=this.readSeparator(".",n,()=>this.readNumber(10,3,!1,1));if(t===void 0)return;e[n]=t}return e})}readIPv6Addr(){let e=n=>{for(let t=0;t<n.length/2;t++){let i=t*2;if(t<n.length-3){let c=this.readSeparator(":",t,()=>this.readIPv4Addr());if(c!==void 0)return n[i]=c[0],n[i+1]=c[1],n[i+2]=c[2],n[i+3]=c[3],[i+4,!0]}let o=this.readSeparator(":",t,()=>this.readNumber(16,4,!0,2));if(o===void 0)return[i,!1];n[i]=o>>8,n[i+1]=o&255}return[n.length,!1]};return this.readAtomically(()=>{let n=new Uint8Array(16),[t,i]=e(n);if(t===16)return n;if(i||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),c=16-(t+2),[h]=e(o.subarray(0,c));return n.set(o.subarray(0,h),16-h),n})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var hs=new rr;var xs=parseInt("0xFFFF",16),vs=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Xr(r,e="utf8"){let n=er[e];if(n==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Se(globalThis.Buffer.from(r,"utf-8")):n.decoder.decode(`${n.prefix}${r}`)}var tt=V.isIPv4,yo=V.isIPv6,Yr=function(r){let e=0;if(r=r.toString().trim(),tt(r)){let n=new Uint8Array(e+4);return r.split(/\./g).forEach(t=>{n[e++]=parseInt(t,10)&255}),n}if(yo(r)){let n=r.split(":",8),t;for(t=0;t<n.length;t++){let o=tt(n[t]),c;o&&(c=Yr(n[t]),n[t]=_(c.slice(0,2),"base16")),c!=null&&++t<8&&n.splice(t,0,_(c.slice(2,4),"base16"))}if(n[0]==="")for(;n.length<8;)n.unshift("0");else if(n[n.length-1]==="")for(;n.length<8;)n.push("0");else if(n.length<8){for(t=0;t<n.length&&n[t]!=="";t++);let o=[t,1];for(t=9-n.length;t>0;t--)o.push("0");n.splice.apply(n,o)}let i=new Uint8Array(e+16);for(t=0;t<n.length;t++){let o=parseInt(n[t],16);i[e++]=o>>8&255,i[e++]=o&255}return i}throw new Error("invalid ip address")},it=function(r,e=0,n){e=~~e,n=n??r.length-e;let t=new DataView(r.buffer);if(n===4){let i=[];for(let o=0;o<n;o++)i.push(r[e+o]);return i.join(".")}if(n===16){let i=[];for(let o=0;o<n;o+=2)i.push(t.getUint16(e+o).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var De={},Gr={},Eo=[[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"]];Eo.forEach(r=>{let e=Io(...r);Gr[e.code]=e,De[e.name]=e});function Io(r,e,n,t,i){return{code:r,size:e,name:n,resolvable:!!t,path:!!i}}function A(r){if(typeof r=="number"){if(Gr[r]!=null)return Gr[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(De[r]!=null)return De[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var sa=A("ip4"),aa=A("ip6"),da=A("ipcidr");function Wr(r,e){switch(A(r).code){case 4:case 41:return vo(e);case 42:return st(e);case 6:case 273:case 33:case 132:return dt(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return st(e);case 421:return Lo(e);case 444:return at(e);case 445:return at(e);case 466:return So(e);default:return _(e,"base16")}}function Jr(r,e){switch(A(r).code){case 4:return ot(e);case 41:return ot(e);case 42:return ct(e);case 6:case 273:case 33:case 132:return Zr(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ct(e);case 421:return Ao(e);case 444:return bo(e);case 445:return Co(e);case 466:return Uo(e);default:return Xr(e,"base16")}}var Qr=Object.values(Ie).map(r=>r.decoder),xo=function(){let r=Qr[0].or(Qr[1]);return Qr.slice(2).forEach(e=>r=r.or(e)),r}();function ot(r){if(!fe(r))throw new Error("invalid ip address");return Yr(r)}function vo(r){let e=it(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!fe(e))throw new Error("invalid ip address");return e}function Zr(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function dt(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function ct(r){let e=Xr(r),n=Uint8Array.from(Be(e.length));return me([n,e],n.length+e.length)}function st(r){let e=Le(r);if(r=r.slice(ne(e)),r.length!==e)throw new Error("inconsistent lengths");return _(r)}function Ao(r){let e;r[0]==="Q"||r[0]==="1"?e=Ae(P.decode(`z${r}`)).bytes:e=Y.parse(r).multihash.bytes;let n=Uint8Array.from(Be(e.length));return me([n,e],n.length+e.length)}function Uo(r){let e=xo.decode(r),n=Uint8Array.from(Be(e.length));return me([n,e],n.length+e.length)}function So(r){let e=Le(r),n=r.slice(ne(e));if(n.length!==e)throw new Error("inconsistent lengths");return"u"+_(n,"base64url")}function Lo(r){let e=Le(r),n=r.slice(ne(e));if(n.length!==e)throw new Error("inconsistent lengths");return _(n,"base58btc")}function bo(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let n=ge.decode("b"+e[0]),t=parseInt(e[1],10);if(t<1||t>65536)throw new Error("Port number is not in range(1, 65536)");let i=Zr(t);return me([n,i],n.length+i.length)}function Co(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let n=ge.decode(`b${e[0]}`),t=parseInt(e[1],10);if(t<1||t>65536)throw new Error("Port number is not in range(1, 65536)");let i=Zr(t);return me([n,i],n.length+i.length)}function at(r){let e=r.slice(0,r.length-2),n=r.slice(r.length-2),t=_(e,"base32"),i=dt(n);return`${t}:${i}`}function lt(r){r=fr(r);let e=[],n=[],t=null,i=r.split("/").slice(1);if(i.length===1&&i[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<i.length;o++){let c=i[o],h=A(c);if(h.size===0){e.push([h.code]),n.push([h.code]);continue}if(o++,o>=i.length)throw ht("invalid address: "+r);if(h.path===!0){t=fr(i.slice(o).join("/")),e.push([h.code,Jr(h.code,t)]),n.push([h.code,t]);break}let a=Jr(h.code,i[o]);e.push([h.code,a]),n.push([h.code,Wr(h.code,a)])}return{string:ut(n),bytes:rn(e),tuples:e,stringTuples:n,path:t}}function en(r){let e=[],n=[],t=null,i=0;for(;i<r.length;){let o=Le(r,i),c=ne(o),h=A(o),a=Oo(h,r.slice(i+c));if(a===0){e.push([o]),n.push([o]),i+=c;continue}let d=r.slice(i+c,i+c+a);if(i+=a+c,i>r.length)throw ht("Invalid address Uint8Array: "+_(r,"base16"));e.push([o,d]);let m=Wr(o,d);if(n.push([o,m]),h.path===!0){t=m;break}}return{bytes:Uint8Array.from(r),string:ut(n),tuples:e,stringTuples:n,path:t}}function ut(r){let e=[];return r.map(n=>{let t=A(n[0]);return e.push(t.name),n.length>1&&n[1]!=null&&e.push(n[1]),null}),fr(e.join("/"))}function rn(r){return me(r.map(e=>{let n=A(e[0]),t=Uint8Array.from(Be(n.code));return e.length>1&&e[1]!=null&&(t=me([t,e[1]])),t}))}function Oo(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let n=Le(e instanceof Uint8Array?e:Uint8Array.from(e));return n+ne(n)}}function fr(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function ht(r){return new Error("Error parsing address: "+r)}var To=Symbol.for("nodejs.util.inspect.custom"),nn=Symbol.for("@multiformats/js-multiaddr/multiaddr"),No=[A("dns").code,A("dns4").code,A("dns6").code,A("dnsaddr").code],nr=class r{bytes;#e;#r;#n;#t;[nn]=!0;constructor(e){e==null&&(e="");let n;if(e instanceof Uint8Array)n=en(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);n=lt(e)}else if(gt(e))n=en(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=n.bytes,this.#e=n.string,this.#r=n.tuples,this.#n=n.stringTuples,this.#t=n.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,n,t,i,o="",c=A("tcp"),h=A("udp"),a=A("ip4"),d=A("ip6"),m=A("dns6"),l=A("ip6zone");for(let[p,s]of this.stringTuples())p===l.code&&(o=`%${s??""}`),No.includes(p)&&(n=c.name,i=443,t=`${s??""}${o}`,e=p===m.code?6:4),(p===c.code||p===h.code)&&(n=A(p).name,i=parseInt(s??"")),(p===a.code||p===d.code)&&(n=A(p).name,t=`${s??""}${o}`,e=p===d.code?6:4);if(e==null||n==null||t==null||i==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:t,transport:n,port:i}}protos(){return this.#r.map(([e])=>Object.assign({},A(e)))}protoCodes(){return this.#r.map(([e])=>e)}protoNames(){return this.#r.map(([e])=>A(e).name)}tuples(){return this.#r}stringTuples(){return this.#n}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let n=e.toString(),t=this.toString(),i=t.lastIndexOf(n);if(i<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(t.slice(0,i))}decapsulateCode(e){let n=this.tuples();for(let t=n.length-1;t>=0;t--)if(n[t][0]===e)return new r(rn(n.slice(0,t)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([t,i])=>{t===De.p2p.code&&e.push([t,i]),t===De["p2p-circuit"].code&&(e=[])});let n=e.pop();if(n?.[1]!=null){let t=n[1];return t[0]==="Q"||t[0]==="1"?_(P.decode(`z${t}`),"base58btc"):_(Y.parse(t).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#t}equals(e){return Me(this.bytes,e.bytes)}async resolve(e){let n=this.protos().find(o=>o.resolvable);if(n==null)return[this];let t=pt.get(n.name);if(t==null)throw new Xe(`no available resolver for ${n.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await t(this,e)).map(o=>new r(o))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let n=(e??this).protos();return!(n.length!==2||n[0].code!==4&&n[0].code!==41||n[1].code!==6&&n[1].code!==273)}[To](){return`Multiaddr(${this.#e})`}};var pt=new Map;function gt(r){return!!r?.[nn]}function tn(r){return new nr(r)}function mt(r,e,n,t){let i=()=>{t?.log.trace("query",e),r.query({questions:[{name:e,type:"PTR"}]})};return i(),setInterval(i,n)}function yt(r,e,n,t){if(r.answers==null)return;let i,o=[];if(r.answers.forEach(c=>{switch(c.type){case"PTR":i=c;break;case"TXT":o.push(c);break;default:break}}),r.additionals.forEach(c=>{switch(c.type){case"TXT":o.push(c);break;default:break}}),!(i==null||i?.name!==n||o.length===0||i.data.startsWith(e)))try{let c=o.flatMap(a=>a.data).filter(a=>a.toString().startsWith("dnsaddr=")).map(a=>tn(a.toString().substring(8))),h=c[0].getPeerId();if(h==null)throw new Error("Multiaddr doesn't contain PeerId");return t?.log("peer found %p",h),{id:qr(h),multiaddrs:c.map(a=>a.decapsulateCode(A("p2p").code))}}catch(c){t?.log.error("failed to parse mdns response",c)}}function wt(r,e,n,t,i,o,c){if(!o){c?.log("not responding to mDNS query as broadcast mode is false");return}if(t.length!==0&&r.questions[0]!=null&&r.questions[0].name===i){let h=[];h.push({name:i,type:"PTR",class:"IN",ttl:120,data:n+"."+i}),t.filter(Po).forEach(a=>{let d="dnsaddr="+a.toString();if(d.length>255){c?.log("multiaddr %a is too long to use in mDNS query response",a);return}if(a.getPeerId()==null){c?.log("multiaddr %a did not have a peer ID so cannot be used in mDNS query response",a);return}h.push({name:n+"."+i,type:"TXT",class:"IN",ttl:120,data:d})}),c?.log.trace("responding to query"),e.respond(h)}}function Po(r){return!!Jn(r)}function Et(r){let e="",n="abcdefghijklmnopqrstuvwxyz0123456789";for(let t=0;t<r;t++)e+=n.charAt(Math.floor(Math.random()*n.length));return e}var tr=class extends Ye{mdns;log;broadcast;interval;serviceTag;peerName;port;ip;_queryInterval;components;constructor(e,n={}){if(super(),this.log=e.logger.forComponent("libp2p:mdns"),this.broadcast=n.broadcast!==!1,this.interval=n.interval??1e3*10,this.serviceTag=n.serviceTag??"_p2p._udp.local",this.ip=n.ip??"224.0.0.251",this.peerName=n.peerName??Et(63),this.peerName.length>=64)throw new Error("Peer name should be less than 64 chars long");this.port=n.port??5353,this.components=e,this._queryInterval=null,this._onMdnsQuery=this._onMdnsQuery.bind(this),this._onMdnsResponse=this._onMdnsResponse.bind(this),this._onMdnsWarning=this._onMdnsWarning.bind(this),this._onMdnsError=this._onMdnsError.bind(this)}[cn]=this;[Symbol.toStringTag]="@libp2p/mdns";isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,It.default)({port:this.port,ip:this.ip}),this.mdns.on("query",this._onMdnsQuery),this.mdns.on("response",this._onMdnsResponse),this.mdns.on("warning",this._onMdnsWarning),this.mdns.on("error",this._onMdnsError),this._queryInterval=mt(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),wt(e,this.mdns,this.peerName,this.components.addressManager.getAddresses(),this.serviceTag,this.broadcast,{log:this.log}))}_onMdnsResponse(e){this.log.trace("received mDNS query response");try{let n=yt(e,this.peerName,this.serviceTag,{log:this.log});n!=null&&(this.log("discovered peer in mDNS query response %p",n.id),this.dispatchEvent(new cr("peer",{detail:n})))}catch(n){this.log.error("Error processing peer response",n)}}_onMdnsWarning(e){this.log.error("mdns warning",e)}_onMdnsError(e){this.log.error("mdns error",e)}async stop(){this.mdns!=null&&(this.mdns.removeListener("query",this._onMdnsQuery),this.mdns.removeListener("response",this._onMdnsResponse),this.mdns.removeListener("warning",this._onMdnsWarning),this.mdns.removeListener("error",this._onMdnsError),this._queryInterval!=null&&(clearInterval(this._queryInterval),this._queryInterval=null),await new Promise(e=>{this.mdns!=null?this.mdns.destroy(e):e()}),this.mdns=void 0)}};function Do(r={}){return e=>new tr(e,r)}return Lt(Fo);})();
3
3
  return Libp2PMdns}));
@@ -3,75 +3,75 @@
3
3
  *
4
4
  * A peer discover mechanism that uses [mDNS](https://datatracker.ietf.org/doc/html/rfc6762) to discover peers on the local network.
5
5
  *
6
- * @example
6
+ * @example Use with libp2p
7
7
  *
8
8
  * ```TypeScript
9
+ * import { createLibp2p } from 'libp2p'
9
10
  * import { mdns } from '@libp2p/mdns'
10
11
  *
11
- * const options = {
12
+ * const libp2p = await createLibp2p({
12
13
  * peerDiscovery: [
13
14
  * mdns()
14
15
  * ]
15
- * }
16
- *
17
- * const libp2p = await createLibp2p(options)
18
- *
19
- * libp2p.on('peer:discovery', function (peerId) {
20
- * console.log('found peer: ', peerId.toB58String())
21
16
  * })
22
17
  *
23
- * await libp2p.start()
18
+ * libp2p.addEventListener('peer:discovery', (evt) => {
19
+ * console.log('found peer: ', evt.detail.toString())
20
+ * })
24
21
  * ```
25
22
  *
26
23
  * ## MDNS messages
27
24
  *
28
25
  * A query is sent to discover the libp2p nodes on the local network
29
26
  *
30
- * ```js
27
+ * ```JSON
31
28
  * {
32
- * type: 'query',
33
- * questions: [ { name: '_p2p._udp.local', type: 'PTR' } ]
29
+ * "type": "query",
30
+ * "questions": [{
31
+ * "name": "_p2p._udp.local",
32
+ * "type": "PTR"
33
+ * }]
34
34
  * }
35
35
  * ```
36
36
  *
37
37
  * When a query is detected, each libp2p node sends an answer about itself
38
38
  *
39
- * ```js
39
+ * ```JSON
40
40
  * [{
41
- * name: '_p2p._udp.local',
42
- * type: 'PTR',
43
- * class: 'IN',
44
- * ttl: 120,
45
- * data: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local'
41
+ * "name": "_p2p._udp.local",
42
+ * "type": "PTR",
43
+ * "class": "IN",
44
+ * "ttl": 120,
45
+ * "data": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local"
46
46
  * }, {
47
- * name: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local',
48
- * type: 'SRV',
49
- * class: 'IN',
50
- * ttl: 120,
51
- * data: {
52
- * priority: 10,
53
- * weight: 1,
54
- * port: '20002',
55
- * target: 'LAPTOP-G5LJ7VN9'
47
+ * "name": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local",
48
+ * "type": "SRV",
49
+ * "class": "IN",
50
+ * "ttl": 120,
51
+ * "data": {
52
+ * "priority": 10,
53
+ * "weight": 1,
54
+ * "port": "20002",
55
+ * "target": "LAPTOP-G5LJ7VN9"
56
56
  * }
57
57
  * }, {
58
- * name: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local',
59
- * type: 'TXT',
60
- * class: 'IN',
61
- * ttl: 120,
62
- * data: ['QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK']
58
+ * "name": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local",
59
+ * "type": "TXT",
60
+ * "class": "IN",
61
+ * "ttl": 120,
62
+ * "data": ["QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK"]
63
63
  * }, {
64
- * name: 'LAPTOP-G5LJ7VN9',
65
- * type: 'A',
66
- * class: 'IN',
67
- * ttl: 120,
68
- * data: '127.0.0.1'
64
+ * "name": "LAPTOP-G5LJ7VN9",
65
+ * "type": "A",
66
+ * "class": "IN",
67
+ * "ttl": 120,
68
+ * "data": "127.0.0.1"
69
69
  * }, {
70
- * name: 'LAPTOP-G5LJ7VN9',
71
- * type: 'AAAA',
72
- * class: 'IN',
73
- * ttl: 120,
74
- * data: '::1'
70
+ * "name": "LAPTOP-G5LJ7VN9",
71
+ * "type": "AAAA",
72
+ * "class": "IN",
73
+ * "ttl": 120,
74
+ * "data": "::1"
75
75
  * }]
76
76
  * ```
77
77
  */
package/dist/src/index.js CHANGED
@@ -3,75 +3,75 @@
3
3
  *
4
4
  * A peer discover mechanism that uses [mDNS](https://datatracker.ietf.org/doc/html/rfc6762) to discover peers on the local network.
5
5
  *
6
- * @example
6
+ * @example Use with libp2p
7
7
  *
8
8
  * ```TypeScript
9
+ * import { createLibp2p } from 'libp2p'
9
10
  * import { mdns } from '@libp2p/mdns'
10
11
  *
11
- * const options = {
12
+ * const libp2p = await createLibp2p({
12
13
  * peerDiscovery: [
13
14
  * mdns()
14
15
  * ]
15
- * }
16
- *
17
- * const libp2p = await createLibp2p(options)
18
- *
19
- * libp2p.on('peer:discovery', function (peerId) {
20
- * console.log('found peer: ', peerId.toB58String())
21
16
  * })
22
17
  *
23
- * await libp2p.start()
18
+ * libp2p.addEventListener('peer:discovery', (evt) => {
19
+ * console.log('found peer: ', evt.detail.toString())
20
+ * })
24
21
  * ```
25
22
  *
26
23
  * ## MDNS messages
27
24
  *
28
25
  * A query is sent to discover the libp2p nodes on the local network
29
26
  *
30
- * ```js
27
+ * ```JSON
31
28
  * {
32
- * type: 'query',
33
- * questions: [ { name: '_p2p._udp.local', type: 'PTR' } ]
29
+ * "type": "query",
30
+ * "questions": [{
31
+ * "name": "_p2p._udp.local",
32
+ * "type": "PTR"
33
+ * }]
34
34
  * }
35
35
  * ```
36
36
  *
37
37
  * When a query is detected, each libp2p node sends an answer about itself
38
38
  *
39
- * ```js
39
+ * ```JSON
40
40
  * [{
41
- * name: '_p2p._udp.local',
42
- * type: 'PTR',
43
- * class: 'IN',
44
- * ttl: 120,
45
- * data: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local'
41
+ * "name": "_p2p._udp.local",
42
+ * "type": "PTR",
43
+ * "class": "IN",
44
+ * "ttl": 120,
45
+ * "data": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local"
46
46
  * }, {
47
- * name: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local',
48
- * type: 'SRV',
49
- * class: 'IN',
50
- * ttl: 120,
51
- * data: {
52
- * priority: 10,
53
- * weight: 1,
54
- * port: '20002',
55
- * target: 'LAPTOP-G5LJ7VN9'
47
+ * "name": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local",
48
+ * "type": "SRV",
49
+ * "class": "IN",
50
+ * "ttl": 120,
51
+ * "data": {
52
+ * "priority": 10,
53
+ * "weight": 1,
54
+ * "port": "20002",
55
+ * "target": "LAPTOP-G5LJ7VN9"
56
56
  * }
57
57
  * }, {
58
- * name: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local',
59
- * type: 'TXT',
60
- * class: 'IN',
61
- * ttl: 120,
62
- * data: ['QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK']
58
+ * "name": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local",
59
+ * "type": "TXT",
60
+ * "class": "IN",
61
+ * "ttl": 120,
62
+ * "data": ["QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK"]
63
63
  * }, {
64
- * name: 'LAPTOP-G5LJ7VN9',
65
- * type: 'A',
66
- * class: 'IN',
67
- * ttl: 120,
68
- * data: '127.0.0.1'
64
+ * "name": "LAPTOP-G5LJ7VN9",
65
+ * "type": "A",
66
+ * "class": "IN",
67
+ * "ttl": 120,
68
+ * "data": "127.0.0.1"
69
69
  * }, {
70
- * name: 'LAPTOP-G5LJ7VN9',
71
- * type: 'AAAA',
72
- * class: 'IN',
73
- * ttl: 120,
74
- * data: '::1'
70
+ * "name": "LAPTOP-G5LJ7VN9",
71
+ * "type": "AAAA",
72
+ * "class": "IN",
73
+ * "ttl": 120,
74
+ * "data": "::1"
75
75
  * }]
76
76
  * ```
77
77
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/mdns",
3
- "version": "10.0.15",
3
+ "version": "10.0.16-28e51652a",
4
4
  "description": "Node.js libp2p mDNS discovery implementation for peer discovery",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-mdns#readme",
@@ -43,26 +43,27 @@
43
43
  "clean": "aegir clean",
44
44
  "lint": "aegir lint",
45
45
  "dep-check": "aegir dep-check",
46
+ "doc-check": "aegir doc-check",
46
47
  "build": "aegir build",
47
48
  "test": "aegir test -t node",
48
49
  "test:node": "aegir test -t node --cov",
49
50
  "test:electron-main": "aegir test -t electron-main"
50
51
  },
51
52
  "dependencies": {
52
- "@libp2p/interface": "^1.1.3",
53
- "@libp2p/interface-internal": "^1.0.8",
54
- "@libp2p/peer-id": "^4.0.6",
55
- "@libp2p/utils": "^5.2.5",
53
+ "@libp2p/interface": "1.1.4-28e51652a",
54
+ "@libp2p/interface-internal": "1.0.9-28e51652a",
55
+ "@libp2p/peer-id": "4.0.7-28e51652a",
56
+ "@libp2p/utils": "5.2.6-28e51652a",
56
57
  "@multiformats/multiaddr": "^12.1.14",
57
58
  "@types/multicast-dns": "^7.2.4",
58
59
  "dns-packet": "^5.6.1",
59
60
  "multicast-dns": "^7.2.5"
60
61
  },
61
62
  "devDependencies": {
62
- "@libp2p/interface-compliance-tests": "^5.3.1",
63
- "@libp2p/logger": "^4.0.6",
64
- "@libp2p/peer-id-factory": "^4.0.6",
65
- "aegir": "^42.2.3",
63
+ "@libp2p/interface-compliance-tests": "5.3.2-28e51652a",
64
+ "@libp2p/logger": "4.0.7-28e51652a",
65
+ "@libp2p/peer-id-factory": "4.0.7-28e51652a",
66
+ "aegir": "^42.2.4",
66
67
  "p-wait-for": "^5.0.2",
67
68
  "sinon-ts": "^2.0.0"
68
69
  },
package/src/index.ts CHANGED
@@ -3,75 +3,75 @@
3
3
  *
4
4
  * A peer discover mechanism that uses [mDNS](https://datatracker.ietf.org/doc/html/rfc6762) to discover peers on the local network.
5
5
  *
6
- * @example
6
+ * @example Use with libp2p
7
7
  *
8
8
  * ```TypeScript
9
+ * import { createLibp2p } from 'libp2p'
9
10
  * import { mdns } from '@libp2p/mdns'
10
11
  *
11
- * const options = {
12
+ * const libp2p = await createLibp2p({
12
13
  * peerDiscovery: [
13
14
  * mdns()
14
15
  * ]
15
- * }
16
- *
17
- * const libp2p = await createLibp2p(options)
18
- *
19
- * libp2p.on('peer:discovery', function (peerId) {
20
- * console.log('found peer: ', peerId.toB58String())
21
16
  * })
22
17
  *
23
- * await libp2p.start()
18
+ * libp2p.addEventListener('peer:discovery', (evt) => {
19
+ * console.log('found peer: ', evt.detail.toString())
20
+ * })
24
21
  * ```
25
22
  *
26
23
  * ## MDNS messages
27
24
  *
28
25
  * A query is sent to discover the libp2p nodes on the local network
29
26
  *
30
- * ```js
27
+ * ```JSON
31
28
  * {
32
- * type: 'query',
33
- * questions: [ { name: '_p2p._udp.local', type: 'PTR' } ]
29
+ * "type": "query",
30
+ * "questions": [{
31
+ * "name": "_p2p._udp.local",
32
+ * "type": "PTR"
33
+ * }]
34
34
  * }
35
35
  * ```
36
36
  *
37
37
  * When a query is detected, each libp2p node sends an answer about itself
38
38
  *
39
- * ```js
39
+ * ```JSON
40
40
  * [{
41
- * name: '_p2p._udp.local',
42
- * type: 'PTR',
43
- * class: 'IN',
44
- * ttl: 120,
45
- * data: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local'
41
+ * "name": "_p2p._udp.local",
42
+ * "type": "PTR",
43
+ * "class": "IN",
44
+ * "ttl": 120,
45
+ * "data": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local"
46
46
  * }, {
47
- * name: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local',
48
- * type: 'SRV',
49
- * class: 'IN',
50
- * ttl: 120,
51
- * data: {
52
- * priority: 10,
53
- * weight: 1,
54
- * port: '20002',
55
- * target: 'LAPTOP-G5LJ7VN9'
47
+ * "name": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local",
48
+ * "type": "SRV",
49
+ * "class": "IN",
50
+ * "ttl": 120,
51
+ * "data": {
52
+ * "priority": 10,
53
+ * "weight": 1,
54
+ * "port": "20002",
55
+ * "target": "LAPTOP-G5LJ7VN9"
56
56
  * }
57
57
  * }, {
58
- * name: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local',
59
- * type: 'TXT',
60
- * class: 'IN',
61
- * ttl: 120,
62
- * data: ['QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK']
58
+ * "name": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local",
59
+ * "type": "TXT",
60
+ * "class": "IN",
61
+ * "ttl": 120,
62
+ * "data": ["QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK"]
63
63
  * }, {
64
- * name: 'LAPTOP-G5LJ7VN9',
65
- * type: 'A',
66
- * class: 'IN',
67
- * ttl: 120,
68
- * data: '127.0.0.1'
64
+ * "name": "LAPTOP-G5LJ7VN9",
65
+ * "type": "A",
66
+ * "class": "IN",
67
+ * "ttl": 120,
68
+ * "data": "127.0.0.1"
69
69
  * }, {
70
- * name: 'LAPTOP-G5LJ7VN9',
71
- * type: 'AAAA',
72
- * class: 'IN',
73
- * ttl: 120,
74
- * data: '::1'
70
+ * "name": "LAPTOP-G5LJ7VN9",
71
+ * "type": "AAAA",
72
+ * "class": "IN",
73
+ * "ttl": 120,
74
+ * "data": "::1"
75
75
  * }]
76
76
  * ```
77
77
  */
@@ -1,4 +0,0 @@
1
- {
2
- "mdns": "https://libp2p.github.io/js-libp2p/functions/_libp2p_mdns.mdns.html",
3
- ".:mdns": "https://libp2p.github.io/js-libp2p/functions/_libp2p_mdns.mdns.html"
4
- }