@libp2p/mdns 12.0.2 → 12.0.3-93ba5a84f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +3 -3
- package/dist/src/mdns.js +3 -3
- package/dist/src/mdns.js.map +1 -1
- package/dist/src/query.js +2 -2
- package/dist/src/query.js.map +1 -1
- package/package.json +8 -8
- package/src/mdns.ts +3 -3
- package/src/query.ts +2 -2
- package/dist/typedoc-urls.json +0 -6
package/dist/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PMdns = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PMdns=(()=>{var Ec=Object.create;var mr=Object.defineProperty;var Ic=Object.getOwnPropertyDescriptor;var vc=Object.getOwnPropertyNames;var Sc=Object.getPrototypeOf,Ac=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),he=(t,e)=>{for(var r in e)mr(t,r,{get:e[r],enumerable:!0})},jo=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of vc(e))!Ac.call(t,o)&&o!==r&&mr(t,o,{get:()=>e[o],enumerable:!(n=Ic(e,o))||n.enumerable});return t};var Ft=(t,e,r)=>(r=t!=null?Ec(Sc(t)):{},jo(e||!t||!t.__esModule?mr(r,"default",{value:t,enumerable:!0}):r,t)),Bc=t=>jo(mr({},"__esModule",{value:!0}),t);var Xo=Pe(tn=>{"use strict";tn.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};tn.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 Qo=Pe(rn=>{"use strict";rn.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};rn.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 Jo=Pe(nn=>{"use strict";nn.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};nn.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 ei=Pe(on=>{"use strict";on.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};on.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 ti=Pe(sn=>{"use strict";sn.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}`};sn.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 oi=Pe((ni,cn)=>{var ri=(function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=d,t.encode=f,t.familyOf=u,t.name=void 0,t.sizeOf=c,t.v6=t.v4=void 0;let e=/^(\d{1,3}\.){3,3}\d{1,3}$/,r=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,o=16,i={name:"v4",size:r,isFormat:h=>e.test(h),encode(h,p,l){l=~~l,p=p||new Uint8Array(l+r);let m=h.length,b=0;for(let L=0;L<m;){let T=h.charCodeAt(L++);T===46?(p[l++]=b,b=0):b=b*10+(T-48)}return p[l]=b,p},decode(h,p){return p=~~p,`${h[p++]}.${h[p++]}.${h[p++]}.${h[p]}`}};t.v4=i;let s={name:"v6",size:o,isFormat:h=>h.length>0&&n.test(h),encode(h,p,l){l=~~l;let m=l+o,b=-1,L=0,T=0,F=!0,P=!1;p=p||new Uint8Array(l+o);for(let K=0;K<h.length;K++){let k=h.charCodeAt(K);k===58?(F?b!==-1?(l<m&&(p[l]=0),l<m-1&&(p[l+1]=0),l+=2):l<m&&(b=l):(P===!0?(l<m&&(p[l]=T),l++):(l<m&&(p[l]=L>>8),l<m-1&&(p[l+1]=L&255),l+=2),L=0,T=0),F=!0,P=!1):k===46?(l<m&&(p[l]=T),l++,T=0,L=0,F=!1,P=!0):(F=!1,k>=97?k-=87:k>=65?k-=55:(k-=48,T=T*10+k),L=(L<<4)+k)}if(F===!1)P===!0?(l<m&&(p[l]=T),l++):(l<m&&(p[l]=L>>8),l<m-1&&(p[l+1]=L&255),l+=2);else if(b===0)l<m&&(p[l]=0),l<m-1&&(p[l+1]=0),l+=2;else if(b!==-1){l+=2;for(let K=Math.min(l-1,m-1);K>=b+2;K--)p[K]=p[K-2];p[b]=0,p[b+1]=0,b=l}if(b!==l&&b!==-1)for(l>m-2&&(l=m-2);m>b;)p[--m]=l<m&&l>b?p[--l]:0;else for(;l<m;)p[l++]=0;return p},decode(h,p){p=~~p;let l="";for(let m=0;m<o;m+=2)m!==0&&(l+=":"),l+=(h[p+m]<<8|h[p+m+1]).toString(16);return l.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};t.v6=s;let a="ip";t.name=a;function c(h){if(i.isFormat(h))return i.size;if(s.isFormat(h))return s.size;throw Error(`Invalid ip address: ${h}`)}function u(h){return c(h)===i.size?1:2}function f(h,p,l){l=~~l;let m=c(h);return typeof p=="function"&&(p=p(l+m)),m===i.size?i.encode(h,p,l):s.encode(h,p,l)}function d(h,p,l){if(p=~~p,l=l||h.length-p,l===i.size)return i.decode(h,p,l);if(l===s.size)return s.decode(h,p,l);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 ri}):typeof cn=="object"&&typeof ni=="object"&&(cn.exports=ri)});var ci=Pe(I=>{"use strict";var v=le("buffer").Buffer,et=Xo(),Cc=Qo(),Lc=Jo(),Ir=ei(),an=ti(),ft=oi(),Dc=0,ii=32768,un=32768,Uc=~un,si=32768,Oc=~si,x=I.name={};x.encode=function(t,e,r,{mail:n=!1}={}){e||(e=v.alloc(x.encodingLength(t))),r||(r=0);let o=r,i=t.replace(/^\.|\.$/gm,"");if(i.length){let s=[];if(n){let a="";i.split(".").forEach(c=>{c.endsWith("\\")?a+=(a.length?".":"")+c.slice(0,-1):s.length===0&&a.length?s.push(a+"."+c):s.push(c)})}else s=i.split(".");for(let a=0;a<s.length;a++){let c=e.write(s[a],r+1);e[r]=c,r+=c+1}}return e[r++]=0,x.encode.bytes=r-o,e};x.encode.bytes=0;x.decode=function(t,e,{mail:r=!1}={}){e||(e=0);let n=[],o=e,i=0,s=0,a=!1;for(;;){if(e>=t.length)throw new Error("Cannot decode name (buffer overflow)");let c=t[e++];if(s+=a?0:1,c===0)break;if((c&192)===0){if(e+c>t.length)throw new Error("Cannot decode name (buffer overflow)");if(i+=c+1,i>254)throw new Error("Cannot decode name (name too long)");let u=t.toString("utf-8",e,e+c);r&&(u=u.replace(/\./g,"\\.")),n.push(u),e+=c,s+=a?0:c}else if((c&192)===192){if(e+1>t.length)throw new Error("Cannot decode name (buffer overflow)");let u=t.readUInt16BE(e-1)-49152;if(u>=o)throw new Error("Cannot decode name (bad pointer)");e=u,o=u,s+=a?0:1,a=!0}else throw new Error("Cannot decode name (bad label)")}return x.decode.bytes=s,n.length===0?".":n.join(".")};x.decode.bytes=0;x.encodingLength=function(t){return t==="."||t===".."?1:v.byteLength(t.replace(/^\.|\.$/gm,""))+2};var U={};U.encode=function(t,e,r){e||(e=v.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 v.byteLength(t)+1};var Be={};Be.encode=function(t,e,r){e||(e=Be.encodingLength(t)),r||(r=0);let n=(t.flags||0)&32767,o=t.type==="response"?ii:Dc;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};Be.encode.bytes=12;Be.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:Lc.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:Cc.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))}};Be.decode.bytes=12;Be.encodingLength=function(){return 12};var $e=I.unknown={};$e.encode=function(t,e,r){return e||(e=v.alloc($e.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.length,r),t.copy(e,r+2),$e.encode.bytes=t.length+2,e};$e.encode.bytes=0;$e.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=t.slice(e+2,e+2+r);return $e.decode.bytes=r+2,n};$e.decode.bytes=0;$e.encodingLength=function(t){return t.length+2};var je=I.ns={};je.encode=function(t,e,r){return e||(e=v.alloc(je.encodingLength(t))),r||(r=0),x.encode(t,e,r+2),e.writeUInt16BE(x.encode.bytes,r),je.encode.bytes=x.encode.bytes+2,e};je.encode.bytes=0;je.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=x.decode(t,e+2);return je.decode.bytes=r+2,n};je.decode.bytes=0;je.encodingLength=function(t){return x.encodingLength(t)+2};var Ge=I.soa={};Ge.encode=function(t,e,r){e||(e=v.alloc(Ge.encodingLength(t))),r||(r=0);let n=r;return r+=2,x.encode(t.mname,e,r),r+=x.encode.bytes,x.encode(t.rname,e,r,{mail:!0}),r+=x.encode.bytes,e.writeUInt32BE(t.serial||0,r),r+=4,e.writeUInt32BE(t.refresh||0,r),r+=4,e.writeUInt32BE(t.retry||0,r),r+=4,e.writeUInt32BE(t.expire||0,r),r+=4,e.writeUInt32BE(t.minimum||0,r),r+=4,e.writeUInt16BE(r-n-2,n),Ge.encode.bytes=r-n,e};Ge.encode.bytes=0;Ge.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=x.decode(t,e),e+=x.decode.bytes,n.rname=x.decode(t,e,{mail:!0}),e+=x.decode.bytes,n.serial=t.readUInt32BE(e),e+=4,n.refresh=t.readUInt32BE(e),e+=4,n.retry=t.readUInt32BE(e),e+=4,n.expire=t.readUInt32BE(e),e+=4,n.minimum=t.readUInt32BE(e),e+=4,Ge.decode.bytes=e-r,n};Ge.decode.bytes=0;Ge.encodingLength=function(t){return 22+x.encodingLength(t.mname)+x.encodingLength(t.rname)};var Ye=I.txt={};Ye.encode=function(t,e,r){Array.isArray(t)||(t=[t]);for(let o=0;o<t.length;o++)if(typeof t[o]=="string"&&(t[o]=v.from(t[o])),!v.isBuffer(t[o]))throw new Error("Must be a Buffer");e||(e=v.alloc(Ye.encodingLength(t))),r||(r=0);let n=r;return r+=2,t.forEach(function(o){e[r++]=o.length,o.copy(e,r,0,o.length),r+=o.length}),e.writeUInt16BE(r-n-2,n),Ye.encode.bytes=r-n,e};Ye.encode.bytes=0;Ye.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let o=[];for(;n>0;){let i=t[e++];if(--n,n<i)throw new Error("Buffer overflow");o.push(t.slice(e,e+i)),e+=i,n-=i}return Ye.decode.bytes=e-r,o};Ye.decode.bytes=0;Ye.encodingLength=function(t){Array.isArray(t)||(t=[t]);let e=2;return t.forEach(function(r){typeof r=="string"?e+=v.byteLength(r)+1:e+=r.length+1}),e};var We=I.null={};We.encode=function(t,e,r){e||(e=v.alloc(We.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=v.from(t)),t||(t=v.alloc(0));let n=r;r+=2;let o=t.length;return t.copy(e,r,0,o),r+=o,e.writeUInt16BE(r-n-2,n),We.encode.bytes=r-n,e};We.encode.bytes=0;We.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let o=t.slice(e,e+n);return e+=n,We.decode.bytes=e-r,o};We.decode.bytes=0;We.encodingLength=function(t){return t?(v.isBuffer(t)?t.length:v.byteLength(t))+2:2};var Ze=I.hinfo={};Ze.encode=function(t,e,r){e||(e=v.alloc(Ze.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),Ze.encode.bytes=r-n,e};Ze.encode.bytes=0;Ze.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,Ze.decode.bytes=e-r,n};Ze.decode.bytes=0;Ze.encodingLength=function(t){return U.encodingLength(t.cpu)+U.encodingLength(t.os)+2};var Se=I.ptr={},Tc=I.cname=Se,_c=I.dname=Se;Se.encode=function(t,e,r){return e||(e=v.alloc(Se.encodingLength(t))),r||(r=0),x.encode(t,e,r+2),e.writeUInt16BE(x.encode.bytes,r),Se.encode.bytes=x.encode.bytes+2,e};Se.encode.bytes=0;Se.decode=function(t,e){e||(e=0);let r=x.decode(t,e+2);return Se.decode.bytes=x.decode.bytes+2,r};Se.decode.bytes=0;Se.encodingLength=function(t){return x.encodingLength(t)+2};var Xe=I.srv={};Xe.encode=function(t,e,r){e||(e=v.alloc(Xe.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),Xe.encode.bytes=n+2,e};Xe.encode.bytes=0;Xe.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),Xe.decode.bytes=r+2,n};Xe.decode.bytes=0;Xe.encodingLength=function(t){return 8+x.encodingLength(t.target)};var pe=I.caa={};pe.ISSUER_CRITICAL=128;pe.encode=function(t,e,r){let n=pe.encodingLength(t);return e||(e=v.alloc(pe.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=pe.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+=v.byteLength(t.value),pe.encode.bytes=n,e};pe.encode.bytes=0;pe.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&pe.ISSUER_CRITICAL),pe.decode.bytes=r+2,o};pe.decode.bytes=0;pe.encodingLength=function(t){return U.encodingLength(t.tag)+U.encodingLength(t.value)+2};var ct=I.mx={};ct.encode=function(t,e,r){e||(e=v.alloc(ct.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),ct.encode.bytes=r-n,e};ct.encode.bytes=0;ct.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,ct.decode.bytes=e-r,n};ct.encodingLength=function(t){return 4+x.encodingLength(t.exchange)};var Qe=I.a={};Qe.encode=function(t,e,r){return e||(e=v.alloc(Qe.encodingLength(t))),r||(r=0),e.writeUInt16BE(4,r),r+=2,ft.v4.encode(t,e,r),Qe.encode.bytes=6,e};Qe.encode.bytes=0;Qe.decode=function(t,e){e||(e=0),e+=2;let r=ft.v4.decode(t,e);return Qe.decode.bytes=6,r};Qe.decode.bytes=0;Qe.encodingLength=function(){return 6};var Je=I.aaaa={};Je.encode=function(t,e,r){return e||(e=v.alloc(Je.encodingLength(t))),r||(r=0),e.writeUInt16BE(16,r),r+=2,ft.v6.encode(t,e,r),Je.encode.bytes=18,e};Je.encode.bytes=0;Je.decode=function(t,e){e||(e=0),e+=2;let r=ft.v6.decode(t,e);return Je.decode.bytes=18,r};Je.decode.bytes=0;Je.encodingLength=function(){return 18};var ue=I.option={};ue.encode=function(t,e,r){e||(e=v.alloc(ue.encodingLength(t))),r||(r=0);let n=r,o=an.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||ft.familyOf(t.ip),a=ft.encode(t.ip,v.alloc),c=Math.ceil(i/8);e.writeUInt16BE(c+4,r),r+=2,e.writeUInt16BE(s,r),r+=2,e.writeUInt8(i,r++),e.writeUInt8(t.scopePrefixLength||0,r++),a.copy(e,r,0,c),r+=c;break;case 11:t.timeout?(e.writeUInt16BE(2,r),r+=2,e.writeUInt16BE(t.timeout,r),r+=2):(e.writeUInt16BE(0,r),r+=2);break;case 12:let 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 d of t.tags)e.writeUInt16BE(d,r),r+=2;break;default:throw new Error(`Unknown roption code: ${t.code}`)}return ue.encode.bytes=r-n,e};ue.encode.bytes=0;ue.decode=function(t,e){e||(e=0);let r={};r.code=t.readUInt16BE(e),r.type=an.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=ft.decode(o);break;case 11:n>0&&(r.timeout=t.readUInt16BE(e),e+=2);break;case 14:r.tags=[];for(let i=0;i<n;i+=2)r.tags.push(t.readUInt16BE(e)),e+=2}return ue.decode.bytes=n+4,r};ue.decode.bytes=0;ue.encodingLength=function(t){if(t.data)return t.data.length+4;switch(an.toCode(t.code)){case 8:let r=t.sourcePrefixLength||0;return Math.ceil(r/8)+8;case 11:return typeof t.timeout=="number"?6:4;case 12:return t.length+4;case 14:return 4+t.tags.length*2}throw new Error(`Unknown roption code: ${t.code}`)};var ge=I.opt={};ge.encode=function(t,e,r){e||(e=v.alloc(ge.encodingLength(t))),r||(r=0);let n=r,o=St(t,ue);return e.writeUInt16BE(o,r),r=qt(t,ue,e,r+2),ge.encode.bytes=r-n,e};ge.encode.bytes=0;ge.decode=function(t,e){e||(e=0);let r=e,n=[],o=t.readUInt16BE(e);e+=2;let i=0;for(;o>0;)n[i++]=ue.decode(t,e),e+=ue.decode.bytes,o-=ue.decode.bytes;return ge.decode.bytes=e-r,n};ge.decode.bytes=0;ge.encodingLength=function(t){return 2+St(t||[],ue)};var ce=I.dnskey={};ce.PROTOCOL_DNSSEC=3;ce.ZONE_KEY=128;ce.SECURE_ENTRYPOINT=32768;ce.encode=function(t,e,r){e||(e=v.alloc(ce.encodingLength(t))),r||(r=0);let n=r,o=t.key;if(!v.isBuffer(o))throw new Error("Key must be a Buffer");return r+=2,e.writeUInt16BE(t.flags,r),r+=2,e.writeUInt8(ce.PROTOCOL_DNSSEC,r),r+=1,e.writeUInt8(t.algorithm,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,ce.encode.bytes=r-n,e.writeUInt16BE(ce.encode.bytes-2,n),e};ce.encode.bytes=0;ce.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);if(e+=2,n.flags=t.readUInt16BE(e),e+=2,t.readUInt8(e)!==ce.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=t.readUInt8(e),e+=1,n.key=t.slice(e,r+o+2),e+=n.key.length,ce.decode.bytes=e-r,n};ce.decode.bytes=0;ce.encodingLength=function(t){return 6+v.byteLength(t.key)};var Ne=I.rrsig={};Ne.encode=function(t,e,r){e||(e=v.alloc(Ne.encodingLength(t))),r||(r=0);let n=r,o=t.signature;if(!v.isBuffer(o))throw new Error("Signature must be a Buffer");return r+=2,e.writeUInt16BE(et.toType(t.typeCovered),r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.labels,r),r+=1,e.writeUInt32BE(t.originalTTL,r),r+=4,e.writeUInt32BE(t.expiration,r),r+=4,e.writeUInt32BE(t.inception,r),r+=4,e.writeUInt16BE(t.keyTag,r),r+=2,x.encode(t.signersName,e,r),r+=x.encode.bytes,o.copy(e,r,0,o.length),r+=o.length,Ne.encode.bytes=r-n,e.writeUInt16BE(Ne.encode.bytes-2,n),e};Ne.encode.bytes=0;Ne.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.typeCovered=et.toString(t.readUInt16BE(e)),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.labels=t.readUInt8(e),e+=1,n.originalTTL=t.readUInt32BE(e),e+=4,n.expiration=t.readUInt32BE(e),e+=4,n.inception=t.readUInt32BE(e),e+=4,n.keyTag=t.readUInt16BE(e),e+=2,n.signersName=x.decode(t,e),e+=x.decode.bytes,n.signature=t.slice(e,r+o+2),e+=n.signature.length,Ne.decode.bytes=e-r,n};Ne.decode.bytes=0;Ne.encodingLength=function(t){return 20+x.encodingLength(t.signersName)+v.byteLength(t.signature)};var Re=I.rp={};Re.encode=function(t,e,r){e||(e=v.alloc(Re.encodingLength(t))),r||(r=0);let n=r;return r+=2,x.encode(t.mbox||".",e,r,{mail:!0}),r+=x.encode.bytes,x.encode(t.txt||".",e,r),r+=x.encode.bytes,Re.encode.bytes=r-n,e.writeUInt16BE(Re.encode.bytes-2,n),e};Re.encode.bytes=0;Re.decode=function(t,e){e||(e=0);let r=e,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,Re.decode.bytes=e-r,n};Re.decode.bytes=0;Re.encodingLength=function(t){return 2+x.encodingLength(t.mbox||".")+x.encodingLength(t.txt||".")};var W={};W.encode=function(t,e,r){e||(e=v.alloc(W.encodingLength(t))),r||(r=0);let n=r;for(var o=[],i=0;i<t.length;i++){var s=et.toType(t[i]);o[s>>8]===void 0&&(o[s>>8]=[]),o[s>>8][s>>3&31]|=1<<7-(s&7)}for(i=0;i<o.length;i++)if(o[i]!==void 0){var a=v.from(o[i]);e.writeUInt8(i,r),r+=1,e.writeUInt8(a.length,r),r+=1,a.copy(e,r),r+=a.length}return W.encode.bytes=r-n,e};W.encode.bytes=0;W.decode=function(t,e,r){e||(e=0);let n=e;for(var o=[];e-n<r;){var i=t.readUInt8(e);e+=1;var s=t.readUInt8(e);e+=1;for(var a=0;a<s;a++)for(var c=t.readUInt8(e+a),u=0;u<8;u++)if(c&1<<7-u){var f=et.toString(i<<8|a<<3|u);o.push(f)}e+=s}return W.decode.bytes=e-n,o};W.decode.bytes=0;W.encodingLength=function(t){for(var e=[],r=0;r<t.length;r++){var n=et.toType(t[r]);e[n>>8]=Math.max(e[n>>8]||0,n&255)}var o=0;for(r=0;r<e.length;r++)e[r]!==void 0&&(o+=2+Math.ceil((e[r]+1)/8));return o};var Ke=I.nsec={};Ke.encode=function(t,e,r){e||(e=v.alloc(Ke.encodingLength(t))),r||(r=0);let n=r;return r+=2,x.encode(t.nextDomain,e,r),r+=x.encode.bytes,W.encode(t.rrtypes,e,r),r+=W.encode.bytes,Ke.encode.bytes=r-n,e.writeUInt16BE(Ke.encode.bytes-2,n),e};Ke.encode.bytes=0;Ke.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.nextDomain=x.decode(t,e),e+=x.decode.bytes,n.rrtypes=W.decode(t,e,o-(e-r)),e+=W.decode.bytes,Ke.decode.bytes=e-r,n};Ke.decode.bytes=0;Ke.encodingLength=function(t){return 2+x.encodingLength(t.nextDomain)+W.encodingLength(t.rrtypes)};var ke=I.nsec3={};ke.encode=function(t,e,r){e||(e=v.alloc(ke.encodingLength(t))),r||(r=0);let n=r,o=t.salt;if(!v.isBuffer(o))throw new Error("salt must be a Buffer");let i=t.nextDomain;if(!v.isBuffer(i))throw new Error("nextDomain must be a Buffer");return r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.flags,r),r+=1,e.writeUInt16BE(t.iterations,r),r+=2,e.writeUInt8(o.length,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,e.writeUInt8(i.length,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,W.encode(t.rrtypes,e,r),r+=W.encode.bytes,ke.encode.bytes=r-n,e.writeUInt16BE(ke.encode.bytes-2,n),e};ke.encode.bytes=0;ke.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);e+=2,n.algorithm=t.readUInt8(e),e+=1,n.flags=t.readUInt8(e),e+=1,n.iterations=t.readUInt16BE(e),e+=2;let i=t.readUInt8(e);e+=1,n.salt=t.slice(e,e+i),e+=i;let s=t.readUInt8(e);return e+=1,n.nextDomain=t.slice(e,e+s),e+=s,n.rrtypes=W.decode(t,e,o-(e-r)),e+=W.decode.bytes,ke.decode.bytes=e-r,n};ke.decode.bytes=0;ke.encodingLength=function(t){return 8+t.salt.length+t.nextDomain.length+W.encodingLength(t.rrtypes)};var Me=I.ds={};Me.encode=function(t,e,r){e||(e=v.alloc(Me.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,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.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,Me.decode.bytes=e-r,n};Me.decode.bytes=0;Me.encodingLength=function(t){return 6+v.byteLength(t.digest)};var fe=I.sshfp={};fe.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};fe.encode=function(e,r,n){r||(r=v.alloc(fe.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!==fe.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return i.copy(r,n),n+=i.byteLength,fe.encode.bytes=n-o,r.writeUInt16BE(fe.encode.bytes-2,o),r};fe.encode.bytes=0;fe.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=fe.getFingerprintLengthForHashType(o.hash);return o.fingerprint=e.slice(r,r+i).toString("hex").toUpperCase(),r+=i,fe.decode.bytes=r-n,o};fe.decode.bytes=0;fe.encodingLength=function(t){return 4+v.from(t.fingerprint,"hex").byteLength};var Fe=I.naptr={};Fe.encode=function(t,e,r){e||(e=v.alloc(Fe.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,Fe.encode.bytes=r-n,e.writeUInt16BE(Fe.encode.bytes-2,n),e};Fe.encode.bytes=0;Fe.decode=function(t,e){e||(e=0);let r=e,n={};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,Fe.decode.bytes=e-r,n};Fe.decode.bytes=0;Fe.encodingLength=function(t){return U.encodingLength(t.flags)+U.encodingLength(t.services)+U.encodingLength(t.regexp)+x.encodingLength(t.replacement)+6};var He=I.tlsa={};He.encode=function(t,e,r){e||(e=v.alloc(He.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,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={},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,He.decode.bytes=e-r,n};He.decode.bytes=0;He.encodingLength=function(t){return 5+v.byteLength(t.certificate)};var dn=I.record=function(t){switch(t.toUpperCase()){case"A":return Qe;case"PTR":return Se;case"CNAME":return Tc;case"DNAME":return _c;case"TXT":return Ye;case"NULL":return We;case"AAAA":return Je;case"SRV":return Xe;case"HINFO":return Ze;case"CAA":return pe;case"NS":return je;case"SOA":return Ge;case"MX":return ct;case"OPT":return ge;case"DNSKEY":return ce;case"RRSIG":return Ne;case"RP":return Re;case"NSEC":return Ke;case"NSEC3":return ke;case"SSHFP":return fe;case"DS":return Me;case"NAPTR":return Fe;case"TLSA":return He}return $e},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(et.toType(t.type),r),t.type.toUpperCase()==="OPT"){if(t.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(t.udpPayloadSize||4096,r+2),e.writeUInt8(t.extendedRcode||0,r+4),e.writeUInt8(t.ednsVersion||0,r+5),e.writeUInt16BE(t.flags||0,r+6),r+=8,ge.encode(t.options||[],e,r),r+=ge.encode.bytes}else{let o=Ir.toClass(t.class===void 0?"IN":t.class);t.flush&&(o|=un),e.writeUInt16BE(o,r+2),e.writeUInt32BE(t.ttl||0,r+4),r+=8;let i=dn(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=et.toString(t.readUInt16BE(e)),r.type==="OPT")r.udpPayloadSize=t.readUInt16BE(e+2),r.extendedRcode=t.readUInt8(e+4),r.ednsVersion=t.readUInt8(e+5),r.flags=t.readUInt16BE(e+6),r.flag_do=(r.flags>>15&1)===1,r.options=ge.decode(t,e+8),e+=8+ge.decode.bytes;else{let o=t.readUInt16BE(e+2);r.ttl=t.readUInt32BE(e+4),r.class=Ir.toString(o&Uc),r.flush=!!(o&un);let i=dn(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+dn(t.type).encodingLength(e)};var Ae=I.question={};Ae.encode=function(t,e,r){e||(e=v.alloc(Ae.encodingLength(t))),r||(r=0);let n=r;return x.encode(t.name,e,r),r+=x.encode.bytes,e.writeUInt16BE(et.toType(t.type),r),r+=2,e.writeUInt16BE(Ir.toClass(t.class===void 0?"IN":t.class),r),r+=2,Ae.encode.bytes=r-n,t};Ae.encode.bytes=0;Ae.decode=function(t,e){e||(e=0);let r=e,n={};return n.name=x.decode(t,e),e+=x.decode.bytes,n.type=et.toString(t.readUInt16BE(e)),e+=2,n.class=Ir.toString(t.readUInt16BE(e)),e+=2,!!(n.class&si)&&(n.class&=Oc),Ae.decode.bytes=e-r,n};Ae.decode.bytes=0;Ae.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=[]),Be.encode(t,e,r),r+=Be.encode.bytes,r=qt(t.questions,Ae,e,r),r=qt(t.answers,Q,e,r),r=qt(t.authorities,Q,e,r),r=qt(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=Be.decode(t,e);return e+=Be.decode.bytes,e=Er(n.questions,Ae,t,e),e=Er(n.answers,Q,t,e),e=Er(n.authorities,Q,t,e),e=Er(n.additionals,Q,t,e),I.decode.bytes=e-r,n};I.decode.bytes=0;I.encodingLength=function(t){return Be.encodingLength(t)+St(t.questions||[],Ae)+St(t.answers||[],Q)+St(t.authorities||[],Q)+St(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 St(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function qt(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 Er(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 di=Pe((Vl,ui)=>{"use strict";var ai=Mc;process.nextTick(kc,42);ui.exports=Pc;function Pc(t){var e=n;return r;function r(o){e(o||Rc)}function n(o){var i=[o];e=s,t(a);function s(c){i.push(c)}function a(c){var u=arguments;for(e=Nc(c)?n:f;i.length;)f(i.shift());function f(d){ai(Kc,d,u)}}}}function Nc(t){return Object.prototype.toString.call(t)==="[object Error]"}function Rc(){}function Kc(t,e){t.apply(null,e)}function kc(t){t===42&&(ai=process.nextTick)}function Mc(t,e,r){process.nextTick(function(){t(e,r)})}});var pi=Pe((zl,hi)=>{var ln=ci(),Fc=le("dgram"),Hc=di(),qc=le("events"),pn=le("os"),hn=function(){};hi.exports=function(t){t||(t={});var e=new qc.EventEmitter,r=typeof t.port=="number"?t.port:5353,n=t.type||"udp4",o=t.ip||t.host||(n==="udp4"?"224.0.0.251":null),i={address:o,port:r},s={},a=!1,c=null;if(n==="udp6"&&(!o||!t.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var u=t.socket||Fc.createSocket({type:n,reuseAddr:t.reuseAddr!==!1,toString:function(){return n}});u.on("error",function(d){d.code==="EACCES"||d.code==="EADDRINUSE"?e.emit("error",d):e.emit("warning",d)}),u.on("message",function(d,h){try{d=ln.decode(d)}catch(p){e.emit("warning",p);return}e.emit("packet",d,h),d.type==="query"&&e.emit("query",d,h),d.type==="response"&&e.emit("response",d,h)}),u.on("listening",function(){r||(r=i.port=u.address().port),t.multicast!==!1&&(e.update(),c=setInterval(e.update,5e3),u.setMulticastTTL(t.ttl||255),u.setMulticastLoopback(t.loopback!==!1))});var f=Hc(function(d){if(!r||t.bind===!1)return d(null);u.once("error",d),u.bind(r,t.bind||t.interface,function(){u.removeListener("error",d),d(null)})});return f(function(d){if(d)return e.emit("error",d);e.emit("ready")}),e.send=function(d,h,p){if(typeof h=="function")return e.send(d,null,h);p||(p=hn),h?!h.host&&!h.address&&(h.address=i.address):h=i,f(l);function l(m){if(a)return p();if(m)return p(m);var b=ln.encode(d);u.send(b,0,b.length,h.port,h.address||h.host,p)}},e.response=e.respond=function(d,h,p){Array.isArray(d)&&(d={answers:d}),d.type="response",d.flags=(d.flags||0)|ln.AUTHORITATIVE_ANSWER,e.send(d,h,p)},e.query=function(d,h,p,l){if(typeof h=="function")return e.query(d,null,null,h);if(typeof h=="object"&&h&&h.port)return e.query(d,null,h,p);if(typeof p=="function")return e.query(d,h,null,p);l||(l=hn),typeof d=="string"&&(d=[{name:d,type:h||"ANY"}]),Array.isArray(d)&&(d={type:"query",questions:d}),d.type="query",e.send(d,p,l)},e.destroy=function(d){if(d||(d=hn),a)return process.nextTick(d);a=!0,clearInterval(c);for(var h in s)try{u.dropMembership(o,h)}catch{}s={},u.close(d)},e.update=function(){for(var d=t.interface?[].concat(t.interface):zc(),h=!1,p=0;p<d.length;p++){var l=d[p];if(!s[l])try{u.addMembership(o,l),s[l]=!0,h=!0}catch(m){e.emit("warning",m)}}if(h){if(u.setMulticastInterface)try{u.setMulticastInterface(t.interface||Vc())}catch(m){e.emit("warning",m)}e.emit("networkInterface")}},e};function Vc(){for(var t=pn.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(li(i.family)&&!i.internal)return pn.platform()==="darwin"&&e[r]==="en0"?i.address:"0.0.0.0"}return"127.0.0.1"}function zc(){for(var t=pn.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(li(s.family)){r.push(s.address);break}}return r}function li(t){return t===4||t==="IPv4"}});var Qs=Pe(lr=>{(function(){var t,e,r,n,o,i,s,a;a=function(c){var u,f,d,h;return u=(c&255<<24)>>>24,f=(c&255<<16)>>>16,d=(c&65280)>>>8,h=c&255,[u,f,d,h].join(".")},s=function(c){var u,f,d,h,p,l;for(u=[],d=h=0;h<=3&&c.length!==0;d=++h){if(d>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}l=e(c),p=l[0],f=l[1],c=c.substring(f),u.push(p)}if(c.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(c){return c.charCodeAt(0)},n=r("0"),i=r("a"),o=r("A"),e=function(c){var u,f,d,h,p;for(h=0,u=10,f="9",d=0,c.length>1&&c[d]==="0"&&(c[d+1]==="x"||c[d+1]==="X"?(d+=2,u=16):"0"<=c[d+1]&&c[d+1]<="9"&&(d++,u=8,f="7")),p=d;d<c.length;){if("0"<=c[d]&&c[d]<=f)h=h*u+(r(c[d])-n)>>>0;else if(u===16)if("a"<=c[d]&&c[d]<="f")h=h*u+(10+r(c[d])-i)>>>0;else if("A"<=c[d]&&c[d]<="F")h=h*u+(10+r(c[d])-o)>>>0;else break;else break;if(h>4294967295)throw new Error("too large");d++}if(d===p)throw new Error("empty octet");return[h,d]},t=(function(){function c(u,f){var d,h,p,l;if(typeof u!="string")throw new Error("Missing `net' parameter");if(f||(l=u.split("/",2),u=l[0],f=l[1]),f||(f=32),typeof f=="string"&&f.indexOf(".")>-1){try{this.maskLong=s(f)}catch(m){throw d=m,new Error("Invalid mask: "+f)}for(h=p=32;p>=0;h=--p)if(this.maskLong===4294967295<<32-h>>>0){this.bitmask=h;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 d=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=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(u){return typeof u=="string"&&(u.indexOf("/")>0||u.split(".").length!==4)&&(u=new c(u)),u instanceof c?this.contains(u.base)&&this.contains(u.broadcast||u.last):(s(u)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(u){return u==null&&(u=1),new c(a(this.netLong+this.size*u),this.mask)},c.prototype.forEach=function(u){var f,d,h;for(h=s(this.first),d=s(this.last),f=0;h<=d;)u(a(h),h,f),f++,h++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c})(),lr.ip2long=s,lr.long2ip=a,lr.Netmask=t}).call(lr)});var nl={};he(nl,{mdns:()=>rl});var Ie=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},yr=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var wr=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},xr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var Ht=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var Go=Symbol.for("@libp2p/peer-discovery");var en=Symbol.for("@libp2p/peer-id");var Yo=le("node:events"),Wo=(t,...e)=>{try{(0,Yo.setMaxListeners)(t,...e)}catch{}};var br=class extends EventTarget{#e=new Map;constructor(){super(),Wo(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 Zo=Symbol.for("@libp2p/service-capabilities"),ll=Symbol.for("@libp2p/service-dependencies");var bc=Ft(pi(),1);var wn={};he(wn,{base58btc:()=>G,base58flickr:()=>Xc});var $l=new Uint8Array(0);function fi(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 ve(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 gi(t){return new TextEncoder().encode(t)}function mi(t){return new TextDecoder().decode(t)}function $c(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function d(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var m=0,b=0,L=0,T=l.length;L!==T&&l[L]===0;)L++,m++;for(var F=(T-L)*f+1>>>0,P=new Uint8Array(F);L!==T;){for(var K=l[L],k=0,ie=F-1;(K!==0||k<b)&&ie!==-1;ie--,k++)K+=256*P[ie]>>>0,P[ie]=K%a>>>0,K=K/a>>>0;if(K!==0)throw new Error("Non-zero carry");b=k,L++}for(var se=F-b;se!==F&&P[se]===0;)se++;for(var _=c.repeat(m);se<F;++se)_+=t.charAt(P[se]);return _}function h(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var m=0;if(l[m]!==" "){for(var b=0,L=0;l[m]===c;)b++,m++;for(var T=(l.length-m)*u+1>>>0,F=new Uint8Array(T);l[m];){var P=r[l.charCodeAt(m)];if(P===255)return;for(var K=0,k=T-1;(P!==0||K<L)&&k!==-1;k--,K++)P+=a*F[k]>>>0,F[k]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");L=K,m++}if(l[m]!==" "){for(var ie=T-L;ie!==T&&F[ie]===0;)ie++;for(var se=new Uint8Array(b+(T-ie)),_=b;ie!==T;)se[_++]=F[ie++];return se}}}function p(l){var m=h(l);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:h,decode:p}}var jc=$c,Gc=jc,wi=Gc;var fn=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")}},gn=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 xi(this,e)}},mn=class{decoders;constructor(e){this.decoders=e}or(e){return xi(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 xi(t,e){return new mn({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var yn=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 fn(e,r,n),this.decoder=new gn(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function At({name:t,prefix:e,encode:r,decode:n}){return new yn(t,e,r,n)}function at({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=wi(r,t);return At({prefix:e,name:t,encode:n,decode:i=>ve(o(i))})}function Yc(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let u=0;u<o;++u){let f=e[t[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|f,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function Wc(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],s+=8;s>r;)s-=r,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function Zc(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=Zc(n);return At({prefix:e,name:t,encode(i){return Wc(i,n,r)},decode(i){return Yc(i,o,r,t)}})}var G=at({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Xc=at({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var xn={};he(xn,{base32:()=>ut,base32hex:()=>ta,base32hexpad:()=>na,base32hexpadupper:()=>oa,base32hexupper:()=>ra,base32pad:()=>Jc,base32padupper:()=>ea,base32upper:()=>Qc,base32z:()=>ia});var ut=$({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Qc=$({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Jc=$({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ea=$({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ta=$({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ra=$({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),na=$({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),oa=$({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ia=$({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var bn={};he(bn,{base36:()=>Vt,base36upper:()=>sa});var Vt=at({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),sa=at({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ca=Ii,bi=128,aa=127,ua=~aa,da=Math.pow(2,31);function Ii(t,e,r){e=e||[],r=r||0;for(var n=r;t>=da;)e[r++]=t&255|bi,t/=128;for(;t&ua;)e[r++]=t&255|bi,t>>>=7;return e[r]=t|0,Ii.bytes=r-n+1,e}var la=En,ha=128,Ei=127;function En(t,n){var r=0,n=n||0,o=0,i=n,s,a=t.length;do{if(i>=a)throw En.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&Ei)<<o:(s&Ei)*Math.pow(2,o),o+=7}while(s>=ha);return En.bytes=i-n,r}var pa=Math.pow(2,7),fa=Math.pow(2,14),ga=Math.pow(2,21),ma=Math.pow(2,28),ya=Math.pow(2,35),wa=Math.pow(2,42),xa=Math.pow(2,49),ba=Math.pow(2,56),Ea=Math.pow(2,63),Ia=function(t){return t<pa?1:t<fa?2:t<ga?3:t<ma?4:t<ya?5:t<wa?6:t<xa?7:t<ba?8:t<Ea?9:10},va={encode:ca,decode:la,encodingLength:Ia},Sa=va,zt=Sa;function $t(t,e=0){return[zt.decode(t,e),zt.decode.bytes]}function Bt(t,e,r=0){return zt.encode(t,e,r),e}function Ct(t){return zt.encodingLength(t)}function Dt(t,e){let r=e.byteLength,n=Ct(t),o=n+Ct(r),i=new Uint8Array(o+r);return Bt(t,i,0),Bt(r,i,n),i.set(e,o),new Lt(t,r,e,i)}function jt(t){let e=ve(t),[r,n]=$t(e),[o,i]=$t(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Lt(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&&fi(t.bytes,r.bytes)}}var Lt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function Si(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return Ba(r,In(t),e??G.encoder);default:return Ca(r,In(t),e??ut.encoder)}}var Ai=new WeakMap;function In(t){let e=Ai.get(t);if(e==null){let r=new Map;return Ai.set(t,r),r}return e}var J=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!==Gt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==La)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=Dt(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 Si(this,e)}toJSON(){return{"/":Si(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??Bi(n,o,i.bytes))}else if(r[Da]===!0){let{version:n,multihash:o,code:i}=r,s=jt(o);return t.create(n,i,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==Gt)throw new Error(`Version 0 CID must use dag-pb (code: ${Gt}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Bi(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Gt,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=ve(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 Lt(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[d,h]=$t(e.subarray(r));return r+=h,d},o=n(),i=Gt;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),u=r+c,f=u-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:f,size:u}}static parse(e,r){let[n,o]=Aa(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 In(i).set(n,e),i}};function Aa(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 ut.prefix:{let r=e??ut;return[ut.prefix,r.decode(t)]}case Vt.prefix:{let r=e??Vt;return[Vt.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 Ba(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 Ca(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 Gt=112,La=18;function Bi(t,e,r){let n=Ct(t),o=n+Ct(e),i=new Uint8Array(o+r.byteLength);return Bt(t,i,0),Bt(e,i,n),i.set(r,o),i}var Da=Symbol.for("@ipld/js-cid/CID");var vn={};he(vn,{identity:()=>Ce});var Ci=0,Ua="identity",Li=ve;function Oa(t,e){if(e?.truncate!=null&&e.truncate!==t.byteLength){if(e.truncate<0||e.truncate>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e.truncate)}return Dt(Ci,Li(t))}var Ce={code:Ci,name:Ua,encode:Li,digest:Oa};function me(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 Sn=le("node:buffer");function gt(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function tt(t=0){return gt(Sn.Buffer.alloc(t))}function Le(t=0){return gt(Sn.Buffer.allocUnsafe(t))}var Di=le("node:buffer");function qe(t,e){return gt(Di.Buffer.concat(t,e))}var Oi=Symbol.for("@achingbrain/uint8arraylist");function Ui(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 Sr(t){return!!t?.[Oi]}var ye=class t{bufs;length;[Oi]=!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(Sr(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(Sr(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=Ui(this.bufs,e);return r.buf[r.index]}set(e,r){let n=Ui(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(Sr(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 qe(n,o)}subarray(e,r){let{bufs:n,length:o}=this._subList(e,r);return n.length===1?n[0]:qe(n,o)}sublist(e,r){let{bufs:n,length:o}=this._subList(e,r),i=new t;return i.length=o,i.bufs=[...n],i}_subList(e,r){if(e=e??0,r=r??this.length,e<0&&(e=this.length+e),r<0&&(r=this.length+r),e<0||r>this.length)throw new RangeError("index is out of bounds");if(e===r)return{bufs:[],length:0};if(e===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,e>=c)continue;let u=e>=a&&e<c,f=r>a&&r<=c;if(u&&f){if(e===a&&r===c){n.push(s);break}let d=e-a;n.push(s.subarray(d,d+(r-e)));break}if(u){if(e===0){n.push(s);continue}n.push(s.subarray(e-a));continue}if(f){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!Sr(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 a=s,c=this.byteLength-n.byteLength,u=n.byteLength-1,f;for(let d=r;d<=c;d+=f){f=0;for(let h=u;h>=0;h--){let p=this.get(d+h);if(n[h]!==p){f=Math.max(1,h-a[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=Le(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,e)}getInt16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(e,r,n){let o=tt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,e)}getInt32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(e,r,n){let o=tt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,e)}getBigInt64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(e,r,n){let o=tt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,e)}getUint8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(e,r){let n=Le(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,e)}getUint16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(e,r,n){let o=tt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,e)}getUint32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(e,r,n){let o=tt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,e)}getBigUint64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(e,r,n){let o=tt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,e)}getFloat32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(e,r,n){let o=tt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,e)}getFloat64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(e,r,n){let o=tt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof t)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!me(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 Ki=le("node:buffer");var An={};he(An,{base10:()=>Ta});var Ta=at({prefix:"9",name:"base10",alphabet:"0123456789"});var Bn={};he(Bn,{base16:()=>_a,base16upper:()=>Pa});var _a=$({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Pa=$({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Cn={};he(Cn,{base2:()=>Na});var Na=$({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ln={};he(Ln,{base256emoji:()=>Fa});var Ti=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}"),Ra=Ti.reduce((t,e,r)=>(t[r]=e,t),[]),Ka=Ti.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function ka(t){return t.reduce((e,r)=>(e+=Ra[r],e),"")}function Ma(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Ka[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Fa=At({prefix:"\u{1F680}",name:"base256emoji",encode:ka,decode:Ma});var Un={};he(Un,{base64:()=>Ha,base64pad:()=>qa,base64url:()=>Dn,base64urlpad:()=>Va});var Ha=$({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qa=$({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Dn=$({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Va=$({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var On={};he(On,{base8:()=>za});var za=$({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Tn={};he(Tn,{identity:()=>$a});var $a=At({prefix:"\0",name:"identity",encode:t=>mi(t),decode:t=>gi(t)});var Ch=new TextEncoder,Lh=new TextDecoder;var Kn={};he(Kn,{sha256:()=>Rn,sha512:()=>Wa});var Nn=Ft(le("crypto"),1);var Ya=20;function Pn({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new _n(t,e,r,n,o)}var _n=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,i){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Ya,this.maxDigestLength=i}digest(e,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?_i(n,this.code,r?.truncate):n.then(o=>_i(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function _i(t,e,r){if(r!=null&&r!==t.byteLength){if(r>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,r)}return Dt(e,t)}var Rn=Pn({name:"sha2-256",code:18,encode:t=>ve(Nn.default.createHash("sha256").update(t).digest())}),Wa=Pn({name:"sha2-512",code:19,encode:t=>ve(Nn.default.createHash("sha512").update(t).digest())});var Yt={...Tn,...Cn,...On,...An,...Bn,...xn,...bn,...wn,...Un,...Ln},Hh={...Kn,...vn};function Ri(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var Ni=Ri("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),kn=Ri("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Le(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Za={utf8:Ni,"utf-8":Ni,hex:Yt.base16,latin1:kn,ascii:kn,binary:kn,...Yt},Ar=Za;function de(t,e="utf8"){let r=Ar[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?gt(Ki.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var ki=le("node:buffer");function j(t,e="utf8"){let r=Ar[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?ki.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var Xa=parseInt("11111",2),Mn=parseInt("10000000",2),Qa=parseInt("01111111",2),Mi={0:Wt,1:Wt,2:Ja,3:ru,4:nu,5:tu,6:eu,16:Wt,22:Wt,48:Wt};function Fn(t,e={offset:0}){let r=t[e.offset]&Xa;if(e.offset++,Mi[r]!=null)return Mi[r](t,e);throw new Error("No decoder for tag "+r)}function Zt(t,e){let r=0;if((t[e.offset]&Mn)===Mn){let n=t[e.offset]&Qa,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 Wt(t,e){Zt(t,e);let r=[];for(;!(e.offset>=t.byteLength);){let n=Fn(t,e);if(n===null)break;r.push(n)}return r}function Ja(t,e){let r=Zt(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 eu(t,e){let r=Zt(t,e),n=e.offset+r,o=t[e.offset];e.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,c=[];for(;e.offset<n;){let u=t[e.offset];if(e.offset++,c.push(u&127),u<128){c.reverse();let f=0;for(let d=0;d<c.length;d++)f+=c[d]<<d*7;a+=`.${f}`,c=[]}}return a}function tu(t,e){return e.offset++,null}function ru(t,e){let r=Zt(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 nu(t,e){let r=Zt(t,e),n=t.subarray(e.offset,e.offset+r);return e.offset+=r,n}function ou(t){let e=t.toString(16);e.length%2===1&&(e="0"+e);let r=new ye;for(let n=0;n<e.length;n+=2)r.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return r}function Hn(t){if(t.byteLength<128)return Uint8Array.from([t.byteLength]);let e=ou(t.byteLength);return new ye(Uint8Array.from([e.byteLength|Mn]),e)}function Fi(t){let e=new ye,r=128;return(t.subarray()[0]&r)===r&&e.append(Uint8Array.from([0])),e.append(t),new ye(Uint8Array.from([2]),Hn(e),e)}function Hi(t){let e=Uint8Array.from([0]),r=new ye(e,t);return new ye(Uint8Array.from([3]),Hn(r),r)}function Br(t,e=48){let r=new ye;for(let n of t)r.append(n);return new ye(Uint8Array.from([e]),Hn(r),r)}async function qi(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 iu=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),su=Uint8Array.from([6,5,43,129,4,0,34]),cu=Uint8Array.from([6,5,43,129,4,0,35]),au={ext:!0,kty:"EC",crv:"P-256"},uu={ext:!0,kty:"EC",crv:"P-384"},du={ext:!0,kty:"EC",crv:"P-521"},qn=32,Vn=48,zn=66;function Vi(t){let e=Fn(t);return zi(e)}function zi(t){let e=t[1][1][0],r=1,n,o;if(e.byteLength===qn*2+1)return n=j(e.subarray(r,r+qn),"base64url"),o=j(e.subarray(r+qn),"base64url"),new Ot({...au,key_ops:["verify"],x:n,y:o});if(e.byteLength===Vn*2+1)return n=j(e.subarray(r,r+Vn),"base64url"),o=j(e.subarray(r+Vn),"base64url"),new Ot({...uu,key_ops:["verify"],x:n,y:o});if(e.byteLength===zn*2+1)return n=j(e.subarray(r,r+zn),"base64url"),o=j(e.subarray(r+zn),"base64url"),new Ot({...du,key_ops:["verify"],x:n,y:o});throw new Ie(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function $i(t){return Br([Fi(Uint8Array.from([1])),Br([lu(t.crv)],160),Br([Hi(new ye(Uint8Array.from([4]),de(t.x??"","base64url"),de(t.y??"","base64url")))],161)]).subarray()}function lu(t){if(t==="P-256")return iu;if(t==="P-384")return su;if(t==="P-521")return cu;throw new Ie(`Invalid curve ${t}`)}var Ot=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=$i(this.jwk)),this._raw}toMultihash(){return Ce.digest(Tt(this))}toCID(){return J.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}async verify(e,r,n){return qi(this.jwk,r,e,n)}};var Cr=Ft(le("crypto"),1);var I0=Cr.default.generateKeyPairSync,Xt=32;var hu=64;function ji(t,e,r){if(t.byteLength!==Xt)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!==hu)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=Cr.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:j(t,"base64url"),kty:"OKP"}});return Cr.default.verify(null,r instanceof Uint8Array?r:r.subarray(),n,e)}function Yi(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}var Lr=class{type="Ed25519";raw;constructor(e){this.raw=$n(e,Xt)}toMultihash(){return Ce.digest(Tt(this))}toCID(){return J.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}verify(e,r,n){n?.signal?.throwIfAborted();let o=ji(this.raw,r,e);return Yi(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function Wi(t){return t=$n(t,Xt),new Lr(t)}function $n(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new Ie(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}var fu=Math.pow(2,7),gu=Math.pow(2,14),mu=Math.pow(2,21),jn=Math.pow(2,28),Gn=Math.pow(2,35),Yn=Math.pow(2,42),Wn=Math.pow(2,49),q=128,re=127;function Ve(t){if(t<fu)return 1;if(t<gu)return 2;if(t<mu)return 3;if(t<jn)return 4;if(t<Gn)return 5;if(t<Yn)return 6;if(t<Wn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Qt(t,e,r=0){switch(Ve(t)){case 8:e[r++]=t&255|q,t/=128;case 7:e[r++]=t&255|q,t/=128;case 6:e[r++]=t&255|q,t/=128;case 5:e[r++]=t&255|q,t/=128;case 4:e[r++]=t&255|q,t>>>=7;case 3:e[r++]=t&255|q,t>>>=7;case 2:e[r++]=t&255|q,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function Zn(t,e){let r=t[e],n=0;if(n+=r&re,r<q||(r=t[e+1],n+=(r&re)<<7,r<q)||(r=t[e+2],n+=(r&re)<<14,r<q)||(r=t[e+3],n+=(r&re)<<21,r<q)||(r=t[e+4],n+=(r&re)*jn,r<q)||(r=t[e+5],n+=(r&re)*Gn,r<q)||(r=t[e+6],n+=(r&re)*Yn,r<q)||(r=t[e+7],n+=(r&re)*Wn,r<q))return n;throw new RangeError("Could not decode varint")}function yu(t,e){let r=t.get(e),n=0;if(n+=r&re,r<q||(r=t.get(e+1),n+=(r&re)<<7,r<q)||(r=t.get(e+2),n+=(r&re)<<14,r<q)||(r=t.get(e+3),n+=(r&re)<<21,r<q)||(r=t.get(e+4),n+=(r&re)*jn,r<q)||(r=t.get(e+5),n+=(r&re)*Gn,r<q)||(r=t.get(e+6),n+=(r&re)*Yn,r<q)||(r=t.get(e+7),n+=(r&re)*Wn,r<q))return n;throw new RangeError("Could not decode varint")}function Xn(t,e=0){return t instanceof Uint8Array?Zn(t,e):yu(t,e)}var Qn=new Float32Array([-0]),dt=new Uint8Array(Qn.buffer);function Zi(t,e,r){Qn[0]=t,e[r]=dt[0],e[r+1]=dt[1],e[r+2]=dt[2],e[r+3]=dt[3]}function Xi(t,e){return dt[0]=t[e],dt[1]=t[e+1],dt[2]=t[e+2],dt[3]=t[e+3],Qn[0]}var Jn=new Float64Array([-0]),ne=new Uint8Array(Jn.buffer);function Qi(t,e,r){Jn[0]=t,e[r]=ne[0],e[r+1]=ne[1],e[r+2]=ne[2],e[r+3]=ne[3],e[r+4]=ne[4],e[r+5]=ne[5],e[r+6]=ne[6],e[r+7]=ne[7]}function Ji(t,e){return ne[0]=t[e],ne[1]=t[e+1],ne[2]=t[e+2],ne[3]=t[e+3],ne[4]=t[e+4],ne[5]=t[e+5],ne[6]=t[e+6],ne[7]=t[e+7],Jn[0]}var xu=BigInt(Number.MAX_SAFE_INTEGER),bu=BigInt(Number.MIN_SAFE_INTEGER),we=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 mt;if(e<xu&&e>bu)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>es&&(o=0n,++n>es&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return mt;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):mt}},mt=new we(0,0);mt.toBigInt=function(){return 0n};mt.zzEncode=mt.zzDecode=function(){return this};mt.length=function(){return 1};var es=4294967296n;function ts(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 rs(t,e,r){if(r-e<1)return"";let o,i=[],s=0,a;for(;e<r;)a=t[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function eo(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 Dr(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var to=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 Dr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw De(this,4);return Dr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw De(this,4);let e=Xi(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw De(this,4);let e=Ji(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 rs(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 we(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=Dr(this.buf,this.pos+=4),r=Dr(this.buf,this.pos+=4);return new we(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=Zn(this.buf,this.pos);return this.pos+=Ve(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 ro(t){return new to(t instanceof Uint8Array?t:t.subarray())}function Ur(t,e,r){let n=ro(t);return e.decode(n,void 0,r)}function no(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return Le(s);o+s>e&&(n=Le(e),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var yt=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function oo(){}var so=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Eu=no();function Iu(t){return globalThis.Buffer!=null?Le(t):Eu(t)}var er=class{len;head;tail;states;constructor(){this.len=0,this.head=new yt(oo,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new yt(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new co((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(Or,10,we.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=we.fromBigInt(e);return this._push(Or,r.length(),r)}uint64Number(e){return this._push(Qt,Ve(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=we.fromBigInt(e).zzEncode();return this._push(Or,r.length(),r)}sint64Number(e){let r=we.fromNumber(e).zzEncode();return this._push(Or,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(Jt,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=we.fromBigInt(e);return this._push(Jt,4,r.lo)._push(Jt,4,r.hi)}fixed64Number(e){let r=we.fromNumber(e);return this._push(Jt,4,r.lo)._push(Jt,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(Zi,4,e)}double(e){return this._push(Qi,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(io,1,0):this.uint32(r)._push(Su,r,e)}string(e){let r=ts(e);return r!==0?this.uint32(r)._push(eo,r,e):this._push(io,1,0)}fork(){return this.states=new so(this),this.head=this.tail=new yt(oo,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new yt(oo,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=Iu(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 vu(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var co=class extends yt{next;constructor(e,r){super(vu,e,r),this.next=void 0}};function Or(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 Jt(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 Su(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(er.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(Au,e,t),this},er.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(Bu,e,t),this});function Au(t,e,r){e.set(t,r)}function Bu(t,e,r){t.length<40?eo(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(de(t),r)}function ao(){return new er}function Tr(t,e){let r=ao();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var _t;(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"})(_t||(_t={}));function _r(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function uo(t){function e(o){if(t[o.toString()]==null)throw new Error("Invalid enum value");return t[o]}let r=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return _r("enum",_t.VARINT,r,n)}function Pr(t,e){return _r("message",_t.LENGTH_DELIMITED,t,e)}var xe;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.ECDSA="ECDSA"})(xe||(xe={}));var lo;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1",t[t.ECDSA=3]="ECDSA"})(lo||(lo={}));(function(t){t.codec=()=>uo(lo)})(xe||(xe={}));var tr;(function(t){let e;t.codec=()=>(e==null&&(e=Pr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),xe.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=xe.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Tr(r,t.codec()),t.decode=(r,n)=>Ur(r,t.codec(),n)})(tr||(tr={}));var ho;(function(t){let e;t.codec=()=>(e==null&&(e=Pr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),xe.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=xe.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Tr(r,t.codec()),t.decode=(r,n)=>Ur(r,t.codec(),n)})(ho||(ho={}));function rr(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ze(t,e=""){if(!Number.isSafeInteger(t)||t<0){let r=e&&`"${e}" `;throw new Error(`${r}expected integer >= 0, got ${t}`)}}function M(t,e,r=""){let n=rr(t),o=t?.length,i=e!==void 0;if(!n||i&&o!==e){let s=r&&`"${r}" `,a=i?` of length ${e}`:"",c=n?`length=${o}`:`type=${typeof t}`;throw new Error(s+"expected Uint8Array"+a+", got "+c)}return t}function Nr(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash must wrapped by utils.createHasher");ze(t.outputLen),ze(t.blockLen)}function Pt(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 is(t,e){M(t,void 0,"digestInto() output");let r=e.outputLen;if(t.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function wt(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Rr(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ue(t,e){return t<<32-e|t>>>e}var ss=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Lu=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function xt(t){if(M(t),ss)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=Lu[t[r]];return e}var rt={_0:48,_9:57,A:65,F:70,a:97,f:102};function os(t){if(t>=rt._0&&t<=rt._9)return t-rt._0;if(t>=rt.A&&t<=rt.F)return t-(rt.A-10);if(t>=rt.a&&t<=rt.f)return t-(rt.a-10)}function bt(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=os(t.charCodeAt(i)),a=os(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function Oe(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];M(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}function cs(t,e={}){let r=(o,i)=>t(i).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function Kr(t=32){let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(t))}var as=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function us(t,e,r){return t&e^~t&r}function ds(t,e,r){return t&e^t&r^e&r}var kr=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,r,n,o){this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Rr(this.buffer)}update(e){Pt(this),M(e);let{view:r,buffer:n,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Rr(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Pt(this),is(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,wt(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let d=s;d<o;d++)r[d]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let a=Rr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<u;d++)a.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||=new this.constructor,e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=a,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},nt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Du=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),lt=new Uint32Array(64),po=class extends kr{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,r,n,o,i,s,a,c]}set(e,r,n,o,i,s,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,r){for(let d=0;d<16;d++,r+=4)lt[d]=e.getUint32(r,!1);for(let d=16;d<64;d++){let h=lt[d-15],p=lt[d-2],l=Ue(h,7)^Ue(h,18)^h>>>3,m=Ue(p,17)^Ue(p,19)^p>>>10;lt[d]=m+lt[d-7]+l+lt[d-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:u,H:f}=this;for(let d=0;d<64;d++){let h=Ue(a,6)^Ue(a,11)^Ue(a,25),p=f+h+us(a,c,u)+Du[d]+lt[d]|0,m=(Ue(n,2)^Ue(n,13)^Ue(n,22))+ds(n,o,i)|0;f=u,u=c,c=a,a=s+p|0,s=i,i=o,o=n,n=p+m|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(n,o,i,s,a,c,u,f)}roundClean(){wt(lt)}destroy(){this.set(0,0,0,0,0,0,0,0),wt(this.buffer)}},fo=class extends po{A=nt[0]|0;B=nt[1]|0;C=nt[2]|0;D=nt[3]|0;E=nt[4]|0;F=nt[5]|0;G=nt[6]|0;H=nt[7]|0;constructor(){super(32)}};var ls=cs(()=>new fo,as(1));var Hs=Ft(le("node:crypto"),1);var mo=BigInt(0),go=BigInt(1);function nr(t,e=""){if(typeof t!="boolean"){let r=e&&`"${e}" `;throw new Error(r+"expected boolean, got type="+typeof t)}return t}function hs(t){if(typeof t=="bigint"){if(!Mr(t))throw new Error("positive bigint expected, got "+t)}else ze(t);return t}function or(t){let e=hs(t).toString(16);return e.length&1?"0"+e:e}function ps(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?mo:BigInt("0x"+t)}function Nt(t){return ps(xt(t))}function yo(t){return ps(xt(Uu(M(t)).reverse()))}function Fr(t,e){ze(e),t=hs(t);let r=bt(t.toString(16).padStart(e*2,"0"));if(r.length!==e)throw new Error("number too large");return r}function wo(t,e){return Fr(t,e).reverse()}function Uu(t){return Uint8Array.from(t)}var Mr=t=>typeof t=="bigint"&&mo<=t;function Ou(t,e,r){return Mr(t)&&Mr(e)&&Mr(r)&&e<=t&&t<r}function fs(t,e,r,n){if(!Ou(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function xo(t){let e;for(e=0;t>mo;t>>=go,e+=1);return e}var ir=t=>(go<<BigInt(t))-go;function gs(t,e,r){if(ze(t,"hashLen"),ze(e,"qByteLen"),typeof r!="function")throw new Error("hmacFn must be a function");let n=b=>new Uint8Array(b),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=n(t),u=n(t),f=0,d=()=>{c.fill(1),u.fill(0),f=0},h=(...b)=>r(u,Oe(c,...b)),p=(b=o)=>{u=h(i,b),c=h(),b.length!==0&&(u=h(s,b),c=h())},l=()=>{if(f++>=a)throw new Error("drbg: tried max amount of iterations");let b=0,L=[];for(;b<e;){c=h();let T=c.slice();L.push(T),b+=c.length}return Oe(...L)};return(b,L)=>{d(),p(b);let T;for(;!(T=L(l()));)p();return d(),T}}function sr(t,e={},r={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function n(i,s,a){let c=t[i];if(a&&c===void 0)return;let u=typeof c;if(u!==s||c===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${u}`)}let o=(i,s)=>Object.entries(i).forEach(([a,c])=>n(a,c,s));o(e,!1),o(r,!0)}function bo(t){let e=new WeakMap;return(r,...n)=>{let o=e.get(r);if(o!==void 0)return o;let i=t(r,...n);return e.set(r,i),i}}var ae=BigInt(0),oe=BigInt(1),Et=BigInt(2),ws=BigInt(3),xs=BigInt(4),bs=BigInt(5),Tu=BigInt(7),Es=BigInt(8),_u=BigInt(9),Is=BigInt(16);function Te(t,e){let r=t%e;return r>=ae?r:e+r}function be(t,e,r){let n=t;for(;e-- >ae;)n*=n,n%=r;return n}function ms(t,e){if(t===ae)throw new Error("invert: expected non-zero number");if(e<=ae)throw new Error("invert: expected positive modulus, got "+e);let r=Te(t,e),n=e,o=ae,i=oe,s=oe,a=ae;for(;r!==ae;){let u=n/r,f=n%r,d=o-s*u,h=i-a*u;n=r,r=f,o=s,i=a,s=d,a=h}if(n!==oe)throw new Error("invert: does not exist");return Te(o,e)}function Io(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function vs(t,e){let r=(t.ORDER+oe)/xs,n=t.pow(e,r);return Io(t,n,e),n}function Pu(t,e){let r=(t.ORDER-bs)/Es,n=t.mul(e,Et),o=t.pow(n,r),i=t.mul(e,o),s=t.mul(t.mul(i,Et),o),a=t.mul(i,t.sub(s,t.ONE));return Io(t,a,e),a}function Nu(t){let e=Rt(t),r=Ss(t),n=r(e,e.neg(e.ONE)),o=r(e,n),i=r(e,e.neg(n)),s=(t+Tu)/Is;return(a,c)=>{let u=a.pow(c,s),f=a.mul(u,n),d=a.mul(u,o),h=a.mul(u,i),p=a.eql(a.sqr(f),c),l=a.eql(a.sqr(d),c);u=a.cmov(u,f,p),f=a.cmov(h,d,l);let m=a.eql(a.sqr(f),c),b=a.cmov(u,f,m);return Io(a,b,c),b}}function Ss(t){if(t<ws)throw new Error("sqrt is not defined for small field");let e=t-oe,r=0;for(;e%Et===ae;)e/=Et,r++;let n=Et,o=Rt(t);for(;ys(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return vs;let i=o.pow(n,e),s=(e+oe)/Et;return function(c,u){if(c.is0(u))return u;if(ys(c,u)!==1)throw new Error("Cannot find square root");let f=r,d=c.mul(c.ONE,i),h=c.pow(u,e),p=c.pow(u,s);for(;!c.eql(h,c.ONE);){if(c.is0(h))return c.ZERO;let l=1,m=c.sqr(h);for(;!c.eql(m,c.ONE);)if(l++,m=c.sqr(m),l===f)throw new Error("Cannot find square root");let b=oe<<BigInt(f-l-1),L=c.pow(d,b);f=l,d=c.sqr(L),h=c.mul(h,d),p=c.mul(p,L)}return p}}function Ru(t){return t%xs===ws?vs:t%Es===bs?Pu:t%Is===_u?Nu(t):Ss(t)}var Ku=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function vo(t){let e={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Ku.reduce((n,o)=>(n[o]="function",n),e);return sr(t,r),t}function ku(t,e,r){if(r<ae)throw new Error("invalid exponent, negatives unsupported");if(r===ae)return t.ONE;if(r===oe)return e;let n=t.ONE,o=e;for(;r>ae;)r&oe&&(n=t.mul(n,o)),o=t.sqr(o),r>>=oe;return n}function Hr(t,e,r=!1){let n=new Array(e.length).fill(r?t.ZERO:void 0),o=e.reduce((s,a,c)=>t.is0(a)?s:(n[c]=s,t.mul(s,a)),t.ONE),i=t.inv(o);return e.reduceRight((s,a,c)=>t.is0(a)?s:(n[c]=t.mul(s,n[c]),t.mul(s,a)),i),n}function ys(t,e){let r=(t.ORDER-oe)/Et,n=t.pow(e,r),o=t.eql(n,t.ONE),i=t.eql(n,t.ZERO),s=t.eql(n,t.neg(t.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function Mu(t,e){e!==void 0&&ze(e);let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var Eo=class{ORDER;BITS;BYTES;isLE;ZERO=ae;ONE=oe;_lengths;_sqrt;_mod;constructor(e,r={}){if(e<=ae)throw new Error("invalid field: expected ORDER > 0, got "+e);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:i}=Mu(e,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=i,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return Te(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof e);return ae<=e&&e<this.ORDER}is0(e){return e===ae}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&oe)===oe}neg(e){return Te(-e,this.ORDER)}eql(e,r){return e===r}sqr(e){return Te(e*e,this.ORDER)}add(e,r){return Te(e+r,this.ORDER)}sub(e,r){return Te(e-r,this.ORDER)}mul(e,r){return Te(e*r,this.ORDER)}pow(e,r){return ku(this,e,r)}div(e,r){return Te(e*ms(r,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,r){return e+r}subN(e,r){return e-r}mulN(e,r){return e*r}inv(e){return ms(e,this.ORDER)}sqrt(e){return this._sqrt||(this._sqrt=Ru(this.ORDER)),this._sqrt(this,e)}toBytes(e){return this.isLE?wo(e,this.BYTES):Fr(e,this.BYTES)}fromBytes(e,r=!1){M(e);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:a}=this;if(n){if(!n.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);let u=new Uint8Array(o);u.set(e,i?0:u.length-e.length),e=u}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let c=i?yo(e):Nt(e);if(a&&(c=Te(c,s)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(e){return Hr(this,e)}cmov(e,r,n){return n?r:e}};function Rt(t,e={}){return new Eo(t,e)}function As(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 So(t){let e=As(t);return e+Math.ceil(e/2)}function Ao(t,e,r=!1){M(t);let n=t.length,o=As(e),i=So(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?yo(t):Nt(t),a=Te(s,e-oe)+oe;return r?wo(a,o):Fr(a,o)}var Kt=BigInt(0),It=BigInt(1);function cr(t,e){let r=e.negate();return t?r:e}function Do(t,e){let r=Hr(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function Ds(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Bo(t,e){Ds(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1),o=2**t,i=ir(t),s=BigInt(t);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Bs(t,e,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,a=Number(t&o),c=t>>s;a>n&&(a-=i,c+=It);let u=e*n,f=u+Math.abs(a)-1,d=a===0,h=a<0,p=e%2!==0;return{nextN:c,offset:f,isZero:d,isNeg:h,isNegF:p,offsetF:u}}var Co=new WeakMap,Us=new WeakMap;function Lo(t){return Us.get(t)||1}function Cs(t){if(t!==Kt)throw new Error("invalid wNAF")}var qr=class{BASE;ZERO;Fn;bits;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>Kt;)r&It&&(n=n.add(o)),o=o.double(),r>>=It;return n}precomputeWindow(e,r){let{windows:n,windowSize:o}=Bo(r,this.bits),i=[],s=e,a=s;for(let c=0;c<n;c++){a=s,i.push(a);for(let u=1;u<o;u++)a=a.add(s),i.push(a);s=a.double()}return i}wNAF(e,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=Bo(e,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:u,isZero:f,isNeg:d,isNegF:h,offsetF:p}=Bs(n,a,s);n=c,f?i=i.add(cr(h,r[p])):o=o.add(cr(d,r[u]))}return Cs(n),{p:o,f:i}}wNAFUnsafe(e,r,n,o=this.ZERO){let i=Bo(e,this.bits);for(let s=0;s<i.windows&&n!==Kt;s++){let{nextN:a,offset:c,isZero:u,isNeg:f}=Bs(n,s,i);if(n=a,!u){let d=r[c];o=o.add(f?d.negate():d)}}return Cs(n),o}getPrecomputes(e,r,n){let o=Co.get(r);return o||(o=this.precomputeWindow(r,e),e!==1&&(typeof n=="function"&&(o=n(o)),Co.set(r,o))),o}cached(e,r,n){let o=Lo(e);return this.wNAF(o,this.getPrecomputes(o,e,n),r)}unsafe(e,r,n,o){let i=Lo(e);return i===1?this._unsafeLadder(e,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),r,o)}createCache(e,r){Ds(r,this.bits),Us.set(e,r),Co.delete(e)}hasCache(e){return Lo(e)!==1}};function Os(t,e,r,n){let o=e,i=t.ZERO,s=t.ZERO;for(;r>Kt||n>Kt;)r&It&&(i=i.add(o)),n&It&&(s=s.add(o)),o=o.double(),r>>=It,n>>=It;return{p1:i,p2:s}}function Ls(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return vo(e),e}else return Rt(t,{isLE:r})}function Ts(t,e,r={},n){if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(let c of["p","n","h"]){let u=e[c];if(!(typeof u=="bigint"&&u>Kt))throw new Error(`CURVE.${c} must be positive bigint`)}let o=Ls(e.p,r.Fp,n),i=Ls(e.n,r.Fn,n),a=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:i}}function _s(t,e){return function(n){let o=t(n);return{secretKey:o,publicKey:e(o)}}}var Vr=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,r){if(Nr(e),M(r,void 0,"key"),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 n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),wt(o)}update(e){return Pt(this),this.iHash.update(e),this}digestInto(e){Pt(this),M(e,this.outputLen,"output"),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||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Uo=(t,e,r)=>new Vr(t,e).update(r).digest();Uo.create=(t,e)=>new Vr(t,e);var Ps=(t,e)=>(t+(t>=0?e:-e)/Ns)/e;function Fu(t,e,r){let[[n,o],[i,s]]=e,a=Ps(s*t,r),c=Ps(-o*t,r),u=t-a*n-c*i,f=-a*o-c*s,d=u<ot,h=f<ot;d&&(u=-u),h&&(f=-f);let p=ir(Math.ceil(xo(r)/2))+kt;if(u<ot||u>=p||f<ot||f>=p)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:d,k1:u,k2neg:h,k2:f}}function To(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Oo(t,e){let r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return nr(r.lowS,"lowS"),nr(r.prehash,"prehash"),r.format!==void 0&&To(r.format),r}var _o=class extends Error{constructor(e=""){super(e)}},ht={Err:_o,_tlv:{encode:(t,e)=>{let{Err:r}=ht;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=or(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?or(o.length/2|128):"";return or(t)+i+o+e},decode(t,e){let{Err:r}=ht,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let u=e.subarray(n,n+c);if(u.length!==c)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+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=ht;if(t<ot)throw new e("integer: negative integers are not allowed");let r=or(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}=ht;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 Nt(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=ht,o=M(t,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:u,l:f}=n.decode(2,c);if(f.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(t){let{_tlv:e,_int:r}=ht,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}},ot=BigInt(0),kt=BigInt(1),Ns=BigInt(2),zr=BigInt(3),Hu=BigInt(4);function Rs(t,e={}){let r=Ts("weierstrass",t,e),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s,n:a}=i;sr(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=e;if(c&&(!n.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let u=ks(n,o);function f(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function d(R,w,y){let{x:g,y:E}=w.toAffine(),A=n.toBytes(g);if(nr(y,"isCompressed"),y){f();let C=!n.isOdd(E);return Oe(Ks(C),A)}else return Oe(Uint8Array.of(4),A,n.toBytes(E))}function h(R){M(R,void 0,"Point");let{publicKey:w,publicKeyUncompressed:y}=u,g=R.length,E=R[0],A=R.subarray(1);if(g===w&&(E===2||E===3)){let C=n.fromBytes(A);if(!n.isValid(C))throw new Error("bad point: is not on curve, wrong x");let B=m(C),S;try{S=n.sqrt(B)}catch(Y){let H=Y instanceof Error?": "+Y.message:"";throw new Error("bad point: is not on curve, sqrt error"+H)}f();let D=n.isOdd(S);return(E&1)===1!==D&&(S=n.neg(S)),{x:C,y:S}}else if(g===y&&E===4){let C=n.BYTES,B=n.fromBytes(A.subarray(0,C)),S=n.fromBytes(A.subarray(C,C*2));if(!b(B,S))throw new Error("bad point: is not on curve");return{x:B,y:S}}else throw new Error(`bad point: got length ${g}, expected compressed=${w} or uncompressed=${y}`)}let p=e.toBytes||d,l=e.fromBytes||h;function m(R){let w=n.sqr(R),y=n.mul(w,R);return n.add(n.add(y,n.mul(R,i.a)),i.b)}function b(R,w){let y=n.sqr(w),g=m(R);return n.eql(y,g)}if(!b(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let L=n.mul(n.pow(i.a,zr),Hu),T=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(L,T)))throw new Error("bad curve params: a or b");function F(R,w,y=!1){if(!n.isValid(w)||y&&n.is0(w))throw new Error(`bad point coordinate ${R}`);return w}function P(R){if(!(R instanceof _))throw new Error("Weierstrass Point expected")}function K(R){if(!c||!c.basises)throw new Error("no endo");return Fu(R,c.basises,o.ORDER)}let k=bo((R,w)=>{let{X:y,Y:g,Z:E}=R;if(n.eql(E,n.ONE))return{x:y,y:g};let A=R.is0();w==null&&(w=A?n.ONE:n.inv(E));let C=n.mul(y,w),B=n.mul(g,w),S=n.mul(E,w);if(A)return{x:n.ZERO,y:n.ZERO};if(!n.eql(S,n.ONE))throw new Error("invZ was invalid");return{x:C,y:B}}),ie=bo(R=>{if(R.is0()){if(e.allowInfinityPoint&&!n.is0(R.Y))return;throw new Error("bad point: ZERO")}let{x:w,y}=R.toAffine();if(!n.isValid(w)||!n.isValid(y))throw new Error("bad point: x or y not field elements");if(!b(w,y))throw new Error("bad point: equation left != right");if(!R.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function se(R,w,y,g,E){return y=new _(n.mul(y.X,R),y.Y,y.Z),w=cr(g,w),y=cr(E,y),w.add(y)}class _{static BASE=new _(i.Gx,i.Gy,n.ONE);static ZERO=new _(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(w,y,g){this.X=F("x",w),this.Y=F("y",y,!0),this.Z=F("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 _)throw new Error("projective point not allowed");return n.is0(y)&&n.is0(g)?_.ZERO:new _(y,g,n.ONE)}static fromBytes(w){let y=_.fromAffine(l(M(w,void 0,"point")));return y.assertValidity(),y}static fromHex(w){return _.fromBytes(bt(w))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,y=!0){return pt.createCache(this,w),y||this.multiply(zr),this}assertValidity(){ie(this)}hasEvenY(){let{y:w}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(w)}equals(w){P(w);let{X:y,Y:g,Z:E}=this,{X:A,Y:C,Z:B}=w,S=n.eql(n.mul(y,B),n.mul(A,E)),D=n.eql(n.mul(g,B),n.mul(C,E));return S&&D}negate(){return new _(this.X,n.neg(this.Y),this.Z)}double(){let{a:w,b:y}=i,g=n.mul(y,zr),{X:E,Y:A,Z:C}=this,B=n.ZERO,S=n.ZERO,D=n.ZERO,O=n.mul(E,E),Y=n.mul(A,A),H=n.mul(C,C),N=n.mul(E,A);return N=n.add(N,N),D=n.mul(E,C),D=n.add(D,D),B=n.mul(w,D),S=n.mul(g,H),S=n.add(B,S),B=n.sub(Y,S),S=n.add(Y,S),S=n.mul(B,S),B=n.mul(N,B),D=n.mul(g,D),H=n.mul(w,H),N=n.sub(O,H),N=n.mul(w,N),N=n.add(N,D),D=n.add(O,O),O=n.add(D,O),O=n.add(O,H),O=n.mul(O,N),S=n.add(S,O),H=n.mul(A,C),H=n.add(H,H),O=n.mul(H,N),B=n.sub(B,O),D=n.mul(H,Y),D=n.add(D,D),D=n.add(D,D),new _(B,S,D)}add(w){P(w);let{X:y,Y:g,Z:E}=this,{X:A,Y:C,Z:B}=w,S=n.ZERO,D=n.ZERO,O=n.ZERO,Y=i.a,H=n.mul(i.b,zr),N=n.mul(y,A),V=n.mul(g,C),X=n.mul(E,B),_e=n.add(y,g),z=n.add(A,C);_e=n.mul(_e,z),z=n.add(N,V),_e=n.sub(_e,z),z=n.add(y,E);let te=n.add(A,B);return z=n.mul(z,te),te=n.add(N,X),z=n.sub(z,te),te=n.add(g,E),S=n.add(C,B),te=n.mul(te,S),S=n.add(V,X),te=n.sub(te,S),O=n.mul(Y,z),S=n.mul(H,X),O=n.add(S,O),S=n.sub(V,O),O=n.add(V,O),D=n.mul(S,O),V=n.add(N,N),V=n.add(V,N),X=n.mul(Y,X),z=n.mul(H,z),V=n.add(V,X),X=n.sub(N,X),X=n.mul(Y,X),z=n.add(z,X),N=n.mul(V,z),D=n.add(D,N),N=n.mul(te,z),S=n.mul(_e,S),S=n.sub(S,N),N=n.mul(_e,V),O=n.mul(te,O),O=n.add(O,N),new _(S,D,O)}subtract(w){return this.add(w.negate())}is0(){return this.equals(_.ZERO)}multiply(w){let{endo:y}=e;if(!o.isValidNot0(w))throw new Error("invalid scalar: out of range");let g,E,A=C=>pt.cached(this,C,B=>Do(_,B));if(y){let{k1neg:C,k1:B,k2neg:S,k2:D}=K(w),{p:O,f:Y}=A(B),{p:H,f:N}=A(D);E=Y.add(N),g=se(y.beta,O,H,C,S)}else{let{p:C,f:B}=A(w);g=C,E=B}return Do(_,[g,E])[0]}multiplyUnsafe(w){let{endo:y}=e,g=this;if(!o.isValid(w))throw new Error("invalid scalar: out of range");if(w===ot||g.is0())return _.ZERO;if(w===kt)return g;if(pt.hasCache(this))return this.multiply(w);if(y){let{k1neg:E,k1:A,k2neg:C,k2:B}=K(w),{p1:S,p2:D}=Os(_,g,A,B);return se(y.beta,S,D,E,C)}else return pt.unsafe(g,w)}toAffine(w){return k(this,w)}isTorsionFree(){let{isTorsionFree:w}=e;return s===kt?!0:w?w(_,this):pt.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:w}=e;return s===kt?this:w?w(_,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(w=!0){return nr(w,"isCompressed"),this.assertValidity(),p(_,this,w)}toHex(w=!0){return xt(this.toBytes(w))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let fr=o.BITS,pt=new qr(_,e.endo?Math.ceil(fr/2):fr);return _.BASE.precompute(8),_}function Ks(t){return Uint8Array.of(t?2:3)}function ks(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function qu(t,e={}){let{Fn:r}=t,n=e.randomBytes||Kr,o=Object.assign(ks(t.Fp,r),{seed:So(r.ORDER)});function i(p){try{let l=r.fromBytes(p);return r.isValidNot0(l)}catch{return!1}}function s(p,l){let{publicKey:m,publicKeyUncompressed:b}=o;try{let L=p.length;return l===!0&&L!==m||l===!1&&L!==b?!1:!!t.fromBytes(p)}catch{return!1}}function a(p=n(o.seed)){return Ao(M(p,o.seed,"seed"),r.ORDER)}function c(p,l=!0){return t.BASE.multiply(r.fromBytes(p)).toBytes(l)}function u(p){let{secretKey:l,publicKey:m,publicKeyUncompressed:b}=o;if(!rr(p)||"_lengths"in r&&r._lengths||l===m)return;let L=M(p,void 0,"key").length;return L===m||L===b}function f(p,l,m=!0){if(u(p)===!0)throw new Error("first arg must be private key");if(u(l)===!1)throw new Error("second arg must be public key");let b=r.fromBytes(p);return t.fromBytes(l).multiply(b).toBytes(m)}let d={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},h=_s(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:f,keygen:h,Point:t,utils:d,lengths:o})}function Ms(t,e,r={}){Nr(e),sr(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||Kr,o=r.hmac||((y,g)=>Uo(e,y,g)),{Fp:i,Fn:s}=t,{ORDER:a,BITS:c}=s,{keygen:u,getPublicKey:f,getSharedSecret:d,utils:h,lengths:p}=qu(t,r),l={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},m=a*Ns<i.ORDER;function b(y){let g=a>>kt;return y>g}function L(y,g){if(!s.isValidNot0(g))throw new Error(`invalid signature ${y}: out of range 1..Point.Fn.ORDER`);return g}function T(){if(m)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function F(y,g){To(g);let E=p.signature,A=g==="compact"?E:g==="recovered"?E+1:void 0;return M(y,A)}class P{r;s;recovery;constructor(g,E,A){if(this.r=L("r",g),this.s=L("s",E),A!=null){if(T(),![0,1,2,3].includes(A))throw new Error("invalid recovery id");this.recovery=A}Object.freeze(this)}static fromBytes(g,E=l.format){F(g,E);let A;if(E==="der"){let{r:D,s:O}=ht.toSig(M(g));return new P(D,O)}E==="recovered"&&(A=g[0],E="compact",g=g.subarray(1));let C=p.signature/2,B=g.subarray(0,C),S=g.subarray(C,C*2);return new P(s.fromBytes(B),s.fromBytes(S),A)}static fromHex(g,E){return this.fromBytes(bt(g),E)}assertRecovery(){let{recovery:g}=this;if(g==null)throw new Error("invalid recovery id: must be present");return g}addRecoveryBit(g){return new P(this.r,this.s,g)}recoverPublicKey(g){let{r:E,s:A}=this,C=this.assertRecovery(),B=C===2||C===3?E+a:E;if(!i.isValid(B))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let S=i.toBytes(B),D=t.fromBytes(Oe(Ks((C&1)===0),S)),O=s.inv(B),Y=k(M(g,void 0,"msgHash")),H=s.create(-Y*O),N=s.create(A*O),V=t.BASE.multiplyUnsafe(H).add(D.multiplyUnsafe(N));if(V.is0())throw new Error("invalid recovery: point at infinify");return V.assertValidity(),V}hasHighS(){return b(this.s)}toBytes(g=l.format){if(To(g),g==="der")return bt(ht.hexFromSig(this));let{r:E,s:A}=this,C=s.toBytes(E),B=s.toBytes(A);return g==="recovered"?(T(),Oe(Uint8Array.of(this.assertRecovery()),C,B)):Oe(C,B)}toHex(g){return xt(this.toBytes(g))}}let K=r.bits2int||function(g){if(g.length>8192)throw new Error("input is too large");let E=Nt(g),A=g.length*8-c;return A>0?E>>BigInt(A):E},k=r.bits2int_modN||function(g){return s.create(K(g))},ie=ir(c);function se(y){return fs("num < 2^"+c,y,ot,ie),s.toBytes(y)}function _(y,g){return M(y,void 0,"message"),g?M(e(y),void 0,"prehashed message"):y}function fr(y,g,E){let{lowS:A,prehash:C,extraEntropy:B}=Oo(E,l);y=_(y,C);let S=k(y),D=s.fromBytes(g);if(!s.isValidNot0(D))throw new Error("invalid private key");let O=[se(D),se(S)];if(B!=null&&B!==!1){let V=B===!0?n(p.secretKey):B;O.push(M(V,void 0,"extraEntropy"))}let Y=Oe(...O),H=S;function N(V){let X=K(V);if(!s.isValidNot0(X))return;let _e=s.inv(X),z=t.BASE.multiply(X).toAffine(),te=s.create(z.x);if(te===ot)return;let gr=s.create(_e*s.create(H+te*D));if(gr===ot)return;let zo=(z.x===te?0:2)|Number(z.y&kt),$o=gr;return A&&b(gr)&&($o=s.neg(gr),zo^=1),new P(te,$o,m?void 0:zo)}return{seed:Y,k2sig:N}}function pt(y,g,E={}){let{seed:A,k2sig:C}=fr(y,g,E);return gs(e.outputLen,s.BYTES,o)(A,C).toBytes(E.format)}function R(y,g,E,A={}){let{lowS:C,prehash:B,format:S}=Oo(A,l);if(E=M(E,void 0,"publicKey"),g=_(g,B),!rr(y)){let D=y instanceof P?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+D)}F(y,S);try{let D=P.fromBytes(y,S),O=t.fromBytes(E);if(C&&D.hasHighS())return!1;let{r:Y,s:H}=D,N=k(g),V=s.inv(H),X=s.create(N*V),_e=s.create(Y*V),z=t.BASE.multiplyUnsafe(X).add(O.multiplyUnsafe(_e));return z.is0()?!1:s.create(z.x)===Y}catch{return!1}}function w(y,g,E={}){let{prehash:A}=Oo(E,l);return g=_(g,A),P.fromBytes(y,"recovered").recoverPublicKey(g).toBytes()}return Object.freeze({keygen:u,getPublicKey:f,getSharedSecret:d,utils:h,lengths:p,Point:t,sign:pt,verify:R,recoverPublicKey:w,Signature:P,hash:e})}var No={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Vu={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Fs=BigInt(2);function zu(t){let e=No.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=t*t*t%e,f=u*u*t%e,d=be(f,r,e)*f%e,h=be(d,r,e)*f%e,p=be(h,Fs,e)*u%e,l=be(p,o,e)*p%e,m=be(l,i,e)*l%e,b=be(m,a,e)*m%e,L=be(b,c,e)*b%e,T=be(L,a,e)*m%e,F=be(T,r,e)*f%e,P=be(F,s,e)*l%e,K=be(P,n,e)*u%e,k=be(K,Fs,e);if(!Po.eql(Po.sqr(k),t))throw new Error("Cannot find square root");return k}var Po=Rt(No.p,{sqrt:zu}),$u=Rs(No,{Fp:Po,endo:Vu}),ar=Ms($u,ls);var $r=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function qs(t,e,r,n){n?.signal?.throwIfAborted();let o=Hs.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 ar.verify(e,i,t,{prehash:!1,format:"der"})}catch(s){throw new $r(String(s))}}var jr=class{type="secp256k1";raw;_key;constructor(e){this._key=zs(e),this.raw=Vs(this._key)}toMultihash(){return Ce.digest(Tt(this))}toCID(){return J.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}verify(e,r,n){return qs(this._key,r,e,n)}};function $s(t){return new jr(t)}function Vs(t){return ar.Point.fromBytes(t).toBytes()}function zs(t){try{return ar.Point.fromBytes(t),t}catch(e){throw new yr(String(e))}}function js(t){let{Type:e,Data:r}=tr.decode(t.digest),n=r??new Uint8Array;switch(e){case xe.Ed25519:return Wi(n);case xe.secp256k1:return $s(n);case xe.ECDSA:return Vi(n);default:throw new Ht}}function Tt(t){return tr.encode({Type:xe[t.type],Data:t.raw})}var Gs=Symbol.for("nodejs.util.inspect.custom"),ju=114,ur=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()})`}[en]=!0;toString(){return this.string==null&&(this.string=G.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return J.createV1(ju,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return me(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return me(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[Gs](){return`PeerId(${this.toString()})`}},Gr=class extends ur{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Yr=class extends ur{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},Wr=class extends ur{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},Gu=2336,dr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Ce.digest(de(this.url))}[Gs](){return`PeerId(${this.url})`}[en]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return J.createV1(Gu,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=j(e)),e.toString()===this.toString())}};var Yu=114,Ys=2336;function Ws(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=jt(G.decode(`z${t}`));else{if(t.startsWith("k51qzi5uqu5")||t.startsWith("kzwfwjn5ji4")||t.startsWith("k2k4r8")||t.startsWith("bafz"))return Wu(J.parse(t));if(e==null)throw new Ie('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=jt(e.decode(t))}return Zs(r)}function Zs(t){if(Xu(t))return new Gr({multihash:t});if(Zu(t))try{let e=js(t);if(e.type==="Ed25519")return new Yr({multihash:t,publicKey:e});if(e.type==="secp256k1")return new Wr({multihash:t,publicKey:e})}catch{let r=j(t.digest);return new dr(new URL(r))}throw new xr("Supplied PeerID Multihash is invalid")}function Wu(t){if(t?.multihash==null||t.version==null||t.version===1&&t.code!==Yu&&t.code!==Ys)throw new wr("Supplied PeerID CID is invalid");if(t.code===Ys){let e=j(t.multihash.digest);return new dr(new URL(e))}return Zs(t.multihash)}function Zu(t){return t.code===Ce.code}function Xu(t){return t.code===Rn.code}function Xs(t){let e=t.getComponents(),r={},n=0;if(e[n]?.name==="ip6zone"&&(r.zone=`${e[n].value}`,n++),e[n].name==="ip4"||e[n].name==="ip6"||e[n].name==="dns"||e[n].name==="dns4"||e[n].name==="dns6"?(r.type=e[n].name,r.host=e[n].value,n++):e[n].name==="dnsaddr"&&(r.type=e[n].name,r.host=`_dnsaddr.${e[n].value}`,n++),(e[n]?.name==="tcp"||e[n]?.name==="udp")&&(r.protocol=e[n].name==="tcp"?"tcp":"udp",r.port=parseInt(`${e[n].value}`),n++),e[n]?.name==="ipcidr"&&(r.type==="ip4"?r.cidr=parseInt(`${e[n].value}`):r.type==="ip6"&&(r.cidr=`${e[n].value}`),n++),r.type==null||r.host==null)throw new Ie(`Multiaddr ${t} was not an IPv4, IPv6, DNS, DNS4, DNS6 or DNSADDR address`);return e[n]?.name==="tls"&&e[n+1]?.name==="sni"&&(r.sni=e[n+1].value,n+=2),r}var Ee=le("node:net");var Js=Ft(Qs(),1),Qu=["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"],Ju=Qu.map(t=>new Js.Netmask(t));function Ro(t){for(let e of Ju)if(e.contains(t))return!0;return!1}function ed(t){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(t)}function td(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 Ro(o)}function rd(t){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)}function nd(t){let e=t.split(":"),r=e[e.length-1];return Ro(r)}function od(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 ec(t){if((0,Ee.isIPv4)(t))return Ro(t);if(ed(t))return td(t);if(rd(t))return nd(t);if((0,Ee.isIPv6)(t))return od(t)}function tc(t){try{let e=Xs(t);switch(e.type){case"ip4":case"ip6":return ec(e.host)??!1;default:return e.host==="localhost"}}catch{return!1}}var ee=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},it=class extends Error{static name="ValidationError";name="ValidationError"},Zr=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Xr=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function ko(t){return e=>j(e,t)}function Mo(t){return e=>de(e,t)}function Mt(t){return new DataView(t.buffer).getUint16(t.byteOffset).toString()}function vt(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof t=="string"?parseInt(t):t),new Uint8Array(e)}function rc(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=de(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=vt(n);return qe([r,o],r.length+o.length)}function nc(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=ut.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=vt(n);return qe([r,o],r.length+o.length)}function Fo(t){let e=t.subarray(0,t.length-2),r=t.subarray(t.length-2),n=j(e,"base32"),o=Mt(r);return`${n}:${o}`}var Ho=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},oc=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,Ee.isIPv4)(r[n]),s;i&&(s=Ho(r[n]),r[n]=j(s.subarray(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,j(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},ic=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(".")},sc=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 cc(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 Ko=Object.values(Yt).map(t=>t.decoder),id=(function(){let t=Ko[0].or(Ko[1]);return Ko.slice(2).forEach(e=>t=t.or(e)),t})();function ac(t){return id.decode(t)}function uc(t){return e=>t.encoder.encode(e)}function sd(t){if(parseInt(t).toString()!==t)throw new it("Value must be an integer")}function cd(t){if(t<0)throw new it("Value must be a positive integer, or zero")}function ad(t){return e=>{if(e>t)throw new it(`Value must be smaller than or equal to ${t}`)}}function ud(...t){return e=>{for(let r of t)r(e)}}var hr=ud(sd,cd,ad(65535));var Z=-1,qo=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 Xr(`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)}))}},st=new qo,Wd=[{code:4,name:"ip4",size:32,valueToBytes:Ho,bytesToValue:ic,validate:t=>{if(!(0,Ee.isIPv4)(t))throw new it(`Invalid IPv4 address "${t}"`)}},{code:6,name:"tcp",size:16,valueToBytes:vt,bytesToValue:Mt,validate:hr},{code:273,name:"udp",size:16,valueToBytes:vt,bytesToValue:Mt,validate:hr},{code:33,name:"dccp",size:16,valueToBytes:vt,bytesToValue:Mt,validate:hr},{code:41,name:"ip6",size:128,valueToBytes:oc,bytesToValue:sc,stringToValue:cc,validate:t=>{if(!(0,Ee.isIPv6)(t))throw new it(`Invalid IPv6 address "${t}"`)}},{code:42,name:"ip6zone",size:Z},{code:43,name:"ipcidr",size:8,bytesToValue:ko("base10"),valueToBytes:Mo("base10")},{code:53,name:"dns",size:Z},{code:54,name:"dns4",size:Z},{code:55,name:"dns6",size:Z},{code:56,name:"dnsaddr",size:Z},{code:132,name:"sctp",size:16,valueToBytes:vt,bytesToValue:Mt,validate:hr},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:Z,stringToValue:t=>decodeURIComponent(t),valueToString:t=>encodeURIComponent(t)},{code:421,name:"p2p",aliases:["ipfs"],size:Z,bytesToValue:ko("base58btc"),valueToBytes:t=>t.startsWith("Q")||t.startsWith("1")?Mo("base58btc")(t):J.parse(t).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:Fo,valueToBytes:rc},{code:445,name:"onion3",size:296,bytesToValue:Fo,valueToBytes:nc},{code:446,name:"garlic64",size:Z},{code:447,name:"garlic32",size:Z},{code:448,name:"tls"},{code:449,name:"sni",size:Z},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:Z,bytesToValue:uc(Dn),valueToBytes:ac},{code:480,name:"http"},{code:481,name:"http-path",size:Z,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:Z}];Wd.forEach(t=>{st.addProtocol(t)});function dc(t){let e=[],r=0;for(;r<t.length;){let n=Xn(t,r),o=st.getProtocol(n),i=Ve(n),s=Zd(o,t,r+i),a=0;s>0&&o.size===Z&&(a=Ve(s));let c=i+a+s,u={code:n,name:o.name,bytes:t.subarray(r,r+c)};if(s>0){let f=r+i+a,d=t.subarray(f,f+s);u.value=o.bytesToValue?.(d)??j(d)}e.push(u),r+=c}return e}function lc(t){let e=0,r=[];for(let n of t){if(n.bytes==null){let o=st.getProtocol(n.code),i=Ve(n.code),s,a=0,c=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??de(n.value),a=s.byteLength,o.size===Z&&(c=Ve(a)));let u=new Uint8Array(i+c+a),f=0;Qt(n.code,u,f),f+=i,s!=null&&(o.size===Z&&(Qt(a,u,f),f+=c),u.set(s,f)),n.bytes=u}r.push(n.bytes),e+=n.bytes.byteLength}return qe(r,e)}function hc(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 a=i===t.length-1;if(s==="/"||a){let c=st.getProtocol(o);if(r==="protocol"){if(c.size==null||c.size===0){e.push({code:c.code,name:c.name}),n="",o="",r="protocol";continue}else if(a)throw new ee(`Component ${o} was missing value`);r="value"}else if(r==="value"){let u={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new ee(`Component ${o} was missing value`);u.value=c.stringToValue?.(n)??n}e.push(u),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new ee("Incomplete multiaddr");return e}function pc(t){return`/${t.flatMap(e=>{if(e.value==null)return e.name;let r=st.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 Zd(t,e,r){return t.size==null||t.size===0?0:t.size>0?t.size/8:Xn(e,r)}var Xd=Symbol.for("nodejs.util.inspect.custom"),Vo=Symbol.for("@multiformats/multiaddr");function Qd(t){if(t==null&&(t="/"),fc(t))return t.getComponents();if(t instanceof Uint8Array)return dc(t);if(typeof t=="string")return t=t.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),t===""&&(t="/"),hc(t);if(Array.isArray(t))return t;throw new ee("Must be a string, Uint8Array, Component[], or another Multiaddr")}var Qr=class t{[Vo]=!0;#e;#t;#r;constructor(e="/",r={}){this.#e=Qd(e),r.validate!==!1&&Jd(this)}get bytes(){return this.#r==null&&(this.#r=lc(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=pc(this.#e)),this.#t}toJSON(){return this.toString()}getComponents(){return[...this.#e.map(e=>({...e}))]}encapsulate(e){let r=new t(e);return new t([...this.#e,...r.getComponents()],{validate:!1})}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Zr(`Address ${this.toString()} does not contain subaddress: ${r}`);return new t(n.slice(0,o),{validate:!1})}decapsulateCode(e){let r;for(let n=this.#e.length-1;n>-1;n--)if(this.#e[n].code===e){r=n;break}return new t(this.#e.slice(0,r),{validate:!1})}equals(e){return me(this.bytes,e.bytes)}[Xd](){return`Multiaddr(${this.toString()})`}};function Jd(t){t.getComponents().forEach(e=>{let r=st.getProtocol(e.code);e.value!=null&&r.validate?.(e.value)})}function fc(t){return!!t?.[Vo]}function gc(t){return new Qr(t)}function mc(t,e,r,n){let o=()=>{n?.log.trace("query",e),t.query({questions:[{name:e,type:"PTR"}]})};return o(),setInterval(o,r)}function yc(t,e,r,n){if(t.answers==null)return;let o,i=[];if(t.answers.forEach(s=>{switch(s.type){case"PTR":o=s;break;case"TXT":i.push(s);break;default:break}}),t.additionals.forEach(s=>{switch(s.type){case"TXT":i.push(s);break;default:break}}),!(o==null||o?.name!==r||i.length===0||o.data.startsWith(e)))try{let s=i.flatMap(c=>c.data).filter(c=>c.toString().startsWith("dnsaddr=")).map(c=>gc(c.toString().substring(8))),a=s[0].getComponents().findLast(c=>c.code===421)?.value;if(a==null)throw new Error("Multiaddr doesn't contain PeerId");return n?.log("peer found %p",a),{id:Ws(a),multiaddrs:s.map(c=>c.decapsulateCode(421))}}catch(s){n?.log.error("failed to parse mdns response",s)}}function wc(t,e,r,n,o,i,s){if(!i){s?.log("not responding to mDNS query as broadcast mode is false");return}if(n.length!==0&&t.questions[0]!=null&&t.questions[0].name===o){let a=[];a.push({name:o,type:"PTR",class:"IN",ttl:120,data:r+"."+o}),n.filter(el).forEach(c=>{let u="dnsaddr="+c.toString();if(u.length>255){s?.log("multiaddr %a is too long to use in mDNS query response",c);return}if(c.getComponents().findLast(f=>f.code===421)?.value==null){s?.log("multiaddr %a did not have a peer ID so cannot be used in mDNS query response",c);return}a.push({name:r+"."+o,type:"TXT",class:"IN",ttl:120,data:u})}),s?.log.trace("responding to query"),e.respond(a)}}function el(t){return!!tc(t)}function xc(t){let e="",r="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<t;n++)e+=r.charAt(Math.floor(Math.random()*r.length));return e}var Jr=class extends br{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??xc(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)}[Go]=this;[Symbol.toStringTag]="@libp2p/mdns";[Zo]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,bc.default)({port:this.port,ip:this.ip}),this.mdns.on("query",this._onMdnsQuery),this.mdns.on("response",this._onMdnsResponse),this.mdns.on("warning",this._onMdnsWarning),this.mdns.on("error",this._onMdnsError),this._queryInterval=mc(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),wc(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=yc(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 rl(t={}){return e=>new Jr(e,t)}return Bc(nl);})();
|
|
2
|
+
"use strict";var Libp2PMdns=(()=>{var Ec=Object.create;var mr=Object.defineProperty;var Ic=Object.getOwnPropertyDescriptor;var vc=Object.getOwnPropertyNames;var Sc=Object.getPrototypeOf,Ac=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),he=(t,e)=>{for(var r in e)mr(t,r,{get:e[r],enumerable:!0})},jo=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of vc(e))!Ac.call(t,o)&&o!==r&&mr(t,o,{get:()=>e[o],enumerable:!(n=Ic(e,o))||n.enumerable});return t};var Ft=(t,e,r)=>(r=t!=null?Ec(Sc(t)):{},jo(e||!t||!t.__esModule?mr(r,"default",{value:t,enumerable:!0}):r,t)),Bc=t=>jo(mr({},"__esModule",{value:!0}),t);var Xo=Pe(tn=>{"use strict";tn.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};tn.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 Qo=Pe(rn=>{"use strict";rn.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};rn.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 Jo=Pe(nn=>{"use strict";nn.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};nn.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 ei=Pe(on=>{"use strict";on.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};on.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 ti=Pe(sn=>{"use strict";sn.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}`};sn.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 oi=Pe((ni,cn)=>{var ri=(function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=d,t.encode=f,t.familyOf=u,t.name=void 0,t.sizeOf=c,t.v6=t.v4=void 0;let e=/^(\d{1,3}\.){3,3}\d{1,3}$/,r=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,o=16,i={name:"v4",size:r,isFormat:h=>e.test(h),encode(h,p,l){l=~~l,p=p||new Uint8Array(l+r);let m=h.length,b=0;for(let L=0;L<m;){let T=h.charCodeAt(L++);T===46?(p[l++]=b,b=0):b=b*10+(T-48)}return p[l]=b,p},decode(h,p){return p=~~p,`${h[p++]}.${h[p++]}.${h[p++]}.${h[p]}`}};t.v4=i;let s={name:"v6",size:o,isFormat:h=>h.length>0&&n.test(h),encode(h,p,l){l=~~l;let m=l+o,b=-1,L=0,T=0,F=!0,P=!1;p=p||new Uint8Array(l+o);for(let K=0;K<h.length;K++){let k=h.charCodeAt(K);k===58?(F?b!==-1?(l<m&&(p[l]=0),l<m-1&&(p[l+1]=0),l+=2):l<m&&(b=l):(P===!0?(l<m&&(p[l]=T),l++):(l<m&&(p[l]=L>>8),l<m-1&&(p[l+1]=L&255),l+=2),L=0,T=0),F=!0,P=!1):k===46?(l<m&&(p[l]=T),l++,T=0,L=0,F=!1,P=!0):(F=!1,k>=97?k-=87:k>=65?k-=55:(k-=48,T=T*10+k),L=(L<<4)+k)}if(F===!1)P===!0?(l<m&&(p[l]=T),l++):(l<m&&(p[l]=L>>8),l<m-1&&(p[l+1]=L&255),l+=2);else if(b===0)l<m&&(p[l]=0),l<m-1&&(p[l+1]=0),l+=2;else if(b!==-1){l+=2;for(let K=Math.min(l-1,m-1);K>=b+2;K--)p[K]=p[K-2];p[b]=0,p[b+1]=0,b=l}if(b!==l&&b!==-1)for(l>m-2&&(l=m-2);m>b;)p[--m]=l<m&&l>b?p[--l]:0;else for(;l<m;)p[l++]=0;return p},decode(h,p){p=~~p;let l="";for(let m=0;m<o;m+=2)m!==0&&(l+=":"),l+=(h[p+m]<<8|h[p+m+1]).toString(16);return l.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};t.v6=s;let a="ip";t.name=a;function c(h){if(i.isFormat(h))return i.size;if(s.isFormat(h))return s.size;throw Error(`Invalid ip address: ${h}`)}function u(h){return c(h)===i.size?1:2}function f(h,p,l){l=~~l;let m=c(h);return typeof p=="function"&&(p=p(l+m)),m===i.size?i.encode(h,p,l):s.encode(h,p,l)}function d(h,p,l){if(p=~~p,l=l||h.length-p,l===i.size)return i.decode(h,p,l);if(l===s.size)return s.decode(h,p,l);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 ri}):typeof cn=="object"&&typeof ni=="object"&&(cn.exports=ri)});var ci=Pe(I=>{"use strict";var v=le("buffer").Buffer,et=Xo(),Cc=Qo(),Lc=Jo(),Ir=ei(),an=ti(),ft=oi(),Dc=0,ii=32768,un=32768,Uc=~un,si=32768,Oc=~si,x=I.name={};x.encode=function(t,e,r,{mail:n=!1}={}){e||(e=v.alloc(x.encodingLength(t))),r||(r=0);let o=r,i=t.replace(/^\.|\.$/gm,"");if(i.length){let s=[];if(n){let a="";i.split(".").forEach(c=>{c.endsWith("\\")?a+=(a.length?".":"")+c.slice(0,-1):s.length===0&&a.length?s.push(a+"."+c):s.push(c)})}else s=i.split(".");for(let a=0;a<s.length;a++){let c=e.write(s[a],r+1);e[r]=c,r+=c+1}}return e[r++]=0,x.encode.bytes=r-o,e};x.encode.bytes=0;x.decode=function(t,e,{mail:r=!1}={}){e||(e=0);let n=[],o=e,i=0,s=0,a=!1;for(;;){if(e>=t.length)throw new Error("Cannot decode name (buffer overflow)");let c=t[e++];if(s+=a?0:1,c===0)break;if((c&192)===0){if(e+c>t.length)throw new Error("Cannot decode name (buffer overflow)");if(i+=c+1,i>254)throw new Error("Cannot decode name (name too long)");let u=t.toString("utf-8",e,e+c);r&&(u=u.replace(/\./g,"\\.")),n.push(u),e+=c,s+=a?0:c}else if((c&192)===192){if(e+1>t.length)throw new Error("Cannot decode name (buffer overflow)");let u=t.readUInt16BE(e-1)-49152;if(u>=o)throw new Error("Cannot decode name (bad pointer)");e=u,o=u,s+=a?0:1,a=!0}else throw new Error("Cannot decode name (bad label)")}return x.decode.bytes=s,n.length===0?".":n.join(".")};x.decode.bytes=0;x.encodingLength=function(t){return t==="."||t===".."?1:v.byteLength(t.replace(/^\.|\.$/gm,""))+2};var U={};U.encode=function(t,e,r){e||(e=v.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 v.byteLength(t)+1};var Be={};Be.encode=function(t,e,r){e||(e=Be.encodingLength(t)),r||(r=0);let n=(t.flags||0)&32767,o=t.type==="response"?ii:Dc;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};Be.encode.bytes=12;Be.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:Lc.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:Cc.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))}};Be.decode.bytes=12;Be.encodingLength=function(){return 12};var $e=I.unknown={};$e.encode=function(t,e,r){return e||(e=v.alloc($e.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.length,r),t.copy(e,r+2),$e.encode.bytes=t.length+2,e};$e.encode.bytes=0;$e.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=t.slice(e+2,e+2+r);return $e.decode.bytes=r+2,n};$e.decode.bytes=0;$e.encodingLength=function(t){return t.length+2};var je=I.ns={};je.encode=function(t,e,r){return e||(e=v.alloc(je.encodingLength(t))),r||(r=0),x.encode(t,e,r+2),e.writeUInt16BE(x.encode.bytes,r),je.encode.bytes=x.encode.bytes+2,e};je.encode.bytes=0;je.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=x.decode(t,e+2);return je.decode.bytes=r+2,n};je.decode.bytes=0;je.encodingLength=function(t){return x.encodingLength(t)+2};var Ge=I.soa={};Ge.encode=function(t,e,r){e||(e=v.alloc(Ge.encodingLength(t))),r||(r=0);let n=r;return r+=2,x.encode(t.mname,e,r),r+=x.encode.bytes,x.encode(t.rname,e,r,{mail:!0}),r+=x.encode.bytes,e.writeUInt32BE(t.serial||0,r),r+=4,e.writeUInt32BE(t.refresh||0,r),r+=4,e.writeUInt32BE(t.retry||0,r),r+=4,e.writeUInt32BE(t.expire||0,r),r+=4,e.writeUInt32BE(t.minimum||0,r),r+=4,e.writeUInt16BE(r-n-2,n),Ge.encode.bytes=r-n,e};Ge.encode.bytes=0;Ge.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=x.decode(t,e),e+=x.decode.bytes,n.rname=x.decode(t,e,{mail:!0}),e+=x.decode.bytes,n.serial=t.readUInt32BE(e),e+=4,n.refresh=t.readUInt32BE(e),e+=4,n.retry=t.readUInt32BE(e),e+=4,n.expire=t.readUInt32BE(e),e+=4,n.minimum=t.readUInt32BE(e),e+=4,Ge.decode.bytes=e-r,n};Ge.decode.bytes=0;Ge.encodingLength=function(t){return 22+x.encodingLength(t.mname)+x.encodingLength(t.rname)};var Ye=I.txt={};Ye.encode=function(t,e,r){Array.isArray(t)||(t=[t]);for(let o=0;o<t.length;o++)if(typeof t[o]=="string"&&(t[o]=v.from(t[o])),!v.isBuffer(t[o]))throw new Error("Must be a Buffer");e||(e=v.alloc(Ye.encodingLength(t))),r||(r=0);let n=r;return r+=2,t.forEach(function(o){e[r++]=o.length,o.copy(e,r,0,o.length),r+=o.length}),e.writeUInt16BE(r-n-2,n),Ye.encode.bytes=r-n,e};Ye.encode.bytes=0;Ye.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let o=[];for(;n>0;){let i=t[e++];if(--n,n<i)throw new Error("Buffer overflow");o.push(t.slice(e,e+i)),e+=i,n-=i}return Ye.decode.bytes=e-r,o};Ye.decode.bytes=0;Ye.encodingLength=function(t){Array.isArray(t)||(t=[t]);let e=2;return t.forEach(function(r){typeof r=="string"?e+=v.byteLength(r)+1:e+=r.length+1}),e};var We=I.null={};We.encode=function(t,e,r){e||(e=v.alloc(We.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=v.from(t)),t||(t=v.alloc(0));let n=r;r+=2;let o=t.length;return t.copy(e,r,0,o),r+=o,e.writeUInt16BE(r-n-2,n),We.encode.bytes=r-n,e};We.encode.bytes=0;We.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let o=t.slice(e,e+n);return e+=n,We.decode.bytes=e-r,o};We.decode.bytes=0;We.encodingLength=function(t){return t?(v.isBuffer(t)?t.length:v.byteLength(t))+2:2};var Ze=I.hinfo={};Ze.encode=function(t,e,r){e||(e=v.alloc(Ze.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),Ze.encode.bytes=r-n,e};Ze.encode.bytes=0;Ze.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,Ze.decode.bytes=e-r,n};Ze.decode.bytes=0;Ze.encodingLength=function(t){return U.encodingLength(t.cpu)+U.encodingLength(t.os)+2};var Se=I.ptr={},Tc=I.cname=Se,_c=I.dname=Se;Se.encode=function(t,e,r){return e||(e=v.alloc(Se.encodingLength(t))),r||(r=0),x.encode(t,e,r+2),e.writeUInt16BE(x.encode.bytes,r),Se.encode.bytes=x.encode.bytes+2,e};Se.encode.bytes=0;Se.decode=function(t,e){e||(e=0);let r=x.decode(t,e+2);return Se.decode.bytes=x.decode.bytes+2,r};Se.decode.bytes=0;Se.encodingLength=function(t){return x.encodingLength(t)+2};var Xe=I.srv={};Xe.encode=function(t,e,r){e||(e=v.alloc(Xe.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),Xe.encode.bytes=n+2,e};Xe.encode.bytes=0;Xe.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),Xe.decode.bytes=r+2,n};Xe.decode.bytes=0;Xe.encodingLength=function(t){return 8+x.encodingLength(t.target)};var pe=I.caa={};pe.ISSUER_CRITICAL=128;pe.encode=function(t,e,r){let n=pe.encodingLength(t);return e||(e=v.alloc(pe.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=pe.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+=v.byteLength(t.value),pe.encode.bytes=n,e};pe.encode.bytes=0;pe.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&pe.ISSUER_CRITICAL),pe.decode.bytes=r+2,o};pe.decode.bytes=0;pe.encodingLength=function(t){return U.encodingLength(t.tag)+U.encodingLength(t.value)+2};var ct=I.mx={};ct.encode=function(t,e,r){e||(e=v.alloc(ct.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),ct.encode.bytes=r-n,e};ct.encode.bytes=0;ct.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,ct.decode.bytes=e-r,n};ct.encodingLength=function(t){return 4+x.encodingLength(t.exchange)};var Qe=I.a={};Qe.encode=function(t,e,r){return e||(e=v.alloc(Qe.encodingLength(t))),r||(r=0),e.writeUInt16BE(4,r),r+=2,ft.v4.encode(t,e,r),Qe.encode.bytes=6,e};Qe.encode.bytes=0;Qe.decode=function(t,e){e||(e=0),e+=2;let r=ft.v4.decode(t,e);return Qe.decode.bytes=6,r};Qe.decode.bytes=0;Qe.encodingLength=function(){return 6};var Je=I.aaaa={};Je.encode=function(t,e,r){return e||(e=v.alloc(Je.encodingLength(t))),r||(r=0),e.writeUInt16BE(16,r),r+=2,ft.v6.encode(t,e,r),Je.encode.bytes=18,e};Je.encode.bytes=0;Je.decode=function(t,e){e||(e=0),e+=2;let r=ft.v6.decode(t,e);return Je.decode.bytes=18,r};Je.decode.bytes=0;Je.encodingLength=function(){return 18};var ue=I.option={};ue.encode=function(t,e,r){e||(e=v.alloc(ue.encodingLength(t))),r||(r=0);let n=r,o=an.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||ft.familyOf(t.ip),a=ft.encode(t.ip,v.alloc),c=Math.ceil(i/8);e.writeUInt16BE(c+4,r),r+=2,e.writeUInt16BE(s,r),r+=2,e.writeUInt8(i,r++),e.writeUInt8(t.scopePrefixLength||0,r++),a.copy(e,r,0,c),r+=c;break;case 11:t.timeout?(e.writeUInt16BE(2,r),r+=2,e.writeUInt16BE(t.timeout,r),r+=2):(e.writeUInt16BE(0,r),r+=2);break;case 12:let 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 d of t.tags)e.writeUInt16BE(d,r),r+=2;break;default:throw new Error(`Unknown roption code: ${t.code}`)}return ue.encode.bytes=r-n,e};ue.encode.bytes=0;ue.decode=function(t,e){e||(e=0);let r={};r.code=t.readUInt16BE(e),r.type=an.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=ft.decode(o);break;case 11:n>0&&(r.timeout=t.readUInt16BE(e),e+=2);break;case 14:r.tags=[];for(let i=0;i<n;i+=2)r.tags.push(t.readUInt16BE(e)),e+=2}return ue.decode.bytes=n+4,r};ue.decode.bytes=0;ue.encodingLength=function(t){if(t.data)return t.data.length+4;switch(an.toCode(t.code)){case 8:let r=t.sourcePrefixLength||0;return Math.ceil(r/8)+8;case 11:return typeof t.timeout=="number"?6:4;case 12:return t.length+4;case 14:return 4+t.tags.length*2}throw new Error(`Unknown roption code: ${t.code}`)};var ge=I.opt={};ge.encode=function(t,e,r){e||(e=v.alloc(ge.encodingLength(t))),r||(r=0);let n=r,o=St(t,ue);return e.writeUInt16BE(o,r),r=qt(t,ue,e,r+2),ge.encode.bytes=r-n,e};ge.encode.bytes=0;ge.decode=function(t,e){e||(e=0);let r=e,n=[],o=t.readUInt16BE(e);e+=2;let i=0;for(;o>0;)n[i++]=ue.decode(t,e),e+=ue.decode.bytes,o-=ue.decode.bytes;return ge.decode.bytes=e-r,n};ge.decode.bytes=0;ge.encodingLength=function(t){return 2+St(t||[],ue)};var ce=I.dnskey={};ce.PROTOCOL_DNSSEC=3;ce.ZONE_KEY=128;ce.SECURE_ENTRYPOINT=32768;ce.encode=function(t,e,r){e||(e=v.alloc(ce.encodingLength(t))),r||(r=0);let n=r,o=t.key;if(!v.isBuffer(o))throw new Error("Key must be a Buffer");return r+=2,e.writeUInt16BE(t.flags,r),r+=2,e.writeUInt8(ce.PROTOCOL_DNSSEC,r),r+=1,e.writeUInt8(t.algorithm,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,ce.encode.bytes=r-n,e.writeUInt16BE(ce.encode.bytes-2,n),e};ce.encode.bytes=0;ce.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);if(e+=2,n.flags=t.readUInt16BE(e),e+=2,t.readUInt8(e)!==ce.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=t.readUInt8(e),e+=1,n.key=t.slice(e,r+o+2),e+=n.key.length,ce.decode.bytes=e-r,n};ce.decode.bytes=0;ce.encodingLength=function(t){return 6+v.byteLength(t.key)};var Ne=I.rrsig={};Ne.encode=function(t,e,r){e||(e=v.alloc(Ne.encodingLength(t))),r||(r=0);let n=r,o=t.signature;if(!v.isBuffer(o))throw new Error("Signature must be a Buffer");return r+=2,e.writeUInt16BE(et.toType(t.typeCovered),r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.labels,r),r+=1,e.writeUInt32BE(t.originalTTL,r),r+=4,e.writeUInt32BE(t.expiration,r),r+=4,e.writeUInt32BE(t.inception,r),r+=4,e.writeUInt16BE(t.keyTag,r),r+=2,x.encode(t.signersName,e,r),r+=x.encode.bytes,o.copy(e,r,0,o.length),r+=o.length,Ne.encode.bytes=r-n,e.writeUInt16BE(Ne.encode.bytes-2,n),e};Ne.encode.bytes=0;Ne.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.typeCovered=et.toString(t.readUInt16BE(e)),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.labels=t.readUInt8(e),e+=1,n.originalTTL=t.readUInt32BE(e),e+=4,n.expiration=t.readUInt32BE(e),e+=4,n.inception=t.readUInt32BE(e),e+=4,n.keyTag=t.readUInt16BE(e),e+=2,n.signersName=x.decode(t,e),e+=x.decode.bytes,n.signature=t.slice(e,r+o+2),e+=n.signature.length,Ne.decode.bytes=e-r,n};Ne.decode.bytes=0;Ne.encodingLength=function(t){return 20+x.encodingLength(t.signersName)+v.byteLength(t.signature)};var Re=I.rp={};Re.encode=function(t,e,r){e||(e=v.alloc(Re.encodingLength(t))),r||(r=0);let n=r;return r+=2,x.encode(t.mbox||".",e,r,{mail:!0}),r+=x.encode.bytes,x.encode(t.txt||".",e,r),r+=x.encode.bytes,Re.encode.bytes=r-n,e.writeUInt16BE(Re.encode.bytes-2,n),e};Re.encode.bytes=0;Re.decode=function(t,e){e||(e=0);let r=e,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,Re.decode.bytes=e-r,n};Re.decode.bytes=0;Re.encodingLength=function(t){return 2+x.encodingLength(t.mbox||".")+x.encodingLength(t.txt||".")};var W={};W.encode=function(t,e,r){e||(e=v.alloc(W.encodingLength(t))),r||(r=0);let n=r;for(var o=[],i=0;i<t.length;i++){var s=et.toType(t[i]);o[s>>8]===void 0&&(o[s>>8]=[]),o[s>>8][s>>3&31]|=1<<7-(s&7)}for(i=0;i<o.length;i++)if(o[i]!==void 0){var a=v.from(o[i]);e.writeUInt8(i,r),r+=1,e.writeUInt8(a.length,r),r+=1,a.copy(e,r),r+=a.length}return W.encode.bytes=r-n,e};W.encode.bytes=0;W.decode=function(t,e,r){e||(e=0);let n=e;for(var o=[];e-n<r;){var i=t.readUInt8(e);e+=1;var s=t.readUInt8(e);e+=1;for(var a=0;a<s;a++)for(var c=t.readUInt8(e+a),u=0;u<8;u++)if(c&1<<7-u){var f=et.toString(i<<8|a<<3|u);o.push(f)}e+=s}return W.decode.bytes=e-n,o};W.decode.bytes=0;W.encodingLength=function(t){for(var e=[],r=0;r<t.length;r++){var n=et.toType(t[r]);e[n>>8]=Math.max(e[n>>8]||0,n&255)}var o=0;for(r=0;r<e.length;r++)e[r]!==void 0&&(o+=2+Math.ceil((e[r]+1)/8));return o};var Ke=I.nsec={};Ke.encode=function(t,e,r){e||(e=v.alloc(Ke.encodingLength(t))),r||(r=0);let n=r;return r+=2,x.encode(t.nextDomain,e,r),r+=x.encode.bytes,W.encode(t.rrtypes,e,r),r+=W.encode.bytes,Ke.encode.bytes=r-n,e.writeUInt16BE(Ke.encode.bytes-2,n),e};Ke.encode.bytes=0;Ke.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.nextDomain=x.decode(t,e),e+=x.decode.bytes,n.rrtypes=W.decode(t,e,o-(e-r)),e+=W.decode.bytes,Ke.decode.bytes=e-r,n};Ke.decode.bytes=0;Ke.encodingLength=function(t){return 2+x.encodingLength(t.nextDomain)+W.encodingLength(t.rrtypes)};var ke=I.nsec3={};ke.encode=function(t,e,r){e||(e=v.alloc(ke.encodingLength(t))),r||(r=0);let n=r,o=t.salt;if(!v.isBuffer(o))throw new Error("salt must be a Buffer");let i=t.nextDomain;if(!v.isBuffer(i))throw new Error("nextDomain must be a Buffer");return r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.flags,r),r+=1,e.writeUInt16BE(t.iterations,r),r+=2,e.writeUInt8(o.length,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,e.writeUInt8(i.length,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,W.encode(t.rrtypes,e,r),r+=W.encode.bytes,ke.encode.bytes=r-n,e.writeUInt16BE(ke.encode.bytes-2,n),e};ke.encode.bytes=0;ke.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);e+=2,n.algorithm=t.readUInt8(e),e+=1,n.flags=t.readUInt8(e),e+=1,n.iterations=t.readUInt16BE(e),e+=2;let i=t.readUInt8(e);e+=1,n.salt=t.slice(e,e+i),e+=i;let s=t.readUInt8(e);return e+=1,n.nextDomain=t.slice(e,e+s),e+=s,n.rrtypes=W.decode(t,e,o-(e-r)),e+=W.decode.bytes,ke.decode.bytes=e-r,n};ke.decode.bytes=0;ke.encodingLength=function(t){return 8+t.salt.length+t.nextDomain.length+W.encodingLength(t.rrtypes)};var Me=I.ds={};Me.encode=function(t,e,r){e||(e=v.alloc(Me.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,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.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,Me.decode.bytes=e-r,n};Me.decode.bytes=0;Me.encodingLength=function(t){return 6+v.byteLength(t.digest)};var fe=I.sshfp={};fe.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};fe.encode=function(e,r,n){r||(r=v.alloc(fe.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!==fe.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return i.copy(r,n),n+=i.byteLength,fe.encode.bytes=n-o,r.writeUInt16BE(fe.encode.bytes-2,o),r};fe.encode.bytes=0;fe.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=fe.getFingerprintLengthForHashType(o.hash);return o.fingerprint=e.slice(r,r+i).toString("hex").toUpperCase(),r+=i,fe.decode.bytes=r-n,o};fe.decode.bytes=0;fe.encodingLength=function(t){return 4+v.from(t.fingerprint,"hex").byteLength};var Fe=I.naptr={};Fe.encode=function(t,e,r){e||(e=v.alloc(Fe.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,Fe.encode.bytes=r-n,e.writeUInt16BE(Fe.encode.bytes-2,n),e};Fe.encode.bytes=0;Fe.decode=function(t,e){e||(e=0);let r=e,n={};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,Fe.decode.bytes=e-r,n};Fe.decode.bytes=0;Fe.encodingLength=function(t){return U.encodingLength(t.flags)+U.encodingLength(t.services)+U.encodingLength(t.regexp)+x.encodingLength(t.replacement)+6};var He=I.tlsa={};He.encode=function(t,e,r){e||(e=v.alloc(He.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,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={},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,He.decode.bytes=e-r,n};He.decode.bytes=0;He.encodingLength=function(t){return 5+v.byteLength(t.certificate)};var dn=I.record=function(t){switch(t.toUpperCase()){case"A":return Qe;case"PTR":return Se;case"CNAME":return Tc;case"DNAME":return _c;case"TXT":return Ye;case"NULL":return We;case"AAAA":return Je;case"SRV":return Xe;case"HINFO":return Ze;case"CAA":return pe;case"NS":return je;case"SOA":return Ge;case"MX":return ct;case"OPT":return ge;case"DNSKEY":return ce;case"RRSIG":return Ne;case"RP":return Re;case"NSEC":return Ke;case"NSEC3":return ke;case"SSHFP":return fe;case"DS":return Me;case"NAPTR":return Fe;case"TLSA":return He}return $e},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(et.toType(t.type),r),t.type.toUpperCase()==="OPT"){if(t.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(t.udpPayloadSize||4096,r+2),e.writeUInt8(t.extendedRcode||0,r+4),e.writeUInt8(t.ednsVersion||0,r+5),e.writeUInt16BE(t.flags||0,r+6),r+=8,ge.encode(t.options||[],e,r),r+=ge.encode.bytes}else{let o=Ir.toClass(t.class===void 0?"IN":t.class);t.flush&&(o|=un),e.writeUInt16BE(o,r+2),e.writeUInt32BE(t.ttl||0,r+4),r+=8;let i=dn(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=et.toString(t.readUInt16BE(e)),r.type==="OPT")r.udpPayloadSize=t.readUInt16BE(e+2),r.extendedRcode=t.readUInt8(e+4),r.ednsVersion=t.readUInt8(e+5),r.flags=t.readUInt16BE(e+6),r.flag_do=(r.flags>>15&1)===1,r.options=ge.decode(t,e+8),e+=8+ge.decode.bytes;else{let o=t.readUInt16BE(e+2);r.ttl=t.readUInt32BE(e+4),r.class=Ir.toString(o&Uc),r.flush=!!(o&un);let i=dn(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+dn(t.type).encodingLength(e)};var Ae=I.question={};Ae.encode=function(t,e,r){e||(e=v.alloc(Ae.encodingLength(t))),r||(r=0);let n=r;return x.encode(t.name,e,r),r+=x.encode.bytes,e.writeUInt16BE(et.toType(t.type),r),r+=2,e.writeUInt16BE(Ir.toClass(t.class===void 0?"IN":t.class),r),r+=2,Ae.encode.bytes=r-n,t};Ae.encode.bytes=0;Ae.decode=function(t,e){e||(e=0);let r=e,n={};return n.name=x.decode(t,e),e+=x.decode.bytes,n.type=et.toString(t.readUInt16BE(e)),e+=2,n.class=Ir.toString(t.readUInt16BE(e)),e+=2,!!(n.class&si)&&(n.class&=Oc),Ae.decode.bytes=e-r,n};Ae.decode.bytes=0;Ae.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=[]),Be.encode(t,e,r),r+=Be.encode.bytes,r=qt(t.questions,Ae,e,r),r=qt(t.answers,Q,e,r),r=qt(t.authorities,Q,e,r),r=qt(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=Be.decode(t,e);return e+=Be.decode.bytes,e=Er(n.questions,Ae,t,e),e=Er(n.answers,Q,t,e),e=Er(n.authorities,Q,t,e),e=Er(n.additionals,Q,t,e),I.decode.bytes=e-r,n};I.decode.bytes=0;I.encodingLength=function(t){return Be.encodingLength(t)+St(t.questions||[],Ae)+St(t.answers||[],Q)+St(t.authorities||[],Q)+St(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 St(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function qt(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 Er(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 di=Pe((Vl,ui)=>{"use strict";var ai=Mc;process.nextTick(kc,42);ui.exports=Pc;function Pc(t){var e=n;return r;function r(o){e(o||Rc)}function n(o){var i=[o];e=s,t(a);function s(c){i.push(c)}function a(c){var u=arguments;for(e=Nc(c)?n:f;i.length;)f(i.shift());function f(d){ai(Kc,d,u)}}}}function Nc(t){return Object.prototype.toString.call(t)==="[object Error]"}function Rc(){}function Kc(t,e){t.apply(null,e)}function kc(t){t===42&&(ai=process.nextTick)}function Mc(t,e,r){process.nextTick(function(){t(e,r)})}});var pi=Pe((zl,hi)=>{var ln=ci(),Fc=le("dgram"),Hc=di(),qc=le("events"),pn=le("os"),hn=function(){};hi.exports=function(t){t||(t={});var e=new qc.EventEmitter,r=typeof t.port=="number"?t.port:5353,n=t.type||"udp4",o=t.ip||t.host||(n==="udp4"?"224.0.0.251":null),i={address:o,port:r},s={},a=!1,c=null;if(n==="udp6"&&(!o||!t.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var u=t.socket||Fc.createSocket({type:n,reuseAddr:t.reuseAddr!==!1,toString:function(){return n}});u.on("error",function(d){d.code==="EACCES"||d.code==="EADDRINUSE"?e.emit("error",d):e.emit("warning",d)}),u.on("message",function(d,h){try{d=ln.decode(d)}catch(p){e.emit("warning",p);return}e.emit("packet",d,h),d.type==="query"&&e.emit("query",d,h),d.type==="response"&&e.emit("response",d,h)}),u.on("listening",function(){r||(r=i.port=u.address().port),t.multicast!==!1&&(e.update(),c=setInterval(e.update,5e3),u.setMulticastTTL(t.ttl||255),u.setMulticastLoopback(t.loopback!==!1))});var f=Hc(function(d){if(!r||t.bind===!1)return d(null);u.once("error",d),u.bind(r,t.bind||t.interface,function(){u.removeListener("error",d),d(null)})});return f(function(d){if(d)return e.emit("error",d);e.emit("ready")}),e.send=function(d,h,p){if(typeof h=="function")return e.send(d,null,h);p||(p=hn),h?!h.host&&!h.address&&(h.address=i.address):h=i,f(l);function l(m){if(a)return p();if(m)return p(m);var b=ln.encode(d);u.send(b,0,b.length,h.port,h.address||h.host,p)}},e.response=e.respond=function(d,h,p){Array.isArray(d)&&(d={answers:d}),d.type="response",d.flags=(d.flags||0)|ln.AUTHORITATIVE_ANSWER,e.send(d,h,p)},e.query=function(d,h,p,l){if(typeof h=="function")return e.query(d,null,null,h);if(typeof h=="object"&&h&&h.port)return e.query(d,null,h,p);if(typeof p=="function")return e.query(d,h,null,p);l||(l=hn),typeof d=="string"&&(d=[{name:d,type:h||"ANY"}]),Array.isArray(d)&&(d={type:"query",questions:d}),d.type="query",e.send(d,p,l)},e.destroy=function(d){if(d||(d=hn),a)return process.nextTick(d);a=!0,clearInterval(c);for(var h in s)try{u.dropMembership(o,h)}catch{}s={},u.close(d)},e.update=function(){for(var d=t.interface?[].concat(t.interface):zc(),h=!1,p=0;p<d.length;p++){var l=d[p];if(!s[l])try{u.addMembership(o,l),s[l]=!0,h=!0}catch(m){e.emit("warning",m)}}if(h){if(u.setMulticastInterface)try{u.setMulticastInterface(t.interface||Vc())}catch(m){e.emit("warning",m)}e.emit("networkInterface")}},e};function Vc(){for(var t=pn.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(li(i.family)&&!i.internal)return pn.platform()==="darwin"&&e[r]==="en0"?i.address:"0.0.0.0"}return"127.0.0.1"}function zc(){for(var t=pn.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(li(s.family)){r.push(s.address);break}}return r}function li(t){return t===4||t==="IPv4"}});var Qs=Pe(lr=>{(function(){var t,e,r,n,o,i,s,a;a=function(c){var u,f,d,h;return u=(c&255<<24)>>>24,f=(c&255<<16)>>>16,d=(c&65280)>>>8,h=c&255,[u,f,d,h].join(".")},s=function(c){var u,f,d,h,p,l;for(u=[],d=h=0;h<=3&&c.length!==0;d=++h){if(d>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}l=e(c),p=l[0],f=l[1],c=c.substring(f),u.push(p)}if(c.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(c){return c.charCodeAt(0)},n=r("0"),i=r("a"),o=r("A"),e=function(c){var u,f,d,h,p;for(h=0,u=10,f="9",d=0,c.length>1&&c[d]==="0"&&(c[d+1]==="x"||c[d+1]==="X"?(d+=2,u=16):"0"<=c[d+1]&&c[d+1]<="9"&&(d++,u=8,f="7")),p=d;d<c.length;){if("0"<=c[d]&&c[d]<=f)h=h*u+(r(c[d])-n)>>>0;else if(u===16)if("a"<=c[d]&&c[d]<="f")h=h*u+(10+r(c[d])-i)>>>0;else if("A"<=c[d]&&c[d]<="F")h=h*u+(10+r(c[d])-o)>>>0;else break;else break;if(h>4294967295)throw new Error("too large");d++}if(d===p)throw new Error("empty octet");return[h,d]},t=(function(){function c(u,f){var d,h,p,l;if(typeof u!="string")throw new Error("Missing `net' parameter");if(f||(l=u.split("/",2),u=l[0],f=l[1]),f||(f=32),typeof f=="string"&&f.indexOf(".")>-1){try{this.maskLong=s(f)}catch(m){throw d=m,new Error("Invalid mask: "+f)}for(h=p=32;p>=0;h=--p)if(this.maskLong===4294967295<<32-h>>>0){this.bitmask=h;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 d=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=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(u){return typeof u=="string"&&(u.indexOf("/")>0||u.split(".").length!==4)&&(u=new c(u)),u instanceof c?this.contains(u.base)&&this.contains(u.broadcast||u.last):(s(u)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(u){return u==null&&(u=1),new c(a(this.netLong+this.size*u),this.mask)},c.prototype.forEach=function(u){var f,d,h;for(h=s(this.first),d=s(this.last),f=0;h<=d;)u(a(h),h,f),f++,h++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c})(),lr.ip2long=s,lr.long2ip=a,lr.Netmask=t}).call(lr)});var nl={};he(nl,{mdns:()=>rl});var Ie=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},yr=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var wr=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},xr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var Ht=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var Go=Symbol.for("@libp2p/peer-discovery");var en=Symbol.for("@libp2p/peer-id");var Yo=le("node:events"),Wo=(t,...e)=>{try{(0,Yo.setMaxListeners)(t,...e)}catch{}};var br=class extends EventTarget{#e=new Map;constructor(){super(),Wo(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 Zo=Symbol.for("@libp2p/service-capabilities"),ll=Symbol.for("@libp2p/service-dependencies");var bc=Ft(pi(),1);var wn={};he(wn,{base58btc:()=>G,base58flickr:()=>Xc});var $l=new Uint8Array(0);function fi(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 ve(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 gi(t){return new TextEncoder().encode(t)}function mi(t){return new TextDecoder().decode(t)}function $c(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function d(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var m=0,b=0,L=0,T=l.length;L!==T&&l[L]===0;)L++,m++;for(var F=(T-L)*f+1>>>0,P=new Uint8Array(F);L!==T;){for(var K=l[L],k=0,ie=F-1;(K!==0||k<b)&&ie!==-1;ie--,k++)K+=256*P[ie]>>>0,P[ie]=K%a>>>0,K=K/a>>>0;if(K!==0)throw new Error("Non-zero carry");b=k,L++}for(var se=F-b;se!==F&&P[se]===0;)se++;for(var _=c.repeat(m);se<F;++se)_+=t.charAt(P[se]);return _}function h(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var m=0;if(l[m]!==" "){for(var b=0,L=0;l[m]===c;)b++,m++;for(var T=(l.length-m)*u+1>>>0,F=new Uint8Array(T);l[m];){var P=r[l.charCodeAt(m)];if(P===255)return;for(var K=0,k=T-1;(P!==0||K<L)&&k!==-1;k--,K++)P+=a*F[k]>>>0,F[k]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");L=K,m++}if(l[m]!==" "){for(var ie=T-L;ie!==T&&F[ie]===0;)ie++;for(var se=new Uint8Array(b+(T-ie)),_=b;ie!==T;)se[_++]=F[ie++];return se}}}function p(l){var m=h(l);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:h,decode:p}}var jc=$c,Gc=jc,wi=Gc;var fn=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")}},gn=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 xi(this,e)}},mn=class{decoders;constructor(e){this.decoders=e}or(e){return xi(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 xi(t,e){return new mn({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var yn=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 fn(e,r,n),this.decoder=new gn(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function At({name:t,prefix:e,encode:r,decode:n}){return new yn(t,e,r,n)}function at({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=wi(r,t);return At({prefix:e,name:t,encode:n,decode:i=>ve(o(i))})}function Yc(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let u=0;u<o;++u){let f=e[t[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|f,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function Wc(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],s+=8;s>r;)s-=r,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function Zc(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=Zc(n);return At({prefix:e,name:t,encode(i){return Wc(i,n,r)},decode(i){return Yc(i,o,r,t)}})}var G=at({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Xc=at({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var xn={};he(xn,{base32:()=>ut,base32hex:()=>ta,base32hexpad:()=>na,base32hexpadupper:()=>oa,base32hexupper:()=>ra,base32pad:()=>Jc,base32padupper:()=>ea,base32upper:()=>Qc,base32z:()=>ia});var ut=$({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Qc=$({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Jc=$({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ea=$({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ta=$({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ra=$({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),na=$({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),oa=$({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ia=$({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var bn={};he(bn,{base36:()=>Vt,base36upper:()=>sa});var Vt=at({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),sa=at({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ca=Ii,bi=128,aa=127,ua=~aa,da=Math.pow(2,31);function Ii(t,e,r){e=e||[],r=r||0;for(var n=r;t>=da;)e[r++]=t&255|bi,t/=128;for(;t&ua;)e[r++]=t&255|bi,t>>>=7;return e[r]=t|0,Ii.bytes=r-n+1,e}var la=En,ha=128,Ei=127;function En(t,n){var r=0,n=n||0,o=0,i=n,s,a=t.length;do{if(i>=a)throw En.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&Ei)<<o:(s&Ei)*Math.pow(2,o),o+=7}while(s>=ha);return En.bytes=i-n,r}var pa=Math.pow(2,7),fa=Math.pow(2,14),ga=Math.pow(2,21),ma=Math.pow(2,28),ya=Math.pow(2,35),wa=Math.pow(2,42),xa=Math.pow(2,49),ba=Math.pow(2,56),Ea=Math.pow(2,63),Ia=function(t){return t<pa?1:t<fa?2:t<ga?3:t<ma?4:t<ya?5:t<wa?6:t<xa?7:t<ba?8:t<Ea?9:10},va={encode:ca,decode:la,encodingLength:Ia},Sa=va,zt=Sa;function $t(t,e=0){return[zt.decode(t,e),zt.decode.bytes]}function Bt(t,e,r=0){return zt.encode(t,e,r),e}function Ct(t){return zt.encodingLength(t)}function Dt(t,e){let r=e.byteLength,n=Ct(t),o=n+Ct(r),i=new Uint8Array(o+r);return Bt(t,i,0),Bt(r,i,n),i.set(e,o),new Lt(t,r,e,i)}function jt(t){let e=ve(t),[r,n]=$t(e),[o,i]=$t(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Lt(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&&fi(t.bytes,r.bytes)}}var Lt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function Si(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return Ba(r,In(t),e??G.encoder);default:return Ca(r,In(t),e??ut.encoder)}}var Ai=new WeakMap;function In(t){let e=Ai.get(t);if(e==null){let r=new Map;return Ai.set(t,r),r}return e}var J=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!==Gt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==La)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=Dt(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 Si(this,e)}toJSON(){return{"/":Si(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??Bi(n,o,i.bytes))}else if(r[Da]===!0){let{version:n,multihash:o,code:i}=r,s=jt(o);return t.create(n,i,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==Gt)throw new Error(`Version 0 CID must use dag-pb (code: ${Gt}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Bi(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Gt,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=ve(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 Lt(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[d,h]=$t(e.subarray(r));return r+=h,d},o=n(),i=Gt;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),u=r+c,f=u-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:f,size:u}}static parse(e,r){let[n,o]=Aa(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 In(i).set(n,e),i}};function Aa(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 ut.prefix:{let r=e??ut;return[ut.prefix,r.decode(t)]}case Vt.prefix:{let r=e??Vt;return[Vt.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 Ba(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 Ca(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 Gt=112,La=18;function Bi(t,e,r){let n=Ct(t),o=n+Ct(e),i=new Uint8Array(o+r.byteLength);return Bt(t,i,0),Bt(e,i,n),i.set(r,o),i}var Da=Symbol.for("@ipld/js-cid/CID");var vn={};he(vn,{identity:()=>Ce});var Ci=0,Ua="identity",Li=ve;function Oa(t,e){if(e?.truncate!=null&&e.truncate!==t.byteLength){if(e.truncate<0||e.truncate>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e.truncate)}return Dt(Ci,Li(t))}var Ce={code:Ci,name:Ua,encode:Li,digest:Oa};function me(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 Sn=le("node:buffer");function gt(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function tt(t=0){return gt(Sn.Buffer.alloc(t))}function Le(t=0){return gt(Sn.Buffer.allocUnsafe(t))}var Di=le("node:buffer");function qe(t,e){return gt(Di.Buffer.concat(t,e))}var Oi=Symbol.for("@achingbrain/uint8arraylist");function Ui(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 Sr(t){return!!t?.[Oi]}var ye=class t{bufs;length;[Oi]=!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(Sr(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(Sr(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=Ui(this.bufs,e);return r.buf[r.index]}set(e,r){let n=Ui(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(Sr(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 qe(n,o)}subarray(e,r){let{bufs:n,length:o}=this._subList(e,r);return n.length===1?n[0]:qe(n,o)}sublist(e,r){let{bufs:n,length:o}=this._subList(e,r),i=new t;return i.length=o,i.bufs=[...n],i}_subList(e,r){if(e=e??0,r=r??this.length,e<0&&(e=this.length+e),r<0&&(r=this.length+r),e<0||r>this.length)throw new RangeError("index is out of bounds");if(e===r)return{bufs:[],length:0};if(e===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,e>=c)continue;let u=e>=a&&e<c,f=r>a&&r<=c;if(u&&f){if(e===a&&r===c){n.push(s);break}let d=e-a;n.push(s.subarray(d,d+(r-e)));break}if(u){if(e===0){n.push(s);continue}n.push(s.subarray(e-a));continue}if(f){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!Sr(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 a=s,c=this.byteLength-n.byteLength,u=n.byteLength-1,f;for(let d=r;d<=c;d+=f){f=0;for(let h=u;h>=0;h--){let p=this.get(d+h);if(n[h]!==p){f=Math.max(1,h-a[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=Le(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,e)}getInt16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(e,r,n){let o=tt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,e)}getInt32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(e,r,n){let o=tt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,e)}getBigInt64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(e,r,n){let o=tt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,e)}getUint8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(e,r){let n=Le(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,e)}getUint16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(e,r,n){let o=tt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,e)}getUint32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(e,r,n){let o=tt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,e)}getBigUint64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(e,r,n){let o=tt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,e)}getFloat32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(e,r,n){let o=tt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,e)}getFloat64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(e,r,n){let o=tt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof t)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!me(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 Ki=le("node:buffer");var An={};he(An,{base10:()=>Ta});var Ta=at({prefix:"9",name:"base10",alphabet:"0123456789"});var Bn={};he(Bn,{base16:()=>_a,base16upper:()=>Pa});var _a=$({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Pa=$({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Cn={};he(Cn,{base2:()=>Na});var Na=$({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ln={};he(Ln,{base256emoji:()=>Fa});var Ti=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}"),Ra=Ti.reduce((t,e,r)=>(t[r]=e,t),[]),Ka=Ti.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function ka(t){return t.reduce((e,r)=>(e+=Ra[r],e),"")}function Ma(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Ka[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Fa=At({prefix:"\u{1F680}",name:"base256emoji",encode:ka,decode:Ma});var Un={};he(Un,{base64:()=>Ha,base64pad:()=>qa,base64url:()=>Dn,base64urlpad:()=>Va});var Ha=$({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qa=$({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Dn=$({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Va=$({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var On={};he(On,{base8:()=>za});var za=$({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Tn={};he(Tn,{identity:()=>$a});var $a=At({prefix:"\0",name:"identity",encode:t=>mi(t),decode:t=>gi(t)});var Ch=new TextEncoder,Lh=new TextDecoder;var Kn={};he(Kn,{sha256:()=>Rn,sha512:()=>Wa});var Nn=Ft(le("crypto"),1);var Ya=20;function Pn({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new _n(t,e,r,n,o)}var _n=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,i){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Ya,this.maxDigestLength=i}digest(e,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?_i(n,this.code,r?.truncate):n.then(o=>_i(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function _i(t,e,r){if(r!=null&&r!==t.byteLength){if(r>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,r)}return Dt(e,t)}var Rn=Pn({name:"sha2-256",code:18,encode:t=>ve(Nn.default.createHash("sha256").update(t).digest())}),Wa=Pn({name:"sha2-512",code:19,encode:t=>ve(Nn.default.createHash("sha512").update(t).digest())});var Yt={...Tn,...Cn,...On,...An,...Bn,...xn,...bn,...wn,...Un,...Ln},Hh={...Kn,...vn};function Ri(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var Ni=Ri("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),kn=Ri("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Le(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Za={utf8:Ni,"utf-8":Ni,hex:Yt.base16,latin1:kn,ascii:kn,binary:kn,...Yt},Ar=Za;function de(t,e="utf8"){let r=Ar[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?gt(Ki.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var ki=le("node:buffer");function j(t,e="utf8"){let r=Ar[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?ki.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var Xa=parseInt("11111",2),Mn=parseInt("10000000",2),Qa=parseInt("01111111",2),Mi={0:Wt,1:Wt,2:Ja,3:ru,4:nu,5:tu,6:eu,16:Wt,22:Wt,48:Wt};function Fn(t,e={offset:0}){let r=t[e.offset]&Xa;if(e.offset++,Mi[r]!=null)return Mi[r](t,e);throw new Error("No decoder for tag "+r)}function Zt(t,e){let r=0;if((t[e.offset]&Mn)===Mn){let n=t[e.offset]&Qa,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 Wt(t,e){Zt(t,e);let r=[];for(;!(e.offset>=t.byteLength);){let n=Fn(t,e);if(n===null)break;r.push(n)}return r}function Ja(t,e){let r=Zt(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 eu(t,e){let r=Zt(t,e),n=e.offset+r,o=t[e.offset];e.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,c=[];for(;e.offset<n;){let u=t[e.offset];if(e.offset++,c.push(u&127),u<128){c.reverse();let f=0;for(let d=0;d<c.length;d++)f+=c[d]<<d*7;a+=`.${f}`,c=[]}}return a}function tu(t,e){return e.offset++,null}function ru(t,e){let r=Zt(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 nu(t,e){let r=Zt(t,e),n=t.subarray(e.offset,e.offset+r);return e.offset+=r,n}function ou(t){let e=t.toString(16);e.length%2===1&&(e="0"+e);let r=new ye;for(let n=0;n<e.length;n+=2)r.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return r}function Hn(t){if(t.byteLength<128)return Uint8Array.from([t.byteLength]);let e=ou(t.byteLength);return new ye(Uint8Array.from([e.byteLength|Mn]),e)}function Fi(t){let e=new ye,r=128;return(t.subarray()[0]&r)===r&&e.append(Uint8Array.from([0])),e.append(t),new ye(Uint8Array.from([2]),Hn(e),e)}function Hi(t){let e=Uint8Array.from([0]),r=new ye(e,t);return new ye(Uint8Array.from([3]),Hn(r),r)}function Br(t,e=48){let r=new ye;for(let n of t)r.append(n);return new ye(Uint8Array.from([e]),Hn(r),r)}async function qi(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 iu=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),su=Uint8Array.from([6,5,43,129,4,0,34]),cu=Uint8Array.from([6,5,43,129,4,0,35]),au={ext:!0,kty:"EC",crv:"P-256"},uu={ext:!0,kty:"EC",crv:"P-384"},du={ext:!0,kty:"EC",crv:"P-521"},qn=32,Vn=48,zn=66;function Vi(t){let e=Fn(t);return zi(e)}function zi(t){let e=t[1][1][0],r=1,n,o;if(e.byteLength===qn*2+1)return n=j(e.subarray(r,r+qn),"base64url"),o=j(e.subarray(r+qn),"base64url"),new Ot({...au,key_ops:["verify"],x:n,y:o});if(e.byteLength===Vn*2+1)return n=j(e.subarray(r,r+Vn),"base64url"),o=j(e.subarray(r+Vn),"base64url"),new Ot({...uu,key_ops:["verify"],x:n,y:o});if(e.byteLength===zn*2+1)return n=j(e.subarray(r,r+zn),"base64url"),o=j(e.subarray(r+zn),"base64url"),new Ot({...du,key_ops:["verify"],x:n,y:o});throw new Ie(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function $i(t){return Br([Fi(Uint8Array.from([1])),Br([lu(t.crv)],160),Br([Hi(new ye(Uint8Array.from([4]),de(t.x??"","base64url"),de(t.y??"","base64url")))],161)]).subarray()}function lu(t){if(t==="P-256")return iu;if(t==="P-384")return su;if(t==="P-521")return cu;throw new Ie(`Invalid curve ${t}`)}var Ot=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=$i(this.jwk)),this._raw}toMultihash(){return Ce.digest(Tt(this))}toCID(){return J.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}async verify(e,r,n){return qi(this.jwk,r,e,n)}};var Cr=Ft(le("crypto"),1);var I0=Cr.default.generateKeyPairSync,Xt=32;var hu=64;function ji(t,e,r){if(t.byteLength!==Xt)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!==hu)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=Cr.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:j(t,"base64url"),kty:"OKP"}});return Cr.default.verify(null,r instanceof Uint8Array?r:r.subarray(),n,e)}function Yi(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}var Lr=class{type="Ed25519";raw;constructor(e){this.raw=$n(e,Xt)}toMultihash(){return Ce.digest(Tt(this))}toCID(){return J.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}verify(e,r,n){n?.signal?.throwIfAborted();let o=ji(this.raw,r,e);return Yi(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function Wi(t){return t=$n(t,Xt),new Lr(t)}function $n(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new Ie(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}var fu=Math.pow(2,7),gu=Math.pow(2,14),mu=Math.pow(2,21),jn=Math.pow(2,28),Gn=Math.pow(2,35),Yn=Math.pow(2,42),Wn=Math.pow(2,49),q=128,re=127;function Ve(t){if(t<fu)return 1;if(t<gu)return 2;if(t<mu)return 3;if(t<jn)return 4;if(t<Gn)return 5;if(t<Yn)return 6;if(t<Wn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Qt(t,e,r=0){switch(Ve(t)){case 8:e[r++]=t&255|q,t/=128;case 7:e[r++]=t&255|q,t/=128;case 6:e[r++]=t&255|q,t/=128;case 5:e[r++]=t&255|q,t/=128;case 4:e[r++]=t&255|q,t>>>=7;case 3:e[r++]=t&255|q,t>>>=7;case 2:e[r++]=t&255|q,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function Zn(t,e){let r=t[e],n=0;if(n+=r&re,r<q||(r=t[e+1],n+=(r&re)<<7,r<q)||(r=t[e+2],n+=(r&re)<<14,r<q)||(r=t[e+3],n+=(r&re)<<21,r<q)||(r=t[e+4],n+=(r&re)*jn,r<q)||(r=t[e+5],n+=(r&re)*Gn,r<q)||(r=t[e+6],n+=(r&re)*Yn,r<q)||(r=t[e+7],n+=(r&re)*Wn,r<q))return n;throw new RangeError("Could not decode varint")}function yu(t,e){let r=t.get(e),n=0;if(n+=r&re,r<q||(r=t.get(e+1),n+=(r&re)<<7,r<q)||(r=t.get(e+2),n+=(r&re)<<14,r<q)||(r=t.get(e+3),n+=(r&re)<<21,r<q)||(r=t.get(e+4),n+=(r&re)*jn,r<q)||(r=t.get(e+5),n+=(r&re)*Gn,r<q)||(r=t.get(e+6),n+=(r&re)*Yn,r<q)||(r=t.get(e+7),n+=(r&re)*Wn,r<q))return n;throw new RangeError("Could not decode varint")}function Xn(t,e=0){return t instanceof Uint8Array?Zn(t,e):yu(t,e)}var Qn=new Float32Array([-0]),dt=new Uint8Array(Qn.buffer);function Zi(t,e,r){Qn[0]=t,e[r]=dt[0],e[r+1]=dt[1],e[r+2]=dt[2],e[r+3]=dt[3]}function Xi(t,e){return dt[0]=t[e],dt[1]=t[e+1],dt[2]=t[e+2],dt[3]=t[e+3],Qn[0]}var Jn=new Float64Array([-0]),ne=new Uint8Array(Jn.buffer);function Qi(t,e,r){Jn[0]=t,e[r]=ne[0],e[r+1]=ne[1],e[r+2]=ne[2],e[r+3]=ne[3],e[r+4]=ne[4],e[r+5]=ne[5],e[r+6]=ne[6],e[r+7]=ne[7]}function Ji(t,e){return ne[0]=t[e],ne[1]=t[e+1],ne[2]=t[e+2],ne[3]=t[e+3],ne[4]=t[e+4],ne[5]=t[e+5],ne[6]=t[e+6],ne[7]=t[e+7],Jn[0]}var xu=BigInt(Number.MAX_SAFE_INTEGER),bu=BigInt(Number.MIN_SAFE_INTEGER),we=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 mt;if(e<xu&&e>bu)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>es&&(o=0n,++n>es&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return mt;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):mt}},mt=new we(0,0);mt.toBigInt=function(){return 0n};mt.zzEncode=mt.zzDecode=function(){return this};mt.length=function(){return 1};var es=4294967296n;function ts(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 rs(t,e,r){if(r-e<1)return"";let o,i=[],s=0,a;for(;e<r;)a=t[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function eo(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 Dr(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var to=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 Dr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw De(this,4);return Dr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw De(this,4);let e=Xi(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw De(this,4);let e=Ji(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 rs(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 we(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=Dr(this.buf,this.pos+=4),r=Dr(this.buf,this.pos+=4);return new we(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=Zn(this.buf,this.pos);return this.pos+=Ve(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 ro(t){return new to(t instanceof Uint8Array?t:t.subarray())}function Ur(t,e,r){let n=ro(t);return e.decode(n,void 0,r)}function no(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return Le(s);o+s>e&&(n=Le(e),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var yt=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function oo(){}var so=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Eu=no();function Iu(t){return globalThis.Buffer!=null?Le(t):Eu(t)}var er=class{len;head;tail;states;constructor(){this.len=0,this.head=new yt(oo,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new yt(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new co((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(Or,10,we.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=we.fromBigInt(e);return this._push(Or,r.length(),r)}uint64Number(e){return this._push(Qt,Ve(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=we.fromBigInt(e).zzEncode();return this._push(Or,r.length(),r)}sint64Number(e){let r=we.fromNumber(e).zzEncode();return this._push(Or,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(Jt,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=we.fromBigInt(e);return this._push(Jt,4,r.lo)._push(Jt,4,r.hi)}fixed64Number(e){let r=we.fromNumber(e);return this._push(Jt,4,r.lo)._push(Jt,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(Zi,4,e)}double(e){return this._push(Qi,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(io,1,0):this.uint32(r)._push(Su,r,e)}string(e){let r=ts(e);return r!==0?this.uint32(r)._push(eo,r,e):this._push(io,1,0)}fork(){return this.states=new so(this),this.head=this.tail=new yt(oo,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new yt(oo,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=Iu(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 vu(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var co=class extends yt{next;constructor(e,r){super(vu,e,r),this.next=void 0}};function Or(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 Jt(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 Su(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(er.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(Au,e,t),this},er.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(Bu,e,t),this});function Au(t,e,r){e.set(t,r)}function Bu(t,e,r){t.length<40?eo(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(de(t),r)}function ao(){return new er}function Tr(t,e){let r=ao();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var _t;(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"})(_t||(_t={}));function _r(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function uo(t){function e(o){if(t[o.toString()]==null)throw new Error("Invalid enum value");return t[o]}let r=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return _r("enum",_t.VARINT,r,n)}function Pr(t,e){return _r("message",_t.LENGTH_DELIMITED,t,e)}var xe;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.ECDSA="ECDSA"})(xe||(xe={}));var lo;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1",t[t.ECDSA=3]="ECDSA"})(lo||(lo={}));(function(t){t.codec=()=>uo(lo)})(xe||(xe={}));var tr;(function(t){let e;t.codec=()=>(e==null&&(e=Pr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),xe.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=xe.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Tr(r,t.codec()),t.decode=(r,n)=>Ur(r,t.codec(),n)})(tr||(tr={}));var ho;(function(t){let e;t.codec=()=>(e==null&&(e=Pr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),xe.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=xe.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Tr(r,t.codec()),t.decode=(r,n)=>Ur(r,t.codec(),n)})(ho||(ho={}));function rr(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ze(t,e=""){if(!Number.isSafeInteger(t)||t<0){let r=e&&`"${e}" `;throw new Error(`${r}expected integer >= 0, got ${t}`)}}function M(t,e,r=""){let n=rr(t),o=t?.length,i=e!==void 0;if(!n||i&&o!==e){let s=r&&`"${r}" `,a=i?` of length ${e}`:"",c=n?`length=${o}`:`type=${typeof t}`;throw new Error(s+"expected Uint8Array"+a+", got "+c)}return t}function Nr(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash must wrapped by utils.createHasher");ze(t.outputLen),ze(t.blockLen)}function Pt(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 is(t,e){M(t,void 0,"digestInto() output");let r=e.outputLen;if(t.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function wt(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Rr(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ue(t,e){return t<<32-e|t>>>e}var ss=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Lu=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function xt(t){if(M(t),ss)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=Lu[t[r]];return e}var rt={_0:48,_9:57,A:65,F:70,a:97,f:102};function os(t){if(t>=rt._0&&t<=rt._9)return t-rt._0;if(t>=rt.A&&t<=rt.F)return t-(rt.A-10);if(t>=rt.a&&t<=rt.f)return t-(rt.a-10)}function bt(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=os(t.charCodeAt(i)),a=os(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function Oe(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];M(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}function cs(t,e={}){let r=(o,i)=>t(i).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function Kr(t=32){let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(t))}var as=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function us(t,e,r){return t&e^~t&r}function ds(t,e,r){return t&e^t&r^e&r}var kr=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,r,n,o){this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Rr(this.buffer)}update(e){Pt(this),M(e);let{view:r,buffer:n,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Rr(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Pt(this),is(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,wt(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let d=s;d<o;d++)r[d]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let a=Rr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<u;d++)a.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||=new this.constructor,e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=a,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},nt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Du=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),lt=new Uint32Array(64),po=class extends kr{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,r,n,o,i,s,a,c]}set(e,r,n,o,i,s,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,r){for(let d=0;d<16;d++,r+=4)lt[d]=e.getUint32(r,!1);for(let d=16;d<64;d++){let h=lt[d-15],p=lt[d-2],l=Ue(h,7)^Ue(h,18)^h>>>3,m=Ue(p,17)^Ue(p,19)^p>>>10;lt[d]=m+lt[d-7]+l+lt[d-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:u,H:f}=this;for(let d=0;d<64;d++){let h=Ue(a,6)^Ue(a,11)^Ue(a,25),p=f+h+us(a,c,u)+Du[d]+lt[d]|0,m=(Ue(n,2)^Ue(n,13)^Ue(n,22))+ds(n,o,i)|0;f=u,u=c,c=a,a=s+p|0,s=i,i=o,o=n,n=p+m|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(n,o,i,s,a,c,u,f)}roundClean(){wt(lt)}destroy(){this.set(0,0,0,0,0,0,0,0),wt(this.buffer)}},fo=class extends po{A=nt[0]|0;B=nt[1]|0;C=nt[2]|0;D=nt[3]|0;E=nt[4]|0;F=nt[5]|0;G=nt[6]|0;H=nt[7]|0;constructor(){super(32)}};var ls=cs(()=>new fo,as(1));var Hs=Ft(le("node:crypto"),1);var mo=BigInt(0),go=BigInt(1);function nr(t,e=""){if(typeof t!="boolean"){let r=e&&`"${e}" `;throw new Error(r+"expected boolean, got type="+typeof t)}return t}function hs(t){if(typeof t=="bigint"){if(!Mr(t))throw new Error("positive bigint expected, got "+t)}else ze(t);return t}function or(t){let e=hs(t).toString(16);return e.length&1?"0"+e:e}function ps(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?mo:BigInt("0x"+t)}function Nt(t){return ps(xt(t))}function yo(t){return ps(xt(Uu(M(t)).reverse()))}function Fr(t,e){ze(e),t=hs(t);let r=bt(t.toString(16).padStart(e*2,"0"));if(r.length!==e)throw new Error("number too large");return r}function wo(t,e){return Fr(t,e).reverse()}function Uu(t){return Uint8Array.from(t)}var Mr=t=>typeof t=="bigint"&&mo<=t;function Ou(t,e,r){return Mr(t)&&Mr(e)&&Mr(r)&&e<=t&&t<r}function fs(t,e,r,n){if(!Ou(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function xo(t){let e;for(e=0;t>mo;t>>=go,e+=1);return e}var ir=t=>(go<<BigInt(t))-go;function gs(t,e,r){if(ze(t,"hashLen"),ze(e,"qByteLen"),typeof r!="function")throw new Error("hmacFn must be a function");let n=b=>new Uint8Array(b),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=n(t),u=n(t),f=0,d=()=>{c.fill(1),u.fill(0),f=0},h=(...b)=>r(u,Oe(c,...b)),p=(b=o)=>{u=h(i,b),c=h(),b.length!==0&&(u=h(s,b),c=h())},l=()=>{if(f++>=a)throw new Error("drbg: tried max amount of iterations");let b=0,L=[];for(;b<e;){c=h();let T=c.slice();L.push(T),b+=c.length}return Oe(...L)};return(b,L)=>{d(),p(b);let T;for(;!(T=L(l()));)p();return d(),T}}function sr(t,e={},r={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function n(i,s,a){let c=t[i];if(a&&c===void 0)return;let u=typeof c;if(u!==s||c===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${u}`)}let o=(i,s)=>Object.entries(i).forEach(([a,c])=>n(a,c,s));o(e,!1),o(r,!0)}function bo(t){let e=new WeakMap;return(r,...n)=>{let o=e.get(r);if(o!==void 0)return o;let i=t(r,...n);return e.set(r,i),i}}var ae=BigInt(0),oe=BigInt(1),Et=BigInt(2),ws=BigInt(3),xs=BigInt(4),bs=BigInt(5),Tu=BigInt(7),Es=BigInt(8),_u=BigInt(9),Is=BigInt(16);function Te(t,e){let r=t%e;return r>=ae?r:e+r}function be(t,e,r){let n=t;for(;e-- >ae;)n*=n,n%=r;return n}function ms(t,e){if(t===ae)throw new Error("invert: expected non-zero number");if(e<=ae)throw new Error("invert: expected positive modulus, got "+e);let r=Te(t,e),n=e,o=ae,i=oe,s=oe,a=ae;for(;r!==ae;){let u=n/r,f=n%r,d=o-s*u,h=i-a*u;n=r,r=f,o=s,i=a,s=d,a=h}if(n!==oe)throw new Error("invert: does not exist");return Te(o,e)}function Io(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function vs(t,e){let r=(t.ORDER+oe)/xs,n=t.pow(e,r);return Io(t,n,e),n}function Pu(t,e){let r=(t.ORDER-bs)/Es,n=t.mul(e,Et),o=t.pow(n,r),i=t.mul(e,o),s=t.mul(t.mul(i,Et),o),a=t.mul(i,t.sub(s,t.ONE));return Io(t,a,e),a}function Nu(t){let e=Rt(t),r=Ss(t),n=r(e,e.neg(e.ONE)),o=r(e,n),i=r(e,e.neg(n)),s=(t+Tu)/Is;return(a,c)=>{let u=a.pow(c,s),f=a.mul(u,n),d=a.mul(u,o),h=a.mul(u,i),p=a.eql(a.sqr(f),c),l=a.eql(a.sqr(d),c);u=a.cmov(u,f,p),f=a.cmov(h,d,l);let m=a.eql(a.sqr(f),c),b=a.cmov(u,f,m);return Io(a,b,c),b}}function Ss(t){if(t<ws)throw new Error("sqrt is not defined for small field");let e=t-oe,r=0;for(;e%Et===ae;)e/=Et,r++;let n=Et,o=Rt(t);for(;ys(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return vs;let i=o.pow(n,e),s=(e+oe)/Et;return function(c,u){if(c.is0(u))return u;if(ys(c,u)!==1)throw new Error("Cannot find square root");let f=r,d=c.mul(c.ONE,i),h=c.pow(u,e),p=c.pow(u,s);for(;!c.eql(h,c.ONE);){if(c.is0(h))return c.ZERO;let l=1,m=c.sqr(h);for(;!c.eql(m,c.ONE);)if(l++,m=c.sqr(m),l===f)throw new Error("Cannot find square root");let b=oe<<BigInt(f-l-1),L=c.pow(d,b);f=l,d=c.sqr(L),h=c.mul(h,d),p=c.mul(p,L)}return p}}function Ru(t){return t%xs===ws?vs:t%Es===bs?Pu:t%Is===_u?Nu(t):Ss(t)}var Ku=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function vo(t){let e={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Ku.reduce((n,o)=>(n[o]="function",n),e);return sr(t,r),t}function ku(t,e,r){if(r<ae)throw new Error("invalid exponent, negatives unsupported");if(r===ae)return t.ONE;if(r===oe)return e;let n=t.ONE,o=e;for(;r>ae;)r&oe&&(n=t.mul(n,o)),o=t.sqr(o),r>>=oe;return n}function Hr(t,e,r=!1){let n=new Array(e.length).fill(r?t.ZERO:void 0),o=e.reduce((s,a,c)=>t.is0(a)?s:(n[c]=s,t.mul(s,a)),t.ONE),i=t.inv(o);return e.reduceRight((s,a,c)=>t.is0(a)?s:(n[c]=t.mul(s,n[c]),t.mul(s,a)),i),n}function ys(t,e){let r=(t.ORDER-oe)/Et,n=t.pow(e,r),o=t.eql(n,t.ONE),i=t.eql(n,t.ZERO),s=t.eql(n,t.neg(t.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function Mu(t,e){e!==void 0&&ze(e);let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var Eo=class{ORDER;BITS;BYTES;isLE;ZERO=ae;ONE=oe;_lengths;_sqrt;_mod;constructor(e,r={}){if(e<=ae)throw new Error("invalid field: expected ORDER > 0, got "+e);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:i}=Mu(e,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=i,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return Te(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof e);return ae<=e&&e<this.ORDER}is0(e){return e===ae}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&oe)===oe}neg(e){return Te(-e,this.ORDER)}eql(e,r){return e===r}sqr(e){return Te(e*e,this.ORDER)}add(e,r){return Te(e+r,this.ORDER)}sub(e,r){return Te(e-r,this.ORDER)}mul(e,r){return Te(e*r,this.ORDER)}pow(e,r){return ku(this,e,r)}div(e,r){return Te(e*ms(r,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,r){return e+r}subN(e,r){return e-r}mulN(e,r){return e*r}inv(e){return ms(e,this.ORDER)}sqrt(e){return this._sqrt||(this._sqrt=Ru(this.ORDER)),this._sqrt(this,e)}toBytes(e){return this.isLE?wo(e,this.BYTES):Fr(e,this.BYTES)}fromBytes(e,r=!1){M(e);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:a}=this;if(n){if(!n.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);let u=new Uint8Array(o);u.set(e,i?0:u.length-e.length),e=u}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let c=i?yo(e):Nt(e);if(a&&(c=Te(c,s)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(e){return Hr(this,e)}cmov(e,r,n){return n?r:e}};function Rt(t,e={}){return new Eo(t,e)}function As(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 So(t){let e=As(t);return e+Math.ceil(e/2)}function Ao(t,e,r=!1){M(t);let n=t.length,o=As(e),i=So(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?yo(t):Nt(t),a=Te(s,e-oe)+oe;return r?wo(a,o):Fr(a,o)}var Kt=BigInt(0),It=BigInt(1);function cr(t,e){let r=e.negate();return t?r:e}function Do(t,e){let r=Hr(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function Ds(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Bo(t,e){Ds(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1),o=2**t,i=ir(t),s=BigInt(t);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Bs(t,e,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,a=Number(t&o),c=t>>s;a>n&&(a-=i,c+=It);let u=e*n,f=u+Math.abs(a)-1,d=a===0,h=a<0,p=e%2!==0;return{nextN:c,offset:f,isZero:d,isNeg:h,isNegF:p,offsetF:u}}var Co=new WeakMap,Us=new WeakMap;function Lo(t){return Us.get(t)||1}function Cs(t){if(t!==Kt)throw new Error("invalid wNAF")}var qr=class{BASE;ZERO;Fn;bits;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>Kt;)r&It&&(n=n.add(o)),o=o.double(),r>>=It;return n}precomputeWindow(e,r){let{windows:n,windowSize:o}=Bo(r,this.bits),i=[],s=e,a=s;for(let c=0;c<n;c++){a=s,i.push(a);for(let u=1;u<o;u++)a=a.add(s),i.push(a);s=a.double()}return i}wNAF(e,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=Bo(e,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:u,isZero:f,isNeg:d,isNegF:h,offsetF:p}=Bs(n,a,s);n=c,f?i=i.add(cr(h,r[p])):o=o.add(cr(d,r[u]))}return Cs(n),{p:o,f:i}}wNAFUnsafe(e,r,n,o=this.ZERO){let i=Bo(e,this.bits);for(let s=0;s<i.windows&&n!==Kt;s++){let{nextN:a,offset:c,isZero:u,isNeg:f}=Bs(n,s,i);if(n=a,!u){let d=r[c];o=o.add(f?d.negate():d)}}return Cs(n),o}getPrecomputes(e,r,n){let o=Co.get(r);return o||(o=this.precomputeWindow(r,e),e!==1&&(typeof n=="function"&&(o=n(o)),Co.set(r,o))),o}cached(e,r,n){let o=Lo(e);return this.wNAF(o,this.getPrecomputes(o,e,n),r)}unsafe(e,r,n,o){let i=Lo(e);return i===1?this._unsafeLadder(e,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),r,o)}createCache(e,r){Ds(r,this.bits),Us.set(e,r),Co.delete(e)}hasCache(e){return Lo(e)!==1}};function Os(t,e,r,n){let o=e,i=t.ZERO,s=t.ZERO;for(;r>Kt||n>Kt;)r&It&&(i=i.add(o)),n&It&&(s=s.add(o)),o=o.double(),r>>=It,n>>=It;return{p1:i,p2:s}}function Ls(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return vo(e),e}else return Rt(t,{isLE:r})}function Ts(t,e,r={},n){if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(let c of["p","n","h"]){let u=e[c];if(!(typeof u=="bigint"&&u>Kt))throw new Error(`CURVE.${c} must be positive bigint`)}let o=Ls(e.p,r.Fp,n),i=Ls(e.n,r.Fn,n),a=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:i}}function _s(t,e){return function(n){let o=t(n);return{secretKey:o,publicKey:e(o)}}}var Vr=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,r){if(Nr(e),M(r,void 0,"key"),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 n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),wt(o)}update(e){return Pt(this),this.iHash.update(e),this}digestInto(e){Pt(this),M(e,this.outputLen,"output"),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||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Uo=(t,e,r)=>new Vr(t,e).update(r).digest();Uo.create=(t,e)=>new Vr(t,e);var Ps=(t,e)=>(t+(t>=0?e:-e)/Ns)/e;function Fu(t,e,r){let[[n,o],[i,s]]=e,a=Ps(s*t,r),c=Ps(-o*t,r),u=t-a*n-c*i,f=-a*o-c*s,d=u<ot,h=f<ot;d&&(u=-u),h&&(f=-f);let p=ir(Math.ceil(xo(r)/2))+kt;if(u<ot||u>=p||f<ot||f>=p)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:d,k1:u,k2neg:h,k2:f}}function To(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Oo(t,e){let r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return nr(r.lowS,"lowS"),nr(r.prehash,"prehash"),r.format!==void 0&&To(r.format),r}var _o=class extends Error{constructor(e=""){super(e)}},ht={Err:_o,_tlv:{encode:(t,e)=>{let{Err:r}=ht;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=or(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?or(o.length/2|128):"";return or(t)+i+o+e},decode(t,e){let{Err:r}=ht,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let u=e.subarray(n,n+c);if(u.length!==c)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+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=ht;if(t<ot)throw new e("integer: negative integers are not allowed");let r=or(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}=ht;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 Nt(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=ht,o=M(t,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:u,l:f}=n.decode(2,c);if(f.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(t){let{_tlv:e,_int:r}=ht,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}},ot=BigInt(0),kt=BigInt(1),Ns=BigInt(2),zr=BigInt(3),Hu=BigInt(4);function Rs(t,e={}){let r=Ts("weierstrass",t,e),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s,n:a}=i;sr(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=e;if(c&&(!n.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let u=ks(n,o);function f(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function d(R,w,y){let{x:g,y:E}=w.toAffine(),A=n.toBytes(g);if(nr(y,"isCompressed"),y){f();let C=!n.isOdd(E);return Oe(Ks(C),A)}else return Oe(Uint8Array.of(4),A,n.toBytes(E))}function h(R){M(R,void 0,"Point");let{publicKey:w,publicKeyUncompressed:y}=u,g=R.length,E=R[0],A=R.subarray(1);if(g===w&&(E===2||E===3)){let C=n.fromBytes(A);if(!n.isValid(C))throw new Error("bad point: is not on curve, wrong x");let B=m(C),S;try{S=n.sqrt(B)}catch(Y){let H=Y instanceof Error?": "+Y.message:"";throw new Error("bad point: is not on curve, sqrt error"+H)}f();let D=n.isOdd(S);return(E&1)===1!==D&&(S=n.neg(S)),{x:C,y:S}}else if(g===y&&E===4){let C=n.BYTES,B=n.fromBytes(A.subarray(0,C)),S=n.fromBytes(A.subarray(C,C*2));if(!b(B,S))throw new Error("bad point: is not on curve");return{x:B,y:S}}else throw new Error(`bad point: got length ${g}, expected compressed=${w} or uncompressed=${y}`)}let p=e.toBytes||d,l=e.fromBytes||h;function m(R){let w=n.sqr(R),y=n.mul(w,R);return n.add(n.add(y,n.mul(R,i.a)),i.b)}function b(R,w){let y=n.sqr(w),g=m(R);return n.eql(y,g)}if(!b(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let L=n.mul(n.pow(i.a,zr),Hu),T=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(L,T)))throw new Error("bad curve params: a or b");function F(R,w,y=!1){if(!n.isValid(w)||y&&n.is0(w))throw new Error(`bad point coordinate ${R}`);return w}function P(R){if(!(R instanceof _))throw new Error("Weierstrass Point expected")}function K(R){if(!c||!c.basises)throw new Error("no endo");return Fu(R,c.basises,o.ORDER)}let k=bo((R,w)=>{let{X:y,Y:g,Z:E}=R;if(n.eql(E,n.ONE))return{x:y,y:g};let A=R.is0();w==null&&(w=A?n.ONE:n.inv(E));let C=n.mul(y,w),B=n.mul(g,w),S=n.mul(E,w);if(A)return{x:n.ZERO,y:n.ZERO};if(!n.eql(S,n.ONE))throw new Error("invZ was invalid");return{x:C,y:B}}),ie=bo(R=>{if(R.is0()){if(e.allowInfinityPoint&&!n.is0(R.Y))return;throw new Error("bad point: ZERO")}let{x:w,y}=R.toAffine();if(!n.isValid(w)||!n.isValid(y))throw new Error("bad point: x or y not field elements");if(!b(w,y))throw new Error("bad point: equation left != right");if(!R.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function se(R,w,y,g,E){return y=new _(n.mul(y.X,R),y.Y,y.Z),w=cr(g,w),y=cr(E,y),w.add(y)}class _{static BASE=new _(i.Gx,i.Gy,n.ONE);static ZERO=new _(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(w,y,g){this.X=F("x",w),this.Y=F("y",y,!0),this.Z=F("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 _)throw new Error("projective point not allowed");return n.is0(y)&&n.is0(g)?_.ZERO:new _(y,g,n.ONE)}static fromBytes(w){let y=_.fromAffine(l(M(w,void 0,"point")));return y.assertValidity(),y}static fromHex(w){return _.fromBytes(bt(w))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,y=!0){return pt.createCache(this,w),y||this.multiply(zr),this}assertValidity(){ie(this)}hasEvenY(){let{y:w}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(w)}equals(w){P(w);let{X:y,Y:g,Z:E}=this,{X:A,Y:C,Z:B}=w,S=n.eql(n.mul(y,B),n.mul(A,E)),D=n.eql(n.mul(g,B),n.mul(C,E));return S&&D}negate(){return new _(this.X,n.neg(this.Y),this.Z)}double(){let{a:w,b:y}=i,g=n.mul(y,zr),{X:E,Y:A,Z:C}=this,B=n.ZERO,S=n.ZERO,D=n.ZERO,O=n.mul(E,E),Y=n.mul(A,A),H=n.mul(C,C),N=n.mul(E,A);return N=n.add(N,N),D=n.mul(E,C),D=n.add(D,D),B=n.mul(w,D),S=n.mul(g,H),S=n.add(B,S),B=n.sub(Y,S),S=n.add(Y,S),S=n.mul(B,S),B=n.mul(N,B),D=n.mul(g,D),H=n.mul(w,H),N=n.sub(O,H),N=n.mul(w,N),N=n.add(N,D),D=n.add(O,O),O=n.add(D,O),O=n.add(O,H),O=n.mul(O,N),S=n.add(S,O),H=n.mul(A,C),H=n.add(H,H),O=n.mul(H,N),B=n.sub(B,O),D=n.mul(H,Y),D=n.add(D,D),D=n.add(D,D),new _(B,S,D)}add(w){P(w);let{X:y,Y:g,Z:E}=this,{X:A,Y:C,Z:B}=w,S=n.ZERO,D=n.ZERO,O=n.ZERO,Y=i.a,H=n.mul(i.b,zr),N=n.mul(y,A),V=n.mul(g,C),X=n.mul(E,B),_e=n.add(y,g),z=n.add(A,C);_e=n.mul(_e,z),z=n.add(N,V),_e=n.sub(_e,z),z=n.add(y,E);let te=n.add(A,B);return z=n.mul(z,te),te=n.add(N,X),z=n.sub(z,te),te=n.add(g,E),S=n.add(C,B),te=n.mul(te,S),S=n.add(V,X),te=n.sub(te,S),O=n.mul(Y,z),S=n.mul(H,X),O=n.add(S,O),S=n.sub(V,O),O=n.add(V,O),D=n.mul(S,O),V=n.add(N,N),V=n.add(V,N),X=n.mul(Y,X),z=n.mul(H,z),V=n.add(V,X),X=n.sub(N,X),X=n.mul(Y,X),z=n.add(z,X),N=n.mul(V,z),D=n.add(D,N),N=n.mul(te,z),S=n.mul(_e,S),S=n.sub(S,N),N=n.mul(_e,V),O=n.mul(te,O),O=n.add(O,N),new _(S,D,O)}subtract(w){return this.add(w.negate())}is0(){return this.equals(_.ZERO)}multiply(w){let{endo:y}=e;if(!o.isValidNot0(w))throw new Error("invalid scalar: out of range");let g,E,A=C=>pt.cached(this,C,B=>Do(_,B));if(y){let{k1neg:C,k1:B,k2neg:S,k2:D}=K(w),{p:O,f:Y}=A(B),{p:H,f:N}=A(D);E=Y.add(N),g=se(y.beta,O,H,C,S)}else{let{p:C,f:B}=A(w);g=C,E=B}return Do(_,[g,E])[0]}multiplyUnsafe(w){let{endo:y}=e,g=this;if(!o.isValid(w))throw new Error("invalid scalar: out of range");if(w===ot||g.is0())return _.ZERO;if(w===kt)return g;if(pt.hasCache(this))return this.multiply(w);if(y){let{k1neg:E,k1:A,k2neg:C,k2:B}=K(w),{p1:S,p2:D}=Os(_,g,A,B);return se(y.beta,S,D,E,C)}else return pt.unsafe(g,w)}toAffine(w){return k(this,w)}isTorsionFree(){let{isTorsionFree:w}=e;return s===kt?!0:w?w(_,this):pt.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:w}=e;return s===kt?this:w?w(_,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(w=!0){return nr(w,"isCompressed"),this.assertValidity(),p(_,this,w)}toHex(w=!0){return xt(this.toBytes(w))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let fr=o.BITS,pt=new qr(_,e.endo?Math.ceil(fr/2):fr);return _.BASE.precompute(8),_}function Ks(t){return Uint8Array.of(t?2:3)}function ks(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function qu(t,e={}){let{Fn:r}=t,n=e.randomBytes||Kr,o=Object.assign(ks(t.Fp,r),{seed:So(r.ORDER)});function i(p){try{let l=r.fromBytes(p);return r.isValidNot0(l)}catch{return!1}}function s(p,l){let{publicKey:m,publicKeyUncompressed:b}=o;try{let L=p.length;return l===!0&&L!==m||l===!1&&L!==b?!1:!!t.fromBytes(p)}catch{return!1}}function a(p=n(o.seed)){return Ao(M(p,o.seed,"seed"),r.ORDER)}function c(p,l=!0){return t.BASE.multiply(r.fromBytes(p)).toBytes(l)}function u(p){let{secretKey:l,publicKey:m,publicKeyUncompressed:b}=o;if(!rr(p)||"_lengths"in r&&r._lengths||l===m)return;let L=M(p,void 0,"key").length;return L===m||L===b}function f(p,l,m=!0){if(u(p)===!0)throw new Error("first arg must be private key");if(u(l)===!1)throw new Error("second arg must be public key");let b=r.fromBytes(p);return t.fromBytes(l).multiply(b).toBytes(m)}let d={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},h=_s(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:f,keygen:h,Point:t,utils:d,lengths:o})}function Ms(t,e,r={}){Nr(e),sr(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||Kr,o=r.hmac||((y,g)=>Uo(e,y,g)),{Fp:i,Fn:s}=t,{ORDER:a,BITS:c}=s,{keygen:u,getPublicKey:f,getSharedSecret:d,utils:h,lengths:p}=qu(t,r),l={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},m=a*Ns<i.ORDER;function b(y){let g=a>>kt;return y>g}function L(y,g){if(!s.isValidNot0(g))throw new Error(`invalid signature ${y}: out of range 1..Point.Fn.ORDER`);return g}function T(){if(m)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function F(y,g){To(g);let E=p.signature,A=g==="compact"?E:g==="recovered"?E+1:void 0;return M(y,A)}class P{r;s;recovery;constructor(g,E,A){if(this.r=L("r",g),this.s=L("s",E),A!=null){if(T(),![0,1,2,3].includes(A))throw new Error("invalid recovery id");this.recovery=A}Object.freeze(this)}static fromBytes(g,E=l.format){F(g,E);let A;if(E==="der"){let{r:D,s:O}=ht.toSig(M(g));return new P(D,O)}E==="recovered"&&(A=g[0],E="compact",g=g.subarray(1));let C=p.signature/2,B=g.subarray(0,C),S=g.subarray(C,C*2);return new P(s.fromBytes(B),s.fromBytes(S),A)}static fromHex(g,E){return this.fromBytes(bt(g),E)}assertRecovery(){let{recovery:g}=this;if(g==null)throw new Error("invalid recovery id: must be present");return g}addRecoveryBit(g){return new P(this.r,this.s,g)}recoverPublicKey(g){let{r:E,s:A}=this,C=this.assertRecovery(),B=C===2||C===3?E+a:E;if(!i.isValid(B))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let S=i.toBytes(B),D=t.fromBytes(Oe(Ks((C&1)===0),S)),O=s.inv(B),Y=k(M(g,void 0,"msgHash")),H=s.create(-Y*O),N=s.create(A*O),V=t.BASE.multiplyUnsafe(H).add(D.multiplyUnsafe(N));if(V.is0())throw new Error("invalid recovery: point at infinify");return V.assertValidity(),V}hasHighS(){return b(this.s)}toBytes(g=l.format){if(To(g),g==="der")return bt(ht.hexFromSig(this));let{r:E,s:A}=this,C=s.toBytes(E),B=s.toBytes(A);return g==="recovered"?(T(),Oe(Uint8Array.of(this.assertRecovery()),C,B)):Oe(C,B)}toHex(g){return xt(this.toBytes(g))}}let K=r.bits2int||function(g){if(g.length>8192)throw new Error("input is too large");let E=Nt(g),A=g.length*8-c;return A>0?E>>BigInt(A):E},k=r.bits2int_modN||function(g){return s.create(K(g))},ie=ir(c);function se(y){return fs("num < 2^"+c,y,ot,ie),s.toBytes(y)}function _(y,g){return M(y,void 0,"message"),g?M(e(y),void 0,"prehashed message"):y}function fr(y,g,E){let{lowS:A,prehash:C,extraEntropy:B}=Oo(E,l);y=_(y,C);let S=k(y),D=s.fromBytes(g);if(!s.isValidNot0(D))throw new Error("invalid private key");let O=[se(D),se(S)];if(B!=null&&B!==!1){let V=B===!0?n(p.secretKey):B;O.push(M(V,void 0,"extraEntropy"))}let Y=Oe(...O),H=S;function N(V){let X=K(V);if(!s.isValidNot0(X))return;let _e=s.inv(X),z=t.BASE.multiply(X).toAffine(),te=s.create(z.x);if(te===ot)return;let gr=s.create(_e*s.create(H+te*D));if(gr===ot)return;let zo=(z.x===te?0:2)|Number(z.y&kt),$o=gr;return A&&b(gr)&&($o=s.neg(gr),zo^=1),new P(te,$o,m?void 0:zo)}return{seed:Y,k2sig:N}}function pt(y,g,E={}){let{seed:A,k2sig:C}=fr(y,g,E);return gs(e.outputLen,s.BYTES,o)(A,C).toBytes(E.format)}function R(y,g,E,A={}){let{lowS:C,prehash:B,format:S}=Oo(A,l);if(E=M(E,void 0,"publicKey"),g=_(g,B),!rr(y)){let D=y instanceof P?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+D)}F(y,S);try{let D=P.fromBytes(y,S),O=t.fromBytes(E);if(C&&D.hasHighS())return!1;let{r:Y,s:H}=D,N=k(g),V=s.inv(H),X=s.create(N*V),_e=s.create(Y*V),z=t.BASE.multiplyUnsafe(X).add(O.multiplyUnsafe(_e));return z.is0()?!1:s.create(z.x)===Y}catch{return!1}}function w(y,g,E={}){let{prehash:A}=Oo(E,l);return g=_(g,A),P.fromBytes(y,"recovered").recoverPublicKey(g).toBytes()}return Object.freeze({keygen:u,getPublicKey:f,getSharedSecret:d,utils:h,lengths:p,Point:t,sign:pt,verify:R,recoverPublicKey:w,Signature:P,hash:e})}var No={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Vu={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Fs=BigInt(2);function zu(t){let e=No.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=t*t*t%e,f=u*u*t%e,d=be(f,r,e)*f%e,h=be(d,r,e)*f%e,p=be(h,Fs,e)*u%e,l=be(p,o,e)*p%e,m=be(l,i,e)*l%e,b=be(m,a,e)*m%e,L=be(b,c,e)*b%e,T=be(L,a,e)*m%e,F=be(T,r,e)*f%e,P=be(F,s,e)*l%e,K=be(P,n,e)*u%e,k=be(K,Fs,e);if(!Po.eql(Po.sqr(k),t))throw new Error("Cannot find square root");return k}var Po=Rt(No.p,{sqrt:zu}),$u=Rs(No,{Fp:Po,endo:Vu}),ar=Ms($u,ls);var $r=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function qs(t,e,r,n){n?.signal?.throwIfAborted();let o=Hs.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 ar.verify(e,i,t,{prehash:!1,format:"der"})}catch(s){throw new $r(String(s))}}var jr=class{type="secp256k1";raw;_key;constructor(e){this._key=zs(e),this.raw=Vs(this._key)}toMultihash(){return Ce.digest(Tt(this))}toCID(){return J.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}verify(e,r,n){return qs(this._key,r,e,n)}};function $s(t){return new jr(t)}function Vs(t){return ar.Point.fromBytes(t).toBytes()}function zs(t){try{return ar.Point.fromBytes(t),t}catch(e){throw new yr(String(e))}}function js(t){let{Type:e,Data:r}=tr.decode(t.digest),n=r??new Uint8Array;switch(e){case xe.Ed25519:return Wi(n);case xe.secp256k1:return $s(n);case xe.ECDSA:return Vi(n);default:throw new Ht}}function Tt(t){return tr.encode({Type:xe[t.type],Data:t.raw})}var Gs=Symbol.for("nodejs.util.inspect.custom"),ju=114,ur=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()})`}[en]=!0;toString(){return this.string==null&&(this.string=G.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return J.createV1(ju,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return me(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return me(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[Gs](){return`PeerId(${this.toString()})`}},Gr=class extends ur{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Yr=class extends ur{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},Wr=class extends ur{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},Gu=2336,dr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Ce.digest(de(this.url))}[Gs](){return`PeerId(${this.url})`}[en]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return J.createV1(Gu,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=j(e)),e.toString()===this.toString())}};var Yu=114,Ys=2336;function Ws(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=jt(G.decode(`z${t}`));else{if(t.startsWith("k51qzi5uqu5")||t.startsWith("kzwfwjn5ji4")||t.startsWith("k2k4r8")||t.startsWith("bafz"))return Wu(J.parse(t));if(e==null)throw new Ie('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=jt(e.decode(t))}return Zs(r)}function Zs(t){if(Xu(t))return new Gr({multihash:t});if(Zu(t))try{let e=js(t);if(e.type==="Ed25519")return new Yr({multihash:t,publicKey:e});if(e.type==="secp256k1")return new Wr({multihash:t,publicKey:e})}catch{let r=j(t.digest);return new dr(new URL(r))}throw new xr("Supplied PeerID Multihash is invalid")}function Wu(t){if(t?.multihash==null||t.version==null||t.version===1&&t.code!==Yu&&t.code!==Ys)throw new wr("Supplied PeerID CID is invalid");if(t.code===Ys){let e=j(t.multihash.digest);return new dr(new URL(e))}return Zs(t.multihash)}function Zu(t){return t.code===Ce.code}function Xu(t){return t.code===Rn.code}function Xs(t){let e=t.getComponents(),r={},n=0;if(e[n]?.name==="ip6zone"&&(r.zone=`${e[n].value}`,n++),e[n].name==="ip4"||e[n].name==="ip6"||e[n].name==="dns"||e[n].name==="dns4"||e[n].name==="dns6"?(r.type=e[n].name,r.host=e[n].value,n++):e[n].name==="dnsaddr"&&(r.type=e[n].name,r.host=`_dnsaddr.${e[n].value}`,n++),(e[n]?.name==="tcp"||e[n]?.name==="udp")&&(r.protocol=e[n].name==="tcp"?"tcp":"udp",r.port=parseInt(`${e[n].value}`),n++),e[n]?.name==="ipcidr"&&(r.type==="ip4"?r.cidr=parseInt(`${e[n].value}`):r.type==="ip6"&&(r.cidr=`${e[n].value}`),n++),r.type==null||r.host==null)throw new Ie(`Multiaddr ${t} was not an IPv4, IPv6, DNS, DNS4, DNS6 or DNSADDR address`);return e[n]?.name==="tls"&&e[n+1]?.name==="sni"&&(r.sni=e[n+1].value,n+=2),r}var Ee=le("node:net");var Js=Ft(Qs(),1),Qu=["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"],Ju=Qu.map(t=>new Js.Netmask(t));function Ro(t){for(let e of Ju)if(e.contains(t))return!0;return!1}function ed(t){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(t)}function td(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 Ro(o)}function rd(t){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)}function nd(t){let e=t.split(":"),r=e[e.length-1];return Ro(r)}function od(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 ec(t){if((0,Ee.isIPv4)(t))return Ro(t);if(ed(t))return td(t);if(rd(t))return nd(t);if((0,Ee.isIPv6)(t))return od(t)}function tc(t){try{let e=Xs(t);switch(e.type){case"ip4":case"ip6":return ec(e.host)??!1;default:return e.host==="localhost"}}catch{return!1}}var ee=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},it=class extends Error{static name="ValidationError";name="ValidationError"},Zr=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Xr=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function ko(t){return e=>j(e,t)}function Mo(t){return e=>de(e,t)}function Mt(t){return new DataView(t.buffer).getUint16(t.byteOffset).toString()}function vt(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof t=="string"?parseInt(t):t),new Uint8Array(e)}function rc(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=de(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=vt(n);return qe([r,o],r.length+o.length)}function nc(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=ut.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=vt(n);return qe([r,o],r.length+o.length)}function Fo(t){let e=t.subarray(0,t.length-2),r=t.subarray(t.length-2),n=j(e,"base32"),o=Mt(r);return`${n}:${o}`}var Ho=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},oc=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,Ee.isIPv4)(r[n]),s;i&&(s=Ho(r[n]),r[n]=j(s.subarray(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,j(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},ic=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(".")},sc=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 cc(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 Ko=Object.values(Yt).map(t=>t.decoder),id=(function(){let t=Ko[0].or(Ko[1]);return Ko.slice(2).forEach(e=>t=t.or(e)),t})();function ac(t){return id.decode(t)}function uc(t){return e=>t.encoder.encode(e)}function sd(t){if(parseInt(t).toString()!==t)throw new it("Value must be an integer")}function cd(t){if(t<0)throw new it("Value must be a positive integer, or zero")}function ad(t){return e=>{if(e>t)throw new it(`Value must be smaller than or equal to ${t}`)}}function ud(...t){return e=>{for(let r of t)r(e)}}var hr=ud(sd,cd,ad(65535));var Z=-1,qo=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 Xr(`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)}))}},st=new qo,Wd=[{code:4,name:"ip4",size:32,valueToBytes:Ho,bytesToValue:ic,validate:t=>{if(!(0,Ee.isIPv4)(t))throw new it(`Invalid IPv4 address "${t}"`)}},{code:6,name:"tcp",size:16,valueToBytes:vt,bytesToValue:Mt,validate:hr},{code:273,name:"udp",size:16,valueToBytes:vt,bytesToValue:Mt,validate:hr},{code:33,name:"dccp",size:16,valueToBytes:vt,bytesToValue:Mt,validate:hr},{code:41,name:"ip6",size:128,valueToBytes:oc,bytesToValue:sc,stringToValue:cc,validate:t=>{if(!(0,Ee.isIPv6)(t))throw new it(`Invalid IPv6 address "${t}"`)}},{code:42,name:"ip6zone",size:Z},{code:43,name:"ipcidr",size:8,bytesToValue:ko("base10"),valueToBytes:Mo("base10")},{code:53,name:"dns",size:Z},{code:54,name:"dns4",size:Z},{code:55,name:"dns6",size:Z},{code:56,name:"dnsaddr",size:Z},{code:132,name:"sctp",size:16,valueToBytes:vt,bytesToValue:Mt,validate:hr},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:Z,stringToValue:t=>decodeURIComponent(t),valueToString:t=>encodeURIComponent(t)},{code:421,name:"p2p",aliases:["ipfs"],size:Z,bytesToValue:ko("base58btc"),valueToBytes:t=>t.startsWith("Q")||t.startsWith("1")?Mo("base58btc")(t):J.parse(t).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:Fo,valueToBytes:rc},{code:445,name:"onion3",size:296,bytesToValue:Fo,valueToBytes:nc},{code:446,name:"garlic64",size:Z},{code:447,name:"garlic32",size:Z},{code:448,name:"tls"},{code:449,name:"sni",size:Z},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:Z,bytesToValue:uc(Dn),valueToBytes:ac},{code:480,name:"http"},{code:481,name:"http-path",size:Z,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:Z}];Wd.forEach(t=>{st.addProtocol(t)});function dc(t){let e=[],r=0;for(;r<t.length;){let n=Xn(t,r),o=st.getProtocol(n),i=Ve(n),s=Zd(o,t,r+i),a=0;s>0&&o.size===Z&&(a=Ve(s));let c=i+a+s,u={code:n,name:o.name,bytes:t.subarray(r,r+c)};if(s>0){let f=r+i+a,d=t.subarray(f,f+s);u.value=o.bytesToValue?.(d)??j(d)}e.push(u),r+=c}return e}function lc(t){let e=0,r=[];for(let n of t){if(n.bytes==null){let o=st.getProtocol(n.code),i=Ve(n.code),s,a=0,c=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??de(n.value),a=s.byteLength,o.size===Z&&(c=Ve(a)));let u=new Uint8Array(i+c+a),f=0;Qt(n.code,u,f),f+=i,s!=null&&(o.size===Z&&(Qt(a,u,f),f+=c),u.set(s,f)),n.bytes=u}r.push(n.bytes),e+=n.bytes.byteLength}return qe(r,e)}function hc(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 a=i===t.length-1;if(s==="/"||a){let c=st.getProtocol(o);if(r==="protocol"){if(c.size==null||c.size===0){e.push({code:c.code,name:c.name}),n="",o="",r="protocol";continue}else if(a)throw new ee(`Component ${o} was missing value`);r="value"}else if(r==="value"){let u={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new ee(`Component ${o} was missing value`);u.value=c.stringToValue?.(n)??n}e.push(u),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new ee("Incomplete multiaddr");return e}function pc(t){return`/${t.flatMap(e=>{if(e.value==null)return e.name;let r=st.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 Zd(t,e,r){return t.size==null||t.size===0?0:t.size>0?t.size/8:Xn(e,r)}var Xd=Symbol.for("nodejs.util.inspect.custom"),Vo=Symbol.for("@multiformats/multiaddr");function Qd(t){if(t==null&&(t="/"),fc(t))return t.getComponents();if(t instanceof Uint8Array)return dc(t);if(typeof t=="string")return t=t.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),t===""&&(t="/"),hc(t);if(Array.isArray(t))return t;throw new ee("Must be a string, Uint8Array, Component[], or another Multiaddr")}var Qr=class t{[Vo]=!0;#e;#t;#r;constructor(e="/",r={}){this.#e=Qd(e),r.validate!==!1&&Jd(this)}get bytes(){return this.#r==null&&(this.#r=lc(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=pc(this.#e)),this.#t}toJSON(){return this.toString()}getComponents(){return[...this.#e.map(e=>({...e}))]}encapsulate(e){let r=new t(e);return new t([...this.#e,...r.getComponents()],{validate:!1})}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Zr(`Address ${this.toString()} does not contain subaddress: ${r}`);return new t(n.slice(0,o),{validate:!1})}decapsulateCode(e){let r;for(let n=this.#e.length-1;n>-1;n--)if(this.#e[n].code===e){r=n;break}return new t(this.#e.slice(0,r),{validate:!1})}equals(e){return me(this.bytes,e.bytes)}[Xd](){return`Multiaddr(${this.toString()})`}};function Jd(t){t.getComponents().forEach(e=>{let r=st.getProtocol(e.code);e.value!=null&&r.validate?.(e.value)})}function fc(t){return!!t?.[Vo]}function gc(t){return new Qr(t)}function mc(t,e,r,n){let o=()=>{n?.log.trace("query",e),t.query({questions:[{name:e,type:"PTR"}]})};return o(),setInterval(o,r)}function yc(t,e,r,n){if(t.answers==null)return;let o,i=[];if(t.answers.forEach(s=>{switch(s.type){case"PTR":o=s;break;case"TXT":i.push(s);break;default:break}}),t.additionals.forEach(s=>{switch(s.type){case"TXT":i.push(s);break;default:break}}),!(o==null||o?.name!==r||i.length===0||o.data.startsWith(e)))try{let s=i.flatMap(c=>c.data).filter(c=>c.toString().startsWith("dnsaddr=")).map(c=>gc(c.toString().substring(8))),a=s[0].getComponents().findLast(c=>c.code===421)?.value;if(a==null)throw new Error("Multiaddr doesn't contain PeerId");return n?.log("peer found %p",a),{id:Ws(a),multiaddrs:s.map(c=>c.decapsulateCode(421))}}catch(s){n?.log.error("failed to parse mdns response - %e",s)}}function wc(t,e,r,n,o,i,s){if(!i){s?.log("not responding to mDNS query as broadcast mode is false");return}if(n.length!==0&&t.questions[0]!=null&&t.questions[0].name===o){let a=[];a.push({name:o,type:"PTR",class:"IN",ttl:120,data:r+"."+o}),n.filter(el).forEach(c=>{let u="dnsaddr="+c.toString();if(u.length>255){s?.log("multiaddr %a is too long to use in mDNS query response",c);return}if(c.getComponents().findLast(f=>f.code===421)?.value==null){s?.log("multiaddr %a did not have a peer ID so cannot be used in mDNS query response",c);return}a.push({name:r+"."+o,type:"TXT",class:"IN",ttl:120,data:u})}),s?.log.trace("responding to query"),e.respond(a)}}function el(t){return!!tc(t)}function xc(t){let e="",r="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<t;n++)e+=r.charAt(Math.floor(Math.random()*r.length));return e}var Jr=class extends br{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??xc(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)}[Go]=this;[Symbol.toStringTag]="@libp2p/mdns";[Zo]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,bc.default)({port:this.port,ip:this.ip}),this.mdns.on("query",this._onMdnsQuery),this.mdns.on("response",this._onMdnsResponse),this.mdns.on("warning",this._onMdnsWarning),this.mdns.on("error",this._onMdnsError),this._queryInterval=mc(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),wc(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=yc(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 - %e",r)}}_onMdnsWarning(e){this.log.error("mdns warning - %e",e)}_onMdnsError(e){this.log.error("mdns error - %e",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 rl(t={}){return e=>new Jr(e,t)}return Bc(nl);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/hashes/utils.js:
|