@libp2p/mdns 11.0.46-cb1c14e62 → 11.0.46-cf9aab5c8

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 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 Hc=Object.create;var Ur=Object.defineProperty;var qc=Object.getOwnPropertyDescriptor;var Vc=Object.getOwnPropertyNames;var zc=Object.getPrototypeOf,jc=Object.prototype.hasOwnProperty;var le=(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 Pe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),me=(t,e)=>{for(var r in e)Ur(t,r,{get:e[r],enumerable:!0})},ui=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Vc(e))!jc.call(t,o)&&o!==r&&Ur(t,o,{get:()=>e[o],enumerable:!(n=qc(e,o))||n.enumerable});return t};var Ot=(t,e,r)=>(r=t!=null?Hc(zc(t)):{},ui(e||!t||!t.__esModule?Ur(r,"default",{value:t,enumerable:!0}):r,t)),$c=t=>ui(Ur({},"__esModule",{value:!0}),t);var fi=Pe(yn=>{"use strict";yn.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};yn.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 mi=Pe(wn=>{"use strict";wn.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};wn.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 gi=Pe(xn=>{"use strict";xn.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};xn.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 yi=Pe(bn=>{"use strict";bn.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};bn.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 wi=Pe(En=>{"use strict";En.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}`};En.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 Ei=Pe((bi,In)=>{var xi=function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=d,t.encode=f,t.familyOf=l,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:u=>e.test(u),encode(u,p,h){h=~~h,p=p||new Uint8Array(h+r);let g=u.length,B=0;for(let L=0;L<g;){let N=u.charCodeAt(L++);N===46?(p[h++]=B,B=0):B=B*10+(N-48)}return p[h]=B,p},decode(u,p){return p=~~p,`${u[p++]}.${u[p++]}.${u[p++]}.${u[p]}`}};t.v4=i;let s={name:"v6",size:o,isFormat:u=>u.length>0&&n.test(u),encode(u,p,h){h=~~h;let g=h+o,B=-1,L=0,N=0,z=!0,q=!1;p=p||new Uint8Array(h+o);for(let M=0;M<u.length;M++){let v=u.charCodeAt(M);v===58?(z?B!==-1?(h<g&&(p[h]=0),h<g-1&&(p[h+1]=0),h+=2):h<g&&(B=h):(q===!0?(h<g&&(p[h]=N),h++):(h<g&&(p[h]=L>>8),h<g-1&&(p[h+1]=L&255),h+=2),L=0,N=0),z=!0,q=!1):v===46?(h<g&&(p[h]=N),h++,N=0,L=0,z=!1,q=!0):(z=!1,v>=97?v-=87:v>=65?v-=55:(v-=48,N=N*10+v),L=(L<<4)+v)}if(z===!1)q===!0?(h<g&&(p[h]=N),h++):(h<g&&(p[h]=L>>8),h<g-1&&(p[h+1]=L&255),h+=2);else if(B===0)h<g&&(p[h]=0),h<g-1&&(p[h+1]=0),h+=2;else if(B!==-1){h+=2;for(let M=Math.min(h-1,g-1);M>=B+2;M--)p[M]=p[M-2];p[B]=0,p[B+1]=0,B=h}if(B!==h&&B!==-1)for(h>g-2&&(h=g-2);g>B;)p[--g]=h<g&&h>B?p[--h]:0;else for(;h<g;)p[h++]=0;return p},decode(u,p){p=~~p;let h="";for(let g=0;g<o;g+=2)g!==0&&(h+=":"),h+=(u[p+g]<<8|u[p+g+1]).toString(16);return h.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};t.v6=s;let c="ip";t.name=c;function a(u){if(i.isFormat(u))return i.size;if(s.isFormat(u))return s.size;throw Error(`Invalid ip address: ${u}`)}function l(u){return a(u)===i.size?1:2}function f(u,p,h){h=~~h;let g=a(u);return typeof p=="function"&&(p=p(h+g)),g===i.size?i.encode(u,p,h):s.encode(u,p,h)}function d(u,p,h){if(p=~~p,h=h||u.length-p,h===i.size)return i.decode(u,p,h);if(h===s.size)return s.decode(u,p,h);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 xi}):typeof In=="object"&&typeof bi=="object"&&(In.exports=xi)});var Si=Pe(E=>{"use strict";var I=le("buffer").Buffer,tt=fi(),Gc=mi(),Yc=gi(),Pr=yi(),vn=wi(),bt=Ei(),Wc=0,Ii=32768,Sn=32768,Zc=~Sn,vi=32768,Xc=~vi,x=E.name={};x.encode=function(t,e,r,{mail:n=!1}={}){e||(e=I.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 l=t.toString("utf-8",e,e+a);r&&(l=l.replace(/\./g,"\\.")),n.push(l),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 l=t.readUInt16BE(e-1)-49152;if(l>=o)throw new Error("Cannot decode name (bad pointer)");e=l,o=l,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:I.byteLength(t.replace(/^\.|\.$/gm,""))+2};var U={};U.encode=function(t,e,r){e||(e=I.alloc(U.encodingLength(t))),r||(r=0);let n=e.write(t,r+1);return e[r]=n,U.encode.bytes=n+1,e};U.encode.bytes=0;U.decode=function(t,e){e||(e=0);let r=t[e],n=t.toString("utf-8",e+1,e+1+r);return U.decode.bytes=r+1,n};U.decode.bytes=0;U.encodingLength=function(t){return I.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"?Ii:Wc;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&Ii?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:Yc.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:Gc.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=E.unknown={};$e.encode=function(t,e,r){return e||(e=I.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 Ge=E.ns={};Ge.encode=function(t,e,r){return e||(e=I.alloc(Ge.encodingLength(t))),r||(r=0),x.encode(t,e,r+2),e.writeUInt16BE(x.encode.bytes,r),Ge.encode.bytes=x.encode.bytes+2,e};Ge.encode.bytes=0;Ge.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=x.decode(t,e+2);return Ge.decode.bytes=r+2,n};Ge.decode.bytes=0;Ge.encodingLength=function(t){return x.encodingLength(t)+2};var Ye=E.soa={};Ye.encode=function(t,e,r){e||(e=I.alloc(Ye.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),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.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,Ye.decode.bytes=e-r,n};Ye.decode.bytes=0;Ye.encodingLength=function(t){return 22+x.encodingLength(t.mname)+x.encodingLength(t.rname)};var We=E.txt={};We.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]=I.from(t[o])),!I.isBuffer(t[o]))throw new Error("Must be a Buffer");e||(e=I.alloc(We.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),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=[];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 We.decode.bytes=e-r,o};We.decode.bytes=0;We.encodingLength=function(t){Array.isArray(t)||(t=[t]);let e=2;return t.forEach(function(r){typeof r=="string"?e+=I.byteLength(r)+1:e+=r.length+1}),e};var Ze=E.null={};Ze.encode=function(t,e,r){e||(e=I.alloc(Ze.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=I.from(t)),t||(t=I.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),Ze.encode.bytes=r-n,e};Ze.encode.bytes=0;Ze.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,Ze.decode.bytes=e-r,o};Ze.decode.bytes=0;Ze.encodingLength=function(t){return t?(I.isBuffer(t)?t.length:I.byteLength(t))+2:2};var Xe=E.hinfo={};Xe.encode=function(t,e,r){e||(e=I.alloc(Xe.encodingLength(t))),r||(r=0);let n=r;return r+=2,U.encode(t.cpu,e,r),r+=U.encode.bytes,U.encode(t.os,e,r),r+=U.encode.bytes,e.writeUInt16BE(r-n-2,n),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=U.decode(t,e),e+=U.decode.bytes,n.os=U.decode(t,e),e+=U.decode.bytes,Xe.decode.bytes=e-r,n};Xe.decode.bytes=0;Xe.encodingLength=function(t){return U.encodingLength(t.cpu)+U.encodingLength(t.os)+2};var Ce=E.ptr={},Qc=E.cname=Ce,Jc=E.dname=Ce;Ce.encode=function(t,e,r){return e||(e=I.alloc(Ce.encodingLength(t))),r||(r=0),x.encode(t,e,r+2),e.writeUInt16BE(x.encode.bytes,r),Ce.encode.bytes=x.encode.bytes+2,e};Ce.encode.bytes=0;Ce.decode=function(t,e){e||(e=0);let r=x.decode(t,e+2);return Ce.decode.bytes=x.decode.bytes+2,r};Ce.decode.bytes=0;Ce.encodingLength=function(t){return x.encodingLength(t)+2};var Qe=E.srv={};Qe.encode=function(t,e,r){e||(e=I.alloc(Qe.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),Qe.encode.bytes=n+2,e};Qe.encode.bytes=0;Qe.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),Qe.decode.bytes=r+2,n};Qe.decode.bytes=0;Qe.encodingLength=function(t){return 8+x.encodingLength(t.target)};var ge=E.caa={};ge.ISSUER_CRITICAL=128;ge.encode=function(t,e,r){let n=ge.encodingLength(t);return e||(e=I.alloc(ge.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=ge.ISSUER_CRITICAL),e.writeUInt16BE(n-2,r),r+=2,e.writeUInt8(t.flags||0,r),r+=1,U.encode(t.tag,e,r),r+=U.encode.bytes,e.write(t.value,r),r+=I.byteLength(t.value),ge.encode.bytes=n,e};ge.encode.bytes=0;ge.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e);e+=2;let n=e,o={};return o.flags=t.readUInt8(e),e+=1,o.tag=U.decode(t,e),e+=U.decode.bytes,o.value=t.toString("utf-8",e,n+r),o.issuerCritical=!!(o.flags&ge.ISSUER_CRITICAL),ge.decode.bytes=r+2,o};ge.decode.bytes=0;ge.encodingLength=function(t){return U.encodingLength(t.tag)+U.encodingLength(t.value)+2};var dt=E.mx={};dt.encode=function(t,e,r){e||(e=I.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 Je=E.a={};Je.encode=function(t,e,r){return e||(e=I.alloc(Je.encodingLength(t))),r||(r=0),e.writeUInt16BE(4,r),r+=2,bt.v4.encode(t,e,r),Je.encode.bytes=6,e};Je.encode.bytes=0;Je.decode=function(t,e){e||(e=0),e+=2;let r=bt.v4.decode(t,e);return Je.decode.bytes=6,r};Je.decode.bytes=0;Je.encodingLength=function(){return 6};var et=E.aaaa={};et.encode=function(t,e,r){return e||(e=I.alloc(et.encodingLength(t))),r||(r=0),e.writeUInt16BE(16,r),r+=2,bt.v6.encode(t,e,r),et.encode.bytes=18,e};et.encode.bytes=0;et.decode=function(t,e){e||(e=0),e+=2;let r=bt.v6.decode(t,e);return et.decode.bytes=18,r};et.decode.bytes=0;et.encodingLength=function(){return 18};var de=E.option={};de.encode=function(t,e,r){e||(e=I.alloc(de.encodingLength(t))),r||(r=0);let n=r,o=vn.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||bt.familyOf(t.ip),c=bt.encode(t.ip,I.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 l=t.length||0;e.writeUInt16BE(l,r),r+=2,e.fill(0,r,r+l),r+=l;break;case 14:let f=t.tags.length*2;e.writeUInt16BE(f,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 de.encode.bytes=r-n,e};de.encode.bytes=0;de.decode=function(t,e){e||(e=0);let r={};r.code=t.readUInt16BE(e),r.type=vn.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=I.alloc(r.family===1?4:16);t.copy(o,0,e,e+n-4),r.ip=bt.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 de.decode.bytes=n+4,r};de.decode.bytes=0;de.encodingLength=function(t){if(t.data)return t.data.length+4;switch(vn.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 we=E.opt={};we.encode=function(t,e,r){e||(e=I.alloc(we.encodingLength(t))),r||(r=0);let n=r,o=Pt(t,de);return e.writeUInt16BE(o,r),r=er(t,de,e,r+2),we.encode.bytes=r-n,e};we.encode.bytes=0;we.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++]=de.decode(t,e),e+=de.decode.bytes,o-=de.decode.bytes;return we.decode.bytes=e-r,n};we.decode.bytes=0;we.encodingLength=function(t){return 2+Pt(t||[],de)};var ce=E.dnskey={};ce.PROTOCOL_DNSSEC=3;ce.ZONE_KEY=128;ce.SECURE_ENTRYPOINT=32768;ce.encode=function(t,e,r){e||(e=I.alloc(ce.encodingLength(t))),r||(r=0);let n=r,o=t.key;if(!I.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+I.byteLength(t.key)};var Re=E.rrsig={};Re.encode=function(t,e,r){e||(e=I.alloc(Re.encodingLength(t))),r||(r=0);let n=r,o=t.signature;if(!I.isBuffer(o))throw new Error("Signature must be a Buffer");return r+=2,e.writeUInt16BE(tt.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=tt.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)+I.byteLength(t.signature)};var ke=E.rp={};ke.encode=function(t,e,r){e||(e=I.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 X={};X.encode=function(t,e,r){e||(e=I.alloc(X.encodingLength(t))),r||(r=0);let n=r;for(var o=[],i=0;i<t.length;i++){var s=tt.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=I.from(o[i]);e.writeUInt8(i,r),r+=1,e.writeUInt8(c.length,r),r+=1,c.copy(e,r),r+=c.length}return X.encode.bytes=r-n,e};X.encode.bytes=0;X.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),l=0;l<8;l++)if(a&1<<7-l){var f=tt.toString(i<<8|c<<3|l);o.push(f)}e+=s}return X.decode.bytes=e-n,o};X.decode.bytes=0;X.encodingLength=function(t){for(var e=[],r=0;r<t.length;r++){var n=tt.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=E.nsec={};Ke.encode=function(t,e,r){e||(e=I.alloc(Ke.encodingLength(t))),r||(r=0);let n=r;return r+=2,x.encode(t.nextDomain,e,r),r+=x.encode.bytes,X.encode(t.rrtypes,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;var n={},o=t.readUInt16BE(e);return e+=2,n.nextDomain=x.decode(t,e),e+=x.decode.bytes,n.rrtypes=X.decode(t,e,o-(e-r)),e+=X.decode.bytes,Ke.decode.bytes=e-r,n};Ke.decode.bytes=0;Ke.encodingLength=function(t){return 2+x.encodingLength(t.nextDomain)+X.encodingLength(t.rrtypes)};var Me=E.nsec3={};Me.encode=function(t,e,r){e||(e=I.alloc(Me.encodingLength(t))),r||(r=0);let n=r,o=t.salt;if(!I.isBuffer(o))throw new Error("salt must be a Buffer");let i=t.nextDomain;if(!I.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,X.encode(t.rrtypes,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;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=X.decode(t,e,o-(e-r)),e+=X.decode.bytes,Me.decode.bytes=e-r,n};Me.decode.bytes=0;Me.encodingLength=function(t){return 8+t.salt.length+t.nextDomain.length+X.encodingLength(t.rrtypes)};var Fe=E.ds={};Fe.encode=function(t,e,r){e||(e=I.alloc(Fe.encodingLength(t))),r||(r=0);let n=r,o=t.digest;if(!I.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+I.byteLength(t.digest)};var ye=E.sshfp={};ye.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};ye.encode=function(e,r,n){r||(r=I.alloc(ye.encodingLength(e))),n||(n=0);let o=n;n+=2,r[n]=e.algorithm,n+=1,r[n]=e.hash,n+=1;let i=I.from(e.fingerprint.toUpperCase(),"hex");if(i.length!==ye.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return i.copy(r,n),n+=i.byteLength,ye.encode.bytes=n-o,r.writeUInt16BE(ye.encode.bytes-2,o),r};ye.encode.bytes=0;ye.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=ye.getFingerprintLengthForHashType(o.hash);return o.fingerprint=e.slice(r,r+i).toString("hex").toUpperCase(),r+=i,ye.decode.bytes=r-n,o};ye.decode.bytes=0;ye.encodingLength=function(t){return 4+I.from(t.fingerprint,"hex").byteLength};var He=E.naptr={};He.encode=function(t,e,r){e||(e=I.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,U.encode(t.flags,e,r),r+=U.encode.bytes,U.encode(t.services,e,r),r+=U.encode.bytes,U.encode(t.regexp,e,r),r+=U.encode.bytes,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=U.decode(t,e),e+=U.decode.bytes,n.services=U.decode(t,e),e+=U.decode.bytes,n.regexp=U.decode(t,e),e+=U.decode.bytes,n.replacement=x.decode(t,e),e+=x.decode.bytes,He.decode.bytes=e-r,n};He.decode.bytes=0;He.encodingLength=function(t){return U.encodingLength(t.flags)+U.encodingLength(t.services)+U.encodingLength(t.regexp)+x.encodingLength(t.replacement)+6};var qe=E.tlsa={};qe.encode=function(t,e,r){e||(e=I.alloc(qe.encodingLength(t))),r||(r=0);let n=r,o=t.certificate;if(!I.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+I.byteLength(t.certificate)};var An=E.record=function(t){switch(t.toUpperCase()){case"A":return Je;case"PTR":return Ce;case"CNAME":return Qc;case"DNAME":return Jc;case"TXT":return We;case"NULL":return Ze;case"AAAA":return et;case"SRV":return Qe;case"HINFO":return Xe;case"CAA":return ge;case"NS":return Ge;case"SOA":return Ye;case"MX":return dt;case"OPT":return we;case"DNSKEY":return ce;case"RRSIG":return Re;case"RP":return ke;case"NSEC":return Ke;case"NSEC3":return Me;case"SSHFP":return ye;case"DS":return Fe;case"NAPTR":return He;case"TLSA":return qe}return $e},ee=E.answer={};ee.encode=function(t,e,r){e||(e=I.alloc(ee.encodingLength(t))),r||(r=0);let n=r;if(x.encode(t.name,e,r),r+=x.encode.bytes,e.writeUInt16BE(tt.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,we.encode(t.options||[],e,r),r+=we.encode.bytes}else{let o=Pr.toClass(t.class===void 0?"IN":t.class);t.flush&&(o|=Sn),e.writeUInt16BE(o,r+2),e.writeUInt32BE(t.ttl||0,r+4),r+=8;let i=An(t.type);i.encode(t.data,e,r),r+=i.encode.bytes}return ee.encode.bytes=r-n,e};ee.encode.bytes=0;ee.decode=function(t,e){e||(e=0);let r={},n=e;if(r.name=x.decode(t,e),e+=x.decode.bytes,r.type=tt.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=we.decode(t,e+8),e+=8+we.decode.bytes;else{let o=t.readUInt16BE(e+2);r.ttl=t.readUInt32BE(e+4),r.class=Pr.toString(o&Zc),r.flush=!!(o&Sn);let i=An(r.type);r.data=i.decode(t,e+8),e+=8+i.decode.bytes}return ee.decode.bytes=e-n,r};ee.decode.bytes=0;ee.encodingLength=function(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return x.encodingLength(t.name)+8+An(t.type).encodingLength(e)};var Ue=E.question={};Ue.encode=function(t,e,r){e||(e=I.alloc(Ue.encodingLength(t))),r||(r=0);let n=r;return x.encode(t.name,e,r),r+=x.encode.bytes,e.writeUInt16BE(tt.toType(t.type),r),r+=2,e.writeUInt16BE(Pr.toClass(t.class===void 0?"IN":t.class),r),r+=2,Ue.encode.bytes=r-n,t};Ue.encode.bytes=0;Ue.decode=function(t,e){e||(e=0);let r=e,n={};return n.name=x.decode(t,e),e+=x.decode.bytes,n.type=tt.toString(t.readUInt16BE(e)),e+=2,n.class=Pr.toString(t.readUInt16BE(e)),e+=2,!!(n.class&vi)&&(n.class&=Xc),Ue.decode.bytes=e-r,n};Ue.decode.bytes=0;Ue.encodingLength=function(t){return x.encodingLength(t.name)+4};E.AUTHORITATIVE_ANSWER=1024;E.TRUNCATED_RESPONSE=512;E.RECURSION_DESIRED=256;E.RECURSION_AVAILABLE=128;E.AUTHENTIC_DATA=32;E.CHECKING_DISABLED=16;E.DNSSEC_OK=32768;E.encode=function(t,e,r){let n=!e;n&&(e=I.alloc(E.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=er(t.questions,Ue,e,r),r=er(t.answers,ee,e,r),r=er(t.authorities,ee,e,r),r=er(t.additionals,ee,e,r),E.encode.bytes=r-o,n&&E.encode.bytes!==e.length?e.slice(0,E.encode.bytes):e};E.encode.bytes=0;E.decode=function(t,e){e||(e=0);let r=e,n=Le.decode(t,e);return e+=Le.decode.bytes,e=Or(n.questions,Ue,t,e),e=Or(n.answers,ee,t,e),e=Or(n.authorities,ee,t,e),e=Or(n.additionals,ee,t,e),E.decode.bytes=e-r,n};E.decode.bytes=0;E.encodingLength=function(t){return Le.encodingLength(t)+Pt(t.questions||[],Ue)+Pt(t.answers||[],ee)+Pt(t.authorities||[],ee)+Pt(t.additionals||[],ee)};E.streamEncode=function(t){let e=E.encode(t),r=I.alloc(2);r.writeUInt16BE(e.byteLength);let n=I.concat([r,e]);return E.streamEncode.bytes=n.byteLength,n};E.streamEncode.bytes=0;E.streamDecode=function(t){let e=t.readUInt16BE(0);if(t.byteLength<e+2)return null;let r=E.decode(t.slice(2));return E.streamDecode.bytes=E.decode.bytes,r};E.streamDecode.bytes=0;function Pt(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function er(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 Or(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 Ci=Pe((oh,Bi)=>{"use strict";var Ai=ia;process.nextTick(oa,42);Bi.exports=ea;function ea(t){var e=n;return r;function r(o){e(o||ra)}function n(o){var i=[o];e=s,t(c);function s(a){i.push(a)}function c(a){var l=arguments;for(e=ta(a)?n:f;i.length;)f(i.shift());function f(d){Ai(na,d,l)}}}}function ta(t){return Object.prototype.toString.call(t)==="[object Error]"}function ra(){}function na(t,e){t.apply(null,e)}function oa(t){t===42&&(Ai=process.nextTick)}function ia(t,e,r){process.nextTick(function(){t(e,r)})}});var Ti=Pe((ih,Li)=>{var Bn=Si(),sa=le("dgram"),ca=Ci(),aa=le("events"),Un=le("os"),Cn=function(){};Li.exports=function(t){t||(t={});var e=new aa.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 l=t.socket||sa.createSocket({type:n,reuseAddr:t.reuseAddr!==!1,toString:function(){return n}});l.on("error",function(d){d.code==="EACCES"||d.code==="EADDRINUSE"?e.emit("error",d):e.emit("warning",d)}),l.on("message",function(d,u){try{d=Bn.decode(d)}catch(p){e.emit("warning",p);return}e.emit("packet",d,u),d.type==="query"&&e.emit("query",d,u),d.type==="response"&&e.emit("response",d,u)}),l.on("listening",function(){r||(r=i.port=l.address().port),t.multicast!==!1&&(e.update(),a=setInterval(e.update,5e3),l.setMulticastTTL(t.ttl||255),l.setMulticastLoopback(t.loopback!==!1))});var f=ca(function(d){if(!r||t.bind===!1)return d(null);l.once("error",d),l.bind(r,t.bind||t.interface,function(){l.removeListener("error",d),d(null)})});return f(function(d){if(d)return e.emit("error",d);e.emit("ready")}),e.send=function(d,u,p){if(typeof u=="function")return e.send(d,null,u);p||(p=Cn),u?!u.host&&!u.address&&(u.address=i.address):u=i,f(h);function h(g){if(c)return p();if(g)return p(g);var B=Bn.encode(d);l.send(B,0,B.length,u.port,u.address||u.host,p)}},e.response=e.respond=function(d,u,p){Array.isArray(d)&&(d={answers:d}),d.type="response",d.flags=(d.flags||0)|Bn.AUTHORITATIVE_ANSWER,e.send(d,u,p)},e.query=function(d,u,p,h){if(typeof u=="function")return e.query(d,null,null,u);if(typeof u=="object"&&u&&u.port)return e.query(d,null,u,p);if(typeof p=="function")return e.query(d,u,null,p);h||(h=Cn),typeof d=="string"&&(d=[{name:d,type:u||"ANY"}]),Array.isArray(d)&&(d={type:"query",questions:d}),d.type="query",e.send(d,p,h)},e.destroy=function(d){if(d||(d=Cn),c)return process.nextTick(d);c=!0,clearInterval(a);for(var u in s)try{l.dropMembership(o,u)}catch{}s={},l.close(d)},e.update=function(){for(var d=t.interface?[].concat(t.interface):la(),u=!1,p=0;p<d.length;p++){var h=d[p];if(!s[h])try{l.addMembership(o,h),s[h]=!0,u=!0}catch(g){e.emit("warning",g)}}if(u){if(l.setMulticastInterface)try{l.setMulticastInterface(t.interface||ua())}catch(g){e.emit("warning",g)}e.emit("networkInterface")}},e};function ua(){for(var t=Un.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(Ui(i.family)&&!i.internal)return Un.platform()==="darwin"&&e[r]==="en0"?i.address:"0.0.0.0"}return"127.0.0.1"}function la(){for(var t=Un.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(Ui(s.family)){r.push(s.address);break}}return r}function Ui(t){return t===4||t==="IPv4"}});var fc=Pe(vr=>{(function(){var t,e,r,n,o,i,s,c;c=function(a){var l,f,d,u;return l=(a&255<<24)>>>24,f=(a&255<<16)>>>16,d=(a&65280)>>>8,u=a&255,[l,f,d,u].join(".")},s=function(a){var l,f,d,u,p,h;for(l=[],d=u=0;u<=3&&a.length!==0;d=++u){if(d>0){if(a[0]!==".")throw new Error("Invalid IP");a=a.substring(1)}h=e(a),p=h[0],f=h[1],a=a.substring(f),l.push(p)}if(a.length!==0)throw new Error("Invalid IP");switch(l.length){case 1:if(l[0]>4294967295)throw new Error("Invalid IP");return l[0]>>>0;case 2:if(l[0]>255||l[1]>16777215)throw new Error("Invalid IP");return(l[0]<<24|l[1])>>>0;case 3:if(l[0]>255||l[1]>255||l[2]>65535)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2])>>>0;case 4:if(l[0]>255||l[1]>255||l[2]>255||l[3]>255)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2]<<8|l[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 l,f,d,u,p;for(u=0,l=10,f="9",d=0,a.length>1&&a[d]==="0"&&(a[d+1]==="x"||a[d+1]==="X"?(d+=2,l=16):"0"<=a[d+1]&&a[d+1]<="9"&&(d++,l=8,f="7")),p=d;d<a.length;){if("0"<=a[d]&&a[d]<=f)u=u*l+(r(a[d])-n)>>>0;else if(l===16)if("a"<=a[d]&&a[d]<="f")u=u*l+(10+r(a[d])-i)>>>0;else if("A"<=a[d]&&a[d]<="F")u=u*l+(10+r(a[d])-o)>>>0;else break;else break;if(u>4294967295)throw new Error("too large");d++}if(d===p)throw new Error("empty octet");return[u,d]},t=function(){function a(l,f){var d,u,p,h;if(typeof l!="string")throw new Error("Missing `net' parameter");if(f||(h=l.split("/",2),l=h[0],f=h[1]),f||(f=32),typeof f=="string"&&f.indexOf(".")>-1){try{this.maskLong=s(f)}catch(g){throw d=g,new Error("Invalid mask: "+f)}for(u=p=32;p>=0;u=--p)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(l)&this.maskLong)>>>0}catch(g){throw d=g,new Error("Invalid net address: "+l)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+f);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(l){return typeof l=="string"&&(l.indexOf("/")>0||l.split(".").length!==4)&&(l=new a(l)),l instanceof a?this.contains(l.base)&&this.contains(l.broadcast||l.last):(s(l)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},a.prototype.next=function(l){return l==null&&(l=1),new a(c(this.netLong+this.size*l),this.mask)},a.prototype.forEach=function(l){var f,d,u;for(u=s(this.first),d=s(this.last),f=0;u<=d;)l(c(u),u,f),f++,u++},a.prototype.toString=function(){return this.base+"/"+this.bitmask},a}(),vr.ip2long=s,vr.long2ip=c,vr.Netmask=t}).call(vr)});var Id={};me(Id,{mdns:()=>Ed});var li=Symbol.for("@libp2p/peer-discovery");var gn=Symbol.for("@libp2p/peer-id");var Ne=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},Lr=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var Tr=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},Dr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var Jt=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var di=le("node:events"),hi=(t,...e)=>{try{(0,di.setMaxListeners)(t,...e)}catch{}};var _r=class extends EventTarget{#e=new Map;constructor(){super(),hi(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 pi=Symbol.for("@libp2p/service-capabilities"),Td=Symbol.for("@libp2p/service-dependencies");var Fc=Ot(Ti(),1);var On={};me(On,{base58btc:()=>G,base58flickr:()=>ya});var sh=new Uint8Array(0);function Di(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 Ae(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 _i(t){return new TextEncoder().encode(t)}function Oi(t){return new TextDecoder().decode(t)}function da(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),l=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function d(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var g=0,B=0,L=0,N=h.length;L!==N&&h[L]===0;)L++,g++;for(var z=(N-L)*f+1>>>0,q=new Uint8Array(z);L!==N;){for(var M=h[L],v=0,Z=z-1;(M!==0||v<B)&&Z!==-1;Z--,v++)M+=256*q[Z]>>>0,q[Z]=M%c>>>0,M=M/c>>>0;if(M!==0)throw new Error("Non-zero carry");B=v,L++}for(var J=z-B;J!==z&&q[J]===0;)J++;for(var P=a.repeat(g);J<z;++J)P+=t.charAt(q[J]);return P}function u(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var g=0;if(h[g]!==" "){for(var B=0,L=0;h[g]===a;)B++,g++;for(var N=(h.length-g)*l+1>>>0,z=new Uint8Array(N);h[g];){var q=r[h.charCodeAt(g)];if(q===255)return;for(var M=0,v=N-1;(q!==0||M<L)&&v!==-1;v--,M++)q+=c*z[v]>>>0,z[v]=q%256>>>0,q=q/256>>>0;if(q!==0)throw new Error("Non-zero carry");L=M,g++}if(h[g]!==" "){for(var Z=N-L;Z!==N&&z[Z]===0;)Z++;for(var J=new Uint8Array(B+(N-Z)),P=B;Z!==N;)J[P++]=z[Z++];return J}}}function p(h){var g=u(h);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:u,decode:p}}var ha=da,pa=ha,Ni=pa;var Ln=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")}},Tn=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 Ri(this,e)}},Dn=class{decoders;constructor(e){this.decoders=e}or(e){return Ri(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 Ri(t,e){return new Dn({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var _n=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 Ln(e,r,n),this.decoder=new Tn(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Nt({name:t,prefix:e,encode:r,decode:n}){return new _n(t,e,r,n)}function ht({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=Ni(r,t);return Nt({prefix:e,name:t,encode:n,decode:i=>Ae(o(i))})}function fa(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 l=0;l<o;++l){let f=e[t[l]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|f,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 ma(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 ga(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function $({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=ga(n);return Nt({prefix:e,name:t,encode(i){return ma(i,n,r)},decode(i){return fa(i,o,r,t)}})}var G=ht({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ya=ht({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Pn={};me(Pn,{base32:()=>pt,base32hex:()=>Ea,base32hexpad:()=>va,base32hexpadupper:()=>Sa,base32hexupper:()=>Ia,base32pad:()=>xa,base32padupper:()=>ba,base32upper:()=>wa,base32z:()=>Aa});var pt=$({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),wa=$({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),xa=$({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ba=$({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ea=$({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ia=$({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),va=$({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Sa=$({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Aa=$({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Nn={};me(Nn,{base36:()=>tr,base36upper:()=>Ba});var tr=ht({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ba=ht({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ca=Mi,ki=128,Ua=127,La=~Ua,Ta=Math.pow(2,31);function Mi(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Ta;)e[r++]=t&255|ki,t/=128;for(;t&La;)e[r++]=t&255|ki,t>>>=7;return e[r]=t|0,Mi.bytes=r-n+1,e}var Da=Rn,_a=128,Ki=127;function Rn(t,n){var r=0,n=n||0,o=0,i=n,s,c=t.length;do{if(i>=c)throw Rn.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&Ki)<<o:(s&Ki)*Math.pow(2,o),o+=7}while(s>=_a);return Rn.bytes=i-n,r}var Oa=Math.pow(2,7),Pa=Math.pow(2,14),Na=Math.pow(2,21),Ra=Math.pow(2,28),ka=Math.pow(2,35),Ka=Math.pow(2,42),Ma=Math.pow(2,49),Fa=Math.pow(2,56),Ha=Math.pow(2,63),qa=function(t){return t<Oa?1:t<Pa?2:t<Na?3:t<Ra?4:t<ka?5:t<Ka?6:t<Ma?7:t<Fa?8:t<Ha?9:10},Va={encode:Ca,decode:Da,encodingLength:qa},za=Va,rr=za;function nr(t,e=0){return[rr.decode(t,e),rr.decode.bytes]}function Rt(t,e,r=0){return rr.encode(t,e,r),e}function kt(t){return rr.encodingLength(t)}function Et(t,e){let r=e.byteLength,n=kt(t),o=n+kt(r),i=new Uint8Array(o+r);return Rt(t,i,0),Rt(r,i,n),i.set(e,o),new Kt(t,r,e,i)}function or(t){let e=Ae(t),[r,n]=nr(e),[o,i]=nr(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Kt(r,o,s,e)}function Fi(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Di(t.bytes,r.bytes)}}var Kt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function Hi(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return $a(r,kn(t),e??G.encoder);default:return Ga(r,kn(t),e??pt.encoder)}}var qi=new WeakMap;function kn(t){let e=qi.get(t);if(e==null){let r=new Map;return qi.set(t,r),r}return e}var W=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!==ir)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Ya)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=Et(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&&Fi(e.multihash,n.multihash)}toString(e){return Hi(this,e)}toJSON(){return{"/":Hi(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??Vi(n,o,i.bytes))}else if(r[Wa]===!0){let{version:n,multihash:o,code:i}=r,s=or(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!==ir)throw new Error(`Version 0 CID must use dag-pb (code: ${ir}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Vi(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,ir,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=Ae(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 Kt(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,u]=nr(e.subarray(r));return r+=u,d},o=n(),i=ir;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(),l=r+a,f=l-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:f,size:l}}static parse(e,r){let[n,o]=ja(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 kn(i).set(n,e),i}};function ja(t,e){switch(t[0]){case"Q":{let r=e??G;return[G.prefix,r.decode(`${G.prefix}${t}`)]}case G.prefix:{let r=e??G;return[G.prefix,r.decode(t)]}case pt.prefix:{let r=e??pt;return[pt.prefix,r.decode(t)]}case tr.prefix:{let r=e??tr;return[tr.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!==G.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 Ga(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 ir=112,Ya=18;function Vi(t,e,r){let n=kt(t),o=n+kt(e),i=new Uint8Array(o+r.byteLength);return Rt(t,i,0),Rt(e,i,n),i.set(r,o),i}var Wa=Symbol.for("@ipld/js-cid/CID");var Kn={};me(Kn,{identity:()=>Te});var zi=0,Za="identity",ji=Ae;function Xa(t){return Et(zi,ji(t))}var Te={code:zi,name:Za,encode:ji,digest:Xa};function xe(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 Mn=le("node:buffer");function It(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function rt(t=0){return It(Mn.Buffer.alloc(t))}function De(t=0){return It(Mn.Buffer.allocUnsafe(t))}var $i=le("node:buffer");function Ve(t,e){return It($i.Buffer.concat(t,e))}var Yi=Symbol.for("@achingbrain/uint8arraylist");function Gi(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 Rr(t){return!!t?.[Yi]}var be=class t{bufs;length;[Yi]=!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(Rr(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(Rr(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=Gi(this.bufs,e);return r.buf[r.index]}set(e,r){let n=Gi(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(Rr(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],c=o,a=c+s.byteLength;if(o=a,e>=a)continue;let l=e>=c&&e<a,f=r>c&&r<=a;if(l&&f){if(e===c&&r===a){n.push(s);break}let d=e-c;n.push(s.subarray(d,d+(r-e)));break}if(l){if(e===0){n.push(s);continue}n.push(s.subarray(e-c));continue}if(f){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(!Rr(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,l=n.byteLength-1,f;for(let d=r;d<=a;d+=f){f=0;for(let u=l;u>=0;u--){let p=this.get(d+u);if(n[u]!==p){f=Math.max(1,u-c[p]);break}}if(f===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=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=rt(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=rt(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=rt(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=rt(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=rt(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=rt(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=rt(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=rt(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(!xe(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 Ji=le("node:buffer");var Fn={};me(Fn,{base10:()=>Qa});var Qa=ht({prefix:"9",name:"base10",alphabet:"0123456789"});var Hn={};me(Hn,{base16:()=>Ja,base16upper:()=>eu});var Ja=$({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),eu=$({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var qn={};me(qn,{base2:()=>tu});var tu=$({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Vn={};me(Vn,{base256emoji:()=>su});var Wi=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}"),ru=Wi.reduce((t,e,r)=>(t[r]=e,t),[]),nu=Wi.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function ou(t){return t.reduce((e,r)=>(e+=ru[r],e),"")}function iu(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=nu[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var su=Nt({prefix:"\u{1F680}",name:"base256emoji",encode:ou,decode:iu});var jn={};me(jn,{base64:()=>cu,base64pad:()=>au,base64url:()=>zn,base64urlpad:()=>uu});var cu=$({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),au=$({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),zn=$({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),uu=$({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var $n={};me($n,{base8:()=>lu});var lu=$({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Gn={};me(Gn,{identity:()=>du});var du=Nt({prefix:"\0",name:"identity",encode:t=>Oi(t),decode:t=>_i(t)});var qh=new TextEncoder,Vh=new TextDecoder;var Qn={};me(Qn,{sha256:()=>Xn,sha512:()=>fu});var Zn=Ot(le("crypto"),1);function Wn({name:t,code:e,encode:r}){return new Yn(t,e,r)}var Yn=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?Et(this.code,r):r.then(n=>Et(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Xn=Wn({name:"sha2-256",code:18,encode:t=>Ae(Zn.default.createHash("sha256").update(t).digest())}),fu=Wn({name:"sha2-512",code:19,encode:t=>Ae(Zn.default.createHash("sha512").update(t).digest())});var sr={...Gn,...qn,...$n,...Fn,...Hn,...Pn,...Nn,...On,...jn,...Vn},rp={...Qn,...Kn};function Qi(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var Xi=Qi("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Jn=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}),mu={utf8:Xi,"utf-8":Xi,hex:sr.base16,latin1:Jn,ascii:Jn,binary:Jn,...sr},kr=mu;function te(t,e="utf8"){let r=kr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?It(Ji.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var es=le("node:buffer");function H(t,e="utf8"){let r=kr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?es.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var gu=parseInt("11111",2),eo=parseInt("10000000",2),yu=parseInt("01111111",2),ts={0:cr,1:cr,2:wu,3:Eu,4:Iu,5:bu,6:xu,16:cr,22:cr,48:cr};function to(t,e={offset:0}){let r=t[e.offset]&gu;if(e.offset++,ts[r]!=null)return ts[r](t,e);throw new Error("No decoder for tag "+r)}function ar(t,e){let r=0;if((t[e.offset]&eo)===eo){let n=t[e.offset]&yu,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 cr(t,e){ar(t,e);let r=[];for(;!(e.offset>=t.byteLength);){let n=to(t,e);if(n===null)break;r.push(n)}return r}function wu(t,e){let r=ar(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 xu(t,e){let r=ar(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 l=t[e.offset];if(e.offset++,a.push(l&127),l<128){a.reverse();let f=0;for(let d=0;d<a.length;d++)f+=a[d]<<d*7;c+=`.${f}`,a=[]}}return c}function bu(t,e){return e.offset++,null}function Eu(t,e){let r=ar(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 Iu(t,e){let r=ar(t,e),n=t.subarray(e.offset,e.offset+r);return e.offset+=r,n}function vu(t){let e=t.toString(16);e.length%2===1&&(e="0"+e);let r=new be;for(let n=0;n<e.length;n+=2)r.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return r}function ro(t){if(t.byteLength<128)return Uint8Array.from([t.byteLength]);let e=vu(t.byteLength);return new be(Uint8Array.from([e.byteLength|eo]),e)}function rs(t){let e=new be,r=128;return(t.subarray()[0]&r)===r&&e.append(Uint8Array.from([0])),e.append(t),new be(Uint8Array.from([2]),ro(e),e)}function ns(t){let e=Uint8Array.from([0]),r=new be(e,t);return new be(Uint8Array.from([3]),ro(r),r)}function Kr(t,e=48){let r=new be;for(let n of t)r.append(n);return new be(Uint8Array.from([e]),ro(r),r)}async function os(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 Su=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Au=Uint8Array.from([6,5,43,129,4,0,34]),Bu=Uint8Array.from([6,5,43,129,4,0,35]),Cu={ext:!0,kty:"EC",crv:"P-256"},Uu={ext:!0,kty:"EC",crv:"P-384"},Lu={ext:!0,kty:"EC",crv:"P-521"},no=32,oo=48,io=66;function is(t){let e=to(t);return ss(e)}function ss(t){let e=t[1][1][0],r=1,n,o;if(e.byteLength===no*2+1)return n=H(e.subarray(r,r+no),"base64url"),o=H(e.subarray(r+no),"base64url"),new Ft({...Cu,key_ops:["verify"],x:n,y:o});if(e.byteLength===oo*2+1)return n=H(e.subarray(r,r+oo),"base64url"),o=H(e.subarray(r+oo),"base64url"),new Ft({...Uu,key_ops:["verify"],x:n,y:o});if(e.byteLength===io*2+1)return n=H(e.subarray(r,r+io),"base64url"),o=H(e.subarray(r+io),"base64url"),new Ft({...Lu,key_ops:["verify"],x:n,y:o});throw new Ne(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function cs(t){return Kr([rs(Uint8Array.from([1])),Kr([Tu(t.crv)],160),Kr([ns(new be(Uint8Array.from([4]),te(t.x??"","base64url"),te(t.y??"","base64url")))],161)]).subarray()}function Tu(t){if(t==="P-256")return Su;if(t==="P-384")return Au;if(t==="P-521")return Bu;throw new Ne(`Invalid curve ${t}`)}var Ft=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=cs(this.jwk)),this._raw}toMultihash(){return Te.digest(Ht(this))}toCID(){return W.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:xe(this.raw,e.raw)}async verify(e,r,n){return os(this.jwk,r,e,n)}};var Mr=Ot(le("crypto"),1);var kp=Mr.default.generateKeyPairSync,ur=32;var Du=64;function as(t,e,r){if(t.byteLength!==ur)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!==Du)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=Mr.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:H(t,"base64url"),kty:"OKP"}});return Mr.default.verify(null,r instanceof Uint8Array?r:r.subarray(),n,e)}function ls(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}var Fr=class{type="Ed25519";raw;constructor(e){this.raw=so(e,ur)}toMultihash(){return Te.digest(Ht(this))}toCID(){return W.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:xe(this.raw,e.raw)}verify(e,r,n){n?.signal?.throwIfAborted();let o=as(this.raw,r,e);return ls(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function ds(t){return t=so(t,ur),new Fr(t)}function so(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new Ne(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}var Ou=Math.pow(2,7),Pu=Math.pow(2,14),Nu=Math.pow(2,21),co=Math.pow(2,28),ao=Math.pow(2,35),uo=Math.pow(2,42),lo=Math.pow(2,49),j=128,ne=127;function ze(t){if(t<Ou)return 1;if(t<Pu)return 2;if(t<Nu)return 3;if(t<co)return 4;if(t<ao)return 5;if(t<uo)return 6;if(t<lo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function lr(t,e,r=0){switch(ze(t)){case 8:e[r++]=t&255|j,t/=128;case 7:e[r++]=t&255|j,t/=128;case 6:e[r++]=t&255|j,t/=128;case 5:e[r++]=t&255|j,t/=128;case 4:e[r++]=t&255|j,t>>>=7;case 3:e[r++]=t&255|j,t>>>=7;case 2:e[r++]=t&255|j,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function ho(t,e){let r=t[e],n=0;if(n+=r&ne,r<j||(r=t[e+1],n+=(r&ne)<<7,r<j)||(r=t[e+2],n+=(r&ne)<<14,r<j)||(r=t[e+3],n+=(r&ne)<<21,r<j)||(r=t[e+4],n+=(r&ne)*co,r<j)||(r=t[e+5],n+=(r&ne)*ao,r<j)||(r=t[e+6],n+=(r&ne)*uo,r<j)||(r=t[e+7],n+=(r&ne)*lo,r<j))return n;throw new RangeError("Could not decode varint")}function Ru(t,e){let r=t.get(e),n=0;if(n+=r&ne,r<j||(r=t.get(e+1),n+=(r&ne)<<7,r<j)||(r=t.get(e+2),n+=(r&ne)<<14,r<j)||(r=t.get(e+3),n+=(r&ne)<<21,r<j)||(r=t.get(e+4),n+=(r&ne)*co,r<j)||(r=t.get(e+5),n+=(r&ne)*ao,r<j)||(r=t.get(e+6),n+=(r&ne)*uo,r<j)||(r=t.get(e+7),n+=(r&ne)*lo,r<j))return n;throw new RangeError("Could not decode varint")}function po(t,e=0){return t instanceof Uint8Array?ho(t,e):Ru(t,e)}var fo=new Float32Array([-0]),ft=new Uint8Array(fo.buffer);function hs(t,e,r){fo[0]=t,e[r]=ft[0],e[r+1]=ft[1],e[r+2]=ft[2],e[r+3]=ft[3]}function ps(t,e){return ft[0]=t[e],ft[1]=t[e+1],ft[2]=t[e+2],ft[3]=t[e+3],fo[0]}var mo=new Float64Array([-0]),oe=new Uint8Array(mo.buffer);function fs(t,e,r){mo[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 ms(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],mo[0]}var Ku=BigInt(Number.MAX_SAFE_INTEGER),Mu=BigInt(Number.MIN_SAFE_INTEGER),Ee=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 vt;if(e<Ku&&e>Mu)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>gs&&(o=0n,++n>gs&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return vt;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):vt}},vt=new Ee(0,0);vt.toBigInt=function(){return 0n};vt.zzEncode=vt.zzDecode=function(){return this};vt.length=function(){return 1};var gs=4294967296n;function ys(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 ws(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 go(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 _e(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function Hr(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var yo=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,_e(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 _e(this,4);return Hr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw _e(this,4);return Hr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw _e(this,4);let e=ps(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw _e(this,4);let e=ms(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 _e(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return ws(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw _e(this,e);this.pos+=e}else do if(this.pos>=this.len)throw _e(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 Ee(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 _e(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 _e(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 _e(this,8);let e=Hr(this.buf,this.pos+=4),r=Hr(this.buf,this.pos+=4);return new Ee(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=ho(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 wo(t){return new yo(t instanceof Uint8Array?t:t.subarray())}function qr(t,e,r){let n=wo(t);return e.decode(n,void 0,r)}function xo(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 c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var St=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function bo(){}var Io=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Fu=xo();function Hu(t){return globalThis.Buffer!=null?De(t):Fu(t)}var hr=class{len;head;tail;states;constructor(){this.len=0,this.head=new St(bo,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new St(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new vo((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(Vr,10,Ee.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=Ee.fromBigInt(e);return this._push(Vr,r.length(),r)}uint64Number(e){return this._push(lr,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=Ee.fromBigInt(e).zzEncode();return this._push(Vr,r.length(),r)}sint64Number(e){let r=Ee.fromNumber(e).zzEncode();return this._push(Vr,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Eo,1,e?1:0)}fixed32(e){return this._push(dr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=Ee.fromBigInt(e);return this._push(dr,4,r.lo)._push(dr,4,r.hi)}fixed64Number(e){let r=Ee.fromNumber(e);return this._push(dr,4,r.lo)._push(dr,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(hs,4,e)}double(e){return this._push(fs,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(Eo,1,0):this.uint32(r)._push(Vu,r,e)}string(e){let r=ys(e);return r!==0?this.uint32(r)._push(go,r,e):this._push(Eo,1,0)}fork(){return this.states=new Io(this),this.head=this.tail=new St(bo,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 St(bo,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=Hu(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function Eo(t,e,r){e[r]=t&255}function qu(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var vo=class extends St{next;constructor(e,r){super(qu,e,r),this.next=void 0}};function Vr(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 dr(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 Vu(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(hr.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(zu,e,t),this},hr.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(ju,e,t),this});function zu(t,e,r){e.set(t,r)}function ju(t,e,r){t.length<40?go(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(te(t),r)}function So(){return new hr}function zr(t,e){let r=So();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var qt;(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"})(qt||(qt={}));function jr(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function Ao(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 jr("enum",qt.VARINT,r,n)}function $r(t,e){return jr("message",qt.LENGTH_DELIMITED,t,e)}var Ie;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.ECDSA="ECDSA"})(Ie||(Ie={}));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=()=>Ao(Bo)})(Ie||(Ie={}));var pr;(function(t){let e;t.codec=()=>(e==null&&(e=$r((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),Ie.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=Ie.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),e),t.encode=r=>zr(r,t.codec()),t.decode=(r,n)=>qr(r,t.codec(),n)})(pr||(pr={}));var Co;(function(t){let e;t.codec=()=>(e==null&&(e=$r((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),Ie.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=Ie.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),e),t.encode=r=>zr(r,t.codec()),t.decode=(r,n)=>qr(r,t.codec(),n)})(Co||(Co={}));var nt=Ot(le("node:crypto"),1),At=nt&&typeof nt=="object"&&"webcrypto"in nt?nt.webcrypto:nt&&typeof nt=="object"&&"randomBytes"in nt?nt:void 0;function Bt(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function fr(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ie(t,...e){if(!Bt(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 Gr(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");fr(t.outputLen),fr(t.blockLen)}function zt(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 Es(t,e){ie(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Ct(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Yr(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Oe(t,e){return t<<32-e|t>>>e}var Is=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Gu=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function it(t){if(ie(t),Is)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=Gu[t[r]];return e}var ot={_0:48,_9:57,A:65,F:70,a:97,f:102};function bs(t){if(t>=ot._0&&t<=ot._9)return t-ot._0;if(t>=ot.A&&t<=ot.F)return t-(ot.A-10);if(t>=ot.a&&t<=ot.f)return t-(ot.a-10)}function Ut(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Is)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=bs(t.charCodeAt(i)),c=bs(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 vs(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function mr(t){return typeof t=="string"&&(t=vs(t)),ie(t),t}function je(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];ie(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 Vt=class{};function Ss(t){let e=n=>t().update(mr(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Uo(t=32){if(At&&typeof At.getRandomValues=="function")return At.getRandomValues(new Uint8Array(t));if(At&&typeof At.randomBytes=="function")return Uint8Array.from(At.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}function Yu(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,l=n?0:4;t.setUint32(e+a,s,n),t.setUint32(e+l,c,n)}function As(t,e,r){return t&e^~t&r}function Bs(t,e,r){return t&e^t&r^e&r}var Wr=class extends Vt{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=Yr(this.buffer)}update(e){zt(this),e=mr(e),ie(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=Yr(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){zt(this),Es(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,Ct(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let d=s;d<o;d++)r[d]=0;Yu(n,o-8,BigInt(this.length*8),i),this.process(n,0);let c=Yr(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=a/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)c.setUint32(4*d,f[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()}},st=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Wu=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]),mt=new Uint32Array(64),Lo=class extends Wr{constructor(e=32){super(64,e,8,!1),this.A=st[0]|0,this.B=st[1]|0,this.C=st[2]|0,this.D=st[3]|0,this.E=st[4]|0,this.F=st[5]|0,this.G=st[6]|0,this.H=st[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)mt[d]=e.getUint32(r,!1);for(let d=16;d<64;d++){let u=mt[d-15],p=mt[d-2],h=Oe(u,7)^Oe(u,18)^u>>>3,g=Oe(p,17)^Oe(p,19)^p>>>10;mt[d]=g+mt[d-7]+h+mt[d-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:l,H:f}=this;for(let d=0;d<64;d++){let u=Oe(c,6)^Oe(c,11)^Oe(c,25),p=f+u+As(c,a,l)+Wu[d]+mt[d]|0,g=(Oe(n,2)^Oe(n,13)^Oe(n,22))+Bs(n,o,i)|0;f=l,l=a,a=c,c=s+p|0,s=i,i=o,o=n,n=p+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,l=l+this.G|0,f=f+this.H|0,this.set(n,o,i,s,c,a,l,f)}roundClean(){Ct(mt)}destroy(){this.set(0,0,0,0,0,0,0,0),Ct(this.buffer)}};var Cs=Ss(()=>new Lo);var oc=Ot(le("node:crypto"),1);var Zr=class extends Vt{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Gr(e);let n=mr(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),Ct(i)}update(e){return zt(this),this.iHash.update(e),this}digestInto(e){zt(this),ie(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()}},To=(t,e,r)=>new Zr(t,e).update(r).digest();To.create=(t,e)=>new Zr(t,e);var Oo=BigInt(0),_o=BigInt(1);function gr(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}function yr(t){let e=t.toString(16);return e.length&1?"0"+e:e}function Us(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Oo:BigInt("0x"+t)}function jt(t){return Us(it(t))}function Po(t){return ie(t),Us(it(Uint8Array.from(t).reverse()))}function Xr(t,e){return Ut(t.toString(16).padStart(e*2,"0"))}function No(t,e){return Xr(t,e).reverse()}function ae(t,e,r){let n;if(typeof e=="string")try{n=Ut(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(Bt(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 Do=t=>typeof t=="bigint"&&Oo<=t;function Ls(t,e,r){return Do(t)&&Do(e)&&Do(r)&&e<=t&&t<r}function Ts(t,e,r,n){if(!Ls(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Qr(t){let e;for(e=0;t>Oo;t>>=_o,e+=1);return e}var gt=t=>(_o<<BigInt(t))-_o;function Ds(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=p=>new Uint8Array(p),o=p=>Uint8Array.of(p),i=n(t),s=n(t),c=0,a=()=>{i.fill(1),s.fill(0),c=0},l=(...p)=>r(s,i,...p),f=(p=n(0))=>{s=l(o(0),p),i=l(),p.length!==0&&(s=l(o(1),p),i=l())},d=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let p=0,h=[];for(;p<e;){i=l();let g=i.slice();h.push(g),p+=i.length}return je(...h)};return(p,h)=>{a(),f(p);let g;for(;!(g=h(d()));)f();return a(),g}}function wr(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 Ro(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 ue=BigInt(0),se=BigInt(1),Lt=BigInt(2),Ps=BigInt(3),Ns=BigInt(4),Rs=BigInt(5),Zu=BigInt(7),ks=BigInt(8),Xu=BigInt(9),Ks=BigInt(16);function Be(t,e){let r=t%e;return r>=ue?r:e+r}function ve(t,e,r){let n=t;for(;e-- >ue;)n*=n,n%=r;return n}function _s(t,e){if(t===ue)throw new Error("invert: expected non-zero number");if(e<=ue)throw new Error("invert: expected positive modulus, got "+e);let r=Be(t,e),n=e,o=ue,i=se,s=se,c=ue;for(;r!==ue;){let l=n/r,f=n%r,d=o-s*l,u=i-c*l;n=r,r=f,o=s,i=c,s=d,c=u}if(n!==se)throw new Error("invert: does not exist");return Be(o,e)}function ko(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function Ms(t,e){let r=(t.ORDER+se)/Ns,n=t.pow(e,r);return ko(t,n,e),n}function Qu(t,e){let r=(t.ORDER-Rs)/ks,n=t.mul(e,Lt),o=t.pow(n,r),i=t.mul(e,o),s=t.mul(t.mul(i,Lt),o),c=t.mul(i,t.sub(s,t.ONE));return ko(t,c,e),c}function Ju(t){let e=yt(t),r=Fs(t),n=r(e,e.neg(e.ONE)),o=r(e,n),i=r(e,e.neg(n)),s=(t+Zu)/Ks;return(c,a)=>{let l=c.pow(a,s),f=c.mul(l,n),d=c.mul(l,o),u=c.mul(l,i),p=c.eql(c.sqr(f),a),h=c.eql(c.sqr(d),a);l=c.cmov(l,f,p),f=c.cmov(u,d,h);let g=c.eql(c.sqr(f),a),B=c.cmov(l,f,g);return ko(c,B,a),B}}function Fs(t){if(t<Ps)throw new Error("sqrt is not defined for small field");let e=t-se,r=0;for(;e%Lt===ue;)e/=Lt,r++;let n=Lt,o=yt(t);for(;Os(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Ms;let i=o.pow(n,e),s=(e+se)/Lt;return function(a,l){if(a.is0(l))return l;if(Os(a,l)!==1)throw new Error("Cannot find square root");let f=r,d=a.mul(a.ONE,i),u=a.pow(l,e),p=a.pow(l,s);for(;!a.eql(u,a.ONE);){if(a.is0(u))return a.ZERO;let h=1,g=a.sqr(u);for(;!a.eql(g,a.ONE);)if(h++,g=a.sqr(g),h===f)throw new Error("Cannot find square root");let B=se<<BigInt(f-h-1),L=a.pow(d,B);f=h,d=a.sqr(L),u=a.mul(u,d),p=a.mul(p,L)}return p}}function el(t){return t%Ns===Ps?Ms:t%ks===Rs?Qu:t%Ks===Xu?Ju(t):Fs(t)}var tl=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ko(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},r=tl.reduce((n,o)=>(n[o]="function",n),e);return wr(t,r),t}function rl(t,e,r){if(r<ue)throw new Error("invalid exponent, negatives unsupported");if(r===ue)return t.ONE;if(r===se)return e;let n=t.ONE,o=e;for(;r>ue;)r&se&&(n=t.mul(n,o)),o=t.sqr(o),r>>=se;return n}function Jr(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 Os(t,e){let r=(t.ORDER-se)/Lt,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 Hs(t,e){e!==void 0&&fr(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<=ue)throw new Error("invalid field: expected ORDER > 0, got "+t);let o,i,s=!1,c;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.modOnDecode=="boolean"&&(s=u.modOnDecode),c=u.allowedLengths}else typeof e=="number"&&(o=e),n.sqrt&&(i=n.sqrt);let{nBitLength:a,nByteLength:l}=Hs(t,o);if(l>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let f,d=Object.freeze({ORDER:t,isLE:r,BITS:a,BYTES:l,MASK:gt(a),ZERO:ue,ONE:se,allowedLengths:c,create:u=>Be(u,t),isValid:u=>{if(typeof u!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof u);return ue<=u&&u<t},is0:u=>u===ue,isValidNot0:u=>!d.is0(u)&&d.isValid(u),isOdd:u=>(u&se)===se,neg:u=>Be(-u,t),eql:(u,p)=>u===p,sqr:u=>Be(u*u,t),add:(u,p)=>Be(u+p,t),sub:(u,p)=>Be(u-p,t),mul:(u,p)=>Be(u*p,t),pow:(u,p)=>rl(d,u,p),div:(u,p)=>Be(u*_s(p,t),t),sqrN:u=>u*u,addN:(u,p)=>u+p,subN:(u,p)=>u-p,mulN:(u,p)=>u*p,inv:u=>_s(u,t),sqrt:i||(u=>(f||(f=el(t)),f(d,u))),toBytes:u=>r?No(u,l):Xr(u,l),fromBytes:(u,p=!0)=>{if(c){if(!c.includes(u.length)||u.length>l)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+u.length);let g=new Uint8Array(l);g.set(u,r?0:g.length-u.length),u=g}if(u.length!==l)throw new Error("Field.fromBytes: expected "+l+" bytes, got "+u.length);let h=r?Po(u):jt(u);if(s&&(h=Be(h,t)),!p&&!d.isValid(h))throw new Error("invalid field element: outside of range 0..ORDER");return h},invertBatch:u=>Jr(d,u),cmov:(u,p,h)=>h?p:u});return Object.freeze(d)}function qs(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 Mo(t){let e=qs(t);return e+Math.ceil(e/2)}function Fo(t,e,r=!1){let n=t.length,o=qs(e),i=Mo(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Po(t):jt(t),c=Be(s,e-se)+se;return r?No(c,o):Xr(c,o)}var $t=BigInt(0),Tt=BigInt(1);function xr(t,e){let r=e.negate();return t?r:e}function tn(t,e){let r=Jr(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function $s(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Ho(t,e){$s(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 Vs(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+=Tt);let l=e*n,f=l+Math.abs(c)-1,d=c===0,u=c<0,p=e%2!==0;return{nextN:a,offset:f,isZero:d,isNeg:u,isNegF:p,offsetF:l}}function nl(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 ol(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 qo=new WeakMap,Gs=new WeakMap;function Vo(t){return Gs.get(t)||1}function zs(t){if(t!==$t)throw new Error("invalid wNAF")}var en=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>$t;)r&Tt&&(n=n.add(o)),o=o.double(),r>>=Tt;return n}precomputeWindow(e,r){let{windows:n,windowSize:o}=Ho(r,this.bits),i=[],s=e,c=s;for(let a=0;a<n;a++){c=s,i.push(c);for(let l=1;l<o;l++)c=c.add(s),i.push(c);s=c.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=Ho(e,this.bits);for(let c=0;c<s.windows;c++){let{nextN:a,offset:l,isZero:f,isNeg:d,isNegF:u,offsetF:p}=Vs(n,c,s);n=a,f?i=i.add(xr(u,r[p])):o=o.add(xr(d,r[l]))}return zs(n),{p:o,f:i}}wNAFUnsafe(e,r,n,o=this.ZERO){let i=Ho(e,this.bits);for(let s=0;s<i.windows&&n!==$t;s++){let{nextN:c,offset:a,isZero:l,isNeg:f}=Vs(n,s,i);if(n=c,!l){let d=r[a];o=o.add(f?d.negate():d)}}return zs(n),o}getPrecomputes(e,r,n){let o=qo.get(r);return o||(o=this.precomputeWindow(r,e),e!==1&&(typeof n=="function"&&(o=n(o)),qo.set(r,o))),o}cached(e,r,n){let o=Vo(e);return this.wNAF(o,this.getPrecomputes(o,e,n),r)}unsafe(e,r,n,o){let i=Vo(e);return i===1?this._unsafeLadder(e,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),r,o)}createCache(e,r){$s(r,this.bits),Gs.set(e,r),qo.delete(e)}hasCache(e){return Vo(e)!==1}};function Ys(t,e,r,n){let o=e,i=t.ZERO,s=t.ZERO;for(;r>$t||n>$t;)r&Tt&&(i=i.add(o)),n&Tt&&(s=s.add(o)),o=o.double(),r>>=Tt,n>>=Tt;return{p1:i,p2:s}}function Ws(t,e,r,n){nl(r,t),ol(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=Qr(BigInt(o)),a=1;c>12?a=c-3:c>4?a=c-2:c>0&&(a=2);let l=gt(a),f=new Array(Number(l)+1).fill(s),d=Math.floor((e.BITS-1)/a)*a,u=s;for(let p=d;p>=0;p-=a){f.fill(s);for(let g=0;g<i;g++){let B=n[g],L=Number(B>>BigInt(p)&l);f[L]=f[L].add(r[g])}let h=s;for(let g=f.length-1,B=s;g>0;g--)B=B.add(f[g]),h=h.add(B);if(u=u.add(h),p!==0)for(let g=0;g<a;g++)u=u.double()}return u}function js(t,e){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Ko(e),e}else return yt(t)}function Zs(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>$t))throw new Error(`CURVE.${c} must be positive bigint`)}let n=js(e.p,r.Fp),o=js(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}}var Xs=(t,e)=>(t+(t>=0?e:-e)/Js)/e;function il(t,e,r){let[[n,o],[i,s]]=e,c=Xs(s*t,r),a=Xs(-o*t,r),l=t-c*n-a*i,f=-c*o-a*s,d=l<at,u=f<at;d&&(l=-l),u&&(f=-f);let p=gt(Math.ceil(Qr(r)/2))+Yt;if(l<at||l>=p||f<at||f>=p)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:d,k1:l,k2neg:u,k2:f}}function Qs(t){t.lowS!==void 0&&gr("lowS",t.lowS),t.prehash!==void 0&&gr("prehash",t.prehash)}var zo=class extends Error{constructor(e=""){super(e)}},ct={Err:zo,_tlv:{encode:(t,e)=>{let{Err:r}=ct;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=yr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?yr(o.length/2|128):"";return yr(t)+i+o+e},decode(t,e){let{Err:r}=ct,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 l=e.subarray(n,n+a);if(l.length!==a)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let f of l)s=s<<8|f;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}=ct;if(t<at)throw new e("integer: negative integers are not allowed");let r=yr(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}=ct;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 jt(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=ct,o=ae("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:l,l:f}=n.decode(2,a);if(f.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(l)}},hexFromSig(t){let{_tlv:e,_int:r}=ct,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}},at=BigInt(0),Yt=BigInt(1),Js=BigInt(2),rn=BigInt(3),sl=BigInt(4);function cl(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 Gt(t,e){let{BYTES:r}=t,n;if(typeof e=="bigint")n=e;else{let o=ae("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 al(t,e={}){let{Fp:r,Fn:n}=Zs("weierstrass",t,e),{h:o,n:i}=t;wr(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"||!Array.isArray(s.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');function c(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function a(P,y,S){let{x:C,y:_}=y.toAffine(),R=r.toBytes(C);if(gr("isCompressed",S),S){c();let k=!r.isOdd(_);return je(ec(k),R)}else return je(Uint8Array.of(4),R,r.toBytes(_))}function l(P){ie(P);let y=r.BYTES,S=y+1,C=2*y+1,_=P.length,R=P[0],k=P.subarray(1);if(_===S&&(R===2||R===3)){let w=r.fromBytes(k);if(!r.isValid(w))throw new Error("bad point: is not on curve, wrong x");let m=u(w),b;try{b=r.sqrt(m)}catch(D){let O=D instanceof Error?": "+D.message:"";throw new Error("bad point: is not on curve, sqrt error"+O)}c();let A=r.isOdd(b);return(R&1)===1!==A&&(b=r.neg(b)),{x:w,y:b}}else if(_===C&&R===4){let w=r.fromBytes(k.subarray(y*0,y*1)),m=r.fromBytes(k.subarray(y*1,y*2));if(!p(w,m))throw new Error("bad point: is not on curve");return{x:w,y:m}}else throw new Error(`bad point: got length ${_}, expected compressed=${S} or uncompressed=${C}`)}let f=e.toBytes||a,d=e.fromBytes||l,u=cl(r,t.a,t.b);function p(P,y){let S=r.sqr(y),C=u(P);return r.eql(S,C)}if(!p(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let h=r.mul(r.pow(t.a,rn),sl),g=r.mul(r.sqr(t.b),BigInt(27));if(r.is0(r.add(h,g)))throw new Error("bad curve params: a or b");function B(P,y,S=!1){if(!r.isValid(y)||S&&r.is0(y))throw new Error(`bad point coordinate ${P}`);return y}function L(P){if(!(P instanceof v))throw new Error("ProjectivePoint expected")}function N(P){if(!s||!s.basises)throw new Error("no endo");return il(P,s.basises,n.ORDER)}let z=Ro((P,y)=>{let{X:S,Y:C,Z:_}=P;if(r.eql(_,r.ONE))return{x:S,y:C};let R=P.is0();y==null&&(y=R?r.ONE:r.inv(_));let k=r.mul(S,y),w=r.mul(C,y),m=r.mul(_,y);if(R)return{x:r.ZERO,y:r.ZERO};if(!r.eql(m,r.ONE))throw new Error("invZ was invalid");return{x:k,y:w}}),q=Ro(P=>{if(P.is0()){if(e.allowInfinityPoint&&!r.is0(P.Y))return;throw new Error("bad point: ZERO")}let{x:y,y:S}=P.toAffine();if(!r.isValid(y)||!r.isValid(S))throw new Error("bad point: x or y not field elements");if(!p(y,S))throw new Error("bad point: equation left != right");if(!P.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function M(P,y,S,C,_){return S=new v(r.mul(S.X,P),S.Y,S.Z),y=xr(C,y),S=xr(_,S),y.add(S)}class v{constructor(y,S,C){this.X=B("x",y),this.Y=B("y",S,!0),this.Z=B("z",C),Object.freeze(this)}static fromAffine(y){let{x:S,y:C}=y||{};if(!y||!r.isValid(S)||!r.isValid(C))throw new Error("invalid affine point");if(y instanceof v)throw new Error("projective point not allowed");return r.is0(S)&&r.is0(C)?v.ZERO:new v(S,C,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}static normalizeZ(y){return tn(v,y)}static fromBytes(y){return ie(y),v.fromHex(y)}static fromHex(y){let S=v.fromAffine(d(ae("pointHex",y)));return S.assertValidity(),S}static fromPrivateKey(y){return v.BASE.multiply(Gt(n,y))}static msm(y,S){return Ws(v,n,y,S)}_setWindowSize(y){this.precompute(y)}precompute(y=8,S=!0){return J.createCache(this,y),S||this.multiply(rn),this}assertValidity(){q(this)}hasEvenY(){let{y}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(y)}equals(y){L(y);let{X:S,Y:C,Z:_}=this,{X:R,Y:k,Z:w}=y,m=r.eql(r.mul(S,w),r.mul(R,_)),b=r.eql(r.mul(C,w),r.mul(k,_));return m&&b}negate(){return new v(this.X,r.neg(this.Y),this.Z)}double(){let{a:y,b:S}=t,C=r.mul(S,rn),{X:_,Y:R,Z:k}=this,w=r.ZERO,m=r.ZERO,b=r.ZERO,A=r.mul(_,_),T=r.mul(R,R),D=r.mul(k,k),O=r.mul(_,R);return O=r.add(O,O),b=r.mul(_,k),b=r.add(b,b),w=r.mul(y,b),m=r.mul(C,D),m=r.add(w,m),w=r.sub(T,m),m=r.add(T,m),m=r.mul(w,m),w=r.mul(O,w),b=r.mul(C,b),D=r.mul(y,D),O=r.sub(A,D),O=r.mul(y,O),O=r.add(O,b),b=r.add(A,A),A=r.add(b,A),A=r.add(A,D),A=r.mul(A,O),m=r.add(m,A),D=r.mul(R,k),D=r.add(D,D),A=r.mul(D,O),w=r.sub(w,A),b=r.mul(D,T),b=r.add(b,b),b=r.add(b,b),new v(w,m,b)}add(y){L(y);let{X:S,Y:C,Z:_}=this,{X:R,Y:k,Z:w}=y,m=r.ZERO,b=r.ZERO,A=r.ZERO,T=t.a,D=r.mul(t.b,rn),O=r.mul(S,R),V=r.mul(C,k),F=r.mul(_,w),pe=r.add(S,C),K=r.add(R,k);pe=r.mul(pe,K),K=r.add(O,V),pe=r.sub(pe,K),K=r.add(S,_);let Y=r.add(R,w);return K=r.mul(K,Y),Y=r.add(O,F),K=r.sub(K,Y),Y=r.add(C,_),m=r.add(k,w),Y=r.mul(Y,m),m=r.add(V,F),Y=r.sub(Y,m),A=r.mul(T,K),m=r.mul(D,F),A=r.add(m,A),m=r.sub(V,A),A=r.add(V,A),b=r.mul(m,A),V=r.add(O,O),V=r.add(V,O),F=r.mul(T,F),K=r.mul(D,K),V=r.add(V,F),F=r.sub(O,F),F=r.mul(T,F),K=r.add(K,F),O=r.mul(V,K),b=r.add(b,O),O=r.mul(Y,K),m=r.mul(pe,m),m=r.sub(m,O),O=r.mul(pe,V),A=r.mul(Y,A),A=r.add(A,O),new v(m,b,A)}subtract(y){return this.add(y.negate())}is0(){return this.equals(v.ZERO)}multiply(y){let{endo:S}=e;if(!n.isValidNot0(y))throw new Error("invalid scalar: out of range");let C,_,R=k=>J.cached(this,k,w=>tn(v,w));if(S){let{k1neg:k,k1:w,k2neg:m,k2:b}=N(y),{p:A,f:T}=R(w),{p:D,f:O}=R(b);_=T.add(O),C=M(S.beta,A,D,k,m)}else{let{p:k,f:w}=R(y);C=k,_=w}return tn(v,[C,_])[0]}multiplyUnsafe(y){let{endo:S}=e,C=this;if(!n.isValid(y))throw new Error("invalid scalar: out of range");if(y===at||C.is0())return v.ZERO;if(y===Yt)return C;if(J.hasCache(this))return this.multiply(y);if(S){let{k1neg:_,k1:R,k2neg:k,k2:w}=N(y),{p1:m,p2:b}=Ys(v,C,R,w);return M(S.beta,m,b,_,k)}else return J.unsafe(C,y)}multiplyAndAddUnsafe(y,S,C){let _=this.multiplyUnsafe(S).add(y.multiplyUnsafe(C));return _.is0()?void 0:_}toAffine(y){return z(this,y)}isTorsionFree(){let{isTorsionFree:y}=e;return o===Yt?!0:y?y(v,this):J.unsafe(this,i).is0()}clearCofactor(){let{clearCofactor:y}=e;return o===Yt?this:y?y(v,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(y=!0){return gr("isCompressed",y),this.assertValidity(),f(v,this,y)}toRawBytes(y=!0){return this.toBytes(y)}toHex(y=!0){return it(this.toBytes(y))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}v.BASE=new v(t.Gx,t.Gy,r.ONE),v.ZERO=new v(r.ZERO,r.ONE,r.ZERO),v.Fp=r,v.Fn=n;let Z=n.BITS,J=new en(v,e.endo?Math.ceil(Z/2):Z);return v}function ec(t){return Uint8Array.of(t?2:3)}function ul(t,e,r={}){Gr(e),wr(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let n=r.randomBytes||Uo,o=r.hmac||((w,...m)=>To(e,w,je(...m))),{Fp:i,Fn:s}=t,{ORDER:c,BITS:a}=s,l=Mo(c),f={secret:s.BYTES,public:1+i.BYTES,publicUncompressed:1+2*i.BYTES,signature:2*s.BYTES,seed:l};function d(w){let m=c>>Yt;return w>m}function u(w){return d(w)?s.neg(w):w}function p(w,m){if(!s.isValidNot0(m))throw new Error(`invalid signature ${w}: out of range 1..CURVE.n`)}class h{constructor(m,b,A){p("r",m),p("s",b),this.r=m,this.s=b,A!=null&&(this.recovery=A),Object.freeze(this)}static fromBytes(m,b="compact"){if(b==="compact"){let A=s.BYTES;ie(m,A*2);let T=m.subarray(0,A),D=m.subarray(A,A*2);return new h(s.fromBytes(T),s.fromBytes(D))}if(b==="der"){ie(m);let{r:A,s:T}=ct.toSig(m);return new h(A,T)}throw new Error("invalid format")}static fromHex(m,b){return this.fromBytes(Ut(m),b)}addRecoveryBit(m){return new h(this.r,this.s,m)}recoverPublicKey(m){let b=i.ORDER,{r:A,s:T,recovery:D}=this;if(D==null||![0,1,2,3].includes(D))throw new Error("recovery id invalid");if(c*Js<b&&D>1)throw new Error("recovery id is ambiguous for h>1 curve");let V=D===2||D===3?A+c:A;if(!i.isValid(V))throw new Error("recovery id 2 or 3 invalid");let F=i.toBytes(V),pe=t.fromHex(je(ec((D&1)===0),F)),K=s.inv(V),Y=Z(ae("msgHash",m)),fe=s.create(-Y*K),lt=s.create(T*K),wt=t.BASE.multiplyUnsafe(fe).add(pe.multiplyUnsafe(lt));if(wt.is0())throw new Error("point at infinify");return wt.assertValidity(),wt}hasHighS(){return d(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,s.neg(this.s),this.recovery):this}toBytes(m="compact"){if(m==="compact")return je(s.toBytes(this.r),s.toBytes(this.s));if(m==="der")return Ut(ct.hexFromSig(this));throw new Error("invalid format")}toHex(m){return it(this.toBytes(m))}assertValidity(){}static fromCompact(m){return h.fromBytes(ae("sig",m),"compact")}static fromDER(m){return h.fromBytes(ae("sig",m),"der")}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return it(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return it(this.toBytes("compact"))}}function g(w){try{return!!Gt(s,w)}catch{return!1}}function B(w,m){try{let b=w.length;return m===!0&&b!==f.public||m===!1&&b!==f.publicUncompressed?!1:!!t.fromBytes(w)}catch{return!1}}function L(w=n(l)){return Fo(w,c)}let N={isValidSecretKey:g,isValidPublicKey:B,randomSecretKey:L,isValidPrivateKey:g,randomPrivateKey:L,normPrivateKeyToScalar:w=>Gt(s,w),precompute(w=8,m=t.BASE){return m.precompute(w,!1)}};function z(w,m=!0){return t.BASE.multiply(Gt(s,w)).toBytes(m)}function q(w){if(typeof w=="bigint")return!1;if(w instanceof t)return!0;if(s.allowedLengths||f.secret===f.public)return;let m=ae("key",w).length;return m===f.public||m===f.publicUncompressed}function M(w,m,b=!0){if(q(w)===!0)throw new Error("first arg must be private key");if(q(m)===!1)throw new Error("second arg must be public key");let A=Gt(s,w);return t.fromHex(m).multiply(A).toBytes(b)}let v=r.bits2int||function(w){if(w.length>8192)throw new Error("input is too large");let m=jt(w),b=w.length*8-a;return b>0?m>>BigInt(b):m},Z=r.bits2int_modN||function(w){return s.create(v(w))},J=gt(a);function P(w){return Ts("num < 2^"+a,w,at,J),s.toBytes(w)}function y(w,m,b=S){if(["recovered","canonical"].some(fe=>fe in b))throw new Error("sign() legacy options not supported");let{lowS:A,prehash:T,extraEntropy:D}=b;A==null&&(A=!0),w=ae("msgHash",w),Qs(b),T&&(w=ae("prehashed msgHash",e(w)));let O=Z(w),V=Gt(s,m),F=[P(V),P(O)];if(D!=null&&D!==!1){let fe=D===!0?n(f.secret):D;F.push(ae("extraEntropy",fe))}let pe=je(...F),K=O;function Y(fe){let lt=v(fe);if(!s.isValidNot0(lt))return;let wt=s.inv(lt),Xt=t.BASE.multiply(lt).toAffine(),xt=s.create(Xt.x);if(xt===at)return;let Qt=s.create(wt*s.create(K+xt*V));if(Qt===at)return;let ci=(Xt.x===xt?0:2)|Number(Xt.y&Yt),ai=Qt;return A&&d(Qt)&&(ai=u(Qt),ci^=1),new h(xt,ai,ci)}return{seed:pe,k2sig:Y}}let S={lowS:r.lowS,prehash:!1},C={lowS:r.lowS,prehash:!1};function _(w,m,b=S){let{seed:A,k2sig:T}=y(w,m,b);return Ds(e.outputLen,s.BYTES,o)(A,T)}t.BASE.precompute(8);function R(w,m,b,A=C){let T=w;m=ae("msgHash",m),b=ae("publicKey",b),Qs(A);let{lowS:D,prehash:O,format:V}=A;if("strict"in A)throw new Error("options.strict was renamed to lowS");let F,pe;if(V===void 0){let K=typeof T=="string"||Bt(T),Y=!K&&T!==null&&typeof T=="object"&&typeof T.r=="bigint"&&typeof T.s=="bigint";if(!K&&!Y)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(Y)F=new h(T.r,T.s);else if(K){try{F=h.fromDER(T)}catch(fe){if(!(fe instanceof ct.Err))throw fe}if(!F)try{F=h.fromCompact(T)}catch{return!1}}}else if(V==="compact"||V==="der"){if(typeof T!="string"&&!Bt(T))throw new Error('"der" / "compact" format expects Uint8Array signature');F=h.fromBytes(ae("sig",T),V)}else if(V==="js"){if(!(T instanceof h))throw new Error('"js" format expects Signature instance');F=T}else throw new Error('format must be "compact", "der" or "js"');if(!F)return!1;try{if(pe=t.fromHex(b),D&&F.hasHighS())return!1;O&&(m=e(m));let{r:K,s:Y}=F,fe=Z(m),lt=s.inv(Y),wt=s.create(fe*lt),Xt=s.create(K*lt),xt=t.BASE.multiplyUnsafe(wt).add(pe.multiplyUnsafe(Xt));return xt.is0()?!1:s.create(xt.x)===K}catch{return!1}}function k(w){let m=N.randomSecretKey(w);return{secretKey:m,publicKey:z(m)}}return Object.freeze({keygen:k,getPublicKey:z,sign:_,verify:R,getSharedSecret:M,utils:N,Point:t,Signature:h,info:{type:"weierstrass",lengths:f,publicKeyHasPrefix:!0}})}function ll(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,modOnDecode: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 dl(t){let{CURVE:e,curveOpts:r}=ll(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 hl(t,e){return Object.assign({},e,{ProjectivePoint:e.Point,CURVE:t})}function tc(t){let{CURVE:e,curveOpts:r,hash:n,ecdsaOpts:o}=dl(t),i=al(e,r),s=ul(i,n,o);return hl(t,s)}function rc(t,e){let r=n=>tc({...t,hash:n});return{...r(e),create:r}}var $o={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},pl={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var nc=BigInt(2);function fl(t){let e=$o.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),l=t*t*t%e,f=l*l*t%e,d=ve(f,r,e)*f%e,u=ve(d,r,e)*f%e,p=ve(u,nc,e)*l%e,h=ve(p,o,e)*p%e,g=ve(h,i,e)*h%e,B=ve(g,c,e)*g%e,L=ve(B,a,e)*B%e,N=ve(L,c,e)*g%e,z=ve(N,r,e)*f%e,q=ve(z,s,e)*h%e,M=ve(q,n,e)*l%e,v=ve(M,nc,e);if(!jo.eql(jo.sqr(v),t))throw new Error("Cannot find square root");return v}var jo=yt($o.p,void 0,void 0,{sqrt:fl}),br=rc({...$o,Fp:jo,lowS:!0,endo:pl},Cs);var nn=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function ic(t,e,r,n){n?.signal?.throwIfAborted();let o=oc.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 br.verify(e,i,t)}catch(s){throw new nn(String(s))}}var on=class{type="secp256k1";raw;_key;constructor(e){this._key=cc(e),this.raw=sc(this._key)}toMultihash(){return Te.digest(Ht(this))}toCID(){return W.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:xe(this.raw,e.raw)}verify(e,r,n){return ic(this._key,r,e,n)}};function ac(t){return new on(t)}function sc(t){return br.ProjectivePoint.fromHex(t).toRawBytes(!0)}function cc(t){try{return br.ProjectivePoint.fromHex(t),t}catch(e){throw new Lr(String(e))}}function uc(t){let{Type:e,Data:r}=pr.decode(t.digest),n=r??new Uint8Array;switch(e){case Ie.Ed25519:return ds(n);case Ie.secp256k1:return ac(n);case Ie.ECDSA:return is(n);default:throw new Jt}}function Ht(t){return pr.encode({Type:Ie[t.type],Data:t.raw})}var lc=Symbol.for("nodejs.util.inspect.custom"),ml=114,Er=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()})`}[gn]=!0;toString(){return this.string==null&&(this.string=G.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return W.createV1(ml,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return xe(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return xe(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[lc](){return`PeerId(${this.toString()})`}},sn=class extends Er{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},cn=class extends Er{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},an=class extends Er{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},gl=2336,Ir=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Te.digest(te(this.url))}[lc](){return`PeerId(${this.url})`}[gn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return W.createV1(gl,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=H(e)),e.toString()===this.toString())}};var yl=114,dc=2336;function hc(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=or(G.decode(`z${t}`));else{if(t.startsWith("k51qzi5uqu5")||t.startsWith("kzwfwjn5ji4")||t.startsWith("k2k4r8")||t.startsWith("bafz"))return wl(W.parse(t));if(e==null)throw new Ne('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=or(e.decode(t))}return pc(r)}function pc(t){if(bl(t))return new sn({multihash:t});if(xl(t))try{let e=uc(t);if(e.type==="Ed25519")return new cn({multihash:t,publicKey:e});if(e.type==="secp256k1")return new an({multihash:t,publicKey:e})}catch{let r=H(t.digest);return new Ir(new URL(r))}throw new Dr("Supplied PeerID Multihash is invalid")}function wl(t){if(t?.multihash==null||t.version==null||t.version===1&&t.code!==yl&&t.code!==dc)throw new Tr("Supplied PeerID CID is invalid");if(t.code===dc){let e=H(t.multihash.digest);return new Ir(new URL(e))}return pc(t.multihash)}function xl(t){return t.code===Te.code}function bl(t){return t.code===Xn.code}var Se=le("node:net");var mc=Ot(fc(),1),El=["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"],Il=El.map(t=>new mc.Netmask(t));function Go(t){for(let e of Il)if(e.contains(t))return!0;return!1}function vl(t){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(t)}function Sl(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 Go(o)}function Al(t){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)}function Bl(t){let e=t.split(":"),r=e[e.length-1];return Go(r)}function Cl(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 gc(t){if((0,Se.isIPv4)(t))return Go(t);if(vl(t))return Sl(t);if(Al(t))return Bl(t);if((0,Se.isIPv6)(t))return Cl(t)}var re=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},ut=class extends Error{static name="ValidationError";name="ValidationError"},Sr=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},un=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function Wo(t){return e=>H(e,t)}function Zo(t){return e=>te(e,t)}function Wt(t){return new DataView(t.buffer).getUint16(t.byteOffset).toString()}function Dt(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof t=="string"?parseInt(t):t),new Uint8Array(e)}function yc(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=te(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=Dt(n);return Ve([r,o],r.length+o.length)}function wc(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=pt.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=Dt(n);return Ve([r,o],r.length+o.length)}function Xo(t){let e=t.subarray(0,t.length-2),r=t.subarray(t.length-2),n=H(e,"base32"),o=Wt(r);return`${n}:${o}`}var Qo=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 re("Invalid byte value in IP address");e[n]=o}),e},xc=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,Se.isIPv4)(r[n]),s;i&&(s=Qo(r[n]),r[n]=H(s.subarray(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,H(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 re("Invalid byte value in IP address");o[e++]=i>>8&255,o[e++]=i&255}return o},bc=function(t){if(t.byteLength!==4)throw new re("IPv4 address was incorrect length");let e=[];for(let r=0;r<t.byteLength;r++)e.push(t[r]);return e.join(".")},Ec=function(t){if(t.byteLength!==16)throw new re("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 re(`Invalid IPv6 address "${r}"`)}};function Ic(t){try{let e=new URL(`http://[${t}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new re(`Invalid IPv6 address "${t}"`)}}var Yo=Object.values(sr).map(t=>t.decoder),Ul=function(){let t=Yo[0].or(Yo[1]);return Yo.slice(2).forEach(e=>t=t.or(e)),t}();function vc(t){return Ul.decode(t)}function Sc(t){return e=>t.encoder.encode(e)}function Ll(t){if(parseInt(t).toString()!==t)throw new ut("Value must be an integer")}function Tl(t){if(t<0)throw new ut("Value must be a positive integer, or zero")}function Dl(t){return e=>{if(e>t)throw new ut(`Value must be smaller than or equal to ${t}`)}}function _l(...t){return e=>{for(let r of t)r(e)}}var Ar=_l(Ll,Tl,Dl(65535));var Q=-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 un(`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,ad=[{code:4,name:"ip4",size:32,valueToBytes:Qo,bytesToValue:bc,validate:t=>{if(!(0,Se.isIPv4)(t))throw new ut(`Invalid IPv4 address "${t}"`)}},{code:6,name:"tcp",size:16,valueToBytes:Dt,bytesToValue:Wt,validate:Ar},{code:273,name:"udp",size:16,valueToBytes:Dt,bytesToValue:Wt,validate:Ar},{code:33,name:"dccp",size:16,valueToBytes:Dt,bytesToValue:Wt,validate:Ar},{code:41,name:"ip6",size:128,valueToBytes:xc,bytesToValue:Ec,stringToValue:Ic,validate:t=>{if(!(0,Se.isIPv6)(t))throw new ut(`Invalid IPv6 address "${t}"`)}},{code:42,name:"ip6zone",size:Q},{code:43,name:"ipcidr",size:8,bytesToValue:Wo("base10"),valueToBytes:Zo("base10")},{code:53,name:"dns",size:Q,resolvable:!0},{code:54,name:"dns4",size:Q,resolvable:!0},{code:55,name:"dns6",size:Q,resolvable:!0},{code:56,name:"dnsaddr",size:Q,resolvable:!0},{code:132,name:"sctp",size:16,valueToBytes:Dt,bytesToValue:Wt,validate:Ar},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:Q,path:!0,stringToValue:t=>decodeURIComponent(t),valueToString:t=>encodeURIComponent(t)},{code:421,name:"p2p",aliases:["ipfs"],size:Q,bytesToValue:Wo("base58btc"),valueToBytes:t=>t.startsWith("Q")||t.startsWith("1")?Zo("base58btc")(t):W.parse(t).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:Xo,valueToBytes:yc},{code:445,name:"onion3",size:296,bytesToValue:Xo,valueToBytes:wc},{code:446,name:"garlic64",size:Q},{code:447,name:"garlic32",size:Q},{code:448,name:"tls"},{code:449,name:"sni",size:Q},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:Q,bytesToValue:Sc(zn),valueToBytes:vc},{code:480,name:"http"},{code:481,name:"http-path",size:Q,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:Q}];ad.forEach(t=>{he.addProtocol(t)});function Ac(t){let e=[],r=0;for(;r<t.length;){let n=po(t,r),o=he.getProtocol(n),i=ze(n),s=ud(o,t,r+i),c=0;s>0&&o.size===Q&&(c=ze(s));let a=i+c+s,l={code:n,name:o.name,bytes:t.subarray(r,r+a)};if(s>0){let f=r+i+c,d=t.subarray(f,f+s);l.value=o.bytesToValue?.(d)??H(d)}e.push(l),r+=a}return e}function Bc(t){let e=0,r=[];for(let n of t){if(n.bytes==null){let o=he.getProtocol(n.code),i=ze(n.code),s,c=0,a=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??te(n.value),c=s.byteLength,o.size===Q&&(a=ze(c)));let l=new Uint8Array(i+a+c),f=0;lr(n.code,l,f),f+=i,s!=null&&(o.size===Q&&(lr(c,l,f),f+=a),l.set(s,f)),n.bytes=l}r.push(n.bytes),e+=n.bytes.byteLength}return Ve(r,e)}function Cc(t){if(t.charAt(0)!=="/")throw new re('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 re(`Component ${o} was missing value`);r="value"}else if(r==="value"){let l={code:a.code,name:a.name};if(a.size!=null&&a.size!==0){if(n==="")throw new re(`Component ${o} was missing value`);l.value=a.stringToValue?.(n)??n}e.push(l),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new re("Incomplete multiaddr");return e}function Uc(t){return`/${t.flatMap(e=>{if(e.value==null)return e.name;let r=he.getProtocol(e.code);if(r==null)throw new re(`Unknown protocol code ${e.code}`);return[e.name,r.valueToString?.(e.value)??e.value]}).join("/")}`}function ud(t,e,r){return t.size==null||t.size===0?0:t.size>0?t.size/8:po(e,r)}var ld=Symbol.for("nodejs.util.inspect.custom"),si=Symbol.for("@multiformats/multiaddr"),dd=[53,54,55,56],ii=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}};function hd(t){if(t==null&&(t="/"),Tc(t))return t.getComponents();if(t instanceof Uint8Array)return Ac(t);if(typeof t=="string")return t=t.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),t===""&&(t="/"),Cc(t);if(Array.isArray(t))return t;throw new re("Must be a string, Uint8Array, Component[], or another Multiaddr")}var pn=class t{[si]=!0;#e;#t;#r;constructor(e="/",r={}){this.#e=hd(e),r.validate!==!1&&pd(this)}get bytes(){return this.#r==null&&(this.#r=Bc(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=Uc(this.#e)),this.#t}toJSON(){return this.toString()}toOptions(){let e,r,n,o,i="";for(let{code:c,name:a,value:l}of this.#e)c===42&&(i=`%${l??""}`),dd.includes(c)&&(r="tcp",o=443,n=`${l??""}${i}`,e=c===55?6:4),(c===6||c===273)&&(r=a==="tcp"?"tcp":"udp",o=parseInt(l??"")),(c===4||c===41)&&(r="tcp",n=`${l??""}${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)??te(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 Sr(`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"?H(G.decode(`z${n}`),"base58btc"):H(W.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 xe(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(i=>i.resolvable);if(r==null)return[this];let n=Lc.get(r.name);if(n==null)throw new ii(`no available resolver for ${r.name}`);return(await n(this,e)).map(i=>Cr(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)}[ld](){return`Multiaddr(${this.toString()})`}};function pd(t){t.getComponents().forEach(e=>{let r=he.getProtocol(e.code);e.value!=null&&r.validate?.(e.value)})}var fn=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",l=2**(8*o)-1;for(;;){let f=this.readAtomically(()=>{let d=this.readChar();if(d===void 0)return;let u=Number.parseInt(d,e);if(!Number.isNaN(u))return u});if(f===void 0)break;if(i*=e,i+=f,i>l||(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 og=new fn;var hg=parseInt("0xFFFF",16),pg=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var Lc=new Map;function Tc(t){return!!t?.[si]}function Cr(t){return new pn(t)}function Oc(t){let e=he.getProtocol(t);return{code:e.code,size:e.size??0,name:e.name,resolvable:!!e.resolvable,path:!!e.path}}function Pc(t){try{for(let{code:e}of t.getComponents())if(e!==42)return e===4||e===41}catch{}return!1}function Nc(t){try{if(!Pc(t))return!1;let[[,e]]=t.stringTuples();return e==null?!1:gc(e)??!1}catch{}return!0}function Rc(t,e,r,n){let o=()=>{n?.log.trace("query",e),t.query({questions:[{name:e,type:"PTR"}]})};return o(),setInterval(o,r)}function kc(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=>Cr(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:hc(c),multiaddrs:s.map(a=>a.decapsulateCode(Oc("p2p").code))}}catch(s){n?.log.error("failed to parse mdns response",s)}}function Kc(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(xd).forEach(a=>{let l="dnsaddr="+a.toString();if(l.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:l})}),s?.log.trace("responding to query"),e.respond(c)}}function xd(t){return!!Nc(t)}function Mc(t){let e="",r="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<t;n++)e+=r.charAt(Math.floor(Math.random()*r.length));return e}var mn=class extends _r{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??Mc(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)}[li]=this;[Symbol.toStringTag]="@libp2p/mdns";[pi]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,Fc.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=Rc(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),Kc(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=kc(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 Ed(t={}){return e=>new mn(e,t)}return $c(Id);})();
2
+ "use strict";var Libp2PMdns=(()=>{var Vc=Object.create;var Cr=Object.defineProperty;var qc=Object.getOwnPropertyDescriptor;var zc=Object.getOwnPropertyNames;var $c=Object.getPrototypeOf,jc=Object.prototype.hasOwnProperty;var le=(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),fe=(t,e)=>{for(var r in e)Cr(t,r,{get:e[r],enumerable:!0})},li=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of zc(e))!jc.call(t,o)&&o!==r&&Cr(t,o,{get:()=>e[o],enumerable:!(n=qc(e,o))||n.enumerable});return t};var _t=(t,e,r)=>(r=t!=null?Vc($c(t)):{},li(e||!t||!t.__esModule?Cr(r,"default",{value:t,enumerable:!0}):r,t)),Gc=t=>li(Cr({},"__esModule",{value:!0}),t);var gi=Ne(wn=>{"use strict";wn.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};wn.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 yi=Ne(xn=>{"use strict";xn.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};xn.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 wi=Ne(bn=>{"use strict";bn.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};bn.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 xi=Ne(En=>{"use strict";En.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};En.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 bi=Ne(In=>{"use strict";In.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}`};In.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 vi=Ne((Ii,vn)=>{var Ei=function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=l,t.encode=f,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:d=>e.test(d),encode(d,h,p){p=~~p,h=h||new Uint8Array(p+r);let m=d.length,E=0;for(let U=0;U<m;){let k=d.charCodeAt(U++);k===46?(h[p++]=E,E=0):E=E*10+(k-48)}return h[p]=E,h},decode(d,h){return h=~~h,`${d[h++]}.${d[h++]}.${d[h++]}.${d[h]}`}};t.v4=i;let s={name:"v6",size:o,isFormat:d=>d.length>0&&n.test(d),encode(d,h,p){p=~~p;let m=p+o,E=-1,U=0,k=0,O=!0,M=!1;h=h||new Uint8Array(p+o);for(let R=0;R<d.length;R++){let F=d.charCodeAt(R);F===58?(O?E!==-1?(p<m&&(h[p]=0),p<m-1&&(h[p+1]=0),p+=2):p<m&&(E=p):(M===!0?(p<m&&(h[p]=k),p++):(p<m&&(h[p]=U>>8),p<m-1&&(h[p+1]=U&255),p+=2),U=0,k=0),O=!0,M=!1):F===46?(p<m&&(h[p]=k),p++,k=0,U=0,O=!1,M=!0):(O=!1,F>=97?F-=87:F>=65?F-=55:(F-=48,k=k*10+F),U=(U<<4)+F)}if(O===!1)M===!0?(p<m&&(h[p]=k),p++):(p<m&&(h[p]=U>>8),p<m-1&&(h[p+1]=U&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(d,h){h=~~h;let p="";for(let m=0;m<o;m+=2)m!==0&&(p+=":"),p+=(d[h+m]<<8|d[h+m+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(d){if(i.isFormat(d))return i.size;if(s.isFormat(d))return s.size;throw Error(`Invalid ip address: ${d}`)}function u(d){return a(d)===i.size?1:2}function f(d,h,p){p=~~p;let m=a(d);return typeof h=="function"&&(h=h(p+m)),m===i.size?i.encode(d,h,p):s.encode(d,h,p)}function l(d,h,p){if(h=~~h,p=p||d.length-h,p===i.size)return i.decode(d,h,p);if(p===s.size)return s.decode(d,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 Ei}):typeof vn=="object"&&typeof Ii=="object"&&(vn.exports=Ei)});var Bi=Ne(I=>{"use strict";var v=le("buffer").Buffer,tt=gi(),Wc=yi(),Yc=wi(),Or=xi(),Sn=bi(),xt=vi(),Zc=0,Si=32768,An=32768,Xc=~An,Ai=32768,Qc=~Ai,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 T={};T.encode=function(t,e,r){e||(e=v.alloc(T.encodingLength(t))),r||(r=0);let n=e.write(t,r+1);return e[r]=n,T.encode.bytes=n+1,e};T.encode.bytes=0;T.decode=function(t,e){e||(e=0);let r=t[e],n=t.toString("utf-8",e+1,e+1+r);return T.decode.bytes=r+1,n};T.decode.bytes=0;T.encodingLength=function(t){return v.byteLength(t)+1};var Ue={};Ue.encode=function(t,e,r){e||(e=Ue.encodingLength(t)),r||(r=0);let n=(t.flags||0)&32767,o=t.type==="response"?Si:Zc;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};Ue.encode.bytes=12;Ue.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&Si?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:Yc.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:Wc.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))}};Ue.decode.bytes=12;Ue.encodingLength=function(){return 12};var je=I.unknown={};je.encode=function(t,e,r){return e||(e=v.alloc(je.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.length,r),t.copy(e,r+2),je.encode.bytes=t.length+2,e};je.encode.bytes=0;je.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=t.slice(e+2,e+2+r);return je.decode.bytes=r+2,n};je.decode.bytes=0;je.encodingLength=function(t){return t.length+2};var Ge=I.ns={};Ge.encode=function(t,e,r){return e||(e=v.alloc(Ge.encodingLength(t))),r||(r=0),x.encode(t,e,r+2),e.writeUInt16BE(x.encode.bytes,r),Ge.encode.bytes=x.encode.bytes+2,e};Ge.encode.bytes=0;Ge.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=x.decode(t,e+2);return Ge.decode.bytes=r+2,n};Ge.decode.bytes=0;Ge.encodingLength=function(t){return x.encodingLength(t)+2};var We=I.soa={};We.encode=function(t,e,r){e||(e=v.alloc(We.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),We.encode.bytes=r-n,e};We.encode.bytes=0;We.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.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,We.decode.bytes=e-r,n};We.decode.bytes=0;We.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 Ze=I.null={};Ze.encode=function(t,e,r){e||(e=v.alloc(Ze.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),Ze.encode.bytes=r-n,e};Ze.encode.bytes=0;Ze.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,Ze.decode.bytes=e-r,o};Ze.decode.bytes=0;Ze.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,T.encode(t.cpu,e,r),r+=T.encode.bytes,T.encode(t.os,e,r),r+=T.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=T.decode(t,e),e+=T.decode.bytes,n.os=T.decode(t,e),e+=T.decode.bytes,Xe.decode.bytes=e-r,n};Xe.decode.bytes=0;Xe.encodingLength=function(t){return T.encodingLength(t.cpu)+T.encodingLength(t.os)+2};var Be=I.ptr={},Jc=I.cname=Be,ea=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 Qe=I.srv={};Qe.encode=function(t,e,r){e||(e=v.alloc(Qe.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),Qe.encode.bytes=n+2,e};Qe.encode.bytes=0;Qe.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),Qe.decode.bytes=r+2,n};Qe.decode.bytes=0;Qe.encodingLength=function(t){return 8+x.encodingLength(t.target)};var me=I.caa={};me.ISSUER_CRITICAL=128;me.encode=function(t,e,r){let n=me.encodingLength(t);return e||(e=v.alloc(me.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=me.ISSUER_CRITICAL),e.writeUInt16BE(n-2,r),r+=2,e.writeUInt8(t.flags||0,r),r+=1,T.encode(t.tag,e,r),r+=T.encode.bytes,e.write(t.value,r),r+=v.byteLength(t.value),me.encode.bytes=n,e};me.encode.bytes=0;me.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=T.decode(t,e),e+=T.decode.bytes,o.value=t.toString("utf-8",e,n+r),o.issuerCritical=!!(o.flags&me.ISSUER_CRITICAL),me.decode.bytes=r+2,o};me.decode.bytes=0;me.encodingLength=function(t){return T.encodingLength(t.tag)+T.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 Je=I.a={};Je.encode=function(t,e,r){return e||(e=v.alloc(Je.encodingLength(t))),r||(r=0),e.writeUInt16BE(4,r),r+=2,xt.v4.encode(t,e,r),Je.encode.bytes=6,e};Je.encode.bytes=0;Je.decode=function(t,e){e||(e=0),e+=2;let r=xt.v4.decode(t,e);return Je.decode.bytes=6,r};Je.decode.bytes=0;Je.encodingLength=function(){return 6};var et=I.aaaa={};et.encode=function(t,e,r){return e||(e=v.alloc(et.encodingLength(t))),r||(r=0),e.writeUInt16BE(16,r),r+=2,xt.v6.encode(t,e,r),et.encode.bytes=18,e};et.encode.bytes=0;et.decode=function(t,e){e||(e=0),e+=2;let r=xt.v6.decode(t,e);return et.decode.bytes=18,r};et.decode.bytes=0;et.encodingLength=function(){return 18};var he=I.option={};he.encode=function(t,e,r){e||(e=v.alloc(he.encodingLength(t))),r||(r=0);let n=r,o=Sn.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),c=xt.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 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 he.encode.bytes=r-n,e};he.encode.bytes=0;he.decode=function(t,e){e||(e=0);let r={};r.code=t.readUInt16BE(e),r.type=Sn.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 he.decode.bytes=n+4,r};he.decode.bytes=0;he.encodingLength=function(t){if(t.data)return t.data.length+4;switch(Sn.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 ye=I.opt={};ye.encode=function(t,e,r){e||(e=v.alloc(ye.encodingLength(t))),r||(r=0);let n=r,o=Ot(t,he);return e.writeUInt16BE(o,r),r=Xt(t,he,e,r+2),ye.encode.bytes=r-n,e};ye.encode.bytes=0;ye.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++]=he.decode(t,e),e+=he.decode.bytes,o-=he.decode.bytes;return ye.decode.bytes=e-r,n};ye.decode.bytes=0;ye.encodingLength=function(t){return 2+Ot(t||[],he)};var ae=I.dnskey={};ae.PROTOCOL_DNSSEC=3;ae.ZONE_KEY=128;ae.SECURE_ENTRYPOINT=32768;ae.encode=function(t,e,r){e||(e=v.alloc(ae.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(ae.PROTOCOL_DNSSEC,r),r+=1,e.writeUInt8(t.algorithm,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,ae.encode.bytes=r-n,e.writeUInt16BE(ae.encode.bytes-2,n),e};ae.encode.bytes=0;ae.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);if(e+=2,n.flags=t.readUInt16BE(e),e+=2,t.readUInt8(e)!==ae.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,ae.decode.bytes=e-r,n};ae.decode.bytes=0;ae.encodingLength=function(t){return 6+v.byteLength(t.key)};var ke=I.rrsig={};ke.encode=function(t,e,r){e||(e=v.alloc(ke.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(tt.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,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.typeCovered=tt.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,ke.decode.bytes=e-r,n};ke.decode.bytes=0;ke.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 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=tt.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 f=tt.toString(i<<8|c<<3|u);o.push(f)}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=tt.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 Me=I.nsec={};Me.encode=function(t,e,r){e||(e=v.alloc(Me.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,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);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,Me.decode.bytes=e-r,n};Me.decode.bytes=0;Me.encodingLength=function(t){return 2+x.encodingLength(t.nextDomain)+Z.encodingLength(t.rrtypes)};var Fe=I.nsec3={};Fe.encode=function(t,e,r){e||(e=v.alloc(Fe.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,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);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,Fe.decode.bytes=e-r,n};Fe.decode.bytes=0;Fe.encodingLength=function(t){return 8+t.salt.length+t.nextDomain.length+Z.encodingLength(t.rrtypes)};var He=I.ds={};He.encode=function(t,e,r){e||(e=v.alloc(He.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,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;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,He.decode.bytes=e-r,n};He.decode.bytes=0;He.encodingLength=function(t){return 6+v.byteLength(t.digest)};var ge=I.sshfp={};ge.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};ge.encode=function(e,r,n){r||(r=v.alloc(ge.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!==ge.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return i.copy(r,n),n+=i.byteLength,ge.encode.bytes=n-o,r.writeUInt16BE(ge.encode.bytes-2,o),r};ge.encode.bytes=0;ge.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=ge.getFingerprintLengthForHashType(o.hash);return o.fingerprint=e.slice(r,r+i).toString("hex").toUpperCase(),r+=i,ge.decode.bytes=r-n,o};ge.decode.bytes=0;ge.encodingLength=function(t){return 4+v.from(t.fingerprint,"hex").byteLength};var Ve=I.naptr={};Ve.encode=function(t,e,r){e||(e=v.alloc(Ve.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,T.encode(t.flags,e,r),r+=T.encode.bytes,T.encode(t.services,e,r),r+=T.encode.bytes,T.encode(t.regexp,e,r),r+=T.encode.bytes,x.encode(t.replacement,e,r),r+=x.encode.bytes,Ve.encode.bytes=r-n,e.writeUInt16BE(Ve.encode.bytes-2,n),e};Ve.encode.bytes=0;Ve.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=T.decode(t,e),e+=T.decode.bytes,n.services=T.decode(t,e),e+=T.decode.bytes,n.regexp=T.decode(t,e),e+=T.decode.bytes,n.replacement=x.decode(t,e),e+=x.decode.bytes,Ve.decode.bytes=e-r,n};Ve.decode.bytes=0;Ve.encodingLength=function(t){return T.encodingLength(t.flags)+T.encodingLength(t.services)+T.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 Bn=I.record=function(t){switch(t.toUpperCase()){case"A":return Je;case"PTR":return Be;case"CNAME":return Jc;case"DNAME":return ea;case"TXT":return Ye;case"NULL":return Ze;case"AAAA":return et;case"SRV":return Qe;case"HINFO":return Xe;case"CAA":return me;case"NS":return Ge;case"SOA":return We;case"MX":return dt;case"OPT":return ye;case"DNSKEY":return ae;case"RRSIG":return ke;case"RP":return Ke;case"NSEC":return Me;case"NSEC3":return Fe;case"SSHFP":return ge;case"DS":return He;case"NAPTR":return Ve;case"TLSA":return qe}return je},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(tt.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,ye.encode(t.options||[],e,r),r+=ye.encode.bytes}else{let o=Or.toClass(t.class===void 0?"IN":t.class);t.flush&&(o|=An),e.writeUInt16BE(o,r+2),e.writeUInt32BE(t.ttl||0,r+4),r+=8;let i=Bn(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=tt.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=ye.decode(t,e+8),e+=8+ye.decode.bytes;else{let o=t.readUInt16BE(e+2);r.ttl=t.readUInt32BE(e+4),r.class=Or.toString(o&Xc),r.flush=!!(o&An);let i=Bn(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+Bn(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(tt.toType(t.type),r),r+=2,e.writeUInt16BE(Or.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=tt.toString(t.readUInt16BE(e)),e+=2,n.class=Or.toString(t.readUInt16BE(e)),e+=2,!!(n.class&Ai)&&(n.class&=Qc),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=[]),Ue.encode(t,e,r),r+=Ue.encode.bytes,r=Xt(t.questions,Ce,e,r),r=Xt(t.answers,Q,e,r),r=Xt(t.authorities,Q,e,r),r=Xt(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=Ue.decode(t,e);return e+=Ue.decode.bytes,e=_r(n.questions,Ce,t,e),e=_r(n.answers,Q,t,e),e=_r(n.authorities,Q,t,e),e=_r(n.additionals,Q,t,e),I.decode.bytes=e-r,n};I.decode.bytes=0;I.encodingLength=function(t){return Ue.encodingLength(t)+Ot(t.questions||[],Ce)+Ot(t.answers||[],Q)+Ot(t.authorities||[],Q)+Ot(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 Ot(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function Xt(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 _r(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 Li=Ne((ih,Ui)=>{"use strict";var Ci=sa;process.nextTick(ia,42);Ui.exports=ta;function ta(t){var e=n;return r;function r(o){e(o||na)}function n(o){var i=[o];e=s,t(c);function s(a){i.push(a)}function c(a){var u=arguments;for(e=ra(a)?n:f;i.length;)f(i.shift());function f(l){Ci(oa,l,u)}}}}function ra(t){return Object.prototype.toString.call(t)==="[object Error]"}function na(){}function oa(t,e){t.apply(null,e)}function ia(t){t===42&&(Ci=process.nextTick)}function sa(t,e,r){process.nextTick(function(){t(e,r)})}});var _i=Ne((sh,Di)=>{var Cn=Bi(),ca=le("dgram"),aa=Li(),ua=le("events"),Ln=le("os"),Un=function(){};Di.exports=function(t){t||(t={});var e=new ua.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||ca.createSocket({type:n,reuseAddr:t.reuseAddr!==!1,toString:function(){return n}});u.on("error",function(l){l.code==="EACCES"||l.code==="EADDRINUSE"?e.emit("error",l):e.emit("warning",l)}),u.on("message",function(l,d){try{l=Cn.decode(l)}catch(h){e.emit("warning",h);return}e.emit("packet",l,d),l.type==="query"&&e.emit("query",l,d),l.type==="response"&&e.emit("response",l,d)}),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 f=aa(function(l){if(!r||t.bind===!1)return l(null);u.once("error",l),u.bind(r,t.bind||t.interface,function(){u.removeListener("error",l),l(null)})});return f(function(l){if(l)return e.emit("error",l);e.emit("ready")}),e.send=function(l,d,h){if(typeof d=="function")return e.send(l,null,d);h||(h=Un),d?!d.host&&!d.address&&(d.address=i.address):d=i,f(p);function p(m){if(c)return h();if(m)return h(m);var E=Cn.encode(l);u.send(E,0,E.length,d.port,d.address||d.host,h)}},e.response=e.respond=function(l,d,h){Array.isArray(l)&&(l={answers:l}),l.type="response",l.flags=(l.flags||0)|Cn.AUTHORITATIVE_ANSWER,e.send(l,d,h)},e.query=function(l,d,h,p){if(typeof d=="function")return e.query(l,null,null,d);if(typeof d=="object"&&d&&d.port)return e.query(l,null,d,h);if(typeof h=="function")return e.query(l,d,null,h);p||(p=Un),typeof l=="string"&&(l=[{name:l,type:d||"ANY"}]),Array.isArray(l)&&(l={type:"query",questions:l}),l.type="query",e.send(l,h,p)},e.destroy=function(l){if(l||(l=Un),c)return process.nextTick(l);c=!0,clearInterval(a);for(var d in s)try{u.dropMembership(o,d)}catch{}s={},u.close(l)},e.update=function(){for(var l=t.interface?[].concat(t.interface):la(),d=!1,h=0;h<l.length;h++){var p=l[h];if(!s[p])try{u.addMembership(o,p),s[p]=!0,d=!0}catch(m){e.emit("warning",m)}}if(d){if(u.setMulticastInterface)try{u.setMulticastInterface(t.interface||da())}catch(m){e.emit("warning",m)}e.emit("networkInterface")}},e};function da(){for(var t=Ln.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(Ti(i.family)&&!i.internal)return Ln.platform()==="darwin"&&e[r]==="en0"?i.address:"0.0.0.0"}return"127.0.0.1"}function la(){for(var t=Ln.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(Ti(s.family)){r.push(s.address);break}}return r}function Ti(t){return t===4||t==="IPv4"}});var mc=Ne(br=>{(function(){var t,e,r,n,o,i,s,c;c=function(a){var u,f,l,d;return u=(a&255<<24)>>>24,f=(a&255<<16)>>>16,l=(a&65280)>>>8,d=a&255,[u,f,l,d].join(".")},s=function(a){var u,f,l,d,h,p;for(u=[],l=d=0;d<=3&&a.length!==0;l=++d){if(l>0){if(a[0]!==".")throw new Error("Invalid IP");a=a.substring(1)}p=e(a),h=p[0],f=p[1],a=a.substring(f),u.push(h)}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,f,l,d,h;for(d=0,u=10,f="9",l=0,a.length>1&&a[l]==="0"&&(a[l+1]==="x"||a[l+1]==="X"?(l+=2,u=16):"0"<=a[l+1]&&a[l+1]<="9"&&(l++,u=8,f="7")),h=l;l<a.length;){if("0"<=a[l]&&a[l]<=f)d=d*u+(r(a[l])-n)>>>0;else if(u===16)if("a"<=a[l]&&a[l]<="f")d=d*u+(10+r(a[l])-i)>>>0;else if("A"<=a[l]&&a[l]<="F")d=d*u+(10+r(a[l])-o)>>>0;else break;else break;if(d>4294967295)throw new Error("too large");l++}if(l===h)throw new Error("empty octet");return[d,l]},t=function(){function a(u,f){var l,d,h,p;if(typeof u!="string")throw new Error("Missing `net' parameter");if(f||(p=u.split("/",2),u=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(d=h=32;h>=0;d=--h)if(this.maskLong===4294967295<<32-d>>>0){this.bitmask=d;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(u)&this.maskLong)>>>0}catch(m){throw l=m,new Error("Invalid net address: "+u)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+f);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 f,l,d;for(d=s(this.first),l=s(this.last),f=0;d<=l;)u(c(d),d,f),f++,d++},a.prototype.toString=function(){return this.base+"/"+this.bitmask},a}(),br.ip2long=s,br.long2ip=c,br.Netmask=t}).call(br)});var vl={};fe(vl,{mdns:()=>Il});var hi=Symbol.for("@libp2p/peer-discovery");var yn=Symbol.for("@libp2p/peer-id");var Re=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},Ur=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var Lr=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},Tr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var Zt=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var pi=le("node:events"),fi=(t,...e)=>{try{(0,pi.setMaxListeners)(t,...e)}catch{}};var Dr=class extends EventTarget{#e=new Map;constructor(){super(),fi(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 mi=Symbol.for("@libp2p/service-capabilities"),Dl=Symbol.for("@libp2p/service-dependencies");var Hc=_t(_i(),1);var Pn={};fe(Pn,{base58btc:()=>j,base58flickr:()=>wa});var ch=new Uint8Array(0);function Oi(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 Pi(t){return new TextEncoder().encode(t)}function Ni(t){return new TextDecoder().decode(t)}function ha(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),f=Math.log(256)/Math.log(c);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,U=0,k=p.length;U!==k&&p[U]===0;)U++,m++;for(var O=(k-U)*f+1>>>0,M=new Uint8Array(O);U!==k;){for(var R=p[U],F=0,te=O-1;(R!==0||F<E)&&te!==-1;te--,F++)R+=256*M[te]>>>0,M[te]=R%c>>>0,R=R/c>>>0;if(R!==0)throw new Error("Non-zero carry");E=F,U++}for(var re=O-E;re!==O&&M[re]===0;)re++;for(var D=a.repeat(m);re<O;++re)D+=t.charAt(M[re]);return D}function d(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,U=0;p[m]===a;)E++,m++;for(var k=(p.length-m)*u+1>>>0,O=new Uint8Array(k);p[m];){var M=r[p.charCodeAt(m)];if(M===255)return;for(var R=0,F=k-1;(M!==0||R<U)&&F!==-1;F--,R++)M+=c*O[F]>>>0,O[F]=M%256>>>0,M=M/256>>>0;if(M!==0)throw new Error("Non-zero carry");U=R,m++}if(p[m]!==" "){for(var te=k-U;te!==k&&O[te]===0;)te++;for(var re=new Uint8Array(E+(k-te)),D=E;te!==k;)re[D++]=O[te++];return re}}}function h(p){var m=d(p);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:d,decode:h}}var pa=ha,fa=pa,ki=fa;var Tn=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")}},Dn=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 Ki(this,e)}},_n=class{decoders;constructor(e){this.decoders=e}or(e){return Ki(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 Ki(t,e){return new _n({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var On=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 Tn(e,r,n),this.decoder=new Dn(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Pt({name:t,prefix:e,encode:r,decode:n}){return new On(t,e,r,n)}function lt({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=ki(r,t);return Pt({prefix:e,name:t,encode:n,decode:i=>Se(o(i))})}function ma(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 f=e[t[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|f,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 ga(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 ya(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function $({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=ya(n);return Pt({prefix:e,name:t,encode(i){return ga(i,n,r)},decode(i){return ma(i,o,r,t)}})}var j=lt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),wa=lt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Nn={};fe(Nn,{base32:()=>ht,base32hex:()=>Ia,base32hexpad:()=>Sa,base32hexpadupper:()=>Aa,base32hexupper:()=>va,base32pad:()=>ba,base32padupper:()=>Ea,base32upper:()=>xa,base32z:()=>Ba});var ht=$({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),xa=$({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ba=$({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ea=$({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ia=$({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),va=$({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Sa=$({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Aa=$({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ba=$({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Rn={};fe(Rn,{base36:()=>Qt,base36upper:()=>Ca});var Qt=lt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ca=lt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ua=Hi,Mi=128,La=127,Ta=~La,Da=Math.pow(2,31);function Hi(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Da;)e[r++]=t&255|Mi,t/=128;for(;t&Ta;)e[r++]=t&255|Mi,t>>>=7;return e[r]=t|0,Hi.bytes=r-n+1,e}var _a=kn,Oa=128,Fi=127;function kn(t,n){var r=0,n=n||0,o=0,i=n,s,c=t.length;do{if(i>=c)throw kn.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&Fi)<<o:(s&Fi)*Math.pow(2,o),o+=7}while(s>=Oa);return kn.bytes=i-n,r}var Pa=Math.pow(2,7),Na=Math.pow(2,14),Ra=Math.pow(2,21),ka=Math.pow(2,28),Ka=Math.pow(2,35),Ma=Math.pow(2,42),Fa=Math.pow(2,49),Ha=Math.pow(2,56),Va=Math.pow(2,63),qa=function(t){return t<Pa?1:t<Na?2:t<Ra?3:t<ka?4:t<Ka?5:t<Ma?6:t<Fa?7:t<Ha?8:t<Va?9:10},za={encode:Ua,decode:_a,encodingLength:qa},$a=za,Jt=$a;function er(t,e=0){return[Jt.decode(t,e),Jt.decode.bytes]}function Nt(t,e,r=0){return Jt.encode(t,e,r),e}function Rt(t){return Jt.encodingLength(t)}function bt(t,e){let r=e.byteLength,n=Rt(t),o=n+Rt(r),i=new Uint8Array(o+r);return Nt(t,i,0),Nt(r,i,n),i.set(e,o),new kt(t,r,e,i)}function tr(t){let e=Se(t),[r,n]=er(e),[o,i]=er(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new kt(r,o,s,e)}function Vi(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Oi(t.bytes,r.bytes)}}var kt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function qi(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return Ga(r,Kn(t),e??j.encoder);default:return Wa(r,Kn(t),e??ht.encoder)}}var zi=new WeakMap;function Kn(t){let e=zi.get(t);if(e==null){let r=new Map;return zi.set(t,r),r}return e}var Y=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!==rr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Ya)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=bt(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&&Vi(e.multihash,n.multihash)}toString(e){return qi(this,e)}toJSON(){return{"/":qi(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[Za]===!0){let{version:n,multihash:o,code:i}=r,s=tr(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!==rr)throw new Error(`Version 0 CID must use dag-pb (code: ${rr}) 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,rr,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 kt(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,d]=er(e.subarray(r));return r+=d,l},o=n(),i=rr;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,f=u-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:f,size:u}}static parse(e,r){let[n,o]=ja(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 Kn(i).set(n,e),i}};function ja(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 Qt.prefix:{let r=e??Qt;return[Qt.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 Ga(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 Wa(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 rr=112,Ya=18;function $i(t,e,r){let n=Rt(t),o=n+Rt(e),i=new Uint8Array(o+r.byteLength);return Nt(t,i,0),Nt(e,i,n),i.set(r,o),i}var Za=Symbol.for("@ipld/js-cid/CID");var Mn={};fe(Mn,{identity:()=>Le});var ji=0,Xa="identity",Gi=Se;function Qa(t){return bt(ji,Gi(t))}var Le={code:ji,name:Xa,encode:Gi,digest:Qa};function we(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 Fn=le("node:buffer");function Et(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function rt(t=0){return Et(Fn.Buffer.alloc(t))}function Te(t=0){return Et(Fn.Buffer.allocUnsafe(t))}var Wi=le("node:buffer");function ze(t,e){return Et(Wi.Buffer.concat(t,e))}var Zi=Symbol.for("@achingbrain/uint8arraylist");function Yi(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 Nr(t){return!!t?.[Zi]}var xe=class t{bufs;length;[Zi]=!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(Nr(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(Nr(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=Yi(this.bufs,e);return r.buf[r.index]}set(e,r){let n=Yi(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(Nr(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 ze(n,o)}subarray(e,r){let{bufs:n,length:o}=this._subList(e,r);return n.length===1?n[0]:ze(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,f=r>c&&r<=a;if(u&&f){if(e===c&&r===a){n.push(s);break}let l=e-c;n.push(s.subarray(l,l+(r-e)));break}if(u){if(e===0){n.push(s);continue}n.push(s.subarray(e-c));continue}if(f){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(!Nr(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 c=s,a=this.byteLength-n.byteLength,u=n.byteLength-1,f;for(let l=r;l<=a;l+=f){f=0;for(let d=u;d>=0;d--){let h=this.get(l+d);if(n[d]!==h){f=Math.max(1,d-c[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=Te(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=rt(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=rt(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=rt(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=Te(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=rt(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=rt(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=rt(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=rt(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=rt(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(!we(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 ts=le("node:buffer");var Hn={};fe(Hn,{base10:()=>Ja});var Ja=lt({prefix:"9",name:"base10",alphabet:"0123456789"});var Vn={};fe(Vn,{base16:()=>eu,base16upper:()=>tu});var eu=$({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),tu=$({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var qn={};fe(qn,{base2:()=>ru});var ru=$({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var zn={};fe(zn,{base256emoji:()=>cu});var Xi=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}"),nu=Xi.reduce((t,e,r)=>(t[r]=e,t),[]),ou=Xi.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function iu(t){return t.reduce((e,r)=>(e+=nu[r],e),"")}function su(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=ou[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var cu=Pt({prefix:"\u{1F680}",name:"base256emoji",encode:iu,decode:su});var jn={};fe(jn,{base64:()=>au,base64pad:()=>uu,base64url:()=>$n,base64urlpad:()=>du});var au=$({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),uu=$({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),$n=$({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),du=$({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Gn={};fe(Gn,{base8:()=>lu});var lu=$({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Wn={};fe(Wn,{identity:()=>hu});var hu=Pt({prefix:"\0",name:"identity",encode:t=>Ni(t),decode:t=>Pi(t)});var qh=new TextEncoder,zh=new TextDecoder;var Jn={};fe(Jn,{sha256:()=>Qn,sha512:()=>mu});var Xn=_t(le("crypto"),1);function Zn({name:t,code:e,encode:r}){return new Yn(t,e,r)}var Yn=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?bt(this.code,r):r.then(n=>bt(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Qn=Zn({name:"sha2-256",code:18,encode:t=>Se(Xn.default.createHash("sha256").update(t).digest())}),mu=Zn({name:"sha2-512",code:19,encode:t=>Se(Xn.default.createHash("sha512").update(t).digest())});var nr={...Wn,...qn,...Gn,...Hn,...Vn,...Nn,...Rn,...Pn,...jn,...zn},np={...Jn,...Mn};function es(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var Ji=es("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),eo=es("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=Te(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),gu={utf8:Ji,"utf-8":Ji,hex:nr.base16,latin1:eo,ascii:eo,binary:eo,...nr},Rr=gu;function J(t,e="utf8"){let r=Rr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?Et(ts.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var rs=le("node:buffer");function K(t,e="utf8"){let r=Rr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?rs.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var yu=parseInt("11111",2),to=parseInt("10000000",2),wu=parseInt("01111111",2),ns={0:or,1:or,2:xu,3:Iu,4:vu,5:Eu,6:bu,16:or,22:or,48:or};function ro(t,e={offset:0}){let r=t[e.offset]&yu;if(e.offset++,ns[r]!=null)return ns[r](t,e);throw new Error("No decoder for tag "+r)}function ir(t,e){let r=0;if((t[e.offset]&to)===to){let n=t[e.offset]&wu,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 or(t,e){ir(t,e);let r=[];for(;!(e.offset>=t.byteLength);){let n=ro(t,e);if(n===null)break;r.push(n)}return r}function xu(t,e){let r=ir(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 bu(t,e){let r=ir(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 f=0;for(let l=0;l<a.length;l++)f+=a[l]<<l*7;c+=`.${f}`,a=[]}}return c}function Eu(t,e){return e.offset++,null}function Iu(t,e){let r=ir(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 vu(t,e){let r=ir(t,e),n=t.subarray(e.offset,e.offset+r);return e.offset+=r,n}function Su(t){let e=t.toString(16);e.length%2===1&&(e="0"+e);let r=new xe;for(let n=0;n<e.length;n+=2)r.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return r}function no(t){if(t.byteLength<128)return Uint8Array.from([t.byteLength]);let e=Su(t.byteLength);return new xe(Uint8Array.from([e.byteLength|to]),e)}function os(t){let e=new xe,r=128;return(t.subarray()[0]&r)===r&&e.append(Uint8Array.from([0])),e.append(t),new xe(Uint8Array.from([2]),no(e),e)}function is(t){let e=Uint8Array.from([0]),r=new xe(e,t);return new xe(Uint8Array.from([3]),no(r),r)}function kr(t,e=48){let r=new xe;for(let n of t)r.append(n);return new xe(Uint8Array.from([e]),no(r),r)}async function ss(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 Au=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Bu=Uint8Array.from([6,5,43,129,4,0,34]),Cu=Uint8Array.from([6,5,43,129,4,0,35]),Uu={ext:!0,kty:"EC",crv:"P-256"},Lu={ext:!0,kty:"EC",crv:"P-384"},Tu={ext:!0,kty:"EC",crv:"P-521"},oo=32,io=48,so=66;function cs(t){let e=ro(t);return as(e)}function as(t){let e=t[1][1][0],r=1,n,o;if(e.byteLength===oo*2+1)return n=K(e.subarray(r,r+oo),"base64url"),o=K(e.subarray(r+oo),"base64url"),new Mt({...Uu,key_ops:["verify"],x:n,y:o});if(e.byteLength===io*2+1)return n=K(e.subarray(r,r+io),"base64url"),o=K(e.subarray(r+io),"base64url"),new Mt({...Lu,key_ops:["verify"],x:n,y:o});if(e.byteLength===so*2+1)return n=K(e.subarray(r,r+so),"base64url"),o=K(e.subarray(r+so),"base64url"),new Mt({...Tu,key_ops:["verify"],x:n,y:o});throw new Re(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function us(t){return kr([os(Uint8Array.from([1])),kr([Du(t.crv)],160),kr([is(new xe(Uint8Array.from([4]),J(t.x??"","base64url"),J(t.y??"","base64url")))],161)]).subarray()}function Du(t){if(t==="P-256")return Au;if(t==="P-384")return Bu;if(t==="P-521")return Cu;throw new Re(`Invalid curve ${t}`)}var Mt=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=us(this.jwk)),this._raw}toMultihash(){return Le.digest(Ft(this))}toCID(){return Y.createV1(114,this.toMultihash())}toString(){return j.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:we(this.raw,e.raw)}async verify(e,r,n){return ss(this.jwk,r,e,n)}};var Kr=_t(le("crypto"),1);var Kp=Kr.default.generateKeyPairSync,sr=32;var _u=64;function ds(t,e,r){if(t.byteLength!==sr)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!==_u)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=Kr.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:K(t,"base64url"),kty:"OKP"}});return Kr.default.verify(null,r instanceof Uint8Array?r:r.subarray(),n,e)}function hs(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}var Mr=class{type="Ed25519";raw;constructor(e){this.raw=co(e,sr)}toMultihash(){return Le.digest(Ft(this))}toCID(){return Y.createV1(114,this.toMultihash())}toString(){return j.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:we(this.raw,e.raw)}verify(e,r,n){n?.signal?.throwIfAborted();let o=ds(this.raw,r,e);return hs(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function ps(t){return t=co(t,sr),new Mr(t)}function co(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new Re(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}var Pu=Math.pow(2,7),Nu=Math.pow(2,14),Ru=Math.pow(2,21),ao=Math.pow(2,28),uo=Math.pow(2,35),lo=Math.pow(2,42),ho=Math.pow(2,49),V=128,oe=127;function $e(t){if(t<Pu)return 1;if(t<Nu)return 2;if(t<Ru)return 3;if(t<ao)return 4;if(t<uo)return 5;if(t<lo)return 6;if(t<ho)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function cr(t,e,r=0){switch($e(t)){case 8:e[r++]=t&255|V,t/=128;case 7:e[r++]=t&255|V,t/=128;case 6:e[r++]=t&255|V,t/=128;case 5:e[r++]=t&255|V,t/=128;case 4:e[r++]=t&255|V,t>>>=7;case 3:e[r++]=t&255|V,t>>>=7;case 2:e[r++]=t&255|V,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function po(t,e){let r=t[e],n=0;if(n+=r&oe,r<V||(r=t[e+1],n+=(r&oe)<<7,r<V)||(r=t[e+2],n+=(r&oe)<<14,r<V)||(r=t[e+3],n+=(r&oe)<<21,r<V)||(r=t[e+4],n+=(r&oe)*ao,r<V)||(r=t[e+5],n+=(r&oe)*uo,r<V)||(r=t[e+6],n+=(r&oe)*lo,r<V)||(r=t[e+7],n+=(r&oe)*ho,r<V))return n;throw new RangeError("Could not decode varint")}function ku(t,e){let r=t.get(e),n=0;if(n+=r&oe,r<V||(r=t.get(e+1),n+=(r&oe)<<7,r<V)||(r=t.get(e+2),n+=(r&oe)<<14,r<V)||(r=t.get(e+3),n+=(r&oe)<<21,r<V)||(r=t.get(e+4),n+=(r&oe)*ao,r<V)||(r=t.get(e+5),n+=(r&oe)*uo,r<V)||(r=t.get(e+6),n+=(r&oe)*lo,r<V)||(r=t.get(e+7),n+=(r&oe)*ho,r<V))return n;throw new RangeError("Could not decode varint")}function fo(t,e=0){return t instanceof Uint8Array?po(t,e):ku(t,e)}var mo=new Float32Array([-0]),pt=new Uint8Array(mo.buffer);function fs(t,e,r){mo[0]=t,e[r]=pt[0],e[r+1]=pt[1],e[r+2]=pt[2],e[r+3]=pt[3]}function ms(t,e){return pt[0]=t[e],pt[1]=t[e+1],pt[2]=t[e+2],pt[3]=t[e+3],mo[0]}var go=new Float64Array([-0]),ie=new Uint8Array(go.buffer);function gs(t,e,r){go[0]=t,e[r]=ie[0],e[r+1]=ie[1],e[r+2]=ie[2],e[r+3]=ie[3],e[r+4]=ie[4],e[r+5]=ie[5],e[r+6]=ie[6],e[r+7]=ie[7]}function ys(t,e){return ie[0]=t[e],ie[1]=t[e+1],ie[2]=t[e+2],ie[3]=t[e+3],ie[4]=t[e+4],ie[5]=t[e+5],ie[6]=t[e+6],ie[7]=t[e+7],go[0]}var Mu=BigInt(Number.MAX_SAFE_INTEGER),Fu=BigInt(Number.MIN_SAFE_INTEGER),be=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 It;if(e<Mu&&e>Fu)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>ws&&(o=0n,++n>ws&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return It;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):It}},It=new be(0,0);It.toBigInt=function(){return 0n};It.zzEncode=It.zzDecode=function(){return this};It.length=function(){return 1};var ws=4294967296n;function xs(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 bs(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 yo(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 De(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function Fr(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var wo=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,De(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 De(this,4);return Fr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw De(this,4);return Fr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw De(this,4);let e=ms(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw De(this,4);let e=ys(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 De(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return bs(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw De(this,e);this.pos+=e}else do if(this.pos>=this.len)throw De(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 be(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 De(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 De(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 De(this,8);let e=Fr(this.buf,this.pos+=4),r=Fr(this.buf,this.pos+=4);return new be(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=po(this.buf,this.pos);return this.pos+=$e(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 xo(t){return new wo(t instanceof Uint8Array?t:t.subarray())}function Hr(t,e,r){let n=xo(t);return e.decode(n,void 0,r)}function bo(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return Te(s);o+s>e&&(n=Te(e),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var vt=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function Eo(){}var vo=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Hu=bo();function Vu(t){return globalThis.Buffer!=null?Te(t):Hu(t)}var ur=class{len;head;tail;states;constructor(){this.len=0,this.head=new vt(Eo,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new vt(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new So((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(Vr,10,be.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=be.fromBigInt(e);return this._push(Vr,r.length(),r)}uint64Number(e){return this._push(cr,$e(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=be.fromBigInt(e).zzEncode();return this._push(Vr,r.length(),r)}sint64Number(e){let r=be.fromNumber(e).zzEncode();return this._push(Vr,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Io,1,e?1:0)}fixed32(e){return this._push(ar,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=be.fromBigInt(e);return this._push(ar,4,r.lo)._push(ar,4,r.hi)}fixed64Number(e){let r=be.fromNumber(e);return this._push(ar,4,r.lo)._push(ar,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(fs,4,e)}double(e){return this._push(gs,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(Io,1,0):this.uint32(r)._push(zu,r,e)}string(e){let r=xs(e);return r!==0?this.uint32(r)._push(yo,r,e):this._push(Io,1,0)}fork(){return this.states=new vo(this),this.head=this.tail=new vt(Eo,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 vt(Eo,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=Vu(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function Io(t,e,r){e[r]=t&255}function qu(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var So=class extends vt{next;constructor(e,r){super(qu,e,r),this.next=void 0}};function Vr(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 ar(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 zu(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(ur.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push($u,e,t),this},ur.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(ju,e,t),this});function $u(t,e,r){e.set(t,r)}function ju(t,e,r){t.length<40?yo(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(J(t),r)}function Ao(){return new ur}function qr(t,e){let r=Ao();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var Ht;(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"})(Ht||(Ht={}));function zr(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function Bo(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 zr("enum",Ht.VARINT,r,n)}function $r(t,e){return zr("message",Ht.LENGTH_DELIMITED,t,e)}var Ee;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.ECDSA="ECDSA"})(Ee||(Ee={}));var Co;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1",t[t.ECDSA=3]="ECDSA"})(Co||(Co={}));(function(t){t.codec=()=>Bo(Co)})(Ee||(Ee={}));var dr;(function(t){let e;t.codec=()=>(e==null&&(e=$r((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),Ee.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=Ee.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),e),t.encode=r=>qr(r,t.codec()),t.decode=(r,n)=>Hr(r,t.codec(),n)})(dr||(dr={}));var Uo;(function(t){let e;t.codec=()=>(e==null&&(e=$r((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),Ee.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=Ee.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),e),t.encode=r=>qr(r,t.codec()),t.decode=(r,n)=>Hr(r,t.codec(),n)})(Uo||(Uo={}));var nt=_t(le("node:crypto"),1),St=nt&&typeof nt=="object"&&"webcrypto"in nt?nt.webcrypto:nt&&typeof nt=="object"&&"randomBytes"in nt?nt:void 0;function At(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function lr(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function _e(t,...e){if(!At(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 jr(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");lr(t.outputLen),lr(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 vs(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 Bt(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Gr(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Oe(t,e){return t<<32-e|t>>>e}var Ss=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Wu=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function it(t){if(_e(t),Ss)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=Wu[t[r]];return e}var ot={_0:48,_9:57,A:65,F:70,a:97,f:102};function Is(t){if(t>=ot._0&&t<=ot._9)return t-ot._0;if(t>=ot.A&&t<=ot.F)return t-(ot.A-10);if(t>=ot.a&&t<=ot.f)return t-(ot.a-10)}function Ct(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Ss)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=Is(t.charCodeAt(i)),c=Is(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 As(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function hr(t){return typeof t=="string"&&(t=As(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 Vt=class{};function Bs(t){let e=n=>t().update(hr(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Wr(t=32){if(St&&typeof St.getRandomValues=="function")return St.getRandomValues(new Uint8Array(t));if(St&&typeof St.randomBytes=="function")return Uint8Array.from(St.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}function Yu(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 Cs(t,e,r){return t&e^~t&r}function Us(t,e,r){return t&e^t&r^e&r}var Yr=class extends Vt{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=Gr(this.buffer)}update(e){qt(this),e=hr(e),_e(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=Gr(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){qt(this),vs(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,Bt(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;Yu(n,o-8,BigInt(this.length*8),i),this.process(n,0);let c=Gr(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=a/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)c.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: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()}},st=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Zu=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),Lo=class extends Yr{constructor(e=32){super(64,e,8,!1),this.A=st[0]|0,this.B=st[1]|0,this.C=st[2]|0,this.D=st[3]|0,this.E=st[4]|0,this.F=st[5]|0,this.G=st[6]|0,this.H=st[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 l=0;l<16;l++,r+=4)ft[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let d=ft[l-15],h=ft[l-2],p=Oe(d,7)^Oe(d,18)^d>>>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:c,F:a,G:u,H:f}=this;for(let l=0;l<64;l++){let d=Oe(c,6)^Oe(c,11)^Oe(c,25),h=f+d+Cs(c,a,u)+Zu[l]+ft[l]|0,m=(Oe(n,2)^Oe(n,13)^Oe(n,22))+Us(n,o,i)|0;f=u,u=a,a=c,c=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,c=c+this.E|0,a=a+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(n,o,i,s,c,a,u,f)}roundClean(){Bt(ft)}destroy(){this.set(0,0,0,0,0,0,0,0),Bt(this.buffer)}};var Ls=Bs(()=>new Lo);var ic=_t(le("node:crypto"),1);var Zr=class extends Vt{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,jr(e);let n=hr(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),Bt(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: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()}},To=(t,e,r)=>new Zr(t,e).update(r).digest();To.create=(t,e)=>new Zr(t,e);var Oo=BigInt(0),_o=BigInt(1);function pr(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=At(t),o=t?.length,i=e!==void 0;if(!n||i&&o!==e){let s=r&&`"${r}" `,c=i?` of length ${e}`:"",a=n?`length=${o}`:`type=${typeof t}`;throw new Error(s+"expected Uint8Array"+c+", got "+a)}return t}function fr(t){let e=t.toString(16);return e.length&1?"0"+e:e}function Ts(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Oo:BigInt("0x"+t)}function zt(t){return Ts(it(t))}function Po(t){return _e(t),Ts(it(Uint8Array.from(t).reverse()))}function Xr(t,e){return Ct(t.toString(16).padStart(e*2,"0"))}function No(t,e){return Xr(t,e).reverse()}function se(t,e,r){let n;if(typeof e=="string")try{n=Ct(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(At(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 Do=t=>typeof t=="bigint"&&Oo<=t;function Ds(t,e,r){return Do(t)&&Do(e)&&Do(r)&&e<=t&&t<r}function _s(t,e,r,n){if(!Ds(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Qr(t){let e;for(e=0;t>Oo;t>>=_o,e+=1);return e}var gt=t=>(_o<<BigInt(t))-_o;function Os(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),c=0,a=()=>{i.fill(1),s.fill(0),c=0},u=(...h)=>r(s,i,...h),f=(h=n(0))=>{s=u(o(0),h),i=u(),h.length!==0&&(s=u(o(1),h),i=u())},l=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let h=0,p=[];for(;h<e;){i=u();let m=i.slice();p.push(m),h+=i.length}return Pe(...p)};return(h,p)=>{a(),f(h);let m;for(;!(m=p(l()));)f();return a(),m}}function mr(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 Ro(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 ue=BigInt(0),ce=BigInt(1),Ut=BigInt(2),Rs=BigInt(3),ks=BigInt(4),Ks=BigInt(5),Xu=BigInt(7),Ms=BigInt(8),Qu=BigInt(9),Fs=BigInt(16);function Ae(t,e){let r=t%e;return r>=ue?r:e+r}function Ie(t,e,r){let n=t;for(;e-- >ue;)n*=n,n%=r;return n}function Ps(t,e){if(t===ue)throw new Error("invert: expected non-zero number");if(e<=ue)throw new Error("invert: expected positive modulus, got "+e);let r=Ae(t,e),n=e,o=ue,i=ce,s=ce,c=ue;for(;r!==ue;){let u=n/r,f=n%r,l=o-s*u,d=i-c*u;n=r,r=f,o=s,i=c,s=l,c=d}if(n!==ce)throw new Error("invert: does not exist");return Ae(o,e)}function ko(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function Hs(t,e){let r=(t.ORDER+ce)/ks,n=t.pow(e,r);return ko(t,n,e),n}function Ju(t,e){let r=(t.ORDER-Ks)/Ms,n=t.mul(e,Ut),o=t.pow(n,r),i=t.mul(e,o),s=t.mul(t.mul(i,Ut),o),c=t.mul(i,t.sub(s,t.ONE));return ko(t,c,e),c}function ed(t){let e=yt(t),r=Vs(t),n=r(e,e.neg(e.ONE)),o=r(e,n),i=r(e,e.neg(n)),s=(t+Xu)/Fs;return(c,a)=>{let u=c.pow(a,s),f=c.mul(u,n),l=c.mul(u,o),d=c.mul(u,i),h=c.eql(c.sqr(f),a),p=c.eql(c.sqr(l),a);u=c.cmov(u,f,h),f=c.cmov(d,l,p);let m=c.eql(c.sqr(f),a),E=c.cmov(u,f,m);return ko(c,E,a),E}}function Vs(t){if(t<Rs)throw new Error("sqrt is not defined for small field");let e=t-ce,r=0;for(;e%Ut===ue;)e/=Ut,r++;let n=Ut,o=yt(t);for(;Ns(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Hs;let i=o.pow(n,e),s=(e+ce)/Ut;return function(a,u){if(a.is0(u))return u;if(Ns(a,u)!==1)throw new Error("Cannot find square root");let f=r,l=a.mul(a.ONE,i),d=a.pow(u,e),h=a.pow(u,s);for(;!a.eql(d,a.ONE);){if(a.is0(d))return a.ZERO;let p=1,m=a.sqr(d);for(;!a.eql(m,a.ONE);)if(p++,m=a.sqr(m),p===f)throw new Error("Cannot find square root");let E=ce<<BigInt(f-p-1),U=a.pow(l,E);f=p,l=a.sqr(U),d=a.mul(d,l),h=a.mul(h,U)}return h}}function td(t){return t%ks===Rs?Hs:t%Ms===Ks?Ju:t%Fs===Qu?ed(t):Vs(t)}var rd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ko(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},r=rd.reduce((n,o)=>(n[o]="function",n),e);return mr(t,r),t}function nd(t,e,r){if(r<ue)throw new Error("invalid exponent, negatives unsupported");if(r===ue)return t.ONE;if(r===ce)return e;let n=t.ONE,o=e;for(;r>ue;)r&ce&&(n=t.mul(n,o)),o=t.sqr(o),r>>=ce;return n}function Jr(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 Ns(t,e){let r=(t.ORDER-ce)/Ut,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 en(t,e){e!==void 0&&lr(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<=ue)throw new Error("invalid field: expected ORDER > 0, got "+t);let o,i,s=!1,c;if(typeof e=="object"&&e!=null){if(n.sqrt||r)throw new Error("cannot specify opts in two arguments");let d=e;d.BITS&&(o=d.BITS),d.sqrt&&(i=d.sqrt),typeof d.isLE=="boolean"&&(r=d.isLE),typeof d.modFromBytes=="boolean"&&(s=d.modFromBytes),c=d.allowedLengths}else typeof e=="number"&&(o=e),n.sqrt&&(i=n.sqrt);let{nBitLength:a,nByteLength:u}=en(t,o);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let f,l=Object.freeze({ORDER:t,isLE:r,BITS:a,BYTES:u,MASK:gt(a),ZERO:ue,ONE:ce,allowedLengths:c,create:d=>Ae(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return ue<=d&&d<t},is0:d=>d===ue,isValidNot0:d=>!l.is0(d)&&l.isValid(d),isOdd:d=>(d&ce)===ce,neg:d=>Ae(-d,t),eql:(d,h)=>d===h,sqr:d=>Ae(d*d,t),add:(d,h)=>Ae(d+h,t),sub:(d,h)=>Ae(d-h,t),mul:(d,h)=>Ae(d*h,t),pow:(d,h)=>nd(l,d,h),div:(d,h)=>Ae(d*Ps(h,t),t),sqrN:d=>d*d,addN:(d,h)=>d+h,subN:(d,h)=>d-h,mulN:(d,h)=>d*h,inv:d=>Ps(d,t),sqrt:i||(d=>(f||(f=td(t)),f(l,d))),toBytes:d=>r?No(d,u):Xr(d,u),fromBytes:(d,h=!0)=>{if(c){if(!c.includes(d.length)||d.length>u)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+d.length);let m=new Uint8Array(u);m.set(d,r?0:m.length-d.length),d=m}if(d.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+d.length);let p=r?Po(d):zt(d);if(s&&(p=Ae(p,t)),!h&&!l.isValid(p))throw new Error("invalid field element: outside of range 0..ORDER");return p},invertBatch:d=>Jr(l,d),cmov:(d,h,p)=>p?h:d});return Object.freeze(l)}function qs(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 Mo(t){let e=qs(t);return e+Math.ceil(e/2)}function Fo(t,e,r=!1){let n=t.length,o=qs(e),i=Mo(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Po(t):zt(t),c=Ae(s,e-ce)+ce;return r?No(c,o):Xr(c,o)}var $t=BigInt(0),Lt=BigInt(1);function gr(t,e){let r=e.negate();return t?r:e}function rn(t,e){let r=Jr(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function Gs(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Ho(t,e){Gs(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 zs(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+=Lt);let u=e*n,f=u+Math.abs(c)-1,l=c===0,d=c<0,h=e%2!==0;return{nextN:a,offset:f,isZero:l,isNeg:d,isNegF:h,offsetF:u}}function od(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 id(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 Vo=new WeakMap,Ws=new WeakMap;function qo(t){return Ws.get(t)||1}function $s(t){if(t!==$t)throw new Error("invalid wNAF")}var tn=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>$t;)r&Lt&&(n=n.add(o)),o=o.double(),r>>=Lt;return n}precomputeWindow(e,r){let{windows:n,windowSize:o}=Ho(r,this.bits),i=[],s=e,c=s;for(let a=0;a<n;a++){c=s,i.push(c);for(let u=1;u<o;u++)c=c.add(s),i.push(c);s=c.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=Ho(e,this.bits);for(let c=0;c<s.windows;c++){let{nextN:a,offset:u,isZero:f,isNeg:l,isNegF:d,offsetF:h}=zs(n,c,s);n=a,f?i=i.add(gr(d,r[h])):o=o.add(gr(l,r[u]))}return $s(n),{p:o,f:i}}wNAFUnsafe(e,r,n,o=this.ZERO){let i=Ho(e,this.bits);for(let s=0;s<i.windows&&n!==$t;s++){let{nextN:c,offset:a,isZero:u,isNeg:f}=zs(n,s,i);if(n=c,!u){let l=r[a];o=o.add(f?l.negate():l)}}return $s(n),o}getPrecomputes(e,r,n){let o=Vo.get(r);return o||(o=this.precomputeWindow(r,e),e!==1&&(typeof n=="function"&&(o=n(o)),Vo.set(r,o))),o}cached(e,r,n){let o=qo(e);return this.wNAF(o,this.getPrecomputes(o,e,n),r)}unsafe(e,r,n,o){let i=qo(e);return i===1?this._unsafeLadder(e,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),r,o)}createCache(e,r){Gs(r,this.bits),Ws.set(e,r),Vo.delete(e)}hasCache(e){return qo(e)!==1}};function Ys(t,e,r,n){let o=e,i=t.ZERO,s=t.ZERO;for(;r>$t||n>$t;)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 Zs(t,e,r,n){od(r,t),id(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=Qr(BigInt(o)),a=1;c>12?a=c-3:c>4?a=c-2:c>0&&(a=2);let u=gt(a),f=new Array(Number(u)+1).fill(s),l=Math.floor((e.BITS-1)/a)*a,d=s;for(let h=l;h>=0;h-=a){f.fill(s);for(let m=0;m<i;m++){let E=n[m],U=Number(E>>BigInt(h)&u);f[U]=f[U].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(d=d.add(p),h!==0)for(let m=0;m<a;m++)d=d.double()}return d}function js(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Ko(e),e}else return yt(t,{isLE:r})}function Xs(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 a of["p","n","h"]){let u=e[a];if(!(typeof u=="bigint"&&u>$t))throw new Error(`CURVE.${a} must be positive bigint`)}let o=js(e.p,r.Fp,n),i=js(e.n,r.Fn,n),c=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let a of c)if(!o.isValid(e[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:i}}var Qs=(t,e)=>(t+(t>=0?e:-e)/Js)/e;function sd(t,e,r){let[[n,o],[i,s]]=e,c=Qs(s*t,r),a=Qs(-o*t,r),u=t-c*n-a*i,f=-c*o-a*s,l=u<at,d=f<at;l&&(u=-u),d&&(f=-f);let h=gt(Math.ceil(Qr(r)/2))+Gt;if(u<at||u>=h||f<at||f>=h)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:l,k1:u,k2neg:d,k2:f}}function $o(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function zo(t,e){let r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return pr(r.lowS,"lowS"),pr(r.prehash,"prehash"),r.format!==void 0&&$o(r.format),r}var jo=class extends Error{constructor(e=""){super(e)}},ct={Err:jo,_tlv:{encode:(t,e)=>{let{Err:r}=ct;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=fr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?fr(o.length/2|128):"";return fr(t)+i+o+e},decode(t,e){let{Err:r}=ct,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 f of u)s=s<<8|f;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}=ct;if(t<at)throw new e("integer: negative integers are not allowed");let r=fr(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}=ct;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 zt(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=ct,o=se("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:f}=n.decode(2,a);if(f.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}=ct,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}},at=BigInt(0),Gt=BigInt(1),Js=BigInt(2),nn=BigInt(3),cd=BigInt(4);function jt(t,e){let{BYTES:r}=t,n;if(typeof e=="bigint")n=e;else{let o=se("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 ad(t,e={}){let r=Xs("weierstrass",t,e),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s,n:c}=i;mr(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:a}=e;if(a&&(!n.is0(i.a)||typeof a.beta!="bigint"||!Array.isArray(a.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let u=tc(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(pr(y,"isCompressed"),y){f();let C=!n.isOdd(b);return Pe(ec(C),S)}else return Pe(Uint8Array.of(4),S,n.toBytes(b))}function d(N){mt(N,void 0,"Point");let{publicKey:w,publicKeyUncompressed:y}=u,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 H=G instanceof Error?": "+G.message:"";throw new Error("bad point: is not on curve, sqrt error"+H)}f();let L=n.isOdd(A);return(b&1)===1!==L&&(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||d;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 U=n.mul(n.pow(i.a,nn),cd),k=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(U,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 M(N){if(!(N instanceof D))throw new Error("ProjectivePoint expected")}function R(N){if(!a||!a.basises)throw new Error("no endo");return sd(N,a.basises,o.ORDER)}let F=Ro((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}}),te=Ro(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 re(N,w,y,g,b){return y=new D(n.mul(y.X,N),y.Y,y.Z),w=gr(g,w),y=gr(b,y),w.add(y)}class D{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 D)throw new Error("projective point not allowed");return n.is0(y)&&n.is0(g)?D.ZERO:new D(y,g,n.ONE)}static fromBytes(w){let y=D.fromAffine(p(mt(w,void 0,"point")));return y.assertValidity(),y}static fromHex(w){return D.fromBytes(se("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(nn),this}assertValidity(){te(this)}hasEvenY(){let{y:w}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(w)}equals(w){M(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)),L=n.eql(n.mul(g,B),n.mul(C,b));return A&&L}negate(){return new D(this.X,n.neg(this.Y),this.Z)}double(){let{a:w,b:y}=i,g=n.mul(y,nn),{X:b,Y:S,Z:C}=this,B=n.ZERO,A=n.ZERO,L=n.ZERO,_=n.mul(b,b),G=n.mul(S,S),H=n.mul(C,C),P=n.mul(b,S);return P=n.add(P,P),L=n.mul(b,C),L=n.add(L,L),B=n.mul(w,L),A=n.mul(g,H),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),L=n.mul(g,L),H=n.mul(w,H),P=n.sub(_,H),P=n.mul(w,P),P=n.add(P,L),L=n.add(_,_),_=n.add(L,_),_=n.add(_,H),_=n.mul(_,P),A=n.add(A,_),H=n.mul(S,C),H=n.add(H,H),_=n.mul(H,P),B=n.sub(B,_),L=n.mul(H,G),L=n.add(L,L),L=n.add(L,L),new D(B,A,L)}add(w){M(w);let{X:y,Y:g,Z:b}=this,{X:S,Y:C,Z:B}=w,A=n.ZERO,L=n.ZERO,_=n.ZERO,G=i.a,H=n.mul(i.b,nn),P=n.mul(y,S),q=n.mul(g,C),W=n.mul(b,B),de=n.add(y,g),z=n.add(S,C);de=n.mul(de,z),z=n.add(P,q),de=n.sub(de,z),z=n.add(y,b);let ne=n.add(S,B);return z=n.mul(z,ne),ne=n.add(P,W),z=n.sub(z,ne),ne=n.add(g,b),A=n.add(C,B),ne=n.mul(ne,A),A=n.add(q,W),ne=n.sub(ne,A),_=n.mul(G,z),A=n.mul(H,W),_=n.add(A,_),A=n.sub(q,_),_=n.add(q,_),L=n.mul(A,_),q=n.add(P,P),q=n.add(q,P),W=n.mul(G,W),z=n.mul(H,z),q=n.add(q,W),W=n.sub(P,W),W=n.mul(G,W),z=n.add(z,W),P=n.mul(q,z),L=n.add(L,P),P=n.mul(ne,z),A=n.mul(de,A),A=n.sub(A,P),P=n.mul(de,q),_=n.mul(ne,_),_=n.add(_,P),new D(A,L,_)}subtract(w){return this.add(w.negate())}is0(){return this.equals(D.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=>rn(D,B));if(y){let{k1neg:C,k1:B,k2neg:A,k2:L}=R(w),{p:_,f:G}=S(B),{p:H,f:P}=S(L);b=G.add(P),g=re(y.beta,_,H,C,A)}else{let{p:C,f:B}=S(w);g=C,b=B}return rn(D,[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===at||g.is0())return D.ZERO;if(w===Gt)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:L}=Ys(D,g,S,B);return re(y.beta,A,L,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 F(this,w)}isTorsionFree(){let{isTorsionFree:w}=e;return s===Gt?!0:w?w(D,this):wt.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:w}=e;return s===Gt?this:w?w(D,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(w=!0){return pr(w,"isCompressed"),this.assertValidity(),h(D,this,w)}toHex(w=!0){return it(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 rn(D,w)}static msm(w,y){return Zs(D,o,w,y)}static fromPrivateKey(w){return D.BASE.multiply(jt(o,w))}}D.BASE=new D(i.Gx,i.Gy,n.ONE),D.ZERO=new D(n.ZERO,n.ONE,n.ZERO),D.Fp=n,D.Fn=o;let Ar=o.BITS,wt=new tn(D,e.endo?Math.ceil(Ar/2):Ar);return D.BASE.precompute(8),D}function ec(t){return Uint8Array.of(t?2:3)}function tc(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function ud(t,e={}){let{Fn:r}=t,n=e.randomBytes||Wr,o=Object.assign(tc(t.Fp,r),{seed:Mo(r.ORDER)});function i(h){try{return!!jt(r,h)}catch{return!1}}function s(h,p){let{publicKey:m,publicKeyUncompressed:E}=o;try{let U=h.length;return p===!0&&U!==m||p===!1&&U!==E?!1:!!t.fromBytes(h)}catch{return!1}}function c(h=n(o.seed)){return Fo(mt(h,o.seed,"seed"),r.ORDER)}function a(h,p=!0){return t.BASE.multiply(jt(r,h)).toBytes(p)}function u(h){let p=c(h);return{secretKey:p,publicKey:a(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 U=se("key",h).length;return U===m||U===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=jt(r,h);return t.fromHex(p).multiply(E).toBytes(m)}return Object.freeze({getPublicKey:a,getSharedSecret:l,keygen:u,Point:t,utils:{isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:c,isValidPrivateKey:i,randomPrivateKey:c,normPrivateKeyToScalar:h=>jt(r,h),precompute(h=8,p=t.BASE){return p.precompute(h,!1)}},lengths:o})}function dd(t,e,r={}){jr(e),mr(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let n=r.randomBytes||Wr,o=r.hmac||((y,...g)=>To(e,y,Pe(...g))),{Fp:i,Fn:s}=t,{ORDER:c,BITS:a}=s,{keygen:u,getPublicKey:f,getSharedSecret:l,utils:d,lengths:h}=ud(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=c>>Gt;return y>g}function U(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){$o(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=U("r",g),this.s=U("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:L,s:_}=ct.toSig(mt(g));return new O(L,_)}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(Ct(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(c*Js<b&&B>1)throw new Error("recovery id is ambiguous for h>1 curve");let L=B===2||B===3?S+c:S;if(!i.isValid(L))throw new Error("recovery id 2 or 3 invalid");let _=i.toBytes(L),G=t.fromBytes(Pe(ec((B&1)===0),_)),H=s.inv(L),P=R(se("msgHash",g)),q=s.create(-P*H),W=s.create(C*H),de=t.BASE.multiplyUnsafe(q).add(G.multiplyUnsafe(W));if(de.is0())throw new Error("point at infinify");return de.assertValidity(),de}hasHighS(){return E(this.s)}toBytes(g=m){if($o(g),g==="der")return Ct(ct.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 it(this.toBytes(g))}assertValidity(){}static fromCompact(g){return O.fromBytes(se("sig",g),"compact")}static fromDER(g){return O.fromBytes(se("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 it(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return it(this.toBytes("compact"))}}let M=r.bits2int||function(g){if(g.length>8192)throw new Error("input is too large");let b=zt(g),S=g.length*8-a;return S>0?b>>BigInt(S):b},R=r.bits2int_modN||function(g){return s.create(M(g))},F=gt(a);function te(y){return _s("num < 2^"+a,y,at,F),s.toBytes(y)}function re(y,g){return mt(y,void 0,"message"),g?mt(e(y),void 0,"prehashed message"):y}function D(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}=zo(b,p);y=re(y,C);let A=R(y),L=jt(s,g),_=[te(L),te(A)];if(B!=null&&B!==!1){let q=B===!0?n(h.secretKey):B;_.push(se("extraEntropy",q))}let G=Pe(..._),H=A;function P(q){let W=M(q);if(!s.isValidNot0(W))return;let de=s.inv(W),z=t.BASE.multiply(W).toAffine(),ne=s.create(z.x);if(ne===at)return;let Br=s.create(de*s.create(H+ne*L));if(Br===at)return;let ui=(z.x===ne?0:2)|Number(z.y&Gt),di=Br;return S&&E(Br)&&(di=s.neg(Br),ui^=1),new O(ne,di,ui)}return{seed:G,k2sig:P}}function Ar(y,g,b={}){y=se("message",y);let{seed:S,k2sig:C}=D(y,g,b);return Os(e.outputLen,s.BYTES,o)(S,C)}function wt(y){let g,b=typeof y=="string"||At(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(se("sig",y),"der")}catch(C){if(!(C instanceof ct.Err))throw C}if(!g)try{g=O.fromBytes(se("sig",y),"compact")}catch{return!1}}return g||!1}function N(y,g,b,S={}){let{lowS:C,prehash:B,format:A}=zo(S,p);if(b=se("publicKey",b),g=re(se("message",g),B),"strict"in S)throw new Error("options.strict was renamed to lowS");let L=A===void 0?wt(y):O.fromBytes(se("sig",y),A);if(L===!1)return!1;try{let _=t.fromBytes(b);if(C&&L.hasHighS())return!1;let{r:G,s:H}=L,P=R(g),q=s.inv(H),W=s.create(P*q),de=s.create(G*q),z=t.BASE.multiplyUnsafe(W).add(_.multiplyUnsafe(de));return z.is0()?!1:s.create(z.x)===G}catch{return!1}}function w(y,g,b={}){let{prehash:S}=zo(b,p);return g=re(g,S),O.fromBytes(y,"recovered").recoverPublicKey(g).toBytes()}return Object.freeze({keygen:u,getPublicKey:f,getSharedSecret:l,utils:d,lengths:h,Point:t,sign:Ar,verify:N,recoverPublicKey:w,Signature:O,hash:e})}function ld(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 hd(t){let{CURVE:e,curveOpts:r}=ld(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 pd(t,e){let r=e.Point;return Object.assign({},e,{ProjectivePoint:r,CURVE:Object.assign({},t,en(r.Fn.ORDER,r.Fn.BITS))})}function rc(t){let{CURVE:e,curveOpts:r,hash:n,ecdsaOpts:o}=hd(t),i=ad(e,r),s=dd(i,n,o);return pd(t,s)}function nc(t,e){let r=n=>rc({...t,hash:n});return{...r(e),create:r}}var Wo={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},fd={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var oc=BigInt(2);function md(t){let e=Wo.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,f=u*u*t%e,l=Ie(f,r,e)*f%e,d=Ie(l,r,e)*f%e,h=Ie(d,oc,e)*u%e,p=Ie(h,o,e)*h%e,m=Ie(p,i,e)*p%e,E=Ie(m,c,e)*m%e,U=Ie(E,a,e)*E%e,k=Ie(U,c,e)*m%e,O=Ie(k,r,e)*f%e,M=Ie(O,s,e)*p%e,R=Ie(M,n,e)*u%e,F=Ie(R,oc,e);if(!Go.eql(Go.sqr(F),t))throw new Error("Cannot find square root");return F}var Go=yt(Wo.p,{sqrt:md}),yr=nc({...Wo,Fp:Go,lowS:!0,endo:fd},Ls);var on=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function sc(t,e,r,n){n?.signal?.throwIfAborted();let o=ic.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 yr.verify(e,i,t)}catch(s){throw new on(String(s))}}var sn=class{type="secp256k1";raw;_key;constructor(e){this._key=ac(e),this.raw=cc(this._key)}toMultihash(){return Le.digest(Ft(this))}toCID(){return Y.createV1(114,this.toMultihash())}toString(){return j.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:we(this.raw,e.raw)}verify(e,r,n){return sc(this._key,r,e,n)}};function uc(t){return new sn(t)}function cc(t){return yr.ProjectivePoint.fromHex(t).toRawBytes(!0)}function ac(t){try{return yr.ProjectivePoint.fromHex(t),t}catch(e){throw new Ur(String(e))}}function dc(t){let{Type:e,Data:r}=dr.decode(t.digest),n=r??new Uint8Array;switch(e){case Ee.Ed25519:return ps(n);case Ee.secp256k1:return uc(n);case Ee.ECDSA:return cs(n);default:throw new Zt}}function Ft(t){return dr.encode({Type:Ee[t.type],Data:t.raw})}var lc=Symbol.for("nodejs.util.inspect.custom"),gd=114,wr=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()})`}[yn]=!0;toString(){return this.string==null&&(this.string=j.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return Y.createV1(gd,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return we(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return we(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[lc](){return`PeerId(${this.toString()})`}},cn=class extends wr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},an=class extends wr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},un=class extends wr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},yd=2336,xr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Le.digest(J(this.url))}[lc](){return`PeerId(${this.url})`}[yn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return Y.createV1(yd,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=K(e)),e.toString()===this.toString())}};var wd=114,hc=2336;function pc(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=tr(j.decode(`z${t}`));else{if(t.startsWith("k51qzi5uqu5")||t.startsWith("kzwfwjn5ji4")||t.startsWith("k2k4r8")||t.startsWith("bafz"))return xd(Y.parse(t));if(e==null)throw new Re('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=tr(e.decode(t))}return fc(r)}function fc(t){if(Ed(t))return new cn({multihash:t});if(bd(t))try{let e=dc(t);if(e.type==="Ed25519")return new an({multihash:t,publicKey:e});if(e.type==="secp256k1")return new un({multihash:t,publicKey:e})}catch{let r=K(t.digest);return new xr(new URL(r))}throw new Tr("Supplied PeerID Multihash is invalid")}function xd(t){if(t?.multihash==null||t.version==null||t.version===1&&t.code!==wd&&t.code!==hc)throw new Lr("Supplied PeerID CID is invalid");if(t.code===hc){let e=K(t.multihash.digest);return new xr(new URL(e))}return fc(t.multihash)}function bd(t){return t.code===Le.code}function Ed(t){return t.code===Qn.code}var ve=le("node:net");var gc=_t(mc(),1),Id=["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"],vd=Id.map(t=>new gc.Netmask(t));function Yo(t){for(let e of vd)if(e.contains(t))return!0;return!1}function Sd(t){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(t)}function Ad(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 Yo(o)}function Bd(t){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)}function Cd(t){let e=t.split(":"),r=e[e.length-1];return Yo(r)}function Ud(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 yc(t){if((0,ve.isIPv4)(t))return Yo(t);if(Sd(t))return Ad(t);if(Bd(t))return Cd(t);if((0,ve.isIPv6)(t))return Ud(t)}var ee=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},ut=class extends Error{static name="ValidationError";name="ValidationError"},Er=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},dn=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function Xo(t){return e=>K(e,t)}function Qo(t){return e=>J(e,t)}function Wt(t){return new DataView(t.buffer).getUint16(t.byteOffset).toString()}function Tt(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof t=="string"?parseInt(t):t),new Uint8Array(e)}function wc(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=Tt(n);return ze([r,o],r.length+o.length)}function xc(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=Tt(n);return ze([r,o],r.length+o.length)}function Jo(t){let e=t.subarray(0,t.length-2),r=t.subarray(t.length-2),n=K(e,"base32"),o=Wt(r);return`${n}:${o}`}var ei=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},bc=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=ei(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},Ec=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(".")},Ic=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 vc(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 Zo=Object.values(nr).map(t=>t.decoder),Ld=function(){let t=Zo[0].or(Zo[1]);return Zo.slice(2).forEach(e=>t=t.or(e)),t}();function Sc(t){return Ld.decode(t)}function Ac(t){return e=>t.encoder.encode(e)}function Td(t){if(parseInt(t).toString()!==t)throw new ut("Value must be an integer")}function Dd(t){if(t<0)throw new ut("Value must be a positive integer, or zero")}function _d(t){return e=>{if(e>t)throw new ut(`Value must be smaller than or equal to ${t}`)}}function Od(...t){return e=>{for(let r of t)r(e)}}var Ir=Od(Td,Dd,_d(65535));var X=-1,ti=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 dn(`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)}))}},pe=new ti,ul=[{code:4,name:"ip4",size:32,valueToBytes:ei,bytesToValue:Ec,validate:t=>{if(!(0,ve.isIPv4)(t))throw new ut(`Invalid IPv4 address "${t}"`)}},{code:6,name:"tcp",size:16,valueToBytes:Tt,bytesToValue:Wt,validate:Ir},{code:273,name:"udp",size:16,valueToBytes:Tt,bytesToValue:Wt,validate:Ir},{code:33,name:"dccp",size:16,valueToBytes:Tt,bytesToValue:Wt,validate:Ir},{code:41,name:"ip6",size:128,valueToBytes:bc,bytesToValue:Ic,stringToValue:vc,validate:t=>{if(!(0,ve.isIPv6)(t))throw new ut(`Invalid IPv6 address "${t}"`)}},{code:42,name:"ip6zone",size:X},{code:43,name:"ipcidr",size:8,bytesToValue:Xo("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:Tt,bytesToValue:Wt,validate:Ir},{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:Xo("base58btc"),valueToBytes:t=>t.startsWith("Q")||t.startsWith("1")?Qo("base58btc")(t):Y.parse(t).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:Jo,valueToBytes:wc},{code:445,name:"onion3",size:296,bytesToValue:Jo,valueToBytes:xc},{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:Ac($n),valueToBytes:Sc},{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}];ul.forEach(t=>{pe.addProtocol(t)});function Bc(t){let e=[],r=0;for(;r<t.length;){let n=fo(t,r),o=pe.getProtocol(n),i=$e(n),s=dl(o,t,r+i),c=0;s>0&&o.size===X&&(c=$e(s));let a=i+c+s,u={code:n,name:o.name,bytes:t.subarray(r,r+a)};if(s>0){let f=r+i+c,l=t.subarray(f,f+s);u.value=o.bytesToValue?.(l)??K(l)}e.push(u),r+=a}return e}function Cc(t){let e=0,r=[];for(let n of t){if(n.bytes==null){let o=pe.getProtocol(n.code),i=$e(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=$e(c)));let u=new Uint8Array(i+a+c),f=0;cr(n.code,u,f),f+=i,s!=null&&(o.size===X&&(cr(c,u,f),f+=a),u.set(s,f)),n.bytes=u}r.push(n.bytes),e+=n.bytes.byteLength}return ze(r,e)}function Uc(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=pe.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 Lc(t){return`/${t.flatMap(e=>{if(e.value==null)return e.name;let r=pe.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 dl(t,e,r){return t.size==null||t.size===0?0:t.size>0?t.size/8:fo(e,r)}var ll=Symbol.for("nodejs.util.inspect.custom"),ai=Symbol.for("@multiformats/multiaddr"),hl=[53,54,55,56],ci=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}};function pl(t){if(t==null&&(t="/"),Dc(t))return t.getComponents();if(t instanceof Uint8Array)return Bc(t);if(typeof t=="string")return t=t.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),t===""&&(t="/"),Uc(t);if(Array.isArray(t))return t;throw new ee("Must be a string, Uint8Array, Component[], or another Multiaddr")}var fn=class t{[ai]=!0;#e;#t;#r;constructor(e="/",r={}){this.#e=pl(e),r.validate!==!1&&fl(this)}get bytes(){return this.#r==null&&(this.#r=Cc(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=Lc(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??""}`),hl.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=pe.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=pe.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 Er(`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(j.decode(`z${n}`),"base58btc"):K(Y.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){for(let e of this.#e)if(pe.getProtocol(e.code).path)return e.value??null;return null}equals(e){return we(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(i=>i.resolvable);if(r==null)return[this];let n=Tc.get(r.name);if(n==null)throw new ci(`no available resolver for ${r.name}`);return(await n(this,e)).map(i=>Sr(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)}[ll](){return`Multiaddr(${this.toString()})`}};function fl(t){t.getComponents().forEach(e=>{let r=pe.getProtocol(e.code);e.value!=null&&r.validate?.(e.value)})}var mn=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 f=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let d=Number.parseInt(l,e);if(!Number.isNaN(d))return d});if(f===void 0)break;if(i*=e,i+=f,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 ig=new mn;var pg=parseInt("0xFFFF",16),fg=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var Tc=new Map;function Dc(t){return!!t?.[ai]}function Sr(t){return new fn(t)}function Pc(t){let e=pe.getProtocol(t);return{code:e.code,size:e.size??0,name:e.name,resolvable:!!e.resolvable,path:!!e.path}}function Nc(t){try{for(let{code:e}of t.getComponents())if(e!==42)return e===4||e===41}catch{}return!1}function Rc(t){try{if(!Nc(t))return!1;let[[,e]]=t.stringTuples();return e==null?!1:yc(e)??!1}catch{}return!0}function kc(t,e,r,n){let o=()=>{n?.log.trace("query",e),t.query({questions:[{name:e,type:"PTR"}]})};return o(),setInterval(o,r)}function Kc(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=>Sr(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:pc(c),multiaddrs:s.map(a=>a.decapsulateCode(Pc("p2p").code))}}catch(s){n?.log.error("failed to parse mdns response",s)}}function Mc(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(bl).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 bl(t){return!!Rc(t)}function Fc(t){let e="",r="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<t;n++)e+=r.charAt(Math.floor(Math.random()*r.length));return e}var gn=class extends Dr{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??Fc(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)}[hi]=this;[Symbol.toStringTag]="@libp2p/mdns";[mi]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,Hc.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=kc(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),Mc(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=Kc(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 Il(t={}){return e=>new gn(e,t)}return Gc(vl);})();
3
3
  /*! Bundled license information:
4
4
 
5
5
  @noble/hashes/esm/utils.js: