@libp2p/mdns 10.0.11 → 10.0.12-3e47d88fd
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 +2 -2
- package/package.json +10 -9
- package/dist/typedoc-urls.json +0 -4
package/dist/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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 Nn=Object.create;var Qe=Object.defineProperty;var Bn=Object.getOwnPropertyDescriptor;var Fn=Object.getOwnPropertyNames;var fn=Object.getPrototypeOf,kn=Object.prototype.hasOwnProperty;var Ce=(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 j=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),$=(r,e)=>{for(var t in e)Qe(r,t,{get:e[t],enumerable:!0})},lt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Fn(e))!kn.call(r,i)&&i!==t&&Qe(r,i,{get:()=>e[i],enumerable:!(n=Bn(e,i))||n.enumerable});return r};var We=(r,e,t)=>(t=r!=null?Nn(fn(r)):{},lt(e||!r||!r.__esModule?Qe(t,"default",{value:r,enumerable:!0}):t,r)),$n=r=>lt(Qe({},"__esModule",{value:!0}),r);var mt=j(hr=>{"use strict";hr.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};hr.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=j(pr=>{"use strict";pr.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};pr.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=j(gr=>{"use strict";gr.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};gr.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 It=j(mr=>{"use strict";mr.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};mr.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 xt=j(yr=>{"use strict";yr.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}`};yr.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=j((vt,wr)=>{var Et=function(r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.decode=g,r.encode=x,r.familyOf=p,r.name=void 0,r.sizeOf=h,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,c={name:"v4",size:t,isFormat:d=>e.test(d),encode(d,o,s){s=~~s,o=o||new Uint8Array(s+t);let a=d.length,l=0;for(let y=0;y<a;){let w=d.charCodeAt(y++);w===46?(o[s++]=l,l=0):l=l*10+(w-48)}return o[s]=l,o},decode(d,o){return o=~~o,`${d[o++]}.${d[o++]}.${d[o++]}.${d[o]}`}};r.v4=c;let u={name:"v6",size:i,isFormat:d=>d.length>0&&n.test(d),encode(d,o,s){s=~~s;let a=s+i,l=-1,y=0,w=0,A=!0,O=!1;o=o||new Uint8Array(s+i);for(let P=0;P<d.length;P++){let L=d.charCodeAt(P);L===58?(A?l!==-1?(s<a&&(o[s]=0),s<a-1&&(o[s+1]=0),s+=2):s<a&&(l=s):(O===!0?(s<a&&(o[s]=w),s++):(s<a&&(o[s]=y>>8),s<a-1&&(o[s+1]=y&255),s+=2),y=0,w=0),A=!0,O=!1):L===46?(s<a&&(o[s]=w),s++,w=0,y=0,A=!1,O=!0):(A=!1,L>=97?L-=87:L>=65?L-=55:(L-=48,w=w*10+L),y=(y<<4)+L)}if(A===!1)O===!0?(s<a&&(o[s]=w),s++):(s<a&&(o[s]=y>>8),s<a-1&&(o[s+1]=y&255),s+=2);else if(l===0)s<a&&(o[s]=0),s<a-1&&(o[s+1]=0),s+=2;else if(l!==-1){s+=2;for(let P=Math.min(s-1,a-1);P>=l+2;P--)o[P]=o[P-2];o[l]=0,o[l+1]=0,l=s}if(l!==s&&l!==-1)for(s>a-2&&(s=a-2);a>l;)o[--a]=s<a&&s>l?o[--s]:0;else for(;s<a;)o[s++]=0;return o},decode(d,o){o=~~o;let s="";for(let a=0;a<i;a+=2)a!==0&&(s+=":"),s+=(d[o+a]<<8|d[o+a+1]).toString(16);return s.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};r.v6=u;let m="ip";r.name=m;function h(d){if(c.isFormat(d))return c.size;if(u.isFormat(d))return u.size;throw Error(`Invalid ip address: ${d}`)}function p(d){return h(d)===c.size?1:2}function x(d,o,s){s=~~s;let a=h(d);return typeof o=="function"&&(o=o(s+a)),a===c.size?c.encode(d,o,s):u.encode(d,o,s)}function g(d,o,s){if(o=~~o,s=s||d.length-o,s===c.size)return c.decode(d,o,s);if(s===u.size)return u.decode(d,o,s);throw Error(`Invalid buffer size needs to be ${c.size} for v4 or ${u.size} for v6.`)}return"default"in r?r.default:r}({});typeof define=="function"&&define.amd?define([],function(){return Et}):typeof wr=="object"&&typeof vt=="object"&&(wr.exports=Et)});var Ut=j(E=>{"use strict";var v=Ce("buffer").Buffer,ge=mt(),Mn=yt(),_n=wt(),er=It(),Ir=xt(),Se=At(),zn=0,St=32768,xr=32768,Vn=~xr,bt=32768,qn=~bt,I=E.name={};I.encode=function(r,e,t,{mail:n=!1}={}){e||(e=v.alloc(I.encodingLength(r))),t||(t=0);let i=t,c=r.replace(/^\.|\.$/gm,"");if(c.length){let u=[];if(n){let m="";c.split(".").forEach(h=>{h.endsWith("\\")?m+=(m.length?".":"")+h.slice(0,-1):u.length===0&&m.length?u.push(m+"."+h):u.push(h)})}else u=c.split(".");for(let m=0;m<u.length;m++){let h=e.write(u[m],t+1);e[t]=h,t+=h+1}}return e[t++]=0,I.encode.bytes=t-i,e};I.encode.bytes=0;I.decode=function(r,e,{mail:t=!1}={}){e||(e=0);let n=[],i=e,c=0,u=0,m=!1;for(;;){if(e>=r.length)throw new Error("Cannot decode name (buffer overflow)");let h=r[e++];if(u+=m?0:1,h===0)break;if(h&192)if((h&192)===192){if(e+1>r.length)throw new Error("Cannot decode name (buffer overflow)");let p=r.readUInt16BE(e-1)-49152;if(p>=i)throw new Error("Cannot decode name (bad pointer)");e=p,i=p,u+=m?0:1,m=!0}else throw new Error("Cannot decode name (bad label)");else{if(e+h>r.length)throw new Error("Cannot decode name (buffer overflow)");if(c+=h+1,c>254)throw new Error("Cannot decode name (name too long)");let p=r.toString("utf-8",e,e+h);t&&(p=p.replace(/\./g,"\\.")),n.push(p),e+=h,u+=m?0:h}}return I.decode.bytes=u,n.length===0?".":n.join(".")};I.decode.bytes=0;I.encodingLength=function(r){return r==="."||r===".."?1:v.byteLength(r.replace(/^\.|\.$/gm,""))+2};var S={};S.encode=function(r,e,t){e||(e=v.alloc(S.encodingLength(r))),t||(t=0);let n=e.write(r,t+1);return e[t]=n,S.encode.bytes=n+1,e};S.encode.bytes=0;S.decode=function(r,e){e||(e=0);let t=r[e],n=r.toString("utf-8",e+1,e+1+t);return S.decode.bytes=t+1,n};S.decode.bytes=0;S.encodingLength=function(r){return v.byteLength(r)+1};var X={};X.encode=function(r,e,t){e||(e=X.encodingLength(r)),t||(t=0);let n=(r.flags||0)&32767,i=r.type==="response"?St:zn;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};X.encode.bytes=12;X.decode=function(r,e){if(e||(e=0),r.length<12)throw new Error("Header must be 12 bytes");let 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:Mn.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))}};X.decode.bytes=12;X.encodingLength=function(){return 12};var oe=E.unknown={};oe.encode=function(r,e,t){return e||(e=v.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 se=E.ns={};se.encode=function(r,e,t){return e||(e=v.alloc(se.encodingLength(r))),t||(t=0),I.encode(r,e,t+2),e.writeUInt16BE(I.encode.bytes,t),se.encode.bytes=I.encode.bytes+2,e};se.encode.bytes=0;se.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n=I.decode(r,e+2);return se.decode.bytes=t+2,n};se.decode.bytes=0;se.encodingLength=function(r){return I.encodingLength(r)+2};var ce=E.soa={};ce.encode=function(r,e,t){e||(e=v.alloc(ce.encodingLength(r))),t||(t=0);let n=t;return t+=2,I.encode(r.mname,e,t),t+=I.encode.bytes,I.encode(r.rname,e,t,{mail:!0}),t+=I.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),ce.encode.bytes=t-n,e};ce.encode.bytes=0;ce.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.mname=I.decode(r,e),e+=I.decode.bytes,n.rname=I.decode(r,e,{mail:!0}),e+=I.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,ce.decode.bytes=e-t,n};ce.decode.bytes=0;ce.encodingLength=function(r){return 22+I.encodingLength(r.mname)+I.encodingLength(r.rname)};var ae=E.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]=v.from(r[i])),!v.isBuffer(r[i]))throw new Error("Must be a Buffer");e||(e=v.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 c=r[e++];if(--n,n<c)throw new Error("Buffer overflow");i.push(r.slice(e,e+c)),e+=c,n-=c}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+=v.byteLength(t)+1:e+=t.length+1}),e};var de=E.null={};de.encode=function(r,e,t){e||(e=v.alloc(de.encodingLength(r))),t||(t=0),typeof r=="string"&&(r=v.from(r)),r||(r=v.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?(v.isBuffer(r)?r.length:v.byteLength(r))+2:2};var le=E.hinfo={};le.encode=function(r,e,t){e||(e=v.alloc(le.encodingLength(r))),t||(t=0);let n=t;return t+=2,S.encode(r.cpu,e,t),t+=S.encode.bytes,S.encode(r.os,e,t),t+=S.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=S.decode(r,e),e+=S.decode.bytes,n.os=S.decode(r,e),e+=S.decode.bytes,le.decode.bytes=e-t,n};le.decode.bytes=0;le.encodingLength=function(r){return S.encodingLength(r.cpu)+S.encodingLength(r.os)+2};var K=E.ptr={},jn=E.cname=K,Kn=E.dname=K;K.encode=function(r,e,t){return e||(e=v.alloc(K.encodingLength(r))),t||(t=0),I.encode(r,e,t+2),e.writeUInt16BE(I.encode.bytes,t),K.encode.bytes=I.encode.bytes+2,e};K.encode.bytes=0;K.decode=function(r,e){e||(e=0);let t=I.decode(r,e+2);return K.decode.bytes=I.decode.bytes+2,t};K.decode.bytes=0;K.encodingLength=function(r){return I.encodingLength(r)+2};var ue=E.srv={};ue.encode=function(r,e,t){e||(e=v.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),I.encode(r.target,e,t+8);let n=I.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=I.decode(r,e+8),ue.decode.bytes=t+2,n};ue.decode.bytes=0;ue.encodingLength=function(r){return 8+I.encodingLength(r.target)};var M=E.caa={};M.ISSUER_CRITICAL=128;M.encode=function(r,e,t){let n=M.encodingLength(r);return e||(e=v.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,S.encode(r.tag,e,t),t+=S.encode.bytes,e.write(r.value,t),t+=v.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=S.decode(r,e),e+=S.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 S.encodingLength(r.tag)+S.encodingLength(r.value)+2};var we=E.mx={};we.encode=function(r,e,t){e||(e=v.alloc(we.encodingLength(r))),t||(t=0);let n=t;return t+=2,e.writeUInt16BE(r.preference||0,t),t+=2,I.encode(r.exchange,e,t),t+=I.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=I.decode(r,e),e+=I.decode.bytes,we.decode.bytes=e-t,n};we.encodingLength=function(r){return 4+I.encodingLength(r.exchange)};var he=E.a={};he.encode=function(r,e,t){return e||(e=v.alloc(he.encodingLength(r))),t||(t=0),e.writeUInt16BE(4,t),t+=2,Se.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=Se.v4.decode(r,e);return he.decode.bytes=6,t};he.decode.bytes=0;he.encodingLength=function(){return 6};var pe=E.aaaa={};pe.encode=function(r,e,t){return e||(e=v.alloc(pe.encodingLength(r))),t||(t=0),e.writeUInt16BE(16,t),t+=2,Se.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=Se.v6.decode(r,e);return pe.decode.bytes=18,t};pe.decode.bytes=0;pe.encodingLength=function(){return 18};var f=E.option={};f.encode=function(r,e,t){e||(e=v.alloc(f.encodingLength(r))),t||(t=0);let n=t,i=Ir.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 c=r.sourcePrefixLength||0,u=r.family||Se.familyOf(r.ip),m=Se.encode(r.ip,v.alloc),h=Math.ceil(c/8);e.writeUInt16BE(h+4,t),t+=2,e.writeUInt16BE(u,t),t+=2,e.writeUInt8(c,t++),e.writeUInt8(r.scopePrefixLength||0,t++),m.copy(e,t,0,h),t+=h;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 p=r.length||0;e.writeUInt16BE(p,t),t+=2,e.fill(0,t,t+p),t+=p;break;case 14:let x=r.tags.length*2;e.writeUInt16BE(x,t),t+=2;for(let g of r.tags)e.writeUInt16BE(g,t),t+=2;break;default:throw new Error(`Unknown roption code: ${r.code}`)}return f.encode.bytes=t-n,e};f.encode.bytes=0;f.decode=function(r,e){e||(e=0);let t={};t.code=r.readUInt16BE(e),t.type=Ir.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=v.alloc(t.family===1?4:16);r.copy(i,0,e,e+n-4),t.ip=Se.decode(i);break;case 11:n>0&&(t.timeout=r.readUInt16BE(e),e+=2);break;case 14:t.tags=[];for(let c=0;c<n;c+=2)t.tags.push(r.readUInt16BE(e)),e+=2}return f.decode.bytes=n+4,t};f.decode.bytes=0;f.encodingLength=function(r){if(r.data)return r.data.length+4;switch(Ir.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 z=E.opt={};z.encode=function(r,e,t){e||(e=v.alloc(z.encodingLength(r))),t||(t=0);let n=t,i=Oe(r,f);return e.writeUInt16BE(i,t),t=Me(r,f,e,t+2),z.encode.bytes=t-n,e};z.encode.bytes=0;z.decode=function(r,e){e||(e=0);let t=e,n=[],i=r.readUInt16BE(e);e+=2;let c=0;for(;i>0;)n[c++]=f.decode(r,e),e+=f.decode.bytes,i-=f.decode.bytes;return z.decode.bytes=e-t,n};z.decode.bytes=0;z.encodingLength=function(r){return 2+Oe(r||[],f)};var F=E.dnskey={};F.PROTOCOL_DNSSEC=3;F.ZONE_KEY=128;F.SECURE_ENTRYPOINT=32768;F.encode=function(r,e,t){e||(e=v.alloc(F.encodingLength(r))),t||(t=0);let n=t,i=r.key;if(!v.isBuffer(i))throw new Error("Key must be a Buffer");return t+=2,e.writeUInt16BE(r.flags,t),t+=2,e.writeUInt8(F.PROTOCOL_DNSSEC,t),t+=1,e.writeUInt8(r.algorithm,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,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);if(e+=2,n.flags=r.readUInt16BE(e),e+=2,r.readUInt8(e)!==F.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,F.decode.bytes=e-t,n};F.decode.bytes=0;F.encodingLength=function(r){return 6+v.byteLength(r.key)};var Q=E.rrsig={};Q.encode=function(r,e,t){e||(e=v.alloc(Q.encodingLength(r))),t||(t=0);let n=t,i=r.signature;if(!v.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,I.encode(r.signersName,e,t),t+=I.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=I.decode(r,e),e+=I.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+I.encodingLength(r.signersName)+v.byteLength(r.signature)};var W=E.rp={};W.encode=function(r,e,t){e||(e=v.alloc(W.encodingLength(r))),t||(t=0);let n=t;return t+=2,I.encode(r.mbox||".",e,t,{mail:!0}),t+=I.encode.bytes,I.encode(r.txt||".",e,t),t+=I.encode.bytes,W.encode.bytes=t-n,e.writeUInt16BE(W.encode.bytes-2,n),e};W.encode.bytes=0;W.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.mbox=I.decode(r,e,{mail:!0})||".",e+=I.decode.bytes,n.txt=I.decode(r,e)||".",e+=I.decode.bytes,W.decode.bytes=e-t,n};W.decode.bytes=0;W.encodingLength=function(r){return 2+I.encodingLength(r.mbox||".")+I.encodingLength(r.txt||".")};var T={};T.encode=function(r,e,t){e||(e=v.alloc(T.encodingLength(r))),t||(t=0);let n=t;for(var i=[],c=0;c<r.length;c++){var u=ge.toType(r[c]);i[u>>8]===void 0&&(i[u>>8]=[]),i[u>>8][u>>3&31]|=1<<7-(u&7)}for(c=0;c<i.length;c++)if(i[c]!==void 0){var m=v.from(i[c]);e.writeUInt8(c,t),t+=1,e.writeUInt8(m.length,t),t+=1,m.copy(e,t),t+=m.length}return T.encode.bytes=t-n,e};T.encode.bytes=0;T.decode=function(r,e,t){e||(e=0);let n=e;for(var i=[];e-n<t;){var c=r.readUInt8(e);e+=1;var u=r.readUInt8(e);e+=1;for(var m=0;m<u;m++)for(var h=r.readUInt8(e+m),p=0;p<8;p++)if(h&1<<7-p){var x=ge.toString(c<<8|m<<3|p);i.push(x)}e+=u}return T.decode.bytes=e-n,i};T.decode.bytes=0;T.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 J=E.nsec={};J.encode=function(r,e,t){e||(e=v.alloc(J.encodingLength(r))),t||(t=0);let n=t;return t+=2,I.encode(r.nextDomain,e,t),t+=I.encode.bytes,T.encode(r.rrtypes,e,t),t+=T.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;var n={},i=r.readUInt16BE(e);return e+=2,n.nextDomain=I.decode(r,e),e+=I.decode.bytes,n.rrtypes=T.decode(r,e,i-(e-t)),e+=T.decode.bytes,J.decode.bytes=e-t,n};J.decode.bytes=0;J.encodingLength=function(r){return 2+I.encodingLength(r.nextDomain)+T.encodingLength(r.rrtypes)};var Z=E.nsec3={};Z.encode=function(r,e,t){e||(e=v.alloc(Z.encodingLength(r))),t||(t=0);let n=t,i=r.salt;if(!v.isBuffer(i))throw new Error("salt must be a Buffer");let c=r.nextDomain;if(!v.isBuffer(c))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(c.length,t),t+=1,c.copy(e,t,0,c.length),t+=c.length,T.encode(r.rrtypes,e,t),t+=T.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);e+=2,n.algorithm=r.readUInt8(e),e+=1,n.flags=r.readUInt8(e),e+=1,n.iterations=r.readUInt16BE(e),e+=2;let c=r.readUInt8(e);e+=1,n.salt=r.slice(e,e+c),e+=c;let u=r.readUInt8(e);return e+=1,n.nextDomain=r.slice(e,e+u),e+=u,n.rrtypes=T.decode(r,e,i-(e-t)),e+=T.decode.bytes,Z.decode.bytes=e-t,n};Z.decode.bytes=0;Z.encodingLength=function(r){return 8+r.salt.length+r.nextDomain.length+T.encodingLength(r.rrtypes)};var ee=E.ds={};ee.encode=function(r,e,t){e||(e=v.alloc(ee.encodingLength(r))),t||(t=0);let n=t,i=r.digest;if(!v.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+v.byteLength(r.digest)};var _=E.sshfp={};_.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};_.encode=function(e,t,n){t||(t=v.alloc(_.encodingLength(e))),n||(n=0);let i=n;n+=2,t[n]=e.algorithm,n+=1,t[n]=e.hash,n+=1;let c=v.from(e.fingerprint.toUpperCase(),"hex");if(c.length!==_.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return c.copy(t,n),n+=c.byteLength,_.encode.bytes=n-i,t.writeUInt16BE(_.encode.bytes-2,i),t};_.encode.bytes=0;_.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 c=_.getFingerprintLengthForHashType(i.hash);return i.fingerprint=e.slice(t,t+c).toString("hex").toUpperCase(),t+=c,_.decode.bytes=t-n,i};_.decode.bytes=0;_.encodingLength=function(r){return 4+v.from(r.fingerprint,"hex").byteLength};var re=E.naptr={};re.encode=function(r,e,t){e||(e=v.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,S.encode(r.flags,e,t),t+=S.encode.bytes,S.encode(r.services,e,t),t+=S.encode.bytes,S.encode(r.regexp,e,t),t+=S.encode.bytes,I.encode(r.replacement,e,t),t+=I.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=S.decode(r,e),e+=S.decode.bytes,n.services=S.decode(r,e),e+=S.decode.bytes,n.regexp=S.decode(r,e),e+=S.decode.bytes,n.replacement=I.decode(r,e),e+=I.decode.bytes,re.decode.bytes=e-t,n};re.decode.bytes=0;re.encodingLength=function(r){return S.encodingLength(r.flags)+S.encodingLength(r.services)+S.encodingLength(r.regexp)+I.encodingLength(r.replacement)+6};var te=E.tlsa={};te.encode=function(r,e,t){e||(e=v.alloc(te.encodingLength(r))),t||(t=0);let n=t,i=r.certificate;if(!v.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+v.byteLength(r.certificate)};var Er=E.record=function(r){switch(r.toUpperCase()){case"A":return he;case"PTR":return K;case"CNAME":return jn;case"DNAME":return Kn;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 se;case"SOA":return ce;case"MX":return we;case"OPT":return z;case"DNSKEY":return F;case"RRSIG":return Q;case"RP":return W;case"NSEC":return J;case"NSEC3":return Z;case"SSHFP":return _;case"DS":return ee;case"NAPTR":return re;case"TLSA":return te}return oe},D=E.answer={};D.encode=function(r,e,t){e||(e=v.alloc(D.encodingLength(r))),t||(t=0);let n=t;if(I.encode(r.name,e,t),t+=I.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,z.encode(r.options||[],e,t),t+=z.encode.bytes}else{let i=er.toClass(r.class===void 0?"IN":r.class);r.flush&&(i|=xr),e.writeUInt16BE(i,t+2),e.writeUInt32BE(r.ttl||0,t+4),t+=8;let c=Er(r.type);c.encode(r.data,e,t),t+=c.encode.bytes}return D.encode.bytes=t-n,e};D.encode.bytes=0;D.decode=function(r,e){e||(e=0);let t={},n=e;if(t.name=I.decode(r,e),e+=I.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=z.decode(r,e+8),e+=8+z.decode.bytes;else{let i=r.readUInt16BE(e+2);t.ttl=r.readUInt32BE(e+4),t.class=er.toString(i&Vn),t.flush=!!(i&xr);let c=Er(t.type);t.data=c.decode(r,e+8),e+=8+c.decode.bytes}return D.decode.bytes=e-n,t};D.decode.bytes=0;D.encodingLength=function(r){let e=r.data!==null&&r.data!==void 0?r.data:r.options;return I.encodingLength(r.name)+8+Er(r.type).encodingLength(e)};var H=E.question={};H.encode=function(r,e,t){e||(e=v.alloc(H.encodingLength(r))),t||(t=0);let n=t;return I.encode(r.name,e,t),t+=I.encode.bytes,e.writeUInt16BE(ge.toType(r.type),t),t+=2,e.writeUInt16BE(er.toClass(r.class===void 0?"IN":r.class),t),t+=2,H.encode.bytes=t-n,r};H.encode.bytes=0;H.decode=function(r,e){e||(e=0);let t=e,n={};return n.name=I.decode(r,e),e+=I.decode.bytes,n.type=ge.toString(r.readUInt16BE(e)),e+=2,n.class=er.toString(r.readUInt16BE(e)),e+=2,!!(n.class&bt)&&(n.class&=qn),H.decode.bytes=e-t,n};H.decode.bytes=0;H.encodingLength=function(r){return I.encodingLength(r.name)+4};E.AUTHORITATIVE_ANSWER=1024;E.TRUNCATED_RESPONSE=512;E.RECURSION_DESIRED=256;E.RECURSION_AVAILABLE=128;E.AUTHENTIC_DATA=32;E.CHECKING_DISABLED=16;E.DNSSEC_OK=32768;E.encode=function(r,e,t){let n=!e;n&&(e=v.alloc(E.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=[]),X.encode(r,e,t),t+=X.encode.bytes,t=Me(r.questions,H,e,t),t=Me(r.answers,D,e,t),t=Me(r.authorities,D,e,t),t=Me(r.additionals,D,e,t),E.encode.bytes=t-i,n&&E.encode.bytes!==e.length?e.slice(0,E.encode.bytes):e};E.encode.bytes=0;E.decode=function(r,e){e||(e=0);let t=e,n=X.decode(r,e);return e+=X.decode.bytes,e=Ze(n.questions,H,r,e),e=Ze(n.answers,D,r,e),e=Ze(n.authorities,D,r,e),e=Ze(n.additionals,D,r,e),E.decode.bytes=e-t,n};E.decode.bytes=0;E.encodingLength=function(r){return X.encodingLength(r)+Oe(r.questions||[],H)+Oe(r.answers||[],D)+Oe(r.authorities||[],D)+Oe(r.additionals||[],D)};E.streamEncode=function(r){let e=E.encode(r),t=v.alloc(2);t.writeUInt16BE(e.byteLength);let n=v.concat([t,e]);return E.streamEncode.bytes=n.byteLength,n};E.streamEncode.bytes=0;E.streamDecode=function(r){let e=r.readUInt16BE(0);if(r.byteLength<e+2)return null;let t=E.decode(r.slice(2));return E.streamDecode.bytes=E.decode.bytes,t};E.streamDecode.bytes=0;function Oe(r,e){let t=0;for(let n=0;n<r.length;n++)t+=e.encodingLength(r[n]);return t}function Me(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 Ze(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=j((Ks,Lt)=>{"use strict";var Pt=Wn;process.nextTick(Qn,42);Lt.exports=Hn;function Hn(r){var e=n;return t;function t(i){e(i||Gn)}function n(i){var c=[i];e=u,r(m);function u(h){c.push(h)}function m(h){var p=arguments;for(e=Xn(h)?n:x;c.length;)x(c.shift());function x(g){Pt(Yn,g,p)}}}}function Xn(r){return Object.prototype.toString.call(r)==="[object Error]"}function Gn(){}function Yn(r,e){r.apply(null,e)}function Qn(r){r===42&&(Pt=process.nextTick)}function Wn(r,e,t){process.nextTick(function(){r(e,t)})}});var Tt=j((Hs,Rt)=>{var vr=Ut(),Jn=Ce("dgram"),Zn=Ct(),ei=Ce("events"),Sr=Ce("os"),Ar=function(){};Rt.exports=function(r){r||(r={});var e=new ei.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),c={address:i,port:t},u={},m=!1,h=null;if(n==="udp6"&&(!i||!r.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var p=r.socket||Jn.createSocket({type:n,reuseAddr:r.reuseAddr!==!1,toString:function(){return n}});p.on("error",function(g){g.code==="EACCES"||g.code==="EADDRINUSE"?e.emit("error",g):e.emit("warning",g)}),p.on("message",function(g,d){try{g=vr.decode(g)}catch(o){e.emit("warning",o);return}e.emit("packet",g,d),g.type==="query"&&e.emit("query",g,d),g.type==="response"&&e.emit("response",g,d)}),p.on("listening",function(){t||(t=c.port=p.address().port),r.multicast!==!1&&(e.update(),h=setInterval(e.update,5e3),p.setMulticastTTL(r.ttl||255),p.setMulticastLoopback(r.loopback!==!1))});var x=Zn(function(g){if(!t||r.bind===!1)return g(null);p.once("error",g),p.bind(t,r.bind||r.interface,function(){p.removeListener("error",g),g(null)})});return x(function(g){if(g)return e.emit("error",g);e.emit("ready")}),e.send=function(g,d,o){if(typeof d=="function")return e.send(g,null,d);o||(o=Ar),d?!d.host&&!d.address&&(d.address=c.address):d=c,x(s);function s(a){if(m)return o();if(a)return o(a);var l=vr.encode(g);p.send(l,0,l.length,d.port,d.address||d.host,o)}},e.response=e.respond=function(g,d,o){Array.isArray(g)&&(g={answers:g}),g.type="response",g.flags=(g.flags||0)|vr.AUTHORITATIVE_ANSWER,e.send(g,d,o)},e.query=function(g,d,o,s){if(typeof d=="function")return e.query(g,null,null,d);if(typeof d=="object"&&d&&d.port)return e.query(g,null,d,o);if(typeof o=="function")return e.query(g,d,null,o);s||(s=Ar),typeof g=="string"&&(g=[{name:g,type:d||"ANY"}]),Array.isArray(g)&&(g={type:"query",questions:g}),g.type="query",e.send(g,o,s)},e.destroy=function(g){if(g||(g=Ar),m)return process.nextTick(g);m=!0,clearInterval(h);for(var d in u)try{p.dropMembership(i,d)}catch{}u={},p.close(g)},e.update=function(){for(var g=r.interface?[].concat(r.interface):ti(),d=!1,o=0;o<g.length;o++){var s=g[o];if(!u[s])try{p.addMembership(i,s),u[s]=!0,d=!0}catch(a){e.emit("warning",a)}}if(d){if(p.setMulticastInterface)try{p.setMulticastInterface(r.interface||ri())}catch(a){e.emit("warning",a)}e.emit("networkInterface")}},e};function ri(){for(var r=Sr.networkInterfaces(),e=Object.keys(r),t=0;t<e.length;t++)for(var n=r[e[t]],i=0;i<n.length;i++){var c=n[i];if(Ot(c.family)&&!c.internal)return Sr.platform()==="darwin"&&e[t]==="en0"?c.address:"0.0.0.0"}return"127.0.0.1"}function ti(){for(var r=Sr.networkInterfaces(),e=Object.keys(r),t=[],n=0;n<e.length;n++)for(var i=r[e[n]],c=0;c<i.length;c++){var u=i[c];if(Ot(u.family)){t.push(u.address);break}}return t}function Ot(r){return r===4||r==="IPv4"}});var Zt=j(Ge=>{(function(){var r,e,t,n,i,c,u,m;m=function(h){var p,x,g,d;return p=(h&255<<24)>>>24,x=(h&255<<16)>>>16,g=(h&65280)>>>8,d=h&255,[p,x,g,d].join(".")},u=function(h){var p,x,g,d,o,s;for(p=[],g=d=0;d<=3&&h.length!==0;g=++d){if(g>0){if(h[0]!==".")throw new Error("Invalid IP");h=h.substring(1)}s=e(h),o=s[0],x=s[1],h=h.substring(x),p.push(o)}if(h.length!==0)throw new Error("Invalid IP");switch(p.length){case 1:if(p[0]>4294967295)throw new Error("Invalid IP");return p[0]>>>0;case 2:if(p[0]>255||p[1]>16777215)throw new Error("Invalid IP");return(p[0]<<24|p[1])>>>0;case 3:if(p[0]>255||p[1]>255||p[2]>65535)throw new Error("Invalid IP");return(p[0]<<24|p[1]<<16|p[2])>>>0;case 4:if(p[0]>255||p[1]>255||p[2]>255||p[3]>255)throw new Error("Invalid IP");return(p[0]<<24|p[1]<<16|p[2]<<8|p[3])>>>0;default:throw new Error("Invalid IP")}},t=function(h){return h.charCodeAt(0)},n=t("0"),c=t("a"),i=t("A"),e=function(h){var p,x,g,d,o;for(d=0,p=10,x="9",g=0,h.length>1&&h[g]==="0"&&(h[g+1]==="x"||h[g+1]==="X"?(g+=2,p=16):"0"<=h[g+1]&&h[g+1]<="9"&&(g++,p=8,x="7")),o=g;g<h.length;){if("0"<=h[g]&&h[g]<=x)d=d*p+(t(h[g])-n)>>>0;else if(p===16)if("a"<=h[g]&&h[g]<="f")d=d*p+(10+t(h[g])-c)>>>0;else if("A"<=h[g]&&h[g]<="F")d=d*p+(10+t(h[g])-i)>>>0;else break;else break;if(d>4294967295)throw new Error("too large");g++}if(g===o)throw new Error("empty octet");return[d,g]},r=function(){function h(p,x){var g,d,o,s;if(typeof p!="string")throw new Error("Missing `net' parameter");if(x||(s=p.split("/",2),p=s[0],x=s[1]),x||(x=32),typeof x=="string"&&x.indexOf(".")>-1){try{this.maskLong=u(x)}catch(a){throw g=a,new Error("Invalid mask: "+x)}for(d=o=32;o>=0;d=--o)if(this.maskLong===4294967295<<32-d>>>0){this.bitmask=d;break}}else if(x||x===0)this.bitmask=parseInt(x,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(u(p)&this.maskLong)>>>0}catch(a){throw g=a,new Error("Invalid net address: "+p)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+x);this.size=Math.pow(2,32-this.bitmask),this.base=m(this.netLong),this.mask=m(this.maskLong),this.hostmask=m(~this.maskLong),this.first=this.bitmask<=30?m(this.netLong+1):this.base,this.last=this.bitmask<=30?m(this.netLong+this.size-2):m(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?m(this.netLong+this.size-1):void 0}return h.prototype.contains=function(p){return typeof p=="string"&&(p.indexOf("/")>0||p.split(".").length!==4)&&(p=new h(p)),p instanceof h?this.contains(p.base)&&this.contains(p.broadcast||p.last):(u(p)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},h.prototype.next=function(p){return p==null&&(p=1),new h(m(this.netLong+this.size*p),this.mask)},h.prototype.forEach=function(p){var x,g,d;for(d=u(this.first),g=u(this.last),x=0;d<=g;)p(m(d),d,x),x++,d++},h.prototype.toString=function(){return this.base+"/"+this.bitmask},h}(),Ge.ip2long=u,Ge.long2ip=m,Ge.Netmask=r}).call(Ge)});var nn=j((tn,or)=>{(function(r){"use strict";let e="(0?\\d+|0x[a-f0-9]+)",t={fourOctet:new RegExp(`^${e}\\.${e}\\.${e}\\.${e}$`,"i"),threeOctet:new RegExp(`^${e}\\.${e}\\.${e}$`,"i"),twoOctet:new RegExp(`^${e}\\.${e}$`,"i"),longValue:new RegExp(`^${e}$`,"i")},n=new RegExp("^0[0-7]+$","i"),i=new RegExp("^0x[a-f0-9]+$","i"),c="%[0-9a-z]{1,}",u="(?:[0-9a-f]+::?)+",m={zoneIndex:new RegExp(c,"i"),native:new RegExp(`^(::)?(${u})?([0-9a-f]+)?(::)?(${c})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${e}\\.${e}\\.${e}\\.${e}(${c})?)$`,"i"),transitional:new RegExp(`^((?:${u})|(?:::)(?:${u})?)${e}\\.${e}\\.${e}\\.${e}(${c})?$`,"i")};function h(o,s){if(o.indexOf("::")!==o.lastIndexOf("::"))return null;let a=0,l=-1,y=(o.match(m.zoneIndex)||[])[0],w,A;for(y&&(y=y.substring(1),o=o.replace(/%.+$/,""));(l=o.indexOf(":",l+1))>=0;)a++;if(o.substr(0,2)==="::"&&a--,o.substr(-2,2)==="::"&&a--,a>s)return null;for(A=s-a,w=":";A--;)w+="0:";return o=o.replace("::",w),o[0]===":"&&(o=o.slice(1)),o[o.length-1]===":"&&(o=o.slice(0,-1)),s=function(){let O=o.split(":"),P=[];for(let L=0;L<O.length;L++)P.push(parseInt(O[L],16));return P}(),{parts:s,zoneId:y}}function p(o,s,a,l){if(o.length!==s.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let y=0,w;for(;l>0;){if(w=a-l,w<0&&(w=0),o[y]>>w!==s[y]>>w)return!1;l-=a,y+=1}return!0}function x(o){if(i.test(o))return parseInt(o,16);if(o[0]==="0"&&!isNaN(parseInt(o[1],10))){if(n.test(o))return parseInt(o,8);throw new Error(`ipaddr: cannot parse ${o} as octal`)}return parseInt(o,10)}function g(o,s){for(;o.length<s;)o=`0${o}`;return o}let d={};d.IPv4=function(){function o(s){if(s.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let a,l;for(a=0;a<s.length;a++)if(l=s[a],!(0<=l&&l<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=s}return o.prototype.SpecialRanges={unspecified:[[new o([0,0,0,0]),8]],broadcast:[[new o([255,255,255,255]),32]],multicast:[[new o([224,0,0,0]),4]],linkLocal:[[new o([169,254,0,0]),16]],loopback:[[new o([127,0,0,0]),8]],carrierGradeNat:[[new o([100,64,0,0]),10]],private:[[new o([10,0,0,0]),8],[new o([172,16,0,0]),12],[new o([192,168,0,0]),16]],reserved:[[new o([192,0,0,0]),24],[new o([192,0,2,0]),24],[new o([192,88,99,0]),24],[new o([198,18,0,0]),15],[new o([198,51,100,0]),24],[new o([203,0,113,0]),24],[new o([240,0,0,0]),4]]},o.prototype.kind=function(){return"ipv4"},o.prototype.match=function(s,a){let l;if(a===void 0&&(l=s,s=l[0],a=l[1]),s.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return p(this.octets,s.octets,8,a)},o.prototype.prefixLengthFromSubnetMask=function(){let s=0,a=!1,l={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},y,w,A;for(y=3;y>=0;y-=1)if(w=this.octets[y],w in l){if(A=l[w],a&&A!==0)return null;A!==8&&(a=!0),s+=A}else return null;return 32-s},o.prototype.range=function(){return d.subnetMatch(this,this.SpecialRanges)},o.prototype.toByteArray=function(){return this.octets.slice(0)},o.prototype.toIPv4MappedAddress=function(){return d.IPv6.parse(`::ffff:${this.toString()}`)},o.prototype.toNormalizedString=function(){return this.toString()},o.prototype.toString=function(){return this.octets.join(".")},o}(),d.IPv4.broadcastAddressFromCIDR=function(o){try{let s=this.parseCIDR(o),a=s[0].toByteArray(),l=this.subnetMaskFromPrefixLength(s[1]).toByteArray(),y=[],w=0;for(;w<4;)y.push(parseInt(a[w],10)|parseInt(l[w],10)^255),w++;return new this(y)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},d.IPv4.isIPv4=function(o){return this.parser(o)!==null},d.IPv4.isValid=function(o){try{return new this(this.parser(o)),!0}catch{return!1}},d.IPv4.isValidFourPartDecimal=function(o){return!!(d.IPv4.isValid(o)&&o.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},d.IPv4.networkAddressFromCIDR=function(o){let s,a,l,y,w;try{for(s=this.parseCIDR(o),l=s[0].toByteArray(),w=this.subnetMaskFromPrefixLength(s[1]).toByteArray(),y=[],a=0;a<4;)y.push(parseInt(l[a],10)&parseInt(w[a],10)),a++;return new this(y)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},d.IPv4.parse=function(o){let s=this.parser(o);if(s===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(s)},d.IPv4.parseCIDR=function(o){let s;if(s=o.match(/^(.+)\/(\d+)$/)){let a=parseInt(s[2]);if(a>=0&&a<=32){let l=[this.parse(s[1]),a];return Object.defineProperty(l,"toString",{value:function(){return this.join("/")}}),l}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},d.IPv4.parser=function(o){let s,a,l;if(s=o.match(t.fourOctet))return function(){let y=s.slice(1,6),w=[];for(let A=0;A<y.length;A++)a=y[A],w.push(x(a));return w}();if(s=o.match(t.longValue)){if(l=x(s[1]),l>4294967295||l<0)throw new Error("ipaddr: address outside defined range");return function(){let y=[],w;for(w=0;w<=24;w+=8)y.push(l>>w&255);return y}().reverse()}else return(s=o.match(t.twoOctet))?function(){let y=s.slice(1,4),w=[];if(l=x(y[1]),l>16777215||l<0)throw new Error("ipaddr: address outside defined range");return w.push(x(y[0])),w.push(l>>16&255),w.push(l>>8&255),w.push(l&255),w}():(s=o.match(t.threeOctet))?function(){let y=s.slice(1,5),w=[];if(l=x(y[2]),l>65535||l<0)throw new Error("ipaddr: address outside defined range");return w.push(x(y[0])),w.push(x(y[1])),w.push(l>>8&255),w.push(l&255),w}():null},d.IPv4.subnetMaskFromPrefixLength=function(o){if(o=parseInt(o),o<0||o>32)throw new Error("ipaddr: invalid IPv4 prefix length");let s=[0,0,0,0],a=0,l=Math.floor(o/8);for(;a<l;)s[a]=255,a++;return l<4&&(s[l]=Math.pow(2,o%8)-1<<8-o%8),new this(s)},d.IPv6=function(){function o(s,a){let l,y;if(s.length===16)for(this.parts=[],l=0;l<=14;l+=2)this.parts.push(s[l]<<8|s[l+1]);else if(s.length===8)this.parts=s;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(l=0;l<this.parts.length;l++)if(y=this.parts[l],!(0<=y&&y<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");a&&(this.zoneId=a)}return o.prototype.SpecialRanges={unspecified:[new o([0,0,0,0,0,0,0,0]),128],linkLocal:[new o([65152,0,0,0,0,0,0,0]),10],multicast:[new o([65280,0,0,0,0,0,0,0]),8],loopback:[new o([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new o([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new o([0,0,0,0,0,65535,0,0]),96],rfc6145:[new o([0,0,0,0,65535,0,0,0]),96],rfc6052:[new o([100,65435,0,0,0,0,0,0]),96],"6to4":[new o([8194,0,0,0,0,0,0,0]),16],teredo:[new o([8193,0,0,0,0,0,0,0]),32],reserved:[[new o([8193,3512,0,0,0,0,0,0]),32]],benchmarking:[new o([8193,2,0,0,0,0,0,0]),48],amt:[new o([8193,3,0,0,0,0,0,0]),32],as112v6:[new o([8193,4,274,0,0,0,0,0]),48],deprecated:[new o([8193,16,0,0,0,0,0,0]),28],orchid2:[new o([8193,32,0,0,0,0,0,0]),28]},o.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},o.prototype.kind=function(){return"ipv6"},o.prototype.match=function(s,a){let l;if(a===void 0&&(l=s,s=l[0],a=l[1]),s.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return p(this.parts,s.parts,16,a)},o.prototype.prefixLengthFromSubnetMask=function(){let s=0,a=!1,l={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},y,w;for(let A=7;A>=0;A-=1)if(y=this.parts[A],y in l){if(w=l[y],a&&w!==0)return null;w!==16&&(a=!0),s+=w}else return null;return 128-s},o.prototype.range=function(){return d.subnetMatch(this,this.SpecialRanges)},o.prototype.toByteArray=function(){let s,a=[],l=this.parts;for(let y=0;y<l.length;y++)s=l[y],a.push(s>>8),a.push(s&255);return a},o.prototype.toFixedLengthString=function(){let s=function(){let l=[];for(let y=0;y<this.parts.length;y++)l.push(g(this.parts[y].toString(16),4));return l}.call(this).join(":"),a="";return this.zoneId&&(a=`%${this.zoneId}`),s+a},o.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let s=this.parts.slice(-2),a=s[0],l=s[1];return new d.IPv4([a>>8,a&255,l>>8,l&255])},o.prototype.toNormalizedString=function(){let s=function(){let l=[];for(let y=0;y<this.parts.length;y++)l.push(this.parts[y].toString(16));return l}.call(this).join(":"),a="";return this.zoneId&&(a=`%${this.zoneId}`),s+a},o.prototype.toRFC5952String=function(){let s=/((^|:)(0(:|$)){2,})/g,a=this.toNormalizedString(),l=0,y=-1,w;for(;w=s.exec(a);)w[0].length>y&&(l=w.index,y=w[0].length);return y<0?a:`${a.substring(0,l)}::${a.substring(l+y)}`},o.prototype.toString=function(){return this.toRFC5952String()},o}(),d.IPv6.broadcastAddressFromCIDR=function(o){try{let s=this.parseCIDR(o),a=s[0].toByteArray(),l=this.subnetMaskFromPrefixLength(s[1]).toByteArray(),y=[],w=0;for(;w<16;)y.push(parseInt(a[w],10)|parseInt(l[w],10)^255),w++;return new this(y)}catch(s){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${s})`)}},d.IPv6.isIPv6=function(o){return this.parser(o)!==null},d.IPv6.isValid=function(o){if(typeof o=="string"&&o.indexOf(":")===-1)return!1;try{let s=this.parser(o);return new this(s.parts,s.zoneId),!0}catch{return!1}},d.IPv6.networkAddressFromCIDR=function(o){let s,a,l,y,w;try{for(s=this.parseCIDR(o),l=s[0].toByteArray(),w=this.subnetMaskFromPrefixLength(s[1]).toByteArray(),y=[],a=0;a<16;)y.push(parseInt(l[a],10)&parseInt(w[a],10)),a++;return new this(y)}catch(A){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${A})`)}},d.IPv6.parse=function(o){let s=this.parser(o);if(s.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(s.parts,s.zoneId)},d.IPv6.parseCIDR=function(o){let s,a,l;if((a=o.match(/^(.+)\/(\d+)$/))&&(s=parseInt(a[2]),s>=0&&s<=128))return l=[this.parse(a[1]),s],Object.defineProperty(l,"toString",{value:function(){return this.join("/")}}),l;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},d.IPv6.parser=function(o){let s,a,l,y,w,A;if(l=o.match(m.deprecatedTransitional))return this.parser(`::ffff:${l[1]}`);if(m.native.test(o))return h(o,8);if((l=o.match(m.transitional))&&(A=l[6]||"",s=h(l[1].slice(0,-1)+A,6),s.parts)){for(w=[parseInt(l[2]),parseInt(l[3]),parseInt(l[4]),parseInt(l[5])],a=0;a<w.length;a++)if(y=w[a],!(0<=y&&y<=255))return null;return s.parts.push(w[0]<<8|w[1]),s.parts.push(w[2]<<8|w[3]),{parts:s.parts,zoneId:s.zoneId}}return null},d.IPv6.subnetMaskFromPrefixLength=function(o){if(o=parseInt(o),o<0||o>128)throw new Error("ipaddr: invalid IPv6 prefix length");let s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a=0,l=Math.floor(o/8);for(;a<l;)s[a]=255,a++;return l<16&&(s[l]=Math.pow(2,o%8)-1<<8-o%8),new this(s)},d.fromByteArray=function(o){let s=o.length;if(s===4)return new d.IPv4(o);if(s===16)return new d.IPv6(o);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},d.isValid=function(o){return d.IPv6.isValid(o)||d.IPv4.isValid(o)},d.parse=function(o){if(d.IPv6.isValid(o))return d.IPv6.parse(o);if(d.IPv4.isValid(o))return d.IPv4.parse(o);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},d.parseCIDR=function(o){try{return d.IPv6.parseCIDR(o)}catch{try{return d.IPv4.parseCIDR(o)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},d.process=function(o){let s=this.parse(o);return s.kind()==="ipv6"&&s.isIPv4MappedAddress()?s.toIPv4Address():s},d.subnetMatch=function(o,s,a){let l,y,w,A;a==null&&(a="unicast");for(y in s)if(Object.prototype.hasOwnProperty.call(s,y)){for(w=s[y],w[0]&&!(w[0]instanceof Array)&&(w=[w]),l=0;l<w.length;l++)if(A=w[l],o.kind()===A[0].kind()&&o.match.apply(o,A))return y}return a},typeof or<"u"&&or.exports?or.exports=d:r.ipaddr=d})(tn)});var Wo={};$(Wo,{mdns:()=>Qo});var Zo=Symbol.for("@libp2p/connection");var rs=Symbol.for("@libp2p/content-routing");var ut=Symbol.for("@libp2p/peer-discovery");var ht=Symbol.for("@libp2p/peer-id");var ss=Symbol.for("@libp2p/peer-routing");var pt;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(pt||(pt={}));var ls=Symbol.for("@libp2p/transport");var gt;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(gt||(gt={}));var $e=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var Je=class extends EventTarget{#e=new Map;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:c})=>c!==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 ur(e,t))}},lr=class extends Event{detail;constructor(e,t){super(e,t),this.detail=t?.detail}},ur=globalThis.CustomEvent??lr;var Dn=We(Tt(),1);var Cr={};$(Cr,{base58btc:()=>N,base58flickr:()=>ai});var Xs=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 V(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 Nt(r){return new TextEncoder().encode(r)}function Bt(r){return new TextDecoder().decode(r)}function ni(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 c=r.charAt(i),u=c.charCodeAt(0);if(t[u]!==255)throw new TypeError(c+" is ambiguous");t[u]=i}var m=r.length,h=r.charAt(0),p=Math.log(m)/Math.log(256),x=Math.log(256)/Math.log(m);function g(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 a=0,l=0,y=0,w=s.length;y!==w&&s[y]===0;)y++,a++;for(var A=(w-y)*x+1>>>0,O=new Uint8Array(A);y!==w;){for(var P=s[y],L=0,q=A-1;(P!==0||L<l)&&q!==-1;q--,L++)P+=256*O[q]>>>0,O[q]=P%m>>>0,P=P/m>>>0;if(P!==0)throw new Error("Non-zero carry");l=L,y++}for(var ie=A-l;ie!==A&&O[ie]===0;)ie++;for(var Ye=h.repeat(a);ie<A;++ie)Ye+=r.charAt(O[ie]);return Ye}function d(s){if(typeof s!="string")throw new TypeError("Expected String");if(s.length===0)return new Uint8Array;var a=0;if(s[a]!==" "){for(var l=0,y=0;s[a]===h;)l++,a++;for(var w=(s.length-a)*p+1>>>0,A=new Uint8Array(w);s[a];){var O=t[s.charCodeAt(a)];if(O===255)return;for(var P=0,L=w-1;(O!==0||P<y)&&L!==-1;L--,P++)O+=m*A[L]>>>0,A[L]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");y=P,a++}if(s[a]!==" "){for(var q=w-y;q!==w&&A[q]===0;)q++;for(var ie=new Uint8Array(l+(w-q)),Ye=l;q!==w;)ie[Ye++]=A[q++];return ie}}}function o(s){var a=d(s);if(a)return a;throw new Error(`Non-${e} character`)}return{encode:g,decodeUnsafe:d,decode:o}}var ii=ni,oi=ii,ft=oi;var br=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")}},Ur=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)}},Pr=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 Pr({...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 br(e,t,n),this.decoder=new Ur(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Re({name:r,prefix:e,encode:t,decode:n}){return new Lr(r,e,t,n)}function Ie({name:r,prefix:e,alphabet:t}){let{encode:n,decode:i}=ft(t,r);return Re({prefix:e,name:r,encode:n,decode:c=>V(i(c))})}function si(r,e,t,n){let i={};for(let x=0;x<e.length;++x)i[e[x]]=x;let c=r.length;for(;r[c-1]==="=";)--c;let u=new Uint8Array(c*t/8|0),m=0,h=0,p=0;for(let x=0;x<c;++x){let g=i[r[x]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<t|g,m+=t,m>=8&&(m-=8,u[p++]=255&h>>m)}if(m>=t||255&h<<8-m)throw new SyntaxError("Unexpected end of data");return u}function ci(r,e,t){let n=e[e.length-1]==="=",i=(1<<t)-1,c="",u=0,m=0;for(let h=0;h<r.length;++h)for(m=m<<8|r[h],u+=8;u>t;)u-=t,c+=e[i&m>>u];if(u!==0&&(c+=e[i&m<<t-u]),n)for(;c.length*t&7;)c+="=";return c}function C({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Re({prefix:e,name:r,encode(i){return ci(i,n,t)},decode(i){return si(i,n,t,r)}})}var N=Ie({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ai=Ie({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Or={};$(Or,{base10:()=>di});var di=Ie({prefix:"9",name:"base10",alphabet:"0123456789"});var Rr={};$(Rr,{base16:()=>li,base16upper:()=>ui});var li=C({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ui=C({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Tr={};$(Tr,{base2:()=>hi});var hi=C({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Dr={};$(Dr,{base256emoji:()=>wi});var $t=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}"),pi=$t.reduce((r,e,t)=>(r[t]=e,r),[]),gi=$t.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function mi(r){return r.reduce((e,t)=>(e+=pi[t],e),"")}function yi(r){let e=[];for(let t of r){let n=gi[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var wi=Re({prefix:"\u{1F680}",name:"base256emoji",encode:mi,decode:yi});var Nr={};$(Nr,{base32:()=>me,base32hex:()=>vi,base32hexpad:()=>Si,base32hexpadupper:()=>bi,base32hexupper:()=>Ai,base32pad:()=>xi,base32padupper:()=>Ei,base32upper:()=>Ii,base32z:()=>Ui});var me=C({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ii=C({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),xi=C({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ei=C({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),vi=C({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ai=C({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Si=C({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),bi=C({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ui=C({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Br={};$(Br,{base36:()=>Pi,base36upper:()=>Li});var Pi=Ie({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Li=Ie({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Fr={};$(Fr,{base64:()=>Ci,base64pad:()=>Oi,base64url:()=>Ri,base64urlpad:()=>Ti});var Ci=C({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Oi=C({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ri=C({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ti=C({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var fr={};$(fr,{base8:()=>Di});var Di=C({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var kr={};$(kr,{identity:()=>Ni});var Ni=Re({prefix:"\0",name:"identity",encode:r=>Bt(r),decode:r=>Nt(r)});var dc=new TextEncoder,lc=new TextDecoder;var Mr={};$(Mr,{identity:()=>tr});var fi=zt,Mt=128,ki=127,$i=~ki,Mi=Math.pow(2,31);function zt(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Mi;)e[t++]=r&255|Mt,r/=128;for(;r&$i;)e[t++]=r&255|Mt,r>>>=7;return e[t]=r|0,zt.bytes=t-n+1,e}var _i=$r,zi=128,_t=127;function $r(r,n){var t=0,n=n||0,i=0,c=n,u,m=r.length;do{if(c>=m)throw $r.bytes=0,new RangeError("Could not decode varint");u=r[c++],t+=i<28?(u&_t)<<i:(u&_t)*Math.pow(2,i),i+=7}while(u>=zi);return $r.bytes=c-n,t}var Vi=Math.pow(2,7),qi=Math.pow(2,14),ji=Math.pow(2,21),Ki=Math.pow(2,28),Hi=Math.pow(2,35),Xi=Math.pow(2,42),Gi=Math.pow(2,49),Yi=Math.pow(2,56),Qi=Math.pow(2,63),Wi=function(r){return r<Vi?1:r<qi?2:r<ji?3:r<Ki?4:r<Hi?5:r<Xi?6:r<Gi?7:r<Yi?8:r<Qi?9:10},Ji={encode:fi,decode:_i,encodingLength:Wi},Zi=Ji,_e=Zi;function ze(r,e=0){return[_e.decode(r,e),_e.decode.bytes]}function Te(r,e,t=0){return _e.encode(r,e,t),e}function De(r){return _e.encodingLength(r)}function xe(r,e){let t=e.byteLength,n=De(r),i=n+De(t),c=new Uint8Array(i+t);return Te(r,c,0),Te(t,c,n),c.set(e,i),new Ne(r,t,e,c)}function be(r){let e=V(r),[t,n]=ze(e),[i,c]=ze(e.subarray(n)),u=e.subarray(n+c);if(u.byteLength!==i)throw new Error("Incorrect length");return new Ne(t,i,u,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 Ne=class{code;size;digest;bytes;constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}};var qt=0,eo="identity",jt=V;function ro(r){return xe(qt,jt(r))}var tr={code:qt,name:eo,encode:jt,digest:ro};var qr={};$(qr,{sha256:()=>nr,sha512:()=>to});var Vr=We(Ce("crypto"),1);function zr({name:r,code:e,encode:t}){return new _r(r,e,t)}var _r=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?xe(this.code,t):t.then(n=>xe(this.code,n))}else throw Error("Unknown type, must be binary type")}};var nr=zr({name:"sha2-256",code:18,encode:r=>V(Vr.default.createHash("sha256").update(r).digest())}),to=zr({name:"sha2-512",code:19,encode:r=>V(Vr.default.createHash("sha512").update(r).digest())});function Ht(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return io(t,jr(r),e??N.encoder);default:return oo(t,jr(r),e??me.encoder)}}var Xt=new WeakMap;function jr(r){let e=Xt.get(r);if(e==null){let t=new Map;return Xt.set(r,t),t}return e}var G=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!==Ve)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==so)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=xe(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 Ht(this,e)}toJSON(){return{"/":Ht(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:c,bytes:u}=t;return new r(n,i,c,u??Gt(n,i,c.bytes))}else if(t[co]===!0){let{version:n,multihash:i,code:c}=t,u=be(i);return r.create(n,c,u)}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!==Ve)throw new Error(`Version 0 CID must use dag-pb (code: ${Ve}) 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,Ve,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=V(e.subarray(n,n+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");let c=i.subarray(t.multihashSize-t.digestSize),u=new Ne(t.multihashCode,t.digestSize,c,i);return[t.version===0?r.createV0(u):r.createV1(t.codec,u),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[g,d]=ze(e.subarray(t));return t+=d,g},i=n(),c=Ve;if(i===18?(i=0,t=0):c=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let u=t,m=n(),h=n(),p=t+h,x=p-u;return{version:i,codec:c,multihashCode:m,digestSize:h,multihashSize:x,size:p}}static parse(e,t){let[n,i]=no(e,t),c=r.decode(i);if(c.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return jr(c).set(n,e),c}};function no(r,e){switch(r[0]){case"Q":{let t=e??N;return[N.prefix,t.decode(`${N.prefix}${r}`)]}case N.prefix:{let t=e??N;return[N.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 io(r,e,t){let{prefix:n}=t;if(n!==N.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let i=e.get(n);if(i==null){let c=t.encode(r).slice(1);return e.set(n,c),c}else return i}function oo(r,e,t){let{prefix:n}=t,i=e.get(n);if(i==null){let c=t.encode(r);return e.set(n,c),c}else return i}var Ve=112,so=18;function Gt(r,e,t){let n=De(r),i=n+De(e),c=new Uint8Array(i+t.byteLength);return Te(r,c,0),Te(e,c,n),c.set(t,i),c}var co=Symbol.for("@ipld/js-cid/CID");var Ee={...kr,...Tr,...fr,...Or,...Rr,...Nr,...Br,...Cr,...Fr,...Dr},Dc={...qr,...Mr};function qe(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 ao=Symbol.for("nodejs.util.inspect.custom"),Yt=Object.values(Ee).map(r=>r.decoder).reduce((r,e)=>r.or(e),Ee.identity.decoder),Qt=114,Wt=36,Jt=37,je=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()})`}[ht]=!0;toString(){return this.string==null&&(this.string=N.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return G.createV1(Qt,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return qe(this.multihash.bytes,e);if(typeof e=="string")return Kr(e).equals(this);if(e?.multihash?.bytes!=null)return qe(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[ao](){return`PeerId(${this.toString()})`}},Ke=class extends je{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},He=class extends je{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Xe=class extends je{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function Kr(r,e){if(e=e??Yt,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=be(N.decode(`z${r}`));return r.startsWith("12D")?new He({multihash:t}):r.startsWith("16U")?new Xe({multihash:t}):new Ke({multihash:t})}return lo(Yt.decode(r))}function lo(r){try{let e=be(r);if(e.code===tr.code){if(e.digest.length===Wt)return new He({multihash:e});if(e.digest.length===Jt)return new Xe({multihash:e})}if(e.code===nr.code)return new Ke({multihash:e})}catch{return uo(G.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function uo(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Qt)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===nr.code)return new Ke({multihash:r.multihash});if(e.code===tr.code){if(e.digest.length===Wt)return new He({multihash:r.multihash});if(e.digest.length===Jt)return new Xe({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var sn=We(Zt(),1);var en="[a-fA-F\\d:]",ve=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${en})|(?<=${en})(?=\\s|$))`:"",Y="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",R="[a-fA-F\\d]{1,4}",ir=`
|
|
2
|
+
"use strict";var Libp2PMdns=(()=>{var Tn=Object.create;var Ye=Object.defineProperty;var Dn=Object.getOwnPropertyDescriptor;var Nn=Object.getOwnPropertyNames;var Bn=Object.getPrototypeOf,Fn=Object.prototype.hasOwnProperty;var Ce=(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 j=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),M=(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 Nn(e))!Fn.call(r,i)&&i!==t&&Ye(r,i,{get:()=>e[i],enumerable:!(n=Dn(e,i))||n.enumerable});return r};var Qe=(r,e,t)=>(t=r!=null?Tn(Bn(r)):{},lt(e||!r||!r.__esModule?Ye(t,"default",{value:r,enumerable:!0}):t,r)),kn=r=>lt(Ye({},"__esModule",{value:!0}),r);var pt=j(hr=>{"use strict";hr.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};hr.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 gt=j(pr=>{"use strict";pr.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};pr.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 mt=j(gr=>{"use strict";gr.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};gr.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 yt=j(mr=>{"use strict";mr.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};mr.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 wt=j(yr=>{"use strict";yr.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}`};yr.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 xt=j((Et,wr)=>{var It=function(r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.decode=g,r.encode=E,r.familyOf=p,r.name=void 0,r.sizeOf=h,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,c={name:"v4",size:t,isFormat:d=>e.test(d),encode(d,o,s){s=~~s,o=o||new Uint8Array(s+t);let a=d.length,l=0;for(let y=0;y<a;){let w=d.charCodeAt(y++);w===46?(o[s++]=l,l=0):l=l*10+(w-48)}return o[s]=l,o},decode(d,o){return o=~~o,`${d[o++]}.${d[o++]}.${d[o++]}.${d[o]}`}};r.v4=c;let u={name:"v6",size:i,isFormat:d=>d.length>0&&n.test(d),encode(d,o,s){s=~~s;let a=s+i,l=-1,y=0,w=0,A=!0,O=!1;o=o||new Uint8Array(s+i);for(let P=0;P<d.length;P++){let L=d.charCodeAt(P);L===58?(A?l!==-1?(s<a&&(o[s]=0),s<a-1&&(o[s+1]=0),s+=2):s<a&&(l=s):(O===!0?(s<a&&(o[s]=w),s++):(s<a&&(o[s]=y>>8),s<a-1&&(o[s+1]=y&255),s+=2),y=0,w=0),A=!0,O=!1):L===46?(s<a&&(o[s]=w),s++,w=0,y=0,A=!1,O=!0):(A=!1,L>=97?L-=87:L>=65?L-=55:(L-=48,w=w*10+L),y=(y<<4)+L)}if(A===!1)O===!0?(s<a&&(o[s]=w),s++):(s<a&&(o[s]=y>>8),s<a-1&&(o[s+1]=y&255),s+=2);else if(l===0)s<a&&(o[s]=0),s<a-1&&(o[s+1]=0),s+=2;else if(l!==-1){s+=2;for(let P=Math.min(s-1,a-1);P>=l+2;P--)o[P]=o[P-2];o[l]=0,o[l+1]=0,l=s}if(l!==s&&l!==-1)for(s>a-2&&(s=a-2);a>l;)o[--a]=s<a&&s>l?o[--s]:0;else for(;s<a;)o[s++]=0;return o},decode(d,o){o=~~o;let s="";for(let a=0;a<i;a+=2)a!==0&&(s+=":"),s+=(d[o+a]<<8|d[o+a+1]).toString(16);return s.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};r.v6=u;let m="ip";r.name=m;function h(d){if(c.isFormat(d))return c.size;if(u.isFormat(d))return u.size;throw Error(`Invalid ip address: ${d}`)}function p(d){return h(d)===c.size?1:2}function E(d,o,s){s=~~s;let a=h(d);return typeof o=="function"&&(o=o(s+a)),a===c.size?c.encode(d,o,s):u.encode(d,o,s)}function g(d,o,s){if(o=~~o,s=s||d.length-o,s===c.size)return c.decode(d,o,s);if(s===u.size)return u.decode(d,o,s);throw Error(`Invalid buffer size needs to be ${c.size} for v4 or ${u.size} for v6.`)}return"default"in r?r.default:r}({});typeof define=="function"&&define.amd?define([],function(){return It}):typeof wr=="object"&&typeof Et=="object"&&(wr.exports=It)});var St=j(x=>{"use strict";var v=Ce("buffer").Buffer,ge=pt(),$n=gt(),Mn=mt(),er=yt(),Ir=wt(),Se=xt(),fn=0,vt=32768,Er=32768,_n=~Er,At=32768,zn=~At,I=x.name={};I.encode=function(r,e,t,{mail:n=!1}={}){e||(e=v.alloc(I.encodingLength(r))),t||(t=0);let i=t,c=r.replace(/^\.|\.$/gm,"");if(c.length){let u=[];if(n){let m="";c.split(".").forEach(h=>{h.endsWith("\\")?m+=(m.length?".":"")+h.slice(0,-1):u.length===0&&m.length?u.push(m+"."+h):u.push(h)})}else u=c.split(".");for(let m=0;m<u.length;m++){let h=e.write(u[m],t+1);e[t]=h,t+=h+1}}return e[t++]=0,I.encode.bytes=t-i,e};I.encode.bytes=0;I.decode=function(r,e,{mail:t=!1}={}){e||(e=0);let n=[],i=e,c=0,u=0,m=!1;for(;;){if(e>=r.length)throw new Error("Cannot decode name (buffer overflow)");let h=r[e++];if(u+=m?0:1,h===0)break;if(h&192)if((h&192)===192){if(e+1>r.length)throw new Error("Cannot decode name (buffer overflow)");let p=r.readUInt16BE(e-1)-49152;if(p>=i)throw new Error("Cannot decode name (bad pointer)");e=p,i=p,u+=m?0:1,m=!0}else throw new Error("Cannot decode name (bad label)");else{if(e+h>r.length)throw new Error("Cannot decode name (buffer overflow)");if(c+=h+1,c>254)throw new Error("Cannot decode name (name too long)");let p=r.toString("utf-8",e,e+h);t&&(p=p.replace(/\./g,"\\.")),n.push(p),e+=h,u+=m?0:h}}return I.decode.bytes=u,n.length===0?".":n.join(".")};I.decode.bytes=0;I.encodingLength=function(r){return r==="."||r===".."?1:v.byteLength(r.replace(/^\.|\.$/gm,""))+2};var S={};S.encode=function(r,e,t){e||(e=v.alloc(S.encodingLength(r))),t||(t=0);let n=e.write(r,t+1);return e[t]=n,S.encode.bytes=n+1,e};S.encode.bytes=0;S.decode=function(r,e){e||(e=0);let t=r[e],n=r.toString("utf-8",e+1,e+1+t);return S.decode.bytes=t+1,n};S.decode.bytes=0;S.encodingLength=function(r){return v.byteLength(r)+1};var X={};X.encode=function(r,e,t){e||(e=X.encodingLength(r)),t||(t=0);let n=(r.flags||0)&32767,i=r.type==="response"?vt:fn;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};X.encode.bytes=12;X.decode=function(r,e){if(e||(e=0),r.length<12)throw new Error("Header must be 12 bytes");let t=r.readUInt16BE(e+2);return{id:r.readUInt16BE(e),type:t&vt?"response":"query",flags:t&32767,flag_qr:(t>>15&1)===1,opcode:Mn.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:$n.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))}};X.decode.bytes=12;X.encodingLength=function(){return 12};var oe=x.unknown={};oe.encode=function(r,e,t){return e||(e=v.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 se=x.ns={};se.encode=function(r,e,t){return e||(e=v.alloc(se.encodingLength(r))),t||(t=0),I.encode(r,e,t+2),e.writeUInt16BE(I.encode.bytes,t),se.encode.bytes=I.encode.bytes+2,e};se.encode.bytes=0;se.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n=I.decode(r,e+2);return se.decode.bytes=t+2,n};se.decode.bytes=0;se.encodingLength=function(r){return I.encodingLength(r)+2};var ce=x.soa={};ce.encode=function(r,e,t){e||(e=v.alloc(ce.encodingLength(r))),t||(t=0);let n=t;return t+=2,I.encode(r.mname,e,t),t+=I.encode.bytes,I.encode(r.rname,e,t,{mail:!0}),t+=I.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),ce.encode.bytes=t-n,e};ce.encode.bytes=0;ce.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.mname=I.decode(r,e),e+=I.decode.bytes,n.rname=I.decode(r,e,{mail:!0}),e+=I.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,ce.decode.bytes=e-t,n};ce.decode.bytes=0;ce.encodingLength=function(r){return 22+I.encodingLength(r.mname)+I.encodingLength(r.rname)};var ae=x.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]=v.from(r[i])),!v.isBuffer(r[i]))throw new Error("Must be a Buffer");e||(e=v.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 c=r[e++];if(--n,n<c)throw new Error("Buffer overflow");i.push(r.slice(e,e+c)),e+=c,n-=c}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+=v.byteLength(t)+1:e+=t.length+1}),e};var de=x.null={};de.encode=function(r,e,t){e||(e=v.alloc(de.encodingLength(r))),t||(t=0),typeof r=="string"&&(r=v.from(r)),r||(r=v.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?(v.isBuffer(r)?r.length:v.byteLength(r))+2:2};var le=x.hinfo={};le.encode=function(r,e,t){e||(e=v.alloc(le.encodingLength(r))),t||(t=0);let n=t;return t+=2,S.encode(r.cpu,e,t),t+=S.encode.bytes,S.encode(r.os,e,t),t+=S.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=S.decode(r,e),e+=S.decode.bytes,n.os=S.decode(r,e),e+=S.decode.bytes,le.decode.bytes=e-t,n};le.decode.bytes=0;le.encodingLength=function(r){return S.encodingLength(r.cpu)+S.encodingLength(r.os)+2};var K=x.ptr={},Vn=x.cname=K,qn=x.dname=K;K.encode=function(r,e,t){return e||(e=v.alloc(K.encodingLength(r))),t||(t=0),I.encode(r,e,t+2),e.writeUInt16BE(I.encode.bytes,t),K.encode.bytes=I.encode.bytes+2,e};K.encode.bytes=0;K.decode=function(r,e){e||(e=0);let t=I.decode(r,e+2);return K.decode.bytes=I.decode.bytes+2,t};K.decode.bytes=0;K.encodingLength=function(r){return I.encodingLength(r)+2};var ue=x.srv={};ue.encode=function(r,e,t){e||(e=v.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),I.encode(r.target,e,t+8);let n=I.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=I.decode(r,e+8),ue.decode.bytes=t+2,n};ue.decode.bytes=0;ue.encodingLength=function(r){return 8+I.encodingLength(r.target)};var f=x.caa={};f.ISSUER_CRITICAL=128;f.encode=function(r,e,t){let n=f.encodingLength(r);return e||(e=v.alloc(f.encodingLength(r))),t||(t=0),r.issuerCritical&&(r.flags=f.ISSUER_CRITICAL),e.writeUInt16BE(n-2,t),t+=2,e.writeUInt8(r.flags||0,t),t+=1,S.encode(r.tag,e,t),t+=S.encode.bytes,e.write(r.value,t),t+=v.byteLength(r.value),f.encode.bytes=n,e};f.encode.bytes=0;f.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=S.decode(r,e),e+=S.decode.bytes,i.value=r.toString("utf-8",e,n+t),i.issuerCritical=!!(i.flags&f.ISSUER_CRITICAL),f.decode.bytes=t+2,i};f.decode.bytes=0;f.encodingLength=function(r){return S.encodingLength(r.tag)+S.encodingLength(r.value)+2};var we=x.mx={};we.encode=function(r,e,t){e||(e=v.alloc(we.encodingLength(r))),t||(t=0);let n=t;return t+=2,e.writeUInt16BE(r.preference||0,t),t+=2,I.encode(r.exchange,e,t),t+=I.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=I.decode(r,e),e+=I.decode.bytes,we.decode.bytes=e-t,n};we.encodingLength=function(r){return 4+I.encodingLength(r.exchange)};var he=x.a={};he.encode=function(r,e,t){return e||(e=v.alloc(he.encodingLength(r))),t||(t=0),e.writeUInt16BE(4,t),t+=2,Se.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=Se.v4.decode(r,e);return he.decode.bytes=6,t};he.decode.bytes=0;he.encodingLength=function(){return 6};var pe=x.aaaa={};pe.encode=function(r,e,t){return e||(e=v.alloc(pe.encodingLength(r))),t||(t=0),e.writeUInt16BE(16,t),t+=2,Se.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=Se.v6.decode(r,e);return pe.decode.bytes=18,t};pe.decode.bytes=0;pe.encodingLength=function(){return 18};var k=x.option={};k.encode=function(r,e,t){e||(e=v.alloc(k.encodingLength(r))),t||(t=0);let n=t,i=Ir.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 c=r.sourcePrefixLength||0,u=r.family||Se.familyOf(r.ip),m=Se.encode(r.ip,v.alloc),h=Math.ceil(c/8);e.writeUInt16BE(h+4,t),t+=2,e.writeUInt16BE(u,t),t+=2,e.writeUInt8(c,t++),e.writeUInt8(r.scopePrefixLength||0,t++),m.copy(e,t,0,h),t+=h;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 p=r.length||0;e.writeUInt16BE(p,t),t+=2,e.fill(0,t,t+p),t+=p;break;case 14:let E=r.tags.length*2;e.writeUInt16BE(E,t),t+=2;for(let g of r.tags)e.writeUInt16BE(g,t),t+=2;break;default:throw new Error(`Unknown roption code: ${r.code}`)}return k.encode.bytes=t-n,e};k.encode.bytes=0;k.decode=function(r,e){e||(e=0);let t={};t.code=r.readUInt16BE(e),t.type=Ir.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=v.alloc(t.family===1?4:16);r.copy(i,0,e,e+n-4),t.ip=Se.decode(i);break;case 11:n>0&&(t.timeout=r.readUInt16BE(e),e+=2);break;case 14:t.tags=[];for(let c=0;c<n;c+=2)t.tags.push(r.readUInt16BE(e)),e+=2}return k.decode.bytes=n+4,t};k.decode.bytes=0;k.encodingLength=function(r){if(r.data)return r.data.length+4;switch(Ir.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 z=x.opt={};z.encode=function(r,e,t){e||(e=v.alloc(z.encodingLength(r))),t||(t=0);let n=t,i=Oe(r,k);return e.writeUInt16BE(i,t),t=Me(r,k,e,t+2),z.encode.bytes=t-n,e};z.encode.bytes=0;z.decode=function(r,e){e||(e=0);let t=e,n=[],i=r.readUInt16BE(e);e+=2;let c=0;for(;i>0;)n[c++]=k.decode(r,e),e+=k.decode.bytes,i-=k.decode.bytes;return z.decode.bytes=e-t,n};z.decode.bytes=0;z.encodingLength=function(r){return 2+Oe(r||[],k)};var F=x.dnskey={};F.PROTOCOL_DNSSEC=3;F.ZONE_KEY=128;F.SECURE_ENTRYPOINT=32768;F.encode=function(r,e,t){e||(e=v.alloc(F.encodingLength(r))),t||(t=0);let n=t,i=r.key;if(!v.isBuffer(i))throw new Error("Key must be a Buffer");return t+=2,e.writeUInt16BE(r.flags,t),t+=2,e.writeUInt8(F.PROTOCOL_DNSSEC,t),t+=1,e.writeUInt8(r.algorithm,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,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);if(e+=2,n.flags=r.readUInt16BE(e),e+=2,r.readUInt8(e)!==F.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,F.decode.bytes=e-t,n};F.decode.bytes=0;F.encodingLength=function(r){return 6+v.byteLength(r.key)};var Q=x.rrsig={};Q.encode=function(r,e,t){e||(e=v.alloc(Q.encodingLength(r))),t||(t=0);let n=t,i=r.signature;if(!v.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,I.encode(r.signersName,e,t),t+=I.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=I.decode(r,e),e+=I.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+I.encodingLength(r.signersName)+v.byteLength(r.signature)};var W=x.rp={};W.encode=function(r,e,t){e||(e=v.alloc(W.encodingLength(r))),t||(t=0);let n=t;return t+=2,I.encode(r.mbox||".",e,t,{mail:!0}),t+=I.encode.bytes,I.encode(r.txt||".",e,t),t+=I.encode.bytes,W.encode.bytes=t-n,e.writeUInt16BE(W.encode.bytes-2,n),e};W.encode.bytes=0;W.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.mbox=I.decode(r,e,{mail:!0})||".",e+=I.decode.bytes,n.txt=I.decode(r,e)||".",e+=I.decode.bytes,W.decode.bytes=e-t,n};W.decode.bytes=0;W.encodingLength=function(r){return 2+I.encodingLength(r.mbox||".")+I.encodingLength(r.txt||".")};var T={};T.encode=function(r,e,t){e||(e=v.alloc(T.encodingLength(r))),t||(t=0);let n=t;for(var i=[],c=0;c<r.length;c++){var u=ge.toType(r[c]);i[u>>8]===void 0&&(i[u>>8]=[]),i[u>>8][u>>3&31]|=1<<7-(u&7)}for(c=0;c<i.length;c++)if(i[c]!==void 0){var m=v.from(i[c]);e.writeUInt8(c,t),t+=1,e.writeUInt8(m.length,t),t+=1,m.copy(e,t),t+=m.length}return T.encode.bytes=t-n,e};T.encode.bytes=0;T.decode=function(r,e,t){e||(e=0);let n=e;for(var i=[];e-n<t;){var c=r.readUInt8(e);e+=1;var u=r.readUInt8(e);e+=1;for(var m=0;m<u;m++)for(var h=r.readUInt8(e+m),p=0;p<8;p++)if(h&1<<7-p){var E=ge.toString(c<<8|m<<3|p);i.push(E)}e+=u}return T.decode.bytes=e-n,i};T.decode.bytes=0;T.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 J=x.nsec={};J.encode=function(r,e,t){e||(e=v.alloc(J.encodingLength(r))),t||(t=0);let n=t;return t+=2,I.encode(r.nextDomain,e,t),t+=I.encode.bytes,T.encode(r.rrtypes,e,t),t+=T.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;var n={},i=r.readUInt16BE(e);return e+=2,n.nextDomain=I.decode(r,e),e+=I.decode.bytes,n.rrtypes=T.decode(r,e,i-(e-t)),e+=T.decode.bytes,J.decode.bytes=e-t,n};J.decode.bytes=0;J.encodingLength=function(r){return 2+I.encodingLength(r.nextDomain)+T.encodingLength(r.rrtypes)};var Z=x.nsec3={};Z.encode=function(r,e,t){e||(e=v.alloc(Z.encodingLength(r))),t||(t=0);let n=t,i=r.salt;if(!v.isBuffer(i))throw new Error("salt must be a Buffer");let c=r.nextDomain;if(!v.isBuffer(c))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(c.length,t),t+=1,c.copy(e,t,0,c.length),t+=c.length,T.encode(r.rrtypes,e,t),t+=T.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);e+=2,n.algorithm=r.readUInt8(e),e+=1,n.flags=r.readUInt8(e),e+=1,n.iterations=r.readUInt16BE(e),e+=2;let c=r.readUInt8(e);e+=1,n.salt=r.slice(e,e+c),e+=c;let u=r.readUInt8(e);return e+=1,n.nextDomain=r.slice(e,e+u),e+=u,n.rrtypes=T.decode(r,e,i-(e-t)),e+=T.decode.bytes,Z.decode.bytes=e-t,n};Z.decode.bytes=0;Z.encodingLength=function(r){return 8+r.salt.length+r.nextDomain.length+T.encodingLength(r.rrtypes)};var ee=x.ds={};ee.encode=function(r,e,t){e||(e=v.alloc(ee.encodingLength(r))),t||(t=0);let n=t,i=r.digest;if(!v.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+v.byteLength(r.digest)};var _=x.sshfp={};_.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};_.encode=function(e,t,n){t||(t=v.alloc(_.encodingLength(e))),n||(n=0);let i=n;n+=2,t[n]=e.algorithm,n+=1,t[n]=e.hash,n+=1;let c=v.from(e.fingerprint.toUpperCase(),"hex");if(c.length!==_.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return c.copy(t,n),n+=c.byteLength,_.encode.bytes=n-i,t.writeUInt16BE(_.encode.bytes-2,i),t};_.encode.bytes=0;_.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 c=_.getFingerprintLengthForHashType(i.hash);return i.fingerprint=e.slice(t,t+c).toString("hex").toUpperCase(),t+=c,_.decode.bytes=t-n,i};_.decode.bytes=0;_.encodingLength=function(r){return 4+v.from(r.fingerprint,"hex").byteLength};var re=x.naptr={};re.encode=function(r,e,t){e||(e=v.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,S.encode(r.flags,e,t),t+=S.encode.bytes,S.encode(r.services,e,t),t+=S.encode.bytes,S.encode(r.regexp,e,t),t+=S.encode.bytes,I.encode(r.replacement,e,t),t+=I.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=S.decode(r,e),e+=S.decode.bytes,n.services=S.decode(r,e),e+=S.decode.bytes,n.regexp=S.decode(r,e),e+=S.decode.bytes,n.replacement=I.decode(r,e),e+=I.decode.bytes,re.decode.bytes=e-t,n};re.decode.bytes=0;re.encodingLength=function(r){return S.encodingLength(r.flags)+S.encodingLength(r.services)+S.encodingLength(r.regexp)+I.encodingLength(r.replacement)+6};var te=x.tlsa={};te.encode=function(r,e,t){e||(e=v.alloc(te.encodingLength(r))),t||(t=0);let n=t,i=r.certificate;if(!v.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+v.byteLength(r.certificate)};var xr=x.record=function(r){switch(r.toUpperCase()){case"A":return he;case"PTR":return K;case"CNAME":return Vn;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 f;case"NS":return se;case"SOA":return ce;case"MX":return we;case"OPT":return z;case"DNSKEY":return F;case"RRSIG":return Q;case"RP":return W;case"NSEC":return J;case"NSEC3":return Z;case"SSHFP":return _;case"DS":return ee;case"NAPTR":return re;case"TLSA":return te}return oe},D=x.answer={};D.encode=function(r,e,t){e||(e=v.alloc(D.encodingLength(r))),t||(t=0);let n=t;if(I.encode(r.name,e,t),t+=I.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,z.encode(r.options||[],e,t),t+=z.encode.bytes}else{let i=er.toClass(r.class===void 0?"IN":r.class);r.flush&&(i|=Er),e.writeUInt16BE(i,t+2),e.writeUInt32BE(r.ttl||0,t+4),t+=8;let c=xr(r.type);c.encode(r.data,e,t),t+=c.encode.bytes}return D.encode.bytes=t-n,e};D.encode.bytes=0;D.decode=function(r,e){e||(e=0);let t={},n=e;if(t.name=I.decode(r,e),e+=I.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=z.decode(r,e+8),e+=8+z.decode.bytes;else{let i=r.readUInt16BE(e+2);t.ttl=r.readUInt32BE(e+4),t.class=er.toString(i&_n),t.flush=!!(i&Er);let c=xr(t.type);t.data=c.decode(r,e+8),e+=8+c.decode.bytes}return D.decode.bytes=e-n,t};D.decode.bytes=0;D.encodingLength=function(r){let e=r.data!==null&&r.data!==void 0?r.data:r.options;return I.encodingLength(r.name)+8+xr(r.type).encodingLength(e)};var H=x.question={};H.encode=function(r,e,t){e||(e=v.alloc(H.encodingLength(r))),t||(t=0);let n=t;return I.encode(r.name,e,t),t+=I.encode.bytes,e.writeUInt16BE(ge.toType(r.type),t),t+=2,e.writeUInt16BE(er.toClass(r.class===void 0?"IN":r.class),t),t+=2,H.encode.bytes=t-n,r};H.encode.bytes=0;H.decode=function(r,e){e||(e=0);let t=e,n={};return n.name=I.decode(r,e),e+=I.decode.bytes,n.type=ge.toString(r.readUInt16BE(e)),e+=2,n.class=er.toString(r.readUInt16BE(e)),e+=2,!!(n.class&At)&&(n.class&=zn),H.decode.bytes=e-t,n};H.decode.bytes=0;H.encodingLength=function(r){return I.encodingLength(r.name)+4};x.AUTHORITATIVE_ANSWER=1024;x.TRUNCATED_RESPONSE=512;x.RECURSION_DESIRED=256;x.RECURSION_AVAILABLE=128;x.AUTHENTIC_DATA=32;x.CHECKING_DISABLED=16;x.DNSSEC_OK=32768;x.encode=function(r,e,t){let n=!e;n&&(e=v.alloc(x.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=[]),X.encode(r,e,t),t+=X.encode.bytes,t=Me(r.questions,H,e,t),t=Me(r.answers,D,e,t),t=Me(r.authorities,D,e,t),t=Me(r.additionals,D,e,t),x.encode.bytes=t-i,n&&x.encode.bytes!==e.length?e.slice(0,x.encode.bytes):e};x.encode.bytes=0;x.decode=function(r,e){e||(e=0);let t=e,n=X.decode(r,e);return e+=X.decode.bytes,e=Ze(n.questions,H,r,e),e=Ze(n.answers,D,r,e),e=Ze(n.authorities,D,r,e),e=Ze(n.additionals,D,r,e),x.decode.bytes=e-t,n};x.decode.bytes=0;x.encodingLength=function(r){return X.encodingLength(r)+Oe(r.questions||[],H)+Oe(r.answers||[],D)+Oe(r.authorities||[],D)+Oe(r.additionals||[],D)};x.streamEncode=function(r){let e=x.encode(r),t=v.alloc(2);t.writeUInt16BE(e.byteLength);let n=v.concat([t,e]);return x.streamEncode.bytes=n.byteLength,n};x.streamEncode.bytes=0;x.streamDecode=function(r){let e=r.readUInt16BE(0);if(r.byteLength<e+2)return null;let t=x.decode(r.slice(2));return x.streamDecode.bytes=x.decode.bytes,t};x.streamDecode.bytes=0;function Oe(r,e){let t=0;for(let n=0;n<r.length;n++)t+=e.encodingLength(r[n]);return t}function Me(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 Ze(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 Pt=j((cs,bt)=>{"use strict";var Ut=Yn;process.nextTick(Gn,42);bt.exports=jn;function jn(r){var e=n;return t;function t(i){e(i||Hn)}function n(i){var c=[i];e=u,r(m);function u(h){c.push(h)}function m(h){var p=arguments;for(e=Kn(h)?n:E;c.length;)E(c.shift());function E(g){Ut(Xn,g,p)}}}}function Kn(r){return Object.prototype.toString.call(r)==="[object Error]"}function Hn(){}function Xn(r,e){r.apply(null,e)}function Gn(r){r===42&&(Ut=process.nextTick)}function Yn(r,e,t){process.nextTick(function(){r(e,t)})}});var Ot=j((as,Ct)=>{var vr=St(),Qn=Ce("dgram"),Wn=Pt(),Jn=Ce("events"),Sr=Ce("os"),Ar=function(){};Ct.exports=function(r){r||(r={});var e=new Jn.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),c={address:i,port:t},u={},m=!1,h=null;if(n==="udp6"&&(!i||!r.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var p=r.socket||Qn.createSocket({type:n,reuseAddr:r.reuseAddr!==!1,toString:function(){return n}});p.on("error",function(g){g.code==="EACCES"||g.code==="EADDRINUSE"?e.emit("error",g):e.emit("warning",g)}),p.on("message",function(g,d){try{g=vr.decode(g)}catch(o){e.emit("warning",o);return}e.emit("packet",g,d),g.type==="query"&&e.emit("query",g,d),g.type==="response"&&e.emit("response",g,d)}),p.on("listening",function(){t||(t=c.port=p.address().port),r.multicast!==!1&&(e.update(),h=setInterval(e.update,5e3),p.setMulticastTTL(r.ttl||255),p.setMulticastLoopback(r.loopback!==!1))});var E=Wn(function(g){if(!t||r.bind===!1)return g(null);p.once("error",g),p.bind(t,r.bind||r.interface,function(){p.removeListener("error",g),g(null)})});return E(function(g){if(g)return e.emit("error",g);e.emit("ready")}),e.send=function(g,d,o){if(typeof d=="function")return e.send(g,null,d);o||(o=Ar),d?!d.host&&!d.address&&(d.address=c.address):d=c,E(s);function s(a){if(m)return o();if(a)return o(a);var l=vr.encode(g);p.send(l,0,l.length,d.port,d.address||d.host,o)}},e.response=e.respond=function(g,d,o){Array.isArray(g)&&(g={answers:g}),g.type="response",g.flags=(g.flags||0)|vr.AUTHORITATIVE_ANSWER,e.send(g,d,o)},e.query=function(g,d,o,s){if(typeof d=="function")return e.query(g,null,null,d);if(typeof d=="object"&&d&&d.port)return e.query(g,null,d,o);if(typeof o=="function")return e.query(g,d,null,o);s||(s=Ar),typeof g=="string"&&(g=[{name:g,type:d||"ANY"}]),Array.isArray(g)&&(g={type:"query",questions:g}),g.type="query",e.send(g,o,s)},e.destroy=function(g){if(g||(g=Ar),m)return process.nextTick(g);m=!0,clearInterval(h);for(var d in u)try{p.dropMembership(i,d)}catch{}u={},p.close(g)},e.update=function(){for(var g=r.interface?[].concat(r.interface):ei(),d=!1,o=0;o<g.length;o++){var s=g[o];if(!u[s])try{p.addMembership(i,s),u[s]=!0,d=!0}catch(a){e.emit("warning",a)}}if(d){if(p.setMulticastInterface)try{p.setMulticastInterface(r.interface||Zn())}catch(a){e.emit("warning",a)}e.emit("networkInterface")}},e};function Zn(){for(var r=Sr.networkInterfaces(),e=Object.keys(r),t=0;t<e.length;t++)for(var n=r[e[t]],i=0;i<n.length;i++){var c=n[i];if(Lt(c.family)&&!c.internal)return Sr.platform()==="darwin"&&e[t]==="en0"?c.address:"0.0.0.0"}return"127.0.0.1"}function ei(){for(var r=Sr.networkInterfaces(),e=Object.keys(r),t=[],n=0;n<e.length;n++)for(var i=r[e[n]],c=0;c<i.length;c++){var u=i[c];if(Lt(u.family)){t.push(u.address);break}}return t}function Lt(r){return r===4||r==="IPv4"}});var Wt=j(Xe=>{(function(){var r,e,t,n,i,c,u,m;m=function(h){var p,E,g,d;return p=(h&255<<24)>>>24,E=(h&255<<16)>>>16,g=(h&65280)>>>8,d=h&255,[p,E,g,d].join(".")},u=function(h){var p,E,g,d,o,s;for(p=[],g=d=0;d<=3&&h.length!==0;g=++d){if(g>0){if(h[0]!==".")throw new Error("Invalid IP");h=h.substring(1)}s=e(h),o=s[0],E=s[1],h=h.substring(E),p.push(o)}if(h.length!==0)throw new Error("Invalid IP");switch(p.length){case 1:if(p[0]>4294967295)throw new Error("Invalid IP");return p[0]>>>0;case 2:if(p[0]>255||p[1]>16777215)throw new Error("Invalid IP");return(p[0]<<24|p[1])>>>0;case 3:if(p[0]>255||p[1]>255||p[2]>65535)throw new Error("Invalid IP");return(p[0]<<24|p[1]<<16|p[2])>>>0;case 4:if(p[0]>255||p[1]>255||p[2]>255||p[3]>255)throw new Error("Invalid IP");return(p[0]<<24|p[1]<<16|p[2]<<8|p[3])>>>0;default:throw new Error("Invalid IP")}},t=function(h){return h.charCodeAt(0)},n=t("0"),c=t("a"),i=t("A"),e=function(h){var p,E,g,d,o;for(d=0,p=10,E="9",g=0,h.length>1&&h[g]==="0"&&(h[g+1]==="x"||h[g+1]==="X"?(g+=2,p=16):"0"<=h[g+1]&&h[g+1]<="9"&&(g++,p=8,E="7")),o=g;g<h.length;){if("0"<=h[g]&&h[g]<=E)d=d*p+(t(h[g])-n)>>>0;else if(p===16)if("a"<=h[g]&&h[g]<="f")d=d*p+(10+t(h[g])-c)>>>0;else if("A"<=h[g]&&h[g]<="F")d=d*p+(10+t(h[g])-i)>>>0;else break;else break;if(d>4294967295)throw new Error("too large");g++}if(g===o)throw new Error("empty octet");return[d,g]},r=function(){function h(p,E){var g,d,o,s;if(typeof p!="string")throw new Error("Missing `net' parameter");if(E||(s=p.split("/",2),p=s[0],E=s[1]),E||(E=32),typeof E=="string"&&E.indexOf(".")>-1){try{this.maskLong=u(E)}catch(a){throw g=a,new Error("Invalid mask: "+E)}for(d=o=32;o>=0;d=--o)if(this.maskLong===4294967295<<32-d>>>0){this.bitmask=d;break}}else if(E||E===0)this.bitmask=parseInt(E,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(u(p)&this.maskLong)>>>0}catch(a){throw g=a,new Error("Invalid net address: "+p)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+E);this.size=Math.pow(2,32-this.bitmask),this.base=m(this.netLong),this.mask=m(this.maskLong),this.hostmask=m(~this.maskLong),this.first=this.bitmask<=30?m(this.netLong+1):this.base,this.last=this.bitmask<=30?m(this.netLong+this.size-2):m(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?m(this.netLong+this.size-1):void 0}return h.prototype.contains=function(p){return typeof p=="string"&&(p.indexOf("/")>0||p.split(".").length!==4)&&(p=new h(p)),p instanceof h?this.contains(p.base)&&this.contains(p.broadcast||p.last):(u(p)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},h.prototype.next=function(p){return p==null&&(p=1),new h(m(this.netLong+this.size*p),this.mask)},h.prototype.forEach=function(p){var E,g,d;for(d=u(this.first),g=u(this.last),E=0;d<=g;)p(m(d),d,E),E++,d++},h.prototype.toString=function(){return this.base+"/"+this.bitmask},h}(),Xe.ip2long=u,Xe.long2ip=m,Xe.Netmask=r}).call(Xe)});var rn=j((en,or)=>{(function(r){"use strict";let e="(0?\\d+|0x[a-f0-9]+)",t={fourOctet:new RegExp(`^${e}\\.${e}\\.${e}\\.${e}$`,"i"),threeOctet:new RegExp(`^${e}\\.${e}\\.${e}$`,"i"),twoOctet:new RegExp(`^${e}\\.${e}$`,"i"),longValue:new RegExp(`^${e}$`,"i")},n=new RegExp("^0[0-7]+$","i"),i=new RegExp("^0x[a-f0-9]+$","i"),c="%[0-9a-z]{1,}",u="(?:[0-9a-f]+::?)+",m={zoneIndex:new RegExp(c,"i"),native:new RegExp(`^(::)?(${u})?([0-9a-f]+)?(::)?(${c})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${e}\\.${e}\\.${e}\\.${e}(${c})?)$`,"i"),transitional:new RegExp(`^((?:${u})|(?:::)(?:${u})?)${e}\\.${e}\\.${e}\\.${e}(${c})?$`,"i")};function h(o,s){if(o.indexOf("::")!==o.lastIndexOf("::"))return null;let a=0,l=-1,y=(o.match(m.zoneIndex)||[])[0],w,A;for(y&&(y=y.substring(1),o=o.replace(/%.+$/,""));(l=o.indexOf(":",l+1))>=0;)a++;if(o.substr(0,2)==="::"&&a--,o.substr(-2,2)==="::"&&a--,a>s)return null;for(A=s-a,w=":";A--;)w+="0:";return o=o.replace("::",w),o[0]===":"&&(o=o.slice(1)),o[o.length-1]===":"&&(o=o.slice(0,-1)),s=function(){let O=o.split(":"),P=[];for(let L=0;L<O.length;L++)P.push(parseInt(O[L],16));return P}(),{parts:s,zoneId:y}}function p(o,s,a,l){if(o.length!==s.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let y=0,w;for(;l>0;){if(w=a-l,w<0&&(w=0),o[y]>>w!==s[y]>>w)return!1;l-=a,y+=1}return!0}function E(o){if(i.test(o))return parseInt(o,16);if(o[0]==="0"&&!isNaN(parseInt(o[1],10))){if(n.test(o))return parseInt(o,8);throw new Error(`ipaddr: cannot parse ${o} as octal`)}return parseInt(o,10)}function g(o,s){for(;o.length<s;)o=`0${o}`;return o}let d={};d.IPv4=function(){function o(s){if(s.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let a,l;for(a=0;a<s.length;a++)if(l=s[a],!(0<=l&&l<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=s}return o.prototype.SpecialRanges={unspecified:[[new o([0,0,0,0]),8]],broadcast:[[new o([255,255,255,255]),32]],multicast:[[new o([224,0,0,0]),4]],linkLocal:[[new o([169,254,0,0]),16]],loopback:[[new o([127,0,0,0]),8]],carrierGradeNat:[[new o([100,64,0,0]),10]],private:[[new o([10,0,0,0]),8],[new o([172,16,0,0]),12],[new o([192,168,0,0]),16]],reserved:[[new o([192,0,0,0]),24],[new o([192,0,2,0]),24],[new o([192,88,99,0]),24],[new o([198,18,0,0]),15],[new o([198,51,100,0]),24],[new o([203,0,113,0]),24],[new o([240,0,0,0]),4]]},o.prototype.kind=function(){return"ipv4"},o.prototype.match=function(s,a){let l;if(a===void 0&&(l=s,s=l[0],a=l[1]),s.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return p(this.octets,s.octets,8,a)},o.prototype.prefixLengthFromSubnetMask=function(){let s=0,a=!1,l={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},y,w,A;for(y=3;y>=0;y-=1)if(w=this.octets[y],w in l){if(A=l[w],a&&A!==0)return null;A!==8&&(a=!0),s+=A}else return null;return 32-s},o.prototype.range=function(){return d.subnetMatch(this,this.SpecialRanges)},o.prototype.toByteArray=function(){return this.octets.slice(0)},o.prototype.toIPv4MappedAddress=function(){return d.IPv6.parse(`::ffff:${this.toString()}`)},o.prototype.toNormalizedString=function(){return this.toString()},o.prototype.toString=function(){return this.octets.join(".")},o}(),d.IPv4.broadcastAddressFromCIDR=function(o){try{let s=this.parseCIDR(o),a=s[0].toByteArray(),l=this.subnetMaskFromPrefixLength(s[1]).toByteArray(),y=[],w=0;for(;w<4;)y.push(parseInt(a[w],10)|parseInt(l[w],10)^255),w++;return new this(y)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},d.IPv4.isIPv4=function(o){return this.parser(o)!==null},d.IPv4.isValid=function(o){try{return new this(this.parser(o)),!0}catch{return!1}},d.IPv4.isValidFourPartDecimal=function(o){return!!(d.IPv4.isValid(o)&&o.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},d.IPv4.networkAddressFromCIDR=function(o){let s,a,l,y,w;try{for(s=this.parseCIDR(o),l=s[0].toByteArray(),w=this.subnetMaskFromPrefixLength(s[1]).toByteArray(),y=[],a=0;a<4;)y.push(parseInt(l[a],10)&parseInt(w[a],10)),a++;return new this(y)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},d.IPv4.parse=function(o){let s=this.parser(o);if(s===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(s)},d.IPv4.parseCIDR=function(o){let s;if(s=o.match(/^(.+)\/(\d+)$/)){let a=parseInt(s[2]);if(a>=0&&a<=32){let l=[this.parse(s[1]),a];return Object.defineProperty(l,"toString",{value:function(){return this.join("/")}}),l}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},d.IPv4.parser=function(o){let s,a,l;if(s=o.match(t.fourOctet))return function(){let y=s.slice(1,6),w=[];for(let A=0;A<y.length;A++)a=y[A],w.push(E(a));return w}();if(s=o.match(t.longValue)){if(l=E(s[1]),l>4294967295||l<0)throw new Error("ipaddr: address outside defined range");return function(){let y=[],w;for(w=0;w<=24;w+=8)y.push(l>>w&255);return y}().reverse()}else return(s=o.match(t.twoOctet))?function(){let y=s.slice(1,4),w=[];if(l=E(y[1]),l>16777215||l<0)throw new Error("ipaddr: address outside defined range");return w.push(E(y[0])),w.push(l>>16&255),w.push(l>>8&255),w.push(l&255),w}():(s=o.match(t.threeOctet))?function(){let y=s.slice(1,5),w=[];if(l=E(y[2]),l>65535||l<0)throw new Error("ipaddr: address outside defined range");return w.push(E(y[0])),w.push(E(y[1])),w.push(l>>8&255),w.push(l&255),w}():null},d.IPv4.subnetMaskFromPrefixLength=function(o){if(o=parseInt(o),o<0||o>32)throw new Error("ipaddr: invalid IPv4 prefix length");let s=[0,0,0,0],a=0,l=Math.floor(o/8);for(;a<l;)s[a]=255,a++;return l<4&&(s[l]=Math.pow(2,o%8)-1<<8-o%8),new this(s)},d.IPv6=function(){function o(s,a){let l,y;if(s.length===16)for(this.parts=[],l=0;l<=14;l+=2)this.parts.push(s[l]<<8|s[l+1]);else if(s.length===8)this.parts=s;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(l=0;l<this.parts.length;l++)if(y=this.parts[l],!(0<=y&&y<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");a&&(this.zoneId=a)}return o.prototype.SpecialRanges={unspecified:[new o([0,0,0,0,0,0,0,0]),128],linkLocal:[new o([65152,0,0,0,0,0,0,0]),10],multicast:[new o([65280,0,0,0,0,0,0,0]),8],loopback:[new o([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new o([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new o([0,0,0,0,0,65535,0,0]),96],rfc6145:[new o([0,0,0,0,65535,0,0,0]),96],rfc6052:[new o([100,65435,0,0,0,0,0,0]),96],"6to4":[new o([8194,0,0,0,0,0,0,0]),16],teredo:[new o([8193,0,0,0,0,0,0,0]),32],reserved:[[new o([8193,3512,0,0,0,0,0,0]),32]],benchmarking:[new o([8193,2,0,0,0,0,0,0]),48],amt:[new o([8193,3,0,0,0,0,0,0]),32],as112v6:[new o([8193,4,274,0,0,0,0,0]),48],deprecated:[new o([8193,16,0,0,0,0,0,0]),28],orchid2:[new o([8193,32,0,0,0,0,0,0]),28]},o.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},o.prototype.kind=function(){return"ipv6"},o.prototype.match=function(s,a){let l;if(a===void 0&&(l=s,s=l[0],a=l[1]),s.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return p(this.parts,s.parts,16,a)},o.prototype.prefixLengthFromSubnetMask=function(){let s=0,a=!1,l={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},y,w;for(let A=7;A>=0;A-=1)if(y=this.parts[A],y in l){if(w=l[y],a&&w!==0)return null;w!==16&&(a=!0),s+=w}else return null;return 128-s},o.prototype.range=function(){return d.subnetMatch(this,this.SpecialRanges)},o.prototype.toByteArray=function(){let s,a=[],l=this.parts;for(let y=0;y<l.length;y++)s=l[y],a.push(s>>8),a.push(s&255);return a},o.prototype.toFixedLengthString=function(){let s=function(){let l=[];for(let y=0;y<this.parts.length;y++)l.push(g(this.parts[y].toString(16),4));return l}.call(this).join(":"),a="";return this.zoneId&&(a=`%${this.zoneId}`),s+a},o.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let s=this.parts.slice(-2),a=s[0],l=s[1];return new d.IPv4([a>>8,a&255,l>>8,l&255])},o.prototype.toNormalizedString=function(){let s=function(){let l=[];for(let y=0;y<this.parts.length;y++)l.push(this.parts[y].toString(16));return l}.call(this).join(":"),a="";return this.zoneId&&(a=`%${this.zoneId}`),s+a},o.prototype.toRFC5952String=function(){let s=/((^|:)(0(:|$)){2,})/g,a=this.toNormalizedString(),l=0,y=-1,w;for(;w=s.exec(a);)w[0].length>y&&(l=w.index,y=w[0].length);return y<0?a:`${a.substring(0,l)}::${a.substring(l+y)}`},o.prototype.toString=function(){return this.toRFC5952String()},o}(),d.IPv6.broadcastAddressFromCIDR=function(o){try{let s=this.parseCIDR(o),a=s[0].toByteArray(),l=this.subnetMaskFromPrefixLength(s[1]).toByteArray(),y=[],w=0;for(;w<16;)y.push(parseInt(a[w],10)|parseInt(l[w],10)^255),w++;return new this(y)}catch(s){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${s})`)}},d.IPv6.isIPv6=function(o){return this.parser(o)!==null},d.IPv6.isValid=function(o){if(typeof o=="string"&&o.indexOf(":")===-1)return!1;try{let s=this.parser(o);return new this(s.parts,s.zoneId),!0}catch{return!1}},d.IPv6.networkAddressFromCIDR=function(o){let s,a,l,y,w;try{for(s=this.parseCIDR(o),l=s[0].toByteArray(),w=this.subnetMaskFromPrefixLength(s[1]).toByteArray(),y=[],a=0;a<16;)y.push(parseInt(l[a],10)&parseInt(w[a],10)),a++;return new this(y)}catch(A){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${A})`)}},d.IPv6.parse=function(o){let s=this.parser(o);if(s.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(s.parts,s.zoneId)},d.IPv6.parseCIDR=function(o){let s,a,l;if((a=o.match(/^(.+)\/(\d+)$/))&&(s=parseInt(a[2]),s>=0&&s<=128))return l=[this.parse(a[1]),s],Object.defineProperty(l,"toString",{value:function(){return this.join("/")}}),l;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},d.IPv6.parser=function(o){let s,a,l,y,w,A;if(l=o.match(m.deprecatedTransitional))return this.parser(`::ffff:${l[1]}`);if(m.native.test(o))return h(o,8);if((l=o.match(m.transitional))&&(A=l[6]||"",s=h(l[1].slice(0,-1)+A,6),s.parts)){for(w=[parseInt(l[2]),parseInt(l[3]),parseInt(l[4]),parseInt(l[5])],a=0;a<w.length;a++)if(y=w[a],!(0<=y&&y<=255))return null;return s.parts.push(w[0]<<8|w[1]),s.parts.push(w[2]<<8|w[3]),{parts:s.parts,zoneId:s.zoneId}}return null},d.IPv6.subnetMaskFromPrefixLength=function(o){if(o=parseInt(o),o<0||o>128)throw new Error("ipaddr: invalid IPv6 prefix length");let s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a=0,l=Math.floor(o/8);for(;a<l;)s[a]=255,a++;return l<16&&(s[l]=Math.pow(2,o%8)-1<<8-o%8),new this(s)},d.fromByteArray=function(o){let s=o.length;if(s===4)return new d.IPv4(o);if(s===16)return new d.IPv6(o);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},d.isValid=function(o){return d.IPv6.isValid(o)||d.IPv4.isValid(o)},d.parse=function(o){if(d.IPv6.isValid(o))return d.IPv6.parse(o);if(d.IPv4.isValid(o))return d.IPv4.parse(o);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},d.parseCIDR=function(o){try{return d.IPv6.parseCIDR(o)}catch{try{return d.IPv4.parseCIDR(o)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},d.process=function(o){let s=this.parse(o);return s.kind()==="ipv6"&&s.isIPv4MappedAddress()?s.toIPv4Address():s},d.subnetMatch=function(o,s,a){let l,y,w,A;a==null&&(a="unicast");for(y in s)if(Object.prototype.hasOwnProperty.call(s,y)){for(w=s[y],w[0]&&!(w[0]instanceof Array)&&(w=[w]),l=0;l<w.length;l++)if(A=w[l],o.kind()===A[0].kind()&&o.match.apply(o,A))return y}return a},typeof or<"u"&&or.exports?or.exports=d:r.ipaddr=d})(en)});var Yo={};M(Yo,{mdns:()=>Go});var ut=Symbol.for("@libp2p/peer-discovery");var ht=Symbol.for("@libp2p/peer-id");var We=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var Je=class extends EventTarget{#e=new Map;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:c})=>c!==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 ur(e,t))}},lr=class extends Event{detail;constructor(e,t){super(e,t),this.detail=t?.detail}},ur=globalThis.CustomEvent??lr;var Rn=Qe(Ot(),1);var Cr={};M(Cr,{base58btc:()=>N,base58flickr:()=>si});var ds=new Uint8Array(0);function Rt(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 V(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 Tt(r){return new TextEncoder().encode(r)}function Dt(r){return new TextDecoder().decode(r)}function ri(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 c=r.charAt(i),u=c.charCodeAt(0);if(t[u]!==255)throw new TypeError(c+" is ambiguous");t[u]=i}var m=r.length,h=r.charAt(0),p=Math.log(m)/Math.log(256),E=Math.log(256)/Math.log(m);function g(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 a=0,l=0,y=0,w=s.length;y!==w&&s[y]===0;)y++,a++;for(var A=(w-y)*E+1>>>0,O=new Uint8Array(A);y!==w;){for(var P=s[y],L=0,q=A-1;(P!==0||L<l)&&q!==-1;q--,L++)P+=256*O[q]>>>0,O[q]=P%m>>>0,P=P/m>>>0;if(P!==0)throw new Error("Non-zero carry");l=L,y++}for(var ie=A-l;ie!==A&&O[ie]===0;)ie++;for(var Ge=h.repeat(a);ie<A;++ie)Ge+=r.charAt(O[ie]);return Ge}function d(s){if(typeof s!="string")throw new TypeError("Expected String");if(s.length===0)return new Uint8Array;var a=0;if(s[a]!==" "){for(var l=0,y=0;s[a]===h;)l++,a++;for(var w=(s.length-a)*p+1>>>0,A=new Uint8Array(w);s[a];){var O=t[s.charCodeAt(a)];if(O===255)return;for(var P=0,L=w-1;(O!==0||P<y)&&L!==-1;L--,P++)O+=m*A[L]>>>0,A[L]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");y=P,a++}if(s[a]!==" "){for(var q=w-y;q!==w&&A[q]===0;)q++;for(var ie=new Uint8Array(l+(w-q)),Ge=l;q!==w;)ie[Ge++]=A[q++];return ie}}}function o(s){var a=d(s);if(a)return a;throw new Error(`Non-${e} character`)}return{encode:g,decodeUnsafe:d,decode:o}}var ti=ri,ni=ti,Bt=ni;var Ur=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")}},br=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 Ft(this,e)}},Pr=class{decoders;constructor(e){this.decoders=e}or(e){return Ft(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 Ft(r,e){return new Pr({...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 Ur(e,t,n),this.decoder=new br(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Re({name:r,prefix:e,encode:t,decode:n}){return new Lr(r,e,t,n)}function Ie({name:r,prefix:e,alphabet:t}){let{encode:n,decode:i}=Bt(t,r);return Re({prefix:e,name:r,encode:n,decode:c=>V(i(c))})}function ii(r,e,t,n){let i={};for(let E=0;E<e.length;++E)i[e[E]]=E;let c=r.length;for(;r[c-1]==="=";)--c;let u=new Uint8Array(c*t/8|0),m=0,h=0,p=0;for(let E=0;E<c;++E){let g=i[r[E]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<t|g,m+=t,m>=8&&(m-=8,u[p++]=255&h>>m)}if(m>=t||255&h<<8-m)throw new SyntaxError("Unexpected end of data");return u}function oi(r,e,t){let n=e[e.length-1]==="=",i=(1<<t)-1,c="",u=0,m=0;for(let h=0;h<r.length;++h)for(m=m<<8|r[h],u+=8;u>t;)u-=t,c+=e[i&m>>u];if(u!==0&&(c+=e[i&m<<t-u]),n)for(;c.length*t&7;)c+="=";return c}function C({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Re({prefix:e,name:r,encode(i){return oi(i,n,t)},decode(i){return ii(i,n,t,r)}})}var N=Ie({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),si=Ie({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Or={};M(Or,{base10:()=>ci});var ci=Ie({prefix:"9",name:"base10",alphabet:"0123456789"});var Rr={};M(Rr,{base16:()=>ai,base16upper:()=>di});var ai=C({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),di=C({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Tr={};M(Tr,{base2:()=>li});var li=C({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Dr={};M(Dr,{base256emoji:()=>mi});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}"),ui=kt.reduce((r,e,t)=>(r[t]=e,r),[]),hi=kt.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function pi(r){return r.reduce((e,t)=>(e+=ui[t],e),"")}function gi(r){let e=[];for(let t of r){let n=hi[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var mi=Re({prefix:"\u{1F680}",name:"base256emoji",encode:pi,decode:gi});var Nr={};M(Nr,{base32:()=>me,base32hex:()=>Ei,base32hexpad:()=>vi,base32hexpadupper:()=>Ai,base32hexupper:()=>xi,base32pad:()=>wi,base32padupper:()=>Ii,base32upper:()=>yi,base32z:()=>Si});var me=C({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),yi=C({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),wi=C({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ii=C({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ei=C({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),xi=C({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),vi=C({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ai=C({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Si=C({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Br={};M(Br,{base36:()=>Ui,base36upper:()=>bi});var Ui=Ie({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),bi=Ie({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Fr={};M(Fr,{base64:()=>Pi,base64pad:()=>Li,base64url:()=>Ci,base64urlpad:()=>Oi});var Pi=C({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Li=C({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ci=C({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Oi=C({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var kr={};M(kr,{base8:()=>Ri});var Ri=C({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var $r={};M($r,{identity:()=>Ti});var Ti=Re({prefix:"\0",name:"identity",encode:r=>Dt(r),decode:r=>Tt(r)});var bs=new TextEncoder,Ps=new TextDecoder;var fr={};M(fr,{identity:()=>tr});var Bi=ft,$t=128,Fi=127,ki=~Fi,$i=Math.pow(2,31);function ft(r,e,t){e=e||[],t=t||0;for(var n=t;r>=$i;)e[t++]=r&255|$t,r/=128;for(;r&ki;)e[t++]=r&255|$t,r>>>=7;return e[t]=r|0,ft.bytes=t-n+1,e}var Mi=Mr,fi=128,Mt=127;function Mr(r,n){var t=0,n=n||0,i=0,c=n,u,m=r.length;do{if(c>=m)throw Mr.bytes=0,new RangeError("Could not decode varint");u=r[c++],t+=i<28?(u&Mt)<<i:(u&Mt)*Math.pow(2,i),i+=7}while(u>=fi);return Mr.bytes=c-n,t}var _i=Math.pow(2,7),zi=Math.pow(2,14),Vi=Math.pow(2,21),qi=Math.pow(2,28),ji=Math.pow(2,35),Ki=Math.pow(2,42),Hi=Math.pow(2,49),Xi=Math.pow(2,56),Gi=Math.pow(2,63),Yi=function(r){return r<_i?1:r<zi?2:r<Vi?3:r<qi?4:r<ji?5:r<Ki?6:r<Hi?7:r<Xi?8:r<Gi?9:10},Qi={encode:Bi,decode:Mi,encodingLength:Yi},Wi=Qi,fe=Wi;function _e(r,e=0){return[fe.decode(r,e),fe.decode.bytes]}function Te(r,e,t=0){return fe.encode(r,e,t),e}function De(r){return fe.encodingLength(r)}function Ee(r,e){let t=e.byteLength,n=De(r),i=n+De(t),c=new Uint8Array(i+t);return Te(r,c,0),Te(t,c,n),c.set(e,i),new Ne(r,t,e,c)}function Ue(r){let e=V(r),[t,n]=_e(e),[i,c]=_e(e.subarray(n)),u=e.subarray(n+c);if(u.byteLength!==i)throw new Error("Incorrect length");return new Ne(t,i,u,e)}function _t(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Rt(r.bytes,t.bytes)}}var Ne=class{code;size;digest;bytes;constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}};var zt=0,Ji="identity",Vt=V;function Zi(r){return Ee(zt,Vt(r))}var tr={code:zt,name:Ji,encode:Vt,digest:Zi};var qr={};M(qr,{sha256:()=>nr,sha512:()=>eo});var Vr=Qe(Ce("crypto"),1);function zr({name:r,code:e,encode:t}){return new _r(r,e,t)}var _r=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?Ee(this.code,t):t.then(n=>Ee(this.code,n))}else throw Error("Unknown type, must be binary type")}};var nr=zr({name:"sha2-256",code:18,encode:r=>V(Vr.default.createHash("sha256").update(r).digest())}),eo=zr({name:"sha2-512",code:19,encode:r=>V(Vr.default.createHash("sha512").update(r).digest())});function jt(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return to(t,jr(r),e??N.encoder);default:return no(t,jr(r),e??me.encoder)}}var Kt=new WeakMap;function jr(r){let e=Kt.get(r);if(e==null){let t=new Map;return Kt.set(r,t),t}return e}var G=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!==ze)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==io)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=Ee(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&&_t(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:c,bytes:u}=t;return new r(n,i,c,u??Ht(n,i,c.bytes))}else if(t[oo]===!0){let{version:n,multihash:i,code:c}=t,u=Ue(i);return r.create(n,c,u)}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!==ze)throw new Error(`Version 0 CID must use dag-pb (code: ${ze}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let i=Ht(e,t,n.bytes);return new r(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,ze,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=V(e.subarray(n,n+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");let c=i.subarray(t.multihashSize-t.digestSize),u=new Ne(t.multihashCode,t.digestSize,c,i);return[t.version===0?r.createV0(u):r.createV1(t.codec,u),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[g,d]=_e(e.subarray(t));return t+=d,g},i=n(),c=ze;if(i===18?(i=0,t=0):c=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let u=t,m=n(),h=n(),p=t+h,E=p-u;return{version:i,codec:c,multihashCode:m,digestSize:h,multihashSize:E,size:p}}static parse(e,t){let[n,i]=ro(e,t),c=r.decode(i);if(c.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return jr(c).set(n,e),c}};function ro(r,e){switch(r[0]){case"Q":{let t=e??N;return[N.prefix,t.decode(`${N.prefix}${r}`)]}case N.prefix:{let t=e??N;return[N.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 to(r,e,t){let{prefix:n}=t;if(n!==N.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let i=e.get(n);if(i==null){let c=t.encode(r).slice(1);return e.set(n,c),c}else return i}function no(r,e,t){let{prefix:n}=t,i=e.get(n);if(i==null){let c=t.encode(r);return e.set(n,c),c}else return i}var ze=112,io=18;function Ht(r,e,t){let n=De(r),i=n+De(e),c=new Uint8Array(i+t.byteLength);return Te(r,c,0),Te(e,c,n),c.set(t,i),c}var oo=Symbol.for("@ipld/js-cid/CID");var xe={...$r,...Tr,...kr,...Or,...Rr,...Nr,...Br,...Cr,...Fr,...Dr},Gs={...qr,...fr};function Ve(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 so=Symbol.for("nodejs.util.inspect.custom"),Xt=Object.values(xe).map(r=>r.decoder).reduce((r,e)=>r.or(e),xe.identity.decoder),Gt=114,Yt=36,Qt=37,qe=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()})`}[ht]=!0;toString(){return this.string==null&&(this.string=N.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return G.createV1(Gt,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return Ve(this.multihash.bytes,e);if(typeof e=="string")return Kr(e).equals(this);if(e?.multihash?.bytes!=null)return Ve(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[so](){return`PeerId(${this.toString()})`}},je=class extends qe{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Ke=class extends qe{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},He=class extends qe{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function Kr(r,e){if(e=e??Xt,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=Ue(N.decode(`z${r}`));return r.startsWith("12D")?new Ke({multihash:t}):r.startsWith("16U")?new He({multihash:t}):new je({multihash:t})}return co(Xt.decode(r))}function co(r){try{let e=Ue(r);if(e.code===tr.code){if(e.digest.length===Yt)return new Ke({multihash:e});if(e.digest.length===Qt)return new He({multihash:e})}if(e.code===nr.code)return new je({multihash:e})}catch{return ao(G.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function ao(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Gt)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===nr.code)return new je({multihash:r.multihash});if(e.code===tr.code){if(e.digest.length===Yt)return new Ke({multihash:r.multihash});if(e.digest.length===Qt)return new He({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var nn=Qe(Wt(),1);var Jt="[a-fA-F\\d:]",ve=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${Jt})|(?<=${Jt})(?=\\s|$))`:"",Y="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",R="[a-fA-F\\d]{1,4}",ir=`
|
|
3
3
|
(?:
|
|
4
4
|
(?:${R}:){7}(?:${R}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
|
|
5
5
|
(?:${R}:){6}(?:${Y}|:${R}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
(?:${R}:){1}(?:(?::${R}){0,4}:${Y}|(?::${R}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
|
|
11
11
|
(?::(?:(?::${R}){0,5}:${Y}|(?::${R}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
|
|
12
12
|
)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
|
|
13
|
-
`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),ho=new RegExp(`(?:^${Y}$)|(?:^${ir}$)`),po=new RegExp(`^${Y}$`),go=new RegExp(`^${ir}$`),Hr=r=>r&&r.exact?ho:new RegExp(`(?:${ve(r)}${Y}${ve(r)})|(?:${ve(r)}${ir}${ve(r)})`,"g");Hr.v4=r=>r&&r.exact?po:new RegExp(`${ve(r)}${Y}${ve(r)}`,"g");Hr.v6=r=>r&&r.exact?go:new RegExp(`${ve(r)}${ir}${ve(r)}`,"g");var rn=Hr;var Ae=Ce("node:net");function Be(r){return!!(0,Ae.isIP)(r)}var cn=We(nn(),1),{isValid:mo,parse:yo}=cn.default,wo=["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"],Io=wo.map(r=>new sn.Netmask(r));function xo(r){for(let e of Io)if(e.contains(r))return!0;return!1}function on(r){return/^::$/.test(r)||/^::1$/.test(r)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}var an=r=>{if(mo(r)){let e=yo(r);if(e.kind()==="ipv4")return xo(e.toNormalizedString());if(e.kind()==="ipv6")return on(r)}else if(Be(r)&&rn.v6().test(r))return on(r)};var dn=an;function ln(r){try{let{address:e}=r.nodeAddress();return!!dn(e)}catch{return!0}}function Pe(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Fe(r=0){return globalThis.Buffer?.allocUnsafe!=null?Pe(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function hn(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var un=hn("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Xr=hn("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=Fe(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Eo={utf8:un,"utf-8":un,hex:Ee.base16,latin1:Xr,ascii:Xr,binary:Xr,...Ee},sr=Eo;function k(r,e="utf8"){let t=sr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var vo=Math.pow(2,7),Ao=Math.pow(2,14),So=Math.pow(2,21),Gr=Math.pow(2,28),Yr=Math.pow(2,35),Qr=Math.pow(2,42),Wr=Math.pow(2,49),b=128,B=127;function ne(r){if(r<vo)return 1;if(r<Ao)return 2;if(r<So)return 3;if(r<Gr)return 4;if(r<Yr)return 5;if(r<Qr)return 6;if(r<Wr)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function bo(r,e,t=0){switch(ne(r)){case 8:e[t++]=r&255|b,r/=128;case 7:e[t++]=r&255|b,r/=128;case 6:e[t++]=r&255|b,r/=128;case 5:e[t++]=r&255|b,r/=128;case 4:e[t++]=r&255|b,r>>>=7;case 3:e[t++]=r&255|b,r>>>=7;case 2:e[t++]=r&255|b,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Uo(r,e,t=0){switch(ne(r)){case 8:e.set(t++,r&255|b),r/=128;case 7:e.set(t++,r&255|b),r/=128;case 6:e.set(t++,r&255|b),r/=128;case 5:e.set(t++,r&255|b),r/=128;case 4:e.set(t++,r&255|b),r>>>=7;case 3:e.set(t++,r&255|b),r>>>=7;case 2:e.set(t++,r&255|b),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function Po(r,e){let t=r[e],n=0;if(n+=t&B,t<b||(t=r[e+1],n+=(t&B)<<7,t<b)||(t=r[e+2],n+=(t&B)<<14,t<b)||(t=r[e+3],n+=(t&B)<<21,t<b)||(t=r[e+4],n+=(t&B)*Gr,t<b)||(t=r[e+5],n+=(t&B)*Yr,t<b)||(t=r[e+6],n+=(t&B)*Qr,t<b)||(t=r[e+7],n+=(t&B)*Wr,t<b))return n;throw new RangeError("Could not decode varint")}function Lo(r,e){let t=r.get(e),n=0;if(n+=t&B,t<b||(t=r.get(e+1),n+=(t&B)<<7,t<b)||(t=r.get(e+2),n+=(t&B)<<14,t<b)||(t=r.get(e+3),n+=(t&B)<<21,t<b)||(t=r.get(e+4),n+=(t&B)*Gr,t<b)||(t=r.get(e+5),n+=(t&B)*Yr,t<b)||(t=r.get(e+6),n+=(t&B)*Qr,t<b)||(t=r.get(e+7),n+=(t&B)*Wr,t<b))return n;throw new RangeError("Could not decode varint")}function fe(r,e,t=0){return e==null&&(e=Fe(ne(r))),e instanceof Uint8Array?bo(r,e,t):Uo(r,e,t)}function Le(r,e=0){return r instanceof Uint8Array?Po(r,e):Lo(r,e)}function ye(r,e){if(globalThis.Buffer!=null)return Pe(globalThis.Buffer.concat(r,e));e==null&&(e=r.reduce((i,c)=>i+c.length,0));let t=Fe(e),n=0;for(let i of r)t.set(i,n),n+=i.length;return Pe(t)}var cr=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 c=0,u=0,m=this.peekChar();if(m===void 0)return;let h=m==="0",p=2**(8*i)-1;for(;;){let x=this.readAtomically(()=>{let g=this.readChar();if(g===void 0)return;let d=Number.parseInt(g,e);if(!Number.isNaN(d))return d});if(x===void 0)break;if(c*=e,c+=x,c>p||(u+=1,t!==void 0&&u>t))return}if(u!==0)return!n&&h&&u>1?void 0:c})}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 u=this.readSeparator(":",n,()=>this.readIPv4Addr());if(u!==void 0)return t[i]=u[0],t[i+1]=u[1],t[i+2]=u[2],t[i+3]=u[3],[i+4,!0]}let c=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(c===void 0)return[i,!1];t[i]=c>>8,t[i+1]=c&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 c=new Uint8Array(14),u=16-(n+2),[m]=e(c.subarray(0,u));return t.set(c.subarray(0,m),16-m),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var ga=new cr;var Aa=parseInt("0xFFFF",16),Sa=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Jr(r,e="utf8"){let t=sr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Pe(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var yn=Ae.isIPv4,No=Ae.isIPv6,Zr=function(r){let e=0;if(r=r.toString().trim(),yn(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(No(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let c=yn(t[n]),u;c&&(u=Zr(t[n]),t[n]=k(u.slice(0,2),"base16")),u!=null&&++n<8&&t.splice(n,0,k(u.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 c=[n,1];for(n=9-t.length;n>0;n--)c.push("0");t.splice.apply(t,c)}let i=new Uint8Array(e+16);for(n=0;n<t.length;n++){let c=parseInt(t[n],16);i[e++]=c>>8&255,i[e++]=c&255}return i}throw new Error("invalid ip address")},wn=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 c=0;c<t;c++)i.push(r[e+c]);return i.join(".")}if(t===16){let i=[];for(let c=0;c<t;c+=2)i.push(n.getUint16(e+c).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var ke={},et={},Fo=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];Fo.forEach(r=>{let e=fo(...r);et[e.code]=e,ke[e.name]=e});function fo(r,e,t,n,i){return{code:r,size:e,name:t,resolvable:!!n,path:!!i}}function U(r){if(typeof r=="number"){if(et[r]!=null)return et[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(ke[r]!=null)return ke[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var dd=U("ip4"),ld=U("ip6"),ud=U("ipcidr");function tt(r,e){switch(U(r).code){case 4:case 41:return $o(e);case 42:return En(e);case 6:case 273:case 33:case 132:return An(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return En(e);case 421:return Vo(e);case 444:return vn(e);case 445:return vn(e);case 466:return zo(e);default:return k(e,"base16")}}function nt(r,e){switch(U(r).code){case 4:return In(e);case 41:return In(e);case 42:return xn(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 xn(e);case 421:return Mo(e);case 444:return qo(e);case 445:return jo(e);case 466:return _o(e);default:return Jr(e,"base16")}}var rt=Object.values(Ee).map(r=>r.decoder),ko=function(){let r=rt[0].or(rt[1]);return rt.slice(2).forEach(e=>r=r.or(e)),r}();function In(r){if(!Be(r))throw new Error("invalid ip address");return Zr(r)}function $o(r){let e=wn(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Be(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 An(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function xn(r){let e=Jr(r),t=Uint8Array.from(fe(e.length));return ye([t,e],t.length+e.length)}function En(r){let e=Le(r);if(r=r.slice(ne(e)),r.length!==e)throw new Error("inconsistent lengths");return k(r)}function Mo(r){let e;r[0]==="Q"||r[0]==="1"?e=be(N.decode(`z${r}`)).bytes:e=G.parse(r).multihash.bytes;let t=Uint8Array.from(fe(e.length));return ye([t,e],t.length+e.length)}function _o(r){let e=ko.decode(r),t=Uint8Array.from(fe(e.length));return ye([t,e],t.length+e.length)}function zo(r){let e=Le(r),t=r.slice(ne(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+k(t,"base64url")}function Vo(r){let e=Le(r),t=r.slice(ne(e));if(t.length!==e)throw new Error("inconsistent lengths");return k(t,"base58btc")}function qo(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 jo(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 vn(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=k(e,"base32"),i=An(t);return`${n}:${i}`}function Sn(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 c=0;c<i.length;c++){let u=i[c],m=U(u);if(m.size===0){e.push([m.code]),t.push([m.code]);continue}if(c++,c>=i.length)throw Un("invalid address: "+r);if(m.path===!0){n=ot(i.slice(c).join("/")),e.push([m.code,nt(m.code,n)]),t.push([m.code,n]);break}let h=nt(m.code,i[c]);e.push([m.code,h]),t.push([m.code,tt(m.code,h)])}return{string:bn(t),bytes:ct(e),tuples:e,stringTuples:t,path:n}}function st(r){let e=[],t=[],n=null,i=0;for(;i<r.length;){let c=Le(r,i),u=ne(c),m=U(c),h=Ko(m,r.slice(i+u));if(h===0){e.push([c]),t.push([c]),i+=u;continue}let p=r.slice(i+u,i+u+h);if(i+=h+u,i>r.length)throw Un("Invalid address Uint8Array: "+k(r,"base16"));e.push([c,p]);let x=tt(c,p);if(t.push([c,x]),m.path===!0){n=x;break}}return{bytes:Uint8Array.from(r),string:bn(t),tuples:e,stringTuples:t,path:n}}function bn(r){let e=[];return r.map(t=>{let n=U(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),ot(e.join("/"))}function ct(r){return ye(r.map(e=>{let t=U(e[0]),n=Uint8Array.from(fe(t.code));return e.length>1&&e[1]!=null&&(n=ye([n,e[1]])),n}))}function Ko(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Le(e instanceof Uint8Array?e:Uint8Array.from(e));return t+ne(t)}}function ot(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function Un(r){return new Error("Error parsing address: "+r)}var Ho=Symbol.for("nodejs.util.inspect.custom"),at=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Xo=[U("dns").code,U("dns4").code,U("dns6").code,U("dnsaddr").code],ar=class r{bytes;#e;#r;#t;#n;[at]=!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=Sn(e)}else if(Ln(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,c="",u=U("tcp"),m=U("udp"),h=U("ip4"),p=U("ip6"),x=U("dns6"),g=U("ip6zone");for(let[o,s]of this.stringTuples())o===g.code&&(c=`%${s??""}`),Xo.includes(o)&&(t=u.name,i=443,n=`${s??""}${c}`,e=o===x.code?6:4),(o===u.code||o===m.code)&&(t=U(o).name,i=parseInt(s??"")),(o===h.code||o===p.code)&&(t=U(o).name,n=`${s??""}${c}`,e=o===p.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({},U(e)))}protoCodes(){return this.#r.map(([e])=>e)}protoNames(){return this.#r.map(([e])=>U(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(ct(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,i])=>{n===ke.p2p.code&&e.push([n,i]),n===ke["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?k(N.decode(`z${n}`),"base58btc"):k(G.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return qe(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(c=>c.resolvable);if(t==null)return[this];let n=Pn.get(t.name);if(n==null)throw new $e(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(c=>new r(c))}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)}[Ho](){return`Multiaddr(${this.#e})`}};var Pn=new Map;function Ln(r){return!!r?.[at]}function dt(r){return new ar(r)}function Cn(r,e,t,n){let i=()=>{n?.log.trace("query",e),r.query({questions:[{name:e,type:"PTR"}]})};return i(),setInterval(i,t)}function On(r,e,t,n){if(r.answers==null)return;let i,c=[];if(r.answers.forEach(u=>{switch(u.type){case"PTR":i=u;break;case"TXT":c.push(u);break;default:break}}),r.additionals.forEach(u=>{switch(u.type){case"TXT":c.push(u);break;default:break}}),!(i==null||i?.name!==t||c.length===0||i.data.startsWith(e)))try{let u=c.flatMap(h=>h.data).filter(h=>h.toString().startsWith("dnsaddr=")).map(h=>dt(h.toString().substring(8))),m=u[0].getPeerId();if(m==null)throw new Error("Multiaddr doesn't contain PeerId");return n?.log("peer found %p",m),{id:Kr(m),multiaddrs:u.map(h=>h.decapsulateCode(U("p2p").code))}}catch(u){n?.log.error("failed to parse mdns response",u)}}function Rn(r,e,t,n,i,c,u){if(!c){u?.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 m=[];m.push({name:i,type:"PTR",class:"IN",ttl:120,data:t+"."+i}),n.filter(Go).forEach(h=>{let p="dnsaddr="+h.toString();if(p.length>255){u?.log("multiaddr %a is too long to use in mDNS query response",h);return}if(h.getPeerId()==null){u?.log("multiaddr %a did not have a peer ID so cannot be used in mDNS query response",h);return}m.push({name:t+"."+i,type:"TXT",class:"IN",ttl:120,data:p})}),u?.log.trace("responding to query"),e.respond(m)}}function Go(r){return!!ln(r)}function Tn(r){let e="",t="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<r;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}var dr=class extends Je{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??Tn(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";isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,Dn.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=Cn(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),Rn(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=On(e,this.peerName,this.serviceTag,{log:this.log});t!=null&&(this.log("discovered peer in mDNS query response %p",t.id),this.dispatchEvent(new ur("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 Qo(r={}){return e=>new dr(e,r)}return $n(Wo);})();
|
|
13
|
+
`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),lo=new RegExp(`(?:^${Y}$)|(?:^${ir}$)`),uo=new RegExp(`^${Y}$`),ho=new RegExp(`^${ir}$`),Hr=r=>r&&r.exact?lo:new RegExp(`(?:${ve(r)}${Y}${ve(r)})|(?:${ve(r)}${ir}${ve(r)})`,"g");Hr.v4=r=>r&&r.exact?uo:new RegExp(`${ve(r)}${Y}${ve(r)}`,"g");Hr.v6=r=>r&&r.exact?ho:new RegExp(`${ve(r)}${ir}${ve(r)}`,"g");var Zt=Hr;var Ae=Ce("node:net");function Be(r){return!!(0,Ae.isIP)(r)}var on=Qe(rn(),1),{isValid:po,parse:go}=on.default,mo=["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"],yo=mo.map(r=>new nn.Netmask(r));function wo(r){for(let e of yo)if(e.contains(r))return!0;return!1}function tn(r){return/^::$/.test(r)||/^::1$/.test(r)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}var sn=r=>{if(po(r)){let e=go(r);if(e.kind()==="ipv4")return wo(e.toNormalizedString());if(e.kind()==="ipv6")return tn(r)}else if(Be(r)&&Zt.v6().test(r))return tn(r)};var cn=sn;function an(r){try{let{address:e}=r.nodeAddress();return!!cn(e)}catch{return!0}}function Pe(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Fe(r=0){return globalThis.Buffer?.allocUnsafe!=null?Pe(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function ln(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var dn=ln("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Xr=ln("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=Fe(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Io={utf8:dn,"utf-8":dn,hex:xe.base16,latin1:Xr,ascii:Xr,binary:Xr,...xe},sr=Io;function $(r,e="utf8"){let t=sr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var Eo=Math.pow(2,7),xo=Math.pow(2,14),vo=Math.pow(2,21),Gr=Math.pow(2,28),Yr=Math.pow(2,35),Qr=Math.pow(2,42),Wr=Math.pow(2,49),U=128,B=127;function ne(r){if(r<Eo)return 1;if(r<xo)return 2;if(r<vo)return 3;if(r<Gr)return 4;if(r<Yr)return 5;if(r<Qr)return 6;if(r<Wr)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Ao(r,e,t=0){switch(ne(r)){case 8:e[t++]=r&255|U,r/=128;case 7:e[t++]=r&255|U,r/=128;case 6:e[t++]=r&255|U,r/=128;case 5:e[t++]=r&255|U,r/=128;case 4:e[t++]=r&255|U,r>>>=7;case 3:e[t++]=r&255|U,r>>>=7;case 2:e[t++]=r&255|U,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function So(r,e,t=0){switch(ne(r)){case 8:e.set(t++,r&255|U),r/=128;case 7:e.set(t++,r&255|U),r/=128;case 6:e.set(t++,r&255|U),r/=128;case 5:e.set(t++,r&255|U),r/=128;case 4:e.set(t++,r&255|U),r>>>=7;case 3:e.set(t++,r&255|U),r>>>=7;case 2:e.set(t++,r&255|U),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function Uo(r,e){let t=r[e],n=0;if(n+=t&B,t<U||(t=r[e+1],n+=(t&B)<<7,t<U)||(t=r[e+2],n+=(t&B)<<14,t<U)||(t=r[e+3],n+=(t&B)<<21,t<U)||(t=r[e+4],n+=(t&B)*Gr,t<U)||(t=r[e+5],n+=(t&B)*Yr,t<U)||(t=r[e+6],n+=(t&B)*Qr,t<U)||(t=r[e+7],n+=(t&B)*Wr,t<U))return n;throw new RangeError("Could not decode varint")}function bo(r,e){let t=r.get(e),n=0;if(n+=t&B,t<U||(t=r.get(e+1),n+=(t&B)<<7,t<U)||(t=r.get(e+2),n+=(t&B)<<14,t<U)||(t=r.get(e+3),n+=(t&B)<<21,t<U)||(t=r.get(e+4),n+=(t&B)*Gr,t<U)||(t=r.get(e+5),n+=(t&B)*Yr,t<U)||(t=r.get(e+6),n+=(t&B)*Qr,t<U)||(t=r.get(e+7),n+=(t&B)*Wr,t<U))return n;throw new RangeError("Could not decode varint")}function ke(r,e,t=0){return e==null&&(e=Fe(ne(r))),e instanceof Uint8Array?Ao(r,e,t):So(r,e,t)}function Le(r,e=0){return r instanceof Uint8Array?Uo(r,e):bo(r,e)}function ye(r,e){if(globalThis.Buffer!=null)return Pe(globalThis.Buffer.concat(r,e));e==null&&(e=r.reduce((i,c)=>i+c.length,0));let t=Fe(e),n=0;for(let i of r)t.set(i,n),n+=i.length;return Pe(t)}var cr=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 c=0,u=0,m=this.peekChar();if(m===void 0)return;let h=m==="0",p=2**(8*i)-1;for(;;){let E=this.readAtomically(()=>{let g=this.readChar();if(g===void 0)return;let d=Number.parseInt(g,e);if(!Number.isNaN(d))return d});if(E===void 0)break;if(c*=e,c+=E,c>p||(u+=1,t!==void 0&&u>t))return}if(u!==0)return!n&&h&&u>1?void 0:c})}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 u=this.readSeparator(":",n,()=>this.readIPv4Addr());if(u!==void 0)return t[i]=u[0],t[i+1]=u[1],t[i+2]=u[2],t[i+3]=u[3],[i+4,!0]}let c=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(c===void 0)return[i,!1];t[i]=c>>8,t[i+1]=c&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 c=new Uint8Array(14),u=16-(n+2),[m]=e(c.subarray(0,u));return t.set(c.subarray(0,m),16-m),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Oc=new cr;var $c=parseInt("0xFFFF",16),Mc=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Jr(r,e="utf8"){let t=sr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Pe(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var gn=Ae.isIPv4,To=Ae.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(To(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let c=gn(t[n]),u;c&&(u=Zr(t[n]),t[n]=$(u.slice(0,2),"base16")),u!=null&&++n<8&&t.splice(n,0,$(u.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 c=[n,1];for(n=9-t.length;n>0;n--)c.push("0");t.splice.apply(t,c)}let i=new Uint8Array(e+16);for(n=0;n<t.length;n++){let c=parseInt(t[n],16);i[e++]=c>>8&255,i[e++]=c&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 c=0;c<t;c++)i.push(r[e+c]);return i.join(".")}if(t===16){let i=[];for(let c=0;c<t;c+=2)i.push(n.getUint16(e+c).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var $e={},et={},No=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];No.forEach(r=>{let e=Bo(...r);et[e.code]=e,$e[e.name]=e});function Bo(r,e,t,n,i){return{code:r,size:e,name:t,resolvable:!!n,path:!!i}}function b(r){if(typeof r=="number"){if(et[r]!=null)return et[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if($e[r]!=null)return $e[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Ua=b("ip4"),ba=b("ip6"),Pa=b("ipcidr");function tt(r,e){switch(b(r).code){case 4:case 41:return ko(e);case 42:return In(e);case 6:case 273:case 33:case 132:return xn(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return In(e);case 421:return _o(e);case 444:return En(e);case 445:return En(e);case 466:return fo(e);default:return $(e,"base16")}}function nt(r,e){switch(b(r).code){case 4:return yn(e);case 41:return yn(e);case 42:return wn(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 wn(e);case 421:return $o(e);case 444:return zo(e);case 445:return Vo(e);case 466:return Mo(e);default:return Jr(e,"base16")}}var rt=Object.values(xe).map(r=>r.decoder),Fo=function(){let r=rt[0].or(rt[1]);return rt.slice(2).forEach(e=>r=r.or(e)),r}();function yn(r){if(!Be(r))throw new Error("invalid ip address");return Zr(r)}function ko(r){let e=mn(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Be(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 xn(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function wn(r){let e=Jr(r),t=Uint8Array.from(ke(e.length));return ye([t,e],t.length+e.length)}function In(r){let e=Le(r);if(r=r.slice(ne(e)),r.length!==e)throw new Error("inconsistent lengths");return $(r)}function $o(r){let e;r[0]==="Q"||r[0]==="1"?e=Ue(N.decode(`z${r}`)).bytes:e=G.parse(r).multihash.bytes;let t=Uint8Array.from(ke(e.length));return ye([t,e],t.length+e.length)}function Mo(r){let e=Fo.decode(r),t=Uint8Array.from(ke(e.length));return ye([t,e],t.length+e.length)}function fo(r){let e=Le(r),t=r.slice(ne(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+$(t,"base64url")}function _o(r){let e=Le(r),t=r.slice(ne(e));if(t.length!==e)throw new Error("inconsistent lengths");return $(t,"base58btc")}function zo(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 Vo(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 En(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=$(e,"base32"),i=xn(t);return`${n}:${i}`}function vn(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 c=0;c<i.length;c++){let u=i[c],m=b(u);if(m.size===0){e.push([m.code]),t.push([m.code]);continue}if(c++,c>=i.length)throw Sn("invalid address: "+r);if(m.path===!0){n=ot(i.slice(c).join("/")),e.push([m.code,nt(m.code,n)]),t.push([m.code,n]);break}let h=nt(m.code,i[c]);e.push([m.code,h]),t.push([m.code,tt(m.code,h)])}return{string:An(t),bytes:ct(e),tuples:e,stringTuples:t,path:n}}function st(r){let e=[],t=[],n=null,i=0;for(;i<r.length;){let c=Le(r,i),u=ne(c),m=b(c),h=qo(m,r.slice(i+u));if(h===0){e.push([c]),t.push([c]),i+=u;continue}let p=r.slice(i+u,i+u+h);if(i+=h+u,i>r.length)throw Sn("Invalid address Uint8Array: "+$(r,"base16"));e.push([c,p]);let E=tt(c,p);if(t.push([c,E]),m.path===!0){n=E;break}}return{bytes:Uint8Array.from(r),string:An(t),tuples:e,stringTuples:t,path:n}}function An(r){let e=[];return r.map(t=>{let n=b(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),ot(e.join("/"))}function ct(r){return ye(r.map(e=>{let t=b(e[0]),n=Uint8Array.from(ke(t.code));return e.length>1&&e[1]!=null&&(n=ye([n,e[1]])),n}))}function qo(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Le(e instanceof Uint8Array?e:Uint8Array.from(e));return t+ne(t)}}function ot(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function Sn(r){return new Error("Error parsing address: "+r)}var jo=Symbol.for("nodejs.util.inspect.custom"),at=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Ko=[b("dns").code,b("dns4").code,b("dns6").code,b("dnsaddr").code],ar=class r{bytes;#e;#r;#t;#n;[at]=!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=vn(e)}else if(bn(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,c="",u=b("tcp"),m=b("udp"),h=b("ip4"),p=b("ip6"),E=b("dns6"),g=b("ip6zone");for(let[o,s]of this.stringTuples())o===g.code&&(c=`%${s??""}`),Ko.includes(o)&&(t=u.name,i=443,n=`${s??""}${c}`,e=o===E.code?6:4),(o===u.code||o===m.code)&&(t=b(o).name,i=parseInt(s??"")),(o===h.code||o===p.code)&&(t=b(o).name,n=`${s??""}${c}`,e=o===p.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({},b(e)))}protoCodes(){return this.#r.map(([e])=>e)}protoNames(){return this.#r.map(([e])=>b(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(ct(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,i])=>{n===$e.p2p.code&&e.push([n,i]),n===$e["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?$(N.decode(`z${n}`),"base58btc"):$(G.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return Ve(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(c=>c.resolvable);if(t==null)return[this];let n=Un.get(t.name);if(n==null)throw new We(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(c=>new r(c))}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)}[jo](){return`Multiaddr(${this.#e})`}};var Un=new Map;function bn(r){return!!r?.[at]}function dt(r){return new ar(r)}function Pn(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,c=[];if(r.answers.forEach(u=>{switch(u.type){case"PTR":i=u;break;case"TXT":c.push(u);break;default:break}}),r.additionals.forEach(u=>{switch(u.type){case"TXT":c.push(u);break;default:break}}),!(i==null||i?.name!==t||c.length===0||i.data.startsWith(e)))try{let u=c.flatMap(h=>h.data).filter(h=>h.toString().startsWith("dnsaddr=")).map(h=>dt(h.toString().substring(8))),m=u[0].getPeerId();if(m==null)throw new Error("Multiaddr doesn't contain PeerId");return n?.log("peer found %p",m),{id:Kr(m),multiaddrs:u.map(h=>h.decapsulateCode(b("p2p").code))}}catch(u){n?.log.error("failed to parse mdns response",u)}}function Cn(r,e,t,n,i,c,u){if(!c){u?.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 m=[];m.push({name:i,type:"PTR",class:"IN",ttl:120,data:t+"."+i}),n.filter(Ho).forEach(h=>{let p="dnsaddr="+h.toString();if(p.length>255){u?.log("multiaddr %a is too long to use in mDNS query response",h);return}if(h.getPeerId()==null){u?.log("multiaddr %a did not have a peer ID so cannot be used in mDNS query response",h);return}m.push({name:t+"."+i,type:"TXT",class:"IN",ttl:120,data:p})}),u?.log.trace("responding to query"),e.respond(m)}}function Ho(r){return!!an(r)}function On(r){let e="",t="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<r;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}var dr=class extends Je{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??On(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";isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,Rn.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=Pn(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),Cn(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 ur("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 Go(r={}){return e=>new dr(e,r)}return kn(Yo);})();
|
|
14
14
|
return Libp2PMdns}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/mdns",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.12-3e47d88fd",
|
|
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",
|
|
@@ -49,21 +49,22 @@
|
|
|
49
49
|
"test:electron-main": "aegir test -t electron-main"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@libp2p/interface": "
|
|
53
|
-
"@libp2p/interface-internal": "
|
|
54
|
-
"@libp2p/peer-id": "
|
|
55
|
-
"@libp2p/utils": "
|
|
52
|
+
"@libp2p/interface": "1.1.2-3e47d88fd",
|
|
53
|
+
"@libp2p/interface-internal": "1.0.7-3e47d88fd",
|
|
54
|
+
"@libp2p/peer-id": "4.0.5-3e47d88fd",
|
|
55
|
+
"@libp2p/utils": "5.2.2-3e47d88fd",
|
|
56
56
|
"@multiformats/multiaddr": "^12.1.10",
|
|
57
57
|
"@types/multicast-dns": "^7.2.1",
|
|
58
58
|
"dns-packet": "^5.4.0",
|
|
59
59
|
"multicast-dns": "^7.2.5"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@libp2p/interface-compliance-tests": "
|
|
63
|
-
"@libp2p/logger": "
|
|
64
|
-
"@libp2p/peer-id-factory": "
|
|
62
|
+
"@libp2p/interface-compliance-tests": "5.1.3-3e47d88fd",
|
|
63
|
+
"@libp2p/logger": "4.0.5-3e47d88fd",
|
|
64
|
+
"@libp2p/peer-id-factory": "4.0.5-3e47d88fd",
|
|
65
65
|
"aegir": "^42.0.0",
|
|
66
66
|
"p-wait-for": "^5.0.2",
|
|
67
67
|
"sinon-ts": "^2.0.0"
|
|
68
|
-
}
|
|
68
|
+
},
|
|
69
|
+
"sideEffects": false
|
|
69
70
|
}
|
package/dist/typedoc-urls.json
DELETED