@libp2p/mdns 10.1.4 → 10.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/package.json +8 -8
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 Tn=Object.create;var Ye=Object.defineProperty;var Nn=Object.getOwnPropertyDescriptor;var Pn=Object.getOwnPropertyNames;var Dn=Object.getPrototypeOf,Bn=Object.prototype.hasOwnProperty;var j=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var W=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),k=(r,e)=>{for(var t in e)Ye(r,t,{get:e[t],enumerable:!0})},lt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Pn(e))!Bn.call(r,i)&&i!==t&&Ye(r,i,{get:()=>e[i],enumerable:!(n=Nn(e,i))||n.enumerable});return r};var cr=(r,e,t)=>(t=r!=null?Tn(Dn(r)):{},lt(e||!r||!r.__esModule?Ye(t,"default",{value:r,enumerable:!0}):t,r)),Fn=r=>lt(Ye({},"__esModule",{value:!0}),r);var mt=W(lr=>{"use strict";lr.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};lr.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 yt=W(ur=>{"use strict";ur.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};ur.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 wt=W(hr=>{"use strict";hr.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};hr.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 Et=W(pr=>{"use strict";pr.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};pr.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 It=W(gr=>{"use strict";gr.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}`};gr.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 At=W((vt,mr)=>{var xt=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}$/,t=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,i=16,o={name:"v4",size:t,isFormat:u=>e.test(u),encode(u,p,s){s=~~s,p=p||new Uint8Array(s+t);let y=u.length,v=0;for(let S=0;S<y;){let L=u.charCodeAt(S++);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&&n.test(u),encode(u,p,s){s=~~s;let y=s+i,v=-1,S=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]=S>>8),s<y-1&&(p[s+1]=S&255),s+=2),S=0,L=0),B=!0,T=!1):C===46?(s<y&&(p[s]=L),s++,L=0,S=0,B=!1,T=!0):(B=!1,C>=97?C-=87:C>=65?C-=55:(C-=48,L=L*10+C),S=(S<<4)+C)}if(B===!1)T===!0?(s<y&&(p[s]=L),s++):(s<y&&(p[s]=S>>8),s<y-1&&(p[s+1]=S&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 xt}):typeof mr=="object"&&typeof vt=="object"&&(mr.exports=xt)});var Lt=W(w=>{"use strict";var E=j("buffer").Buffer,ge=mt(),Rn=yt(),_n=wt(),Je=Et(),yr=It(),ve=At(),kn=0,St=32768,wr=32768,Mn=~wr,Ut=32768,zn=~Ut,g=w.name={};g.encode=function(r,e,t,{mail:n=!1}={}){e||(e=E.alloc(g.encodingLength(r))),t||(t=0);let i=t,o=r.replace(/^\.|\.$/gm,"");if(o.length){let c=[];if(n){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],t+1);e[t]=a,t+=a+1}}return e[t++]=0,g.encode.bytes=t-i,e};g.encode.bytes=0;g.decode=function(r,e,{mail:t=!1}={}){e||(e=0);let n=[],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);t&&(d=d.replace(/\./g,"\\.")),n.push(d),e+=a,c+=h?0:a}}return g.decode.bytes=c,n.length===0?".":n.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,t){e||(e=E.alloc(I.encodingLength(r))),t||(t=0);let n=e.write(r,t+1);return e[t]=n,I.encode.bytes=n+1,e};I.encode.bytes=0;I.decode=function(r,e){e||(e=0);let t=r[e],n=r.toString("utf-8",e+1,e+1+t);return I.decode.bytes=t+1,n};I.decode.bytes=0;I.encodingLength=function(r){return E.byteLength(r)+1};var G={};G.encode=function(r,e,t){e||(e=G.encodingLength(r)),t||(t=0);let n=(r.flags||0)&32767,i=r.type==="response"?St:kn;return e.writeUInt16BE(r.id||0,t),e.writeUInt16BE(n|i,t+2),e.writeUInt16BE(r.questions.length,t+4),e.writeUInt16BE(r.answers.length,t+6),e.writeUInt16BE(r.authorities.length,t+8),e.writeUInt16BE(r.additionals.length,t+10),e};G.encode.bytes=12;G.decode=function(r,e){if(e||(e=0),r.length<12)throw new Error("Header must be 12 bytes");let t=r.readUInt16BE(e+2);return{id:r.readUInt16BE(e),type:t&St?"response":"query",flags:t&32767,flag_qr:(t>>15&1)===1,opcode:_n.toString(t>>11&15),flag_aa:(t>>10&1)===1,flag_tc:(t>>9&1)===1,flag_rd:(t>>8&1)===1,flag_ra:(t>>7&1)===1,flag_z:(t>>6&1)===1,flag_ad:(t>>5&1)===1,flag_cd:(t>>4&1)===1,rcode:Rn.toString(t&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))}};G.decode.bytes=12;G.encodingLength=function(){return 12};var oe=w.unknown={};oe.encode=function(r,e,t){return e||(e=E.alloc(oe.encodingLength(r))),t||(t=0),e.writeUInt16BE(r.length,t),r.copy(e,t+2),oe.encode.bytes=r.length+2,e};oe.encode.bytes=0;oe.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n=r.slice(e+2,e+2+t);return oe.decode.bytes=t+2,n};oe.decode.bytes=0;oe.encodingLength=function(r){return r.length+2};var ce=w.ns={};ce.encode=function(r,e,t){return e||(e=E.alloc(ce.encodingLength(r))),t||(t=0),g.encode(r,e,t+2),e.writeUInt16BE(g.encode.bytes,t),ce.encode.bytes=g.encode.bytes+2,e};ce.encode.bytes=0;ce.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n=g.decode(r,e+2);return ce.decode.bytes=t+2,n};ce.decode.bytes=0;ce.encodingLength=function(r){return g.encodingLength(r)+2};var se=w.soa={};se.encode=function(r,e,t){e||(e=E.alloc(se.encodingLength(r))),t||(t=0);let n=t;return t+=2,g.encode(r.mname,e,t),t+=g.encode.bytes,g.encode(r.rname,e,t,{mail:!0}),t+=g.encode.bytes,e.writeUInt32BE(r.serial||0,t),t+=4,e.writeUInt32BE(r.refresh||0,t),t+=4,e.writeUInt32BE(r.retry||0,t),t+=4,e.writeUInt32BE(r.expire||0,t),t+=4,e.writeUInt32BE(r.minimum||0,t),t+=4,e.writeUInt16BE(t-n-2,n),se.encode.bytes=t-n,e};se.encode.bytes=0;se.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.mname=g.decode(r,e),e+=g.decode.bytes,n.rname=g.decode(r,e,{mail:!0}),e+=g.decode.bytes,n.serial=r.readUInt32BE(e),e+=4,n.refresh=r.readUInt32BE(e),e+=4,n.retry=r.readUInt32BE(e),e+=4,n.expire=r.readUInt32BE(e),e+=4,n.minimum=r.readUInt32BE(e),e+=4,se.decode.bytes=e-t,n};se.decode.bytes=0;se.encodingLength=function(r){return 22+g.encodingLength(r.mname)+g.encodingLength(r.rname)};var ae=w.txt={};ae.encode=function(r,e,t){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(ae.encodingLength(r))),t||(t=0);let n=t;return t+=2,r.forEach(function(i){e[t++]=i.length,i.copy(e,t,0,i.length),t+=i.length}),e.writeUInt16BE(t-n-2,n),ae.encode.bytes=t-n,e};ae.encode.bytes=0;ae.decode=function(r,e){e||(e=0);let t=e,n=r.readUInt16BE(e);e+=2;let i=[];for(;n>0;){let o=r[e++];if(--n,n<o)throw new Error("Buffer overflow");i.push(r.slice(e,e+o)),e+=o,n-=o}return ae.decode.bytes=e-t,i};ae.decode.bytes=0;ae.encodingLength=function(r){Array.isArray(r)||(r=[r]);let e=2;return r.forEach(function(t){typeof t=="string"?e+=E.byteLength(t)+1:e+=t.length+1}),e};var de=w.null={};de.encode=function(r,e,t){e||(e=E.alloc(de.encodingLength(r))),t||(t=0),typeof r=="string"&&(r=E.from(r)),r||(r=E.alloc(0));let n=t;t+=2;let i=r.length;return r.copy(e,t,0,i),t+=i,e.writeUInt16BE(t-n-2,n),de.encode.bytes=t-n,e};de.encode.bytes=0;de.decode=function(r,e){e||(e=0);let t=e,n=r.readUInt16BE(e);e+=2;let i=r.slice(e,e+n);return e+=n,de.decode.bytes=e-t,i};de.decode.bytes=0;de.encodingLength=function(r){return r?(E.isBuffer(r)?r.length:E.byteLength(r))+2:2};var le=w.hinfo={};le.encode=function(r,e,t){e||(e=E.alloc(le.encodingLength(r))),t||(t=0);let n=t;return t+=2,I.encode(r.cpu,e,t),t+=I.encode.bytes,I.encode(r.os,e,t),t+=I.encode.bytes,e.writeUInt16BE(t-n-2,n),le.encode.bytes=t-n,e};le.encode.bytes=0;le.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.cpu=I.decode(r,e),e+=I.decode.bytes,n.os=I.decode(r,e),e+=I.decode.bytes,le.decode.bytes=e-t,n};le.decode.bytes=0;le.encodingLength=function(r){return I.encodingLength(r.cpu)+I.encodingLength(r.os)+2};var X=w.ptr={},$n=w.cname=X,qn=w.dname=X;X.encode=function(r,e,t){return e||(e=E.alloc(X.encodingLength(r))),t||(t=0),g.encode(r,e,t+2),e.writeUInt16BE(g.encode.bytes,t),X.encode.bytes=g.encode.bytes+2,e};X.encode.bytes=0;X.decode=function(r,e){e||(e=0);let t=g.decode(r,e+2);return X.decode.bytes=g.decode.bytes+2,t};X.decode.bytes=0;X.encodingLength=function(r){return g.encodingLength(r)+2};var ue=w.srv={};ue.encode=function(r,e,t){e||(e=E.alloc(ue.encodingLength(r))),t||(t=0),e.writeUInt16BE(r.priority||0,t+2),e.writeUInt16BE(r.weight||0,t+4),e.writeUInt16BE(r.port||0,t+6),g.encode(r.target,e,t+8);let n=g.encode.bytes+6;return e.writeUInt16BE(n,t),ue.encode.bytes=n+2,e};ue.encode.bytes=0;ue.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n={};return n.priority=r.readUInt16BE(e+2),n.weight=r.readUInt16BE(e+4),n.port=r.readUInt16BE(e+6),n.target=g.decode(r,e+8),ue.decode.bytes=t+2,n};ue.decode.bytes=0;ue.encodingLength=function(r){return 8+g.encodingLength(r.target)};var M=w.caa={};M.ISSUER_CRITICAL=128;M.encode=function(r,e,t){let n=M.encodingLength(r);return e||(e=E.alloc(M.encodingLength(r))),t||(t=0),r.issuerCritical&&(r.flags=M.ISSUER_CRITICAL),e.writeUInt16BE(n-2,t),t+=2,e.writeUInt8(r.flags||0,t),t+=1,I.encode(r.tag,e,t),t+=I.encode.bytes,e.write(r.value,t),t+=E.byteLength(r.value),M.encode.bytes=n,e};M.encode.bytes=0;M.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e);e+=2;let n=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,n+t),i.issuerCritical=!!(i.flags&M.ISSUER_CRITICAL),M.decode.bytes=t+2,i};M.decode.bytes=0;M.encodingLength=function(r){return I.encodingLength(r.tag)+I.encodingLength(r.value)+2};var we=w.mx={};we.encode=function(r,e,t){e||(e=E.alloc(we.encodingLength(r))),t||(t=0);let n=t;return t+=2,e.writeUInt16BE(r.preference||0,t),t+=2,g.encode(r.exchange,e,t),t+=g.encode.bytes,e.writeUInt16BE(t-n-2,n),we.encode.bytes=t-n,e};we.encode.bytes=0;we.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.preference=r.readUInt16BE(e),e+=2,n.exchange=g.decode(r,e),e+=g.decode.bytes,we.decode.bytes=e-t,n};we.encodingLength=function(r){return 4+g.encodingLength(r.exchange)};var he=w.a={};he.encode=function(r,e,t){return e||(e=E.alloc(he.encodingLength(r))),t||(t=0),e.writeUInt16BE(4,t),t+=2,ve.v4.encode(r,e,t),he.encode.bytes=6,e};he.encode.bytes=0;he.decode=function(r,e){e||(e=0),e+=2;let t=ve.v4.decode(r,e);return he.decode.bytes=6,t};he.decode.bytes=0;he.encodingLength=function(){return 6};var pe=w.aaaa={};pe.encode=function(r,e,t){return e||(e=E.alloc(pe.encodingLength(r))),t||(t=0),e.writeUInt16BE(16,t),t+=2,ve.v6.encode(r,e,t),pe.encode.bytes=18,e};pe.encode.bytes=0;pe.decode=function(r,e){e||(e=0),e+=2;let t=ve.v6.decode(r,e);return pe.decode.bytes=18,t};pe.decode.bytes=0;pe.encodingLength=function(){return 18};var _=w.option={};_.encode=function(r,e,t){e||(e=E.alloc(_.encodingLength(r))),t||(t=0);let n=t,i=yr.toCode(r.code);if(e.writeUInt16BE(i,t),t+=2,r.data)e.writeUInt16BE(r.data.length,t),t+=2,r.data.copy(e,t),t+=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,t),t+=2,e.writeUInt16BE(c,t),t+=2,e.writeUInt8(o,t++),e.writeUInt8(r.scopePrefixLength||0,t++),h.copy(e,t,0,a),t+=a;break;case 11:r.timeout?(e.writeUInt16BE(2,t),t+=2,e.writeUInt16BE(r.timeout,t),t+=2):(e.writeUInt16BE(0,t),t+=2);break;case 12:let d=r.length||0;e.writeUInt16BE(d,t),t+=2,e.fill(0,t,t+d),t+=d;break;case 14:let m=r.tags.length*2;e.writeUInt16BE(m,t),t+=2;for(let l of r.tags)e.writeUInt16BE(l,t),t+=2;break;default:throw new Error(`Unknown roption code: ${r.code}`)}return _.encode.bytes=t-n,e};_.encode.bytes=0;_.decode=function(r,e){e||(e=0);let t={};t.code=r.readUInt16BE(e),t.type=yr.toString(t.code),e+=2;let n=r.readUInt16BE(e);switch(e+=2,t.data=r.slice(e,e+n),t.code){case 8:t.family=r.readUInt16BE(e),e+=2,t.sourcePrefixLength=r.readUInt8(e++),t.scopePrefixLength=r.readUInt8(e++);let i=E.alloc(t.family===1?4:16);r.copy(i,0,e,e+n-4),t.ip=ve.decode(i);break;case 11:n>0&&(t.timeout=r.readUInt16BE(e),e+=2);break;case 14:t.tags=[];for(let o=0;o<n;o+=2)t.tags.push(r.readUInt16BE(e)),e+=2}return _.decode.bytes=n+4,t};_.decode.bytes=0;_.encodingLength=function(r){if(r.data)return r.data.length+4;switch(yr.toCode(r.code)){case 8:let t=r.sourcePrefixLength||0;return Math.ceil(t/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 $=w.opt={};$.encode=function(r,e,t){e||(e=E.alloc($.encodingLength(r))),t||(t=0);let n=t,i=Le(r,_);return e.writeUInt16BE(i,t),t=Be(r,_,e,t+2),$.encode.bytes=t-n,e};$.encode.bytes=0;$.decode=function(r,e){e||(e=0);let t=e,n=[],i=r.readUInt16BE(e);e+=2;let o=0;for(;i>0;)n[o++]=_.decode(r,e),e+=_.decode.bytes,i-=_.decode.bytes;return $.decode.bytes=e-t,n};$.decode.bytes=0;$.encodingLength=function(r){return 2+Le(r||[],_)};var R=w.dnskey={};R.PROTOCOL_DNSSEC=3;R.ZONE_KEY=128;R.SECURE_ENTRYPOINT=32768;R.encode=function(r,e,t){e||(e=E.alloc(R.encodingLength(r))),t||(t=0);let n=t,i=r.key;if(!E.isBuffer(i))throw new Error("Key must be a Buffer");return t+=2,e.writeUInt16BE(r.flags,t),t+=2,e.writeUInt8(R.PROTOCOL_DNSSEC,t),t+=1,e.writeUInt8(r.algorithm,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,R.encode.bytes=t-n,e.writeUInt16BE(R.encode.bytes-2,n),e};R.encode.bytes=0;R.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);if(e+=2,n.flags=r.readUInt16BE(e),e+=2,r.readUInt8(e)!==R.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=r.readUInt8(e),e+=1,n.key=r.slice(e,t+i+2),e+=n.key.length,R.decode.bytes=e-t,n};R.decode.bytes=0;R.encodingLength=function(r){return 6+E.byteLength(r.key)};var Q=w.rrsig={};Q.encode=function(r,e,t){e||(e=E.alloc(Q.encodingLength(r))),t||(t=0);let n=t,i=r.signature;if(!E.isBuffer(i))throw new Error("Signature must be a Buffer");return t+=2,e.writeUInt16BE(ge.toType(r.typeCovered),t),t+=2,e.writeUInt8(r.algorithm,t),t+=1,e.writeUInt8(r.labels,t),t+=1,e.writeUInt32BE(r.originalTTL,t),t+=4,e.writeUInt32BE(r.expiration,t),t+=4,e.writeUInt32BE(r.inception,t),t+=4,e.writeUInt16BE(r.keyTag,t),t+=2,g.encode(r.signersName,e,t),t+=g.encode.bytes,i.copy(e,t,0,i.length),t+=i.length,Q.encode.bytes=t-n,e.writeUInt16BE(Q.encode.bytes-2,n),e};Q.encode.bytes=0;Q.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.typeCovered=ge.toString(r.readUInt16BE(e)),e+=2,n.algorithm=r.readUInt8(e),e+=1,n.labels=r.readUInt8(e),e+=1,n.originalTTL=r.readUInt32BE(e),e+=4,n.expiration=r.readUInt32BE(e),e+=4,n.inception=r.readUInt32BE(e),e+=4,n.keyTag=r.readUInt16BE(e),e+=2,n.signersName=g.decode(r,e),e+=g.decode.bytes,n.signature=r.slice(e,t+i+2),e+=n.signature.length,Q.decode.bytes=e-t,n};Q.decode.bytes=0;Q.encodingLength=function(r){return 20+g.encodingLength(r.signersName)+E.byteLength(r.signature)};var J=w.rp={};J.encode=function(r,e,t){e||(e=E.alloc(J.encodingLength(r))),t||(t=0);let n=t;return t+=2,g.encode(r.mbox||".",e,t,{mail:!0}),t+=g.encode.bytes,g.encode(r.txt||".",e,t),t+=g.encode.bytes,J.encode.bytes=t-n,e.writeUInt16BE(J.encode.bytes-2,n),e};J.encode.bytes=0;J.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.mbox=g.decode(r,e,{mail:!0})||".",e+=g.decode.bytes,n.txt=g.decode(r,e)||".",e+=g.decode.bytes,J.decode.bytes=e-t,n};J.decode.bytes=0;J.encodingLength=function(r){return 2+g.encodingLength(r.mbox||".")+g.encodingLength(r.txt||".")};var O={};O.encode=function(r,e,t){e||(e=E.alloc(O.encodingLength(r))),t||(t=0);let n=t;for(var i=[],o=0;o<r.length;o++){var c=ge.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,t),t+=1,e.writeUInt8(h.length,t),t+=1,h.copy(e,t),t+=h.length}return O.encode.bytes=t-n,e};O.encode.bytes=0;O.decode=function(r,e,t){e||(e=0);let n=e;for(var i=[];e-n<t;){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=ge.toString(o<<8|h<<3|d);i.push(m)}e+=c}return O.decode.bytes=e-n,i};O.decode.bytes=0;O.encodingLength=function(r){for(var e=[],t=0;t<r.length;t++){var n=ge.toType(r[t]);e[n>>8]=Math.max(e[n>>8]||0,n&255)}var i=0;for(t=0;t<e.length;t++)e[t]!==void 0&&(i+=2+Math.ceil((e[t]+1)/8));return i};var Z=w.nsec={};Z.encode=function(r,e,t){e||(e=E.alloc(Z.encodingLength(r))),t||(t=0);let n=t;return t+=2,g.encode(r.nextDomain,e,t),t+=g.encode.bytes,O.encode(r.rrtypes,e,t),t+=O.encode.bytes,Z.encode.bytes=t-n,e.writeUInt16BE(Z.encode.bytes-2,n),e};Z.encode.bytes=0;Z.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.nextDomain=g.decode(r,e),e+=g.decode.bytes,n.rrtypes=O.decode(r,e,i-(e-t)),e+=O.decode.bytes,Z.decode.bytes=e-t,n};Z.decode.bytes=0;Z.encodingLength=function(r){return 2+g.encodingLength(r.nextDomain)+O.encodingLength(r.rrtypes)};var f=w.nsec3={};f.encode=function(r,e,t){e||(e=E.alloc(f.encodingLength(r))),t||(t=0);let n=t,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 t+=2,e.writeUInt8(r.algorithm,t),t+=1,e.writeUInt8(r.flags,t),t+=1,e.writeUInt16BE(r.iterations,t),t+=2,e.writeUInt8(i.length,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,e.writeUInt8(o.length,t),t+=1,o.copy(e,t,0,o.length),t+=o.length,O.encode(r.rrtypes,e,t),t+=O.encode.bytes,f.encode.bytes=t-n,e.writeUInt16BE(f.encode.bytes-2,n),e};f.encode.bytes=0;f.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);e+=2,n.algorithm=r.readUInt8(e),e+=1,n.flags=r.readUInt8(e),e+=1,n.iterations=r.readUInt16BE(e),e+=2;let o=r.readUInt8(e);e+=1,n.salt=r.slice(e,e+o),e+=o;let c=r.readUInt8(e);return e+=1,n.nextDomain=r.slice(e,e+c),e+=c,n.rrtypes=O.decode(r,e,i-(e-t)),e+=O.decode.bytes,f.decode.bytes=e-t,n};f.decode.bytes=0;f.encodingLength=function(r){return 8+r.salt.length+r.nextDomain.length+O.encodingLength(r.rrtypes)};var ee=w.ds={};ee.encode=function(r,e,t){e||(e=E.alloc(ee.encodingLength(r))),t||(t=0);let n=t,i=r.digest;if(!E.isBuffer(i))throw new Error("Digest must be a Buffer");return t+=2,e.writeUInt16BE(r.keyTag,t),t+=2,e.writeUInt8(r.algorithm,t),t+=1,e.writeUInt8(r.digestType,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,ee.encode.bytes=t-n,e.writeUInt16BE(ee.encode.bytes-2,n),e};ee.encode.bytes=0;ee.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.keyTag=r.readUInt16BE(e),e+=2,n.algorithm=r.readUInt8(e),e+=1,n.digestType=r.readUInt8(e),e+=1,n.digest=r.slice(e,t+i+2),e+=n.digest.length,ee.decode.bytes=e-t,n};ee.decode.bytes=0;ee.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,t,n){t||(t=E.alloc(z.encodingLength(e))),n||(n=0);let i=n;n+=2,t[n]=e.algorithm,n+=1,t[n]=e.hash,n+=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(t,n),n+=o.byteLength,z.encode.bytes=n-i,t.writeUInt16BE(z.encode.bytes-2,i),t};z.encode.bytes=0;z.decode=function(e,t){t||(t=0);let n=t,i={};t+=2,i.algorithm=e[t],t+=1,i.hash=e[t],t+=1;let o=z.getFingerprintLengthForHashType(i.hash);return i.fingerprint=e.slice(t,t+o).toString("hex").toUpperCase(),t+=o,z.decode.bytes=t-n,i};z.decode.bytes=0;z.encodingLength=function(r){return 4+E.from(r.fingerprint,"hex").byteLength};var re=w.naptr={};re.encode=function(r,e,t){e||(e=E.alloc(re.encodingLength(r))),t||(t=0);let n=t;return t+=2,e.writeUInt16BE(r.order||0,t),t+=2,e.writeUInt16BE(r.preference||0,t),t+=2,I.encode(r.flags,e,t),t+=I.encode.bytes,I.encode(r.services,e,t),t+=I.encode.bytes,I.encode(r.regexp,e,t),t+=I.encode.bytes,g.encode(r.replacement,e,t),t+=g.encode.bytes,re.encode.bytes=t-n,e.writeUInt16BE(re.encode.bytes-2,n),e};re.encode.bytes=0;re.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.order=r.readUInt16BE(e),e+=2,n.preference=r.readUInt16BE(e),e+=2,n.flags=I.decode(r,e),e+=I.decode.bytes,n.services=I.decode(r,e),e+=I.decode.bytes,n.regexp=I.decode(r,e),e+=I.decode.bytes,n.replacement=g.decode(r,e),e+=g.decode.bytes,re.decode.bytes=e-t,n};re.decode.bytes=0;re.encodingLength=function(r){return I.encodingLength(r.flags)+I.encodingLength(r.services)+I.encodingLength(r.regexp)+g.encodingLength(r.replacement)+6};var te=w.tlsa={};te.encode=function(r,e,t){e||(e=E.alloc(te.encodingLength(r))),t||(t=0);let n=t,i=r.certificate;if(!E.isBuffer(i))throw new Error("Certificate must be a Buffer");return t+=2,e.writeUInt8(r.usage,t),t+=1,e.writeUInt8(r.selector,t),t+=1,e.writeUInt8(r.matchingType,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,te.encode.bytes=t-n,e.writeUInt16BE(te.encode.bytes-2,n),e};te.encode.bytes=0;te.decode=function(r,e){e||(e=0);let t=e,n={},i=r.readUInt16BE(e);return e+=2,n.usage=r.readUInt8(e),e+=1,n.selector=r.readUInt8(e),e+=1,n.matchingType=r.readUInt8(e),e+=1,n.certificate=r.slice(e,t+i+2),e+=n.certificate.length,te.decode.bytes=e-t,n};te.decode.bytes=0;te.encodingLength=function(r){return 5+E.byteLength(r.certificate)};var Er=w.record=function(r){switch(r.toUpperCase()){case"A":return he;case"PTR":return X;case"CNAME":return $n;case"DNAME":return qn;case"TXT":return ae;case"NULL":return de;case"AAAA":return pe;case"SRV":return ue;case"HINFO":return le;case"CAA":return M;case"NS":return ce;case"SOA":return se;case"MX":return we;case"OPT":return $;case"DNSKEY":return R;case"RRSIG":return Q;case"RP":return J;case"NSEC":return Z;case"NSEC3":return f;case"SSHFP":return z;case"DS":return ee;case"NAPTR":return re;case"TLSA":return te}return oe},N=w.answer={};N.encode=function(r,e,t){e||(e=E.alloc(N.encodingLength(r))),t||(t=0);let n=t;if(g.encode(r.name,e,t),t+=g.encode.bytes,e.writeUInt16BE(ge.toType(r.type),t),r.type.toUpperCase()==="OPT"){if(r.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(r.udpPayloadSize||4096,t+2),e.writeUInt8(r.extendedRcode||0,t+4),e.writeUInt8(r.ednsVersion||0,t+5),e.writeUInt16BE(r.flags||0,t+6),t+=8,$.encode(r.options||[],e,t),t+=$.encode.bytes}else{let i=Je.toClass(r.class===void 0?"IN":r.class);r.flush&&(i|=wr),e.writeUInt16BE(i,t+2),e.writeUInt32BE(r.ttl||0,t+4),t+=8;let o=Er(r.type);o.encode(r.data,e,t),t+=o.encode.bytes}return N.encode.bytes=t-n,e};N.encode.bytes=0;N.decode=function(r,e){e||(e=0);let t={},n=e;if(t.name=g.decode(r,e),e+=g.decode.bytes,t.type=ge.toString(r.readUInt16BE(e)),t.type==="OPT")t.udpPayloadSize=r.readUInt16BE(e+2),t.extendedRcode=r.readUInt8(e+4),t.ednsVersion=r.readUInt8(e+5),t.flags=r.readUInt16BE(e+6),t.flag_do=(t.flags>>15&1)===1,t.options=$.decode(r,e+8),e+=8+$.decode.bytes;else{let i=r.readUInt16BE(e+2);t.ttl=r.readUInt32BE(e+4),t.class=Je.toString(i&Mn),t.flush=!!(i&wr);let o=Er(t.type);t.data=o.decode(r,e+8),e+=8+o.decode.bytes}return N.decode.bytes=e-n,t};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+Er(r.type).encodingLength(e)};var Y=w.question={};Y.encode=function(r,e,t){e||(e=E.alloc(Y.encodingLength(r))),t||(t=0);let n=t;return g.encode(r.name,e,t),t+=g.encode.bytes,e.writeUInt16BE(ge.toType(r.type),t),t+=2,e.writeUInt16BE(Je.toClass(r.class===void 0?"IN":r.class),t),t+=2,Y.encode.bytes=t-n,r};Y.encode.bytes=0;Y.decode=function(r,e){e||(e=0);let t=e,n={};return n.name=g.decode(r,e),e+=g.decode.bytes,n.type=ge.toString(r.readUInt16BE(e)),e+=2,n.class=Je.toString(r.readUInt16BE(e)),e+=2,!!(n.class&Ut)&&(n.class&=zn),Y.decode.bytes=e-t,n};Y.decode.bytes=0;Y.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,t){let n=!e;n&&(e=E.alloc(w.encodingLength(r))),t||(t=0);let i=t;return r.questions||(r.questions=[]),r.answers||(r.answers=[]),r.authorities||(r.authorities=[]),r.additionals||(r.additionals=[]),G.encode(r,e,t),t+=G.encode.bytes,t=Be(r.questions,Y,e,t),t=Be(r.answers,N,e,t),t=Be(r.authorities,N,e,t),t=Be(r.additionals,N,e,t),w.encode.bytes=t-i,n&&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 t=e,n=G.decode(r,e);return e+=G.decode.bytes,e=Qe(n.questions,Y,r,e),e=Qe(n.answers,N,r,e),e=Qe(n.authorities,N,r,e),e=Qe(n.additionals,N,r,e),w.decode.bytes=e-t,n};w.decode.bytes=0;w.encodingLength=function(r){return G.encodingLength(r)+Le(r.questions||[],Y)+Le(r.answers||[],N)+Le(r.authorities||[],N)+Le(r.additionals||[],N)};w.streamEncode=function(r){let e=w.encode(r),t=E.alloc(2);t.writeUInt16BE(e.byteLength);let n=E.concat([t,e]);return w.streamEncode.bytes=n.byteLength,n};w.streamEncode.bytes=0;w.streamDecode=function(r){let e=r.readUInt16BE(0);if(r.byteLength<e+2)return null;let t=w.decode(r.slice(2));return w.streamDecode.bytes=w.decode.bytes,t};w.streamDecode.bytes=0;function Le(r,e){let t=0;for(let n=0;n<r.length;n++)t+=e.encodingLength(r[n]);return t}function Be(r,e,t,n){for(let i=0;i<r.length;i++)e.encode(r[i],t,n),n+=e.encode.bytes;return n}function Qe(r,e,t,n){for(let i=0;i<r.length;i++)r[i]=e.decode(t,n),n+=e.decode.bytes;return n}});var Ot=W((Tc,Ct)=>{"use strict";var bt=Yn;process.nextTick(Xn,42);Ct.exports=Vn;function Vn(r){var e=n;return t;function t(i){e(i||Hn)}function n(i){var o=[i];e=c,r(h);function c(a){o.push(a)}function h(a){var d=arguments;for(e=Kn(a)?n:m;o.length;)m(o.shift());function m(l){bt(jn,l,d)}}}}function Kn(r){return Object.prototype.toString.call(r)==="[object Error]"}function Hn(){}function jn(r,e){r.apply(null,e)}function Xn(r){r===42&&(bt=process.nextTick)}function Yn(r,e,t){process.nextTick(function(){r(e,t)})}});var Pt=W((Nc,Nt)=>{var Ir=Lt(),Gn=j("dgram"),Wn=Ot(),Qn=j("events"),vr=j("os"),xr=function(){};Nt.exports=function(r){r||(r={});var e=new Qn.EventEmitter,t=typeof r.port=="number"?r.port:5353,n=r.type||"udp4",i=r.ip||r.host||(n==="udp4"?"224.0.0.251":null),o={address:i,port:t},c={},h=!1,a=null;if(n==="udp6"&&(!i||!r.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var d=r.socket||Gn.createSocket({type:n,reuseAddr:r.reuseAddr!==!1,toString:function(){return n}});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=Ir.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(){t||(t=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=Wn(function(l){if(!t||r.bind===!1)return l(null);d.once("error",l),d.bind(t,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=xr),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=Ir.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)|Ir.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=xr),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=xr),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):Zn(),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||Jn())}catch(y){e.emit("warning",y)}e.emit("networkInterface")}},e};function Jn(){for(var r=vr.networkInterfaces(),e=Object.keys(r),t=0;t<e.length;t++)for(var n=r[e[t]],i=0;i<n.length;i++){var o=n[i];if(Tt(o.family)&&!o.internal)return vr.platform()==="darwin"&&e[t]==="en0"?o.address:"0.0.0.0"}return"127.0.0.1"}function Zn(){for(var r=vr.networkInterfaces(),e=Object.keys(r),t=[],n=0;n<e.length;n++)for(var i=r[e[n]],o=0;o<i.length;o++){var c=i[o];if(Tt(c.family)){t.push(c.address);break}}return t}function Tt(r){return r===4||r==="IPv4"}});var cn=W(He=>{(function(){var r,e,t,n,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")}},t=function(a){return a.charCodeAt(0)},n=t("0"),o=t("a"),i=t("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+(t(a[l])-n)>>>0;else if(d===16)if("a"<=a[l]&&a[l]<="f")u=u*d+(10+t(a[l])-o)>>>0;else if("A"<=a[l]&&a[l]<="F")u=u*d+(10+t(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}(),He.ip2long=c,He.long2ip=h,He.Netmask=r}).call(He)});var jo={};k(jo,{mdns:()=>Ho});var ut=Symbol.for("@libp2p/peer-discovery");var sr=Symbol.for("@libp2p/peer-id");var Ge=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var ht=j("events"),pt=(r,...e)=>{try{(0,ht.setMaxListeners)(r,...e)}catch{}};var We=class extends EventTarget{#e=new Map;constructor(){super(),pt(1/0,this)}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let i=this.#e.get(e);i==null&&(i=[],this.#e.set(e,i)),i.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let i=this.#e.get(e);i!=null&&(i=i.filter(({callback:o})=>o!==t),this.#e.set(e,i))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:i})=>!i),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new dr(e,t))}},ar=class extends Event{detail;constructor(e,t){super(e,t),this.detail=t?.detail}},dr=globalThis.CustomEvent??ar;var gt=Symbol.for("@libp2p/service-capabilities"),fo=Symbol.for("@libp2p/service-dependencies");var On=cr(Pt(),1);var br={};k(br,{base58btc:()=>P,base58flickr:()=>ii});var Pc=new Uint8Array(0);function Dt(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function q(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 Bt(r){return new TextEncoder().encode(r)}function Ft(r){return new TextDecoder().decode(r)}function fn(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var i=0;i<r.length;i++){var o=r.charAt(i),c=o.charCodeAt(0);if(t[c]!==255)throw new TypeError(o+" is ambiguous");t[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,S=0,L=s.length;S!==L&&s[S]===0;)S++,y++;for(var B=(L-S)*m+1>>>0,T=new Uint8Array(B);S!==L;){for(var b=s[S],C=0,H=B-1;(b!==0||C<v)&&H!==-1;H--,C++)b+=256*T[H]>>>0,T[H]=b%h>>>0,b=b/h>>>0;if(b!==0)throw new Error("Non-zero carry");v=C,S++}for(var ie=B-v;ie!==B&&T[ie]===0;)ie++;for(var Xe=a.repeat(y);ie<B;++ie)Xe+=r.charAt(T[ie]);return Xe}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,S=0;s[y]===a;)v++,y++;for(var L=(s.length-y)*d+1>>>0,B=new Uint8Array(L);s[y];){var T=t[s.charCodeAt(y)];if(T===255)return;for(var b=0,C=L-1;(T!==0||b<S)&&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");S=b,y++}if(s[y]!==" "){for(var H=L-S;H!==L&&B[H]===0;)H++;for(var ie=new Uint8Array(v+(L-H)),Xe=v;H!==L;)ie[Xe++]=B[H++];return ie}}}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 ei=fn,ri=ei,_t=ri;var Ar=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Sr=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return kt(this,e)}},Ur=class{decoders;constructor(e){this.decoders=e}or(e){return kt(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function kt(r,e){return new Ur({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Lr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,i){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new Ar(e,t,n),this.decoder=new Sr(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function be({name:r,prefix:e,encode:t,decode:n}){return new Lr(r,e,t,n)}function Ee({name:r,prefix:e,alphabet:t}){let{encode:n,decode:i}=_t(t,r);return be({prefix:e,name:r,encode:n,decode:o=>q(i(o))})}function ti(r,e,t,n){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*t/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-${n} character`);a=a<<t|l,h+=t,h>=8&&(h-=8,c[d++]=255&a>>h)}if(h>=t||255&a<<8-h)throw new SyntaxError("Unexpected end of data");return c}function ni(r,e,t){let n=e[e.length-1]==="=",i=(1<<t)-1,o="",c=0,h=0;for(let a=0;a<r.length;++a)for(h=h<<8|r[a],c+=8;c>t;)c-=t,o+=e[i&h>>c];if(c!==0&&(o+=e[i&h<<t-c]),n)for(;o.length*t&7;)o+="=";return o}function U({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return be({prefix:e,name:r,encode(i){return ni(i,n,t)},decode(i){return ti(i,n,t,r)}})}var P=Ee({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ii=Ee({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Cr={};k(Cr,{base10:()=>oi});var oi=Ee({prefix:"9",name:"base10",alphabet:"0123456789"});var Or={};k(Or,{base16:()=>ci,base16upper:()=>si});var ci=U({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),si=U({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Tr={};k(Tr,{base2:()=>ai});var ai=U({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Nr={};k(Nr,{base256emoji:()=>pi});var Mt=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}"),di=Mt.reduce((r,e,t)=>(r[t]=e,r),[]),li=Mt.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function ui(r){return r.reduce((e,t)=>(e+=di[t],e),"")}function hi(r){let e=[];for(let t of r){let n=li[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var pi=be({prefix:"\u{1F680}",name:"base256emoji",encode:ui,decode:hi});var Pr={};k(Pr,{base32:()=>me,base32hex:()=>wi,base32hexpad:()=>Ii,base32hexpadupper:()=>xi,base32hexupper:()=>Ei,base32pad:()=>mi,base32padupper:()=>yi,base32upper:()=>gi,base32z:()=>vi});var me=U({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),gi=U({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mi=U({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yi=U({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),wi=U({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ei=U({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ii=U({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),xi=U({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vi=U({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Dr={};k(Dr,{base36:()=>Ai,base36upper:()=>Si});var Ai=Ee({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Si=Ee({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Br={};k(Br,{base64:()=>Ui,base64pad:()=>Li,base64url:()=>bi,base64urlpad:()=>Ci});var Ui=U({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Li=U({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),bi=U({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ci=U({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Fr={};k(Fr,{base8:()=>Oi});var Oi=U({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Rr={};k(Rr,{identity:()=>Ti});var Ti=be({prefix:"\0",name:"identity",encode:r=>Ft(r),decode:r=>Bt(r)});var Yc=new TextEncoder,Gc=new TextDecoder;var kr={};k(kr,{identity:()=>_e});var Di=qt,zt=128,Bi=127,Fi=~Bi,Ri=Math.pow(2,31);function qt(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Ri;)e[t++]=r&255|zt,r/=128;for(;r&Fi;)e[t++]=r&255|zt,r>>>=7;return e[t]=r|0,qt.bytes=t-n+1,e}var _i=_r,ki=128,$t=127;function _r(r,n){var t=0,n=n||0,i=0,o=n,c,h=r.length;do{if(o>=h)throw _r.bytes=0,new RangeError("Could not decode varint");c=r[o++],t+=i<28?(c&$t)<<i:(c&$t)*Math.pow(2,i),i+=7}while(c>=ki);return _r.bytes=o-n,t}var Mi=Math.pow(2,7),zi=Math.pow(2,14),$i=Math.pow(2,21),qi=Math.pow(2,28),Vi=Math.pow(2,35),Ki=Math.pow(2,42),Hi=Math.pow(2,49),ji=Math.pow(2,56),Xi=Math.pow(2,63),Yi=function(r){return r<Mi?1:r<zi?2:r<$i?3:r<qi?4:r<Vi?5:r<Ki?6:r<Hi?7:r<ji?8:r<Xi?9:10},Gi={encode:Di,decode:_i,encodingLength:Yi},Wi=Gi,Fe=Wi;function Re(r,e=0){return[Fe.decode(r,e),Fe.decode.bytes]}function Ce(r,e,t=0){return Fe.encode(r,e,t),e}function Oe(r){return Fe.encodingLength(r)}function Ie(r,e){let t=e.byteLength,n=Oe(r),i=n+Oe(t),o=new Uint8Array(i+t);return Ce(r,o,0),Ce(t,o,n),o.set(e,i),new Te(r,t,e,o)}function Ae(r){let e=q(r),[t,n]=Re(e),[i,o]=Re(e.subarray(n)),c=e.subarray(n+o);if(c.byteLength!==i)throw new Error("Incorrect length");return new Te(t,i,c,e)}function Vt(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Dt(r.bytes,t.bytes)}}var Te=class{code;size;digest;bytes;constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}};var Kt=0,Qi="identity",Ht=q;function Ji(r){return Ie(Kt,Ht(r))}var _e={code:Kt,name:Qi,encode:Ht,digest:Ji};var qr={};k(qr,{sha256:()=>fe,sha512:()=>Zi});var $r=cr(j("crypto"),1);function zr({name:r,code:e,encode:t}){return new Mr(r,e,t)}var Mr=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Ie(this.code,t):t.then(n=>Ie(this.code,n))}else throw Error("Unknown type, must be binary type")}};var fe=zr({name:"sha2-256",code:18,encode:r=>q($r.default.createHash("sha256").update(r).digest())}),Zi=zr({name:"sha2-512",code:19,encode:r=>q($r.default.createHash("sha512").update(r).digest())});function Xt(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return eo(t,Vr(r),e??P.encoder);default:return ro(t,Vr(r),e??me.encoder)}}var Yt=new WeakMap;function Vr(r){let e=Yt.get(r);if(e==null){let t=new Map;return Yt.set(r,t),t}return e}var V=class r{code;version;multihash;bytes;"/";constructor(e,t,n,i){this.code=t,this.version=e,this.multihash=n,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:t}=this;if(e!==ke)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==to)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=Ie(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&Vt(e.multihash,n.multihash)}toString(e){return Xt(this,e)}toJSON(){return{"/":Xt(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:i,multihash:o,bytes:c}=t;return new r(n,i,o,c??Gt(n,i,o.bytes))}else if(t[no]===!0){let{version:n,multihash:i,code:o}=t,c=Ae(i);return r.create(n,o,c)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==ke)throw new Error(`Version 0 CID must use dag-pb (code: ${ke}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let i=Gt(e,t,n.bytes);return new r(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,ke,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,i=q(e.subarray(n,n+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");let o=i.subarray(t.multihashSize-t.digestSize),c=new Te(t.multihashCode,t.digestSize,o,i);return[t.version===0?r.createV0(c):r.createV1(t.codec,c),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,u]=Re(e.subarray(t));return t+=u,l},i=n(),o=ke;if(i===18?(i=0,t=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let c=t,h=n(),a=n(),d=t+a,m=d-c;return{version:i,codec:o,multihashCode:h,digestSize:a,multihashSize:m,size:d}}static parse(e,t){let[n,i]=fi(e,t),o=r.decode(i);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Vr(o).set(n,e),o}};function fi(r,e){switch(r[0]){case"Q":{let t=e??P;return[P.prefix,t.decode(`${P.prefix}${r}`)]}case P.prefix:{let t=e??P;return[P.prefix,t.decode(r)]}case me.prefix:{let t=e??me;return[me.prefix,t.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 eo(r,e,t){let{prefix:n}=t;if(n!==P.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let i=e.get(n);if(i==null){let o=t.encode(r).slice(1);return e.set(n,o),o}else return i}function ro(r,e,t){let{prefix:n}=t,i=e.get(n);if(i==null){let o=t.encode(r);return e.set(n,o),o}else return i}var ke=112,to=18;function Gt(r,e,t){let n=Oe(r),i=n+Oe(e),o=new Uint8Array(i+t.byteLength);return Ce(r,o,0),Ce(e,o,n),o.set(t,i),o}var no=Symbol.for("@ipld/js-cid/CID");var xe={...Rr,...Tr,...Fr,...Cr,...Or,...Pr,...Dr,...br,...Br,...Nr},ys={...qr,...kr};function Me(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var Zt=j("node:buffer");var Wt=j("node:buffer");function Ne(r){return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}function er(r=0){return Ne(Wt.Buffer.allocUnsafe(r))}function Jt(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Qt=Jt("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Kr=Jt("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=er(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),io={utf8:Qt,"utf-8":Qt,hex:xe.base16,latin1:Kr,ascii:Kr,binary:Kr,...xe},rr=io;function ze(r,e="utf8"){let t=rr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?Ne(Zt.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var ft=j("node:buffer");function D(r,e="utf8"){let t=rr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?ft.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var rn=Symbol.for("nodejs.util.inspect.custom"),en=Object.values(xe).map(r=>r.decoder).reduce((r,e)=>r.or(e),xe.identity.decoder),tn=114,nn=36,on=37,$e=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()})`}[sr]=!0;toString(){return this.string==null&&(this.string=P.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return V.createV1(tn,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 Xr(e).equals(this);if(e?.multihash?.bytes!=null)return Me(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[rn](){return`PeerId(${this.toString()})`}},qe=class extends $e{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Ve=class extends $e{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Ke=class extends $e{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}},Hr=2336,jr=class{type="url";multihash;privateKey;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=_e.digest(ze(this.url))}[rn](){return`PeerId(${this.url})`}[sr]=!0;toString(){return this.toCID().toString()}toCID(){return V.createV1(Hr,this.multihash)}toBytes(){return this.toCID().bytes}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=D(e)),e.toString()===this.toString())}};function Xr(r,e){if(e=e??en,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=Ae(P.decode(`z${r}`));return r.startsWith("12D")?new Ve({multihash:t}):r.startsWith("16U")?new Ke({multihash:t}):new qe({multihash:t})}return oo(en.decode(r))}function oo(r){try{let e=Ae(r);if(e.code===_e.code){if(e.digest.length===nn)return new Ve({multihash:e});if(e.digest.length===on)return new Ke({multihash:e})}if(e.code===fe.code)return new qe({multihash:e})}catch{return co(V.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function co(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==tn&&r.code!==Hr)throw new Error("Supplied PeerID CID is invalid");if(r.code===Hr){let t=D(r.multihash.digest);return new jr(new URL(t))}let e=r.multihash;if(e.code===fe.code)return new qe({multihash:r.multihash});if(e.code===_e.code){if(e.digest.length===nn)return new Ve({multihash:r.multihash});if(e.digest.length===on)return new Ke({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var K=j("node:net");function tr(r){return!!(0,K.isIP)(r)}var sn=cr(cn(),1),so=["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"],ao=so.map(r=>new sn.Netmask(r));function Yr(r){for(let e of ao)if(e.contains(r))return!0;return!1}function lo(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function uo(r){let e=r.split(":");if(e.length<2)return!1;let t=e[e.length-1].padStart(4,"0"),n=e[e.length-2].padStart(4,"0"),i=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(t.substring(0,2),16)}.${parseInt(t.substring(2),16)}`;return Yr(i)}function ho(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function po(r){let e=r.split(":"),t=e[e.length-1];return Yr(t)}function go(r){return/^::$/.test(r)||/^::1$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function an(r){return(0,K.isIPv4)(r)?Yr(r):lo(r)?uo(r):ho(r)?po(r):(0,K.isIPv6)(r)?go(r):void 0}function dn(r){try{let{address:e}=r.nodeAddress();return!!an(e)}catch{return!0}}var mo=Math.pow(2,7),yo=Math.pow(2,14),wo=Math.pow(2,21),Gr=Math.pow(2,28),Wr=Math.pow(2,35),Qr=Math.pow(2,42),Jr=Math.pow(2,49),x=128,F=127;function ne(r){if(r<mo)return 1;if(r<yo)return 2;if(r<wo)return 3;if(r<Gr)return 4;if(r<Wr)return 5;if(r<Qr)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 Eo(r,e,t=0){switch(ne(r)){case 8:e[t++]=r&255|x,r/=128;case 7:e[t++]=r&255|x,r/=128;case 6:e[t++]=r&255|x,r/=128;case 5:e[t++]=r&255|x,r/=128;case 4:e[t++]=r&255|x,r>>>=7;case 3:e[t++]=r&255|x,r>>>=7;case 2:e[t++]=r&255|x,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Io(r,e,t=0){switch(ne(r)){case 8:e.set(t++,r&255|x),r/=128;case 7:e.set(t++,r&255|x),r/=128;case 6:e.set(t++,r&255|x),r/=128;case 5:e.set(t++,r&255|x),r/=128;case 4:e.set(t++,r&255|x),r>>>=7;case 3:e.set(t++,r&255|x),r>>>=7;case 2:e.set(t++,r&255|x),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function xo(r,e){let t=r[e],n=0;if(n+=t&F,t<x||(t=r[e+1],n+=(t&F)<<7,t<x)||(t=r[e+2],n+=(t&F)<<14,t<x)||(t=r[e+3],n+=(t&F)<<21,t<x)||(t=r[e+4],n+=(t&F)*Gr,t<x)||(t=r[e+5],n+=(t&F)*Wr,t<x)||(t=r[e+6],n+=(t&F)*Qr,t<x)||(t=r[e+7],n+=(t&F)*Jr,t<x))return n;throw new RangeError("Could not decode varint")}function vo(r,e){let t=r.get(e),n=0;if(n+=t&F,t<x||(t=r.get(e+1),n+=(t&F)<<7,t<x)||(t=r.get(e+2),n+=(t&F)<<14,t<x)||(t=r.get(e+3),n+=(t&F)<<21,t<x)||(t=r.get(e+4),n+=(t&F)*Gr,t<x)||(t=r.get(e+5),n+=(t&F)*Wr,t<x)||(t=r.get(e+6),n+=(t&F)*Qr,t<x)||(t=r.get(e+7),n+=(t&F)*Jr,t<x))return n;throw new RangeError("Could not decode varint")}function Pe(r,e,t=0){return e==null&&(e=er(ne(r))),e instanceof Uint8Array?Eo(r,e,t):Io(r,e,t)}function Ue(r,e=0){return r instanceof Uint8Array?xo(r,e):vo(r,e)}var un=j("node:buffer");function ye(r,e){return Ne(un.Buffer.concat(r,e))}var nr=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,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,t!==void 0&&c>t))return}if(c!==0)return!n&&a&&c>1?void 0:o})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let i=n*2;if(n<t.length-3){let c=this.readSeparator(":",n,()=>this.readIPv4Addr());if(c!==void 0)return t[i]=c[0],t[i+1]=c[1],t[i+2]=c[2],t[i+3]=c[3],[i+4,!0]}let o=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(o===void 0)return[i,!1];t[i]=o>>8,t[i+1]=o&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,i]=e(t);if(n===16)return t;if(i||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),c=16-(n+2),[h]=e(o.subarray(0,c));return t.set(o.subarray(0,h),16-h),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Js=new nr;var oa=parseInt("0xFFFF",16),ca=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var gn=K.isIPv4,Co=K.isIPv6,Zr=function(r){let e=0;if(r=r.toString().trim(),gn(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(Co(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let o=gn(t[n]),c;o&&(c=Zr(t[n]),t[n]=D(c.slice(0,2),"base16")),c!=null&&++n<8&&t.splice(n,0,D(c.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let o=[n,1];for(n=9-t.length;n>0;n--)o.push("0");t.splice.apply(t,o)}let i=new Uint8Array(e+16);for(n=0;n<t.length;n++){let o=parseInt(t[n],16);i[e++]=o>>8&255,i[e++]=o&255}return i}throw new Error("invalid ip address")},mn=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let i=[];for(let o=0;o<t;o++)i.push(r[e+o]);return i.join(".")}if(t===16){let i=[];for(let o=0;o<t;o+=2)i.push(n.getUint16(e+o).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var De={},fr={},To=[[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"],[481,-1,"http-path"],[777,-1,"memory"]];To.forEach(r=>{let e=No(...r);fr[e.code]=e,De[e.name]=e});function No(r,e,t,n,i){return{code:r,size:e,name:t,resolvable:!!n,path:!!i}}function A(r){if(typeof r=="number"){if(fr[r]!=null)return fr[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 Ka=A("ip4"),Ha=A("ip6"),ja=A("ipcidr");function nt(r,e){switch(A(r).code){case 4:case 41:return Do(e);case 42:return tt(e);case 6:case 273:case 33:case 132:return En(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return tt(e);case 421:return _o(e);case 444:return wn(e);case 445:return wn(e);case 466:return Ro(e);case 481:return globalThis.encodeURIComponent(tt(e));default:return D(e,"base16")}}function it(r,e){switch(A(r).code){case 4:return yn(e);case 41:return yn(e);case 42:return rt(e);case 6:case 273:case 33:case 132:return ot(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return rt(e);case 421:return Bo(e);case 444:return ko(e);case 445:return Mo(e);case 466:return Fo(e);case 481:return rt(globalThis.decodeURIComponent(e));default:return ze(e,"base16")}}var et=Object.values(xe).map(r=>r.decoder),Po=function(){let r=et[0].or(et[1]);return et.slice(2).forEach(e=>r=r.or(e)),r}();function yn(r){if(!tr(r))throw new Error("invalid ip address");return Zr(r)}function Do(r){let e=mn(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!tr(e))throw new Error("invalid ip address");return e}function ot(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function En(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function rt(r){let e=ze(r),t=Uint8Array.from(Pe(e.length));return ye([t,e],t.length+e.length)}function tt(r){let e=Ue(r);if(r=r.slice(ne(e)),r.length!==e)throw new Error("inconsistent lengths");return D(r)}function Bo(r){let e;r[0]==="Q"||r[0]==="1"?e=Ae(P.decode(`z${r}`)).bytes:e=V.parse(r).multihash.bytes;let t=Uint8Array.from(Pe(e.length));return ye([t,e],t.length+e.length)}function Fo(r){let e=Po.decode(r),t=Uint8Array.from(Pe(e.length));return ye([t,e],t.length+e.length)}function Ro(r){let e=Ue(r),t=r.slice(ne(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+D(t,"base64url")}function _o(r){let e=Ue(r),t=r.slice(ne(e));if(t.length!==e)throw new Error("inconsistent lengths");return D(t,"base58btc")}function ko(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=me.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=ot(n);return ye([t,i],t.length+i.length)}function Mo(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=me.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=ot(n);return ye([t,i],t.length+i.length)}function wn(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=D(e,"base32"),i=En(t);return`${n}:${i}`}function In(r){r=ct(r);let e=[],t=[],n=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]),t.push([h.code]);continue}if(o++,o>=i.length)throw vn("invalid address: "+r);if(h.path===!0){n=ct(i.slice(o).join("/")),e.push([h.code,it(h.code,n)]),t.push([h.code,n]);break}let a=it(h.code,i[o]);e.push([h.code,a]),t.push([h.code,nt(h.code,a)])}return{string:xn(t),bytes:at(e),tuples:e,stringTuples:t,path:n}}function st(r){let e=[],t=[],n=null,i=0;for(;i<r.length;){let o=Ue(r,i),c=ne(o),h=A(o),a=zo(h,r.slice(i+c));if(a===0){e.push([o]),t.push([o]),i+=c;continue}let d=r.slice(i+c,i+c+a);if(i+=a+c,i>r.length)throw vn("Invalid address Uint8Array: "+D(r,"base16"));e.push([o,d]);let m=nt(o,d);if(t.push([o,m]),h.path===!0){n=m;break}}return{bytes:Uint8Array.from(r),string:xn(t),tuples:e,stringTuples:t,path:n}}function xn(r){let e=[];return r.map(t=>{let n=A(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),ct(e.join("/"))}function at(r){return ye(r.map(e=>{let t=A(e[0]),n=Uint8Array.from(Pe(t.code));return e.length>1&&e[1]!=null&&(n=ye([n,e[1]])),n}))}function zo(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Ue(e instanceof Uint8Array?e:Uint8Array.from(e));return t+ne(t)}}function ct(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function vn(r){return new Error("Error parsing address: "+r)}var $o=Symbol.for("nodejs.util.inspect.custom"),dt=Symbol.for("@multiformats/js-multiaddr/multiaddr"),qo=[A("dns").code,A("dns4").code,A("dns6").code,A("dnsaddr").code],ir=class r{bytes;#e;#r;#t;#n;[dt]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=st(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=In(e)}else if(Sn(e))t=st(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#r=t.tuples,this.#t=t.stringTuples,this.#n=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,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??""}`),qo.includes(p)&&(t=c.name,i=443,n=`${s??""}${o}`,e=p===m.code?6:4),(p===c.code||p===h.code)&&(t=A(p).name,i=parseInt(s??"")),(p===a.code||p===d.code)&&(t=A(p).name,n=`${s??""}${o}`,e=p===d.code?6:4);if(e==null||t==null||n==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:n,transport:t,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.#t}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),i=n.lastIndexOf(t);if(i<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,i))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(at(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,i])=>{n===De.p2p.code&&e.push([n,i]),n===De["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?D(P.decode(`z${n}`),"base58btc"):D(V.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return Me(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(o=>o.resolvable);if(t==null)return[this];let n=An.get(t.name);if(n==null)throw new Ge(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(o=>je(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 t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[$o](){return`Multiaddr(${this.#e})`}};var An=new Map;function Sn(r){return!!r?.[dt]}function je(r){return new ir(r)}function Un(r,e,t,n){let i=()=>{n?.log.trace("query",e),r.query({questions:[{name:e,type:"PTR"}]})};return i(),setInterval(i,t)}function Ln(r,e,t,n){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!==t||o.length===0||i.data.startsWith(e)))try{let c=o.flatMap(a=>a.data).filter(a=>a.toString().startsWith("dnsaddr=")).map(a=>je(a.toString().substring(8))),h=c[0].getPeerId();if(h==null)throw new Error("Multiaddr doesn't contain PeerId");return n?.log("peer found %p",h),{id:Xr(h),multiaddrs:c.map(a=>a.decapsulateCode(A("p2p").code))}}catch(c){n?.log.error("failed to parse mdns response",c)}}function bn(r,e,t,n,i,o,c){if(!o){c?.log("not responding to mDNS query as broadcast mode is false");return}if(n.length!==0&&r.questions[0]!=null&&r.questions[0].name===i){let h=[];h.push({name:i,type:"PTR",class:"IN",ttl:120,data:t+"."+i}),n.filter(Vo).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:t+"."+i,type:"TXT",class:"IN",ttl:120,data:d})}),c?.log.trace("responding to query"),e.respond(h)}}function Vo(r){return!!dn(r)}function Cn(r){let e="",t="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<r;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}var or=class extends We{mdns;log;broadcast;interval;serviceTag;peerName;port;ip;_queryInterval;components;constructor(e,t={}){if(super(),this.log=e.logger.forComponent("libp2p:mdns"),this.broadcast=t.broadcast!==!1,this.interval=t.interval??1e3*10,this.serviceTag=t.serviceTag??"_p2p._udp.local",this.ip=t.ip??"224.0.0.251",this.peerName=t.peerName??Cn(63),this.peerName.length>=64)throw new Error("Peer name should be less than 64 chars long");this.port=t.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)}[ut]=this;[Symbol.toStringTag]="@libp2p/mdns";[gt]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,On.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=Un(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),bn(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 t=Ln(e,this.peerName,this.serviceTag,{log:this.log});t!=null&&(this.log("discovered peer in mDNS query response %p",t.id),this.dispatchEvent(new dr("peer",{detail:t})))}catch(t){this.log.error("Error processing peer response",t)}}_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 Ho(r={}){return e=>new or(e,r)}return Fn(jo);})();
|
|
2
|
+
"use strict";var Libp2PMdns=(()=>{var On=Object.create;var Ye=Object.defineProperty;var Tn=Object.getOwnPropertyDescriptor;var Nn=Object.getOwnPropertyNames;var Pn=Object.getPrototypeOf,Dn=Object.prototype.hasOwnProperty;var j=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var W=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),k=(r,e)=>{for(var t in e)Ye(r,t,{get:e[t],enumerable:!0})},dt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Nn(e))!Dn.call(r,i)&&i!==t&&Ye(r,i,{get:()=>e[i],enumerable:!(n=Tn(e,i))||n.enumerable});return r};var cr=(r,e,t)=>(t=r!=null?On(Pn(r)):{},dt(e||!r||!r.__esModule?Ye(t,"default",{value:r,enumerable:!0}):t,r)),Bn=r=>dt(Ye({},"__esModule",{value:!0}),r);var gt=W(dr=>{"use strict";dr.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};dr.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 mt=W(lr=>{"use strict";lr.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};lr.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 yt=W(ur=>{"use strict";ur.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};ur.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 wt=W(hr=>{"use strict";hr.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};hr.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 Et=W(pr=>{"use strict";pr.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}`};pr.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 vt=W((xt,gr)=>{var It=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}$/,t=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,i=16,o={name:"v4",size:t,isFormat:u=>e.test(u),encode(u,p,s){s=~~s,p=p||new Uint8Array(s+t);let y=u.length,v=0;for(let S=0;S<y;){let L=u.charCodeAt(S++);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&&n.test(u),encode(u,p,s){s=~~s;let y=s+i,v=-1,S=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]=S>>8),s<y-1&&(p[s+1]=S&255),s+=2),S=0,L=0),B=!0,T=!1):C===46?(s<y&&(p[s]=L),s++,L=0,S=0,B=!1,T=!0):(B=!1,C>=97?C-=87:C>=65?C-=55:(C-=48,L=L*10+C),S=(S<<4)+C)}if(B===!1)T===!0?(s<y&&(p[s]=L),s++):(s<y&&(p[s]=S>>8),s<y-1&&(p[s+1]=S&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 It}):typeof gr=="object"&&typeof xt=="object"&&(gr.exports=It)});var Ut=W(w=>{"use strict";var E=j("buffer").Buffer,ge=gt(),Fn=mt(),Rn=yt(),Je=wt(),mr=Et(),ve=vt(),_n=0,At=32768,yr=32768,kn=~yr,St=32768,Mn=~St,g=w.name={};g.encode=function(r,e,t,{mail:n=!1}={}){e||(e=E.alloc(g.encodingLength(r))),t||(t=0);let i=t,o=r.replace(/^\.|\.$/gm,"");if(o.length){let c=[];if(n){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],t+1);e[t]=a,t+=a+1}}return e[t++]=0,g.encode.bytes=t-i,e};g.encode.bytes=0;g.decode=function(r,e,{mail:t=!1}={}){e||(e=0);let n=[],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);t&&(d=d.replace(/\./g,"\\.")),n.push(d),e+=a,c+=h?0:a}}return g.decode.bytes=c,n.length===0?".":n.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,t){e||(e=E.alloc(I.encodingLength(r))),t||(t=0);let n=e.write(r,t+1);return e[t]=n,I.encode.bytes=n+1,e};I.encode.bytes=0;I.decode=function(r,e){e||(e=0);let t=r[e],n=r.toString("utf-8",e+1,e+1+t);return I.decode.bytes=t+1,n};I.decode.bytes=0;I.encodingLength=function(r){return E.byteLength(r)+1};var G={};G.encode=function(r,e,t){e||(e=G.encodingLength(r)),t||(t=0);let n=(r.flags||0)&32767,i=r.type==="response"?At:_n;return e.writeUInt16BE(r.id||0,t),e.writeUInt16BE(n|i,t+2),e.writeUInt16BE(r.questions.length,t+4),e.writeUInt16BE(r.answers.length,t+6),e.writeUInt16BE(r.authorities.length,t+8),e.writeUInt16BE(r.additionals.length,t+10),e};G.encode.bytes=12;G.decode=function(r,e){if(e||(e=0),r.length<12)throw new Error("Header must be 12 bytes");let t=r.readUInt16BE(e+2);return{id:r.readUInt16BE(e),type:t&At?"response":"query",flags:t&32767,flag_qr:(t>>15&1)===1,opcode:Rn.toString(t>>11&15),flag_aa:(t>>10&1)===1,flag_tc:(t>>9&1)===1,flag_rd:(t>>8&1)===1,flag_ra:(t>>7&1)===1,flag_z:(t>>6&1)===1,flag_ad:(t>>5&1)===1,flag_cd:(t>>4&1)===1,rcode:Fn.toString(t&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))}};G.decode.bytes=12;G.encodingLength=function(){return 12};var oe=w.unknown={};oe.encode=function(r,e,t){return e||(e=E.alloc(oe.encodingLength(r))),t||(t=0),e.writeUInt16BE(r.length,t),r.copy(e,t+2),oe.encode.bytes=r.length+2,e};oe.encode.bytes=0;oe.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n=r.slice(e+2,e+2+t);return oe.decode.bytes=t+2,n};oe.decode.bytes=0;oe.encodingLength=function(r){return r.length+2};var ce=w.ns={};ce.encode=function(r,e,t){return e||(e=E.alloc(ce.encodingLength(r))),t||(t=0),g.encode(r,e,t+2),e.writeUInt16BE(g.encode.bytes,t),ce.encode.bytes=g.encode.bytes+2,e};ce.encode.bytes=0;ce.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n=g.decode(r,e+2);return ce.decode.bytes=t+2,n};ce.decode.bytes=0;ce.encodingLength=function(r){return g.encodingLength(r)+2};var se=w.soa={};se.encode=function(r,e,t){e||(e=E.alloc(se.encodingLength(r))),t||(t=0);let n=t;return t+=2,g.encode(r.mname,e,t),t+=g.encode.bytes,g.encode(r.rname,e,t,{mail:!0}),t+=g.encode.bytes,e.writeUInt32BE(r.serial||0,t),t+=4,e.writeUInt32BE(r.refresh||0,t),t+=4,e.writeUInt32BE(r.retry||0,t),t+=4,e.writeUInt32BE(r.expire||0,t),t+=4,e.writeUInt32BE(r.minimum||0,t),t+=4,e.writeUInt16BE(t-n-2,n),se.encode.bytes=t-n,e};se.encode.bytes=0;se.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.mname=g.decode(r,e),e+=g.decode.bytes,n.rname=g.decode(r,e,{mail:!0}),e+=g.decode.bytes,n.serial=r.readUInt32BE(e),e+=4,n.refresh=r.readUInt32BE(e),e+=4,n.retry=r.readUInt32BE(e),e+=4,n.expire=r.readUInt32BE(e),e+=4,n.minimum=r.readUInt32BE(e),e+=4,se.decode.bytes=e-t,n};se.decode.bytes=0;se.encodingLength=function(r){return 22+g.encodingLength(r.mname)+g.encodingLength(r.rname)};var ae=w.txt={};ae.encode=function(r,e,t){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(ae.encodingLength(r))),t||(t=0);let n=t;return t+=2,r.forEach(function(i){e[t++]=i.length,i.copy(e,t,0,i.length),t+=i.length}),e.writeUInt16BE(t-n-2,n),ae.encode.bytes=t-n,e};ae.encode.bytes=0;ae.decode=function(r,e){e||(e=0);let t=e,n=r.readUInt16BE(e);e+=2;let i=[];for(;n>0;){let o=r[e++];if(--n,n<o)throw new Error("Buffer overflow");i.push(r.slice(e,e+o)),e+=o,n-=o}return ae.decode.bytes=e-t,i};ae.decode.bytes=0;ae.encodingLength=function(r){Array.isArray(r)||(r=[r]);let e=2;return r.forEach(function(t){typeof t=="string"?e+=E.byteLength(t)+1:e+=t.length+1}),e};var de=w.null={};de.encode=function(r,e,t){e||(e=E.alloc(de.encodingLength(r))),t||(t=0),typeof r=="string"&&(r=E.from(r)),r||(r=E.alloc(0));let n=t;t+=2;let i=r.length;return r.copy(e,t,0,i),t+=i,e.writeUInt16BE(t-n-2,n),de.encode.bytes=t-n,e};de.encode.bytes=0;de.decode=function(r,e){e||(e=0);let t=e,n=r.readUInt16BE(e);e+=2;let i=r.slice(e,e+n);return e+=n,de.decode.bytes=e-t,i};de.decode.bytes=0;de.encodingLength=function(r){return r?(E.isBuffer(r)?r.length:E.byteLength(r))+2:2};var le=w.hinfo={};le.encode=function(r,e,t){e||(e=E.alloc(le.encodingLength(r))),t||(t=0);let n=t;return t+=2,I.encode(r.cpu,e,t),t+=I.encode.bytes,I.encode(r.os,e,t),t+=I.encode.bytes,e.writeUInt16BE(t-n-2,n),le.encode.bytes=t-n,e};le.encode.bytes=0;le.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.cpu=I.decode(r,e),e+=I.decode.bytes,n.os=I.decode(r,e),e+=I.decode.bytes,le.decode.bytes=e-t,n};le.decode.bytes=0;le.encodingLength=function(r){return I.encodingLength(r.cpu)+I.encodingLength(r.os)+2};var X=w.ptr={},zn=w.cname=X,$n=w.dname=X;X.encode=function(r,e,t){return e||(e=E.alloc(X.encodingLength(r))),t||(t=0),g.encode(r,e,t+2),e.writeUInt16BE(g.encode.bytes,t),X.encode.bytes=g.encode.bytes+2,e};X.encode.bytes=0;X.decode=function(r,e){e||(e=0);let t=g.decode(r,e+2);return X.decode.bytes=g.decode.bytes+2,t};X.decode.bytes=0;X.encodingLength=function(r){return g.encodingLength(r)+2};var ue=w.srv={};ue.encode=function(r,e,t){e||(e=E.alloc(ue.encodingLength(r))),t||(t=0),e.writeUInt16BE(r.priority||0,t+2),e.writeUInt16BE(r.weight||0,t+4),e.writeUInt16BE(r.port||0,t+6),g.encode(r.target,e,t+8);let n=g.encode.bytes+6;return e.writeUInt16BE(n,t),ue.encode.bytes=n+2,e};ue.encode.bytes=0;ue.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n={};return n.priority=r.readUInt16BE(e+2),n.weight=r.readUInt16BE(e+4),n.port=r.readUInt16BE(e+6),n.target=g.decode(r,e+8),ue.decode.bytes=t+2,n};ue.decode.bytes=0;ue.encodingLength=function(r){return 8+g.encodingLength(r.target)};var M=w.caa={};M.ISSUER_CRITICAL=128;M.encode=function(r,e,t){let n=M.encodingLength(r);return e||(e=E.alloc(M.encodingLength(r))),t||(t=0),r.issuerCritical&&(r.flags=M.ISSUER_CRITICAL),e.writeUInt16BE(n-2,t),t+=2,e.writeUInt8(r.flags||0,t),t+=1,I.encode(r.tag,e,t),t+=I.encode.bytes,e.write(r.value,t),t+=E.byteLength(r.value),M.encode.bytes=n,e};M.encode.bytes=0;M.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e);e+=2;let n=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,n+t),i.issuerCritical=!!(i.flags&M.ISSUER_CRITICAL),M.decode.bytes=t+2,i};M.decode.bytes=0;M.encodingLength=function(r){return I.encodingLength(r.tag)+I.encodingLength(r.value)+2};var we=w.mx={};we.encode=function(r,e,t){e||(e=E.alloc(we.encodingLength(r))),t||(t=0);let n=t;return t+=2,e.writeUInt16BE(r.preference||0,t),t+=2,g.encode(r.exchange,e,t),t+=g.encode.bytes,e.writeUInt16BE(t-n-2,n),we.encode.bytes=t-n,e};we.encode.bytes=0;we.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.preference=r.readUInt16BE(e),e+=2,n.exchange=g.decode(r,e),e+=g.decode.bytes,we.decode.bytes=e-t,n};we.encodingLength=function(r){return 4+g.encodingLength(r.exchange)};var he=w.a={};he.encode=function(r,e,t){return e||(e=E.alloc(he.encodingLength(r))),t||(t=0),e.writeUInt16BE(4,t),t+=2,ve.v4.encode(r,e,t),he.encode.bytes=6,e};he.encode.bytes=0;he.decode=function(r,e){e||(e=0),e+=2;let t=ve.v4.decode(r,e);return he.decode.bytes=6,t};he.decode.bytes=0;he.encodingLength=function(){return 6};var pe=w.aaaa={};pe.encode=function(r,e,t){return e||(e=E.alloc(pe.encodingLength(r))),t||(t=0),e.writeUInt16BE(16,t),t+=2,ve.v6.encode(r,e,t),pe.encode.bytes=18,e};pe.encode.bytes=0;pe.decode=function(r,e){e||(e=0),e+=2;let t=ve.v6.decode(r,e);return pe.decode.bytes=18,t};pe.decode.bytes=0;pe.encodingLength=function(){return 18};var _=w.option={};_.encode=function(r,e,t){e||(e=E.alloc(_.encodingLength(r))),t||(t=0);let n=t,i=mr.toCode(r.code);if(e.writeUInt16BE(i,t),t+=2,r.data)e.writeUInt16BE(r.data.length,t),t+=2,r.data.copy(e,t),t+=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,t),t+=2,e.writeUInt16BE(c,t),t+=2,e.writeUInt8(o,t++),e.writeUInt8(r.scopePrefixLength||0,t++),h.copy(e,t,0,a),t+=a;break;case 11:r.timeout?(e.writeUInt16BE(2,t),t+=2,e.writeUInt16BE(r.timeout,t),t+=2):(e.writeUInt16BE(0,t),t+=2);break;case 12:let d=r.length||0;e.writeUInt16BE(d,t),t+=2,e.fill(0,t,t+d),t+=d;break;case 14:let m=r.tags.length*2;e.writeUInt16BE(m,t),t+=2;for(let l of r.tags)e.writeUInt16BE(l,t),t+=2;break;default:throw new Error(`Unknown roption code: ${r.code}`)}return _.encode.bytes=t-n,e};_.encode.bytes=0;_.decode=function(r,e){e||(e=0);let t={};t.code=r.readUInt16BE(e),t.type=mr.toString(t.code),e+=2;let n=r.readUInt16BE(e);switch(e+=2,t.data=r.slice(e,e+n),t.code){case 8:t.family=r.readUInt16BE(e),e+=2,t.sourcePrefixLength=r.readUInt8(e++),t.scopePrefixLength=r.readUInt8(e++);let i=E.alloc(t.family===1?4:16);r.copy(i,0,e,e+n-4),t.ip=ve.decode(i);break;case 11:n>0&&(t.timeout=r.readUInt16BE(e),e+=2);break;case 14:t.tags=[];for(let o=0;o<n;o+=2)t.tags.push(r.readUInt16BE(e)),e+=2}return _.decode.bytes=n+4,t};_.decode.bytes=0;_.encodingLength=function(r){if(r.data)return r.data.length+4;switch(mr.toCode(r.code)){case 8:let t=r.sourcePrefixLength||0;return Math.ceil(t/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 $=w.opt={};$.encode=function(r,e,t){e||(e=E.alloc($.encodingLength(r))),t||(t=0);let n=t,i=Le(r,_);return e.writeUInt16BE(i,t),t=Be(r,_,e,t+2),$.encode.bytes=t-n,e};$.encode.bytes=0;$.decode=function(r,e){e||(e=0);let t=e,n=[],i=r.readUInt16BE(e);e+=2;let o=0;for(;i>0;)n[o++]=_.decode(r,e),e+=_.decode.bytes,i-=_.decode.bytes;return $.decode.bytes=e-t,n};$.decode.bytes=0;$.encodingLength=function(r){return 2+Le(r||[],_)};var R=w.dnskey={};R.PROTOCOL_DNSSEC=3;R.ZONE_KEY=128;R.SECURE_ENTRYPOINT=32768;R.encode=function(r,e,t){e||(e=E.alloc(R.encodingLength(r))),t||(t=0);let n=t,i=r.key;if(!E.isBuffer(i))throw new Error("Key must be a Buffer");return t+=2,e.writeUInt16BE(r.flags,t),t+=2,e.writeUInt8(R.PROTOCOL_DNSSEC,t),t+=1,e.writeUInt8(r.algorithm,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,R.encode.bytes=t-n,e.writeUInt16BE(R.encode.bytes-2,n),e};R.encode.bytes=0;R.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);if(e+=2,n.flags=r.readUInt16BE(e),e+=2,r.readUInt8(e)!==R.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=r.readUInt8(e),e+=1,n.key=r.slice(e,t+i+2),e+=n.key.length,R.decode.bytes=e-t,n};R.decode.bytes=0;R.encodingLength=function(r){return 6+E.byteLength(r.key)};var Q=w.rrsig={};Q.encode=function(r,e,t){e||(e=E.alloc(Q.encodingLength(r))),t||(t=0);let n=t,i=r.signature;if(!E.isBuffer(i))throw new Error("Signature must be a Buffer");return t+=2,e.writeUInt16BE(ge.toType(r.typeCovered),t),t+=2,e.writeUInt8(r.algorithm,t),t+=1,e.writeUInt8(r.labels,t),t+=1,e.writeUInt32BE(r.originalTTL,t),t+=4,e.writeUInt32BE(r.expiration,t),t+=4,e.writeUInt32BE(r.inception,t),t+=4,e.writeUInt16BE(r.keyTag,t),t+=2,g.encode(r.signersName,e,t),t+=g.encode.bytes,i.copy(e,t,0,i.length),t+=i.length,Q.encode.bytes=t-n,e.writeUInt16BE(Q.encode.bytes-2,n),e};Q.encode.bytes=0;Q.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.typeCovered=ge.toString(r.readUInt16BE(e)),e+=2,n.algorithm=r.readUInt8(e),e+=1,n.labels=r.readUInt8(e),e+=1,n.originalTTL=r.readUInt32BE(e),e+=4,n.expiration=r.readUInt32BE(e),e+=4,n.inception=r.readUInt32BE(e),e+=4,n.keyTag=r.readUInt16BE(e),e+=2,n.signersName=g.decode(r,e),e+=g.decode.bytes,n.signature=r.slice(e,t+i+2),e+=n.signature.length,Q.decode.bytes=e-t,n};Q.decode.bytes=0;Q.encodingLength=function(r){return 20+g.encodingLength(r.signersName)+E.byteLength(r.signature)};var J=w.rp={};J.encode=function(r,e,t){e||(e=E.alloc(J.encodingLength(r))),t||(t=0);let n=t;return t+=2,g.encode(r.mbox||".",e,t,{mail:!0}),t+=g.encode.bytes,g.encode(r.txt||".",e,t),t+=g.encode.bytes,J.encode.bytes=t-n,e.writeUInt16BE(J.encode.bytes-2,n),e};J.encode.bytes=0;J.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.mbox=g.decode(r,e,{mail:!0})||".",e+=g.decode.bytes,n.txt=g.decode(r,e)||".",e+=g.decode.bytes,J.decode.bytes=e-t,n};J.decode.bytes=0;J.encodingLength=function(r){return 2+g.encodingLength(r.mbox||".")+g.encodingLength(r.txt||".")};var O={};O.encode=function(r,e,t){e||(e=E.alloc(O.encodingLength(r))),t||(t=0);let n=t;for(var i=[],o=0;o<r.length;o++){var c=ge.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,t),t+=1,e.writeUInt8(h.length,t),t+=1,h.copy(e,t),t+=h.length}return O.encode.bytes=t-n,e};O.encode.bytes=0;O.decode=function(r,e,t){e||(e=0);let n=e;for(var i=[];e-n<t;){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=ge.toString(o<<8|h<<3|d);i.push(m)}e+=c}return O.decode.bytes=e-n,i};O.decode.bytes=0;O.encodingLength=function(r){for(var e=[],t=0;t<r.length;t++){var n=ge.toType(r[t]);e[n>>8]=Math.max(e[n>>8]||0,n&255)}var i=0;for(t=0;t<e.length;t++)e[t]!==void 0&&(i+=2+Math.ceil((e[t]+1)/8));return i};var Z=w.nsec={};Z.encode=function(r,e,t){e||(e=E.alloc(Z.encodingLength(r))),t||(t=0);let n=t;return t+=2,g.encode(r.nextDomain,e,t),t+=g.encode.bytes,O.encode(r.rrtypes,e,t),t+=O.encode.bytes,Z.encode.bytes=t-n,e.writeUInt16BE(Z.encode.bytes-2,n),e};Z.encode.bytes=0;Z.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.nextDomain=g.decode(r,e),e+=g.decode.bytes,n.rrtypes=O.decode(r,e,i-(e-t)),e+=O.decode.bytes,Z.decode.bytes=e-t,n};Z.decode.bytes=0;Z.encodingLength=function(r){return 2+g.encodingLength(r.nextDomain)+O.encodingLength(r.rrtypes)};var f=w.nsec3={};f.encode=function(r,e,t){e||(e=E.alloc(f.encodingLength(r))),t||(t=0);let n=t,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 t+=2,e.writeUInt8(r.algorithm,t),t+=1,e.writeUInt8(r.flags,t),t+=1,e.writeUInt16BE(r.iterations,t),t+=2,e.writeUInt8(i.length,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,e.writeUInt8(o.length,t),t+=1,o.copy(e,t,0,o.length),t+=o.length,O.encode(r.rrtypes,e,t),t+=O.encode.bytes,f.encode.bytes=t-n,e.writeUInt16BE(f.encode.bytes-2,n),e};f.encode.bytes=0;f.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);e+=2,n.algorithm=r.readUInt8(e),e+=1,n.flags=r.readUInt8(e),e+=1,n.iterations=r.readUInt16BE(e),e+=2;let o=r.readUInt8(e);e+=1,n.salt=r.slice(e,e+o),e+=o;let c=r.readUInt8(e);return e+=1,n.nextDomain=r.slice(e,e+c),e+=c,n.rrtypes=O.decode(r,e,i-(e-t)),e+=O.decode.bytes,f.decode.bytes=e-t,n};f.decode.bytes=0;f.encodingLength=function(r){return 8+r.salt.length+r.nextDomain.length+O.encodingLength(r.rrtypes)};var ee=w.ds={};ee.encode=function(r,e,t){e||(e=E.alloc(ee.encodingLength(r))),t||(t=0);let n=t,i=r.digest;if(!E.isBuffer(i))throw new Error("Digest must be a Buffer");return t+=2,e.writeUInt16BE(r.keyTag,t),t+=2,e.writeUInt8(r.algorithm,t),t+=1,e.writeUInt8(r.digestType,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,ee.encode.bytes=t-n,e.writeUInt16BE(ee.encode.bytes-2,n),e};ee.encode.bytes=0;ee.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.keyTag=r.readUInt16BE(e),e+=2,n.algorithm=r.readUInt8(e),e+=1,n.digestType=r.readUInt8(e),e+=1,n.digest=r.slice(e,t+i+2),e+=n.digest.length,ee.decode.bytes=e-t,n};ee.decode.bytes=0;ee.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,t,n){t||(t=E.alloc(z.encodingLength(e))),n||(n=0);let i=n;n+=2,t[n]=e.algorithm,n+=1,t[n]=e.hash,n+=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(t,n),n+=o.byteLength,z.encode.bytes=n-i,t.writeUInt16BE(z.encode.bytes-2,i),t};z.encode.bytes=0;z.decode=function(e,t){t||(t=0);let n=t,i={};t+=2,i.algorithm=e[t],t+=1,i.hash=e[t],t+=1;let o=z.getFingerprintLengthForHashType(i.hash);return i.fingerprint=e.slice(t,t+o).toString("hex").toUpperCase(),t+=o,z.decode.bytes=t-n,i};z.decode.bytes=0;z.encodingLength=function(r){return 4+E.from(r.fingerprint,"hex").byteLength};var re=w.naptr={};re.encode=function(r,e,t){e||(e=E.alloc(re.encodingLength(r))),t||(t=0);let n=t;return t+=2,e.writeUInt16BE(r.order||0,t),t+=2,e.writeUInt16BE(r.preference||0,t),t+=2,I.encode(r.flags,e,t),t+=I.encode.bytes,I.encode(r.services,e,t),t+=I.encode.bytes,I.encode(r.regexp,e,t),t+=I.encode.bytes,g.encode(r.replacement,e,t),t+=g.encode.bytes,re.encode.bytes=t-n,e.writeUInt16BE(re.encode.bytes-2,n),e};re.encode.bytes=0;re.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.order=r.readUInt16BE(e),e+=2,n.preference=r.readUInt16BE(e),e+=2,n.flags=I.decode(r,e),e+=I.decode.bytes,n.services=I.decode(r,e),e+=I.decode.bytes,n.regexp=I.decode(r,e),e+=I.decode.bytes,n.replacement=g.decode(r,e),e+=g.decode.bytes,re.decode.bytes=e-t,n};re.decode.bytes=0;re.encodingLength=function(r){return I.encodingLength(r.flags)+I.encodingLength(r.services)+I.encodingLength(r.regexp)+g.encodingLength(r.replacement)+6};var te=w.tlsa={};te.encode=function(r,e,t){e||(e=E.alloc(te.encodingLength(r))),t||(t=0);let n=t,i=r.certificate;if(!E.isBuffer(i))throw new Error("Certificate must be a Buffer");return t+=2,e.writeUInt8(r.usage,t),t+=1,e.writeUInt8(r.selector,t),t+=1,e.writeUInt8(r.matchingType,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,te.encode.bytes=t-n,e.writeUInt16BE(te.encode.bytes-2,n),e};te.encode.bytes=0;te.decode=function(r,e){e||(e=0);let t=e,n={},i=r.readUInt16BE(e);return e+=2,n.usage=r.readUInt8(e),e+=1,n.selector=r.readUInt8(e),e+=1,n.matchingType=r.readUInt8(e),e+=1,n.certificate=r.slice(e,t+i+2),e+=n.certificate.length,te.decode.bytes=e-t,n};te.decode.bytes=0;te.encodingLength=function(r){return 5+E.byteLength(r.certificate)};var wr=w.record=function(r){switch(r.toUpperCase()){case"A":return he;case"PTR":return X;case"CNAME":return zn;case"DNAME":return $n;case"TXT":return ae;case"NULL":return de;case"AAAA":return pe;case"SRV":return ue;case"HINFO":return le;case"CAA":return M;case"NS":return ce;case"SOA":return se;case"MX":return we;case"OPT":return $;case"DNSKEY":return R;case"RRSIG":return Q;case"RP":return J;case"NSEC":return Z;case"NSEC3":return f;case"SSHFP":return z;case"DS":return ee;case"NAPTR":return re;case"TLSA":return te}return oe},N=w.answer={};N.encode=function(r,e,t){e||(e=E.alloc(N.encodingLength(r))),t||(t=0);let n=t;if(g.encode(r.name,e,t),t+=g.encode.bytes,e.writeUInt16BE(ge.toType(r.type),t),r.type.toUpperCase()==="OPT"){if(r.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(r.udpPayloadSize||4096,t+2),e.writeUInt8(r.extendedRcode||0,t+4),e.writeUInt8(r.ednsVersion||0,t+5),e.writeUInt16BE(r.flags||0,t+6),t+=8,$.encode(r.options||[],e,t),t+=$.encode.bytes}else{let i=Je.toClass(r.class===void 0?"IN":r.class);r.flush&&(i|=yr),e.writeUInt16BE(i,t+2),e.writeUInt32BE(r.ttl||0,t+4),t+=8;let o=wr(r.type);o.encode(r.data,e,t),t+=o.encode.bytes}return N.encode.bytes=t-n,e};N.encode.bytes=0;N.decode=function(r,e){e||(e=0);let t={},n=e;if(t.name=g.decode(r,e),e+=g.decode.bytes,t.type=ge.toString(r.readUInt16BE(e)),t.type==="OPT")t.udpPayloadSize=r.readUInt16BE(e+2),t.extendedRcode=r.readUInt8(e+4),t.ednsVersion=r.readUInt8(e+5),t.flags=r.readUInt16BE(e+6),t.flag_do=(t.flags>>15&1)===1,t.options=$.decode(r,e+8),e+=8+$.decode.bytes;else{let i=r.readUInt16BE(e+2);t.ttl=r.readUInt32BE(e+4),t.class=Je.toString(i&kn),t.flush=!!(i&yr);let o=wr(t.type);t.data=o.decode(r,e+8),e+=8+o.decode.bytes}return N.decode.bytes=e-n,t};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+wr(r.type).encodingLength(e)};var Y=w.question={};Y.encode=function(r,e,t){e||(e=E.alloc(Y.encodingLength(r))),t||(t=0);let n=t;return g.encode(r.name,e,t),t+=g.encode.bytes,e.writeUInt16BE(ge.toType(r.type),t),t+=2,e.writeUInt16BE(Je.toClass(r.class===void 0?"IN":r.class),t),t+=2,Y.encode.bytes=t-n,r};Y.encode.bytes=0;Y.decode=function(r,e){e||(e=0);let t=e,n={};return n.name=g.decode(r,e),e+=g.decode.bytes,n.type=ge.toString(r.readUInt16BE(e)),e+=2,n.class=Je.toString(r.readUInt16BE(e)),e+=2,!!(n.class&St)&&(n.class&=Mn),Y.decode.bytes=e-t,n};Y.decode.bytes=0;Y.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,t){let n=!e;n&&(e=E.alloc(w.encodingLength(r))),t||(t=0);let i=t;return r.questions||(r.questions=[]),r.answers||(r.answers=[]),r.authorities||(r.authorities=[]),r.additionals||(r.additionals=[]),G.encode(r,e,t),t+=G.encode.bytes,t=Be(r.questions,Y,e,t),t=Be(r.answers,N,e,t),t=Be(r.authorities,N,e,t),t=Be(r.additionals,N,e,t),w.encode.bytes=t-i,n&&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 t=e,n=G.decode(r,e);return e+=G.decode.bytes,e=Qe(n.questions,Y,r,e),e=Qe(n.answers,N,r,e),e=Qe(n.authorities,N,r,e),e=Qe(n.additionals,N,r,e),w.decode.bytes=e-t,n};w.decode.bytes=0;w.encodingLength=function(r){return G.encodingLength(r)+Le(r.questions||[],Y)+Le(r.answers||[],N)+Le(r.authorities||[],N)+Le(r.additionals||[],N)};w.streamEncode=function(r){let e=w.encode(r),t=E.alloc(2);t.writeUInt16BE(e.byteLength);let n=E.concat([t,e]);return w.streamEncode.bytes=n.byteLength,n};w.streamEncode.bytes=0;w.streamDecode=function(r){let e=r.readUInt16BE(0);if(r.byteLength<e+2)return null;let t=w.decode(r.slice(2));return w.streamDecode.bytes=w.decode.bytes,t};w.streamDecode.bytes=0;function Le(r,e){let t=0;for(let n=0;n<r.length;n++)t+=e.encodingLength(r[n]);return t}function Be(r,e,t,n){for(let i=0;i<r.length;i++)e.encode(r[i],t,n),n+=e.encode.bytes;return n}function Qe(r,e,t,n){for(let i=0;i<r.length;i++)r[i]=e.decode(t,n),n+=e.decode.bytes;return n}});var Ct=W((Oc,bt)=>{"use strict";var Lt=Xn;process.nextTick(jn,42);bt.exports=qn;function qn(r){var e=n;return t;function t(i){e(i||Kn)}function n(i){var o=[i];e=c,r(h);function c(a){o.push(a)}function h(a){var d=arguments;for(e=Vn(a)?n:m;o.length;)m(o.shift());function m(l){Lt(Hn,l,d)}}}}function Vn(r){return Object.prototype.toString.call(r)==="[object Error]"}function Kn(){}function Hn(r,e){r.apply(null,e)}function jn(r){r===42&&(Lt=process.nextTick)}function Xn(r,e,t){process.nextTick(function(){r(e,t)})}});var Nt=W((Tc,Tt)=>{var Er=Ut(),Yn=j("dgram"),Gn=Ct(),Wn=j("events"),xr=j("os"),Ir=function(){};Tt.exports=function(r){r||(r={});var e=new Wn.EventEmitter,t=typeof r.port=="number"?r.port:5353,n=r.type||"udp4",i=r.ip||r.host||(n==="udp4"?"224.0.0.251":null),o={address:i,port:t},c={},h=!1,a=null;if(n==="udp6"&&(!i||!r.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var d=r.socket||Yn.createSocket({type:n,reuseAddr:r.reuseAddr!==!1,toString:function(){return n}});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=Er.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(){t||(t=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=Gn(function(l){if(!t||r.bind===!1)return l(null);d.once("error",l),d.bind(t,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=Ir),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=Er.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)|Er.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=Ir),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=Ir),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):Jn(),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||Qn())}catch(y){e.emit("warning",y)}e.emit("networkInterface")}},e};function Qn(){for(var r=xr.networkInterfaces(),e=Object.keys(r),t=0;t<e.length;t++)for(var n=r[e[t]],i=0;i<n.length;i++){var o=n[i];if(Ot(o.family)&&!o.internal)return xr.platform()==="darwin"&&e[t]==="en0"?o.address:"0.0.0.0"}return"127.0.0.1"}function Jn(){for(var r=xr.networkInterfaces(),e=Object.keys(r),t=[],n=0;n<e.length;n++)for(var i=r[e[n]],o=0;o<i.length;o++){var c=i[o];if(Ot(c.family)){t.push(c.address);break}}return t}function Ot(r){return r===4||r==="IPv4"}});var on=W(He=>{(function(){var r,e,t,n,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")}},t=function(a){return a.charCodeAt(0)},n=t("0"),o=t("a"),i=t("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+(t(a[l])-n)>>>0;else if(d===16)if("a"<=a[l]&&a[l]<="f")u=u*d+(10+t(a[l])-o)>>>0;else if("A"<=a[l]&&a[l]<="F")u=u*d+(10+t(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}(),He.ip2long=c,He.long2ip=h,He.Netmask=r}).call(He)});var Ho={};k(Ho,{mdns:()=>Ko});var lt=Symbol.for("@libp2p/peer-discovery");var sr=Symbol.for("@libp2p/peer-id");var Ge=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var ut=j("events"),ht=(r,...e)=>{try{(0,ut.setMaxListeners)(r,...e)}catch{}};var We=class extends EventTarget{#e=new Map;constructor(){super(),ht(1/0,this)}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let i=this.#e.get(e);i==null&&(i=[],this.#e.set(e,i)),i.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let i=this.#e.get(e);i!=null&&(i=i.filter(({callback:o})=>o!==t),this.#e.set(e,i))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:i})=>!i),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new ar(e,t))}},ar=globalThis.CustomEvent;var pt=Symbol.for("@libp2p/service-capabilities"),Zo=Symbol.for("@libp2p/service-dependencies");var Cn=cr(Nt(),1);var Lr={};k(Lr,{base58btc:()=>P,base58flickr:()=>ni});var Nc=new Uint8Array(0);function Pt(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function q(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 Dt(r){return new TextEncoder().encode(r)}function Bt(r){return new TextDecoder().decode(r)}function Zn(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var i=0;i<r.length;i++){var o=r.charAt(i),c=o.charCodeAt(0);if(t[c]!==255)throw new TypeError(o+" is ambiguous");t[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,S=0,L=s.length;S!==L&&s[S]===0;)S++,y++;for(var B=(L-S)*m+1>>>0,T=new Uint8Array(B);S!==L;){for(var b=s[S],C=0,H=B-1;(b!==0||C<v)&&H!==-1;H--,C++)b+=256*T[H]>>>0,T[H]=b%h>>>0,b=b/h>>>0;if(b!==0)throw new Error("Non-zero carry");v=C,S++}for(var ie=B-v;ie!==B&&T[ie]===0;)ie++;for(var Xe=a.repeat(y);ie<B;++ie)Xe+=r.charAt(T[ie]);return Xe}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,S=0;s[y]===a;)v++,y++;for(var L=(s.length-y)*d+1>>>0,B=new Uint8Array(L);s[y];){var T=t[s.charCodeAt(y)];if(T===255)return;for(var b=0,C=L-1;(T!==0||b<S)&&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");S=b,y++}if(s[y]!==" "){for(var H=L-S;H!==L&&B[H]===0;)H++;for(var ie=new Uint8Array(v+(L-H)),Xe=v;H!==L;)ie[Xe++]=B[H++];return ie}}}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 fn=Zn,ei=fn,Rt=ei;var vr=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Ar=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return _t(this,e)}},Sr=class{decoders;constructor(e){this.decoders=e}or(e){return _t(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function _t(r,e){return new Sr({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Ur=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,i){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new vr(e,t,n),this.decoder=new Ar(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function be({name:r,prefix:e,encode:t,decode:n}){return new Ur(r,e,t,n)}function Ee({name:r,prefix:e,alphabet:t}){let{encode:n,decode:i}=Rt(t,r);return be({prefix:e,name:r,encode:n,decode:o=>q(i(o))})}function ri(r,e,t,n){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*t/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-${n} character`);a=a<<t|l,h+=t,h>=8&&(h-=8,c[d++]=255&a>>h)}if(h>=t||255&a<<8-h)throw new SyntaxError("Unexpected end of data");return c}function ti(r,e,t){let n=e[e.length-1]==="=",i=(1<<t)-1,o="",c=0,h=0;for(let a=0;a<r.length;++a)for(h=h<<8|r[a],c+=8;c>t;)c-=t,o+=e[i&h>>c];if(c!==0&&(o+=e[i&h<<t-c]),n)for(;o.length*t&7;)o+="=";return o}function U({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return be({prefix:e,name:r,encode(i){return ti(i,n,t)},decode(i){return ri(i,n,t,r)}})}var P=Ee({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ni=Ee({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var br={};k(br,{base10:()=>ii});var ii=Ee({prefix:"9",name:"base10",alphabet:"0123456789"});var Cr={};k(Cr,{base16:()=>oi,base16upper:()=>ci});var oi=U({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ci=U({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Or={};k(Or,{base2:()=>si});var si=U({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Tr={};k(Tr,{base256emoji:()=>hi});var kt=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}"),ai=kt.reduce((r,e,t)=>(r[t]=e,r),[]),di=kt.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function li(r){return r.reduce((e,t)=>(e+=ai[t],e),"")}function ui(r){let e=[];for(let t of r){let n=di[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var hi=be({prefix:"\u{1F680}",name:"base256emoji",encode:li,decode:ui});var Nr={};k(Nr,{base32:()=>me,base32hex:()=>yi,base32hexpad:()=>Ei,base32hexpadupper:()=>Ii,base32hexupper:()=>wi,base32pad:()=>gi,base32padupper:()=>mi,base32upper:()=>pi,base32z:()=>xi});var me=U({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pi=U({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),gi=U({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),mi=U({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),yi=U({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wi=U({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ei=U({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ii=U({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xi=U({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Pr={};k(Pr,{base36:()=>vi,base36upper:()=>Ai});var vi=Ee({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ai=Ee({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Dr={};k(Dr,{base64:()=>Si,base64pad:()=>Ui,base64url:()=>Li,base64urlpad:()=>bi});var Si=U({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ui=U({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Li=U({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),bi=U({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Br={};k(Br,{base8:()=>Ci});var Ci=U({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Fr={};k(Fr,{identity:()=>Oi});var Oi=be({prefix:"\0",name:"identity",encode:r=>Bt(r),decode:r=>Dt(r)});var Xc=new TextEncoder,Yc=new TextDecoder;var _r={};k(_r,{identity:()=>_e});var Pi=$t,Mt=128,Di=127,Bi=~Di,Fi=Math.pow(2,31);function $t(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Fi;)e[t++]=r&255|Mt,r/=128;for(;r&Bi;)e[t++]=r&255|Mt,r>>>=7;return e[t]=r|0,$t.bytes=t-n+1,e}var Ri=Rr,_i=128,zt=127;function Rr(r,n){var t=0,n=n||0,i=0,o=n,c,h=r.length;do{if(o>=h)throw Rr.bytes=0,new RangeError("Could not decode varint");c=r[o++],t+=i<28?(c&zt)<<i:(c&zt)*Math.pow(2,i),i+=7}while(c>=_i);return Rr.bytes=o-n,t}var ki=Math.pow(2,7),Mi=Math.pow(2,14),zi=Math.pow(2,21),$i=Math.pow(2,28),qi=Math.pow(2,35),Vi=Math.pow(2,42),Ki=Math.pow(2,49),Hi=Math.pow(2,56),ji=Math.pow(2,63),Xi=function(r){return r<ki?1:r<Mi?2:r<zi?3:r<$i?4:r<qi?5:r<Vi?6:r<Ki?7:r<Hi?8:r<ji?9:10},Yi={encode:Pi,decode:Ri,encodingLength:Xi},Gi=Yi,Fe=Gi;function Re(r,e=0){return[Fe.decode(r,e),Fe.decode.bytes]}function Ce(r,e,t=0){return Fe.encode(r,e,t),e}function Oe(r){return Fe.encodingLength(r)}function Ie(r,e){let t=e.byteLength,n=Oe(r),i=n+Oe(t),o=new Uint8Array(i+t);return Ce(r,o,0),Ce(t,o,n),o.set(e,i),new Te(r,t,e,o)}function Ae(r){let e=q(r),[t,n]=Re(e),[i,o]=Re(e.subarray(n)),c=e.subarray(n+o);if(c.byteLength!==i)throw new Error("Incorrect length");return new Te(t,i,c,e)}function qt(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Pt(r.bytes,t.bytes)}}var Te=class{code;size;digest;bytes;constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}};var Vt=0,Wi="identity",Kt=q;function Qi(r){return Ie(Vt,Kt(r))}var _e={code:Vt,name:Wi,encode:Kt,digest:Qi};var $r={};k($r,{sha256:()=>fe,sha512:()=>Ji});var zr=cr(j("crypto"),1);function Mr({name:r,code:e,encode:t}){return new kr(r,e,t)}var kr=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Ie(this.code,t):t.then(n=>Ie(this.code,n))}else throw Error("Unknown type, must be binary type")}};var fe=Mr({name:"sha2-256",code:18,encode:r=>q(zr.default.createHash("sha256").update(r).digest())}),Ji=Mr({name:"sha2-512",code:19,encode:r=>q(zr.default.createHash("sha512").update(r).digest())});function jt(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return fi(t,qr(r),e??P.encoder);default:return eo(t,qr(r),e??me.encoder)}}var Xt=new WeakMap;function qr(r){let e=Xt.get(r);if(e==null){let t=new Map;return Xt.set(r,t),t}return e}var V=class r{code;version;multihash;bytes;"/";constructor(e,t,n,i){this.code=t,this.version=e,this.multihash=n,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:t}=this;if(e!==ke)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==ro)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=Ie(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&qt(e.multihash,n.multihash)}toString(e){return jt(this,e)}toJSON(){return{"/":jt(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:i,multihash:o,bytes:c}=t;return new r(n,i,o,c??Yt(n,i,o.bytes))}else if(t[to]===!0){let{version:n,multihash:i,code:o}=t,c=Ae(i);return r.create(n,o,c)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==ke)throw new Error(`Version 0 CID must use dag-pb (code: ${ke}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let i=Yt(e,t,n.bytes);return new r(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,ke,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,i=q(e.subarray(n,n+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");let o=i.subarray(t.multihashSize-t.digestSize),c=new Te(t.multihashCode,t.digestSize,o,i);return[t.version===0?r.createV0(c):r.createV1(t.codec,c),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,u]=Re(e.subarray(t));return t+=u,l},i=n(),o=ke;if(i===18?(i=0,t=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let c=t,h=n(),a=n(),d=t+a,m=d-c;return{version:i,codec:o,multihashCode:h,digestSize:a,multihashSize:m,size:d}}static parse(e,t){let[n,i]=Zi(e,t),o=r.decode(i);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return qr(o).set(n,e),o}};function Zi(r,e){switch(r[0]){case"Q":{let t=e??P;return[P.prefix,t.decode(`${P.prefix}${r}`)]}case P.prefix:{let t=e??P;return[P.prefix,t.decode(r)]}case me.prefix:{let t=e??me;return[me.prefix,t.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 fi(r,e,t){let{prefix:n}=t;if(n!==P.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let i=e.get(n);if(i==null){let o=t.encode(r).slice(1);return e.set(n,o),o}else return i}function eo(r,e,t){let{prefix:n}=t,i=e.get(n);if(i==null){let o=t.encode(r);return e.set(n,o),o}else return i}var ke=112,ro=18;function Yt(r,e,t){let n=Oe(r),i=n+Oe(e),o=new Uint8Array(i+t.byteLength);return Ce(r,o,0),Ce(e,o,n),o.set(t,i),o}var to=Symbol.for("@ipld/js-cid/CID");var xe={...Fr,...Or,...Br,...br,...Cr,...Nr,...Pr,...Lr,...Dr,...Tr},ms={...$r,..._r};function Me(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var Jt=j("node:buffer");var Gt=j("node:buffer");function Ne(r){return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}function er(r=0){return Ne(Gt.Buffer.allocUnsafe(r))}function Qt(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Wt=Qt("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Vr=Qt("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=er(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),no={utf8:Wt,"utf-8":Wt,hex:xe.base16,latin1:Vr,ascii:Vr,binary:Vr,...xe},rr=no;function ze(r,e="utf8"){let t=rr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?Ne(Jt.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var Zt=j("node:buffer");function D(r,e="utf8"){let t=rr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?Zt.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var en=Symbol.for("nodejs.util.inspect.custom"),ft=Object.values(xe).map(r=>r.decoder).reduce((r,e)=>r.or(e),xe.identity.decoder),rn=114,tn=36,nn=37,$e=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()})`}[sr]=!0;toString(){return this.string==null&&(this.string=P.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return V.createV1(rn,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 jr(e).equals(this);if(e?.multihash?.bytes!=null)return Me(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[en](){return`PeerId(${this.toString()})`}},qe=class extends $e{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Ve=class extends $e{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Ke=class extends $e{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}},Kr=2336,Hr=class{type="url";multihash;privateKey;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=_e.digest(ze(this.url))}[en](){return`PeerId(${this.url})`}[sr]=!0;toString(){return this.toCID().toString()}toCID(){return V.createV1(Kr,this.multihash)}toBytes(){return this.toCID().bytes}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=D(e)),e.toString()===this.toString())}};function jr(r,e){if(e=e??ft,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=Ae(P.decode(`z${r}`));return r.startsWith("12D")?new Ve({multihash:t}):r.startsWith("16U")?new Ke({multihash:t}):new qe({multihash:t})}return io(ft.decode(r))}function io(r){try{let e=Ae(r);if(e.code===_e.code){if(e.digest.length===tn)return new Ve({multihash:e});if(e.digest.length===nn)return new Ke({multihash:e})}if(e.code===fe.code)return new qe({multihash:e})}catch{return oo(V.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function oo(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==rn&&r.code!==Kr)throw new Error("Supplied PeerID CID is invalid");if(r.code===Kr){let t=D(r.multihash.digest);return new Hr(new URL(t))}let e=r.multihash;if(e.code===fe.code)return new qe({multihash:r.multihash});if(e.code===_e.code){if(e.digest.length===tn)return new Ve({multihash:r.multihash});if(e.digest.length===nn)return new Ke({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var K=j("node:net");function tr(r){return!!(0,K.isIP)(r)}var cn=cr(on(),1),co=["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"],so=co.map(r=>new cn.Netmask(r));function Xr(r){for(let e of so)if(e.contains(r))return!0;return!1}function ao(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function lo(r){let e=r.split(":");if(e.length<2)return!1;let t=e[e.length-1].padStart(4,"0"),n=e[e.length-2].padStart(4,"0"),i=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(t.substring(0,2),16)}.${parseInt(t.substring(2),16)}`;return Xr(i)}function uo(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function ho(r){let e=r.split(":"),t=e[e.length-1];return Xr(t)}function po(r){return/^::$/.test(r)||/^::1$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function sn(r){return(0,K.isIPv4)(r)?Xr(r):ao(r)?lo(r):uo(r)?ho(r):(0,K.isIPv6)(r)?po(r):void 0}function an(r){try{let{address:e}=r.nodeAddress();return!!sn(e)}catch{return!0}}var go=Math.pow(2,7),mo=Math.pow(2,14),yo=Math.pow(2,21),Yr=Math.pow(2,28),Gr=Math.pow(2,35),Wr=Math.pow(2,42),Qr=Math.pow(2,49),x=128,F=127;function ne(r){if(r<go)return 1;if(r<mo)return 2;if(r<yo)return 3;if(r<Yr)return 4;if(r<Gr)return 5;if(r<Wr)return 6;if(r<Qr)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function wo(r,e,t=0){switch(ne(r)){case 8:e[t++]=r&255|x,r/=128;case 7:e[t++]=r&255|x,r/=128;case 6:e[t++]=r&255|x,r/=128;case 5:e[t++]=r&255|x,r/=128;case 4:e[t++]=r&255|x,r>>>=7;case 3:e[t++]=r&255|x,r>>>=7;case 2:e[t++]=r&255|x,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Eo(r,e,t=0){switch(ne(r)){case 8:e.set(t++,r&255|x),r/=128;case 7:e.set(t++,r&255|x),r/=128;case 6:e.set(t++,r&255|x),r/=128;case 5:e.set(t++,r&255|x),r/=128;case 4:e.set(t++,r&255|x),r>>>=7;case 3:e.set(t++,r&255|x),r>>>=7;case 2:e.set(t++,r&255|x),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function Io(r,e){let t=r[e],n=0;if(n+=t&F,t<x||(t=r[e+1],n+=(t&F)<<7,t<x)||(t=r[e+2],n+=(t&F)<<14,t<x)||(t=r[e+3],n+=(t&F)<<21,t<x)||(t=r[e+4],n+=(t&F)*Yr,t<x)||(t=r[e+5],n+=(t&F)*Gr,t<x)||(t=r[e+6],n+=(t&F)*Wr,t<x)||(t=r[e+7],n+=(t&F)*Qr,t<x))return n;throw new RangeError("Could not decode varint")}function xo(r,e){let t=r.get(e),n=0;if(n+=t&F,t<x||(t=r.get(e+1),n+=(t&F)<<7,t<x)||(t=r.get(e+2),n+=(t&F)<<14,t<x)||(t=r.get(e+3),n+=(t&F)<<21,t<x)||(t=r.get(e+4),n+=(t&F)*Yr,t<x)||(t=r.get(e+5),n+=(t&F)*Gr,t<x)||(t=r.get(e+6),n+=(t&F)*Wr,t<x)||(t=r.get(e+7),n+=(t&F)*Qr,t<x))return n;throw new RangeError("Could not decode varint")}function Pe(r,e,t=0){return e==null&&(e=er(ne(r))),e instanceof Uint8Array?wo(r,e,t):Eo(r,e,t)}function Ue(r,e=0){return r instanceof Uint8Array?Io(r,e):xo(r,e)}var ln=j("node:buffer");function ye(r,e){return Ne(ln.Buffer.concat(r,e))}var nr=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,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,t!==void 0&&c>t))return}if(c!==0)return!n&&a&&c>1?void 0:o})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let i=n*2;if(n<t.length-3){let c=this.readSeparator(":",n,()=>this.readIPv4Addr());if(c!==void 0)return t[i]=c[0],t[i+1]=c[1],t[i+2]=c[2],t[i+3]=c[3],[i+4,!0]}let o=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(o===void 0)return[i,!1];t[i]=o>>8,t[i+1]=o&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,i]=e(t);if(n===16)return t;if(i||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),c=16-(n+2),[h]=e(o.subarray(0,c));return t.set(o.subarray(0,h),16-h),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Qs=new nr;var ia=parseInt("0xFFFF",16),oa=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var pn=K.isIPv4,bo=K.isIPv6,Jr=function(r){let e=0;if(r=r.toString().trim(),pn(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(bo(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let o=pn(t[n]),c;o&&(c=Jr(t[n]),t[n]=D(c.slice(0,2),"base16")),c!=null&&++n<8&&t.splice(n,0,D(c.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let o=[n,1];for(n=9-t.length;n>0;n--)o.push("0");t.splice.apply(t,o)}let i=new Uint8Array(e+16);for(n=0;n<t.length;n++){let o=parseInt(t[n],16);i[e++]=o>>8&255,i[e++]=o&255}return i}throw new Error("invalid ip address")},gn=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let i=[];for(let o=0;o<t;o++)i.push(r[e+o]);return i.join(".")}if(t===16){let i=[];for(let o=0;o<t;o+=2)i.push(n.getUint16(e+o).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var De={},Zr={},Oo=[[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"],[481,-1,"http-path"],[777,-1,"memory"]];Oo.forEach(r=>{let e=To(...r);Zr[e.code]=e,De[e.name]=e});function To(r,e,t,n,i){return{code:r,size:e,name:t,resolvable:!!n,path:!!i}}function A(r){if(typeof r=="number"){if(Zr[r]!=null)return Zr[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 Va=A("ip4"),Ka=A("ip6"),Ha=A("ipcidr");function tt(r,e){switch(A(r).code){case 4:case 41:return Po(e);case 42:return rt(e);case 6:case 273:case 33:case 132:return wn(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return rt(e);case 421:return Ro(e);case 444:return yn(e);case 445:return yn(e);case 466:return Fo(e);case 481:return globalThis.encodeURIComponent(rt(e));default:return D(e,"base16")}}function nt(r,e){switch(A(r).code){case 4:return mn(e);case 41:return mn(e);case 42:return et(e);case 6:case 273:case 33:case 132:return it(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return et(e);case 421:return Do(e);case 444:return _o(e);case 445:return ko(e);case 466:return Bo(e);case 481:return et(globalThis.decodeURIComponent(e));default:return ze(e,"base16")}}var fr=Object.values(xe).map(r=>r.decoder),No=function(){let r=fr[0].or(fr[1]);return fr.slice(2).forEach(e=>r=r.or(e)),r}();function mn(r){if(!tr(r))throw new Error("invalid ip address");return Jr(r)}function Po(r){let e=gn(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!tr(e))throw new Error("invalid ip address");return e}function it(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function wn(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function et(r){let e=ze(r),t=Uint8Array.from(Pe(e.length));return ye([t,e],t.length+e.length)}function rt(r){let e=Ue(r);if(r=r.slice(ne(e)),r.length!==e)throw new Error("inconsistent lengths");return D(r)}function Do(r){let e;r[0]==="Q"||r[0]==="1"?e=Ae(P.decode(`z${r}`)).bytes:e=V.parse(r).multihash.bytes;let t=Uint8Array.from(Pe(e.length));return ye([t,e],t.length+e.length)}function Bo(r){let e=No.decode(r),t=Uint8Array.from(Pe(e.length));return ye([t,e],t.length+e.length)}function Fo(r){let e=Ue(r),t=r.slice(ne(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+D(t,"base64url")}function Ro(r){let e=Ue(r),t=r.slice(ne(e));if(t.length!==e)throw new Error("inconsistent lengths");return D(t,"base58btc")}function _o(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=me.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=it(n);return ye([t,i],t.length+i.length)}function ko(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=me.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=it(n);return ye([t,i],t.length+i.length)}function yn(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=D(e,"base32"),i=wn(t);return`${n}:${i}`}function En(r){r=ot(r);let e=[],t=[],n=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]),t.push([h.code]);continue}if(o++,o>=i.length)throw xn("invalid address: "+r);if(h.path===!0){n=ot(i.slice(o).join("/")),e.push([h.code,nt(h.code,n)]),t.push([h.code,n]);break}let a=nt(h.code,i[o]);e.push([h.code,a]),t.push([h.code,tt(h.code,a)])}return{string:In(t),bytes:st(e),tuples:e,stringTuples:t,path:n}}function ct(r){let e=[],t=[],n=null,i=0;for(;i<r.length;){let o=Ue(r,i),c=ne(o),h=A(o),a=Mo(h,r.slice(i+c));if(a===0){e.push([o]),t.push([o]),i+=c;continue}let d=r.slice(i+c,i+c+a);if(i+=a+c,i>r.length)throw xn("Invalid address Uint8Array: "+D(r,"base16"));e.push([o,d]);let m=tt(o,d);if(t.push([o,m]),h.path===!0){n=m;break}}return{bytes:Uint8Array.from(r),string:In(t),tuples:e,stringTuples:t,path:n}}function In(r){let e=[];return r.map(t=>{let n=A(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),ot(e.join("/"))}function st(r){return ye(r.map(e=>{let t=A(e[0]),n=Uint8Array.from(Pe(t.code));return e.length>1&&e[1]!=null&&(n=ye([n,e[1]])),n}))}function Mo(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Ue(e instanceof Uint8Array?e:Uint8Array.from(e));return t+ne(t)}}function ot(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function xn(r){return new Error("Error parsing address: "+r)}var zo=Symbol.for("nodejs.util.inspect.custom"),at=Symbol.for("@multiformats/js-multiaddr/multiaddr"),$o=[A("dns").code,A("dns4").code,A("dns6").code,A("dnsaddr").code],ir=class r{bytes;#e;#r;#t;#n;[at]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=ct(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=En(e)}else if(An(e))t=ct(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#r=t.tuples,this.#t=t.stringTuples,this.#n=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,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??""}`),$o.includes(p)&&(t=c.name,i=443,n=`${s??""}${o}`,e=p===m.code?6:4),(p===c.code||p===h.code)&&(t=A(p).name,i=parseInt(s??"")),(p===a.code||p===d.code)&&(t=A(p).name,n=`${s??""}${o}`,e=p===d.code?6:4);if(e==null||t==null||n==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:n,transport:t,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.#t}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),i=n.lastIndexOf(t);if(i<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,i))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(st(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,i])=>{n===De.p2p.code&&e.push([n,i]),n===De["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?D(P.decode(`z${n}`),"base58btc"):D(V.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return Me(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(o=>o.resolvable);if(t==null)return[this];let n=vn.get(t.name);if(n==null)throw new Ge(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(o=>je(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 t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[zo](){return`Multiaddr(${this.#e})`}};var vn=new Map;function An(r){return!!r?.[at]}function je(r){return new ir(r)}function Sn(r,e,t,n){let i=()=>{n?.log.trace("query",e),r.query({questions:[{name:e,type:"PTR"}]})};return i(),setInterval(i,t)}function Un(r,e,t,n){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!==t||o.length===0||i.data.startsWith(e)))try{let c=o.flatMap(a=>a.data).filter(a=>a.toString().startsWith("dnsaddr=")).map(a=>je(a.toString().substring(8))),h=c[0].getPeerId();if(h==null)throw new Error("Multiaddr doesn't contain PeerId");return n?.log("peer found %p",h),{id:jr(h),multiaddrs:c.map(a=>a.decapsulateCode(A("p2p").code))}}catch(c){n?.log.error("failed to parse mdns response",c)}}function Ln(r,e,t,n,i,o,c){if(!o){c?.log("not responding to mDNS query as broadcast mode is false");return}if(n.length!==0&&r.questions[0]!=null&&r.questions[0].name===i){let h=[];h.push({name:i,type:"PTR",class:"IN",ttl:120,data:t+"."+i}),n.filter(qo).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:t+"."+i,type:"TXT",class:"IN",ttl:120,data:d})}),c?.log.trace("responding to query"),e.respond(h)}}function qo(r){return!!an(r)}function bn(r){let e="",t="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<r;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}var or=class extends We{mdns;log;broadcast;interval;serviceTag;peerName;port;ip;_queryInterval;components;constructor(e,t={}){if(super(),this.log=e.logger.forComponent("libp2p:mdns"),this.broadcast=t.broadcast!==!1,this.interval=t.interval??1e3*10,this.serviceTag=t.serviceTag??"_p2p._udp.local",this.ip=t.ip??"224.0.0.251",this.peerName=t.peerName??bn(63),this.peerName.length>=64)throw new Error("Peer name should be less than 64 chars long");this.port=t.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)}[lt]=this;[Symbol.toStringTag]="@libp2p/mdns";[pt]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,Cn.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=Sn(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),Ln(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 t=Un(e,this.peerName,this.serviceTag,{log:this.log});t!=null&&(this.log("discovered peer in mDNS query response %p",t.id),this.dispatchEvent(new ar("peer",{detail:t})))}catch(t){this.log.error("Error processing peer response",t)}}_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 Ko(r={}){return e=>new or(e,r)}return Bn(Ho);})();
|
|
3
3
|
return Libp2PMdns}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/mdns",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.5",
|
|
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",
|
|
@@ -50,19 +50,19 @@
|
|
|
50
50
|
"test:electron-main": "aegir test -t electron-main"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@libp2p/interface": "^1.
|
|
54
|
-
"@libp2p/interface-internal": "^1.3.
|
|
55
|
-
"@libp2p/peer-id": "^4.2.
|
|
56
|
-
"@libp2p/utils": "^5.4.
|
|
53
|
+
"@libp2p/interface": "^1.7.0",
|
|
54
|
+
"@libp2p/interface-internal": "^1.3.4",
|
|
55
|
+
"@libp2p/peer-id": "^4.2.4",
|
|
56
|
+
"@libp2p/utils": "^5.4.9",
|
|
57
57
|
"@multiformats/multiaddr": "^12.2.3",
|
|
58
58
|
"@types/multicast-dns": "^7.2.4",
|
|
59
59
|
"dns-packet": "^5.6.1",
|
|
60
60
|
"multicast-dns": "^7.2.5"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@libp2p/interface-compliance-tests": "^5.4.
|
|
64
|
-
"@libp2p/logger": "^4.0.
|
|
65
|
-
"@libp2p/peer-id-factory": "^4.2.
|
|
63
|
+
"@libp2p/interface-compliance-tests": "^5.4.12",
|
|
64
|
+
"@libp2p/logger": "^4.0.20",
|
|
65
|
+
"@libp2p/peer-id-factory": "^4.2.4",
|
|
66
66
|
"aegir": "^44.0.1",
|
|
67
67
|
"p-wait-for": "^5.0.2",
|
|
68
68
|
"sinon-ts": "^2.0.0"
|