@libp2p/mdns 11.0.46 → 11.0.47-6059227cb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/query.js +5 -5
- package/dist/src/query.js.map +1 -1
- package/package.json +11 -10
- package/src/query.ts +5 -5
- package/dist/typedoc-urls.json +0 -6
package/dist/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PMdns = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PMdns=(()=>{var _c=Object.create;var Sr=Object.defineProperty;var Pc=Object.getOwnPropertyDescriptor;var Oc=Object.getOwnPropertyNames;var Nc=Object.getPrototypeOf,Rc=Object.prototype.hasOwnProperty;var ae=(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 _e=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),pe=(t,e)=>{for(var r in e)Sr(t,r,{get:e[r],enumerable:!0})},Jo=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Oc(e))!Rc.call(t,o)&&o!==r&&Sr(t,o,{get:()=>e[o],enumerable:!(n=Pc(e,o))||n.enumerable});return t};var Ut=(t,e,r)=>(r=t!=null?_c(Nc(t)):{},Jo(e||!t||!t.__esModule?Sr(r,"default",{value:t,enumerable:!0}):r,t)),kc=t=>Jo(Sr({},"__esModule",{value:!0}),t);var oi=_e(ln=>{"use strict";ln.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};ln.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 ii=_e(hn=>{"use strict";hn.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};hn.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 si=_e(pn=>{"use strict";pn.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};pn.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 ci=_e(fn=>{"use strict";fn.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};fn.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 ai=_e(mn=>{"use strict";mn.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}`};mn.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 li=_e((di,gn)=>{var ui=function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=d,t.encode=l,t.familyOf=u,t.name=void 0,t.sizeOf=a,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:h=>e.test(h),encode(h,f,p){p=~~p,f=f||new Uint8Array(p+r);let g=h.length,U=0;for(let P=0;P<g;){let N=h.charCodeAt(P++);N===46?(f[p++]=U,U=0):U=U*10+(N-48)}return f[p]=U,f},decode(h,f){return f=~~f,`${h[f++]}.${h[f++]}.${h[f++]}.${h[f]}`}};t.v4=i;let s={name:"v6",size:o,isFormat:h=>h.length>0&&n.test(h),encode(h,f,p){p=~~p;let g=p+o,U=-1,P=0,N=0,F=!0,H=!1;f=f||new Uint8Array(p+o);for(let S=0;S<h.length;S++){let k=h.charCodeAt(S);k===58?(F?U!==-1?(p<g&&(f[p]=0),p<g-1&&(f[p+1]=0),p+=2):p<g&&(U=p):(H===!0?(p<g&&(f[p]=N),p++):(p<g&&(f[p]=P>>8),p<g-1&&(f[p+1]=P&255),p+=2),P=0,N=0),F=!0,H=!1):k===46?(p<g&&(f[p]=N),p++,N=0,P=0,F=!1,H=!0):(F=!1,k>=97?k-=87:k>=65?k-=55:(k-=48,N=N*10+k),P=(P<<4)+k)}if(F===!1)H===!0?(p<g&&(f[p]=N),p++):(p<g&&(f[p]=P>>8),p<g-1&&(f[p+1]=P&255),p+=2);else if(U===0)p<g&&(f[p]=0),p<g-1&&(f[p+1]=0),p+=2;else if(U!==-1){p+=2;for(let S=Math.min(p-1,g-1);S>=U+2;S--)f[S]=f[S-2];f[U]=0,f[U+1]=0,U=p}if(U!==p&&U!==-1)for(p>g-2&&(p=g-2);g>U;)f[--g]=p<g&&p>U?f[--p]:0;else for(;p<g;)f[p++]=0;return f},decode(h,f){f=~~f;let p="";for(let g=0;g<o;g+=2)g!==0&&(p+=":"),p+=(h[f+g]<<8|h[f+g+1]).toString(16);return p.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};t.v6=s;let c="ip";t.name=c;function a(h){if(i.isFormat(h))return i.size;if(s.isFormat(h))return s.size;throw Error(`Invalid ip address: ${h}`)}function u(h){return a(h)===i.size?1:2}function l(h,f,p){p=~~p;let g=a(h);return typeof f=="function"&&(f=f(p+g)),g===i.size?i.encode(h,f,p):s.encode(h,f,p)}function d(h,f,p){if(f=~~f,p=p||h.length-f,p===i.size)return i.decode(h,f,p);if(p===s.size)return s.decode(h,f,p);throw Error(`Invalid buffer size needs to be ${i.size} for v4 or ${s.size} for v6.`)}return"default"in t?t.default:t}({});typeof define=="function"&&define.amd?define([],function(){return ui}):typeof gn=="object"&&typeof di=="object"&&(gn.exports=ui)});var fi=_e(I=>{"use strict";var v=ae("buffer").Buffer,Je=oi(),Kc=ii(),Mc=si(),Tr=ci(),yn=ai(),pt=li(),Fc=0,hi=32768,wn=32768,Hc=~wn,pi=32768,qc=~pi,x=I.name={};x.encode=function(t,e,r,{mail:n=!1}={}){e||(e=v.alloc(x.encodingLength(t))),r||(r=0);let o=r,i=t.replace(/^\.|\.$/gm,"");if(i.length){let s=[];if(n){let c="";i.split(".").forEach(a=>{a.endsWith("\\")?c+=(c.length?".":"")+a.slice(0,-1):s.length===0&&c.length?s.push(c+"."+a):s.push(a)})}else s=i.split(".");for(let c=0;c<s.length;c++){let a=e.write(s[c],r+1);e[r]=a,r+=a+1}}return e[r++]=0,x.encode.bytes=r-o,e};x.encode.bytes=0;x.decode=function(t,e,{mail:r=!1}={}){e||(e=0);let n=[],o=e,i=0,s=0,c=!1;for(;;){if(e>=t.length)throw new Error("Cannot decode name (buffer overflow)");let a=t[e++];if(s+=c?0:1,a===0)break;if((a&192)===0){if(e+a>t.length)throw new Error("Cannot decode name (buffer overflow)");if(i+=a+1,i>254)throw new Error("Cannot decode name (name too long)");let u=t.toString("utf-8",e,e+a);r&&(u=u.replace(/\./g,"\\.")),n.push(u),e+=a,s+=c?0:a}else if((a&192)===192){if(e+1>t.length)throw new Error("Cannot decode name (buffer overflow)");let u=t.readUInt16BE(e-1)-49152;if(u>=o)throw new Error("Cannot decode name (bad pointer)");e=u,o=u,s+=c?0:1,c=!0}else throw new Error("Cannot decode name (bad label)")}return x.decode.bytes=s,n.length===0?".":n.join(".")};x.decode.bytes=0;x.encodingLength=function(t){return t==="."||t===".."?1:v.byteLength(t.replace(/^\.|\.$/gm,""))+2};var _={};_.encode=function(t,e,r){e||(e=v.alloc(_.encodingLength(t))),r||(r=0);let n=e.write(t,r+1);return e[r]=n,_.encode.bytes=n+1,e};_.encode.bytes=0;_.decode=function(t,e){e||(e=0);let r=t[e],n=t.toString("utf-8",e+1,e+1+r);return _.decode.bytes=r+1,n};_.decode.bytes=0;_.encodingLength=function(t){return v.byteLength(t)+1};var Ce={};Ce.encode=function(t,e,r){e||(e=Ce.encodingLength(t)),r||(r=0);let n=(t.flags||0)&32767,o=t.type==="response"?hi:Fc;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};Ce.encode.bytes=12;Ce.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&hi?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:Mc.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:Kc.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))}};Ce.decode.bytes=12;Ce.encodingLength=function(){return 12};var ze=I.unknown={};ze.encode=function(t,e,r){return e||(e=v.alloc(ze.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.length,r),t.copy(e,r+2),ze.encode.bytes=t.length+2,e};ze.encode.bytes=0;ze.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=t.slice(e+2,e+2+r);return ze.decode.bytes=r+2,n};ze.decode.bytes=0;ze.encodingLength=function(t){return t.length+2};var je=I.ns={};je.encode=function(t,e,r){return e||(e=v.alloc(je.encodingLength(t))),r||(r=0),x.encode(t,e,r+2),e.writeUInt16BE(x.encode.bytes,r),je.encode.bytes=x.encode.bytes+2,e};je.encode.bytes=0;je.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=x.decode(t,e+2);return je.decode.bytes=r+2,n};je.decode.bytes=0;je.encodingLength=function(t){return x.encodingLength(t)+2};var $e=I.soa={};$e.encode=function(t,e,r){e||(e=v.alloc($e.encodingLength(t))),r||(r=0);let n=r;return r+=2,x.encode(t.mname,e,r),r+=x.encode.bytes,x.encode(t.rname,e,r,{mail:!0}),r+=x.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),$e.encode.bytes=r-n,e};$e.encode.bytes=0;$e.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=x.decode(t,e),e+=x.decode.bytes,n.rname=x.decode(t,e,{mail:!0}),e+=x.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,$e.decode.bytes=e-r,n};$e.decode.bytes=0;$e.encodingLength=function(t){return 22+x.encodingLength(t.mname)+x.encodingLength(t.rname)};var Ge=I.txt={};Ge.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]=v.from(t[o])),!v.isBuffer(t[o]))throw new Error("Must be a Buffer");e||(e=v.alloc(Ge.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),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=[];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 Ge.decode.bytes=e-r,o};Ge.decode.bytes=0;Ge.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 We=I.null={};We.encode=function(t,e,r){e||(e=v.alloc(We.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=v.from(t)),t||(t=v.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),We.encode.bytes=r-n,e};We.encode.bytes=0;We.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,We.decode.bytes=e-r,o};We.decode.bytes=0;We.encodingLength=function(t){return t?(v.isBuffer(t)?t.length:v.byteLength(t))+2:2};var Ye=I.hinfo={};Ye.encode=function(t,e,r){e||(e=v.alloc(Ye.encodingLength(t))),r||(r=0);let n=r;return r+=2,_.encode(t.cpu,e,r),r+=_.encode.bytes,_.encode(t.os,e,r),r+=_.encode.bytes,e.writeUInt16BE(r-n-2,n),Ye.encode.bytes=r-n,e};Ye.encode.bytes=0;Ye.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.cpu=_.decode(t,e),e+=_.decode.bytes,n.os=_.decode(t,e),e+=_.decode.bytes,Ye.decode.bytes=e-r,n};Ye.decode.bytes=0;Ye.encodingLength=function(t){return _.encodingLength(t.cpu)+_.encodingLength(t.os)+2};var Ae=I.ptr={},Vc=I.cname=Ae,zc=I.dname=Ae;Ae.encode=function(t,e,r){return e||(e=v.alloc(Ae.encodingLength(t))),r||(r=0),x.encode(t,e,r+2),e.writeUInt16BE(x.encode.bytes,r),Ae.encode.bytes=x.encode.bytes+2,e};Ae.encode.bytes=0;Ae.decode=function(t,e){e||(e=0);let r=x.decode(t,e+2);return Ae.decode.bytes=x.decode.bytes+2,r};Ae.decode.bytes=0;Ae.encodingLength=function(t){return x.encodingLength(t)+2};var Ze=I.srv={};Ze.encode=function(t,e,r){e||(e=v.alloc(Ze.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),x.encode(t.target,e,r+8);let n=x.encode.bytes+6;return e.writeUInt16BE(n,r),Ze.encode.bytes=n+2,e};Ze.encode.bytes=0;Ze.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=x.decode(t,e+8),Ze.decode.bytes=r+2,n};Ze.decode.bytes=0;Ze.encodingLength=function(t){return 8+x.encodingLength(t.target)};var fe=I.caa={};fe.ISSUER_CRITICAL=128;fe.encode=function(t,e,r){let n=fe.encodingLength(t);return e||(e=v.alloc(fe.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=fe.ISSUER_CRITICAL),e.writeUInt16BE(n-2,r),r+=2,e.writeUInt8(t.flags||0,r),r+=1,_.encode(t.tag,e,r),r+=_.encode.bytes,e.write(t.value,r),r+=v.byteLength(t.value),fe.encode.bytes=n,e};fe.encode.bytes=0;fe.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=_.decode(t,e),e+=_.decode.bytes,o.value=t.toString("utf-8",e,n+r),o.issuerCritical=!!(o.flags&fe.ISSUER_CRITICAL),fe.decode.bytes=r+2,o};fe.decode.bytes=0;fe.encodingLength=function(t){return _.encodingLength(t.tag)+_.encodingLength(t.value)+2};var st=I.mx={};st.encode=function(t,e,r){e||(e=v.alloc(st.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,x.encode(t.exchange,e,r),r+=x.encode.bytes,e.writeUInt16BE(r-n-2,n),st.encode.bytes=r-n,e};st.encode.bytes=0;st.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.preference=t.readUInt16BE(e),e+=2,n.exchange=x.decode(t,e),e+=x.decode.bytes,st.decode.bytes=e-r,n};st.encodingLength=function(t){return 4+x.encodingLength(t.exchange)};var Xe=I.a={};Xe.encode=function(t,e,r){return e||(e=v.alloc(Xe.encodingLength(t))),r||(r=0),e.writeUInt16BE(4,r),r+=2,pt.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=pt.v4.decode(t,e);return Xe.decode.bytes=6,r};Xe.decode.bytes=0;Xe.encodingLength=function(){return 6};var Qe=I.aaaa={};Qe.encode=function(t,e,r){return e||(e=v.alloc(Qe.encodingLength(t))),r||(r=0),e.writeUInt16BE(16,r),r+=2,pt.v6.encode(t,e,r),Qe.encode.bytes=18,e};Qe.encode.bytes=0;Qe.decode=function(t,e){e||(e=0),e+=2;let r=pt.v6.decode(t,e);return Qe.decode.bytes=18,r};Qe.decode.bytes=0;Qe.encodingLength=function(){return 18};var ue=I.option={};ue.encode=function(t,e,r){e||(e=v.alloc(ue.encodingLength(t))),r||(r=0);let n=r,o=yn.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,s=t.family||pt.familyOf(t.ip),c=pt.encode(t.ip,v.alloc),a=Math.ceil(i/8);e.writeUInt16BE(a+4,r),r+=2,e.writeUInt16BE(s,r),r+=2,e.writeUInt8(i,r++),e.writeUInt8(t.scopePrefixLength||0,r++),c.copy(e,r,0,a),r+=a;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 u=t.length||0;e.writeUInt16BE(u,r),r+=2,e.fill(0,r,r+u),r+=u;break;case 14:let l=t.tags.length*2;e.writeUInt16BE(l,r),r+=2;for(let d of t.tags)e.writeUInt16BE(d,r),r+=2;break;default:throw new Error(`Unknown roption code: ${t.code}`)}return ue.encode.bytes=r-n,e};ue.encode.bytes=0;ue.decode=function(t,e){e||(e=0);let r={};r.code=t.readUInt16BE(e),r.type=yn.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=v.alloc(r.family===1?4:16);t.copy(o,0,e,e+n-4),r.ip=pt.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 ue.decode.bytes=n+4,r};ue.decode.bytes=0;ue.encodingLength=function(t){if(t.data)return t.data.length+4;switch(yn.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 ge=I.opt={};ge.encode=function(t,e,r){e||(e=v.alloc(ge.encodingLength(t))),r||(r=0);let n=r,o=Lt(t,ue);return e.writeUInt16BE(o,r),r=Yt(t,ue,e,r+2),ge.encode.bytes=r-n,e};ge.encode.bytes=0;ge.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++]=ue.decode(t,e),e+=ue.decode.bytes,o-=ue.decode.bytes;return ge.decode.bytes=e-r,n};ge.decode.bytes=0;ge.encodingLength=function(t){return 2+Lt(t||[],ue)};var se=I.dnskey={};se.PROTOCOL_DNSSEC=3;se.ZONE_KEY=128;se.SECURE_ENTRYPOINT=32768;se.encode=function(t,e,r){e||(e=v.alloc(se.encodingLength(t))),r||(r=0);let n=r,o=t.key;if(!v.isBuffer(o))throw new Error("Key must be a Buffer");return r+=2,e.writeUInt16BE(t.flags,r),r+=2,e.writeUInt8(se.PROTOCOL_DNSSEC,r),r+=1,e.writeUInt8(t.algorithm,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);if(e+=2,n.flags=t.readUInt16BE(e),e+=2,t.readUInt8(e)!==se.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,se.decode.bytes=e-r,n};se.decode.bytes=0;se.encodingLength=function(t){return 6+v.byteLength(t.key)};var Oe=I.rrsig={};Oe.encode=function(t,e,r){e||(e=v.alloc(Oe.encodingLength(t))),r||(r=0);let n=r,o=t.signature;if(!v.isBuffer(o))throw new Error("Signature must be a Buffer");return r+=2,e.writeUInt16BE(Je.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,x.encode(t.signersName,e,r),r+=x.encode.bytes,o.copy(e,r,0,o.length),r+=o.length,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.typeCovered=Je.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=x.decode(t,e),e+=x.decode.bytes,n.signature=t.slice(e,r+o+2),e+=n.signature.length,Oe.decode.bytes=e-r,n};Oe.decode.bytes=0;Oe.encodingLength=function(t){return 20+x.encodingLength(t.signersName)+v.byteLength(t.signature)};var Ne=I.rp={};Ne.encode=function(t,e,r){e||(e=v.alloc(Ne.encodingLength(t))),r||(r=0);let n=r;return r+=2,x.encode(t.mbox||".",e,r,{mail:!0}),r+=x.encode.bytes,x.encode(t.txt||".",e,r),r+=x.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=x.decode(t,e,{mail:!0})||".",e+=x.decode.bytes,n.txt=x.decode(t,e)||".",e+=x.decode.bytes,Ne.decode.bytes=e-r,n};Ne.decode.bytes=0;Ne.encodingLength=function(t){return 2+x.encodingLength(t.mbox||".")+x.encodingLength(t.txt||".")};var Z={};Z.encode=function(t,e,r){e||(e=v.alloc(Z.encodingLength(t))),r||(r=0);let n=r;for(var o=[],i=0;i<t.length;i++){var s=Je.toType(t[i]);o[s>>8]===void 0&&(o[s>>8]=[]),o[s>>8][s>>3&31]|=1<<7-(s&7)}for(i=0;i<o.length;i++)if(o[i]!==void 0){var c=v.from(o[i]);e.writeUInt8(i,r),r+=1,e.writeUInt8(c.length,r),r+=1,c.copy(e,r),r+=c.length}return Z.encode.bytes=r-n,e};Z.encode.bytes=0;Z.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 s=t.readUInt8(e);e+=1;for(var c=0;c<s;c++)for(var a=t.readUInt8(e+c),u=0;u<8;u++)if(a&1<<7-u){var l=Je.toString(i<<8|c<<3|u);o.push(l)}e+=s}return Z.decode.bytes=e-n,o};Z.decode.bytes=0;Z.encodingLength=function(t){for(var e=[],r=0;r<t.length;r++){var n=Je.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 Re=I.nsec={};Re.encode=function(t,e,r){e||(e=v.alloc(Re.encodingLength(t))),r||(r=0);let n=r;return r+=2,x.encode(t.nextDomain,e,r),r+=x.encode.bytes,Z.encode(t.rrtypes,e,r),r+=Z.encode.bytes,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.nextDomain=x.decode(t,e),e+=x.decode.bytes,n.rrtypes=Z.decode(t,e,o-(e-r)),e+=Z.decode.bytes,Re.decode.bytes=e-r,n};Re.decode.bytes=0;Re.encodingLength=function(t){return 2+x.encodingLength(t.nextDomain)+Z.encodingLength(t.rrtypes)};var ke=I.nsec3={};ke.encode=function(t,e,r){e||(e=v.alloc(ke.encodingLength(t))),r||(r=0);let n=r,o=t.salt;if(!v.isBuffer(o))throw new Error("salt must be a Buffer");let i=t.nextDomain;if(!v.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,Z.encode(t.rrtypes,e,r),r+=Z.encode.bytes,ke.encode.bytes=r-n,e.writeUInt16BE(ke.encode.bytes-2,n),e};ke.encode.bytes=0;ke.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 s=t.readUInt8(e);return e+=1,n.nextDomain=t.slice(e,e+s),e+=s,n.rrtypes=Z.decode(t,e,o-(e-r)),e+=Z.decode.bytes,ke.decode.bytes=e-r,n};ke.decode.bytes=0;ke.encodingLength=function(t){return 8+t.salt.length+t.nextDomain.length+Z.encodingLength(t.rrtypes)};var Ke=I.ds={};Ke.encode=function(t,e,r){e||(e=v.alloc(Ke.encodingLength(t))),r||(r=0);let n=r,o=t.digest;if(!v.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,Ke.encode.bytes=r-n,e.writeUInt16BE(Ke.encode.bytes-2,n),e};Ke.encode.bytes=0;Ke.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,Ke.decode.bytes=e-r,n};Ke.decode.bytes=0;Ke.encodingLength=function(t){return 6+v.byteLength(t.digest)};var me=I.sshfp={};me.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};me.encode=function(e,r,n){r||(r=v.alloc(me.encodingLength(e))),n||(n=0);let o=n;n+=2,r[n]=e.algorithm,n+=1,r[n]=e.hash,n+=1;let i=v.from(e.fingerprint.toUpperCase(),"hex");if(i.length!==me.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return i.copy(r,n),n+=i.byteLength,me.encode.bytes=n-o,r.writeUInt16BE(me.encode.bytes-2,o),r};me.encode.bytes=0;me.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=me.getFingerprintLengthForHashType(o.hash);return o.fingerprint=e.slice(r,r+i).toString("hex").toUpperCase(),r+=i,me.decode.bytes=r-n,o};me.decode.bytes=0;me.encodingLength=function(t){return 4+v.from(t.fingerprint,"hex").byteLength};var Me=I.naptr={};Me.encode=function(t,e,r){e||(e=v.alloc(Me.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,_.encode(t.flags,e,r),r+=_.encode.bytes,_.encode(t.services,e,r),r+=_.encode.bytes,_.encode(t.regexp,e,r),r+=_.encode.bytes,x.encode(t.replacement,e,r),r+=x.encode.bytes,Me.encode.bytes=r-n,e.writeUInt16BE(Me.encode.bytes-2,n),e};Me.encode.bytes=0;Me.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=_.decode(t,e),e+=_.decode.bytes,n.services=_.decode(t,e),e+=_.decode.bytes,n.regexp=_.decode(t,e),e+=_.decode.bytes,n.replacement=x.decode(t,e),e+=x.decode.bytes,Me.decode.bytes=e-r,n};Me.decode.bytes=0;Me.encodingLength=function(t){return _.encodingLength(t.flags)+_.encodingLength(t.services)+_.encodingLength(t.regexp)+x.encodingLength(t.replacement)+6};var Fe=I.tlsa={};Fe.encode=function(t,e,r){e||(e=v.alloc(Fe.encodingLength(t))),r||(r=0);let n=r,o=t.certificate;if(!v.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,Fe.encode.bytes=r-n,e.writeUInt16BE(Fe.encode.bytes-2,n),e};Fe.encode.bytes=0;Fe.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,Fe.decode.bytes=e-r,n};Fe.decode.bytes=0;Fe.encodingLength=function(t){return 5+v.byteLength(t.certificate)};var xn=I.record=function(t){switch(t.toUpperCase()){case"A":return Xe;case"PTR":return Ae;case"CNAME":return Vc;case"DNAME":return zc;case"TXT":return Ge;case"NULL":return We;case"AAAA":return Qe;case"SRV":return Ze;case"HINFO":return Ye;case"CAA":return fe;case"NS":return je;case"SOA":return $e;case"MX":return st;case"OPT":return ge;case"DNSKEY":return se;case"RRSIG":return Oe;case"RP":return Ne;case"NSEC":return Re;case"NSEC3":return ke;case"SSHFP":return me;case"DS":return Ke;case"NAPTR":return Me;case"TLSA":return Fe}return ze},Q=I.answer={};Q.encode=function(t,e,r){e||(e=v.alloc(Q.encodingLength(t))),r||(r=0);let n=r;if(x.encode(t.name,e,r),r+=x.encode.bytes,e.writeUInt16BE(Je.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,ge.encode(t.options||[],e,r),r+=ge.encode.bytes}else{let o=Tr.toClass(t.class===void 0?"IN":t.class);t.flush&&(o|=wn),e.writeUInt16BE(o,r+2),e.writeUInt32BE(t.ttl||0,r+4),r+=8;let i=xn(t.type);i.encode(t.data,e,r),r+=i.encode.bytes}return Q.encode.bytes=r-n,e};Q.encode.bytes=0;Q.decode=function(t,e){e||(e=0);let r={},n=e;if(r.name=x.decode(t,e),e+=x.decode.bytes,r.type=Je.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=ge.decode(t,e+8),e+=8+ge.decode.bytes;else{let o=t.readUInt16BE(e+2);r.ttl=t.readUInt32BE(e+4),r.class=Tr.toString(o&Hc),r.flush=!!(o&wn);let i=xn(r.type);r.data=i.decode(t,e+8),e+=8+i.decode.bytes}return Q.decode.bytes=e-n,r};Q.decode.bytes=0;Q.encodingLength=function(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return x.encodingLength(t.name)+8+xn(t.type).encodingLength(e)};var Be=I.question={};Be.encode=function(t,e,r){e||(e=v.alloc(Be.encodingLength(t))),r||(r=0);let n=r;return x.encode(t.name,e,r),r+=x.encode.bytes,e.writeUInt16BE(Je.toType(t.type),r),r+=2,e.writeUInt16BE(Tr.toClass(t.class===void 0?"IN":t.class),r),r+=2,Be.encode.bytes=r-n,t};Be.encode.bytes=0;Be.decode=function(t,e){e||(e=0);let r=e,n={};return n.name=x.decode(t,e),e+=x.decode.bytes,n.type=Je.toString(t.readUInt16BE(e)),e+=2,n.class=Tr.toString(t.readUInt16BE(e)),e+=2,!!(n.class&pi)&&(n.class&=qc),Be.decode.bytes=e-r,n};Be.decode.bytes=0;Be.encodingLength=function(t){return x.encodingLength(t.name)+4};I.AUTHORITATIVE_ANSWER=1024;I.TRUNCATED_RESPONSE=512;I.RECURSION_DESIRED=256;I.RECURSION_AVAILABLE=128;I.AUTHENTIC_DATA=32;I.CHECKING_DISABLED=16;I.DNSSEC_OK=32768;I.encode=function(t,e,r){let n=!e;n&&(e=v.alloc(I.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=[]),Ce.encode(t,e,r),r+=Ce.encode.bytes,r=Yt(t.questions,Be,e,r),r=Yt(t.answers,Q,e,r),r=Yt(t.authorities,Q,e,r),r=Yt(t.additionals,Q,e,r),I.encode.bytes=r-o,n&&I.encode.bytes!==e.length?e.slice(0,I.encode.bytes):e};I.encode.bytes=0;I.decode=function(t,e){e||(e=0);let r=e,n=Ce.decode(t,e);return e+=Ce.decode.bytes,e=Lr(n.questions,Be,t,e),e=Lr(n.answers,Q,t,e),e=Lr(n.authorities,Q,t,e),e=Lr(n.additionals,Q,t,e),I.decode.bytes=e-r,n};I.decode.bytes=0;I.encodingLength=function(t){return Ce.encodingLength(t)+Lt(t.questions||[],Be)+Lt(t.answers||[],Q)+Lt(t.authorities||[],Q)+Lt(t.additionals||[],Q)};I.streamEncode=function(t){let e=I.encode(t),r=v.alloc(2);r.writeUInt16BE(e.byteLength);let n=v.concat([r,e]);return I.streamEncode.bytes=n.byteLength,n};I.streamEncode.bytes=0;I.streamDecode=function(t){let e=t.readUInt16BE(0);if(t.byteLength<e+2)return null;let r=I.decode(t.slice(2));return I.streamDecode.bytes=I.decode.bytes,r};I.streamDecode.bytes=0;function Lt(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function Yt(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 Lr(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 yi=_e((Wl,gi)=>{"use strict";var mi=Zc;process.nextTick(Yc,42);gi.exports=jc;function jc(t){var e=n;return r;function r(o){e(o||Gc)}function n(o){var i=[o];e=s,t(c);function s(a){i.push(a)}function c(a){var u=arguments;for(e=$c(a)?n:l;i.length;)l(i.shift());function l(d){mi(Wc,d,u)}}}}function $c(t){return Object.prototype.toString.call(t)==="[object Error]"}function Gc(){}function Wc(t,e){t.apply(null,e)}function Yc(t){t===42&&(mi=process.nextTick)}function Zc(t,e,r){process.nextTick(function(){t(e,r)})}});var bi=_e((Yl,xi)=>{var bn=fi(),Xc=ae("dgram"),Qc=yi(),Jc=ae("events"),In=ae("os"),En=function(){};xi.exports=function(t){t||(t={});var e=new Jc.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},s={},c=!1,a=null;if(n==="udp6"&&(!o||!t.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var u=t.socket||Xc.createSocket({type:n,reuseAddr:t.reuseAddr!==!1,toString:function(){return n}});u.on("error",function(d){d.code==="EACCES"||d.code==="EADDRINUSE"?e.emit("error",d):e.emit("warning",d)}),u.on("message",function(d,h){try{d=bn.decode(d)}catch(f){e.emit("warning",f);return}e.emit("packet",d,h),d.type==="query"&&e.emit("query",d,h),d.type==="response"&&e.emit("response",d,h)}),u.on("listening",function(){r||(r=i.port=u.address().port),t.multicast!==!1&&(e.update(),a=setInterval(e.update,5e3),u.setMulticastTTL(t.ttl||255),u.setMulticastLoopback(t.loopback!==!1))});var l=Qc(function(d){if(!r||t.bind===!1)return d(null);u.once("error",d),u.bind(r,t.bind||t.interface,function(){u.removeListener("error",d),d(null)})});return l(function(d){if(d)return e.emit("error",d);e.emit("ready")}),e.send=function(d,h,f){if(typeof h=="function")return e.send(d,null,h);f||(f=En),h?!h.host&&!h.address&&(h.address=i.address):h=i,l(p);function p(g){if(c)return f();if(g)return f(g);var U=bn.encode(d);u.send(U,0,U.length,h.port,h.address||h.host,f)}},e.response=e.respond=function(d,h,f){Array.isArray(d)&&(d={answers:d}),d.type="response",d.flags=(d.flags||0)|bn.AUTHORITATIVE_ANSWER,e.send(d,h,f)},e.query=function(d,h,f,p){if(typeof h=="function")return e.query(d,null,null,h);if(typeof h=="object"&&h&&h.port)return e.query(d,null,h,f);if(typeof f=="function")return e.query(d,h,null,f);p||(p=En),typeof d=="string"&&(d=[{name:d,type:h||"ANY"}]),Array.isArray(d)&&(d={type:"query",questions:d}),d.type="query",e.send(d,f,p)},e.destroy=function(d){if(d||(d=En),c)return process.nextTick(d);c=!0,clearInterval(a);for(var h in s)try{u.dropMembership(o,h)}catch{}s={},u.close(d)},e.update=function(){for(var d=t.interface?[].concat(t.interface):ta(),h=!1,f=0;f<d.length;f++){var p=d[f];if(!s[p])try{u.addMembership(o,p),s[p]=!0,h=!0}catch(g){e.emit("warning",g)}}if(h){if(u.setMulticastInterface)try{u.setMulticastInterface(t.interface||ea())}catch(g){e.emit("warning",g)}e.emit("networkInterface")}},e};function ea(){for(var t=In.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(wi(i.family)&&!i.internal)return In.platform()==="darwin"&&e[r]==="en0"?i.address:"0.0.0.0"}return"127.0.0.1"}function ta(){for(var t=In.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 s=o[i];if(wi(s.family)){r.push(s.address);break}}return r}function wi(t){return t===4||t==="IPv4"}});var ic=_e(xr=>{(function(){var t,e,r,n,o,i,s,c;c=function(a){var u,l,d,h;return u=(a&255<<24)>>>24,l=(a&255<<16)>>>16,d=(a&65280)>>>8,h=a&255,[u,l,d,h].join(".")},s=function(a){var u,l,d,h,f,p;for(u=[],d=h=0;h<=3&&a.length!==0;d=++h){if(d>0){if(a[0]!==".")throw new Error("Invalid IP");a=a.substring(1)}p=e(a),f=p[0],l=p[1],a=a.substring(l),u.push(f)}if(a.length!==0)throw new Error("Invalid IP");switch(u.length){case 1:if(u[0]>4294967295)throw new Error("Invalid IP");return u[0]>>>0;case 2:if(u[0]>255||u[1]>16777215)throw new Error("Invalid IP");return(u[0]<<24|u[1])>>>0;case 3:if(u[0]>255||u[1]>255||u[2]>65535)throw new Error("Invalid IP");return(u[0]<<24|u[1]<<16|u[2])>>>0;case 4:if(u[0]>255||u[1]>255||u[2]>255||u[3]>255)throw new Error("Invalid IP");return(u[0]<<24|u[1]<<16|u[2]<<8|u[3])>>>0;default:throw new Error("Invalid IP")}},r=function(a){return a.charCodeAt(0)},n=r("0"),i=r("a"),o=r("A"),e=function(a){var u,l,d,h,f;for(h=0,u=10,l="9",d=0,a.length>1&&a[d]==="0"&&(a[d+1]==="x"||a[d+1]==="X"?(d+=2,u=16):"0"<=a[d+1]&&a[d+1]<="9"&&(d++,u=8,l="7")),f=d;d<a.length;){if("0"<=a[d]&&a[d]<=l)h=h*u+(r(a[d])-n)>>>0;else if(u===16)if("a"<=a[d]&&a[d]<="f")h=h*u+(10+r(a[d])-i)>>>0;else if("A"<=a[d]&&a[d]<="F")h=h*u+(10+r(a[d])-o)>>>0;else break;else break;if(h>4294967295)throw new Error("too large");d++}if(d===f)throw new Error("empty octet");return[h,d]},t=function(){function a(u,l){var d,h,f,p;if(typeof u!="string")throw new Error("Missing `net' parameter");if(l||(p=u.split("/",2),u=p[0],l=p[1]),l||(l=32),typeof l=="string"&&l.indexOf(".")>-1){try{this.maskLong=s(l)}catch(g){throw d=g,new Error("Invalid mask: "+l)}for(h=f=32;f>=0;h=--f)if(this.maskLong===4294967295<<32-h>>>0){this.bitmask=h;break}}else if(l||l===0)this.bitmask=parseInt(l,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(s(u)&this.maskLong)>>>0}catch(g){throw d=g,new Error("Invalid net address: "+u)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+l);this.size=Math.pow(2,32-this.bitmask),this.base=c(this.netLong),this.mask=c(this.maskLong),this.hostmask=c(~this.maskLong),this.first=this.bitmask<=30?c(this.netLong+1):this.base,this.last=this.bitmask<=30?c(this.netLong+this.size-2):c(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?c(this.netLong+this.size-1):void 0}return a.prototype.contains=function(u){return typeof u=="string"&&(u.indexOf("/")>0||u.split(".").length!==4)&&(u=new a(u)),u instanceof a?this.contains(u.base)&&this.contains(u.broadcast||u.last):(s(u)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},a.prototype.next=function(u){return u==null&&(u=1),new a(c(this.netLong+this.size*u),this.mask)},a.prototype.forEach=function(u){var l,d,h;for(h=s(this.first),d=s(this.last),l=0;h<=d;)u(c(h),h,l),l++,h++},a.prototype.toString=function(){return this.base+"/"+this.bitmask},a}(),xr.ip2long=s,xr.long2ip=c,xr.Netmask=t}).call(xr)});var hl={};pe(hl,{mdns:()=>ll});var ei=Symbol.for("@libp2p/peer-discovery");var dn=Symbol.for("@libp2p/peer-id");var Pe=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},Ar=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var Br=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},Cr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var Wt=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var ti=ae("node:events"),ri=(t,...e)=>{try{(0,ti.setMaxListeners)(t,...e)}catch{}};var Ur=class extends EventTarget{#e=new Map;constructor(){super(),ri(1/0,this)}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 CustomEvent(e,r))}};var ni=Symbol.for("@libp2p/service-capabilities"),bl=Symbol.for("@libp2p/service-dependencies");var Dc=Ut(bi(),1);var Cn={};pe(Cn,{base58btc:()=>z,base58flickr:()=>aa});var Zl=new Uint8Array(0);function Ei(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 Se(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 Ii(t){return new TextEncoder().encode(t)}function vi(t){return new TextDecoder().decode(t)}function ra(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),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var c=t.length,a=t.charAt(0),u=Math.log(c)/Math.log(256),l=Math.log(256)/Math.log(c);function d(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var g=0,U=0,P=0,N=p.length;P!==N&&p[P]===0;)P++,g++;for(var F=(N-P)*l+1>>>0,H=new Uint8Array(F);P!==N;){for(var S=p[P],k=0,j=F-1;(S!==0||k<U)&&j!==-1;j--,k++)S+=256*H[j]>>>0,H[j]=S%c>>>0,S=S/c>>>0;if(S!==0)throw new Error("Non-zero carry");U=k,P++}for(var O=F-U;O!==F&&H[O]===0;)O++;for(var m=a.repeat(g);O<F;++O)m+=t.charAt(H[O]);return m}function h(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var g=0;if(p[g]!==" "){for(var U=0,P=0;p[g]===a;)U++,g++;for(var N=(p.length-g)*u+1>>>0,F=new Uint8Array(N);p[g];){var H=r[p.charCodeAt(g)];if(H===255)return;for(var S=0,k=N-1;(H!==0||S<P)&&k!==-1;k--,S++)H+=c*F[k]>>>0,F[k]=H%256>>>0,H=H/256>>>0;if(H!==0)throw new Error("Non-zero carry");P=S,g++}if(p[g]!==" "){for(var j=N-P;j!==N&&F[j]===0;)j++;for(var O=new Uint8Array(U+(N-j)),m=U;j!==N;)O[m++]=F[j++];return O}}}function f(p){var g=h(p);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:h,decode:f}}var na=ra,oa=na,Ai=oa;var vn=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")}},Sn=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,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 Bi(this,e)}},An=class{decoders;constructor(e){this.decoders=e}or(e){return Bi(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 Bi(t,e){return new An({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var Bn=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 vn(e,r,n),this.decoder=new Sn(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Tt({name:t,prefix:e,encode:r,decode:n}){return new Bn(t,e,r,n)}function ct({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=Ai(r,t);return Tt({prefix:e,name:t,encode:n,decode:i=>Se(o(i))})}function ia(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,c=0,a=0;for(let u=0;u<o;++u){let l=e[t[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|l,s+=r,s>=8&&(s-=8,i[a++]=255&c>>s)}if(s>=r||(255&c<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function sa(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,c=0;for(let a=0;a<t.length;++a)for(c=c<<8|t[a],s+=8;s>r;)s-=r,i+=e[o&c>>s];if(s!==0&&(i+=e[o&c<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function ca(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function V({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=ca(n);return Tt({prefix:e,name:t,encode(i){return sa(i,n,r)},decode(i){return ia(i,o,r,t)}})}var z=ct({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),aa=ct({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Un={};pe(Un,{base32:()=>at,base32hex:()=>ha,base32hexpad:()=>fa,base32hexpadupper:()=>ma,base32hexupper:()=>pa,base32pad:()=>da,base32padupper:()=>la,base32upper:()=>ua,base32z:()=>ga});var at=V({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ua=V({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),da=V({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),la=V({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ha=V({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),pa=V({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),fa=V({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ma=V({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ga=V({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ln={};pe(Ln,{base36:()=>Zt,base36upper:()=>ya});var Zt=ct({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ya=ct({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var wa=Li,Ci=128,xa=127,ba=~xa,Ea=Math.pow(2,31);function Li(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Ea;)e[r++]=t&255|Ci,t/=128;for(;t&ba;)e[r++]=t&255|Ci,t>>>=7;return e[r]=t|0,Li.bytes=r-n+1,e}var Ia=Tn,va=128,Ui=127;function Tn(t,n){var r=0,n=n||0,o=0,i=n,s,c=t.length;do{if(i>=c)throw Tn.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&Ui)<<o:(s&Ui)*Math.pow(2,o),o+=7}while(s>=va);return Tn.bytes=i-n,r}var Sa=Math.pow(2,7),Aa=Math.pow(2,14),Ba=Math.pow(2,21),Ca=Math.pow(2,28),Ua=Math.pow(2,35),La=Math.pow(2,42),Ta=Math.pow(2,49),Da=Math.pow(2,56),_a=Math.pow(2,63),Pa=function(t){return t<Sa?1:t<Aa?2:t<Ba?3:t<Ca?4:t<Ua?5:t<La?6:t<Ta?7:t<Da?8:t<_a?9:10},Oa={encode:wa,decode:Ia,encodingLength:Pa},Na=Oa,Xt=Na;function Qt(t,e=0){return[Xt.decode(t,e),Xt.decode.bytes]}function Dt(t,e,r=0){return Xt.encode(t,e,r),e}function _t(t){return Xt.encodingLength(t)}function ft(t,e){let r=e.byteLength,n=_t(t),o=n+_t(r),i=new Uint8Array(o+r);return Dt(t,i,0),Dt(r,i,n),i.set(e,o),new Pt(t,r,e,i)}function Jt(t){let e=Se(t),[r,n]=Qt(e),[o,i]=Qt(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Pt(r,o,s,e)}function Ti(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Ei(t.bytes,r.bytes)}}var Pt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function Di(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return ka(r,Dn(t),e??z.encoder);default:return Ka(r,Dn(t),e??at.encoder)}}var _i=new WeakMap;function Dn(t){let e=_i.get(t);if(e==null){let r=new Map;return _i.set(t,r),r}return e}var G=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!==er)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Ma)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=ft(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&&Ti(e.multihash,n.multihash)}toString(e){return Di(this,e)}toJSON(){return{"/":Di(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:s}=r;return new t(n,o,i,s??Pi(n,o,i.bytes))}else if(r[Fa]===!0){let{version:n,multihash:o,code:i}=r,s=Jt(o);return t.create(n,i,s)}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!==er)throw new Error(`Version 0 CID must use dag-pb (code: ${er}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Pi(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,er,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=Se(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new Pt(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[d,h]=Qt(e.subarray(r));return r+=h,d},o=n(),i=er;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,c=n(),a=n(),u=r+a,l=u-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:l,size:u}}static parse(e,r){let[n,o]=Ra(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 Dn(i).set(n,e),i}};function Ra(t,e){switch(t[0]){case"Q":{let r=e??z;return[z.prefix,r.decode(`${z.prefix}${t}`)]}case z.prefix:{let r=e??z;return[z.prefix,r.decode(t)]}case at.prefix:{let r=e??at;return[at.prefix,r.decode(t)]}case Zt.prefix:{let r=e??Zt;return[Zt.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function ka(t,e,r){let{prefix:n}=r;if(n!==z.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 Ka(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 er=112,Ma=18;function Pi(t,e,r){let n=_t(t),o=n+_t(e),i=new Uint8Array(o+r.byteLength);return Dt(t,i,0),Dt(e,i,n),i.set(r,o),i}var Fa=Symbol.for("@ipld/js-cid/CID");var _n={};pe(_n,{identity:()=>Ue});var Oi=0,Ha="identity",Ni=Se;function qa(t){return ft(Oi,Ni(t))}var Ue={code:Oi,name:Ha,encode:Ni,digest:qa};function ye(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 Pn=ae("node:buffer");function mt(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function et(t=0){return mt(Pn.Buffer.alloc(t))}function Le(t=0){return mt(Pn.Buffer.allocUnsafe(t))}var Ri=ae("node:buffer");function He(t,e){return mt(Ri.Buffer.concat(t,e))}var Ki=Symbol.for("@achingbrain/uint8arraylist");function ki(t,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let r=0;for(let n of t){let o=r+n.byteLength;if(e<o)return{buf:n,index:e-r};r=o}throw new RangeError("index is out of bounds")}function _r(t){return!!t?.[Ki]}var we=class t{bufs;length;[Ki]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let r=0;for(let n of e)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(_r(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...e){this.prependAll(e)}prependAll(e){let r=0;for(let n of e.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(_r(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(e){let r=ki(this.bufs,e);return r.buf[r.index]}set(e,r){let n=ki(this.bufs,e);n.buf[n.index]=r}write(e,r=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(r+n,e[n]);else if(_r(e))for(let n=0;n<e.length;n++)this.set(r+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,r){let{bufs:n,length:o}=this._subList(e,r);return He(n,o)}subarray(e,r){let{bufs:n,length:o}=this._subList(e,r);return n.length===1?n[0]:He(n,o)}sublist(e,r){let{bufs:n,length:o}=this._subList(e,r),i=new t;return i.length=o,i.bufs=[...n],i}_subList(e,r){if(e=e??0,r=r??this.length,e<0&&(e=this.length+e),r<0&&(r=this.length+r),e<0||r>this.length)throw new RangeError("index is out of bounds");if(e===r)return{bufs:[],length:0};if(e===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],c=o,a=c+s.byteLength;if(o=a,e>=a)continue;let u=e>=c&&e<a,l=r>c&&r<=a;if(u&&l){if(e===c&&r===a){n.push(s);break}let d=e-c;n.push(s.subarray(d,d+(r-e)));break}if(u){if(e===0){n.push(s);continue}n.push(s.subarray(e-c));continue}if(l){if(r===a){n.push(s);break}n.push(s.subarray(0,r-c));break}n.push(s)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!_r(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),e.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let d=0;d<i;d++)s[d]=-1;for(let d=0;d<o;d++)s[n[d]]=d;let c=s,a=this.byteLength-n.byteLength,u=n.byteLength-1,l;for(let d=r;d<=a;d+=l){l=0;for(let h=u;h>=0;h--){let f=this.get(d+h);if(n[h]!==f){l=Math.max(1,h-c[f]);break}}if(l===0)return d}return-1}getInt8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(e,r){let n=Le(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,e)}getInt16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(e,r,n){let o=et(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,e)}getInt32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(e,r,n){let o=et(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,e)}getBigInt64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(e,r,n){let o=et(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,e)}getUint8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(e,r){let n=Le(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,e)}getUint16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(e,r,n){let o=et(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,e)}getUint32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(e,r,n){let o=et(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,e)}getBigUint64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(e,r,n){let o=et(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,e)}getFloat32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(e,r,n){let o=et(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,e)}getFloat64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(e,r,n){let o=et(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof t)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!ye(this.bufs[r],e.bufs[r]))return!1;return!0}static fromUint8Arrays(e,r){let n=new t;return n.bufs=e,r==null&&(r=e.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var Vi=ae("node:buffer");var On={};pe(On,{base10:()=>Va});var Va=ct({prefix:"9",name:"base10",alphabet:"0123456789"});var Nn={};pe(Nn,{base16:()=>za,base16upper:()=>ja});var za=V({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ja=V({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Rn={};pe(Rn,{base2:()=>$a});var $a=V({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var kn={};pe(kn,{base256emoji:()=>Xa});var Mi=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}"),Ga=Mi.reduce((t,e,r)=>(t[r]=e,t),[]),Wa=Mi.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function Ya(t){return t.reduce((e,r)=>(e+=Ga[r],e),"")}function Za(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Wa[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Xa=Tt({prefix:"\u{1F680}",name:"base256emoji",encode:Ya,decode:Za});var Mn={};pe(Mn,{base64:()=>Qa,base64pad:()=>Ja,base64url:()=>Kn,base64urlpad:()=>eu});var Qa=V({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ja=V({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Kn=V({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),eu=V({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Fn={};pe(Fn,{base8:()=>tu});var tu=V({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Hn={};pe(Hn,{identity:()=>ru});var ru=Tt({prefix:"\0",name:"identity",encode:t=>vi(t),decode:t=>Ii(t)});var _h=new TextEncoder,Ph=new TextDecoder;var $n={};pe($n,{sha256:()=>jn,sha512:()=>iu});var zn=Ut(ae("crypto"),1);function Vn({name:t,code:e,encode:r}){return new qn(t,e,r)}var qn=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?ft(this.code,r):r.then(n=>ft(this.code,n))}else throw Error("Unknown type, must be binary type")}};var jn=Vn({name:"sha2-256",code:18,encode:t=>Se(zn.default.createHash("sha256").update(t).digest())}),iu=Vn({name:"sha2-512",code:19,encode:t=>Se(zn.default.createHash("sha512").update(t).digest())});var tr={...Hn,...Rn,...Fn,...On,...Nn,...Un,...Ln,...Cn,...Mn,...kn},$h={...$n,..._n};function qi(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var Hi=qi("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Gn=qi("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=Le(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),su={utf8:Hi,"utf-8":Hi,hex:tr.base16,latin1:Gn,ascii:Gn,binary:Gn,...tr},Pr=su;function J(t,e="utf8"){let r=Pr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?mt(Vi.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var zi=ae("node:buffer");function K(t,e="utf8"){let r=Pr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?zi.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var cu=parseInt("11111",2),Wn=parseInt("10000000",2),au=parseInt("01111111",2),ji={0:rr,1:rr,2:uu,3:hu,4:pu,5:lu,6:du,16:rr,22:rr,48:rr};function Yn(t,e={offset:0}){let r=t[e.offset]&cu;if(e.offset++,ji[r]!=null)return ji[r](t,e);throw new Error("No decoder for tag "+r)}function nr(t,e){let r=0;if((t[e.offset]&Wn)===Wn){let n=t[e.offset]&au,o="0x";e.offset++;for(let i=0;i<n;i++,e.offset++)o+=t[e.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=t[e.offset],e.offset++;return r}function rr(t,e){nr(t,e);let r=[];for(;!(e.offset>=t.byteLength);){let n=Yn(t,e);if(n===null)break;r.push(n)}return r}function uu(t,e){let r=nr(t,e),n=e.offset,o=e.offset+r,i=[];for(let s=n;s<o;s++)s===n&&t[s]===0||i.push(t[s]);return e.offset+=r,Uint8Array.from(i)}function du(t,e){let r=nr(t,e),n=e.offset+r,o=t[e.offset];e.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let c=`${i}.${s}`,a=[];for(;e.offset<n;){let u=t[e.offset];if(e.offset++,a.push(u&127),u<128){a.reverse();let l=0;for(let d=0;d<a.length;d++)l+=a[d]<<d*7;c+=`.${l}`,a=[]}}return c}function lu(t,e){return e.offset++,null}function hu(t,e){let r=nr(t,e),n=t[e.offset];e.offset++;let o=t.subarray(e.offset,e.offset+r-1);if(e.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function pu(t,e){let r=nr(t,e),n=t.subarray(e.offset,e.offset+r);return e.offset+=r,n}function fu(t){let e=t.toString(16);e.length%2===1&&(e="0"+e);let r=new we;for(let n=0;n<e.length;n+=2)r.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return r}function Zn(t){if(t.byteLength<128)return Uint8Array.from([t.byteLength]);let e=fu(t.byteLength);return new we(Uint8Array.from([e.byteLength|Wn]),e)}function $i(t){let e=new we,r=128;return(t.subarray()[0]&r)===r&&e.append(Uint8Array.from([0])),e.append(t),new we(Uint8Array.from([2]),Zn(e),e)}function Gi(t){let e=Uint8Array.from([0]),r=new we(e,t);return new we(Uint8Array.from([3]),Zn(r),r)}function Or(t,e=48){let r=new we;for(let n of t)r.append(n);return new we(Uint8Array.from([e]),Zn(r),r)}async function Wi(t,e,r,n){let o=await crypto.subtle.importKey("jwk",t,{name:"ECDSA",namedCurve:t.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,e,r.subarray());return n?.signal?.throwIfAborted(),i}var mu=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),gu=Uint8Array.from([6,5,43,129,4,0,34]),yu=Uint8Array.from([6,5,43,129,4,0,35]),wu={ext:!0,kty:"EC",crv:"P-256"},xu={ext:!0,kty:"EC",crv:"P-384"},bu={ext:!0,kty:"EC",crv:"P-521"},Xn=32,Qn=48,Jn=66;function Yi(t){let e=Yn(t);return Zi(e)}function Zi(t){let e=t[1][1][0],r=1,n,o;if(e.byteLength===Xn*2+1)return n=K(e.subarray(r,r+Xn),"base64url"),o=K(e.subarray(r+Xn),"base64url"),new Nt({...wu,key_ops:["verify"],x:n,y:o});if(e.byteLength===Qn*2+1)return n=K(e.subarray(r,r+Qn),"base64url"),o=K(e.subarray(r+Qn),"base64url"),new Nt({...xu,key_ops:["verify"],x:n,y:o});if(e.byteLength===Jn*2+1)return n=K(e.subarray(r,r+Jn),"base64url"),o=K(e.subarray(r+Jn),"base64url"),new Nt({...bu,key_ops:["verify"],x:n,y:o});throw new Pe(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function Xi(t){return Or([$i(Uint8Array.from([1])),Or([Eu(t.crv)],160),Or([Gi(new we(Uint8Array.from([4]),J(t.x??"","base64url"),J(t.y??"","base64url")))],161)]).subarray()}function Eu(t){if(t==="P-256")return mu;if(t==="P-384")return gu;if(t==="P-521")return yu;throw new Pe(`Invalid curve ${t}`)}var Nt=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=Xi(this.jwk)),this._raw}toMultihash(){return Ue.digest(Rt(this))}toCID(){return G.createV1(114,this.toMultihash())}toString(){return z.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ye(this.raw,e.raw)}async verify(e,r,n){return Wi(this.jwk,r,e,n)}};var Nr=Ut(ae("crypto"),1);var Cp=Nr.default.generateKeyPairSync,or=32;var Iu=64;function Qi(t,e,r){if(t.byteLength!==or)throw new TypeError('"key" must be 32 bytes in length.');if(!(t instanceof Uint8Array))throw new TypeError('"key" must be a node.js Buffer, or Uint8Array.');if(e.byteLength!==Iu)throw new TypeError('"sig" must be 64 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"sig" must be a node.js Buffer, or Uint8Array.');let n=Nr.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:K(t,"base64url"),kty:"OKP"}});return Nr.default.verify(null,r instanceof Uint8Array?r:r.subarray(),n,e)}function es(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}var Rr=class{type="Ed25519";raw;constructor(e){this.raw=eo(e,or)}toMultihash(){return Ue.digest(Rt(this))}toCID(){return G.createV1(114,this.toMultihash())}toString(){return z.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ye(this.raw,e.raw)}verify(e,r,n){n?.signal?.throwIfAborted();let o=Qi(this.raw,r,e);return es(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function ts(t){return t=eo(t,or),new Rr(t)}function eo(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new Pe(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}var Su=Math.pow(2,7),Au=Math.pow(2,14),Bu=Math.pow(2,21),to=Math.pow(2,28),ro=Math.pow(2,35),no=Math.pow(2,42),oo=Math.pow(2,49),q=128,re=127;function qe(t){if(t<Su)return 1;if(t<Au)return 2;if(t<Bu)return 3;if(t<to)return 4;if(t<ro)return 5;if(t<no)return 6;if(t<oo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ir(t,e,r=0){switch(qe(t)){case 8:e[r++]=t&255|q,t/=128;case 7:e[r++]=t&255|q,t/=128;case 6:e[r++]=t&255|q,t/=128;case 5:e[r++]=t&255|q,t/=128;case 4:e[r++]=t&255|q,t>>>=7;case 3:e[r++]=t&255|q,t>>>=7;case 2:e[r++]=t&255|q,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function io(t,e){let r=t[e],n=0;if(n+=r&re,r<q||(r=t[e+1],n+=(r&re)<<7,r<q)||(r=t[e+2],n+=(r&re)<<14,r<q)||(r=t[e+3],n+=(r&re)<<21,r<q)||(r=t[e+4],n+=(r&re)*to,r<q)||(r=t[e+5],n+=(r&re)*ro,r<q)||(r=t[e+6],n+=(r&re)*no,r<q)||(r=t[e+7],n+=(r&re)*oo,r<q))return n;throw new RangeError("Could not decode varint")}function Cu(t,e){let r=t.get(e),n=0;if(n+=r&re,r<q||(r=t.get(e+1),n+=(r&re)<<7,r<q)||(r=t.get(e+2),n+=(r&re)<<14,r<q)||(r=t.get(e+3),n+=(r&re)<<21,r<q)||(r=t.get(e+4),n+=(r&re)*to,r<q)||(r=t.get(e+5),n+=(r&re)*ro,r<q)||(r=t.get(e+6),n+=(r&re)*no,r<q)||(r=t.get(e+7),n+=(r&re)*oo,r<q))return n;throw new RangeError("Could not decode varint")}function so(t,e=0){return t instanceof Uint8Array?io(t,e):Cu(t,e)}var co=new Float32Array([-0]),ut=new Uint8Array(co.buffer);function rs(t,e,r){co[0]=t,e[r]=ut[0],e[r+1]=ut[1],e[r+2]=ut[2],e[r+3]=ut[3]}function ns(t,e){return ut[0]=t[e],ut[1]=t[e+1],ut[2]=t[e+2],ut[3]=t[e+3],co[0]}var ao=new Float64Array([-0]),ne=new Uint8Array(ao.buffer);function os(t,e,r){ao[0]=t,e[r]=ne[0],e[r+1]=ne[1],e[r+2]=ne[2],e[r+3]=ne[3],e[r+4]=ne[4],e[r+5]=ne[5],e[r+6]=ne[6],e[r+7]=ne[7]}function is(t,e){return ne[0]=t[e],ne[1]=t[e+1],ne[2]=t[e+2],ne[3]=t[e+3],ne[4]=t[e+4],ne[5]=t[e+5],ne[6]=t[e+6],ne[7]=t[e+7],ao[0]}var Lu=BigInt(Number.MAX_SAFE_INTEGER),Tu=BigInt(Number.MIN_SAFE_INTEGER),xe=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return gt;if(e<Lu&&e>Tu)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>ss&&(o=0n,++n>ss&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return gt;let r=e<0;r&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new t(n,o)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):gt}},gt=new xe(0,0);gt.toBigInt=function(){return 0n};gt.zzEncode=gt.zzDecode=function(){return this};gt.length=function(){return 1};var ss=4294967296n;function cs(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function as(t,e,r){if(r-e<1)return"";let o,i=[],s=0,c;for(;e<r;)c=t[e++],c<128?i[s++]=c:c>191&&c<224?i[s++]=(c&31)<<6|t[e++]&63:c>239&&c<365?(c=((c&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(c>>10),i[s++]=56320+(c&1023)):i[s++]=(c&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function uo(t,e,r){let n=r,o,i;for(let s=0;s<t.length;++s)o=t.charCodeAt(s),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((i=t.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-n}function Te(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function kr(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var lo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Te(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Te(this,4);return kr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Te(this,4);return kr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Te(this,4);let e=ns(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Te(this,4);let e=is(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw Te(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return as(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Te(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Te(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new xe(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Te(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw Te(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Te(this,8);let e=kr(this.buf,this.pos+=4),r=kr(this.buf,this.pos+=4);return new xe(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=io(this.buf,this.pos);return this.pos+=qe(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function ho(t){return new lo(t instanceof Uint8Array?t:t.subarray())}function Kr(t,e,r){let n=ho(t);return e.decode(n,void 0,r)}function po(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return Le(s);o+s>e&&(n=Le(e),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var yt=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function fo(){}var go=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Du=po();function _u(t){return globalThis.Buffer!=null?Le(t):Du(t)}var cr=class{len;head;tail;states;constructor(){this.len=0,this.head=new yt(fo,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new yt(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new yo((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Mr,10,xe.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=xe.fromBigInt(e);return this._push(Mr,r.length(),r)}uint64Number(e){return this._push(ir,qe(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=xe.fromBigInt(e).zzEncode();return this._push(Mr,r.length(),r)}sint64Number(e){let r=xe.fromNumber(e).zzEncode();return this._push(Mr,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(mo,1,e?1:0)}fixed32(e){return this._push(sr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=xe.fromBigInt(e);return this._push(sr,4,r.lo)._push(sr,4,r.hi)}fixed64Number(e){let r=xe.fromNumber(e);return this._push(sr,4,r.lo)._push(sr,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(rs,4,e)}double(e){return this._push(os,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(mo,1,0):this.uint32(r)._push(Ou,r,e)}string(e){let r=cs(e);return r!==0?this.uint32(r)._push(uo,r,e):this._push(mo,1,0)}fork(){return this.states=new go(this),this.head=this.tail=new yt(fo,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new yt(fo,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=_u(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function mo(t,e,r){e[r]=t&255}function Pu(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var yo=class extends yt{next;constructor(e,r){super(Pu,e,r),this.next=void 0}};function Mr(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function sr(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function Ou(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(cr.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(Nu,e,t),this},cr.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(Ru,e,t),this});function Nu(t,e,r){e.set(t,r)}function Ru(t,e,r){t.length<40?uo(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(J(t),r)}function wo(){return new cr}function Fr(t,e){let r=wo();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var kt;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(kt||(kt={}));function Hr(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function xo(t){function e(o){if(t[o.toString()]==null)throw new Error("Invalid enum value");return t[o]}let r=function(i,s){let c=e(i);s.int32(c)},n=function(i){let s=i.int32();return e(s)};return Hr("enum",kt.VARINT,r,n)}function qr(t,e){return Hr("message",kt.LENGTH_DELIMITED,t,e)}var be;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.ECDSA="ECDSA"})(be||(be={}));var bo;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1",t[t.ECDSA=3]="ECDSA"})(bo||(bo={}));(function(t){t.codec=()=>xo(bo)})(be||(be={}));var ar;(function(t){let e;t.codec=()=>(e==null&&(e=qr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),be.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.Type=be.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),e),t.encode=r=>Fr(r,t.codec()),t.decode=(r,n)=>Kr(r,t.codec(),n)})(ar||(ar={}));var Eo;(function(t){let e;t.codec=()=>(e==null&&(e=qr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),be.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.Type=be.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),e),t.encode=r=>Fr(r,t.codec()),t.decode=(r,n)=>Kr(r,t.codec(),n)})(Eo||(Eo={}));var tt=Ut(ae("node:crypto"),1),wt=tt&&typeof tt=="object"&&"webcrypto"in tt?tt.webcrypto:tt&&typeof tt=="object"&&"randomBytes"in tt?tt:void 0;function Mt(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ur(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function de(t,...e){if(!Mt(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function ls(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");ur(t.outputLen),ur(t.blockLen)}function Ft(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function hs(t,e){de(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function xt(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Vr(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function De(t,e){return t<<32-e|t>>>e}var ps=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Ku=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function dt(t){if(de(t),ps)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=Ku[t[r]];return e}var rt={_0:48,_9:57,A:65,F:70,a:97,f:102};function ds(t){if(t>=rt._0&&t<=rt._9)return t-rt._0;if(t>=rt.A&&t<=rt.F)return t-(rt.A-10);if(t>=rt.a&&t<=rt.f)return t-(rt.a-10)}function Ht(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(ps)return Uint8Array.fromHex(t);let e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=ds(t.charCodeAt(i)),c=ds(t.charCodeAt(i+1));if(s===void 0||c===void 0){let a=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+i)}n[o]=s*16+c}return n}function fs(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function dr(t){return typeof t=="string"&&(t=fs(t)),de(t),t}function Ve(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];de(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}var Kt=class{};function ms(t){let e=n=>t().update(dr(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Io(t=32){if(wt&&typeof wt.getRandomValues=="function")return wt.getRandomValues(new Uint8Array(t));if(wt&&typeof wt.randomBytes=="function")return Uint8Array.from(wt.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}function Mu(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),c=Number(r&i),a=n?4:0,u=n?0:4;t.setUint32(e+a,s,n),t.setUint32(e+u,c,n)}function gs(t,e,r){return t&e^~t&r}function ys(t,e,r){return t&e^t&r^e&r}var zr=class extends Kt{constructor(e,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Vr(this.buffer)}update(e){Ft(this),e=dr(e),de(e);let{view:r,buffer:n,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=Vr(e);for(;o<=i-s;s+=o)this.process(a,s);continue}n.set(e.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ft(this),hs(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,xt(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let d=s;d<o;d++)r[d]=0;Mu(n,o-8,BigInt(this.length*8),i),this.process(n,0);let c=Vr(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=a/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<u;d++)c.setUint32(4*d,l[d],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:c}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=c,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},nt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Fu=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),lt=new Uint32Array(64),vo=class extends zr{constructor(e=32){super(64,e,8,!1),this.A=nt[0]|0,this.B=nt[1]|0,this.C=nt[2]|0,this.D=nt[3]|0,this.E=nt[4]|0,this.F=nt[5]|0,this.G=nt[6]|0,this.H=nt[7]|0}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:c,H:a}=this;return[e,r,n,o,i,s,c,a]}set(e,r,n,o,i,s,c,a){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}process(e,r){for(let d=0;d<16;d++,r+=4)lt[d]=e.getUint32(r,!1);for(let d=16;d<64;d++){let h=lt[d-15],f=lt[d-2],p=De(h,7)^De(h,18)^h>>>3,g=De(f,17)^De(f,19)^f>>>10;lt[d]=g+lt[d-7]+p+lt[d-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:u,H:l}=this;for(let d=0;d<64;d++){let h=De(c,6)^De(c,11)^De(c,25),f=l+h+gs(c,a,u)+Fu[d]+lt[d]|0,g=(De(n,2)^De(n,13)^De(n,22))+ys(n,o,i)|0;l=u,u=a,a=c,c=s+f|0,s=i,i=o,o=n,n=f+g|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(n,o,i,s,c,a,u,l)}roundClean(){xt(lt)}destroy(){this.set(0,0,0,0,0,0,0,0),xt(this.buffer)}};var ws=ms(()=>new vo);var Ys=Ut(ae("node:crypto"),1);var jr=class extends Kt{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,ls(e);let n=dr(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),xt(i)}update(e){return Ft(this),this.iHash.update(e),this}digestInto(e){Ft(this),de(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=c,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},So=(t,e,r)=>new jr(t,e).update(r).digest();So.create=(t,e)=>new jr(t,e);var Co=BigInt(0),Bo=BigInt(1);function lr(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}function hr(t){let e=t.toString(16);return e.length&1?"0"+e:e}function xs(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Co:BigInt("0x"+t)}function qt(t){return xs(dt(t))}function Uo(t){return de(t),xs(dt(Uint8Array.from(t).reverse()))}function $r(t,e){return Ht(t.toString(16).padStart(e*2,"0"))}function Lo(t,e){return $r(t,e).reverse()}function le(t,e,r){let n;if(typeof e=="string")try{n=Ht(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(Mt(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(t+" of length "+r+" expected, got "+o);return n}var Ao=t=>typeof t=="bigint"&&Co<=t;function bs(t,e,r){return Ao(t)&&Ao(e)&&Ao(r)&&e<=t&&t<r}function Es(t,e,r,n){if(!bs(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Is(t){let e;for(e=0;t>Co;t>>=Bo,e+=1);return e}var bt=t=>(Bo<<BigInt(t))-Bo;function vs(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=f=>new Uint8Array(f),o=f=>Uint8Array.of(f),i=n(t),s=n(t),c=0,a=()=>{i.fill(1),s.fill(0),c=0},u=(...f)=>r(s,i,...f),l=(f=n(0))=>{s=u(o(0),f),i=u(),f.length!==0&&(s=u(o(1),f),i=u())},d=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,p=[];for(;f<e;){i=u();let g=i.slice();p.push(g),f+=i.length}return Ve(...p)};return(f,p)=>{a(),l(f);let g;for(;!(g=p(d()));)l();return a(),g}}function pr(t,e,r={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function n(o,i,s){let c=t[o];if(s&&c===void 0)return;let a=typeof c;if(a!==i||c===null)throw new Error(`param "${o}" is invalid: expected ${i}, got ${a}`)}Object.entries(e).forEach(([o,i])=>n(o,i,!1)),Object.entries(r).forEach(([o,i])=>n(o,i,!0))}function To(t){let e=new WeakMap;return(r,...n)=>{let o=e.get(r);if(o!==void 0)return o;let i=t(r,...n);return e.set(r,i),i}}var ce=BigInt(0),oe=BigInt(1),Et=BigInt(2),Hu=BigInt(3),Bs=BigInt(4),Cs=BigInt(5),Us=BigInt(8);function Ee(t,e){let r=t%e;return r>=ce?r:e+r}function Ie(t,e,r){let n=t;for(;e-- >ce;)n*=n,n%=r;return n}function Ss(t,e){if(t===ce)throw new Error("invert: expected non-zero number");if(e<=ce)throw new Error("invert: expected positive modulus, got "+e);let r=Ee(t,e),n=e,o=ce,i=oe,s=oe,c=ce;for(;r!==ce;){let u=n/r,l=n%r,d=o-s*u,h=i-c*u;n=r,r=l,o=s,i=c,s=d,c=h}if(n!==oe)throw new Error("invert: does not exist");return Ee(o,e)}function Ls(t,e){let r=(t.ORDER+oe)/Bs,n=t.pow(e,r);if(!t.eql(t.sqr(n),e))throw new Error("Cannot find square root");return n}function qu(t,e){let r=(t.ORDER-Cs)/Us,n=t.mul(e,Et),o=t.pow(n,r),i=t.mul(e,o),s=t.mul(t.mul(i,Et),o),c=t.mul(i,t.sub(s,t.ONE));if(!t.eql(t.sqr(c),e))throw new Error("Cannot find square root");return c}function Vu(t){if(t<BigInt(3))throw new Error("sqrt is not defined for small field");let e=t-oe,r=0;for(;e%Et===ce;)e/=Et,r++;let n=Et,o=It(t);for(;As(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Ls;let i=o.pow(n,e),s=(e+oe)/Et;return function(a,u){if(a.is0(u))return u;if(As(a,u)!==1)throw new Error("Cannot find square root");let l=r,d=a.mul(a.ONE,i),h=a.pow(u,e),f=a.pow(u,s);for(;!a.eql(h,a.ONE);){if(a.is0(h))return a.ZERO;let p=1,g=a.sqr(h);for(;!a.eql(g,a.ONE);)if(p++,g=a.sqr(g),p===l)throw new Error("Cannot find square root");let U=oe<<BigInt(l-p-1),P=a.pow(d,U);l=p,d=a.sqr(P),h=a.mul(h,d),f=a.mul(f,P)}return f}}function zu(t){return t%Bs===Hu?Ls:t%Us===Cs?qu:Vu(t)}var ju=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Do(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},r=ju.reduce((n,o)=>(n[o]="function",n),e);return pr(t,r),t}function $u(t,e,r){if(r<ce)throw new Error("invalid exponent, negatives unsupported");if(r===ce)return t.ONE;if(r===oe)return e;let n=t.ONE,o=e;for(;r>ce;)r&oe&&(n=t.mul(n,o)),o=t.sqr(o),r>>=oe;return n}function Gr(t,e,r=!1){let n=new Array(e.length).fill(r?t.ZERO:void 0),o=e.reduce((s,c,a)=>t.is0(c)?s:(n[a]=s,t.mul(s,c)),t.ONE),i=t.inv(o);return e.reduceRight((s,c,a)=>t.is0(c)?s:(n[a]=t.mul(s,n[a]),t.mul(s,c)),i),n}function As(t,e){let r=(t.ORDER-oe)/Et,n=t.pow(e,r),o=t.eql(n,t.ONE),i=t.eql(n,t.ZERO),s=t.eql(n,t.neg(t.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function Ts(t,e){e!==void 0&&ur(e);let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function It(t,e,r=!1,n={}){if(t<=ce)throw new Error("invalid field: expected ORDER > 0, got "+t);let o,i;if(typeof e=="object"&&e!=null){if(n.sqrt||r)throw new Error("cannot specify opts in two arguments");let l=e;l.BITS&&(o=l.BITS),l.sqrt&&(i=l.sqrt),typeof l.isLE=="boolean"&&(r=l.isLE)}else typeof e=="number"&&(o=e),n.sqrt&&(i=n.sqrt);let{nBitLength:s,nByteLength:c}=Ts(t,o);if(c>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let a,u=Object.freeze({ORDER:t,isLE:r,BITS:s,BYTES:c,MASK:bt(s),ZERO:ce,ONE:oe,create:l=>Ee(l,t),isValid:l=>{if(typeof l!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof l);return ce<=l&&l<t},is0:l=>l===ce,isValidNot0:l=>!u.is0(l)&&u.isValid(l),isOdd:l=>(l&oe)===oe,neg:l=>Ee(-l,t),eql:(l,d)=>l===d,sqr:l=>Ee(l*l,t),add:(l,d)=>Ee(l+d,t),sub:(l,d)=>Ee(l-d,t),mul:(l,d)=>Ee(l*d,t),pow:(l,d)=>$u(u,l,d),div:(l,d)=>Ee(l*Ss(d,t),t),sqrN:l=>l*l,addN:(l,d)=>l+d,subN:(l,d)=>l-d,mulN:(l,d)=>l*d,inv:l=>Ss(l,t),sqrt:i||(l=>(a||(a=zu(t)),a(u,l))),toBytes:l=>r?Lo(l,c):$r(l,c),fromBytes:l=>{if(l.length!==c)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+l.length);return r?Uo(l):qt(l)},invertBatch:l=>Gr(u,l),cmov:(l,d,h)=>h?d:l});return Object.freeze(u)}function Ds(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function _o(t){let e=Ds(t);return e+Math.ceil(e/2)}function _s(t,e,r=!1){let n=t.length,o=Ds(e),i=_o(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Uo(t):qt(t),c=Ee(s,e-oe)+oe;return r?Lo(c,o):$r(c,o)}var zt=BigInt(0),vt=BigInt(1);function Vt(t,e){let r=e.negate();return t?r:e}function Rs(t,e,r){let n=e==="pz"?s=>s.pz:s=>s.ez,o=Gr(t.Fp,r.map(n));return r.map((s,c)=>s.toAffine(o[c])).map(t.fromAffine)}function ks(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Po(t,e){ks(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1),o=2**t,i=bt(t),s=BigInt(t);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Ps(t,e,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,c=Number(t&o),a=t>>s;c>n&&(c-=i,a+=vt);let u=e*n,l=u+Math.abs(c)-1,d=c===0,h=c<0,f=e%2!==0;return{nextN:a,offset:l,isZero:d,isNeg:h,isNegF:f,offsetF:u}}function Gu(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,n)=>{if(!(r instanceof e))throw new Error("invalid point at index "+n)})}function Wu(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,n)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+n)})}var Oo=new WeakMap,Ks=new WeakMap;function No(t){return Ks.get(t)||1}function Os(t){if(t!==zt)throw new Error("invalid wNAF")}function Ms(t,e){return{constTimeNegate:Vt,hasPrecomputes(r){return No(r)!==1},unsafeLadder(r,n,o=t.ZERO){let i=r;for(;n>zt;)n&vt&&(o=o.add(i)),i=i.double(),n>>=vt;return o},precomputeWindow(r,n){let{windows:o,windowSize:i}=Po(n,e),s=[],c=r,a=c;for(let u=0;u<o;u++){a=c,s.push(a);for(let l=1;l<i;l++)a=a.add(c),s.push(a);c=a.double()}return s},wNAF(r,n,o){let i=t.ZERO,s=t.BASE,c=Po(r,e);for(let a=0;a<c.windows;a++){let{nextN:u,offset:l,isZero:d,isNeg:h,isNegF:f,offsetF:p}=Ps(o,a,c);o=u,d?s=s.add(Vt(f,n[p])):i=i.add(Vt(h,n[l]))}return Os(o),{p:i,f:s}},wNAFUnsafe(r,n,o,i=t.ZERO){let s=Po(r,e);for(let c=0;c<s.windows&&o!==zt;c++){let{nextN:a,offset:u,isZero:l,isNeg:d}=Ps(o,c,s);if(o=a,!l){let h=n[u];i=i.add(d?h.negate():h)}}return Os(o),i},getPrecomputes(r,n,o){let i=Oo.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&(typeof o=="function"&&(i=o(i)),Oo.set(n,i))),i},wNAFCached(r,n,o){let i=No(r);return this.wNAF(i,this.getPrecomputes(i,r,o),n)},wNAFCachedUnsafe(r,n,o,i){let s=No(r);return s===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,r,o),n,i)},setWindowSize(r,n){ks(n,e),Ks.set(r,n),Oo.delete(r)}}}function Fs(t,e,r,n){let o=e,i=t.ZERO,s=t.ZERO;for(;r>zt||n>zt;)r&vt&&(i=i.add(o)),n&vt&&(s=s.add(o)),o=o.double(),r>>=vt,n>>=vt;return{p1:i,p2:s}}function Hs(t,e,r,n){Gu(r,t),Wu(n,e);let o=r.length,i=n.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");let s=t.ZERO,c=Is(BigInt(o)),a=1;c>12?a=c-3:c>4?a=c-2:c>0&&(a=2);let u=bt(a),l=new Array(Number(u)+1).fill(s),d=Math.floor((e.BITS-1)/a)*a,h=s;for(let f=d;f>=0;f-=a){l.fill(s);for(let g=0;g<i;g++){let U=n[g],P=Number(U>>BigInt(f)&u);l[P]=l[P].add(r[g])}let p=s;for(let g=l.length-1,U=s;g>0;g--)U=U.add(l[g]),p=p.add(U);if(h=h.add(p),f!==0)for(let g=0;g<a;g++)h=h.double()}return h}function Ns(t,e){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Do(e),e}else return It(t)}function qs(t,e,r={}){if(!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(let c of["p","n","h"]){let a=e[c];if(!(typeof a=="bigint"&&a>zt))throw new Error(`CURVE.${c} must be positive bigint`)}let n=Ns(e.p,r.Fp),o=Ns(e.n,r.Fn),s=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let c of s)if(!n.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return{Fp:n,Fn:o}}function Vs(t){t.lowS!==void 0&&lr("lowS",t.lowS),t.prehash!==void 0&&lr("prehash",t.prehash)}var Ro=class extends Error{constructor(e=""){super(e)}},ot={Err:Ro,_tlv:{encode:(t,e)=>{let{Err:r}=ot;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=hr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?hr(o.length/2|128):"";return hr(t)+i+o+e},decode(t,e){let{Err:r}=ot,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let a=o&127;if(!a)throw new r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");let u=e.subarray(n,n+a);if(u.length!==a)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let l of u)s=s<<8|l;if(n+=a,s<128)throw new r("tlv.decode(long): not minimal encoding")}let c=e.subarray(n,n+s);if(c.length!==s)throw new r("tlv.decode: wrong value length");return{v:c,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=ot;if(t<fr)throw new e("integer: negative integers are not allowed");let r=hr(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=ot;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return qt(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=ot,o=le("signature",t),{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,i),{v:u,l}=n.decode(2,a);if(l.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(u)}},hexFromSig(t){let{_tlv:e,_int:r}=ot,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}},fr=BigInt(0),mr=BigInt(1),Yu=BigInt(2),Wr=BigInt(3),Zu=BigInt(4);function Xu(t,e,r){function n(o){let i=t.sqr(o),s=t.mul(i,o);return t.add(t.add(s,t.mul(o,e)),r)}return n}function zs(t,e,r){let{BYTES:n}=t;function o(i){let s;if(typeof i=="bigint")s=i;else{let c=le("private key",i);if(e){if(!e.includes(c.length*2))throw new Error("invalid private key");let a=new Uint8Array(n);a.set(c,a.length-c.length),c=a}try{s=t.fromBytes(c)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof i}`)}}if(r&&(s=t.create(s)),!t.isValidNot0(s))throw new Error("invalid private key: out of range [1..N-1]");return s}return o}function Qu(t,e={}){let{Fp:r,Fn:n}=qs("weierstrass",t,e),{h:o,n:i}=t;pr(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:s}=e;if(s&&(!r.is0(t.a)||typeof s.beta!="bigint"||typeof s.splitScalar!="function"))throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');function c(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function a(O,m,b){let{x:y,y:w}=m.toAffine(),E=r.toBytes(y);if(lr("isCompressed",b),b){c();let C=!r.isOdd(w);return Ve(js(C),E)}else return Ve(Uint8Array.of(4),E,r.toBytes(w))}function u(O){de(O);let m=r.BYTES,b=m+1,y=2*m+1,w=O.length,E=O[0],C=O.subarray(1);if(w===b&&(E===2||E===3)){let A=r.fromBytes(C);if(!r.isValid(A))throw new Error("bad point: is not on curve, wrong x");let B=h(A),T;try{T=r.sqrt(B)}catch(R){let D=R instanceof Error?": "+R.message:"";throw new Error("bad point: is not on curve, sqrt error"+D)}c();let L=r.isOdd(T);return(E&1)===1!==L&&(T=r.neg(T)),{x:A,y:T}}else if(w===y&&E===4){let A=r.fromBytes(C.subarray(m*0,m*1)),B=r.fromBytes(C.subarray(m*1,m*2));if(!f(A,B))throw new Error("bad point: is not on curve");return{x:A,y:B}}else throw new Error(`bad point: got length ${w}, expected compressed=${b} or uncompressed=${y}`)}let l=e.toBytes||a,d=e.fromBytes||u,h=Xu(r,t.a,t.b);function f(O,m){let b=r.sqr(m),y=h(O);return r.eql(b,y)}if(!f(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let p=r.mul(r.pow(t.a,Wr),Zu),g=r.mul(r.sqr(t.b),BigInt(27));if(r.is0(r.add(p,g)))throw new Error("bad curve params: a or b");function U(O,m,b=!1){if(!r.isValid(m)||b&&r.is0(m))throw new Error(`bad point coordinate ${O}`);return m}function P(O){if(!(O instanceof S))throw new Error("ProjectivePoint expected")}let N=To((O,m)=>{let{px:b,py:y,pz:w}=O;if(r.eql(w,r.ONE))return{x:b,y};let E=O.is0();m==null&&(m=E?r.ONE:r.inv(w));let C=r.mul(b,m),A=r.mul(y,m),B=r.mul(w,m);if(E)return{x:r.ZERO,y:r.ZERO};if(!r.eql(B,r.ONE))throw new Error("invZ was invalid");return{x:C,y:A}}),F=To(O=>{if(O.is0()){if(e.allowInfinityPoint&&!r.is0(O.py))return;throw new Error("bad point: ZERO")}let{x:m,y:b}=O.toAffine();if(!r.isValid(m)||!r.isValid(b))throw new Error("bad point: x or y not field elements");if(!f(m,b))throw new Error("bad point: equation left != right");if(!O.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function H(O,m,b,y,w){return b=new S(r.mul(b.px,O),b.py,b.pz),m=Vt(y,m),b=Vt(w,b),m.add(b)}class S{constructor(m,b,y){this.px=U("x",m),this.py=U("y",b,!0),this.pz=U("z",y),Object.freeze(this)}static fromAffine(m){let{x:b,y}=m||{};if(!m||!r.isValid(b)||!r.isValid(y))throw new Error("invalid affine point");if(m instanceof S)throw new Error("projective point not allowed");return r.is0(b)&&r.is0(y)?S.ZERO:new S(b,y,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(m){return Rs(S,"pz",m)}static fromBytes(m){return de(m),S.fromHex(m)}static fromHex(m){let b=S.fromAffine(d(le("pointHex",m)));return b.assertValidity(),b}static fromPrivateKey(m){let b=zs(n,e.allowedPrivateKeyLengths,e.wrapPrivateKey);return S.BASE.multiply(b(m))}static msm(m,b){return Hs(S,n,m,b)}precompute(m=8,b=!0){return j.setWindowSize(this,m),b||this.multiply(Wr),this}_setWindowSize(m){this.precompute(m)}assertValidity(){F(this)}hasEvenY(){let{y:m}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(m)}equals(m){P(m);let{px:b,py:y,pz:w}=this,{px:E,py:C,pz:A}=m,B=r.eql(r.mul(b,A),r.mul(E,w)),T=r.eql(r.mul(y,A),r.mul(C,w));return B&&T}negate(){return new S(this.px,r.neg(this.py),this.pz)}double(){let{a:m,b}=t,y=r.mul(b,Wr),{px:w,py:E,pz:C}=this,A=r.ZERO,B=r.ZERO,T=r.ZERO,L=r.mul(w,w),$=r.mul(E,E),R=r.mul(C,C),D=r.mul(w,E);return D=r.add(D,D),T=r.mul(w,C),T=r.add(T,T),A=r.mul(m,T),B=r.mul(y,R),B=r.add(A,B),A=r.sub($,B),B=r.add($,B),B=r.mul(A,B),A=r.mul(D,A),T=r.mul(y,T),R=r.mul(m,R),D=r.sub(L,R),D=r.mul(m,D),D=r.add(D,T),T=r.add(L,L),L=r.add(T,L),L=r.add(L,R),L=r.mul(L,D),B=r.add(B,L),R=r.mul(E,C),R=r.add(R,R),L=r.mul(R,D),A=r.sub(A,L),T=r.mul(R,$),T=r.add(T,T),T=r.add(T,T),new S(A,B,T)}add(m){P(m);let{px:b,py:y,pz:w}=this,{px:E,py:C,pz:A}=m,B=r.ZERO,T=r.ZERO,L=r.ZERO,$=t.a,R=r.mul(t.b,Wr),D=r.mul(b,E),W=r.mul(y,C),Y=r.mul(w,A),te=r.add(b,y),M=r.add(E,C);te=r.mul(te,M),M=r.add(D,W),te=r.sub(te,M),M=r.add(b,w);let ie=r.add(E,A);return M=r.mul(M,ie),ie=r.add(D,Y),M=r.sub(M,ie),ie=r.add(y,w),B=r.add(C,A),ie=r.mul(ie,B),B=r.add(W,Y),ie=r.sub(ie,B),L=r.mul($,M),B=r.mul(R,Y),L=r.add(B,L),B=r.sub(W,L),L=r.add(W,L),T=r.mul(B,L),W=r.add(D,D),W=r.add(W,D),Y=r.mul($,Y),M=r.mul(R,M),W=r.add(W,Y),Y=r.sub(D,Y),Y=r.mul($,Y),M=r.add(M,Y),D=r.mul(W,M),T=r.add(T,D),D=r.mul(ie,M),B=r.mul(te,B),B=r.sub(B,D),D=r.mul(te,W),L=r.mul(ie,L),L=r.add(L,D),new S(B,T,L)}subtract(m){return this.add(m.negate())}is0(){return this.equals(S.ZERO)}multiply(m){let{endo:b}=e;if(!n.isValidNot0(m))throw new Error("invalid scalar: out of range");let y,w,E=C=>j.wNAFCached(this,C,S.normalizeZ);if(b){let{k1neg:C,k1:A,k2neg:B,k2:T}=b.splitScalar(m),{p:L,f:$}=E(A),{p:R,f:D}=E(T);w=$.add(D),y=H(b.beta,L,R,C,B)}else{let{p:C,f:A}=E(m);y=C,w=A}return S.normalizeZ([y,w])[0]}multiplyUnsafe(m){let{endo:b}=e,y=this;if(!n.isValid(m))throw new Error("invalid scalar: out of range");if(m===fr||y.is0())return S.ZERO;if(m===mr)return y;if(j.hasPrecomputes(this))return this.multiply(m);if(b){let{k1neg:w,k1:E,k2neg:C,k2:A}=b.splitScalar(m),{p1:B,p2:T}=Fs(S,y,E,A);return H(b.beta,B,T,w,C)}else return j.wNAFCachedUnsafe(y,m)}multiplyAndAddUnsafe(m,b,y){let w=this.multiplyUnsafe(b).add(m.multiplyUnsafe(y));return w.is0()?void 0:w}toAffine(m){return N(this,m)}isTorsionFree(){let{isTorsionFree:m}=e;return o===mr?!0:m?m(S,this):j.wNAFCachedUnsafe(this,i).is0()}clearCofactor(){let{clearCofactor:m}=e;return o===mr?this:m?m(S,this):this.multiplyUnsafe(o)}toBytes(m=!0){return lr("isCompressed",m),this.assertValidity(),l(S,this,m)}toRawBytes(m=!0){return this.toBytes(m)}toHex(m=!0){return dt(this.toBytes(m))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}S.BASE=new S(t.Gx,t.Gy,r.ONE),S.ZERO=new S(r.ZERO,r.ONE,r.ZERO),S.Fp=r,S.Fn=n;let k=n.BITS,j=Ms(S,e.endo?Math.ceil(k/2):k);return S}function js(t){return Uint8Array.of(t?2:3)}function Ju(t,e,r={}){pr(e,{hash:"function"},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let n=e.randomBytes||Io,o=e.hmac||((y,...w)=>So(e.hash,y,Ve(...w))),{Fp:i,Fn:s}=t,{ORDER:c,BITS:a}=s;function u(y){let w=c>>mr;return y>w}function l(y){return u(y)?s.neg(y):y}function d(y,w){if(!s.isValidNot0(w))throw new Error(`invalid signature ${y}: out of range 1..CURVE.n`)}class h{constructor(w,E,C){d("r",w),d("s",E),this.r=w,this.s=E,C!=null&&(this.recovery=C),Object.freeze(this)}static fromCompact(w){let E=s.BYTES,C=le("compactSignature",w,E*2);return new h(s.fromBytes(C.subarray(0,E)),s.fromBytes(C.subarray(E,E*2)))}static fromDER(w){let{r:E,s:C}=ot.toSig(le("DER",w));return new h(E,C)}assertValidity(){}addRecoveryBit(w){return new h(this.r,this.s,w)}recoverPublicKey(w){let E=i.ORDER,{r:C,s:A,recovery:B}=this;if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");if(c*Yu<E&&B>1)throw new Error("recovery id is ambiguous for h>1 curve");let L=B===2||B===3?C+c:C;if(!i.isValid(L))throw new Error("recovery id 2 or 3 invalid");let $=i.toBytes(L),R=t.fromHex(Ve(js((B&1)===0),$)),D=s.inv(L),W=F(le("msgHash",w)),Y=s.create(-W*D),te=s.create(A*D),M=t.BASE.multiplyUnsafe(Y).add(R.multiplyUnsafe(te));if(M.is0())throw new Error("point at infinify");return M.assertValidity(),M}hasHighS(){return u(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,s.neg(this.s),this.recovery):this}toBytes(w){if(w==="compact")return Ve(s.toBytes(this.r),s.toBytes(this.s));if(w==="der")return Ht(ot.hexFromSig(this));throw new Error("invalid format")}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return dt(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return dt(this.toBytes("compact"))}}let f=zs(s,r.allowedPrivateKeyLengths,r.wrapPrivateKey),p={isValidPrivateKey(y){try{return f(y),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let y=c;return _s(n(_o(y)),y)},precompute(y=8,w=t.BASE){return w.precompute(y,!1)}};function g(y,w=!0){return t.fromPrivateKey(y).toBytes(w)}function U(y){if(typeof y=="bigint")return!1;if(y instanceof t)return!0;let E=le("key",y).length,C=i.BYTES,A=C+1,B=2*C+1;if(!(r.allowedPrivateKeyLengths||s.BYTES===A))return E===A||E===B}function P(y,w,E=!0){if(U(y)===!0)throw new Error("first arg must be private key");if(U(w)===!1)throw new Error("second arg must be public key");return t.fromHex(w).multiply(f(y)).toBytes(E)}let N=e.bits2int||function(y){if(y.length>8192)throw new Error("input is too large");let w=qt(y),E=y.length*8-a;return E>0?w>>BigInt(E):w},F=e.bits2int_modN||function(y){return s.create(N(y))},H=bt(a);function S(y){return Es("num < 2^"+a,y,fr,H),s.toBytes(y)}function k(y,w,E=j){if(["recovered","canonical"].some(te=>te in E))throw new Error("sign() legacy options not supported");let{hash:C}=e,{lowS:A,prehash:B,extraEntropy:T}=E;A==null&&(A=!0),y=le("msgHash",y),Vs(E),B&&(y=le("prehashed msgHash",C(y)));let L=F(y),$=f(w),R=[S($),S(L)];if(T!=null&&T!==!1){let te=T===!0?n(i.BYTES):T;R.push(le("extraEntropy",te))}let D=Ve(...R),W=L;function Y(te){let M=N(te);if(!s.isValidNot0(M))return;let ie=s.inv(M),Gt=t.BASE.multiply(M).toAffine(),Bt=s.create(Gt.x);if(Bt===fr)return;let ht=s.create(ie*s.create(W+Bt*$));if(ht===fr)return;let un=(Gt.x===Bt?0:2)|Number(Gt.y&mr),Ct=ht;return A&&u(ht)&&(Ct=l(ht),un^=1),new h(Bt,Ct,un)}return{seed:D,k2sig:Y}}let j={lowS:e.lowS,prehash:!1},O={lowS:e.lowS,prehash:!1};function m(y,w,E=j){let{seed:C,k2sig:A}=k(y,w,E);return vs(e.hash.outputLen,s.BYTES,o)(C,A)}t.BASE.precompute(8);function b(y,w,E,C=O){let A=y;w=le("msgHash",w),E=le("publicKey",E),Vs(C);let{lowS:B,prehash:T,format:L}=C;if("strict"in C)throw new Error("options.strict was renamed to lowS");if(L!==void 0&&!["compact","der","js"].includes(L))throw new Error('format must be "compact", "der" or "js"');let $=typeof A=="string"||Mt(A),R=!$&&!L&&typeof A=="object"&&A!==null&&typeof A.r=="bigint"&&typeof A.s=="bigint";if(!$&&!R)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let D,W;try{if(R)if(L===void 0||L==="js")D=new h(A.r,A.s);else throw new Error("invalid format");if($){try{L!=="compact"&&(D=h.fromDER(A))}catch(Ct){if(!(Ct instanceof ot.Err))throw Ct}!D&&L!=="der"&&(D=h.fromCompact(A))}W=t.fromHex(E)}catch{return!1}if(!D||B&&D.hasHighS())return!1;T&&(w=e.hash(w));let{r:Y,s:te}=D,M=F(w),ie=s.inv(te),Gt=s.create(M*ie),Bt=s.create(Y*ie),ht=t.BASE.multiplyUnsafe(Gt).add(W.multiplyUnsafe(Bt));return ht.is0()?!1:s.create(ht.x)===Y}return Object.freeze({getPublicKey:g,getSharedSecret:P,sign:m,verify:b,utils:p,Point:t,Signature:h})}function ed(t){let e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},r=t.Fp,n=It(e.n,t.nBitLength),o={Fp:r,Fn:n,allowedPrivateKeyLengths:t.allowedPrivateKeyLengths,allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,wrapPrivateKey:t.wrapPrivateKey,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes};return{CURVE:e,curveOpts:o}}function td(t){let{CURVE:e,curveOpts:r}=ed(t),n={hash:t.hash,hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:r,ecdsaOpts:n}}function rd(t,e){return Object.assign({},e,{ProjectivePoint:e.Point,CURVE:t})}function $s(t){let{CURVE:e,curveOpts:r,ecdsaOpts:n}=td(t),o=Qu(e,r),i=Ju(o,n,r);return rd(t,i)}function Gs(t,e){let r=n=>$s({...t,hash:n});return{...r(e),create:r}}var Yr={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},of=BigInt(0),nd=BigInt(1),ko=BigInt(2),Ws=(t,e)=>(t+e/ko)/e;function od(t){let e=Yr.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),u=t*t*t%e,l=u*u*t%e,d=Ie(l,r,e)*l%e,h=Ie(d,r,e)*l%e,f=Ie(h,ko,e)*u%e,p=Ie(f,o,e)*f%e,g=Ie(p,i,e)*p%e,U=Ie(g,c,e)*g%e,P=Ie(U,a,e)*U%e,N=Ie(P,c,e)*g%e,F=Ie(N,r,e)*l%e,H=Ie(F,s,e)*p%e,S=Ie(H,n,e)*u%e,k=Ie(S,ko,e);if(!Ko.eql(Ko.sqr(k),t))throw new Error("Cannot find square root");return k}var Ko=It(Yr.p,void 0,void 0,{sqrt:od}),gr=Gs({...Yr,Fp:Ko,lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=Yr.n,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-nd*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),c=Ws(i*t,e),a=Ws(-n*t,e),u=Ee(t-c*r-a*o,e),l=Ee(-c*n-a*i,e),d=u>s,h=l>s;if(d&&(u=e-u),h&&(l=e-l),u>s||l>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:d,k1:u,k2neg:h,k2:l}}}},ws);var Zr=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function Zs(t,e,r,n){n?.signal?.throwIfAborted();let o=Ys.default.createHash("sha256");if(r instanceof Uint8Array)o.update(r);else for(let s of r)o.update(s);let i=o.digest();try{return gr.verify(e,i,t)}catch(s){throw new Zr(String(s))}}var Xr=class{type="secp256k1";raw;_key;constructor(e){this._key=Qs(e),this.raw=Xs(this._key)}toMultihash(){return Ue.digest(Rt(this))}toCID(){return G.createV1(114,this.toMultihash())}toString(){return z.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ye(this.raw,e.raw)}verify(e,r,n){return Zs(this._key,r,e,n)}};function Js(t){return new Xr(t)}function Xs(t){return gr.ProjectivePoint.fromHex(t).toRawBytes(!0)}function Qs(t){try{return gr.ProjectivePoint.fromHex(t),t}catch(e){throw new Ar(String(e))}}function ec(t){let{Type:e,Data:r}=ar.decode(t.digest),n=r??new Uint8Array;switch(e){case be.Ed25519:return ts(n);case be.secp256k1:return Js(n);case be.ECDSA:return Yi(n);default:throw new Wt}}function Rt(t){return ar.encode({Type:be[t.type],Data:t.raw})}var tc=Symbol.for("nodejs.util.inspect.custom"),id=114,yr=class{type;multihash;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[dn]=!0;toString(){return this.string==null&&(this.string=z.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return G.createV1(id,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return ye(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return ye(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[tc](){return`PeerId(${this.toString()})`}},Qr=class extends yr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Jr=class extends yr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},en=class extends yr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},sd=2336,wr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Ue.digest(J(this.url))}[tc](){return`PeerId(${this.url})`}[dn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return G.createV1(sd,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=K(e)),e.toString()===this.toString())}};var cd=114,rc=2336;function nc(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=Jt(z.decode(`z${t}`));else{if(t.startsWith("k51qzi5uqu5")||t.startsWith("kzwfwjn5ji4")||t.startsWith("k2k4r8")||t.startsWith("bafz"))return ad(G.parse(t));if(e==null)throw new Pe('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=Jt(e.decode(t))}return oc(r)}function oc(t){if(dd(t))return new Qr({multihash:t});if(ud(t))try{let e=ec(t);if(e.type==="Ed25519")return new Jr({multihash:t,publicKey:e});if(e.type==="secp256k1")return new en({multihash:t,publicKey:e})}catch{let r=K(t.digest);return new wr(new URL(r))}throw new Cr("Supplied PeerID Multihash is invalid")}function ad(t){if(t?.multihash==null||t.version==null||t.version===1&&t.code!==cd&&t.code!==rc)throw new Br("Supplied PeerID CID is invalid");if(t.code===rc){let e=K(t.multihash.digest);return new wr(new URL(e))}return oc(t.multihash)}function ud(t){return t.code===Ue.code}function dd(t){return t.code===jn.code}var ve=ae("node:net");var sc=Ut(ic(),1),ld=["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"],hd=ld.map(t=>new sc.Netmask(t));function Mo(t){for(let e of hd)if(e.contains(t))return!0;return!1}function pd(t){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(t)}function fd(t){let e=t.split(":");if(e.length<2)return!1;let r=e[e.length-1].padStart(4,"0"),n=e[e.length-2].padStart(4,"0"),o=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(r.substring(0,2),16)}.${parseInt(r.substring(2),16)}`;return Mo(o)}function md(t){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)}function gd(t){let e=t.split(":"),r=e[e.length-1];return Mo(r)}function yd(t){return/^::$/.test(t)||/^::1$/.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)}function cc(t){if((0,ve.isIPv4)(t))return Mo(t);if(pd(t))return fd(t);if(md(t))return gd(t);if((0,ve.isIPv6)(t))return yd(t)}var ee=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},it=class extends Error{static name="ValidationError";name="ValidationError"},br=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},tn=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function Ho(t){return e=>K(e,t)}function qo(t){return e=>J(e,t)}function jt(t){return new DataView(t.buffer).getUint16(t.byteOffset).toString()}function St(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof t=="string"?parseInt(t):t),new Uint8Array(e)}function ac(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=J(e[0],"base32"),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=St(n);return He([r,o],r.length+o.length)}function uc(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=at.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=St(n);return He([r,o],r.length+o.length)}function Vo(t){let e=t.subarray(0,t.length-2),r=t.subarray(t.length-2),n=K(e,"base32"),o=jt(r);return`${n}:${o}`}var zo=function(t){t=t.toString().trim();let e=new Uint8Array(4);return t.split(/\./g).forEach((r,n)=>{let o=parseInt(r,10);if(isNaN(o)||o<0||o>255)throw new ee("Invalid byte value in IP address");e[n]=o}),e},dc=function(t){let e=0;t=t.toString().trim();let r=t.split(":",8),n;for(n=0;n<r.length;n++){let i=(0,ve.isIPv4)(r[n]),s;i&&(s=zo(r[n]),r[n]=K(s.subarray(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,K(s.subarray(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++){r[n]===""&&(r[n]="0");let i=parseInt(r[n],16);if(isNaN(i)||i<0||i>65535)throw new ee("Invalid byte value in IP address");o[e++]=i>>8&255,o[e++]=i&255}return o},lc=function(t){if(t.byteLength!==4)throw new ee("IPv4 address was incorrect length");let e=[];for(let r=0;r<t.byteLength;r++)e.push(t[r]);return e.join(".")},hc=function(t){if(t.byteLength!==16)throw new ee("IPv6 address was incorrect length");let e=[];for(let n=0;n<t.byteLength;n+=2){let o=t[n],i=t[n+1],s=`${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`;e.push(s)}let r=e.join(":");try{let n=new URL(`http://[${r}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new ee(`Invalid IPv6 address "${r}"`)}};function pc(t){try{let e=new URL(`http://[${t}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new ee(`Invalid IPv6 address "${t}"`)}}var Fo=Object.values(tr).map(t=>t.decoder),wd=function(){let t=Fo[0].or(Fo[1]);return Fo.slice(2).forEach(e=>t=t.or(e)),t}();function fc(t){return wd.decode(t)}function mc(t){return e=>t.encoder.encode(e)}function xd(t){if(parseInt(t).toString()!==t)throw new it("Value must be an integer")}function bd(t){if(t<0)throw new it("Value must be a positive integer, or zero")}function Ed(t){return e=>{if(e>t)throw new it(`Value must be smaller than or equal to ${t}`)}}function Id(...t){return e=>{for(let r of t)r(e)}}var Er=Id(xd,bd,Ed(65535));var X=-1,jo=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(e){let r;if(typeof e=="string"?r=this.protocolsByName.get(e):r=this.protocolsByCode.get(e),r==null)throw new tn(`Protocol ${e} was unknown`);return r}addProtocol(e){this.protocolsByCode.set(e.code,e),this.protocolsByName.set(e.name,e),e.aliases?.forEach(r=>{this.protocolsByName.set(r,e)})}removeProtocol(e){let r=this.protocolsByCode.get(e);r!=null&&(this.protocolsByCode.delete(r.code),this.protocolsByName.delete(r.name),r.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},he=new jo,Qd=[{code:4,name:"ip4",size:32,valueToBytes:zo,bytesToValue:lc,validate:t=>{if(!(0,ve.isIPv4)(t))throw new it(`Invalid IPv4 address "${t}"`)}},{code:6,name:"tcp",size:16,valueToBytes:St,bytesToValue:jt,validate:Er},{code:273,name:"udp",size:16,valueToBytes:St,bytesToValue:jt,validate:Er},{code:33,name:"dccp",size:16,valueToBytes:St,bytesToValue:jt,validate:Er},{code:41,name:"ip6",size:128,valueToBytes:dc,bytesToValue:hc,stringToValue:pc,validate:t=>{if(!(0,ve.isIPv6)(t))throw new it(`Invalid IPv6 address "${t}"`)}},{code:42,name:"ip6zone",size:X},{code:43,name:"ipcidr",size:8,bytesToValue:Ho("base10"),valueToBytes:qo("base10")},{code:53,name:"dns",size:X,resolvable:!0},{code:54,name:"dns4",size:X,resolvable:!0},{code:55,name:"dns6",size:X,resolvable:!0},{code:56,name:"dnsaddr",size:X,resolvable:!0},{code:132,name:"sctp",size:16,valueToBytes:St,bytesToValue:jt,validate:Er},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:X,path:!0,stringToValue:t=>decodeURIComponent(t),valueToString:t=>encodeURIComponent(t)},{code:421,name:"p2p",aliases:["ipfs"],size:X,bytesToValue:Ho("base58btc"),valueToBytes:t=>t.startsWith("Q")||t.startsWith("1")?qo("base58btc")(t):G.parse(t).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:Vo,valueToBytes:ac},{code:445,name:"onion3",size:296,bytesToValue:Vo,valueToBytes:uc},{code:446,name:"garlic64",size:X},{code:447,name:"garlic32",size:X},{code:448,name:"tls"},{code:449,name:"sni",size:X},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:X,bytesToValue:mc(Kn),valueToBytes:fc},{code:480,name:"http"},{code:481,name:"http-path",size:X,stringToValue:t=>`/${decodeURIComponent(t)}`,valueToString:t=>encodeURIComponent(t.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:X}];Qd.forEach(t=>{he.addProtocol(t)});function gc(t){let e=[],r=0;for(;r<t.length;){let n=so(t,r),o=he.getProtocol(n),i=qe(n),s=Jd(o,t,r+i),c=0;s>0&&o.size===X&&(c=qe(s));let a=i+c+s,u={code:n,name:o.name,bytes:t.subarray(r,r+a)};if(s>0){let l=r+i+c,d=t.subarray(l,l+s);u.value=o.bytesToValue?.(d)??K(d)}e.push(u),r+=a}return e}function yc(t){let e=0,r=[];for(let n of t){if(n.bytes==null){let o=he.getProtocol(n.code),i=qe(n.code),s,c=0,a=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??J(n.value),c=s.byteLength,o.size===X&&(a=qe(c)));let u=new Uint8Array(i+a+c),l=0;ir(n.code,u,l),l+=i,s!=null&&(o.size===X&&(ir(c,u,l),l+=a),u.set(s,l)),n.bytes=u}r.push(n.bytes),e+=n.bytes.byteLength}return He(r,e)}function wc(t){if(t.charAt(0)!=="/")throw new ee('String multiaddr must start with "/"');let e=[],r="protocol",n="",o="";for(let i=1;i<t.length;i++){let s=t.charAt(i);s!=="/"&&(r==="protocol"?o+=t.charAt(i):n+=t.charAt(i));let c=i===t.length-1;if(s==="/"||c){let a=he.getProtocol(o);if(r==="protocol"){if(a.size==null||a.size===0){e.push({code:a.code,name:a.name}),n="",o="",r="protocol";continue}else if(c)throw new ee(`Component ${o} was missing value`);r="value"}else if(r==="value"){let u={code:a.code,name:a.name};if(a.size!=null&&a.size!==0){if(n==="")throw new ee(`Component ${o} was missing value`);u.value=a.stringToValue?.(n)??n}e.push(u),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new ee("Incomplete multiaddr");return e}function xc(t){return`/${t.flatMap(e=>{if(e.value==null)return e.name;let r=he.getProtocol(e.code);if(r==null)throw new ee(`Unknown protocol code ${e.code}`);return[e.name,r.valueToString?.(e.value)??e.value]}).join("/")}`}function Jd(t,e,r){return t.size==null||t.size===0?0:t.size>0?t.size/8:so(e,r)}var el=Symbol.for("nodejs.util.inspect.custom"),Qo=Symbol.for("@multiformats/multiaddr"),tl=[53,54,55,56],Xo=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}};function rl(t){if(t==null&&(t="/"),Ec(t))return t.getComponents();if(t instanceof Uint8Array)return gc(t);if(typeof t=="string")return t=t.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),t===""&&(t="/"),wc(t);if(Array.isArray(t))return t;throw new ee("Must be a string, Uint8Array, Component[], or another Multiaddr")}var sn=class t{[Qo]=!0;#e;#t;#r;constructor(e="/",r={}){this.#e=rl(e),r.validate!==!1&&nl(this)}get bytes(){return this.#r==null&&(this.#r=yc(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=xc(this.#e)),this.#t}toJSON(){return this.toString()}toOptions(){let e,r,n,o,i="";for(let{code:c,name:a,value:u}of this.#e)c===42&&(i=`%${u??""}`),tl.includes(c)&&(r="tcp",o=443,n=`${u??""}${i}`,e=c===55?6:4),(c===6||c===273)&&(r=a==="tcp"?"tcp":"udp",o=parseInt(u??"")),(c===4||c===41)&&(r="tcp",n=`${u??""}${i}`,e=c===41?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}}getComponents(){return[...this.#e]}protos(){return this.#e.map(({code:e,value:r})=>{let n=he.getProtocol(e);return{code:e,size:n.size??0,name:n.name,resolvable:!!n.resolvable,path:!!n.path}})}protoCodes(){return this.#e.map(({code:e})=>e)}protoNames(){return this.#e.map(({name:e})=>e)}tuples(){return this.#e.map(({code:e,value:r})=>{if(r==null)return[e];let n=he.getProtocol(e),o=[e];return r!=null&&o.push(n.valueToBytes?.(r)??J(r)),o})}stringTuples(){return this.#e.map(({code:e,value:r})=>r==null?[e]:[e,r])}encapsulate(e){let r=new t(e);return new t([...this.#e,...r.getComponents()],{validate:!1})}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new br(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new t(n.slice(0,o),{validate:!1})}decapsulateCode(e){let r;for(let n=this.#e.length-1;n>-1;n--)if(this.#e[n].code===e){r=n;break}return new t(this.#e.slice(0,r),{validate:!1})}getPeerId(){try{let e=[];this.#e.forEach(({code:n,value:o})=>{n===421&&e.push([n,o]),n===290&&(e=[])});let r=e.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?K(z.decode(`z${n}`),"base58btc"):K(G.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){for(let e of this.#e)if(he.getProtocol(e.code).path)return e.value??null;return null}equals(e){return ye(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(i=>i.resolvable);if(r==null)return[this];let n=bc.get(r.name);if(n==null)throw new Xo(`no available resolver for ${r.name}`);return(await n(this,e)).map(i=>vr(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(){return!(this.#e.length!==2||this.#e[0].code!==4&&this.#e[0].code!==41||this.#e[1].code!==6&&this.#e[1].code!==273)}[el](){return`Multiaddr(${this.toString()})`}};function nl(t){t.getComponents().forEach(e=>{let r=he.getProtocol(e.code);e.value!=null&&r.validate?.(e.value)})}var cn=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,s=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",u=2**(8*o)-1;for(;;){let l=this.readAtomically(()=>{let d=this.readChar();if(d===void 0)return;let h=Number.parseInt(d,e);if(!Number.isNaN(h))return h});if(l===void 0)break;if(i*=e,i+=l,i>u||(s+=1,r!==void 0&&s>r))return}if(s!==0)return!n&&a&&s>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 s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return r[o]=s[0],r[o+1]=s[1],r[o+2]=s[2],r[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];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),s=16-(n+2),[c]=e(i.subarray(0,s));return r.set(i.subarray(0,c),16-c),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Wm=new cn;var rg=parseInt("0xFFFF",16),ng=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var bc=new Map;function Ec(t){return!!t?.[Qo]}function vr(t){return new sn(t)}function Sc(t){let e=he.getProtocol(t);return{code:e.code,size:e.size??0,name:e.name,resolvable:!!e.resolvable,path:!!e.path}}function Ac(t){try{for(let{code:e}of t.getComponents())if(e!==42)return e===4||e===41}catch{}return!1}function Bc(t){try{if(!Ac(t))return!1;let[[,e]]=t.stringTuples();return e==null?!1:cc(e)??!1}catch{}return!0}function Cc(t,e,r,n){let o=()=>{n?.log.trace("query",e),t.query({questions:[{name:e,type:"PTR"}]})};return o(),setInterval(o,r)}function Uc(t,e,r,n){if(t.answers==null)return;let o,i=[];if(t.answers.forEach(s=>{switch(s.type){case"PTR":o=s;break;case"TXT":i.push(s);break;default:break}}),t.additionals.forEach(s=>{switch(s.type){case"TXT":i.push(s);break;default:break}}),!(o==null||o?.name!==r||i.length===0||o.data.startsWith(e)))try{let s=i.flatMap(a=>a.data).filter(a=>a.toString().startsWith("dnsaddr=")).map(a=>vr(a.toString().substring(8))),c=s[0].getPeerId();if(c==null)throw new Error("Multiaddr doesn't contain PeerId");return n?.log("peer found %p",c),{id:nc(c),multiaddrs:s.map(a=>a.decapsulateCode(Sc("p2p").code))}}catch(s){n?.log.error("failed to parse mdns response",s)}}function Lc(t,e,r,n,o,i,s){if(!i){s?.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 c=[];c.push({name:o,type:"PTR",class:"IN",ttl:120,data:r+"."+o}),n.filter(ul).forEach(a=>{let u="dnsaddr="+a.toString();if(u.length>255){s?.log("multiaddr %a is too long to use in mDNS query response",a);return}if(a.getPeerId()==null){s?.log("multiaddr %a did not have a peer ID so cannot be used in mDNS query response",a);return}c.push({name:r+"."+o,type:"TXT",class:"IN",ttl:120,data:u})}),s?.log.trace("responding to query"),e.respond(c)}}function ul(t){return!!Bc(t)}function Tc(t){let e="",r="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<t;n++)e+=r.charAt(Math.floor(Math.random()*r.length));return e}var an=class extends Ur{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??Tc(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)}[ei]=this;[Symbol.toStringTag]="@libp2p/mdns";[ni]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,Dc.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=Cc(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),Lc(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=Uc(e,this.peerName,this.serviceTag,{log:this.log});r!=null&&(this.log("discovered peer in mDNS query response %p",r.id),this.dispatchEvent(new CustomEvent("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 ll(t={}){return e=>new an(e,t)}return kc(hl);})();
|
|
2
|
+
"use strict";var Libp2PMdns=(()=>{var Cc=Object.create;var vr=Object.defineProperty;var Lc=Object.getOwnPropertyDescriptor;var Uc=Object.getOwnPropertyNames;var Dc=Object.getPrototypeOf,Tc=Object.prototype.hasOwnProperty;var de=(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 Ne=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),pe=(t,e)=>{for(var r in e)vr(t,r,{get:e[r],enumerable:!0})},Qo=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Uc(e))!Tc.call(t,o)&&o!==r&&vr(t,o,{get:()=>e[o],enumerable:!(n=Lc(e,o))||n.enumerable});return t};var Dt=(t,e,r)=>(r=t!=null?Cc(Dc(t)):{},Qo(e||!t||!t.__esModule?vr(r,"default",{value:t,enumerable:!0}):r,t)),_c=t=>Qo(vr({},"__esModule",{value:!0}),t);var ni=Ne(ln=>{"use strict";ln.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};ln.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 oi=Ne(hn=>{"use strict";hn.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};hn.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 ii=Ne(pn=>{"use strict";pn.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};pn.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 si=Ne(fn=>{"use strict";fn.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};fn.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 ci=Ne(mn=>{"use strict";mn.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}`};mn.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 di=Ne((ui,gn)=>{var ai=(function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=l,t.encode=f,t.familyOf=d,t.name=void 0,t.sizeOf=c,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:u=>e.test(u),encode(u,h,p){p=~~p,h=h||new Uint8Array(p+r);let m=u.length,E=0;for(let L=0;L<m;){let K=u.charCodeAt(L++);K===46?(h[p++]=E,E=0):E=E*10+(K-48)}return h[p]=E,h},decode(u,h){return h=~~h,`${u[h++]}.${u[h++]}.${u[h++]}.${u[h]}`}};t.v4=i;let s={name:"v6",size:o,isFormat:u=>u.length>0&&n.test(u),encode(u,h,p){p=~~p;let m=p+o,E=-1,L=0,K=0,O=!0,k=!1;h=h||new Uint8Array(p+o);for(let R=0;R<u.length;R++){let M=u.charCodeAt(R);M===58?(O?E!==-1?(p<m&&(h[p]=0),p<m-1&&(h[p+1]=0),p+=2):p<m&&(E=p):(k===!0?(p<m&&(h[p]=K),p++):(p<m&&(h[p]=L>>8),p<m-1&&(h[p+1]=L&255),p+=2),L=0,K=0),O=!0,k=!1):M===46?(p<m&&(h[p]=K),p++,K=0,L=0,O=!1,k=!0):(O=!1,M>=97?M-=87:M>=65?M-=55:(M-=48,K=K*10+M),L=(L<<4)+M)}if(O===!1)k===!0?(p<m&&(h[p]=K),p++):(p<m&&(h[p]=L>>8),p<m-1&&(h[p+1]=L&255),p+=2);else if(E===0)p<m&&(h[p]=0),p<m-1&&(h[p+1]=0),p+=2;else if(E!==-1){p+=2;for(let R=Math.min(p-1,m-1);R>=E+2;R--)h[R]=h[R-2];h[E]=0,h[E+1]=0,E=p}if(E!==p&&E!==-1)for(p>m-2&&(p=m-2);m>E;)h[--m]=p<m&&p>E?h[--p]:0;else for(;p<m;)h[p++]=0;return h},decode(u,h){h=~~h;let p="";for(let m=0;m<o;m+=2)m!==0&&(p+=":"),p+=(u[h+m]<<8|u[h+m+1]).toString(16);return p.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};t.v6=s;let a="ip";t.name=a;function c(u){if(i.isFormat(u))return i.size;if(s.isFormat(u))return s.size;throw Error(`Invalid ip address: ${u}`)}function d(u){return c(u)===i.size?1:2}function f(u,h,p){p=~~p;let m=c(u);return typeof h=="function"&&(h=h(p+m)),m===i.size?i.encode(u,h,p):s.encode(u,h,p)}function l(u,h,p){if(h=~~h,p=p||u.length-h,p===i.size)return i.decode(u,h,p);if(p===s.size)return s.decode(u,h,p);throw Error(`Invalid buffer size needs to be ${i.size} for v4 or ${s.size} for v6.`)}return"default"in t?t.default:t})({});typeof define=="function"&&define.amd?define([],function(){return ai}):typeof gn=="object"&&typeof ui=="object"&&(gn.exports=ai)});var pi=Ne(I=>{"use strict";var v=de("buffer").Buffer,et=ni(),Oc=oi(),Pc=ii(),Ur=si(),yn=ci(),xt=di(),Nc=0,li=32768,wn=32768,Rc=~wn,hi=32768,Kc=~hi,x=I.name={};x.encode=function(t,e,r,{mail:n=!1}={}){e||(e=v.alloc(x.encodingLength(t))),r||(r=0);let o=r,i=t.replace(/^\.|\.$/gm,"");if(i.length){let s=[];if(n){let a="";i.split(".").forEach(c=>{c.endsWith("\\")?a+=(a.length?".":"")+c.slice(0,-1):s.length===0&&a.length?s.push(a+"."+c):s.push(c)})}else s=i.split(".");for(let a=0;a<s.length;a++){let c=e.write(s[a],r+1);e[r]=c,r+=c+1}}return e[r++]=0,x.encode.bytes=r-o,e};x.encode.bytes=0;x.decode=function(t,e,{mail:r=!1}={}){e||(e=0);let n=[],o=e,i=0,s=0,a=!1;for(;;){if(e>=t.length)throw new Error("Cannot decode name (buffer overflow)");let c=t[e++];if(s+=a?0:1,c===0)break;if((c&192)===0){if(e+c>t.length)throw new Error("Cannot decode name (buffer overflow)");if(i+=c+1,i>254)throw new Error("Cannot decode name (name too long)");let d=t.toString("utf-8",e,e+c);r&&(d=d.replace(/\./g,"\\.")),n.push(d),e+=c,s+=a?0:c}else if((c&192)===192){if(e+1>t.length)throw new Error("Cannot decode name (buffer overflow)");let d=t.readUInt16BE(e-1)-49152;if(d>=o)throw new Error("Cannot decode name (bad pointer)");e=d,o=d,s+=a?0:1,a=!0}else throw new Error("Cannot decode name (bad label)")}return x.decode.bytes=s,n.length===0?".":n.join(".")};x.decode.bytes=0;x.encodingLength=function(t){return t==="."||t===".."?1:v.byteLength(t.replace(/^\.|\.$/gm,""))+2};var D={};D.encode=function(t,e,r){e||(e=v.alloc(D.encodingLength(t))),r||(r=0);let n=e.write(t,r+1);return e[r]=n,D.encode.bytes=n+1,e};D.encode.bytes=0;D.decode=function(t,e){e||(e=0);let r=t[e],n=t.toString("utf-8",e+1,e+1+r);return D.decode.bytes=r+1,n};D.decode.bytes=0;D.encodingLength=function(t){return v.byteLength(t)+1};var Le={};Le.encode=function(t,e,r){e||(e=Le.encodingLength(t)),r||(r=0);let n=(t.flags||0)&32767,o=t.type==="response"?li:Nc;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};Le.encode.bytes=12;Le.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&li?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:Pc.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:Oc.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))}};Le.decode.bytes=12;Le.encodingLength=function(){return 12};var $e=I.unknown={};$e.encode=function(t,e,r){return e||(e=v.alloc($e.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.length,r),t.copy(e,r+2),$e.encode.bytes=t.length+2,e};$e.encode.bytes=0;$e.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=t.slice(e+2,e+2+r);return $e.decode.bytes=r+2,n};$e.decode.bytes=0;$e.encodingLength=function(t){return t.length+2};var je=I.ns={};je.encode=function(t,e,r){return e||(e=v.alloc(je.encodingLength(t))),r||(r=0),x.encode(t,e,r+2),e.writeUInt16BE(x.encode.bytes,r),je.encode.bytes=x.encode.bytes+2,e};je.encode.bytes=0;je.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=x.decode(t,e+2);return je.decode.bytes=r+2,n};je.decode.bytes=0;je.encodingLength=function(t){return x.encodingLength(t)+2};var Ge=I.soa={};Ge.encode=function(t,e,r){e||(e=v.alloc(Ge.encodingLength(t))),r||(r=0);let n=r;return r+=2,x.encode(t.mname,e,r),r+=x.encode.bytes,x.encode(t.rname,e,r,{mail:!0}),r+=x.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),Ge.encode.bytes=r-n,e};Ge.encode.bytes=0;Ge.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=x.decode(t,e),e+=x.decode.bytes,n.rname=x.decode(t,e,{mail:!0}),e+=x.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,Ge.decode.bytes=e-r,n};Ge.decode.bytes=0;Ge.encodingLength=function(t){return 22+x.encodingLength(t.mname)+x.encodingLength(t.rname)};var Ye=I.txt={};Ye.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]=v.from(t[o])),!v.isBuffer(t[o]))throw new Error("Must be a Buffer");e||(e=v.alloc(Ye.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),Ye.encode.bytes=r-n,e};Ye.encode.bytes=0;Ye.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 Ye.decode.bytes=e-r,o};Ye.decode.bytes=0;Ye.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 We=I.null={};We.encode=function(t,e,r){e||(e=v.alloc(We.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=v.from(t)),t||(t=v.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),We.encode.bytes=r-n,e};We.encode.bytes=0;We.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,We.decode.bytes=e-r,o};We.decode.bytes=0;We.encodingLength=function(t){return t?(v.isBuffer(t)?t.length:v.byteLength(t))+2:2};var Xe=I.hinfo={};Xe.encode=function(t,e,r){e||(e=v.alloc(Xe.encodingLength(t))),r||(r=0);let n=r;return r+=2,D.encode(t.cpu,e,r),r+=D.encode.bytes,D.encode(t.os,e,r),r+=D.encode.bytes,e.writeUInt16BE(r-n-2,n),Xe.encode.bytes=r-n,e};Xe.encode.bytes=0;Xe.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.cpu=D.decode(t,e),e+=D.decode.bytes,n.os=D.decode(t,e),e+=D.decode.bytes,Xe.decode.bytes=e-r,n};Xe.decode.bytes=0;Xe.encodingLength=function(t){return D.encodingLength(t.cpu)+D.encodingLength(t.os)+2};var Be=I.ptr={},kc=I.cname=Be,Mc=I.dname=Be;Be.encode=function(t,e,r){return e||(e=v.alloc(Be.encodingLength(t))),r||(r=0),x.encode(t,e,r+2),e.writeUInt16BE(x.encode.bytes,r),Be.encode.bytes=x.encode.bytes+2,e};Be.encode.bytes=0;Be.decode=function(t,e){e||(e=0);let r=x.decode(t,e+2);return Be.decode.bytes=x.decode.bytes+2,r};Be.decode.bytes=0;Be.encodingLength=function(t){return x.encodingLength(t)+2};var Ze=I.srv={};Ze.encode=function(t,e,r){e||(e=v.alloc(Ze.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),x.encode(t.target,e,r+8);let n=x.encode.bytes+6;return e.writeUInt16BE(n,r),Ze.encode.bytes=n+2,e};Ze.encode.bytes=0;Ze.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=x.decode(t,e+8),Ze.decode.bytes=r+2,n};Ze.decode.bytes=0;Ze.encodingLength=function(t){return 8+x.encodingLength(t.target)};var fe=I.caa={};fe.ISSUER_CRITICAL=128;fe.encode=function(t,e,r){let n=fe.encodingLength(t);return e||(e=v.alloc(fe.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=fe.ISSUER_CRITICAL),e.writeUInt16BE(n-2,r),r+=2,e.writeUInt8(t.flags||0,r),r+=1,D.encode(t.tag,e,r),r+=D.encode.bytes,e.write(t.value,r),r+=v.byteLength(t.value),fe.encode.bytes=n,e};fe.encode.bytes=0;fe.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=D.decode(t,e),e+=D.decode.bytes,o.value=t.toString("utf-8",e,n+r),o.issuerCritical=!!(o.flags&fe.ISSUER_CRITICAL),fe.decode.bytes=r+2,o};fe.decode.bytes=0;fe.encodingLength=function(t){return D.encodingLength(t.tag)+D.encodingLength(t.value)+2};var dt=I.mx={};dt.encode=function(t,e,r){e||(e=v.alloc(dt.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,x.encode(t.exchange,e,r),r+=x.encode.bytes,e.writeUInt16BE(r-n-2,n),dt.encode.bytes=r-n,e};dt.encode.bytes=0;dt.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.preference=t.readUInt16BE(e),e+=2,n.exchange=x.decode(t,e),e+=x.decode.bytes,dt.decode.bytes=e-r,n};dt.encodingLength=function(t){return 4+x.encodingLength(t.exchange)};var Qe=I.a={};Qe.encode=function(t,e,r){return e||(e=v.alloc(Qe.encodingLength(t))),r||(r=0),e.writeUInt16BE(4,r),r+=2,xt.v4.encode(t,e,r),Qe.encode.bytes=6,e};Qe.encode.bytes=0;Qe.decode=function(t,e){e||(e=0),e+=2;let r=xt.v4.decode(t,e);return Qe.decode.bytes=6,r};Qe.decode.bytes=0;Qe.encodingLength=function(){return 6};var Je=I.aaaa={};Je.encode=function(t,e,r){return e||(e=v.alloc(Je.encodingLength(t))),r||(r=0),e.writeUInt16BE(16,r),r+=2,xt.v6.encode(t,e,r),Je.encode.bytes=18,e};Je.encode.bytes=0;Je.decode=function(t,e){e||(e=0),e+=2;let r=xt.v6.decode(t,e);return Je.decode.bytes=18,r};Je.decode.bytes=0;Je.encodingLength=function(){return 18};var le=I.option={};le.encode=function(t,e,r){e||(e=v.alloc(le.encodingLength(t))),r||(r=0);let n=r,o=yn.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,s=t.family||xt.familyOf(t.ip),a=xt.encode(t.ip,v.alloc),c=Math.ceil(i/8);e.writeUInt16BE(c+4,r),r+=2,e.writeUInt16BE(s,r),r+=2,e.writeUInt8(i,r++),e.writeUInt8(t.scopePrefixLength||0,r++),a.copy(e,r,0,c),r+=c;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 d=t.length||0;e.writeUInt16BE(d,r),r+=2,e.fill(0,r,r+d),r+=d;break;case 14:let f=t.tags.length*2;e.writeUInt16BE(f,r),r+=2;for(let l of t.tags)e.writeUInt16BE(l,r),r+=2;break;default:throw new Error(`Unknown roption code: ${t.code}`)}return le.encode.bytes=r-n,e};le.encode.bytes=0;le.decode=function(t,e){e||(e=0);let r={};r.code=t.readUInt16BE(e),r.type=yn.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=v.alloc(r.family===1?4:16);t.copy(o,0,e,e+n-4),r.ip=xt.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 le.decode.bytes=n+4,r};le.decode.bytes=0;le.encodingLength=function(t){if(t.data)return t.data.length+4;switch(yn.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 ge=I.opt={};ge.encode=function(t,e,r){e||(e=v.alloc(ge.encodingLength(t))),r||(r=0);let n=r,o=Tt(t,le);return e.writeUInt16BE(o,r),r=Wt(t,le,e,r+2),ge.encode.bytes=r-n,e};ge.encode.bytes=0;ge.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++]=le.decode(t,e),e+=le.decode.bytes,o-=le.decode.bytes;return ge.decode.bytes=e-r,n};ge.decode.bytes=0;ge.encodingLength=function(t){return 2+Tt(t||[],le)};var ce=I.dnskey={};ce.PROTOCOL_DNSSEC=3;ce.ZONE_KEY=128;ce.SECURE_ENTRYPOINT=32768;ce.encode=function(t,e,r){e||(e=v.alloc(ce.encodingLength(t))),r||(r=0);let n=r,o=t.key;if(!v.isBuffer(o))throw new Error("Key must be a Buffer");return r+=2,e.writeUInt16BE(t.flags,r),r+=2,e.writeUInt8(ce.PROTOCOL_DNSSEC,r),r+=1,e.writeUInt8(t.algorithm,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,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;var n={},o=t.readUInt16BE(e);if(e+=2,n.flags=t.readUInt16BE(e),e+=2,t.readUInt8(e)!==ce.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,ce.decode.bytes=e-r,n};ce.decode.bytes=0;ce.encodingLength=function(t){return 6+v.byteLength(t.key)};var Re=I.rrsig={};Re.encode=function(t,e,r){e||(e=v.alloc(Re.encodingLength(t))),r||(r=0);let n=r,o=t.signature;if(!v.isBuffer(o))throw new Error("Signature must be a Buffer");return r+=2,e.writeUInt16BE(et.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,x.encode(t.signersName,e,r),r+=x.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=et.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=x.decode(t,e),e+=x.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+x.encodingLength(t.signersName)+v.byteLength(t.signature)};var Ke=I.rp={};Ke.encode=function(t,e,r){e||(e=v.alloc(Ke.encodingLength(t))),r||(r=0);let n=r;return r+=2,x.encode(t.mbox||".",e,r,{mail:!0}),r+=x.encode.bytes,x.encode(t.txt||".",e,r),r+=x.encode.bytes,Ke.encode.bytes=r-n,e.writeUInt16BE(Ke.encode.bytes-2,n),e};Ke.encode.bytes=0;Ke.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mbox=x.decode(t,e,{mail:!0})||".",e+=x.decode.bytes,n.txt=x.decode(t,e)||".",e+=x.decode.bytes,Ke.decode.bytes=e-r,n};Ke.decode.bytes=0;Ke.encodingLength=function(t){return 2+x.encodingLength(t.mbox||".")+x.encodingLength(t.txt||".")};var W={};W.encode=function(t,e,r){e||(e=v.alloc(W.encodingLength(t))),r||(r=0);let n=r;for(var o=[],i=0;i<t.length;i++){var s=et.toType(t[i]);o[s>>8]===void 0&&(o[s>>8]=[]),o[s>>8][s>>3&31]|=1<<7-(s&7)}for(i=0;i<o.length;i++)if(o[i]!==void 0){var a=v.from(o[i]);e.writeUInt8(i,r),r+=1,e.writeUInt8(a.length,r),r+=1,a.copy(e,r),r+=a.length}return W.encode.bytes=r-n,e};W.encode.bytes=0;W.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 s=t.readUInt8(e);e+=1;for(var a=0;a<s;a++)for(var c=t.readUInt8(e+a),d=0;d<8;d++)if(c&1<<7-d){var f=et.toString(i<<8|a<<3|d);o.push(f)}e+=s}return W.decode.bytes=e-n,o};W.decode.bytes=0;W.encodingLength=function(t){for(var e=[],r=0;r<t.length;r++){var n=et.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 ke=I.nsec={};ke.encode=function(t,e,r){e||(e=v.alloc(ke.encodingLength(t))),r||(r=0);let n=r;return r+=2,x.encode(t.nextDomain,e,r),r+=x.encode.bytes,W.encode(t.rrtypes,e,r),r+=W.encode.bytes,ke.encode.bytes=r-n,e.writeUInt16BE(ke.encode.bytes-2,n),e};ke.encode.bytes=0;ke.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.nextDomain=x.decode(t,e),e+=x.decode.bytes,n.rrtypes=W.decode(t,e,o-(e-r)),e+=W.decode.bytes,ke.decode.bytes=e-r,n};ke.decode.bytes=0;ke.encodingLength=function(t){return 2+x.encodingLength(t.nextDomain)+W.encodingLength(t.rrtypes)};var Me=I.nsec3={};Me.encode=function(t,e,r){e||(e=v.alloc(Me.encodingLength(t))),r||(r=0);let n=r,o=t.salt;if(!v.isBuffer(o))throw new Error("salt must be a Buffer");let i=t.nextDomain;if(!v.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,W.encode(t.rrtypes,e,r),r+=W.encode.bytes,Me.encode.bytes=r-n,e.writeUInt16BE(Me.encode.bytes-2,n),e};Me.encode.bytes=0;Me.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 s=t.readUInt8(e);return e+=1,n.nextDomain=t.slice(e,e+s),e+=s,n.rrtypes=W.decode(t,e,o-(e-r)),e+=W.decode.bytes,Me.decode.bytes=e-r,n};Me.decode.bytes=0;Me.encodingLength=function(t){return 8+t.salt.length+t.nextDomain.length+W.encodingLength(t.rrtypes)};var Fe=I.ds={};Fe.encode=function(t,e,r){e||(e=v.alloc(Fe.encodingLength(t))),r||(r=0);let n=r,o=t.digest;if(!v.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,Fe.encode.bytes=r-n,e.writeUInt16BE(Fe.encode.bytes-2,n),e};Fe.encode.bytes=0;Fe.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,Fe.decode.bytes=e-r,n};Fe.decode.bytes=0;Fe.encodingLength=function(t){return 6+v.byteLength(t.digest)};var me=I.sshfp={};me.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};me.encode=function(e,r,n){r||(r=v.alloc(me.encodingLength(e))),n||(n=0);let o=n;n+=2,r[n]=e.algorithm,n+=1,r[n]=e.hash,n+=1;let i=v.from(e.fingerprint.toUpperCase(),"hex");if(i.length!==me.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return i.copy(r,n),n+=i.byteLength,me.encode.bytes=n-o,r.writeUInt16BE(me.encode.bytes-2,o),r};me.encode.bytes=0;me.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=me.getFingerprintLengthForHashType(o.hash);return o.fingerprint=e.slice(r,r+i).toString("hex").toUpperCase(),r+=i,me.decode.bytes=r-n,o};me.decode.bytes=0;me.encodingLength=function(t){return 4+v.from(t.fingerprint,"hex").byteLength};var He=I.naptr={};He.encode=function(t,e,r){e||(e=v.alloc(He.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,D.encode(t.flags,e,r),r+=D.encode.bytes,D.encode(t.services,e,r),r+=D.encode.bytes,D.encode(t.regexp,e,r),r+=D.encode.bytes,x.encode(t.replacement,e,r),r+=x.encode.bytes,He.encode.bytes=r-n,e.writeUInt16BE(He.encode.bytes-2,n),e};He.encode.bytes=0;He.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=D.decode(t,e),e+=D.decode.bytes,n.services=D.decode(t,e),e+=D.decode.bytes,n.regexp=D.decode(t,e),e+=D.decode.bytes,n.replacement=x.decode(t,e),e+=x.decode.bytes,He.decode.bytes=e-r,n};He.decode.bytes=0;He.encodingLength=function(t){return D.encodingLength(t.flags)+D.encodingLength(t.services)+D.encodingLength(t.regexp)+x.encodingLength(t.replacement)+6};var qe=I.tlsa={};qe.encode=function(t,e,r){e||(e=v.alloc(qe.encodingLength(t))),r||(r=0);let n=r,o=t.certificate;if(!v.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,qe.encode.bytes=r-n,e.writeUInt16BE(qe.encode.bytes-2,n),e};qe.encode.bytes=0;qe.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,qe.decode.bytes=e-r,n};qe.decode.bytes=0;qe.encodingLength=function(t){return 5+v.byteLength(t.certificate)};var xn=I.record=function(t){switch(t.toUpperCase()){case"A":return Qe;case"PTR":return Be;case"CNAME":return kc;case"DNAME":return Mc;case"TXT":return Ye;case"NULL":return We;case"AAAA":return Je;case"SRV":return Ze;case"HINFO":return Xe;case"CAA":return fe;case"NS":return je;case"SOA":return Ge;case"MX":return dt;case"OPT":return ge;case"DNSKEY":return ce;case"RRSIG":return Re;case"RP":return Ke;case"NSEC":return ke;case"NSEC3":return Me;case"SSHFP":return me;case"DS":return Fe;case"NAPTR":return He;case"TLSA":return qe}return $e},Z=I.answer={};Z.encode=function(t,e,r){e||(e=v.alloc(Z.encodingLength(t))),r||(r=0);let n=r;if(x.encode(t.name,e,r),r+=x.encode.bytes,e.writeUInt16BE(et.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,ge.encode(t.options||[],e,r),r+=ge.encode.bytes}else{let o=Ur.toClass(t.class===void 0?"IN":t.class);t.flush&&(o|=wn),e.writeUInt16BE(o,r+2),e.writeUInt32BE(t.ttl||0,r+4),r+=8;let i=xn(t.type);i.encode(t.data,e,r),r+=i.encode.bytes}return Z.encode.bytes=r-n,e};Z.encode.bytes=0;Z.decode=function(t,e){e||(e=0);let r={},n=e;if(r.name=x.decode(t,e),e+=x.decode.bytes,r.type=et.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=ge.decode(t,e+8),e+=8+ge.decode.bytes;else{let o=t.readUInt16BE(e+2);r.ttl=t.readUInt32BE(e+4),r.class=Ur.toString(o&Rc),r.flush=!!(o&wn);let i=xn(r.type);r.data=i.decode(t,e+8),e+=8+i.decode.bytes}return Z.decode.bytes=e-n,r};Z.decode.bytes=0;Z.encodingLength=function(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return x.encodingLength(t.name)+8+xn(t.type).encodingLength(e)};var Ce=I.question={};Ce.encode=function(t,e,r){e||(e=v.alloc(Ce.encodingLength(t))),r||(r=0);let n=r;return x.encode(t.name,e,r),r+=x.encode.bytes,e.writeUInt16BE(et.toType(t.type),r),r+=2,e.writeUInt16BE(Ur.toClass(t.class===void 0?"IN":t.class),r),r+=2,Ce.encode.bytes=r-n,t};Ce.encode.bytes=0;Ce.decode=function(t,e){e||(e=0);let r=e,n={};return n.name=x.decode(t,e),e+=x.decode.bytes,n.type=et.toString(t.readUInt16BE(e)),e+=2,n.class=Ur.toString(t.readUInt16BE(e)),e+=2,!!(n.class&hi)&&(n.class&=Kc),Ce.decode.bytes=e-r,n};Ce.decode.bytes=0;Ce.encodingLength=function(t){return x.encodingLength(t.name)+4};I.AUTHORITATIVE_ANSWER=1024;I.TRUNCATED_RESPONSE=512;I.RECURSION_DESIRED=256;I.RECURSION_AVAILABLE=128;I.AUTHENTIC_DATA=32;I.CHECKING_DISABLED=16;I.DNSSEC_OK=32768;I.encode=function(t,e,r){let n=!e;n&&(e=v.alloc(I.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=[]),Le.encode(t,e,r),r+=Le.encode.bytes,r=Wt(t.questions,Ce,e,r),r=Wt(t.answers,Z,e,r),r=Wt(t.authorities,Z,e,r),r=Wt(t.additionals,Z,e,r),I.encode.bytes=r-o,n&&I.encode.bytes!==e.length?e.slice(0,I.encode.bytes):e};I.encode.bytes=0;I.decode=function(t,e){e||(e=0);let r=e,n=Le.decode(t,e);return e+=Le.decode.bytes,e=Lr(n.questions,Ce,t,e),e=Lr(n.answers,Z,t,e),e=Lr(n.authorities,Z,t,e),e=Lr(n.additionals,Z,t,e),I.decode.bytes=e-r,n};I.decode.bytes=0;I.encodingLength=function(t){return Le.encodingLength(t)+Tt(t.questions||[],Ce)+Tt(t.answers||[],Z)+Tt(t.authorities||[],Z)+Tt(t.additionals||[],Z)};I.streamEncode=function(t){let e=I.encode(t),r=v.alloc(2);r.writeUInt16BE(e.byteLength);let n=v.concat([r,e]);return I.streamEncode.bytes=n.byteLength,n};I.streamEncode.bytes=0;I.streamDecode=function(t){let e=t.readUInt16BE(0);if(t.byteLength<e+2)return null;let r=I.decode(t.slice(2));return I.streamDecode.bytes=I.decode.bytes,r};I.streamDecode.bytes=0;function Tt(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function Wt(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 Lr(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 gi=Ne((Jl,mi)=>{"use strict";var fi=$c;process.nextTick(zc,42);mi.exports=Fc;function Fc(t){var e=n;return r;function r(o){e(o||qc)}function n(o){var i=[o];e=s,t(a);function s(c){i.push(c)}function a(c){var d=arguments;for(e=Hc(c)?n:f;i.length;)f(i.shift());function f(l){fi(Vc,l,d)}}}}function Hc(t){return Object.prototype.toString.call(t)==="[object Error]"}function qc(){}function Vc(t,e){t.apply(null,e)}function zc(t){t===42&&(fi=process.nextTick)}function $c(t,e,r){process.nextTick(function(){t(e,r)})}});var xi=Ne((eh,wi)=>{var bn=pi(),jc=de("dgram"),Gc=gi(),Yc=de("events"),In=de("os"),En=function(){};wi.exports=function(t){t||(t={});var e=new Yc.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},s={},a=!1,c=null;if(n==="udp6"&&(!o||!t.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var d=t.socket||jc.createSocket({type:n,reuseAddr:t.reuseAddr!==!1,toString:function(){return n}});d.on("error",function(l){l.code==="EACCES"||l.code==="EADDRINUSE"?e.emit("error",l):e.emit("warning",l)}),d.on("message",function(l,u){try{l=bn.decode(l)}catch(h){e.emit("warning",h);return}e.emit("packet",l,u),l.type==="query"&&e.emit("query",l,u),l.type==="response"&&e.emit("response",l,u)}),d.on("listening",function(){r||(r=i.port=d.address().port),t.multicast!==!1&&(e.update(),c=setInterval(e.update,5e3),d.setMulticastTTL(t.ttl||255),d.setMulticastLoopback(t.loopback!==!1))});var f=Gc(function(l){if(!r||t.bind===!1)return l(null);d.once("error",l),d.bind(r,t.bind||t.interface,function(){d.removeListener("error",l),l(null)})});return f(function(l){if(l)return e.emit("error",l);e.emit("ready")}),e.send=function(l,u,h){if(typeof u=="function")return e.send(l,null,u);h||(h=En),u?!u.host&&!u.address&&(u.address=i.address):u=i,f(p);function p(m){if(a)return h();if(m)return h(m);var E=bn.encode(l);d.send(E,0,E.length,u.port,u.address||u.host,h)}},e.response=e.respond=function(l,u,h){Array.isArray(l)&&(l={answers:l}),l.type="response",l.flags=(l.flags||0)|bn.AUTHORITATIVE_ANSWER,e.send(l,u,h)},e.query=function(l,u,h,p){if(typeof u=="function")return e.query(l,null,null,u);if(typeof u=="object"&&u&&u.port)return e.query(l,null,u,h);if(typeof h=="function")return e.query(l,u,null,h);p||(p=En),typeof l=="string"&&(l=[{name:l,type:u||"ANY"}]),Array.isArray(l)&&(l={type:"query",questions:l}),l.type="query",e.send(l,h,p)},e.destroy=function(l){if(l||(l=En),a)return process.nextTick(l);a=!0,clearInterval(c);for(var u in s)try{d.dropMembership(o,u)}catch{}s={},d.close(l)},e.update=function(){for(var l=t.interface?[].concat(t.interface):Xc(),u=!1,h=0;h<l.length;h++){var p=l[h];if(!s[p])try{d.addMembership(o,p),s[p]=!0,u=!0}catch(m){e.emit("warning",m)}}if(u){if(d.setMulticastInterface)try{d.setMulticastInterface(t.interface||Wc())}catch(m){e.emit("warning",m)}e.emit("networkInterface")}},e};function Wc(){for(var t=In.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(yi(i.family)&&!i.internal)return In.platform()==="darwin"&&e[r]==="en0"?i.address:"0.0.0.0"}return"127.0.0.1"}function Xc(){for(var t=In.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 s=o[i];if(yi(s.family)){r.push(s.address);break}}return r}function yi(t){return t===4||t==="IPv4"}});var oc=Ne(wr=>{(function(){var t,e,r,n,o,i,s,a;a=function(c){var d,f,l,u;return d=(c&255<<24)>>>24,f=(c&255<<16)>>>16,l=(c&65280)>>>8,u=c&255,[d,f,l,u].join(".")},s=function(c){var d,f,l,u,h,p;for(d=[],l=u=0;u<=3&&c.length!==0;l=++u){if(l>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}p=e(c),h=p[0],f=p[1],c=c.substring(f),d.push(h)}if(c.length!==0)throw new Error("Invalid IP");switch(d.length){case 1:if(d[0]>4294967295)throw new Error("Invalid IP");return d[0]>>>0;case 2:if(d[0]>255||d[1]>16777215)throw new Error("Invalid IP");return(d[0]<<24|d[1])>>>0;case 3:if(d[0]>255||d[1]>255||d[2]>65535)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2])>>>0;case 4:if(d[0]>255||d[1]>255||d[2]>255||d[3]>255)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2]<<8|d[3])>>>0;default:throw new Error("Invalid IP")}},r=function(c){return c.charCodeAt(0)},n=r("0"),i=r("a"),o=r("A"),e=function(c){var d,f,l,u,h;for(u=0,d=10,f="9",l=0,c.length>1&&c[l]==="0"&&(c[l+1]==="x"||c[l+1]==="X"?(l+=2,d=16):"0"<=c[l+1]&&c[l+1]<="9"&&(l++,d=8,f="7")),h=l;l<c.length;){if("0"<=c[l]&&c[l]<=f)u=u*d+(r(c[l])-n)>>>0;else if(d===16)if("a"<=c[l]&&c[l]<="f")u=u*d+(10+r(c[l])-i)>>>0;else if("A"<=c[l]&&c[l]<="F")u=u*d+(10+r(c[l])-o)>>>0;else break;else break;if(u>4294967295)throw new Error("too large");l++}if(l===h)throw new Error("empty octet");return[u,l]},t=(function(){function c(d,f){var l,u,h,p;if(typeof d!="string")throw new Error("Missing `net' parameter");if(f||(p=d.split("/",2),d=p[0],f=p[1]),f||(f=32),typeof f=="string"&&f.indexOf(".")>-1){try{this.maskLong=s(f)}catch(m){throw l=m,new Error("Invalid mask: "+f)}for(u=h=32;h>=0;u=--h)if(this.maskLong===4294967295<<32-u>>>0){this.bitmask=u;break}}else if(f||f===0)this.bitmask=parseInt(f,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(s(d)&this.maskLong)>>>0}catch(m){throw l=m,new Error("Invalid net address: "+d)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+f);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(d){return typeof d=="string"&&(d.indexOf("/")>0||d.split(".").length!==4)&&(d=new c(d)),d instanceof c?this.contains(d.base)&&this.contains(d.broadcast||d.last):(s(d)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(d){return d==null&&(d=1),new c(a(this.netLong+this.size*d),this.mask)},c.prototype.forEach=function(d){var f,l,u;for(u=s(this.first),l=s(this.last),f=0;u<=l;)d(a(u),u,f),f++,u++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c})(),wr.ip2long=s,wr.long2ip=a,wr.Netmask=t}).call(wr)});var pl={};pe(pl,{mdns:()=>hl});var ve=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},Sr=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var Ar=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},Br=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var Yt=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var Jo=Symbol.for("@libp2p/peer-discovery");var dn=Symbol.for("@libp2p/peer-id");var ei=de("node:events"),ti=(t,...e)=>{try{(0,ei.setMaxListeners)(t,...e)}catch{}};var Cr=class extends EventTarget{#e=new Map;constructor(){super(),ti(1/0,this)}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 CustomEvent(e,r))}};var ri=Symbol.for("@libp2p/service-capabilities"),El=Symbol.for("@libp2p/service-dependencies");var Bc=Dt(xi(),1);var Cn={};pe(Cn,{base58btc:()=>j,base58flickr:()=>na});var th=new Uint8Array(0);function bi(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 Se(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 Ei(t){return new TextEncoder().encode(t)}function Ii(t){return new TextDecoder().decode(t)}function Zc(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),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=t.length,c=t.charAt(0),d=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var m=0,E=0,L=0,K=p.length;L!==K&&p[L]===0;)L++,m++;for(var O=(K-L)*f+1>>>0,k=new Uint8Array(O);L!==K;){for(var R=p[L],M=0,ee=O-1;(R!==0||M<E)&&ee!==-1;ee--,M++)R+=256*k[ee]>>>0,k[ee]=R%a>>>0,R=R/a>>>0;if(R!==0)throw new Error("Non-zero carry");E=M,L++}for(var te=O-E;te!==O&&k[te]===0;)te++;for(var T=c.repeat(m);te<O;++te)T+=t.charAt(k[te]);return T}function u(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var m=0;if(p[m]!==" "){for(var E=0,L=0;p[m]===c;)E++,m++;for(var K=(p.length-m)*d+1>>>0,O=new Uint8Array(K);p[m];){var k=r[p.charCodeAt(m)];if(k===255)return;for(var R=0,M=K-1;(k!==0||R<L)&&M!==-1;M--,R++)k+=a*O[M]>>>0,O[M]=k%256>>>0,k=k/256>>>0;if(k!==0)throw new Error("Non-zero carry");L=R,m++}if(p[m]!==" "){for(var ee=K-L;ee!==K&&O[ee]===0;)ee++;for(var te=new Uint8Array(E+(K-ee)),T=E;ee!==K;)te[T++]=O[ee++];return te}}}function h(p){var m=u(p);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:u,decode:h}}var Qc=Zc,Jc=Qc,Si=Jc;var vn=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")}},Sn=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,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 Ai(this,e)}},An=class{decoders;constructor(e){this.decoders=e}or(e){return Ai(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 Ai(t,e){return new An({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var Bn=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 vn(e,r,n),this.decoder=new Sn(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function _t({name:t,prefix:e,encode:r,decode:n}){return new Bn(t,e,r,n)}function lt({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=Si(r,t);return _t({prefix:e,name:t,encode:n,decode:i=>Se(o(i))})}function ea(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let d=0;d<o;++d){let f=e[t[d]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|f,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function ta(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],s+=8;s>r;)s-=r,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function ra(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function z({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=ra(n);return _t({prefix:e,name:t,encode(i){return ta(i,n,r)},decode(i){return ea(i,o,r,t)}})}var j=lt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),na=lt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ln={};pe(Ln,{base32:()=>ht,base32hex:()=>ca,base32hexpad:()=>ua,base32hexpadupper:()=>da,base32hexupper:()=>aa,base32pad:()=>ia,base32padupper:()=>sa,base32upper:()=>oa,base32z:()=>la});var ht=z({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),oa=z({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ia=z({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),sa=z({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ca=z({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),aa=z({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ua=z({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),da=z({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),la=z({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Un={};pe(Un,{base36:()=>Xt,base36upper:()=>ha});var Xt=lt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ha=lt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var pa=Li,Bi=128,fa=127,ma=~fa,ga=Math.pow(2,31);function Li(t,e,r){e=e||[],r=r||0;for(var n=r;t>=ga;)e[r++]=t&255|Bi,t/=128;for(;t&ma;)e[r++]=t&255|Bi,t>>>=7;return e[r]=t|0,Li.bytes=r-n+1,e}var ya=Dn,wa=128,Ci=127;function Dn(t,n){var r=0,n=n||0,o=0,i=n,s,a=t.length;do{if(i>=a)throw Dn.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&Ci)<<o:(s&Ci)*Math.pow(2,o),o+=7}while(s>=wa);return Dn.bytes=i-n,r}var xa=Math.pow(2,7),ba=Math.pow(2,14),Ea=Math.pow(2,21),Ia=Math.pow(2,28),va=Math.pow(2,35),Sa=Math.pow(2,42),Aa=Math.pow(2,49),Ba=Math.pow(2,56),Ca=Math.pow(2,63),La=function(t){return t<xa?1:t<ba?2:t<Ea?3:t<Ia?4:t<va?5:t<Sa?6:t<Aa?7:t<Ba?8:t<Ca?9:10},Ua={encode:pa,decode:ya,encodingLength:La},Da=Ua,Zt=Da;function Qt(t,e=0){return[Zt.decode(t,e),Zt.decode.bytes]}function Ot(t,e,r=0){return Zt.encode(t,e,r),e}function Pt(t){return Zt.encodingLength(t)}function Rt(t,e){let r=e.byteLength,n=Pt(t),o=n+Pt(r),i=new Uint8Array(o+r);return Ot(t,i,0),Ot(r,i,n),i.set(e,o),new Nt(t,r,e,i)}function Jt(t){let e=Se(t),[r,n]=Qt(e),[o,i]=Qt(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Nt(r,o,s,e)}function Ui(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&bi(t.bytes,r.bytes)}}var Nt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function Di(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return _a(r,Tn(t),e??j.encoder);default:return Oa(r,Tn(t),e??ht.encoder)}}var Ti=new WeakMap;function Tn(t){let e=Ti.get(t);if(e==null){let r=new Map;return Ti.set(t,r),r}return e}var Q=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!==er)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Pa)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=Rt(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&&Ui(e.multihash,n.multihash)}toString(e){return Di(this,e)}toJSON(){return{"/":Di(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:s}=r;return new t(n,o,i,s??_i(n,o,i.bytes))}else if(r[Na]===!0){let{version:n,multihash:o,code:i}=r,s=Jt(o);return t.create(n,i,s)}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!==er)throw new Error(`Version 0 CID must use dag-pb (code: ${er}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=_i(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,er,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=Se(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new Nt(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,u]=Qt(e.subarray(r));return r+=u,l},o=n(),i=er;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),d=r+c,f=d-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:f,size:d}}static parse(e,r){let[n,o]=Ta(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 Tn(i).set(n,e),i}};function Ta(t,e){switch(t[0]){case"Q":{let r=e??j;return[j.prefix,r.decode(`${j.prefix}${t}`)]}case j.prefix:{let r=e??j;return[j.prefix,r.decode(t)]}case ht.prefix:{let r=e??ht;return[ht.prefix,r.decode(t)]}case Xt.prefix:{let r=e??Xt;return[Xt.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function _a(t,e,r){let{prefix:n}=r;if(n!==j.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 Oa(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 er=112,Pa=18;function _i(t,e,r){let n=Pt(t),o=n+Pt(e),i=new Uint8Array(o+r.byteLength);return Ot(t,i,0),Ot(e,i,n),i.set(r,o),i}var Na=Symbol.for("@ipld/js-cid/CID");var _n={};pe(_n,{identity:()=>Ue});var Oi=0,Ra="identity",Pi=Se;function Ka(t,e){if(e?.truncate!=null&&e.truncate!==t.byteLength){if(e.truncate<0||e.truncate>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e.truncate)}return Rt(Oi,Pi(t))}var Ue={code:Oi,name:Ra,encode:Pi,digest:Ka};function ye(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 On=de("node:buffer");function bt(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function tt(t=0){return bt(On.Buffer.alloc(t))}function De(t=0){return bt(On.Buffer.allocUnsafe(t))}var Ni=de("node:buffer");function Ve(t,e){return bt(Ni.Buffer.concat(t,e))}var Ki=Symbol.for("@achingbrain/uint8arraylist");function Ri(t,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let r=0;for(let n of t){let o=r+n.byteLength;if(e<o)return{buf:n,index:e-r};r=o}throw new RangeError("index is out of bounds")}function Tr(t){return!!t?.[Ki]}var we=class t{bufs;length;[Ki]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let r=0;for(let n of e)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(Tr(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...e){this.prependAll(e)}prependAll(e){let r=0;for(let n of e.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(Tr(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(e){let r=Ri(this.bufs,e);return r.buf[r.index]}set(e,r){let n=Ri(this.bufs,e);n.buf[n.index]=r}write(e,r=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(r+n,e[n]);else if(Tr(e))for(let n=0;n<e.length;n++)this.set(r+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,r){let{bufs:n,length:o}=this._subList(e,r);return Ve(n,o)}subarray(e,r){let{bufs:n,length:o}=this._subList(e,r);return n.length===1?n[0]:Ve(n,o)}sublist(e,r){let{bufs:n,length:o}=this._subList(e,r),i=new t;return i.length=o,i.bufs=[...n],i}_subList(e,r){if(e=e??0,r=r??this.length,e<0&&(e=this.length+e),r<0&&(r=this.length+r),e<0||r>this.length)throw new RangeError("index is out of bounds");if(e===r)return{bufs:[],length:0};if(e===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,e>=c)continue;let d=e>=a&&e<c,f=r>a&&r<=c;if(d&&f){if(e===a&&r===c){n.push(s);break}let l=e-a;n.push(s.subarray(l,l+(r-e)));break}if(d){if(e===0){n.push(s);continue}n.push(s.subarray(e-a));continue}if(f){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!Tr(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),e.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let a=s,c=this.byteLength-n.byteLength,d=n.byteLength-1,f;for(let l=r;l<=c;l+=f){f=0;for(let u=d;u>=0;u--){let h=this.get(l+u);if(n[u]!==h){f=Math.max(1,u-a[h]);break}}if(f===0)return l}return-1}getInt8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(e,r){let n=De(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,e)}getInt16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(e,r,n){let o=tt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,e)}getInt32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(e,r,n){let o=tt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,e)}getBigInt64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(e,r,n){let o=tt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,e)}getUint8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(e,r){let n=De(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,e)}getUint16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(e,r,n){let o=tt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,e)}getUint32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(e,r,n){let o=tt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,e)}getBigUint64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(e,r,n){let o=tt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,e)}getFloat32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(e,r,n){let o=tt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,e)}getFloat64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(e,r,n){let o=tt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof t)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!ye(this.bufs[r],e.bufs[r]))return!1;return!0}static fromUint8Arrays(e,r){let n=new t;return n.bufs=e,r==null&&(r=e.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var Vi=de("node:buffer");var Pn={};pe(Pn,{base10:()=>ka});var ka=lt({prefix:"9",name:"base10",alphabet:"0123456789"});var Nn={};pe(Nn,{base16:()=>Ma,base16upper:()=>Fa});var Ma=z({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Fa=z({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Rn={};pe(Rn,{base2:()=>Ha});var Ha=z({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Kn={};pe(Kn,{base256emoji:()=>ja});var ki=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}"),qa=ki.reduce((t,e,r)=>(t[r]=e,t),[]),Va=ki.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function za(t){return t.reduce((e,r)=>(e+=qa[r],e),"")}function $a(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Va[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var ja=_t({prefix:"\u{1F680}",name:"base256emoji",encode:za,decode:$a});var Mn={};pe(Mn,{base64:()=>Ga,base64pad:()=>Ya,base64url:()=>kn,base64urlpad:()=>Wa});var Ga=z({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ya=z({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),kn=z({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Wa=z({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Fn={};pe(Fn,{base8:()=>Xa});var Xa=z({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Hn={};pe(Hn,{identity:()=>Za});var Za=_t({prefix:"\0",name:"identity",encode:t=>Ii(t),decode:t=>Ei(t)});var Kh=new TextEncoder,kh=new TextDecoder;var jn={};pe(jn,{sha256:()=>$n,sha512:()=>tu});var zn=Dt(de("crypto"),1);var eu=20;function Vn({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new qn(t,e,r,n,o)}var qn=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,i){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??eu,this.maxDigestLength=i}digest(e,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?Mi(n,this.code,r?.truncate):n.then(o=>Mi(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Mi(t,e,r){if(r!=null&&r!==t.byteLength){if(r>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,r)}return Rt(e,t)}var $n=Vn({name:"sha2-256",code:18,encode:t=>Se(zn.default.createHash("sha256").update(t).digest())}),tu=Vn({name:"sha2-512",code:19,encode:t=>Se(zn.default.createHash("sha512").update(t).digest())});var tr={...Hn,...Rn,...Fn,...Pn,...Nn,...Ln,...Un,...Cn,...Mn,...Kn},Zh={...jn,..._n};function qi(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var Hi=qi("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Gn=qi("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=De(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),ru={utf8:Hi,"utf-8":Hi,hex:tr.base16,latin1:Gn,ascii:Gn,binary:Gn,...tr},_r=ru;function he(t,e="utf8"){let r=_r[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?bt(Vi.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var zi=de("node:buffer");function $(t,e="utf8"){let r=_r[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?zi.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var nu=parseInt("11111",2),Yn=parseInt("10000000",2),ou=parseInt("01111111",2),$i={0:rr,1:rr,2:iu,3:au,4:uu,5:cu,6:su,16:rr,22:rr,48:rr};function Wn(t,e={offset:0}){let r=t[e.offset]νif(e.offset++,$i[r]!=null)return $i[r](t,e);throw new Error("No decoder for tag "+r)}function nr(t,e){let r=0;if((t[e.offset]&Yn)===Yn){let n=t[e.offset]&ou,o="0x";e.offset++;for(let i=0;i<n;i++,e.offset++)o+=t[e.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=t[e.offset],e.offset++;return r}function rr(t,e){nr(t,e);let r=[];for(;!(e.offset>=t.byteLength);){let n=Wn(t,e);if(n===null)break;r.push(n)}return r}function iu(t,e){let r=nr(t,e),n=e.offset,o=e.offset+r,i=[];for(let s=n;s<o;s++)s===n&&t[s]===0||i.push(t[s]);return e.offset+=r,Uint8Array.from(i)}function su(t,e){let r=nr(t,e),n=e.offset+r,o=t[e.offset];e.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,c=[];for(;e.offset<n;){let d=t[e.offset];if(e.offset++,c.push(d&127),d<128){c.reverse();let f=0;for(let l=0;l<c.length;l++)f+=c[l]<<l*7;a+=`.${f}`,c=[]}}return a}function cu(t,e){return e.offset++,null}function au(t,e){let r=nr(t,e),n=t[e.offset];e.offset++;let o=t.subarray(e.offset,e.offset+r-1);if(e.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function uu(t,e){let r=nr(t,e),n=t.subarray(e.offset,e.offset+r);return e.offset+=r,n}function du(t){let e=t.toString(16);e.length%2===1&&(e="0"+e);let r=new we;for(let n=0;n<e.length;n+=2)r.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return r}function Xn(t){if(t.byteLength<128)return Uint8Array.from([t.byteLength]);let e=du(t.byteLength);return new we(Uint8Array.from([e.byteLength|Yn]),e)}function ji(t){let e=new we,r=128;return(t.subarray()[0]&r)===r&&e.append(Uint8Array.from([0])),e.append(t),new we(Uint8Array.from([2]),Xn(e),e)}function Gi(t){let e=Uint8Array.from([0]),r=new we(e,t);return new we(Uint8Array.from([3]),Xn(r),r)}function Or(t,e=48){let r=new we;for(let n of t)r.append(n);return new we(Uint8Array.from([e]),Xn(r),r)}async function Yi(t,e,r,n){let o=await crypto.subtle.importKey("jwk",t,{name:"ECDSA",namedCurve:t.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,e,r.subarray());return n?.signal?.throwIfAborted(),i}var lu=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),hu=Uint8Array.from([6,5,43,129,4,0,34]),pu=Uint8Array.from([6,5,43,129,4,0,35]),fu={ext:!0,kty:"EC",crv:"P-256"},mu={ext:!0,kty:"EC",crv:"P-384"},gu={ext:!0,kty:"EC",crv:"P-521"},Zn=32,Qn=48,Jn=66;function Wi(t){let e=Wn(t);return Xi(e)}function Xi(t){let e=t[1][1][0],r=1,n,o;if(e.byteLength===Zn*2+1)return n=$(e.subarray(r,r+Zn),"base64url"),o=$(e.subarray(r+Zn),"base64url"),new kt({...fu,key_ops:["verify"],x:n,y:o});if(e.byteLength===Qn*2+1)return n=$(e.subarray(r,r+Qn),"base64url"),o=$(e.subarray(r+Qn),"base64url"),new kt({...mu,key_ops:["verify"],x:n,y:o});if(e.byteLength===Jn*2+1)return n=$(e.subarray(r,r+Jn),"base64url"),o=$(e.subarray(r+Jn),"base64url"),new kt({...gu,key_ops:["verify"],x:n,y:o});throw new ve(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function Zi(t){return Or([ji(Uint8Array.from([1])),Or([yu(t.crv)],160),Or([Gi(new we(Uint8Array.from([4]),he(t.x??"","base64url"),he(t.y??"","base64url")))],161)]).subarray()}function yu(t){if(t==="P-256")return lu;if(t==="P-384")return hu;if(t==="P-521")return pu;throw new ve(`Invalid curve ${t}`)}var kt=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=Zi(this.jwk)),this._raw}toMultihash(){return Ue.digest(Mt(this))}toCID(){return Q.createV1(114,this.toMultihash())}toString(){return j.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ye(this.raw,e.raw)}async verify(e,r,n){return Yi(this.jwk,r,e,n)}};var Pr=Dt(de("crypto"),1);var _0=Pr.default.generateKeyPairSync,or=32;var wu=64;function Qi(t,e,r){if(t.byteLength!==or)throw new TypeError('"key" must be 32 bytes in length.');if(!(t instanceof Uint8Array))throw new TypeError('"key" must be a node.js Buffer, or Uint8Array.');if(e.byteLength!==wu)throw new TypeError('"sig" must be 64 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"sig" must be a node.js Buffer, or Uint8Array.');let n=Pr.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:$(t,"base64url"),kty:"OKP"}});return Pr.default.verify(null,r instanceof Uint8Array?r:r.subarray(),n,e)}function es(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}var Nr=class{type="Ed25519";raw;constructor(e){this.raw=eo(e,or)}toMultihash(){return Ue.digest(Mt(this))}toCID(){return Q.createV1(114,this.toMultihash())}toString(){return j.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ye(this.raw,e.raw)}verify(e,r,n){n?.signal?.throwIfAborted();let o=Qi(this.raw,r,e);return es(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function ts(t){return t=eo(t,or),new Nr(t)}function eo(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new ve(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}var bu=Math.pow(2,7),Eu=Math.pow(2,14),Iu=Math.pow(2,21),to=Math.pow(2,28),ro=Math.pow(2,35),no=Math.pow(2,42),oo=Math.pow(2,49),H=128,ne=127;function ze(t){if(t<bu)return 1;if(t<Eu)return 2;if(t<Iu)return 3;if(t<to)return 4;if(t<ro)return 5;if(t<no)return 6;if(t<oo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ir(t,e,r=0){switch(ze(t)){case 8:e[r++]=t&255|H,t/=128;case 7:e[r++]=t&255|H,t/=128;case 6:e[r++]=t&255|H,t/=128;case 5:e[r++]=t&255|H,t/=128;case 4:e[r++]=t&255|H,t>>>=7;case 3:e[r++]=t&255|H,t>>>=7;case 2:e[r++]=t&255|H,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function io(t,e){let r=t[e],n=0;if(n+=r&ne,r<H||(r=t[e+1],n+=(r&ne)<<7,r<H)||(r=t[e+2],n+=(r&ne)<<14,r<H)||(r=t[e+3],n+=(r&ne)<<21,r<H)||(r=t[e+4],n+=(r&ne)*to,r<H)||(r=t[e+5],n+=(r&ne)*ro,r<H)||(r=t[e+6],n+=(r&ne)*no,r<H)||(r=t[e+7],n+=(r&ne)*oo,r<H))return n;throw new RangeError("Could not decode varint")}function vu(t,e){let r=t.get(e),n=0;if(n+=r&ne,r<H||(r=t.get(e+1),n+=(r&ne)<<7,r<H)||(r=t.get(e+2),n+=(r&ne)<<14,r<H)||(r=t.get(e+3),n+=(r&ne)<<21,r<H)||(r=t.get(e+4),n+=(r&ne)*to,r<H)||(r=t.get(e+5),n+=(r&ne)*ro,r<H)||(r=t.get(e+6),n+=(r&ne)*no,r<H)||(r=t.get(e+7),n+=(r&ne)*oo,r<H))return n;throw new RangeError("Could not decode varint")}function so(t,e=0){return t instanceof Uint8Array?io(t,e):vu(t,e)}var co=new Float32Array([-0]),pt=new Uint8Array(co.buffer);function rs(t,e,r){co[0]=t,e[r]=pt[0],e[r+1]=pt[1],e[r+2]=pt[2],e[r+3]=pt[3]}function ns(t,e){return pt[0]=t[e],pt[1]=t[e+1],pt[2]=t[e+2],pt[3]=t[e+3],co[0]}var ao=new Float64Array([-0]),oe=new Uint8Array(ao.buffer);function os(t,e,r){ao[0]=t,e[r]=oe[0],e[r+1]=oe[1],e[r+2]=oe[2],e[r+3]=oe[3],e[r+4]=oe[4],e[r+5]=oe[5],e[r+6]=oe[6],e[r+7]=oe[7]}function is(t,e){return oe[0]=t[e],oe[1]=t[e+1],oe[2]=t[e+2],oe[3]=t[e+3],oe[4]=t[e+4],oe[5]=t[e+5],oe[6]=t[e+6],oe[7]=t[e+7],ao[0]}var Au=BigInt(Number.MAX_SAFE_INTEGER),Bu=BigInt(Number.MIN_SAFE_INTEGER),xe=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Et;if(e<Au&&e>Bu)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>ss&&(o=0n,++n>ss&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return Et;let r=e<0;r&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new t(n,o)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):Et}},Et=new xe(0,0);Et.toBigInt=function(){return 0n};Et.zzEncode=Et.zzDecode=function(){return this};Et.length=function(){return 1};var ss=4294967296n;function cs(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function as(t,e,r){if(r-e<1)return"";let o,i=[],s=0,a;for(;e<r;)a=t[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function uo(t,e,r){let n=r,o,i;for(let s=0;s<t.length;++s)o=t.charCodeAt(s),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((i=t.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-n}function Te(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function Rr(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var lo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Te(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Te(this,4);return Rr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Te(this,4);return Rr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Te(this,4);let e=ns(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Te(this,4);let e=is(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw Te(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return as(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Te(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Te(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new xe(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Te(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw Te(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Te(this,8);let e=Rr(this.buf,this.pos+=4),r=Rr(this.buf,this.pos+=4);return new xe(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=io(this.buf,this.pos);return this.pos+=ze(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function ho(t){return new lo(t instanceof Uint8Array?t:t.subarray())}function Kr(t,e,r){let n=ho(t);return e.decode(n,void 0,r)}function po(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return De(s);o+s>e&&(n=De(e),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var It=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function fo(){}var go=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Cu=po();function Lu(t){return globalThis.Buffer!=null?De(t):Cu(t)}var cr=class{len;head;tail;states;constructor(){this.len=0,this.head=new It(fo,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new It(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new yo((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(kr,10,xe.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=xe.fromBigInt(e);return this._push(kr,r.length(),r)}uint64Number(e){return this._push(ir,ze(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=xe.fromBigInt(e).zzEncode();return this._push(kr,r.length(),r)}sint64Number(e){let r=xe.fromNumber(e).zzEncode();return this._push(kr,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(mo,1,e?1:0)}fixed32(e){return this._push(sr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=xe.fromBigInt(e);return this._push(sr,4,r.lo)._push(sr,4,r.hi)}fixed64Number(e){let r=xe.fromNumber(e);return this._push(sr,4,r.lo)._push(sr,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(rs,4,e)}double(e){return this._push(os,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(mo,1,0):this.uint32(r)._push(Du,r,e)}string(e){let r=cs(e);return r!==0?this.uint32(r)._push(uo,r,e):this._push(mo,1,0)}fork(){return this.states=new go(this),this.head=this.tail=new It(fo,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new It(fo,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=Lu(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function mo(t,e,r){e[r]=t&255}function Uu(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var yo=class extends It{next;constructor(e,r){super(Uu,e,r),this.next=void 0}};function kr(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function sr(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function Du(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(cr.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(Tu,e,t),this},cr.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(_u,e,t),this});function Tu(t,e,r){e.set(t,r)}function _u(t,e,r){t.length<40?uo(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(he(t),r)}function wo(){return new cr}function Mr(t,e){let r=wo();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var Ft;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(Ft||(Ft={}));function Fr(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function xo(t){function e(o){if(t[o.toString()]==null)throw new Error("Invalid enum value");return t[o]}let r=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return Fr("enum",Ft.VARINT,r,n)}function Hr(t,e){return Fr("message",Ft.LENGTH_DELIMITED,t,e)}var be;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.ECDSA="ECDSA"})(be||(be={}));var bo;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1",t[t.ECDSA=3]="ECDSA"})(bo||(bo={}));(function(t){t.codec=()=>xo(bo)})(be||(be={}));var ar;(function(t){let e;t.codec=()=>(e==null&&(e=Hr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),be.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=be.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Mr(r,t.codec()),t.decode=(r,n)=>Kr(r,t.codec(),n)})(ar||(ar={}));var Eo;(function(t){let e;t.codec=()=>(e==null&&(e=Hr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),be.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=be.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Mr(r,t.codec()),t.decode=(r,n)=>Kr(r,t.codec(),n)})(Eo||(Eo={}));var rt=Dt(de("node:crypto"),1),vt=rt&&typeof rt=="object"&&"webcrypto"in rt?rt.webcrypto:rt&&typeof rt=="object"&&"randomBytes"in rt?rt:void 0;function St(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ur(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function _e(t,...e){if(!St(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function qr(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");ur(t.outputLen),ur(t.blockLen)}function qt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function ls(t,e){_e(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function At(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Vr(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Oe(t,e){return t<<32-e|t>>>e}var hs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Pu=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ot(t){if(_e(t),hs)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=Pu[t[r]];return e}var nt={_0:48,_9:57,A:65,F:70,a:97,f:102};function ds(t){if(t>=nt._0&&t<=nt._9)return t-nt._0;if(t>=nt.A&&t<=nt.F)return t-(nt.A-10);if(t>=nt.a&&t<=nt.f)return t-(nt.a-10)}function Bt(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(hs)return Uint8Array.fromHex(t);let e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=ds(t.charCodeAt(i)),a=ds(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function ps(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function dr(t){return typeof t=="string"&&(t=ps(t)),_e(t),t}function Pe(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];_e(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}var Ht=class{};function fs(t){let e=n=>t().update(dr(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function zr(t=32){if(vt&&typeof vt.getRandomValues=="function")return vt.getRandomValues(new Uint8Array(t));if(vt&&typeof vt.randomBytes=="function")return Uint8Array.from(vt.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}function Nu(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,d=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+d,a,n)}function ms(t,e,r){return t&e^~t&r}function gs(t,e,r){return t&e^t&r^e&r}var $r=class extends Ht{constructor(e,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Vr(this.buffer)}update(e){qt(this),e=dr(e),_e(e);let{view:r,buffer:n,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Vr(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){qt(this),ls(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,At(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;Nu(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Vr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=c/4,f=this.get();if(d>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<d;l++)a.setUint32(4*l,f[l],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=a,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},it=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Ru=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ft=new Uint32Array(64),Io=class extends $r{constructor(e=32){super(64,e,8,!1),this.A=it[0]|0,this.B=it[1]|0,this.C=it[2]|0,this.D=it[3]|0,this.E=it[4]|0,this.F=it[5]|0,this.G=it[6]|0,this.H=it[7]|0}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,r,n,o,i,s,a,c]}set(e,r,n,o,i,s,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,r){for(let l=0;l<16;l++,r+=4)ft[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let u=ft[l-15],h=ft[l-2],p=Oe(u,7)^Oe(u,18)^u>>>3,m=Oe(h,17)^Oe(h,19)^h>>>10;ft[l]=m+ft[l-7]+p+ft[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:d,H:f}=this;for(let l=0;l<64;l++){let u=Oe(a,6)^Oe(a,11)^Oe(a,25),h=f+u+ms(a,c,d)+Ru[l]+ft[l]|0,m=(Oe(n,2)^Oe(n,13)^Oe(n,22))+gs(n,o,i)|0;f=d,d=c,c=a,a=s+h|0,s=i,i=o,o=n,n=h+m|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(n,o,i,s,a,c,d,f)}roundClean(){At(ft)}destroy(){this.set(0,0,0,0,0,0,0,0),At(this.buffer)}};var ys=fs(()=>new Io);var Gs=Dt(de("node:crypto"),1);var jr=class extends Ht{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,qr(e);let n=dr(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),At(i)}update(e){return qt(this),this.iHash.update(e),this}digestInto(e){qt(this),_e(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},vo=(t,e,r)=>new jr(t,e).update(r).digest();vo.create=(t,e)=>new jr(t,e);var Bo=BigInt(0),Ao=BigInt(1);function lr(t,e=""){if(typeof t!="boolean"){let r=e&&`"${e}"`;throw new Error(r+"expected boolean, got type="+typeof t)}return t}function mt(t,e,r=""){let n=St(t),o=t?.length,i=e!==void 0;if(!n||i&&o!==e){let s=r&&`"${r}" `,a=i?` of length ${e}`:"",c=n?`length=${o}`:`type=${typeof t}`;throw new Error(s+"expected Uint8Array"+a+", got "+c)}return t}function hr(t){let e=t.toString(16);return e.length&1?"0"+e:e}function ws(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Bo:BigInt("0x"+t)}function Vt(t){return ws(ot(t))}function Co(t){return _e(t),ws(ot(Uint8Array.from(t).reverse()))}function Gr(t,e){return Bt(t.toString(16).padStart(e*2,"0"))}function Lo(t,e){return Gr(t,e).reverse()}function ie(t,e,r){let n;if(typeof e=="string")try{n=Bt(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(St(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(t+" of length "+r+" expected, got "+o);return n}var So=t=>typeof t=="bigint"&&Bo<=t;function xs(t,e,r){return So(t)&&So(e)&&So(r)&&e<=t&&t<r}function bs(t,e,r,n){if(!xs(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Yr(t){let e;for(e=0;t>Bo;t>>=Ao,e+=1);return e}var gt=t=>(Ao<<BigInt(t))-Ao;function Es(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=h=>new Uint8Array(h),o=h=>Uint8Array.of(h),i=n(t),s=n(t),a=0,c=()=>{i.fill(1),s.fill(0),a=0},d=(...h)=>r(s,i,...h),f=(h=n(0))=>{s=d(o(0),h),i=d(),h.length!==0&&(s=d(o(1),h),i=d())},l=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let h=0,p=[];for(;h<e;){i=d();let m=i.slice();p.push(m),h+=i.length}return Pe(...p)};return(h,p)=>{c(),f(h);let m;for(;!(m=p(l()));)f();return c(),m}}function pr(t,e,r={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function n(o,i,s){let a=t[o];if(s&&a===void 0)return;let c=typeof a;if(c!==i||a===null)throw new Error(`param "${o}" is invalid: expected ${i}, got ${c}`)}Object.entries(e).forEach(([o,i])=>n(o,i,!1)),Object.entries(r).forEach(([o,i])=>n(o,i,!0))}function Uo(t){let e=new WeakMap;return(r,...n)=>{let o=e.get(r);if(o!==void 0)return o;let i=t(r,...n);return e.set(r,i),i}}var ae=BigInt(0),se=BigInt(1),Ct=BigInt(2),Ss=BigInt(3),As=BigInt(4),Bs=BigInt(5),Ku=BigInt(7),Cs=BigInt(8),ku=BigInt(9),Ls=BigInt(16);function Ae(t,e){let r=t%e;return r>=ae?r:e+r}function Ee(t,e,r){let n=t;for(;e-- >ae;)n*=n,n%=r;return n}function Is(t,e){if(t===ae)throw new Error("invert: expected non-zero number");if(e<=ae)throw new Error("invert: expected positive modulus, got "+e);let r=Ae(t,e),n=e,o=ae,i=se,s=se,a=ae;for(;r!==ae;){let d=n/r,f=n%r,l=o-s*d,u=i-a*d;n=r,r=f,o=s,i=a,s=l,a=u}if(n!==se)throw new Error("invert: does not exist");return Ae(o,e)}function Do(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function Us(t,e){let r=(t.ORDER+se)/As,n=t.pow(e,r);return Do(t,n,e),n}function Mu(t,e){let r=(t.ORDER-Bs)/Cs,n=t.mul(e,Ct),o=t.pow(n,r),i=t.mul(e,o),s=t.mul(t.mul(i,Ct),o),a=t.mul(i,t.sub(s,t.ONE));return Do(t,a,e),a}function Fu(t){let e=yt(t),r=Ds(t),n=r(e,e.neg(e.ONE)),o=r(e,n),i=r(e,e.neg(n)),s=(t+Ku)/Ls;return(a,c)=>{let d=a.pow(c,s),f=a.mul(d,n),l=a.mul(d,o),u=a.mul(d,i),h=a.eql(a.sqr(f),c),p=a.eql(a.sqr(l),c);d=a.cmov(d,f,h),f=a.cmov(u,l,p);let m=a.eql(a.sqr(f),c),E=a.cmov(d,f,m);return Do(a,E,c),E}}function Ds(t){if(t<Ss)throw new Error("sqrt is not defined for small field");let e=t-se,r=0;for(;e%Ct===ae;)e/=Ct,r++;let n=Ct,o=yt(t);for(;vs(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Us;let i=o.pow(n,e),s=(e+se)/Ct;return function(c,d){if(c.is0(d))return d;if(vs(c,d)!==1)throw new Error("Cannot find square root");let f=r,l=c.mul(c.ONE,i),u=c.pow(d,e),h=c.pow(d,s);for(;!c.eql(u,c.ONE);){if(c.is0(u))return c.ZERO;let p=1,m=c.sqr(u);for(;!c.eql(m,c.ONE);)if(p++,m=c.sqr(m),p===f)throw new Error("Cannot find square root");let E=se<<BigInt(f-p-1),L=c.pow(l,E);f=p,l=c.sqr(L),u=c.mul(u,l),h=c.mul(h,L)}return h}}function Hu(t){return t%As===Ss?Us:t%Cs===Bs?Mu:t%Ls===ku?Fu(t):Ds(t)}var qu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function To(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},r=qu.reduce((n,o)=>(n[o]="function",n),e);return pr(t,r),t}function Vu(t,e,r){if(r<ae)throw new Error("invalid exponent, negatives unsupported");if(r===ae)return t.ONE;if(r===se)return e;let n=t.ONE,o=e;for(;r>ae;)r&se&&(n=t.mul(n,o)),o=t.sqr(o),r>>=se;return n}function Wr(t,e,r=!1){let n=new Array(e.length).fill(r?t.ZERO:void 0),o=e.reduce((s,a,c)=>t.is0(a)?s:(n[c]=s,t.mul(s,a)),t.ONE),i=t.inv(o);return e.reduceRight((s,a,c)=>t.is0(a)?s:(n[c]=t.mul(s,n[c]),t.mul(s,a)),i),n}function vs(t,e){let r=(t.ORDER-se)/Ct,n=t.pow(e,r),o=t.eql(n,t.ONE),i=t.eql(n,t.ZERO),s=t.eql(n,t.neg(t.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function Xr(t,e){e!==void 0&&ur(e);let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function yt(t,e,r=!1,n={}){if(t<=ae)throw new Error("invalid field: expected ORDER > 0, got "+t);let o,i,s=!1,a;if(typeof e=="object"&&e!=null){if(n.sqrt||r)throw new Error("cannot specify opts in two arguments");let u=e;u.BITS&&(o=u.BITS),u.sqrt&&(i=u.sqrt),typeof u.isLE=="boolean"&&(r=u.isLE),typeof u.modFromBytes=="boolean"&&(s=u.modFromBytes),a=u.allowedLengths}else typeof e=="number"&&(o=e),n.sqrt&&(i=n.sqrt);let{nBitLength:c,nByteLength:d}=Xr(t,o);if(d>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let f,l=Object.freeze({ORDER:t,isLE:r,BITS:c,BYTES:d,MASK:gt(c),ZERO:ae,ONE:se,allowedLengths:a,create:u=>Ae(u,t),isValid:u=>{if(typeof u!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof u);return ae<=u&&u<t},is0:u=>u===ae,isValidNot0:u=>!l.is0(u)&&l.isValid(u),isOdd:u=>(u&se)===se,neg:u=>Ae(-u,t),eql:(u,h)=>u===h,sqr:u=>Ae(u*u,t),add:(u,h)=>Ae(u+h,t),sub:(u,h)=>Ae(u-h,t),mul:(u,h)=>Ae(u*h,t),pow:(u,h)=>Vu(l,u,h),div:(u,h)=>Ae(u*Is(h,t),t),sqrN:u=>u*u,addN:(u,h)=>u+h,subN:(u,h)=>u-h,mulN:(u,h)=>u*h,inv:u=>Is(u,t),sqrt:i||(u=>(f||(f=Hu(t)),f(l,u))),toBytes:u=>r?Lo(u,d):Gr(u,d),fromBytes:(u,h=!0)=>{if(a){if(!a.includes(u.length)||u.length>d)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+u.length);let m=new Uint8Array(d);m.set(u,r?0:m.length-u.length),u=m}if(u.length!==d)throw new Error("Field.fromBytes: expected "+d+" bytes, got "+u.length);let p=r?Co(u):Vt(u);if(s&&(p=Ae(p,t)),!h&&!l.isValid(p))throw new Error("invalid field element: outside of range 0..ORDER");return p},invertBatch:u=>Wr(l,u),cmov:(u,h,p)=>p?h:u});return Object.freeze(l)}function Ts(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function _o(t){let e=Ts(t);return e+Math.ceil(e/2)}function Oo(t,e,r=!1){let n=t.length,o=Ts(e),i=_o(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Co(t):Vt(t),a=Ae(s,e-se)+se;return r?Lo(a,o):Gr(a,o)}var zt=BigInt(0),Lt=BigInt(1);function fr(t,e){let r=e.negate();return t?r:e}function Qr(t,e){let r=Wr(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function Ns(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Po(t,e){Ns(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1),o=2**t,i=gt(t),s=BigInt(t);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function _s(t,e,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,a=Number(t&o),c=t>>s;a>n&&(a-=i,c+=Lt);let d=e*n,f=d+Math.abs(a)-1,l=a===0,u=a<0,h=e%2!==0;return{nextN:c,offset:f,isZero:l,isNeg:u,isNegF:h,offsetF:d}}function zu(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,n)=>{if(!(r instanceof e))throw new Error("invalid point at index "+n)})}function $u(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,n)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+n)})}var No=new WeakMap,Rs=new WeakMap;function Ro(t){return Rs.get(t)||1}function Os(t){if(t!==zt)throw new Error("invalid wNAF")}var Zr=class{constructor(e,r){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=r}_unsafeLadder(e,r,n=this.ZERO){let o=e;for(;r>zt;)r&Lt&&(n=n.add(o)),o=o.double(),r>>=Lt;return n}precomputeWindow(e,r){let{windows:n,windowSize:o}=Po(r,this.bits),i=[],s=e,a=s;for(let c=0;c<n;c++){a=s,i.push(a);for(let d=1;d<o;d++)a=a.add(s),i.push(a);s=a.double()}return i}wNAF(e,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=Po(e,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:d,isZero:f,isNeg:l,isNegF:u,offsetF:h}=_s(n,a,s);n=c,f?i=i.add(fr(u,r[h])):o=o.add(fr(l,r[d]))}return Os(n),{p:o,f:i}}wNAFUnsafe(e,r,n,o=this.ZERO){let i=Po(e,this.bits);for(let s=0;s<i.windows&&n!==zt;s++){let{nextN:a,offset:c,isZero:d,isNeg:f}=_s(n,s,i);if(n=a,!d){let l=r[c];o=o.add(f?l.negate():l)}}return Os(n),o}getPrecomputes(e,r,n){let o=No.get(r);return o||(o=this.precomputeWindow(r,e),e!==1&&(typeof n=="function"&&(o=n(o)),No.set(r,o))),o}cached(e,r,n){let o=Ro(e);return this.wNAF(o,this.getPrecomputes(o,e,n),r)}unsafe(e,r,n,o){let i=Ro(e);return i===1?this._unsafeLadder(e,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),r,o)}createCache(e,r){Ns(r,this.bits),Rs.set(e,r),No.delete(e)}hasCache(e){return Ro(e)!==1}};function Ks(t,e,r,n){let o=e,i=t.ZERO,s=t.ZERO;for(;r>zt||n>zt;)r&Lt&&(i=i.add(o)),n&Lt&&(s=s.add(o)),o=o.double(),r>>=Lt,n>>=Lt;return{p1:i,p2:s}}function ks(t,e,r,n){zu(r,t),$u(n,e);let o=r.length,i=n.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");let s=t.ZERO,a=Yr(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let d=gt(c),f=new Array(Number(d)+1).fill(s),l=Math.floor((e.BITS-1)/c)*c,u=s;for(let h=l;h>=0;h-=c){f.fill(s);for(let m=0;m<i;m++){let E=n[m],L=Number(E>>BigInt(h)&d);f[L]=f[L].add(r[m])}let p=s;for(let m=f.length-1,E=s;m>0;m--)E=E.add(f[m]),p=p.add(E);if(u=u.add(p),h!==0)for(let m=0;m<c;m++)u=u.double()}return u}function Ps(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return To(e),e}else return yt(t,{isLE:r})}function Ms(t,e,r={},n){if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(let c of["p","n","h"]){let d=e[c];if(!(typeof d=="bigint"&&d>zt))throw new Error(`CURVE.${c} must be positive bigint`)}let o=Ps(e.p,r.Fp,n),i=Ps(e.n,r.Fn,n),a=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:i}}var Fs=(t,e)=>(t+(t>=0?e:-e)/Hs)/e;function ju(t,e,r){let[[n,o],[i,s]]=e,a=Fs(s*t,r),c=Fs(-o*t,r),d=t-a*n-c*i,f=-a*o-c*s,l=d<ct,u=f<ct;l&&(d=-d),u&&(f=-f);let h=gt(Math.ceil(Yr(r)/2))+jt;if(d<ct||d>=h||f<ct||f>=h)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:l,k1:d,k2neg:u,k2:f}}function ko(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Ko(t,e){let r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return lr(r.lowS,"lowS"),lr(r.prehash,"prehash"),r.format!==void 0&&ko(r.format),r}var Mo=class extends Error{constructor(e=""){super(e)}},st={Err:Mo,_tlv:{encode:(t,e)=>{let{Err:r}=st;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=hr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?hr(o.length/2|128):"";return hr(t)+i+o+e},decode(t,e){let{Err:r}=st,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let d=e.subarray(n,n+c);if(d.length!==c)throw new r("tlv.decode: length bytes not complete");if(d[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let f of d)s=s<<8|f;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=st;if(t<ct)throw new e("integer: negative integers are not allowed");let r=hr(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=st;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Vt(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=st,o=ie("signature",t),{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:d,l:f}=n.decode(2,c);if(f.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(d)}},hexFromSig(t){let{_tlv:e,_int:r}=st,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}},ct=BigInt(0),jt=BigInt(1),Hs=BigInt(2),Jr=BigInt(3),Gu=BigInt(4);function $t(t,e){let{BYTES:r}=t,n;if(typeof e=="bigint")n=e;else{let o=ie("private key",e);try{n=t.fromBytes(o)}catch{throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof e}`)}}if(!t.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function Yu(t,e={}){let r=Ms("weierstrass",t,e),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s,n:a}=i;pr(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:c}=e;if(c&&(!n.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let d=Vs(n,o);function f(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(N,w,y){let{x:g,y:b}=w.toAffine(),S=n.toBytes(g);if(lr(y,"isCompressed"),y){f();let C=!n.isOdd(b);return Pe(qs(C),S)}else return Pe(Uint8Array.of(4),S,n.toBytes(b))}function u(N){mt(N,void 0,"Point");let{publicKey:w,publicKeyUncompressed:y}=d,g=N.length,b=N[0],S=N.subarray(1);if(g===w&&(b===2||b===3)){let C=n.fromBytes(S);if(!n.isValid(C))throw new Error("bad point: is not on curve, wrong x");let B=m(C),A;try{A=n.sqrt(B)}catch(G){let F=G instanceof Error?": "+G.message:"";throw new Error("bad point: is not on curve, sqrt error"+F)}f();let U=n.isOdd(A);return(b&1)===1!==U&&(A=n.neg(A)),{x:C,y:A}}else if(g===y&&b===4){let C=n.BYTES,B=n.fromBytes(S.subarray(0,C)),A=n.fromBytes(S.subarray(C,C*2));if(!E(B,A))throw new Error("bad point: is not on curve");return{x:B,y:A}}else throw new Error(`bad point: got length ${g}, expected compressed=${w} or uncompressed=${y}`)}let h=e.toBytes||l,p=e.fromBytes||u;function m(N){let w=n.sqr(N),y=n.mul(w,N);return n.add(n.add(y,n.mul(N,i.a)),i.b)}function E(N,w){let y=n.sqr(w),g=m(N);return n.eql(y,g)}if(!E(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let L=n.mul(n.pow(i.a,Jr),Gu),K=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(L,K)))throw new Error("bad curve params: a or b");function O(N,w,y=!1){if(!n.isValid(w)||y&&n.is0(w))throw new Error(`bad point coordinate ${N}`);return w}function k(N){if(!(N instanceof T))throw new Error("ProjectivePoint expected")}function R(N){if(!c||!c.basises)throw new Error("no endo");return ju(N,c.basises,o.ORDER)}let M=Uo((N,w)=>{let{X:y,Y:g,Z:b}=N;if(n.eql(b,n.ONE))return{x:y,y:g};let S=N.is0();w==null&&(w=S?n.ONE:n.inv(b));let C=n.mul(y,w),B=n.mul(g,w),A=n.mul(b,w);if(S)return{x:n.ZERO,y:n.ZERO};if(!n.eql(A,n.ONE))throw new Error("invZ was invalid");return{x:C,y:B}}),ee=Uo(N=>{if(N.is0()){if(e.allowInfinityPoint&&!n.is0(N.Y))return;throw new Error("bad point: ZERO")}let{x:w,y}=N.toAffine();if(!n.isValid(w)||!n.isValid(y))throw new Error("bad point: x or y not field elements");if(!E(w,y))throw new Error("bad point: equation left != right");if(!N.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function te(N,w,y,g,b){return y=new T(n.mul(y.X,N),y.Y,y.Z),w=fr(g,w),y=fr(b,y),w.add(y)}class T{constructor(w,y,g){this.X=O("x",w),this.Y=O("y",y,!0),this.Z=O("z",g),Object.freeze(this)}static CURVE(){return i}static fromAffine(w){let{x:y,y:g}=w||{};if(!w||!n.isValid(y)||!n.isValid(g))throw new Error("invalid affine point");if(w instanceof T)throw new Error("projective point not allowed");return n.is0(y)&&n.is0(g)?T.ZERO:new T(y,g,n.ONE)}static fromBytes(w){let y=T.fromAffine(p(mt(w,void 0,"point")));return y.assertValidity(),y}static fromHex(w){return T.fromBytes(ie("pointHex",w))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,y=!0){return wt.createCache(this,w),y||this.multiply(Jr),this}assertValidity(){ee(this)}hasEvenY(){let{y:w}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(w)}equals(w){k(w);let{X:y,Y:g,Z:b}=this,{X:S,Y:C,Z:B}=w,A=n.eql(n.mul(y,B),n.mul(S,b)),U=n.eql(n.mul(g,B),n.mul(C,b));return A&&U}negate(){return new T(this.X,n.neg(this.Y),this.Z)}double(){let{a:w,b:y}=i,g=n.mul(y,Jr),{X:b,Y:S,Z:C}=this,B=n.ZERO,A=n.ZERO,U=n.ZERO,_=n.mul(b,b),G=n.mul(S,S),F=n.mul(C,C),P=n.mul(b,S);return P=n.add(P,P),U=n.mul(b,C),U=n.add(U,U),B=n.mul(w,U),A=n.mul(g,F),A=n.add(B,A),B=n.sub(G,A),A=n.add(G,A),A=n.mul(B,A),B=n.mul(P,B),U=n.mul(g,U),F=n.mul(w,F),P=n.sub(_,F),P=n.mul(w,P),P=n.add(P,U),U=n.add(_,_),_=n.add(U,_),_=n.add(_,F),_=n.mul(_,P),A=n.add(A,_),F=n.mul(S,C),F=n.add(F,F),_=n.mul(F,P),B=n.sub(B,_),U=n.mul(F,G),U=n.add(U,U),U=n.add(U,U),new T(B,A,U)}add(w){k(w);let{X:y,Y:g,Z:b}=this,{X:S,Y:C,Z:B}=w,A=n.ZERO,U=n.ZERO,_=n.ZERO,G=i.a,F=n.mul(i.b,Jr),P=n.mul(y,S),q=n.mul(g,C),Y=n.mul(b,B),ue=n.add(y,g),V=n.add(S,C);ue=n.mul(ue,V),V=n.add(P,q),ue=n.sub(ue,V),V=n.add(y,b);let re=n.add(S,B);return V=n.mul(V,re),re=n.add(P,Y),V=n.sub(V,re),re=n.add(g,b),A=n.add(C,B),re=n.mul(re,A),A=n.add(q,Y),re=n.sub(re,A),_=n.mul(G,V),A=n.mul(F,Y),_=n.add(A,_),A=n.sub(q,_),_=n.add(q,_),U=n.mul(A,_),q=n.add(P,P),q=n.add(q,P),Y=n.mul(G,Y),V=n.mul(F,V),q=n.add(q,Y),Y=n.sub(P,Y),Y=n.mul(G,Y),V=n.add(V,Y),P=n.mul(q,V),U=n.add(U,P),P=n.mul(re,V),A=n.mul(ue,A),A=n.sub(A,P),P=n.mul(ue,q),_=n.mul(re,_),_=n.add(_,P),new T(A,U,_)}subtract(w){return this.add(w.negate())}is0(){return this.equals(T.ZERO)}multiply(w){let{endo:y}=e;if(!o.isValidNot0(w))throw new Error("invalid scalar: out of range");let g,b,S=C=>wt.cached(this,C,B=>Qr(T,B));if(y){let{k1neg:C,k1:B,k2neg:A,k2:U}=R(w),{p:_,f:G}=S(B),{p:F,f:P}=S(U);b=G.add(P),g=te(y.beta,_,F,C,A)}else{let{p:C,f:B}=S(w);g=C,b=B}return Qr(T,[g,b])[0]}multiplyUnsafe(w){let{endo:y}=e,g=this;if(!o.isValid(w))throw new Error("invalid scalar: out of range");if(w===ct||g.is0())return T.ZERO;if(w===jt)return g;if(wt.hasCache(this))return this.multiply(w);if(y){let{k1neg:b,k1:S,k2neg:C,k2:B}=R(w),{p1:A,p2:U}=Ks(T,g,S,B);return te(y.beta,A,U,b,C)}else return wt.unsafe(g,w)}multiplyAndAddUnsafe(w,y,g){let b=this.multiplyUnsafe(y).add(w.multiplyUnsafe(g));return b.is0()?void 0:b}toAffine(w){return M(this,w)}isTorsionFree(){let{isTorsionFree:w}=e;return s===jt?!0:w?w(T,this):wt.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:w}=e;return s===jt?this:w?w(T,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(w=!0){return lr(w,"isCompressed"),this.assertValidity(),h(T,this,w)}toHex(w=!0){return ot(this.toBytes(w))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(w=!0){return this.toBytes(w)}_setWindowSize(w){this.precompute(w)}static normalizeZ(w){return Qr(T,w)}static msm(w,y){return ks(T,o,w,y)}static fromPrivateKey(w){return T.BASE.multiply($t(o,w))}}T.BASE=new T(i.Gx,i.Gy,n.ONE),T.ZERO=new T(n.ZERO,n.ONE,n.ZERO),T.Fp=n,T.Fn=o;let Er=o.BITS,wt=new Zr(T,e.endo?Math.ceil(Er/2):Er);return T.BASE.precompute(8),T}function qs(t){return Uint8Array.of(t?2:3)}function Vs(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function Wu(t,e={}){let{Fn:r}=t,n=e.randomBytes||zr,o=Object.assign(Vs(t.Fp,r),{seed:_o(r.ORDER)});function i(h){try{return!!$t(r,h)}catch{return!1}}function s(h,p){let{publicKey:m,publicKeyUncompressed:E}=o;try{let L=h.length;return p===!0&&L!==m||p===!1&&L!==E?!1:!!t.fromBytes(h)}catch{return!1}}function a(h=n(o.seed)){return Oo(mt(h,o.seed,"seed"),r.ORDER)}function c(h,p=!0){return t.BASE.multiply($t(r,h)).toBytes(p)}function d(h){let p=a(h);return{secretKey:p,publicKey:c(p)}}function f(h){if(typeof h=="bigint")return!1;if(h instanceof t)return!0;let{secretKey:p,publicKey:m,publicKeyUncompressed:E}=o;if(r.allowedLengths||p===m)return;let L=ie("key",h).length;return L===m||L===E}function l(h,p,m=!0){if(f(h)===!0)throw new Error("first arg must be private key");if(f(p)===!1)throw new Error("second arg must be public key");let E=$t(r,h);return t.fromHex(p).multiply(E).toBytes(m)}return Object.freeze({getPublicKey:c,getSharedSecret:l,keygen:d,Point:t,utils:{isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a,isValidPrivateKey:i,randomPrivateKey:a,normPrivateKeyToScalar:h=>$t(r,h),precompute(h=8,p=t.BASE){return p.precompute(h,!1)}},lengths:o})}function Xu(t,e,r={}){qr(e),pr(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let n=r.randomBytes||zr,o=r.hmac||((y,...g)=>vo(e,y,Pe(...g))),{Fp:i,Fn:s}=t,{ORDER:a,BITS:c}=s,{keygen:d,getPublicKey:f,getSharedSecret:l,utils:u,lengths:h}=Wu(t,r),p={prehash:!1,lowS:typeof r.lowS=="boolean"?r.lowS:!1,format:void 0,extraEntropy:!1},m="compact";function E(y){let g=a>>jt;return y>g}function L(y,g){if(!s.isValidNot0(g))throw new Error(`invalid signature ${y}: out of range 1..Point.Fn.ORDER`);return g}function K(y,g){ko(g);let b=h.signature,S=g==="compact"?b:g==="recovered"?b+1:void 0;return mt(y,S,`${g} signature`)}class O{constructor(g,b,S){this.r=L("r",g),this.s=L("s",b),S!=null&&(this.recovery=S),Object.freeze(this)}static fromBytes(g,b=m){K(g,b);let S;if(b==="der"){let{r:U,s:_}=st.toSig(mt(g));return new O(U,_)}b==="recovered"&&(S=g[0],b="compact",g=g.subarray(1));let C=s.BYTES,B=g.subarray(0,C),A=g.subarray(C,C*2);return new O(s.fromBytes(B),s.fromBytes(A),S)}static fromHex(g,b){return this.fromBytes(Bt(g),b)}addRecoveryBit(g){return new O(this.r,this.s,g)}recoverPublicKey(g){let b=i.ORDER,{r:S,s:C,recovery:B}=this;if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");if(a*Hs<b&&B>1)throw new Error("recovery id is ambiguous for h>1 curve");let U=B===2||B===3?S+a:S;if(!i.isValid(U))throw new Error("recovery id 2 or 3 invalid");let _=i.toBytes(U),G=t.fromBytes(Pe(qs((B&1)===0),_)),F=s.inv(U),P=R(ie("msgHash",g)),q=s.create(-P*F),Y=s.create(C*F),ue=t.BASE.multiplyUnsafe(q).add(G.multiplyUnsafe(Y));if(ue.is0())throw new Error("point at infinify");return ue.assertValidity(),ue}hasHighS(){return E(this.s)}toBytes(g=m){if(ko(g),g==="der")return Bt(st.hexFromSig(this));let b=s.toBytes(this.r),S=s.toBytes(this.s);if(g==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return Pe(Uint8Array.of(this.recovery),b,S)}return Pe(b,S)}toHex(g){return ot(this.toBytes(g))}assertValidity(){}static fromCompact(g){return O.fromBytes(ie("sig",g),"compact")}static fromDER(g){return O.fromBytes(ie("sig",g),"der")}normalizeS(){return this.hasHighS()?new O(this.r,s.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return ot(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return ot(this.toBytes("compact"))}}let k=r.bits2int||function(g){if(g.length>8192)throw new Error("input is too large");let b=Vt(g),S=g.length*8-c;return S>0?b>>BigInt(S):b},R=r.bits2int_modN||function(g){return s.create(k(g))},M=gt(c);function ee(y){return bs("num < 2^"+c,y,ct,M),s.toBytes(y)}function te(y,g){return mt(y,void 0,"message"),g?mt(e(y),void 0,"prehashed message"):y}function T(y,g,b){if(["recovered","canonical"].some(q=>q in b))throw new Error("sign() legacy options not supported");let{lowS:S,prehash:C,extraEntropy:B}=Ko(b,p);y=te(y,C);let A=R(y),U=$t(s,g),_=[ee(U),ee(A)];if(B!=null&&B!==!1){let q=B===!0?n(h.secretKey):B;_.push(ie("extraEntropy",q))}let G=Pe(..._),F=A;function P(q){let Y=k(q);if(!s.isValidNot0(Y))return;let ue=s.inv(Y),V=t.BASE.multiply(Y).toAffine(),re=s.create(V.x);if(re===ct)return;let Ir=s.create(ue*s.create(F+re*U));if(Ir===ct)return;let Xo=(V.x===re?0:2)|Number(V.y&jt),Zo=Ir;return S&&E(Ir)&&(Zo=s.neg(Ir),Xo^=1),new O(re,Zo,Xo)}return{seed:G,k2sig:P}}function Er(y,g,b={}){y=ie("message",y);let{seed:S,k2sig:C}=T(y,g,b);return Es(e.outputLen,s.BYTES,o)(S,C)}function wt(y){let g,b=typeof y=="string"||St(y),S=!b&&y!==null&&typeof y=="object"&&typeof y.r=="bigint"&&typeof y.s=="bigint";if(!b&&!S)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(S)g=new O(y.r,y.s);else if(b){try{g=O.fromBytes(ie("sig",y),"der")}catch(C){if(!(C instanceof st.Err))throw C}if(!g)try{g=O.fromBytes(ie("sig",y),"compact")}catch{return!1}}return g||!1}function N(y,g,b,S={}){let{lowS:C,prehash:B,format:A}=Ko(S,p);if(b=ie("publicKey",b),g=te(ie("message",g),B),"strict"in S)throw new Error("options.strict was renamed to lowS");let U=A===void 0?wt(y):O.fromBytes(ie("sig",y),A);if(U===!1)return!1;try{let _=t.fromBytes(b);if(C&&U.hasHighS())return!1;let{r:G,s:F}=U,P=R(g),q=s.inv(F),Y=s.create(P*q),ue=s.create(G*q),V=t.BASE.multiplyUnsafe(Y).add(_.multiplyUnsafe(ue));return V.is0()?!1:s.create(V.x)===G}catch{return!1}}function w(y,g,b={}){let{prehash:S}=Ko(b,p);return g=te(g,S),O.fromBytes(y,"recovered").recoverPublicKey(g).toBytes()}return Object.freeze({keygen:d,getPublicKey:f,getSharedSecret:l,utils:u,lengths:h,Point:t,sign:Er,verify:N,recoverPublicKey:w,Signature:O,hash:e})}function Zu(t){let e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},r=t.Fp,n=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(s=>Math.ceil(s/2)))):void 0,o=yt(e.n,{BITS:t.nBitLength,allowedLengths:n,modFromBytes:t.wrapPrivateKey}),i={Fp:r,Fn:o,allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes};return{CURVE:e,curveOpts:i}}function Qu(t){let{CURVE:e,curveOpts:r}=Zu(t),n={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:r,hash:t.hash,ecdsaOpts:n}}function Ju(t,e){let r=e.Point;return Object.assign({},e,{ProjectivePoint:r,CURVE:Object.assign({},t,Xr(r.Fn.ORDER,r.Fn.BITS))})}function zs(t){let{CURVE:e,curveOpts:r,hash:n,ecdsaOpts:o}=Qu(t),i=Yu(e,r),s=Xu(i,n,o);return Ju(t,s)}function $s(t,e){let r=n=>zs({...t,hash:n});return{...r(e),create:r}}var Ho={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},ed={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var js=BigInt(2);function td(t){let e=Ho.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),d=t*t*t%e,f=d*d*t%e,l=Ee(f,r,e)*f%e,u=Ee(l,r,e)*f%e,h=Ee(u,js,e)*d%e,p=Ee(h,o,e)*h%e,m=Ee(p,i,e)*p%e,E=Ee(m,a,e)*m%e,L=Ee(E,c,e)*E%e,K=Ee(L,a,e)*m%e,O=Ee(K,r,e)*f%e,k=Ee(O,s,e)*p%e,R=Ee(k,n,e)*d%e,M=Ee(R,js,e);if(!Fo.eql(Fo.sqr(M),t))throw new Error("Cannot find square root");return M}var Fo=yt(Ho.p,{sqrt:td}),mr=$s({...Ho,Fp:Fo,lowS:!0,endo:ed},ys);var en=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function Ys(t,e,r,n){n?.signal?.throwIfAborted();let o=Gs.default.createHash("sha256");if(r instanceof Uint8Array)o.update(r);else for(let s of r)o.update(s);let i=o.digest();try{return mr.verify(e,i,t)}catch(s){throw new en(String(s))}}var tn=class{type="secp256k1";raw;_key;constructor(e){this._key=Xs(e),this.raw=Ws(this._key)}toMultihash(){return Ue.digest(Mt(this))}toCID(){return Q.createV1(114,this.toMultihash())}toString(){return j.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ye(this.raw,e.raw)}verify(e,r,n){return Ys(this._key,r,e,n)}};function Zs(t){return new tn(t)}function Ws(t){return mr.ProjectivePoint.fromHex(t).toRawBytes(!0)}function Xs(t){try{return mr.ProjectivePoint.fromHex(t),t}catch(e){throw new Sr(String(e))}}function Qs(t){let{Type:e,Data:r}=ar.decode(t.digest),n=r??new Uint8Array;switch(e){case be.Ed25519:return ts(n);case be.secp256k1:return Zs(n);case be.ECDSA:return Wi(n);default:throw new Yt}}function Mt(t){return ar.encode({Type:be[t.type],Data:t.raw})}var Js=Symbol.for("nodejs.util.inspect.custom"),rd=114,gr=class{type;multihash;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[dn]=!0;toString(){return this.string==null&&(this.string=j.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return Q.createV1(rd,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return ye(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return ye(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[Js](){return`PeerId(${this.toString()})`}},rn=class extends gr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},nn=class extends gr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},on=class extends gr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},nd=2336,yr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Ue.digest(he(this.url))}[Js](){return`PeerId(${this.url})`}[dn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return Q.createV1(nd,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=$(e)),e.toString()===this.toString())}};var od=114,ec=2336;function tc(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=Jt(j.decode(`z${t}`));else{if(t.startsWith("k51qzi5uqu5")||t.startsWith("kzwfwjn5ji4")||t.startsWith("k2k4r8")||t.startsWith("bafz"))return id(Q.parse(t));if(e==null)throw new ve('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=Jt(e.decode(t))}return rc(r)}function rc(t){if(cd(t))return new rn({multihash:t});if(sd(t))try{let e=Qs(t);if(e.type==="Ed25519")return new nn({multihash:t,publicKey:e});if(e.type==="secp256k1")return new on({multihash:t,publicKey:e})}catch{let r=$(t.digest);return new yr(new URL(r))}throw new Br("Supplied PeerID Multihash is invalid")}function id(t){if(t?.multihash==null||t.version==null||t.version===1&&t.code!==od&&t.code!==ec)throw new Ar("Supplied PeerID CID is invalid");if(t.code===ec){let e=$(t.multihash.digest);return new yr(new URL(e))}return rc(t.multihash)}function sd(t){return t.code===Ue.code}function cd(t){return t.code===$n.code}function nc(t){let e=t.getComponents(),r={},n=0;if(e[n]?.name==="ip6zone"&&(r.zone=`${e[n].value}`,n++),e[n].name==="ip4"||e[n].name==="ip6"||e[n].name==="dns"||e[n].name==="dns4"||e[n].name==="dns6"?(r.type=e[n].name,r.host=e[n].value,n++):e[n].name==="dnsaddr"&&(r.type=e[n].name,r.host=`_dnsaddr.${e[n].value}`,n++),(e[n]?.name==="tcp"||e[n]?.name==="udp")&&(r.protocol=e[n].name==="tcp"?"tcp":"udp",r.port=parseInt(`${e[n].value}`),n++),e[n]?.name==="ipcidr"&&(r.type==="ip4"?r.cidr=parseInt(`${e[n].value}`):r.type==="ip6"&&(r.cidr=`${e[n].value}`),n++),r.type==null||r.host==null)throw new ve(`Multiaddr ${t} was not an IPv4, IPv6, DNS, DNS4, DNS6 or DNSADDR address`);return e[n]?.name==="tls"&&e[n+1]?.name==="sni"&&(r.sni=e[n+1].value,n+=2),r}var Ie=de("node:net");var ic=Dt(oc(),1),ad=["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"],ud=ad.map(t=>new ic.Netmask(t));function qo(t){for(let e of ud)if(e.contains(t))return!0;return!1}function dd(t){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(t)}function ld(t){let e=t.split(":");if(e.length<2)return!1;let r=e[e.length-1].padStart(4,"0"),n=e[e.length-2].padStart(4,"0"),o=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(r.substring(0,2),16)}.${parseInt(r.substring(2),16)}`;return qo(o)}function hd(t){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)}function pd(t){let e=t.split(":"),r=e[e.length-1];return qo(r)}function fd(t){return/^::$/.test(t)||/^::1$/.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)}function sc(t){if((0,Ie.isIPv4)(t))return qo(t);if(dd(t))return ld(t);if(hd(t))return pd(t);if((0,Ie.isIPv6)(t))return fd(t)}function cc(t){try{let e=nc(t);switch(e.type){case"ip4":case"ip6":return sc(e.host)??!1;default:return e.host==="localhost"}}catch{return!1}}var J=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},at=class extends Error{static name="ValidationError";name="ValidationError"},sn=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},cn=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function zo(t){return e=>$(e,t)}function $o(t){return e=>he(e,t)}function Gt(t){return new DataView(t.buffer).getUint16(t.byteOffset).toString()}function Ut(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof t=="string"?parseInt(t):t),new Uint8Array(e)}function ac(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=he(e[0],"base32"),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ut(n);return Ve([r,o],r.length+o.length)}function uc(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=ht.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=Ut(n);return Ve([r,o],r.length+o.length)}function jo(t){let e=t.subarray(0,t.length-2),r=t.subarray(t.length-2),n=$(e,"base32"),o=Gt(r);return`${n}:${o}`}var Go=function(t){t=t.toString().trim();let e=new Uint8Array(4);return t.split(/\./g).forEach((r,n)=>{let o=parseInt(r,10);if(isNaN(o)||o<0||o>255)throw new J("Invalid byte value in IP address");e[n]=o}),e},dc=function(t){let e=0;t=t.toString().trim();let r=t.split(":",8),n;for(n=0;n<r.length;n++){let i=(0,Ie.isIPv4)(r[n]),s;i&&(s=Go(r[n]),r[n]=$(s.subarray(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,$(s.subarray(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++){r[n]===""&&(r[n]="0");let i=parseInt(r[n],16);if(isNaN(i)||i<0||i>65535)throw new J("Invalid byte value in IP address");o[e++]=i>>8&255,o[e++]=i&255}return o},lc=function(t){if(t.byteLength!==4)throw new J("IPv4 address was incorrect length");let e=[];for(let r=0;r<t.byteLength;r++)e.push(t[r]);return e.join(".")},hc=function(t){if(t.byteLength!==16)throw new J("IPv6 address was incorrect length");let e=[];for(let n=0;n<t.byteLength;n+=2){let o=t[n],i=t[n+1],s=`${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`;e.push(s)}let r=e.join(":");try{let n=new URL(`http://[${r}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new J(`Invalid IPv6 address "${r}"`)}};function pc(t){try{let e=new URL(`http://[${t}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new J(`Invalid IPv6 address "${t}"`)}}var Vo=Object.values(tr).map(t=>t.decoder),md=(function(){let t=Vo[0].or(Vo[1]);return Vo.slice(2).forEach(e=>t=t.or(e)),t})();function fc(t){return md.decode(t)}function mc(t){return e=>t.encoder.encode(e)}function gd(t){if(parseInt(t).toString()!==t)throw new at("Value must be an integer")}function yd(t){if(t<0)throw new at("Value must be a positive integer, or zero")}function wd(t){return e=>{if(e>t)throw new at(`Value must be smaller than or equal to ${t}`)}}function xd(...t){return e=>{for(let r of t)r(e)}}var xr=xd(gd,yd,wd(65535));var X=-1,Yo=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(e){let r;if(typeof e=="string"?r=this.protocolsByName.get(e):r=this.protocolsByCode.get(e),r==null)throw new cn(`Protocol ${e} was unknown`);return r}addProtocol(e){this.protocolsByCode.set(e.code,e),this.protocolsByName.set(e.name,e),e.aliases?.forEach(r=>{this.protocolsByName.set(r,e)})}removeProtocol(e){let r=this.protocolsByCode.get(e);r!=null&&(this.protocolsByCode.delete(r.code),this.protocolsByName.delete(r.name),r.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},ut=new Yo,il=[{code:4,name:"ip4",size:32,valueToBytes:Go,bytesToValue:lc,validate:t=>{if(!(0,Ie.isIPv4)(t))throw new at(`Invalid IPv4 address "${t}"`)}},{code:6,name:"tcp",size:16,valueToBytes:Ut,bytesToValue:Gt,validate:xr},{code:273,name:"udp",size:16,valueToBytes:Ut,bytesToValue:Gt,validate:xr},{code:33,name:"dccp",size:16,valueToBytes:Ut,bytesToValue:Gt,validate:xr},{code:41,name:"ip6",size:128,valueToBytes:dc,bytesToValue:hc,stringToValue:pc,validate:t=>{if(!(0,Ie.isIPv6)(t))throw new at(`Invalid IPv6 address "${t}"`)}},{code:42,name:"ip6zone",size:X},{code:43,name:"ipcidr",size:8,bytesToValue:zo("base10"),valueToBytes:$o("base10")},{code:53,name:"dns",size:X},{code:54,name:"dns4",size:X},{code:55,name:"dns6",size:X},{code:56,name:"dnsaddr",size:X},{code:132,name:"sctp",size:16,valueToBytes:Ut,bytesToValue:Gt,validate:xr},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:X,stringToValue:t=>decodeURIComponent(t),valueToString:t=>encodeURIComponent(t)},{code:421,name:"p2p",aliases:["ipfs"],size:X,bytesToValue:zo("base58btc"),valueToBytes:t=>t.startsWith("Q")||t.startsWith("1")?$o("base58btc")(t):Q.parse(t).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:jo,valueToBytes:ac},{code:445,name:"onion3",size:296,bytesToValue:jo,valueToBytes:uc},{code:446,name:"garlic64",size:X},{code:447,name:"garlic32",size:X},{code:448,name:"tls"},{code:449,name:"sni",size:X},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:X,bytesToValue:mc(kn),valueToBytes:fc},{code:480,name:"http"},{code:481,name:"http-path",size:X,stringToValue:t=>`/${decodeURIComponent(t)}`,valueToString:t=>encodeURIComponent(t.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:X}];il.forEach(t=>{ut.addProtocol(t)});function gc(t){let e=[],r=0;for(;r<t.length;){let n=so(t,r),o=ut.getProtocol(n),i=ze(n),s=sl(o,t,r+i),a=0;s>0&&o.size===X&&(a=ze(s));let c=i+a+s,d={code:n,name:o.name,bytes:t.subarray(r,r+c)};if(s>0){let f=r+i+a,l=t.subarray(f,f+s);d.value=o.bytesToValue?.(l)??$(l)}e.push(d),r+=c}return e}function yc(t){let e=0,r=[];for(let n of t){if(n.bytes==null){let o=ut.getProtocol(n.code),i=ze(n.code),s,a=0,c=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??he(n.value),a=s.byteLength,o.size===X&&(c=ze(a)));let d=new Uint8Array(i+c+a),f=0;ir(n.code,d,f),f+=i,s!=null&&(o.size===X&&(ir(a,d,f),f+=c),d.set(s,f)),n.bytes=d}r.push(n.bytes),e+=n.bytes.byteLength}return Ve(r,e)}function wc(t){if(t.charAt(0)!=="/")throw new J('String multiaddr must start with "/"');let e=[],r="protocol",n="",o="";for(let i=1;i<t.length;i++){let s=t.charAt(i);s!=="/"&&(r==="protocol"?o+=t.charAt(i):n+=t.charAt(i));let a=i===t.length-1;if(s==="/"||a){let c=ut.getProtocol(o);if(r==="protocol"){if(c.size==null||c.size===0){e.push({code:c.code,name:c.name}),n="",o="",r="protocol";continue}else if(a)throw new J(`Component ${o} was missing value`);r="value"}else if(r==="value"){let d={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new J(`Component ${o} was missing value`);d.value=c.stringToValue?.(n)??n}e.push(d),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new J("Incomplete multiaddr");return e}function xc(t){return`/${t.flatMap(e=>{if(e.value==null)return e.name;let r=ut.getProtocol(e.code);if(r==null)throw new J(`Unknown protocol code ${e.code}`);return[e.name,r.valueToString?.(e.value)??e.value]}).join("/")}`}function sl(t,e,r){return t.size==null||t.size===0?0:t.size>0?t.size/8:so(e,r)}var cl=Symbol.for("nodejs.util.inspect.custom"),Wo=Symbol.for("@multiformats/multiaddr");function al(t){if(t==null&&(t="/"),bc(t))return t.getComponents();if(t instanceof Uint8Array)return gc(t);if(typeof t=="string")return t=t.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),t===""&&(t="/"),wc(t);if(Array.isArray(t))return t;throw new J("Must be a string, Uint8Array, Component[], or another Multiaddr")}var an=class t{[Wo]=!0;#e;#t;#r;constructor(e="/",r={}){this.#e=al(e),r.validate!==!1&&ul(this)}get bytes(){return this.#r==null&&(this.#r=yc(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=xc(this.#e)),this.#t}toJSON(){return this.toString()}getComponents(){return[...this.#e.map(e=>({...e}))]}encapsulate(e){let r=new t(e);return new t([...this.#e,...r.getComponents()],{validate:!1})}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new sn(`Address ${this.toString()} does not contain subaddress: ${r}`);return new t(n.slice(0,o),{validate:!1})}decapsulateCode(e){let r;for(let n=this.#e.length-1;n>-1;n--)if(this.#e[n].code===e){r=n;break}return new t(this.#e.slice(0,r),{validate:!1})}equals(e){return ye(this.bytes,e.bytes)}[cl](){return`Multiaddr(${this.toString()})`}};function ul(t){t.getComponents().forEach(e=>{let r=ut.getProtocol(e.code);e.value!=null&&r.validate?.(e.value)})}function bc(t){return!!t?.[Wo]}function Ec(t){return new an(t)}function Ic(t,e,r,n){let o=()=>{n?.log.trace("query",e),t.query({questions:[{name:e,type:"PTR"}]})};return o(),setInterval(o,r)}function vc(t,e,r,n){if(t.answers==null)return;let o,i=[];if(t.answers.forEach(s=>{switch(s.type){case"PTR":o=s;break;case"TXT":i.push(s);break;default:break}}),t.additionals.forEach(s=>{switch(s.type){case"TXT":i.push(s);break;default:break}}),!(o==null||o?.name!==r||i.length===0||o.data.startsWith(e)))try{let s=i.flatMap(c=>c.data).filter(c=>c.toString().startsWith("dnsaddr=")).map(c=>Ec(c.toString().substring(8))),a=s[0].getComponents().findLast(c=>c.code===421)?.value;if(a==null)throw new Error("Multiaddr doesn't contain PeerId");return n?.log("peer found %p",a),{id:tc(a),multiaddrs:s.map(c=>c.decapsulateCode(421))}}catch(s){n?.log.error("failed to parse mdns response",s)}}function Sc(t,e,r,n,o,i,s){if(!i){s?.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 a=[];a.push({name:o,type:"PTR",class:"IN",ttl:120,data:r+"."+o}),n.filter(dl).forEach(c=>{let d="dnsaddr="+c.toString();if(d.length>255){s?.log("multiaddr %a is too long to use in mDNS query response",c);return}if(c.getComponents().findLast(f=>f.code===421)?.value==null){s?.log("multiaddr %a did not have a peer ID so cannot be used in mDNS query response",c);return}a.push({name:r+"."+o,type:"TXT",class:"IN",ttl:120,data:d})}),s?.log.trace("responding to query"),e.respond(a)}}function dl(t){return!!cc(t)}function Ac(t){let e="",r="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<t;n++)e+=r.charAt(Math.floor(Math.random()*r.length));return e}var un=class extends Cr{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??Ac(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)}[Jo]=this;[Symbol.toStringTag]="@libp2p/mdns";[ri]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,Bc.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=Ic(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),Sc(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=vc(e,this.peerName,this.serviceTag,{log:this.log});r!=null&&(this.log("discovered peer in mDNS query response %p",r.id),this.dispatchEvent(new CustomEvent("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 hl(t={}){return e=>new un(e,t)}return _c(pl);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/hashes/esm/utils.js:
|