@libp2p/mdns 10.0.7 → 10.0.8-4e0135c7d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.min.js +10 -10
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/package.json +8 -8
- package/src/index.ts +1 -1
- package/dist/typedoc-urls.json +0 -4
package/README.md
CHANGED
package/dist/index.min.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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 fn=Object.create;var Ge=Object.defineProperty;var kn=Object.getOwnPropertyDescriptor;var $n=Object.getOwnPropertyNames;var Mn=Object.getPrototypeOf,_n=Object.prototype.hasOwnProperty;var Pe=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var j=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),$=(t,e)=>{for(var r in e)Ge(t,r,{get:e[r],enumerable:!0})},lr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of $n(e))!_n.call(t,i)&&i!==r&&Ge(t,i,{get:()=>e[i],enumerable:!(n=kn(e,i))||n.enumerable});return t};var Ye=(t,e,r)=>(r=t!=null?fn(Mn(t)):{},lr(e||!t||!t.__esModule?Ge(r,"default",{value:t,enumerable:!0}):r,t)),zn=t=>lr(Ge({},"__esModule",{value:!0}),t);var mr=j(ut=>{"use strict";ut.toString=function(t){switch(t){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_"+t};ut.toType=function(t){switch(t.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 t.toUpperCase().startsWith("UNKNOWN_")?parseInt(t.slice(8)):0}});var yr=j(ht=>{"use strict";ht.toString=function(t){switch(t){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_"+t};ht.toRcode=function(t){switch(t.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 wr=j(pt=>{"use strict";pt.toString=function(t){switch(t){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_"+t};pt.toOpcode=function(t){switch(t.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 Ir=j(gt=>{"use strict";gt.toString=function(t){switch(t){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+t};gt.toClass=function(t){switch(t.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}});var Er=j(mt=>{"use strict";mt.toString=function(t){switch(t){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 t<0?null:`OPTION_${t}`};mt.toCode=function(t){if(typeof t=="number")return t;if(!t)return-1;switch(t.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=t.match(/_(\d+)$/);return e?parseInt(e[1],10):-1}});var Ar=j((vr,yt)=>{var xr=function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=g,t.encode=E,t.familyOf=p,t.name=void 0,t.sizeOf=h,t.v6=t.v4=void 0;let e=/^(\d{1,3}\.){3,3}\d{1,3}$/,r=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:r,isFormat:d=>e.test(d),encode(d,o,s){s=~~s,o=o||new Uint8Array(s+r);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]}`}};t.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 L=0;L<d.length;L++){let P=d.charCodeAt(L);P===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):P===46?(s<a&&(o[s]=w),s++,w=0,y=0,A=!1,O=!0):(A=!1,P>=97?P-=87:P>=65?P-=55:(P-=48,w=w*10+P),y=(y<<4)+P)}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 L=Math.min(s-1,a-1);L>=l+2;L--)o[L]=o[L-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}/,"::")}};t.v6=u;let m="ip";t.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 t?t.default:t}({});typeof define=="function"&&define.amd?define([],function(){return xr}):typeof yt=="object"&&typeof vr=="object"&&(yt.exports=xr)});var Ur=j(x=>{"use strict";var v=Pe("buffer").Buffer,ge=mr(),Vn=yr(),qn=wr(),Je=Ir(),wt=Er(),Se=Ar(),jn=0,Sr=32768,It=32768,Kn=~It,br=32768,Hn=~br,I=x.name={};I.encode=function(t,e,r,{mail:n=!1}={}){e||(e=v.alloc(I.encodingLength(t))),r||(r=0);let i=r,c=t.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],r+1);e[r]=h,r+=h+1}}return e[r++]=0,I.encode.bytes=r-i,e};I.encode.bytes=0;I.decode=function(t,e,{mail:r=!1}={}){e||(e=0);let n=[],i=e,c=0,u=0,m=!1;for(;;){if(e>=t.length)throw new Error("Cannot decode name (buffer overflow)");let h=t[e++];if(u+=m?0:1,h===0)break;if(h&192)if((h&192)===192){if(e+1>t.length)throw new Error("Cannot decode name (buffer overflow)");let p=t.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>t.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=t.toString("utf-8",e,e+h);r&&(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(t){return t==="."||t===".."?1:v.byteLength(t.replace(/^\.|\.$/gm,""))+2};var S={};S.encode=function(t,e,r){e||(e=v.alloc(S.encodingLength(t))),r||(r=0);let n=e.write(t,r+1);return e[r]=n,S.encode.bytes=n+1,e};S.encode.bytes=0;S.decode=function(t,e){e||(e=0);let r=t[e],n=t.toString("utf-8",e+1,e+1+r);return S.decode.bytes=r+1,n};S.decode.bytes=0;S.encodingLength=function(t){return v.byteLength(t)+1};var X={};X.encode=function(t,e,r){e||(e=X.encodingLength(t)),r||(r=0);let n=(t.flags||0)&32767,i=t.type==="response"?Sr:jn;return e.writeUInt16BE(t.id||0,r),e.writeUInt16BE(n|i,r+2),e.writeUInt16BE(t.questions.length,r+4),e.writeUInt16BE(t.answers.length,r+6),e.writeUInt16BE(t.authorities.length,r+8),e.writeUInt16BE(t.additionals.length,r+10),e};X.encode.bytes=12;X.decode=function(t,e){if(e||(e=0),t.length<12)throw new Error("Header must be 12 bytes");let r=t.readUInt16BE(e+2);return{id:t.readUInt16BE(e),type:r&Sr?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:qn.toString(r>>11&15),flag_aa:(r>>10&1)===1,flag_tc:(r>>9&1)===1,flag_rd:(r>>8&1)===1,flag_ra:(r>>7&1)===1,flag_z:(r>>6&1)===1,flag_ad:(r>>5&1)===1,flag_cd:(r>>4&1)===1,rcode:Vn.toString(r&15),questions:new Array(t.readUInt16BE(e+4)),answers:new Array(t.readUInt16BE(e+6)),authorities:new Array(t.readUInt16BE(e+8)),additionals:new Array(t.readUInt16BE(e+10))}};X.decode.bytes=12;X.encodingLength=function(){return 12};var oe=x.unknown={};oe.encode=function(t,e,r){return e||(e=v.alloc(oe.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.length,r),t.copy(e,r+2),oe.encode.bytes=t.length+2,e};oe.encode.bytes=0;oe.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=t.slice(e+2,e+2+r);return oe.decode.bytes=r+2,n};oe.decode.bytes=0;oe.encodingLength=function(t){return t.length+2};var se=x.ns={};se.encode=function(t,e,r){return e||(e=v.alloc(se.encodingLength(t))),r||(r=0),I.encode(t,e,r+2),e.writeUInt16BE(I.encode.bytes,r),se.encode.bytes=I.encode.bytes+2,e};se.encode.bytes=0;se.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=I.decode(t,e+2);return se.decode.bytes=r+2,n};se.decode.bytes=0;se.encodingLength=function(t){return I.encodingLength(t)+2};var ce=x.soa={};ce.encode=function(t,e,r){e||(e=v.alloc(ce.encodingLength(t))),r||(r=0);let n=r;return r+=2,I.encode(t.mname,e,r),r+=I.encode.bytes,I.encode(t.rname,e,r,{mail:!0}),r+=I.encode.bytes,e.writeUInt32BE(t.serial||0,r),r+=4,e.writeUInt32BE(t.refresh||0,r),r+=4,e.writeUInt32BE(t.retry||0,r),r+=4,e.writeUInt32BE(t.expire||0,r),r+=4,e.writeUInt32BE(t.minimum||0,r),r+=4,e.writeUInt16BE(r-n-2,n),ce.encode.bytes=r-n,e};ce.encode.bytes=0;ce.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=I.decode(t,e),e+=I.decode.bytes,n.rname=I.decode(t,e,{mail:!0}),e+=I.decode.bytes,n.serial=t.readUInt32BE(e),e+=4,n.refresh=t.readUInt32BE(e),e+=4,n.retry=t.readUInt32BE(e),e+=4,n.expire=t.readUInt32BE(e),e+=4,n.minimum=t.readUInt32BE(e),e+=4,ce.decode.bytes=e-r,n};ce.decode.bytes=0;ce.encodingLength=function(t){return 22+I.encodingLength(t.mname)+I.encodingLength(t.rname)};var ae=x.txt={};ae.encode=function(t,e,r){Array.isArray(t)||(t=[t]);for(let i=0;i<t.length;i++)if(typeof t[i]=="string"&&(t[i]=v.from(t[i])),!v.isBuffer(t[i]))throw new Error("Must be a Buffer");e||(e=v.alloc(ae.encodingLength(t))),r||(r=0);let n=r;return r+=2,t.forEach(function(i){e[r++]=i.length,i.copy(e,r,0,i.length),r+=i.length}),e.writeUInt16BE(r-n-2,n),ae.encode.bytes=r-n,e};ae.encode.bytes=0;ae.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let i=[];for(;n>0;){let c=t[e++];if(--n,n<c)throw new Error("Buffer overflow");i.push(t.slice(e,e+c)),e+=c,n-=c}return ae.decode.bytes=e-r,i};ae.decode.bytes=0;ae.encodingLength=function(t){Array.isArray(t)||(t=[t]);let e=2;return t.forEach(function(r){typeof r=="string"?e+=v.byteLength(r)+1:e+=r.length+1}),e};var de=x.null={};de.encode=function(t,e,r){e||(e=v.alloc(de.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=v.from(t)),t||(t=v.alloc(0));let n=r;r+=2;let i=t.length;return t.copy(e,r,0,i),r+=i,e.writeUInt16BE(r-n-2,n),de.encode.bytes=r-n,e};de.encode.bytes=0;de.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let i=t.slice(e,e+n);return e+=n,de.decode.bytes=e-r,i};de.decode.bytes=0;de.encodingLength=function(t){return t?(v.isBuffer(t)?t.length:v.byteLength(t))+2:2};var le=x.hinfo={};le.encode=function(t,e,r){e||(e=v.alloc(le.encodingLength(t))),r||(r=0);let n=r;return r+=2,S.encode(t.cpu,e,r),r+=S.encode.bytes,S.encode(t.os,e,r),r+=S.encode.bytes,e.writeUInt16BE(r-n-2,n),le.encode.bytes=r-n,e};le.encode.bytes=0;le.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.cpu=S.decode(t,e),e+=S.decode.bytes,n.os=S.decode(t,e),e+=S.decode.bytes,le.decode.bytes=e-r,n};le.decode.bytes=0;le.encodingLength=function(t){return S.encodingLength(t.cpu)+S.encodingLength(t.os)+2};var K=x.ptr={},Xn=x.cname=K,Gn=x.dname=K;K.encode=function(t,e,r){return e||(e=v.alloc(K.encodingLength(t))),r||(r=0),I.encode(t,e,r+2),e.writeUInt16BE(I.encode.bytes,r),K.encode.bytes=I.encode.bytes+2,e};K.encode.bytes=0;K.decode=function(t,e){e||(e=0);let r=I.decode(t,e+2);return K.decode.bytes=I.decode.bytes+2,r};K.decode.bytes=0;K.encodingLength=function(t){return I.encodingLength(t)+2};var ue=x.srv={};ue.encode=function(t,e,r){e||(e=v.alloc(ue.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.priority||0,r+2),e.writeUInt16BE(t.weight||0,r+4),e.writeUInt16BE(t.port||0,r+6),I.encode(t.target,e,r+8);let n=I.encode.bytes+6;return e.writeUInt16BE(n,r),ue.encode.bytes=n+2,e};ue.encode.bytes=0;ue.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n={};return n.priority=t.readUInt16BE(e+2),n.weight=t.readUInt16BE(e+4),n.port=t.readUInt16BE(e+6),n.target=I.decode(t,e+8),ue.decode.bytes=r+2,n};ue.decode.bytes=0;ue.encodingLength=function(t){return 8+I.encodingLength(t.target)};var M=x.caa={};M.ISSUER_CRITICAL=128;M.encode=function(t,e,r){let n=M.encodingLength(t);return e||(e=v.alloc(M.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=M.ISSUER_CRITICAL),e.writeUInt16BE(n-2,r),r+=2,e.writeUInt8(t.flags||0,r),r+=1,S.encode(t.tag,e,r),r+=S.encode.bytes,e.write(t.value,r),r+=v.byteLength(t.value),M.encode.bytes=n,e};M.encode.bytes=0;M.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e);e+=2;let n=e,i={};return i.flags=t.readUInt8(e),e+=1,i.tag=S.decode(t,e),e+=S.decode.bytes,i.value=t.toString("utf-8",e,n+r),i.issuerCritical=!!(i.flags&M.ISSUER_CRITICAL),M.decode.bytes=r+2,i};M.decode.bytes=0;M.encodingLength=function(t){return S.encodingLength(t.tag)+S.encodingLength(t.value)+2};var we=x.mx={};we.encode=function(t,e,r){e||(e=v.alloc(we.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,I.encode(t.exchange,e,r),r+=I.encode.bytes,e.writeUInt16BE(r-n-2,n),we.encode.bytes=r-n,e};we.encode.bytes=0;we.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.preference=t.readUInt16BE(e),e+=2,n.exchange=I.decode(t,e),e+=I.decode.bytes,we.decode.bytes=e-r,n};we.encodingLength=function(t){return 4+I.encodingLength(t.exchange)};var he=x.a={};he.encode=function(t,e,r){return e||(e=v.alloc(he.encodingLength(t))),r||(r=0),e.writeUInt16BE(4,r),r+=2,Se.v4.encode(t,e,r),he.encode.bytes=6,e};he.encode.bytes=0;he.decode=function(t,e){e||(e=0),e+=2;let r=Se.v4.decode(t,e);return he.decode.bytes=6,r};he.decode.bytes=0;he.encodingLength=function(){return 6};var pe=x.aaaa={};pe.encode=function(t,e,r){return e||(e=v.alloc(pe.encodingLength(t))),r||(r=0),e.writeUInt16BE(16,r),r+=2,Se.v6.encode(t,e,r),pe.encode.bytes=18,e};pe.encode.bytes=0;pe.decode=function(t,e){e||(e=0),e+=2;let r=Se.v6.decode(t,e);return pe.decode.bytes=18,r};pe.decode.bytes=0;pe.encodingLength=function(){return 18};var f=x.option={};f.encode=function(t,e,r){e||(e=v.alloc(f.encodingLength(t))),r||(r=0);let n=r,i=wt.toCode(t.code);if(e.writeUInt16BE(i,r),r+=2,t.data)e.writeUInt16BE(t.data.length,r),r+=2,t.data.copy(e,r),r+=t.data.length;else switch(i){case 8:let c=t.sourcePrefixLength||0,u=t.family||Se.familyOf(t.ip),m=Se.encode(t.ip,v.alloc),h=Math.ceil(c/8);e.writeUInt16BE(h+4,r),r+=2,e.writeUInt16BE(u,r),r+=2,e.writeUInt8(c,r++),e.writeUInt8(t.scopePrefixLength||0,r++),m.copy(e,r,0,h),r+=h;break;case 11:t.timeout?(e.writeUInt16BE(2,r),r+=2,e.writeUInt16BE(t.timeout,r),r+=2):(e.writeUInt16BE(0,r),r+=2);break;case 12:let p=t.length||0;e.writeUInt16BE(p,r),r+=2,e.fill(0,r,r+p),r+=p;break;case 14:let E=t.tags.length*2;e.writeUInt16BE(E,r),r+=2;for(let g of t.tags)e.writeUInt16BE(g,r),r+=2;break;default:throw new Error(`Unknown roption code: ${t.code}`)}return f.encode.bytes=r-n,e};f.encode.bytes=0;f.decode=function(t,e){e||(e=0);let r={};r.code=t.readUInt16BE(e),r.type=wt.toString(r.code),e+=2;let n=t.readUInt16BE(e);switch(e+=2,r.data=t.slice(e,e+n),r.code){case 8:r.family=t.readUInt16BE(e),e+=2,r.sourcePrefixLength=t.readUInt8(e++),r.scopePrefixLength=t.readUInt8(e++);let i=v.alloc(r.family===1?4:16);t.copy(i,0,e,e+n-4),r.ip=Se.decode(i);break;case 11:n>0&&(r.timeout=t.readUInt16BE(e),e+=2);break;case 14:r.tags=[];for(let c=0;c<n;c+=2)r.tags.push(t.readUInt16BE(e)),e+=2}return f.decode.bytes=n+4,r};f.decode.bytes=0;f.encodingLength=function(t){if(t.data)return t.data.length+4;switch(wt.toCode(t.code)){case 8:let r=t.sourcePrefixLength||0;return Math.ceil(r/8)+8;case 11:return typeof t.timeout=="number"?6:4;case 12:return t.length+4;case 14:return 4+t.tags.length*2}throw new Error(`Unknown roption code: ${t.code}`)};var z=x.opt={};z.encode=function(t,e,r){e||(e=v.alloc(z.encodingLength(t))),r||(r=0);let n=r,i=Ce(t,f);return e.writeUInt16BE(i,r),r=$e(t,f,e,r+2),z.encode.bytes=r-n,e};z.encode.bytes=0;z.decode=function(t,e){e||(e=0);let r=e,n=[],i=t.readUInt16BE(e);e+=2;let c=0;for(;i>0;)n[c++]=f.decode(t,e),e+=f.decode.bytes,i-=f.decode.bytes;return z.decode.bytes=e-r,n};z.decode.bytes=0;z.encodingLength=function(t){return 2+Ce(t||[],f)};var F=x.dnskey={};F.PROTOCOL_DNSSEC=3;F.ZONE_KEY=128;F.SECURE_ENTRYPOINT=32768;F.encode=function(t,e,r){e||(e=v.alloc(F.encodingLength(t))),r||(r=0);let n=r,i=t.key;if(!v.isBuffer(i))throw new Error("Key must be a Buffer");return r+=2,e.writeUInt16BE(t.flags,r),r+=2,e.writeUInt8(F.PROTOCOL_DNSSEC,r),r+=1,e.writeUInt8(t.algorithm,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,F.encode.bytes=r-n,e.writeUInt16BE(F.encode.bytes-2,n),e};F.encode.bytes=0;F.decode=function(t,e){e||(e=0);let r=e;var n={},i=t.readUInt16BE(e);if(e+=2,n.flags=t.readUInt16BE(e),e+=2,t.readUInt8(e)!==F.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=t.readUInt8(e),e+=1,n.key=t.slice(e,r+i+2),e+=n.key.length,F.decode.bytes=e-r,n};F.decode.bytes=0;F.encodingLength=function(t){return 6+v.byteLength(t.key)};var Q=x.rrsig={};Q.encode=function(t,e,r){e||(e=v.alloc(Q.encodingLength(t))),r||(r=0);let n=r,i=t.signature;if(!v.isBuffer(i))throw new Error("Signature must be a Buffer");return r+=2,e.writeUInt16BE(ge.toType(t.typeCovered),r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.labels,r),r+=1,e.writeUInt32BE(t.originalTTL,r),r+=4,e.writeUInt32BE(t.expiration,r),r+=4,e.writeUInt32BE(t.inception,r),r+=4,e.writeUInt16BE(t.keyTag,r),r+=2,I.encode(t.signersName,e,r),r+=I.encode.bytes,i.copy(e,r,0,i.length),r+=i.length,Q.encode.bytes=r-n,e.writeUInt16BE(Q.encode.bytes-2,n),e};Q.encode.bytes=0;Q.decode=function(t,e){e||(e=0);let r=e;var n={},i=t.readUInt16BE(e);return e+=2,n.typeCovered=ge.toString(t.readUInt16BE(e)),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.labels=t.readUInt8(e),e+=1,n.originalTTL=t.readUInt32BE(e),e+=4,n.expiration=t.readUInt32BE(e),e+=4,n.inception=t.readUInt32BE(e),e+=4,n.keyTag=t.readUInt16BE(e),e+=2,n.signersName=I.decode(t,e),e+=I.decode.bytes,n.signature=t.slice(e,r+i+2),e+=n.signature.length,Q.decode.bytes=e-r,n};Q.decode.bytes=0;Q.encodingLength=function(t){return 20+I.encodingLength(t.signersName)+v.byteLength(t.signature)};var W=x.rp={};W.encode=function(t,e,r){e||(e=v.alloc(W.encodingLength(t))),r||(r=0);let n=r;return r+=2,I.encode(t.mbox||".",e,r,{mail:!0}),r+=I.encode.bytes,I.encode(t.txt||".",e,r),r+=I.encode.bytes,W.encode.bytes=r-n,e.writeUInt16BE(W.encode.bytes-2,n),e};W.encode.bytes=0;W.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mbox=I.decode(t,e,{mail:!0})||".",e+=I.decode.bytes,n.txt=I.decode(t,e)||".",e+=I.decode.bytes,W.decode.bytes=e-r,n};W.decode.bytes=0;W.encodingLength=function(t){return 2+I.encodingLength(t.mbox||".")+I.encodingLength(t.txt||".")};var R={};R.encode=function(t,e,r){e||(e=v.alloc(R.encodingLength(t))),r||(r=0);let n=r;for(var i=[],c=0;c<t.length;c++){var u=ge.toType(t[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,r),r+=1,e.writeUInt8(m.length,r),r+=1,m.copy(e,r),r+=m.length}return R.encode.bytes=r-n,e};R.encode.bytes=0;R.decode=function(t,e,r){e||(e=0);let n=e;for(var i=[];e-n<r;){var c=t.readUInt8(e);e+=1;var u=t.readUInt8(e);e+=1;for(var m=0;m<u;m++)for(var h=t.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 R.decode.bytes=e-n,i};R.decode.bytes=0;R.encodingLength=function(t){for(var e=[],r=0;r<t.length;r++){var n=ge.toType(t[r]);e[n>>8]=Math.max(e[n>>8]||0,n&255)}var i=0;for(r=0;r<e.length;r++)e[r]!==void 0&&(i+=2+Math.ceil((e[r]+1)/8));return i};var J=x.nsec={};J.encode=function(t,e,r){e||(e=v.alloc(J.encodingLength(t))),r||(r=0);let n=r;return r+=2,I.encode(t.nextDomain,e,r),r+=I.encode.bytes,R.encode(t.rrtypes,e,r),r+=R.encode.bytes,J.encode.bytes=r-n,e.writeUInt16BE(J.encode.bytes-2,n),e};J.encode.bytes=0;J.decode=function(t,e){e||(e=0);let r=e;var n={},i=t.readUInt16BE(e);return e+=2,n.nextDomain=I.decode(t,e),e+=I.decode.bytes,n.rrtypes=R.decode(t,e,i-(e-r)),e+=R.decode.bytes,J.decode.bytes=e-r,n};J.decode.bytes=0;J.encodingLength=function(t){return 2+I.encodingLength(t.nextDomain)+R.encodingLength(t.rrtypes)};var Z=x.nsec3={};Z.encode=function(t,e,r){e||(e=v.alloc(Z.encodingLength(t))),r||(r=0);let n=r,i=t.salt;if(!v.isBuffer(i))throw new Error("salt must be a Buffer");let c=t.nextDomain;if(!v.isBuffer(c))throw new Error("nextDomain must be a Buffer");return r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.flags,r),r+=1,e.writeUInt16BE(t.iterations,r),r+=2,e.writeUInt8(i.length,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,e.writeUInt8(c.length,r),r+=1,c.copy(e,r,0,c.length),r+=c.length,R.encode(t.rrtypes,e,r),r+=R.encode.bytes,Z.encode.bytes=r-n,e.writeUInt16BE(Z.encode.bytes-2,n),e};Z.encode.bytes=0;Z.decode=function(t,e){e||(e=0);let r=e;var n={},i=t.readUInt16BE(e);e+=2,n.algorithm=t.readUInt8(e),e+=1,n.flags=t.readUInt8(e),e+=1,n.iterations=t.readUInt16BE(e),e+=2;let c=t.readUInt8(e);e+=1,n.salt=t.slice(e,e+c),e+=c;let u=t.readUInt8(e);return e+=1,n.nextDomain=t.slice(e,e+u),e+=u,n.rrtypes=R.decode(t,e,i-(e-r)),e+=R.decode.bytes,Z.decode.bytes=e-r,n};Z.decode.bytes=0;Z.encodingLength=function(t){return 8+t.salt.length+t.nextDomain.length+R.encodingLength(t.rrtypes)};var ee=x.ds={};ee.encode=function(t,e,r){e||(e=v.alloc(ee.encodingLength(t))),r||(r=0);let n=r,i=t.digest;if(!v.isBuffer(i))throw new Error("Digest must be a Buffer");return r+=2,e.writeUInt16BE(t.keyTag,r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.digestType,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,ee.encode.bytes=r-n,e.writeUInt16BE(ee.encode.bytes-2,n),e};ee.encode.bytes=0;ee.decode=function(t,e){e||(e=0);let r=e;var n={},i=t.readUInt16BE(e);return e+=2,n.keyTag=t.readUInt16BE(e),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.digestType=t.readUInt8(e),e+=1,n.digest=t.slice(e,r+i+2),e+=n.digest.length,ee.decode.bytes=e-r,n};ee.decode.bytes=0;ee.encodingLength=function(t){return 6+v.byteLength(t.digest)};var _=x.sshfp={};_.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};_.encode=function(e,r,n){r||(r=v.alloc(_.encodingLength(e))),n||(n=0);let i=n;n+=2,r[n]=e.algorithm,n+=1,r[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(r,n),n+=c.byteLength,_.encode.bytes=n-i,r.writeUInt16BE(_.encode.bytes-2,i),r};_.encode.bytes=0;_.decode=function(e,r){r||(r=0);let n=r,i={};r+=2,i.algorithm=e[r],r+=1,i.hash=e[r],r+=1;let c=_.getFingerprintLengthForHashType(i.hash);return i.fingerprint=e.slice(r,r+c).toString("hex").toUpperCase(),r+=c,_.decode.bytes=r-n,i};_.decode.bytes=0;_.encodingLength=function(t){return 4+v.from(t.fingerprint,"hex").byteLength};var te=x.naptr={};te.encode=function(t,e,r){e||(e=v.alloc(te.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.order||0,r),r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,S.encode(t.flags,e,r),r+=S.encode.bytes,S.encode(t.services,e,r),r+=S.encode.bytes,S.encode(t.regexp,e,r),r+=S.encode.bytes,I.encode(t.replacement,e,r),r+=I.encode.bytes,te.encode.bytes=r-n,e.writeUInt16BE(te.encode.bytes-2,n),e};te.encode.bytes=0;te.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.order=t.readUInt16BE(e),e+=2,n.preference=t.readUInt16BE(e),e+=2,n.flags=S.decode(t,e),e+=S.decode.bytes,n.services=S.decode(t,e),e+=S.decode.bytes,n.regexp=S.decode(t,e),e+=S.decode.bytes,n.replacement=I.decode(t,e),e+=I.decode.bytes,te.decode.bytes=e-r,n};te.decode.bytes=0;te.encodingLength=function(t){return S.encodingLength(t.flags)+S.encodingLength(t.services)+S.encodingLength(t.regexp)+I.encodingLength(t.replacement)+6};var re=x.tlsa={};re.encode=function(t,e,r){e||(e=v.alloc(re.encodingLength(t))),r||(r=0);let n=r,i=t.certificate;if(!v.isBuffer(i))throw new Error("Certificate must be a Buffer");return r+=2,e.writeUInt8(t.usage,r),r+=1,e.writeUInt8(t.selector,r),r+=1,e.writeUInt8(t.matchingType,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,re.encode.bytes=r-n,e.writeUInt16BE(re.encode.bytes-2,n),e};re.encode.bytes=0;re.decode=function(t,e){e||(e=0);let r=e,n={},i=t.readUInt16BE(e);return e+=2,n.usage=t.readUInt8(e),e+=1,n.selector=t.readUInt8(e),e+=1,n.matchingType=t.readUInt8(e),e+=1,n.certificate=t.slice(e,r+i+2),e+=n.certificate.length,re.decode.bytes=e-r,n};re.decode.bytes=0;re.encodingLength=function(t){return 5+v.byteLength(t.certificate)};var Et=x.record=function(t){switch(t.toUpperCase()){case"A":return he;case"PTR":return K;case"CNAME":return Xn;case"DNAME":return Gn;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 te;case"TLSA":return re}return oe},B=x.answer={};B.encode=function(t,e,r){e||(e=v.alloc(B.encodingLength(t))),r||(r=0);let n=r;if(I.encode(t.name,e,r),r+=I.encode.bytes,e.writeUInt16BE(ge.toType(t.type),r),t.type.toUpperCase()==="OPT"){if(t.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(t.udpPayloadSize||4096,r+2),e.writeUInt8(t.extendedRcode||0,r+4),e.writeUInt8(t.ednsVersion||0,r+5),e.writeUInt16BE(t.flags||0,r+6),r+=8,z.encode(t.options||[],e,r),r+=z.encode.bytes}else{let i=Je.toClass(t.class===void 0?"IN":t.class);t.flush&&(i|=It),e.writeUInt16BE(i,r+2),e.writeUInt32BE(t.ttl||0,r+4),r+=8;let c=Et(t.type);c.encode(t.data,e,r),r+=c.encode.bytes}return B.encode.bytes=r-n,e};B.encode.bytes=0;B.decode=function(t,e){e||(e=0);let r={},n=e;if(r.name=I.decode(t,e),e+=I.decode.bytes,r.type=ge.toString(t.readUInt16BE(e)),r.type==="OPT")r.udpPayloadSize=t.readUInt16BE(e+2),r.extendedRcode=t.readUInt8(e+4),r.ednsVersion=t.readUInt8(e+5),r.flags=t.readUInt16BE(e+6),r.flag_do=(r.flags>>15&1)===1,r.options=z.decode(t,e+8),e+=8+z.decode.bytes;else{let i=t.readUInt16BE(e+2);r.ttl=t.readUInt32BE(e+4),r.class=Je.toString(i&Kn),r.flush=!!(i&It);let c=Et(r.type);r.data=c.decode(t,e+8),e+=8+c.decode.bytes}return B.decode.bytes=e-n,r};B.decode.bytes=0;B.encodingLength=function(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return I.encodingLength(t.name)+8+Et(t.type).encodingLength(e)};var H=x.question={};H.encode=function(t,e,r){e||(e=v.alloc(H.encodingLength(t))),r||(r=0);let n=r;return I.encode(t.name,e,r),r+=I.encode.bytes,e.writeUInt16BE(ge.toType(t.type),r),r+=2,e.writeUInt16BE(Je.toClass(t.class===void 0?"IN":t.class),r),r+=2,H.encode.bytes=r-n,t};H.encode.bytes=0;H.decode=function(t,e){e||(e=0);let r=e,n={};return n.name=I.decode(t,e),e+=I.decode.bytes,n.type=ge.toString(t.readUInt16BE(e)),e+=2,n.class=Je.toString(t.readUInt16BE(e)),e+=2,!!(n.class&br)&&(n.class&=Hn),H.decode.bytes=e-r,n};H.decode.bytes=0;H.encodingLength=function(t){return I.encodingLength(t.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(t,e,r){let n=!e;n&&(e=v.alloc(x.encodingLength(t))),r||(r=0);let i=r;return t.questions||(t.questions=[]),t.answers||(t.answers=[]),t.authorities||(t.authorities=[]),t.additionals||(t.additionals=[]),X.encode(t,e,r),r+=X.encode.bytes,r=$e(t.questions,H,e,r),r=$e(t.answers,B,e,r),r=$e(t.authorities,B,e,r),r=$e(t.additionals,B,e,r),x.encode.bytes=r-i,n&&x.encode.bytes!==e.length?e.slice(0,x.encode.bytes):e};x.encode.bytes=0;x.decode=function(t,e){e||(e=0);let r=e,n=X.decode(t,e);return e+=X.decode.bytes,e=We(n.questions,H,t,e),e=We(n.answers,B,t,e),e=We(n.authorities,B,t,e),e=We(n.additionals,B,t,e),x.decode.bytes=e-r,n};x.decode.bytes=0;x.encodingLength=function(t){return X.encodingLength(t)+Ce(t.questions||[],H)+Ce(t.answers||[],B)+Ce(t.authorities||[],B)+Ce(t.additionals||[],B)};x.streamEncode=function(t){let e=x.encode(t),r=v.alloc(2);r.writeUInt16BE(e.byteLength);let n=v.concat([r,e]);return x.streamEncode.bytes=n.byteLength,n};x.streamEncode.bytes=0;x.streamDecode=function(t){let e=t.readUInt16BE(0);if(t.byteLength<e+2)return null;let r=x.decode(t.slice(2));return x.streamDecode.bytes=x.decode.bytes,r};x.streamDecode.bytes=0;function Ce(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function $e(t,e,r,n){for(let i=0;i<t.length;i++)e.encode(t[i],r,n),n+=e.encode.bytes;return n}function We(t,e,r,n){for(let i=0;i<t.length;i++)t[i]=e.decode(r,n),n+=e.decode.bytes;return n}});var Cr=j((Gs,Pr)=>{"use strict";var Lr=ei;process.nextTick(Zn,42);Pr.exports=Yn;function Yn(t){var e=n;return r;function r(i){e(i||Wn)}function n(i){var c=[i];e=u,t(m);function u(h){c.push(h)}function m(h){var p=arguments;for(e=Qn(h)?n:E;c.length;)E(c.shift());function E(g){Lr(Jn,g,p)}}}}function Qn(t){return Object.prototype.toString.call(t)==="[object Error]"}function Wn(){}function Jn(t,e){t.apply(null,e)}function Zn(t){t===42&&(Lr=process.nextTick)}function ei(t,e,r){process.nextTick(function(){t(e,r)})}});var Rr=j((Ys,Tr)=>{var xt=Ur(),ti=Pe("dgram"),ri=Cr(),ni=Pe("events"),At=Pe("os"),vt=function(){};Tr.exports=function(t){t||(t={});var e=new ni.EventEmitter,r=typeof t.port=="number"?t.port:5353,n=t.type||"udp4",i=t.ip||t.host||(n==="udp4"?"224.0.0.251":null),c={address:i,port:r},u={},m=!1,h=null;if(n==="udp6"&&(!i||!t.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var p=t.socket||ti.createSocket({type:n,reuseAddr:t.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=xt.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(){r||(r=c.port=p.address().port),t.multicast!==!1&&(e.update(),h=setInterval(e.update,5e3),p.setMulticastTTL(t.ttl||255),p.setMulticastLoopback(t.loopback!==!1))});var E=ri(function(g){if(!r||t.bind===!1)return g(null);p.once("error",g),p.bind(r,t.bind||t.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=vt),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=xt.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)|xt.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=vt),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=vt),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=t.interface?[].concat(t.interface):oi(),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(t.interface||ii())}catch(a){e.emit("warning",a)}e.emit("networkInterface")}},e};function ii(){for(var t=At.networkInterfaces(),e=Object.keys(t),r=0;r<e.length;r++)for(var n=t[e[r]],i=0;i<n.length;i++){var c=n[i];if(Or(c.family)&&!c.internal)return At.platform()==="darwin"&&e[r]==="en0"?c.address:"0.0.0.0"}return"127.0.0.1"}function oi(){for(var t=At.networkInterfaces(),e=Object.keys(t),r=[],n=0;n<e.length;n++)for(var i=t[e[n]],c=0;c<i.length;c++){var u=i[c];if(Or(u.family)){r.push(u.address);break}}return r}function Or(t){return t===4||t==="IPv4"}});var Zr=j(He=>{(function(){var t,e,r,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")}},r=function(h){return h.charCodeAt(0)},n=r("0"),c=r("a"),i=r("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+(r(h[g])-n)>>>0;else if(p===16)if("a"<=h[g]&&h[g]<="f")d=d*p+(10+r(h[g])-c)>>>0;else if("A"<=h[g]&&h[g]<="F")d=d*p+(10+r(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]},t=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}(),He.ip2long=u,He.long2ip=m,He.Netmask=t}).call(He)});var nn=j((rn,nt)=>{(function(t){"use strict";let e="(0?\\d+|0x[a-f0-9]+)",r={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(":"),L=[];for(let P=0;P<O.length;P++)L.push(parseInt(O[P],16));return L}(),{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(r.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(r.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(r.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(r.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 nt<"u"&&nt.exports?nt.exports=d:t.ipaddr=d})(rn)});var es={};$(es,{mdns:()=>Zo});var rs=Symbol.for("@libp2p/connection");var is=Symbol.for("@libp2p/content-routing");var ur=Symbol.for("@libp2p/peer-discovery");var hr=Symbol.for("@libp2p/peer-id");var ds=Symbol.for("@libp2p/peer-routing");var pr;(function(t){t.Accept="accept",t.Ignore="ignore",t.Reject="reject"})(pr||(pr={}));var ps=Symbol.for("@libp2p/transport");var gr;(function(t){t[t.FATAL_ALL=0]="FATAL_ALL",t[t.NO_FATAL=1]="NO_FATAL"})(gr||(gr={}));var ke=class extends Error{code;props;constructor(e,r,n){super(e),this.code=r,this.name=n?.name??"CodeError",this.props=n??{}}};var Qe=class extends EventTarget{#e=new Map;listenerCount(e){let r=this.#e.get(e);return r==null?0:r.length}addEventListener(e,r,n){super.addEventListener(e,r,n);let i=this.#e.get(e);i==null&&(i=[],this.#e.set(e,i)),i.push({callback:r,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,r,n){super.removeEventListener(e.toString(),r??null,n);let i=this.#e.get(e);i!=null&&(i=i.filter(({callback:c})=>c!==r),this.#e.set(e,i))}dispatchEvent(e){let r=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:i})=>!i),this.#e.set(e.type,n)),r}safeDispatchEvent(e,r){return this.dispatchEvent(new lt(e,r))}},dt=class extends Event{detail;constructor(e,r){super(e,r),this.detail=r?.detail}},lt=globalThis.CustomEvent??dt;var Fn=Ye(Rr(),1);var Pt={};$(Pt,{base58btc:()=>D,base58flickr:()=>ui});function si(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var c=t.charAt(i),u=c.charCodeAt(0);if(r[u]!==255)throw new TypeError(c+" is ambiguous");r[u]=i}var m=t.length,h=t.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 L=s[y],P=0,q=A-1;(L!==0||P<l)&&q!==-1;q--,P++)L+=256*O[q]>>>0,O[q]=L%m>>>0,L=L/m>>>0;if(L!==0)throw new Error("Non-zero carry");l=P,y++}for(var ie=A-l;ie!==A&&O[ie]===0;)ie++;for(var Xe=h.repeat(a);ie<A;++ie)Xe+=t.charAt(O[ie]);return Xe}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=r[s.charCodeAt(a)];if(O===255)return;for(var L=0,P=w-1;(O!==0||L<y)&&P!==-1;P--,L++)O+=m*A[P]>>>0,A[P]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");y=L,a++}if(s[a]!==" "){for(var q=w-y;q!==w&&A[q]===0;)q++;for(var ie=new Uint8Array(l+(w-q)),Xe=l;q!==w;)ie[Xe++]=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 ci=si,ai=ci,Br=ai;var Ws=new Uint8Array(0);var Dr=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},V=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var Nr=t=>new TextEncoder().encode(t),Fr=t=>new TextDecoder().decode(t);var St=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},bt=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.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 kr(this,e)}},Ut=class{constructor(e){this.decoders=e}or(e){return kr(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},kr=(t,e)=>new Ut({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),Lt=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new St(e,r,n),this.decoder=new bt(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Oe=({name:t,prefix:e,encode:r,decode:n})=>new Lt(t,e,r,n),Ie=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:i}=Br(r,e);return Oe({prefix:t,name:e,encode:n,decode:c=>V(i(c))})},di=(t,e,r,n)=>{let i={};for(let E=0;E<e.length;++E)i[e[E]]=E;let c=t.length;for(;t[c-1]==="=";)--c;let u=new Uint8Array(c*r/8|0),m=0,h=0,p=0;for(let E=0;E<c;++E){let g=i[t[E]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<r|g,m+=r,m>=8&&(m-=8,u[p++]=255&h>>m)}if(m>=r||255&h<<8-m)throw new SyntaxError("Unexpected end of data");return u},li=(t,e,r)=>{let n=e[e.length-1]==="=",i=(1<<r)-1,c="",u=0,m=0;for(let h=0;h<t.length;++h)for(m=m<<8|t[h],u+=8;u>r;)u-=r,c+=e[i&m>>u];if(u&&(c+=e[i&m<<r-u]),n)for(;c.length*r&7;)c+="=";return c},C=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Oe({prefix:e,name:t,encode(i){return li(i,n,r)},decode(i){return di(i,n,r,t)}});var D=Ie({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ui=Ie({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ct={};$(Ct,{base10:()=>hi});var hi=Ie({prefix:"9",name:"base10",alphabet:"0123456789"});var Ot={};$(Ot,{base16:()=>pi,base16upper:()=>gi});var pi=C({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),gi=C({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Tt={};$(Tt,{base2:()=>mi});var mi=C({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Rt={};$(Rt,{base256emoji:()=>xi});var $r=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}"),yi=$r.reduce((t,e,r)=>(t[r]=e,t),[]),wi=$r.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Ii(t){return t.reduce((e,r)=>(e+=yi[r],e),"")}function Ei(t){let e=[];for(let r of t){let n=wi[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var xi=Oe({prefix:"\u{1F680}",name:"base256emoji",encode:Ii,decode:Ei});var Bt={};$(Bt,{base32:()=>me,base32hex:()=>bi,base32hexpad:()=>Li,base32hexpadupper:()=>Pi,base32hexupper:()=>Ui,base32pad:()=>Ai,base32padupper:()=>Si,base32upper:()=>vi,base32z:()=>Ci});var me=C({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),vi=C({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ai=C({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Si=C({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bi=C({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ui=C({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Li=C({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Pi=C({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ci=C({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Dt={};$(Dt,{base36:()=>Oi,base36upper:()=>Ti});var Oi=Ie({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ti=Ie({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Nt={};$(Nt,{base64:()=>Ri,base64pad:()=>Bi,base64url:()=>Di,base64urlpad:()=>Ni});var Ri=C({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Bi=C({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Di=C({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ni=C({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ft={};$(Ft,{base8:()=>Fi});var Fi=C({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ft={};$(ft,{identity:()=>fi});var fi=Oe({prefix:"\0",name:"identity",encode:t=>Fr(t),decode:t=>Nr(t)});var hc=new TextEncoder,pc=new TextDecoder;var $t={};$($t,{identity:()=>et});var Mi=zr,Mr=128,_i=127,zi=~_i,Vi=Math.pow(2,31);function zr(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Vi;)e[r++]=t&255|Mr,t/=128;for(;t&zi;)e[r++]=t&255|Mr,t>>>=7;return e[r]=t|0,zr.bytes=r-n+1,e}var qi=kt,ji=128,_r=127;function kt(t,n){var r=0,n=n||0,i=0,c=n,u,m=t.length;do{if(c>=m)throw kt.bytes=0,new RangeError("Could not decode varint");u=t[c++],r+=i<28?(u&_r)<<i:(u&_r)*Math.pow(2,i),i+=7}while(u>=ji);return kt.bytes=c-n,r}var Ki=Math.pow(2,7),Hi=Math.pow(2,14),Xi=Math.pow(2,21),Gi=Math.pow(2,28),Yi=Math.pow(2,35),Qi=Math.pow(2,42),Wi=Math.pow(2,49),Ji=Math.pow(2,56),Zi=Math.pow(2,63),eo=function(t){return t<Ki?1:t<Hi?2:t<Xi?3:t<Gi?4:t<Yi?5:t<Qi?6:t<Wi?7:t<Ji?8:t<Zi?9:10},to={encode:Mi,decode:qi,encodingLength:eo},ro=to,Me=ro;var _e=(t,e=0)=>[Me.decode(t,e),Me.decode.bytes],Te=(t,e,r=0)=>(Me.encode(t,e,r),e),Re=t=>Me.encodingLength(t);var Ee=(t,e)=>{let r=e.byteLength,n=Re(t),i=n+Re(r),c=new Uint8Array(i+r);return Te(t,c,0),Te(r,c,n),c.set(e,i),new Be(t,r,e,c)},be=t=>{let e=V(t),[r,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 Be(r,i,u,e)},Vr=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Dr(t.bytes,r.bytes)}},Be=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};var qr=0,no="identity",jr=V,io=t=>Ee(qr,jr(t)),et={code:qr,name:no,encode:jr,digest:io};var Vt={};$(Vt,{sha256:()=>tt,sha512:()=>oo});var zt=Ye(Pe("crypto"),1);var _t=({name:t,code:e,encode:r})=>new Mt(t,e,r),Mt=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?Ee(this.code,r):r.then(n=>Ee(this.code,n))}else throw Error("Unknown type, must be binary type")}};var tt=_t({name:"sha2-256",code:18,encode:t=>V(zt.default.createHash("sha256").update(t).digest())}),oo=_t({name:"sha2-512",code:19,encode:t=>V(zt.default.createHash("sha512").update(t).digest())});var Hr=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return co(r,qt(t),e||D.encoder);default:return ao(r,qt(t),e||me.encoder)}};var Xr=new WeakMap,qt=t=>{let e=Xr.get(t);if(e==null){let r=new Map;return Xr.set(t,r),r}return e},G=class t{constructor(e,r,n,i){this.code=r,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:r}=this;if(e!==ze)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==lo)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}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:r}=this.multihash,n=Ee(e,r);return t.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 t.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&Vr(e.multihash,n.multihash)}toString(e){return Hr(this,e)}toJSON(){return{"/":Hr(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:i,multihash:c,bytes:u}=r;return new t(n,i,c,u||Gr(n,i,c.bytes))}else if(r[uo]===!0){let{version:n,multihash:i,code:c}=r,u=be(i);return t.create(n,c,u)}else return null}static create(e,r,n){if(typeof r!="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(r!==ze)throw new Error(`Version 0 CID must use dag-pb (code: ${ze}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=Gr(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,ze,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,i=V(e.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let c=i.subarray(r.multihashSize-r.digestSize),u=new Be(r.multihashCode,r.digestSize,c,i);return[r.version===0?t.createV0(u):t.createV1(r.codec,u),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[g,d]=_e(e.subarray(r));return r+=d,g},i=n(),c=ze;if(i===18?(i=0,r=0):c=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let u=r,m=n(),h=n(),p=r+h,E=p-u;return{version:i,codec:c,multihashCode:m,digestSize:h,multihashSize:E,size:p}}static parse(e,r){let[n,i]=so(e,r),c=t.decode(i);if(c.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return qt(c).set(n,e),c}},so=(t,e)=>{switch(t[0]){case"Q":{let r=e||D;return[D.prefix,r.decode(`${D.prefix}${t}`)]}case D.prefix:{let r=e||D;return[D.prefix,r.decode(t)]}case me.prefix:{let r=e||me;return[me.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},co=(t,e,r)=>{let{prefix:n}=r;if(n!==D.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=e.get(n);if(i==null){let c=r.encode(t).slice(1);return e.set(n,c),c}else return i},ao=(t,e,r)=>{let{prefix:n}=r,i=e.get(n);if(i==null){let c=r.encode(t);return e.set(n,c),c}else return i},ze=112,lo=18,Gr=(t,e,r)=>{let n=Re(t),i=n+Re(e),c=new Uint8Array(i+r.byteLength);return Te(t,c,0),Te(e,c,n),c.set(r,i),c},uo=Symbol.for("@ipld/js-cid/CID");var xe={...ft,...Tt,...Ft,...Ct,...Ot,...Bt,...Dt,...Pt,...Nt,...Rt},Tc={...Vt,...$t};function jt(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var ho=Symbol.for("nodejs.util.inspect.custom"),Yr=Object.values(xe).map(t=>t.decoder).reduce((t,e)=>t.or(e),xe.identity.decoder),Qr=114,Wr=36,Jr=37,Ve=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()})`}[hr]=!0;toString(){return this.string==null&&(this.string=D.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return G.createV1(Qr,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return jt(this.multihash.bytes,e);if(typeof e=="string")return Kt(e).equals(this);if(e?.multihash?.bytes!=null)return jt(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[ho](){return`PeerId(${this.toString()})`}},qe=class extends Ve{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},je=class extends Ve{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Ke=class extends Ve{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function Kt(t,e){if(e=e??Yr,t.charAt(0)==="1"||t.charAt(0)==="Q"){let r=be(D.decode(`z${t}`));return t.startsWith("12D")?new je({multihash:r}):t.startsWith("16U")?new Ke({multihash:r}):new qe({multihash:r})}return po(Yr.decode(t))}function po(t){try{let e=be(t);if(e.code===et.code){if(e.digest.length===Wr)return new je({multihash:e});if(e.digest.length===Jr)return new Ke({multihash:e})}if(e.code===tt.code)return new qe({multihash:e})}catch{return go(G.decode(t))}throw new Error("Supplied PeerID CID is invalid")}function go(t){if(t==null||t.multihash==null||t.version==null||t.version===1&&t.code!==Qr)throw new Error("Supplied PeerID CID is invalid");let e=t.multihash;if(e.code===tt.code)return new qe({multihash:t.multihash});if(e.code===et.code){if(e.digest.length===Wr)return new je({multihash:t.multihash});if(e.digest.length===Jr)return new Ke({multihash:t.multihash})}throw new Error("Supplied PeerID CID is invalid")}var sn=Ye(Zr(),1);var en="[a-fA-F\\d:]",ve=t=>t&&t.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}",T="[a-fA-F\\d]{1,4}",rt=`
|
|
2
|
+
"use strict";var Libp2PMdns=(()=>{var $i=Object.create;var At=Object.defineProperty;var zi=Object.getOwnPropertyDescriptor;var _i=Object.getOwnPropertyNames;var Vi=Object.getPrototypeOf,qi=Object.prototype.hasOwnProperty;var Ie=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var J=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),C=(t,e)=>{for(var r in e)At(t,r,{get:e[r],enumerable:!0})},Nn=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of _i(e))!qi.call(t,o)&&o!==r&&At(t,o,{get:()=>e[o],enumerable:!(n=zi(e,o))||n.enumerable});return t};var Me=(t,e,r)=>(r=t!=null?$i(Vi(t)):{},Nn(e||!t||!t.__esModule?At(r,"default",{value:t,enumerable:!0}):r,t)),ji=t=>Nn(At({},"__esModule",{value:!0}),t);var kn=J(qt=>{"use strict";qt.toString=function(t){switch(t){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_"+t};qt.toType=function(t){switch(t.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 t.toUpperCase().startsWith("UNKNOWN_")?parseInt(t.slice(8)):0}});var $n=J(jt=>{"use strict";jt.toString=function(t){switch(t){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_"+t};jt.toRcode=function(t){switch(t.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 zn=J(Kt=>{"use strict";Kt.toString=function(t){switch(t){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_"+t};Kt.toOpcode=function(t){switch(t.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 _n=J(Xt=>{"use strict";Xt.toString=function(t){switch(t){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+t};Xt.toClass=function(t){switch(t.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}});var Vn=J(Ht=>{"use strict";Ht.toString=function(t){switch(t){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 t<0?null:`OPTION_${t}`};Ht.toCode=function(t){if(typeof t=="number")return t;if(!t)return-1;switch(t.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=t.match(/_(\d+)$/);return e?parseInt(e[1],10):-1}});var Kn=J((jn,Gt)=>{var qn=function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=w,t.encode=x,t.familyOf=m,t.name=void 0,t.sizeOf=p,t.v6=t.v4=void 0;let e=/^(\d{1,3}\.){3,3}\d{1,3}$/,r=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,o=16,i={name:"v4",size:r,isFormat:l=>e.test(l),encode(l,c,s){s=~~s,c=c||new Uint8Array(s+r);let d=l.length,h=0;for(let g=0;g<d;){let y=l.charCodeAt(g++);y===46?(c[s++]=h,h=0):h=h*10+(y-48)}return c[s]=h,c},decode(l,c){return c=~~c,`${l[c++]}.${l[c++]}.${l[c++]}.${l[c]}`}};t.v4=i;let a={name:"v6",size:o,isFormat:l=>l.length>0&&n.test(l),encode(l,c,s){s=~~s;let d=s+o,h=-1,g=0,y=0,b=!0,I=!1;c=c||new Uint8Array(s+o);for(let A=0;A<l.length;A++){let S=l.charCodeAt(A);S===58?(b?h!==-1?(s<d&&(c[s]=0),s<d-1&&(c[s+1]=0),s+=2):s<d&&(h=s):(I===!0?(s<d&&(c[s]=y),s++):(s<d&&(c[s]=g>>8),s<d-1&&(c[s+1]=g&255),s+=2),g=0,y=0),b=!0,I=!1):S===46?(s<d&&(c[s]=y),s++,y=0,g=0,b=!1,I=!0):(b=!1,S>=97?S-=87:S>=65?S-=55:(S-=48,y=y*10+S),g=(g<<4)+S)}if(b===!1)I===!0?(s<d&&(c[s]=y),s++):(s<d&&(c[s]=g>>8),s<d-1&&(c[s+1]=g&255),s+=2);else if(h===0)s<d&&(c[s]=0),s<d-1&&(c[s+1]=0),s+=2;else if(h!==-1){s+=2;for(let A=Math.min(s-1,d-1);A>=h+2;A--)c[A]=c[A-2];c[h]=0,c[h+1]=0,h=s}if(h!==s&&h!==-1)for(s>d-2&&(s=d-2);d>h;)c[--d]=s<d&&s>h?c[--s]:0;else for(;s<d;)c[s++]=0;return c},decode(l,c){c=~~c;let s="";for(let d=0;d<o;d+=2)d!==0&&(s+=":"),s+=(l[c+d]<<8|l[c+d+1]).toString(16);return s.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};t.v6=a;let u="ip";t.name=u;function p(l){if(i.isFormat(l))return i.size;if(a.isFormat(l))return a.size;throw Error(`Invalid ip address: ${l}`)}function m(l){return p(l)===i.size?1:2}function x(l,c,s){s=~~s;let d=p(l);return typeof c=="function"&&(c=c(s+d)),d===i.size?i.encode(l,c,s):a.encode(l,c,s)}function w(l,c,s){if(c=~~c,s=s||l.length-c,s===i.size)return i.decode(l,c,s);if(s===a.size)return a.decode(l,c,s);throw Error(`Invalid buffer size needs to be ${i.size} for v4 or ${a.size} for v6.`)}return"default"in t?t.default:t}({});typeof define=="function"&&define.amd?define([],function(){return qn}):typeof Gt=="object"&&typeof jn=="object"&&(Gt.exports=qn)});var Gn=J(v=>{"use strict";var E=Ie("buffer").Buffer,be=kn(),Ki=$n(),Xi=zn(),Ct=_n(),Yt=Vn(),Te=Kn(),Hi=0,Xn=32768,Qt=32768,Gi=~Qt,Hn=32768,Yi=~Hn,f=v.name={};f.encode=function(t,e,r,{mail:n=!1}={}){e||(e=E.alloc(f.encodingLength(t))),r||(r=0);let o=r,i=t.replace(/^\.|\.$/gm,"");if(i.length){let a=[];if(n){let u="";i.split(".").forEach(p=>{p.endsWith("\\")?u+=(u.length?".":"")+p.slice(0,-1):a.length===0&&u.length?a.push(u+"."+p):a.push(p)})}else a=i.split(".");for(let u=0;u<a.length;u++){let p=e.write(a[u],r+1);e[r]=p,r+=p+1}}return e[r++]=0,f.encode.bytes=r-o,e};f.encode.bytes=0;f.decode=function(t,e,{mail:r=!1}={}){e||(e=0);let n=[],o=e,i=0,a=0,u=!1;for(;;){if(e>=t.length)throw new Error("Cannot decode name (buffer overflow)");let p=t[e++];if(a+=u?0:1,p===0)break;if(p&192)if((p&192)===192){if(e+1>t.length)throw new Error("Cannot decode name (buffer overflow)");let m=t.readUInt16BE(e-1)-49152;if(m>=o)throw new Error("Cannot decode name (bad pointer)");e=m,o=m,a+=u?0:1,u=!0}else throw new Error("Cannot decode name (bad label)");else{if(e+p>t.length)throw new Error("Cannot decode name (buffer overflow)");if(i+=p+1,i>254)throw new Error("Cannot decode name (name too long)");let m=t.toString("utf-8",e,e+p);r&&(m=m.replace(/\./g,"\\.")),n.push(m),e+=p,a+=u?0:p}}return f.decode.bytes=a,n.length===0?".":n.join(".")};f.decode.bytes=0;f.encodingLength=function(t){return t==="."||t===".."?1:E.byteLength(t.replace(/^\.|\.$/gm,""))+2};var U={};U.encode=function(t,e,r){e||(e=E.alloc(U.encodingLength(t))),r||(r=0);let n=e.write(t,r+1);return e[r]=n,U.encode.bytes=n+1,e};U.encode.bytes=0;U.decode=function(t,e){e||(e=0);let r=t[e],n=t.toString("utf-8",e+1,e+1+r);return U.decode.bytes=r+1,n};U.decode.bytes=0;U.encodingLength=function(t){return E.byteLength(t)+1};var ee={};ee.encode=function(t,e,r){e||(e=ee.encodingLength(t)),r||(r=0);let n=(t.flags||0)&32767,o=t.type==="response"?Xn:Hi;return e.writeUInt16BE(t.id||0,r),e.writeUInt16BE(n|o,r+2),e.writeUInt16BE(t.questions.length,r+4),e.writeUInt16BE(t.answers.length,r+6),e.writeUInt16BE(t.authorities.length,r+8),e.writeUInt16BE(t.additionals.length,r+10),e};ee.encode.bytes=12;ee.decode=function(t,e){if(e||(e=0),t.length<12)throw new Error("Header must be 12 bytes");let r=t.readUInt16BE(e+2);return{id:t.readUInt16BE(e),type:r&Xn?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:Xi.toString(r>>11&15),flag_aa:(r>>10&1)===1,flag_tc:(r>>9&1)===1,flag_rd:(r>>8&1)===1,flag_ra:(r>>7&1)===1,flag_z:(r>>6&1)===1,flag_ad:(r>>5&1)===1,flag_cd:(r>>4&1)===1,rcode:Ki.toString(r&15),questions:new Array(t.readUInt16BE(e+4)),answers:new Array(t.readUInt16BE(e+6)),authorities:new Array(t.readUInt16BE(e+8)),additionals:new Array(t.readUInt16BE(e+10))}};ee.decode.bytes=12;ee.encodingLength=function(){return 12};var he=v.unknown={};he.encode=function(t,e,r){return e||(e=E.alloc(he.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.length,r),t.copy(e,r+2),he.encode.bytes=t.length+2,e};he.encode.bytes=0;he.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=t.slice(e+2,e+2+r);return he.decode.bytes=r+2,n};he.decode.bytes=0;he.encodingLength=function(t){return t.length+2};var ue=v.ns={};ue.encode=function(t,e,r){return e||(e=E.alloc(ue.encodingLength(t))),r||(r=0),f.encode(t,e,r+2),e.writeUInt16BE(f.encode.bytes,r),ue.encode.bytes=f.encode.bytes+2,e};ue.encode.bytes=0;ue.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=f.decode(t,e+2);return ue.decode.bytes=r+2,n};ue.decode.bytes=0;ue.encodingLength=function(t){return f.encodingLength(t)+2};var pe=v.soa={};pe.encode=function(t,e,r){e||(e=E.alloc(pe.encodingLength(t))),r||(r=0);let n=r;return r+=2,f.encode(t.mname,e,r),r+=f.encode.bytes,f.encode(t.rname,e,r,{mail:!0}),r+=f.encode.bytes,e.writeUInt32BE(t.serial||0,r),r+=4,e.writeUInt32BE(t.refresh||0,r),r+=4,e.writeUInt32BE(t.retry||0,r),r+=4,e.writeUInt32BE(t.expire||0,r),r+=4,e.writeUInt32BE(t.minimum||0,r),r+=4,e.writeUInt16BE(r-n-2,n),pe.encode.bytes=r-n,e};pe.encode.bytes=0;pe.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=f.decode(t,e),e+=f.decode.bytes,n.rname=f.decode(t,e,{mail:!0}),e+=f.decode.bytes,n.serial=t.readUInt32BE(e),e+=4,n.refresh=t.readUInt32BE(e),e+=4,n.retry=t.readUInt32BE(e),e+=4,n.expire=t.readUInt32BE(e),e+=4,n.minimum=t.readUInt32BE(e),e+=4,pe.decode.bytes=e-r,n};pe.decode.bytes=0;pe.encodingLength=function(t){return 22+f.encodingLength(t.mname)+f.encodingLength(t.rname)};var me=v.txt={};me.encode=function(t,e,r){Array.isArray(t)||(t=[t]);for(let o=0;o<t.length;o++)if(typeof t[o]=="string"&&(t[o]=E.from(t[o])),!E.isBuffer(t[o]))throw new Error("Must be a Buffer");e||(e=E.alloc(me.encodingLength(t))),r||(r=0);let n=r;return r+=2,t.forEach(function(o){e[r++]=o.length,o.copy(e,r,0,o.length),r+=o.length}),e.writeUInt16BE(r-n-2,n),me.encode.bytes=r-n,e};me.encode.bytes=0;me.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let o=[];for(;n>0;){let i=t[e++];if(--n,n<i)throw new Error("Buffer overflow");o.push(t.slice(e,e+i)),e+=i,n-=i}return me.decode.bytes=e-r,o};me.decode.bytes=0;me.encodingLength=function(t){Array.isArray(t)||(t=[t]);let e=2;return t.forEach(function(r){typeof r=="string"?e+=E.byteLength(r)+1:e+=r.length+1}),e};var ge=v.null={};ge.encode=function(t,e,r){e||(e=E.alloc(ge.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=E.from(t)),t||(t=E.alloc(0));let n=r;r+=2;let o=t.length;return t.copy(e,r,0,o),r+=o,e.writeUInt16BE(r-n-2,n),ge.encode.bytes=r-n,e};ge.encode.bytes=0;ge.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let o=t.slice(e,e+n);return e+=n,ge.decode.bytes=e-r,o};ge.decode.bytes=0;ge.encodingLength=function(t){return t?(E.isBuffer(t)?t.length:E.byteLength(t))+2:2};var we=v.hinfo={};we.encode=function(t,e,r){e||(e=E.alloc(we.encodingLength(t))),r||(r=0);let n=r;return r+=2,U.encode(t.cpu,e,r),r+=U.encode.bytes,U.encode(t.os,e,r),r+=U.encode.bytes,e.writeUInt16BE(r-n-2,n),we.encode.bytes=r-n,e};we.encode.bytes=0;we.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.cpu=U.decode(t,e),e+=U.decode.bytes,n.os=U.decode(t,e),e+=U.decode.bytes,we.decode.bytes=e-r,n};we.decode.bytes=0;we.encodingLength=function(t){return U.encodingLength(t.cpu)+U.encodingLength(t.os)+2};var W=v.ptr={},Qi=v.cname=W,Ji=v.dname=W;W.encode=function(t,e,r){return e||(e=E.alloc(W.encodingLength(t))),r||(r=0),f.encode(t,e,r+2),e.writeUInt16BE(f.encode.bytes,r),W.encode.bytes=f.encode.bytes+2,e};W.encode.bytes=0;W.decode=function(t,e){e||(e=0);let r=f.decode(t,e+2);return W.decode.bytes=f.decode.bytes+2,r};W.decode.bytes=0;W.encodingLength=function(t){return f.encodingLength(t)+2};var ye=v.srv={};ye.encode=function(t,e,r){e||(e=E.alloc(ye.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.priority||0,r+2),e.writeUInt16BE(t.weight||0,r+4),e.writeUInt16BE(t.port||0,r+6),f.encode(t.target,e,r+8);let n=f.encode.bytes+6;return e.writeUInt16BE(n,r),ye.encode.bytes=n+2,e};ye.encode.bytes=0;ye.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n={};return n.priority=t.readUInt16BE(e+2),n.weight=t.readUInt16BE(e+4),n.port=t.readUInt16BE(e+6),n.target=f.decode(t,e+8),ye.decode.bytes=r+2,n};ye.decode.bytes=0;ye.encodingLength=function(t){return 8+f.encodingLength(t.target)};var j=v.caa={};j.ISSUER_CRITICAL=128;j.encode=function(t,e,r){let n=j.encodingLength(t);return e||(e=E.alloc(j.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=j.ISSUER_CRITICAL),e.writeUInt16BE(n-2,r),r+=2,e.writeUInt8(t.flags||0,r),r+=1,U.encode(t.tag,e,r),r+=U.encode.bytes,e.write(t.value,r),r+=E.byteLength(t.value),j.encode.bytes=n,e};j.encode.bytes=0;j.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e);e+=2;let n=e,o={};return o.flags=t.readUInt8(e),e+=1,o.tag=U.decode(t,e),e+=U.decode.bytes,o.value=t.toString("utf-8",e,n+r),o.issuerCritical=!!(o.flags&j.ISSUER_CRITICAL),j.decode.bytes=r+2,o};j.decode.bytes=0;j.encodingLength=function(t){return U.encodingLength(t.tag)+U.encodingLength(t.value)+2};var Ae=v.mx={};Ae.encode=function(t,e,r){e||(e=E.alloc(Ae.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,f.encode(t.exchange,e,r),r+=f.encode.bytes,e.writeUInt16BE(r-n-2,n),Ae.encode.bytes=r-n,e};Ae.encode.bytes=0;Ae.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.preference=t.readUInt16BE(e),e+=2,n.exchange=f.decode(t,e),e+=f.decode.bytes,Ae.decode.bytes=e-r,n};Ae.encodingLength=function(t){return 4+f.encodingLength(t.exchange)};var xe=v.a={};xe.encode=function(t,e,r){return e||(e=E.alloc(xe.encodingLength(t))),r||(r=0),e.writeUInt16BE(4,r),r+=2,Te.v4.encode(t,e,r),xe.encode.bytes=6,e};xe.encode.bytes=0;xe.decode=function(t,e){e||(e=0),e+=2;let r=Te.v4.decode(t,e);return xe.decode.bytes=6,r};xe.decode.bytes=0;xe.encodingLength=function(){return 6};var fe=v.aaaa={};fe.encode=function(t,e,r){return e||(e=E.alloc(fe.encodingLength(t))),r||(r=0),e.writeUInt16BE(16,r),r+=2,Te.v6.encode(t,e,r),fe.encode.bytes=18,e};fe.encode.bytes=0;fe.decode=function(t,e){e||(e=0),e+=2;let r=Te.v6.decode(t,e);return fe.decode.bytes=18,r};fe.decode.bytes=0;fe.encodingLength=function(){return 18};var _=v.option={};_.encode=function(t,e,r){e||(e=E.alloc(_.encodingLength(t))),r||(r=0);let n=r,o=Yt.toCode(t.code);if(e.writeUInt16BE(o,r),r+=2,t.data)e.writeUInt16BE(t.data.length,r),r+=2,t.data.copy(e,r),r+=t.data.length;else switch(o){case 8:let i=t.sourcePrefixLength||0,a=t.family||Te.familyOf(t.ip),u=Te.encode(t.ip,E.alloc),p=Math.ceil(i/8);e.writeUInt16BE(p+4,r),r+=2,e.writeUInt16BE(a,r),r+=2,e.writeUInt8(i,r++),e.writeUInt8(t.scopePrefixLength||0,r++),u.copy(e,r,0,p),r+=p;break;case 11:t.timeout?(e.writeUInt16BE(2,r),r+=2,e.writeUInt16BE(t.timeout,r),r+=2):(e.writeUInt16BE(0,r),r+=2);break;case 12:let m=t.length||0;e.writeUInt16BE(m,r),r+=2,e.fill(0,r,r+m),r+=m;break;case 14:let x=t.tags.length*2;e.writeUInt16BE(x,r),r+=2;for(let w of t.tags)e.writeUInt16BE(w,r),r+=2;break;default:throw new Error(`Unknown roption code: ${t.code}`)}return _.encode.bytes=r-n,e};_.encode.bytes=0;_.decode=function(t,e){e||(e=0);let r={};r.code=t.readUInt16BE(e),r.type=Yt.toString(r.code),e+=2;let n=t.readUInt16BE(e);switch(e+=2,r.data=t.slice(e,e+n),r.code){case 8:r.family=t.readUInt16BE(e),e+=2,r.sourcePrefixLength=t.readUInt8(e++),r.scopePrefixLength=t.readUInt8(e++);let o=E.alloc(r.family===1?4:16);t.copy(o,0,e,e+n-4),r.ip=Te.decode(o);break;case 11:n>0&&(r.timeout=t.readUInt16BE(e),e+=2);break;case 14:r.tags=[];for(let i=0;i<n;i+=2)r.tags.push(t.readUInt16BE(e)),e+=2}return _.decode.bytes=n+4,r};_.decode.bytes=0;_.encodingLength=function(t){if(t.data)return t.data.length+4;switch(Yt.toCode(t.code)){case 8:let r=t.sourcePrefixLength||0;return Math.ceil(r/8)+8;case 11:return typeof t.timeout=="number"?6:4;case 12:return t.length+4;case 14:return 4+t.tags.length*2}throw new Error(`Unknown roption code: ${t.code}`)};var X=v.opt={};X.encode=function(t,e,r){e||(e=E.alloc(X.encodingLength(t))),r||(r=0);let n=r,o=ke(t,_);return e.writeUInt16BE(o,r),r=ct(t,_,e,r+2),X.encode.bytes=r-n,e};X.encode.bytes=0;X.decode=function(t,e){e||(e=0);let r=e,n=[],o=t.readUInt16BE(e);e+=2;let i=0;for(;o>0;)n[i++]=_.decode(t,e),e+=_.decode.bytes,o-=_.decode.bytes;return X.decode.bytes=e-r,n};X.decode.bytes=0;X.encodingLength=function(t){return 2+ke(t||[],_)};var $=v.dnskey={};$.PROTOCOL_DNSSEC=3;$.ZONE_KEY=128;$.SECURE_ENTRYPOINT=32768;$.encode=function(t,e,r){e||(e=E.alloc($.encodingLength(t))),r||(r=0);let n=r,o=t.key;if(!E.isBuffer(o))throw new Error("Key must be a Buffer");return r+=2,e.writeUInt16BE(t.flags,r),r+=2,e.writeUInt8($.PROTOCOL_DNSSEC,r),r+=1,e.writeUInt8(t.algorithm,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,$.encode.bytes=r-n,e.writeUInt16BE($.encode.bytes-2,n),e};$.encode.bytes=0;$.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);if(e+=2,n.flags=t.readUInt16BE(e),e+=2,t.readUInt8(e)!==$.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=t.readUInt8(e),e+=1,n.key=t.slice(e,r+o+2),e+=n.key.length,$.decode.bytes=e-r,n};$.decode.bytes=0;$.encodingLength=function(t){return 6+E.byteLength(t.key)};var re=v.rrsig={};re.encode=function(t,e,r){e||(e=E.alloc(re.encodingLength(t))),r||(r=0);let n=r,o=t.signature;if(!E.isBuffer(o))throw new Error("Signature must be a Buffer");return r+=2,e.writeUInt16BE(be.toType(t.typeCovered),r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.labels,r),r+=1,e.writeUInt32BE(t.originalTTL,r),r+=4,e.writeUInt32BE(t.expiration,r),r+=4,e.writeUInt32BE(t.inception,r),r+=4,e.writeUInt16BE(t.keyTag,r),r+=2,f.encode(t.signersName,e,r),r+=f.encode.bytes,o.copy(e,r,0,o.length),r+=o.length,re.encode.bytes=r-n,e.writeUInt16BE(re.encode.bytes-2,n),e};re.encode.bytes=0;re.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.typeCovered=be.toString(t.readUInt16BE(e)),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.labels=t.readUInt8(e),e+=1,n.originalTTL=t.readUInt32BE(e),e+=4,n.expiration=t.readUInt32BE(e),e+=4,n.inception=t.readUInt32BE(e),e+=4,n.keyTag=t.readUInt16BE(e),e+=2,n.signersName=f.decode(t,e),e+=f.decode.bytes,n.signature=t.slice(e,r+o+2),e+=n.signature.length,re.decode.bytes=e-r,n};re.decode.bytes=0;re.encodingLength=function(t){return 20+f.encodingLength(t.signersName)+E.byteLength(t.signature)};var ne=v.rp={};ne.encode=function(t,e,r){e||(e=E.alloc(ne.encodingLength(t))),r||(r=0);let n=r;return r+=2,f.encode(t.mbox||".",e,r,{mail:!0}),r+=f.encode.bytes,f.encode(t.txt||".",e,r),r+=f.encode.bytes,ne.encode.bytes=r-n,e.writeUInt16BE(ne.encode.bytes-2,n),e};ne.encode.bytes=0;ne.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mbox=f.decode(t,e,{mail:!0})||".",e+=f.decode.bytes,n.txt=f.decode(t,e)||".",e+=f.decode.bytes,ne.decode.bytes=e-r,n};ne.decode.bytes=0;ne.encodingLength=function(t){return 2+f.encodingLength(t.mbox||".")+f.encodingLength(t.txt||".")};var F={};F.encode=function(t,e,r){e||(e=E.alloc(F.encodingLength(t))),r||(r=0);let n=r;for(var o=[],i=0;i<t.length;i++){var a=be.toType(t[i]);o[a>>8]===void 0&&(o[a>>8]=[]),o[a>>8][a>>3&31]|=1<<7-(a&7)}for(i=0;i<o.length;i++)if(o[i]!==void 0){var u=E.from(o[i]);e.writeUInt8(i,r),r+=1,e.writeUInt8(u.length,r),r+=1,u.copy(e,r),r+=u.length}return F.encode.bytes=r-n,e};F.encode.bytes=0;F.decode=function(t,e,r){e||(e=0);let n=e;for(var o=[];e-n<r;){var i=t.readUInt8(e);e+=1;var a=t.readUInt8(e);e+=1;for(var u=0;u<a;u++)for(var p=t.readUInt8(e+u),m=0;m<8;m++)if(p&1<<7-m){var x=be.toString(i<<8|u<<3|m);o.push(x)}e+=a}return F.decode.bytes=e-n,o};F.decode.bytes=0;F.encodingLength=function(t){for(var e=[],r=0;r<t.length;r++){var n=be.toType(t[r]);e[n>>8]=Math.max(e[n>>8]||0,n&255)}var o=0;for(r=0;r<e.length;r++)e[r]!==void 0&&(o+=2+Math.ceil((e[r]+1)/8));return o};var oe=v.nsec={};oe.encode=function(t,e,r){e||(e=E.alloc(oe.encodingLength(t))),r||(r=0);let n=r;return r+=2,f.encode(t.nextDomain,e,r),r+=f.encode.bytes,F.encode(t.rrtypes,e,r),r+=F.encode.bytes,oe.encode.bytes=r-n,e.writeUInt16BE(oe.encode.bytes-2,n),e};oe.encode.bytes=0;oe.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.nextDomain=f.decode(t,e),e+=f.decode.bytes,n.rrtypes=F.decode(t,e,o-(e-r)),e+=F.decode.bytes,oe.decode.bytes=e-r,n};oe.decode.bytes=0;oe.encodingLength=function(t){return 2+f.encodingLength(t.nextDomain)+F.encodingLength(t.rrtypes)};var ie=v.nsec3={};ie.encode=function(t,e,r){e||(e=E.alloc(ie.encodingLength(t))),r||(r=0);let n=r,o=t.salt;if(!E.isBuffer(o))throw new Error("salt must be a Buffer");let i=t.nextDomain;if(!E.isBuffer(i))throw new Error("nextDomain must be a Buffer");return r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.flags,r),r+=1,e.writeUInt16BE(t.iterations,r),r+=2,e.writeUInt8(o.length,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,e.writeUInt8(i.length,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,F.encode(t.rrtypes,e,r),r+=F.encode.bytes,ie.encode.bytes=r-n,e.writeUInt16BE(ie.encode.bytes-2,n),e};ie.encode.bytes=0;ie.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);e+=2,n.algorithm=t.readUInt8(e),e+=1,n.flags=t.readUInt8(e),e+=1,n.iterations=t.readUInt16BE(e),e+=2;let i=t.readUInt8(e);e+=1,n.salt=t.slice(e,e+i),e+=i;let a=t.readUInt8(e);return e+=1,n.nextDomain=t.slice(e,e+a),e+=a,n.rrtypes=F.decode(t,e,o-(e-r)),e+=F.decode.bytes,ie.decode.bytes=e-r,n};ie.decode.bytes=0;ie.encodingLength=function(t){return 8+t.salt.length+t.nextDomain.length+F.encodingLength(t.rrtypes)};var se=v.ds={};se.encode=function(t,e,r){e||(e=E.alloc(se.encodingLength(t))),r||(r=0);let n=r,o=t.digest;if(!E.isBuffer(o))throw new Error("Digest must be a Buffer");return r+=2,e.writeUInt16BE(t.keyTag,r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.digestType,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,se.encode.bytes=r-n,e.writeUInt16BE(se.encode.bytes-2,n),e};se.encode.bytes=0;se.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.keyTag=t.readUInt16BE(e),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.digestType=t.readUInt8(e),e+=1,n.digest=t.slice(e,r+o+2),e+=n.digest.length,se.decode.bytes=e-r,n};se.decode.bytes=0;se.encodingLength=function(t){return 6+E.byteLength(t.digest)};var K=v.sshfp={};K.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};K.encode=function(e,r,n){r||(r=E.alloc(K.encodingLength(e))),n||(n=0);let o=n;n+=2,r[n]=e.algorithm,n+=1,r[n]=e.hash,n+=1;let i=E.from(e.fingerprint.toUpperCase(),"hex");if(i.length!==K.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return i.copy(r,n),n+=i.byteLength,K.encode.bytes=n-o,r.writeUInt16BE(K.encode.bytes-2,o),r};K.encode.bytes=0;K.decode=function(e,r){r||(r=0);let n=r,o={};r+=2,o.algorithm=e[r],r+=1,o.hash=e[r],r+=1;let i=K.getFingerprintLengthForHashType(o.hash);return o.fingerprint=e.slice(r,r+i).toString("hex").toUpperCase(),r+=i,K.decode.bytes=r-n,o};K.decode.bytes=0;K.encodingLength=function(t){return 4+E.from(t.fingerprint,"hex").byteLength};var ce=v.naptr={};ce.encode=function(t,e,r){e||(e=E.alloc(ce.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.order||0,r),r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,U.encode(t.flags,e,r),r+=U.encode.bytes,U.encode(t.services,e,r),r+=U.encode.bytes,U.encode(t.regexp,e,r),r+=U.encode.bytes,f.encode(t.replacement,e,r),r+=f.encode.bytes,ce.encode.bytes=r-n,e.writeUInt16BE(ce.encode.bytes-2,n),e};ce.encode.bytes=0;ce.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.order=t.readUInt16BE(e),e+=2,n.preference=t.readUInt16BE(e),e+=2,n.flags=U.decode(t,e),e+=U.decode.bytes,n.services=U.decode(t,e),e+=U.decode.bytes,n.regexp=U.decode(t,e),e+=U.decode.bytes,n.replacement=f.decode(t,e),e+=f.decode.bytes,ce.decode.bytes=e-r,n};ce.decode.bytes=0;ce.encodingLength=function(t){return U.encodingLength(t.flags)+U.encodingLength(t.services)+U.encodingLength(t.regexp)+f.encodingLength(t.replacement)+6};var ae=v.tlsa={};ae.encode=function(t,e,r){e||(e=E.alloc(ae.encodingLength(t))),r||(r=0);let n=r,o=t.certificate;if(!E.isBuffer(o))throw new Error("Certificate must be a Buffer");return r+=2,e.writeUInt8(t.usage,r),r+=1,e.writeUInt8(t.selector,r),r+=1,e.writeUInt8(t.matchingType,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,ae.encode.bytes=r-n,e.writeUInt16BE(ae.encode.bytes-2,n),e};ae.encode.bytes=0;ae.decode=function(t,e){e||(e=0);let r=e,n={},o=t.readUInt16BE(e);return e+=2,n.usage=t.readUInt8(e),e+=1,n.selector=t.readUInt8(e),e+=1,n.matchingType=t.readUInt8(e),e+=1,n.certificate=t.slice(e,r+o+2),e+=n.certificate.length,ae.decode.bytes=e-r,n};ae.decode.bytes=0;ae.encodingLength=function(t){return 5+E.byteLength(t.certificate)};var Jt=v.record=function(t){switch(t.toUpperCase()){case"A":return xe;case"PTR":return W;case"CNAME":return Qi;case"DNAME":return Ji;case"TXT":return me;case"NULL":return ge;case"AAAA":return fe;case"SRV":return ye;case"HINFO":return we;case"CAA":return j;case"NS":return ue;case"SOA":return pe;case"MX":return Ae;case"OPT":return X;case"DNSKEY":return $;case"RRSIG":return re;case"RP":return ne;case"NSEC":return oe;case"NSEC3":return ie;case"SSHFP":return K;case"DS":return se;case"NAPTR":return ce;case"TLSA":return ae}return he},M=v.answer={};M.encode=function(t,e,r){e||(e=E.alloc(M.encodingLength(t))),r||(r=0);let n=r;if(f.encode(t.name,e,r),r+=f.encode.bytes,e.writeUInt16BE(be.toType(t.type),r),t.type.toUpperCase()==="OPT"){if(t.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(t.udpPayloadSize||4096,r+2),e.writeUInt8(t.extendedRcode||0,r+4),e.writeUInt8(t.ednsVersion||0,r+5),e.writeUInt16BE(t.flags||0,r+6),r+=8,X.encode(t.options||[],e,r),r+=X.encode.bytes}else{let o=Ct.toClass(t.class===void 0?"IN":t.class);t.flush&&(o|=Qt),e.writeUInt16BE(o,r+2),e.writeUInt32BE(t.ttl||0,r+4),r+=8;let i=Jt(t.type);i.encode(t.data,e,r),r+=i.encode.bytes}return M.encode.bytes=r-n,e};M.encode.bytes=0;M.decode=function(t,e){e||(e=0);let r={},n=e;if(r.name=f.decode(t,e),e+=f.decode.bytes,r.type=be.toString(t.readUInt16BE(e)),r.type==="OPT")r.udpPayloadSize=t.readUInt16BE(e+2),r.extendedRcode=t.readUInt8(e+4),r.ednsVersion=t.readUInt8(e+5),r.flags=t.readUInt16BE(e+6),r.flag_do=(r.flags>>15&1)===1,r.options=X.decode(t,e+8),e+=8+X.decode.bytes;else{let o=t.readUInt16BE(e+2);r.ttl=t.readUInt32BE(e+4),r.class=Ct.toString(o&Gi),r.flush=!!(o&Qt);let i=Jt(r.type);r.data=i.decode(t,e+8),e+=8+i.decode.bytes}return M.decode.bytes=e-n,r};M.decode.bytes=0;M.encodingLength=function(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return f.encodingLength(t.name)+8+Jt(t.type).encodingLength(e)};var Z=v.question={};Z.encode=function(t,e,r){e||(e=E.alloc(Z.encodingLength(t))),r||(r=0);let n=r;return f.encode(t.name,e,r),r+=f.encode.bytes,e.writeUInt16BE(be.toType(t.type),r),r+=2,e.writeUInt16BE(Ct.toClass(t.class===void 0?"IN":t.class),r),r+=2,Z.encode.bytes=r-n,t};Z.encode.bytes=0;Z.decode=function(t,e){e||(e=0);let r=e,n={};return n.name=f.decode(t,e),e+=f.decode.bytes,n.type=be.toString(t.readUInt16BE(e)),e+=2,n.class=Ct.toString(t.readUInt16BE(e)),e+=2,!!(n.class&Hn)&&(n.class&=Yi),Z.decode.bytes=e-r,n};Z.decode.bytes=0;Z.encodingLength=function(t){return f.encodingLength(t.name)+4};v.AUTHORITATIVE_ANSWER=1024;v.TRUNCATED_RESPONSE=512;v.RECURSION_DESIRED=256;v.RECURSION_AVAILABLE=128;v.AUTHENTIC_DATA=32;v.CHECKING_DISABLED=16;v.DNSSEC_OK=32768;v.encode=function(t,e,r){let n=!e;n&&(e=E.alloc(v.encodingLength(t))),r||(r=0);let o=r;return t.questions||(t.questions=[]),t.answers||(t.answers=[]),t.authorities||(t.authorities=[]),t.additionals||(t.additionals=[]),ee.encode(t,e,r),r+=ee.encode.bytes,r=ct(t.questions,Z,e,r),r=ct(t.answers,M,e,r),r=ct(t.authorities,M,e,r),r=ct(t.additionals,M,e,r),v.encode.bytes=r-o,n&&v.encode.bytes!==e.length?e.slice(0,v.encode.bytes):e};v.encode.bytes=0;v.decode=function(t,e){e||(e=0);let r=e,n=ee.decode(t,e);return e+=ee.decode.bytes,e=Ut(n.questions,Z,t,e),e=Ut(n.answers,M,t,e),e=Ut(n.authorities,M,t,e),e=Ut(n.additionals,M,t,e),v.decode.bytes=e-r,n};v.decode.bytes=0;v.encodingLength=function(t){return ee.encodingLength(t)+ke(t.questions||[],Z)+ke(t.answers||[],M)+ke(t.authorities||[],M)+ke(t.additionals||[],M)};v.streamEncode=function(t){let e=v.encode(t),r=E.alloc(2);r.writeUInt16BE(e.byteLength);let n=E.concat([r,e]);return v.streamEncode.bytes=n.byteLength,n};v.streamEncode.bytes=0;v.streamDecode=function(t){let e=t.readUInt16BE(0);if(t.byteLength<e+2)return null;let r=v.decode(t.slice(2));return v.streamDecode.bytes=v.decode.bytes,r};v.streamDecode.bytes=0;function ke(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function ct(t,e,r,n){for(let o=0;o<t.length;o++)e.encode(t[o],r,n),n+=e.encode.bytes;return n}function Ut(t,e,r,n){for(let o=0;o<t.length;o++)t[o]=e.decode(r,n),n+=e.decode.bytes;return n}});var Jn=J((lh,Qn)=>{"use strict";var Yn=ns;process.nextTick(rs,42);Qn.exports=Wi;function Wi(t){var e=n;return r;function r(o){e(o||es)}function n(o){var i=[o];e=a,t(u);function a(p){i.push(p)}function u(p){var m=arguments;for(e=Zi(p)?n:x;i.length;)x(i.shift());function x(w){Yn(ts,w,m)}}}}function Zi(t){return Object.prototype.toString.call(t)==="[object Error]"}function es(){}function ts(t,e){t.apply(null,e)}function rs(t){t===42&&(Yn=process.nextTick)}function ns(t,e,r){process.nextTick(function(){t(e,r)})}});var eo=J((hh,Zn)=>{var Wt=Gn(),os=Ie("dgram"),is=Jn(),ss=Ie("events"),er=Ie("os"),Zt=function(){};Zn.exports=function(t){t||(t={});var e=new ss.EventEmitter,r=typeof t.port=="number"?t.port:5353,n=t.type||"udp4",o=t.ip||t.host||(n==="udp4"?"224.0.0.251":null),i={address:o,port:r},a={},u=!1,p=null;if(n==="udp6"&&(!o||!t.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var m=t.socket||os.createSocket({type:n,reuseAddr:t.reuseAddr!==!1,toString:function(){return n}});m.on("error",function(w){w.code==="EACCES"||w.code==="EADDRINUSE"?e.emit("error",w):e.emit("warning",w)}),m.on("message",function(w,l){try{w=Wt.decode(w)}catch(c){e.emit("warning",c);return}e.emit("packet",w,l),w.type==="query"&&e.emit("query",w,l),w.type==="response"&&e.emit("response",w,l)}),m.on("listening",function(){r||(r=i.port=m.address().port),t.multicast!==!1&&(e.update(),p=setInterval(e.update,5e3),m.setMulticastTTL(t.ttl||255),m.setMulticastLoopback(t.loopback!==!1))});var x=is(function(w){if(!r||t.bind===!1)return w(null);m.once("error",w),m.bind(r,t.bind||t.interface,function(){m.removeListener("error",w),w(null)})});return x(function(w){if(w)return e.emit("error",w);e.emit("ready")}),e.send=function(w,l,c){if(typeof l=="function")return e.send(w,null,l);c||(c=Zt),l?!l.host&&!l.address&&(l.address=i.address):l=i,x(s);function s(d){if(u)return c();if(d)return c(d);var h=Wt.encode(w);m.send(h,0,h.length,l.port,l.address||l.host,c)}},e.response=e.respond=function(w,l,c){Array.isArray(w)&&(w={answers:w}),w.type="response",w.flags=(w.flags||0)|Wt.AUTHORITATIVE_ANSWER,e.send(w,l,c)},e.query=function(w,l,c,s){if(typeof l=="function")return e.query(w,null,null,l);if(typeof l=="object"&&l&&l.port)return e.query(w,null,l,c);if(typeof c=="function")return e.query(w,l,null,c);s||(s=Zt),typeof w=="string"&&(w=[{name:w,type:l||"ANY"}]),Array.isArray(w)&&(w={type:"query",questions:w}),w.type="query",e.send(w,c,s)},e.destroy=function(w){if(w||(w=Zt),u)return process.nextTick(w);u=!0,clearInterval(p);for(var l in a)try{m.dropMembership(o,l)}catch{}a={},m.close(w)},e.update=function(){for(var w=t.interface?[].concat(t.interface):as(),l=!1,c=0;c<w.length;c++){var s=w[c];if(!a[s])try{m.addMembership(o,s),a[s]=!0,l=!0}catch(d){e.emit("warning",d)}}if(l){if(m.setMulticastInterface)try{m.setMulticastInterface(t.interface||cs())}catch(d){e.emit("warning",d)}e.emit("networkInterface")}},e};function cs(){for(var t=er.networkInterfaces(),e=Object.keys(t),r=0;r<e.length;r++)for(var n=t[e[r]],o=0;o<n.length;o++){var i=n[o];if(Wn(i.family)&&!i.internal)return er.platform()==="darwin"&&e[r]==="en0"?i.address:"0.0.0.0"}return"127.0.0.1"}function as(){for(var t=er.networkInterfaces(),e=Object.keys(t),r=[],n=0;n<e.length;n++)for(var o=t[e[n]],i=0;i<o.length;i++){var a=o[i];if(Wn(a.family)){r.push(a.address);break}}return r}function Wn(t){return t===4||t==="IPv4"}});var Io=J(wt=>{(function(){var t,e,r,n,o,i,a,u;u=function(p){var m,x,w,l;return m=(p&255<<24)>>>24,x=(p&255<<16)>>>16,w=(p&65280)>>>8,l=p&255,[m,x,w,l].join(".")},a=function(p){var m,x,w,l,c,s;for(m=[],w=l=0;l<=3&&p.length!==0;w=++l){if(w>0){if(p[0]!==".")throw new Error("Invalid IP");p=p.substring(1)}s=e(p),c=s[0],x=s[1],p=p.substring(x),m.push(c)}if(p.length!==0)throw new Error("Invalid IP");switch(m.length){case 1:if(m[0]>4294967295)throw new Error("Invalid IP");return m[0]>>>0;case 2:if(m[0]>255||m[1]>16777215)throw new Error("Invalid IP");return(m[0]<<24|m[1])>>>0;case 3:if(m[0]>255||m[1]>255||m[2]>65535)throw new Error("Invalid IP");return(m[0]<<24|m[1]<<16|m[2])>>>0;case 4:if(m[0]>255||m[1]>255||m[2]>255||m[3]>255)throw new Error("Invalid IP");return(m[0]<<24|m[1]<<16|m[2]<<8|m[3])>>>0;default:throw new Error("Invalid IP")}},r=function(p){return p.charCodeAt(0)},n=r("0"),i=r("a"),o=r("A"),e=function(p){var m,x,w,l,c;for(l=0,m=10,x="9",w=0,p.length>1&&p[w]==="0"&&(p[w+1]==="x"||p[w+1]==="X"?(w+=2,m=16):"0"<=p[w+1]&&p[w+1]<="9"&&(w++,m=8,x="7")),c=w;w<p.length;){if("0"<=p[w]&&p[w]<=x)l=l*m+(r(p[w])-n)>>>0;else if(m===16)if("a"<=p[w]&&p[w]<="f")l=l*m+(10+r(p[w])-i)>>>0;else if("A"<=p[w]&&p[w]<="F")l=l*m+(10+r(p[w])-o)>>>0;else break;else break;if(l>4294967295)throw new Error("too large");w++}if(w===c)throw new Error("empty octet");return[l,w]},t=function(){function p(m,x){var w,l,c,s;if(typeof m!="string")throw new Error("Missing `net' parameter");if(x||(s=m.split("/",2),m=s[0],x=s[1]),x||(x=32),typeof x=="string"&&x.indexOf(".")>-1){try{this.maskLong=a(x)}catch(d){throw w=d,new Error("Invalid mask: "+x)}for(l=c=32;c>=0;l=--c)if(this.maskLong===4294967295<<32-l>>>0){this.bitmask=l;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=(a(m)&this.maskLong)>>>0}catch(d){throw w=d,new Error("Invalid net address: "+m)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+x);this.size=Math.pow(2,32-this.bitmask),this.base=u(this.netLong),this.mask=u(this.maskLong),this.hostmask=u(~this.maskLong),this.first=this.bitmask<=30?u(this.netLong+1):this.base,this.last=this.bitmask<=30?u(this.netLong+this.size-2):u(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?u(this.netLong+this.size-1):void 0}return p.prototype.contains=function(m){return typeof m=="string"&&(m.indexOf("/")>0||m.split(".").length!==4)&&(m=new p(m)),m instanceof p?this.contains(m.base)&&this.contains(m.broadcast||m.last):(a(m)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},p.prototype.next=function(m){return m==null&&(m=1),new p(u(this.netLong+this.size*m),this.mask)},p.prototype.forEach=function(m){var x,w,l;for(l=a(this.first),w=a(this.last),x=0;l<=w;)m(u(l),l,x),x++,l++},p.prototype.toString=function(){return this.base+"/"+this.bitmask},p}(),wt.ip2long=a,wt.long2ip=u,wt.Netmask=t}).call(wt)});var Co=J((Uo,Tt)=>{(function(t){"use strict";let e="(0?\\d+|0x[a-f0-9]+)",r={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"),o=new RegExp("^0x[a-f0-9]+$","i"),i="%[0-9a-z]{1,}",a="(?:[0-9a-f]+::?)+",u={zoneIndex:new RegExp(i,"i"),native:new RegExp(`^(::)?(${a})?([0-9a-f]+)?(::)?(${i})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${e}\\.${e}\\.${e}\\.${e}(${i})?)$`,"i"),transitional:new RegExp(`^((?:${a})|(?:::)(?:${a})?)${e}\\.${e}\\.${e}\\.${e}(${i})?$`,"i")};function p(c,s){if(c.indexOf("::")!==c.lastIndexOf("::"))return null;let d=0,h=-1,g=(c.match(u.zoneIndex)||[])[0],y,b;for(g&&(g=g.substring(1),c=c.replace(/%.+$/,""));(h=c.indexOf(":",h+1))>=0;)d++;if(c.substr(0,2)==="::"&&d--,c.substr(-2,2)==="::"&&d--,d>s)return null;for(b=s-d,y=":";b--;)y+="0:";return c=c.replace("::",y),c[0]===":"&&(c=c.slice(1)),c[c.length-1]===":"&&(c=c.slice(0,-1)),s=function(){let I=c.split(":"),A=[];for(let S=0;S<I.length;S++)A.push(parseInt(I[S],16));return A}(),{parts:s,zoneId:g}}function m(c,s,d,h){if(c.length!==s.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let g=0,y;for(;h>0;){if(y=d-h,y<0&&(y=0),c[g]>>y!==s[g]>>y)return!1;h-=d,g+=1}return!0}function x(c){if(o.test(c))return parseInt(c,16);if(c[0]==="0"&&!isNaN(parseInt(c[1],10))){if(n.test(c))return parseInt(c,8);throw new Error(`ipaddr: cannot parse ${c} as octal`)}return parseInt(c,10)}function w(c,s){for(;c.length<s;)c=`0${c}`;return c}let l={};l.IPv4=function(){function c(s){if(s.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let d,h;for(d=0;d<s.length;d++)if(h=s[d],!(0<=h&&h<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=s}return c.prototype.SpecialRanges={unspecified:[[new c([0,0,0,0]),8]],broadcast:[[new c([255,255,255,255]),32]],multicast:[[new c([224,0,0,0]),4]],linkLocal:[[new c([169,254,0,0]),16]],loopback:[[new c([127,0,0,0]),8]],carrierGradeNat:[[new c([100,64,0,0]),10]],private:[[new c([10,0,0,0]),8],[new c([172,16,0,0]),12],[new c([192,168,0,0]),16]],reserved:[[new c([192,0,0,0]),24],[new c([192,0,2,0]),24],[new c([192,88,99,0]),24],[new c([198,18,0,0]),15],[new c([198,51,100,0]),24],[new c([203,0,113,0]),24],[new c([240,0,0,0]),4]]},c.prototype.kind=function(){return"ipv4"},c.prototype.match=function(s,d){let h;if(d===void 0&&(h=s,s=h[0],d=h[1]),s.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return m(this.octets,s.octets,8,d)},c.prototype.prefixLengthFromSubnetMask=function(){let s=0,d=!1,h={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},g,y,b;for(g=3;g>=0;g-=1)if(y=this.octets[g],y in h){if(b=h[y],d&&b!==0)return null;b!==8&&(d=!0),s+=b}else return null;return 32-s},c.prototype.range=function(){return l.subnetMatch(this,this.SpecialRanges)},c.prototype.toByteArray=function(){return this.octets.slice(0)},c.prototype.toIPv4MappedAddress=function(){return l.IPv6.parse(`::ffff:${this.toString()}`)},c.prototype.toNormalizedString=function(){return this.toString()},c.prototype.toString=function(){return this.octets.join(".")},c}(),l.IPv4.broadcastAddressFromCIDR=function(c){try{let s=this.parseCIDR(c),d=s[0].toByteArray(),h=this.subnetMaskFromPrefixLength(s[1]).toByteArray(),g=[],y=0;for(;y<4;)g.push(parseInt(d[y],10)|parseInt(h[y],10)^255),y++;return new this(g)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},l.IPv4.isIPv4=function(c){return this.parser(c)!==null},l.IPv4.isValid=function(c){try{return new this(this.parser(c)),!0}catch{return!1}},l.IPv4.isValidFourPartDecimal=function(c){return!!(l.IPv4.isValid(c)&&c.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},l.IPv4.networkAddressFromCIDR=function(c){let s,d,h,g,y;try{for(s=this.parseCIDR(c),h=s[0].toByteArray(),y=this.subnetMaskFromPrefixLength(s[1]).toByteArray(),g=[],d=0;d<4;)g.push(parseInt(h[d],10)&parseInt(y[d],10)),d++;return new this(g)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},l.IPv4.parse=function(c){let s=this.parser(c);if(s===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(s)},l.IPv4.parseCIDR=function(c){let s;if(s=c.match(/^(.+)\/(\d+)$/)){let d=parseInt(s[2]);if(d>=0&&d<=32){let h=[this.parse(s[1]),d];return Object.defineProperty(h,"toString",{value:function(){return this.join("/")}}),h}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},l.IPv4.parser=function(c){let s,d,h;if(s=c.match(r.fourOctet))return function(){let g=s.slice(1,6),y=[];for(let b=0;b<g.length;b++)d=g[b],y.push(x(d));return y}();if(s=c.match(r.longValue)){if(h=x(s[1]),h>4294967295||h<0)throw new Error("ipaddr: address outside defined range");return function(){let g=[],y;for(y=0;y<=24;y+=8)g.push(h>>y&255);return g}().reverse()}else return(s=c.match(r.twoOctet))?function(){let g=s.slice(1,4),y=[];if(h=x(g[1]),h>16777215||h<0)throw new Error("ipaddr: address outside defined range");return y.push(x(g[0])),y.push(h>>16&255),y.push(h>>8&255),y.push(h&255),y}():(s=c.match(r.threeOctet))?function(){let g=s.slice(1,5),y=[];if(h=x(g[2]),h>65535||h<0)throw new Error("ipaddr: address outside defined range");return y.push(x(g[0])),y.push(x(g[1])),y.push(h>>8&255),y.push(h&255),y}():null},l.IPv4.subnetMaskFromPrefixLength=function(c){if(c=parseInt(c),c<0||c>32)throw new Error("ipaddr: invalid IPv4 prefix length");let s=[0,0,0,0],d=0,h=Math.floor(c/8);for(;d<h;)s[d]=255,d++;return h<4&&(s[h]=Math.pow(2,c%8)-1<<8-c%8),new this(s)},l.IPv6=function(){function c(s,d){let h,g;if(s.length===16)for(this.parts=[],h=0;h<=14;h+=2)this.parts.push(s[h]<<8|s[h+1]);else if(s.length===8)this.parts=s;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(h=0;h<this.parts.length;h++)if(g=this.parts[h],!(0<=g&&g<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");d&&(this.zoneId=d)}return c.prototype.SpecialRanges={unspecified:[new c([0,0,0,0,0,0,0,0]),128],linkLocal:[new c([65152,0,0,0,0,0,0,0]),10],multicast:[new c([65280,0,0,0,0,0,0,0]),8],loopback:[new c([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new c([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new c([0,0,0,0,0,65535,0,0]),96],rfc6145:[new c([0,0,0,0,65535,0,0,0]),96],rfc6052:[new c([100,65435,0,0,0,0,0,0]),96],"6to4":[new c([8194,0,0,0,0,0,0,0]),16],teredo:[new c([8193,0,0,0,0,0,0,0]),32],reserved:[[new c([8193,3512,0,0,0,0,0,0]),32]],benchmarking:[new c([8193,2,0,0,0,0,0,0]),48],amt:[new c([8193,3,0,0,0,0,0,0]),32],as112v6:[new c([8193,4,274,0,0,0,0,0]),48],deprecated:[new c([8193,16,0,0,0,0,0,0]),28],orchid2:[new c([8193,32,0,0,0,0,0,0]),28]},c.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},c.prototype.kind=function(){return"ipv6"},c.prototype.match=function(s,d){let h;if(d===void 0&&(h=s,s=h[0],d=h[1]),s.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return m(this.parts,s.parts,16,d)},c.prototype.prefixLengthFromSubnetMask=function(){let s=0,d=!1,h={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},g,y;for(let b=7;b>=0;b-=1)if(g=this.parts[b],g in h){if(y=h[g],d&&y!==0)return null;y!==16&&(d=!0),s+=y}else return null;return 128-s},c.prototype.range=function(){return l.subnetMatch(this,this.SpecialRanges)},c.prototype.toByteArray=function(){let s,d=[],h=this.parts;for(let g=0;g<h.length;g++)s=h[g],d.push(s>>8),d.push(s&255);return d},c.prototype.toFixedLengthString=function(){let s=function(){let h=[];for(let g=0;g<this.parts.length;g++)h.push(w(this.parts[g].toString(16),4));return h}.call(this).join(":"),d="";return this.zoneId&&(d=`%${this.zoneId}`),s+d},c.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),d=s[0],h=s[1];return new l.IPv4([d>>8,d&255,h>>8,h&255])},c.prototype.toNormalizedString=function(){let s=function(){let h=[];for(let g=0;g<this.parts.length;g++)h.push(this.parts[g].toString(16));return h}.call(this).join(":"),d="";return this.zoneId&&(d=`%${this.zoneId}`),s+d},c.prototype.toRFC5952String=function(){let s=/((^|:)(0(:|$)){2,})/g,d=this.toNormalizedString(),h=0,g=-1,y;for(;y=s.exec(d);)y[0].length>g&&(h=y.index,g=y[0].length);return g<0?d:`${d.substring(0,h)}::${d.substring(h+g)}`},c.prototype.toString=function(){return this.toRFC5952String()},c}(),l.IPv6.broadcastAddressFromCIDR=function(c){try{let s=this.parseCIDR(c),d=s[0].toByteArray(),h=this.subnetMaskFromPrefixLength(s[1]).toByteArray(),g=[],y=0;for(;y<16;)g.push(parseInt(d[y],10)|parseInt(h[y],10)^255),y++;return new this(g)}catch(s){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${s})`)}},l.IPv6.isIPv6=function(c){return this.parser(c)!==null},l.IPv6.isValid=function(c){if(typeof c=="string"&&c.indexOf(":")===-1)return!1;try{let s=this.parser(c);return new this(s.parts,s.zoneId),!0}catch{return!1}},l.IPv6.networkAddressFromCIDR=function(c){let s,d,h,g,y;try{for(s=this.parseCIDR(c),h=s[0].toByteArray(),y=this.subnetMaskFromPrefixLength(s[1]).toByteArray(),g=[],d=0;d<16;)g.push(parseInt(h[d],10)&parseInt(y[d],10)),d++;return new this(g)}catch(b){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${b})`)}},l.IPv6.parse=function(c){let s=this.parser(c);if(s.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(s.parts,s.zoneId)},l.IPv6.parseCIDR=function(c){let s,d,h;if((d=c.match(/^(.+)\/(\d+)$/))&&(s=parseInt(d[2]),s>=0&&s<=128))return h=[this.parse(d[1]),s],Object.defineProperty(h,"toString",{value:function(){return this.join("/")}}),h;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},l.IPv6.parser=function(c){let s,d,h,g,y,b;if(h=c.match(u.deprecatedTransitional))return this.parser(`::ffff:${h[1]}`);if(u.native.test(c))return p(c,8);if((h=c.match(u.transitional))&&(b=h[6]||"",s=p(h[1].slice(0,-1)+b,6),s.parts)){for(y=[parseInt(h[2]),parseInt(h[3]),parseInt(h[4]),parseInt(h[5])],d=0;d<y.length;d++)if(g=y[d],!(0<=g&&g<=255))return null;return s.parts.push(y[0]<<8|y[1]),s.parts.push(y[2]<<8|y[3]),{parts:s.parts,zoneId:s.zoneId}}return null},l.IPv6.subnetMaskFromPrefixLength=function(c){if(c=parseInt(c),c<0||c>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],d=0,h=Math.floor(c/8);for(;d<h;)s[d]=255,d++;return h<16&&(s[h]=Math.pow(2,c%8)-1<<8-c%8),new this(s)},l.fromByteArray=function(c){let s=c.length;if(s===4)return new l.IPv4(c);if(s===16)return new l.IPv6(c);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},l.isValid=function(c){return l.IPv6.isValid(c)||l.IPv4.isValid(c)},l.parse=function(c){if(l.IPv6.isValid(c))return l.IPv6.parse(c);if(l.IPv4.isValid(c))return l.IPv4.parse(c);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},l.parseCIDR=function(c){try{return l.IPv6.parseCIDR(c)}catch{try{return l.IPv4.parseCIDR(c)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},l.process=function(c){let s=this.parse(c);return s.kind()==="ipv6"&&s.isIPv4MappedAddress()?s.toIPv4Address():s},l.subnetMatch=function(c,s,d){let h,g,y,b;d==null&&(d="unicast");for(g in s)if(Object.prototype.hasOwnProperty.call(s,g)){for(y=s[g],y[0]&&!(y[0]instanceof Array)&&(y=[y]),h=0;h<y.length;h++)if(b=y[h],c.kind()===b[0].kind()&&c.match.apply(c,b))return g}return d},typeof Tt<"u"&&Tt.exports?Tt.exports=l:t.ipaddr=l})(Uo)});var wl={};C(wl,{mdns:()=>gl});var xl=Symbol.for("@libp2p/connection");var bl=Symbol.for("@libp2p/content-routing");var Bn=Symbol.for("@libp2p/peer-discovery");var Rn=Symbol.for("@libp2p/peer-id");var Sl=Symbol.for("@libp2p/peer-routing");var Fn;(function(t){t.Accept="accept",t.Ignore="ignore",t.Reject="reject"})(Fn||(Fn={}));var Pl=Symbol.for("@libp2p/transport");var Mn;(function(t){t[t.FATAL_ALL=0]="FATAL_ALL",t[t.NO_FATAL=1]="NO_FATAL"})(Mn||(Mn={}));var st=class extends Error{code;props;constructor(e,r,n){super(e),this.code=r,this.name=n?.name??"CodeError",this.props=n??{}}};var St=class extends EventTarget{#e=new Map;listenerCount(e){let r=this.#e.get(e);return r==null?0:r.length}addEventListener(e,r,n){super.addEventListener(e,r,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:r,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,r,n){super.removeEventListener(e.toString(),r??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:i})=>i!==r),this.#e.set(e,o))}dispatchEvent(e){let r=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),r}safeDispatchEvent(e,r){return this.dispatchEvent(new Vt(e,r))}},_t=class extends Event{detail;constructor(e,r){super(e,r),this.detail=r?.detail}},Vt=globalThis.CustomEvent??_t;var ki=Me(eo(),1);var ir={};C(ir,{base58btc:()=>H,base58flickr:()=>ms});var uh=new Uint8Array(0);function to(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function G(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function ro(t){return new TextEncoder().encode(t)}function no(t){return new TextDecoder().decode(t)}function ds(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),a=i.charCodeAt(0);if(r[a]!==255)throw new TypeError(i+" is ambiguous");r[a]=o}var u=t.length,p=t.charAt(0),m=Math.log(u)/Math.log(256),x=Math.log(256)/Math.log(u);function w(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 d=0,h=0,g=0,y=s.length;g!==y&&s[g]===0;)g++,d++;for(var b=(y-g)*x+1>>>0,I=new Uint8Array(b);g!==y;){for(var A=s[g],S=0,L=b-1;(A!==0||S<h)&&L!==-1;L--,S++)A+=256*I[L]>>>0,I[L]=A%u>>>0,A=A/u>>>0;if(A!==0)throw new Error("Non-zero carry");h=S,g++}for(var O=b-h;O!==b&&I[O]===0;)O++;for(var z=p.repeat(d);O<b;++O)z+=t.charAt(I[O]);return z}function l(s){if(typeof s!="string")throw new TypeError("Expected String");if(s.length===0)return new Uint8Array;var d=0;if(s[d]!==" "){for(var h=0,g=0;s[d]===p;)h++,d++;for(var y=(s.length-d)*m+1>>>0,b=new Uint8Array(y);s[d];){var I=r[s.charCodeAt(d)];if(I===255)return;for(var A=0,S=y-1;(I!==0||A<g)&&S!==-1;S--,A++)I+=u*b[S]>>>0,b[S]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");g=A,d++}if(s[d]!==" "){for(var L=y-g;L!==y&&b[L]===0;)L++;for(var O=new Uint8Array(h+(y-L)),z=h;L!==y;)O[z++]=b[L++];return O}}}function c(s){var d=l(s);if(d)return d;throw new Error(`Non-${e} character`)}return{encode:w,decodeUnsafe:l,decode:c}}var ls=ds,hs=ls,io=hs;var tr=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},rr=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.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 so(this,e)}},nr=class{decoders;constructor(e){this.decoders=e}or(e){return so(this,e)}decode(e){let r=e[0],n=this.decoders[r];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 so(t,e){return new nr({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var or=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new tr(e,r,n),this.decoder=new rr(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function $e({name:t,prefix:e,encode:r,decode:n}){return new or(t,e,r,n)}function Se({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=io(r,t);return $e({prefix:e,name:t,encode:n,decode:i=>G(o(i))})}function us(t,e,r,n){let o={};for(let x=0;x<e.length;++x)o[e[x]]=x;let i=t.length;for(;t[i-1]==="=";)--i;let a=new Uint8Array(i*r/8|0),u=0,p=0,m=0;for(let x=0;x<i;++x){let w=o[t[x]];if(w===void 0)throw new SyntaxError(`Non-${n} character`);p=p<<r|w,u+=r,u>=8&&(u-=8,a[m++]=255&p>>u)}if(u>=r||255&p<<8-u)throw new SyntaxError("Unexpected end of data");return a}function ps(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",a=0,u=0;for(let p=0;p<t.length;++p)for(u=u<<8|t[p],a+=8;a>r;)a-=r,i+=e[o&u>>a];if(a!==0&&(i+=e[o&u<<r-a]),n)for(;i.length*r&7;)i+="=";return i}function T({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return $e({prefix:e,name:t,encode(o){return ps(o,n,r)},decode(o){return us(o,n,r,t)}})}var H=Se({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ms=Se({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var sr={};C(sr,{base10:()=>gs});var gs=Se({prefix:"9",name:"base10",alphabet:"0123456789"});var cr={};C(cr,{base16:()=>ws,base16upper:()=>ys});var ws=T({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ys=T({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ar={};C(ar,{base2:()=>xs});var xs=T({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var dr={};C(dr,{base256emoji:()=>Is});var co=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),fs=co.reduce((t,e,r)=>(t[r]=e,t),[]),bs=co.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function vs(t){return t.reduce((e,r)=>(e+=fs[r],e),"")}function Es(t){let e=[];for(let r of t){let n=bs[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var Is=$e({prefix:"\u{1F680}",name:"base256emoji",encode:vs,decode:Es});var lr={};C(lr,{base32:()=>ze,base32hex:()=>Cs,base32hexpad:()=>Ps,base32hexpadupper:()=>Os,base32hexupper:()=>Ls,base32pad:()=>Ss,base32padupper:()=>Us,base32upper:()=>As,base32z:()=>Ds});var ze=T({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),As=T({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ss=T({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Us=T({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Cs=T({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ls=T({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ps=T({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Os=T({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ds=T({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var hr={};C(hr,{base36:()=>Ts,base36upper:()=>Ns});var Ts=Se({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ns=Se({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ur={};C(ur,{base64:()=>Bs,base64pad:()=>Rs,base64url:()=>Fs,base64urlpad:()=>Ms});var Bs=T({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Rs=T({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Fs=T({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ms=T({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var pr={};C(pr,{base8:()=>ks});var ks=T({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var mr={};C(mr,{identity:()=>$s});var $s=$e({prefix:"\0",name:"identity",encode:t=>no(t),decode:t=>ro(t)});var Lh=new TextEncoder,Ph=new TextDecoder;var wr={};C(wr,{identity:()=>Pt});var Vs=ho,ao=128,qs=127,js=~qs,Ks=Math.pow(2,31);function ho(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Ks;)e[r++]=t&255|ao,t/=128;for(;t&js;)e[r++]=t&255|ao,t>>>=7;return e[r]=t|0,ho.bytes=r-n+1,e}var Xs=gr,Hs=128,lo=127;function gr(t,n){var r=0,n=n||0,o=0,i=n,a,u=t.length;do{if(i>=u)throw gr.bytes=0,new RangeError("Could not decode varint");a=t[i++],r+=o<28?(a&lo)<<o:(a&lo)*Math.pow(2,o),o+=7}while(a>=Hs);return gr.bytes=i-n,r}var Gs=Math.pow(2,7),Ys=Math.pow(2,14),Qs=Math.pow(2,21),Js=Math.pow(2,28),Ws=Math.pow(2,35),Zs=Math.pow(2,42),ec=Math.pow(2,49),tc=Math.pow(2,56),rc=Math.pow(2,63),nc=function(t){return t<Gs?1:t<Ys?2:t<Qs?3:t<Js?4:t<Ws?5:t<Zs?6:t<ec?7:t<tc?8:t<rc?9:10},oc={encode:Vs,decode:Xs,encodingLength:nc},ic=oc,at=ic;function dt(t,e=0){return[at.decode(t,e),at.decode.bytes]}function _e(t,e,r=0){return at.encode(t,e,r),e}function Ve(t){return at.encodingLength(t)}function Ue(t,e){let r=e.byteLength,n=Ve(t),o=n+Ve(r),i=new Uint8Array(o+r);return _e(t,i,0),_e(r,i,n),i.set(e,o),new qe(t,r,e,i)}function lt(t){let e=G(t),[r,n]=dt(e),[o,i]=dt(e.subarray(n)),a=e.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new qe(r,o,a,e)}function uo(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&to(t.bytes,r.bytes)}}var qe=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var po=0,sc="identity",mo=G;function cc(t){return Ue(po,mo(t))}var Pt={code:po,name:sc,encode:mo,digest:cc};var br={};C(br,{sha256:()=>Ot,sha512:()=>ac});var fr=Me(Ie("crypto"),1);function xr({name:t,code:e,encode:r}){return new yr(t,e,r)}var yr=class{name;code;encode;constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?Ue(this.code,r):r.then(n=>Ue(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Ot=xr({name:"sha2-256",code:18,encode:t=>G(fr.default.createHash("sha256").update(t).digest())}),ac=xr({name:"sha2-512",code:19,encode:t=>G(fr.default.createHash("sha512").update(t).digest())});function wo(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return lc(r,vr(t),e??H.encoder);default:return hc(r,vr(t),e??ze.encoder)}}var yo=new WeakMap;function vr(t){let e=yo.get(t);if(e==null){let r=new Map;return yo.set(t,r),r}return e}var Ne=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==ht)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==uc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}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:r}=this.multihash,n=Ue(e,r);return t.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 t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&uo(e.multihash,n.multihash)}toString(e){return wo(this,e)}toJSON(){return{"/":wo(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 r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:a}=r;return new t(n,o,i,a??xo(n,o,i.bytes))}else if(r[pc]===!0){let{version:n,multihash:o,code:i}=r,a=lt(o);return t.create(n,i,a)}else return null}static create(e,r,n){if(typeof r!="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(r!==ht)throw new Error(`Version 0 CID must use dag-pb (code: ${ht}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=xo(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,ht,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=G(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),a=new qe(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(a):t.createV1(r.codec,a),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[w,l]=dt(e.subarray(r));return r+=l,w},o=n(),i=ht;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,u=n(),p=n(),m=r+p,x=m-a;return{version:o,codec:i,multihashCode:u,digestSize:p,multihashSize:x,size:m}}static parse(e,r){let[n,o]=dc(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return vr(i).set(n,e),i}};function dc(t,e){switch(t[0]){case"Q":{let r=e??H;return[H.prefix,r.decode(`${H.prefix}${t}`)]}case H.prefix:{let r=e??H;return[H.prefix,r.decode(t)]}case ze.prefix:{let r=e??ze;return[ze.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function lc(t,e,r){let{prefix:n}=r;if(n!==H.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o}function hc(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o}var ht=112,uc=18;function xo(t,e,r){let n=Ve(t),o=n+Ve(e),i=new Uint8Array(o+r.byteLength);return _e(t,i,0),_e(e,i,n),i.set(r,o),i}var pc=Symbol.for("@ipld/js-cid/CID");var Er={...mr,...ar,...pr,...sr,...cr,...lr,...hr,...ir,...ur,...dr},Jh={...br,...wr};function Ir(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var mc=Symbol.for("nodejs.util.inspect.custom"),fo=Object.values(Er).map(t=>t.decoder).reduce((t,e)=>t.or(e),Er.identity.decoder),bo=114,vo=36,Eo=37,ut=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()})`}[Rn]=!0;toString(){return this.string==null&&(this.string=H.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Ne.createV1(bo,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return Ir(this.multihash.bytes,e);if(typeof e=="string")return Ar(e).equals(this);if(e?.multihash?.bytes!=null)return Ir(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[mc](){return`PeerId(${this.toString()})`}},pt=class extends ut{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},mt=class extends ut{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},gt=class extends ut{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function Ar(t,e){if(e=e??fo,t.charAt(0)==="1"||t.charAt(0)==="Q"){let r=lt(H.decode(`z${t}`));return t.startsWith("12D")?new mt({multihash:r}):t.startsWith("16U")?new gt({multihash:r}):new pt({multihash:r})}return gc(fo.decode(t))}function gc(t){try{let e=lt(t);if(e.code===Pt.code){if(e.digest.length===vo)return new mt({multihash:e});if(e.digest.length===Eo)return new gt({multihash:e})}if(e.code===Ot.code)return new pt({multihash:e})}catch{return wc(Ne.decode(t))}throw new Error("Supplied PeerID CID is invalid")}function wc(t){if(t==null||t.multihash==null||t.version==null||t.version===1&&t.code!==bo)throw new Error("Supplied PeerID CID is invalid");let e=t.multihash;if(e.code===Ot.code)return new pt({multihash:t.multihash});if(e.code===Pt.code){if(e.digest.length===vo)return new mt({multihash:t.multihash});if(e.digest.length===Eo)return new gt({multihash:t.multihash})}throw new Error("Supplied PeerID CID is invalid")}var Po=Me(Io(),1);var Ao="[a-fA-F\\d:]",Ce=t=>t&&t.includeBoundaries?`(?:(?<=\\s|^)(?=${Ao})|(?<=${Ao})(?=\\s|$))`:"",te="(?: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}",Dt=`
|
|
3
3
|
(?:
|
|
4
|
-
(?:${
|
|
5
|
-
(?:${
|
|
6
|
-
(?:${
|
|
7
|
-
(?:${
|
|
8
|
-
(?:${
|
|
9
|
-
(?:${
|
|
10
|
-
(?:${
|
|
11
|
-
(?::(?:(?::${
|
|
4
|
+
(?:${R}:){7}(?:${R}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
|
|
5
|
+
(?:${R}:){6}(?:${te}|:${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
|
|
6
|
+
(?:${R}:){5}(?::${te}|(?::${R}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
|
|
7
|
+
(?:${R}:){4}(?:(?::${R}){0,1}:${te}|(?::${R}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
|
|
8
|
+
(?:${R}:){3}(?:(?::${R}){0,2}:${te}|(?::${R}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
|
|
9
|
+
(?:${R}:){2}(?:(?::${R}){0,3}:${te}|(?::${R}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
|
|
10
|
+
(?:${R}:){1}(?:(?::${R}){0,4}:${te}|(?::${R}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
|
|
11
|
+
(?::(?:(?::${R}){0,5}:${te}|(?::${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(),mo=new RegExp(`(?:^${Y}$)|(?:^${rt}$)`),yo=new RegExp(`^${Y}$`),wo=new RegExp(`^${rt}$`),Ht=t=>t&&t.exact?mo:new RegExp(`(?:${ve(t)}${Y}${ve(t)})|(?:${ve(t)}${rt}${ve(t)})`,"g");Ht.v4=t=>t&&t.exact?yo:new RegExp(`${ve(t)}${Y}${ve(t)}`,"g");Ht.v6=t=>t&&t.exact?wo:new RegExp(`${ve(t)}${rt}${ve(t)}`,"g");var tn=Ht;var Ae=Pe("node:net");function De(t){return!!(0,Ae.isIP)(t)}var cn=Ye(nn(),1),{isValid:Io,parse:Eo}=cn.default,xo=["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"],vo=xo.map(t=>new sn.Netmask(t));function Ao(t){for(let e of vo)if(e.contains(t))return!0;return!1}function on(t){return/^::$/.test(t)||/^::1$/.test(t)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^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(t)||/^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(t)||/^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(t)||/^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(t)||/^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(t)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(t)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(t)||/^ff([0-9a-fA-F]{2,2}):/i.test(t)}var an=t=>{if(Io(t)){let e=Eo(t);if(e.kind()==="ipv4")return Ao(e.toNormalizedString());if(e.kind()==="ipv6")return on(t)}else if(De(t)&&tn.v6().test(t))return on(t)};var dn=an;function ln(t){try{let{address:e}=t.nodeAddress();return!!dn(e)}catch{return!0}}function un(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function Ne(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function it(t=0){return globalThis.Buffer?.allocUnsafe!=null?Ne(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function pn(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var hn=pn("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Xt=pn("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=it(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),So={utf8:hn,"utf-8":hn,hex:xe.base16,latin1:Xt,ascii:Xt,binary:Xt,...xe},ot=So;function k(t,e="utf8"){let r=ot[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}function gn(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function mn(t=0){return globalThis.Buffer?.allocUnsafe!=null?gn(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}var bo=Math.pow(2,7),Uo=Math.pow(2,14),Lo=Math.pow(2,21),Gt=Math.pow(2,28),Yt=Math.pow(2,35),Qt=Math.pow(2,42),Wt=Math.pow(2,49),b=128,N=127;function ne(t){if(t<bo)return 1;if(t<Uo)return 2;if(t<Lo)return 3;if(t<Gt)return 4;if(t<Yt)return 5;if(t<Qt)return 6;if(t<Wt)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Po(t,e,r=0){switch(ne(t)){case 8:e[r++]=t&255|b,t/=128;case 7:e[r++]=t&255|b,t/=128;case 6:e[r++]=t&255|b,t/=128;case 5:e[r++]=t&255|b,t/=128;case 4:e[r++]=t&255|b,t>>>=7;case 3:e[r++]=t&255|b,t>>>=7;case 2:e[r++]=t&255|b,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function Co(t,e,r=0){switch(ne(t)){case 8:e.set(r++,t&255|b),t/=128;case 7:e.set(r++,t&255|b),t/=128;case 6:e.set(r++,t&255|b),t/=128;case 5:e.set(r++,t&255|b),t/=128;case 4:e.set(r++,t&255|b),t>>>=7;case 3:e.set(r++,t&255|b),t>>>=7;case 2:e.set(r++,t&255|b),t>>>=7;case 1:{e.set(r++,t&255),t>>>=7;break}default:throw new Error("unreachable")}return e}function Oo(t,e){let r=t[e],n=0;if(n+=r&N,r<b||(r=t[e+1],n+=(r&N)<<7,r<b)||(r=t[e+2],n+=(r&N)<<14,r<b)||(r=t[e+3],n+=(r&N)<<21,r<b)||(r=t[e+4],n+=(r&N)*Gt,r<b)||(r=t[e+5],n+=(r&N)*Yt,r<b)||(r=t[e+6],n+=(r&N)*Qt,r<b)||(r=t[e+7],n+=(r&N)*Wt,r<b))return n;throw new RangeError("Could not decode varint")}function To(t,e){let r=t.get(e),n=0;if(n+=r&N,r<b||(r=t.get(e+1),n+=(r&N)<<7,r<b)||(r=t.get(e+2),n+=(r&N)<<14,r<b)||(r=t.get(e+3),n+=(r&N)<<21,r<b)||(r=t.get(e+4),n+=(r&N)*Gt,r<b)||(r=t.get(e+5),n+=(r&N)*Yt,r<b)||(r=t.get(e+6),n+=(r&N)*Qt,r<b)||(r=t.get(e+7),n+=(r&N)*Wt,r<b))return n;throw new RangeError("Could not decode varint")}function Fe(t,e,r=0){return e==null&&(e=mn(ne(t))),e instanceof Uint8Array?Po(t,e,r):Co(t,e,r)}function Le(t,e=0){return t instanceof Uint8Array?Oo(t,e):To(t,e)}function ye(t,e){e==null&&(e=t.reduce((i,c)=>i+c.length,0));let r=it(e),n=0;for(let i of t)r.set(i,n),n+=i.length;return Ne(r)}var st=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let r=this.index,n=e();return n===void 0&&(this.index=r),n}parseWith(e){let r=e();if(this.index===this.input.length)return r}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 r=this.readChar();if(r===e)return r})}readSeparator(e,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,r,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,r!==void 0&&u>r))return}if(u!==0)return!n&&h&&u>1?void 0:c})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let r=0;r<e.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[r]=n}return e})}readIPv6Addr(){let e=r=>{for(let n=0;n<r.length/2;n++){let i=n*2;if(n<r.length-3){let u=this.readSeparator(":",n,()=>this.readIPv4Addr());if(u!==void 0)return r[i]=u[0],r[i+1]=u[1],r[i+2]=u[2],r[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];r[i]=c>>8,r[i+1]=c&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,i]=e(r);if(n===16)return r;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 r.set(c.subarray(0,m),16-m),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var ya=new st;var ba=parseInt("0xFFFF",16),Ua=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Jt(t,e="utf8"){let r=ot[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Ne(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var En=Ae.isIPv4,fo=Ae.isIPv6,Zt=function(t){let e=0;if(t=t.toString().trim(),En(t)){let r=new Uint8Array(e+4);return t.split(/\./g).forEach(n=>{r[e++]=parseInt(n,10)&255}),r}if(fo(t)){let r=t.split(":",8),n;for(n=0;n<r.length;n++){let c=En(r[n]),u;c&&(u=Zt(r[n]),r[n]=k(u.slice(0,2),"base16")),u!=null&&++n<8&&r.splice(n,0,k(u.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let c=[n,1];for(n=9-r.length;n>0;n--)c.push("0");r.splice.apply(r,c)}let i=new Uint8Array(e+16);for(n=0;n<r.length;n++){let c=parseInt(r[n],16);i[e++]=c>>8&255,i[e++]=c&255}return i}throw new Error("invalid ip address")},xn=function(t,e=0,r){e=~~e,r=r??t.length-e;let n=new DataView(t.buffer);if(r===4){let i=[];for(let c=0;c<r;c++)i.push(t[e+c]);return i.join(".")}if(r===16){let i=[];for(let c=0;c<r;c+=2)i.push(n.getUint16(e+c).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var fe={},er={},$o=[[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"]];$o.forEach(t=>{let e=Mo(...t);er[e.code]=e,fe[e.name]=e});function Mo(t,e,r,n,i){return{code:t,size:e,name:r,resolvable:!!n,path:!!i}}function U(t){if(typeof t=="number"){if(er[t]!=null)return er[t];throw new Error(`no protocol with code: ${t}`)}else if(typeof t=="string"){if(fe[t]!=null)return fe[t];throw new Error(`no protocol with name: ${t}`)}throw new Error(`invalid protocol id type: ${typeof t}`)}var ud=U("ip4"),hd=U("ip6"),pd=U("ipcidr");function rr(t,e){switch(U(t).code){case 4:case 41:return zo(e);case 42:return Sn(e);case 6:case 273:case 33:case 132:return Un(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Sn(e);case 421:return Ko(e);case 444:return bn(e);case 445:return bn(e);case 466:return jo(e);default:return k(e,"base16")}}function nr(t,e){switch(U(t).code){case 4:return vn(e);case 41:return vn(e);case 42:return An(e);case 6:case 273:case 33:case 132:return ir(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return An(e);case 421:return Vo(e);case 444:return Ho(e);case 445:return Xo(e);case 466:return qo(e);default:return Jt(e,"base16")}}var tr=Object.values(xe).map(t=>t.decoder),_o=function(){let t=tr[0].or(tr[1]);return tr.slice(2).forEach(e=>t=t.or(e)),t}();function vn(t){if(!De(t))throw new Error("invalid ip address");return Zt(t)}function zo(t){let e=xn(t,0,t.length);if(e==null)throw new Error("ipBuff is required");if(!De(e))throw new Error("invalid ip address");return e}function ir(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function Un(t){return new DataView(t.buffer).getUint16(t.byteOffset)}function An(t){let e=Jt(t),r=Uint8Array.from(Fe(e.length));return ye([r,e],r.length+e.length)}function Sn(t){let e=Le(t);if(t=t.slice(ne(e)),t.length!==e)throw new Error("inconsistent lengths");return k(t)}function Vo(t){let e;t[0]==="Q"||t[0]==="1"?e=be(D.decode(`z${t}`)).bytes:e=G.parse(t).multihash.bytes;let r=Uint8Array.from(Fe(e.length));return ye([r,e],r.length+e.length)}function qo(t){let e=_o.decode(t),r=Uint8Array.from(Fe(e.length));return ye([r,e],r.length+e.length)}function jo(t){let e=Le(t),r=t.slice(ne(e));if(r.length!==e)throw new Error("inconsistent lengths");return"u"+k(r,"base64url")}function Ko(t){let e=Le(t),r=t.slice(ne(e));if(r.length!==e)throw new Error("inconsistent lengths");return k(r,"base58btc")}function Ho(t){let e=t.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 r=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=ir(n);return ye([r,i],r.length+i.length)}function Xo(t){let e=t.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 r=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=ir(n);return ye([r,i],r.length+i.length)}function bn(t){let e=t.slice(0,t.length-2),r=t.slice(t.length-2),n=k(e,"base32"),i=Un(r);return`${n}:${i}`}function Ln(t){t=or(t);let e=[],r=[],n=null,i=t.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]),r.push([m.code]);continue}if(c++,c>=i.length)throw Cn("invalid address: "+t);if(m.path===!0){n=or(i.slice(c).join("/")),e.push([m.code,nr(m.code,n)]),r.push([m.code,n]);break}let h=nr(m.code,i[c]);e.push([m.code,h]),r.push([m.code,rr(m.code,h)])}return{string:Pn(r),bytes:cr(e),tuples:e,stringTuples:r,path:n}}function sr(t){let e=[],r=[],n=null,i=0;for(;i<t.length;){let c=Le(t,i),u=ne(c),m=U(c),h=Go(m,t.slice(i+u));if(h===0){e.push([c]),r.push([c]),i+=u;continue}let p=t.slice(i+u,i+u+h);if(i+=h+u,i>t.length)throw Cn("Invalid address Uint8Array: "+k(t,"base16"));e.push([c,p]);let E=rr(c,p);if(r.push([c,E]),m.path===!0){n=E;break}}return{bytes:Uint8Array.from(t),string:Pn(r),tuples:e,stringTuples:r,path:n}}function Pn(t){let e=[];return t.map(r=>{let n=U(r[0]);return e.push(n.name),r.length>1&&r[1]!=null&&e.push(r[1]),null}),or(e.join("/"))}function cr(t){return ye(t.map(e=>{let r=U(e[0]),n=Uint8Array.from(Fe(r.code));return e.length>1&&e[1]!=null&&(n=ye([n,e[1]])),n}))}function Go(t,e){if(t.size>0)return t.size/8;if(t.size===0)return 0;{let r=Le(e instanceof Uint8Array?e:Uint8Array.from(e));return r+ne(r)}}function or(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}function Cn(t){return new Error("Error parsing address: "+t)}var Yo=Symbol.for("nodejs.util.inspect.custom"),ar=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Qo=[U("dns").code,U("dns4").code,U("dns6").code,U("dnsaddr").code],ct=class t{bytes;#e;#t;#r;#n;[ar]=!0;constructor(e){e==null&&(e="");let r;if(e instanceof Uint8Array)r=sr(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);r=Ln(e)}else if(Tn(e))r=sr(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.bytes,this.#e=r.string,this.#t=r.tuples,this.#r=r.stringTuples,this.#n=r.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,r,n,i,c="",u=U("tcp"),m=U("udp"),h=U("ip4"),p=U("ip6"),E=U("dns6"),g=U("ip6zone");for(let[o,s]of this.stringTuples())o===g.code&&(c=`%${s??""}`),Qo.includes(o)&&(r=u.name,i=443,n=`${s??""}${c}`,e=o===E.code?6:4),(o===u.code||o===m.code)&&(r=U(o).name,i=parseInt(s??"")),(o===h.code||o===p.code)&&(r=U(o).name,n=`${s??""}${c}`,e=o===p.code?6:4);if(e==null||r==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:r,port:i}}protos(){return this.#t.map(([e])=>Object.assign({},U(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>U(e).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(e){return e=new t(e),new t(this.toString()+e.toString())}decapsulate(e){let r=e.toString(),n=this.toString(),i=n.lastIndexOf(r);if(i<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new t(n.slice(0,i))}decapsulateCode(e){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===e)return new t(cr(r.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,i])=>{n===fe.p2p.code&&e.push([n,i]),n===fe["p2p-circuit"].code&&(e=[])});let r=e.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?k(D.decode(`z${n}`),"base58btc"):k(G.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return un(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(c=>c.resolvable);if(r==null)return[this];let n=On.get(r.name);if(n==null)throw new ke(`no available resolver for ${r.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(c=>new t(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 r=(e??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[Yo](){return`Multiaddr(${this.#e})`}};var On=new Map;function Tn(t){return!!t?.[ar]}function dr(t){return new ct(t)}function Rn(t,e,r,n){let i=()=>{n?.log.trace("query",e),t.query({questions:[{name:e,type:"PTR"}]})};return i(),setInterval(i,r)}function Bn(t,e,r,n){if(t.answers==null)return;let i,c=[];if(t.answers.forEach(u=>{switch(u.type){case"PTR":i=u;break;case"TXT":c.push(u);break;default:break}}),t.additionals.forEach(u=>{switch(u.type){case"TXT":c.push(u);break;default:break}}),!(i==null||i?.name!==r||c.length===0||i.data.startsWith(e)))try{let u=c.flatMap(h=>h.data).filter(h=>h.toString().startsWith("dnsaddr=")).map(h=>dr(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:Kt(m),multiaddrs:u.map(h=>h.decapsulateCode(U("p2p").code))}}catch(u){n?.log.error("failed to parse mdns response",u)}}function Dn(t,e,r,n,i,c,u){if(!c){u?.log("not responding to mDNS query as broadcast mode is false");return}if(n.length!==0&&t.questions[0]!=null&&t.questions[0].name===i){let m=[];m.push({name:i,type:"PTR",class:"IN",ttl:120,data:r+"."+i}),n.filter(Wo).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:r+"."+i,type:"TXT",class:"IN",ttl:120,data:p})}),u?.log.trace("responding to query"),e.respond(m)}}function Wo(t){return!!ln(t)}function Nn(t){let e="",r="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<t;n++)e+=r.charAt(Math.floor(Math.random()*r.length));return e}var at=class extends Qe{mdns;log;broadcast;interval;serviceTag;peerName;port;ip;_queryInterval;components;constructor(e,r={}){if(super(),this.log=e.logger.forComponent("libp2p:mdns"),this.broadcast=r.broadcast!==!1,this.interval=r.interval??1e3*10,this.serviceTag=r.serviceTag??"_p2p._udp.local",this.ip=r.ip??"224.0.0.251",this.peerName=r.peerName??Nn(63),this.peerName.length>=64)throw new Error("Peer name should be less than 64 chars long");this.port=r.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)}[ur]=this;[Symbol.toStringTag]="@libp2p/mdns";isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,Fn.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=Rn(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),Dn(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 r=Bn(e,this.peerName,this.serviceTag,{log:this.log});r!=null&&(this.log("discovered peer in mDNS query response %p",r.id),this.dispatchEvent(new lt("peer",{detail:r})))}catch(r){this.log.error("Error processing peer response",r)}}_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 Zo(t={}){return e=>new at(e,t)}return zn(es);})();
|
|
13
|
+
`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),yc=new RegExp(`(?:^${te}$)|(?:^${Dt}$)`),xc=new RegExp(`^${te}$`),fc=new RegExp(`^${Dt}$`),Sr=t=>t&&t.exact?yc:new RegExp(`(?:${Ce(t)}${te}${Ce(t)})|(?:${Ce(t)}${Dt}${Ce(t)})`,"g");Sr.v4=t=>t&&t.exact?xc:new RegExp(`${Ce(t)}${te}${Ce(t)}`,"g");Sr.v6=t=>t&&t.exact?fc:new RegExp(`${Ce(t)}${Dt}${Ce(t)}`,"g");var So=Sr;var Le=Ie("node:net");function Ke(t){return!!(0,Le.isIP)(t)}var Oo=Me(Co(),1),{isValid:bc,parse:vc}=Oo.default,Ec=["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"],Ic=Ec.map(t=>new Po.Netmask(t));function Ac(t){for(let e of Ic)if(e.contains(t))return!0;return!1}function Lo(t){return/^::$/.test(t)||/^::1$/.test(t)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^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(t)||/^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(t)||/^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(t)||/^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(t)||/^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(t)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(t)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(t)||/^ff([0-9a-fA-F]{2,2}):/i.test(t)}var Do=t=>{if(bc(t)){let e=vc(t);if(e.kind()==="ipv4")return Ac(e.toNormalizedString());if(e.kind()==="ipv6")return Lo(t)}else if(Ke(t)&&So.v6().test(t))return Lo(t)};var To=Do;function No(t){try{let{address:e}=t.nodeAddress();return!!To(e)}catch{return!0}}var Or={};C(Or,{base58btc:()=>V,base58flickr:()=>Oc});function Sc(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),a=i.charCodeAt(0);if(r[a]!==255)throw new TypeError(i+" is ambiguous");r[a]=o}var u=t.length,p=t.charAt(0),m=Math.log(u)/Math.log(256),x=Math.log(256)/Math.log(u);function w(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 d=0,h=0,g=0,y=s.length;g!==y&&s[g]===0;)g++,d++;for(var b=(y-g)*x+1>>>0,I=new Uint8Array(b);g!==y;){for(var A=s[g],S=0,L=b-1;(A!==0||S<h)&&L!==-1;L--,S++)A+=256*I[L]>>>0,I[L]=A%u>>>0,A=A/u>>>0;if(A!==0)throw new Error("Non-zero carry");h=S,g++}for(var O=b-h;O!==b&&I[O]===0;)O++;for(var z=p.repeat(d);O<b;++O)z+=t.charAt(I[O]);return z}function l(s){if(typeof s!="string")throw new TypeError("Expected String");if(s.length===0)return new Uint8Array;var d=0;if(s[d]!==" "){for(var h=0,g=0;s[d]===p;)h++,d++;for(var y=(s.length-d)*m+1>>>0,b=new Uint8Array(y);s[d];){var I=r[s.charCodeAt(d)];if(I===255)return;for(var A=0,S=y-1;(I!==0||A<g)&&S!==-1;S--,A++)I+=u*b[S]>>>0,b[S]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");g=A,d++}if(s[d]!==" "){for(var L=y-g;L!==y&&b[L]===0;)L++;for(var O=new Uint8Array(h+(y-L)),z=h;L!==y;)O[z++]=b[L++];return O}}}function c(s){var d=l(s);if(d)return d;throw new Error(`Non-${e} character`)}return{encode:w,decodeUnsafe:l,decode:c}}var Uc=Sc,Cc=Uc,Bo=Cc;var bu=new Uint8Array(0);var Ro=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},Y=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var Fo=t=>new TextEncoder().encode(t),Mo=t=>new TextDecoder().decode(t);var Ur=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Cr=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.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 $o(this,e)}},Lr=class{constructor(e){this.decoders=e}or(e){return $o(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},$o=(t,e)=>new Lr({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),Pr=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ur(e,r,n),this.decoder=new Cr(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Xe=({name:t,prefix:e,encode:r,decode:n})=>new Pr(t,e,r,n),Pe=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=Bo(r,e);return Xe({prefix:t,name:e,encode:n,decode:i=>Y(o(i))})},Lc=(t,e,r,n)=>{let o={};for(let x=0;x<e.length;++x)o[e[x]]=x;let i=t.length;for(;t[i-1]==="=";)--i;let a=new Uint8Array(i*r/8|0),u=0,p=0,m=0;for(let x=0;x<i;++x){let w=o[t[x]];if(w===void 0)throw new SyntaxError(`Non-${n} character`);p=p<<r|w,u+=r,u>=8&&(u-=8,a[m++]=255&p>>u)}if(u>=r||255&p<<8-u)throw new SyntaxError("Unexpected end of data");return a},Pc=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,i="",a=0,u=0;for(let p=0;p<t.length;++p)for(u=u<<8|t[p],a+=8;a>r;)a-=r,i+=e[o&u>>a];if(a&&(i+=e[o&u<<r-a]),n)for(;i.length*r&7;)i+="=";return i},N=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Xe({prefix:e,name:t,encode(o){return Pc(o,n,r)},decode(o){return Lc(o,n,r,t)}});var V=Pe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Oc=Pe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Dr={};C(Dr,{base32:()=>ve,base32hex:()=>Bc,base32hexpad:()=>Fc,base32hexpadupper:()=>Mc,base32hexupper:()=>Rc,base32pad:()=>Tc,base32padupper:()=>Nc,base32upper:()=>Dc,base32z:()=>kc});var ve=N({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Dc=N({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Tc=N({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Nc=N({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Bc=N({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Rc=N({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Fc=N({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Mc=N({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),kc=N({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var $c=Vo,zo=128,zc=127,_c=~zc,Vc=Math.pow(2,31);function Vo(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Vc;)e[r++]=t&255|zo,t/=128;for(;t&_c;)e[r++]=t&255|zo,t>>>=7;return e[r]=t|0,Vo.bytes=r-n+1,e}var qc=Tr,jc=128,_o=127;function Tr(t,n){var r=0,n=n||0,o=0,i=n,a,u=t.length;do{if(i>=u)throw Tr.bytes=0,new RangeError("Could not decode varint");a=t[i++],r+=o<28?(a&_o)<<o:(a&_o)*Math.pow(2,o),o+=7}while(a>=jc);return Tr.bytes=i-n,r}var Kc=Math.pow(2,7),Xc=Math.pow(2,14),Hc=Math.pow(2,21),Gc=Math.pow(2,28),Yc=Math.pow(2,35),Qc=Math.pow(2,42),Jc=Math.pow(2,49),Wc=Math.pow(2,56),Zc=Math.pow(2,63),ea=function(t){return t<Kc?1:t<Xc?2:t<Hc?3:t<Gc?4:t<Yc?5:t<Qc?6:t<Jc?7:t<Wc?8:t<Zc?9:10},ta={encode:$c,decode:qc,encodingLength:ea},ra=ta,yt=ra;var xt=(t,e=0)=>[yt.decode(t,e),yt.decode.bytes],He=(t,e,r=0)=>(yt.encode(t,e,r),e),Ge=t=>yt.encodingLength(t);var Be=(t,e)=>{let r=e.byteLength,n=Ge(t),o=n+Ge(r),i=new Uint8Array(o+r);return He(t,i,0),He(r,i,n),i.set(e,o),new Ye(t,r,e,i)},Bt=t=>{let e=Y(t),[r,n]=xt(e),[o,i]=xt(e.subarray(n)),a=e.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new Ye(r,o,a,e)},qo=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Ro(t.bytes,r.bytes)}},Ye=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var jo=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return oa(r,Nr(t),e||V.encoder);default:return ia(r,Nr(t),e||ve.encoder)}};var Ko=new WeakMap,Nr=t=>{let e=Ko.get(t);if(e==null){let r=new Map;return Ko.set(t,r),r}return e},Oe=class t{constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==ft)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==sa)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}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:r}=this.multihash,n=Be(e,r);return t.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 t.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&qo(e.multihash,n.multihash)}toString(e){return jo(this,e)}toJSON(){return{"/":jo(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:a}=r;return new t(n,o,i,a||Xo(n,o,i.bytes))}else if(r[ca]===!0){let{version:n,multihash:o,code:i}=r,a=Bt(o);return t.create(n,i,a)}else return null}static create(e,r,n){if(typeof r!="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(r!==ft)throw new Error(`Version 0 CID must use dag-pb (code: ${ft}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Xo(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,ft,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=Y(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),a=new Ye(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(a):t.createV1(r.codec,a),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[w,l]=xt(e.subarray(r));return r+=l,w},o=n(),i=ft;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,u=n(),p=n(),m=r+p,x=m-a;return{version:o,codec:i,multihashCode:u,digestSize:p,multihashSize:x,size:m}}static parse(e,r){let[n,o]=na(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Nr(i).set(n,e),i}},na=(t,e)=>{switch(t[0]){case"Q":{let r=e||V;return[V.prefix,r.decode(`${V.prefix}${t}`)]}case V.prefix:{let r=e||V;return[V.prefix,r.decode(t)]}case ve.prefix:{let r=e||ve;return[ve.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},oa=(t,e,r)=>{let{prefix:n}=r;if(n!==V.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o},ia=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o},ft=112,sa=18,Xo=(t,e,r)=>{let n=Ge(t),o=n+Ge(e),i=new Uint8Array(o+r.byteLength);return He(t,i,0),He(e,i,n),i.set(r,o),i},ca=Symbol.for("@ipld/js-cid/CID");function Ho(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var kr={};C(kr,{base10:()=>pa});function aa(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),a=i.charCodeAt(0);if(r[a]!==255)throw new TypeError(i+" is ambiguous");r[a]=o}var u=t.length,p=t.charAt(0),m=Math.log(u)/Math.log(256),x=Math.log(256)/Math.log(u);function w(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 d=0,h=0,g=0,y=s.length;g!==y&&s[g]===0;)g++,d++;for(var b=(y-g)*x+1>>>0,I=new Uint8Array(b);g!==y;){for(var A=s[g],S=0,L=b-1;(A!==0||S<h)&&L!==-1;L--,S++)A+=256*I[L]>>>0,I[L]=A%u>>>0,A=A/u>>>0;if(A!==0)throw new Error("Non-zero carry");h=S,g++}for(var O=b-h;O!==b&&I[O]===0;)O++;for(var z=p.repeat(d);O<b;++O)z+=t.charAt(I[O]);return z}function l(s){if(typeof s!="string")throw new TypeError("Expected String");if(s.length===0)return new Uint8Array;var d=0;if(s[d]!==" "){for(var h=0,g=0;s[d]===p;)h++,d++;for(var y=(s.length-d)*m+1>>>0,b=new Uint8Array(y);s[d];){var I=r[s.charCodeAt(d)];if(I===255)return;for(var A=0,S=y-1;(I!==0||A<g)&&S!==-1;S--,A++)I+=u*b[S]>>>0,b[S]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");g=A,d++}if(s[d]!==" "){for(var L=y-g;L!==y&&b[L]===0;)L++;for(var O=new Uint8Array(h+(y-L)),z=h;L!==y;)O[z++]=b[L++];return O}}}function c(s){var d=l(s);if(d)return d;throw new Error(`Non-${e} character`)}return{encode:w,decodeUnsafe:l,decode:c}}var da=aa,la=da,Go=la;var Fu=new Uint8Array(0);var Yo=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},Q=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var Qo=t=>new TextEncoder().encode(t),Jo=t=>new TextDecoder().decode(t);var Br=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Rr=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.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 Zo(this,e)}},Fr=class{constructor(e){this.decoders=e}or(e){return Zo(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Zo=(t,e)=>new Fr({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),Mr=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Br(e,r,n),this.decoder=new Rr(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Je=({name:t,prefix:e,encode:r,decode:n})=>new Mr(t,e,r,n),De=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=Go(r,e);return Je({prefix:t,name:e,encode:n,decode:i=>Q(o(i))})},ha=(t,e,r,n)=>{let o={};for(let x=0;x<e.length;++x)o[e[x]]=x;let i=t.length;for(;t[i-1]==="=";)--i;let a=new Uint8Array(i*r/8|0),u=0,p=0,m=0;for(let x=0;x<i;++x){let w=o[t[x]];if(w===void 0)throw new SyntaxError(`Non-${n} character`);p=p<<r|w,u+=r,u>=8&&(u-=8,a[m++]=255&p>>u)}if(u>=r||255&p<<8-u)throw new SyntaxError("Unexpected end of data");return a},ua=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,i="",a=0,u=0;for(let p=0;p<t.length;++p)for(u=u<<8|t[p],a+=8;a>r;)a-=r,i+=e[o&u>>a];if(a&&(i+=e[o&u<<r-a]),n)for(;i.length*r&7;)i+="=";return i},B=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Je({prefix:e,name:t,encode(o){return ua(o,n,r)},decode(o){return ha(o,n,r,t)}});var pa=De({prefix:"9",name:"base10",alphabet:"0123456789"});var $r={};C($r,{base16:()=>ma,base16upper:()=>ga});var ma=B({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ga=B({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var zr={};C(zr,{base2:()=>wa});var wa=B({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var _r={};C(_r,{base256emoji:()=>va});var ei=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}"),ya=ei.reduce((t,e,r)=>(t[r]=e,t),[]),xa=ei.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function fa(t){return t.reduce((e,r)=>(e+=ya[r],e),"")}function ba(t){let e=[];for(let r of t){let n=xa[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var va=Je({prefix:"\u{1F680}",name:"base256emoji",encode:fa,decode:ba});var Vr={};C(Vr,{base32:()=>We,base32hex:()=>Sa,base32hexpad:()=>Ca,base32hexpadupper:()=>La,base32hexupper:()=>Ua,base32pad:()=>Ia,base32padupper:()=>Aa,base32upper:()=>Ea,base32z:()=>Pa});var We=B({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ea=B({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ia=B({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Aa=B({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Sa=B({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ua=B({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ca=B({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),La=B({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Pa=B({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var qr={};C(qr,{base36:()=>Oa,base36upper:()=>Da});var Oa=De({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Da=De({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var jr={};C(jr,{base58btc:()=>de,base58flickr:()=>Ta});var de=De({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ta=De({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Kr={};C(Kr,{base64:()=>Na,base64pad:()=>Ba,base64url:()=>Ra,base64urlpad:()=>Fa});var Na=B({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ba=B({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ra=B({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Fa=B({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Xr={};C(Xr,{base8:()=>Ma});var Ma=B({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Hr={};C(Hr,{identity:()=>ka});var ka=Je({prefix:"\0",name:"identity",encode:t=>Jo(t),decode:t=>Qo(t)});var Ju=new TextEncoder,Wu=new TextDecoder;var Yr={};C(Yr,{identity:()=>cd});var _a=ni,ti=128,Va=127,qa=~Va,ja=Math.pow(2,31);function ni(t,e,r){e=e||[],r=r||0;for(var n=r;t>=ja;)e[r++]=t&255|ti,t/=128;for(;t&qa;)e[r++]=t&255|ti,t>>>=7;return e[r]=t|0,ni.bytes=r-n+1,e}var Ka=Gr,Xa=128,ri=127;function Gr(t,n){var r=0,n=n||0,o=0,i=n,a,u=t.length;do{if(i>=u)throw Gr.bytes=0,new RangeError("Could not decode varint");a=t[i++],r+=o<28?(a&ri)<<o:(a&ri)*Math.pow(2,o),o+=7}while(a>=Xa);return Gr.bytes=i-n,r}var Ha=Math.pow(2,7),Ga=Math.pow(2,14),Ya=Math.pow(2,21),Qa=Math.pow(2,28),Ja=Math.pow(2,35),Wa=Math.pow(2,42),Za=Math.pow(2,49),ed=Math.pow(2,56),td=Math.pow(2,63),rd=function(t){return t<Ha?1:t<Ga?2:t<Ya?3:t<Qa?4:t<Ja?5:t<Wa?6:t<Za?7:t<ed?8:t<td?9:10},nd={encode:_a,decode:Ka,encodingLength:rd},od=nd,bt=od;var vt=(t,e=0)=>[bt.decode(t,e),bt.decode.bytes],Ze=(t,e,r=0)=>(bt.encode(t,e,r),e),et=t=>bt.encodingLength(t);var Re=(t,e)=>{let r=e.byteLength,n=et(t),o=n+et(r),i=new Uint8Array(o+r);return Ze(t,i,0),Ze(r,i,n),i.set(e,o),new tt(t,r,e,i)},oi=t=>{let e=Q(t),[r,n]=vt(e),[o,i]=vt(e.subarray(n)),a=e.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new tt(r,o,a,e)},ii=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Yo(t.bytes,r.bytes)}},tt=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var si=0,id="identity",ci=Q,sd=t=>Re(si,ci(t)),cd={code:si,name:id,encode:ci,digest:sd};var Zr={};C(Zr,{sha256:()=>ad,sha512:()=>dd});var Wr=Me(Ie("crypto"),1);var Jr=({name:t,code:e,encode:r})=>new Qr(t,e,r),Qr=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?Re(this.code,r):r.then(n=>Re(this.code,n))}else throw Error("Unknown type, must be binary type")}};var ad=Jr({name:"sha2-256",code:18,encode:t=>Q(Wr.default.createHash("sha256").update(t).digest())}),dd=Jr({name:"sha2-512",code:19,encode:t=>Q(Wr.default.createHash("sha512").update(t).digest())});var di=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return hd(r,en(t),e||de.encoder);default:return ud(r,en(t),e||We.encoder)}};var li=new WeakMap,en=t=>{let e=li.get(t);if(e==null){let r=new Map;return li.set(t,r),r}return e},Ft=class t{constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==It)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==pd)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}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:r}=this.multihash,n=Re(e,r);return t.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 t.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&ii(e.multihash,n.multihash)}toString(e){return di(this,e)}toJSON(){return{"/":di(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:a}=r;return new t(n,o,i,a||hi(n,o,i.bytes))}else if(r[md]===!0){let{version:n,multihash:o,code:i}=r,a=oi(o);return t.create(n,i,a)}else return null}static create(e,r,n){if(typeof r!="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(r!==It)throw new Error(`Version 0 CID must use dag-pb (code: ${It}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=hi(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,It,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=Q(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),a=new tt(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(a):t.createV1(r.codec,a),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[w,l]=vt(e.subarray(r));return r+=l,w},o=n(),i=It;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,u=n(),p=n(),m=r+p,x=m-a;return{version:o,codec:i,multihashCode:u,digestSize:p,multihashSize:x,size:m}}static parse(e,r){let[n,o]=ld(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return en(i).set(n,e),i}},ld=(t,e)=>{switch(t[0]){case"Q":{let r=e||de;return[de.prefix,r.decode(`${de.prefix}${t}`)]}case de.prefix:{let r=e||de;return[de.prefix,r.decode(t)]}case We.prefix:{let r=e||We;return[We.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},hd=(t,e,r)=>{let{prefix:n}=r;if(n!==de.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o},ud=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o},It=112,pd=18,hi=(t,e,r)=>{let n=et(t),o=n+et(e),i=new Uint8Array(o+r.byteLength);return Ze(t,i,0),Ze(e,i,n),i.set(r,o),i},md=Symbol.for("@ipld/js-cid/CID");var tn={...Hr,...zr,...Xr,...kr,...$r,...Vr,...qr,...jr,...Kr,..._r},gp={...Zr,...Yr};function rt(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function nt(t=0){return globalThis.Buffer?.allocUnsafe!=null?rt(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function pi(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var ui=pi("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),rn=pi("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=nt(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),gd={utf8:ui,"utf-8":ui,hex:tn.base16,latin1:rn,ascii:rn,binary:rn,...tn},Mt=gd;function q(t,e="utf8"){let r=Mt[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var wd=Math.pow(2,7),yd=Math.pow(2,14),xd=Math.pow(2,21),nn=Math.pow(2,28),on=Math.pow(2,35),sn=Math.pow(2,42),cn=Math.pow(2,49),P=128,k=127;function le(t){if(t<wd)return 1;if(t<yd)return 2;if(t<xd)return 3;if(t<nn)return 4;if(t<on)return 5;if(t<sn)return 6;if(t<cn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function fd(t,e,r=0){switch(le(t)){case 8:e[r++]=t&255|P,t/=128;case 7:e[r++]=t&255|P,t/=128;case 6:e[r++]=t&255|P,t/=128;case 5:e[r++]=t&255|P,t/=128;case 4:e[r++]=t&255|P,t>>>=7;case 3:e[r++]=t&255|P,t>>>=7;case 2:e[r++]=t&255|P,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function bd(t,e,r=0){switch(le(t)){case 8:e.set(r++,t&255|P),t/=128;case 7:e.set(r++,t&255|P),t/=128;case 6:e.set(r++,t&255|P),t/=128;case 5:e.set(r++,t&255|P),t/=128;case 4:e.set(r++,t&255|P),t>>>=7;case 3:e.set(r++,t&255|P),t>>>=7;case 2:e.set(r++,t&255|P),t>>>=7;case 1:{e.set(r++,t&255),t>>>=7;break}default:throw new Error("unreachable")}return e}function vd(t,e){let r=t[e],n=0;if(n+=r&k,r<P||(r=t[e+1],n+=(r&k)<<7,r<P)||(r=t[e+2],n+=(r&k)<<14,r<P)||(r=t[e+3],n+=(r&k)<<21,r<P)||(r=t[e+4],n+=(r&k)*nn,r<P)||(r=t[e+5],n+=(r&k)*on,r<P)||(r=t[e+6],n+=(r&k)*sn,r<P)||(r=t[e+7],n+=(r&k)*cn,r<P))return n;throw new RangeError("Could not decode varint")}function Ed(t,e){let r=t.get(e),n=0;if(n+=r&k,r<P||(r=t.get(e+1),n+=(r&k)<<7,r<P)||(r=t.get(e+2),n+=(r&k)<<14,r<P)||(r=t.get(e+3),n+=(r&k)<<21,r<P)||(r=t.get(e+4),n+=(r&k)*nn,r<P)||(r=t.get(e+5),n+=(r&k)*on,r<P)||(r=t.get(e+6),n+=(r&k)*sn,r<P)||(r=t.get(e+7),n+=(r&k)*cn,r<P))return n;throw new RangeError("Could not decode varint")}function ot(t,e,r=0){return e==null&&(e=nt(le(t))),e instanceof Uint8Array?fd(t,e,r):bd(t,e,r)}function Fe(t,e=0){return t instanceof Uint8Array?vd(t,e):Ed(t,e)}function Ee(t,e){e==null&&(e=t.reduce((o,i)=>o+i.length,0));let r=nt(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return rt(r)}var kt=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let r=this.index,n=e();return n===void 0&&(this.index=r),n}parseWith(e){let r=e();if(this.index===this.input.length)return r}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 r=this.readChar();if(r===e)return r})}readSeparator(e,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,r,n,o){return this.readAtomically(()=>{let i=0,a=0,u=this.peekChar();if(u===void 0)return;let p=u==="0",m=2**(8*o)-1;for(;;){let x=this.readAtomically(()=>{let w=this.readChar();if(w===void 0)return;let l=Number.parseInt(w,e);if(!Number.isNaN(l))return l});if(x===void 0)break;if(i*=e,i+=x,i>m||(a+=1,r!==void 0&&a>r))return}if(a!==0)return!n&&p&&a>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let r=0;r<e.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[r]=n}return e})}readIPv6Addr(){let e=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let a=this.readSeparator(":",n,()=>this.readIPv4Addr());if(a!==void 0)return r[o]=a[0],r[o+1]=a[1],r[o+2]=a[2],r[o+3]=a[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];r[o]=i>>8,r[o+1]=i&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=e(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),a=16-(n+2),[u]=e(i.subarray(0,a));return r.set(i.subarray(0,u),16-u),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Dp=new kt;var $p=parseInt("0xFFFF",16),zp=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var an={};C(an,{base10:()=>Ld});var Ld=Pe({prefix:"9",name:"base10",alphabet:"0123456789"});var dn={};C(dn,{base16:()=>Pd,base16upper:()=>Od});var Pd=N({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Od=N({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ln={};C(ln,{base2:()=>Dd});var Dd=N({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var hn={};C(hn,{base256emoji:()=>Fd});var yi=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}"),Td=yi.reduce((t,e,r)=>(t[r]=e,t),[]),Nd=yi.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Bd(t){return t.reduce((e,r)=>(e+=Td[r],e),"")}function Rd(t){let e=[];for(let r of t){let n=Nd[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var Fd=Xe({prefix:"\u{1F680}",name:"base256emoji",encode:Bd,decode:Rd});var un={};C(un,{base36:()=>Md,base36upper:()=>kd});var Md=Pe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),kd=Pe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var pn={};C(pn,{base64:()=>$d,base64pad:()=>zd,base64url:()=>_d,base64urlpad:()=>Vd});var $d=N({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),zd=N({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),_d=N({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Vd=N({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var mn={};C(mn,{base8:()=>qd});var qd=N({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var gn={};C(gn,{identity:()=>jd});var jd=Xe({prefix:"\0",name:"identity",encode:t=>Mo(t),decode:t=>Fo(t)});var f0=new TextEncoder,b0=new TextDecoder;var wn={};C(wn,{identity:()=>Yd});var xi=0,Hd="identity",fi=Y,Gd=t=>Be(xi,fi(t)),Yd={code:xi,name:Hd,encode:fi,digest:Gd};var bn={};C(bn,{sha256:()=>Qd,sha512:()=>Jd});var fn=Me(Ie("crypto"),1);var xn=({name:t,code:e,encode:r})=>new yn(t,e,r),yn=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?Be(this.code,r):r.then(n=>Be(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Qd=xn({name:"sha2-256",code:18,encode:t=>Y(fn.default.createHash("sha256").update(t).digest())}),Jd=xn({name:"sha2-512",code:19,encode:t=>Y(fn.default.createHash("sha512").update(t).digest())});var vi={...gn,...ln,...mn,...an,...dn,...Dr,...un,...Or,...pn,...hn},P0={...bn,...wn};function vn(t,e="utf8"){let r=Mt[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?rt(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var Ei=Le.isIPv4,Wd=Le.isIPv6,En=function(t){let e=0;if(t=t.toString().trim(),Ei(t)){let r=new Uint8Array(e+4);return t.split(/\./g).forEach(n=>{r[e++]=parseInt(n,10)&255}),r}if(Wd(t)){let r=t.split(":",8),n;for(n=0;n<r.length;n++){let i=Ei(r[n]),a;i&&(a=En(r[n]),r[n]=q(a.slice(0,2),"base16")),a!=null&&++n<8&&r.splice(n,0,q(a.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let i=[n,1];for(n=9-r.length;n>0;n--)i.push("0");r.splice.apply(r,i)}let o=new Uint8Array(e+16);for(n=0;n<r.length;n++){let i=parseInt(r[n],16);o[e++]=i>>8&255,o[e++]=i&255}return o}throw new Error("invalid ip address")},Ii=function(t,e=0,r){e=~~e,r=r??t.length-e;let n=new DataView(t.buffer);if(r===4){let o=[];for(let i=0;i<r;i++)o.push(t[e+i]);return o.join(".")}if(r===16){let o=[];for(let i=0;i<r;i+=2)o.push(n.getUint16(e+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var it={},In={},el=[[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"]];el.forEach(t=>{let e=tl(...t);In[e.code]=e,it[e.name]=e});function tl(t,e,r,n,o){return{code:t,size:e,name:r,resolvable:!!n,path:!!o}}function D(t){if(typeof t=="number"){if(In[t]!=null)return In[t];throw new Error(`no protocol with code: ${t}`)}else if(typeof t=="string"){if(it[t]!=null)return it[t];throw new Error(`no protocol with name: ${t}`)}throw new Error(`invalid protocol id type: ${typeof t}`)}var H0=D("ip4"),G0=D("ip6"),Y0=D("ipcidr");function Sn(t,e){switch(D(t).code){case 4:case 41:return nl(e);case 42:return Ui(e);case 6:case 273:case 33:case 132:return Li(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ui(e);case 421:return cl(e);case 444:return Ci(e);case 445:return Ci(e);case 466:return sl(e);default:return q(e,"base16")}}function Un(t,e){switch(D(t).code){case 4:return Ai(e);case 41:return Ai(e);case 42:return Si(e);case 6:case 273:case 33:case 132:return Cn(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Si(e);case 421:return ol(e);case 444:return al(e);case 445:return dl(e);case 466:return il(e);default:return vn(e,"base16")}}var An=Object.values(vi).map(t=>t.decoder),rl=function(){let t=An[0].or(An[1]);return An.slice(2).forEach(e=>t=t.or(e)),t}();function Ai(t){if(!Ke(t))throw new Error("invalid ip address");return En(t)}function nl(t){let e=Ii(t,0,t.length);if(e==null)throw new Error("ipBuff is required");if(!Ke(e))throw new Error("invalid ip address");return e}function Cn(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function Li(t){return new DataView(t.buffer).getUint16(t.byteOffset)}function Si(t){let e=vn(t),r=Uint8Array.from(ot(e.length));return Ee([r,e],r.length+e.length)}function Ui(t){let e=Fe(t);if(t=t.slice(le(e)),t.length!==e)throw new Error("inconsistent lengths");return q(t)}function ol(t){let e;t[0]==="Q"||t[0]==="1"?e=Bt(V.decode(`z${t}`)).bytes:e=Oe.parse(t).multihash.bytes;let r=Uint8Array.from(ot(e.length));return Ee([r,e],r.length+e.length)}function il(t){let e=rl.decode(t),r=Uint8Array.from(ot(e.length));return Ee([r,e],r.length+e.length)}function sl(t){let e=Fe(t),r=t.slice(le(e));if(r.length!==e)throw new Error("inconsistent lengths");return"u"+q(r,"base64url")}function cl(t){let e=Fe(t),r=t.slice(le(e));if(r.length!==e)throw new Error("inconsistent lengths");return q(r,"base58btc")}function al(t){let e=t.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 r=ve.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Cn(n);return Ee([r,o],r.length+o.length)}function dl(t){let e=t.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 r=ve.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Cn(n);return Ee([r,o],r.length+o.length)}function Ci(t){let e=t.slice(0,t.length-2),r=t.slice(t.length-2),n=q(e,"base32"),o=Li(r);return`${n}:${o}`}function Pi(t){t=Ln(t);let e=[],r=[],n=null,o=t.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let a=o[i],u=D(a);if(u.size===0){e.push([u.code]),r.push([u.code]);continue}if(i++,i>=o.length)throw Di("invalid address: "+t);if(u.path===!0){n=Ln(o.slice(i).join("/")),e.push([u.code,Un(u.code,n)]),r.push([u.code,n]);break}let p=Un(u.code,o[i]);e.push([u.code,p]),r.push([u.code,Sn(u.code,p)])}return{string:Oi(r),bytes:On(e),tuples:e,stringTuples:r,path:n}}function Pn(t){let e=[],r=[],n=null,o=0;for(;o<t.length;){let i=Fe(t,o),a=le(i),u=D(i),p=ll(u,t.slice(o+a));if(p===0){e.push([i]),r.push([i]),o+=a;continue}let m=t.slice(o+a,o+a+p);if(o+=p+a,o>t.length)throw Di("Invalid address Uint8Array: "+q(t,"base16"));e.push([i,m]);let x=Sn(i,m);if(r.push([i,x]),u.path===!0){n=x;break}}return{bytes:Uint8Array.from(t),string:Oi(r),tuples:e,stringTuples:r,path:n}}function Oi(t){let e=[];return t.map(r=>{let n=D(r[0]);return e.push(n.name),r.length>1&&r[1]!=null&&e.push(r[1]),null}),Ln(e.join("/"))}function On(t){return Ee(t.map(e=>{let r=D(e[0]),n=Uint8Array.from(ot(r.code));return e.length>1&&e[1]!=null&&(n=Ee([n,e[1]])),n}))}function ll(t,e){if(t.size>0)return t.size/8;if(t.size===0)return 0;{let r=Fe(e instanceof Uint8Array?e:Uint8Array.from(e));return r+le(r)}}function Ln(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}function Di(t){return new Error("Error parsing address: "+t)}var hl=Symbol.for("nodejs.util.inspect.custom"),Dn=Symbol.for("@multiformats/js-multiaddr/multiaddr"),ul=[D("dns").code,D("dns4").code,D("dns6").code,D("dnsaddr").code],$t=class t{bytes;#e;#t;#r;#n;[Dn]=!0;constructor(e){e==null&&(e="");let r;if(e instanceof Uint8Array)r=Pn(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);r=Pi(e)}else if(Ni(e))r=Pn(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.bytes,this.#e=r.string,this.#t=r.tuples,this.#r=r.stringTuples,this.#n=r.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,r,n,o,i="",a=D("tcp"),u=D("udp"),p=D("ip4"),m=D("ip6"),x=D("dns6"),w=D("ip6zone");for(let[c,s]of this.stringTuples())c===w.code&&(i=`%${s??""}`),ul.includes(c)&&(r=a.name,o=443,n=`${s??""}${i}`,e=c===x.code?6:4),(c===a.code||c===u.code)&&(r=D(c).name,o=parseInt(s??"")),(c===p.code||c===m.code)&&(r=D(c).name,n=`${s??""}${i}`,e=c===m.code?6:4);if(e==null||r==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:r,port:o}}protos(){return this.#t.map(([e])=>Object.assign({},D(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>D(e).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(e){return e=new t(e),new t(this.toString()+e.toString())}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new t(n.slice(0,o))}decapsulateCode(e){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===e)return new t(On(r.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===it.p2p.code&&e.push([n,o]),n===it["p2p-circuit"].code&&(e=[])});let r=e.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?q(V.decode(`z${n}`),"base58btc"):q(Oe.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return Ho(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(i=>i.resolvable);if(r==null)return[this];let n=Ti.get(r.name);if(n==null)throw new st(`no available resolver for ${r.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(i=>new t(i))}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 r=(e??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[hl](){return`Multiaddr(${this.#e})`}};var Ti=new Map;function Ni(t){return!!t?.[Dn]}function Tn(t){return new $t(t)}function Bi(t,e,r,n){let o=()=>{n?.log.trace("query",e),t.query({questions:[{name:e,type:"PTR"}]})};return o(),setInterval(o,r)}function Ri(t,e,r,n){if(t.answers==null)return;let o,i=[];if(t.answers.forEach(a=>{switch(a.type){case"PTR":o=a;break;case"TXT":i.push(a);break;default:break}}),t.additionals.forEach(a=>{switch(a.type){case"TXT":i.push(a);break;default:break}}),!(o==null||o?.name!==r||i.length===0||o.data.startsWith(e)))try{let a=i.flatMap(p=>p.data).filter(p=>p.toString().startsWith("dnsaddr=")).map(p=>Tn(p.toString().substring(8))),u=a[0].getPeerId();if(u==null)throw new Error("Multiaddr doesn't contain PeerId");return n?.log("peer found %p",u),{id:Ar(u),multiaddrs:a.map(p=>p.decapsulateCode(D("p2p").code))}}catch(a){n?.log.error("failed to parse mdns response",a)}}function Fi(t,e,r,n,o,i,a){if(!i){a?.log("not responding to mDNS query as broadcast mode is false");return}if(n.length!==0&&t.questions[0]!=null&&t.questions[0].name===o){let u=[];u.push({name:o,type:"PTR",class:"IN",ttl:120,data:r+"."+o}),n.filter(pl).forEach(p=>{let m="dnsaddr="+p.toString();if(m.length>255){a?.log("multiaddr %a is too long to use in mDNS query response",p);return}if(p.getPeerId()==null){a?.log("multiaddr %a did not have a peer ID so cannot be used in mDNS query response",p);return}u.push({name:r+"."+o,type:"TXT",class:"IN",ttl:120,data:m})}),a?.log.trace("responding to query"),e.respond(u)}}function pl(t){return!!No(t)}function Mi(t){let e="",r="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<t;n++)e+=r.charAt(Math.floor(Math.random()*r.length));return e}var zt=class extends St{mdns;log;broadcast;interval;serviceTag;peerName;port;ip;_queryInterval;components;constructor(e,r={}){if(super(),this.log=e.logger.forComponent("libp2p:mdns"),this.broadcast=r.broadcast!==!1,this.interval=r.interval??1e3*10,this.serviceTag=r.serviceTag??"_p2p._udp.local",this.ip=r.ip??"224.0.0.251",this.peerName=r.peerName??Mi(63),this.peerName.length>=64)throw new Error("Peer name should be less than 64 chars long");this.port=r.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)}[Bn]=this;[Symbol.toStringTag]="@libp2p/mdns";isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,ki.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=Bi(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),Fi(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 r=Ri(e,this.peerName,this.serviceTag,{log:this.log});r!=null&&(this.log("discovered peer in mDNS query response %p",r.id),this.dispatchEvent(new Vt("peer",{detail:r})))}catch(r){this.log.error("Error processing peer response",r)}}_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 gl(t={}){return e=>new zt(e,t)}return ji(wl);})();
|
|
14
14
|
return Libp2PMdns}));
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/mdns",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.8-4e0135c7d",
|
|
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,19 +49,19 @@
|
|
|
49
49
|
"test:electron-main": "aegir test -t electron-main"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@libp2p/interface": "
|
|
53
|
-
"@libp2p/peer-id": "
|
|
54
|
-
"@libp2p/utils": "
|
|
52
|
+
"@libp2p/interface": "1.0.2-4e0135c7d",
|
|
53
|
+
"@libp2p/peer-id": "4.0.2-4e0135c7d",
|
|
54
|
+
"@libp2p/utils": "5.1.0-4e0135c7d",
|
|
55
55
|
"@multiformats/multiaddr": "^12.1.10",
|
|
56
56
|
"@types/multicast-dns": "^7.2.1",
|
|
57
57
|
"dns-packet": "^5.4.0",
|
|
58
58
|
"multicast-dns": "^7.2.5"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@libp2p/interface-compliance-tests": "
|
|
62
|
-
"@libp2p/interface-internal": "
|
|
63
|
-
"@libp2p/logger": "
|
|
64
|
-
"@libp2p/peer-id-factory": "
|
|
61
|
+
"@libp2p/interface-compliance-tests": "5.0.8-4e0135c7d",
|
|
62
|
+
"@libp2p/interface-internal": "1.0.3-4e0135c7d",
|
|
63
|
+
"@libp2p/logger": "4.0.2-4e0135c7d",
|
|
64
|
+
"@libp2p/peer-id-factory": "4.0.1-4e0135c7d",
|
|
65
65
|
"aegir": "^41.0.2",
|
|
66
66
|
"p-wait-for": "^5.0.2",
|
|
67
67
|
"sinon-ts": "^2.0.0"
|
package/src/index.ts
CHANGED
package/dist/typedoc-urls.json
DELETED